メインコンテンツへスキップ

オーディオ

商品説明

このコンポーネントにより、エンティティはサウンドを再生することができる。

プロパティ一覧

PropertyType初期値商品説明
url (必須)ストリング''ソースURL
ボリューム番号1音声の再生音量 0から1の間の値
ループブーリアンfalse終了後にオーディオを再開するかどうか
休止中ブーリアンfalseオーディオが一時停止中かどうか
ピッチ番号1オーディオのピッチを変更するために使用される係数。 1がデフォルトのピッチ。
ポジションブーリアンfalseオーディオをポジション再生するかどうか
反射距離番号1**リスナーが遠ざかるにつれて、この音源からの音量が減少し始める距離を示す値。 負でない値でなければならない。
距離モデルストリング'逆'**このオーディオソースとリスナーとの間の距離が大きくなるにつれて音量を下げるために使用されるアルゴリズム。 取り得る値には、「linear」、「inverse」、「exponential」がある。
ロールオフ係数番号1**この音源とリスナーとの距離が離れるにつれて、音量が減少する速さ。 許容される値の範囲は、distanceModel に応じて以下のように変化する: linear: 0~1、inverse: 0~Infinity: 0から無限大、指数: 0から無限大
最大距離番号10000positionalがtrueで、distanceModelがlinearの場合のみ適用される。 このオーディオソースとリスナーとの最大距離。 この時点以降、体積は減らない。 正の値でなければならない。

関数一覧

Get

Returns a read-only reference.

Example

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

Set

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

Example

ecs.Audio.set(world, component.eid, {
url: '',
volume: 1,
loop: false,
paused: false,
pitch: 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.Audio.mutate(world, component.eid, (cursor) => {
cursor.volume = 0.5;
cursor.loop = true;
return false;
})

Remove

Removes the component from the entity.

Example

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

Has

Returns true if the component is present on the entity.

Example

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

Reset

Adds, or resets the component to its default state.

Example

ecs.Audio.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.Audio.cursor(world, component.eid)

Acquire

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

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

Commit

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

Example
ecs.Audio.commit(world, component.eid)
ecs.Audio.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.Audio.dirty(world, component.eid)