IntersectObjects returns an empty array

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 ?

Can you upload to codepen or codesandbox to test it?

There is :slight_smile:

I don’t know if I used codesandbox well ! It doesn’t work at all in Codesandbox !!! I have a result in VS Studio.

Always error
image

I haven’t this error in VS Studio Code … :expressionless:
I forgot to upload texture files … But I don’t know how to make it work in CodeSandBox without error …
In Visual Studio Code it works but I can’t click in a mesh with Raytracer …
Thanks for Help !