I am trying to import a Blender object into ThreeJS using this:
loader.load(`model.glb`, function(gltf){
scene.add(gltf.scene);
gltf.scene.position.set(0, 0, 0);
});
In blender I have merged multiple meshes together to form 1 Object. What i want to do is, whenever the object is clicked, I want to simply flip it over using this code:
function onMouseClick(event) {
mouse.x = (event.clientX / sizes.width) * 2 - 1;
mouse.y = -(event.clientY / sizes.height) * 2 + 1;
raycaster.setFromCamera(mouse, camera);
const intersects = raycaster.intersectObjects(scene.children, true);
if (intersects.length > 0) {
const mesh = intersects[0].object;
const tl = gsap.timeline({ defaults: { duration: 1 } });
tl.fromTo(mesh.rotation, { z: 0 }, { z: (Math.PI) });
}
else{
return;
}
}
}
However it seems like somewhere underwater this merged object from blender is still seen as 2 different objects. Since only a part of the object flips over when clicked.
If i import the exported glb model into blender it is again seen as 1 object…
Any tips or thoughts on this?