Readonly
CameraReadonly
PlayerThe current player entity
Readonly
RootRefer to the root of the scene, all Transforms without a parent are parenting with RootEntity.
Add the system to the engine. It will be called every tick updated.
function mySystem(dt: number) {
const entitiesWithMeshRenderer = engine.getEntitiesWith(MeshRenderer, Transform)
for (const [entity, _meshRenderer, _transform] of engine.getEntitiesWith(MeshRenderer, Transform)) {
// do stuffs
}
}
engine.addSystem(mySystem, 10)
function that receives the delta time between last tick and current one.
Optional
priority: numbera number with the priority, big number are called before smaller ones
Optional
name: stringoptional: a unique name to identify it
Iterator of registered components
Define a component and add it to the engine.
The component definition
const CustomComponent = engine.defineComponent("my-scene::custom-name", {
id: Schemas.Int,
name: Schemas.String
})
unique name to identify the component, a hash is calculated for it, it will fail if the hash has collisions.
An object with schema fields
Optional
constructorDefault: Partial<MapResult<T>>the initial value prefilled when a component is created without a value
Define a component and add it to the engine.
The component definition
const StateComponentId = 10023
const StateComponent = engine.defineComponentFromSchema("my-lib::VisibleComponent", Schemas.Bool)
unique name to identify the component, a hash is calculated for it, it will fail if the hash has collisions.
An object with schema fields
Defines a value set component.
The component definition
const StateComponentId = 10023
const StateComponent = engine.defineValueSetComponentFromSchema("my-lib::VisibleComponent", Schemas.Int)
unique name to identify the component, a hash is calculated for it, it will fail if the hash has collisions.
An object with schema fields
Get the component definition from the component id.
the component definition, throw an error if it doesn't exist
const StateComponentId = 10023
const StateComponent = engine.getComponent(StateComponentId)
component number or name used to identify the component descriptor
Get the component definition from the component id.
the component definition or null if its not founded
const StateComponentId = 10023
const StateComponent = engine.getComponent(StateComponentId)
component number or name used to identify the component descriptor
Get a iterator of entities that has all the component requested.
An iterator of an array with the [entity, component1, component2, ...]
Example:
for (const [entity, meshRenderer, transform] of engine.getEntitiesWith(MeshRenderer, Transform)) {
// the properties of meshRenderer and transform are read only
}
Rest
...components: Ta list of component definitions
Check the state of an entityin the engine
EntityState enum
the entity to validate
Registers a custom component definition.
unique name to identify the component, a hash is calculated for it, it will fail if the hash has collisions.
The component definition
Camera entity of current player.