From af9c696db2fefe4fc12c0ea0458a66c6ab03ad29 Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Fri, 26 Jan 2024 12:46:08 +0100 Subject: [PATCH] Force a matrix world update when audio is created --- src/bit-systems/audio-emitter-system.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bit-systems/audio-emitter-system.ts b/src/bit-systems/audio-emitter-system.ts index 448a6723e5..a525fc3e02 100644 --- a/src/bit-systems/audio-emitter-system.ts +++ b/src/bit-systems/audio-emitter-system.ts @@ -1,4 +1,4 @@ -import { addComponent, addEntity, defineQuery, removeComponent } from "bitecs"; +import { addComponent, addEntity, defineQuery, enterQuery, removeComponent } from "bitecs"; import { PositionalAudio, Audio as StereoAudio, AudioListener as ThreeAudioListener } from "three"; import { HubsWorld } from "../app"; import { AudioEmitter, AudioSettingsChanged, MediaVideoData } from "../bit-components"; @@ -94,7 +94,13 @@ export function makeAudioEntity(world: HubsWorld, source: number, sourceType: So } const staleAudioEmittersQuery = defineQuery([AudioEmitter, AudioSettingsChanged]); +const audioEmitterQuery = defineQuery([AudioEmitter]); +const audioEmitterEnterQuery = enterQuery(audioEmitterQuery); export function audioEmitterSystem(world: HubsWorld, audioSystem: AudioSystem) { + audioEmitterEnterQuery(world).forEach(eid => { + const audio = APP.audios.get(eid)!; + audio.updateMatrixWorld(true); + }); staleAudioEmittersQuery(world).forEach(function (eid) { const audio = world.eid2obj.get(eid)! as PositionalAudio | StereoAudio; const settings = getCurrentAudioSettings(eid);