React Components
The three-steam-audio/react entry point provides declarative components for React Three Fiber.
<SteamAudio>
Section titled “<SteamAudio>”Provider that owns or receives a World. It runs world.step(delta) automatically each frame.
import { const SteamAudio: (props: SteamAudioProps) => import("react").JSX.Element
SteamAudio } from 'three-steam-audio/react'audioContext
: Required when creating an owned world. The AudioContext to use.
options
: Omit<WorldOptions, 'audioContext'> — options passed to createWorld.
world
: An existing World to use instead of creating one.
paused
: boolean — when true, world.step is not called. Default: false.
updatePriority
: number — R3F useFrame priority. Default: -100.
children
: React nodes rendered inside the provider.
useSteamAudio()
Section titled “useSteamAudio()”import { const useSteamAudio: () => SteamAudioContextValue
useSteamAudio } from 'three-steam-audio/react'
const { const listener: Listener
listener, const scene: AcousticSceneImpl
scene, const world: World
world } = function useSteamAudio(): SteamAudioContextValue
useSteamAudio()Returns the current world, listener, and scene. Must be called inside <SteamAudio>.
<SteamAudioListener>
Section titled “<SteamAudioListener>”Synchronizes the R3F camera (or a custom object) to world.listener.
object
: Optional ref to an Object3D to use as the listener transform. Defaults to the R3F camera.
<SteamAudioEnvironment>
Section titled “<SteamAudioEnvironment>”Creates optional reflection and reverb buses and wires them to a destination.
destination
: AudioNode | null — where buses are connected. Defaults to world.audioContext.destination.
reflections
: boolean | ReflectionBusSettings — enables and configures a reflection bus.
reverb
: false | (ReverbBusSettings & ReverbSettings) — enables and configures a reverb bus, and configures listener reverb.
children
: React nodes rendered inside the environment context.
useSteamAudioEnvironment()
Section titled “useSteamAudioEnvironment()”import { const useSteamAudioEnvironment: () => EnvironmentValue
useSteamAudioEnvironment } from 'three-steam-audio/react'
const { const reflectionBus: ReflectionBusNode | undefined
reflectionBus, const reverbBus: ReverbBusNode | undefined
reverbBus } = function useSteamAudioEnvironment(): EnvironmentValue
useSteamAudioEnvironment()Returns the buses created by the nearest <SteamAudioEnvironment>, if any.
<AcousticMesh>
Section titled “<AcousticMesh>”Wraps children meshes and registers them as acoustic geometry.
material
: AcousticMaterial | readonly AcousticMaterial[] | ((mesh: Mesh) => AcousticMaterial | readonly AcousticMaterial[]) — material or materials to apply.
dynamic
: boolean — registers meshes as dynamic geometry. Default: false.
All other props are forwarded to the inner <group>.
Does not support SkinnedMesh or morph targets.
<SteamAudioSource>
Section titled “<SteamAudioSource>”Declarative source component.
input
: AudioNode | null — the mono audio input.
destination
: AudioNode | null — where to connect the node’s main output.
hrtf
: boolean.
airAbsorption
: boolean.
occlusion
: 'raycast' | 'volumetric' | false.
transmission
: 'frequency-dependent' | 'frequency-independent' | boolean.
directivity
: { dipoleWeight?: number, dipolePower?: number }.
spatialBlend
: number.
reflections
: SourceSettings['reflections'].
reflectionSend
: number — gain to the environment reflection bus.
reverbSend
: number — gain to the environment reverb bus.
settings
: SourceSettings — full source settings object. Other props are merged into this object.
onReady
: (api: SteamAudioSourceApi) => void — called when the source group is mounted.
All other props are forwarded to the inner <group>.
useSteamAudioSource(object, settings?)
Section titled “useSteamAudioSource(object, settings?)”Lower-level hook that creates a source and node tied to an Object3D ref.
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 { 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'
const const objectRef: RefObject<Object3D<Object3DEventMap> | null>
objectRef = 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 node: SteamAudioNode
node, const source: Source
source } = function useSteamAudioSource(object: RefObject<null | Object3D>, settings?: SourceSettings): { node: SteamAudioNode; source: Source;}
useSteamAudioSource(const objectRef: RefObject<Object3D<Object3DEventMap> | null>
objectRef)SteamAudioSourceApi
Section titled “SteamAudioSourceApi”import type { class Group<TEventMap extends Object3DEventMap = Object3DEventMap>
Its purpose is to make working with groups of objects syntactically clearer.
Group } from 'three'import type { class SteamAudioNode
SteamAudioNode } from 'three-steam-audio'import type { (alias) interface Sourceimport Source
Source } from 'three-steam-audio'
interface interface SteamAudioSourceApi
SteamAudioSourceApi { SteamAudioSourceApi.group: Group<Object3DEventMap>
group: class Group<TEventMap extends Object3DEventMap = Object3DEventMap>
Its purpose is to make working with groups of objects syntactically clearer.
Group SteamAudioSourceApi.node: SteamAudioNode
node: class SteamAudioNode
SteamAudioNode SteamAudioSourceApi.source: Source
source: (alias) interface Sourceimport Source
Source}