@loaders.gl/textures 4.4.0-alpha.17 → 4.4.0-alpha.19
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.
- package/README.md +153 -1
- package/dist/basis-loader.d.ts +0 -4
- package/dist/basis-loader.d.ts.map +1 -1
- package/dist/basis-loader.js +0 -1
- package/dist/basis-loader.js.map +1 -1
- package/dist/basis-worker-node.js +57 -30
- package/dist/basis-worker.js +55 -29
- package/dist/compressed-texture-loader.d.ts +0 -4
- package/dist/compressed-texture-loader.d.ts.map +1 -1
- package/dist/compressed-texture-loader.js +0 -1
- package/dist/compressed-texture-loader.js.map +1 -1
- package/dist/compressed-texture-worker.js +122 -79
- package/dist/crunch-loader.d.ts +1 -5
- package/dist/crunch-loader.d.ts.map +1 -1
- package/dist/crunch-loader.js +1 -3
- package/dist/crunch-loader.js.map +1 -1
- package/dist/crunch-worker.js +36 -14
- package/dist/dist.dev.js +1526 -435
- package/dist/dist.min.js +1 -1
- package/dist/index.cjs +1034 -160
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/ktx2-basis-writer-worker-node.js +14 -3
- package/dist/ktx2-basis-writer-worker.js +13 -3
- package/dist/lib/composite-image/image-texture-cube.d.ts +47 -0
- package/dist/lib/composite-image/image-texture-cube.d.ts.map +1 -0
- package/dist/lib/composite-image/image-texture-cube.js +42 -0
- package/dist/lib/composite-image/image-texture-cube.js.map +1 -0
- package/dist/lib/composite-image/parse-composite-image.d.ts +43 -0
- package/dist/lib/composite-image/parse-composite-image.d.ts.map +1 -0
- package/dist/lib/composite-image/parse-composite-image.js +437 -0
- package/dist/lib/composite-image/parse-composite-image.js.map +1 -0
- package/dist/lib/encoders/encode-ktx2-basis-texture.d.ts.map +1 -1
- package/dist/lib/encoders/encode-ktx2-basis-texture.js +2 -1
- package/dist/lib/encoders/encode-ktx2-basis-texture.js.map +1 -1
- package/dist/lib/gl-extensions.d.ts +2 -0
- package/dist/lib/gl-extensions.d.ts.map +1 -1
- package/dist/lib/gl-extensions.js +2 -0
- package/dist/lib/gl-extensions.js.map +1 -1
- package/dist/lib/gl-types.d.ts +4 -0
- package/dist/lib/gl-types.d.ts.map +1 -0
- package/dist/lib/gl-types.js +5 -0
- package/dist/lib/gl-types.js.map +1 -0
- package/dist/lib/parsers/crunch-module-loader.d.ts +2 -2
- package/dist/lib/parsers/crunch-module-loader.d.ts.map +1 -1
- package/dist/lib/parsers/crunch-module-loader.js.map +1 -1
- package/dist/lib/parsers/parse-basis.d.ts +9 -2
- package/dist/lib/parsers/parse-basis.d.ts.map +1 -1
- package/dist/lib/parsers/parse-basis.js +51 -26
- package/dist/lib/parsers/parse-basis.js.map +1 -1
- package/dist/lib/parsers/parse-crunch.d.ts.map +1 -1
- package/dist/lib/parsers/parse-crunch.js +6 -6
- package/dist/lib/parsers/parse-crunch.js.map +1 -1
- package/dist/lib/parsers/parse-dds.d.ts.map +1 -1
- package/dist/lib/parsers/parse-dds.js +10 -11
- package/dist/lib/parsers/parse-dds.js.map +1 -1
- package/dist/lib/parsers/parse-hdr.d.ts +21 -0
- package/dist/lib/parsers/parse-hdr.d.ts.map +1 -0
- package/dist/lib/parsers/parse-hdr.js +305 -0
- package/dist/lib/parsers/parse-hdr.js.map +1 -0
- package/dist/lib/parsers/parse-ktx.d.ts.map +1 -1
- package/dist/lib/parsers/parse-ktx.js +5 -5
- package/dist/lib/parsers/parse-ktx.js.map +1 -1
- package/dist/lib/parsers/parse-pvr.d.ts.map +1 -1
- package/dist/lib/parsers/parse-pvr.js +31 -32
- package/dist/lib/parsers/parse-pvr.js.map +1 -1
- package/dist/lib/texture-api/generate-url.d.ts.map +1 -1
- package/dist/lib/texture-api/generate-url.js +2 -10
- package/dist/lib/texture-api/generate-url.js.map +1 -1
- package/dist/lib/texture-api/load-image-array.d.ts +6 -3
- package/dist/lib/texture-api/load-image-array.d.ts.map +1 -1
- package/dist/lib/texture-api/load-image-array.js +5 -3
- package/dist/lib/texture-api/load-image-array.js.map +1 -1
- package/dist/lib/texture-api/load-image-cube.d.ts +7 -11
- package/dist/lib/texture-api/load-image-cube.d.ts.map +1 -1
- package/dist/lib/texture-api/load-image-cube.js +8 -20
- package/dist/lib/texture-api/load-image-cube.js.map +1 -1
- package/dist/lib/texture-api/load-image.d.ts +6 -3
- package/dist/lib/texture-api/load-image.d.ts.map +1 -1
- package/dist/lib/texture-api/load-image.js +8 -4
- package/dist/lib/texture-api/load-image.js.map +1 -1
- package/dist/lib/texture-api/texture-api-types.d.ts +13 -0
- package/dist/lib/texture-api/texture-api-types.d.ts.map +1 -1
- package/dist/lib/utils/detect-supported-texture-formats.js +4 -4
- package/dist/lib/utils/extract-mipmap-images.d.ts +5 -1
- package/dist/lib/utils/extract-mipmap-images.d.ts.map +1 -1
- package/dist/lib/utils/extract-mipmap-images.js +4 -3
- package/dist/lib/utils/extract-mipmap-images.js.map +1 -1
- package/dist/lib/utils/ktx-format-helper.d.ts +8 -1
- package/dist/lib/utils/ktx-format-helper.d.ts.map +1 -1
- package/dist/lib/utils/ktx-format-helper.js +9 -0
- package/dist/lib/utils/ktx-format-helper.js.map +1 -1
- package/dist/lib/utils/texture-format-map.d.ts +8 -1
- package/dist/lib/utils/texture-format-map.d.ts.map +1 -1
- package/dist/lib/utils/texture-format-map.js +19 -3
- package/dist/lib/utils/texture-format-map.js.map +1 -1
- package/dist/lib/utils/version.js +1 -1
- package/dist/npy-worker.js +1 -1
- package/dist/radiance-hdr-loader.d.ts +25 -0
- package/dist/radiance-hdr-loader.d.ts.map +1 -0
- package/dist/radiance-hdr-loader.js +23 -0
- package/dist/radiance-hdr-loader.js.map +1 -0
- package/dist/texture-array-loader.d.ts +25 -0
- package/dist/texture-array-loader.d.ts.map +1 -0
- package/dist/texture-array-loader.js +24 -0
- package/dist/texture-array-loader.js.map +1 -0
- package/dist/texture-cube-array-loader.d.ts +25 -0
- package/dist/texture-cube-array-loader.d.ts.map +1 -0
- package/dist/texture-cube-array-loader.js +24 -0
- package/dist/texture-cube-array-loader.js.map +1 -0
- package/dist/texture-cube-loader.d.ts +25 -0
- package/dist/texture-cube-loader.d.ts.map +1 -0
- package/dist/texture-cube-loader.js +24 -0
- package/dist/texture-cube-loader.js.map +1 -0
- package/dist/texture-loader.d.ts +25 -0
- package/dist/texture-loader.d.ts.map +1 -0
- package/dist/texture-loader.js +24 -0
- package/dist/texture-loader.js.map +1 -0
- package/dist/workers/crunch-worker.d.ts +1 -3
- package/dist/workers/crunch-worker.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/basis-loader.ts +0 -3
- package/src/compressed-texture-loader.ts +0 -3
- package/src/crunch-loader.ts +1 -5
- package/src/index.ts +19 -0
- package/src/lib/composite-image/image-texture-cube.ts +49 -0
- package/src/lib/composite-image/parse-composite-image.ts +699 -0
- package/src/lib/encoders/encode-ktx2-basis-texture.ts +2 -1
- package/src/lib/gl-extensions.ts +2 -0
- package/src/lib/gl-types.ts +136 -0
- package/src/lib/parsers/crunch-module-loader.ts +4 -4
- package/src/lib/parsers/parse-basis.ts +58 -28
- package/src/lib/parsers/parse-crunch.ts +8 -12
- package/src/lib/parsers/parse-dds.ts +11 -19
- package/src/lib/parsers/parse-hdr.ts +426 -0
- package/src/lib/parsers/parse-ktx.ts +6 -6
- package/src/lib/parsers/parse-pvr.ts +33 -75
- package/src/lib/texture-api/generate-url.ts +2 -12
- package/src/lib/texture-api/load-image-array.ts +15 -6
- package/src/lib/texture-api/load-image-cube.ts +20 -34
- package/src/lib/texture-api/load-image.ts +19 -8
- package/src/lib/texture-api/texture-api-types.ts +15 -0
- package/src/lib/utils/detect-supported-texture-formats.ts +4 -4
- package/src/lib/utils/extract-mipmap-images.ts +12 -4
- package/src/lib/utils/ktx-format-helper.ts +12 -1
- package/src/lib/utils/texture-format-map.ts +30 -3
- package/src/radiance-hdr-loader.ts +36 -0
- package/src/texture-array-loader.ts +46 -0
- package/src/texture-cube-array-loader.ts +49 -0
- package/src/texture-cube-loader.ts +46 -0
- package/src/texture-loader.ts +49 -0
package/dist/index.cjs
CHANGED
|
@@ -96,12 +96,18 @@ __export(dist_exports, {
|
|
|
96
96
|
GL_RGB565: () => GL_RGB565,
|
|
97
97
|
GL_RGB5_A1: () => GL_RGB5_A1,
|
|
98
98
|
GL_RGBA: () => GL_RGBA,
|
|
99
|
+
GL_RGBA32F: () => GL_RGBA32F,
|
|
99
100
|
GL_RGBA4: () => GL_RGBA4,
|
|
100
101
|
GL_RGBA8: () => GL_RGBA8,
|
|
101
102
|
KTX2BasisWriter: () => KTX2BasisWriter,
|
|
102
103
|
KTX2BasisWriterWorker: () => KTX2BasisWriterWorker,
|
|
103
104
|
NPYLoader: () => NPYLoader,
|
|
104
105
|
NPYWorkerLoader: () => NPYWorkerLoader,
|
|
106
|
+
RadianceHDRLoader: () => RadianceHDRLoader,
|
|
107
|
+
TextureArrayLoader: () => TextureArrayLoader,
|
|
108
|
+
TextureCubeArrayLoader: () => TextureCubeArrayLoader,
|
|
109
|
+
TextureCubeLoader: () => TextureCubeLoader,
|
|
110
|
+
TextureLoader: () => TextureLoader,
|
|
105
111
|
loadImageTexture: () => loadImageTexture,
|
|
106
112
|
loadImageTextureArray: () => loadImageTextureArray,
|
|
107
113
|
loadImageTextureCube: () => loadImageTextureCube
|
|
@@ -109,7 +115,10 @@ __export(dist_exports, {
|
|
|
109
115
|
module.exports = __toCommonJS(dist_exports);
|
|
110
116
|
|
|
111
117
|
// dist/lib/utils/version.js
|
|
112
|
-
var VERSION = true ? "4.4.0-alpha.
|
|
118
|
+
var VERSION = true ? "4.4.0-alpha.19" : "latest";
|
|
119
|
+
|
|
120
|
+
// dist/lib/parsers/parse-basis.js
|
|
121
|
+
var import_worker_utils2 = require("@loaders.gl/worker-utils");
|
|
113
122
|
|
|
114
123
|
// dist/lib/parsers/basis-module-loader.js
|
|
115
124
|
var import_loader_utils = require("@loaders.gl/loader-utils");
|
|
@@ -197,6 +206,7 @@ var GL_RGBA4 = 32854;
|
|
|
197
206
|
var GL_RGB5_A1 = 32855;
|
|
198
207
|
var GL_RGBA8 = 32856;
|
|
199
208
|
var GL_RGB565 = 36194;
|
|
209
|
+
var GL_RGBA32F = 34836;
|
|
200
210
|
var GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 33776;
|
|
201
211
|
var GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 33777;
|
|
202
212
|
var GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 33778;
|
|
@@ -266,6 +276,7 @@ var GL_EXTENSIONS_CONSTANTS = {
|
|
|
266
276
|
RGB5_A1: GL_RGB5_A1,
|
|
267
277
|
RGBA8: GL_RGBA8,
|
|
268
278
|
RGB565: GL_RGB565,
|
|
279
|
+
RGBA32F: GL_RGBA32F,
|
|
269
280
|
COMPRESSED_RGB_S3TC_DXT1_EXT: GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
|
270
281
|
COMPRESSED_RGBA_S3TC_DXT1_EXT: GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
|
|
271
282
|
COMPRESSED_RGBA_S3TC_DXT3_EXT: GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
|
|
@@ -382,7 +393,7 @@ var WEBGL_TEXTURE_FORMATS = {
|
|
|
382
393
|
"bc7-rgba-unorm",
|
|
383
394
|
"bc7-rgba-unorm-srgb"
|
|
384
395
|
],
|
|
385
|
-
WEBGL_compressed_texture_etc1: ["etc1-
|
|
396
|
+
WEBGL_compressed_texture_etc1: ["etc1-rgb-unorm-webgl"],
|
|
386
397
|
WEBGL_compressed_texture_etc: [
|
|
387
398
|
"etc2-rgb8unorm",
|
|
388
399
|
"etc2-rgb8unorm-srgb",
|
|
@@ -398,7 +409,7 @@ var WEBGL_TEXTURE_FORMATS = {
|
|
|
398
409
|
WEBGL_compressed_texture_pvrtc: [
|
|
399
410
|
"pvrtc-rgb4unorm-webgl",
|
|
400
411
|
"pvrtc-rgba4unorm-webgl",
|
|
401
|
-
"pvrtc-
|
|
412
|
+
"pvrtc-rgb2unorm-webgl",
|
|
402
413
|
"pvrtc-rgba2unorm-webgl"
|
|
403
414
|
],
|
|
404
415
|
WEBGL_compressed_texture_atc: [
|
|
@@ -470,6 +481,7 @@ var import_ktx_parse = require("ktx-parse");
|
|
|
470
481
|
|
|
471
482
|
// dist/lib/utils/texture-format-map.js
|
|
472
483
|
var WEBGL_TO_TEXTURE_FORMAT = {
|
|
484
|
+
[GL_RGBA32F]: "rgba32float",
|
|
473
485
|
[GL_COMPRESSED_RGB_S3TC_DXT1_EXT]: "bc1-rgb-unorm-webgl",
|
|
474
486
|
[GL_COMPRESSED_SRGB_S3TC_DXT1_EXT]: "bc1-rgb-unorm-srgb-webgl",
|
|
475
487
|
[GL_COMPRESSED_RGBA_S3TC_DXT1_EXT]: "bc1-rgba-unorm",
|
|
@@ -522,25 +534,35 @@ var WEBGL_TO_TEXTURE_FORMAT = {
|
|
|
522
534
|
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR]: "astc-12x12-unorm-srgb",
|
|
523
535
|
[GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG]: "pvrtc-rgb4unorm-webgl",
|
|
524
536
|
[GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG]: "pvrtc-rgba4unorm-webgl",
|
|
525
|
-
[GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG]: "pvrtc-
|
|
537
|
+
[GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG]: "pvrtc-rgb2unorm-webgl",
|
|
526
538
|
[GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG]: "pvrtc-rgba2unorm-webgl",
|
|
527
|
-
[GL_COMPRESSED_RGB_ETC1_WEBGL]: "etc1-
|
|
539
|
+
[GL_COMPRESSED_RGB_ETC1_WEBGL]: "etc1-rgb-unorm-webgl",
|
|
528
540
|
[GL_COMPRESSED_RGB_ATC_WEBGL]: "atc-rgb-unorm-webgl",
|
|
529
541
|
[GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL]: "atc-rgba-unorm-webgl",
|
|
530
542
|
[GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL]: "atc-rgbai-unorm-webgl"
|
|
531
543
|
};
|
|
544
|
+
var TEXTURE_FORMAT_TO_WEBGL = Object.fromEntries(Object.entries(WEBGL_TO_TEXTURE_FORMAT).map(([format, textureFormat]) => [
|
|
545
|
+
textureFormat,
|
|
546
|
+
Number(format)
|
|
547
|
+
]));
|
|
532
548
|
function getTextureFormatFromWebGLFormat(format) {
|
|
533
549
|
if (format === void 0) {
|
|
534
550
|
return void 0;
|
|
535
551
|
}
|
|
536
552
|
return WEBGL_TO_TEXTURE_FORMAT[format];
|
|
537
553
|
}
|
|
554
|
+
function getWebGLFormatFromTextureFormat(textureFormat) {
|
|
555
|
+
if (textureFormat === void 0) {
|
|
556
|
+
return void 0;
|
|
557
|
+
}
|
|
558
|
+
return TEXTURE_FORMAT_TO_WEBGL[textureFormat];
|
|
559
|
+
}
|
|
538
560
|
|
|
539
561
|
// dist/lib/utils/extract-mipmap-images.js
|
|
540
562
|
function extractMipmapImages(data, options) {
|
|
541
563
|
const images = new Array(options.mipMapLevels);
|
|
542
|
-
const
|
|
543
|
-
const
|
|
564
|
+
const textureFormat = options.textureFormat || getTextureFormatFromWebGLFormat(options.internalFormat);
|
|
565
|
+
const format = options.internalFormat || getWebGLFormatFromTextureFormat(options.textureFormat);
|
|
544
566
|
let levelWidth = options.width;
|
|
545
567
|
let levelHeight = options.height;
|
|
546
568
|
let offset = 0;
|
|
@@ -653,6 +675,9 @@ var VULKAN_TO_WEBGL_FORMAT_MAP = {
|
|
|
653
675
|
function mapVkFormatToWebGL(vkFormat) {
|
|
654
676
|
return VULKAN_TO_WEBGL_FORMAT_MAP[vkFormat];
|
|
655
677
|
}
|
|
678
|
+
function mapVkFormatToTextureFormat(vkFormat) {
|
|
679
|
+
return getTextureFormatFromWebGLFormat(mapVkFormatToWebGL(vkFormat));
|
|
680
|
+
}
|
|
656
681
|
|
|
657
682
|
// dist/lib/parsers/parse-ktx.js
|
|
658
683
|
var KTX2_ID = [
|
|
@@ -692,26 +717,27 @@ function parseKTX(arrayBuffer) {
|
|
|
692
717
|
const mipMapLevels = Math.max(1, ktx.levels.length);
|
|
693
718
|
const width = ktx.pixelWidth;
|
|
694
719
|
const height = ktx.pixelHeight;
|
|
695
|
-
const
|
|
696
|
-
if (
|
|
697
|
-
import_loader_utils2.log.warn(`KTX2 container vkFormat ${ktx.vkFormat} does not map to a known
|
|
720
|
+
const textureFormat = mapVkFormatToTextureFormat(ktx.vkFormat);
|
|
721
|
+
if (textureFormat === void 0) {
|
|
722
|
+
import_loader_utils2.log.warn(`KTX2 container vkFormat ${ktx.vkFormat} does not map to a known texture format; returning texture levels without format metadata.`)();
|
|
698
723
|
}
|
|
699
724
|
return extractMipmapImages(ktx.levels, {
|
|
700
725
|
mipMapLevels,
|
|
701
726
|
width,
|
|
702
727
|
height,
|
|
703
728
|
sizeFunction: (level) => level.uncompressedByteLength,
|
|
704
|
-
|
|
729
|
+
textureFormat
|
|
705
730
|
});
|
|
706
731
|
}
|
|
707
732
|
|
|
708
733
|
// dist/lib/parsers/parse-basis.js
|
|
734
|
+
var basisTranscodingLock = Promise.resolve();
|
|
709
735
|
var BASIS_FORMAT_TO_OUTPUT_OPTIONS = {
|
|
710
736
|
etc1: {
|
|
711
737
|
basisFormat: 0,
|
|
712
738
|
compressed: true,
|
|
713
739
|
format: GL_COMPRESSED_RGB_ETC1_WEBGL,
|
|
714
|
-
textureFormat: "etc1-
|
|
740
|
+
textureFormat: "etc1-rgb-unorm-webgl"
|
|
715
741
|
},
|
|
716
742
|
etc2: {
|
|
717
743
|
basisFormat: 1,
|
|
@@ -811,31 +837,47 @@ var BASIS_FORMAT_TO_OUTPUT_OPTIONS = {
|
|
|
811
837
|
}
|
|
812
838
|
};
|
|
813
839
|
var BASIS_FORMATS = Object.freeze(Object.keys(BASIS_FORMAT_TO_OUTPUT_OPTIONS));
|
|
840
|
+
async function withBasisTranscodingLock(transcode) {
|
|
841
|
+
const previousLock = basisTranscodingLock;
|
|
842
|
+
let releaseLock;
|
|
843
|
+
basisTranscodingLock = new Promise((resolve) => {
|
|
844
|
+
releaseLock = resolve;
|
|
845
|
+
});
|
|
846
|
+
await previousLock;
|
|
847
|
+
try {
|
|
848
|
+
return await transcode();
|
|
849
|
+
} finally {
|
|
850
|
+
releaseLock();
|
|
851
|
+
}
|
|
852
|
+
}
|
|
814
853
|
async function parseBasis(data, options = {}) {
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
return parseBasisFile(BasisFile, data, options);
|
|
823
|
-
}
|
|
824
|
-
switch (options.basis.module) {
|
|
825
|
-
case "encoder":
|
|
826
|
-
const fileConstructors = await loadBasisEncoderModule((options == null ? void 0 : options.core) || {});
|
|
827
|
-
switch (options.basis.containerFormat) {
|
|
828
|
-
case "ktx2":
|
|
829
|
-
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
830
|
-
case "basis":
|
|
831
|
-
default:
|
|
832
|
-
return parseBasisFile(fileConstructors.BasisFile, data, options);
|
|
854
|
+
const loadLibraryOptions = (0, import_worker_utils2.extractLoadLibraryOptions)(options);
|
|
855
|
+
return await withBasisTranscodingLock(async () => {
|
|
856
|
+
var _a;
|
|
857
|
+
if (!((_a = options.basis) == null ? void 0 : _a.containerFormat) || options.basis.containerFormat === "auto") {
|
|
858
|
+
if (isKTX(data)) {
|
|
859
|
+
const fileConstructors = await loadBasisEncoderModule(loadLibraryOptions);
|
|
860
|
+
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
833
861
|
}
|
|
834
|
-
|
|
835
|
-
default:
|
|
836
|
-
const { BasisFile } = await loadBasisTranscoderModule(options.core || {});
|
|
862
|
+
const { BasisFile } = await loadBasisTranscoderModule(loadLibraryOptions);
|
|
837
863
|
return parseBasisFile(BasisFile, data, options);
|
|
838
|
-
|
|
864
|
+
}
|
|
865
|
+
switch (options.basis.module) {
|
|
866
|
+
case "encoder":
|
|
867
|
+
const fileConstructors = await loadBasisEncoderModule(loadLibraryOptions);
|
|
868
|
+
switch (options.basis.containerFormat) {
|
|
869
|
+
case "ktx2":
|
|
870
|
+
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
871
|
+
case "basis":
|
|
872
|
+
default:
|
|
873
|
+
return parseBasisFile(fileConstructors.BasisFile, data, options);
|
|
874
|
+
}
|
|
875
|
+
case "transcoder":
|
|
876
|
+
default:
|
|
877
|
+
const { BasisFile } = await loadBasisTranscoderModule(loadLibraryOptions);
|
|
878
|
+
return parseBasisFile(BasisFile, data, options);
|
|
879
|
+
}
|
|
880
|
+
});
|
|
839
881
|
}
|
|
840
882
|
function parseBasisFile(BasisFile, data, options) {
|
|
841
883
|
const basisFile = new BasisFile(new Uint8Array(data));
|
|
@@ -976,7 +1018,7 @@ function selectSupportedBasisFormat(supportedTextureFormats = detectSupportedTex
|
|
|
976
1018
|
} else if (hasSupportedTextureFormat(textureFormats2, [
|
|
977
1019
|
"pvrtc-rgb4unorm-webgl",
|
|
978
1020
|
"pvrtc-rgba4unorm-webgl",
|
|
979
|
-
"pvrtc-
|
|
1021
|
+
"pvrtc-rgb2unorm-webgl",
|
|
980
1022
|
"pvrtc-rgba2unorm-webgl"
|
|
981
1023
|
])) {
|
|
982
1024
|
return {
|
|
@@ -996,7 +1038,7 @@ function selectSupportedBasisFormat(supportedTextureFormats = detectSupportedTex
|
|
|
996
1038
|
"eac-rg11snorm"
|
|
997
1039
|
])) {
|
|
998
1040
|
return "etc2";
|
|
999
|
-
} else if (textureFormats2.has("etc1-
|
|
1041
|
+
} else if (textureFormats2.has("etc1-rgb-unorm-webgl")) {
|
|
1000
1042
|
return "etc1";
|
|
1001
1043
|
} else if (hasSupportedTextureFormat(textureFormats2, [
|
|
1002
1044
|
"atc-rgb-unorm-webgl",
|
|
@@ -1030,7 +1072,6 @@ var BasisWorkerLoader = {
|
|
|
1030
1072
|
options: {
|
|
1031
1073
|
basis: {
|
|
1032
1074
|
format: "auto",
|
|
1033
|
-
libraryPath: "libs/",
|
|
1034
1075
|
containerFormat: "auto",
|
|
1035
1076
|
module: "transcoder"
|
|
1036
1077
|
}
|
|
@@ -1057,13 +1098,13 @@ var DDS_CONSTANTS = {
|
|
|
1057
1098
|
DDSD_MIPMAPCOUNT: 131072,
|
|
1058
1099
|
DDPF_FOURCC: 4
|
|
1059
1100
|
};
|
|
1060
|
-
var
|
|
1061
|
-
DXT1:
|
|
1062
|
-
DXT3:
|
|
1063
|
-
DXT5:
|
|
1064
|
-
"ATC ":
|
|
1065
|
-
ATCA:
|
|
1066
|
-
ATCI:
|
|
1101
|
+
var DDS_TEXTURE_FORMATS = {
|
|
1102
|
+
DXT1: "bc1-rgb-unorm-webgl",
|
|
1103
|
+
DXT3: "bc2-rgba-unorm",
|
|
1104
|
+
DXT5: "bc3-rgba-unorm",
|
|
1105
|
+
"ATC ": "atc-rgb-unorm-webgl",
|
|
1106
|
+
ATCA: "atc-rgba-unorm-webgl",
|
|
1107
|
+
ATCI: "atc-rgbai-unorm-webgl"
|
|
1067
1108
|
};
|
|
1068
1109
|
var getATCLevelSize = getDxt1LevelSize;
|
|
1069
1110
|
var getATCALevelSize = getDxtXLevelSize;
|
|
@@ -1086,9 +1127,9 @@ function parseDDS(data) {
|
|
|
1086
1127
|
const pixelFormatNumber = header[DDS_CONSTANTS.HEADER_PF_FOURCC_INDEX];
|
|
1087
1128
|
(0, import_loader_utils3.assert)(Boolean(header[DDS_CONSTANTS.HEADER_PF_FLAGS_INDEX] & DDS_CONSTANTS.DDPF_FOURCC), "DDS: Unsupported format, must contain a FourCC code");
|
|
1088
1129
|
const fourCC = int32ToFourCC(pixelFormatNumber);
|
|
1089
|
-
const
|
|
1130
|
+
const textureFormat = DDS_TEXTURE_FORMATS[fourCC];
|
|
1090
1131
|
const sizeFunction = DDS_SIZE_FUNCTIONS[fourCC];
|
|
1091
|
-
(0, import_loader_utils3.assert)(
|
|
1132
|
+
(0, import_loader_utils3.assert)(textureFormat && sizeFunction, `DDS: Unknown pixel format ${pixelFormatNumber}`);
|
|
1092
1133
|
let mipMapLevels = 1;
|
|
1093
1134
|
if (header[DDS_CONSTANTS.HEADER_FLAGS_INDEX] & DDS_CONSTANTS.DDSD_MIPMAPCOUNT) {
|
|
1094
1135
|
mipMapLevels = Math.max(1, header[DDS_CONSTANTS.MIPMAPCOUNT_INDEX]);
|
|
@@ -1102,7 +1143,7 @@ function parseDDS(data) {
|
|
|
1102
1143
|
width,
|
|
1103
1144
|
height,
|
|
1104
1145
|
sizeFunction,
|
|
1105
|
-
|
|
1146
|
+
textureFormat
|
|
1106
1147
|
});
|
|
1107
1148
|
}
|
|
1108
1149
|
function getDxt1LevelSize(width, height) {
|
|
@@ -1129,34 +1170,34 @@ var PVR_CONSTANTS = {
|
|
|
1129
1170
|
MIPMAPCOUNT_INDEX: 11,
|
|
1130
1171
|
METADATA_SIZE_INDEX: 12
|
|
1131
1172
|
};
|
|
1132
|
-
var
|
|
1133
|
-
0: [
|
|
1134
|
-
1: [
|
|
1135
|
-
2: [
|
|
1136
|
-
3: [
|
|
1137
|
-
6: [
|
|
1138
|
-
7: [
|
|
1139
|
-
9: [
|
|
1140
|
-
11: [
|
|
1141
|
-
22: [
|
|
1142
|
-
23: [
|
|
1143
|
-
24: [
|
|
1144
|
-
25: [
|
|
1145
|
-
26: [
|
|
1146
|
-
27: [
|
|
1147
|
-
28: [
|
|
1148
|
-
29: [
|
|
1149
|
-
30: [
|
|
1150
|
-
31: [
|
|
1151
|
-
32: [
|
|
1152
|
-
33: [
|
|
1153
|
-
34: [
|
|
1154
|
-
35: [
|
|
1155
|
-
36: [
|
|
1156
|
-
37: [
|
|
1157
|
-
38: [
|
|
1158
|
-
39: [
|
|
1159
|
-
40: [
|
|
1173
|
+
var PVR_TEXTURE_FORMATS = {
|
|
1174
|
+
0: ["pvrtc-rgb2unorm-webgl"],
|
|
1175
|
+
1: ["pvrtc-rgba2unorm-webgl"],
|
|
1176
|
+
2: ["pvrtc-rgb4unorm-webgl"],
|
|
1177
|
+
3: ["pvrtc-rgba4unorm-webgl"],
|
|
1178
|
+
6: ["etc1-rgb-unorm-webgl"],
|
|
1179
|
+
7: ["bc1-rgb-unorm-webgl"],
|
|
1180
|
+
9: ["bc2-rgba-unorm"],
|
|
1181
|
+
11: ["bc3-rgba-unorm"],
|
|
1182
|
+
22: ["etc2-rgb8unorm"],
|
|
1183
|
+
23: ["etc2-rgba8unorm"],
|
|
1184
|
+
24: ["etc2-rgb8a1unorm"],
|
|
1185
|
+
25: ["eac-r11unorm"],
|
|
1186
|
+
26: ["eac-rg11unorm"],
|
|
1187
|
+
27: ["astc-4x4-unorm", "astc-4x4-unorm-srgb"],
|
|
1188
|
+
28: ["astc-5x4-unorm", "astc-5x4-unorm-srgb"],
|
|
1189
|
+
29: ["astc-5x5-unorm", "astc-5x5-unorm-srgb"],
|
|
1190
|
+
30: ["astc-6x5-unorm", "astc-6x5-unorm-srgb"],
|
|
1191
|
+
31: ["astc-6x6-unorm", "astc-6x6-unorm-srgb"],
|
|
1192
|
+
32: ["astc-8x5-unorm", "astc-8x5-unorm-srgb"],
|
|
1193
|
+
33: ["astc-8x6-unorm", "astc-8x6-unorm-srgb"],
|
|
1194
|
+
34: ["astc-8x8-unorm", "astc-8x8-unorm-srgb"],
|
|
1195
|
+
35: ["astc-10x5-unorm", "astc-10x5-unorm-srgb"],
|
|
1196
|
+
36: ["astc-10x6-unorm", "astc-10x6-unorm-srgb"],
|
|
1197
|
+
37: ["astc-10x8-unorm", "astc-10x8-unorm-srgb"],
|
|
1198
|
+
38: ["astc-10x10-unorm", "astc-10x10-unorm-srgb"],
|
|
1199
|
+
39: ["astc-12x10-unorm", "astc-12x10-unorm-srgb"],
|
|
1200
|
+
40: ["astc-12x12-unorm", "astc-12x12-unorm-srgb"]
|
|
1160
1201
|
};
|
|
1161
1202
|
var PVR_SIZE_FUNCTIONS = {
|
|
1162
1203
|
0: pvrtc2bppSize,
|
|
@@ -1196,8 +1237,8 @@ function parsePVR(data) {
|
|
|
1196
1237
|
const header = new Uint32Array(data, 0, PVR_CONSTANTS.HEADER_LENGTH);
|
|
1197
1238
|
const pvrFormat = header[PVR_CONSTANTS.PIXEL_FORMAT_INDEX];
|
|
1198
1239
|
const colourSpace = header[PVR_CONSTANTS.COLOUR_SPACE_INDEX];
|
|
1199
|
-
const
|
|
1200
|
-
const
|
|
1240
|
+
const textureFormats2 = PVR_TEXTURE_FORMATS[pvrFormat] || [];
|
|
1241
|
+
const textureFormat = textureFormats2.length > 1 && colourSpace ? textureFormats2[1] : textureFormats2[0];
|
|
1201
1242
|
const sizeFunction = PVR_SIZE_FUNCTIONS[pvrFormat];
|
|
1202
1243
|
const mipMapLevels = header[PVR_CONSTANTS.MIPMAPCOUNT_INDEX];
|
|
1203
1244
|
const width = header[PVR_CONSTANTS.WIDTH_INDEX];
|
|
@@ -1209,7 +1250,7 @@ function parsePVR(data) {
|
|
|
1209
1250
|
width,
|
|
1210
1251
|
height,
|
|
1211
1252
|
sizeFunction,
|
|
1212
|
-
|
|
1253
|
+
textureFormat
|
|
1213
1254
|
});
|
|
1214
1255
|
}
|
|
1215
1256
|
function pvrtc2bppSize(width, height) {
|
|
@@ -1309,7 +1350,6 @@ var CompressedTextureWorkerLoader = {
|
|
|
1309
1350
|
binary: true,
|
|
1310
1351
|
options: {
|
|
1311
1352
|
"compressed-texture": {
|
|
1312
|
-
libraryPath: "libs/",
|
|
1313
1353
|
useBasis: false
|
|
1314
1354
|
}
|
|
1315
1355
|
}
|
|
@@ -1349,10 +1389,326 @@ var CrunchLoader = {
|
|
|
1349
1389
|
mimeTypes: ["image/crn", "image/x-crn", "application/octet-stream"],
|
|
1350
1390
|
binary: true,
|
|
1351
1391
|
options: {
|
|
1352
|
-
crunch: {
|
|
1353
|
-
|
|
1392
|
+
crunch: {}
|
|
1393
|
+
}
|
|
1394
|
+
};
|
|
1395
|
+
|
|
1396
|
+
// dist/lib/parsers/parse-hdr.js
|
|
1397
|
+
var HDR_MAGIC_HEADERS = ["#?RADIANCE", "#?RGBE"];
|
|
1398
|
+
var HDR_FORMAT = "32-bit_rle_rgbe";
|
|
1399
|
+
function isHDR(arrayBuffer) {
|
|
1400
|
+
const state = {
|
|
1401
|
+
data: new Uint8Array(arrayBuffer),
|
|
1402
|
+
offset: 0
|
|
1403
|
+
};
|
|
1404
|
+
const firstLine = readLine(state);
|
|
1405
|
+
return firstLine ? HDR_MAGIC_HEADERS.includes(firstLine) : false;
|
|
1406
|
+
}
|
|
1407
|
+
function parseHDR(arrayBuffer) {
|
|
1408
|
+
const state = {
|
|
1409
|
+
data: new Uint8Array(arrayBuffer),
|
|
1410
|
+
offset: 0
|
|
1411
|
+
};
|
|
1412
|
+
const header = readHeader(state);
|
|
1413
|
+
const { width, height } = header;
|
|
1414
|
+
const rgbeData = readPixels(state, header);
|
|
1415
|
+
const data = convertRGBEToFloat(rgbeData);
|
|
1416
|
+
const level = {
|
|
1417
|
+
shape: "texture-level",
|
|
1418
|
+
compressed: false,
|
|
1419
|
+
width,
|
|
1420
|
+
height,
|
|
1421
|
+
data,
|
|
1422
|
+
levelSize: data.byteLength,
|
|
1423
|
+
format: GL_RGBA32F,
|
|
1424
|
+
textureFormat: "rgba32float"
|
|
1425
|
+
};
|
|
1426
|
+
return {
|
|
1427
|
+
shape: "texture",
|
|
1428
|
+
type: "2d",
|
|
1429
|
+
format: "rgba32float",
|
|
1430
|
+
...header.metadata ? { metadata: header.metadata } : {},
|
|
1431
|
+
data: [level]
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
function readHeader(state) {
|
|
1435
|
+
const magicHeader = readLine(state);
|
|
1436
|
+
if (!magicHeader || !HDR_MAGIC_HEADERS.includes(magicHeader)) {
|
|
1437
|
+
throw new Error("RadianceHDRLoader: bad initial token");
|
|
1438
|
+
}
|
|
1439
|
+
let hasFormat = false;
|
|
1440
|
+
const metadata = {};
|
|
1441
|
+
while (state.offset < state.data.length) {
|
|
1442
|
+
const line = readLine(state);
|
|
1443
|
+
if (line === null) {
|
|
1444
|
+
break;
|
|
1445
|
+
}
|
|
1446
|
+
if (!line || line.startsWith("#")) {
|
|
1447
|
+
continue;
|
|
1448
|
+
}
|
|
1449
|
+
if (line.startsWith("FORMAT=")) {
|
|
1450
|
+
hasFormat = line.slice("FORMAT=".length) === HDR_FORMAT;
|
|
1451
|
+
if (!hasFormat) {
|
|
1452
|
+
throw new Error("RadianceHDRLoader: unsupported format specifier");
|
|
1453
|
+
}
|
|
1454
|
+
continue;
|
|
1455
|
+
}
|
|
1456
|
+
parseMetadataLine(metadata, line);
|
|
1457
|
+
const dimensions = parseDimensions(line);
|
|
1458
|
+
if (dimensions) {
|
|
1459
|
+
if (!hasFormat) {
|
|
1460
|
+
throw new Error("RadianceHDRLoader: missing format specifier");
|
|
1461
|
+
}
|
|
1462
|
+
return {
|
|
1463
|
+
...dimensions,
|
|
1464
|
+
...hasMetadata(metadata) ? { metadata } : {}
|
|
1465
|
+
};
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
if (!hasFormat) {
|
|
1469
|
+
throw new Error("RadianceHDRLoader: missing format specifier");
|
|
1470
|
+
}
|
|
1471
|
+
throw new Error("RadianceHDRLoader: missing image size specifier");
|
|
1472
|
+
}
|
|
1473
|
+
function parseDimensions(line) {
|
|
1474
|
+
const match = line.match(/^([+-])([YX])\s+(\d+)\s+([+-])([YX])\s+(\d+)$/);
|
|
1475
|
+
if (!match) {
|
|
1476
|
+
return null;
|
|
1477
|
+
}
|
|
1478
|
+
const majorSign = match[1] === "+" ? 1 : -1;
|
|
1479
|
+
const majorAxis = match[2];
|
|
1480
|
+
const majorLength = Number(match[3]);
|
|
1481
|
+
const minorSign = match[4] === "+" ? 1 : -1;
|
|
1482
|
+
const minorAxis = match[5];
|
|
1483
|
+
const minorLength = Number(match[6]);
|
|
1484
|
+
if (majorAxis === minorAxis) {
|
|
1485
|
+
throw new Error("RadianceHDRLoader: invalid image dimensions");
|
|
1486
|
+
}
|
|
1487
|
+
const width = majorAxis === "X" ? majorLength : minorLength;
|
|
1488
|
+
const height = majorAxis === "Y" ? majorLength : minorLength;
|
|
1489
|
+
if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) {
|
|
1490
|
+
throw new Error("RadianceHDRLoader: invalid image dimensions");
|
|
1491
|
+
}
|
|
1492
|
+
return { width, height, majorAxis, majorSign, minorAxis, minorSign };
|
|
1493
|
+
}
|
|
1494
|
+
function readPixels(state, header) {
|
|
1495
|
+
const { width, height } = header;
|
|
1496
|
+
const pixelCount = width * height;
|
|
1497
|
+
const flatByteLength = pixelCount * 4;
|
|
1498
|
+
const scanlineLength = header.minorAxis === "X" ? width : height;
|
|
1499
|
+
const scanlineCount = header.majorAxis === "Y" ? height : width;
|
|
1500
|
+
if (scanlineLength < 8 || scanlineLength > 32767) {
|
|
1501
|
+
return reorderPixels(readFlatPixels(state, flatByteLength), header);
|
|
1502
|
+
}
|
|
1503
|
+
if (state.offset + 4 > state.data.length) {
|
|
1504
|
+
throw new Error("RadianceHDRLoader: unexpected end of file");
|
|
1505
|
+
}
|
|
1506
|
+
const data = state.data;
|
|
1507
|
+
const isRunLengthEncoded = data[state.offset] === 2 && data[state.offset + 1] === 2 && !(data[state.offset + 2] & 128);
|
|
1508
|
+
if (!isRunLengthEncoded) {
|
|
1509
|
+
return reorderPixels(readFlatPixels(state, flatByteLength), header);
|
|
1510
|
+
}
|
|
1511
|
+
const scanlineWidth = data[state.offset + 2] << 8 | data[state.offset + 3];
|
|
1512
|
+
if (scanlineWidth !== scanlineLength) {
|
|
1513
|
+
return reorderPixels(readFlatPixels(state, flatByteLength), header);
|
|
1514
|
+
}
|
|
1515
|
+
const pixels = new Uint8Array(flatByteLength);
|
|
1516
|
+
const scanlineBuffer = new Uint8Array(scanlineLength * 4);
|
|
1517
|
+
for (let scanlineIndex = 0; scanlineIndex < scanlineCount; scanlineIndex++) {
|
|
1518
|
+
if (state.offset + 4 > data.length) {
|
|
1519
|
+
throw new Error("RadianceHDRLoader: unexpected end of file");
|
|
1520
|
+
}
|
|
1521
|
+
const red = data[state.offset++];
|
|
1522
|
+
const green = data[state.offset++];
|
|
1523
|
+
const blue = data[state.offset++];
|
|
1524
|
+
const exponent = data[state.offset++];
|
|
1525
|
+
if (red !== 2 || green !== 2 || (blue << 8 | exponent) !== scanlineLength) {
|
|
1526
|
+
throw new Error("RadianceHDRLoader: bad rgbe scanline format");
|
|
1527
|
+
}
|
|
1528
|
+
for (let channelIndex = 0; channelIndex < 4; channelIndex++) {
|
|
1529
|
+
const channelOffset = channelIndex * scanlineLength;
|
|
1530
|
+
const channelEnd = channelOffset + scanlineLength;
|
|
1531
|
+
let pixelOffset = channelOffset;
|
|
1532
|
+
while (pixelOffset < channelEnd) {
|
|
1533
|
+
if (state.offset >= data.length) {
|
|
1534
|
+
throw new Error("RadianceHDRLoader: unexpected end of file");
|
|
1535
|
+
}
|
|
1536
|
+
let count = data[state.offset++];
|
|
1537
|
+
if (count > 128) {
|
|
1538
|
+
count -= 128;
|
|
1539
|
+
if (count === 0 || pixelOffset + count > channelEnd || state.offset >= data.length) {
|
|
1540
|
+
throw new Error("RadianceHDRLoader: bad scanline data");
|
|
1541
|
+
}
|
|
1542
|
+
const value = data[state.offset++];
|
|
1543
|
+
scanlineBuffer.fill(value, pixelOffset, pixelOffset + count);
|
|
1544
|
+
pixelOffset += count;
|
|
1545
|
+
continue;
|
|
1546
|
+
}
|
|
1547
|
+
if (count === 0 || pixelOffset + count > channelEnd || state.offset + count > data.length) {
|
|
1548
|
+
throw new Error("RadianceHDRLoader: bad scanline data");
|
|
1549
|
+
}
|
|
1550
|
+
scanlineBuffer.set(data.subarray(state.offset, state.offset + count), pixelOffset);
|
|
1551
|
+
pixelOffset += count;
|
|
1552
|
+
state.offset += count;
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
for (let pixelIndex = 0; pixelIndex < scanlineLength; pixelIndex++) {
|
|
1556
|
+
const outputOffset = getOutputOffset(header, scanlineIndex, pixelIndex);
|
|
1557
|
+
pixels[outputOffset] = scanlineBuffer[pixelIndex];
|
|
1558
|
+
pixels[outputOffset + 1] = scanlineBuffer[pixelIndex + scanlineLength];
|
|
1559
|
+
pixels[outputOffset + 2] = scanlineBuffer[pixelIndex + scanlineLength * 2];
|
|
1560
|
+
pixels[outputOffset + 3] = scanlineBuffer[pixelIndex + scanlineLength * 3];
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
return pixels;
|
|
1564
|
+
}
|
|
1565
|
+
function reorderPixels(data, header) {
|
|
1566
|
+
const pixels = new Uint8Array(data.length);
|
|
1567
|
+
const scanlineLength = header.minorAxis === "X" ? header.width : header.height;
|
|
1568
|
+
const scanlineCount = header.majorAxis === "Y" ? header.height : header.width;
|
|
1569
|
+
for (let scanlineIndex = 0; scanlineIndex < scanlineCount; scanlineIndex++) {
|
|
1570
|
+
for (let pixelIndex = 0; pixelIndex < scanlineLength; pixelIndex++) {
|
|
1571
|
+
const sourceOffset = (scanlineIndex * scanlineLength + pixelIndex) * 4;
|
|
1572
|
+
const outputOffset = getOutputOffset(header, scanlineIndex, pixelIndex);
|
|
1573
|
+
pixels[outputOffset] = data[sourceOffset];
|
|
1574
|
+
pixels[outputOffset + 1] = data[sourceOffset + 1];
|
|
1575
|
+
pixels[outputOffset + 2] = data[sourceOffset + 2];
|
|
1576
|
+
pixels[outputOffset + 3] = data[sourceOffset + 3];
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
return pixels;
|
|
1580
|
+
}
|
|
1581
|
+
function getOutputOffset(header, scanlineIndex, pixelIndex) {
|
|
1582
|
+
const majorCoordinate = getCoordinate(header.majorAxis === "X" ? header.width : header.height, header.majorSign, scanlineIndex);
|
|
1583
|
+
const minorCoordinate = getCoordinate(header.minorAxis === "X" ? header.width : header.height, header.minorSign, pixelIndex);
|
|
1584
|
+
const x = header.majorAxis === "X" ? majorCoordinate : minorCoordinate;
|
|
1585
|
+
const y = header.majorAxis === "Y" ? majorCoordinate : minorCoordinate;
|
|
1586
|
+
return ((header.height - 1 - y) * header.width + x) * 4;
|
|
1587
|
+
}
|
|
1588
|
+
function getCoordinate(length, sign, index) {
|
|
1589
|
+
return sign === 1 ? index : length - 1 - index;
|
|
1590
|
+
}
|
|
1591
|
+
function readFlatPixels(state, byteLength) {
|
|
1592
|
+
if (state.offset + byteLength > state.data.length) {
|
|
1593
|
+
throw new Error("RadianceHDRLoader: unexpected end of file");
|
|
1594
|
+
}
|
|
1595
|
+
const pixels = state.data.slice(state.offset, state.offset + byteLength);
|
|
1596
|
+
state.offset += byteLength;
|
|
1597
|
+
return pixels;
|
|
1598
|
+
}
|
|
1599
|
+
function convertRGBEToFloat(data) {
|
|
1600
|
+
const floatData = new Float32Array(data.length);
|
|
1601
|
+
for (let sourceOffset = 0; sourceOffset < data.length; sourceOffset += 4) {
|
|
1602
|
+
const exponent = data[sourceOffset + 3];
|
|
1603
|
+
const destinationOffset = sourceOffset;
|
|
1604
|
+
if (exponent > 0) {
|
|
1605
|
+
const scale = Math.pow(2, exponent - 128) / 255;
|
|
1606
|
+
floatData[destinationOffset] = data[sourceOffset] * scale;
|
|
1607
|
+
floatData[destinationOffset + 1] = data[sourceOffset + 1] * scale;
|
|
1608
|
+
floatData[destinationOffset + 2] = data[sourceOffset + 2] * scale;
|
|
1354
1609
|
}
|
|
1610
|
+
floatData[destinationOffset + 3] = 1;
|
|
1355
1611
|
}
|
|
1612
|
+
return floatData;
|
|
1613
|
+
}
|
|
1614
|
+
function readLine(state) {
|
|
1615
|
+
if (state.offset >= state.data.length) {
|
|
1616
|
+
return null;
|
|
1617
|
+
}
|
|
1618
|
+
const lineStart = state.offset;
|
|
1619
|
+
while (state.offset < state.data.length) {
|
|
1620
|
+
const byte = state.data[state.offset++];
|
|
1621
|
+
if (byte === 10) {
|
|
1622
|
+
const line2 = decodeASCII(state.data.subarray(lineStart, state.offset - 1));
|
|
1623
|
+
return line2.endsWith("\r") ? line2.slice(0, -1) : line2;
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
const line = decodeASCII(state.data.subarray(lineStart, state.offset));
|
|
1627
|
+
return line.endsWith("\r") ? line.slice(0, -1) : line;
|
|
1628
|
+
}
|
|
1629
|
+
function decodeASCII(data) {
|
|
1630
|
+
let line = "";
|
|
1631
|
+
for (const byte of data) {
|
|
1632
|
+
line += String.fromCharCode(byte);
|
|
1633
|
+
}
|
|
1634
|
+
return line;
|
|
1635
|
+
}
|
|
1636
|
+
function parseMetadataLine(metadata, line) {
|
|
1637
|
+
if (line.startsWith("COLORCORR=")) {
|
|
1638
|
+
const values = parseNumberList(line.slice("COLORCORR=".length), 3);
|
|
1639
|
+
if (values) {
|
|
1640
|
+
metadata.colorCorrection = values;
|
|
1641
|
+
}
|
|
1642
|
+
return;
|
|
1643
|
+
}
|
|
1644
|
+
if (line.startsWith("EXPOSURE=")) {
|
|
1645
|
+
const value = parseNumber(line.slice("EXPOSURE=".length));
|
|
1646
|
+
if (value !== null) {
|
|
1647
|
+
metadata.exposure = value;
|
|
1648
|
+
}
|
|
1649
|
+
return;
|
|
1650
|
+
}
|
|
1651
|
+
if (line.startsWith("GAMMA=")) {
|
|
1652
|
+
const value = parseNumber(line.slice("GAMMA=".length));
|
|
1653
|
+
if (value !== null) {
|
|
1654
|
+
metadata.gamma = value;
|
|
1655
|
+
}
|
|
1656
|
+
return;
|
|
1657
|
+
}
|
|
1658
|
+
if (line.startsWith("PIXASPECT=")) {
|
|
1659
|
+
const value = parseNumber(line.slice("PIXASPECT=".length));
|
|
1660
|
+
if (value !== null) {
|
|
1661
|
+
metadata.pixelAspectRatio = value;
|
|
1662
|
+
}
|
|
1663
|
+
return;
|
|
1664
|
+
}
|
|
1665
|
+
if (line.startsWith("PRIMARIES=")) {
|
|
1666
|
+
const values = parseNumberList(line.slice("PRIMARIES=".length), 8);
|
|
1667
|
+
if (values) {
|
|
1668
|
+
metadata.primaries = values;
|
|
1669
|
+
}
|
|
1670
|
+
return;
|
|
1671
|
+
}
|
|
1672
|
+
if (line.startsWith("SOFTWARE=")) {
|
|
1673
|
+
metadata.software = line.slice("SOFTWARE=".length).trim();
|
|
1674
|
+
return;
|
|
1675
|
+
}
|
|
1676
|
+
if (line.startsWith("VIEW=")) {
|
|
1677
|
+
metadata.view = line.slice("VIEW=".length).trim();
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
function parseNumber(text) {
|
|
1681
|
+
const value = Number(text.trim());
|
|
1682
|
+
return Number.isFinite(value) ? value : null;
|
|
1683
|
+
}
|
|
1684
|
+
function parseNumberList(text, count) {
|
|
1685
|
+
const values = text.trim().split(/\s+/).map((value) => Number(value));
|
|
1686
|
+
if (values.length !== count || values.some((value) => !Number.isFinite(value))) {
|
|
1687
|
+
return null;
|
|
1688
|
+
}
|
|
1689
|
+
return values;
|
|
1690
|
+
}
|
|
1691
|
+
function hasMetadata(metadata) {
|
|
1692
|
+
return Object.keys(metadata).length > 0;
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
// dist/radiance-hdr-loader.js
|
|
1696
|
+
var RadianceHDRLoader = {
|
|
1697
|
+
dataType: null,
|
|
1698
|
+
batchType: null,
|
|
1699
|
+
name: "Radiance HDR",
|
|
1700
|
+
id: "hdr",
|
|
1701
|
+
module: "textures",
|
|
1702
|
+
version: VERSION,
|
|
1703
|
+
extensions: ["hdr"],
|
|
1704
|
+
mimeTypes: ["image/vnd.radiance", "image/x-hdr", "application/octet-stream"],
|
|
1705
|
+
binary: true,
|
|
1706
|
+
tests: [isHDR],
|
|
1707
|
+
options: {
|
|
1708
|
+
hdr: {}
|
|
1709
|
+
},
|
|
1710
|
+
parseSync: parseHDR,
|
|
1711
|
+
parse: async (arrayBuffer) => parseHDR(arrayBuffer)
|
|
1356
1712
|
};
|
|
1357
1713
|
|
|
1358
1714
|
// dist/lib/parsers/parse-npy.js
|
|
@@ -1436,16 +1792,597 @@ var NPYLoader = {
|
|
|
1436
1792
|
parse: async (arrayBuffer, options) => parseNPY(arrayBuffer, options)
|
|
1437
1793
|
};
|
|
1438
1794
|
|
|
1439
|
-
// dist/lib/
|
|
1795
|
+
// dist/lib/composite-image/parse-composite-image.js
|
|
1440
1796
|
var import_loader_utils4 = require("@loaders.gl/loader-utils");
|
|
1441
|
-
var
|
|
1797
|
+
var import_images = require("@loaders.gl/images");
|
|
1798
|
+
|
|
1799
|
+
// dist/lib/texture-api/async-deep-map.js
|
|
1800
|
+
var isObject = (value) => value && typeof value === "object";
|
|
1801
|
+
async function asyncDeepMap(tree, func, options = {}) {
|
|
1802
|
+
return await mapSubtree(tree, func, options);
|
|
1803
|
+
}
|
|
1804
|
+
async function mapSubtree(object, func, options) {
|
|
1805
|
+
if (Array.isArray(object)) {
|
|
1806
|
+
return await mapArray(object, func, options);
|
|
1807
|
+
}
|
|
1808
|
+
if (isObject(object)) {
|
|
1809
|
+
return await mapObject(object, func, options);
|
|
1810
|
+
}
|
|
1811
|
+
const url = object;
|
|
1812
|
+
return await func(url, options);
|
|
1813
|
+
}
|
|
1814
|
+
async function mapObject(object, func, options) {
|
|
1815
|
+
const promises = [];
|
|
1816
|
+
const values = {};
|
|
1817
|
+
for (const key in object) {
|
|
1818
|
+
const url = object[key];
|
|
1819
|
+
const promise = mapSubtree(url, func, options).then((value) => {
|
|
1820
|
+
values[key] = value;
|
|
1821
|
+
});
|
|
1822
|
+
promises.push(promise);
|
|
1823
|
+
}
|
|
1824
|
+
await Promise.all(promises);
|
|
1825
|
+
return values;
|
|
1826
|
+
}
|
|
1827
|
+
async function mapArray(urlArray, func, options = {}) {
|
|
1828
|
+
const promises = urlArray.map((url) => mapSubtree(url, func, options));
|
|
1829
|
+
return await Promise.all(promises);
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
// dist/lib/composite-image/image-texture-cube.js
|
|
1833
|
+
var GL_TEXTURE_CUBE_MAP_POSITIVE_X = 34069;
|
|
1834
|
+
var GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 34070;
|
|
1835
|
+
var GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 34071;
|
|
1836
|
+
var GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 34072;
|
|
1837
|
+
var GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 34073;
|
|
1838
|
+
var GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 34074;
|
|
1839
|
+
var IMAGE_TEXTURE_CUBE_FACES = [
|
|
1840
|
+
{
|
|
1841
|
+
face: GL_TEXTURE_CUBE_MAP_POSITIVE_X,
|
|
1842
|
+
name: "+X",
|
|
1843
|
+
direction: "right",
|
|
1844
|
+
axis: "x",
|
|
1845
|
+
sign: "positive"
|
|
1846
|
+
},
|
|
1847
|
+
{
|
|
1848
|
+
face: GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
|
|
1849
|
+
name: "-X",
|
|
1850
|
+
direction: "left",
|
|
1851
|
+
axis: "x",
|
|
1852
|
+
sign: "negative"
|
|
1853
|
+
},
|
|
1854
|
+
{ face: GL_TEXTURE_CUBE_MAP_POSITIVE_Y, name: "+Y", direction: "top", axis: "y", sign: "positive" },
|
|
1855
|
+
{
|
|
1856
|
+
face: GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
|
|
1857
|
+
name: "-Y",
|
|
1858
|
+
direction: "bottom",
|
|
1859
|
+
axis: "y",
|
|
1860
|
+
sign: "negative"
|
|
1861
|
+
},
|
|
1862
|
+
{
|
|
1863
|
+
face: GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
|
|
1864
|
+
name: "+Z",
|
|
1865
|
+
direction: "front",
|
|
1866
|
+
axis: "z",
|
|
1867
|
+
sign: "positive"
|
|
1868
|
+
},
|
|
1869
|
+
{ face: GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, name: "-Z", direction: "back", axis: "z", sign: "negative" }
|
|
1870
|
+
];
|
|
1871
|
+
|
|
1872
|
+
// dist/lib/composite-image/parse-composite-image.js
|
|
1873
|
+
async function parseCompositeImageManifest(text, expectedShape, options = {}, context) {
|
|
1874
|
+
const manifest = parseCompositeImageManifestJSON(text);
|
|
1875
|
+
if (manifest.shape !== expectedShape) {
|
|
1876
|
+
throw new Error(`Expected ${expectedShape} manifest, got ${manifest.shape}`);
|
|
1877
|
+
}
|
|
1878
|
+
return await loadCompositeImageManifest(manifest, options, context);
|
|
1879
|
+
}
|
|
1880
|
+
function testCompositeImageManifestShape(text, shape) {
|
|
1881
|
+
try {
|
|
1882
|
+
return parseCompositeImageManifestJSON(text).shape === shape;
|
|
1883
|
+
} catch {
|
|
1884
|
+
return false;
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
async function loadCompositeImageManifest(manifest, options = {}, context) {
|
|
1888
|
+
const normalizedOptions = normalizeCompositeImageManifestOptions(options);
|
|
1889
|
+
const urlTree = await getCompositeImageUrlTree(manifest, normalizedOptions, context);
|
|
1890
|
+
const imageData = await loadCompositeImageUrlTree(urlTree, normalizedOptions, context);
|
|
1891
|
+
return convertCompositeImageToTexture(manifest.shape, imageData);
|
|
1892
|
+
}
|
|
1893
|
+
async function loadCompositeImageUrlTree(urlTree, options = {}, context) {
|
|
1894
|
+
const normalizedOptions = normalizeCompositeImageOptions(options);
|
|
1895
|
+
return await asyncDeepMap(urlTree, async (url) => await loadCompositeImageMember(url, normalizedOptions, context));
|
|
1896
|
+
}
|
|
1897
|
+
async function loadCompositeImageMember(url, options = {}, context) {
|
|
1898
|
+
const resolvedUrl = resolveCompositeImageUrl(url, options, context);
|
|
1899
|
+
const fetch2 = getCompositeImageFetch(options, context);
|
|
1900
|
+
const response = await fetch2(resolvedUrl);
|
|
1901
|
+
const subloaderOptions = getCompositeImageSubloaderOptions(options);
|
|
1902
|
+
if (context) {
|
|
1903
|
+
const childContext = getCompositeImageMemberContext(resolvedUrl, response, context);
|
|
1904
|
+
return await (0, import_loader_utils4.parseFromContext)(response, [import_images.ImageLoader], subloaderOptions, childContext);
|
|
1905
|
+
}
|
|
1906
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
1907
|
+
return await import_images.ImageLoader.parse(arrayBuffer, subloaderOptions);
|
|
1908
|
+
}
|
|
1909
|
+
async function getCompositeImageUrlTree(manifest, options = {}, context) {
|
|
1910
|
+
switch (manifest.shape) {
|
|
1911
|
+
case "image-texture":
|
|
1912
|
+
return await getImageTextureSource(manifest, options, context);
|
|
1913
|
+
case "image-texture-array":
|
|
1914
|
+
if (!Array.isArray(manifest.layers) || manifest.layers.length === 0) {
|
|
1915
|
+
throw new Error("image-texture-array manifest must define one or more layers");
|
|
1916
|
+
}
|
|
1917
|
+
return await Promise.all(manifest.layers.map(async (layer, index) => await getNormalizedImageTextureSource(layer, options, context, { index })));
|
|
1918
|
+
case "image-texture-cube":
|
|
1919
|
+
return await getImageTextureCubeUrls(manifest, options, context);
|
|
1920
|
+
case "image-texture-cube-array":
|
|
1921
|
+
if (!Array.isArray(manifest.layers) || manifest.layers.length === 0) {
|
|
1922
|
+
throw new Error("image-texture-cube-array manifest must define one or more layers");
|
|
1923
|
+
}
|
|
1924
|
+
return await Promise.all(manifest.layers.map(async (layer, index) => await getImageTextureCubeUrls(layer, options, context, { index })));
|
|
1925
|
+
default:
|
|
1926
|
+
throw new Error("Unsupported composite image manifest");
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
function normalizeCompositeImageOptions(options = {}) {
|
|
1930
|
+
var _a;
|
|
1931
|
+
if ((_a = options.core) == null ? void 0 : _a.baseUrl) {
|
|
1932
|
+
return options;
|
|
1933
|
+
}
|
|
1934
|
+
const fallbackBaseUrl = options.baseUrl;
|
|
1935
|
+
if (!fallbackBaseUrl) {
|
|
1936
|
+
return options;
|
|
1937
|
+
}
|
|
1938
|
+
return {
|
|
1939
|
+
...options,
|
|
1940
|
+
core: {
|
|
1941
|
+
...options.core,
|
|
1942
|
+
baseUrl: fallbackBaseUrl
|
|
1943
|
+
}
|
|
1944
|
+
};
|
|
1945
|
+
}
|
|
1946
|
+
function resolveCompositeImageUrl(url, options = {}, context) {
|
|
1947
|
+
const resolvedUrl = (0, import_loader_utils4.resolvePath)(url);
|
|
1948
|
+
if (isAbsoluteCompositeImageUrl(url)) {
|
|
1949
|
+
return resolvedUrl;
|
|
1950
|
+
}
|
|
1951
|
+
const baseUrl = getCompositeImageBaseUrl(options, context);
|
|
1952
|
+
if (!baseUrl) {
|
|
1953
|
+
if (resolvedUrl !== url || url.startsWith("@")) {
|
|
1954
|
+
return resolvedUrl;
|
|
1955
|
+
}
|
|
1956
|
+
throw new Error(`Unable to resolve relative image URL ${url} without a base URL`);
|
|
1957
|
+
}
|
|
1958
|
+
return (0, import_loader_utils4.resolvePath)(joinCompositeImageUrl(baseUrl, url));
|
|
1959
|
+
}
|
|
1960
|
+
function parseCompositeImageManifestJSON(text) {
|
|
1961
|
+
const manifest = JSON.parse(text);
|
|
1962
|
+
if (!(manifest == null ? void 0 : manifest.shape)) {
|
|
1963
|
+
throw new Error("Composite image manifest must contain a shape field");
|
|
1964
|
+
}
|
|
1965
|
+
return manifest;
|
|
1966
|
+
}
|
|
1967
|
+
async function getImageTextureSource(manifest, options, context) {
|
|
1968
|
+
var _a;
|
|
1969
|
+
if ((manifest.image || manifest.mipmaps) && manifest.template) {
|
|
1970
|
+
throw new Error("image-texture manifest must define image, mipmaps, or template source");
|
|
1971
|
+
}
|
|
1972
|
+
if (manifest.image && manifest.mipmaps) {
|
|
1973
|
+
throw new Error("image-texture manifest must define image, mipmaps, or template source");
|
|
1974
|
+
}
|
|
1975
|
+
if (manifest.image) {
|
|
1976
|
+
return manifest.image;
|
|
1977
|
+
}
|
|
1978
|
+
if ((_a = manifest.mipmaps) == null ? void 0 : _a.length) {
|
|
1979
|
+
return manifest.mipmaps;
|
|
1980
|
+
}
|
|
1981
|
+
if (manifest.template) {
|
|
1982
|
+
return await expandImageTextureSource({ mipLevels: manifest.mipLevels ?? "auto", template: manifest.template }, options, context, {});
|
|
1983
|
+
}
|
|
1984
|
+
throw new Error("image-texture manifest must define image, mipmaps, or template source");
|
|
1985
|
+
}
|
|
1986
|
+
async function getImageTextureCubeUrls(manifest, options, context, templateOptions = {}) {
|
|
1987
|
+
var _a, _b;
|
|
1988
|
+
const urls = {};
|
|
1989
|
+
for (const { face, name, direction, axis, sign } of IMAGE_TEXTURE_CUBE_FACES) {
|
|
1990
|
+
const source = ((_a = manifest.faces) == null ? void 0 : _a[name]) || ((_b = manifest.faces) == null ? void 0 : _b[direction]);
|
|
1991
|
+
if (!source) {
|
|
1992
|
+
throw new Error(`image-texture-cube manifest is missing ${name} face`);
|
|
1993
|
+
}
|
|
1994
|
+
urls[face] = await getNormalizedImageTextureSource(source, options, context, {
|
|
1995
|
+
...templateOptions,
|
|
1996
|
+
face: name,
|
|
1997
|
+
direction,
|
|
1998
|
+
axis,
|
|
1999
|
+
sign
|
|
2000
|
+
});
|
|
2001
|
+
}
|
|
2002
|
+
return urls;
|
|
2003
|
+
}
|
|
2004
|
+
async function getNormalizedImageTextureSource(source, options, context, templateOptions) {
|
|
2005
|
+
if (typeof source === "string") {
|
|
2006
|
+
return source;
|
|
2007
|
+
}
|
|
2008
|
+
if (Array.isArray(source) && source.length > 0) {
|
|
2009
|
+
return source;
|
|
2010
|
+
}
|
|
2011
|
+
if (isImageTextureTemplateSource(source)) {
|
|
2012
|
+
return await expandImageTextureSource(source, options, context, templateOptions);
|
|
2013
|
+
}
|
|
2014
|
+
throw new Error("Composite image source entries must be strings or non-empty mip arrays");
|
|
2015
|
+
}
|
|
2016
|
+
async function expandImageTextureSource(source, options, context, templateOptions) {
|
|
2017
|
+
const mipLevels = source.mipLevels === "auto" ? await getAutoMipLevels(source.template, options, context, templateOptions) : source.mipLevels;
|
|
2018
|
+
if (!Number.isFinite(mipLevels) || mipLevels <= 0) {
|
|
2019
|
+
throw new Error(`Invalid mipLevels value ${source.mipLevels}`);
|
|
2020
|
+
}
|
|
2021
|
+
const urls = [];
|
|
2022
|
+
for (let lod = 0; lod < mipLevels; lod++) {
|
|
2023
|
+
urls.push(expandTemplate(source.template, { ...templateOptions, lod }));
|
|
2024
|
+
}
|
|
2025
|
+
return urls;
|
|
2026
|
+
}
|
|
2027
|
+
async function getAutoMipLevels(template, options, context, templateOptions) {
|
|
2028
|
+
if (!template.includes("{lod}")) {
|
|
2029
|
+
throw new Error("Template sources with mipLevels: auto must include a {lod} placeholder");
|
|
2030
|
+
}
|
|
2031
|
+
const level0Url = expandTemplate(template, { ...templateOptions, lod: 0 });
|
|
2032
|
+
const image = await loadCompositeImageMember(level0Url, normalizeCompositeImageOptions(options), context);
|
|
2033
|
+
const { width, height } = (0, import_images.getImageSize)(image);
|
|
2034
|
+
return 1 + Math.floor(Math.log2(Math.max(width, height)));
|
|
2035
|
+
}
|
|
2036
|
+
function expandTemplate(template, templateOptions) {
|
|
2037
|
+
let expanded = "";
|
|
2038
|
+
for (let index = 0; index < template.length; index++) {
|
|
2039
|
+
const character = template[index];
|
|
2040
|
+
if (character === "\\") {
|
|
2041
|
+
const nextCharacter = template[index + 1];
|
|
2042
|
+
if (nextCharacter === "{" || nextCharacter === "}" || nextCharacter === "\\") {
|
|
2043
|
+
expanded += nextCharacter;
|
|
2044
|
+
index++;
|
|
2045
|
+
continue;
|
|
2046
|
+
}
|
|
2047
|
+
throw new Error(`Invalid escape sequence \\${nextCharacter || ""} in template ${template}`);
|
|
2048
|
+
}
|
|
2049
|
+
if (character === "}") {
|
|
2050
|
+
throw new Error(`Unexpected } in template ${template}`);
|
|
2051
|
+
}
|
|
2052
|
+
if (character !== "{") {
|
|
2053
|
+
expanded += character;
|
|
2054
|
+
continue;
|
|
2055
|
+
}
|
|
2056
|
+
const closingBraceIndex = findClosingBraceIndex(template, index + 1);
|
|
2057
|
+
if (closingBraceIndex < 0) {
|
|
2058
|
+
throw new Error(`Unterminated placeholder in template ${template}`);
|
|
2059
|
+
}
|
|
2060
|
+
const placeholder = template.slice(index + 1, closingBraceIndex);
|
|
2061
|
+
if (!/^[a-z][a-zA-Z0-9]*$/.test(placeholder)) {
|
|
2062
|
+
throw new Error(`Invalid placeholder {${placeholder}} in template ${template}`);
|
|
2063
|
+
}
|
|
2064
|
+
const value = getTemplateValue(placeholder, templateOptions);
|
|
2065
|
+
if (value === void 0) {
|
|
2066
|
+
throw new Error(`Template ${template} uses unsupported placeholder {${placeholder}} for this source`);
|
|
2067
|
+
}
|
|
2068
|
+
expanded += String(value);
|
|
2069
|
+
index = closingBraceIndex;
|
|
2070
|
+
}
|
|
2071
|
+
return expanded;
|
|
2072
|
+
}
|
|
2073
|
+
function findClosingBraceIndex(template, startIndex) {
|
|
2074
|
+
for (let index = startIndex; index < template.length; index++) {
|
|
2075
|
+
const character = template[index];
|
|
2076
|
+
if (character === "\\") {
|
|
2077
|
+
index++;
|
|
2078
|
+
continue;
|
|
2079
|
+
}
|
|
2080
|
+
if (character === "{") {
|
|
2081
|
+
throw new Error(`Nested placeholders are not supported in template ${template}`);
|
|
2082
|
+
}
|
|
2083
|
+
if (character === "}") {
|
|
2084
|
+
return index;
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
return -1;
|
|
2088
|
+
}
|
|
2089
|
+
function getTemplateValue(placeholder, templateOptions) {
|
|
2090
|
+
switch (placeholder) {
|
|
2091
|
+
case "lod":
|
|
2092
|
+
return templateOptions.lod;
|
|
2093
|
+
case "index":
|
|
2094
|
+
return templateOptions.index;
|
|
2095
|
+
case "face":
|
|
2096
|
+
return templateOptions.face;
|
|
2097
|
+
case "direction":
|
|
2098
|
+
return templateOptions.direction;
|
|
2099
|
+
case "axis":
|
|
2100
|
+
return templateOptions.axis;
|
|
2101
|
+
case "sign":
|
|
2102
|
+
return templateOptions.sign;
|
|
2103
|
+
default:
|
|
2104
|
+
return void 0;
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2107
|
+
function isImageTextureTemplateSource(source) {
|
|
2108
|
+
return typeof source === "object" && source !== null && !Array.isArray(source);
|
|
2109
|
+
}
|
|
2110
|
+
function getCompositeImageBaseUrl(options, context) {
|
|
2111
|
+
var _a;
|
|
2112
|
+
if (context == null ? void 0 : context.baseUrl) {
|
|
2113
|
+
return context.baseUrl;
|
|
2114
|
+
}
|
|
2115
|
+
if (options.baseUrl) {
|
|
2116
|
+
return stripTrailingSlash(options.baseUrl);
|
|
2117
|
+
}
|
|
2118
|
+
if ((_a = options.core) == null ? void 0 : _a.baseUrl) {
|
|
2119
|
+
return getSourceUrlDirectory(options.core.baseUrl);
|
|
2120
|
+
}
|
|
2121
|
+
return null;
|
|
2122
|
+
}
|
|
2123
|
+
function stripTrailingSlash(baseUrl) {
|
|
2124
|
+
if (baseUrl.endsWith("/")) {
|
|
2125
|
+
return baseUrl.slice(0, -1);
|
|
2126
|
+
}
|
|
2127
|
+
return baseUrl;
|
|
2128
|
+
}
|
|
2129
|
+
function getSourceUrlDirectory(baseUrl) {
|
|
2130
|
+
return stripTrailingSlash(import_loader_utils4.path.dirname(baseUrl));
|
|
2131
|
+
}
|
|
2132
|
+
function joinCompositeImageUrl(baseUrl, url) {
|
|
2133
|
+
if (isRequestLikeUrl(baseUrl)) {
|
|
2134
|
+
return new URL(url, `${stripTrailingSlash(baseUrl)}/`).toString();
|
|
2135
|
+
}
|
|
2136
|
+
const normalizedBaseUrl = baseUrl.startsWith("/") ? baseUrl : `/${baseUrl}`;
|
|
2137
|
+
const normalizedUrl = import_loader_utils4.path.resolve(normalizedBaseUrl, url);
|
|
2138
|
+
return baseUrl.startsWith("/") ? normalizedUrl : normalizedUrl.slice(1);
|
|
2139
|
+
}
|
|
2140
|
+
function isRequestLikeUrl(url) {
|
|
2141
|
+
return url.startsWith("http:") || url.startsWith("https:") || url.startsWith("file:") || url.startsWith("blob:");
|
|
2142
|
+
}
|
|
2143
|
+
function getCompositeImageFetch(options, context) {
|
|
2144
|
+
var _a;
|
|
2145
|
+
const fetchOption = options.fetch ?? ((_a = options.core) == null ? void 0 : _a.fetch);
|
|
2146
|
+
if (context == null ? void 0 : context.fetch) {
|
|
2147
|
+
return context.fetch;
|
|
2148
|
+
}
|
|
2149
|
+
if (typeof fetchOption === "function") {
|
|
2150
|
+
return fetchOption;
|
|
2151
|
+
}
|
|
2152
|
+
if (fetchOption && typeof fetchOption === "object") {
|
|
2153
|
+
return (url) => fetch(url, fetchOption);
|
|
2154
|
+
}
|
|
2155
|
+
return fetch;
|
|
2156
|
+
}
|
|
2157
|
+
function getCompositeImageSubloaderOptions(options) {
|
|
2158
|
+
const core = options.core;
|
|
2159
|
+
const rest = { ...options };
|
|
2160
|
+
delete rest.baseUrl;
|
|
2161
|
+
if (!(core == null ? void 0 : core.baseUrl)) {
|
|
2162
|
+
return rest;
|
|
2163
|
+
}
|
|
2164
|
+
const restCore = { ...core };
|
|
2165
|
+
delete restCore.baseUrl;
|
|
2166
|
+
return {
|
|
2167
|
+
...rest,
|
|
2168
|
+
core: restCore
|
|
2169
|
+
};
|
|
2170
|
+
}
|
|
2171
|
+
function normalizeCompositeImageManifestOptions(options) {
|
|
2172
|
+
var _a;
|
|
2173
|
+
if (((_a = options.image) == null ? void 0 : _a.type) || typeof ImageBitmap === "undefined") {
|
|
2174
|
+
return options;
|
|
2175
|
+
}
|
|
2176
|
+
return {
|
|
2177
|
+
...options,
|
|
2178
|
+
image: {
|
|
2179
|
+
...options.image,
|
|
2180
|
+
type: "imagebitmap"
|
|
2181
|
+
}
|
|
2182
|
+
};
|
|
2183
|
+
}
|
|
2184
|
+
function getCompositeImageMemberContext(resolvedUrl, response, context) {
|
|
2185
|
+
const url = response.url || resolvedUrl;
|
|
2186
|
+
const [urlWithoutQueryString, queryString = ""] = url.split("?");
|
|
2187
|
+
return {
|
|
2188
|
+
...context,
|
|
2189
|
+
url,
|
|
2190
|
+
response,
|
|
2191
|
+
filename: import_loader_utils4.path.filename(urlWithoutQueryString),
|
|
2192
|
+
baseUrl: import_loader_utils4.path.dirname(urlWithoutQueryString),
|
|
2193
|
+
queryString
|
|
2194
|
+
};
|
|
2195
|
+
}
|
|
2196
|
+
function convertCompositeImageToTexture(shape, imageData) {
|
|
2197
|
+
switch (shape) {
|
|
2198
|
+
case "image-texture": {
|
|
2199
|
+
const data = normalizeCompositeImageMember(imageData);
|
|
2200
|
+
return {
|
|
2201
|
+
shape: "texture",
|
|
2202
|
+
type: "2d",
|
|
2203
|
+
format: getCompositeTextureFormat(data),
|
|
2204
|
+
data
|
|
2205
|
+
};
|
|
2206
|
+
}
|
|
2207
|
+
case "image-texture-array": {
|
|
2208
|
+
const data = imageData.map((layer) => normalizeCompositeImageMember(layer));
|
|
2209
|
+
return {
|
|
2210
|
+
shape: "texture",
|
|
2211
|
+
type: "2d-array",
|
|
2212
|
+
format: getCompositeTextureFormat(data[0]),
|
|
2213
|
+
data
|
|
2214
|
+
};
|
|
2215
|
+
}
|
|
2216
|
+
case "image-texture-cube": {
|
|
2217
|
+
const data = IMAGE_TEXTURE_CUBE_FACES.map(({ face }) => normalizeCompositeImageMember(imageData[face]));
|
|
2218
|
+
return {
|
|
2219
|
+
shape: "texture",
|
|
2220
|
+
type: "cube",
|
|
2221
|
+
format: getCompositeTextureFormat(data[0]),
|
|
2222
|
+
data
|
|
2223
|
+
};
|
|
2224
|
+
}
|
|
2225
|
+
case "image-texture-cube-array": {
|
|
2226
|
+
const data = imageData.map((layer) => IMAGE_TEXTURE_CUBE_FACES.map(({ face }) => normalizeCompositeImageMember(layer[face])));
|
|
2227
|
+
return {
|
|
2228
|
+
shape: "texture",
|
|
2229
|
+
type: "cube-array",
|
|
2230
|
+
format: getCompositeTextureFormat(data[0][0]),
|
|
2231
|
+
data
|
|
2232
|
+
};
|
|
2233
|
+
}
|
|
2234
|
+
default:
|
|
2235
|
+
throw new Error(`Unsupported composite image shape ${shape}`);
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
function normalizeCompositeImageMember(imageData) {
|
|
2239
|
+
if (Array.isArray(imageData)) {
|
|
2240
|
+
if (imageData.length === 0) {
|
|
2241
|
+
throw new Error("Composite image members must not be empty");
|
|
2242
|
+
}
|
|
2243
|
+
if (imageData.every(isTextureLevel)) {
|
|
2244
|
+
return imageData;
|
|
2245
|
+
}
|
|
2246
|
+
if (imageData.every(import_images.isImage)) {
|
|
2247
|
+
return imageData.map((image) => getTextureLevelFromImage(image));
|
|
2248
|
+
}
|
|
2249
|
+
if (imageData.every((entry) => Array.isArray(entry) && entry.every(isTextureLevel))) {
|
|
2250
|
+
if (imageData.length !== 1) {
|
|
2251
|
+
throw new Error("Composite image members must resolve to a single image or mip chain");
|
|
2252
|
+
}
|
|
2253
|
+
return imageData[0];
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
if (isTexture(imageData)) {
|
|
2257
|
+
if (imageData.type !== "2d") {
|
|
2258
|
+
throw new Error(`Composite image members must resolve to 2d textures, got ${imageData.type}`);
|
|
2259
|
+
}
|
|
2260
|
+
return imageData.data;
|
|
2261
|
+
}
|
|
2262
|
+
if (isTextureLevel(imageData)) {
|
|
2263
|
+
return [imageData];
|
|
2264
|
+
}
|
|
2265
|
+
if ((0, import_images.isImage)(imageData)) {
|
|
2266
|
+
return [getTextureLevelFromImage(imageData)];
|
|
2267
|
+
}
|
|
2268
|
+
throw new Error("Composite image members must resolve to an image, mip chain, or texture");
|
|
2269
|
+
}
|
|
2270
|
+
function getTextureLevelFromImage(image) {
|
|
2271
|
+
const { width, height } = (0, import_images.getImageSize)(image);
|
|
2272
|
+
return {
|
|
2273
|
+
shape: "texture-level",
|
|
2274
|
+
compressed: false,
|
|
2275
|
+
width,
|
|
2276
|
+
height,
|
|
2277
|
+
imageBitmap: typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap ? image : void 0,
|
|
2278
|
+
data: new Uint8Array(0),
|
|
2279
|
+
textureFormat: "rgba8unorm"
|
|
2280
|
+
};
|
|
2281
|
+
}
|
|
2282
|
+
function getCompositeTextureFormat(textureLevels) {
|
|
2283
|
+
var _a;
|
|
2284
|
+
return ((_a = textureLevels[0]) == null ? void 0 : _a.textureFormat) || "rgba8unorm";
|
|
2285
|
+
}
|
|
2286
|
+
function isTextureLevel(textureLevel) {
|
|
2287
|
+
return Boolean(textureLevel && typeof textureLevel === "object" && "shape" in textureLevel && textureLevel.shape === "texture-level");
|
|
2288
|
+
}
|
|
2289
|
+
function isTexture(texture) {
|
|
2290
|
+
return Boolean(texture && typeof texture === "object" && "shape" in texture && texture.shape === "texture");
|
|
2291
|
+
}
|
|
2292
|
+
function isAbsoluteCompositeImageUrl(url) {
|
|
2293
|
+
return url.startsWith("data:") || url.startsWith("blob:") || url.startsWith("file:") || url.startsWith("http:") || url.startsWith("https:") || url.startsWith("/");
|
|
2294
|
+
}
|
|
2295
|
+
|
|
2296
|
+
// dist/texture-loader.js
|
|
2297
|
+
var TextureLoader = {
|
|
2298
|
+
dataType: null,
|
|
2299
|
+
batchType: null,
|
|
2300
|
+
id: "texture",
|
|
2301
|
+
name: "Texture",
|
|
2302
|
+
module: "textures",
|
|
2303
|
+
version: VERSION,
|
|
2304
|
+
extensions: [],
|
|
2305
|
+
mimeTypes: [],
|
|
2306
|
+
text: true,
|
|
2307
|
+
worker: false,
|
|
2308
|
+
testText: (text) => testCompositeImageManifestShape(text, "image-texture"),
|
|
2309
|
+
options: {
|
|
2310
|
+
image: {}
|
|
2311
|
+
},
|
|
2312
|
+
parse: async (arrayBuffer, options, context) => await parseCompositeImageManifest(new TextDecoder().decode(arrayBuffer), "image-texture", options, context),
|
|
2313
|
+
parseText: async (text, options, context) => await parseCompositeImageManifest(text, "image-texture", options, context)
|
|
2314
|
+
};
|
|
2315
|
+
|
|
2316
|
+
// dist/texture-array-loader.js
|
|
2317
|
+
var TextureArrayLoader = {
|
|
2318
|
+
dataType: null,
|
|
2319
|
+
batchType: null,
|
|
2320
|
+
id: "texture-array",
|
|
2321
|
+
name: "Texture Array",
|
|
2322
|
+
module: "textures",
|
|
2323
|
+
version: VERSION,
|
|
2324
|
+
extensions: [],
|
|
2325
|
+
mimeTypes: [],
|
|
2326
|
+
text: true,
|
|
2327
|
+
worker: false,
|
|
2328
|
+
testText: (text) => testCompositeImageManifestShape(text, "image-texture-array"),
|
|
2329
|
+
options: {
|
|
2330
|
+
image: {}
|
|
2331
|
+
},
|
|
2332
|
+
parse: async (arrayBuffer, options, context) => await parseCompositeImageManifest(new TextDecoder().decode(arrayBuffer), "image-texture-array", options, context),
|
|
2333
|
+
parseText: async (text, options, context) => await parseCompositeImageManifest(text, "image-texture-array", options, context)
|
|
2334
|
+
};
|
|
2335
|
+
|
|
2336
|
+
// dist/texture-cube-loader.js
|
|
2337
|
+
var TextureCubeLoader = {
|
|
2338
|
+
dataType: null,
|
|
2339
|
+
batchType: null,
|
|
2340
|
+
id: "texture-cube",
|
|
2341
|
+
name: "Texture Cube",
|
|
2342
|
+
module: "textures",
|
|
2343
|
+
version: VERSION,
|
|
2344
|
+
extensions: [],
|
|
2345
|
+
mimeTypes: [],
|
|
2346
|
+
text: true,
|
|
2347
|
+
worker: false,
|
|
2348
|
+
testText: (text) => testCompositeImageManifestShape(text, "image-texture-cube"),
|
|
2349
|
+
options: {
|
|
2350
|
+
image: {}
|
|
2351
|
+
},
|
|
2352
|
+
parse: async (arrayBuffer, options, context) => await parseCompositeImageManifest(new TextDecoder().decode(arrayBuffer), "image-texture-cube", options, context),
|
|
2353
|
+
parseText: async (text, options, context) => await parseCompositeImageManifest(text, "image-texture-cube", options, context)
|
|
2354
|
+
};
|
|
2355
|
+
|
|
2356
|
+
// dist/texture-cube-array-loader.js
|
|
2357
|
+
var TextureCubeArrayLoader = {
|
|
2358
|
+
dataType: null,
|
|
2359
|
+
batchType: null,
|
|
2360
|
+
id: "texture-cube-array",
|
|
2361
|
+
name: "Texture Cube Array",
|
|
2362
|
+
module: "textures",
|
|
2363
|
+
version: VERSION,
|
|
2364
|
+
extensions: [],
|
|
2365
|
+
mimeTypes: [],
|
|
2366
|
+
text: true,
|
|
2367
|
+
worker: false,
|
|
2368
|
+
testText: (text) => testCompositeImageManifestShape(text, "image-texture-cube-array"),
|
|
2369
|
+
options: {
|
|
2370
|
+
image: {}
|
|
2371
|
+
},
|
|
2372
|
+
parse: async (arrayBuffer, options, context) => await parseCompositeImageManifest(new TextDecoder().decode(arrayBuffer), "image-texture-cube-array", options, context),
|
|
2373
|
+
parseText: async (text, options, context) => await parseCompositeImageManifest(text, "image-texture-cube-array", options, context)
|
|
2374
|
+
};
|
|
2375
|
+
|
|
2376
|
+
// dist/lib/parsers/crunch-module-loader.js
|
|
2377
|
+
var import_loader_utils5 = require("@loaders.gl/loader-utils");
|
|
2378
|
+
var import_worker_utils3 = require("@loaders.gl/worker-utils");
|
|
1442
2379
|
var CRUNCH_EXTERNAL_LIBRARIES = {
|
|
1443
2380
|
/** Crunch decoder library. It is used as dynamically imported script */
|
|
1444
2381
|
DECODER: "crunch.js"
|
|
1445
2382
|
};
|
|
1446
2383
|
|
|
1447
2384
|
// dist/lib/encoders/encode-texture.js
|
|
1448
|
-
var
|
|
2385
|
+
var import_worker_utils4 = require("@loaders.gl/worker-utils");
|
|
1449
2386
|
async function encodeImageURLToCompressedTextureURL(inputUrl, outputUrl, options) {
|
|
1450
2387
|
const args = [
|
|
1451
2388
|
// Note: our actual executable is `npx`, so `texture-compressor` is an argument
|
|
@@ -1461,7 +2398,7 @@ async function encodeImageURLToCompressedTextureURL(inputUrl, outputUrl, options
|
|
|
1461
2398
|
"--output",
|
|
1462
2399
|
outputUrl
|
|
1463
2400
|
];
|
|
1464
|
-
const childProcess = new
|
|
2401
|
+
const childProcess = new import_worker_utils4.ChildProcessProxy();
|
|
1465
2402
|
await childProcess.start({
|
|
1466
2403
|
command: "npx",
|
|
1467
2404
|
arguments: args,
|
|
@@ -1495,9 +2432,10 @@ var CompressedTextureWriter = {
|
|
|
1495
2432
|
};
|
|
1496
2433
|
|
|
1497
2434
|
// dist/lib/encoders/encode-ktx2-basis-texture.js
|
|
2435
|
+
var import_worker_utils5 = require("@loaders.gl/worker-utils");
|
|
1498
2436
|
async function encodeKTX2BasisTexture(image, options = {}) {
|
|
1499
2437
|
const { useSRGB = false, qualityLevel = 10, encodeUASTC = false, mipmaps = false } = (options == null ? void 0 : options["ktx2-basis-writer"]) || {};
|
|
1500
|
-
const { BasisEncoder } = await loadBasisEncoderModule(
|
|
2438
|
+
const { BasisEncoder } = await loadBasisEncoderModule((0, import_worker_utils5.extractLoadLibraryOptions)(options));
|
|
1501
2439
|
const basisEncoder = new BasisEncoder();
|
|
1502
2440
|
try {
|
|
1503
2441
|
const basisFileData = new Uint8Array(image.width * image.height * 4);
|
|
@@ -1542,66 +2480,17 @@ var KTX2BasisWriter = {
|
|
|
1542
2480
|
|
|
1543
2481
|
// dist/lib/texture-api/load-image.js
|
|
1544
2482
|
var import_loader_utils6 = require("@loaders.gl/loader-utils");
|
|
1545
|
-
var
|
|
2483
|
+
var import_images2 = require("@loaders.gl/images");
|
|
1546
2484
|
|
|
1547
2485
|
// dist/lib/texture-api/generate-url.js
|
|
1548
|
-
var import_loader_utils5 = require("@loaders.gl/loader-utils");
|
|
1549
2486
|
function generateUrl(getUrl, options, urlOptions) {
|
|
1550
|
-
|
|
1551
|
-
const baseUrl = options.baseUrl;
|
|
1552
|
-
if (baseUrl) {
|
|
1553
|
-
url = baseUrl[baseUrl.length - 1] === "/" ? `${baseUrl}${url}` : `${baseUrl}/${url}`;
|
|
1554
|
-
}
|
|
1555
|
-
return (0, import_loader_utils5.resolvePath)(url);
|
|
1556
|
-
}
|
|
1557
|
-
|
|
1558
|
-
// dist/lib/texture-api/async-deep-map.js
|
|
1559
|
-
var isObject = (value) => value && typeof value === "object";
|
|
1560
|
-
async function asyncDeepMap(tree, func, options = {}) {
|
|
1561
|
-
return await mapSubtree(tree, func, options);
|
|
1562
|
-
}
|
|
1563
|
-
async function mapSubtree(object, func, options) {
|
|
1564
|
-
if (Array.isArray(object)) {
|
|
1565
|
-
return await mapArray(object, func, options);
|
|
1566
|
-
}
|
|
1567
|
-
if (isObject(object)) {
|
|
1568
|
-
return await mapObject(object, func, options);
|
|
1569
|
-
}
|
|
1570
|
-
const url = object;
|
|
1571
|
-
return await func(url, options);
|
|
1572
|
-
}
|
|
1573
|
-
async function mapObject(object, func, options) {
|
|
1574
|
-
const promises = [];
|
|
1575
|
-
const values = {};
|
|
1576
|
-
for (const key in object) {
|
|
1577
|
-
const url = object[key];
|
|
1578
|
-
const promise = mapSubtree(url, func, options).then((value) => {
|
|
1579
|
-
values[key] = value;
|
|
1580
|
-
});
|
|
1581
|
-
promises.push(promise);
|
|
1582
|
-
}
|
|
1583
|
-
await Promise.all(promises);
|
|
1584
|
-
return values;
|
|
1585
|
-
}
|
|
1586
|
-
async function mapArray(urlArray, func, options = {}) {
|
|
1587
|
-
const promises = urlArray.map((url) => mapSubtree(url, func, options));
|
|
1588
|
-
return await Promise.all(promises);
|
|
1589
|
-
}
|
|
1590
|
-
|
|
1591
|
-
// dist/lib/texture-api/deep-load.js
|
|
1592
|
-
async function deepLoad(urlTree, load, options) {
|
|
1593
|
-
return await asyncDeepMap(urlTree, (url) => shallowLoad(url, load, options));
|
|
1594
|
-
}
|
|
1595
|
-
async function shallowLoad(url, load, options) {
|
|
1596
|
-
const response = await fetch(url, options.fetch);
|
|
1597
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
1598
|
-
return await load(arrayBuffer, options);
|
|
2487
|
+
return typeof getUrl === "function" ? getUrl({ ...options, ...urlOptions }) : getUrl;
|
|
1599
2488
|
}
|
|
1600
2489
|
|
|
1601
2490
|
// dist/lib/texture-api/load-image.js
|
|
1602
2491
|
async function loadImageTexture(getUrl, options = {}) {
|
|
1603
2492
|
const imageUrls = await getImageUrls(getUrl, options);
|
|
1604
|
-
return await
|
|
2493
|
+
return await loadCompositeImageUrlTree(imageUrls, normalizeCompositeImageOptions(options));
|
|
1605
2494
|
}
|
|
1606
2495
|
async function getImageUrls(getUrl, options, urlOptions = {}) {
|
|
1607
2496
|
const mipLevels = options && options.image && options.image.mipLevels || 0;
|
|
@@ -1609,10 +2498,11 @@ async function getImageUrls(getUrl, options, urlOptions = {}) {
|
|
|
1609
2498
|
}
|
|
1610
2499
|
async function getMipmappedImageUrls(getUrl, mipLevels, options, urlOptions) {
|
|
1611
2500
|
const urls = [];
|
|
2501
|
+
const normalizedOptions = normalizeCompositeImageOptions(options);
|
|
1612
2502
|
if (mipLevels === "auto") {
|
|
1613
2503
|
const url = generateUrl(getUrl, options, { ...urlOptions, lod: 0 });
|
|
1614
|
-
const image = await
|
|
1615
|
-
const { width, height } = (0,
|
|
2504
|
+
const image = await loadCompositeImageMember(url, normalizedOptions);
|
|
2505
|
+
const { width, height } = (0, import_images2.getImageSize)(image);
|
|
1616
2506
|
mipLevels = getMipLevels({ width, height });
|
|
1617
2507
|
urls.push(url);
|
|
1618
2508
|
}
|
|
@@ -1628,10 +2518,9 @@ function getMipLevels(size) {
|
|
|
1628
2518
|
}
|
|
1629
2519
|
|
|
1630
2520
|
// dist/lib/texture-api/load-image-array.js
|
|
1631
|
-
var import_images2 = require("@loaders.gl/images");
|
|
1632
2521
|
async function loadImageTextureArray(count, getUrl, options = {}) {
|
|
1633
2522
|
const imageUrls = await getImageArrayUrls(count, getUrl, options);
|
|
1634
|
-
return await
|
|
2523
|
+
return await loadCompositeImageUrlTree(imageUrls, normalizeCompositeImageOptions(options));
|
|
1635
2524
|
}
|
|
1636
2525
|
async function getImageArrayUrls(count, getUrl, options = {}) {
|
|
1637
2526
|
const promises = [];
|
|
@@ -1643,27 +2532,12 @@ async function getImageArrayUrls(count, getUrl, options = {}) {
|
|
|
1643
2532
|
}
|
|
1644
2533
|
|
|
1645
2534
|
// dist/lib/texture-api/load-image-cube.js
|
|
1646
|
-
var import_images3 = require("@loaders.gl/images");
|
|
1647
|
-
var GL_TEXTURE_CUBE_MAP_POSITIVE_X = 34069;
|
|
1648
|
-
var GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 34070;
|
|
1649
|
-
var GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 34071;
|
|
1650
|
-
var GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 34072;
|
|
1651
|
-
var GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 34073;
|
|
1652
|
-
var GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 34074;
|
|
1653
|
-
var CUBE_FACES = [
|
|
1654
|
-
{ face: GL_TEXTURE_CUBE_MAP_POSITIVE_X, direction: "right", axis: "x", sign: "positive" },
|
|
1655
|
-
{ face: GL_TEXTURE_CUBE_MAP_NEGATIVE_X, direction: "left", axis: "x", sign: "negative" },
|
|
1656
|
-
{ face: GL_TEXTURE_CUBE_MAP_POSITIVE_Y, direction: "top", axis: "y", sign: "positive" },
|
|
1657
|
-
{ face: GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, direction: "bottom", axis: "y", sign: "negative" },
|
|
1658
|
-
{ face: GL_TEXTURE_CUBE_MAP_POSITIVE_Z, direction: "front", axis: "z", sign: "positive" },
|
|
1659
|
-
{ face: GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, direction: "back", axis: "z", sign: "negative" }
|
|
1660
|
-
];
|
|
1661
2535
|
async function getImageCubeUrls(getUrl, options) {
|
|
1662
2536
|
const urls = {};
|
|
1663
2537
|
const promises = [];
|
|
1664
2538
|
let index = 0;
|
|
1665
|
-
for (let i = 0; i <
|
|
1666
|
-
const face =
|
|
2539
|
+
for (let i = 0; i < IMAGE_TEXTURE_CUBE_FACES.length; ++i) {
|
|
2540
|
+
const face = IMAGE_TEXTURE_CUBE_FACES[index];
|
|
1667
2541
|
const promise = getImageUrls(getUrl, options, { ...face, index: index++ }).then((url) => {
|
|
1668
2542
|
urls[face.face] = url;
|
|
1669
2543
|
});
|
|
@@ -1674,7 +2548,7 @@ async function getImageCubeUrls(getUrl, options) {
|
|
|
1674
2548
|
}
|
|
1675
2549
|
async function loadImageTextureCube(getUrl, options = {}) {
|
|
1676
2550
|
const urls = await getImageCubeUrls(getUrl, options);
|
|
1677
|
-
return await
|
|
2551
|
+
return await loadCompositeImageUrlTree(urls, normalizeCompositeImageOptions(options));
|
|
1678
2552
|
}
|
|
1679
2553
|
|
|
1680
2554
|
// dist/index.js
|