work in progress [might break]
This commit is contained in:
parent
e52dd993dc
commit
418a4b41ce
2 changed files with 3231 additions and 3214 deletions
File diff suppressed because one or more lines are too long
|
|
@ -14,17 +14,25 @@ let loadAudio = (mimetype) => function(url,opts){
|
|||
/* WebAudio: setup context via THREEjs */
|
||||
if( !camera.listener ){
|
||||
camera.listener = new THREE.AudioListener();
|
||||
camera.add( camera.listener );
|
||||
camera.getCam().add( camera.listener );
|
||||
}
|
||||
|
||||
let listener = camera.listener
|
||||
let isPositionalAudio = !(mesh.position.x == 0 && mesh.position.y == 0 && mesh.position.z == 0)
|
||||
const audioLoader = new THREE.AudioLoader();
|
||||
let sound = isPositionalAudio ? new THREE.PositionalAudio(listener) : new THREE.Audio(listener)
|
||||
let sound = isPositionalAudio ? new THREE.PositionalAudio( camera.listener)
|
||||
: new THREE.Audio( camera.listener )
|
||||
|
||||
audioLoader.load( url.replace(/#.*/,''), function( buffer ) {
|
||||
|
||||
sound.setBuffer( buffer );
|
||||
sound.setLoop(false);
|
||||
sound.setVolume(1.0);
|
||||
if( isPositionalAudio ){
|
||||
sound.setRefDistance( mesh.scale.x);
|
||||
sound.setRolloffFactor(5.0)
|
||||
sound.setDirectionalCone( 360, 360, 1 );
|
||||
}
|
||||
|
||||
sound.playXRF = (t) => {
|
||||
|
||||
if( sound.isPlaying && t.y != undefined ) sound.stop()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue