I am currently able to detect my glb objects with a Raycaster using intersectObjects. However, only if they are directly in front of the camera:
const tempV = new THREE.Vector3();
const raycaster = new THREE.Raycaster();
tempV.project(camera);
raycaster.setFromCamera(tempV, camera);
intersectedObjects = raycaster.intersectObjects(scene.children);
for (let i = 0; i < intersectedObjects.length; i++){
if (intersectedObjects[i].object.name == "Cube") {
intersectedObjects[i].object.material.color.set(0x000000);
}
}
I would like to have labels above a few glb objects (using css2drenderer), but have them disappear if the glb is not visible to the camera.
I almost need a Raycast for the entire screen to detect if it is visible or if the glb is behind another glb - is this possible?
Thank you in advance.