Hierarchy & Transforms
Entities can be arranged in a parent-child hierarchy. The Entity class inherits transform functionality 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. Shallow 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 physical issues.
- Avoid scaling physics-enabled entities unless necessary.