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

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 (110) hide show
  1. package/dist/basis-loader.js +27 -19
  2. package/dist/basis-worker-node.js +183 -127
  3. package/dist/basis-worker.js +5 -3
  4. package/dist/compressed-texture-loader.js +51 -31
  5. package/dist/compressed-texture-worker.js +5 -3
  6. package/dist/compressed-texture-writer.js +32 -19
  7. package/dist/crunch-loader.js +19 -13
  8. package/dist/crunch-worker.js +5 -3
  9. package/dist/dist.dev.js +326 -212
  10. package/dist/dist.min.js +10 -0
  11. package/dist/index.cjs +41 -60
  12. package/dist/index.cjs.map +7 -0
  13. package/dist/index.d.ts +16 -16
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +21 -13
  16. package/dist/ktx2-basis-writer-worker-node.js +183 -127
  17. package/dist/ktx2-basis-writer-worker.js +5 -3
  18. package/dist/ktx2-basis-writer.js +21 -15
  19. package/dist/lib/encoders/encode-ktx.js +6 -3
  20. package/dist/lib/encoders/encode-ktx2-basis-texture.js +38 -33
  21. package/dist/lib/encoders/encode-texture.d.ts +1 -1
  22. package/dist/lib/encoders/encode-texture.d.ts.map +1 -1
  23. package/dist/lib/encoders/encode-texture.js +23 -9
  24. package/dist/lib/gl-extensions.js +70 -59
  25. package/dist/lib/parsers/basis-module-loader.js +97 -61
  26. package/dist/lib/parsers/crunch-module-loader.js +29 -13
  27. package/dist/lib/parsers/parse-basis.js +217 -205
  28. package/dist/lib/parsers/parse-compressed-texture.js +20 -11
  29. package/dist/lib/parsers/parse-crunch.js +89 -59
  30. package/dist/lib/parsers/parse-dds.js +82 -53
  31. package/dist/lib/parsers/parse-ktx.js +37 -18
  32. package/dist/lib/parsers/parse-npy.js +70 -53
  33. package/dist/lib/parsers/parse-pvr.js +203 -112
  34. package/dist/lib/texture-api/async-deep-map.js +33 -28
  35. package/dist/lib/texture-api/deep-load.js +7 -5
  36. package/dist/lib/texture-api/generate-url.d.ts +1 -1
  37. package/dist/lib/texture-api/generate-url.d.ts.map +1 -1
  38. package/dist/lib/texture-api/generate-url.js +12 -10
  39. package/dist/lib/texture-api/load-image-array.d.ts +1 -1
  40. package/dist/lib/texture-api/load-image-array.d.ts.map +1 -1
  41. package/dist/lib/texture-api/load-image-array.js +13 -15
  42. package/dist/lib/texture-api/load-image-cube.d.ts +1 -1
  43. package/dist/lib/texture-api/load-image-cube.d.ts.map +1 -1
  44. package/dist/lib/texture-api/load-image-cube.js +32 -51
  45. package/dist/lib/texture-api/load-image.d.ts +1 -1
  46. package/dist/lib/texture-api/load-image.d.ts.map +1 -1
  47. package/dist/lib/texture-api/load-image.js +30 -36
  48. package/dist/lib/texture-api/texture-api-types.js +3 -1
  49. package/dist/lib/utils/extract-mipmap-images.js +43 -29
  50. package/dist/lib/utils/ktx-format-helper.js +119 -68
  51. package/dist/lib/utils/texture-formats.js +40 -26
  52. package/dist/lib/utils/version.js +7 -2
  53. package/dist/npy-loader.d.ts +1 -1
  54. package/dist/npy-loader.d.ts.map +1 -1
  55. package/dist/npy-loader.js +24 -15
  56. package/dist/npy-worker.js +4 -2
  57. package/dist/workers/basis-worker-node.js +4 -1
  58. package/dist/workers/basis-worker.js +3 -1
  59. package/dist/workers/compressed-texture-worker.js +4 -1
  60. package/dist/workers/crunch-worker.d.ts +1 -1
  61. package/dist/workers/crunch-worker.d.ts.map +1 -1
  62. package/dist/workers/crunch-worker.js +8 -3
  63. package/dist/workers/ktx2-basis-writer-worker-node.js +23 -26
  64. package/dist/workers/ktx2-basis-writer-worker.js +22 -26
  65. package/dist/workers/npy-worker.js +3 -1
  66. package/package.json +12 -10
  67. package/dist/basis-loader.js.map +0 -1
  68. package/dist/compressed-texture-loader.js.map +0 -1
  69. package/dist/compressed-texture-writer.js.map +0 -1
  70. package/dist/crunch-loader.js.map +0 -1
  71. package/dist/index.js.map +0 -1
  72. package/dist/ktx2-basis-writer.js.map +0 -1
  73. package/dist/lib/encoders/encode-ktx.js.map +0 -1
  74. package/dist/lib/encoders/encode-ktx2-basis-texture.js.map +0 -1
  75. package/dist/lib/encoders/encode-texture.js.map +0 -1
  76. package/dist/lib/gl-extensions.js.map +0 -1
  77. package/dist/lib/parsers/basis-module-loader.js.map +0 -1
  78. package/dist/lib/parsers/crunch-module-loader.js.map +0 -1
  79. package/dist/lib/parsers/parse-basis.js.map +0 -1
  80. package/dist/lib/parsers/parse-compressed-texture.js.map +0 -1
  81. package/dist/lib/parsers/parse-crunch.js.map +0 -1
  82. package/dist/lib/parsers/parse-dds.js.map +0 -1
  83. package/dist/lib/parsers/parse-ktx.js.map +0 -1
  84. package/dist/lib/parsers/parse-npy.js.map +0 -1
  85. package/dist/lib/parsers/parse-pvr.js.map +0 -1
  86. package/dist/lib/texture-api/async-deep-map.js.map +0 -1
  87. package/dist/lib/texture-api/deep-load.js.map +0 -1
  88. package/dist/lib/texture-api/generate-url.js.map +0 -1
  89. package/dist/lib/texture-api/load-image-array.js.map +0 -1
  90. package/dist/lib/texture-api/load-image-cube.js.map +0 -1
  91. package/dist/lib/texture-api/load-image.js.map +0 -1
  92. package/dist/lib/texture-api/texture-api-types.js.map +0 -1
  93. package/dist/lib/utils/extract-mipmap-images.js.map +0 -1
  94. package/dist/lib/utils/ktx-format-helper.js.map +0 -1
  95. package/dist/lib/utils/texture-formats.js.map +0 -1
  96. package/dist/lib/utils/version.js.map +0 -1
  97. package/dist/libs/libs/README.md +0 -9
  98. package/dist/libs/libs/basis_encoder.js +0 -21
  99. package/dist/libs/libs/basis_encoder.wasm +0 -0
  100. package/dist/libs/libs/basis_transcoder.js +0 -22
  101. package/dist/libs/libs/basis_transcoder.wasm +0 -0
  102. package/dist/libs/libs/crunch.js +0 -136
  103. package/dist/npy-loader.js.map +0 -1
  104. package/dist/workers/basis-worker-node.js.map +0 -1
  105. package/dist/workers/basis-worker.js.map +0 -1
  106. package/dist/workers/compressed-texture-worker.js.map +0 -1
  107. package/dist/workers/crunch-worker.js.map +0 -1
  108. package/dist/workers/ktx2-basis-writer-worker-node.js.map +0 -1
  109. package/dist/workers/ktx2-basis-writer-worker.js.map +0 -1
  110. package/dist/workers/npy-worker.js.map +0 -1
