@loaders.gl/textures 4.4.0-alpha.18 → 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.
Files changed (129) hide show
  1. package/README.md +153 -1
  2. package/dist/basis-worker-node.js +44 -28
  3. package/dist/basis-worker.js +43 -27
  4. package/dist/compressed-texture-worker.js +110 -77
  5. package/dist/crunch-worker.js +24 -10
  6. package/dist/dist.dev.js +1323 -239
  7. package/dist/dist.min.js +1 -1
  8. package/dist/index.cjs +1024 -151
  9. package/dist/index.cjs.map +4 -4
  10. package/dist/index.d.ts +11 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +5 -0
  13. package/dist/index.js.map +1 -1
  14. package/dist/ktx2-basis-writer-worker-node.js +2 -2
  15. package/dist/ktx2-basis-writer-worker.js +2 -2
  16. package/dist/lib/composite-image/image-texture-cube.d.ts +47 -0
  17. package/dist/lib/composite-image/image-texture-cube.d.ts.map +1 -0
  18. package/dist/lib/composite-image/image-texture-cube.js +42 -0
  19. package/dist/lib/composite-image/image-texture-cube.js.map +1 -0
  20. package/dist/lib/composite-image/parse-composite-image.d.ts +43 -0
  21. package/dist/lib/composite-image/parse-composite-image.d.ts.map +1 -0
  22. package/dist/lib/composite-image/parse-composite-image.js +437 -0
  23. package/dist/lib/composite-image/parse-composite-image.js.map +1 -0
  24. package/dist/lib/gl-extensions.d.ts +2 -0
  25. package/dist/lib/gl-extensions.d.ts.map +1 -1
  26. package/dist/lib/gl-extensions.js +2 -0
  27. package/dist/lib/gl-extensions.js.map +1 -1
  28. package/dist/lib/gl-types.d.ts +4 -0
  29. package/dist/lib/gl-types.d.ts.map +1 -0
  30. package/dist/lib/gl-types.js +5 -0
  31. package/dist/lib/gl-types.js.map +1 -0
  32. package/dist/lib/parsers/parse-basis.d.ts +9 -1
  33. package/dist/lib/parsers/parse-basis.d.ts.map +1 -1
  34. package/dist/lib/parsers/parse-basis.js +48 -25
  35. package/dist/lib/parsers/parse-basis.js.map +1 -1
  36. package/dist/lib/parsers/parse-crunch.d.ts.map +1 -1
  37. package/dist/lib/parsers/parse-crunch.js +4 -5
  38. package/dist/lib/parsers/parse-crunch.js.map +1 -1
  39. package/dist/lib/parsers/parse-dds.d.ts.map +1 -1
  40. package/dist/lib/parsers/parse-dds.js +10 -11
  41. package/dist/lib/parsers/parse-dds.js.map +1 -1
  42. package/dist/lib/parsers/parse-hdr.d.ts +21 -0
  43. package/dist/lib/parsers/parse-hdr.d.ts.map +1 -0
  44. package/dist/lib/parsers/parse-hdr.js +305 -0
  45. package/dist/lib/parsers/parse-hdr.js.map +1 -0
  46. package/dist/lib/parsers/parse-ktx.d.ts.map +1 -1
  47. package/dist/lib/parsers/parse-ktx.js +5 -5
  48. package/dist/lib/parsers/parse-ktx.js.map +1 -1
  49. package/dist/lib/parsers/parse-pvr.d.ts.map +1 -1
  50. package/dist/lib/parsers/parse-pvr.js +31 -32
  51. package/dist/lib/parsers/parse-pvr.js.map +1 -1
  52. package/dist/lib/texture-api/generate-url.d.ts.map +1 -1
  53. package/dist/lib/texture-api/generate-url.js +2 -10
  54. package/dist/lib/texture-api/generate-url.js.map +1 -1
  55. package/dist/lib/texture-api/load-image-array.d.ts +6 -3
  56. package/dist/lib/texture-api/load-image-array.d.ts.map +1 -1
  57. package/dist/lib/texture-api/load-image-array.js +5 -3
  58. package/dist/lib/texture-api/load-image-array.js.map +1 -1
  59. package/dist/lib/texture-api/load-image-cube.d.ts +7 -11
  60. package/dist/lib/texture-api/load-image-cube.d.ts.map +1 -1
  61. package/dist/lib/texture-api/load-image-cube.js +8 -20
  62. package/dist/lib/texture-api/load-image-cube.js.map +1 -1
  63. package/dist/lib/texture-api/load-image.d.ts +6 -3
  64. package/dist/lib/texture-api/load-image.d.ts.map +1 -1
  65. package/dist/lib/texture-api/load-image.js +8 -4
  66. package/dist/lib/texture-api/load-image.js.map +1 -1
  67. package/dist/lib/texture-api/texture-api-types.d.ts +13 -0
  68. package/dist/lib/texture-api/texture-api-types.d.ts.map +1 -1
  69. package/dist/lib/utils/detect-supported-texture-formats.js +4 -4
  70. package/dist/lib/utils/extract-mipmap-images.d.ts +5 -1
  71. package/dist/lib/utils/extract-mipmap-images.d.ts.map +1 -1
  72. package/dist/lib/utils/extract-mipmap-images.js +4 -3
  73. package/dist/lib/utils/extract-mipmap-images.js.map +1 -1
  74. package/dist/lib/utils/ktx-format-helper.d.ts +8 -1
  75. package/dist/lib/utils/ktx-format-helper.d.ts.map +1 -1
  76. package/dist/lib/utils/ktx-format-helper.js +9 -0
  77. package/dist/lib/utils/ktx-format-helper.js.map +1 -1
  78. package/dist/lib/utils/texture-format-map.d.ts +8 -1
  79. package/dist/lib/utils/texture-format-map.d.ts.map +1 -1
  80. package/dist/lib/utils/texture-format-map.js +19 -3
  81. package/dist/lib/utils/texture-format-map.js.map +1 -1
  82. package/dist/lib/utils/version.js +1 -1
  83. package/dist/npy-worker.js +1 -1
  84. package/dist/radiance-hdr-loader.d.ts +25 -0
  85. package/dist/radiance-hdr-loader.d.ts.map +1 -0
  86. package/dist/radiance-hdr-loader.js +23 -0
  87. package/dist/radiance-hdr-loader.js.map +1 -0
  88. package/dist/texture-array-loader.d.ts +25 -0
  89. package/dist/texture-array-loader.d.ts.map +1 -0
  90. package/dist/texture-array-loader.js +24 -0
  91. package/dist/texture-array-loader.js.map +1 -0
  92. package/dist/texture-cube-array-loader.d.ts +25 -0
  93. package/dist/texture-cube-array-loader.d.ts.map +1 -0
  94. package/dist/texture-cube-array-loader.js +24 -0
  95. package/dist/texture-cube-array-loader.js.map +1 -0
  96. package/dist/texture-cube-loader.d.ts +25 -0
  97. package/dist/texture-cube-loader.d.ts.map +1 -0
  98. package/dist/texture-cube-loader.js +24 -0
  99. package/dist/texture-cube-loader.js.map +1 -0
  100. package/dist/texture-loader.d.ts +25 -0
  101. package/dist/texture-loader.d.ts.map +1 -0
  102. package/dist/texture-loader.js +24 -0
  103. package/dist/texture-loader.js.map +1 -0
  104. package/package.json +6 -6
  105. package/src/index.ts +19 -0
  106. package/src/lib/composite-image/image-texture-cube.ts +49 -0
  107. package/src/lib/composite-image/parse-composite-image.ts +699 -0
  108. package/src/lib/gl-extensions.ts +2 -0
  109. package/src/lib/gl-types.ts +136 -0
  110. package/src/lib/parsers/parse-basis.ts +54 -26
  111. package/src/lib/parsers/parse-crunch.ts +6 -11
  112. package/src/lib/parsers/parse-dds.ts +11 -19
  113. package/src/lib/parsers/parse-hdr.ts +426 -0
  114. package/src/lib/parsers/parse-ktx.ts +6 -6
  115. package/src/lib/parsers/parse-pvr.ts +33 -75
  116. package/src/lib/texture-api/generate-url.ts +2 -12
  117. package/src/lib/texture-api/load-image-array.ts +15 -6
  118. package/src/lib/texture-api/load-image-cube.ts +20 -34
  119. package/src/lib/texture-api/load-image.ts +19 -8
  120. package/src/lib/texture-api/texture-api-types.ts +15 -0
  121. package/src/lib/utils/detect-supported-texture-formats.ts +4 -4
  122. package/src/lib/utils/extract-mipmap-images.ts +12 -4
  123. package/src/lib/utils/ktx-format-helper.ts +12 -1
  124. package/src/lib/utils/texture-format-map.ts +30 -3
  125. package/src/radiance-hdr-loader.ts +36 -0
  126. package/src/texture-array-loader.ts +46 -0
  127. package/src/texture-cube-array-loader.ts +49 -0
  128. package/src/texture-cube-loader.ts +46 -0
  129. package/src/texture-loader.ts +49 -0
@@ -529,7 +529,7 @@
529
529
  var dist_default = new ProbeLog({ id: "@probe.gl/log" });
530
530
 
531
531
  // ../loader-utils/src/lib/log-utils/log.ts
532
- var VERSION2 = true ? "4.4.0-alpha.18" : "latest";
532
+ var VERSION2 = true ? "4.4.0-alpha.19" : "latest";
533
533
  var version = VERSION2[0] >= "0" && VERSION2[0] <= "9" ? `v${VERSION2}` : "";
534
534
  function createLog() {
535
535
  const log2 = new ProbeLog({ id: "loaders.gl" });
@@ -564,7 +564,7 @@
564
564
  globalThis._loadersgl_.version = NPM_TAG;
565
565
  warningIssued = true;
566
566
  } else {
567
- globalThis._loadersgl_.version = "4.4.0-alpha.18";
567
+ globalThis._loadersgl_.version = "4.4.0-alpha.19";
568
568
  }
569
569
  }
570
570
  return globalThis._loadersgl_.version;
@@ -924,7 +924,7 @@
924
924
  }
925
925
 
926
926
  // src/lib/utils/version.ts
927
- var VERSION4 = true ? "4.4.0-alpha.18" : "latest";
927
+ var VERSION4 = true ? "4.4.0-alpha.19" : "latest";
928
928
 
