[Solved] Raycaster missing half a plane - bug?

You are missing something^^. If you modify the geometry, you also have to update the corresponding bounding volumes like so:

geometry.computeBoundingSphere();
geometry.computeBoundingBox();

Raycasting first checks the bounding volumes. The more expensive ray/triangle intersection test comes next.

Updated fiddle: Edit fiddle - JSFiddle - Code Playground

BTW: I’ve seen some things in your fiddle that are not so good:

  • You should not dispose a geometry right after creating a mesh. It’s also not necessary to set the geometry variable to null.
  • The way you manipulate the geometry data is strange. Right now, the code that updates the geometry is executed multiple frames. It’s better to put the related logic in a click event listener which is executed just once.
3 Likes