Skip to main content

Function: quaternionFacingCamera()

quaternionFacingCamera(objectPosition, cameraPosition, target): Quaternion

Defined in: src/generative/GenerativeObjectUtils.ts:73

Computes a world-space orientation that turns a plane's front face (+Z) toward the camera while keeping the object upright (yaw only). Used to billboard a generated cutout so it faces the user like a standee, without tilting. Apply it directly to a child of the scene; under a transformed parent, convert it into the parent's space first.

Parameters​

objectPosition​

Vector3

World position of the object.

cameraPosition​

Vector3

World position of the camera.

target​

Quaternion = ...

Optional output world orientation.

Returns​

Quaternion

target oriented so +Z points toward the camera, staying upright.