Use the arrow keys to move around.
import sono from 'sono';
import 'sono/effects';
const sound = sono.create({
url: 'pulsar.mp3',
loop: true,
effects: [
sono.panner({
maxDistance: 1000
})
]
});
const mesh = new THREE.Mesh(geometry, material);
// set source position to the position vector of sound source
sound.effects[0].setPosition(mesh.position);
function update() {
window.requestAnimationFrame(update);
// set listener position to the position vector of the camera
sono.panner.setListenerPosition(camera.position);
// set listener orientation to the forward vector of the camera
const forward = new THREE.Vector3(0, 0, -1);
forward.applyQuaternion(camera.quaternion);
sono.panner.setListenerOrientation(forward.normalize());
}
update();