attach method

void attach(
  1. SceneNode child
)

Adds child while preserving its current scene transform.

The counterpart to add: use it when reparenting should not visibly move anything, which is almost always what a user expects when grouping existing objects.

Implementation

void attach(SceneNode child) {
  final childScene = child.sceneMatrix.clone();
  add(child);
  final parentInverse = sceneMatrix.clone()..invert();
  child.setLocalMatrix(parentInverse * childScene);
}