DirectionalLightShadow.tests.js 2.1 KB

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