@loaders.gl/textures 4.3.0-alpha.3 → 4.3.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,7 +28,7 @@
28
28
  );
29
29
  globalThis._loadersgl_.version = NPM_TAG;
30
30
  } else {
31
- globalThis._loadersgl_.version = "4.3.0-alpha.2";
31
+ globalThis._loadersgl_.version = "4.3.0-alpha.4";
32
32
  }
33
33
  }
34
34
  return globalThis._loadersgl_.version;
@@ -243,7 +243,7 @@
243
243
  script.id = id;
244
244
  try {
245
245
  script.appendChild(document.createTextNode(scriptSource));
246
- } catch (e2) {
246
+ } catch (e) {
247
247
  script.text = scriptSource;
248
248
  }
249
249
  document.body.appendChild(script);
@@ -348,102 +348,258 @@
348
348
  }
349
349
 
350
350
  // src/lib/utils/version.ts
351
- var VERSION2 = true ? "4.3.0-alpha.2" : "latest";
351
+ var VERSION2 = true ? "4.3.0-alpha.4" : "latest";
352
352
 
353
353
  // ../../node_modules/ktx-parse/dist/ktx-parse.modern.js
354
- var t = new Uint8Array([0]);
355
- var e = [171, 75, 84, 88, 32, 50, 48, 187, 13, 10, 26, 10];
356
- var n;
357
- var i;
358
- var s;
359
- var a;
360
- var r;
361
- var o;
362
- var l;
363
- var f;
364
- !function(t2) {
365
- t2[t2.NONE = 0] = "NONE", t2[t2.BASISLZ = 1] = "BASISLZ", t2[t2.ZSTD = 2] = "ZSTD", t2[t2.ZLIB = 3] = "ZLIB";
366
- }(n || (n = {})), function(t2) {
367
- t2[t2.BASICFORMAT = 0] = "BASICFORMAT";
368
- }(i || (i = {})), function(t2) {
369
- t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.ETC1S = 163] = "ETC1S", t2[t2.UASTC = 166] = "UASTC";
370
- }(s || (s = {})), function(t2) {
371
- t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.SRGB = 1] = "SRGB";
372
- }(a || (a = {})), function(t2) {
373
- 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";
374
- }(r || (r = {})), function(t2) {
375
- t2[t2.ALPHA_STRAIGHT = 0] = "ALPHA_STRAIGHT", t2[t2.ALPHA_PREMULTIPLIED = 1] = "ALPHA_PREMULTIPLIED";
376
- }(o || (o = {})), function(t2) {
377
- t2[t2.RGB = 0] = "RGB", t2[t2.RRR = 3] = "RRR", t2[t2.GGG = 4] = "GGG", t2[t2.AAA = 15] = "AAA";
378
- }(l || (l = {})), function(t2) {
379
- t2[t2.RGB = 0] = "RGB", t2[t2.RGBA = 3] = "RGBA", t2[t2.RRR = 4] = "RRR", t2[t2.RRRG = 5] = "RRRG";
380
- }(f || (f = {}));
381
- var U = class {
354
+ var KHR_SUPERCOMPRESSION_NONE = 0;
355
+ var KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT = 0;
356
+ var KHR_DF_VENDORID_KHRONOS = 0;
357
+ var KHR_DF_VERSION = 2;
358
+ var KHR_DF_MODEL_UNSPECIFIED = 0;
359
+ var KHR_DF_FLAG_ALPHA_STRAIGHT = 0;
360
+ var KHR_DF_TRANSFER_SRGB = 2;
361
+ var KHR_DF_PRIMARIES_BT709 = 1;
362
+ var KHR_DF_SAMPLE_DATATYPE_SIGNED = 64;
363
+ var VK_FORMAT_UNDEFINED = 0;
364
+ var KTX2Container = class {
382
365
  constructor() {
383
- 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;
366
+ this.vkFormat = VK_FORMAT_UNDEFINED;
367
+ this.typeSize = 1;
368
+ this.pixelWidth = 0;
369
+ this.pixelHeight = 0;
370
+ this.pixelDepth = 0;
371
+ this.layerCount = 0;
372
+ this.faceCount = 1;
373
+ this.supercompressionScheme = KHR_SUPERCOMPRESSION_NONE;
374
+ this.levels = [];
375
+ this.dataFormatDescriptor = [{
376
+ vendorId: KHR_DF_VENDORID_KHRONOS,
377
+ descriptorType: KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT,
378
+ descriptorBlockSize: 0,
379
+ versionNumber: KHR_DF_VERSION,
380
+ colorModel: KHR_DF_MODEL_UNSPECIFIED,
381
+ colorPrimaries: KHR_DF_PRIMARIES_BT709,
382
+ transferFunction: KHR_DF_TRANSFER_SRGB,
383
+ flags: KHR_DF_FLAG_ALPHA_STRAIGHT,
384
+ texelBlockDimension: [0, 0, 0, 0],
385
+ bytesPlane: [0, 0, 0, 0, 0, 0, 0, 0],
386
+ samples: []
387
+ }];
388
+ this.keyValue = {};
389
+ this.globalData = null;
384
390
  }
385
391
  };
386
- var c = class {
387
- constructor(t2, e2, n2, i2) {
388
- this._dataView = new DataView(t2.buffer, t2.byteOffset + e2, n2), this._littleEndian = i2, this._offset = 0;
392
+ var BufferReader = class {
393
+ constructor(data, byteOffset, byteLength, littleEndian) {
394
+ this._dataView = void 0;
395
+ this._littleEndian = void 0;
396
+ this._offset = void 0;
397
+ this._dataView = new DataView(data.buffer, data.byteOffset + byteOffset, byteLength);
398
+ this._littleEndian = littleEndian;
399
+ this._offset = 0;
389
400
  }
390
401
  _nextUint8() {
391
- const t2 = this._dataView.getUint8(this._offset);
392
- return this._offset += 1, t2;
402
+ const value = this._dataView.getUint8(this._offset);
403
+ this._offset += 1;
404
+ return value;
393
405
  }
394
406
  _nextUint16() {
395
- const t2 = this._dataView.getUint16(this._offset, this._littleEndian);
396
- return this._offset += 2, t2;
407
+ const value = this._dataView.getUint16(this._offset, this._littleEndian);
408
+ this._offset += 2;
409
+ return value;
397
410
  }
398
411
  _nextUint32() {
399
- const t2 = this._dataView.getUint32(this._offset, this._littleEndian);
400
- return this._offset += 4, t2;
412
+ const value = this._dataView.getUint32(this._offset, this._littleEndian);
413
+ this._offset += 4;
414
+ return value;
401
415
  }
402
416
  _nextUint64() {
403
- const t2 = this._dataView.getUint32(this._offset, this._littleEndian) + 2 ** 32 * this._dataView.getUint32(this._offset + 4, this._littleEndian);
404
- return this._offset += 8, t2;
417
+ const left = this._dataView.getUint32(this._offset, this._littleEndian);
418
+ const right = this._dataView.getUint32(this._offset + 4, this._littleEndian);
419
+ const value = left + 2 ** 32 * right;
420
+ this._offset += 8;
421
+ return value;
405
422
  }
406
- _skip(t2) {
407
- return this._offset += t2, this;
423
+ _nextInt32() {
424
+ const value = this._dataView.getInt32(this._offset, this._littleEndian);
425
+ this._offset += 4;
426
+ return value;
408
427
  }
409
- _scan(t2, e2 = 0) {
410
- const n2 = this._offset;
411
- let i2 = 0;
412
- for (; this._dataView.getUint8(this._offset) !== e2 && i2 < t2; )
413
- i2++, this._offset++;
414
- return i2 < t2 && this._offset++, new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + n2, i2);
428
+ _nextUint8Array(len) {
429
+ const value = new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + this._offset, len);
430
+ this._offset += len;
431
+ return value;
432
+ }
433
+ _skip(bytes) {
434
+ this._offset += bytes;
435
+ return this;
436
+ }
437
+ _scan(maxByteLength, term = 0) {
438
+ const byteOffset = this._offset;
439
+ let byteLength = 0;
440
+ while (this._dataView.getUint8(this._offset) !== term && byteLength < maxByteLength) {
441
+ byteLength++;
442
+ this._offset++;
443
+ }
444
+ if (byteLength < maxByteLength)
445
+ this._offset++;
446
+ return new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + byteOffset, byteLength);
415
447
  }
416
448
  };
417
- function _(t2) {
418
- return "undefined" != typeof TextDecoder ? new TextDecoder().decode(t2) : Buffer.from(t2).toString("utf8");
449
+ var NUL = new Uint8Array([0]);
450
+ var KTX2_ID = [
451
+ // '´', 'K', 'T', 'X', '2', '0', 'ª', '\r', '\n', '\x1A', '\n'
452
+ 171,
453
+ 75,
454
+ 84,
455
+ 88,
456
+ 32,
457
+ 50,
458
+ 48,
459
+ 187,
460
+ 13,
461
+ 10,
462
+ 26,
463
+ 10
464
+ ];
465
+ function decodeText(buffer) {
466
+ if (typeof TextDecoder !== "undefined") {
467
+ return new TextDecoder().decode(buffer);
468
+ }
469
+ return Buffer.from(buffer).toString("utf8");
419
470
  }
420
- function p(t2) {
421
- const n2 = new Uint8Array(t2.buffer, t2.byteOffset, e.length);
422
- 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])
471
+ function read(data) {
472
+ const id = new Uint8Array(data.buffer, data.byteOffset, KTX2_ID.length);
473
+ if (id[0] !== KTX2_ID[0] || // '´'
474
+ id[1] !== KTX2_ID[1] || // 'K'
475
+ id[2] !== KTX2_ID[2] || // 'T'
476
+ id[3] !== KTX2_ID[3] || // 'X'
477
+ id[4] !== KTX2_ID[4] || // ' '
478
+ id[5] !== KTX2_ID[5] || // '2'
479
+ id[6] !== KTX2_ID[6] || // '0'
480
+ id[7] !== KTX2_ID[7] || // 'ª'
481
+ id[8] !== KTX2_ID[8] || // '\r'
482
+ id[9] !== KTX2_ID[9] || // '\n'
483
+ id[10] !== KTX2_ID[10] || // '\x1A'
484
+ id[11] !== KTX2_ID[11]) {
423
485
  throw new Error("Missing KTX 2.0 identifier.");
424
- const i2 = new U(), s2 = 17 * Uint32Array.BYTES_PER_ELEMENT, a2 = new c(t2, e.length, s2, true);
425
- i2.vkFormat = a2._nextUint32(), i2.typeSize = a2._nextUint32(), i2.pixelWidth = a2._nextUint32(), i2.pixelHeight = a2._nextUint32(), i2.pixelDepth = a2._nextUint32(), i2.layerCount = a2._nextUint32(), i2.faceCount = a2._nextUint32();
426
- const r2 = a2._nextUint32();
427
- i2.supercompressionScheme = a2._nextUint32();
428
- const o2 = a2._nextUint32(), l2 = a2._nextUint32(), f2 = a2._nextUint32(), h = a2._nextUint32(), g = a2._nextUint64(), p2 = a2._nextUint64(), x = new c(t2, e.length + s2, 3 * r2 * 8, true);
429
- for (let e2 = 0; e2 < r2; e2++)
430
- i2.levels.push({ levelData: new Uint8Array(t2.buffer, t2.byteOffset + x._nextUint64(), x._nextUint64()), uncompressedByteLength: x._nextUint64() });
431
- 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;
432
- for (let t3 = 0; t3 < D; t3++)
433
- 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() };
434
- i2.dataFormatDescriptor.length = 0, i2.dataFormatDescriptor.push(y);
435
- const b = new c(t2, f2, h, true);
436
- for (; b._offset < h; ) {
437
- const t3 = b._nextUint32(), e2 = b._scan(t3), n3 = _(e2), s3 = b._scan(t3 - e2.byteLength);
438
- i2.keyValue[n3] = n3.match(/^ktx/i) ? _(s3) : s3, t3 % 4 && b._skip(4 - t3 % 4);
439
- }
440
- if (p2 <= 0)
441
- return i2;
442
- 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 = [];
443
- for (let t3 = 0; t3 < r2; t3++)
444
- I.push({ imageFlags: d._nextUint32(), rgbSliceByteOffset: d._nextUint32(), rgbSliceByteLength: d._nextUint32(), alphaSliceByteOffset: d._nextUint32(), alphaSliceByteLength: d._nextUint32() });
445
- 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);
446
- return i2.globalData = { endpointCount: B, selectorCount: w, imageDescs: I, endpointsData: P, selectorsData: C, tablesData: F, extendedData: G }, i2;
486
+ }
487
+ const container = new KTX2Container();
488
+ const headerByteLength = 17 * Uint32Array.BYTES_PER_ELEMENT;
489
+ const headerReader = new BufferReader(data, KTX2_ID.length, headerByteLength, true);
490
+ container.vkFormat = headerReader._nextUint32();
491
+ container.typeSize = headerReader._nextUint32();
492
+ container.pixelWidth = headerReader._nextUint32();
493
+ container.pixelHeight = headerReader._nextUint32();
494
+ container.pixelDepth = headerReader._nextUint32();
495
+ container.layerCount = headerReader._nextUint32();
496
+ container.faceCount = headerReader._nextUint32();
497
+ const levelCount = headerReader._nextUint32();
498
+ container.supercompressionScheme = headerReader._nextUint32();
499
+ const dfdByteOffset = headerReader._nextUint32();
500
+ const dfdByteLength = headerReader._nextUint32();
501
+ const kvdByteOffset = headerReader._nextUint32();
502
+ const kvdByteLength = headerReader._nextUint32();
503
+ const sgdByteOffset = headerReader._nextUint64();
504
+ const sgdByteLength = headerReader._nextUint64();
505
+ const levelByteLength = levelCount * 3 * 8;
506
+ const levelReader = new BufferReader(data, KTX2_ID.length + headerByteLength, levelByteLength, true);
507
+ for (let i = 0; i < levelCount; i++) {
508
+ container.levels.push({
509
+ levelData: new Uint8Array(data.buffer, data.byteOffset + levelReader._nextUint64(), levelReader._nextUint64()),
510
+ uncompressedByteLength: levelReader._nextUint64()
511
+ });
512
+ }
513
+ const dfdReader = new BufferReader(data, dfdByteOffset, dfdByteLength, true);
514
+ const dfd = {
515
+ vendorId: dfdReader._skip(
516
+ 4
517
+ /* totalSize */
518
+ )._nextUint16(),
519
+ descriptorType: dfdReader._nextUint16(),
520
+ versionNumber: dfdReader._nextUint16(),
521
+ descriptorBlockSize: dfdReader._nextUint16(),
522
+ colorModel: dfdReader._nextUint8(),
523
+ colorPrimaries: dfdReader._nextUint8(),
524
+ transferFunction: dfdReader._nextUint8(),
525
+ flags: dfdReader._nextUint8(),
526
+ texelBlockDimension: [dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8()],
527
+ bytesPlane: [dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8()],
528
+ samples: []
529
+ };
530
+ const sampleStart = 6;
531
+ const sampleWords = 4;
532
+ const numSamples = (dfd.descriptorBlockSize / 4 - sampleStart) / sampleWords;
533
+ for (let i = 0; i < numSamples; i++) {
534
+ const sample = {
535
+ bitOffset: dfdReader._nextUint16(),
536
+ bitLength: dfdReader._nextUint8(),
537
+ channelType: dfdReader._nextUint8(),
538
+ samplePosition: [dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8()],
539
+ sampleLower: -Infinity,
540
+ sampleUpper: Infinity
541
+ };
542
+ if (sample.channelType & KHR_DF_SAMPLE_DATATYPE_SIGNED) {
543
+ sample.sampleLower = dfdReader._nextInt32();
544
+ sample.sampleUpper = dfdReader._nextInt32();
545
+ } else {
546
+ sample.sampleLower = dfdReader._nextUint32();
547
+ sample.sampleUpper = dfdReader._nextUint32();
548
+ }
549
+ dfd.samples[i] = sample;
550
+ }
551
+ container.dataFormatDescriptor.length = 0;
552
+ container.dataFormatDescriptor.push(dfd);
553
+ const kvdReader = new BufferReader(data, kvdByteOffset, kvdByteLength, true);
554
+ while (kvdReader._offset < kvdByteLength) {
555
+ const keyValueByteLength = kvdReader._nextUint32();
556
+ const keyData = kvdReader._scan(keyValueByteLength);
557
+ const key = decodeText(keyData);
558
+ container.keyValue[key] = kvdReader._nextUint8Array(keyValueByteLength - keyData.byteLength - 1);
559
+ if (key.match(/^ktx/i)) {
560
+ const text = decodeText(container.keyValue[key]);
561
+ container.keyValue[key] = text.substring(0, text.lastIndexOf("\0"));
562
+ }
563
+ const kvPadding = keyValueByteLength % 4 ? 4 - keyValueByteLength % 4 : 0;
564
+ kvdReader._skip(kvPadding);
565
+ }
566
+ if (sgdByteLength <= 0)
567
+ return container;
568
+ const sgdReader = new BufferReader(data, sgdByteOffset, sgdByteLength, true);
569
+ const endpointCount = sgdReader._nextUint16();
570
+ const selectorCount = sgdReader._nextUint16();
571
+ const endpointsByteLength = sgdReader._nextUint32();
572
+ const selectorsByteLength = sgdReader._nextUint32();
573
+ const tablesByteLength = sgdReader._nextUint32();
574
+ const extendedByteLength = sgdReader._nextUint32();
575
+ const imageDescs = [];
576
+ for (let i = 0; i < levelCount; i++) {
577
+ imageDescs.push({
578
+ imageFlags: sgdReader._nextUint32(),
579
+ rgbSliceByteOffset: sgdReader._nextUint32(),
580
+ rgbSliceByteLength: sgdReader._nextUint32(),
581
+ alphaSliceByteOffset: sgdReader._nextUint32(),
582
+ alphaSliceByteLength: sgdReader._nextUint32()
583
+ });
584
+ }
585
+ const endpointsByteOffset = sgdByteOffset + sgdReader._offset;
586
+ const selectorsByteOffset = endpointsByteOffset + endpointsByteLength;
587
+ const tablesByteOffset = selectorsByteOffset + selectorsByteLength;
588
+ const extendedByteOffset = tablesByteOffset + tablesByteLength;
589
+ const endpointsData = new Uint8Array(data.buffer, data.byteOffset + endpointsByteOffset, endpointsByteLength);
590
+ const selectorsData = new Uint8Array(data.buffer, data.byteOffset + selectorsByteOffset, selectorsByteLength);
591
+ const tablesData = new Uint8Array(data.buffer, data.byteOffset + tablesByteOffset, tablesByteLength);
592
+ const extendedData = new Uint8Array(data.buffer, data.byteOffset + extendedByteOffset, extendedByteLength);
593
+ container.globalData = {
594
+ endpointCount,
595
+ selectorCount,
596
+ imageDescs,
597
+ endpointsData,
598
+ selectorsData,
599
+ tablesData,
600
+ extendedData
601
+ };
602
+ return container;
447
603
  }
