Skip to main content

Hierarchy and Transformations

Entities can be arranged in a parent-child hierarchy. The Entity class inherits its transform capabilities from the GraphNode superclass.

Key points

  • Transforms are relative to the parent.
  • World transforms are calculated by combining local transforms through the hierarchy.
  • Moving a parent affects all its children.
tip

Minimize deep hierarchies. Shallower hierarchies are easier to manage and can perform better.

Example

childEntity.setLocalPosition(1, 0, 0); // relative to parent
console.log(childEntity.getWorldPosition()); // global position

See setLocalPosition and getWorldPosition.

Re-parenting

newParent.addChild(childEntity);

Scaling considerations

  • Non-uniform scaling can cause visual or physics issues.
  • Avoid scaling physics-enabled entities unless necessary.