diff --git a/src/animation/AnimationMixer.js b/src/animation/AnimationMixer.js index 9d64330e9ffca9eea7b244d0e7f851103458008f..bd3b8deea8c629c6ab9a1e468a84f9a58073f69e 100644 --- a/src/animation/AnimationMixer.js +++ b/src/animation/AnimationMixer.js @@ -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 }; diff --git a/src/core/BufferGeometry.js b/src/core/BufferGeometry.js index 59b3b917de472fed44d112d7d2455822889dc0fb..ffe18c3e43a2b1dc9c26d17fb1ff896772170535 100644 --- a/src/core/BufferGeometry.js +++ b/src/core/BufferGeometry.js @@ -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 }; diff --git a/src/core/EventDispatcher.js b/src/core/EventDispatcher.js index 417a730bbcadaa92241f95aef9e0bd4313da3801..2b9b4649a6de029820d598a547f7ee617cc7f42f 100644 --- a/src/core/EventDispatcher.js +++ b/src/core/EventDispatcher.js @@ -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 }; diff --git a/src/core/Geometry.js b/src/core/Geometry.js index 9a30363c97b7bcbf6119859bd7f7db6ecf562e64..906de25aedad4e2dc0c1c7c36a9f755a0226957b 100644 --- a/src/core/Geometry.js +++ b/src/core/Geometry.js @@ -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 }; diff --git a/src/core/Object3D.js b/src/core/Object3D.js index 5f7cb0db90e52c36ee9ef230d2fb060071fbfd7d..e667bcdc1daeb3147e58e7bb9cc7403c4e41a809 100644 --- a/src/core/Object3D.js +++ b/src/core/Object3D.js @@ -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 }; diff --git a/src/materials/Material.js b/src/materials/Material.js index 72bb555dbbef0b3a6bd061b3bd511b17fb93196a..1d9d10844d826b0b4446ff34a4ea10029a6ba543 100644 --- a/src/materials/Material.js +++ b/src/materials/Material.js @@ -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 ); diff --git a/src/renderers/WebGLRenderTarget.js b/src/renderers/WebGLRenderTarget.js index 2df589da20619914604b760ffc33d8660b660426..d0a393db3362e5d574fc73c54a40d4a21f86a601 100644 --- a/src/renderers/WebGLRenderTarget.js +++ b/src/renderers/WebGLRenderTarget.js @@ -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 };