Skip to content

Commit

Permalink
Merge pull request Hubs-Foundation#6463 from mozilla/invisible-audio-fix
Browse files Browse the repository at this point in the history
Force a matrix world update when audio is created
  • Loading branch information
keianhzo authored Jan 26, 2024
2 parents 0ee6757 + af9c696 commit a8208fc
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 a8208fc

Please sign in to comment.