提交 246be612 编写于 作者: M Mr.doob

*Audio: Implemented Object.assign(). See #8838.

上级 c4476ed5
......@@ -28,218 +28,221 @@ THREE.Audio = function ( listener ) {
};
THREE.Audio.prototype = Object.create( THREE.Object3D.prototype );
THREE.Audio.prototype.constructor = THREE.Audio;
THREE.Audio.prototype = Object.assign( Object.create( THREE.Object3D.prototype ), {
THREE.Audio.prototype.getOutput = function () {
constructor: THREE.Audio,
return this.gain;
getOutput: function () {
};
return this.gain;
THREE.Audio.prototype.setNodeSource = function ( audioNode ) {
},
this.hasPlaybackControl = false;
this.sourceType = 'audioNode';
this.source = audioNode;
this.connect();
setNodeSource: function ( audioNode ) {
return this;
this.hasPlaybackControl = false;
this.sourceType = 'audioNode';
this.source = audioNode;
this.connect();
};
return this;
THREE.Audio.prototype.setBuffer = function ( audioBuffer ) {
},
var scope = this;
setBuffer: function ( audioBuffer ) {
scope.source.buffer = audioBuffer;
scope.sourceType = 'buffer';
if ( scope.autoplay ) scope.play();
var scope = this;
return this;
scope.source.buffer = audioBuffer;
scope.sourceType = 'buffer';
if ( scope.autoplay ) scope.play();
};
return this;
THREE.Audio.prototype.play = function () {
},
if ( this.isPlaying === true ) {
play: function () {
console.warn( 'THREE.Audio: Audio is already playing.' );
return;
if ( this.isPlaying === true ) {
}
console.warn( 'THREE.Audio: Audio is already playing.' );
return;
if ( this.hasPlaybackControl === false ) {
}
console.warn( 'THREE.Audio: this Audio has no playback control.' );
return;
if ( this.hasPlaybackControl === false ) {
}
console.warn( 'THREE.Audio: this Audio has no playback control.' );
return;
var source = this.context.createBufferSource();
}
source.buffer = this.source.buffer;
source.loop = this.source.loop;
source.onended = this.source.onended;
source.start( 0, this.startTime );
source.playbackRate.value = this.playbackRate;
var source = this.context.createBufferSource();
this.isPlaying = true;
source.buffer = this.source.buffer;
source.loop = this.source.loop;
source.onended = this.source.onended;
source.start( 0, this.startTime );
source.playbackRate.value = this.playbackRate;
this.source = source;
this.isPlaying = true;
this.connect();
this.source = source;
};
this.connect();
THREE.Audio.prototype.pause = function () {
},
if ( this.hasPlaybackControl === false ) {
pause: function () {
console.warn( 'THREE.Audio: this Audio has no playback control.' );
return;
if ( this.hasPlaybackControl === false ) {
}
console.warn( 'THREE.Audio: this Audio has no playback control.' );
return;
this.source.stop();
this.startTime = this.context.currentTime;
}
};
this.source.stop();
this.startTime = this.context.currentTime;
THREE.Audio.prototype.stop = function () {
},
if ( this.hasPlaybackControl === false ) {
stop: function () {
console.warn( 'THREE.Audio: this Audio has no playback control.' );
return;
if ( this.hasPlaybackControl === false ) {
}
console.warn( 'THREE.Audio: this Audio has no playback control.' );
return;
this.source.stop();
this.startTime = 0;
}
};
this.source.stop();
this.startTime = 0;
THREE.Audio.prototype.connect = function () {
},
if ( this.filter !== null ) {
connect: function () {
this.source.connect( this.filter );
this.filter.connect( this.getOutput() );
if ( this.filter !== null ) {
} else {
this.source.connect( this.filter );
this.filter.connect( this.getOutput() );
this.source.connect( this.getOutput() );
} else {
}
this.source.connect( this.getOutput() );
};
}
THREE.Audio.prototype.disconnect = function () {
},
if ( this.filter !== null ) {
disconnect: function () {
this.source.disconnect( this.filter );
this.filter.disconnect( this.getOutput() );
if ( this.filter !== null ) {
} else {
this.source.disconnect( this.filter );
this.filter.disconnect( this.getOutput() );
this.source.disconnect( this.getOutput() );
} else {
}
this.source.disconnect( this.getOutput() );
};
}
THREE.Audio.prototype.getFilter = function () {
},
return this.filter;
getFilter: function () {
};
return this.filter;
THREE.Audio.prototype.setFilter = function ( value ) {
},
if ( value === undefined ) value = null;
setFilter: function ( value ) {
if ( this.isPlaying === true ) {
if ( value === undefined ) value = null;
this.disconnect();
this.filter = value;
this.connect();
if ( this.isPlaying === true ) {
} else {
this.disconnect();
this.filter = value;
this.connect();
this.filter = value;
} else {
}
this.filter = value;
};
}
THREE.Audio.prototype.setPlaybackRate = function ( value ) {
},
if ( this.hasPlaybackControl === false ) {
setPlaybackRate: function ( value ) {
console.warn( 'THREE.Audio: this Audio has no playback control.' );
return;
if ( this.hasPlaybackControl === false ) {
}
console.warn( 'THREE.Audio: this Audio has no playback control.' );
return;
this.playbackRate = value;
}
if ( this.isPlaying === true ) {
this.playbackRate = value;
this.source.playbackRate.value = this.playbackRate;
if ( this.isPlaying === true ) {
}
this.source.playbackRate.value = this.playbackRate;
};
}
THREE.Audio.prototype.getPlaybackRate = function () {
},
return this.playbackRate;
getPlaybackRate: function () {
};
return this.playbackRate;
THREE.Audio.prototype.onEnded = function () {
},
this.isPlaying = false;
onEnded: function () {
};
this.isPlaying = false;
THREE.Audio.prototype.setLoop = function ( value ) {
},
if ( this.hasPlaybackControl === false ) {
getLoop: function () {
console.warn( 'THREE.Audio: this Audio has no playback control.' );
return;
if ( this.hasPlaybackControl === false ) {
}
console.warn( 'THREE.Audio: this Audio has no playback control.' );
return false;
this.source.loop = value;
}
};
return this.source.loop;
THREE.Audio.prototype.getLoop = function () {
},
if ( this.hasPlaybackControl === false ) {
setLoop: function ( value ) {
console.warn( 'THREE.Audio: this Audio has no playback control.' );
return false;
if ( this.hasPlaybackControl === false ) {
}
console.warn( 'THREE.Audio: this Audio has no playback control.' );
return;
return this.source.loop;
}
};
this.source.loop = value;
},
THREE.Audio.prototype.setVolume = function ( value ) {
getVolume: function () {
this.gain.gain.value = value;
return this.gain.gain.value;
};
},
THREE.Audio.prototype.getVolume = function () {
return this.gain.gain.value;
setVolume: function ( value ) {
};
this.gain.gain.value = value;
}
} );
......@@ -13,9 +13,7 @@ THREE.AudioAnalyser = function ( audio, fftSize ) {
};
THREE.AudioAnalyser.prototype = {
constructor: THREE.AudioAnalyser,
Object.assign( THREE.AudioAnalyser.prototype, {
getData: function () {
......@@ -24,4 +22,4 @@ THREE.AudioAnalyser.prototype = {
}
};
} );
......@@ -17,88 +17,90 @@ THREE.AudioListener = function () {
};
THREE.AudioListener.prototype = Object.create( THREE.Object3D.prototype );
THREE.AudioListener.prototype.constructor = THREE.AudioListener;
THREE.AudioListener.prototype = Object.assign( Object.create( THREE.Object3D.prototype ), {
THREE.AudioListener.prototype.getInput = function () {
constructor: THREE.AudioListener,
return this.gain;
getInput: function () {
};
return this.gain;
THREE.AudioListener.prototype.removeFilter = function ( ) {
},
if ( this.filter !== null ) {
removeFilter: function ( ) {
this.gain.disconnect( this.filter );
this.filter.disconnect( this.context.destination );
this.gain.connect( this.context.destination );
this.filter = null;
if ( this.filter !== null ) {
}
this.gain.disconnect( this.filter );
this.filter.disconnect( this.context.destination );
this.gain.connect( this.context.destination );
this.filter = null;
};
}
THREE.AudioListener.prototype.setFilter = function ( value ) {
},
if ( this.filter !== null ) {
getFilter: function () {
this.gain.disconnect( this.filter );
this.filter.disconnect( this.context.destination );
return this.filter;
} else {
},
this.gain.disconnect( this.context.destination );
setFilter: function ( value ) {
}
if ( this.filter !== null ) {
this.filter = value;
this.gain.connect( this.filter );
this.filter.connect( this.context.destination );
this.gain.disconnect( this.filter );
this.filter.disconnect( this.context.destination );
};
} else {
THREE.AudioListener.prototype.getFilter = function () {
this.gain.disconnect( this.context.destination );
return this.filter;
}
};
this.filter = value;
this.gain.connect( this.filter );
this.filter.connect( this.context.destination );
THREE.AudioListener.prototype.setMasterVolume = function ( value ) {
},
this.gain.gain.value = value;
getMasterVolume: function () {
};
return this.gain.gain.value;
THREE.AudioListener.prototype.getMasterVolume = function () {
},
return this.gain.gain.value;
setMasterVolume: function ( value ) {
};
this.gain.gain.value = value;
},
updateMatrixWorld: ( function () {
THREE.AudioListener.prototype.updateMatrixWorld = ( function () {
var position = new THREE.Vector3();
var quaternion = new THREE.Quaternion();
var scale = new THREE.Vector3();
var position = new THREE.Vector3();
var quaternion = new THREE.Quaternion();
var scale = new THREE.Vector3();
var orientation = new THREE.Vector3();
var orientation = new THREE.Vector3();
return function updateMatrixWorld( force ) {
return function updateMatrixWorld( force ) {
THREE.Object3D.prototype.updateMatrixWorld.call( this, force );
THREE.Object3D.prototype.updateMatrixWorld.call( this, force );
var listener = this.context.listener;
var up = this.up;
var listener = this.context.listener;
var up = this.up;
this.matrixWorld.decompose( position, quaternion, scale );
this.matrixWorld.decompose( position, quaternion, scale );
orientation.set( 0, 0, - 1 ).applyQuaternion( quaternion );
orientation.set( 0, 0, - 1 ).applyQuaternion( quaternion );
listener.setPosition( position.x, position.y, position.z );
listener.setOrientation( orientation.x, orientation.y, orientation.z, up.x, up.y, up.z );
listener.setPosition( position.x, position.y, position.z );
listener.setOrientation( orientation.x, orientation.y, orientation.z, up.x, up.y, up.z );
};
};
} )()
} )();
} );
......@@ -11,75 +11,79 @@ THREE.PositionalAudio = function ( listener ) {
};
THREE.PositionalAudio.prototype = Object.create( THREE.Audio.prototype );
THREE.PositionalAudio.prototype.constructor = THREE.PositionalAudio;
THREE.PositionalAudio.prototype = Object.assign( Object.create( THREE.Audio.prototype ), {
THREE.PositionalAudio.prototype.getOutput = function () {
constructor: THREE.PositionalAudio,
return this.panner;
getOutput: function () {
};
return this.panner;
THREE.PositionalAudio.prototype.setRefDistance = function ( value ) {
},
this.panner.refDistance = value;
getRefDistance: function () {
};
return this.panner.refDistance;
THREE.PositionalAudio.prototype.getRefDistance = function () {
},
return this.panner.refDistance;
setRefDistance: function ( value ) {
};
this.panner.refDistance = value;
THREE.PositionalAudio.prototype.setRolloffFactor = function ( value ) {
},
this.panner.rolloffFactor = value;
getRolloffFactor: function () {
};
return this.panner.rolloffFactor;
THREE.PositionalAudio.prototype.getRolloffFactor = function () {
},
return this.panner.rolloffFactor;
setRolloffFactor: function ( value ) {
};
this.panner.rolloffFactor = value;
THREE.PositionalAudio.prototype.setDistanceModel = function ( value ) {
},
this.panner.distanceModel = value;
getDistanceModel: function () {
};
return this.panner.distanceModel;
THREE.PositionalAudio.prototype.getDistanceModel = function () {
},
return this.panner.distanceModel;
setDistanceModel: function ( value ) {
};
this.panner.distanceModel = value;
THREE.PositionalAudio.prototype.setMaxDistance = function ( value ) {
},
this.panner.maxDistance = value;
getMaxDistance: function () {
};
return this.panner.maxDistance;
THREE.PositionalAudio.prototype.getMaxDistance = function () {
},
return this.panner.maxDistance;
setMaxDistance: function ( value ) {
};
this.panner.maxDistance = value;
},
updateMatrixWorld: ( function () {
var position = new THREE.Vector3();
THREE.PositionalAudio.prototype.updateMatrixWorld = ( function () {
return function updateMatrixWorld( force ) {
var position = new THREE.Vector3();
THREE.Object3D.prototype.updateMatrixWorld.call( this, force );
return function updateMatrixWorld( force ) {
position.setFromMatrixPosition( this.matrixWorld );
THREE.Object3D.prototype.updateMatrixWorld.call( this, force );
this.panner.setPosition( position.x, position.y, position.z );
position.setFromMatrixPosition( this.matrixWorld );
};
this.panner.setPosition( position.x, position.y, position.z );
} )()
};
} )();
} );
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册