Explorar o código

Prettified EventDispatcher API.

Mr.doob %!s(int64=12) %!d(string=hai) anos
pai
achega
32ca1d4740

+ 1 - 5
examples/js/loaders/MTLLoader.js

@@ -16,11 +16,6 @@ THREE.MTLLoader.prototype = {
 
 	constructor: THREE.MTLLoader,
 
-	addEventListener: THREE.EventDispatcher.prototype.addEventListener,
-	hasEventListener: THREE.EventDispatcher.prototype.hasEventListener,
-	removeEventListener: THREE.EventDispatcher.prototype.removeEventListener,
-	dispatchEvent: THREE.EventDispatcher.prototype.dispatchEvent,
-
 	/**
 	 * Loads a MTL file
 	 *
@@ -474,3 +469,4 @@ THREE.MTLLoader.nextHighestPowerOfTwo_ = function( x ) {
 
 };
 
+THREE.EventDispatcher.prototype.apply( THREE.MTLLoader.prototype );

+ 2 - 5
examples/js/loaders/OBJMTLLoader.js

@@ -11,11 +11,6 @@ THREE.OBJMTLLoader.prototype = {
 
 	constructor: THREE.OBJMTLLoader,
 
-	addEventListener: THREE.EventDispatcher.prototype.addEventListener,
-	hasEventListener: THREE.EventDispatcher.prototype.hasEventListener,
-	removeEventListener: THREE.EventDispatcher.prototype.removeEventListener,
-	dispatchEvent: THREE.EventDispatcher.prototype.dispatchEvent,
-
 	/**
 	 * Load a Wavefront OBJ file with materials (MTL file)
 	 *
@@ -571,3 +566,5 @@ THREE.OBJMTLLoader.prototype = {
 	}
 
 };
+
+THREE.EventDispatcher.prototype.apply( THREE.OBJMTLLoader.prototype );

+ 2 - 5
examples/js/loaders/PLYLoader.js

@@ -25,11 +25,6 @@ THREE.PLYLoader.prototype = {
 
 	constructor: THREE.PLYLoader,
 
-	addEventListener: THREE.EventDispatcher.prototype.addEventListener,
-	hasEventListener: THREE.EventDispatcher.prototype.hasEventListener,
-	removeEventListener: THREE.EventDispatcher.prototype.removeEventListener,
-	dispatchEvent: THREE.EventDispatcher.prototype.dispatchEvent,
-
 	load: function ( url, callback ) {
 
 		var scope = this;
@@ -175,3 +170,5 @@ THREE.PLYLoader.prototype = {
 
 
 };
+
+THREE.EventDispatcher.prototype.apply( THREE.PLYLoader.prototype );

+ 3 - 6
examples/js/loaders/STLLoader.js

@@ -28,12 +28,7 @@ THREE.STLLoader = function () {};
 
 THREE.STLLoader.prototype = {
 
-	constructor: THREE.STLLoader,
-
-	addEventListener: THREE.EventDispatcher.prototype.addEventListener,
-	hasEventListener: THREE.EventDispatcher.prototype.hasEventListener,
-	removeEventListener: THREE.EventDispatcher.prototype.removeEventListener,
-	dispatchEvent: THREE.EventDispatcher.prototype.dispatchEvent
+	constructor: THREE.STLLoader
 
 };
 
@@ -216,6 +211,8 @@ THREE.STLLoader.prototype.ensureBinary = function (buf) {
 
 };
 
+THREE.EventDispatcher.prototype.apply( THREE.STLLoader.prototype );
+
 if ( typeof DataView === 'undefined'){
 
 	DataView = function(buffer, byteOffset, byteLength){

+ 2 - 5
examples/js/loaders/VRMLLoader.js

@@ -8,11 +8,6 @@ THREE.VRMLLoader.prototype = {
 
 	constructor: THREE.VTKLoader,
 
-	addEventListener: THREE.EventDispatcher.prototype.addEventListener,
-	hasEventListener: THREE.EventDispatcher.prototype.hasEventListener,
-	removeEventListener: THREE.EventDispatcher.prototype.removeEventListener,
-	dispatchEvent: THREE.EventDispatcher.prototype.dispatchEvent,
-
 	load: function ( url, callback ) {
 
 		var scope = this;
@@ -377,3 +372,5 @@ THREE.VRMLLoader.prototype = {
 	}
 
 };
+
+THREE.EventDispatcher.prototype.apply( THREE.VRMLLoader.prototype );

+ 2 - 5
examples/js/loaders/VTKLoader.js

@@ -8,11 +8,6 @@ THREE.VTKLoader.prototype = {
 
 	constructor: THREE.VTKLoader,
 
-	addEventListener: THREE.EventDispatcher.prototype.addEventListener,
-	hasEventListener: THREE.EventDispatcher.prototype.hasEventListener,
-	removeEventListener: THREE.EventDispatcher.prototype.removeEventListener,
-	dispatchEvent: THREE.EventDispatcher.prototype.dispatchEvent,
-
 	load: function ( url, callback ) {
 
 		var scope = this;
@@ -115,3 +110,5 @@ THREE.VTKLoader.prototype = {
 	}
 
 };
+
+THREE.EventDispatcher.prototype.apply( THREE.VTKLoader.prototype );

+ 3 - 6
examples/js/loaders/deprecated/ObjectLoader4.js

@@ -8,11 +8,6 @@ THREE.ObjectLoader4.prototype = {
 
 	constructor: THREE.ObjectLoader,
 
-	addEventListener: THREE.EventDispatcher.prototype.addEventListener,
-	hasEventListener: THREE.EventDispatcher.prototype.hasEventListener,
-	removeEventListener: THREE.EventDispatcher.prototype.removeEventListener,
-	dispatchEvent: THREE.EventDispatcher.prototype.dispatchEvent,
-
 	load: function ( url ) {
 
 		var scope = this;
@@ -299,4 +294,6 @@ THREE.ObjectLoader4.prototype = {
 
 	}
 
-};
+};
+
+THREE.EventDispatcher.prototype.apply( THREE.ObjectLoader4.prototype );

+ 3 - 6
examples/js/loaders/deprecated/ObjectLoader41.js

@@ -8,11 +8,6 @@ THREE.ObjectLoader41.prototype = {
 
 	constructor: THREE.ObjectLoader,
 
-	addEventListener: THREE.EventDispatcher.prototype.addEventListener,
-	hasEventListener: THREE.EventDispatcher.prototype.hasEventListener,
-	removeEventListener: THREE.EventDispatcher.prototype.removeEventListener,
-	dispatchEvent: THREE.EventDispatcher.prototype.dispatchEvent,
-
 	load: function ( url ) {
 
 		var scope = this;
@@ -297,4 +292,6 @@ THREE.ObjectLoader41.prototype = {
 
 	}
 
-};
+};
+
+THREE.EventDispatcher.prototype.apply( THREE.ObjectLoader41.prototype );

+ 2 - 5
src/core/BufferGeometry.js

@@ -36,11 +36,6 @@ THREE.BufferGeometry.prototype = {
 
 	constructor: THREE.BufferGeometry,
 
-	addEventListener: THREE.EventDispatcher.prototype.addEventListener,
-	hasEventListener: THREE.EventDispatcher.prototype.hasEventListener,
-	removeEventListener: THREE.EventDispatcher.prototype.removeEventListener,
-	dispatchEvent: THREE.EventDispatcher.prototype.dispatchEvent,
-
 	applyMatrix: function ( matrix ) {
 
 		var positionArray;
@@ -551,3 +546,5 @@ THREE.BufferGeometry.prototype = {
 	}
 
 };
+
+THREE.EventDispatcher.prototype.apply( THREE.BufferGeometry.prototype );

+ 9 - 0
src/core/EventDispatcher.js

@@ -8,6 +8,15 @@ THREE.EventDispatcher.prototype = {
 
 	constructor: THREE.EventDispatcher,
 
+	apply: function ( object ) {
+
+		object.addEventListener = THREE.EventDispatcher.prototype.addEventListener;
+		object.hasEventListener = THREE.EventDispatcher.prototype.hasEventListener;
+		object.removeEventListener = THREE.EventDispatcher.prototype.removeEventListener;
+		object.dispatchEvent = THREE.EventDispatcher.prototype.dispatchEvent;
+
+	},
+
 	addEventListener: function ( type, listener ) {
 
 		if ( this._listeners === undefined ) this._listeners = {};

+ 2 - 5
src/core/Geometry.js

@@ -57,11 +57,6 @@ THREE.Geometry.prototype = {
 
 	constructor: THREE.Geometry,
 
-	addEventListener: THREE.EventDispatcher.prototype.addEventListener,
-	hasEventListener: THREE.EventDispatcher.prototype.hasEventListener,
-	removeEventListener: THREE.EventDispatcher.prototype.removeEventListener,
-	dispatchEvent: THREE.EventDispatcher.prototype.dispatchEvent,
-
 	applyMatrix: function ( matrix ) {
 
 		var normalMatrix = new THREE.Matrix3().getNormalMatrix( matrix );
@@ -816,4 +811,6 @@ THREE.Geometry.prototype = {
 
 };
 
+THREE.EventDispatcher.prototype.apply( THREE.Geometry.prototype );
+
 THREE.GeometryIdCount = 0;

+ 2 - 5
src/core/Object3D.js

@@ -53,11 +53,6 @@ THREE.Object3D.prototype = {
 
 	constructor: THREE.Object3D,
 
-	addEventListener: THREE.EventDispatcher.prototype.addEventListener,
-	hasEventListener: THREE.EventDispatcher.prototype.hasEventListener,
-	removeEventListener: THREE.EventDispatcher.prototype.removeEventListener,
-	dispatchEvent: THREE.EventDispatcher.prototype.dispatchEvent,
-
 	get eulerOrder () {
 
 		console.warn( 'DEPRECATED: Object3D\'s .eulerOrder has been moved to Object3D\'s .rotation.order.' );
@@ -546,4 +541,6 @@ THREE.Object3D.prototype = {
 
 };
 
+THREE.EventDispatcher.prototype.apply( THREE.Object3D.prototype );
+
 THREE.Object3DIdCount = 0;

+ 2 - 5
src/materials/Material.js

@@ -42,11 +42,6 @@ THREE.Material.prototype = {
 
 	constructor: THREE.Material,
 
-	addEventListener: THREE.EventDispatcher.prototype.addEventListener,
-	hasEventListener: THREE.EventDispatcher.prototype.hasEventListener,
-	removeEventListener: THREE.EventDispatcher.prototype.removeEventListener,
-	dispatchEvent: THREE.EventDispatcher.prototype.dispatchEvent,
-
 	setValues: function ( values ) {
 
 		if ( values === undefined ) return;
@@ -133,4 +128,6 @@ THREE.Material.prototype = {
 
 };
 
+THREE.EventDispatcher.prototype.apply( THREE.Material.prototype );
+
 THREE.MaterialIdCount = 0;

+ 2 - 5
src/renderers/WebGLRenderTarget.js

@@ -37,11 +37,6 @@ THREE.WebGLRenderTarget.prototype = {
 
 	constructor: THREE.WebGLRenderTarget,
 
-	addEventListener: THREE.EventDispatcher.prototype.addEventListener,
-	hasEventListener: THREE.EventDispatcher.prototype.hasEventListener,
-	removeEventListener: THREE.EventDispatcher.prototype.removeEventListener,
-	dispatchEvent: THREE.EventDispatcher.prototype.dispatchEvent,
-
 	clone: function () {
 
 		var tmp = new THREE.WebGLRenderTarget( this.width, this.height );
@@ -78,3 +73,5 @@ THREE.WebGLRenderTarget.prototype = {
 	}
 
 };
+
+THREE.EventDispatcher.prototype.apply( THREE.WebGLRenderTarget.prototype );

+ 2 - 5
src/textures/Texture.js

@@ -44,11 +44,6 @@ THREE.Texture.prototype = {
 
 	constructor: THREE.Texture,
 
-	addEventListener: THREE.EventDispatcher.prototype.addEventListener,
-	hasEventListener: THREE.EventDispatcher.prototype.hasEventListener,
-	removeEventListener: THREE.EventDispatcher.prototype.removeEventListener,
-	dispatchEvent: THREE.EventDispatcher.prototype.dispatchEvent,
-
 	clone: function ( texture ) {
 
 		if ( texture === undefined ) texture = new THREE.Texture();
@@ -89,4 +84,6 @@ THREE.Texture.prototype = {
 
 };
 
+THREE.EventDispatcher.prototype.apply( THREE.Texture.prototype );
+
 THREE.TextureIdCount = 0;