@loaders.gl/textures 4.3.0-alpha.2 → 4.3.0-alpha.4

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/dist/dist.dev.js CHANGED
@@ -224,7 +224,7 @@ var __exports__ = (() => {
224
224
  script.id = id;
225
225
  try {
226
226
  script.appendChild(document.createTextNode(scriptSource));
227
- } catch (e2) {
227
+ } catch (e) {
228
228
  script.text = scriptSource;
229
229
  }
230
230
  document.body.appendChild(script);
@@ -453,99 +453,255 @@ var __exports__ = (() => {
453
453
  }
454
454
 
455
455
  // ../../node_modules/ktx-parse/dist/ktx-parse.modern.js
456
- var t = new Uint8Array([0]);
457
- var e = [171, 75, 84, 88, 32, 50, 48, 187, 13, 10, 26, 10];
458
- var n;
459
- var i;
460
- var s;
461
- var a;
462
- var r;
463
- var o;
464
- var l;
465
- var f;
466
- !function(t2) {
467
- t2[t2.NONE = 0] = "NONE", t2[t2.BASISLZ = 1] = "BASISLZ", t2[t2.ZSTD = 2] = "ZSTD", t2[t2.ZLIB = 3] = "ZLIB";
468
- }(n || (n = {})), function(t2) {
469
- t2[t2.BASICFORMAT = 0] = "BASICFORMAT";
470
- }(i || (i = {})), function(t2) {
471
- t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.ETC1S = 163] = "ETC1S", t2[t2.UASTC = 166] = "UASTC";
472
- }(s || (s = {})), function(t2) {
473
- t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.SRGB = 1] = "SRGB";
474
- }(a || (a = {})), function(t2) {
475
- t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.LINEAR = 1] = "LINEAR", t2[t2.SRGB = 2] = "SRGB", t2[t2.ITU = 3] = "ITU", t2[t2.NTSC = 4] = "NTSC", t2[t2.SLOG = 5] = "SLOG", t2[t2.SLOG2 = 6] = "SLOG2";
476
- }(r || (r = {})), function(t2) {
477
- t2[t2.ALPHA_STRAIGHT = 0] = "ALPHA_STRAIGHT", t2[t2.ALPHA_PREMULTIPLIED = 1] = "ALPHA_PREMULTIPLIED";
478
- }(o || (o = {})), function(t2) {
479
- t2[t2.RGB = 0] = "RGB", t2[t2.RRR = 3] = "RRR", t2[t2.GGG = 4] = "GGG", t2[t2.AAA = 15] = "AAA";
480
- }(l || (l = {})), function(t2) {
481
- t2[t2.RGB = 0] = "RGB", t2[t2.RGBA = 3] = "RGBA", t2[t2.RRR = 4] = "RRR", t2[t2.RRRG = 5] = "RRRG";
482
- }(f || (f = {}));
483
- var U = class {
456
+ var KHR_SUPERCOMPRESSION_NONE = 0;
457
+ var KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT = 0;
458
+ var KHR_DF_VENDORID_KHRONOS = 0;
459
+ var KHR_DF_VERSION = 2;
460
+ var KHR_DF_MODEL_UNSPECIFIED = 0;
461
+ var KHR_DF_FLAG_ALPHA_STRAIGHT = 0;
462
+ var KHR_DF_TRANSFER_SRGB = 2;
463
+ var KHR_DF_PRIMARIES_BT709 = 1;
464
+ var KHR_DF_SAMPLE_DATATYPE_SIGNED = 64;
465
+ var VK_FORMAT_UNDEFINED = 0;
466
+ var KTX2Container = class {
484
467
  constructor() {
485
- this.vkFormat = 0, this.typeSize = 1, this.pixelWidth = 0, this.pixelHeight = 0, this.pixelDepth = 0, this.layerCount = 0, this.faceCount = 1, this.supercompressionScheme = n.NONE, this.levels = [], this.dataFormatDescriptor = [{ vendorId: 0, descriptorType: i.BASICFORMAT, versionNumber: 2, descriptorBlockSize: 40, colorModel: s.UNSPECIFIED, colorPrimaries: a.SRGB, transferFunction: a.SRGB, flags: o.ALPHA_STRAIGHT, texelBlockDimension: { x: 4, y: 4, z: 1, w: 1 }, bytesPlane: [], samples: [] }], this.keyValue = {}, this.globalData = null;
468
+ this.vkFormat = VK_FORMAT_UNDEFINED;
469
+ this.typeSize = 1;
470
+ this.pixelWidth = 0;
471
+ this.pixelHeight = 0;
472
+ this.pixelDepth = 0;
473
+ this.layerCount = 0;
474
+ this.faceCount = 1;
475
+ this.supercompressionScheme = KHR_SUPERCOMPRESSION_NONE;
476
+ this.levels = [];
477
+ this.dataFormatDescriptor = [{
478
+ vendorId: KHR_DF_VENDORID_KHRONOS,
479
+ descriptorType: KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT,
480
+ descriptorBlockSize: 0,
481
+ versionNumber: KHR_DF_VERSION,
482
+ colorModel: KHR_DF_MODEL_UNSPECIFIED,
483
+ colorPrimaries: KHR_DF_PRIMARIES_BT709,
484
+ transferFunction: KHR_DF_TRANSFER_SRGB,
485
+ flags: KHR_DF_FLAG_ALPHA_STRAIGHT,
486
+ texelBlockDimension: [0, 0, 0, 0],
487
+ bytesPlane: [0, 0, 0, 0, 0, 0, 0, 0],
488
+ samples: []
489
+ }];
490
+ this.keyValue = {};
491
+ this.globalData = null;
486
492
  }
487
493
  };
488
- var c = class {
489
- constructor(t2, e2, n2, i2) {
490
- this._dataView = new DataView(t2.buffer, t2.byteOffset + e2, n2), this._littleEndian = i2, this._offset = 0;
494
+ var BufferReader = class {
495
+ constructor(data, byteOffset, byteLength, littleEndian) {
496
+ this._dataView = void 0;
497
+ this._littleEndian = void 0;
498
+ this._offset = void 0;
499
+ this._dataView = new DataView(data.buffer, data.byteOffset + byteOffset, byteLength);
500
+ this._littleEndian = littleEndian;
501
+ this._offset = 0;
491
502
  }
492
503
  _nextUint8() {
493
- const t2 = this._dataView.getUint8(this._offset);
494
- return this._offset += 1, t2;
504
+ const value = this._dataView.getUint8(this._offset);
505
+ this._offset += 1;
506
+ return value;
495
507
  }
496
508
  _nextUint16() {
497
- const t2 = this._dataView.getUint16(this._offset, this._littleEndian);
498
- return this._offset += 2, t2;
509
+ const value = this._dataView.getUint16(this._offset, this._littleEndian);
510
+ this._offset += 2;
511
+ return value;
499
512
  }
500
513
  _nextUint32() {
501
- const t2 = this._dataView.getUint32(this._offset, this._littleEndian);
502
- return this._offset += 4, t2;
514
+ const value = this._dataView.getUint32(this._offset, this._littleEndian);
515
+ this._offset += 4;
516
+ return value;
503
517
  }
504
518
  _nextUint64() {
505
- const t2 = this._dataView.getUint32(this._offset, this._littleEndian) + 2 ** 32 * this._dataView.getUint32(this._offset + 4, this._littleEndian);
506
- return this._offset += 8, t2;
507
- }
508
- _skip(t2) {
509
- return this._offset += t2, this;
510
- }
511
- _scan(t2, e2 = 0) {
512
- const n2 = this._offset;
513
- let i2 = 0;
514
- for (; this._dataView.getUint8(this._offset) !== e2 && i2 < t2; )
515
- i2++, this._offset++;
516
- return i2 < t2 && this._offset++, new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + n2, i2);
519
+ const left = this._dataView.getUint32(this._offset, this._littleEndian);
520
+ const right = this._dataView.getUint32(this._offset + 4, this._littleEndian);
521
+ const value = left + 2 ** 32 * right;
522
+ this._offset += 8;
523
+ return value;
524
+ }
525
+ _nextInt32() {
526
+ const value = this._dataView.getInt32(this._offset, this._littleEndian);
527
+ this._offset += 4;
528
+ return value;
529
+ }
530
+ _nextUint8Array(len) {
531
+ const value = new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + this._offset, len);
532
+ this._offset += len;
533
+ return value;
534
+ }
535
+ _skip(bytes) {
536
+ this._offset += bytes;
537
+ return this;
538
+ }
539
+ _scan(maxByteLength, term = 0) {
540
+ const byteOffset = this._offset;
541
+ let byteLength = 0;
542
+ while (this._dataView.getUint8(this._offset) !== term && byteLength < maxByteLength) {
543
+ byteLength++;
544
+ this._offset++;
545
+ }
546
+ if (byteLength < maxByteLength)
547
+ this._offset++;
548
+ return new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + byteOffset, byteLength);
517
549
  }
518
550
  };
