Browse Source

check perspective camera projection matrix against a reference matrix

simonThiele 10 years ago
parent
commit
8f691af2dd
1 changed files with 11 additions and 9 deletions
  1. 11 9
      test/unit/cameras/PerspectiveCamera.js

+ 11 - 9
test/unit/cameras/PerspectiveCamera.js

@@ -17,20 +17,22 @@ test( "updateProjectionMatrix", function() {
 	var cam = new THREE.PerspectiveCamera( fov, aspect, near, far );
 
 	// updateProjectionMatrix is called in contructor
-	var m = cam.projectionMatrix.elements;
+	var m = cam.projectionMatrix;
 
 	// perspective projection is given my the 4x4 Matrix
 	// 2n/r-l		0			l+r/r-l				 0
 	//   0		2n/t-b	t+b/t-b				 0
 	//   0			0		-(f+n/f-n)	-(2fn/f-n)
-	//   0			0				0						 1
-
-	ok( m[0] === ( 2 * near ) / ( right - left ), "m[0,0] === 2n/r-l" );
-	ok( m[5] === ( 2 * near ) / ( top - bottom ), "m[1,1] === 2n/r-l" );
-	ok( m[8] === ( right + left ) / ( right - left ), "m[2,0] === 2n/r-l" );
-	ok( m[9] === ( top + bottom ) / ( top - bottom ), "m[2,1] === 2n/r-l" );
-	ok( m[10] === - ( far + near ) / ( far - near ), "m[2,2] === 2n/r-l" );
-	ok( m[14] === - ( 2 * near * far ) / ( far - near ), "m[3,2] === 2n/r-l" );
+	//   0			0				-1						 0
+
+	var reference = new THREE.Matrix4().set(
+		( 2 * near ) / ( right - left ), 0, ( right + left ) / ( right - left ), 0,
+		0, ( 2 * near ) / ( top - bottom ), ( top + bottom ) / ( top - bottom ), 0,
+		0, 0, - ( far + near ) / ( far - near ), - ( 2 * near * far ) / ( far - near ),
+		0, 0, -1, 0
+	);
+
+	ok( reference.equals(m) );
 });
 
 test( "clone", function() {