Still can't get raycaster to work on non page-filling canvas with large coordinates

I am trying to get raycaster to work for my pointcloud using OrbitControls and a PerspectiveCamera. I am loading data from a pcd file (generated in open3d in python). The coordinates are light years, and very large (esp x and z are in the 1000’s).
The canvas only uses part of the page, but I think I managed to at least get the mouse coordinates correctly now by using renderer.getContext().canvas.getBoundingClientRect() to get the bounds of the canvas. When I hover with my mouse I do get mouse coordinates between -1 to 1 for both x and y. But if I then do a raycaster.setFromCamera(mouse, camera), no points are found to intersect. I’m not sure what the cause is.
With the mouse in the top right corner, and a point there too, I log both the calculated mouse coordinates and then log the raycaster.ray and get these results:

It’s not clear to me from the docs what unit/coordinate system the “direction” should be in, but the numbers look a bit low if you compare it to the origin, which seems to be the correct camera position.

I have a working demo on with the code on

You have to call intersectObjects() like so:

let intersects = raycaster.intersectObjects( scene.children, true );

Notice the second parameter. If set to true, all descendants are checked as well. Consider to use intersectObject() and directly pass in your point cloud.

BTW: Please do not create an instance of Vector2() in onMouseMove(). Create the vector object once in module scope and then just reuse it.

Besides, keep in mind that you raycast against a point cloud. This code will make the entire point cloud red, not just individual points:

Besides, Material.colorNeedsUpdate does not exist. I suggest you study how the following official example works:

Cool, yeah, the recursive part was what I missed. Thanks for that. The color I knew already, just wanted predictable behavior first.