519
- function _(t2) {
520
- return "undefined" != typeof TextDecoder ? new TextDecoder().decode(t2) : Buffer.from(t2).toString("utf8");
551
+ var NUL = new Uint8Array([0]);
552
+ var KTX2_ID = [
553
+ // '´', 'K', 'T', 'X', '2', '0', 'ª', '\r', '\n', '\x1A', '\n'
554
+ 171,
555
+ 75,
556
+ 84,
557
+ 88,
558
+ 32,
559
+ 50,
560
+ 48,
561
+ 187,
562
+ 13,
563
+ 10,
564
+ 26,
565
+ 10
566
+ ];
567
+ function decodeText(buffer) {
568
+ if (typeof TextDecoder !== "undefined") {
569
+ return new TextDecoder().decode(buffer);
570
+ }
571
+ return Buffer.from(buffer).toString("utf8");
521
572
  }
522
- function p(t2) {
523
- const n2 = new Uint8Array(t2.buffer, t2.byteOffset, e.length);
524
- if (n2[0] !== e[0] || n2[1] !== e[1] || n2[2] !== e[2] || n2[3] !== e[3] || n2[4] !== e[4] || n2[5] !== e[5] || n2[6] !== e[6] || n2[7] !== e[7] || n2[8] !== e[8] || n2[9] !== e[9] || n2[10] !== e[10] || n2[11] !== e[11])
573
+ function read(data) {
574
+ const id = new Uint8Array(data.buffer, data.byteOffset, KTX2_ID.length);
575
+ if (id[0] !== KTX2_ID[0] || // '´'
576
+ id[1] !== KTX2_ID[1] || // 'K'
577
+ id[2] !== KTX2_ID[2] || // 'T'
578
+ id[3] !== KTX2_ID[3] || // 'X'
579
+ id[4] !== KTX2_ID[4] || // ' '
580
+ id[5] !== KTX2_ID[5] || // '2'
581
+ id[6] !== KTX2_ID[6] || // '0'
582
+ id[7] !== KTX2_ID[7] || // 'ª'
583
+ id[8] !== KTX2_ID[8] || // '\r'
584
+ id[9] !== KTX2_ID[9] || // '\n'
585
+ id[10] !== KTX2_ID[10] || // '\x1A'
586
+ id[11] !== KTX2_ID[11]) {
525
587
  throw new Error("Missing KTX 2.0 identifier.");
526
- const i2 = new U(), s2 = 17 * Uint32Array.BYTES_PER_ELEMENT, a3 = new c(t2, e.length, s2, true);
527
- i2.vkFormat = a3._nextUint32(), i2.typeSize = a3._nextUint32(), i2.pixelWidth = a3._nextUint32(), i2.pixelHeight = a3._nextUint32(), i2.pixelDepth = a3._nextUint32(), i2.layerCount = a3._nextUint32(), i2.faceCount = a3._nextUint32();
528
- const r2 = a3._nextUint32();
529
- i2.supercompressionScheme = a3._nextUint32();
530
- const o2 = a3._nextUint32(), l2 = a3._nextUint32(), f2 = a3._nextUint32(), h = a3._nextUint32(), g = a3._nextUint64(), p2 = a3._nextUint64(), x = new c(t2, e.length + s2, 3 * r2 * 8, true);
531
- for (let e2 = 0; e2 < r2; e2++)
532
- i2.levels.push({ levelData: new Uint8Array(t2.buffer, t2.byteOffset + x._nextUint64(), x._nextUint64()), uncompressedByteLength: x._nextUint64() });
533
- const u = new c(t2, o2, l2, true), y = { vendorId: u._skip(4)._nextUint16(), descriptorType: u._nextUint16(), versionNumber: u._nextUint16(), descriptorBlockSize: u._nextUint16(), colorModel: u._nextUint8(), colorPrimaries: u._nextUint8(), transferFunction: u._nextUint8(), flags: u._nextUint8(), texelBlockDimension: { x: u._nextUint8() + 1, y: u._nextUint8() + 1, z: u._nextUint8() + 1, w: u._nextUint8() + 1 }, bytesPlane: [u._nextUint8(), u._nextUint8(), u._nextUint8(), u._nextUint8(), u._nextUint8(), u._nextUint8(), u._nextUint8(), u._nextUint8()], samples: [] }, D = (y.descriptorBlockSize / 4 - 6) / 4;
534
- for (let t3 = 0; t3 < D; t3++)
535
- y.samples[t3] = { bitOffset: u._nextUint16(), bitLength: u._nextUint8(), channelID: u._nextUint8(), samplePosition: [u._nextUint8(), u._nextUint8(), u._nextUint8(), u._nextUint8()], sampleLower: u._nextUint32(), sampleUpper: u._nextUint32() };
536
- i2.dataFormatDescriptor.length = 0, i2.dataFormatDescriptor.push(y);
537
- const b2 = new c(t2, f2, h, true);
538
- for (; b2._offset < h; ) {
539
- const t3 = b2._nextUint32(), e2 = b2._scan(t3), n3 = _(e2), s3 = b2._scan(t3 - e2.byteLength);
540
- i2.keyValue[n3] = n3.match(/^ktx/i) ? _(s3) : s3, t3 % 4 && b2._skip(4 - t3 % 4);
541
- }
542
- if (p2 <= 0)
543
- return i2;
544
- const d = new c(t2, g, p2, true), B = d._nextUint16(), w = d._nextUint16(), A = d._nextUint32(), S = d._nextUint32(), m = d._nextUint32(), L = d._nextUint32(), I = [];
545
- for (let t3 = 0; t3 < r2; t3++)
546
- I.push({ imageFlags: d._nextUint32(), rgbSliceByteOffset: d._nextUint32(), rgbSliceByteLength: d._nextUint32(), alphaSliceByteOffset: d._nextUint32(), alphaSliceByteLength: d._nextUint32() });
547
- const R = g + d._offset, E = R + A, T = E + S, O = T + m, P = new Uint8Array(t2.buffer, t2.byteOffset + R, A), C = new Uint8Array(t2.buffer, t2.byteOffset + E, S), F = new Uint8Array(t2.buffer, t2.byteOffset + T, m), G = new Uint8Array(t2.buffer, t2.byteOffset + O, L);
548
- return i2.globalData = { endpointCount: B, selectorCount: w, imageDescs: I, endpointsData: P, selectorsData: C, tablesData: F, extendedData: G }, i2;
588
+ }
589
+ const container = new KTX2Container();
590
+ const headerByteLength = 17 * Uint32Array.BYTES_PER_ELEMENT;
591
+ const headerReader = new BufferReader(data, KTX2_ID.length, headerByteLength, true);
592
+ container.vkFormat = headerReader._nextUint32();
593
+ container.typeSize = headerReader._nextUint32();
594
+ container.pixelWidth = headerReader._nextUint32();
595
+ container.pixelHeight = headerReader._nextUint32();
596
+ container.pixelDepth = headerReader._nextUint32();
597
+ container.layerCount = headerReader._nextUint32();
598
+ container.faceCount = headerReader._nextUint32();
599
+ const levelCount = headerReader._nextUint32();
600
+ container.supercompressionScheme = headerReader._nextUint32();
601
+ const dfdByteOffset = headerReader._nextUint32();
602
+ const dfdByteLength = headerReader._nextUint32();
603
+ const kvdByteOffset = headerReader._nextUint32();
604
+ const kvdByteLength = headerReader._nextUint32();
605
+ const sgdByteOffset = headerReader._nextUint64();
606
+ const sgdByteLength = headerReader._nextUint64();
607
+ const levelByteLength = levelCount * 3 * 8;
608
+ const levelReader = new BufferReader(data, KTX2_ID.length + headerByteLength, levelByteLength, true);
609
+ for (let i = 0; i < levelCount; i++) {
610
+ container.levels.push({
611
+ levelData: new Uint8Array(data.buffer, data.byteOffset + levelReader._nextUint64(), levelReader._nextUint64()),
612
+ uncompressedByteLength: levelReader._nextUint64()
613
+ });
614
+ }
615
+ const dfdReader = new BufferReader(data, dfdByteOffset, dfdByteLength, true);
616
+ const dfd = {
617
+ vendorId: dfdReader._skip(
618
+ 4
619
+ /* totalSize */
620
+ )._nextUint16(),
621
+ descriptorType: dfdReader._nextUint16(),
622
+ versionNumber: dfdReader._nextUint16(),
623
+ descriptorBlockSize: dfdReader._nextUint16(),
624
+ colorModel: dfdReader._nextUint8(),
625
+ colorPrimaries: dfdReader._nextUint8(),
626
+ transferFunction: dfdReader._nextUint8(),
627
+ flags: dfdReader._nextUint8(),
628
+ texelBlockDimension: [dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8()],
629
+ bytesPlane: [dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8()],
630
+ samples: []
631
+ };
632
+ const sampleStart = 6;
633
+ const sampleWords = 4;
634
+ const numSamples = (dfd.descriptorBlockSize / 4 - sampleStart) / sampleWords;
635
+ for (let i = 0; i < numSamples; i++) {
636
+ const sample = {
637
+ bitOffset: dfdReader._nextUint16(),
638
+ bitLength: dfdReader._nextUint8(),
639
+ channelType: dfdReader._nextUint8(),
640
+ samplePosition: [dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8()],
641
+ sampleLower: -Infinity,
642
+ sampleUpper: Infinity
643
+ };
644
+ if (sample.channelType & KHR_DF_SAMPLE_DATATYPE_SIGNED) {
645
+ sample.sampleLower = dfdReader._nextInt32();
646
+ sample.sampleUpper = dfdReader._nextInt32();
647
+ } else {
648
+ sample.sampleLower = dfdReader._nextUint32();
649
+ sample.sampleUpper = dfdReader._nextUint32();
650
+ }
651
+ dfd.samples[i] = sample;
652
+ }
653
+ container.dataFormatDescriptor.length = 0;
654
+ container.dataFormatDescriptor.push(dfd);
655
+ const kvdReader = new BufferReader(data, kvdByteOffset, kvdByteLength, true);
656
+ while (kvdReader._offset < kvdByteLength) {
657
+ const keyValueByteLength = kvdReader._nextUint32();
658
+ const keyData = kvdReader._scan(keyValueByteLength);
659
+ const key = decodeText(keyData);
660
+ container.keyValue[key] = kvdReader._nextUint8Array(keyValueByteLength - keyData.byteLength - 1);
661
+ if (key.match(/^ktx/i)) {
662
+ const text = decodeText(container.keyValue[key]);
663
+ container.keyValue[key] = text.substring(0, text.lastIndexOf("\0"));
664
+ }
665
+ const kvPadding = keyValueByteLength % 4 ? 4 - keyValueByteLength % 4 : 0;
666
+ kvdReader._skip(kvPadding);
667
+ }
668
+ if (sgdByteLength <= 0)
669
+ return container;
670
+ const sgdReader = new BufferReader(data, sgdByteOffset, sgdByteLength, true);
671
+ const endpointCount = sgdReader._nextUint16();
672
+ const selectorCount = sgdReader._nextUint16();
673
+ const endpointsByteLength = sgdReader._nextUint32();
674
+ const selectorsByteLength = sgdReader._nextUint32();
675
+ const tablesByteLength = sgdReader._nextUint32();
676
+ const extendedByteLength = sgdReader._nextUint32();
677
+ const imageDescs = [];
678
+ for (let i = 0; i < levelCount; i++) {
679
+ imageDescs.push({
680
+ imageFlags: sgdReader._nextUint32(),
681
+ rgbSliceByteOffset: sgdReader._nextUint32(),
682
+ rgbSliceByteLength: sgdReader._nextUint32(),
683
+ alphaSliceByteOffset: sgdReader._nextUint32(),
684
+ alphaSliceByteLength: sgdReader._nextUint32()
685
+ });
686
+ }
687
+ const endpointsByteOffset = sgdByteOffset + sgdReader._offset;
688
+ const selectorsByteOffset = endpointsByteOffset + endpointsByteLength;
689
+ const tablesByteOffset = selectorsByteOffset + selectorsByteLength;
690
+ const extendedByteOffset = tablesByteOffset + tablesByteLength;
691
+ const endpointsData = new Uint8Array(data.buffer, data.byteOffset + endpointsByteOffset, endpointsByteLength);
692
+ const selectorsData = new Uint8Array(data.buffer, data.byteOffset + selectorsByteOffset, selectorsByteLength);
693
+ const tablesData = new Uint8Array(data.buffer, data.byteOffset + tablesByteOffset, tablesByteLength);
694
+ const extendedData = new Uint8Array(data.buffer, data.byteOffset + extendedByteOffset, extendedByteLength);
695
+ container.globalData = {
696
+ endpointCount,
697
+ selectorCount,
698
+ imageDescs,
699
+ endpointsData,
700
+ selectorsData,
701
+ tablesData,
702
+ extendedData
703
+ };
704
+ return container;
549
705
  }
550
706
 
551
707
  // src/lib/utils/extract-mipmap-images.ts
@@ -554,10 +710,10 @@ var __exports__ = (() => {
554
710
  let levelWidth = options.width;
555
711
  let levelHeight = options.height;
556
712
  let offset = 0;
557
- for (let i2 = 0; i2 < options.mipMapLevels; ++i2) {
558
- const levelSize = getLevelSize(options, levelWidth, levelHeight, data, i2);
559
- const levelData = getLevelData(data, i2, offset, levelSize);
560
- images[i2] = {
713
+ for (let i = 0; i < options.mipMapLevels; ++i) {
714
+ const levelSize = getLevelSize(options, levelWidth, levelHeight, data, i);
715
+ const levelData = getLevelData(data, i, offset, levelSize);
716
+ images[i] = {
561
717
  compressed: true,
562
718
  format: options.internalFormat,
563
719
  data: levelData,
@@ -700,7 +856,7 @@ var __exports__ = (() => {
700
856
  }
701
857
 
702
858
  // src/lib/parsers/parse-ktx.ts
703
- var KTX2_ID = [
859
+ var KTX2_ID2 = [
704
860
  // '´', 'K', 'T', 'X', '2', '0', 'ª', '\r', '\n', '\x1A', '\n'
705
861
  171,
706
862
  75,
@@ -717,23 +873,23 @@ var __exports__ = (() => {
717
873
  ];
718
874
  function isKTX(data) {
719
875
  const id = new Uint8Array(data);
720
- const notKTX = id.byteLength < KTX2_ID.length || id[0] !== KTX2_ID[0] || // '´'
721
- id[1] !== KTX2_ID[1] || // 'K'
722
- id[2] !== KTX2_ID[2] || // 'T'
723
- id[3] !== KTX2_ID[3] || // 'X'
724
- id[4] !== KTX2_ID[4] || // ' '
725
- id[5] !== KTX2_ID[5] || // '2'
726
- id[6] !== KTX2_ID[6] || // '0'
727
- id[7] !== KTX2_ID[7] || // 'ª'
728
- id[8] !== KTX2_ID[8] || // '\r'
729
- id[9] !== KTX2_ID[9] || // '\n'
730
- id[10] !== KTX2_ID[10] || // '\x1A'
731
- id[11] !== KTX2_ID[11];
876
+ const notKTX = id.byteLength < KTX2_ID2.length || id[0] !== KTX2_ID2[0] || // '´'
877
+ id[1] !== KTX2_ID2[1] || // 'K'
878
+ id[2] !== KTX2_ID2[2] || // 'T'
879
+ id[3] !== KTX2_ID2[3] || // 'X'
880
+ id[4] !== KTX2_ID2[4] || // ' '
881
+ id[5] !== KTX2_ID2[5] || // '2'
882
+ id[6] !== KTX2_ID2[6] || // '0'
883
+ id[7] !== KTX2_ID2[7] || // 'ª'
884
+ id[8] !== KTX2_ID2[8] || // '\r'
885
+ id[9] !== KTX2_ID2[9] || // '\n'
886
+ id[10] !== KTX2_ID2[10] || // '\x1A'
887
+ id[11] !== KTX2_ID2[11];
732
888
  return !notKTX;
733
889
  }
734
890
  function parseKTX(arrayBuffer) {
735
891
  const uint8Array = new Uint8Array(arrayBuffer);
736
- const ktx = p(uint8Array);
892
+ const ktx = read(uint8Array);
737
893
  const mipMapLevels = Math.max(1, ktx.levels.length);
738
894
  const width = ktx.pixelWidth;
739
895
  const height = ktx.pixelHeight;
@@ -872,7 +1028,6 @@ var __exports__ = (() => {
872
1028
  const levels = [];
873
1029
  for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
874
1030
  levels.push(transcodeKTX2Image(ktx2File, levelIndex, options));
875
- break;
876
1031
  }
877
1032
  return [levels];
878
1033
  } finally {
@@ -1338,8 +1493,8 @@ var __exports__ = (() => {
1338
1493
  };
1339
1494
 
1340
1495
  // src/lib/parsers/parse-npy.ts
1341
- var a2 = new Uint32Array([305419896]);
1342
- var b = new Uint8Array(a2.buffer, a2.byteOffset, a2.byteLength);
1496
+ var a = new Uint32Array([305419896]);
1497
+ var b = new Uint8Array(a.buffer, a.byteOffset, a.byteLength);
1343
1498
  var isLittleEndian = !(b[0] === 18);
1344
1499
  var LITTLE_ENDIAN_OS = isLittleEndian;
1345
1500
  var DTYPES = {
@@ -1360,7 +1515,7 @@ var __exports__ = (() => {
1360
1515
  if (!ArrayType) {
1361
1516
  throw new Error(`Unimplemented type ${numpyType}`);
1362
1517
  }
1363
- const nArrayElements = header.shape?.reduce((a3, b2) => a3 * b2);
1518
+ const nArrayElements = header.shape?.reduce((a2, b2) => a2 * b2);
1364
1519
  const arrayByteLength = nArrayElements * ArrayType.BYTES_PER_ELEMENT;
1365
1520
  if (arrayBuffer.byteLength < headerEndOffset + arrayByteLength) {
1366
1521
  throw new Error("Buffer overflow");
@@ -1727,8 +1882,8 @@ var __exports__ = (() => {
1727
1882
  }
1728
1883
  function checkString(buffer, header, offset = 0) {
1729
1884
  const headerBytes = stringToBytes(header);
1730
- for (let i2 = 0; i2 < headerBytes.length; ++i2) {
1731
- if (headerBytes[i2] !== buffer[i2 + offset]) {
1885
+ for (let i = 0; i < headerBytes.length; ++i) {
1886
+ if (headerBytes[i] !== buffer[i + offset]) {
1732
1887
  return false;
1733
1888
  }
1734
1889
  }
@@ -1798,30 +1953,30 @@ var __exports__ = (() => {
1798
1953
  return null;
1799
1954
  }
1800
1955
  const { tableMarkers, sofMarkers } = getJpegMarkers();
1801
- let i2 = 2;
1802
- while (i2 + 9 < dataView.byteLength) {
1803
- const marker = dataView.getUint16(i2, BIG_ENDIAN);
1956
+ let i = 2;
1957
+ while (i + 9 < dataView.byteLength) {
1958
+ const marker = dataView.getUint16(i, BIG_ENDIAN);
1804
1959
  if (sofMarkers.has(marker)) {
1805
1960
  return {
1806
1961
  mimeType: "image/jpeg",
1807
- height: dataView.getUint16(i2 + 5, BIG_ENDIAN),
1962
+ height: dataView.getUint16(i + 5, BIG_ENDIAN),
1808
1963
  // Number of lines
1809
- width: dataView.getUint16(i2 + 7, BIG_ENDIAN)
1964
+ width: dataView.getUint16(i + 7, BIG_ENDIAN)
1810
1965
  // Number of pixels per line
1811
1966
  };
1812
1967
  }
1813
1968
  if (!tableMarkers.has(marker)) {
1814
1969
  return null;
1815
1970
  }
1816
- i2 += 2;
1817
- i2 += dataView.getUint16(i2, BIG_ENDIAN);
1971
+ i += 2;
1972
+ i += dataView.getUint16(i, BIG_ENDIAN);
1818
1973
  }
1819
1974
  return null;
1820
1975
  }
1821
1976
  function getJpegMarkers() {
1822
1977
  const tableMarkers = /* @__PURE__ */ new Set([65499, 65476, 65484, 65501, 65534]);
1823
- for (let i2 = 65504; i2 < 65520; ++i2) {
1824
- tableMarkers.add(i2);
1978
+ for (let i = 65504; i < 65520; ++i) {
1979
+ tableMarkers.add(i);
1825
1980
  }
1826
1981
  const sofMarkers = /* @__PURE__ */ new Set([
1827
1982
  65472,
@@ -2049,7 +2204,7 @@ var __exports__ = (() => {
2049
2204
  const urls = {};
2050
2205
  const promises = [];
2051
2206
  let index = 0;
2052
- for (let i2 = 0; i2 < CUBE_FACES.length; ++i2) {
2207
+ for (let i = 0; i < CUBE_FACES.length; ++i) {
2053
2208
  const face = CUBE_FACES[index];
2054
2209
  const promise = getImageUrls(getUrl, options, { ...face, index: index++ }).then((url) => {
2055
2210
  urls[face.face] = url;