GltfModel
Beschreibung
Diese Komponente erstellt eine benutzerdefinierte Geometrie für ein Objekt.
Eigenschaften
Eigenschaft | Typ | Standard | Beschreibung |
---|---|---|---|
url (erforderlich) | String | "" | Die Quellurl. |
animationClip | String | "" | Der Name des Animationsclips, der an das abzuspielende Modell angehängt ist. Der Platzhalter "*" wird ebenfalls akzeptiert und führt dazu, dass das Modell jede Animation durchläuft. |
Schleife | boolean | false | Ob der Animationsclip nach Beendigung der Wiedergabe neu startet oder nicht |
pausiert | boolean | false | Ob der Animationsclip pausiert ist |
Zeit | Nummer | 0 | Zeit in Sekunden, zu der der AnimationClip springen soll |
timeScale | Nummer | 1 | Skalierungsfaktor für die Zeit. 0 bewirkt, dass die Animation pausiert. Negative Werte bewirken, dass die Animation rückwärts abgespielt wird. |
Kollider | boolean | false | Ob die Animation den Physikkollider aktualisieren soll. |
umkehren | boolean | false | Wenn diese Option gesetzt ist, wird die Animation rückwärts abgespielt, wenn die Vorwärtswiedergabe beendet ist (dies zählt als eine Schleifeniteration). |
Wiederholungen | Nummer | -1 | Wenn zusammen mit 'loop' gesetzt, die Anzahl der Wiederholungen der Schleife (-1 bedeutet Schleife für immer) |
crossFadeDuration | Nummer | 0 | Die Zeit in Sekunden, die für die Überblendung zwischen Animationen verwendet wird, wenn eine neue Animation gestartet wird (und eine bestehende Animation abgespielt wird) |
Funktionen
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)