Hello I am a threejs beginner and am trying to change gltf model path onclick so the different model load when you click it. My solution was to set the path to variable and changing it but it did not work.
const modelLoader = “”/models/c2.glb""
loader.load(modelLoader, (gltf) => {…}
const intersects = raycaster.intersectObjects(scene.children, true);
if (intersects.length > 0) {
if (modelLoader === "/models/c1.glb") {
modelLoader === "/models/c2.glb";
} else if (modelLoader === "/models/c2.glb") {
scene.remove(model);
modelLoader === "/models/c2.glb";
} else if (modelLoader === "/models/c3.glb") {
modelLoader === "/models/c1.glb";
}
Is there any way to achieve this?
Thank you !