Bläddra i källkod

Merge pull request #12423 from moraxy/expand_tests_lights_curves

Tests: Added more tests for src/extras/curves/* and src/lights/*
Mr.doob 7 år sedan
förälder
incheckning
d3f0843f68

+ 43 - 14
test/unit/qunit-utils.js

@@ -243,33 +243,62 @@ function runStdGeometryTests( assert, geometries ) {
 //
 //
 
 
 // Run common light tests.
 // Run common light tests.
-function runStdLightTests( assert, lights ) {
+function runStdLightTests( lights ) {
 
 
-	for ( var i = 0, l = lights.length; i < l; i++ ) {
+	for ( var i = 0, l = lights.length; i < l; i ++ ) {
 
 
-		var light = lights[i];
+		var light = lights[ i ];
 
 
-		// Clone
-		checkLightClone( light );
+		// copy and clone
+		checkLightCopyClone( light );
+
+		// THREE.Light doesn't get parsed by ObjectLoader as it's only
+		// used as an abstract base class - so we skip the JSON tests
+		if ( light.type !== "Light" ) {
+
+			// json round trip
+			checkLightJsonRoundtrip( light );
+
+		}
 
 
-		// json round trip
-		checkLightJsonRoundtrip( light );
 	}
 	}
 
 
 }
 }
 
 
+function checkLightCopyClone( light ) {
 
 
-function checkLightClone( light ) {
+	// copy
+	var newLight = new light.constructor( 0xc0ffee );
+	newLight.copy( light );
+
+	QUnit.assert.notEqual( newLight.uuid, light.uuid, "Copied light's UUID differs from original" );
+	QUnit.assert.notEqual( newLight.id, light.id, "Copied light's id differs from original" );
+	QUnit.assert.smartEqual( newLight, light, "Copied light is equal to original" );
+
+	// real copy?
+	newLight.color.setHex( 0xc0ffee );
+	QUnit.assert.notStrictEqual(
+		newLight.color.getHex(), light.color.getHex(), "Copied light is independent from original"
+	);
 
 
 	// Clone
 	// Clone
-	var copy = light.clone();
-	QUnit.assert.notEqual( copy.uuid, light.uuid, "clone uuid should differ from original" );
-	QUnit.assert.notEqual( copy.id, light.id, "clone id should differ from original" );
-	QUnit.assert.smartEqual( copy, light, "clone is equal to original" );
+	var clone = light.clone(); // better get a new var
+	QUnit.assert.notEqual( clone.uuid, light.uuid, "Cloned light's UUID differs from original" );
+	QUnit.assert.notEqual( clone.id, light.id, "Clone light's id differs from original" );
+	QUnit.assert.smartEqual( clone, light, "Clone light is equal to original" );
 
 
+	// real clone?
+	clone.color.setHex( 0xc0ffee );
+	QUnit.assert.notStrictEqual(
+		clone.color.getHex(), light.color.getHex(), "Clone light is independent from original"
+	);
 
 
-	// json round trip with clone
-	checkLightJsonRoundtrip( copy );
+	if ( light.type !== "Light" ) {
+
+		// json round trip with clone
+		checkLightJsonRoundtrip( clone );
+
+	}
 
 
 }
 }
 
 

+ 0 - 6
test/unit/src/extras/curves/ArcCurve.js

@@ -1,6 +0,0 @@
-/**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
- */
-
-//Todo
-console.warn("Todo: Unit tests of ArcCurve")

+ 192 - 0
test/unit/src/extras/curves/CatmullRomCurve3.js

@@ -147,3 +147,195 @@ QUnit.test( "closed catmullrom basic check", function( assert ) {
 	} );
 	} );
 
 
 } );
 } );
+
+
+//
+// curve.type = 'catmullrom'; only from here on
+//
+QUnit.test( "getLength/getLengths", function ( assert ) {
+
+	var curve = new THREE.CatmullRomCurve3( positions );
+	curve.type = 'catmullrom';
+
+	var length = curve.getLength();
+	var expectedLength = 551.549686276872;
+
+	assert.numEqual( length, expectedLength, "Correct length of curve" );
+
+	var expectedLengths = [
+		0,
+		120,
+		220,
+		416.9771560359221,
+		536.9771560359221
+	];
+	var lengths = curve.getLengths( expectedLengths.length - 1 );
+
+	assert.strictEqual( lengths.length, expectedLengths.length, "Correct number of segments" );
+
+	lengths.forEach( function ( segment, i ) {
+
+		assert.numEqual( segment, expectedLengths[ i ], "segment[" + i + "] correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getPointAt", function ( assert ) {
+
+	var curve = new THREE.CatmullRomCurve3( positions );
+	curve.type = 'catmullrom';
+
+	var expectedPoints = [
+		new THREE.Vector3( - 60, - 100, 60 ),
+		new THREE.Vector3( - 64.84177333183106, 64.86956465359813, 64.84177333183106 ),
+		new THREE.Vector3( - 28.288507045700854, 104.83101184518996, 28.288507045700854 ),
+		new THREE.Vector3( 60, - 100, - 60 )
+	];
+
+	var points = [
+		curve.getPointAt( 0 ),
+		curve.getPointAt( 0.3 ),
+		curve.getPointAt( 0.5 ),
+		curve.getPointAt( 1 )
+	];
+
+	assert.deepEqual( points, expectedPoints, "Correct points" );
+
+} );
+
+QUnit.test( "getTangent/getTangentAt", function ( assert ) {
+
+	var curve = new THREE.CatmullRomCurve3( positions );
+	curve.type = 'catmullrom';
+
+	var expectedTangents = [
+		new THREE.Vector3( 0, 1, 0 ),
+		new THREE.Vector3( - 0.0001090274561657922, 0.9999999881130137, 0.0001090274561657922 ),
+		new THREE.Vector3( 0.7071067811865475, - 2.0930381713877622e-13, - 0.7071067811865475 ),
+		new THREE.Vector3( 0.43189437062802816, - 0.7917919583070032, - 0.43189437062802816 ),
+		new THREE.Vector3( - 0.00019991333100812723, - 0.9999999600346592, 0.00019991333100812723 )
+	];
+
+	var tangents = [
+		curve.getTangent( 0 ),
+		curve.getTangent( 0.25 ),
+		curve.getTangent( 0.5 ),
+		curve.getTangent( 0.75 ),
+		curve.getTangent( 1 )
+	];
+
+	expectedTangents.forEach( function ( exp, i ) {
+
+		var tangent = tangents[ i ];
+
+		assert.numEqual( tangent.x, exp.x, "getTangent #" + i + ": x correct" );
+		assert.numEqual( tangent.y, exp.y, "getTangent #" + i + ": y correct" );
+
+	} );
+
+	//
+
+	expectedTangents = [
+		new THREE.Vector3( 0, 1, 0 ),
+		new THREE.Vector3( - 0.10709018822205997, 0.9884651653817284, 0.10709018822205997 ),
+		new THREE.Vector3( 0.6396363672964268, - 0.4262987629159402, - 0.6396363672964268 ),
+		new THREE.Vector3( 0.5077298411616501, - 0.6960034603275557, - 0.5077298411616501 ),
+		new THREE.Vector3( - 0.00019991333100812723, - 0.9999999600346592, 0.00019991333100812723 )
+	];
+
+	tangents = [
+		curve.getTangentAt( 0 ),
+		curve.getTangentAt( 0.25 ),
+		curve.getTangentAt( 0.5 ),
+		curve.getTangentAt( 0.75 ),
+		curve.getTangentAt( 1 )
+	];
+
+	expectedTangents.forEach( function ( exp, i ) {
+
+		var tangent = tangents[ i ];
+
+		assert.numEqual( tangent.x, exp.x, "getTangentAt #" + i + ": x correct" );
+		assert.numEqual( tangent.y, exp.y, "getTangentAt #" + i + ": y correct" );
+
+	} );
+
+} );
+
+QUnit.test( "computeFrenetFrames", function ( assert ) {
+
+	var curve = new THREE.CatmullRomCurve3( positions );
+	curve.type = 'catmullrom';
+
+	var expected = {
+		binormals: [
+			new THREE.Vector3( - 1, 0, 0 ),
+			new THREE.Vector3( - 0.28685061854203, 0.6396363672964267, - 0.7131493814579701 ),
+			new THREE.Vector3( - 1.9982670528160395e-8, - 0.0001999133310081272, - 0.9999999800173295 )
+		],
+		normals: [
+			new THREE.Vector3( 0, 0, - 1 ),
+			new THREE.Vector3( - 0.7131493814579699, - 0.6396363672964268, - 0.2868506185420297 ),
+			new THREE.Vector3( - 0.9999999800173294, 0.00019991333100810582, - 1.99826701852146e-8 )
+		],
+		tangents: [
+			new THREE.Vector3( 0, 1, 0 ),
+			new THREE.Vector3( 0.6396363672964269, - 0.4262987629159403, - 0.6396363672964269 ),
+			new THREE.Vector3( - 0.0001999133310081273, - 0.9999999600346594, 0.0001999133310081273 )
+		]
+	};
+
+	var frames = curve.computeFrenetFrames( 2, false );
+
+	Object.keys( expected ).forEach( function ( group, i ) {
+
+		expected[ group ].forEach( function ( vec, j ) {
+
+			assert.numEqual( frames[ group ][ j ].x, vec.x, "Frenet frames [" + i + ", " + j + "].x correct" );
+			assert.numEqual( frames[ group ][ j ].y, vec.y, "Frenet frames [" + i + ", " + j + "].y correct" );
+			assert.numEqual( frames[ group ][ j ].z, vec.z, "Frenet frames [" + i + ", " + j + "].z correct" );
+
+		} );
+
+	} );
+
+} );
+
+QUnit.test( "getUtoTmapping", function ( assert ) {
+
+	var curve = new THREE.CatmullRomCurve3( positions );
+	curve.type = 'catmullrom';
+
+	var start = curve.getUtoTmapping( 0, 0 );
+	var end = curve.getUtoTmapping( 0, curve.getLength() );
+	var somewhere = curve.getUtoTmapping( 0.5, 500 );
+
+	var expectedSomewhere = 0.8964116382083199;
+
+	assert.strictEqual( start, 0, "getUtoTmapping( 0, 0 ) is the starting point" );
+	assert.strictEqual( end, 1, "getUtoTmapping( 0, length ) is the ending point" );
+	assert.numEqual( somewhere, expectedSomewhere, "getUtoTmapping( 0.5, 500 ) is correct" );
+
+} );
+
+QUnit.test( "getSpacedPoints", function ( assert ) {
+
+	var curve = new THREE.CatmullRomCurve3( positions );
+	curve.type = 'catmullrom';
+
+	var expectedPoints = [
+		new THREE.Vector3( - 60, - 100, 60 ),
+		new THREE.Vector3( - 60, 10.311489426555056, 60 ),
+		new THREE.Vector3( - 65.05889864636504, 117.99691802595966, 65.05889864636504 ),
+		new THREE.Vector3( 6.054276900088592, 78.7153118386369, - 6.054276900088592 ),
+		new THREE.Vector3( 64.9991491385602, 8.386980812799566, - 64.9991491385602 ),
+		new THREE.Vector3( 60, - 100, - 60 )
+	];
+
+	var points = curve.getSpacedPoints();
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+	assert.deepEqual( points, expectedPoints, "Correct points calculated" );
+
+} );

+ 189 - 3
test/unit/src/extras/curves/CubicBezierCurve.js

@@ -1,6 +1,192 @@
 /**
 /**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
+ * @author moraxy / https://github.com/moraxy
  */
  */
 
 
-//Todo
-console.warn("Todo: Unit tests of CubicBezierCurve")
+QUnit.module( "CubicBezierCurve", {
+
+	before: function () {
+
+		// from the docs
+		this.curve = new THREE.CubicBezierCurve(
+			new THREE.Vector2( - 10, 0 ),
+			new THREE.Vector2( - 5, 15 ),
+			new THREE.Vector2( 20, 15 ),
+			new THREE.Vector2( 10, 0 )
+		);
+
+	}
+
+} );
+
+QUnit.test( "Simple curve", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( - 10, 0 ),
+		new THREE.Vector2( - 3.359375, 8.4375 ),
+		new THREE.Vector2( 5.625, 11.25 ),
+		new THREE.Vector2( 11.796875, 8.4375 ),
+		new THREE.Vector2( 10, 0 )
+	];
+
+	var points = curve.getPoints( expectedPoints.length - 1 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+	assert.deepEqual( points, expectedPoints, "Correct points calculated" );
+
+	// symmetry
+	var curveRev = new THREE.CubicBezierCurve(
+		curve.v3, curve.v2, curve.v1, curve.v0
+	);
+
+	points = curveRev.getPoints( expectedPoints.length - 1 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Reversed: Correct number of points" );
+	assert.deepEqual( points, expectedPoints.reverse(), "Reversed: Correct points curve" );
+
+} );
+
+QUnit.test( "getLength/getLengths", function ( assert ) {
+
+	var curve = this.curve;
+
+	var length = curve.getLength();
+	var expectedLength = 36.64630888504102;
+
+	assert.numEqual( length, expectedLength, "Correct length of curve" );
+
+	var expectedLengths = [
+		0,
+		10.737285813492393,
+		20.15159143794633,
+		26.93408340370825,
+		35.56079575637337
+	];
+	var lengths = curve.getLengths( expectedLengths.length - 1 );
+
+	assert.strictEqual( lengths.length, expectedLengths.length, "Correct number of segments" );
+
+	lengths.forEach( function ( segment, i ) {
+
+		assert.numEqual( segment, expectedLengths[ i ], "segment[" + i + "] correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getPointAt", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( - 10, 0 ),
+		new THREE.Vector2( - 3.3188282598022596, 8.463722639089221 ),
+		new THREE.Vector2( 3.4718554735926617, 11.07899406116314 ),
+		new THREE.Vector2( 10, 0 )
+	];
+
+	var points = [
+		curve.getPointAt( 0 ),
+		curve.getPointAt( 0.3 ),
+		curve.getPointAt( 0.5 ),
+		curve.getPointAt( 1 )
+	];
+
+	assert.deepEqual( points, expectedPoints, "Correct points" );
+
+} );
+
+QUnit.test( "getTangent/getTangentAt", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedTangents = [
+		new THREE.Vector2( 0.316370061632252, 0.9486358543207215 ),
+		new THREE.Vector2( 0.838961283088303, 0.5441911111721949 ),
+		new THREE.Vector2( 1, 0 ),
+		new THREE.Vector2( 0.47628313192245453, - 0.8792919755383518 ),
+		new THREE.Vector2( - 0.5546041767829665, - 0.8321142992972107 )
+	];
+
+	var tangents = [
+		curve.getTangent( 0 ),
+		curve.getTangent( 0.25 ),
+		curve.getTangent( 0.5 ),
+		curve.getTangent( 0.75 ),
+		curve.getTangent( 1 )
+	];
+
+	expectedTangents.forEach( function ( exp, i ) {
+
+		var tangent = tangents[ i ];
+
+		assert.numEqual( tangent.x, exp.x, "getTangent #" + i + ": x correct" );
+		assert.numEqual( tangent.y, exp.y, "getTangent #" + i + ": y correct" );
+
+	} );
+
+	//
+
+	expectedTangents = [
+		new THREE.Vector2( 0.316370061632252, 0.9486358543207215 ),
+		new THREE.Vector2( 0.7794223085548987, 0.6264988945935596 ),
+		new THREE.Vector2( 0.988266153082452, 0.15274164681452052 ),
+		new THREE.Vector2( 0.5004110404199416, - 0.8657879593906534 ),
+		new THREE.Vector2( - 0.5546041767829665, - 0.8321142992972107 )
+	];
+
+	tangents = [
+		curve.getTangentAt( 0 ),
+		curve.getTangentAt( 0.25 ),
+		curve.getTangentAt( 0.5 ),
+		curve.getTangentAt( 0.75 ),
+		curve.getTangentAt( 1 )
+	];
+
+	expectedTangents.forEach( function ( exp, i ) {
+
+		var tangent = tangents[ i ];
+
+		assert.numEqual( tangent.x, exp.x, "getTangentAt #" + i + ": x correct" );
+		assert.numEqual( tangent.y, exp.y, "getTangentAt #" + i + ": y correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getUtoTmapping", function ( assert ) {
+
+	var curve = this.curve;
+
+	var start = curve.getUtoTmapping( 0, 0 );
+	var end = curve.getUtoTmapping( 0, curve.getLength() );
+	var somewhere = curve.getUtoTmapping( 0.5, 1 );
+
+	var expectedSomewhere = 0.02130029182257093;
+
+	assert.strictEqual( start, 0, "getUtoTmapping( 0, 0 ) is the starting point" );
+	assert.strictEqual( end, 1, "getUtoTmapping( 0, length ) is the ending point" );
+	assert.numEqual( somewhere, expectedSomewhere, "getUtoTmapping( 0.5, 1 ) is correct" );
+
+} );
+
+QUnit.test( "getSpacedPoints", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( - 10, 0 ),
+		new THREE.Vector2( - 6.16826457740703, 6.17025727295411 ),
+		new THREE.Vector2( - 0.058874033259857184, 10.1240558653185 ),
+		new THREE.Vector2( 7.123523032625162, 11.154913869041575 ),
+		new THREE.Vector2( 12.301846885754463, 6.808865855469985 ),
+		new THREE.Vector2( 10, 0 )
+	];
+
+	var points = curve.getSpacedPoints();
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+	assert.deepEqual( points, expectedPoints, "Correct points calculated" );
+
+} );

+ 227 - 3
test/unit/src/extras/curves/CubicBezierCurve3.js

@@ -1,6 +1,230 @@
 /**
 /**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
+ * @author moraxy / https://github.com/moraxy
  */
  */
 
 
-//Todo
-console.warn("Todo: Unit tests of CubicBezierCurve3")
+QUnit.module( "CubicBezierCurve3", {
+
+	before: function () {
+
+		// modified from the docs
+		this.curve = new THREE.CubicBezierCurve3(
+			new THREE.Vector3( - 10, 0, 2 ),
+			new THREE.Vector3( - 5, 15, 4 ),
+			new THREE.Vector3( 20, 15, - 5 ),
+			new THREE.Vector3( 10, 0, 10 )
+		);
+
+	}
+
+} );
+
+QUnit.test( "Simple curve", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector3( - 10, 0, 2 ),
+		new THREE.Vector3( - 3.359375, 8.4375, 1.984375 ),
+		new THREE.Vector3( 5.625, 11.25, 1.125 ),
+		new THREE.Vector3( 11.796875, 8.4375, 2.703125 ),
+		new THREE.Vector3( 10, 0, 10 )
+	];
+
+	var points = curve.getPoints( expectedPoints.length - 1 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+	assert.deepEqual( points, expectedPoints, "Correct points calculated" );
+
+	// symmetry
+	var curveRev = new THREE.CubicBezierCurve3(
+		curve.v3, curve.v2, curve.v1, curve.v0
+	);
+
+	points = curveRev.getPoints( expectedPoints.length - 1 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Reversed: Correct number of points" );
+	assert.deepEqual( points, expectedPoints.reverse(), "Reversed: Correct points curve" );
+
+} );
+
+QUnit.test( "getLength/getLengths", function ( assert ) {
+
+	var curve = this.curve;
+
+	var length = curve.getLength();
+	var expectedLength = 39.58103024989427;
+
+	assert.numEqual( length, expectedLength, "Correct length of curve" );
+
+	var expectedLengths = [
+		0,
+		10.73729718231036,
+		20.19074500737662,
+		27.154413277853756,
+		38.453287150114214
+	];
+	var lengths = curve.getLengths( expectedLengths.length - 1 );
+
+	assert.strictEqual( lengths.length, expectedLengths.length, "Correct number of segments" );
+
+	lengths.forEach( function ( segment, i ) {
+
+		assert.numEqual( segment, expectedLengths[ i ], "segment[" + i + "] correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getPointAt", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector3( - 10, 0, 2 ),
+		new THREE.Vector3( - 2.591880240484318, 8.908333501170798, 1.8953420625251136 ),
+		new THREE.Vector3( 4.866251460832755, 11.22787914038507, 1.150832855206874 ),
+		new THREE.Vector3( 10, 0, 10 )
+	];
+
+	var points = [
+		curve.getPointAt( 0 ),
+		curve.getPointAt( 0.3 ),
+		curve.getPointAt( 0.5 ),
+		curve.getPointAt( 1 )
+	];
+
+	assert.deepEqual( points, expectedPoints, "Correct points" );
+
+} );
+
+QUnit.test( "getTangent/getTangentAt", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedTangents = [
+		new THREE.Vector3( 0.3138715439944244, 0.9411440474105875, 0.12542940601858074 ),
+		new THREE.Vector3( 0.8351825262580098, 0.54174002562179, - 0.09480449605683638 ),
+		new THREE.Vector3( 0.9997531780538501, 0, - 0.02221672728433752 ),
+		new THREE.Vector3( 0.40693407933981185, - 0.7512629496079668, 0.5196235518317053 ),
+		new THREE.Vector3( - 0.42632467075185815, - 0.6396469221230213, 0.6396085444448543 )
+	];
+
+	var tangents = [
+		curve.getTangent( 0 ),
+		curve.getTangent( 0.25 ),
+		curve.getTangent( 0.5 ),
+		curve.getTangent( 0.75 ),
+		curve.getTangent( 1 )
+	];
+
+	expectedTangents.forEach( function ( exp, i ) {
+
+		var tangent = tangents[ i ];
+
+		assert.numEqual( tangent.x, exp.x, "getTangent #" + i + ": x correct" );
+		assert.numEqual( tangent.y, exp.y, "getTangent #" + i + ": y correct" );
+
+	} );
+
+	//
+
+	expectedTangents = [
+		new THREE.Vector3( 0.3138715439944244, 0.9411440474105875, 0.12542940601858074 ),
+		new THREE.Vector3( 0.8016539573770751, 0.5918626760037707, - 0.08396133262002324 ),
+		new THREE.Vector3( 0.997337559412928, 0.05740742907719314, - 0.044968652092444425 ),
+		new THREE.Vector3( 0.1389373097746809, - 0.7882209938358005, 0.5995032016837588 ),
+		new THREE.Vector3( - 0.42632467075185815, - 0.6396469221230213, 0.6396085444448543 )
+	];
+
+	tangents = [
+		curve.getTangentAt( 0 ),
+		curve.getTangentAt( 0.25 ),
+		curve.getTangentAt( 0.5 ),
+		curve.getTangentAt( 0.75 ),
+		curve.getTangentAt( 1 )
+	];
+
+	expectedTangents.forEach( function ( exp, i ) {
+
+		var tangent = tangents[ i ];
+
+		assert.numEqual( tangent.x, exp.x, "getTangentAt #" + i + ": x correct" );
+		assert.numEqual( tangent.y, exp.y, "getTangentAt #" + i + ": y correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getUtoTmapping", function ( assert ) {
+
+	var curve = this.curve;
+
+	var start = curve.getUtoTmapping( 0, 0 );
+	var end = curve.getUtoTmapping( 0, curve.getLength() );
+	var somewhere = curve.getUtoTmapping( 0.5, 1 );
+
+	var expectedSomewhere = 0.021163245321323316;
+
+	assert.strictEqual( start, 0, "getUtoTmapping( 0, 0 ) is the starting point" );
+	assert.strictEqual( end, 1, "getUtoTmapping( 0, length ) is the ending point" );
+	assert.numEqual( somewhere, expectedSomewhere, "getUtoTmapping( 0.5, 1 ) is correct" );
+
+} );
+
+QUnit.test( "getSpacedPoints", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector3( - 10, 0, 2 ),
+		new THREE.Vector3( - 5.756524515061918, 6.568020242700483, 2.22116711170301 ),
+		new THREE.Vector3( 1.0003511895116906, 10.49656064587831, 1.4727101010850698 ),
+		new THREE.Vector3( 8.767656412295171, 10.784286845278622, 1.2873599519775174 ),
+		new THREE.Vector3( 12.306772513558396, 5.545103788071547, 4.909948454535794 ),
+		new THREE.Vector3( 10, 0, 10 )
+	];
+
+	var points = curve.getSpacedPoints();
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+	assert.deepEqual( points, expectedPoints, "Correct points calculated" );
+
+} );
+
+QUnit.test( "computeFrenetFrames", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expected = {
+		binormals: [
+			new THREE.Vector3( - 0.9486358543207215, 0.316370061632252, - 6.938893903907228e-18 ),
+			new THREE.Vector3( - 0.05491430765311864, 0.9969838307670049, 0.054842137122173326 ),
+			new THREE.Vector3( 0.5944656510461876, 0.334836503700931, 0.7310917216844742 )
+		],
+		normals: [
+			new THREE.Vector3( 0.03968210891259515, 0.11898683173537697, - 0.9921025471723304 ),
+			new THREE.Vector3( - 0.047981365124836806, 0.05222670079466692, - 0.9974819097732357 ),
+			new THREE.Vector3( 0.6818048583242511, - 0.6919077473246573, - 0.23749906180354932 )
+		],
+		tangents: [
+			new THREE.Vector3( 0.3138715439944244, 0.9411440474105875, 0.12542940601858074 ),
+			new THREE.Vector3( 0.9973375594129282, 0.05740742907719315, - 0.04496865209244443 ),
+			new THREE.Vector3( - 0.42632467075185815, - 0.6396469221230213, 0.6396085444448543 )
+		]
+	};
+
+	var frames = curve.computeFrenetFrames( 2, false );
+
+	Object.keys( expected ).forEach( function ( group, i ) {
+
+		expected[ group ].forEach( function ( vec, j ) {
+
+			assert.numEqual( frames[ group ][ j ].x, vec.x, "Frenet frames [" + i + ", " + j + "].x correct" );
+			assert.numEqual( frames[ group ][ j ].y, vec.y, "Frenet frames [" + i + ", " + j + "].y correct" );
+			assert.numEqual( frames[ group ][ j ].z, vec.z, "Frenet frames [" + i + ", " + j + "].z correct" );
+
+		} );
+
+	} );
+
+} );

+ 170 - 3
test/unit/src/extras/curves/EllipseCurve.js

@@ -1,6 +1,173 @@
 /**
 /**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
+ * @author moraxy / https://github.com/moraxy
  */
  */
 
 
-//Todo
-console.warn("Todo: Unit tests of EllipseCurve")
+QUnit.module( "EllipseCurve", {
+
+	before: function () {
+
+		// from the docs
+		this.curve = new THREE.EllipseCurve(
+			0, 0, // ax, aY
+			10, 10, // xRadius, yRadius
+			0, 2 * Math.PI, // aStartAngle, aEndAngle
+			false, // aClockwise
+			0 // aRotation
+		);
+
+	}
+
+} );
+
+QUnit.test( "Simple curve", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( 10, 0 ),
+		new THREE.Vector2( 0, 10 ),
+		new THREE.Vector2( - 10, 0 ),
+		new THREE.Vector2( 0, - 10 ),
+		new THREE.Vector2( 10, 0 )
+	];
+
+	var points = curve.getPoints( expectedPoints.length - 1 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+
+	points.forEach( function ( point, i ) {
+
+		assert.numEqual( point.x, expectedPoints[ i ].x, "point[" + i + "].x correct" );
+		assert.numEqual( point.y, expectedPoints[ i ].y, "point[" + i + "].y correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getLength/getLengths", function ( assert ) {
+
+	var curve = this.curve;
+
+	var length = curve.getLength();
+	var expectedLength = 62.829269247282795;
+
+	assert.numEqual( length, expectedLength, "Correct length of curve" );
+
+	var lengths = curve.getLengths( 5 );
+	var expectedLengths = [
+		0,
+		11.755705045849462,
+		23.51141009169892,
+		35.26711513754839,
+		47.02282018339785,
+		58.77852522924731
+	];
+
+	assert.strictEqual( lengths.length, expectedLengths.length, "Correct number of segments" );
+
+	lengths.forEach( function ( segment, i ) {
+
+		assert.numEqual( segment, expectedLengths[ i ], "segment[" + i + "] correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getPoint/getPointAt", function ( assert ) {
+
+	var curve = this.curve;
+
+	var testValues = [ 0, 0.3, 0.5, 0.7, 1 ];
+
+	testValues.forEach( function ( val, i ) {
+
+		var expectedX = Math.cos( val * Math.PI * 2 ) * 10;
+		var expectedY = Math.sin( val * Math.PI * 2 ) * 10;
+
+		var p = curve.getPoint( val );
+		var a = curve.getPointAt( val );
+
+		assert.numEqual( p.x, expectedX, "getPoint(" + val + ").x correct" );
+		assert.numEqual( p.y, expectedY, "getPoint(" + val + ").y correct" );
+
+		assert.numEqual( a.x, expectedX, "getPointAt(" + val + ").x correct" );
+		assert.numEqual( a.y, expectedY, "getPointAt(" + val + ").y correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getTangent", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedTangents = [
+		new THREE.Vector2( - 0.000314159260186071, 0.9999999506519786 ),
+		new THREE.Vector2( - 1, 0 ),
+		new THREE.Vector2( 0, - 1 ),
+		new THREE.Vector2( 1, 0 ),
+		new THREE.Vector2( 0.00031415926018600165, 0.9999999506519784 )
+	];
+
+	var tangents = [
+		curve.getTangent( 0 ),
+		curve.getTangent( 0.25 ),
+		curve.getTangent( 0.5 ),
+		curve.getTangent( 0.75 ),
+		curve.getTangent( 1 )
+	];
+
+	expectedTangents.forEach( function ( exp, i ) {
+
+		var tangent = tangents[ i ];
+
+		assert.numEqual( tangent.x, exp.x, "getTangent #" + i + ": x correct" );
+		assert.numEqual( tangent.y, exp.y, "getTangent #" + i + ": y correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getUtoTmapping", function ( assert ) {
+
+	var curve = this.curve;
+
+	var start = curve.getUtoTmapping( 0, 0 );
+	var end = curve.getUtoTmapping( 0, curve.getLength() );
+	var somewhere = curve.getUtoTmapping( 0.7, 1 );
+
+	var expectedSomewhere = 0.01591614882650014;
+
+	assert.strictEqual( start, 0, "getUtoTmapping( 0, 0 ) is the starting point" );
+	assert.strictEqual( end, 1, "getUtoTmapping( 0, length ) is the ending point" );
+	assert.numEqual( somewhere, expectedSomewhere, "getUtoTmapping( 0.7, 1 ) is correct" );
+
+} );
+
+QUnit.test( "getSpacedPoints", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( 10, 0 ),
+		new THREE.Vector2( 3.0901699437494603, 9.51056516295154 ),
+		new THREE.Vector2( - 8.090169943749492, 5.877852522924707 ),
+		new THREE.Vector2( - 8.090169943749459, - 5.877852522924751 ),
+		new THREE.Vector2( 3.0901699437494807, - 9.510565162951533 ),
+		new THREE.Vector2( 10, - 2.4492935982947065e-15 )
+	];
+
+	var points = curve.getSpacedPoints();
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+
+	expectedPoints.forEach( function ( exp, i ) {
+
+		var point = points[ i ];
+
+		assert.numEqual( point.x, exp.x, "Point #" + i + ": x correct" );
+		assert.numEqual( point.y, exp.y, "Point #" + i + ": y correct" );
+
+	} );
+
+} );

+ 149 - 3
test/unit/src/extras/curves/LineCurve.js

@@ -1,6 +1,152 @@
 /**
 /**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
+ * @author moraxy / https://github.com/moraxy
  */
  */
 
 
-//Todo
-console.warn("Todo: Unit tests of LineCurve")
+QUnit.module( "LineCurve", {
+
+	before: function () {
+
+		this.points = [
+			new THREE.Vector2( 0, 0 ),
+			new THREE.Vector2( 10, 10 ),
+			new THREE.Vector2( - 10, 10 ),
+			new THREE.Vector2( - 8, 5 )
+		];
+
+		this.curve = new THREE.LineCurve( this.points[ 0 ], this.points[ 1 ] );
+
+	}
+
+} );
+
+QUnit.test( "Simple curve", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( 0, 0 ),
+		new THREE.Vector2( 2, 2 ),
+		new THREE.Vector2( 4, 4 ),
+		new THREE.Vector2( 6, 6 ),
+		new THREE.Vector2( 8, 8 ),
+		new THREE.Vector2( 10, 10 )
+	];
+
+	var points = curve.getPoints();
+
+	assert.deepEqual( points, expectedPoints, "Correct points for first curve" );
+
+	//
+
+	curve = new THREE.LineCurve( this.points[ 1 ], this.points[ 2 ] );
+
+	expectedPoints = [
+		new THREE.Vector2( 10, 10 ),
+		new THREE.Vector2( 6, 10 ),
+		new THREE.Vector2( 2, 10 ),
+		new THREE.Vector2( - 2, 10 ),
+		new THREE.Vector2( - 6, 10 ),
+		new THREE.Vector2( - 10, 10 )
+	];
+
+	points = curve.getPoints();
+
+	assert.deepEqual( points, expectedPoints, "Correct points for second curve" );
+
+} );
+
+QUnit.test( "getLength/getLengths", function ( assert ) {
+
+	var curve = this.curve;
+
+	var length = curve.getLength();
+	var expectedLength = Math.sqrt( 200 );
+
+	assert.numEqual( length, expectedLength, "Correct length of curve" );
+
+	var lengths = curve.getLengths( 5 );
+	var expectedLengths = [
+		0.0,
+		Math.sqrt( 8 ),
+		Math.sqrt( 32 ),
+		Math.sqrt( 72 ),
+		Math.sqrt( 128 ),
+		Math.sqrt( 200 )
+	];
+
+	assert.strictEqual( lengths.length, expectedLengths.length, "Correct number of segments" );
+
+	lengths.forEach( function ( segment, i ) {
+
+		assert.numEqual( segment, expectedLengths[ i ], "segment[" + i + "] correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getPointAt", function ( assert ) {
+
+	var curve = new THREE.LineCurve( this.points[ 0 ], this.points[ 3 ] );
+
+	var expectedPoints = [
+		new THREE.Vector2( 0, 0 ),
+		new THREE.Vector2( - 2.4, 1.5 ),
+		new THREE.Vector2( - 4, 2.5 ),
+		new THREE.Vector2( - 8, 5 )
+	];
+
+	var points = [
+		curve.getPointAt( 0 ),
+		curve.getPointAt( 0.3 ),
+		curve.getPointAt( 0.5 ),
+		curve.getPointAt( 1 )
+	];
+
+	assert.deepEqual( points, expectedPoints, "Correct points" );
+
+} );
+
+QUnit.test( "getTangent", function ( assert ) {
+
+	var curve = this.curve;
+
+	var tangent = curve.getTangent( 0 );
+	var expectedTangent = Math.sqrt( 0.5 );
+
+	assert.numEqual( tangent.x, expectedTangent, "tangent.x correct" );
+	assert.numEqual( tangent.y, expectedTangent, "tangent.y correct" );
+
+} );
+
+QUnit.test( "getUtoTmapping", function ( assert ) {
+
+	var curve = this.curve;
+
+	var start = curve.getUtoTmapping( 0, 0 );
+	var end = curve.getUtoTmapping( 0, curve.getLength() );
+	var somewhere = curve.getUtoTmapping( 0.3, 0 );
+
+	assert.strictEqual( start, 0, "getUtoTmapping( 0, 0 ) is the starting point" );
+	assert.strictEqual( end, 1, "getUtoTmapping( 0, length ) is the ending point" );
+	assert.numEqual( somewhere, 0.3, "getUtoTmapping( 0.3, 0 ) is correct" );
+
+} );
+
+QUnit.test( "getSpacedPoints", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( 0, 0 ),
+		new THREE.Vector2( 2.5, 2.5 ),
+		new THREE.Vector2( 5, 5 ),
+		new THREE.Vector2( 7.5, 7.5 ),
+		new THREE.Vector2( 10, 10 )
+	];
+
+	var points = curve.getSpacedPoints( 4 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+	assert.deepEqual( points, expectedPoints, "Correct points calculated" );
+
+} );

+ 178 - 3
test/unit/src/extras/curves/LineCurve3.js

@@ -1,6 +1,181 @@
 /**
 /**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
+ * @author moraxy / https://github.com/moraxy
  */
  */
 
 
-//Todo
-console.warn("Todo: Unit tests of LineCurve3")
+QUnit.module( "LineCurve3", {
+
+	before: function () {
+
+		this.points = [
+			new THREE.Vector3( 0, 0, 0 ),
+			new THREE.Vector3( 10, 10, 10 ),
+			new THREE.Vector3( - 10, 10, - 10 ),
+			new THREE.Vector3( - 8, 5, - 7 )
+		];
+
+		this.curve = new THREE.LineCurve3( this.points[ 0 ], this.points[ 1 ] );
+
+	}
+
+} );
+
+QUnit.test( "Simple curve", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector3( 0, 0, 0 ),
+		new THREE.Vector3( 2, 2, 2 ),
+		new THREE.Vector3( 4, 4, 4 ),
+		new THREE.Vector3( 6, 6, 6 ),
+		new THREE.Vector3( 8, 8, 8 ),
+		new THREE.Vector3( 10, 10, 10 )
+	];
+
+	var points = curve.getPoints();
+
+	assert.deepEqual( points, expectedPoints, "Correct points for first curve" );
+
+	//
+
+	curve = new THREE.LineCurve3( this.points[ 1 ], this.points[ 2 ] );
+
+	expectedPoints = [
+		new THREE.Vector3( 10, 10, 10 ),
+		new THREE.Vector3( 6, 10, 6 ),
+		new THREE.Vector3( 2, 10, 2 ),
+		new THREE.Vector3( - 2, 10, - 2 ),
+		new THREE.Vector3( - 6, 10, - 6 ),
+		new THREE.Vector3( - 10, 10, - 10 )
+	];
+
+	points = curve.getPoints();
+
+	assert.deepEqual( points, expectedPoints, "Correct points for second curve" );
+
+} );
+
+QUnit.test( "getLength/getLengths", function ( assert ) {
+
+	var curve = this.curve;
+
+	var length = curve.getLength();
+	var expectedLength = Math.sqrt( 300 );
+
+	assert.numEqual( length, expectedLength, "Correct length of curve" );
+
+	var lengths = curve.getLengths( 5 );
+	var expectedLengths = [
+		0.0,
+		Math.sqrt( 12 ),
+		Math.sqrt( 48 ),
+		Math.sqrt( 108 ),
+		Math.sqrt( 192 ),
+		Math.sqrt( 300 )
+	];
+
+	assert.strictEqual( lengths.length, expectedLengths.length, "Correct number of segments" );
+
+	lengths.forEach( function ( segment, i ) {
+
+		assert.numEqual( segment, expectedLengths[ i ], "segment[" + i + "] correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getPointAt", function ( assert ) {
+
+	var curve = new THREE.LineCurve3( this.points[ 0 ], this.points[ 3 ] );
+
+	var expectedPoints = [
+		new THREE.Vector3( 0, 0, 0 ),
+		new THREE.Vector3( - 2.4, 1.5, - 2.1 ),
+		new THREE.Vector3( - 4, 2.5, - 3.5 ),
+		new THREE.Vector3( - 8, 5, - 7 )
+	];
+
+	var points = [
+		curve.getPointAt( 0 ),
+		curve.getPointAt( 0.3 ),
+		curve.getPointAt( 0.5 ),
+		curve.getPointAt( 1 )
+	];
+
+	assert.deepEqual( points, expectedPoints, "Correct getPointAt points" );
+
+} );
+
+QUnit.test( "getTangent/getTangentAt", function ( assert ) {
+
+	var curve = this.curve;
+
+	var tangent = curve.getTangent( 0.5 );
+	var expectedTangent = Math.sqrt( 1 / 3 );
+
+	assert.numEqual( tangent.x, expectedTangent, "tangent.x correct" );
+	assert.numEqual( tangent.y, expectedTangent, "tangent.y correct" );
+	assert.numEqual( tangent.z, expectedTangent, "tangent.z correct" );
+
+	tangent = curve.getTangentAt( 0.5 );
+
+	assert.numEqual( tangent.x, expectedTangent, "tangentAt.x correct" );
+	assert.numEqual( tangent.y, expectedTangent, "tangentAt.y correct" );
+	assert.numEqual( tangent.z, expectedTangent, "tangentAt.z correct" );
+
+} );
+
+QUnit.test( "computeFrenetFrames", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expected = {
+		binormals: new THREE.Vector3( - 0.5 * Math.sqrt( 2 ), 0.5 * Math.sqrt( 2 ), 0 ),
+		normals: new THREE.Vector3( Math.sqrt( 1 / 6 ), Math.sqrt( 1 / 6 ), - Math.sqrt( 2 / 3 ) ),
+		tangents: new THREE.Vector3( Math.sqrt( 1 / 3 ), Math.sqrt( 1 / 3 ), Math.sqrt( 1 / 3 ) )
+	};
+
+	var frames = curve.computeFrenetFrames( 1, false );
+
+	for ( var val in expected ) {
+
+		assert.numEqual( frames[ val ][ 0 ].x, expected[ val ].x, "Frenet frames " + val + ".x correct" );
+		assert.numEqual( frames[ val ][ 0 ].y, expected[ val ].y, "Frenet frames " + val + ".y correct" );
+		assert.numEqual( frames[ val ][ 0 ].z, expected[ val ].z, "Frenet frames " + val + ".z correct" );
+
+	}
+
+} );
+
+QUnit.test( "getUtoTmapping", function ( assert ) {
+
+	var curve = this.curve;
+
+	var start = curve.getUtoTmapping( 0, 0 );
+	var end = curve.getUtoTmapping( 0, curve.getLength() );
+	var somewhere = curve.getUtoTmapping( 0.7, 0 );
+
+	assert.strictEqual( start, 0, "getUtoTmapping( 0, 0 ) is the starting point" );
+	assert.strictEqual( end, 1, "getUtoTmapping( 0, length ) is the ending point" );
+	assert.numEqual( somewhere, 0.7, "getUtoTmapping( 0.7, 0 ) is correct" );
+
+} );
+
+QUnit.test( "getSpacedPoints", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector3( 0, 0, 0 ),
+		new THREE.Vector3( 2.5, 2.5, 2.5 ),
+		new THREE.Vector3( 5, 5, 5 ),
+		new THREE.Vector3( 7.5, 7.5, 7.5 ),
+		new THREE.Vector3( 10, 10, 10 )
+	];
+
+	var points = curve.getSpacedPoints( 4 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+	assert.deepEqual( points, expectedPoints, "Correct points calculated" );
+
+} );

+ 188 - 3
test/unit/src/extras/curves/QuadraticBezierCurve.js

@@ -1,6 +1,191 @@
 /**
 /**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
+ * @author moraxy / https://github.com/moraxy
  */
  */
 
 
-//Todo
-console.warn("Todo: Unit tests of QuadraticBezierCurve")
+QUnit.module( "QuadraticBezierCurve", {
+
+	before: function () {
+
+		// from the docs
+		this.curve = new THREE.QuadraticBezierCurve(
+			new THREE.Vector2( - 10, 0 ),
+			new THREE.Vector2( 20, 15 ),
+			new THREE.Vector2( 10, 0 )
+		);
+
+	}
+
+} );
+
+QUnit.test( "Simple curve", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( - 10, 0 ),
+		new THREE.Vector2( 2.5, 5.625 ),
+		new THREE.Vector2( 10, 7.5 ),
+		new THREE.Vector2( 12.5, 5.625 ),
+		new THREE.Vector2( 10, 0 )
+	];
+
+	var points = curve.getPoints( expectedPoints.length - 1 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+	assert.deepEqual( points, expectedPoints, "Correct points calculated" );
+
+	// symmetry
+	var curveRev = new THREE.QuadraticBezierCurve(
+		curve.v2, curve.v1, curve.v0
+	);
+
+	points = curveRev.getPoints( expectedPoints.length - 1 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Reversed: Correct number of points" );
+	assert.deepEqual( points, expectedPoints.reverse(), "Reversed: Correct points curve" );
+
+} );
+
+QUnit.test( "getLength/getLengths", function ( assert ) {
+
+	var curve = this.curve;
+
+	var length = curve.getLength();
+	var expectedLength = 31.269026549416683;
+
+	assert.numEqual( length, expectedLength, "Correct length of curve" );
+
+	var expectedLengths = [
+		0,
+		13.707320124663317,
+		21.43814317269643,
+		24.56314317269643,
+		30.718679298818998
+	];
+	var lengths = curve.getLengths( expectedLengths.length - 1 );
+
+	assert.strictEqual( lengths.length, expectedLengths.length, "Correct number of segments" );
+
+	lengths.forEach( function ( segment, i ) {
+
+		assert.numEqual( segment, expectedLengths[ i ], "segment[" + i + "] correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getPointAt", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( - 10, 0 ),
+		new THREE.Vector2( - 1.5127849599387615, 3.993582003773624 ),
+		new THREE.Vector2( 4.310076165722796, 6.269921971403917 ),
+		new THREE.Vector2( 10, 0 )
+	];
+
+	var points = [
+		curve.getPointAt( 0 ),
+		curve.getPointAt( 0.3 ),
+		curve.getPointAt( 0.5 ),
+		curve.getPointAt( 1 )
+	];
+
+	assert.deepEqual( points, expectedPoints, "Correct points" );
+
+} );
+
+QUnit.test( "getTangent/getTangentAt", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedTangents = [
+		new THREE.Vector2( 0.89443315420562, 0.44720166888975904 ),
+		new THREE.Vector2( 0.936329177569021, 0.3511234415884543 ),
+		new THREE.Vector2( 1, 0 ),
+		new THREE.Vector2( - 5.921189464667277e-13, - 1 ),
+		new THREE.Vector2( - 0.5546617882904897, - 0.8320758983472577 )
+	];
+
+	var tangents = [
+		curve.getTangent( 0 ),
+		curve.getTangent( 0.25 ),
+		curve.getTangent( 0.5 ),
+		curve.getTangent( 0.75 ),
+		curve.getTangent( 1 )
+	];
+
+	expectedTangents.forEach( function ( exp, i ) {
+
+		var tangent = tangents[ i ];
+
+		assert.numEqual( tangent.x, exp.x, "getTangent #" + i + ": x correct" );
+		assert.numEqual( tangent.y, exp.y, "getTangent #" + i + ": y correct" );
+
+	} );
+
+	//
+
+	expectedTangents = [
+		new THREE.Vector2( 0.89443315420562, 0.44720166888975904 ),
+		new THREE.Vector2( 0.9125211423360805, 0.40902954024086674 ),
+		new THREE.Vector2( 0.9480289098765387, 0.3181842014278863 ),
+		new THREE.Vector2( 0.7969127189169473, - 0.6040944615111106 ),
+		new THREE.Vector2( - 0.5546617882904897, - 0.8320758983472577 )
+	];
+
+	tangents = [
+		curve.getTangentAt( 0 ),
+		curve.getTangentAt( 0.25 ),
+		curve.getTangentAt( 0.5 ),
+		curve.getTangentAt( 0.75 ),
+		curve.getTangentAt( 1 )
+	];
+
+	expectedTangents.forEach( function ( exp, i ) {
+
+		var tangent = tangents[ i ];
+
+		assert.numEqual( tangent.x, exp.x, "getTangentAt #" + i + ": x correct" );
+		assert.numEqual( tangent.y, exp.y, "getTangentAt #" + i + ": y correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getUtoTmapping", function ( assert ) {
+
+	var curve = this.curve;
+
+	var start = curve.getUtoTmapping( 0, 0 );
+	var end = curve.getUtoTmapping( 0, curve.getLength() );
+	var somewhere = curve.getUtoTmapping( 0.5, 1 );
+
+	var expectedSomewhere = 0.015073978276116116;
+
+	assert.strictEqual( start, 0, "getUtoTmapping( 0, 0 ) is the starting point" );
+	assert.strictEqual( end, 1, "getUtoTmapping( 0, length ) is the ending point" );
+	assert.numEqual( somewhere, expectedSomewhere, "getUtoTmapping( 0.5, 1 ) is correct" );
+
+} );
+
+QUnit.test( "getSpacedPoints", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( - 10, 0 ),
+		new THREE.Vector2( - 4.366603655406173, 2.715408933540383 ),
+		new THREE.Vector2( 1.3752241477827831, 5.191972084404416 ),
+		new THREE.Vector2( 7.312990279153634, 7.136310044848586 ),
+		new THREE.Vector2( 12.499856644824826, 5.653289188715387 ),
+		new THREE.Vector2( 10, 0 )
+	];
+
+	var points = curve.getSpacedPoints();
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+	assert.deepEqual( points, expectedPoints, "Correct points calculated" );
+
+} );

+ 226 - 3
test/unit/src/extras/curves/QuadraticBezierCurve3.js

@@ -1,6 +1,229 @@
 /**
 /**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
+ * @author moraxy / https://github.com/moraxy
  */
  */
 
 
-//Todo
-console.warn("Todo: Unit tests of QuadraticBezierCurve")
+QUnit.module( "QuadraticBezierCurve3", {
+
+	before: function () {
+
+		// modified from the docs
+		this.curve = new THREE.QuadraticBezierCurve3(
+			new THREE.Vector3( - 10, 0, 2 ),
+			new THREE.Vector3( 20, 15, - 5 ),
+			new THREE.Vector3( 10, 0, 10 )
+		);
+
+	}
+
+} );
+
+QUnit.test( "Simple curve", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector3( - 10, 0, 2 ),
+		new THREE.Vector3( 2.5, 5.625, - 0.125 ),
+		new THREE.Vector3( 10, 7.5, 0.5 ),
+		new THREE.Vector3( 12.5, 5.625, 3.875 ),
+		new THREE.Vector3( 10, 0, 10 )
+	];
+
+	var points = curve.getPoints( expectedPoints.length - 1 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+	assert.deepEqual( points, expectedPoints, "Correct points calculated" );
+
+	// symmetry
+	var curveRev = new THREE.QuadraticBezierCurve3(
+		curve.v2, curve.v1, curve.v0
+	);
+
+	points = curveRev.getPoints( expectedPoints.length - 1 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Reversed: Correct number of points" );
+	assert.deepEqual( points, expectedPoints.reverse(), "Reversed: Correct points curve" );
+
+} );
+
+QUnit.test( "getLength/getLengths", function ( assert ) {
+
+	var curve = this.curve;
+
+	var length = curve.getLength();
+	var expectedLength = 35.47294274967861;
+
+	assert.numEqual( length, expectedLength, "Correct length of curve" );
+
+	var expectedLengths = [
+		0,
+		13.871057998581074,
+		21.62710402732536,
+		26.226696400568883,
+		34.91037361704809
+	];
+	var lengths = curve.getLengths( expectedLengths.length - 1 );
+
+	assert.strictEqual( lengths.length, expectedLengths.length, "Correct number of segments" );
+
+	lengths.forEach( function ( segment, i ) {
+
+		assert.numEqual( segment, expectedLengths[ i ], "segment[" + i + "] correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getPointAt", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector3( - 10, 0, 2 ),
+		new THREE.Vector3( - 0.4981634504454243, 4.427089043881476, 0.19308849757196012 ),
+		new THREE.Vector3( 6.149415812887238, 6.838853310980195, - 0.20278120208668637 ),
+		new THREE.Vector3( 10, 0, 10 )
+	];
+
+	var points = [
+		curve.getPointAt( 0 ),
+		curve.getPointAt( 0.3 ),
+		curve.getPointAt( 0.5 ),
+		curve.getPointAt( 1 )
+	];
+
+	assert.deepEqual( points, expectedPoints, "Correct points" );
+
+} );
+
+QUnit.test( "getTangent/getTangentAt", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedTangents = [
+		new THREE.Vector3( 0.8755715084258769, 0.4377711603816079, - 0.2042815331129452 ),
+		new THREE.Vector3( 0.9340289249885844, 0.3502608468707904, - 0.07005216937416067 ),
+		new THREE.Vector3( 0.9284766908853163, 0, 0.37139067635396156 ),
+		new THREE.Vector3( - 3.669031233375946e-13, - 0.6196442885791218, 0.7848827655333463 ),
+		new THREE.Vector3( - 0.4263618889888853, - 0.6396068005601663, 0.6396238584473043 )
+	];
+
+	var tangents = [
+		curve.getTangent( 0 ),
+		curve.getTangent( 0.25 ),
+		curve.getTangent( 0.5 ),
+		curve.getTangent( 0.75 ),
+		curve.getTangent( 1 )
+	];
+
+	expectedTangents.forEach( function ( exp, i ) {
+
+		var tangent = tangents[ i ];
+
+		assert.numEqual( tangent.x, exp.x, "getTangent #" + i + ": x correct" );
+		assert.numEqual( tangent.y, exp.y, "getTangent #" + i + ": y correct" );
+
+	} );
+
+	//
+
+	expectedTangents = [
+		new THREE.Vector3( 0.8755715084258769, 0.4377711603816079, - 0.2042815331129452 ),
+		new THREE.Vector3( 0.9060725703490549, 0.3984742932857448, - 0.14230507668907377 ),
+		new THREE.Vector3( 0.9621604167456882, 0.2688562845452628, 0.044312872940942424 ),
+		new THREE.Vector3( 0.016586454041780826, - 0.6163270940470614, 0.7873155674098058 ),
+		new THREE.Vector3( - 0.4263618889888853, - 0.6396068005601663, 0.6396238584473043 )
+	];
+
+	tangents = [
+		curve.getTangentAt( 0 ),
+		curve.getTangentAt( 0.25 ),
+		curve.getTangentAt( 0.5 ),
+		curve.getTangentAt( 0.75 ),
+		curve.getTangentAt( 1 )
+	];
+
+	expectedTangents.forEach( function ( exp, i ) {
+
+		var tangent = tangents[ i ];
+
+		assert.numEqual( tangent.x, exp.x, "getTangentAt #" + i + ": x correct" );
+		assert.numEqual( tangent.y, exp.y, "getTangentAt #" + i + ": y correct" );
+
+	} );
+
+} );
+
+QUnit.test( "getUtoTmapping", function ( assert ) {
+
+	var curve = this.curve;
+
+	var start = curve.getUtoTmapping( 0, 0 );
+	var end = curve.getUtoTmapping( 0, curve.getLength() );
+	var somewhere = curve.getUtoTmapping( 0.5, 1 );
+
+	var expectedSomewhere = 0.014760890927167196;
+
+	assert.strictEqual( start, 0, "getUtoTmapping( 0, 0 ) is the starting point" );
+	assert.strictEqual( end, 1, "getUtoTmapping( 0, length ) is the ending point" );
+	assert.numEqual( somewhere, expectedSomewhere, "getUtoTmapping( 0.5, 1 ) is correct" );
+
+} );
+
+QUnit.test( "getSpacedPoints", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector3( - 10, 0, 2 ),
+		new THREE.Vector3( - 3.712652983516992, 3.015179001762753, 0.6957120710270492 ),
+		new THREE.Vector3( 2.7830973773262975, 5.730399338061483, - 0.1452668772806931 ),
+		new THREE.Vector3( 9.575825284074465, 7.48754187603603, 0.3461104039841496 ),
+		new THREE.Vector3( 12.345199937734154, 4.575759904730531, 5.142117429101656 ),
+		new THREE.Vector3( 10, 0, 10 )
+	];
+
+	var points = curve.getSpacedPoints();
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+	assert.deepEqual( points, expectedPoints, "Correct points calculated" );
+
+} );
+
+QUnit.test( "computeFrenetFrames", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expected = {
+		binormals: [
+			new THREE.Vector3( - 0.447201668889759, 0.8944331542056199, 0 ),
+			new THREE.Vector3( - 0.2684231751110917, 0.9631753839815436, - 0.01556209353802903 ),
+			new THREE.Vector3( 0.3459273556592433, 0.53807011680075, 0.7686447905324219 )
+		],
+		normals: [
+			new THREE.Vector3( - 0.18271617600817133, - 0.09135504253146765, - 0.9789121795283909 ),
+			new THREE.Vector3( 0.046865035058597876, - 0.003078628350883253, - 0.9988964863970807 ),
+			new THREE.Vector3( 0.8357929194629689, - 0.5489842348221077, 0.008155102228190641 )
+		],
+		tangents: [
+			new THREE.Vector3( 0.8755715084258767, 0.4377711603816078, - 0.20428153311294514 ),
+			new THREE.Vector3( 0.9621604167456884, 0.26885628454526284, 0.04431287294094243 ),
+			new THREE.Vector3( - 0.4263618889888853, - 0.6396068005601663, 0.6396238584473043 )
+		]
+	};
+
+	var frames = curve.computeFrenetFrames( 2, false );
+
+	Object.keys( expected ).forEach( function ( group, i ) {
+
+		expected[ group ].forEach( function ( vec, j ) {
+
+			assert.numEqual( frames[ group ][ j ].x, vec.x, "Frenet frames [" + i + ", " + j + "].x correct" );
+			assert.numEqual( frames[ group ][ j ].y, vec.y, "Frenet frames [" + i + ", " + j + "].y correct" );
+			assert.numEqual( frames[ group ][ j ].z, vec.z, "Frenet frames [" + i + ", " + j + "].z correct" );
+
+		} );
+
+	} );
+
+} );

+ 149 - 3
test/unit/src/extras/curves/SplineCurve.js

@@ -1,6 +1,152 @@
 /**
 /**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
+ * @author moraxy / https://github.com/moraxy
  */
  */
 
 
-//Todo
-console.warn("Todo: Unit tests of SplineCurve")
+QUnit.module( "SplineCurve", {
+
+	before: function () {
+
+		// Create a sine-like wave
+		this.curve = new THREE.SplineCurve( [
+			new THREE.Vector2( - 10, 0 ),
+			new THREE.Vector2( - 5, 5 ),
+			new THREE.Vector2( 0, 0 ),
+			new THREE.Vector2( 5, - 5 ),
+			new THREE.Vector2( 10, 0 )
+		] );
+
+	}
+
+} );
+
+QUnit.test( "Simple curve", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( - 10, 0 ),
+		new THREE.Vector2( - 6.08, 4.56 ),
+		new THREE.Vector2( - 2, 2.48 ),
+		new THREE.Vector2( 2, - 2.48 ),
+		new THREE.Vector2( 6.08, - 4.56 ),
+		new THREE.Vector2( 10, 0 )
+	];
+
+	var points = curve.getPoints( 5 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "1st: Correct number of points" );
+
+	points.forEach( function ( point, i ) {
+
+		assert.numEqual( point.x, expectedPoints[ i ].x, "points[" + i + "].x" );
+		assert.numEqual( point.y, expectedPoints[ i ].y, "points[" + i + "].y" );
+
+	} );
+
+	//
+
+	points = curve.getPoints( 4 );
+
+	assert.deepEqual( points, curve.points, "2nd: Returned points are identical to control points" );
+
+} );
+
+QUnit.test( "getLength/getLengths", function ( assert ) {
+
+	var curve = this.curve;
+
+	var length = curve.getLength();
+	var expectedLength = 28.876950901868135;
+
+	assert.numEqual( length, expectedLength, "Correct length of curve" );
+
+	var expectedLengths = [
+		0.0,
+		Math.sqrt( 50 ),
+		Math.sqrt( 200 ),
+		Math.sqrt( 450 ),
+		Math.sqrt( 800 )
+	];
+
+	var lengths = curve.getLengths( 4 );
+
+	assert.deepEqual( lengths, expectedLengths, "Correct segment lengths" );
+
+} );
+
+QUnit.test( "getPointAt", function ( assert ) {
+
+	var curve = this.curve;
+
+	assert.ok( curve.getPointAt( 0 ).equals( curve.points[ 0 ] ), "PointAt 0.0 correct" );
+	assert.ok( curve.getPointAt( 1 ).equals( curve.points[ 4 ] ), "PointAt 1.0 correct" );
+
+	var pointAt = curve.getPointAt( 0.5 );
+	assert.numEqual( pointAt.x, 0.0, "PointAt 0.5 x correct" );
+	assert.numEqual( pointAt.y, 0.0, "PointAt 0.5 y correct" );
+
+} );
+
+QUnit.test( "getTangent", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedTangent = [
+		new THREE.Vector2( 0.7068243340243188, 0.7073891155729485 ), // 0
+		new THREE.Vector2( 0.7069654305325396, - 0.7072481035902046 ), // 0.5
+		new THREE.Vector2( 0.7068243340245123, 0.7073891155727552 ) // 1
+	];
+
+	var tangents = [
+		curve.getTangent( 0 ),
+		curve.getTangent( 0.5 ),
+		curve.getTangent( 1 )
+	];
+
+	tangents.forEach( function ( tangent, i ) {
+
+		assert.numEqual( tangent.x, expectedTangent[ i ].x, "tangent[" + i + "].x" );
+		assert.numEqual( tangent.y, expectedTangent[ i ].y, "tangent[" + i + "].y" );
+
+	} );
+
+} );
+
+QUnit.test( "getUtoTmapping", function ( assert ) {
+
+	var curve = this.curve;
+
+	var start = curve.getUtoTmapping( 0, 0 );
+	var end = curve.getUtoTmapping( 0, curve.getLength() );
+	var middle = curve.getUtoTmapping( 0.5, 0 );
+
+	assert.strictEqual( start, 0, "getUtoTmapping( 0, 0 ) is the starting point" );
+	assert.strictEqual( end, 1, "getUtoTmapping( 0, length ) is the ending point" );
+	assert.numEqual( middle, 0.5, "getUtoTmapping( 0.5, 0 ) is the middle" );
+
+} );
+
+QUnit.test( "getSpacedPoints", function ( assert ) {
+
+	var curve = this.curve;
+
+	var expectedPoints = [
+		new THREE.Vector2( - 10, 0 ),
+		new THREE.Vector2( - 4.996509634683014, 4.999995128640857 ),
+		new THREE.Vector2( 0, 0 ),
+		new THREE.Vector2( 4.996509634683006, - 4.999995128640857 ),
+		new THREE.Vector2( 10, 0 )
+	];
+
+	var points = curve.getSpacedPoints( 4 );
+
+	assert.strictEqual( points.length, expectedPoints.length, "Correct number of points" );
+
+	points.forEach( function ( point, i ) {
+
+		assert.numEqual( point.x, expectedPoints[ i ].x, "points[" + i + "].x" );
+		assert.numEqual( point.y, expectedPoints[ i ].y, "points[" + i + "].y" );
+
+	} );
+
+} );

+ 21 - 0
test/unit/src/lights/AmbientLight.js

@@ -0,0 +1,21 @@
+/**
+ * @author moraxy / https://github.com/moraxy
+ */
+
+QUnit.module( "AmbientLight" );
+
+QUnit.test( "Standard Light tests", function ( assert ) {
+
+	var parameters = {
+		color: 0xaaaaaa,
+		intensity: 0.5
+	};
+
+	var lights = [
+		new THREE.AmbientLight( parameters.color ),
+		new THREE.AmbientLight( parameters.color, parameters.intensity )
+	];
+
+	runStdLightTests( lights );
+
+} );

+ 0 - 27
test/unit/src/lights/AmbientLight.tests.js

@@ -1,27 +0,0 @@
-(function () {
-
-	'use strict';
-
-	var lights;
-
-	QUnit.module( "Lights - AmbientLight", {
-
-		beforeEach: function() {
-
-			lights = [
-
-				new THREE.AmbientLight( 0xaaaaaa ),
-
-			];
-
-		}
-
-	});
-
-	QUnit.test( "standard light tests", function( assert ) {
-
-		runStdLightTests( assert, lights );
-
-	});
-
-})();

+ 21 - 0
test/unit/src/lights/DirectionalLight.js

@@ -0,0 +1,21 @@
+/**
+ * @author moraxy / https://github.com/moraxy
+ */
+
+QUnit.module( "DirectionalLight" );
+
+QUnit.test( "Standard Light tests", function ( assert ) {
+
+	var parameters = {
+		color: 0xaaaaaa,
+		intensity: 0.5
+	};
+
+	var lights = [
+		new THREE.DirectionalLight( parameters.color ),
+		new THREE.DirectionalLight( parameters.color, parameters.intensity )
+	];
+
+	runStdLightTests( lights );
+
+} );

+ 0 - 28
test/unit/src/lights/DirectionalLight.tests.js

@@ -1,28 +0,0 @@
-(function () {
-
-	'use strict';
-
-	var lights;
-
-	QUnit.module( "Lights - DirectionalLight", {
-
-		beforeEach: function() {
-
-			lights = [
-
-				new THREE.DirectionalLight( 0xaaaaaa ),
-				new THREE.DirectionalLight( 0xaaaaaa, 0.8 ),
-
-			];
-
-		}
-
-	});
-
-	QUnit.test( "standard light tests", function( assert ) {
-
-		runStdLightTests( assert, lights );
-
-	});
-
-})();

+ 40 - 5
test/unit/src/lights/DirectionalLightShadow.js

@@ -1,6 +1,41 @@
-/**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
- */
 
 
-//Todo
-console.warn("Todo: Unit tests of DirectionalLightShadow")
+QUnit.module( "DirectionalLightShadow" );
+
+QUnit.test( "clone/copy", function ( assert ) {
+
+	var a = new THREE.DirectionalLightShadow();
+	var b = new THREE.DirectionalLightShadow();
+	var c;
+
+	assert.notDeepEqual( a, b, "Newly instanced shadows are not equal" );
+
+	c = a.clone();
+	assert.smartEqual( a, c, "Shadows are identical after clone()" );
+
+	c.mapSize.set( 1024, 1024 );
+	assert.notDeepEqual( a, c, "Shadows are different again after change" );
+
+	b.copy( a );
+	assert.smartEqual( a, b, "Shadows are identical after copy()" );
+
+	b.mapSize.set( 512, 512 );
+	assert.notDeepEqual( a, b, "Shadows are different again after change" );
+
+} );
+
+QUnit.test( "toJSON", function ( assert ) {
+
+	var light = new THREE.DirectionalLight();
+	var shadow = new THREE.DirectionalLightShadow();
+
+	shadow.bias = 10;
+	shadow.radius = 5;
+	shadow.mapSize.set( 1024, 1024 );
+	light.shadow = shadow;
+
+	var json = light.toJSON();
+	var newLight = new THREE.ObjectLoader().parse( json );
+
+	assert.smartEqual( newLight.shadow, light.shadow, "Reloaded shadow is identical to the original one" );
+
+} );

+ 25 - 0
test/unit/src/lights/HemisphereLight.js

@@ -0,0 +1,25 @@
+/**
+ * @author moraxy / https://github.com/moraxy
+ */
+
+QUnit.module( "HemisphereLight" );
+
+QUnit.test( "Standard Light tests", function ( assert ) {
+
+	var parameters = {
+		skyColor: 0x123456,
+		groundColor: 0xabc012,
+		intensity: 0.6
+	};
+
+	var lights = [
+		new THREE.HemisphereLight( parameters.skyColor ),
+		new THREE.HemisphereLight( parameters.skyColor, parameters.groundColor ),
+		new THREE.HemisphereLight(
+			parameters.skyColor, parameters.groundColor, parameters.intensity
+		)
+	];
+
+	runStdLightTests( lights );
+
+} );

+ 0 - 35
test/unit/src/lights/HemisphereLight.tests.js

@@ -1,35 +0,0 @@
-(function () {
-
-	'use strict';
-
-	var parameters = {
-		skyColor: 0x123456,
-		groundColor: 0xabc012,
-		intensity: 0.6
-	};
-
-	var lights;
-
-	QUnit.module( "Lights - HemisphereLight", {
-
-		beforeEach: function() {
-
-			lights = [
-
-				new THREE.HemisphereLight( parameters.skyColor ),
-				new THREE.HemisphereLight( parameters.skyColor, parameters.groundColor ),
-				new THREE.HemisphereLight( parameters.skyColor, parameters.groundColor, parameters.intensity ),
-
-			];
-
-		}
-
-	});
-
-	QUnit.test( "standard light tests", function( assert ) {
-
-		runStdLightTests( assert, lights );
-
-	});
-
-})();

+ 18 - 3
test/unit/src/lights/Light.js

@@ -1,6 +1,21 @@
 /**
 /**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
+ * @author moraxy / https://github.com/moraxy
  */
  */
 
 
-//Todo
-console.warn("Todo: Unit tests of Light")
+QUnit.module( "Light" );
+
+QUnit.test( "Standard Light tests", function ( assert ) {
+
+	var parameters = {
+		color: 0xaaaaaa,
+		intensity: 0.5
+	};
+
+	var lights = [
+		new THREE.Light( parameters.color ),
+		new THREE.Light( parameters.color, parameters.intensity )
+	];
+
+	runStdLightTests( lights, true );
+
+} );

+ 23 - 5
test/unit/src/lights/LightShadow.js

@@ -1,6 +1,24 @@
-/**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
- */
 
 
-//Todo
-console.warn("Todo: Unit tests of LightShadow")
+QUnit.module( "LightShadow" );
+
+QUnit.test( "clone/copy", function ( assert ) {
+
+	var a = new THREE.LightShadow( new THREE.OrthographicCamera( - 5, 5, 5, - 5, 0.5, 500 ) );
+	var b = new THREE.LightShadow( new THREE.OrthographicCamera( - 3, 3, 3, - 3, 0.3, 300 ) );
+	var c;
+
+	assert.notDeepEqual( a, b, "Newly instanced shadows are not equal" );
+
+	c = a.clone();
+	assert.smartEqual( a, c, "Shadows are identical after clone()" );
+
+	c.mapSize.set( 256, 256 );
+	assert.notDeepEqual( a, c, "Shadows are different again after change" );
+
+	b.copy( a );
+	assert.smartEqual( a, b, "Shadows are identical after copy()" );
+
+	b.mapSize.set( 512, 512 );
+	assert.notDeepEqual( a, b, "Shadows are different again after change" );
+
+} );

+ 45 - 0
test/unit/src/lights/PointLight.js

@@ -0,0 +1,45 @@
+/**
+ * @author moraxy / https://github.com/moraxy
+ */
+
+QUnit.module( "PointLight" );
+
+QUnit.test( "Standard Light tests", function ( assert ) {
+
+	var parameters = {
+		color: 0xaaaaaa,
+		intensity: 0.5,
+		distance: 100,
+		decay: 2
+	};
+
+	var lights = [
+		new THREE.PointLight( parameters.color ),
+		new THREE.PointLight( parameters.color, parameters.intensity ),
+		new THREE.PointLight(
+			parameters.color, parameters.intensity, parameters.distance
+		),
+		new THREE.PointLight(
+			parameters.color, parameters.intensity, parameters.distance,
+			parameters.decay
+		)
+	];
+
+	runStdLightTests( lights );
+
+} );
+
+QUnit.test( "power", function ( assert ) {
+
+	var a = new THREE.PointLight( 0xaaaaaa );
+
+	a.intensity = 100;
+	assert.numEqual( a.power, 100 * Math.PI * 4, "Correct power for an intensity of 100" );
+
+	a.intensity = 40;
+	assert.numEqual( a.power, 40 * Math.PI * 4, "Correct power for an intensity of 40" );
+
+	a.power = 100;
+	assert.numEqual( a.intensity, 100 / ( 4 * Math.PI ), "Correct intensity for a power of 100" );
+
+} );

+ 0 - 27
test/unit/src/lights/PointLight.tests.js

@@ -1,27 +0,0 @@
-(function () {
-
-	'use strict';
-
-	var lights;
-
-	QUnit.module( "Lights - PointLight", {
-
-		beforeEach: function() {
-
-			lights = [
-
-				new THREE.PointLight( 0xaaaaaa ),
-
-			];
-
-		}
-
-	});
-
-	QUnit.test( "standard light tests", function( assert ) {
-
-		runStdLightTests( assert, lights );
-
-	});
-
-})();

+ 29 - 0
test/unit/src/lights/RectAreaLight.js

@@ -0,0 +1,29 @@
+/**
+ * @author moraxy / https://github.com/moraxy
+ */
+
+QUnit.module( "RectAreaLight" );
+
+QUnit.test( "Standard Light tests", function ( assert ) {
+
+	var parameters = {
+		color: 0xaaaaaa,
+		intensity: 0.5,
+		width: 100,
+		height: 50
+	};
+
+	var lights = [
+		new THREE.RectAreaLight( parameters.color ),
+		new THREE.RectAreaLight( parameters.color, parameters.intensity ),
+		new THREE.RectAreaLight(
+			parameters.color, parameters.intensity, parameters.width
+		),
+		new THREE.RectAreaLight(
+			parameters.color, parameters.intensity, parameters.width, parameters.height
+		)
+	];
+
+	runStdLightTests( lights );
+
+} );

+ 0 - 38
test/unit/src/lights/RectAreaLight.tests.js

@@ -1,38 +0,0 @@
-(function () {
-
-	'use strict';
-
-	var parameters = {
-		color: 0xaaaaaa,
-		intensity: 0.5,
-	};
-
-	var lights;
-
-	// TODO (abelnation): verify this works
-
-	QUnit.module( "Lights - RectAreaLight", {
-
-		beforeEach: function() {
-
-			lights = [
-
-				new THREE.RectAreaLight( parameters.color ),
-				new THREE.RectAreaLight( parameters.color, parameters.intensity ),
-				new THREE.RectAreaLight( parameters.color, parameters.intensity, 5.0 ),
-				new THREE.RectAreaLight( parameters.color, parameters.intensity, 5.0, 20.0 ),
-				new THREE.RectAreaLight( parameters.color, parameters.intensity, undefined, 20.0 ),
-
-			];
-
-		}
-
-	});
-
-	QUnit.test( "standard light tests", function( assert ) {
-
-		runStdLightTests( assert, lights );
-
-	});
-
-})();

+ 55 - 0
test/unit/src/lights/SpotLight.js

@@ -0,0 +1,55 @@
+/**
+ * @author moraxy / https://github.com/moraxy
+ */
+
+QUnit.module( "SpotLight" );
+
+QUnit.test( "Standard Light tests", function ( assert ) {
+
+	var parameters = {
+		color: 0xaaaaaa,
+		intensity: 0.5,
+		distance: 100,
+		angle: 0.8,
+		penumbra: 8,
+		decay: 2
+	};
+
+	var lights = [
+		new THREE.SpotLight( parameters.color ),
+		new THREE.SpotLight( parameters.color, parameters.intensity ),
+		new THREE.SpotLight(
+			parameters.color, parameters.intensity, parameters.distance
+		),
+		new THREE.SpotLight(
+			parameters.color, parameters.intensity, parameters.distance,
+			parameters.angle
+		),
+		new THREE.SpotLight(
+			parameters.color, parameters.intensity, parameters.distance,
+			parameters.angle, parameters.penumbra
+		),
+		new THREE.SpotLight(
+			parameters.color, parameters.intensity, parameters.distance,
+			parameters.angle, parameters.penumbra, parameters.decay
+		)
+	];
+
+	runStdLightTests( lights );
+
+} );
+
+QUnit.test( "power", function ( assert ) {
+
+	var a = new THREE.SpotLight( 0xaaaaaa );
+
+	a.intensity = 100;
+	assert.numEqual( a.power, 100 * Math.PI, "Correct power for an intensity of 100" );
+
+	a.intensity = 40;
+	assert.numEqual( a.power, 40 * Math.PI, "Correct power for an intensity of 40" );
+
+	a.power = 100;
+	assert.numEqual( a.intensity, 100 / Math.PI, "Correct intensity for a power of 100" );
+
+} );

+ 0 - 41
test/unit/src/lights/SpotLight.tests.js

@@ -1,41 +0,0 @@
-(function () {
-
-	'use strict';
-
-	var parameters = {
-		color: 0xaaaaaa,
-		intensity: 0.5,
-		distance: 100,
-		angle: 0.8,
-		exponent: 8,
-		decay: 2
-	};
-
-	var lights;
-
-	QUnit.module( "Lights - SpotLight", {
-
-		beforeEach: function() {
-
-			lights = [
-
-				new THREE.SpotLight( parameters.color ),
-				new THREE.SpotLight( parameters.color, parameters.intensity ),
-				new THREE.SpotLight( parameters.color, parameters.intensity, parameters.distance ),
-				new THREE.SpotLight( parameters.color, parameters.intensity, parameters.distance, parameters.angle ),
-				new THREE.SpotLight( parameters.color, parameters.intensity, parameters.distance, parameters.angle, parameters.exponent ),
-				new THREE.SpotLight( parameters.color, parameters.intensity, parameters.distance, parameters.angle, parameters.exponent, parameters.decay ),
-
-			];
-
-		}
-
-	});
-
-	QUnit.test( "standard light tests", function( assert ) {
-
-		runStdLightTests( assert, lights );
-
-	});
-
-})();

+ 40 - 5
test/unit/src/lights/SpotLightShadow.js

@@ -1,6 +1,41 @@
-/**
- * @author TristanVALCKE / https://github.com/TristanVALCKE
- */
 
 
-//Todo
-console.warn("Todo: Unit tests of SpotLightShadow")
+QUnit.module( "SpotLightShadow" );
+
+QUnit.test( "clone/copy", function ( assert ) {
+
+	var a = new THREE.SpotLightShadow();
+	var b = new THREE.SpotLightShadow();
+	var c;
+
+	assert.notDeepEqual( a, b, "Newly instanced shadows are not equal" );
+
+	c = a.clone();
+	assert.smartEqual( a, c, "Shadows are identical after clone()" );
+
+	c.mapSize.set( 256, 256 );
+	assert.notDeepEqual( a, c, "Shadows are different again after change" );
+
+	b.copy( a );
+	assert.smartEqual( a, b, "Shadows are identical after copy()" );
+
+	b.mapSize.set( 512, 512 );
+	assert.notDeepEqual( a, b, "Shadows are different again after change" );
+
+} );
+
+QUnit.test( "toJSON", function ( assert ) {
+
+	var light = new THREE.SpotLight();
+	var shadow = new THREE.SpotLightShadow();
+
+	shadow.bias = 10;
+	shadow.radius = 5;
+	shadow.mapSize.set( 128, 128 );
+	light.shadow = shadow;
+
+	var json = light.toJSON();
+	var newLight = new THREE.ObjectLoader().parse( json );
+
+	assert.smartEqual( newLight.shadow, light.shadow, "Reloaded shadow is equal to the original one" );
+
+} );

+ 6 - 7
test/unit/unittests_sources.html

@@ -97,7 +97,6 @@
   <script src="src/extras/core/ShapePath.js"></script>
   <script src="src/extras/core/ShapePath.js"></script>
 
 
   <!-- /src/extras/curves -->
   <!-- /src/extras/curves -->
-  <script src="src/extras/curves/ArcCurve.js"></script>
   <script src="src/extras/curves/CatmullRomCurve3.js"></script>
   <script src="src/extras/curves/CatmullRomCurve3.js"></script>
   <script src="src/extras/curves/CubicBezierCurve.js"></script>
   <script src="src/extras/curves/CubicBezierCurve.js"></script>
   <script src="src/extras/curves/CubicBezierCurve3.js"></script>
   <script src="src/extras/curves/CubicBezierCurve3.js"></script>
@@ -157,15 +156,15 @@
 
 
 
 
   <!-- /src/lights -->
   <!-- /src/lights -->
-  <script src="src/lights/AmbientLight.tests.js"></script>
-  <script src="src/lights/DirectionalLight.tests.js"></script>
+  <script src="src/lights/AmbientLight.js"></script>
+  <script src="src/lights/DirectionalLight.js"></script>
   <script src="src/lights/DirectionalLightShadow.js"></script>
   <script src="src/lights/DirectionalLightShadow.js"></script>
-  <script src="src/lights/HemisphereLight.tests.js"></script>
+  <script src="src/lights/HemisphereLight.js"></script>
   <script src="src/lights/Light.js"></script>
   <script src="src/lights/Light.js"></script>
   <script src="src/lights/LightShadow.js"></script>
   <script src="src/lights/LightShadow.js"></script>
-  <script src="src/lights/PointLight.tests.js"></script>
-  <script src="src/lights/RectAreaLight.tests.js"></script>
-  <script src="src/lights/SpotLight.tests.js"></script>
+  <script src="src/lights/PointLight.js"></script>
+  <script src="src/lights/RectAreaLight.js"></script>
+  <script src="src/lights/SpotLight.js"></script>
   <script src="src/lights/SpotLightShadow.js"></script>
   <script src="src/lights/SpotLightShadow.js"></script>