VideoControls
Beschreibung
Mit dieser Komponente können Entitäten die Videowiedergabe auf Texturen steuern, die auf Materialien angewendet werden. Sie wird automatisch hinzugefügt, wenn ein Video über den Studio-Konfigurator eingestellt wird. Wenn das Video programmatisch hinzugefügt wird, muss diese Komponente manuell hinzugefügt werden, um die Wiedergabesteuerung zu aktivieren.
Eigenschaften
Eigentum | Typ | Standard | Beschreibung |
---|---|---|---|
url (Erforderlich) | String | '' | Quell-URL des Videos |
Band | Nummer | 1 | Wie laut das Video abgespielt werden soll. Ein Wert zwischen 0 und 1 |
Schleife | boolean | falsch | Ob das Video nach Beendigung neu startet |
pausiert | boolean | falsch | Ob das Video gerade angehalten wird |
Geschwindigkeit | Nummer | 1 | Die Abspielgeschwindigkeit des Videos. Beeinflusst auch die Tonhöhe |
Standort | boolean | falsch | Ob der Ton des Videos positionell abgespielt wird |
refDistance | Nummer | 1 | Wird nur angewandt, wenn positional true ist. Die Entfernung, bei der die Lautstärke des Tons zu sinken beginnt. Muss ein nicht-negativer Wert sein |
distanceModel | String | Invers | **Der Algorithmus, der verwendet wird, um die Lautstärke mit zunehmender Entfernung zwischen dieser Videoquelle und dem Zuhörer zu reduzieren. Optionen: 'linear', 'invers', 'exponentiell' |
rolloffFactor | Nummer | 1 | Wird nur angewendet, wenn positional wahr ist. Wie schnell die Lautstärke mit zunehmender Entfernung reduziert wird. Der zulässige Bereich variiert je nach EntfernungModell: linear: 0-1, invers: 0-∞, exponentiell: 0-∞ |
maxDistance | Nummer | 10000 | Wird nur angewendet, wenn positional wahr und distanceModel 'linear' ist. Über diese Entfernung hinaus wird die Lautstärke nicht weiter reduziert. Muss ein positiver Wert sein |
Funktionen
Get
Returns a read-only reference.
Example
ecs.VideoControls.get(world, component.eid)
Set
Ensures the component exists on the entity, then assigns the (optional) data to the component.
Example
ecs.VideoControls.set(world, component.eid, {
url: './assets/video.mp4',
volume: 1,
loop: false,
paused: false,
speed: 1,
positional: false,
refDistance: 1,
distanceModel: ''inverse'',
rolloffFactor: 1,
maxDistance: 10000
})
Mutate
Perform an update to the component within a callback function. Return true
to indicate no changes made.
Example
ecs.VideoControls.mutate(world, component.eid, (cursor) => {
cursor.volume = 0.5;
cursor.loop = true;
return false;
})
Remove
Removes the component from the entity.
Example
ecs.VideoControls.remove(world, component.eid)
Has
Returns true
if the component is present on the entity.
Example
ecs.VideoControls.has(world, component.eid)
Reset
Adds, or resets the component to its default state.
Example
ecs.VideoControls.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.VideoControls.cursor(world, component.eid)
Acquire
Same behavior as cursor, but commit must be called after the cursor is done being used.
Example
ecs.VideoControls.acquire(world, component.eid)
Commit
Called after acquire. An optional third argument determines whether the cursor was mutated or not.
Example
ecs.VideoControls.commit(world, component.eid)
ecs.VideoControls.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.VideoControls.dirty(world, component.eid)