|
@@ -72,22 +72,31 @@ function checkGeometryJsonWriting( geom, json ) {
|
|
|
QUnit.assert.equalKey( geom, json, 'uuid' );
|
|
|
QUnit.assert.equal( json.id, undefined, "should not persist id" );
|
|
|
|
|
|
+ var params = geom.parameters;
|
|
|
+ if ( !params ) {
|
|
|
+
|
|
|
+ return;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
// All parameters from geometry should be persisted.
|
|
|
- _.forOwn( geom.parameters, function ( val, key ) {
|
|
|
+ var keys = Object.keys( params );
|
|
|
+ for ( var i = 0, l = keys.length; i < l; i++ ) {
|
|
|
|
|
|
- QUnit.assert.equalKey( geom.parameters, json, key );
|
|
|
+ QUnit.assert.equalKey( params, json, keys[ i ] );
|
|
|
|
|
|
- });
|
|
|
+ }
|
|
|
|
|
|
// All parameters from json should be transfered to the geometry.
|
|
|
// json is flat. Ignore first level json properties that are not parameters.
|
|
|
var notParameters = [ "metadata", "uuid", "type" ];
|
|
|
- _.forOwn( json, function ( val, key ) {
|
|
|
-
|
|
|
- if ( notParameters.indexOf( key) === -1 ) QUnit.assert.equalKey( geom.parameters, json, key );
|
|
|
+ var keys = Object.keys( json );
|
|
|
+ for ( var i = 0, l = keys.length; i < l; i++ ) {
|
|
|
|
|
|
- });
|
|
|
+ var key = keys[ i ];
|
|
|
+ if ( notParameters.indexOf( key) === -1 ) QUnit.assert.equalKey( params, json, key );
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// Check parsing and reconstruction of json geometry
|
|
@@ -98,9 +107,8 @@ function checkGeometryJsonReading( json, geom ) {
|
|
|
var loader = new THREE.ObjectLoader();
|
|
|
var output = loader.parseGeometries( wrap );
|
|
|
|
|
|
- QUnit.assert.ok( output[geom.uuid], 'geometry matching source uuid not in output' );
|
|
|
- QUnit.assert.smartEqual( output[geom.uuid], geom, 'Reconstruct geometry from ObjectLoader' );
|
|
|
-
|
|
|
+ QUnit.assert.ok( output[ geom.uuid ], 'geometry matching source uuid not in output' );
|
|
|
+ QUnit.assert.smartEqual( output[ geom.uuid ], geom, 'Reconstruct geometry from ObjectLoader' );
|
|
|
}
|
|
|
|
|
|
// Verify geom -> json -> geom
|
|
@@ -115,22 +123,35 @@ function checkGeometryJsonRoundtrip( geom ) {
|
|
|
// Look for undefined and NaN values in numerical fieds.
|
|
|
function checkFinite( geom ) {
|
|
|
|
|
|
- var isNotFinite = _.any( geom.vertices, function ( v ) {
|
|
|
+ var allVerticesAreFinite = true;
|
|
|
+
|
|
|
+ var vertices = geom.vertices || [];
|
|
|
+
|
|
|
+ for ( var i = 0, l = vertices.length; i < l; i++ ) {
|
|
|
|
|
|
- return ! ( _.isFinite( v.x ) || _.isFinite( v.y ) || _.isFinite( v.z ) );
|
|
|
+ var v = geom.vertices[ i ];
|
|
|
|
|
|
- });
|
|
|
+ if ( !( isFinite( v.x ) || isFinite( v.y ) || isFinite( v.z ) ) ) {
|
|
|
+
|
|
|
+ allVerticesAreFinite = false;
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
// TODO Buffers, normal, etc.
|
|
|
|
|
|
- QUnit.assert.ok( isNotFinite === false, "contains non-finite coordinates" );
|
|
|
+ QUnit.assert.ok( allVerticesAreFinite, "contains only finite coordinates" );
|
|
|
|
|
|
}
|
|
|
|
|
|
// Run common geometry tests.
|
|
|
function runStdGeometryTests( assert, geometries ) {
|
|
|
|
|
|
- _.each( geometries, function( geom ) {
|
|
|
+ for ( var i = 0, l = geometries.length; i < l; i++ ) {
|
|
|
+
|
|
|
+ var geom = geometries[ i ];
|
|
|
|
|
|
checkFinite( geom );
|
|
|
|
|
@@ -140,7 +161,7 @@ function runStdGeometryTests( assert, geometries ) {
|
|
|
// json round trip
|
|
|
checkGeometryJsonRoundtrip( geom );
|
|
|
|
|
|
- });
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -154,15 +175,16 @@ function runStdGeometryTests( assert, geometries ) {
|
|
|
// Run common light tests.
|
|
|
function runStdLightTests( assert, lights ) {
|
|
|
|
|
|
- _.each( lights, function( light ) {
|
|
|
+ for ( var i = 0, l = lights.length; i < l; i++ ) {
|
|
|
+
|
|
|
+ var light = lights[i];
|
|
|
|
|
|
// Clone
|
|
|
checkLightClone( light );
|
|
|
|
|
|
// json round trip
|
|
|
checkLightJsonRoundtrip( light );
|
|
|
-
|
|
|
- });
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -209,4 +231,3 @@ function checkLightJsonRoundtrip( light ) {
|
|
|
checkLightJsonReading( json, light );
|
|
|
|
|
|
}
|
|
|
-
|