@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/basis-worker-node.js +8961 -11052
- package/dist/basis-worker.js +2 -31
- package/dist/compressed-texture-worker.js +253 -98
- package/dist/crunch-worker.js +2 -2
- package/dist/dist.dev.js +268 -113
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +1 -2
- package/dist/index.cjs.map +2 -2
- package/dist/ktx2-basis-writer-worker-node.js +8890 -10804
- package/dist/ktx2-basis-writer-worker.js +2 -2
- package/dist/lib/parsers/parse-basis.d.ts.map +1 -1
- package/dist/lib/parsers/parse-basis.js +0 -1
- package/dist/lib/utils/version.js +1 -1
- package/dist/npy-worker.js +1 -1
- package/package.json +7 -7
- package/src/lib/parsers/parse-basis.ts +0 -1
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 (
|
|
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
|
|
457
|
-
var
|
|
458
|
-
var
|
|
459
|
-
var
|
|
460
|
-
var
|
|
461
|
-
var
|
|
462
|
-
var
|
|
463
|
-
var
|
|
464
|
-
var
|
|
465
|
-
var
|
|
466
|
-
|
|
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 =
|
|
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
|
|
489
|
-
constructor(
|
|
490
|
-
this._dataView =
|
|
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
|
|
494
|
-
|
|
504
|
+
const value = this._dataView.getUint8(this._offset);
|
|
505
|
+
this._offset += 1;
|
|
506
|
+
return value;
|
|
495
507
|
}
|
|
496
508
|
_nextUint16() {
|
|
497
|
-
const
|
|
498
|
-
|
|
509
|
+
const value = this._dataView.getUint16(this._offset, this._littleEndian);
|
|
510
|
+
this._offset += 2;
|
|
511
|
+
return value;
|
|
499
512
|
}
|
|
500
513
|
_nextUint32() {
|
|
501
|
-
const
|
|
502
|
-
|
|
514
|
+
const value = this._dataView.getUint32(this._offset, this._littleEndian);
|
|
515
|
+
this._offset += 4;
|
|
516
|
+
return value;
|
|
503
517
|
}
|
|
504
518
|
_nextUint64() {
|
|
505
|
-
const
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
return
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
const
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
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
|
-
|
|
520
|
-
|
|
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
|
|
523
|
-
const
|
|
524
|
-
if (
|
|
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
|
-
|
|
527
|
-
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
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
|
|
558
|
-
const levelSize = getLevelSize(options, levelWidth, levelHeight, data,
|
|
559
|
-
const levelData = getLevelData(data,
|
|
560
|
-
images[
|
|
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
|
|
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 <
|
|
721
|
-
id[1] !==
|
|
722
|
-
id[2] !==
|
|
723
|
-
id[3] !==
|
|
724
|
-
id[4] !==
|
|
725
|
-
id[5] !==
|
|
726
|
-
id[6] !==
|
|
727
|
-
id[7] !==
|
|
728
|
-
id[8] !==
|
|
729
|
-
id[9] !==
|
|
730
|
-
id[10] !==
|
|
731
|
-
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 =
|
|
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
|
|
1342
|
-
var b = new Uint8Array(
|
|
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((
|
|
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
|
|
1731
|
-
if (headerBytes[
|
|
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
|
|
1802
|
-
while (
|
|
1803
|
-
const marker = dataView.getUint16(
|
|
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(
|
|
1962
|
+
height: dataView.getUint16(i + 5, BIG_ENDIAN),
|
|
1808
1963
|
// Number of lines
|
|
1809
|
-
width: dataView.getUint16(
|
|
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
|
-
|
|
1817
|
-
|
|
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
|
|
1824
|
-
tableMarkers.add(
|
|
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
|
|
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;
|