Browse Source

add spacings

simonThiele 9 years ago
parent
commit
aa8ce37bcd
1 changed files with 40 additions and 26 deletions
  1. 40 26
      test/unit/core/Raycaster.js

+ 40 - 26
test/unit/core/Raycaster.js

@@ -8,15 +8,17 @@ test( "intersectObjects", function() {
 	var raycaster = getRaycaster();
 	var objectsToCheck = getObjectsToCheck();
 
-	ok ( raycaster.intersectObjects(objectsToCheck).length === 1,
+	ok ( raycaster.intersectObjects( objectsToCheck ).length === 1,
 		"no recursive search should lead to one hit" );
 
-	ok ( raycaster.intersectObjects(objectsToCheck, true).length === 3,
+	ok ( raycaster.intersectObjects( objectsToCheck, true ).length === 3,
 		"recursive search should lead to two hits" );
 
-	var intersections = raycaster.intersectObjects(objectsToCheck, true);
-	for (var i = 0; i < intersections.length - 1; i++) {
-	  ok( intersections[i].distance <= intersections[i + 1].distance, "intersections are sorted" );
+	var intersections = raycaster.intersectObjects( objectsToCheck, true );
+	for ( var i = 0; i < intersections.length - 1; i++ ) {
+
+	  ok( intersections[ i ].distance <= intersections[ i + 1 ].distance, "intersections are sorted" );
+
 	}
 });
 
@@ -24,15 +26,17 @@ test( "intersectObject", function() {
 	var raycaster = getRaycaster();
 	var objectsToCheck = getObjectsToCheck();
 
-	ok ( raycaster.intersectObject(objectsToCheck[0]).length === 1,
+	ok ( raycaster.intersectObject( objectsToCheck[ 0 ] ).length === 1,
 		"no recursive search should lead to one hit" );
 
-	ok ( raycaster.intersectObject(objectsToCheck[0], true).length === 3,
+	ok ( raycaster.intersectObject( objectsToCheck[ 0 ], true ).length === 3,
 		"recursive search should lead to two hits" );
 
-	var intersections = raycaster.intersectObject(objectsToCheck[0], true);
-	for (var i = 0; i < intersections.length - 1; i++) {
-	  ok( intersections[i].distance <= intersections[i + 1].distance, "intersections are sorted" );
+	var intersections = raycaster.intersectObject( objectsToCheck[ 0 ], true );
+	for ( var i = 0; i < intersections.length - 1; i++ ) {
+
+	  ok( intersections[ i ].distance <= intersections[ i + 1 ].distance, "intersections are sorted" );
+
 	}
 });
 
@@ -46,16 +50,23 @@ test( "setFromCamera", function() {
 		"camera is looking straight to -z and so does the ray in the middle of the screen" );
 
 	var step = 0.1;
-	for (var x = -1; x <= 1; x+=step) {
-		for (var y = -1; y <= 1; y+=step) {
+
+	for ( var x = -1; x <= 1; x += step ) {
+
+		for ( var y = -1; y <= 1; y += step ) {
+
 			raycaster.setFromCamera( { x, y }, camera );
-			var refVector = new THREE.Vector3(x, y, -1).normalize();
-			checkRayDirectionAgainstReferenceVector(rayDirection, refVector);
+
+			var refVector = new THREE.Vector3( x, y, -1 ).normalize();
+
+			checkRayDirectionAgainstReferenceVector( rayDirection, refVector );
+
 		}
+
 	}
 });
 
-function checkRayDirectionAgainstReferenceVector(rayDirection, refVector) {
+function checkRayDirectionAgainstReferenceVector( rayDirection, refVector ) {
 	ok( refVector.x - rayDirection.x <= Number.EPSILON &&
 			refVector.y - rayDirection.y <= Number.EPSILON &&
 			refVector.z - rayDirection.z <= Number.EPSILON,
@@ -75,31 +86,34 @@ function getObjectsToCheck() {
 	var objects = [];
 
 	var sphere1 = getSphere();
-	sphere1.position.set(0, 0, -10);
+	sphere1.position.set( 0, 0, -10 );
 	sphere1.name = 1;
-	objects.push(sphere1);
+	objects.push( sphere1 );
 
 	var sphere11 = getSphere();
-	sphere11.position.set(0, 0, 1);
+	sphere11.position.set( 0, 0, 1 );
 	sphere11.name = 11;
-	sphere1.add(sphere11);
+	sphere1.add( sphere11 );
 
 	var sphere12 = getSphere();
-	sphere12.position.set(0, 0, -1);
+	sphere12.position.set( 0, 0, -1 );
 	sphere12.name = 12;
-	sphere1.add(sphere12);
+	sphere1.add( sphere12 );
 
 	var sphere2 = getSphere();
-	sphere2.position.set(-5, 0, -5);
+	sphere2.position.set( -5, 0, -5 );
 	sphere2.name = 2;
-	objects.push(sphere2);
+	objects.push( sphere2 );
+
+	for ( var i = 0; i < objects.length; i++ ) {
+
+		objects[ i ].updateMatrixWorld();
 
-	for (var i = 0; i < objects.length; i++) {
-		objects[i].updateMatrixWorld();
 	}
+
 	return objects;
 }
 
 function getSphere() {
-	return new THREE.Mesh(new THREE.SphereGeometry(1, 100, 100));
+	return new THREE.Mesh( new THREE.SphereGeometry( 1, 100, 100 ) );
 }