Camera.tests.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* global QUnit */
  2. import { Camera } from '../../../../src/cameras/Camera.js';
  3. import { Vector3 } from '../../../../src/math/Vector3.js';
  4. import { Object3D } from '../../../../src/core/Object3D.js';
  5. export default QUnit.module( 'Cameras', () => {
  6. QUnit.module( 'Camera', () => {
  7. // INHERITANCE
  8. QUnit.test( 'Extending', ( assert ) => {
  9. const object = new Camera();
  10. assert.strictEqual(
  11. object instanceof Object3D, true,
  12. 'Camera extends from Object3D'
  13. );
  14. } );
  15. // INSTANCING
  16. QUnit.todo( 'Instancing', ( assert ) => {
  17. assert.ok( false, 'everything\'s gonna be alright' );
  18. } );
  19. // PROPERTIES
  20. QUnit.test( 'type', ( assert ) => {
  21. const object = new Camera();
  22. assert.ok(
  23. object.type === 'Camera',
  24. 'Camera.type should be Camera'
  25. );
  26. } );
  27. QUnit.todo( 'matrixWorldInverse', ( assert ) => {
  28. assert.ok( false, 'everything\'s gonna be alright' );
  29. } );
  30. QUnit.todo( 'projectionMatrix', ( assert ) => {
  31. assert.ok( false, 'everything\'s gonna be alright' );
  32. } );
  33. QUnit.todo( 'projectionMatrixInverse', ( assert ) => {
  34. assert.ok( false, 'everything\'s gonna be alright' );
  35. } );
  36. // PUBLIC
  37. QUnit.test( 'isCamera', ( assert ) => {
  38. const object = new Camera();
  39. assert.ok(
  40. object.isCamera,
  41. 'Camera.isCamera should be true'
  42. );
  43. } );
  44. QUnit.todo( 'copy', ( assert ) => {
  45. assert.ok( false, 'everything\'s gonna be alright' );
  46. } );
  47. QUnit.todo( 'getWorldDirection', ( assert ) => {
  48. assert.ok( false, 'everything\'s gonna be alright' );
  49. } );
  50. QUnit.todo( 'updateMatrixWorld', ( assert ) => {
  51. assert.ok( false, 'everything\'s gonna be alright' );
  52. } );
  53. QUnit.todo( 'updateWorldMatrix', ( assert ) => {
  54. assert.ok( false, 'everything\'s gonna be alright' );
  55. } );
  56. QUnit.test( 'clone', ( assert ) => {
  57. const cam = new Camera();
  58. // fill the matrices with any nonsense values just to see if they get copied
  59. cam.matrixWorldInverse.set( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 );
  60. cam.projectionMatrix.set( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 );
  61. const clonedCam = cam.clone();
  62. // TODO: do not rely equality on object methods
  63. // TODO: What's append if matrix.equal is wrongly implemented
  64. // TODO: this MUST be check by assert
  65. assert.ok( cam.matrixWorldInverse.equals( clonedCam.matrixWorldInverse ), 'matrixWorldInverse is equal' );
  66. assert.ok( cam.projectionMatrix.equals( clonedCam.projectionMatrix ), 'projectionMatrix is equal' );
  67. } );
  68. // OTHERS
  69. // TODO: this should not be here, Object3D related
  70. QUnit.test( 'lookAt', ( assert ) => {
  71. const cam = new Camera();
  72. cam.lookAt( new Vector3( 0, 1, - 1 ) );
  73. assert.numEqual( cam.rotation.x * ( 180 / Math.PI ), 45, 'x is equal' );
  74. } );
  75. } );
  76. } );
粤ICP备19079148号