TIFFLoader.js 572 B

123456789101112131415161718192021222324252627282930313233343536
  1. import {
  2. DataTextureLoader,
  3. LinearFilter,
  4. LinearMipmapLinearFilter
  5. } from 'three';
  6. import UTIF from '../libs/utif.module.js';
  7. class TIFFLoader extends DataTextureLoader {
  8. constructor( manager ) {
  9. super( manager );
  10. }
  11. parse( buffer ) {
  12. const ifds = UTIF.decode( buffer );
  13. UTIF.decodeImage( buffer, ifds[ 0 ] );
  14. const rgba = UTIF.toRGBA8( ifds[ 0 ] );
  15. return {
  16. width: ifds[ 0 ].width,
  17. height: ifds[ 0 ].height,
  18. data: rgba,
  19. flipY: true,
  20. magFilter: LinearFilter,
  21. minFilter: LinearMipmapLinearFilter
  22. };
  23. }
  24. }
  25. export { TIFFLoader };