Illutions Engine API - v0.26.0
    Preparing search index...

    Class Audio

    The Audio class manages audio playback within a Three.js scene. It handles loading, attaching, fading, and controlling global and positional audio sources, and ensures smooth transitions and automatic AudioContext management.

    Index
    • Returns the audio parameters currently used at runtime.

      Returns Partial<AudioCfg>

      A snapshot of the mutable audio settings.

    • Checks whether an audio source with the given name is loaded.

      Parameters

      • params: { name: string }

        Parameter object.

        • name: string

          The name of the audio.

      Returns boolean

      True if the audio is loaded, otherwise false.

    • Checks whether an audio source with the given name is currently playing.

      Parameters

      • params: { name: string }

        Parameter object.

        • name: string

          The name of the audio.

      Returns boolean

      True if the audio is playing, otherwise false.

    • Loads an audio file without playing it and sends an AUDIO_LOADED event when the sound is ready.

      Parameters

      Returns void

    • Loads an audio file and plays it automatically when loading is complete. Use this method when no separate AUDIO_LOADED handling is required.

      Parameters

      Returns void

    • Plays an audio that has finished loading, with a smooth fade-in. When using load, call this method after receiving the matching AUDIO_LOADED event. This method does not wait for an audio file that is still loading.

      Parameters

      • params: { name: string }

        Parameter object.

        • name: string

          The name of the loaded audio to play.

      Returns void

    • Resumes the Web Audio context after a user gesture.

      Returns void

    • Updates one or more audio parameters at runtime.

      Parameters

      • params: Partial<AudioCfg>

        Audio parameters to update.

      Returns void

    • Creates a THREE.AudioListener and attaches it to a named scene object or the active camera managed by Cam3D.

      Parameters

      • params: { object: string | Cam3D }

        Parameter object.

        • object: string | Cam3D

          The name of a scene object or the Cam3D instance to attach the listener to.

      Returns void

    • Stops the playback of an audio with a smooth fade-out.

      Parameters

      • params: { name: string }

        Parameter object.

        • name: string

          The name of the audio to stop.

      Returns void

    • Registers and executes a low-level extension function with access to the public Audio API.

      Parameters

      • extension: (audio: Audio) => void

        Function that receives the current Audio instance and can use its public members and methods.

      Returns void

      This method is intended for advanced custom integrations where developers need direct access to the engine instance. The extension is executed once immediately when use() is called.