Skip to content

Commit

Permalink
Force a matrix world update when audio is created
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Jan 26, 2024
1 parent 4586072 commit af9c696
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/bit-systems/audio-emitter-system.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit af9c696

Please sign in to comment.