Browse Source

PositionalAudio: Convert to es6 class

Ian Purvis 5 years ago
parent
commit
148763aa12
1 changed files with 30 additions and 33 deletions
  1. 30 33
      src/audio/PositionalAudio.js

+ 30 - 33
src/audio/PositionalAudio.js

@@ -1,90 +1,87 @@
 import { Vector3 } from '../math/Vector3.js';
 import { Vector3 } from '../math/Vector3.js';
 import { Quaternion } from '../math/Quaternion.js';
 import { Quaternion } from '../math/Quaternion.js';
 import { Audio } from './Audio.js';
 import { Audio } from './Audio.js';
-import { Object3D } from '../core/Object3D.js';
 
 
 const _position = new Vector3();
 const _position = new Vector3();
 const _quaternion = new Quaternion();
 const _quaternion = new Quaternion();
 const _scale = new Vector3();
 const _scale = new Vector3();
 const _orientation = new Vector3();
 const _orientation = new Vector3();
 
 
-function PositionalAudio( listener ) {
+class PositionalAudio extends Audio {
 
 
-	Audio.call( this, listener );
+	constructor( listener ) {
 
 
-	this.panner = this.context.createPanner();
-	this.panner.panningModel = 'HRTF';
-	this.panner.connect( this.gain );
+		super( listener );
 
 
-}
-
-PositionalAudio.prototype = Object.assign( Object.create( Audio.prototype ), {
+		this.panner = this.context.createPanner();
+		this.panner.panningModel = 'HRTF';
+		this.panner.connect( this.gain );
 
 
-	constructor: PositionalAudio,
+	}
 
 
-	getOutput: function () {
+	getOutput() {
 
 
 		return this.panner;
 		return this.panner;
 
 
-	},
+	}
 
 
-	getRefDistance: function () {
+	getRefDistance() {
 
 
 		return this.panner.refDistance;
 		return this.panner.refDistance;
 
 
-	},
+	}
 
 
-	setRefDistance: function ( value ) {
+	setRefDistance( value ) {
 
 
 		this.panner.refDistance = value;
 		this.panner.refDistance = value;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	getRolloffFactor: function () {
+	getRolloffFactor() {
 
 
 		return this.panner.rolloffFactor;
 		return this.panner.rolloffFactor;
 
 
-	},
+	}
 
 
-	setRolloffFactor: function ( value ) {
+	setRolloffFactor( value ) {
 
 
 		this.panner.rolloffFactor = value;
 		this.panner.rolloffFactor = value;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	getDistanceModel: function () {
+	getDistanceModel() {
 
 
 		return this.panner.distanceModel;
 		return this.panner.distanceModel;
 
 
-	},
+	}
 
 
-	setDistanceModel: function ( value ) {
+	setDistanceModel( value ) {
 
 
 		this.panner.distanceModel = value;
 		this.panner.distanceModel = value;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	getMaxDistance: function () {
+	getMaxDistance() {
 
 
 		return this.panner.maxDistance;
 		return this.panner.maxDistance;
 
 
-	},
+	}
 
 
-	setMaxDistance: function ( value ) {
+	setMaxDistance( value ) {
 
 
 		this.panner.maxDistance = value;
 		this.panner.maxDistance = value;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setDirectionalCone: function ( coneInnerAngle, coneOuterAngle, coneOuterGain ) {
+	setDirectionalCone( coneInnerAngle, coneOuterAngle, coneOuterGain ) {
 
 
 		this.panner.coneInnerAngle = coneInnerAngle;
 		this.panner.coneInnerAngle = coneInnerAngle;
 		this.panner.coneOuterAngle = coneOuterAngle;
 		this.panner.coneOuterAngle = coneOuterAngle;
@@ -92,11 +89,11 @@ PositionalAudio.prototype = Object.assign( Object.create( Audio.prototype ), {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	updateMatrixWorld: function ( force ) {
+	updateMatrixWorld( force ) {
 
 
-		Object3D.prototype.updateMatrixWorld.call( this, force );
+		super.updateMatrixWorld( force );
 
 
 		if ( this.hasPlaybackControl === true && this.isPlaying === false ) return;
 		if ( this.hasPlaybackControl === true && this.isPlaying === false ) return;
 
 
@@ -128,6 +125,6 @@ PositionalAudio.prototype = Object.assign( Object.create( Audio.prototype ), {
 
 
 	}
 	}
 
 
-} );
+}
 
 
 export { PositionalAudio };
 export { PositionalAudio };