0
votes

I am using this code to get intersects and I'm getting the correct objects but the userData:{} is empty.

var intersects = this.raycaster.intersectObjects(this.scene.children[8].children, true);

userData has 2 properties and they are not getting moved to intersects variable instead the userData under intersects is empty. Can someone help please?

2

2 Answers

2
votes

userData or other Object3D properties are not available in the array of intersections. However, you can retrieve the 3D object from an intersection object like so:

if ( intersects.length > 0 ) console.log( intersects[ 0 ].object.userData );

This will log the userData property for the first intersection.

0
votes

I have figured it out, when I was assigning the parameters to userData, I was doing it to the group object rather than the mesh.