munshkr / threejs-3d-sound-sandbox

ThreeJS example of 3D sound simulation using PositionalAudio and extra filters

Home Page:https://munshkr.github.io/threejs-3d-sound-sandbox/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

threejs-3d-sound-sandbox

See Demo

Testing filters on a ThreeJS PositionalAudio object (WebAudio Panner wrapper), to get a richer 3D sound simulation.

For now, there is a Low shelf filter implemented with the BiquadFilterNode, that changes its frequency dynamically based on the camera and mesh distance. By default, the distance model used is the same as the one set to the Panner/PositionalAudio object (either "linear", "inverse" or "exponential").

Usage

See jsm/PositionalAudioFilter.js for the actual class that implements the filters.

To use:

const camera = new THREE.PerspectiveCamera(...);
const listener = new THREE.AudioListener();
camera.add(listener);

...

const sound = new THREE.PositionalAudio(listener);
const filter = new PositionalAudioFilter(sound);

filter.connect();

Then, when the camera moves, you should call filter.update(), to update frequency based on distance.

Attributions

This example was based on the ThreeJS WebAudio sandbox example.

License

See LICENSE.

About

ThreeJS example of 3D sound simulation using PositionalAudio and extra filters

https://munshkr.github.io/threejs-3d-sound-sandbox/

License:MIT License


Languages

Language:JavaScript 99.3%Language:HTML 0.6%Language:CSS 0.1%