Hello there !
I have a problem : raycaster.intersecObjects returns an empty array …
However, I followed a tutorial with the same code and I can’t get a table with the objects detected by the ray…
Here is my function:
function onclick(e){
let mouse = new THREE.Vector2(
(e.clientX / window.innerWidth)*2-1,
-(e.clientY / window.innerHeight)-2+1
);
raycaster.setFromCamera(mouse, camera);
const intersects = raycaster.intersectObjects(scene.children);
for(var i=0; i<intersects.length; i++) {
intersects[i].object.material.transparent = true;
intersects[i].object.materialopacity = 0.5;
}
console.log(intersects);
The console.log returns “Array[] length:0” …
I specify that “scene” is a global variable and console.log(scene.children) gives all the meshes in the scene.
Can you help a beginner ?