Entity
Entities are the fundamental building blocks of OasisW scenes (Entity).
Key characteristics
- Entities can have zero or more components.
- Entities can have parent-child relationships to form hierarchies (
addChild,removeChild). - Entities can be enabled or disabled (
enabled).
tip
Keep entities lightweight — avoid adding unnecessary components.
Creating Entities in Code
const entity = new pc.Entity("MyEntity");
app.root.addChild(entity);
Enabling / Disabling Entities
entity.enabled = false; // Disable entity and all components
tip
Disable entities when not in use to reduce processing overhead and improve performance.
Lifecycle
- Creation —
Entity constructor. - Parent Assignment —
addChild/removeChild. - Destruction —
destroy.
tip
Call destroy when an entity is no longer needed to free resources and remove it from the hierarchy.