Renderer · function

billboardMatrixY

Orient a mesh so its +Z faces the camera, writing the model matrix in place.

Explained in Hello world.

function billboardMatrixY(out: mat4, x: number, y: number, z: number, cameraX: number, cameraZ: number, scaleX?: number, scaleY?: number): void
import { billboardMatrixY } from '@driftengine/core';

Parameters

ParameterTypeDescription
outmat4
xnumber
ynumber
znumber
cameraXnumber
cameraZnumber
scaleX?number
scaleY?number

In depth

The two variants are a real distinction rather than a convenience pair, and picking the wrong one is the classic billboard mistake:

  • Cylindrical (billboardMatrixY) spins about the world Y axis only. Anything standing on the ground uses this — a figure, a sign, a tree. Look down at it from above and it stays upright, because a thing with feet does not tilt to face you.
  • Spherical (billboardMatrix) faces the camera on every axis. For something with no up of its own: a spark, a puff of smoke, a glow.

Allocation-free: the caller owns the matrix and it is overwritten, so a frame drawing a hundred of these allocates nothing.