Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

224
Views
Threejs and dropdowns: How to display only selected model?

I'd like to display only selected value (in this case the 3d model) from dropdown option. Only selected one should be visible to the camera. Here is the code part that i'm stuck with:

                    const loader = new GLTFLoader().setPath('models/gltf/modeldatabase/');
                for (let i = 0; i < prefabcontainer.length; i++) {

                    let prefabResource = prefabcontainer[i];

                    loader.load(prefabResource, function (gltf) {

                        object = gltf.scene;
                        object.scale.set(5, 5, 5);
                        
                        var select = document.getElementById("selectPrefab");
                        prefabResource = prefabResource.replace(/\..+$/, '');
                        var prefabElement = document.createElement("option");
                        prefabElement.textContent = prefabResource;
                        prefabElement.value = prefabResource;
                        select.appendChild(prefabElement);
                        scene.add(object);
                        render();

                    }, undefined, function (error) {
                        console.error(error);
                    })

            }

Prefabcontainer is just a simple js script:

let prefabcontainer = [
'shotgun.gltf',
'pistol.gltf'];

export{prefabcontainer};

And here is the html part:

<div><select id="selectPrefab">

I appreciate your help, thank you!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!