# IntersectObjects returns an empty array

**URL:** <https://discourse.threejs.org/t/intersectobjects-returns-an-empty-array/34084>\
**Category:** Questions\
**Tags:** intersectobjects, raycaster\
**Created:** [January 25, 2022, 4:38pm UTC](https://discourse.threejs.org/t/intersectobjects-returns-an-empty-array/34084 "2022-01-25T16:38:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Morthaag](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Morthaag](https://discourse.threejs.org/u/Morthaag)\
**Post date:** [January 25, 2022, 4:38pm UTC](https://discourse.threejs.org/t/intersectobjects-returns-an-empty-array/34084/1 "2022-01-25T16:38:25Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![Chaser\_Code](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/chaser_code/32/20199_2.png) [@Chaser\_Code](https://discourse.threejs.org/u/Chaser_Code)\
**Post date:** [January 25, 2022, 5:26pm UTC](https://discourse.threejs.org/t/intersectobjects-returns-an-empty-array/34084/2 "2022-01-25T17:26:30Z")

</div>

Can you upload to codepen or codesandbox to test it?

---

<div class="post-metadata">

**Author:** ![Morthaag](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Morthaag](https://discourse.threejs.org/u/Morthaag)\
**Post date:** [January 25, 2022, 5:54pm UTC](https://discourse.threejs.org/t/intersectobjects-returns-an-empty-array/34084/3 "2022-01-25T17:54:08Z")

</div>

There is 🙂

> **[epic-hooks-19005 - CodeSandbox](https://codesandbox.io/s/epic-hooks-19005?file=%2Findex.html)**
>
> epic-hooks-19005 by denisdupuis.dd using parcel-bundler

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

---

<div class="post-metadata">

**Author:** ![Chaser\_Code](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/chaser_code/32/20199_2.png) [@Chaser\_Code](https://discourse.threejs.org/u/Chaser_Code)\
**Post date:** [January 25, 2022, 6:12pm UTC](https://discourse.threejs.org/t/intersectobjects-returns-an-empty-array/34084/4 "2022-01-25T18:12:27Z")

</div>

Always error  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/9/0/90973d6d3406202b38c28f8d438fbaae3c920218.png)

---

<div class="post-metadata">

**Author:** ![Morthaag](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Morthaag](https://discourse.threejs.org/u/Morthaag)\
**Post date:** [January 25, 2022, 6:43pm UTC](https://discourse.threejs.org/t/intersectobjects-returns-an-empty-array/34084/5 "2022-01-25T18:43:11Z")

</div>

I haven’t this error in VS Studio Code … 😑  
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 !
