Sources
A Source represents a single emitting sound source in the acoustic scene. It stores position, orientation, and simulation settings, and it produces a SteamAudioNode that you connect into the Web Audio graph.
Creating a source
Section titled “Creating a source”Create a source from a world, then create an audio node for it.
import { const createWorld: (options: WorldOptions) => Promise<World>
createWorld } from 'three-steam-audio'
const const audioContext: AudioContext
audioContext = new var AudioContext: new (contextOptions?: AudioContextOptions) => AudioContext
The AudioContext interface represents an audio-processing graph built from audio modules linked together, each represented by an AudioNode.
AudioContext()const const world: World
world = await function createWorld(options: WorldOptions): Promise<World>
createWorld({ WorldOptions.audioContext: AudioContext
audioContext })
const const source: Source
source = const world: World
world.function createSource(settings?: SourceSettings): Source
createSource({ SourceSettings.hrtf?: boolean | undefined
hrtf: true, SourceSettings.directSimulation?: boolean | DirectSimulationSettings | undefined
directSimulation: { DirectSimulationSettings.airAbsorption?: boolean | undefined
airAbsorption: true, DirectSimulationSettings.occlusion?: false | "raycast" | "volumetric" | undefined
occlusion: 'raycast', DirectSimulationSettings.transmission?: false | { type?: "frequency-dependent" | "frequency-independent";} | undefined
transmission: { type?: "frequency-dependent" | "frequency-independent" | undefined
type: 'frequency-dependent' }, },})
const const node: SteamAudioNode
node = const world: World
world.function createNode(sourceValue: Source): SteamAudioNode
createNode(const source: Source
source)
const const oscillator: OscillatorNode
oscillator = new var OscillatorNode: new (context: BaseAudioContext, options?: OscillatorOptions) => OscillatorNode
The OscillatorNode interface represents a periodic waveform, such as a sine wave. It is an AudioScheduledSourceNode audio-processing module that causes a specified frequency of a given wave to be created—in effect, a constant tone.
OscillatorNode(const audioContext: AudioContext
audioContext, { OscillatorOptions.frequency?: number | undefined
frequency: 440 })const oscillator: OscillatorNode
oscillator.AudioNode.connect(destinationNode: AudioNode, output?: number, input?: number): AudioNode (+1 overload)
The connect() method of the AudioNode interface lets you connect one of the node's outputs to a target, which may be either another AudioNode (thereby directing the sound data to the specified node) or an AudioParam, so that the node's output data is automatically used to change the value of that parameter over time.
connect(const node: SteamAudioNode
node)const node: SteamAudioNode
node.AudioNode.connect(destinationNode: AudioNode, output?: number, input?: number): AudioNode (+1 overload)
The connect() method of the AudioNode interface lets you connect one of the node's outputs to a target, which may be either another AudioNode (thereby directing the sound data to the specified node) or an AudioParam, so that the node's output data is automatically used to change the value of that parameter over time.
connect(const audioContext: AudioContext
audioContext.BaseAudioContext.destination: AudioDestinationNode
The destination property of the BaseAudioContext interface returns an AudioDestinationNode representing the final destination of all audio in the context. It often represents an actual audio-rendering device such as your device's speakers.
destination)const oscillator: OscillatorNode
oscillator.AudioScheduledSourceNode.start(when?: number): void
The start() method on AudioScheduledSourceNode schedules a sound to begin playback at the specified time. If no time is specified, then the sound begins playing immediately.
start()import { const Suspense: ExoticComponent<SuspenseProps>
Lets you display a fallback until its children have finished loading.
Suspense, function useEffect(effect: EffectCallback, deps?: DependencyList): void
Accepts a function that contains imperative, possibly effectful code.
useEffect, function useState<S>(initialState: S | (() => S)): [S, Dispatch<SetStateAction<S>>] (+1 overload)
Returns a stateful value, and a function to update it.
useState } from 'react'import { function Canvas(props: CanvasProps): import("react").JSX.Element
A DOM canvas which accepts threejs elements as children.
Canvas } from '@react-three/fiber'import { const SteamAudio: (props: SteamAudioProps) => import("react").JSX.Element
SteamAudio, const SteamAudioListener: ({ object }: SteamAudioListenerProps) => null
SteamAudioListener, const SteamAudioSource: { ({ airAbsorption, destination, directivity, hrtf, input, occlusion, onReady, ref, reflections, reflectionSend, reverbSend, settings, spatialBlend, transmission, ...groupProps }: SteamAudioSourceProps): import("react").JSX.Element; displayName: string;}
SteamAudioSource,} from 'three-steam-audio/react'
export const const App: () => JSX.Element | null
App = () => { const [const audioContext: AudioContext
audioContext] = useState<AudioContext>(initialState: AudioContext | (() => AudioContext)): [AudioContext, Dispatch<SetStateAction<AudioContext>>] (+1 overload)
Returns a stateful value, and a function to update it.
useState(() => new var AudioContext: new (contextOptions?: AudioContextOptions) => AudioContext
The AudioContext interface represents an audio-processing graph built from audio modules linked together, each represented by an AudioNode.
AudioContext()) const [const input: AudioNode | null
input, const setInput: Dispatch<SetStateAction<AudioNode | null>>
setInput] = useState<AudioNode | null>(initialState: AudioNode | (() => AudioNode | null) | null): [AudioNode | null, Dispatch<SetStateAction<AudioNode | null>>] (+1 overload)
Returns a stateful value, and a function to update it.
useState<interface AudioNode
The AudioNode interface is a generic interface for representing an audio processing module.
AudioNode | null>(null)
function useEffect(effect: EffectCallback, deps?: DependencyList): void
Accepts a function that contains imperative, possibly effectful code.
useEffect(() => { const const oscillator: OscillatorNode
oscillator = new var OscillatorNode: new (context: BaseAudioContext, options?: OscillatorOptions) => OscillatorNode
The OscillatorNode interface represents a periodic waveform, such as a sine wave. It is an AudioScheduledSourceNode audio-processing module that causes a specified frequency of a given wave to be created—in effect, a constant tone.
OscillatorNode(const audioContext: AudioContext
audioContext, { OscillatorOptions.frequency?: number | undefined
frequency: 440 }) const oscillator: OscillatorNode
oscillator.AudioScheduledSourceNode.start(when?: number): void
The start() method on AudioScheduledSourceNode schedules a sound to begin playback at the specified time. If no time is specified, then the sound begins playing immediately.
start() const setInput: (value: SetStateAction<AudioNode | null>) => void
setInput(const oscillator: OscillatorNode
oscillator) return () => const oscillator: OscillatorNode
oscillator.AudioScheduledSourceNode.stop(when?: number): void
The stop() method on AudioScheduledSourceNode schedules a sound to cease playback at the specified time. If no time is specified, then the sound stops playing immediately.
stop() }, [const audioContext: AudioContext
audioContext])
if (!const input: AudioNode | null
input) return null
return ( <function Canvas(props: CanvasProps): import("react").JSX.Element
A DOM canvas which accepts threejs elements as children.
Canvas> <const Suspense: ExoticComponent<SuspenseProps>
Lets you display a fallback until its children have finished loading.
Suspense SuspenseProps.fallback?: ReactNode
A fallback react tree to show when a Suspense child (like React.lazy) suspends
fallback={null}> <const SteamAudio: (props: SteamAudioProps) => import("react").JSX.Element
SteamAudio audioContext: AudioContext
audioContext={const audioContext: AudioContext
audioContext}> <const SteamAudioListener: ({ object }: SteamAudioListenerProps) => null
SteamAudioListener /> <const SteamAudioSource: { ({ airAbsorption, destination, directivity, hrtf, input, occlusion, onReady, ref, reflections, reflectionSend, reverbSend, settings, spatialBlend, transmission, ...groupProps }: SteamAudioSourceProps): import("react").JSX.Element; displayName: string;}
SteamAudioSource SteamAudioSourceProps.input?: AudioNode | null | undefined
input={const input: AudioNode
input} SteamAudioSourceProps.hrtf?: boolean | undefined
hrtf SteamAudioSourceProps.airAbsorption?: boolean | undefined
airAbsorption SteamAudioSourceProps.occlusion?: false | "raycast" | "volumetric" | undefined
occlusion="raycast" SteamAudioSourceProps.transmission?: boolean | "frequency-dependent" | "frequency-independent" | undefined
transmission="frequency-dependent" position?: number | Vector3 | [x: number, y: number, z: number] | readonly [x: number, y: number, z: number] | Readonly<Vector3> | undefined
Object's local position.
position={[0, 1, -2]} /> </const SteamAudio: (props: SteamAudioProps) => import("react").JSX.Element
SteamAudio> </const Suspense: ExoticComponent<SuspenseProps>
Lets you display a fallback until its children have finished loading.
Suspense> </function Canvas(props: CanvasProps): import("react").JSX.Element
A DOM canvas which accepts threejs elements as children.
Canvas> )}Sources are created with an upper bound set by world.maxSources. Creating more sources than the world allows throws a SteamAudioError.
Updating transform
Section titled “Updating transform”The simulator needs the source position and orientation every frame. Three Steam Audio uses the same right-handed, Y-up coordinate system as Three.js.
import { const createWorld: (options: WorldOptions) => Promise<World>
createWorld } from 'three-steam-audio'import { class Vector3
Vector3, class Quaternion
Implementation of a quaternion. This is used for rotating things without incurring in the dreaded gimbal lock issue, amongst other advantages.
Quaternion } from 'three'
const const world: World
world = await function createWorld(options: WorldOptions): Promise<World>
createWorld({ WorldOptions.audioContext: AudioContext
audioContext: new var AudioContext: new (contextOptions?: AudioContextOptions) => AudioContext
The AudioContext interface represents an audio-processing graph built from audio modules linked together, each represented by an AudioNode.
AudioContext() })const const source: Source
source = const world: World
world.function createSource(settings?: SourceSettings): Source
createSource()
const source: Source
source.Source.setPosition: (position: Vector3Like) => void
setPosition(const object: { position: Vector3; quaternion: Quaternion;}
object.position: Vector3
position)const source: Source
source.Source.setOrientation: (orientation: QuaternionLike) => void
setOrientation(const object: { position: Vector3; quaternion: Quaternion;}
object.quaternion: Quaternion
quaternion)
// Or both at once:const source: Source
source.Source.setTransform: (position: Vector3Like, orientation: QuaternionLike) => void
setTransform(const object: { position: Vector3; quaternion: Quaternion;}
object.position: Vector3
position, const object: { position: Vector3; quaternion: Quaternion;}
object.quaternion: Quaternion
quaternion)import { const SteamAudioSource: { ({ airAbsorption, destination, directivity, hrtf, input, occlusion, onReady, ref, reflections, reflectionSend, reverbSend, settings, spatialBlend, transmission, ...groupProps }: SteamAudioSourceProps): import("react").JSX.Element; displayName: string;}
SteamAudioSource } from 'three-steam-audio/react'
<const SteamAudioSource: { ({ airAbsorption, destination, directivity, hrtf, input, occlusion, onReady, ref, reflections, reflectionSend, reverbSend, settings, spatialBlend, transmission, ...groupProps }: SteamAudioSourceProps): import("react").JSX.Element; displayName: string;}
SteamAudioSource SteamAudioSourceProps.input?: AudioNode | null | undefined
input={const input: AudioNode
input} position?: number | Vector3 | [x: number, y: number, z: number] | readonly [x: number, y: number, z: number] | Readonly<Vector3> | undefined
Object's local position.
position={[0, 1, -2]} rotation?: number | Euler | [x: number, y: number, z: number, order?: EulerOrder | undefined] | readonly [x: number, y: number, z: number, order?: EulerOrder | undefined] | Readonly<Euler> | undefined
rotation={[0, var Math: Math
An intrinsic object that provides basic mathematics functionality and constants.
Math.Math.PI: number
Pi. This is the ratio of the circumference of a circle to its diameter.
PI / 2, 0]}/>Direct simulation settings
Section titled “Direct simulation settings”Direct simulation covers everything that happens along the straight line from source to listener:
Distance attenuation
Section titled “Distance attenuation”By default, a physics-based inverse-distance model is used. You can disable it, tune the minimum distance, or provide a custom curve:
import { const createWorld: (options: WorldOptions) => Promise<World>
createWorld } from 'three-steam-audio'
const const world: World
world = await function createWorld(options: WorldOptions): Promise<World>
createWorld({ WorldOptions.audioContext: AudioContext
audioContext: new var AudioContext: new (contextOptions?: AudioContextOptions) => AudioContext
The AudioContext interface represents an audio-processing graph built from audio modules linked together, each represented by an AudioNode.
AudioContext() })const const source: Source
source = const world: World
world.function createSource(settings?: SourceSettings): Source
createSource()
// Inverse distance, custom minimum distance.const source: Source
source.Source.setSettings: (settings: Partial<SourceSettings>) => void
setSettings({ distanceAttenuation?: false | DistanceAttenuationSettings | undefined
distanceAttenuation: { model: "inverse"
model: 'inverse', minDistance?: number | undefined
minDistance: 1 },})
// Custom curve.const source: Source
source.Source.setSettings: (settings: Partial<SourceSettings>) => void
setSettings({ distanceAttenuation?: false | DistanceAttenuationSettings | undefined
distanceAttenuation: { model: "curve"
model: 'curve', minDistance: number
minDistance: 1, maxDistance: number
maxDistance: 18, curve: (distance: number) => number
curve: distance: number
distance => var Math: Math
An intrinsic object that provides basic mathematics functionality and constants.
Math.Math.max(...values: number[]): number
Returns the larger of a set of supplied numeric expressions.
max(0, 1 - distance: number
distance / 18) ** 1.5, },})
// Disable entirely.const source: Source
source.Source.setSettings: (settings: Partial<SourceSettings>) => void
setSettings({ distanceAttenuation?: false | DistanceAttenuationSettings | undefined
distanceAttenuation: false })import { const SteamAudioSource: { ({ airAbsorption, destination, directivity, hrtf, input, occlusion, onReady, ref, reflections, reflectionSend, reverbSend, settings, spatialBlend, transmission, ...groupProps }: SteamAudioSourceProps): import("react").JSX.Element; displayName: string;}
SteamAudioSource } from 'three-steam-audio/react'
<const SteamAudioSource: { ({ airAbsorption, destination, directivity, hrtf, input, occlusion, onReady, ref, reflections, reflectionSend, reverbSend, settings, spatialBlend, transmission, ...groupProps }: SteamAudioSourceProps): import("react").JSX.Element; displayName: string;}
SteamAudioSource SteamAudioSourceProps.input?: AudioNode | null | undefined
input={const input: AudioNode
input} SteamAudioSourceProps.settings?: SourceSettings | undefined
settings={{ SourceSettings.distanceAttenuation?: false | DistanceAttenuationSettings | undefined
distanceAttenuation: { model: "curve"
model: 'curve', minDistance: number
minDistance: 1, maxDistance: number
maxDistance: 18, curve: (distance: number) => number
curve: distance: number
distance => var Math: Math
An intrinsic object that provides basic mathematics functionality and constants.
Math.Math.max(...values: number[]): number
Returns the larger of a set of supplied numeric expressions.
max(0, 1 - distance: number
distance / 18) ** 1.5, }, }}/>Air absorption
Section titled “Air absorption”Air absorption models how high frequencies attenuate faster than low frequencies over distance. Enable the default physics-based model or supply your own coefficients or curves.
import { const createWorld: (options: WorldOptions) => Promise<World>
createWorld } from 'three-steam-audio'
const const world: World
world = await function createWorld(options: WorldOptions): Promise<World>
createWorld({ WorldOptions.audioContext: AudioContext
audioContext: new var AudioContext: new (contextOptions?: AudioContextOptions) => AudioContext
The AudioContext interface represents an audio-processing graph built from audio modules linked together, each represented by an AudioNode.
AudioContext() })const const source: Source
source = const world: World
world.function createSource(settings?: SourceSettings): Source
createSource()
const source: Source
source.Source.setSettings: (settings: Partial<SourceSettings>) => void
setSettings({ directSimulation?: boolean | DirectSimulationSettings | undefined
directSimulation: { DirectSimulationSettings.airAbsorption?: boolean | undefined
airAbsorption: true, DirectSimulationSettings.airAbsorptionModel?: AirAbsorptionSettings | undefined
airAbsorptionModel: { model?: "default" | undefined
model: 'default' }, },})import { const SteamAudioSource: { ({ airAbsorption, destination, directivity, hrtf, input, occlusion, onReady, ref, reflections, reflectionSend, reverbSend, settings, spatialBlend, transmission, ...groupProps }: SteamAudioSourceProps): import("react").JSX.Element; displayName: string;}
SteamAudioSource } from 'three-steam-audio/react'
<const SteamAudioSource: { ({ airAbsorption, destination, directivity, hrtf, input, occlusion, onReady, ref, reflections, reflectionSend, reverbSend, settings, spatialBlend, transmission, ...groupProps }: SteamAudioSourceProps): import("react").JSX.Element; displayName: string;}
SteamAudioSource SteamAudioSourceProps.input?: AudioNode | null | undefined
input={const input: AudioNode
input} SteamAudioSourceProps.airAbsorption?: boolean | undefined
airAbsorption />Directivity
Section titled “Directivity”A source can emit sound with a directional pattern. Three Steam Audio supports a weighted dipole pattern controlled by dipoleWeight and dipolePower.
import { const createWorld: (options: WorldOptions) => Promise<World>
createWorld } from 'three-steam-audio'
const const world: World
world = await function createWorld(options: WorldOptions): Promise<World>
createWorld({ WorldOptions.audioContext: AudioContext
audioContext: new var AudioContext: new (contextOptions?: AudioContextOptions) => AudioContext
The AudioContext interface represents an audio-processing graph built from audio modules linked together, each represented by an AudioNode.
AudioContext() })const const source: Source
source = const world: World
world.function createSource(settings?: SourceSettings): Source
createSource()
const source: Source
source.Source.setSettings: (settings: Partial<SourceSettings>) => void
setSettings({ directivity?: { dipolePower?: number; dipoleWeight?: number;} | undefined
directivity: { dipoleWeight?: number | undefined
dipoleWeight: 0.5, dipolePower?: number | undefined
dipolePower: 2, },})import { const SteamAudioSource: { ({ airAbsorption, destination, directivity, hrtf, input, occlusion, onReady, ref, reflections, reflectionSend, reverbSend, settings, spatialBlend, transmission, ...groupProps }: SteamAudioSourceProps): import("react").JSX.Element; displayName: string;}
SteamAudioSource } from 'three-steam-audio/react'
<const SteamAudioSource: { ({ airAbsorption, destination, directivity, hrtf, input, occlusion, onReady, ref, reflections, reflectionSend, reverbSend, settings, spatialBlend, transmission, ...groupProps }: SteamAudioSourceProps): import("react").JSX.Element; displayName: string;}
SteamAudioSource SteamAudioSourceProps.input?: AudioNode | null | undefined
input={const input: AudioNode
input} SteamAudioSourceProps.directivity?: { dipolePower?: number; dipoleWeight?: number;} | undefined
directivity={{ dipoleWeight?: number | undefined
dipoleWeight: 0.5, dipolePower?: number | undefined
dipolePower: 2 }}/>Occlusion and transmission
Section titled “Occlusion and transmission”Occlusion traces rays from listener to source to determine how much of the source is visible. Transmission applies a material-dependent filter to the occluded portion of the sound.
import { const createWorld: (options: WorldOptions) => Promise<World>
createWorld } from 'three-steam-audio'
const const world: World
world = await function createWorld(options: WorldOptions): Promise<World>
createWorld({ WorldOptions.audioContext: AudioContext
audioContext: new var AudioContext: new (contextOptions?: AudioContextOptions) => AudioContext
The AudioContext interface represents an audio-processing graph built from audio modules linked together, each represented by an AudioNode.
AudioContext() })const const source: Source
source = const world: World
world.function createSource(settings?: SourceSettings): Source
createSource()
const source: Source
source.Source.setSettings: (settings: Partial<SourceSettings>) => void
setSettings({ directSimulation?: boolean | DirectSimulationSettings | undefined
directSimulation: { DirectSimulationSettings.occlusion?: false | "raycast" | "volumetric" | undefined
occlusion: 'raycast', // Or volumetric occlusion: // occlusion: 'volumetric', // occlusionRadius: 1, // occlusionSamples: 16, DirectSimulationSettings.transmission?: false | { type?: "frequency-dependent" | "frequency-independent";} | undefined
transmission: { type?: "frequency-dependent" | "frequency-independent" | undefined
type: 'frequency-dependent' }, },})import { const SteamAudioSource: { ({ airAbsorption, destination, directivity, hrtf, input, occlusion, onReady, ref, reflections, reflectionSend, reverbSend, settings, spatialBlend, transmission, ...groupProps }: SteamAudioSourceProps): import("react").JSX.Element; displayName: string;}
SteamAudioSource } from 'three-steam-audio/react'
<const SteamAudioSource: { ({ airAbsorption, destination, directivity, hrtf, input, occlusion, onReady, ref, reflections, reflectionSend, reverbSend, settings, spatialBlend, transmission, ...groupProps }: SteamAudioSourceProps): import("react").JSX.Element; displayName: string;}
SteamAudioSource SteamAudioSourceProps.input?: AudioNode | null | undefined
input={const input: AudioNode
input} SteamAudioSourceProps.occlusion?: false | "raycast" | "volumetric" | undefined
occlusion="raycast" SteamAudioSourceProps.transmission?: boolean | "frequency-dependent" | "frequency-independent" | undefined
transmission="frequency-dependent"/>Spatial blend
Section titled “Spatial blend”Blend between fully spatialized (HRTF) and unspatialized audio. A value of 1 is fully spatialized; 0 is unspatialized.
import { const createWorld: (options: WorldOptions) => Promise<World>
createWorld } from 'three-steam-audio'
const const world: World
world = await function createWorld(options: WorldOptions): Promise<World>
createWorld({ WorldOptions.audioContext: AudioContext
audioContext: new var AudioContext: new (contextOptions?: AudioContextOptions) => AudioContext
The AudioContext interface represents an audio-processing graph built from audio modules linked together, each represented by an AudioNode.
AudioContext() })const const source: Source
source = const world: World
world.function createSource(settings?: SourceSettings): Source
createSource()
const source: Source
source.Source.setSettings: (settings: Partial<SourceSettings>) => void
setSettings({ spatialBlend?: number | undefined
spatialBlend: 0.75 })import { const SteamAudioSource: { ({ airAbsorption, destination, directivity, hrtf, input, occlusion, onReady, ref, reflections, reflectionSend, reverbSend, settings, spatialBlend, transmission, ...groupProps }: SteamAudioSourceProps): import("react").JSX.Element; displayName: string;}
SteamAudioSource } from 'three-steam-audio/react'
<const SteamAudioSource: { ({ airAbsorption, destination, directivity, hrtf, input, occlusion, onReady, ref, reflections, reflectionSend, reverbSend, settings, spatialBlend, transmission, ...groupProps }: SteamAudioSourceProps): import("react").JSX.Element; displayName: string;}
SteamAudioSource SteamAudioSourceProps.input?: AudioNode | null | undefined
input={const input: AudioNode
input} SteamAudioSourceProps.spatialBlend?: number | undefined
spatialBlend={0.75} />Reading simulation outputs
Section titled “Reading simulation outputs”You can read the latest direct simulation results from a source. This is useful for debugging, UI meters, or driving visual effects.
import { const createWorld: (options: WorldOptions) => Promise<World>
createWorld } from 'three-steam-audio'
const const world: World
world = await function createWorld(options: WorldOptions): Promise<World>
createWorld({ WorldOptions.audioContext: AudioContext
audioContext: new var AudioContext: new (contextOptions?: AudioContextOptions) => AudioContext
The AudioContext interface represents an audio-processing graph built from audio modules linked together, each represented by an AudioNode.
AudioContext() })const const source: Source
source = const world: World
world.function createSource(settings?: SourceSettings): Source
createSource()
const const outputs: DirectOutputs
outputs = const source: Source
source.Source.getDirectOutputs: (target?: DirectOutputs) => DirectOutputs
getDirectOutputs()
var console: Console
console.Console.log(...data: any[]): void
The console.log() static method outputs a message to the console.
log(const outputs: DirectOutputs
outputs.DirectOutputs.distanceAttenuation: number
distanceAttenuation)var console: Console
console.Console.log(...data: any[]): void
The console.log() static method outputs a message to the console.
log(const outputs: DirectOutputs
outputs.DirectOutputs.airAbsorption: [number, number, number]
airAbsorption) // [low, mid, high]var console: Console
console.Console.log(...data: any[]): void
The console.log() static method outputs a message to the console.
log(const outputs: DirectOutputs
outputs.DirectOutputs.occlusion: number
occlusion)var console: Console
console.Console.log(...data: any[]): void
The console.log() static method outputs a message to the console.
log(const outputs: DirectOutputs
outputs.DirectOutputs.transmission: [number, number, number]
transmission) // [low, mid, high]var console: Console
console.Console.log(...data: any[]): void
The console.log() static method outputs a message to the console.
log(const outputs: DirectOutputs
outputs.DirectOutputs.directivity: number
directivity)import { function useRef<T>(initialValue: T): RefObject<T> (+2 overloads)
useRef returns a mutable ref object whose .current property is initialized to the passed argument
(initialValue). The returned object will persist for the full lifetime of the component.
Note that useRef() is useful for more than the ref attribute. It’s handy for keeping any mutable
value around similar to how you’d use instance fields in classes.
useRef } from 'react'import { function useFrame(callback: RenderCallback, renderPriority?: number): null
Executes a callback before render in a shared frame loop.
Can order effects with render priority or manually render with a positive priority.
useFrame } from '@react-three/fiber'import { const useSteamAudioSource: (object: RefObject<null | Object3D>, settings?: SourceSettings) => { node: SteamAudioNode; source: Source;}
useSteamAudioSource } from 'three-steam-audio/react'import type { class Object3D<TEventMap extends Object3DEventMap = Object3DEventMap>interface Object3D<TEventMap extends Object3DEventMap = Object3DEventMap>
This is the base class for most objects in three.js and provides a set of properties and methods for manipulating objects in 3D space.
Object3D } from 'three'
export const const Metrics: () => null
Metrics = () => { const const meshRef: RefObject<Object3D<Object3DEventMap> | null>
meshRef = useRef<Object3D<Object3DEventMap>>(initialValue: Object3D<Object3DEventMap> | null): RefObject<Object3D<Object3DEventMap> | null> (+2 overloads)
useRef returns a mutable ref object whose .current property is initialized to the passed argument
(initialValue). The returned object will persist for the full lifetime of the component.
Note that useRef() is useful for more than the ref attribute. It’s handy for keeping any mutable
value around similar to how you’d use instance fields in classes.
useRef<class Object3D<TEventMap extends Object3DEventMap = Object3DEventMap>interface Object3D<TEventMap extends Object3DEventMap = Object3DEventMap>
This is the base class for most objects in three.js and provides a set of properties and methods for manipulating objects in 3D space.
Object3D>(null) const { const source: Source
source } = function useSteamAudioSource(object: RefObject<null | Object3D>, settings?: SourceSettings): { node: SteamAudioNode; source: Source;}
useSteamAudioSource(const meshRef: RefObject<Object3D<Object3DEventMap> | null>
meshRef)
function useFrame(callback: RenderCallback, renderPriority?: number): null
Executes a callback before render in a shared frame loop.
Can order effects with render priority or manually render with a positive priority.
useFrame(() => { const const outputs: DirectOutputs
outputs = const source: Source
source.Source.getDirectOutputs: (target?: DirectOutputs) => DirectOutputs
getDirectOutputs() var console: Console
console.Console.log(...data: any[]): void
The console.log() static method outputs a message to the console.
log(const outputs: DirectOutputs
outputs.DirectOutputs.occlusion: number
occlusion) })
return null}Disposing a source
Section titled “Disposing a source”import { const createWorld: (options: WorldOptions) => Promise<World>
createWorld } from 'three-steam-audio'
const const world: World
world = await function createWorld(options: WorldOptions): Promise<World>
createWorld({ WorldOptions.audioContext: AudioContext
audioContext: new var AudioContext: new (contextOptions?: AudioContextOptions) => AudioContext
The AudioContext interface represents an audio-processing graph built from audio modules linked together, each represented by an AudioNode.
AudioContext() })const const source: Source
source = const world: World
world.function createSource(settings?: SourceSettings): Source
createSource()const const node: SteamAudioNode
node = const world: World
world.function createNode(sourceValue: Source): SteamAudioNode
createNode(const source: Source
source)
const node: SteamAudioNode
node.SteamAudioNode.dispose(): void
dispose() // disconnects the audio nodeconst source: Source
source.Source.dispose: () => void
dispose() // releases the source// <SteamAudioSource> disposes its source and node automatically// when it unmounts.