Skip to main content

Function: orientMeshAlong()

orientMeshAlong(mesh, direction): void

Defined in: src/mobjects/three-d/meshOrient.ts:23

Orient a mesh so its local +Y axis points along a direction.

Three.js cylinders and cones are built along +Y, so a start->end primitive needs one rotation that maps +Y onto the normalized direction. The rotation is a quaternion from setFromUnitVectors, which itself handles the antiparallel (-Y) edge case by choosing an orthogonal axis.

A zero-length direction has no orientation, so the mesh is left at identity.

Parameters​

mesh​

Object3D

The object to orient (its quaternion is overwritten).

direction​

The target direction as a tuple or THREE.Vector3.

Vector3 | Vector3Tuple

Returns​

void