@loaders.gl/textures 4.2.0-alpha.4 → 4.2.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/basis-loader.js +27 -19
  2. package/dist/compressed-texture-loader.js +51 -31
  3. package/dist/compressed-texture-writer.js +32 -19
  4. package/dist/crunch-loader.js +19 -13
  5. package/dist/dist.dev.js +326 -212
  6. package/dist/dist.min.js +10 -0
  7. package/dist/index.cjs +41 -60
  8. package/dist/index.cjs.map +7 -0
  9. package/dist/index.d.ts +16 -16
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +21 -13
  12. package/dist/ktx2-basis-writer.js +21 -15
  13. package/dist/lib/encoders/encode-ktx.js +6 -3
  14. package/dist/lib/encoders/encode-ktx2-basis-texture.js +38 -33
  15. package/dist/lib/encoders/encode-texture.d.ts +1 -1
  16. package/dist/lib/encoders/encode-texture.d.ts.map +1 -1
  17. package/dist/lib/encoders/encode-texture.js +23 -9
  18. package/dist/lib/gl-extensions.js +70 -59
  19. package/dist/lib/parsers/basis-module-loader.js +97 -61
  20. package/dist/lib/parsers/crunch-module-loader.js +29 -13
  21. package/dist/lib/parsers/parse-basis.js +217 -205
  22. package/dist/lib/parsers/parse-compressed-texture.js +20 -11
  23. package/dist/lib/parsers/parse-crunch.js +89 -59
  24. package/dist/lib/parsers/parse-dds.js +82 -53
  25. package/dist/lib/parsers/parse-ktx.js +37 -18
  26. package/dist/lib/parsers/parse-npy.js +70 -53
  27. package/dist/lib/parsers/parse-pvr.js +203 -112
  28. package/dist/lib/texture-api/async-deep-map.js +33 -28
  29. package/dist/lib/texture-api/deep-load.js +7 -5
  30. package/dist/lib/texture-api/generate-url.d.ts +1 -1
  31. package/dist/lib/texture-api/generate-url.d.ts.map +1 -1
  32. package/dist/lib/texture-api/generate-url.js +12 -10
  33. package/dist/lib/texture-api/load-image-array.d.ts +1 -1
  34. package/dist/lib/texture-api/load-image-array.d.ts.map +1 -1
  35. package/dist/lib/texture-api/load-image-array.js +13 -15
  36. package/dist/lib/texture-api/load-image-cube.d.ts +1 -1
  37. package/dist/lib/texture-api/load-image-cube.d.ts.map +1 -1
  38. package/dist/lib/texture-api/load-image-cube.js +32 -51
  39. package/dist/lib/texture-api/load-image.d.ts +1 -1
  40. package/dist/lib/texture-api/load-image.d.ts.map +1 -1
  41. package/dist/lib/texture-api/load-image.js +30 -36
  42. package/dist/lib/texture-api/texture-api-types.js +3 -1
  43. package/dist/lib/utils/extract-mipmap-images.js +43 -29
  44. package/dist/lib/utils/ktx-format-helper.js +119 -68
  45. package/dist/lib/utils/texture-formats.js +40 -26
  46. package/dist/lib/utils/version.js +6 -1
  47. package/dist/npy-loader.d.ts +1 -1
  48. package/dist/npy-loader.d.ts.map +1 -1
  49. package/dist/npy-loader.js +24 -15
  50. package/dist/workers/basis-worker-node.js +4 -1
  51. package/dist/workers/basis-worker.js +3 -1
  52. package/dist/workers/compressed-texture-worker.js +4 -1
  53. package/dist/workers/crunch-worker.d.ts +1 -1
  54. package/dist/workers/crunch-worker.d.ts.map +1 -1
  55. package/dist/workers/crunch-worker.js +8 -3
  56. package/dist/workers/ktx2-basis-writer-worker-node.js +23 -26
  57. package/dist/workers/ktx2-basis-writer-worker.js +22 -26
  58. package/dist/workers/npy-worker.js +3 -1
  59. package/package.json +13 -9
  60. package/dist/basis-loader.js.map +0 -1
  61. package/dist/compressed-texture-loader.js.map +0 -1
  62. package/dist/compressed-texture-writer.js.map +0 -1
  63. package/dist/crunch-loader.js.map +0 -1
  64. package/dist/index.js.map +0 -1
  65. package/dist/ktx2-basis-writer.js.map +0 -1
  66. package/dist/lib/encoders/encode-ktx.js.map +0 -1
  67. package/dist/lib/encoders/encode-ktx2-basis-texture.js.map +0 -1
  68. package/dist/lib/encoders/encode-texture.js.map +0 -1
  69. package/dist/lib/gl-extensions.js.map +0 -1
  70. package/dist/lib/parsers/basis-module-loader.js.map +0 -1
  71. package/dist/lib/parsers/crunch-module-loader.js.map +0 -1
  72. package/dist/lib/parsers/parse-basis.js.map +0 -1
  73. package/dist/lib/parsers/parse-compressed-texture.js.map +0 -1
  74. package/dist/lib/parsers/parse-crunch.js.map +0 -1
  75. package/dist/lib/parsers/parse-dds.js.map +0 -1
  76. package/dist/lib/parsers/parse-ktx.js.map +0 -1
  77. package/dist/lib/parsers/parse-npy.js.map +0 -1
  78. package/dist/lib/parsers/parse-pvr.js.map +0 -1
  79. package/dist/lib/texture-api/async-deep-map.js.map +0 -1
  80. package/dist/lib/texture-api/deep-load.js.map +0 -1
  81. package/dist/lib/texture-api/generate-url.js.map +0 -1
  82. package/dist/lib/texture-api/load-image-array.js.map +0 -1
  83. package/dist/lib/texture-api/load-image-cube.js.map +0 -1
  84. package/dist/lib/texture-api/load-image.js.map +0 -1
  85. package/dist/lib/texture-api/texture-api-types.js.map +0 -1
  86. package/dist/lib/utils/extract-mipmap-images.js.map +0 -1
  87. package/dist/lib/utils/ktx-format-helper.js.map +0 -1
  88. package/dist/lib/utils/texture-formats.js.map +0 -1
  89. package/dist/lib/utils/version.js.map +0 -1
  90. package/dist/libs/libs/README.md +0 -9
  91. package/dist/libs/libs/basis_encoder.js +0 -21
  92. package/dist/libs/libs/basis_encoder.wasm +0 -0
  93. package/dist/libs/libs/basis_transcoder.js +0 -22
  94. package/dist/libs/libs/basis_transcoder.wasm +0 -0
  95. package/dist/libs/libs/crunch.js +0 -136
  96. package/dist/npy-loader.js.map +0 -1
  97. package/dist/workers/basis-worker-node.js.map +0 -1
  98. package/dist/workers/basis-worker.js.map +0 -1
  99. package/dist/workers/compressed-texture-worker.js.map +0 -1
  100. package/dist/workers/crunch-worker.js.map +0 -1
  101. package/dist/workers/ktx2-basis-writer-worker-node.js.map +0 -1
  102. package/dist/workers/ktx2-basis-writer-worker.js.map +0 -1
  103. package/dist/workers/npy-worker.js.map +0 -1
