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

Clean up.

上级 b8d16dae
...@@ -14,28 +14,28 @@ KeyframeTrackPrototype = { ...@@ -14,28 +14,28 @@ KeyframeTrackPrototype = {
DefaultInterpolation: InterpolateLinear, DefaultInterpolation: InterpolateLinear,
InterpolantFactoryMethodDiscrete: function( result ) { InterpolantFactoryMethodDiscrete: function ( result ) {
return new DiscreteInterpolant( return new DiscreteInterpolant(
this.times, this.values, this.getValueSize(), result ); this.times, this.values, this.getValueSize(), result );
}, },
InterpolantFactoryMethodLinear: function( result ) { InterpolantFactoryMethodLinear: function ( result ) {
return new LinearInterpolant( return new LinearInterpolant(
this.times, this.values, this.getValueSize(), result ); this.times, this.values, this.getValueSize(), result );
}, },
InterpolantFactoryMethodSmooth: function( result ) { InterpolantFactoryMethodSmooth: function ( result ) {
return new CubicInterpolant( return new CubicInterpolant(
this.times, this.values, this.getValueSize(), result ); this.times, this.values, this.getValueSize(), result );
}, },
setInterpolation: function( interpolation ) { setInterpolation: function ( interpolation ) {
var factoryMethod; var factoryMethod;
...@@ -90,7 +90,7 @@ KeyframeTrackPrototype = { ...@@ -90,7 +90,7 @@ KeyframeTrackPrototype = {
}, },
getInterpolation: function() { getInterpolation: function () {
switch ( this.createInterpolant ) { switch ( this.createInterpolant ) {
...@@ -110,20 +110,20 @@ KeyframeTrackPrototype = { ...@@ -110,20 +110,20 @@ KeyframeTrackPrototype = {
}, },
getValueSize: function() { getValueSize: function () {
return this.values.length / this.times.length; return this.values.length / this.times.length;
}, },
// move all keyframes either forwards or backwards in time // 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; 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; times[ i ] += timeOffset;
...@@ -136,13 +136,13 @@ KeyframeTrackPrototype = { ...@@ -136,13 +136,13 @@ KeyframeTrackPrototype = {
}, },
// scale all keyframe times by a factor (useful for frame <-> seconds conversions) // 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; 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; times[ i ] *= timeScale;
...@@ -156,7 +156,7 @@ KeyframeTrackPrototype = { ...@@ -156,7 +156,7 @@ KeyframeTrackPrototype = {
// removes keyframes before and after animation without changing any values within the range [startTime, endTime]. // 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 // 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, var times = this.times,
nKeys = times.length, nKeys = times.length,
...@@ -164,17 +164,14 @@ KeyframeTrackPrototype = { ...@@ -164,17 +164,14 @@ KeyframeTrackPrototype = {
to = nKeys - 1; to = nKeys - 1;
while ( from !== nKeys && times[ from ] < startTime ) ++ from; 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 ++ to; // inclusive -> exclusive bound
if( from !== 0 || to !== nKeys ) { if ( from !== 0 || to !== nKeys ) {
// empty tracks are forbidden, so keep at least one keyframe // empty tracks are forbidden, so keep at least one keyframe
if ( from >= to ){ if ( from >= to ) to = Math.max( to, 1 ), from = to - 1;
to = Math.max( to , 1 );
from = to - 1;
}
var stride = this.getValueSize(); var stride = this.getValueSize();
this.times = AnimationUtils.arraySlice( times, from, to ); this.times = AnimationUtils.arraySlice( times, from, to );
...@@ -188,7 +185,7 @@ KeyframeTrackPrototype = { ...@@ -188,7 +185,7 @@ KeyframeTrackPrototype = {
}, },
// ensure we do not get a GarbageInGarbageOut situation, make sure tracks are at least minimally viable // ensure we do not get a GarbageInGarbageOut situation, make sure tracks are at least minimally viable
validate: function() { validate: function () {
var valid = true; var valid = true;
...@@ -205,7 +202,7 @@ KeyframeTrackPrototype = { ...@@ -205,7 +202,7 @@ KeyframeTrackPrototype = {
nKeys = times.length; nKeys = times.length;
if( nKeys === 0 ) { if ( nKeys === 0 ) {
console.error( "track is empty", this ); console.error( "track is empty", this );
valid = false; valid = false;
...@@ -214,7 +211,7 @@ KeyframeTrackPrototype = { ...@@ -214,7 +211,7 @@ KeyframeTrackPrototype = {
var prevTime = null; var prevTime = null;
for( var i = 0; i !== nKeys; i ++ ) { for ( var i = 0; i !== nKeys; i ++ ) {
var currTime = times[ i ]; var currTime = times[ i ];
...@@ -226,7 +223,7 @@ KeyframeTrackPrototype = { ...@@ -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 ); console.error( "out of order keys", this, i, currTime, prevTime );
valid = false; valid = false;
...@@ -266,7 +263,7 @@ KeyframeTrackPrototype = { ...@@ -266,7 +263,7 @@ KeyframeTrackPrototype = {
// removes equivalent sequential keys as common in morph target sequences // 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) // (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, var times = this.times,
values = this.values, values = this.values,
...@@ -277,7 +274,7 @@ KeyframeTrackPrototype = { ...@@ -277,7 +274,7 @@ KeyframeTrackPrototype = {
writeIndex = 1, writeIndex = 1,
lastIndex = times.length - 1; lastIndex = times.length - 1;
for( var i = 1; i < lastIndex; ++ i ) { for ( var i = 1; i < lastIndex; ++ i ) {
var keep = false; var keep = false;
......
...@@ -32,7 +32,7 @@ Object.assign( EventDispatcher.prototype, { ...@@ -32,7 +32,7 @@ Object.assign( EventDispatcher.prototype, {
var listeners = this._listeners; var listeners = this._listeners;
return ( listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== - 1 ); return listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== - 1;
}, },
......
...@@ -129,13 +129,15 @@ Box2.prototype = { ...@@ -129,13 +129,15 @@ Box2.prototype = {
containsPoint: function ( point ) { 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 ) { 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 = { ...@@ -156,8 +158,8 @@ Box2.prototype = {
intersectsBox: function ( box ) { intersectsBox: function ( box ) {
// using 6 splitting planes to rule out intersections. // using 6 splitting planes to rule out intersections.
return box.max.x < this.min.x || box.min.x > this.max.x ||
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.y < this.min.y || box.min.y > this.max.y ? false : true;
}, },
......
...@@ -275,13 +275,17 @@ Box3.prototype = { ...@@ -275,13 +275,17 @@ Box3.prototype = {
containsPoint: function ( point ) { 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 ) { 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 = { ...@@ -303,8 +307,9 @@ Box3.prototype = {
intersectsBox: function ( box ) { intersectsBox: function ( box ) {
// using 6 splitting planes to rule out intersections. // using 6 splitting planes to rule out intersections.
return box.max.x < this.min.x || box.min.x > this.max.x ||
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); 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;
}, },
......
...@@ -67,8 +67,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, paramT ...@@ -67,8 +67,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, paramT
function textureNeedsPowerOfTwo( texture ) { 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 // Fallback filters for non-power-of-2 textures
...@@ -236,8 +237,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, paramT ...@@ -236,8 +237,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, paramT
_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY ); _gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );
var isCompressed = (texture && texture.isCompressedTexture); var isCompressed = ( texture && texture.isCompressedTexture );
var isDataTexture = (texture.image[ 0 ] && texture.image[ 0 ].isDataTexture); var isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture );
var cubeImage = []; var cubeImage = [];
......
...@@ -9,7 +9,11 @@ var unit3 = new THREE.Vector3( 1, 0, 0 ); ...@@ -9,7 +9,11 @@ var unit3 = new THREE.Vector3( 1, 0, 0 );
var planeEquals = function ( a, b, tolerance ) { var planeEquals = function ( a, b, tolerance ) {
tolerance = tolerance || 0.0001; 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;
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册