929
929
  // ../../node_modules/ktx-parse/dist/ktx-parse.modern.js
930
930
  var KHR_SUPERCOMPRESSION_NONE = 0;
@@ -1179,6 +1179,7 @@
1179
1179
  var GL_RGBA4 = 32854;
1180
1180
  var GL_RGBA8 = 32856;
1181
1181
  var GL_RGB565 = 36194;
1182
+ var GL_RGBA32F = 34836;
1182
1183
  var GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 33776;
1183
1184
  var GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 33777;
1184
1185
  var GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 33778;
@@ -1241,6 +1242,7 @@
1241
1242
 
1242
1243
  // src/lib/utils/texture-format-map.ts
1243
1244
  var WEBGL_TO_TEXTURE_FORMAT = {
1245
+ [GL_RGBA32F]: "rgba32float",
1244
1246
  [GL_COMPRESSED_RGB_S3TC_DXT1_EXT]: "bc1-rgb-unorm-webgl",
1245
1247
  [GL_COMPRESSED_SRGB_S3TC_DXT1_EXT]: "bc1-rgb-unorm-srgb-webgl",
1246
1248
  [GL_COMPRESSED_RGBA_S3TC_DXT1_EXT]: "bc1-rgba-unorm",
@@ -1293,25 +1295,37 @@
1293
1295
  [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR]: "astc-12x12-unorm-srgb",
1294
1296
  [GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG]: "pvrtc-rgb4unorm-webgl",
1295
1297
  [GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG]: "pvrtc-rgba4unorm-webgl",
1296
- [GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG]: "pvrtc-rbg2unorm-webgl",
1298
+ [GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG]: "pvrtc-rgb2unorm-webgl",
1297
1299
  [GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG]: "pvrtc-rgba2unorm-webgl",
1298
- [GL_COMPRESSED_RGB_ETC1_WEBGL]: "etc1-rbg-unorm-webgl",
1300
+ [GL_COMPRESSED_RGB_ETC1_WEBGL]: "etc1-rgb-unorm-webgl",
1299
1301
  [GL_COMPRESSED_RGB_ATC_WEBGL]: "atc-rgb-unorm-webgl",
1300
1302
  [GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL]: "atc-rgba-unorm-webgl",
1301
1303
  [GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL]: "atc-rgbai-unorm-webgl"
1302
1304
  };
1305
+ var TEXTURE_FORMAT_TO_WEBGL = Object.fromEntries(
1306
+ Object.entries(WEBGL_TO_TEXTURE_FORMAT).map(([format, textureFormat]) => [
1307
+ textureFormat,
1308
+ Number(format)
1309
+ ])
1310
+ );
1303
1311
  function getTextureFormatFromWebGLFormat(format) {
1304
1312
  if (format === void 0) {
1305
1313
  return void 0;
1306
1314
  }
1307
1315
  return WEBGL_TO_TEXTURE_FORMAT[format];
1308
1316
  }
1317
+ function getWebGLFormatFromTextureFormat(textureFormat) {
1318
+ if (textureFormat === void 0) {
1319
+ return void 0;
1320
+ }
1321
+ return TEXTURE_FORMAT_TO_WEBGL[textureFormat];
1322
+ }
1309
1323
 
1310
1324
  // src/lib/utils/extract-mipmap-images.ts
