I managed to load and display correctly one model in the scene. But I would like to know if there is a way to change the models in the scene when the user chooses another option in the HTML select element.
I tried everything, I searched the web, but didn’t find any solution to this specific problem.
const gltfloader = new GLTFLoader();
let root
function load(path) {
gltfloader.load( path , (gltf) => {
// remove last model
if(root && root.parent) root.parent.remove(root)
// Add new model
root = gltf.scene;
scene.add(root);
});
}
Depending on how many models the user can select, it is also recommended to traverse through the previous model and dispose all geometries, materials and textures. More information about this topic in the following guide:
When you typed “const root” on the second line, was it missing something? I guess that maybe something has to come after “const root”, and maybe this is why I’m having some trouble.
Try to change the const to let. Or you are trying to call the load function before its initialized. But to be sure, it would be nice if you could show some code or your whole html file
hello guys i hope some one help me to solve that problem i have brfv4 beyond reality face v4 and i want to make try on glasses by useing this method threejs 3d modules exactelly like glasses products in the store and make avialible customer to try any glasses type what i want to know is how controle 3d modules threejs from html home “index.html” when the customer select pictur he can try on the module 3d threejs
Sorry, you have to provide a bit more information. Best would be a live example or code and error
“load is not defined” could refer to that the load(...) function is not defined. Or the gltfLoader.load(...) function is not defined.