How to use the AudioLoader function from three

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

4
5
6
7
8
9
10
11
12
13
var THREE = require('three');

var settings = require('../../settings');

function AudioManager (id, isPositional, owner, loop, playOnStart) {
  var audioLoader = new THREE.AudioLoader();

  this.id = id;

  this.isPositional = isPositional;
fork icon10
star icon33
watch icon10

88
89
90
91
92
93
94
95
96
97
{  
  listener = new THREE.AudioListener();
  var audLoad = new THREE.Audio(listener);
  visElements.sound = audLoad;

  audioLoader = new THREE.AudioLoader();

  var mVal = music[index];
  visElements.playTime = songLen[index];
  updateDisplayTime();
fork icon16
star icon0
watch icon2

26
27
28
29
30
31
32
33
34
35
const core_1 = require("@cuboid3/core");
class AudioManager {
    constructor() {
        this.basePath = '/public/audio/';
        this.listener = new THREE.AudioListener();
        this.audioLoader = new THREE.AudioLoader();
        this.loadedSounds = new Map();
        core_1.EventHandler.subscribe('attachAudioListener', (mesh) => {
            mesh.add(this.listener);
        });
fork icon0
star icon2
watch icon0

17
18
19
20
21
22
23
24
25
26
27


let assets = new Assets();
assets.load([{
    key: 'audio-boing',
    url: './static/boing.mp3',
    loader: THREE.AudioLoader
  }, {
    key: 'tex-id',
    // url: './id.png',
    url: './static/id.png',
fork icon1
star icon1
watch icon0

133
134
135
136
137
138
139
140
141
142
this.linstener = new Three.AudioListener();
this.linstener1 = new Three.AudioListener();
this.sound = new Three.Audio(this.linstener);
this.sendSound = new Three.Audio(this.linstener1); // 创建音频加载器

var audioLoader = new Three.AudioLoader();
audioLoader.load("./assets/audio/pow".concat(Math.floor(Math.random() * 4) + 1, ".ogg"), function (buffer) {
  _this.sound.setBuffer(buffer);

  _this.sound.setLoop(false);
fork icon0
star icon0
watch icon0

+ 3 other calls in file

10
11
12
13
14
15
16
17
18
19
// create a global audio source
const sound = new THREE.Audio( listener );
const state = {isReady: false}

// load a sound and set it as the Audio object's buffer
const audioLoader = new THREE.AudioLoader();

audioLoader.load( fname, function( buffer ) {
  sound.setBuffer( buffer );
  //sound.setLoop( true );
fork icon0
star icon0
watch icon0

61
62
63
64
65
66
67
68
69
70
    this.sounds[num].setRefDistance(30);
    if (this.mesh) this.mesh.add(this.sounds[num]);
    this.sounds[num].onEnded(() => this.sounds[num].stop());
}
else {
    let audioLoader = new THREE.AudioLoader();
    audioLoader.load(`/assets/sfx/${path}`, (buffer) => {
        G.get('cache').audio[path] = buffer;
        this.sounds[num] = new THREE.PositionalAudio(G.get('listener'));
        this.sounds[num].setBuffer(buffer);
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)