OrthographicCamera.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * @author simonThiele / https://github.com/simonThiele
  3. */
  4. module( "OrthographicCamera" );
  5. test( "updateProjectionMatrix", function() {
  6. var left = -1, right = 1, top = 1, bottom = -1, near = 1, far = 3;
  7. cam = new THREE.OrthographicCamera(left, right, top, bottom, near, far);
  8. // updateProjectionMatrix is called in contructor
  9. var pMatrix = cam.projectionMatrix.elements;
  10. // orthographic projection is given my the 4x4 Matrix
  11. // 2/r-l 0 0 -(l+r/r-l)
  12. // 0 2/t-b 0 -(t+b/t-b)
  13. // 0 0 -2/f-n -(f+n/f-n)
  14. // 0 0 0 1
  15. ok( pMatrix[0] === 2 / ( right - left ), "m[0,0] === 2 / (r - l)" );
  16. ok( pMatrix[5] === 2 / ( top - bottom ), "m[1,1] === 2 / (t - b)" );
  17. ok( pMatrix[10] === -2 / ( far - near ), "m[2,2] === -2 / (f - n)" );
  18. ok( pMatrix[12] === - ( ( right + left ) / ( right - left ) ), "m[3,0] === -(r+l/r-l)" );
  19. ok( pMatrix[13] === - ( ( top + bottom ) / ( top - bottom ) ), "m[3,1] === -(t+b/b-t)" );
  20. ok( pMatrix[14] === - ( ( far + near ) / ( far - near ) ), "m[3,2] === -(f+n/f-n)" );
  21. });
  22. test( "clone", function() {
  23. var left = -1.5, right = 1.5, top = 1, bottom = -1, near = 0.1, far = 42;
  24. var cam = new THREE.OrthographicCamera(left, right, top, bottom, near, far);
  25. var clonedCam = cam.clone();
  26. ok( cam.left === clonedCam.left , "left is equal" );
  27. ok( cam.right === clonedCam.right , "right is equal" );
  28. ok( cam.top === clonedCam.top , "top is equal" );
  29. ok( cam.bottom === clonedCam.bottom , "bottom is equal" );
  30. ok( cam.near === clonedCam.near , "near is equal" );
  31. ok( cam.far === clonedCam.far , "far is equal" );
  32. ok( cam.zoom === clonedCam.zoom , "zoom is equal" );
  33. });