Raycaster don't intersect with geometry points after updating the position vertices

I’m trying to reshape a geometry by dragging its vertices, at first the raycaster works as intended and intersect perfectly with every geometry points, but if I drag a point updating the geometry the raycatser don’t intersect with it anymore and I have to move the camera around zoom in/out to get it to intersect again.

Here is a jsFiddle with a simple four points geometry to illustrate the problem, if you drag any point the raycaster won’t intersect with it unless you move the camera around.

PS: (Not related) In the fiddle the orbitControl trigger after enabling/disabling it, I don’t have this problem with my actual code, tried to fix without success.

The raycasting logic uses the bounding sphere of geometries for better performance. If you change the position of vertices, you should always recompute it. Updated fiddle: three.js ~ example ~ Mr.doob - JSFiddle - Code Playground

You eventually need points.geometry.computeBoundingSphere(); in your endMove() function.

It works, thanks a lot @Mugen87, it was really frustrating and I was about to ditch the hole project because of this.

You’re i life saver.

1 Like