提交 bc80d200 编写于 作者: V vincent courtalon

cleaning up duplicate code in PositionalAudio and enabling the 'unsetting' of...

cleaning up duplicate code in PositionalAudio and enabling the 'unsetting' of a filter with setting a null filter
上级 e7f881b2
......@@ -22,12 +22,16 @@ THREE.Audio = function ( listener ) {
this.isPlaying = false;
this.hasPlaybackControl = true;
this.sourceType = 'empty';
this.filter = null;
};
THREE.Audio.prototype = Object.create( THREE.Object3D.prototype );
THREE.Audio.prototype.constructor = THREE.Audio;
THREE.Audio.prototype.getOutput = function() {
return this.gain;
};
THREE.Audio.prototype.load = function ( fileName ) {
......@@ -131,14 +135,14 @@ THREE.Audio.prototype.stop = function () {
THREE.Audio.prototype.connect = function () {
if ( this.filter !== undefined ) {
if ( this.filter != null ) {
this.source.connect( this.filter );
this.filter.connect( this.gain );
this.filter.connect( this.getOutput());
} else {
this.source.connect( this.gain );
this.source.connect( this.getOutput());
}
......@@ -146,14 +150,14 @@ THREE.Audio.prototype.connect = function () {
THREE.Audio.prototype.disconnect = function () {
if ( this.filter !== undefined ) {
if ( this.filter != null ) {
this.source.disconnect( this.filter );
this.filter.disconnect( this.gain );
this.filter.disconnect( this.getOutput());
} else {
this.source.disconnect( this.gain );
this.source.disconnect( this.getOutput());
}
......
......@@ -14,59 +14,10 @@ THREE.PositionalAudio = function ( listener ) {
THREE.PositionalAudio.prototype = Object.create( THREE.Audio.prototype );
THREE.PositionalAudio.prototype.constructor = THREE.PositionalAudio;
THREE.PositionalAudio.prototype.connect = function () {
if ( this.filter !== undefined ) {
this.source.connect( this.filter );
this.filter.connect( this.panner );
} else {
this.source.connect( this.panner );
}
THREE.PositionalAudio.prototype.getOutput = function() {
return this.panner;
};
THREE.PositionalAudio.prototype.disconnect = function () {
if ( this.filter !== undefined ) {
this.source.disconnect( this.filter );
this.filter.disconnect( this.panner );
} else {
this.source.disconnect( this.panner );
}
};
THREE.PositionalAudio.prototype.setFilter = function ( value ) {
if ( this.isPlaying === true ) {
this.disconnect();
this.filter = value;
this.connect();
} else {
this.filter = value;
}
};
THREE.PositionalAudio.prototype.getFilter = function () {
return this.filter;
};
THREE.PositionalAudio.prototype.setRefDistance = function ( value ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册