0

I have a mesh object on a floor and based on a click I want to rotate that mesh so it is on the floor. I'm able to get the click and select the mesh but how can I get the face to figure out how to rotate it.

1 Answers1

0

It's hard to say without code example, but probably you're looking for:

  1. Use Raycaster intersectObject for determining both mesh and face you're clicking at;

  2. Determine face rotation by looking into face normal vector . Note that you must call Geometry.computeFaceNormals() before using it if you build your mesh manually

  3. Rotate mesh around face center to the angle, which can be calculated from face normal vector. The simplest approach to rotate around Vector3 here

Hope it will help

Andrew Gura
  • 382
  • 2
  • 11