Model loading · function
mirrorNodes
Mirror an asset's hierarchy by the same reflection convertHandedness mirrors its geometry by.
Explained in Importing models.
function mirrorNodes(nodes: readonly DrftNode[]): DrftNode[]import { mirrorNodes } from '@driftengine/assets';Parameters
| Parameter | Type | Description |
|---|---|---|
nodes | readonly DrftNode[] |
In depth
The pair to convertHandedness, exactly as orientNodes is the pair to orientMeshes, and
it did not exist: the one caller that mirrored a graph negated each node's translation X inline
and left the rotations alone. A hierarchy with rotations then places its parts where the
geometry is not — measured on a real car at 1.385 m apart and on the other side of the
model — while both halves stay individually well formed, which is the worst shape this can
take and the reason the two functions now sit together.
The rotation is conjugated, not negated. Reflecting a rotation R by a mirror M gives
M R M, which is a rotation about the mirrored axis in the opposite sense; as a quaternion that
is (x, −y, −z, w) for a reflection about the YZ plane. A scale is untouched, because M S M
is S for any diagonal.
Every node, not only the roots, which is the one place this differs from orientNodes. A
rotation applied to a root already carries its descendants, so applying it to a child would
apply it twice. A reflection is a conjugation and conjugation distributes over the product —
M (A B) M = (M A M)(M B M) — so leaving a child alone drops the mirror out of the composition
rather than avoiding a double application.