diff --git a/src/animation/KeyframeTrackPrototype.js b/src/animation/KeyframeTrackPrototype.js index 3970e55eb66c29a8749b85954a2df2c7e5b7c523..405883cf842f5e261cf8ac4920d6c3752dec9676 100644 --- a/src/animation/KeyframeTrackPrototype.js +++ b/src/animation/KeyframeTrackPrototype.js @@ -14,28 +14,28 @@ KeyframeTrackPrototype = { DefaultInterpolation: InterpolateLinear, - InterpolantFactoryMethodDiscrete: function( result ) { + InterpolantFactoryMethodDiscrete: function ( result ) { return new DiscreteInterpolant( this.times, this.values, this.getValueSize(), result ); }, - InterpolantFactoryMethodLinear: function( result ) { + InterpolantFactoryMethodLinear: function ( result ) { return new LinearInterpolant( this.times, this.values, this.getValueSize(), result ); }, - InterpolantFactoryMethodSmooth: function( result ) { + InterpolantFactoryMethodSmooth: function ( result ) { return new CubicInterpolant( this.times, this.values, this.getValueSize(), result ); }, - setInterpolation: function( interpolation ) { + setInterpolation: function ( interpolation ) { var factoryMethod; @@ -90,7 +90,7 @@ KeyframeTrackPrototype = { }, - getInterpolation: function() { + getInterpolation: function () { switch ( this.createInterpolant ) { @@ -110,20 +110,20 @@ KeyframeTrackPrototype = { }, - getValueSize: function() { + getValueSize: function () { return this.values.length / this.times.length; }, // move all keyframes either forwards or backwards in time - shift: function( timeOffset ) { + shift: function ( timeOffset ) { - if( timeOffset !== 0.0 ) { + if ( timeOffset !== 0.0 ) { var times = this.times; - for( var i = 0, n = times.length; i !== n; ++ i ) { + for ( var i = 0, n = times.length; i !== n; ++ i ) { times[ i ] += timeOffset; @@ -136,13 +136,13 @@ KeyframeTrackPrototype = { }, // scale all keyframe times by a factor (useful for frame <-> seconds conversions) - scale: function( timeScale ) { + scale: function ( timeScale ) { - if( timeScale !== 1.0 ) { + if ( timeScale !== 1.0 ) { var times = this.times; - for( var i = 0, n = times.length; i !== n; ++ i ) { + for ( var i = 0, n = times.length; i !== n; ++ i ) { times[ i ] *= timeScale; @@ -156,7 +156,7 @@ KeyframeTrackPrototype = { // removes keyframes before and after animation without changing any values within the range [startTime, endTime]. // IMPORTANT: We do not shift around keys to the start of the track time, because for interpolated keys this will change their values - trim: function( startTime, endTime ) { + trim: function ( startTime, endTime ) { var times = this.times, nKeys = times.length, @@ -164,17 +164,14 @@ KeyframeTrackPrototype = { to = nKeys - 1; while ( from !== nKeys && times[ from ] < startTime ) ++ from; - while ( to !== -1 && times[ to ] > endTime ) -- to; + while ( to !== - 1 && times[ to ] > endTime ) -- to; ++ to; // inclusive -> exclusive bound - if( from !== 0 || to !== nKeys ) { + if ( from !== 0 || to !== nKeys ) { // empty tracks are forbidden, so keep at least one keyframe - if ( from >= to ){ - to = Math.max( to , 1 ); - from = to - 1; - } + if ( from >= to ) to = Math.max( to, 1 ), from = to - 1; var stride = this.getValueSize(); this.times = AnimationUtils.arraySlice( times, from, to ); @@ -188,7 +185,7 @@ KeyframeTrackPrototype = { }, // ensure we do not get a GarbageInGarbageOut situation, make sure tracks are at least minimally viable - validate: function() { + validate: function () { var valid = true; @@ -205,7 +202,7 @@ KeyframeTrackPrototype = { nKeys = times.length; - if( nKeys === 0 ) { + if ( nKeys === 0 ) { console.error( "track is empty", this ); valid = false; @@ -214,7 +211,7 @@ KeyframeTrackPrototype = { var prevTime = null; - for( var i = 0; i !== nKeys; i ++ ) { + for ( var i = 0; i !== nKeys; i ++ ) { var currTime = times[ i ]; @@ -226,7 +223,7 @@ KeyframeTrackPrototype = { } - if( prevTime !== null && prevTime > currTime ) { + if ( prevTime !== null && prevTime > currTime ) { console.error( "out of order keys", this, i, currTime, prevTime ); valid = false; @@ -266,7 +263,7 @@ KeyframeTrackPrototype = { // removes equivalent sequential keys as common in morph target sequences // (0,0,0,0,1,1,1,0,0,0,0,0,0,0) --> (0,0,1,1,0,0) - optimize: function() { + optimize: function () { var times = this.times, values = this.values, @@ -277,7 +274,7 @@ KeyframeTrackPrototype = { writeIndex = 1, lastIndex = times.length - 1; - for( var i = 1; i < lastIndex; ++ i ) { + for ( var i = 1; i < lastIndex; ++ i ) { var keep = false; diff --git a/src/core/EventDispatcher.js b/src/core/EventDispatcher.js index 61f5ef127ad85d909c0c226cafc213d4d81a8884..417a730bbcadaa92241f95aef9e0bd4313da3801 100644 --- a/src/core/EventDispatcher.js +++ b/src/core/EventDispatcher.js @@ -32,7 +32,7 @@ Object.assign( EventDispatcher.prototype, { var listeners = this._listeners; - return ( listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== - 1 ); + return listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== - 1; }, diff --git a/src/math/Box2.js b/src/math/Box2.js index 7a469f51ff5824a3e839085417b360bd8ba5e213..6d06fba47c28328e3c92e39a9802e35132882525 100644 --- a/src/math/Box2.js +++ b/src/math/Box2.js @@ -129,13 +129,15 @@ Box2.prototype = { containsPoint: function ( point ) { - return !(point.x < this.min.x || point.x > this.max.x || point.y < this.min.y || point.y > this.max.y); + return point.x < this.min.x || point.x > this.max.x || + point.y < this.min.y || point.y > this.max.y ? false : true; }, containsBox: function ( box ) { - return ( this.min.x <= box.min.x ) && ( box.max.x <= this.max.x ) && ( this.min.y <= box.min.y ) && ( box.max.y <= this.max.y ); + return this.min.x <= box.min.x && box.max.x <= this.max.x && + this.min.y <= box.min.y && box.max.y <= this.max.y; }, @@ -156,8 +158,8 @@ Box2.prototype = { intersectsBox: function ( box ) { // using 6 splitting planes to rule out intersections. - - return !(box.max.x < this.min.x || box.min.x > this.max.x || box.max.y < this.min.y || box.min.y > this.max.y); + return box.max.x < this.min.x || box.min.x > this.max.x || + box.max.y < this.min.y || box.min.y > this.max.y ? false : true; }, diff --git a/src/math/Box3.js b/src/math/Box3.js index 85e267bb7df9b35cd7620d1cb3dc2731363b3116..406ecc2c8b674acadb3d56ddf1f08159c77b70e7 100644 --- a/src/math/Box3.js +++ b/src/math/Box3.js @@ -275,13 +275,17 @@ Box3.prototype = { containsPoint: function ( point ) { - return ( point.x < this.min.x || point.x > this.max.x || point.y < this.min.y || point.y > this.max.y || point.z < this.min.z || point.z > this.max.z ) === false; + return point.x < this.min.x || point.x > this.max.x || + point.y < this.min.y || point.y > this.max.y || + point.z < this.min.z || point.z > this.max.z ? false : true; }, containsBox: function ( box ) { - return ( this.min.x <= box.min.x ) && ( box.max.x <= this.max.x ) && ( this.min.y <= box.min.y ) && ( box.max.y <= this.max.y ) && ( this.min.z <= box.min.z ) && ( box.max.z <= this.max.z ); + return this.min.x <= box.min.x && box.max.x <= this.max.x && + this.min.y <= box.min.y && box.max.y <= this.max.y && + this.min.z <= box.min.z && box.max.z <= this.max.z; }, @@ -303,8 +307,9 @@ Box3.prototype = { intersectsBox: function ( box ) { // using 6 splitting planes to rule out intersections. - - return !(box.max.x < this.min.x || box.min.x > this.max.x || box.max.y < this.min.y || box.min.y > this.max.y || box.max.z < this.min.z || box.min.z > this.max.z); + return box.max.x < this.min.x || box.min.x > this.max.x || + box.max.y < this.min.y || box.min.y > this.max.y || + box.max.z < this.min.z || box.min.z > this.max.z ? false : true; }, diff --git a/src/renderers/webgl/WebGLTextures.js b/src/renderers/webgl/WebGLTextures.js index ac24480cd52ea2074096dcf7a75c4fabebdfe5d6..9adb639ad47a261bc359798f62a134c321cefaf4 100644 --- a/src/renderers/webgl/WebGLTextures.js +++ b/src/renderers/webgl/WebGLTextures.js @@ -67,8 +67,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, paramT function textureNeedsPowerOfTwo( texture ) { - return (texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) || ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ); - + return ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) || + ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ); + } // Fallback filters for non-power-of-2 textures @@ -236,8 +237,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, paramT _gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY ); - var isCompressed = (texture && texture.isCompressedTexture); - var isDataTexture = (texture.image[ 0 ] && texture.image[ 0 ].isDataTexture); + var isCompressed = ( texture && texture.isCompressedTexture ); + var isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture ); var cubeImage = []; diff --git a/test/unit/math/Frustum.js b/test/unit/math/Frustum.js index f3b7489f17c9c1a1ea2e03726b7250308aa3c3d4..0b93986fdfc923a89415d013a3b43da7187b8655 100644 --- a/test/unit/math/Frustum.js +++ b/test/unit/math/Frustum.js @@ -9,7 +9,11 @@ var unit3 = new THREE.Vector3( 1, 0, 0 ); var planeEquals = function ( a, b, tolerance ) { tolerance = tolerance || 0.0001; - return !( a.normal.distanceTo( b.normal ) > tolerance ) && !( Math.abs( a.constant - b.constant ) > tolerance ); + + if ( a.normal.distanceTo( b.normal ) > tolerance ) return false; + if ( Math.abs( a.constant - b.constant ) > tolerance ) return false; + + return true; };