Skip to content

Class: AudioUtils ​

Defined in: packages/core/src/audio/audio-utils.ts:15

Utility helpers to control AudioSource without touching Three audio.

Constructors ​

Constructor ​

new AudioUtils(): AudioUtils

Returns ​

AudioUtils

Methods ​

createOneShot() ​

static createOneShot(world, src, options): Entity

Defined in: packages/core/src/audio/audio-utils.ts:145

Create a one-shot audio entity that auto-removes after playing

Parameters ​

world ​

World

World instance

src ​

string

Audio source path

options ​

Additional audio options

position? ​

{ x: number; y: number; z: number; }

position.x ​

number

position.y ​

number

position.z ​

number

positional? ​

boolean

volume? ​

number

Returns ​

Entity

Created entity


getVolume() ​

static getVolume(entity): number

Defined in: packages/core/src/audio/audio-utils.ts:97

Get volume from an entity's audio

Parameters ​

entity ​

Entity

Entity with Audio component

Returns ​

number

Current volume level


isPlaying() ​

static isPlaying(entity): boolean

Defined in: packages/core/src/audio/audio-utils.ts:68

Check if audio is playing on an entity

Parameters ​

entity ​

Entity

Entity with Audio component

Returns ​

boolean

True if audio is playing


pause() ​

static pause(entity, fadeOut): void

Defined in: packages/core/src/audio/audio-utils.ts:38

Pause audio on an entity

Parameters ​

entity ​

Entity

Entity with Audio component

fadeOut ​

number = 0

Fade out duration in seconds

Returns ​

void


play() ​

static play(entity, fadeIn): void

Defined in: packages/core/src/audio/audio-utils.ts:21

Play audio on an entity

Parameters ​

entity ​

Entity

Entity with Audio component

fadeIn ​

number = 0

Fade in duration in seconds

Returns ​

void


preload() ​

static preload(entity): Promise<void>

Defined in: packages/core/src/audio/audio-utils.ts:111

Preload audio for an entity

Parameters ​

entity ​

Entity

Entity with Audio component

Returns ​

Promise<void>

Promise that resolves when audio is loaded


setVolume() ​

static setVolume(entity, volume): void

Defined in: packages/core/src/audio/audio-utils.ts:82

Set volume on an entity's audio

Parameters ​

entity ​

Entity

Entity with Audio component

volume ​

number

Volume level (0.0 to 1.0)

Returns ​

void


stop() ​

static stop(entity): void

Defined in: packages/core/src/audio/audio-utils.ts:53

Stop audio on an entity

Parameters ​

entity ​

Entity

Entity with Audio component

Returns ​

void

Privacy | Terms