SpotLightShadow.tests.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* global QUnit */
  2. import { SpotLightShadow } from '../../../../src/lights/SpotLightShadow.js';
  3. import { LightShadow } from '../../../../src/lights/LightShadow.js';
  4. import { SpotLight } from '../../../../src/lights/SpotLight.js';
  5. import { ObjectLoader } from '../../../../src/loaders/ObjectLoader.js';
  6. export default QUnit.module( 'Lights', () => {
  7. QUnit.module( 'SpotLightShadow', () => {
  8. // INHERITANCE
  9. QUnit.test( 'Extending', ( assert ) => {
  10. const object = new SpotLightShadow();
  11. assert.strictEqual(
  12. object instanceof LightShadow, true,
  13. 'SpotLightShadow extends from LightShadow'
  14. );
  15. } );
  16. // INSTANCING
  17. QUnit.test( 'Instancing', ( assert ) => {
  18. const object = new SpotLightShadow();
  19. assert.ok( object, 'Can instantiate a SpotLightShadow.' );
  20. } );
  21. // PROPERTIES
  22. QUnit.todo( 'focus', ( assert ) => {
  23. assert.ok( false, 'everything\'s gonna be alright' );
  24. } );
  25. // PUBLIC
  26. QUnit.test( 'isSpotLightShadow', ( assert ) => {
  27. const object = new SpotLightShadow();
  28. assert.ok(
  29. object.isSpotLightShadow,
  30. 'SpotLightShadow.isSpotLightShadow should be true'
  31. );
  32. } );
  33. QUnit.todo( 'updateMatrices', ( assert ) => {
  34. assert.ok( false, 'everything\'s gonna be alright' );
  35. } );
  36. QUnit.todo( 'copy', ( assert ) => {
  37. assert.ok( false, 'everything\'s gonna be alright' );
  38. } );
  39. // OTHERS
  40. QUnit.test( 'clone/copy', ( assert ) => {
  41. const a = new SpotLightShadow();
  42. const b = new SpotLightShadow();
  43. assert.notDeepEqual( a, b, 'Newly instanced shadows are not equal' );
  44. const c = a.clone();
  45. assert.smartEqual( a, c, 'Shadows are identical after clone()' );
  46. c.mapSize.set( 256, 256 );
  47. assert.notDeepEqual( a, c, 'Shadows are different again after change' );
  48. b.copy( a );
  49. assert.smartEqual( a, b, 'Shadows are identical after copy()' );
  50. b.mapSize.set( 512, 512 );
  51. assert.notDeepEqual( a, b, 'Shadows are different again after change' );
  52. } );
  53. QUnit.test( 'toJSON', ( assert ) => {
  54. const light = new SpotLight();
  55. const shadow = new SpotLightShadow();
  56. shadow.bias = 10;
  57. shadow.radius = 5;
  58. shadow.mapSize.set( 128, 128 );
  59. light.shadow = shadow;
  60. const json = light.toJSON();
  61. const newLight = new ObjectLoader().parse( json );
  62. assert.smartEqual( newLight.shadow, light.shadow, 'Reloaded shadow is equal to the original one' );
  63. } );
  64. } );
  65. } );
粤ICP备19079148号