Markus Siebeneicher
Markus Siebeneicher

Reputation: 765

Three.js: move object along face normal direction

I stucked a bit.

I have a face, its center position and the face normal. I want to place another object in front of that face along the normal direction, lets say a 1 unit far. The object I want to place in front of the face, isn't rotated properly yet, thats actually another task to solve: rotate the object (plane) perpendicular to the normal of the face. Any hints for me?

Upvotes: 0

Views: 2650

Answers (1)

Samuel Goodell
Samuel Goodell

Reputation: 630

I am assuming that you have an object that you want to place, a center of the position of the object that the face belongs to, and a face.

You can position the object using the face's normal:

object.position.addVectors(center, new THREE.Vector3(1, 1, 1).multiplyScalar(1));

To rotate it, you can do something like:

object.lookAt(center);

Upvotes: 3

Related Questions