Przeglądaj źródła

Audio: Backwards compatibility.

Mr.doob 9 lat temu
rodzic
commit
438c7b1974
3 zmienionych plików z 24 dodań i 7 usunięć
  1. 13 0
      src/Three.Legacy.js
  2. 9 6
      src/audio/Audio.js
  3. 2 1
      src/audio/AudioListener.js

+ 13 - 0
src/Three.Legacy.js

@@ -2,6 +2,19 @@
  * @author mrdoob / http://mrdoob.com/
  */
 
+Object.defineProperties( THREE.Audio.prototype, {
+	setRefDistance: {
+		value: function () {
+			console.warn( 'THREE.Audio: .setRefDistance() has been moved to THREE.PositionalAudio.' );
+		}
+	},
+	setRolloffFactor: {
+		value: function () {
+			console.warn( 'THREE.Audio: .setRolloffFactor() has been moved to THREE.PositionalAudio.' );
+		}
+	}
+} );
+
 Object.defineProperties( THREE.Box2.prototype, {
 	isIntersectionBox: {
 		value: function ( box ) {

+ 9 - 6
src/audio/Audio.js

@@ -22,6 +22,7 @@ THREE.Audio = function ( listener ) {
 	this.isPlaying = false;
 	this.hasPlaybackControl = true;
 	this.sourceType = 'empty';
+
 	this.filter = null;
 
 };
@@ -161,8 +162,16 @@ THREE.Audio.prototype.disconnect = function () {
 
 };
 
+THREE.Audio.prototype.getFilter = function () {
+
+	return this.filter;
+
+};
+
 THREE.Audio.prototype.setFilter = function ( value ) {
 
+	if ( value === undefined ) value = null;
+
 	if ( this.isPlaying === true ) {
 
 		this.disconnect();
@@ -177,12 +186,6 @@ THREE.Audio.prototype.setFilter = function ( value ) {
 
 };
 
-THREE.Audio.prototype.getFilter = function () {
-
-	return this.filter;
-
-};
-
 THREE.Audio.prototype.setPlaybackRate = function ( value ) {
 
 	if ( this.hasPlaybackControl === false ) {

+ 2 - 1
src/audio/AudioListener.js

@@ -10,7 +10,8 @@ THREE.AudioListener = function () {
 
 	this.context = new ( window.AudioContext || window.webkitAudioContext )();
 	this.masterGain =  this.context.createGain();
-	this.masterGain.connect(this.context.destination);
+	this.masterGain.connect( this.context.destination );
+
 	this.filter = null;
 
 };