1. @threlte/core
  2. AudioInstance

@threlte/core

AudioInstance

This module is deprecated. You can still use it but it will be removed in the future. Please consider using <T>/<Three> instead. Please read the update notice.

This component lets you use any manually instantiated object that extends THREE.Audio in threlte.

Import

Source

Github View Source Code

Package

NPM View Package

Related Docs


Example

<script>
  import { AudioInstance, useAudioListener } from '@threlte/core'
  import { Audio } from 'three'

  export let buffer: AudioBuffer

  const { listener } = useAudioListener()
  const audio = new Audio(listener)
  audio.setBuffer(buffer)
</script>

<AudioInstance {audio} />

Properties

// required
audio: THREE.Audio | THREE.PositionalAudio

// optional
viewportAware: boolean = false
position: Position | undefined = undefined
scale: Scale | undefined = undefined
rotation: Rotation | undefined = undefined
lookAt: LookAt | undefined = undefined
castShadow: boolean | undefined = undefined
receiveShadow: boolean | undefined = undefined
frustumCulled: boolean | undefined = undefined
renderOrder: number | undefined = undefined
visible: boolean | undefined = undefined
dispose: boolean | undefined = undefined
userData: Record<string, any> | undefined = undefined
autoplay: boolean | undefined = undefined
detune: number | undefined = undefined
source: string | AudioBuffer | HTMLMediaElement | AudioBufferSourceNode | MediaStream | undefined = undefined
volume: number | undefined = undefined
loop: boolean | undefined = undefined
filters: BiquadFilterNode[] | BiquadFilterNode | undefined = undefined
playbackRate: number | undefined = undefined
id: string | undefined = undefined

Bindings

inViewport: boolean
play: (delay?: number) => Promise<THREE.Audio | THREE.PositionalAudio>
pause: () => THREE.Audio | THREE.PositionalAudio
stop: () => THREE.Audio | THREE.PositionalAudio

Events

viewportenter: undefined
viewportleave: undefined
load: AudioBuffer
progress: ProgressEvent<EventTarget>
error: ErrorEvent