How to use the PositionalAudio function from three

Find comprehensive JavaScript three.PositionalAudio code examples handpicked from public code repositorys.

10
11
12
13
14
15
16
17
18

this.id = id;

this.isPositional = isPositional;
if (this.isPositional) {
  this.sound = new THREE.PositionalAudio(State.get('listener'));
} else {
  this.sound = new THREE.Audio(State.get('listener'));
}
fork icon10
star icon33
watch icon10

62
63
64
65
66
67
68
69
70
71
    callback(this.loadedSounds.get(label));
    return;
}
this.audioLoader.load(this.basePath + fileName, (buffer) => {
    // load a sound and set it as the Audio object's buffer
    const sound = new THREE.PositionalAudio(this.listener);
    sound.setBuffer(buffer);
    sound.setRefDistance(20);
    sound.setVolume(0.09);
    this.loadedSounds.set(label, sound);
fork icon0
star icon2
watch icon0

54
55
56
57
58
59
60
61
62
63
if (!path) return;

// get from cache if available to prevent eccessive audio loading

if (G.get('cache').audio[path]) {
    this.sounds[num] = new THREE.PositionalAudio(G.get('listener'));
    this.sounds[num].setBuffer(G.get('cache').audio[path]);
    this.sounds[num].setRefDistance(30);
    if (this.mesh) this.mesh.add(this.sounds[num]);
    this.sounds[num].onEnded(() => this.sounds[num].stop());
fork icon0
star icon0
watch icon0

+ 3 other calls in file

72
73
74
75
76
77
78
79
80
81
82
83
}


function clone(sound, mesh){


    if(!mesh.hasSoundAttached){
        let chime = new THREE.PositionalAudio(listener);
        audioLoader.load(sound, (buffer)=>{
        chime.setBuffer(buffer);
        chime.setRefDistance(.3);
        chime.setLoop(false);
fork icon0
star icon0
watch icon0

Other functions in three

Sorted by popularity

function icon

three.Vector3 is the most popular function in three (22341 examples)