1311
1325
  function extractMipmapImages(data, options) {
1312
1326
  const images = new Array(options.mipMapLevels);
1313
- const format = options.internalFormat;
1314
- const textureFormat = format === void 0 ? void 0 : getTextureFormatFromWebGLFormat(format);
1327
+ const textureFormat = options.textureFormat || getTextureFormatFromWebGLFormat(options.internalFormat);
1328
+ const format = options.internalFormat || getWebGLFormatFromTextureFormat(options.textureFormat);
1315
1329
  let levelWidth = options.width;
1316
1330
  let levelHeight = options.height;
1317
1331
  let offset = 0;
@@ -1424,6 +1438,9 @@
1424
1438
  function mapVkFormatToWebGL(vkFormat) {
1425
1439
  return VULKAN_TO_WEBGL_FORMAT_MAP[vkFormat];
1426
1440
  }
1441
+ function mapVkFormatToTextureFormat(vkFormat) {
1442
+ return getTextureFormatFromWebGLFormat(mapVkFormatToWebGL(vkFormat));
1443
+ }
1427
1444
 
1428
1445
  // src/lib/parsers/parse-ktx.ts
1429
1446
  var KTX2_ID2 = [
@@ -1463,10 +1480,10 @@
1463
1480
  const mipMapLevels = Math.max(1, ktx.levels.length);
1464
1481
  const width = ktx.pixelWidth;
1465
1482
  const height = ktx.pixelHeight;
1466
- const internalFormat = mapVkFormatToWebGL(ktx.vkFormat);
1467
- if (internalFormat === void 0) {
1483
+ const textureFormat = mapVkFormatToTextureFormat(ktx.vkFormat);
1484
+ if (textureFormat === void 0) {
1468
1485
  log.warn(
1469
- `KTX2 container vkFormat ${ktx.vkFormat} does not map to a known WebGL format; returning texture levels without format metadata.`
1486
+ `KTX2 container vkFormat ${ktx.vkFormat} does not map to a known texture format; returning texture levels without format metadata.`
1470
1487
  )();
1471
1488
  }
1472
1489
  return extractMipmapImages(ktx.levels, {
@@ -1474,7 +1491,7 @@
1474
1491
  width,
1475
1492
  height,
1476
1493
  sizeFunction: (level) => level.uncompressedByteLength,
1477
- internalFormat
1494
+ textureFormat
1478
1495
  });
1479
1496
  }
1480
1497
 
@@ -1493,13 +1510,13 @@
1493
1510
  DDSD_MIPMAPCOUNT: 131072,
1494
1511
  DDPF_FOURCC: 4
1495
1512
  };
1496
- var DDS_PIXEL_FORMATS = {
1497
- DXT1: GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
1498
- DXT3: GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
1499
- DXT5: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
1500
- "ATC ": GL_COMPRESSED_RGB_ATC_WEBGL,
1501
- ATCA: GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL,
1502
- ATCI: GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL
1513
+ var DDS_TEXTURE_FORMATS = {
1514
+ DXT1: "bc1-rgb-unorm-webgl",
1515
+ DXT3: "bc2-rgba-unorm",
1516
+ DXT5: "bc3-rgba-unorm",
1517
+ "ATC ": "atc-rgb-unorm-webgl",
1518
+ ATCA: "atc-rgba-unorm-webgl",
1519
+ ATCI: "atc-rgbai-unorm-webgl"
1503
1520
  };
1504
1521
  var getATCLevelSize = getDxt1LevelSize;
1505
1522
  var getATCALevelSize = getDxtXLevelSize;
@@ -1525,9 +1542,9 @@
1525
1542
  "DDS: Unsupported format, must contain a FourCC code"
1526
1543
  );
1527
1544
  const fourCC = int32ToFourCC(pixelFormatNumber);
1528
- const internalFormat = DDS_PIXEL_FORMATS[fourCC];
1545
+ const textureFormat = DDS_TEXTURE_FORMATS[fourCC];
1529
1546
  const sizeFunction = DDS_SIZE_FUNCTIONS[fourCC];
1530
- assert(internalFormat && sizeFunction, `DDS: Unknown pixel format ${pixelFormatNumber}`);
1547
+ assert(textureFormat && sizeFunction, `DDS: Unknown pixel format ${pixelFormatNumber}`);
1531
1548
  let mipMapLevels = 1;
1532
1549
  if (header[DDS_CONSTANTS.HEADER_FLAGS_INDEX] & DDS_CONSTANTS.DDSD_MIPMAPCOUNT) {
1533
1550
  mipMapLevels = Math.max(1, header[DDS_CONSTANTS.MIPMAPCOUNT_INDEX]);
@@ -1541,7 +1558,7 @@
1541
1558
  width,
1542
1559
  height,
1543
1560
  sizeFunction,
1544
- internalFormat
1561
+ textureFormat
1545
1562
  });
