I am looking to only show the selected value (in this case, the 3D model) from a dropdown menu. The chosen option should be the only one visible in the camera view. I am encountering some difficulty with the following code segment:
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);
})
}
The 'prefabcontainer' is simply a basic JavaScript script:
let prefabcontainer = [
'shotgun.gltf',
'pistol.gltf'];
export{prefabcontainer};
Here is the HTML snippet involved:
<div><select id="selectPrefab">
Your assistance on this matter is greatly appreciated, thank you!