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

Refactored EventDispatcher usage.

上级 e55d50ab
......@@ -27,12 +27,14 @@ function AnimationMixer( root ) {
}
Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, {
AnimationMixer.prototype = {
constructor: AnimationMixer,
// return an action for a clip optionally using a custom root target
// object (this method allocates a lot of dynamic memory in case a
// previously unknown clip/root combination is specified)
clipAction: function( clip, optionalRoot ) {
clipAction: function ( clip, optionalRoot ) {
var root = optionalRoot || this._root,
rootUuid = root.uuid,
......@@ -273,13 +275,13 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, {
}
} );
};
// Implementation details:
Object.assign( AnimationMixer.prototype, {
_bindAction: function( action, prototypeAction ) {
_bindAction: function ( action, prototypeAction ) {
var root = action._localRoot || this._root,
tracks = action._clip.tracks,
......@@ -346,7 +348,7 @@ Object.assign( AnimationMixer.prototype, {
},
_activateAction: function( action ) {
_activateAction: function ( action ) {
if ( ! this._isActiveAction( action ) ) {
......@@ -388,7 +390,7 @@ Object.assign( AnimationMixer.prototype, {
},
_deactivateAction: function( action ) {
_deactivateAction: function ( action ) {
if ( this._isActiveAction( action ) ) {
......@@ -416,7 +418,7 @@ Object.assign( AnimationMixer.prototype, {
// Memory manager
_initMemoryManager: function() {
_initMemoryManager: function () {
this._actions = []; // 'nActiveActions' followed by inactive ones
this._nActiveActions = 0;
......@@ -461,14 +463,14 @@ Object.assign( AnimationMixer.prototype, {
// Memory management for AnimationAction objects
_isActiveAction: function( action ) {
_isActiveAction: function ( action ) {
var index = action._cacheIndex;
return index !== null && index < this._nActiveActions;
},
_addInactiveAction: function( action, clipUuid, rootUuid ) {
_addInactiveAction: function ( action, clipUuid, rootUuid ) {
var actions = this._actions,
actionsByClip = this._actionsByClip,
......@@ -503,7 +505,7 @@ Object.assign( AnimationMixer.prototype, {
},
_removeInactiveAction: function( action ) {
_removeInactiveAction: function ( action ) {
var actions = this._actions,
lastInactiveAction = actions[ actions.length - 1 ],
......@@ -548,7 +550,7 @@ Object.assign( AnimationMixer.prototype, {
},
_removeInactiveBindingsForAction: function( action ) {
_removeInactiveBindingsForAction: function ( action ) {
var bindings = action._propertyBindings;
for ( var i = 0, n = bindings.length; i !== n; ++ i ) {
......@@ -565,7 +567,7 @@ Object.assign( AnimationMixer.prototype, {
},
_lendAction: function( action ) {
_lendAction: function ( action ) {
// [ active actions | inactive actions ]
// [ active actions >| inactive actions ]
......@@ -588,7 +590,7 @@ Object.assign( AnimationMixer.prototype, {
},
_takeBackAction: function( action ) {
_takeBackAction: function ( action ) {
// [ active actions | inactive actions ]
// [ active actions |< inactive actions ]
......@@ -613,7 +615,7 @@ Object.assign( AnimationMixer.prototype, {
// Memory management for PropertyMixer objects
_addInactiveBinding: function( binding, rootUuid, trackName ) {
_addInactiveBinding: function ( binding, rootUuid, trackName ) {
var bindingsByRoot = this._bindingsByRootAndName,
bindingByName = bindingsByRoot[ rootUuid ],
......@@ -634,7 +636,7 @@ Object.assign( AnimationMixer.prototype, {
},
_removeInactiveBinding: function( binding ) {
_removeInactiveBinding: function ( binding ) {
var bindings = this._bindings,
propBinding = binding.binding,
......@@ -662,7 +664,7 @@ Object.assign( AnimationMixer.prototype, {
},
_lendBinding: function( binding ) {
_lendBinding: function ( binding ) {
var bindings = this._bindings,
prevIndex = binding._cacheIndex,
......@@ -679,7 +681,7 @@ Object.assign( AnimationMixer.prototype, {
},
_takeBackBinding: function( binding ) {
_takeBackBinding: function ( binding ) {
var bindings = this._bindings,
prevIndex = binding._cacheIndex,
......@@ -699,7 +701,7 @@ Object.assign( AnimationMixer.prototype, {
// Memory management of Interpolants for weight and time scale
_lendControlInterpolant: function() {
_lendControlInterpolant: function () {
var interpolants = this._controlInterpolants,
lastActiveIndex = this._nActiveControlInterpolants ++,
......@@ -720,7 +722,7 @@ Object.assign( AnimationMixer.prototype, {
},
_takeBackControlInterpolant: function( interpolant ) {
_takeBackControlInterpolant: function ( interpolant ) {
var interpolants = this._controlInterpolants,
prevIndex = interpolant.__cacheIndex,
......@@ -741,5 +743,6 @@ Object.assign( AnimationMixer.prototype, {
} );
Object.assign( AnimationMixer.prototype, EventDispatcher.prototype );
export { AnimationMixer };
......@@ -38,7 +38,9 @@ function BufferGeometry() {
}
Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
BufferGeometry.prototype = {
constructor: BufferGeometry,
isBufferGeometry: true,
......@@ -1033,9 +1035,10 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
}
} );
};
BufferGeometry.MaxIndex = 65535;
Object.assign( BufferGeometry.prototype, EventDispatcher.prototype );
export { BufferGeometry };
......@@ -4,7 +4,7 @@
function EventDispatcher() {}
Object.assign( EventDispatcher.prototype, {
EventDispatcher.prototype = {
addEventListener: function ( type, listener ) {
......@@ -87,7 +87,7 @@ Object.assign( EventDispatcher.prototype, {
}
} );
};
export { EventDispatcher };
......@@ -19,6 +19,9 @@ import { _Math } from '../math/Math';
* @author bhouston / http://clara.io
*/
var count = 0;
function GeometryIdCount() { return count++; };
function Geometry() {
Object.defineProperty( this, 'id', { value: GeometryIdCount() } );
......@@ -31,7 +34,7 @@ function Geometry() {
this.vertices = [];
this.colors = [];
this.faces = [];
this.faceVertexUvs = [ [] ];
this.faceVertexUvs = [[]];
this.morphTargets = [];
this.morphNormals = [];
......@@ -56,7 +59,9 @@ function Geometry() {
}
Object.assign( Geometry.prototype, EventDispatcher.prototype, {
Geometry.prototype = {
constructor: Geometry,
isGeometry: true,
......@@ -308,7 +313,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, {
for ( var j = start, jl = start + count; j < jl; j += 3 ) {
addFace( indices[ j ], indices[ j + 1 ], indices[ j + 2 ], group.materialIndex );
addFace( indices[ j ], indices[ j + 1 ], indices[ j + 2 ], group.materialIndex );
}
......@@ -701,7 +706,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, {
merge: function ( geometry, matrix, materialIndexOffset ) {
if ( (geometry && geometry.isGeometry) === false ) {
if ( ( geometry && geometry.isGeometry ) === false ) {
console.error( 'THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.', geometry );
return;
......@@ -821,7 +826,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, {
mergeMesh: function ( mesh ) {
if ( (mesh && mesh.isMesh) === false ) {
if ( ( mesh && mesh.isMesh ) === false ) {
console.error( 'THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.', mesh );
return;
......@@ -886,15 +891,12 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, {
indices = [ face.a, face.b, face.c ];
var dupIndex = - 1;
// if any duplicate vertices are found in a Face3
// we have to remove the face as nothing can be saved
for ( var n = 0; n < 3; n ++ ) {
if ( indices[ n ] === indices[ ( n + 1 ) % 3 ] ) {
dupIndex = n;
faceIndicesToRemove.push( i );
break;
......@@ -1265,10 +1267,8 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, {
}
} );
var count = 0;
function GeometryIdCount() { return count++; };
};
Object.assign( Geometry.prototype, EventDispatcher.prototype );
export { GeometryIdCount, Geometry };
......@@ -101,7 +101,9 @@ function Object3D() {
Object3D.DefaultUp = new Vector3( 0, 1, 0 );
Object3D.DefaultMatrixAutoUpdate = true;
Object.assign( Object3D.prototype, EventDispatcher.prototype, {
Object3D.prototype = {
constructor: Object3D,
isObject3D: true,
......@@ -728,6 +730,8 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, {
}
} );
};
Object.assign( Object3D.prototype, EventDispatcher.prototype );
export { Object3D };
......@@ -110,7 +110,7 @@ Material.prototype = {
currentValue.set( newValue );
} else if ( (currentValue && currentValue.isVector3) && (newValue && newValue.isVector3) ) {
} else if ( ( currentValue && currentValue.isVector3 ) && ( newValue && newValue.isVector3 ) ) {
currentValue.copy( newValue );
......
......@@ -39,7 +39,9 @@ function WebGLRenderTarget( width, height, options ) {
}
Object.assign( WebGLRenderTarget.prototype, EventDispatcher.prototype, {
WebGLRenderTarget.prototype = {
constructor: WebGLRenderTarget,
isWebGLRenderTarget: true,
......@@ -88,7 +90,8 @@ Object.assign( WebGLRenderTarget.prototype, EventDispatcher.prototype, {
}
} );
};
Object.assign( WebGLRenderTarget.prototype, EventDispatcher.prototype );
export { WebGLRenderTarget };
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册