|
@@ -12,8 +12,7 @@ THREE.KeyframeTrack = function ( name, times, values, interpolation ) {
|
|
|
|
|
|
if( name === undefined ) throw new Error( "track name is undefined" );
|
|
if( name === undefined ) throw new Error( "track name is undefined" );
|
|
|
|
|
|
- if( times === undefined || times.length === 0 ||
|
|
|
|
- values === undefined || values.length === 0 ) {
|
|
|
|
|
|
+ if( times === undefined || times.length === 0 ) {
|
|
|
|
|
|
throw new Error( "no keyframes in track named " + name );
|
|
throw new Error( "no keyframes in track named " + name );
|
|
|
|
|
|
@@ -221,25 +220,27 @@ THREE.KeyframeTrack.prototype = {
|
|
},
|
|
},
|
|
|
|
|
|
// 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
|
|
- // One could eventually ensure that all key.values in a track are all of the same type (otherwise interpolation makes no sense.)
|
|
|
|
validate: function() {
|
|
validate: function() {
|
|
|
|
|
|
- if ( this.getValueSize() % 1 !== 0 ) {
|
|
|
|
|
|
+ var valid = true;
|
|
|
|
|
|
- throw new Error( "invalid value size for track named " + this.name );
|
|
|
|
|
|
+ var valueSize = this.getValueSize();
|
|
|
|
+ if ( valueSize - Math.floor( valueSize ) !== 0 ) {
|
|
|
|
+
|
|
|
|
+ console.error( "invalid value size in track", this );
|
|
|
|
+ valid = false;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- var times = this.times;
|
|
|
|
- var values = this.values;
|
|
|
|
- var stride = this.getValueSize();
|
|
|
|
|
|
+ var times = this.times,
|
|
|
|
+ values = this.values,
|
|
|
|
|
|
- var nKeys = times.length;
|
|
|
|
|
|
+ nKeys = times.length;
|
|
|
|
|
|
if( nKeys === 0 ) {
|
|
if( nKeys === 0 ) {
|
|
|
|
|
|
- console.error( " track is empty, no keys", this );
|
|
|
|
- return;
|
|
|
|
|
|
+ console.error( "track is empty", this );
|
|
|
|
+ valid = false;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -249,46 +250,49 @@ THREE.KeyframeTrack.prototype = {
|
|
|
|
|
|
var currTime = times[ i ];
|
|
var currTime = times[ i ];
|
|
|
|
|
|
- if( currTime === undefined || currTime === null ) {
|
|
|
|
|
|
+ if ( Number.isNaN( currTime ) ) {
|
|
|
|
|
|
- console.error( " time is null in track", this, i );
|
|
|
|
- return;
|
|
|
|
|
|
+ console.error( "time is not a valid number", this, i, currTime );
|
|
|
|
+ valid = false;
|
|
|
|
+ break;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- if( ( typeof currTime ) !== 'number' || Number.isNaN( currTime ) ) {
|
|
|
|
|
|
+ if( prevTime !== null && prevTime > currTime ) {
|
|
|
|
|
|
- console.error( " time is not a valid number", this, i, currTime );
|
|
|
|
- return;
|
|
|
|
|
|
+ console.error( "out of order keys", this, i, currTime, prevTime );
|
|
|
|
+ valid = false;
|
|
|
|
+ break;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- var offset = i * stride;
|
|
|
|
- for ( var j = offset, e = offset + stride; j !== e; ++ j ) {
|
|
|
|
|
|
+ prevTime = currTime;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
- var value = values[ j ];
|
|
|
|
|
|
+ if ( values !== undefined ) {
|
|
|
|
|
|
- if( value === undefined || value === null) {
|
|
|
|
|
|
+ if ( THREE.AnimationUtils.isTypedArray( values ) ) {
|
|
|
|
|
|
- console.error( " value is null in track", this, j, value );
|
|
|
|
- return;
|
|
|
|
|
|
+ for ( var i = 0, n = values.length; i !== n; ++ i ) {
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ var value = values[ i ];
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ if ( Number.isNaN( value ) ) {
|
|
|
|
|
|
- if( prevTime !== null && prevTime > currTime ) {
|
|
|
|
|
|
+ console.error( "value is not a valid number", this, i, value );
|
|
|
|
+ valid = false;
|
|
|
|
+ break;
|
|
|
|
|
|
- console.error( " time is less than previous key time, out of order keys", this, i, currTime, prevTime );
|
|
|
|
- return;
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- prevTime = currTime;
|
|
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- return this;
|
|
|
|
|
|
+ return valid;
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|