Ir al contenido principal

GltfModel

Descripción

Este componente establece una geometría personalizada en una entidad.

Propiedades

PropiedadTipoPor defectoDescripción
url (Obligatorio)cadena""La url de la fuente.
animationClipcadena""El nombre del animationClip adjunto al modelo a reproducir. También se acepta el comodín *, que hará que el modelo reproduzca todas las animaciones.
buclebooleanofalsoSi el clip de animación se reinicia o no una vez finalizada su reproducción
en pausabooleanofalsoSi el clip de animación está en pausa
tiemponúmero0Tiempo en segundos de animationClip para saltar a
timeScalenúmero1Factor de escala para el tiempo. 0 hace que la animación se detenga. Los valores negativos hacen que la animación se reproduzca hacia atrás.
colisionadorbooleanofalsoSi la animación debe actualizar el colisionador de física.
invertirbooleanofalsoSi se establece, la animación se reproducirá en reversa cuando termine de reproducirse hacia adelante (juntos cuentan como una iteración de bucle)
repeticionesnúmero-1Si se establece junto con 'loop', el número de veces que se repetirá el bucle (-1 significa bucle para siempre)
crossFadeDurationnúmero0El tiempo en segundos que se pasará mezclando entre animaciones cuando se inicie una nueva animación (y se esté reproduciendo una animación existente).

Funciones

Get

Returns a read-only reference.

Example

ecs.GltfModel.get(world, component.eid)

Set

Ensures the component exists on the entity, then assigns the (optional) data to the component.

Example

ecs.GltfModel.set(world, component.eid, {
url: './assets/doty.glb',
animationClip: 'idle',
loop: false,
paused: false,
time: 0,
timeScale: 1,
collider: false,
reverse: false,
repetitions: -1,
crossFadeDuration: 0
})

Mutate

Perform an update to the component within a callback function. Return true to indicate no changes made.

Example

ecs.GltfModel.mutate(world, component.eid, (cursor) => {
cursor.timeScale = 0.5;
cursor.loop = true;
return false;
})

Remove

Removes the component from the entity.

Example

ecs.GltfModel.remove(world, component.eid)

Has

Returns true if the component is present on the entity.

Example

ecs.GltfModel.has(world, component.eid)

Reset

Adds, or resets the component to its default state.

Example

ecs.GltfModel.reset(world, component.eid)

Advanced Functions

Cursor

Returns a mutable reference. Cursors are reused so only one cursor for each component can exist at a time.

Example
ecs.GltfModel.cursor(world, component.eid)

Acquire

Same behavior as cursor, but commit must be called after the cursor is done being used.

Example
ecs.GltfModel.acquire(world, component.eid)

Commit

Called after acquire. An optional third argument determines whether the cursor was mutated or not.

Example
ecs.GltfModel.commit(world, component.eid)
ecs.GltfModel.commit(world, component.eid, false)

Dirty

Mark the entity as having been mutated. Only needed in a specific case where systems are mutating data.

Example
ecs.GltfModel.dirty(world, component.eid)