Raycast to select Points in pointcloud - returns all points - intersectObjects

While attempting to do a selection of a single point by clicking in a point cloud(~20000 pts) loaded using XYZLoader, the intersectObject(pointCloud) returns all the points in the point cloud, even when I’m clicking outside of the point cloud.
Tried
geometry.boundingBox=null after load, doesnt work.
geometry.computeBoundingSphere(), doesnt work.

I had seen previous issues where most of them had to do with single point selection or points aligned in a line, but this one seems to be different from those.
I’m doing the basic raycasting from docs.

function onClick( event ) {

// calculate mouse position in normalized device coordinates
// (-1 to +1) for both components

mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
raycaster.setFromCamera( mouse, camera );


var intersects = raycaster.intersectObject( scene.children[0] );

for(var i = 0; i < intersects.length; i++){

		intersects[ i ].object.material.color.set( 0xff0000 );
}

}

this might be related to the raycasters point threshold and your models size

raycaster.params.Points.threshold = 0.1
1 Like

yes I just figured that out. Thanks anyway!

can you tell us a bit more about your solution? @mikejernil

This was probably just about adjusting your raycaster params. Nevermind.