Module transform

Source
Expand description

Local and world transforms from usd::xformop.

§Matrix layout

In ifcx_alpha files the attribute is an object with one field, transform, holding four rows of four numbers:

"usd::xformop": {"transform": [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [5, 0, 2, 1]]}

This is USD’s convention: points are row vectors multiplied on the left, p' = [x, y, z, 1] · M, so the translation is the last row and the last column is (0, 0, 0, 1). Every one of the 41 840 transforms in the upstream examples (1a63082) has that last column. Upstream’s viewer (src/viewer/render.ts) loads the rows with three.js Matrix4.set and then transposes, which yields the same mapping.

Flattening the rows in file order gives the column-major element order of the equivalent column-vector matrix, which is what glTF node.matrix and three.js Matrix4.elements expect; see Transform::to_column_major.

A node’s transform places its own geometry and all of its children relative to its parent. In the row-vector convention a child’s world matrix is local · parent_world; world_from_parent computes it, and a node without the attribute inherits its parent’s world matrix. Units are those of the file (metres in every upstream sample); no scaling is applied.

Structs§

Transform
An affine 4×4 transform in USD’s row-vector layout.

Constants§

ATTRIBUTE
Attribute id that carries a node’s local transform.

Functions§

world_from_parent
World transform of a node from its parent’s world transform and its own local transform, if it has one. A node without a local transform inherits its parent’s world transform unchanged. Use Transform::IDENTITY as the parent of a root.