Static
updateGets the current update count for the entity repository.
The current update count
Static
_getStatic
_shallowStatic
addAdds a specific component class to an entity and returns the enhanced entity.
The component class to instantiate and add
The entity to add the component to
The entity enhanced with the component's methods
This method creates a new component instance, associates it with the entity, and returns the entity with enhanced type information that includes the component's methods. If the entity already has this component, a warning is logged and the entity is returned unchanged.
const entity = EntityRepository.createEntity();
const enhancedEntity = EntityRepository.addComponentToEntity(
TransformComponent,
entity
);
// enhancedEntity now has transform-related methods
Static
createStatic
deleteStatic
deleteRecursively deletes an entity and all its descendant entities in the scene graph hierarchy.
The unique identifier of the root entity to delete recursively
This method traverses the entire scene graph tree starting from the specified entity and deletes all entities in the hierarchy. Use this when you want to remove an entire subtree from the scene graph.
// Delete a parent entity and all its children
EntityRepository.deleteEntityRecursively(parentEntity.entityUID);
Static
getRetrieves a specific component from an entity.
The unique identifier of the entity
The component class to retrieve
The component instance if found, null otherwise
This method looks up a component of the specified type from the given entity. Returns null if the entity doesn't exist or doesn't have the requested component.
const transform = EntityRepository.getComponentOfEntity(
entityUID,
TransformComponent
);
if (transform) {
// Use the transform component
}
Static
getStatic
getStatic
getStatic
removeRemoves a component from an entity and cleans up associated resources.
The entity with the component removed (typed as IEntity)
This method removes the specified component from the entity, calls the component's destroy method, and returns the entity with basic IEntity typing. You may need to cast the returned entity to the appropriate type after component removal.
const entity = EntityRepository.createEntity();
// Add and later remove a component
EntityRepository.removeComponentFromEntity(TransformComponent, entity);
Static
searchStatic
shallowCreates a shallow copy of an entity, including all its components and tag data.
The entity to shallow copy
A new entity that is a shallow copy of the input entity
This method performs a shallow copy of the entity, its components, and handles
special cases like skeletal joints and tag references. The original entity's
_myLatestCopyEntityUID
will be updated to reference the new entity.
const originalEntity = EntityRepository.createEntity();
const copiedEntity = EntityRepository.shallowCopyEntity(originalEntity);
Static
tryAttempts to add a component to an entity using the component's type ID.
The component type identifier
The entity to add the component to
The entity (possibly with the new component added)
This method looks up the component class by its TID and adds it to the entity if the component class exists. If the component class is not found, the entity is returned unchanged.
const entity = EntityRepository.createEntity();
EntityRepository.tryToAddComponentToEntityByTID(
WellKnownComponentTIDs.TransformComponentTID,
entity
);
The repository class responsible for creating, managing, and deleting entities within the framework. Provides entity lifecycle management, component attachment, and entity querying capabilities.
Remarks
This class manages entity UIDs, tracks entity relationships, and handles component associations. It also provides functionality for entity copying and cleanup operations.