HDRLoader.tests.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { HDRLoader } from '../../../../examples/jsm/loaders/HDRLoader.js';
  2. export default QUnit.module( 'Addons', () => {
  3. QUnit.module( 'Loaders', () => {
  4. QUnit.module( 'HDRLoader', () => {
  5. QUnit.test( 'Instancing', ( assert ) => {
  6. const loader = new HDRLoader();
  7. assert.ok( loader instanceof HDRLoader, 'Can instantiate an HDRLoader.' );
  8. } );
  9. QUnit.test( 'parses valid HDR with large header (> chunk size)', ( assert ) => {
  10. // Regression: fgets uses chunkSize=128. When a line (e.g. pcomb) exceeds
  11. // 128 bytes, chunking can skip the FORMAT line, causing "missing format
  12. // specifier". This minimal synthetic HDR reproduces the bug.
  13. const header = [
  14. '#?RADIANCE',
  15. 'some large header line' + 'x'.repeat( 128 ),
  16. 'FORMAT=32-bit_rle_rgbe',
  17. '-Y 0 +X 0',
  18. ''
  19. ].join( '\n' );
  20. const encoder = new TextEncoder();
  21. const headerBytes = encoder.encode( header );
  22. const buffer = new Uint8Array( headerBytes.length );
  23. buffer.set( headerBytes );
  24. const loader = new HDRLoader();
  25. const result = loader.parse( buffer.buffer );
  26. assert.ok( result, 'Parse succeeds' );
  27. assert.strictEqual( result.width, 0, 'Width' );
  28. assert.strictEqual( result.height, 0, 'Height' );
  29. assert.ok( result.data, 'Has texture data' );
  30. } );
  31. } );
  32. } );
  33. } );
粤ICP备19079148号