Writing a transform to a node
Rotation and scale, written onto the Babylon node itself, in the RUNTIME layer
because both the instantiator and the editor need them and the dependency may
only point one way: the editor may import the runtime, never the reverse.
Putting these in transform-write.ts — where they belong by subject — would
drag the whole editor into a game's bundle, which tree-shaking.test.ts exists
to prevent.
Why the node, when the element has attributes for this
Because for a library-backed piece the attributes do nothing. b3d-destroyable
forwards only {x, y, z, canonical} to library.instantiate, so rx/ry/rz
are dropped on the floor, and size is documented as the placeholder cube's
edge length and ignored outright. Position is the exception: the element
rewrites mesh.position from x/y/z every frame, which is why moving a
piece has always worked and turning or scaling one never has.
Measured, all three:
| written | result |
|---|---|
piece.scale 1 → 2 → 4 |
rendered width 5.273 every time |
element.ry = 90 |
node rotation 0,0,0, quaternion null, unchanged |
authored rot: [0, 45, 0] |
footprint 3.63 × 3.63, identical to no rotation |
Writing the node works: 45° on the node took that footprint to 5.13 × 5.13, which is the √2 a square turns into. Filed as tosijs-3d#47 (scale) and #48 (rotation); when they land this module retires.