| Server IP : 210.245.233.93 / Your IP : 216.73.216.226 Web Server : Apache/2.2.15 (CentOS) System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : apache ( 48) PHP Version : 5.3.3 Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/hkosl.com/3dweb/src/audio/ |
Upload File : |
/**
* @author mrdoob / http://mrdoob.com/
*/
import { Vector3 } from '../math/Vector3.js';
import { Quaternion } from '../math/Quaternion.js';
import { Audio } from './Audio.js';
import { Object3D } from '../core/Object3D.js';
var _position = new Vector3();
var _quaternion = new Quaternion();
var _scale = new Vector3();
var _orientation = new Vector3();
function PositionalAudio( listener ) {
Audio.call( this, listener );
this.panner = this.context.createPanner();
this.panner.panningModel = 'HRTF';
this.panner.connect( this.gain );
}
PositionalAudio.prototype = Object.assign( Object.create( Audio.prototype ), {
constructor: PositionalAudio,
getOutput: function () {
return this.panner;
},
getRefDistance: function () {
return this.panner.refDistance;
},
setRefDistance: function ( value ) {
this.panner.refDistance = value;
return this;
},
getRolloffFactor: function () {
return this.panner.rolloffFactor;
},
setRolloffFactor: function ( value ) {
this.panner.rolloffFactor = value;
return this;
},
getDistanceModel: function () {
return this.panner.distanceModel;
},
setDistanceModel: function ( value ) {
this.panner.distanceModel = value;
return this;
},
getMaxDistance: function () {
return this.panner.maxDistance;
},
setMaxDistance: function ( value ) {
this.panner.maxDistance = value;
return this;
},
setDirectionalCone: function ( coneInnerAngle, coneOuterAngle, coneOuterGain ) {
this.panner.coneInnerAngle = coneInnerAngle;
this.panner.coneOuterAngle = coneOuterAngle;
this.panner.coneOuterGain = coneOuterGain;
return this;
},
updateMatrixWorld: function ( force ) {
Object3D.prototype.updateMatrixWorld.call( this, force );
if ( this.hasPlaybackControl === true && this.isPlaying === false ) return;
this.matrixWorld.decompose( _position, _quaternion, _scale );
_orientation.set( 0, 0, 1 ).applyQuaternion( _quaternion );
var panner = this.panner;
if ( panner.positionX ) {
// code path for Chrome and Firefox (see #14393)
var endTime = this.context.currentTime + this.listener.timeDelta;
panner.positionX.linearRampToValueAtTime( _position.x, endTime );
panner.positionY.linearRampToValueAtTime( _position.y, endTime );
panner.positionZ.linearRampToValueAtTime( _position.z, endTime );
panner.orientationX.linearRampToValueAtTime( _orientation.x, endTime );
panner.orientationY.linearRampToValueAtTime( _orientation.y, endTime );
panner.orientationZ.linearRampToValueAtTime( _orientation.z, endTime );
} else {
panner.setPosition( _position.x, _position.y, _position.z );
panner.setOrientation( _orientation.x, _orientation.y, _orientation.z );
}
}
} );
export { PositionalAudio };