@@ -43,7 +43,7 @@
43
43
  );
44
44
  globalThis._loadersgl_.version = NPM_TAG;
45
45
  } else {
46
- globalThis._loadersgl_.version = "4.2.0-alpha.4";
46
+ globalThis._loadersgl_.version = "4.2.0-alpha.5";
47
47
  }
48
48
  }
49
49
  return globalThis._loadersgl_.version;
@@ -136,7 +136,9 @@
136
136
  }
137
137
  getParentPort().then((parentPort2) => {
138
138
  if (parentPort2) {
139
- parentPort2.on("message", handleMessage);
139
+ parentPort2.on("message", (message) => {
140
+ handleMessage(message);
141
+ });
140
142
  parentPort2.on("exit", () => console.debug("Node worker closing"));
141
143
  } else {
142
144
  globalThis.onmessage = handleMessage;
@@ -358,7 +360,7 @@
358
360
  }
359
361
 
360
362
  // src/lib/utils/version.ts
361
- var VERSION2 = true ? "4.2.0-alpha.4" : "latest";
363
+ var VERSION2 = true ? "4.2.0-alpha.5" : "latest";
362
364
 
363
365
  // src/lib/parsers/basis-module-loader.ts
364
366
  var BASIS_EXTERNAL_LIBRARIES = {
@@ -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
@@ -50,7 +50,7 @@
50
50
  );
51
51
  globalThis._loadersgl_.version = NPM_TAG;
52
52
  } else {
53
- globalThis._loadersgl_.version = "4.2.0-alpha.4";
53
+ globalThis._loadersgl_.version = "4.2.0-alpha.5";
54
54
  }
55
55
  }
56
56
  return globalThis._loadersgl_.version;
@@ -143,7 +143,9 @@
143
143
  }
144
144
  getParentPort().then((parentPort2) => {
145
145
  if (parentPort2) {
146
- parentPort2.on("message", handleMessage);
146
+ parentPort2.on("message", (message) => {
147
+ handleMessage(message);
148
+ });
147
149
  parentPort2.on("exit", () => console.debug("Node worker closing"));
148
150
  } else {
149
151
  globalThis.onmessage = handleMessage;
@@ -365,7 +367,7 @@
365
367
  }
366
368
 
367
369
  // src/lib/utils/version.ts
368
- var VERSION2 = true ? "4.2.0-alpha.4" : "latest";
370
+ var VERSION2 = true ? "4.2.0-alpha.5" : "latest";
369
371
 
370
372
  // ../../node_modules/ktx-parse/dist/ktx-parse.modern.js
371
373
  var t = new Uint8Array([0]);
@@ -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
@@ -50,7 +50,7 @@
50
50
  );
51
51
  globalThis._loadersgl_.version = NPM_TAG;
52
52
  } else {
53
- globalThis._loadersgl_.version = "4.2.0-alpha.4";
53
+ globalThis._loadersgl_.version = "4.2.0-alpha.5";
54
54
  }
55
55
  }
56
56
  return globalThis._loadersgl_.version;
@@ -143,7 +143,9 @@
143
143
  }
144
144
  getParentPort().then((parentPort2) => {
145
145
  if (parentPort2) {
146
- parentPort2.on("message", handleMessage);
146
+ parentPort2.on("message", (message) => {
147
+ handleMessage(message);
148
+ });
147
149
  parentPort2.on("exit", () => console.debug("Node worker closing"));
148
150
  } else {
149
151
  globalThis.onmessage = handleMessage;
@@ -365,7 +367,7 @@
365
367
  }
366
368
 
367
369
  // src/lib/utils/version.ts
368
- var VERSION2 = true ? "4.2.0-alpha.4" : "latest";
370
+ var VERSION2 = true ? "4.2.0-alpha.5" : "latest";
369
371
 
370
372
  // src/crunch-loader.ts
371
373
  var CrunchLoader = {