Skip to content

@relu-interactives/spatial-ecs


@relu-interactives/spatial-ecs / components / AudioComponent

Class: AudioComponent ​

Defined in: components/Audio.ts:29

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 ​

ts
new AudioComponent(path, options?): AudioComponent;

Defined in: components/Audio.ts:67

Parameters ​

ParameterType
pathstring
optionsPartial<typeof DEFAULT_AUDIO_OPTIONS>

Returns ​

AudioComponent

Overrides ​

Component.constructor

Properties ​

PropertyTypeDescriptionDefined in
pathstringSource URL or localasset:// path of the audio file.components/Audio.ts:31
options{ autoplay: boolean; loop: boolean; pitch: number; volume: number; positional: boolean; refDistance: number; distanceModel: string; rolloffFactor: number; bus: AudioBus; }Playback options.Field
options.autoplayboolean-components/Audio.ts:10
options.loopboolean-components/Audio.ts:11
options.pitchnumber-components/Audio.ts:12
options.volumenumber-components/Audio.ts:13
options.positionalboolean-components/Audio.ts:14
options.refDistancenumber-components/Audio.ts:15
options.distanceModelstring-components/Audio.ts:16
options.rolloffFactornumber-components/Audio.ts:17
options.busAudioBus-components/Audio.ts:18
objectObject3D<Object3DEventMap> | nullLive three.js object hosting the audio (a parented Audio/PositionalAudio). null until built.components/Audio.ts:49
audioAudio<GainNode> | PositionalAudio | nullLive three.js audio source. null until built. Recreated when the project loads.components/Audio.ts:51
isPlayingbooleanWhether 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:58
isPausedbooleanWhether 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:65

Methods ​

play() ​

ts
play(): void;

Defined in: components/Audio.ts:101

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() ​

ts
pause(): void;

Defined in: components/Audio.ts:111

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() ​

ts
stop(): void;

Defined in: components/Audio.ts:120

Signals AudioSystem to stop playback and reset the playback position.

Returns ​

void