@relu-interactives/spatial-ecs
@relu-interactives/spatial-ecs / components / AudioComponent
Class: AudioComponent ​
Defined in: components/Audio.ts:27
Plays an audio clip from path. Supports both global stereo (positional: false) and 3D positional audio with the configured distance model. Runtime fields (object, audio, isPlaying, isPaused) are recreated when the project loads and are never persisted to saved snapshots.
Extends ​
Constructors ​
Constructor ​
new AudioComponent(path, options?): AudioComponent;Defined in: components/Audio.ts:64
Parameters ​
| Parameter | Type |
|---|---|
path | string |
options | Partial<typeof DEFAULT_AUDIO_OPTIONS> |
Returns ​
AudioComponent
Overrides ​
Properties ​
| Property | Type | Description | Defined in |
|---|---|---|---|
path | string | Source URL or localasset:// path of the audio file. | components/Audio.ts:29 |
options | { autoplay: boolean; loop: boolean; pitch: number; volume: number; positional: boolean; refDistance: number; distanceModel: string; rolloffFactor: number; } | Playback options. | Field |
options.autoplay | boolean | - | components/Audio.ts:9 |
options.loop | boolean | - | components/Audio.ts:10 |
options.pitch | number | - | components/Audio.ts:11 |
options.volume | number | - | components/Audio.ts:12 |
options.positional | boolean | - | components/Audio.ts:13 |
options.refDistance | number | - | components/Audio.ts:14 |
options.distanceModel | string | - | components/Audio.ts:15 |
options.rolloffFactor | number | - | components/Audio.ts:16 |
object | Object3D<Object3DEventMap> | null | Live three.js object hosting the audio (a parented Audio/PositionalAudio). null until built. | components/Audio.ts:46 |
audio | Audio<GainNode> | PositionalAudio | null | Live three.js audio source. null until built. Recreated when the project loads. | components/Audio.ts:48 |
isPlaying | boolean | Whether the audio should be playing. Managed by AudioSystem in preview. Non-enumerable — not persisted to snapshots or save data. Set via play / stop. | components/Audio.ts:55 |
isPaused | boolean | Whether the audio is paused mid-playback (position is preserved). Non-enumerable — not persisted to snapshots or save data. Set via pause / play / stop. | components/Audio.ts:62 |
Methods ​
play() ​
play(): void;Defined in: components/Audio.ts:98
Signals AudioSystem to start (or resume) playback. Has no direct effect in the editor — AudioSystem drives the actual THREE.js call in preview.
Returns ​
void
pause() ​
pause(): void;Defined in: components/Audio.ts:108
Signals AudioSystem to pause playback, preserving the current position. Calling play afterwards resumes from where it paused. No-op if not currently playing.
Returns ​
void
stop() ​
stop(): void;Defined in: components/Audio.ts:117
Signals AudioSystem to stop playback and reset the playback position.
Returns ​
void

