Sound
Audio events
Emit one event to play a configured sample, notify an AudioWorklet, or do both.
Configure an audio asset
Map a stable sound ID to a browser-readable audio file.
{
"assets": {
"audio": {
"impact": "/audio/impact.ogg"
}
}
}Play the sound
Push a play_audio event from simulation step code.
state.events.push({
type: "play_audio",
payload: {
id: "impact",
volume: 0.8,
position: [x, y, z],
maxDistance: 120
}
});Event payload
id- Sound identifier. It selects an audio asset and is forwarded to an AudioWorklet.
volume- Linear gain. Defaults to 1.
position- Optional world-space [x, y, z] position for distance attenuation and stereo pan.
maxDistance- Optional audible range for positioned sound. Defaults to 120.