API

Function setParent

  • Reparents child while preserving its current world-space transform, mirroring Babylon.js TransformNode.setParent(). Also keeps the scene-graph children arrays consistent: the child is removed from its previous parent's children and appended to the new parent's, so traversal helpers see the new hierarchy.

    The world transform is preserved exactly, mirrors included: decomposeMat4 keeps a negative determinant (as a negative Y scale), and a node created from a raw matrix (createSceneNodeFromMatrix, used for glTF matrix nodes) is switched to TRS so the new local transform actually takes effect.

    Preservation is impossible when parent's world matrix is singular — a collapsed axis has no inverse, so no local transform can reproduce the child's world. In that case the child keeps the parent link and its world position is copied into its local position, but its rotation and scale are not compensated.

    child.parent links are only established by addToScene, so when reparenting a node from inside a freshly loaded asset, add the container first — otherwise the child's "world" matrix is just its local one and the reparent is computed against the wrong space.

    Parameters

    • child: Mesh

      The node to reparent (mesh, transform node, camera, light, or any SceneNode).

    • parent: IWorldMatrixProvider | null

      The new parent (any world-matrix provider), or null to detach to world space.

    Returns void

  • Reparents child while preserving its current world-space transform, mirroring Babylon.js TransformNode.setParent(). Also keeps the scene-graph children arrays consistent: the child is removed from its previous parent's children and appended to the new parent's, so traversal helpers see the new hierarchy.

    The world transform is preserved exactly, mirrors included: decomposeMat4 keeps a negative determinant (as a negative Y scale), and a node created from a raw matrix (createSceneNodeFromMatrix, used for glTF matrix nodes) is switched to TRS so the new local transform actually takes effect.

    Preservation is impossible when parent's world matrix is singular — a collapsed axis has no inverse, so no local transform can reproduce the child's world. In that case the child keeps the parent link and its world position is copied into its local position, but its rotation and scale are not compensated.

    child.parent links are only established by addToScene, so when reparenting a node from inside a freshly loaded asset, add the container first — otherwise the child's "world" matrix is just its local one and the reparent is computed against the wrong space.

    Parameters

    • child: SceneNode

      The node to reparent (mesh, transform node, camera, light, or any SceneNode).

    • parent: IWorldMatrixProvider | null

      The new parent (any world-matrix provider), or null to detach to world space.

    Returns void