提交 28aba0b8 编写于 作者: M Mr.doob

Renamed EventTarget to EventDispatcher as discussed in fdb737d0.

上级 4a0362c6
......@@ -2,9 +2,9 @@
<html lang="en">
<head>
<meta charset="utf-8">
<script src="../../../list.js"></script>
<script src="../../../page.js"></script>
<link type="text/css" rel="stylesheet" href="../../../page.css" />
<script src="../../list.js"></script>
<script src="../../page.js"></script>
<link type="text/css" rel="stylesheet" href="../../page.css" />
</head>
<body>
<h1>[name]</h1>
......
......@@ -16,6 +16,7 @@ var list = {
"Core": [
[ "Clock", "api/core/Clock" ],
[ "Color", "api/core/Color" ],
[ "EventDispatcher", "api/core/EventDispatcher" ],
[ "Face3", "api/core/Face3" ],
[ "Face4", "api/core/Face4" ],
[ "Frustum", "api/core/Frustum" ],
......@@ -139,7 +140,6 @@ var list = {
[ "BufferGeometry", "api/extras/core/BufferGeometry" ],
[ "Curve", "api/extras/core/Curve" ],
[ "CurvePath", "api/extras/core/CurvePath" ],
[ "EventTarget", "api/extras/core/EventTarget" ],
[ "Gyroscope", "api/extras/core/Gyroscope" ],
[ "Path", "api/extras/core/Path" ],
[ "Shape", "api/extras/core/Shape" ]
......
......@@ -7,7 +7,7 @@
THREE.OrbitControls = function ( object, domElement ) {
THREE.EventTarget.call( this );
THREE.EventDispatcher.call( this );
this.object = object;
this.domElement = ( domElement !== undefined ) ? domElement : document;
......
......@@ -4,7 +4,7 @@
THREE.TrackballControls = function ( object, domElement ) {
THREE.EventTarget.call( this );
THREE.EventDispatcher.call( this );
var _this = this;
var STATE = { NONE: -1, ROTATE: 0, ZOOM: 1, PAN: 2 };
......
......@@ -6,7 +6,8 @@
THREE.MTLLoader = function( baseUrl, options ) {
THREE.EventTarget.call( this );
THREE.EventDispatcher.call( this );
this.baseUrl = baseUrl;
this.options = options;
......@@ -149,7 +150,7 @@ THREE.MTLLoader.prototype = {
THREE.MTLLoader.MaterialCreator = function( baseUrl, options ) {
THREE.EventTarget.call( this );
THREE.EventDispatcher.call( this );
this.baseUrl = baseUrl;
this.options = options;
......
......@@ -4,7 +4,7 @@
THREE.OBJLoader = function () {
THREE.EventTarget.call( this );
THREE.EventDispatcher.call( this );
};
......
......@@ -7,7 +7,7 @@
THREE.OBJMTLLoader = function ( ) {
THREE.EventTarget.call( this );
THREE.EventDispatcher.call( this );
};
......
......@@ -20,7 +20,7 @@
THREE.STLLoader = function () {
THREE.EventTarget.call( this );
THREE.EventDispatcher.call( this );
};
......
......@@ -4,7 +4,7 @@
THREE.VTKLoader = function () {
THREE.EventTarget.call( this );
THREE.EventDispatcher.call( this );
};
......
......@@ -4,7 +4,7 @@
THREE.BufferGeometry = function () {
THREE.EventTarget.call( this );
THREE.EventDispatcher.call( this );
this.id = THREE.GeometryIdCount ++;
......@@ -546,7 +546,7 @@ THREE.BufferGeometry.prototype = {
deallocate: function () {
this.dispatchEvent( { type: 'deallocate', target: this } );
this.dispatchEvent( { type: 'deallocate' } );
}
......
/**
* https://github.com/mrdoob/eventtarget.js/
* https://github.com/mrdoob/eventdispatcher.js/
*/
THREE.EventTarget = function () {
THREE.EventDispatcher = function () {
var listeners = {};
......@@ -22,32 +22,34 @@ THREE.EventTarget = function () {
};
this.dispatchEvent = function ( event ) {
var listenerArray = listeners[ event.type ];
if ( listenerArray !== undefined ) {
this.removeEventListener = function ( type, listener ) {
for ( var i = 0, l = listenerArray.length; i < l; i ++ ) {
var index = listeners[ type ].indexOf( listener );
listenerArray[ i ].call( this, event );
if ( index !== - 1 ) {
}
listeners[ type ].splice( index, 1 );
}
};
this.removeEventListener = function ( type, listener ) {
this.dispatchEvent = function ( event ) {
var index = listeners[ type ].indexOf( listener );
var listenerArray = listeners[ event.type ];
if ( index !== - 1 ) {
if ( listenerArray !== undefined ) {
event.target = this;
listeners[ type ].splice( index, 1 );
for ( var i = 0, l = listenerArray.length; i < l; i ++ ) {
listenerArray[ i ].call( this, event );
}
}
};
};
};
\ No newline at end of file
......@@ -9,7 +9,7 @@
THREE.Geometry = function () {
THREE.EventTarget.call( this );
THREE.EventDispatcher.call( this );
this.id = THREE.GeometryIdCount ++;
......@@ -738,7 +738,7 @@ THREE.Geometry.prototype = {
deallocate: function () {
this.dispatchEvent( { type: 'deallocate', target: this } );
this.dispatchEvent( { type: 'deallocate' } );
}
......
......@@ -4,7 +4,7 @@
THREE.ImageLoader = function () {
THREE.EventTarget.call( this );
THREE.EventDispatcher.call( this );
this.crossOrigin = null;
......
......@@ -4,7 +4,7 @@
THREE.LoadingMonitor = function () {
THREE.EventTarget.call( this );
THREE.EventDispatcher.call( this );
var scope = this;
......
......@@ -569,7 +569,7 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
var result;
// loaders which use EventTarget
// loaders which use EventDispatcher
if ( event.content ) {
......
......@@ -4,7 +4,7 @@
THREE.TextureLoader = function () {
THREE.EventTarget.call( this );
THREE.EventDispatcher.call( this );
this.crossOrigin = null;
......
......@@ -5,7 +5,7 @@
THREE.Material = function () {
THREE.EventTarget.call( this );
THREE.EventDispatcher.call( this );
this.id = THREE.MaterialIdCount ++;
......@@ -118,7 +118,7 @@ THREE.Material.prototype.clone = function ( material ) {
THREE.Material.prototype.deallocate = function () {
this.dispatchEvent( { type: 'deallocate', target: this } );
this.dispatchEvent( { type: 'deallocate' } );
};
......
......@@ -5,7 +5,7 @@
THREE.WebGLRenderTarget = function ( width, height, options ) {
THREE.EventTarget.call( this );
THREE.EventDispatcher.call( this );
this.width = width;
this.height = height;
......@@ -66,6 +66,6 @@ THREE.WebGLRenderTarget.prototype.clone = function() {
THREE.WebGLRenderTarget.prototype.deallocate = function () {
this.dispatchEvent( { type: 'deallocate', target: this } );
this.dispatchEvent( { type: 'deallocate' } );
};
......@@ -6,7 +6,7 @@
THREE.Texture = function ( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
THREE.EventTarget.call( this );
THREE.EventDispatcher.call( this );
this.id = THREE.TextureIdCount ++;
......@@ -79,7 +79,7 @@ THREE.Texture.prototype = {
deallocate: function () {
this.dispatchEvent( { type: 'deallocate', target: this } );
this.dispatchEvent( { type: 'deallocate' } );
}
......
......@@ -16,7 +16,7 @@
"../src/math/Quaternion.js",
"../src/math/Vertex.js",
"../src/math/UV.js",
"../src/core/EventTarget.js",
"../src/core/EventDispatcher.js",
"../src/core/Raycaster.js",
"../src/core/Object3D.js",
"../src/core/Projector.js",
......
......@@ -19,7 +19,7 @@
"../src/math/Vertex.js",
"../src/math/UV.js",
"../src/core/Clock.js",
"../src/core/EventTarget.js",
"../src/core/EventDispatcher.js",
"../src/core/Raycaster.js",
"../src/core/Object3D.js",
"../src/core/Projector.js",
......
......@@ -12,7 +12,7 @@
"../src/math/Sphere.js",
"../src/math/Triangle.js",
"../src/math/Plane.js",
"../src/core/EventTarget.js",
"../src/core/EventDispatcher.js",
"../src/core/Raycaster.js",
"../src/core/Object3D.js",
"../src/core/Projector.js",
......
......@@ -18,7 +18,7 @@
"../src/math/Sphere.js",
"../src/math/Plane.js",
"../src/core/Clock.js",
"../src/core/EventTarget.js",
"../src/core/EventDispatcher.js",
"../src/core/Raycaster.js",
"../src/core/Object3D.js",
"../src/core/Projector.js",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册