I have adjusted the mouse coordinates to account for the canvas, I believe.
Apart from that, I’m afraid I do not fully understand your issue. Are raycasting against a point cloud or mesh? Besides, the intersection point (
intersects[0].point
) is always in world space.Object3D.position
which is defined in local space. Depending on whether the 3D object has a parent or not, you can’t compare both values.
I am raycasting against a mesh. I have a point cloud representation saved server side, and using this point cloud representation I am able to cluster points using a variable distance between the points parameter in order to determine what piece of the overall point cloud I’m dealing with, and then compute the bounding box for that piece. I can then use those bounding box coordinates calculated on the server side to draw a cube in ThreeJS.
My issue is I need to know the position in local space that I have clicked so that I can feed those coordinates to my algorithms on the server side. Is there any way to convert the intersection point from world space coordinates to the mesh local space coordinates. The mesh object is listed as a “child” of the THREE.Scene
After reading your comment, I have tried
let p = intersects[0].point
let local_p = mesh.worldToLocal(p)
However I get the same vector for both p
and local_p