Skip to content

defineComponent

defineComponent<T>(name, defaults, metadata?): ComponentDef<T>

Defined in: ecs/component.ts:385

Declare a component type from its name and the defaults every instance starts with. name is the identity a scene file stores, so it is what a saved entity is rebound by; defining the same name twice returns the first definition rather than replacing it, so a hot reload cannot orphan live entities.

T extends object

string

T

ComponentMetadata

ComponentDef<T>

if name is already taken by a built-in engine component.