1546
1563
  }
1547
1564
  function getDxt1LevelSize(width, height) {
@@ -1573,34 +1590,34 @@
1573
1590
  MIPMAPCOUNT_INDEX: 11,
1574
1591
  METADATA_SIZE_INDEX: 12
1575
1592
  };
1576
- var PVR_PIXEL_FORMATS = {
1577
- 0: [GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG],
1578
- 1: [GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG],
1579
- 2: [GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG],
1580
- 3: [GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG],
1581
- 6: [GL_COMPRESSED_RGB_ETC1_WEBGL],
1582
- 7: [GL_COMPRESSED_RGB_S3TC_DXT1_EXT],
1583
- 9: [GL_COMPRESSED_RGBA_S3TC_DXT3_EXT],
1584
- 11: [GL_COMPRESSED_RGBA_S3TC_DXT5_EXT],
1585
- 22: [GL_COMPRESSED_RGB8_ETC2],
1586
- 23: [GL_COMPRESSED_RGBA8_ETC2_EAC],
1587
- 24: [GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2],
1588
- 25: [GL_COMPRESSED_R11_EAC],
1589
- 26: [GL_COMPRESSED_RG11_EAC],
1590
- 27: [GL_COMPRESSED_RGBA_ASTC_4x4_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR],
1591
- 28: [GL_COMPRESSED_RGBA_ASTC_5x4_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR],
1592
- 29: [GL_COMPRESSED_RGBA_ASTC_5x5_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR],
1593
- 30: [GL_COMPRESSED_RGBA_ASTC_6x5_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR],
1594
- 31: [GL_COMPRESSED_RGBA_ASTC_6x6_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR],
1595
- 32: [GL_COMPRESSED_RGBA_ASTC_8x5_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR],
1596
- 33: [GL_COMPRESSED_RGBA_ASTC_8x6_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR],
1597
- 34: [GL_COMPRESSED_RGBA_ASTC_8x8_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR],
1598
- 35: [GL_COMPRESSED_RGBA_ASTC_10x5_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR],
1599
- 36: [GL_COMPRESSED_RGBA_ASTC_10x6_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR],
1600
- 37: [GL_COMPRESSED_RGBA_ASTC_10x8_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR],
1601
- 38: [GL_COMPRESSED_RGBA_ASTC_10x10_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR],
1602
- 39: [GL_COMPRESSED_RGBA_ASTC_12x10_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR],
1603
- 40: [GL_COMPRESSED_RGBA_ASTC_12x12_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR]
1593
+ var PVR_TEXTURE_FORMATS = {
1594
+ 0: ["pvrtc-rgb2unorm-webgl"],
1595
+ 1: ["pvrtc-rgba2unorm-webgl"],
1596
+ 2: ["pvrtc-rgb4unorm-webgl"],
1597
+ 3: ["pvrtc-rgba4unorm-webgl"],
1598
+ 6: ["etc1-rgb-unorm-webgl"],
1599
+ 7: ["bc1-rgb-unorm-webgl"],
1600
+ 9: ["bc2-rgba-unorm"],
1601
+ 11: ["bc3-rgba-unorm"],
1602
+ 22: ["etc2-rgb8unorm"],
1603
+ 23: ["etc2-rgba8unorm"],
1604
+ 24: ["etc2-rgb8a1unorm"],
1605
+ 25: ["eac-r11unorm"],
1606
+ 26: ["eac-rg11unorm"],
1607
+ 27: ["astc-4x4-unorm", "astc-4x4-unorm-srgb"],
1608
+ 28: ["astc-5x4-unorm", "astc-5x4-unorm-srgb"],
1609
+ 29: ["astc-5x5-unorm", "astc-5x5-unorm-srgb"],
1610
+ 30: ["astc-6x5-unorm", "astc-6x5-unorm-srgb"],
1611
+ 31: ["astc-6x6-unorm", "astc-6x6-unorm-srgb"],
1612
+ 32: ["astc-8x5-unorm", "astc-8x5-unorm-srgb"],
1613
+ 33: ["astc-8x6-unorm", "astc-8x6-unorm-srgb"],
1614
+ 34: ["astc-8x8-unorm", "astc-8x8-unorm-srgb"],
1615
+ 35: ["astc-10x5-unorm", "astc-10x5-unorm-srgb"],
1616
+ 36: ["astc-10x6-unorm", "astc-10x6-unorm-srgb"],
1617
+ 37: ["astc-10x8-unorm", "astc-10x8-unorm-srgb"],
1618
+ 38: ["astc-10x10-unorm", "astc-10x10-unorm-srgb"],
1619
+ 39: ["astc-12x10-unorm", "astc-12x10-unorm-srgb"],
1620
+ 40: ["astc-12x12-unorm", "astc-12x12-unorm-srgb"]
1604
1621
  };
1605
1622
  var PVR_SIZE_FUNCTIONS = {
1606
1623
  0: pvrtc2bppSize,
@@ -1640,8 +1657,8 @@
1640
1657
  const header = new Uint32Array(data, 0, PVR_CONSTANTS.HEADER_LENGTH);
1641
1658
  const pvrFormat = header[PVR_CONSTANTS.PIXEL_FORMAT_INDEX];
1642
1659
  const colourSpace = header[PVR_CONSTANTS.COLOUR_SPACE_INDEX];
1643
- const pixelFormats = PVR_PIXEL_FORMATS[pvrFormat] || [];
1644
- const internalFormat = pixelFormats.length > 1 && colourSpace ? pixelFormats[1] : pixelFormats[0];
1660
+ const textureFormats2 = PVR_TEXTURE_FORMATS[pvrFormat] || [];
1661
+ const textureFormat = textureFormats2.length > 1 && colourSpace ? textureFormats2[1] : textureFormats2[0];
1645
1662
  const sizeFunction = PVR_SIZE_FUNCTIONS[pvrFormat];
1646
1663
  const mipMapLevels = header[PVR_CONSTANTS.MIPMAPCOUNT_INDEX];
1647
1664
  const width = header[PVR_CONSTANTS.WIDTH_INDEX];
@@ -1653,7 +1670,7 @@
1653
1670
  width,
1654
1671
  height,
1655
1672
  sizeFunction,
1656
- internalFormat
1673
+ textureFormat
1657
1674
  });
