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!