@@ -1,26 +1,34 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  import { VERSION } from "./lib/utils/version.js";
2
5
  import parseBasis from "./lib/parsers/parse-basis.js";
6
+ /**
7
+ * Worker loader for Basis super compressed textures
8
+ */
3
9
  export const BasisWorkerLoader = {
4
- name: 'Basis',
5
- id: 'basis',
6
- module: 'textures',
7
- version: VERSION,
8
- worker: true,
9
- extensions: ['basis', 'ktx2'],
10
- mimeTypes: ['application/octet-stream', 'image/ktx2'],
11
- tests: ['sB'],
12
- binary: true,
13
- options: {
14
- basis: {
15
- format: 'auto',
16
- libraryPath: 'libs/',
17
- containerFormat: 'auto',
18
- module: 'transcoder'
10
+ name: 'Basis',
11
+ id: 'basis',
12
+ module: 'textures',
13
+ version: VERSION,
14
+ worker: true,
15
+ extensions: ['basis', 'ktx2'],
16
+ mimeTypes: ['application/octet-stream', 'image/ktx2'],
17
+ tests: ['sB'],
18
+ binary: true,
19
+ options: {
20
+ basis: {
21
+ format: 'auto', // gl context doesn't exist on a worker thread
22
+ libraryPath: 'libs/',
23
+ containerFormat: 'auto', // 'basis' || 'ktx2' || 'auto'
24
+ module: 'transcoder' // 'transcoder' || 'encoder'
25
+ }
19
26
  }
20
- }
21
27
  };
28
+ /**
29
+ * Loader for Basis super compressed textures
30
+ */
22
31
  export const BasisLoader = {
23
- ...BasisWorkerLoader,
24
- parse: parseBasis
32
+ ...BasisWorkerLoader,
33
+ parse: parseBasis
25
34
  };
26
- //# sourceMappingURL=basis-loader.js.map
@@ -1,40 +1,60 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  import { VERSION } from "./lib/utils/version.js";
2
5
  import { parseCompressedTexture } from "./lib/parsers/parse-compressed-texture.js";
3
6
  import parseBasis from "./lib/parsers/parse-basis.js";
7
+ /**
8
+ * Worker Loader for KTX, DDS, and PVR texture container formats
9
+ */
4
10
  export const CompressedTextureWorkerLoader = {
5
- name: 'Texture Containers',
6
- id: 'compressed-texture',
7
- module: 'textures',
8
- version: VERSION,
9
- worker: true,
10
- extensions: ['ktx', 'ktx2', 'dds', 'pvr'],
11
- mimeTypes: ['image/ktx2', 'image/ktx', 'image/vnd-ms.dds', 'image/x-dds', 'application/octet-stream'],
12
- binary: true,
13
- options: {
14
- 'compressed-texture': {
15
- libraryPath: 'libs/',
16
- useBasis: false
11
+ name: 'Texture Containers',
12
+ id: 'compressed-texture',
13
+ module: 'textures',
14
+ version: VERSION,
15
+ worker: true,
16
+ extensions: [
17
+ 'ktx',
18
+ 'ktx2',
19
+ 'dds', // WEBGL_compressed_texture_s3tc, WEBGL_compressed_texture_atc
20
+ 'pvr' // WEBGL_compressed_texture_pvrtc
21
+ ],
22
+ mimeTypes: [
23
+ 'image/ktx2',
24
+ 'image/ktx',
25
+ 'image/vnd-ms.dds',
26
+ 'image/x-dds',
27
+ 'application/octet-stream'
28
+ ],
29
+ binary: true,
30
+ options: {
31
+ 'compressed-texture': {
32
+ libraryPath: 'libs/',
33
+ useBasis: false
34
+ }
17
35
  }
18
- }
19
36
  };
37
+ /**
38
+ * Loader for KTX, DDS, and PVR texture container formats
39
+ */
20
40
  export const CompressedTextureLoader = {
21
- ...CompressedTextureWorkerLoader,
22
- parse: async (arrayBuffer, options) => {
23
- var _options$compressedT;
24
- if (options !== null && options !== void 0 && (_options$compressedT = options['compressed-texture']) !== null && _options$compressedT !== void 0 && _options$compressedT.useBasis) {
25
- options.basis = {
26
- format: {
27
- alpha: 'BC3',
28
- noAlpha: 'BC1'
29
- },
30
- ...options.basis,
31
- containerFormat: 'ktx2',
32
- module: 'encoder'
33
- };
34
- const result = await parseBasis(arrayBuffer, options);
35
- return result[0];
41
+ ...CompressedTextureWorkerLoader,
42
+ parse: async (arrayBuffer, options) => {
43
+ if (options?.['compressed-texture']?.useBasis) {
44
+ // @ts-expect-error TODO not allowed to modify inputs
45
+ options.basis = {
46
+ format: {
47
+ alpha: 'BC3',
48
+ noAlpha: 'BC1'
49
+ },
50
+ // @ts-expect-error TODO not allowed to modify inputs
51
+ ...options.basis,
52
+ containerFormat: 'ktx2',
53
+ module: 'encoder'
54
+ };
55
+ const result = await parseBasis(arrayBuffer, options);
56
+ return result[0];
57
+ }
58
+ return parseCompressedTexture(arrayBuffer);
36
59
  }
37
- return parseCompressedTexture(arrayBuffer);
38
- }
39
60
  };
40
- //# sourceMappingURL=compressed-texture-loader.js.map
@@ -1,24 +1,37 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  import { VERSION } from "./lib/utils/version.js";
2
5
  import { encodeImageURLToCompressedTextureURL } from "./lib/encoders/encode-texture.js";
6
+ /**
7
+ * DDS Texture Container Exporter
8
+ */
3
9
  export const CompressedTextureWriter = {
4
- name: 'DDS Texture Container',
5
- id: 'dds',
6
- module: 'textures',
7
- version: VERSION,
8
- extensions: ['dds'],
9
- options: {
10
- texture: {
11
- format: 'auto',
12
- compression: 'auto',
13
- quality: 'auto',
14
- mipmap: false,
15
- flipY: false,
16
- toolFlags: ''
10
+ name: 'DDS Texture Container',
11
+ id: 'dds',
12
+ module: 'textures',
13
+ version: VERSION,
14
+ extensions: ['dds'],
15
+ options: {
16
+ texture: {
17
+ format: 'auto',
18
+ compression: 'auto',
19
+ quality: 'auto',
20
+ mipmap: false,
21
+ flipY: false,
22
+ toolFlags: ''
23
+ }
24
+ },
25
+ encodeURLtoURL: encodeImageURLToCompressedTextureURL,
26
+ encode() {
27
+ throw new Error('Not implemented');
17
28
  }
18
- },
19
- encodeURLtoURL: encodeImageURLToCompressedTextureURL,
20
- encode() {
21
- throw new Error('Not implemented');
22
- }
23
29
  };
24
- //# sourceMappingURL=compressed-texture-writer.js.map
30
+ // TYPE TESTS - TODO find a better way than exporting junk
31
+ // export const _TypecheckCompressedTextureWriter: typeof CompressedTextureWriter & {
32
+ // encodeURLtoURL: (
33
+ // inputUrl: string,
34
+ // outputUrl: string,
35
+ // options?: CompressedTextureWriterOptions
36
+ // ) => Promise<string>;
37
+ // } = CompressedTextureWriter;
@@ -1,17 +1,23 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  import { VERSION } from "./lib/utils/version.js";
5
+ /**
6
+ * Worker loader for the Crunch compressed texture container format
7
+ * @note We avoid bundling crunch - it is a rare format and large lib, so we only offer worker loader
8
+ */
2
9
  export const CrunchLoader = {
3
- id: 'crunch',
4
- name: 'Crunch',
5
- module: 'textures',
6
- version: VERSION,
7
- worker: true,
8
- extensions: ['crn'],
9
- mimeTypes: ['image/crn', 'image/x-crn', 'application/octet-stream'],
10
- binary: true,
11
- options: {
12
- crunch: {
13
- libraryPath: 'libs/'
10
+ id: 'crunch',
11
+ name: 'Crunch',
12
+ module: 'textures',
13
+ version: VERSION,
14
+ worker: true,
15
+ extensions: ['crn'],
16
+ mimeTypes: ['image/crn', 'image/x-crn', 'application/octet-stream'],
17
+ binary: true,
18
+ options: {
19
+ crunch: {
20
+ libraryPath: 'libs/'
21
+ }
14
22
  }
15
- }
16
23
  };
17
- //# sourceMappingURL=crunch-loader.js.map