448
604
 
449
605
  // src/lib/utils/extract-mipmap-images.ts
@@ -452,10 +608,10 @@
452
608
  let levelWidth = options.width;
453
609
  let levelHeight = options.height;
454
610
  let offset = 0;
455
- for (let i2 = 0; i2 < options.mipMapLevels; ++i2) {
456
- const levelSize = getLevelSize(options, levelWidth, levelHeight, data, i2);
457
- const levelData = getLevelData(data, i2, offset, levelSize);
458
- images[i2] = {
611
+ for (let i = 0; i < options.mipMapLevels; ++i) {
612
+ const levelSize = getLevelSize(options, levelWidth, levelHeight, data, i);
613
+ const levelData = getLevelData(data, i, offset, levelSize);
614
+ images[i] = {
459
615
  compressed: true,
460
616
  format: options.internalFormat,
461
617
  data: levelData,
@@ -668,7 +824,7 @@
668
824
  }
669
825
 
670
826
  // src/lib/parsers/parse-ktx.ts
671
- var KTX2_ID = [
827
+ var KTX2_ID2 = [
672
828
  // '´', 'K', 'T', 'X', '2', '0', 'ª', '\r', '\n', '\x1A', '\n'
673
829
  171,
674
830
  75,
@@ -685,23 +841,23 @@
685
841
  ];
686
842
  function isKTX(data) {
687
843
  const id = new Uint8Array(data);
688
- const notKTX = id.byteLength < KTX2_ID.length || id[0] !== KTX2_ID[0] || // '´'
689
- id[1] !== KTX2_ID[1] || // 'K'
690
- id[2] !== KTX2_ID[2] || // 'T'
691
- id[3] !== KTX2_ID[3] || // 'X'
692
- id[4] !== KTX2_ID[4] || // ' '
693
- id[5] !== KTX2_ID[5] || // '2'
694
- id[6] !== KTX2_ID[6] || // '0'
695
- id[7] !== KTX2_ID[7] || // 'ª'
696
- id[8] !== KTX2_ID[8] || // '\r'
697
- id[9] !== KTX2_ID[9] || // '\n'
698
- id[10] !== KTX2_ID[10] || // '\x1A'
699
- id[11] !== KTX2_ID[11];
844
+ const notKTX = id.byteLength < KTX2_ID2.length || id[0] !== KTX2_ID2[0] || // '´'
845
+ id[1] !== KTX2_ID2[1] || // 'K'
846
+ id[2] !== KTX2_ID2[2] || // 'T'
847
+ id[3] !== KTX2_ID2[3] || // 'X'
848
+ id[4] !== KTX2_ID2[4] || // ' '
849
+ id[5] !== KTX2_ID2[5] || // '2'
850
+ id[6] !== KTX2_ID2[6] || // '0'
851
+ id[7] !== KTX2_ID2[7] || // 'ª'
852
+ id[8] !== KTX2_ID2[8] || // '\r'
853
+ id[9] !== KTX2_ID2[9] || // '\n'
854
+ id[10] !== KTX2_ID2[10] || // '\x1A'
855
+ id[11] !== KTX2_ID2[11];
700
856
  return !notKTX;
701
857
  }
702
858
  function parseKTX(arrayBuffer) {
703
859
  const uint8Array = new Uint8Array(arrayBuffer);
704
- const ktx = p(uint8Array);
860
+ const ktx = read(uint8Array);
705
861
  const mipMapLevels = Math.max(1, ktx.levels.length);
706
862
  const width = ktx.pixelWidth;
707
863
  const height = ktx.pixelHeight;
@@ -1246,7 +1402,6 @@
1246
1402
  const levels = [];
1247
1403
  for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
1248
1404
  levels.push(transcodeKTX2Image(ktx2File, levelIndex, options));
1249
- break;
1250
1405
  }
1251
1406
  return [levels];
1252
1407
  } finally {
@@ -28,7 +28,7 @@
28
28
  );
29
29
  globalThis._loadersgl_.version = NPM_TAG;
30
30
  } else {
31
- globalThis._loadersgl_.version = "4.3.0-alpha.2";
31
+ globalThis._loadersgl_.version = "4.3.0-alpha.4";
32
32
  }
33
33
  }
34
34
  return globalThis._loadersgl_.version;
@@ -348,7 +348,7 @@
348
348
  }
349
349
 
350
350
  // src/lib/utils/version.ts
351
- var VERSION2 = true ? "4.3.0-alpha.2" : "latest";
351
+ var VERSION2 = true ? "4.3.0-alpha.4" : "latest";
352
352
 
353
353
  // src/crunch-loader.ts
354
354
  var CrunchLoader = {