1658
1675
  }
1659
1676
  function pvrtc2bppSize(width, height) {
@@ -1826,7 +1843,7 @@
1826
1843
  "bc7-rgba-unorm",
1827
1844
  "bc7-rgba-unorm-srgb"
1828
1845
  ],
1829
- WEBGL_compressed_texture_etc1: ["etc1-rbg-unorm-webgl"],
1846
+ WEBGL_compressed_texture_etc1: ["etc1-rgb-unorm-webgl"],
1830
1847
  WEBGL_compressed_texture_etc: [
1831
1848
  "etc2-rgb8unorm",
1832
1849
  "etc2-rgb8unorm-srgb",
@@ -1842,7 +1859,7 @@
1842
1859
  WEBGL_compressed_texture_pvrtc: [
1843
1860
  "pvrtc-rgb4unorm-webgl",
1844
1861
  "pvrtc-rgba4unorm-webgl",
1845
- "pvrtc-rbg2unorm-webgl",
1862
+ "pvrtc-rgb2unorm-webgl",
1846
1863
  "pvrtc-rgba2unorm-webgl"
1847
1864
  ],
1848
1865
  WEBGL_compressed_texture_atc: [
@@ -1909,12 +1926,13 @@
1909
1926
  }
1910
1927
 
1911
1928
  // src/lib/parsers/parse-basis.ts
1929
+ var basisTranscodingLock = Promise.resolve();
1912
1930
  var BASIS_FORMAT_TO_OUTPUT_OPTIONS = {
1913
1931
  etc1: {
1914
1932
  basisFormat: 0,
1915
1933
  compressed: true,
1916
1934
  format: GL_COMPRESSED_RGB_ETC1_WEBGL,
1917
- textureFormat: "etc1-rbg-unorm-webgl"
1935
+ textureFormat: "etc1-rgb-unorm-webgl"
1918
1936
  },
1919
1937
  etc2: {
1920
1938
  basisFormat: 1,
@@ -2016,31 +2034,46 @@
2016
2034
  var BASIS_FORMATS = Object.freeze(
2017
2035
  Object.keys(BASIS_FORMAT_TO_OUTPUT_OPTIONS)
2018
2036
  );
2037
+ async function withBasisTranscodingLock(transcode) {
2038
+ const previousLock = basisTranscodingLock;
2039
+ let releaseLock;
2040
+ basisTranscodingLock = new Promise((resolve) => {
2041
+ releaseLock = resolve;
2042
+ });
2043
+ await previousLock;
2044
+ try {
2045
+ return await transcode();
2046
+ } finally {
2047
+ releaseLock();
2048
+ }
2049
+ }
2019
2050
  async function parseBasis(data, options = {}) {
2020
2051
  const loadLibraryOptions = extractLoadLibraryOptions(options);
2021
- if (!options.basis?.containerFormat || options.basis.containerFormat === "auto") {
2022
- if (isKTX(data)) {
2023
- const fileConstructors = await loadBasisEncoderModule(loadLibraryOptions);
2024
- return parseKTX2File(fileConstructors.KTX2File, data, options);
2025
- }
2026
- const { BasisFile } = await loadBasisTranscoderModule(loadLibraryOptions);
2027
- return parseBasisFile(BasisFile, data, options);
2028
- }
2029
- switch (options.basis.module) {
2030
- case "encoder":
2031
- const fileConstructors = await loadBasisEncoderModule(loadLibraryOptions);
2032
- switch (options.basis.containerFormat) {
2033
- case "ktx2":
2034
- return parseKTX2File(fileConstructors.KTX2File, data, options);
2035
- case "basis":
2036
- default:
2037
- return parseBasisFile(fileConstructors.BasisFile, data, options);
2052
+ return await withBasisTranscodingLock(async () => {
2053
+ if (!options.basis?.containerFormat || options.basis.containerFormat === "auto") {
2054
+ if (isKTX(data)) {
2055
+ const fileConstructors = await loadBasisEncoderModule(loadLibraryOptions);
2056
+ return parseKTX2File(fileConstructors.KTX2File, data, options);
2038
2057
  }
2039
- case "transcoder":
2040
- default:
2041
2058
  const { BasisFile } = await loadBasisTranscoderModule(loadLibraryOptions);
2042
2059
  return parseBasisFile(BasisFile, data, options);
2043
- }
2060
+ }
2061
+ switch (options.basis.module) {
2062
+ case "encoder":
2063
+ const fileConstructors = await loadBasisEncoderModule(loadLibraryOptions);
2064
+ switch (options.basis.containerFormat) {
2065
+ case "ktx2":
2066
+ return parseKTX2File(fileConstructors.KTX2File, data, options);
2067
+ case "basis":
2068
+ default:
2069
+ return parseBasisFile(fileConstructors.BasisFile, data, options);
2070
+ }
2071
+ case "transcoder":
2072
+ default:
2073
+ const { BasisFile } = await loadBasisTranscoderModule(loadLibraryOptions);
2074
+ return parseBasisFile(BasisFile, data, options);
2075
+ }
2076
+ });
2044
2077
  }
2045
2078
  function parseBasisFile(BasisFile, data, options) {
2046
2079
  const basisFile = new BasisFile(new Uint8Array(data));
@@ -2185,7 +2218,7 @@
2185
2218
  } else if (hasSupportedTextureFormat(textureFormats2, [
2186
2219
  "pvrtc-rgb4unorm-webgl",
2187
2220
  "pvrtc-rgba4unorm-webgl",
2188
- "pvrtc-rbg2unorm-webgl",
2221
+ "pvrtc-rgb2unorm-webgl",
2189
2222
  "pvrtc-rgba2unorm-webgl"
2190
2223
  ])) {
2191
2224
  return {
@@ -2205,7 +2238,7 @@
2205
2238
  "eac-rg11snorm"
2206
2239
  ])) {
2207
2240
  return "etc2";
2208
- } else if (textureFormats2.has("etc1-rbg-unorm-webgl")) {
2241
+ } else if (textureFormats2.has("etc1-rgb-unorm-webgl")) {
2209
2242
  return "etc1";
2210
2243
  } else if (hasSupportedTextureFormat(textureFormats2, [
2211
2244
  "atc-rgb-unorm-webgl",
@@ -29,7 +29,7 @@
29
29
  globalThis._loadersgl_.version = NPM_TAG;
30
30
  warningIssued = true;
31
31
  } else {
32
- globalThis._loadersgl_.version = "4.4.0-alpha.18";
32
+ globalThis._loadersgl_.version = "4.4.0-alpha.19";
33
33
  }
34
34
  }
35
35
  return globalThis._loadersgl_.version;
@@ -389,7 +389,7 @@
389
389
  }
390
390
 
391
391
  // src/lib/utils/version.ts
392
- var VERSION2 = true ? "4.4.0-alpha.18" : "latest";
392
+ var VERSION2 = true ? "4.4.0-alpha.19" : "latest";
393
393
 
394
394
  // src/crunch-loader.ts
395
395
  var CrunchLoader = {
@@ -433,6 +433,7 @@
433
433
  }
434
434
 
435
435
  // src/lib/gl-extensions.ts
436
+ var GL_RGBA32F = 34836;
436
437
  var GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 33776;
437
438
  var GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 33777;
438
439
  var GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 33778;
@@ -494,6 +495,7 @@
494
495
 
495
496
  // src/lib/utils/texture-format-map.ts
496
497
  var WEBGL_TO_TEXTURE_FORMAT = {
498
+ [GL_RGBA32F]: "rgba32float",
497
499
  [GL_COMPRESSED_RGB_S3TC_DXT1_EXT]: "bc1-rgb-unorm-webgl",
498
500
  [GL_COMPRESSED_SRGB_S3TC_DXT1_EXT]: "bc1-rgb-unorm-srgb-webgl",
499
501
  [GL_COMPRESSED_RGBA_S3TC_DXT1_EXT]: "bc1-rgba-unorm",
@@ -546,25 +548,37 @@
546
548
  [GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR]: "astc-12x12-unorm-srgb",
547
549
  [GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG]: "pvrtc-rgb4unorm-webgl",
548
550
  [GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG]: "pvrtc-rgba4unorm-webgl",
549
- [GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG]: "pvrtc-rbg2unorm-webgl",
551
+ [GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG]: "pvrtc-rgb2unorm-webgl",
550
552
  [GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG]: "pvrtc-rgba2unorm-webgl",
551
- [GL_COMPRESSED_RGB_ETC1_WEBGL]: "etc1-rbg-unorm-webgl",
553
+ [GL_COMPRESSED_RGB_ETC1_WEBGL]: "etc1-rgb-unorm-webgl",
552
554
  [GL_COMPRESSED_RGB_ATC_WEBGL]: "atc-rgb-unorm-webgl",
553
555
  [GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL]: "atc-rgba-unorm-webgl",
554
556
  [GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL]: "atc-rgbai-unorm-webgl"
555
557
  };
558
+ var TEXTURE_FORMAT_TO_WEBGL = Object.fromEntries(
559
+ Object.entries(WEBGL_TO_TEXTURE_FORMAT).map(([format, textureFormat]) => [
560
+ textureFormat,
561
+ Number(format)
562
+ ])
563
+ );
556
564
  function getTextureFormatFromWebGLFormat(format) {
557
565
  if (format === void 0) {
558
566
  return void 0;
559
567
  }
560
568
  return WEBGL_TO_TEXTURE_FORMAT[format];
561
569
  }
570
+ function getWebGLFormatFromTextureFormat(textureFormat) {
571
+ if (textureFormat === void 0) {
572
+ return void 0;
573
+ }
574
+ return TEXTURE_FORMAT_TO_WEBGL[textureFormat];
575
+ }
562
576
 
563
577
  // src/lib/utils/extract-mipmap-images.ts
564
578
  function extractMipmapImages(data, options) {
565
579
  const images = new Array(options.mipMapLevels);
566
- const format = options.internalFormat;
567
- const textureFormat = format === void 0 ? void 0 : getTextureFormatFromWebGLFormat(format);
580
+ const textureFormat = options.textureFormat || getTextureFormatFromWebGLFormat(options.internalFormat);
581
+ const format = options.internalFormat || getWebGLFormatFromTextureFormat(options.textureFormat);
568
582
  let levelWidth = options.width;
569
583
  let levelHeight = options.height;
570
584
  let offset = 0;
@@ -624,15 +638,15 @@
624
638
  };
625
639
  var DXT_FORMAT_MAP = {
626
640
  [CRN_FORMAT.cCRNFmtDXT1]: {
627
- pixelFormat: GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
641
+ textureFormat: "bc1-rgb-unorm-webgl",
628
642
  sizeFunction: getDxt1LevelSize
629
643
  },
630
644
  [CRN_FORMAT.cCRNFmtDXT3]: {
631
- pixelFormat: GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
645
+ textureFormat: "bc2-rgba-unorm",
632
646
  sizeFunction: getDxtXLevelSize
633
647
  },
634
648
  [CRN_FORMAT.cCRNFmtDXT5]: {
635
- pixelFormat: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
649
+ textureFormat: "bc3-rgba-unorm",
636
650
  sizeFunction: getDxtXLevelSize
637
651
  }
638
652
  };
@@ -669,7 +683,7 @@
669
683
  width,
670
684
  height,
671
685
  sizeFunction,
672
- internalFormat: DXT_FORMAT_MAP[format].pixelFormat
686
+ textureFormat: DXT_FORMAT_MAP[format].textureFormat
673
687
  });
674
688
  }
675
689
  function arrayBufferCopy(srcData, dstData, dstByteOffset, numBytes) {