AudioSystem
Reconciles AudioComponent state with the underlying THREE.js positional audio objects each frame. Only active in preview mode — editor viewports are unaffected.
Overview
AudioSystem runs every frame in preview and is responsible for:
- Driving
play(),pause(), andstop()on the THREE.jsPositionalAudionode based on the intent flags set byAudioComponent.play(),.pause(), and.stop(). - Detecting when a non-looping clip ends naturally (THREE.js stops on its own) and resetting component state accordingly.
- Syncing
loop,pitch,volume,refDistance,distanceModel, androlloffFactorto the live audio node whenever they change. Changes take effect on the next frame.
Queried components
| Component | Access |
|---|---|
AudioComponent | Read + mutate (isPlaying, isPaused flags; option properties) |
Behavior notes
- Editor skip — when constructed with
{ isEditor: true }theupdatemethod returns immediately, so no audio state is applied in the editor. - Natural end detection — the system compares the THREE.js
isPlayingstate between frames. If the audio node stopped on its own while the component still believed it was playing (and not paused), the component flags are reset and a warning is suppressed. - Change detection — option sync uses a per-entity snapshot from the previous frame, so
AudioComponentoptions can be mutated freely in scripts without causing redundant THREE.js calls on every frame.
API reference
- Class:
AudioComponent - Source:
core/systems/AudioSystem.ts

