@loaders.gl/3d-tiles 4.0.0-alpha.22 → 4.0.0-alpha.23
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/3d-tiles-archive/3d-tiles-archive-archive.d.ts +2 -1
- package/dist/3d-tiles-archive/3d-tiles-archive-archive.d.ts.map +1 -1
- package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts +1 -1
- package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts.map +1 -1
- package/dist/3d-tiles-archive-loader.d.ts +1 -1
- package/dist/3d-tiles-archive-loader.d.ts.map +1 -1
- package/dist/3d-tiles-archive-loader.js +2 -2
- package/dist/cesium-ion-loader.d.ts.map +1 -1
- package/dist/cesium-ion-loader.js +0 -1
- package/dist/dist.min.js +2020 -1475
- package/dist/es5/3d-tiles-archive/3d-tiles-archive-archive.js.map +1 -1
- package/dist/es5/3d-tiles-archive/3d-tiles-archive-parser.js.map +1 -1
- package/dist/es5/3d-tiles-archive-loader.js +3 -3
- package/dist/es5/3d-tiles-archive-loader.js.map +1 -1
- package/dist/es5/cesium-ion-loader.js.map +1 -1
- package/dist/es5/lib/filesystems/tiles-3d-archive-file-system.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-composite.js +3 -1
- package/dist/es5/lib/parsers/parse-3d-tile-composite.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-gltf.js +3 -1
- package/dist/es5/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile.js +3 -1
- package/dist/es5/lib/parsers/parse-3d-tile.js.map +1 -1
- package/dist/es5/lib/utils/version.js +1 -1
- package/dist/es5/tiles-3d-loader.js +2 -0
- package/dist/es5/tiles-3d-loader.js.map +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/esm/3d-tiles-archive/3d-tiles-archive-archive.js.map +1 -1
- package/dist/esm/3d-tiles-archive/3d-tiles-archive-parser.js.map +1 -1
- package/dist/esm/3d-tiles-archive-loader.js +2 -2
- package/dist/esm/3d-tiles-archive-loader.js.map +1 -1
- package/dist/esm/cesium-ion-loader.js.map +1 -1
- package/dist/esm/lib/filesystems/tiles-3d-archive-file-system.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-composite.js +3 -1
- package/dist/esm/lib/parsers/parse-3d-tile-composite.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-gltf.js +2 -1
- package/dist/esm/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile.js +3 -1
- package/dist/esm/lib/parsers/parse-3d-tile.js.map +1 -1
- package/dist/esm/lib/utils/version.js +1 -1
- package/dist/esm/tiles-3d-loader.js +2 -0
- package/dist/esm/tiles-3d-loader.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/lib/filesystems/tiles-3d-archive-file-system.d.ts +2 -1
- package/dist/lib/filesystems/tiles-3d-archive-file-system.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-composite.js +1 -1
- package/dist/lib/parsers/parse-3d-tile-gltf.d.ts +1 -1
- package/dist/lib/parsers/parse-3d-tile-gltf.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-gltf.js +2 -1
- package/dist/lib/parsers/parse-3d-tile.d.ts +1 -1
- package/dist/lib/parsers/parse-3d-tile.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile.js +1 -1
- package/dist/tiles-3d-loader.d.ts +2 -1
- package/dist/tiles-3d-loader.d.ts.map +1 -1
- package/dist/tiles-3d-loader.js +4 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/3d-tiles-archive/3d-tiles-archive-archive.ts +2 -1
- package/src/3d-tiles-archive/3d-tiles-archive-parser.ts +1 -1
- package/src/3d-tiles-archive-loader.ts +2 -2
- package/src/cesium-ion-loader.ts +0 -1
- package/src/lib/filesystems/tiles-3d-archive-file-system.ts +1 -1
- package/src/lib/parsers/parse-3d-tile-composite.ts +1 -1
- package/src/lib/parsers/parse-3d-tile-gltf.ts +3 -2
- package/src/lib/parsers/parse-3d-tile.ts +2 -2
- package/src/tiles-3d-loader.ts +16 -4
- package/src/types.ts +3 -0
package/dist/dist.min.js
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
};
|
|
15
15
|
var __export = (target, all) => {
|
|
16
16
|
__markAsModule(target);
|
|
17
|
-
for (var
|
|
18
|
-
__defProp(target,
|
|
17
|
+
for (var name12 in all)
|
|
18
|
+
__defProp(target, name12, { get: all[name12], enumerable: true });
|
|
19
19
|
};
|
|
20
20
|
var __reExport = (target, module, desc) => {
|
|
21
21
|
if (module && typeof module === "object" || typeof module === "function") {
|
|
@@ -263,9 +263,9 @@
|
|
|
263
263
|
constructor(props) {
|
|
264
264
|
this.terminated = false;
|
|
265
265
|
this._loadableURL = "";
|
|
266
|
-
const { name:
|
|
266
|
+
const { name: name12, source, url } = props;
|
|
267
267
|
assert3(source || url);
|
|
268
|
-
this.name =
|
|
268
|
+
this.name = name12;
|
|
269
269
|
this.source = source;
|
|
270
270
|
this.url = url;
|
|
271
271
|
this.onMessage = NOOP;
|
|
@@ -390,9 +390,9 @@
|
|
|
390
390
|
this.onDebug = props.onDebug;
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
|
-
async startJob(
|
|
393
|
+
async startJob(name12, onMessage2 = (job, type, data) => job.done(data), onError = (job, error) => job.error(error)) {
|
|
394
394
|
const startPromise = new Promise((onStart) => {
|
|
395
|
-
this.jobQueue.push({ name:
|
|
395
|
+
this.jobQueue.push({ name: name12, onMessage: onMessage2, onError, onStart });
|
|
396
396
|
return this;
|
|
397
397
|
});
|
|
398
398
|
this._startQueuedJob();
|
|
@@ -443,8 +443,8 @@
|
|
|
443
443
|
}
|
|
444
444
|
if (this.count < this._getMaxConcurrency()) {
|
|
445
445
|
this.count++;
|
|
446
|
-
const
|
|
447
|
-
return new WorkerThread({ name:
|
|
446
|
+
const name12 = `${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;
|
|
447
|
+
return new WorkerThread({ name: name12, source: this.source, url: this.url });
|
|
448
448
|
}
|
|
449
449
|
return null;
|
|
450
450
|
}
|
|
@@ -496,16 +496,16 @@
|
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
498
|
getWorkerPool(options) {
|
|
499
|
-
const { name:
|
|
500
|
-
let workerPool = this.workerPools.get(
|
|
499
|
+
const { name: name12, source, url } = options;
|
|
500
|
+
let workerPool = this.workerPools.get(name12);
|
|
501
501
|
if (!workerPool) {
|
|
502
502
|
workerPool = new WorkerPool({
|
|
503
|
-
name:
|
|
503
|
+
name: name12,
|
|
504
504
|
source,
|
|
505
505
|
url
|
|
506
506
|
});
|
|
507
507
|
workerPool.setProps(this._getWorkerPoolProps());
|
|
508
|
-
this.workerPools.set(
|
|
508
|
+
this.workerPools.set(name12, workerPool);
|
|
509
509
|
}
|
|
510
510
|
return workerPool;
|
|
511
511
|
}
|
|
@@ -688,10 +688,10 @@
|
|
|
688
688
|
return loader.worker && options?.worker;
|
|
689
689
|
}
|
|
690
690
|
async function parseWithWorker(loader, data, options, context, parseOnMainThread) {
|
|
691
|
-
const
|
|
691
|
+
const name12 = loader.id;
|
|
692
692
|
const url = getWorkerURL(loader, options);
|
|
693
693
|
const workerFarm = WorkerFarm.getWorkerFarm(options);
|
|
694
|
-
const workerPool = workerFarm.getWorkerPool({ name:
|
|
694
|
+
const workerPool = workerFarm.getWorkerPool({ name: name12, url });
|
|
695
695
|
options = JSON.parse(JSON.stringify(options));
|
|
696
696
|
context = JSON.parse(JSON.stringify(context || {}));
|
|
697
697
|
const job = await workerPool.startJob("process-on-worker", onMessage.bind(null, parseOnMainThread));
|
|
@@ -1196,6 +1196,154 @@
|
|
|
1196
1196
|
}
|
|
1197
1197
|
});
|
|
1198
1198
|
|
|
1199
|
+
// ../loader-utils/src/lib/file-provider/file-provider.ts
|
|
1200
|
+
var isFileProvider;
|
|
1201
|
+
var init_file_provider = __esm({
|
|
1202
|
+
"../loader-utils/src/lib/file-provider/file-provider.ts"() {
|
|
1203
|
+
isFileProvider = (fileProvider) => {
|
|
1204
|
+
return fileProvider?.getUint8 && fileProvider?.slice && fileProvider?.length;
|
|
1205
|
+
};
|
|
1206
|
+
}
|
|
1207
|
+
});
|
|
1208
|
+
|
|
1209
|
+
// ../loader-utils/src/lib/file-provider/file-handle.ts
|
|
1210
|
+
var import_fs, FileHandle;
|
|
1211
|
+
var init_file_handle = __esm({
|
|
1212
|
+
"../loader-utils/src/lib/file-provider/file-handle.ts"() {
|
|
1213
|
+
import_fs = __toModule(require_fs());
|
|
1214
|
+
FileHandle = class {
|
|
1215
|
+
constructor(fileDescriptor, stats) {
|
|
1216
|
+
this.read = (buffer, offset, length4, position) => {
|
|
1217
|
+
return new Promise((s2) => {
|
|
1218
|
+
(0, import_fs.read)(this.fileDescriptor, buffer, offset, length4, position, (_err, bytesRead, buffer2) => s2({ bytesRead, buffer: buffer2 }));
|
|
1219
|
+
});
|
|
1220
|
+
};
|
|
1221
|
+
this.fileDescriptor = fileDescriptor;
|
|
1222
|
+
this.stats = stats;
|
|
1223
|
+
}
|
|
1224
|
+
static async open(path) {
|
|
1225
|
+
const [fd, stats] = await Promise.all([
|
|
1226
|
+
new Promise((resolve2, reject) => {
|
|
1227
|
+
(0, import_fs.open)(path, void 0, void 0, (_err, fd2) => _err ? reject(_err) : resolve2(fd2));
|
|
1228
|
+
}),
|
|
1229
|
+
new Promise((resolve2, reject) => {
|
|
1230
|
+
(0, import_fs.stat)(path, { bigint: true }, (_err, stats2) => _err ? reject(_err) : resolve2(stats2));
|
|
1231
|
+
})
|
|
1232
|
+
]);
|
|
1233
|
+
return new FileHandle(fd, stats);
|
|
1234
|
+
}
|
|
1235
|
+
async close() {
|
|
1236
|
+
return new Promise((resolve2) => {
|
|
1237
|
+
(0, import_fs.close)(this.fileDescriptor, (_err) => resolve2());
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
get stat() {
|
|
1241
|
+
return this.stats;
|
|
1242
|
+
}
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1245
|
+
});
|
|
1246
|
+
|
|
1247
|
+
// ../loader-utils/src/lib/file-provider/file-handle-file.ts
|
|
1248
|
+
var FileHandleFile;
|
|
1249
|
+
var init_file_handle_file = __esm({
|
|
1250
|
+
"../loader-utils/src/lib/file-provider/file-handle-file.ts"() {
|
|
1251
|
+
init_file_handle();
|
|
1252
|
+
init_file_aliases();
|
|
1253
|
+
FileHandleFile = class {
|
|
1254
|
+
static async from(path) {
|
|
1255
|
+
path = resolvePath(path);
|
|
1256
|
+
const fileDescriptor = await FileHandle.open(path);
|
|
1257
|
+
return new FileHandleFile(fileDescriptor, fileDescriptor.stat.size);
|
|
1258
|
+
}
|
|
1259
|
+
constructor(fileDescriptor, size) {
|
|
1260
|
+
this.fileDescriptor = fileDescriptor;
|
|
1261
|
+
this.size = size;
|
|
1262
|
+
}
|
|
1263
|
+
async destroy() {
|
|
1264
|
+
await this.fileDescriptor.close();
|
|
1265
|
+
}
|
|
1266
|
+
async getUint8(offset) {
|
|
1267
|
+
const val = new Uint8Array((await this.fileDescriptor.read(Buffer.alloc(1), 0, 1, offset)).buffer.buffer).at(0);
|
|
1268
|
+
if (val === void 0) {
|
|
1269
|
+
throw new Error("something went wrong");
|
|
1270
|
+
}
|
|
1271
|
+
return val;
|
|
1272
|
+
}
|
|
1273
|
+
async getUint16(offset) {
|
|
1274
|
+
const val = new Uint16Array((await this.fileDescriptor.read(Buffer.alloc(2), 0, 2, offset)).buffer.buffer).at(0);
|
|
1275
|
+
if (val === void 0) {
|
|
1276
|
+
throw new Error("something went wrong");
|
|
1277
|
+
}
|
|
1278
|
+
return val;
|
|
1279
|
+
}
|
|
1280
|
+
async getUint32(offset) {
|
|
1281
|
+
const val = new Uint32Array((await this.fileDescriptor.read(Buffer.alloc(4), 0, 4, offset)).buffer.buffer).at(0);
|
|
1282
|
+
if (val === void 0) {
|
|
1283
|
+
throw new Error("something went wrong");
|
|
1284
|
+
}
|
|
1285
|
+
return val;
|
|
1286
|
+
}
|
|
1287
|
+
async getBigUint64(offset) {
|
|
1288
|
+
const val = new BigInt64Array((await this.fileDescriptor.read(Buffer.alloc(8), 0, 8, offset)).buffer.buffer).at(0);
|
|
1289
|
+
if (val === void 0) {
|
|
1290
|
+
throw new Error("something went wrong");
|
|
1291
|
+
}
|
|
1292
|
+
return val;
|
|
1293
|
+
}
|
|
1294
|
+
async slice(startOffsset, endOffset) {
|
|
1295
|
+
const bigLength = endOffset - startOffsset;
|
|
1296
|
+
if (bigLength > Number.MAX_SAFE_INTEGER) {
|
|
1297
|
+
throw new Error("too big slice");
|
|
1298
|
+
}
|
|
1299
|
+
const length4 = Number(bigLength);
|
|
1300
|
+
return (await this.fileDescriptor.read(Buffer.alloc(length4), 0, length4, startOffsset)).buffer.buffer;
|
|
1301
|
+
}
|
|
1302
|
+
get length() {
|
|
1303
|
+
return this.size;
|
|
1304
|
+
}
|
|
1305
|
+
};
|
|
1306
|
+
}
|
|
1307
|
+
});
|
|
1308
|
+
|
|
1309
|
+
// ../loader-utils/src/lib/file-provider/data-view-file.ts
|
|
1310
|
+
var toNumber, DataViewFile;
|
|
1311
|
+
var init_data_view_file = __esm({
|
|
1312
|
+
"../loader-utils/src/lib/file-provider/data-view-file.ts"() {
|
|
1313
|
+
toNumber = (bigint) => {
|
|
1314
|
+
if (bigint > Number.MAX_SAFE_INTEGER) {
|
|
1315
|
+
throw new Error("Offset is out of bounds");
|
|
1316
|
+
}
|
|
1317
|
+
return Number(bigint);
|
|
1318
|
+
};
|
|
1319
|
+
DataViewFile = class {
|
|
1320
|
+
constructor(file) {
|
|
1321
|
+
this.file = file;
|
|
1322
|
+
}
|
|
1323
|
+
async destroy() {
|
|
1324
|
+
}
|
|
1325
|
+
async getUint8(offset) {
|
|
1326
|
+
return this.file.getUint8(toNumber(offset));
|
|
1327
|
+
}
|
|
1328
|
+
async getUint16(offset) {
|
|
1329
|
+
return this.file.getUint16(toNumber(offset), true);
|
|
1330
|
+
}
|
|
1331
|
+
async getUint32(offset) {
|
|
1332
|
+
return this.file.getUint32(toNumber(offset), true);
|
|
1333
|
+
}
|
|
1334
|
+
async getBigUint64(offset) {
|
|
1335
|
+
return this.file.getBigUint64(toNumber(offset), true);
|
|
1336
|
+
}
|
|
1337
|
+
async slice(startOffset, endOffset) {
|
|
1338
|
+
return this.file.buffer.slice(toNumber(startOffset), toNumber(endOffset));
|
|
1339
|
+
}
|
|
1340
|
+
get length() {
|
|
1341
|
+
return BigInt(this.file.byteLength);
|
|
1342
|
+
}
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1345
|
+
});
|
|
1346
|
+
|
|
1199
1347
|
// ../loader-utils/src/index.ts
|
|
1200
1348
|
var init_src2 = __esm({
|
|
1201
1349
|
"../loader-utils/src/index.ts"() {
|
|
@@ -1212,6 +1360,9 @@
|
|
|
1212
1360
|
init_memory_conversion_utils();
|
|
1213
1361
|
init_promisify();
|
|
1214
1362
|
init_path();
|
|
1363
|
+
init_file_provider();
|
|
1364
|
+
init_file_handle_file();
|
|
1365
|
+
init_data_view_file();
|
|
1215
1366
|
}
|
|
1216
1367
|
});
|
|
1217
1368
|
|
|
@@ -5775,7 +5926,7 @@
|
|
|
5775
5926
|
for (const key of propNames) {
|
|
5776
5927
|
const value = object[key];
|
|
5777
5928
|
if (typeof value === "function") {
|
|
5778
|
-
if (!predefined.find((
|
|
5929
|
+
if (!predefined.find((name12) => key === name12)) {
|
|
5779
5930
|
object[key] = value.bind(obj);
|
|
5780
5931
|
}
|
|
5781
5932
|
}
|
|
@@ -6971,7 +7122,6 @@
|
|
|
6971
7122
|
"../core/src/index.ts"() {
|
|
6972
7123
|
init_fetch_file();
|
|
6973
7124
|
init_load();
|
|
6974
|
-
init_src2();
|
|
6975
7125
|
}
|
|
6976
7126
|
});
|
|
6977
7127
|
|
|
@@ -7153,11 +7303,11 @@
|
|
|
7153
7303
|
});
|
|
7154
7304
|
|
|
7155
7305
|
// ../schema/src/lib/mesh/deduce-mesh-schema.ts
|
|
7156
|
-
function deduceMeshField(
|
|
7306
|
+
function deduceMeshField(name12, attribute, optionalMetadata) {
|
|
7157
7307
|
const type = getDataTypeFromTypedArray(attribute.value);
|
|
7158
7308
|
const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
|
|
7159
7309
|
return {
|
|
7160
|
-
name:
|
|
7310
|
+
name: name12,
|
|
7161
7311
|
type: { type: "fixed-size-list", listSize: attribute.size, children: [{ name: "value", type }] },
|
|
7162
7312
|
nullable: false,
|
|
7163
7313
|
metadata
|
|
@@ -7733,8 +7883,8 @@
|
|
|
7733
7883
|
}
|
|
7734
7884
|
throw new Error(ERR_TYPE_CONVERSION);
|
|
7735
7885
|
}
|
|
7736
|
-
static fromName(
|
|
7737
|
-
const glType = NAME_TO_GL_TYPE[
|
|
7886
|
+
static fromName(name12) {
|
|
7887
|
+
const glType = NAME_TO_GL_TYPE[name12];
|
|
7738
7888
|
if (!glType) {
|
|
7739
7889
|
throw new Error(ERR_TYPE_CONVERSION);
|
|
7740
7890
|
}
|
|
@@ -7837,6 +7987,15 @@
|
|
|
7837
7987
|
}
|
|
7838
7988
|
});
|
|
7839
7989
|
|
|
7990
|
+
// ../math/src/geometry/utils/coordinates.ts
|
|
7991
|
+
function emod(n2) {
|
|
7992
|
+
return (n2 % 1 + 1) % 1;
|
|
7993
|
+
}
|
|
7994
|
+
var init_coordinates = __esm({
|
|
7995
|
+
"../math/src/geometry/utils/coordinates.ts"() {
|
|
7996
|
+
}
|
|
7997
|
+
});
|
|
7998
|
+
|
|
7840
7999
|
// ../math/src/index.ts
|
|
7841
8000
|
var init_src7 = __esm({
|
|
7842
8001
|
"../math/src/index.ts"() {
|
|
@@ -7844,6 +8003,7 @@
|
|
|
7844
8003
|
init_gl_type();
|
|
7845
8004
|
init_rgb565();
|
|
7846
8005
|
init_attribute_compression();
|
|
8006
|
+
init_coordinates();
|
|
7847
8007
|
}
|
|
7848
8008
|
});
|
|
7849
8009
|
|
|
@@ -8293,10 +8453,10 @@
|
|
|
8293
8453
|
}
|
|
8294
8454
|
return void 0;
|
|
8295
8455
|
}
|
|
8296
|
-
hasProperty(batchId,
|
|
8456
|
+
hasProperty(batchId, name12) {
|
|
8297
8457
|
this._checkBatchId(batchId);
|
|
8298
|
-
assert2(typeof
|
|
8299
|
-
return defined2(this._properties[
|
|
8458
|
+
assert2(typeof name12 === "string", name12);
|
|
8459
|
+
return defined2(this._properties[name12]) || this._hasPropertyInHierarchy(batchId, name12);
|
|
8300
8460
|
}
|
|
8301
8461
|
getPropertyNames(batchId, results) {
|
|
8302
8462
|
this._checkBatchId(batchId);
|
|
@@ -8309,47 +8469,47 @@
|
|
|
8309
8469
|
}
|
|
8310
8470
|
return results;
|
|
8311
8471
|
}
|
|
8312
|
-
getProperty(batchId,
|
|
8472
|
+
getProperty(batchId, name12) {
|
|
8313
8473
|
this._checkBatchId(batchId);
|
|
8314
|
-
assert2(typeof
|
|
8474
|
+
assert2(typeof name12 === "string", name12);
|
|
8315
8475
|
if (this._binaryProperties) {
|
|
8316
|
-
const binaryProperty = this._binaryProperties[
|
|
8476
|
+
const binaryProperty = this._binaryProperties[name12];
|
|
8317
8477
|
if (defined2(binaryProperty)) {
|
|
8318
8478
|
return this._getBinaryProperty(binaryProperty, batchId);
|
|
8319
8479
|
}
|
|
8320
8480
|
}
|
|
8321
|
-
const propertyValues = this._properties[
|
|
8481
|
+
const propertyValues = this._properties[name12];
|
|
8322
8482
|
if (defined2(propertyValues)) {
|
|
8323
8483
|
return clone3(propertyValues[batchId], true);
|
|
8324
8484
|
}
|
|
8325
8485
|
if (this._hierarchy) {
|
|
8326
|
-
const hierarchyProperty = this._getHierarchyProperty(batchId,
|
|
8486
|
+
const hierarchyProperty = this._getHierarchyProperty(batchId, name12);
|
|
8327
8487
|
if (defined2(hierarchyProperty)) {
|
|
8328
8488
|
return hierarchyProperty;
|
|
8329
8489
|
}
|
|
8330
8490
|
}
|
|
8331
8491
|
return void 0;
|
|
8332
8492
|
}
|
|
8333
|
-
setProperty(batchId,
|
|
8493
|
+
setProperty(batchId, name12, value) {
|
|
8334
8494
|
const featureCount = this.featureCount;
|
|
8335
8495
|
this._checkBatchId(batchId);
|
|
8336
|
-
assert2(typeof
|
|
8496
|
+
assert2(typeof name12 === "string", name12);
|
|
8337
8497
|
if (this._binaryProperties) {
|
|
8338
|
-
const binaryProperty = this._binaryProperties[
|
|
8498
|
+
const binaryProperty = this._binaryProperties[name12];
|
|
8339
8499
|
if (binaryProperty) {
|
|
8340
8500
|
this._setBinaryProperty(binaryProperty, batchId, value);
|
|
8341
8501
|
return;
|
|
8342
8502
|
}
|
|
8343
8503
|
}
|
|
8344
8504
|
if (this._hierarchy) {
|
|
8345
|
-
if (this._setHierarchyProperty(this, batchId,
|
|
8505
|
+
if (this._setHierarchyProperty(this, batchId, name12, value)) {
|
|
8346
8506
|
return;
|
|
8347
8507
|
}
|
|
8348
8508
|
}
|
|
8349
|
-
let propertyValues = this._properties[
|
|
8509
|
+
let propertyValues = this._properties[name12];
|
|
8350
8510
|
if (!defined2(propertyValues)) {
|
|
8351
|
-
this._properties[
|
|
8352
|
-
propertyValues = this._properties[
|
|
8511
|
+
this._properties[name12] = new Array(featureCount);
|
|
8512
|
+
propertyValues = this._properties[name12];
|
|
8353
8513
|
}
|
|
8354
8514
|
propertyValues[batchId] = clone3(value, true);
|
|
8355
8515
|
}
|
|
@@ -8367,21 +8527,21 @@
|
|
|
8367
8527
|
}
|
|
8368
8528
|
_initializeBinaryProperties() {
|
|
8369
8529
|
let binaryProperties = null;
|
|
8370
|
-
for (const
|
|
8371
|
-
const property = this._properties[
|
|
8372
|
-
const binaryProperty = this._initializeBinaryProperty(
|
|
8530
|
+
for (const name12 in this._properties) {
|
|
8531
|
+
const property = this._properties[name12];
|
|
8532
|
+
const binaryProperty = this._initializeBinaryProperty(name12, property);
|
|
8373
8533
|
if (binaryProperty) {
|
|
8374
8534
|
binaryProperties = binaryProperties || {};
|
|
8375
|
-
binaryProperties[
|
|
8535
|
+
binaryProperties[name12] = binaryProperty;
|
|
8376
8536
|
}
|
|
8377
8537
|
}
|
|
8378
8538
|
return binaryProperties;
|
|
8379
8539
|
}
|
|
8380
|
-
_initializeBinaryProperty(
|
|
8540
|
+
_initializeBinaryProperty(name12, property) {
|
|
8381
8541
|
if ("byteOffset" in property) {
|
|
8382
8542
|
const tile3DAccessor = property;
|
|
8383
|
-
assert2(this.binary, `Property ${
|
|
8384
|
-
assert2(tile3DAccessor.type, `Property ${
|
|
8543
|
+
assert2(this.binary, `Property ${name12} requires a batch table binary.`);
|
|
8544
|
+
assert2(tile3DAccessor.type, `Property ${name12} requires a type.`);
|
|
8385
8545
|
const accessor = createTypedArrayFromAccessor(tile3DAccessor, this.binary.buffer, this.binary.byteOffset | 0, this.featureCount);
|
|
8386
8546
|
return {
|
|
8387
8547
|
typedArray: accessor.values,
|
|
@@ -8392,14 +8552,14 @@
|
|
|
8392
8552
|
}
|
|
8393
8553
|
return null;
|
|
8394
8554
|
}
|
|
8395
|
-
_hasPropertyInHierarchy(batchId,
|
|
8555
|
+
_hasPropertyInHierarchy(batchId, name12) {
|
|
8396
8556
|
if (!this._hierarchy) {
|
|
8397
8557
|
return false;
|
|
8398
8558
|
}
|
|
8399
8559
|
const result = traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
|
|
8400
8560
|
const classId = hierarchy.classIds[instanceIndex];
|
|
8401
8561
|
const instances = hierarchy.classes[classId].instances;
|
|
8402
|
-
return defined2(instances[
|
|
8562
|
+
return defined2(instances[name12]);
|
|
8403
8563
|
});
|
|
8404
8564
|
return defined2(result);
|
|
8405
8565
|
}
|
|
@@ -8407,21 +8567,21 @@
|
|
|
8407
8567
|
traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
|
|
8408
8568
|
const classId = hierarchy.classIds[instanceIndex];
|
|
8409
8569
|
const instances = hierarchy.classes[classId].instances;
|
|
8410
|
-
for (const
|
|
8411
|
-
if (instances.hasOwnProperty(
|
|
8412
|
-
if (results.indexOf(
|
|
8413
|
-
results.push(
|
|
8570
|
+
for (const name12 in instances) {
|
|
8571
|
+
if (instances.hasOwnProperty(name12)) {
|
|
8572
|
+
if (results.indexOf(name12) === -1) {
|
|
8573
|
+
results.push(name12);
|
|
8414
8574
|
}
|
|
8415
8575
|
}
|
|
8416
8576
|
}
|
|
8417
8577
|
});
|
|
8418
8578
|
}
|
|
8419
|
-
_getHierarchyProperty(batchId,
|
|
8579
|
+
_getHierarchyProperty(batchId, name12) {
|
|
8420
8580
|
return traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
|
|
8421
8581
|
const classId = hierarchy.classIds[instanceIndex];
|
|
8422
8582
|
const instanceClass = hierarchy.classes[classId];
|
|
8423
8583
|
const indexInClass = hierarchy.classIndexes[instanceIndex];
|
|
8424
|
-
const propertyValues = instanceClass.instances[
|
|
8584
|
+
const propertyValues = instanceClass.instances[name12];
|
|
8425
8585
|
if (defined2(propertyValues)) {
|
|
8426
8586
|
if (defined2(propertyValues.typedArray)) {
|
|
8427
8587
|
return this._getBinaryProperty(propertyValues, indexInClass);
|
|
@@ -8431,14 +8591,14 @@
|
|
|
8431
8591
|
return null;
|
|
8432
8592
|
});
|
|
8433
8593
|
}
|
|
8434
|
-
_setHierarchyProperty(batchTable, batchId,
|
|
8594
|
+
_setHierarchyProperty(batchTable, batchId, name12, value) {
|
|
8435
8595
|
const result = traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
|
|
8436
8596
|
const classId = hierarchy.classIds[instanceIndex];
|
|
8437
8597
|
const instanceClass = hierarchy.classes[classId];
|
|
8438
8598
|
const indexInClass = hierarchy.classIndexes[instanceIndex];
|
|
8439
|
-
const propertyValues = instanceClass.instances[
|
|
8599
|
+
const propertyValues = instanceClass.instances[name12];
|
|
8440
8600
|
if (defined2(propertyValues)) {
|
|
8441
|
-
assert2(instanceIndex === batchId, `Inherited property "${
|
|
8601
|
+
assert2(instanceIndex === batchId, `Inherited property "${name12}" is read-only.`);
|
|
8442
8602
|
if (defined2(propertyValues.typedArray)) {
|
|
8443
8603
|
this._setBinaryProperty(propertyValues, indexInClass, value);
|
|
8444
8604
|
} else {
|
|
@@ -8899,19 +9059,11 @@
|
|
|
8899
9059
|
}
|
|
8900
9060
|
});
|
|
8901
9061
|
|
|
8902
|
-
// ../
|
|
9062
|
+
// ../images/src/lib/utils/version.ts
|
|
8903
9063
|
var VERSION6;
|
|
8904
9064
|
var init_version4 = __esm({
|
|
8905
|
-
"../gltf/src/lib/utils/version.ts"() {
|
|
8906
|
-
VERSION6 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
8907
|
-
}
|
|
8908
|
-
});
|
|
8909
|
-
|
|
8910
|
-
// ../images/src/lib/utils/version.ts
|
|
8911
|
-
var VERSION7;
|
|
8912
|
-
var init_version5 = __esm({
|
|
8913
9065
|
"../images/src/lib/utils/version.ts"() {
|
|
8914
|
-
|
|
9066
|
+
VERSION6 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
8915
9067
|
}
|
|
8916
9068
|
});
|
|
8917
9069
|
|
|
@@ -9336,7 +9488,7 @@
|
|
|
9336
9488
|
var EXTENSIONS, MIME_TYPES, DEFAULT_IMAGE_LOADER_OPTIONS, ImageLoader;
|
|
9337
9489
|
var init_image_loader = __esm({
|
|
9338
9490
|
"../images/src/image-loader.ts"() {
|
|
9339
|
-
|
|
9491
|
+
init_version4();
|
|
9340
9492
|
init_parse_image();
|
|
9341
9493
|
init_binary_image_api();
|
|
9342
9494
|
EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "svg", "avif"];
|
|
@@ -9360,7 +9512,7 @@
|
|
|
9360
9512
|
id: "image",
|
|
9361
9513
|
module: "images",
|
|
9362
9514
|
name: "Images",
|
|
9363
|
-
version:
|
|
9515
|
+
version: VERSION6,
|
|
9364
9516
|
mimeTypes: MIME_TYPES,
|
|
9365
9517
|
extensions: EXTENSIONS,
|
|
9366
9518
|
parse: parseImage,
|
|
@@ -9419,901 +9571,282 @@
|
|
|
9419
9571
|
}
|
|
9420
9572
|
});
|
|
9421
9573
|
|
|
9422
|
-
// ../
|
|
9423
|
-
|
|
9424
|
-
|
|
9425
|
-
|
|
9426
|
-
VERSION8 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
|
|
9427
|
-
}
|
|
9428
|
-
});
|
|
9429
|
-
|
|
9430
|
-
// ../textures/src/lib/parsers/basis-module-loader.ts
|
|
9431
|
-
async function loadBasisTranscoderModule(options) {
|
|
9432
|
-
const modules = options.modules || {};
|
|
9433
|
-
if (modules.basis) {
|
|
9434
|
-
return modules.basis;
|
|
9574
|
+
// ../gltf/src/lib/utils/assert.ts
|
|
9575
|
+
function assert7(condition, message) {
|
|
9576
|
+
if (!condition) {
|
|
9577
|
+
throw new Error(message || "assert failed: gltf");
|
|
9435
9578
|
}
|
|
9436
|
-
loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTranscoder(options);
|
|
9437
|
-
return await loadBasisTranscoderPromise;
|
|
9438
|
-
}
|
|
9439
|
-
async function loadBasisTranscoder(options) {
|
|
9440
|
-
let BASIS = null;
|
|
9441
|
-
let wasmBinary = null;
|
|
9442
|
-
[BASIS, wasmBinary] = await Promise.all([
|
|
9443
|
-
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, "textures", options),
|
|
9444
|
-
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, "textures", options)
|
|
9445
|
-
]);
|
|
9446
|
-
BASIS = BASIS || globalThis.BASIS;
|
|
9447
|
-
return await initializeBasisTranscoderModule(BASIS, wasmBinary);
|
|
9448
9579
|
}
|
|
9449
|
-
|
|
9450
|
-
|
|
9451
|
-
if (wasmBinary) {
|
|
9452
|
-
options.wasmBinary = wasmBinary;
|
|
9580
|
+
var init_assert6 = __esm({
|
|
9581
|
+
"../gltf/src/lib/utils/assert.ts"() {
|
|
9453
9582
|
}
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
|
|
9458
|
-
|
|
9459
|
-
|
|
9460
|
-
});
|
|
9583
|
+
});
|
|
9584
|
+
|
|
9585
|
+
// ../gltf/src/lib/gltf-utils/gltf-utils.ts
|
|
9586
|
+
function getAccessorTypeFromSize(size) {
|
|
9587
|
+
const type = TYPES[size - 1];
|
|
9588
|
+
return type || TYPES[0];
|
|
9461
9589
|
}
|
|
9462
|
-
|
|
9463
|
-
const
|
|
9464
|
-
if (
|
|
9465
|
-
|
|
9590
|
+
function getComponentTypeFromArray(typedArray) {
|
|
9591
|
+
const componentType = ARRAY_TO_COMPONENT_TYPE.get(typedArray.constructor);
|
|
9592
|
+
if (!componentType) {
|
|
9593
|
+
throw new Error("Illegal typed array");
|
|
9466
9594
|
}
|
|
9467
|
-
|
|
9468
|
-
return await loadBasisEncoderPromise;
|
|
9595
|
+
return componentType;
|
|
9469
9596
|
}
|
|
9470
|
-
|
|
9471
|
-
|
|
9472
|
-
|
|
9473
|
-
|
|
9474
|
-
|
|
9475
|
-
|
|
9476
|
-
|
|
9477
|
-
|
|
9478
|
-
return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
|
|
9597
|
+
function getAccessorArrayTypeAndLength(accessor, bufferView) {
|
|
9598
|
+
const ArrayType = ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY[accessor.componentType];
|
|
9599
|
+
const components = ATTRIBUTE_TYPE_TO_COMPONENTS[accessor.type];
|
|
9600
|
+
const bytesPerComponent = ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE[accessor.componentType];
|
|
9601
|
+
const length4 = accessor.count * components;
|
|
9602
|
+
const byteLength = accessor.count * components * bytesPerComponent;
|
|
9603
|
+
assert7(byteLength >= 0 && byteLength <= bufferView.byteLength);
|
|
9604
|
+
return { ArrayType, length: length4, byteLength };
|
|
9479
9605
|
}
|
|
9480
|
-
function
|
|
9481
|
-
|
|
9482
|
-
|
|
9483
|
-
|
|
9484
|
-
|
|
9485
|
-
|
|
9486
|
-
|
|
9487
|
-
|
|
9488
|
-
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
|
|
9606
|
+
function getMemoryUsageGLTF(gltf) {
|
|
9607
|
+
let { images, bufferViews } = gltf;
|
|
9608
|
+
images = images || [];
|
|
9609
|
+
bufferViews = bufferViews || [];
|
|
9610
|
+
const imageBufferViews = images.map((i2) => i2.bufferView);
|
|
9611
|
+
bufferViews = bufferViews.filter((view) => !imageBufferViews.includes(view));
|
|
9612
|
+
const bufferMemory = bufferViews.reduce((acc, view) => acc + view.byteLength, 0);
|
|
9613
|
+
const pixelCount = images.reduce((acc, image) => {
|
|
9614
|
+
const { width, height } = image.image;
|
|
9615
|
+
return acc + width * height;
|
|
9616
|
+
}, 0);
|
|
9617
|
+
return bufferMemory + Math.ceil(4 * pixelCount * MIPMAP_FACTOR);
|
|
9492
9618
|
}
|
|
9493
|
-
var
|
|
9494
|
-
var
|
|
9495
|
-
"../
|
|
9496
|
-
|
|
9497
|
-
|
|
9498
|
-
|
|
9499
|
-
|
|
9500
|
-
|
|
9501
|
-
|
|
9502
|
-
|
|
9503
|
-
|
|
9504
|
-
|
|
9505
|
-
|
|
9506
|
-
|
|
9507
|
-
|
|
9508
|
-
|
|
9509
|
-
|
|
9510
|
-
|
|
9511
|
-
|
|
9512
|
-
|
|
9513
|
-
|
|
9514
|
-
|
|
9515
|
-
|
|
9516
|
-
|
|
9517
|
-
COMPRESSED_RG11_EAC: 37490,
|
|
9518
|
-
COMPRESSED_SIGNED_RG11_EAC: 37491,
|
|
9519
|
-
COMPRESSED_RGB8_ETC2: 37492,
|
|
9520
|
-
COMPRESSED_RGBA8_ETC2_EAC: 37493,
|
|
9521
|
-
COMPRESSED_SRGB8_ETC2: 37494,
|
|
9522
|
-
COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
|
|
9523
|
-
COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
|
|
9524
|
-
COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
|
|
9525
|
-
COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
|
|
9526
|
-
COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
|
|
9527
|
-
COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
|
|
9528
|
-
COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
|
|
9529
|
-
COMPRESSED_RGB_ETC1_WEBGL: 36196,
|
|
9530
|
-
COMPRESSED_RGB_ATC_WEBGL: 35986,
|
|
9531
|
-
COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
|
|
9532
|
-
COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
|
|
9533
|
-
COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
|
|
9534
|
-
COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
|
|
9535
|
-
COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
|
|
9536
|
-
COMPRESSED_RGBA_ASTC_6X5_KHR: 37811,
|
|
9537
|
-
COMPRESSED_RGBA_ASTC_6X6_KHR: 37812,
|
|
9538
|
-
COMPRESSED_RGBA_ASTC_8X5_KHR: 37813,
|
|
9539
|
-
COMPRESSED_RGBA_ASTC_8X6_KHR: 37814,
|
|
9540
|
-
COMPRESSED_RGBA_ASTC_8X8_KHR: 37815,
|
|
9541
|
-
COMPRESSED_RGBA_ASTC_10X5_KHR: 37816,
|
|
9542
|
-
COMPRESSED_RGBA_ASTC_10X6_KHR: 37817,
|
|
9543
|
-
COMPRESSED_RGBA_ASTC_10X8_KHR: 37818,
|
|
9544
|
-
COMPRESSED_RGBA_ASTC_10X10_KHR: 37819,
|
|
9545
|
-
COMPRESSED_RGBA_ASTC_12X10_KHR: 37820,
|
|
9546
|
-
COMPRESSED_RGBA_ASTC_12X12_KHR: 37821,
|
|
9547
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: 37840,
|
|
9548
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: 37841,
|
|
9549
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: 37842,
|
|
9550
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: 37843,
|
|
9551
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: 37844,
|
|
9552
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: 37845,
|
|
9553
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: 37846,
|
|
9554
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: 37847,
|
|
9555
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: 37848,
|
|
9556
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: 37849,
|
|
9557
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: 37850,
|
|
9558
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
|
|
9559
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
|
|
9560
|
-
COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
|
|
9561
|
-
COMPRESSED_RED_RGTC1_EXT: 36283,
|
|
9562
|
-
COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
|
|
9563
|
-
COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
|
|
9564
|
-
COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
|
|
9565
|
-
COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
|
|
9566
|
-
COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
|
|
9567
|
-
COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
|
|
9568
|
-
COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: 35919
|
|
9619
|
+
var MIPMAP_FACTOR, TYPES, ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT, ARRAY_TO_COMPONENT_TYPE, ATTRIBUTE_TYPE_TO_COMPONENTS, ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE, ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY;
|
|
9620
|
+
var init_gltf_utils = __esm({
|
|
9621
|
+
"../gltf/src/lib/gltf-utils/gltf-utils.ts"() {
|
|
9622
|
+
init_assert6();
|
|
9623
|
+
MIPMAP_FACTOR = 1.33;
|
|
9624
|
+
TYPES = ["SCALAR", "VEC2", "VEC3", "VEC4"];
|
|
9625
|
+
ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT = [
|
|
9626
|
+
[Int8Array, 5120],
|
|
9627
|
+
[Uint8Array, 5121],
|
|
9628
|
+
[Int16Array, 5122],
|
|
9629
|
+
[Uint16Array, 5123],
|
|
9630
|
+
[Uint32Array, 5125],
|
|
9631
|
+
[Float32Array, 5126],
|
|
9632
|
+
[Float64Array, 5130]
|
|
9633
|
+
];
|
|
9634
|
+
ARRAY_TO_COMPONENT_TYPE = new Map(ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT);
|
|
9635
|
+
ATTRIBUTE_TYPE_TO_COMPONENTS = {
|
|
9636
|
+
SCALAR: 1,
|
|
9637
|
+
VEC2: 2,
|
|
9638
|
+
VEC3: 3,
|
|
9639
|
+
VEC4: 4,
|
|
9640
|
+
MAT2: 4,
|
|
9641
|
+
MAT3: 9,
|
|
9642
|
+
MAT4: 16
|
|
9569
9643
|
};
|
|
9570
|
-
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
|
|
9575
|
-
|
|
9576
|
-
|
|
9577
|
-
|
|
9578
|
-
|
|
9579
|
-
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
}
|
|
9586
|
-
}
|
|
9587
|
-
return formats;
|
|
9588
|
-
}
|
|
9589
|
-
function getWebGLContext() {
|
|
9590
|
-
try {
|
|
9591
|
-
const canvas = document.createElement("canvas");
|
|
9592
|
-
return canvas.getContext("webgl");
|
|
9593
|
-
} catch (error) {
|
|
9594
|
-
return null;
|
|
9595
|
-
}
|
|
9596
|
-
}
|
|
9597
|
-
var BROWSER_PREFIXES, WEBGL_EXTENSIONS, formats;
|
|
9598
|
-
var init_texture_formats = __esm({
|
|
9599
|
-
"../textures/src/lib/utils/texture-formats.ts"() {
|
|
9600
|
-
BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
|
|
9601
|
-
WEBGL_EXTENSIONS = {
|
|
9602
|
-
WEBGL_compressed_texture_s3tc: "dxt",
|
|
9603
|
-
WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb",
|
|
9604
|
-
WEBGL_compressed_texture_etc1: "etc1",
|
|
9605
|
-
WEBGL_compressed_texture_etc: "etc2",
|
|
9606
|
-
WEBGL_compressed_texture_pvrtc: "pvrtc",
|
|
9607
|
-
WEBGL_compressed_texture_atc: "atc",
|
|
9608
|
-
WEBGL_compressed_texture_astc: "astc",
|
|
9609
|
-
EXT_texture_compression_rgtc: "rgtc"
|
|
9644
|
+
ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE = {
|
|
9645
|
+
5120: 1,
|
|
9646
|
+
5121: 1,
|
|
9647
|
+
5122: 2,
|
|
9648
|
+
5123: 2,
|
|
9649
|
+
5125: 4,
|
|
9650
|
+
5126: 4
|
|
9651
|
+
};
|
|
9652
|
+
ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY = {
|
|
9653
|
+
5120: Int8Array,
|
|
9654
|
+
5121: Uint8Array,
|
|
9655
|
+
5122: Int16Array,
|
|
9656
|
+
5123: Uint16Array,
|
|
9657
|
+
5125: Uint32Array,
|
|
9658
|
+
5126: Float32Array
|
|
9610
9659
|
};
|
|
9611
|
-
formats = null;
|
|
9612
|
-
}
|
|
9613
|
-
});
|
|
9614
|
-
|
|
9615
|
-
// ../../node_modules/ktx-parse/dist/ktx-parse.modern.js
|
|
9616
|
-
var t, n, i, s, a, r, o, l, f;
|
|
9617
|
-
var init_ktx_parse_modern = __esm({
|
|
9618
|
-
"../../node_modules/ktx-parse/dist/ktx-parse.modern.js"() {
|
|
9619
|
-
t = new Uint8Array([0]);
|
|
9620
|
-
!function(t2) {
|
|
9621
|
-
t2[t2.NONE = 0] = "NONE", t2[t2.BASISLZ = 1] = "BASISLZ", t2[t2.ZSTD = 2] = "ZSTD", t2[t2.ZLIB = 3] = "ZLIB";
|
|
9622
|
-
}(n || (n = {})), function(t2) {
|
|
9623
|
-
t2[t2.BASICFORMAT = 0] = "BASICFORMAT";
|
|
9624
|
-
}(i || (i = {})), function(t2) {
|
|
9625
|
-
t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.ETC1S = 163] = "ETC1S", t2[t2.UASTC = 166] = "UASTC";
|
|
9626
|
-
}(s || (s = {})), function(t2) {
|
|
9627
|
-
t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.SRGB = 1] = "SRGB";
|
|
9628
|
-
}(a || (a = {})), function(t2) {
|
|
9629
|
-
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";
|
|
9630
|
-
}(r || (r = {})), function(t2) {
|
|
9631
|
-
t2[t2.ALPHA_STRAIGHT = 0] = "ALPHA_STRAIGHT", t2[t2.ALPHA_PREMULTIPLIED = 1] = "ALPHA_PREMULTIPLIED";
|
|
9632
|
-
}(o || (o = {})), function(t2) {
|
|
9633
|
-
t2[t2.RGB = 0] = "RGB", t2[t2.RRR = 3] = "RRR", t2[t2.GGG = 4] = "GGG", t2[t2.AAA = 15] = "AAA";
|
|
9634
|
-
}(l || (l = {})), function(t2) {
|
|
9635
|
-
t2[t2.RGB = 0] = "RGB", t2[t2.RGBA = 3] = "RGBA", t2[t2.RRR = 4] = "RRR", t2[t2.RRRG = 5] = "RRRG";
|
|
9636
|
-
}(f || (f = {}));
|
|
9637
9660
|
}
|
|
9638
9661
|
});
|
|
9639
9662
|
|
|
9640
|
-
// ../
|
|
9641
|
-
function
|
|
9642
|
-
|
|
9643
|
-
|
|
9644
|
-
|
|
9663
|
+
// ../gltf/src/lib/api/gltf-scenegraph.ts
|
|
9664
|
+
function makeDefaultGLTFJson() {
|
|
9665
|
+
return {
|
|
9666
|
+
asset: {
|
|
9667
|
+
version: "2.0",
|
|
9668
|
+
generator: "loaders.gl"
|
|
9669
|
+
},
|
|
9670
|
+
buffers: [],
|
|
9671
|
+
extensions: {},
|
|
9672
|
+
extensionsRequired: [],
|
|
9673
|
+
extensionsUsed: []
|
|
9674
|
+
};
|
|
9645
9675
|
}
|
|
9646
|
-
var
|
|
9647
|
-
var
|
|
9648
|
-
"../
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
|
|
9653
|
-
|
|
9654
|
-
|
|
9655
|
-
|
|
9656
|
-
|
|
9657
|
-
|
|
9658
|
-
|
|
9659
|
-
|
|
9660
|
-
|
|
9661
|
-
|
|
9662
|
-
|
|
9663
|
-
|
|
9664
|
-
|
|
9665
|
-
|
|
9666
|
-
|
|
9667
|
-
// ../textures/src/lib/parsers/parse-basis.ts
|
|
9668
|
-
async function parseBasis(data, options) {
|
|
9669
|
-
if (options.basis.containerFormat === "auto") {
|
|
9670
|
-
if (isKTX(data)) {
|
|
9671
|
-
const fileConstructors = await loadBasisEncoderModule(options);
|
|
9672
|
-
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
9673
|
-
}
|
|
9674
|
-
const { BasisFile } = await loadBasisTranscoderModule(options);
|
|
9675
|
-
return parseBasisFile(BasisFile, data, options);
|
|
9676
|
-
}
|
|
9677
|
-
switch (options.basis.module) {
|
|
9678
|
-
case "encoder":
|
|
9679
|
-
const fileConstructors = await loadBasisEncoderModule(options);
|
|
9680
|
-
switch (options.basis.containerFormat) {
|
|
9681
|
-
case "ktx2":
|
|
9682
|
-
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
9683
|
-
case "basis":
|
|
9684
|
-
default:
|
|
9685
|
-
return parseBasisFile(fileConstructors.BasisFile, data, options);
|
|
9676
|
+
var GLTFScenegraph;
|
|
9677
|
+
var init_gltf_scenegraph = __esm({
|
|
9678
|
+
"../gltf/src/lib/api/gltf-scenegraph.ts"() {
|
|
9679
|
+
init_src8();
|
|
9680
|
+
init_src2();
|
|
9681
|
+
init_assert6();
|
|
9682
|
+
init_gltf_utils();
|
|
9683
|
+
GLTFScenegraph = class {
|
|
9684
|
+
constructor(gltf) {
|
|
9685
|
+
this.gltf = {
|
|
9686
|
+
json: gltf?.json || makeDefaultGLTFJson(),
|
|
9687
|
+
buffers: gltf?.buffers || [],
|
|
9688
|
+
images: gltf?.images || []
|
|
9689
|
+
};
|
|
9690
|
+
this.sourceBuffers = [];
|
|
9691
|
+
this.byteLength = 0;
|
|
9692
|
+
if (this.gltf.buffers && this.gltf.buffers[0]) {
|
|
9693
|
+
this.byteLength = this.gltf.buffers[0].byteLength;
|
|
9694
|
+
this.sourceBuffers = [this.gltf.buffers[0]];
|
|
9695
|
+
}
|
|
9686
9696
|
}
|
|
9687
|
-
|
|
9688
|
-
|
|
9689
|
-
const { BasisFile } = await loadBasisTranscoderModule(options);
|
|
9690
|
-
return parseBasisFile(BasisFile, data, options);
|
|
9691
|
-
}
|
|
9692
|
-
}
|
|
9693
|
-
function parseBasisFile(BasisFile, data, options) {
|
|
9694
|
-
const basisFile = new BasisFile(new Uint8Array(data));
|
|
9695
|
-
try {
|
|
9696
|
-
if (!basisFile.startTranscoding()) {
|
|
9697
|
-
throw new Error("Failed to start basis transcoding");
|
|
9698
|
-
}
|
|
9699
|
-
const imageCount = basisFile.getNumImages();
|
|
9700
|
-
const images = [];
|
|
9701
|
-
for (let imageIndex = 0; imageIndex < imageCount; imageIndex++) {
|
|
9702
|
-
const levelsCount = basisFile.getNumLevels(imageIndex);
|
|
9703
|
-
const levels = [];
|
|
9704
|
-
for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
|
|
9705
|
-
levels.push(transcodeImage(basisFile, imageIndex, levelIndex, options));
|
|
9697
|
+
get json() {
|
|
9698
|
+
return this.gltf.json;
|
|
9706
9699
|
}
|
|
9707
|
-
|
|
9708
|
-
|
|
9709
|
-
|
|
9710
|
-
|
|
9711
|
-
|
|
9712
|
-
|
|
9713
|
-
|
|
9714
|
-
|
|
9715
|
-
|
|
9716
|
-
|
|
9717
|
-
|
|
9718
|
-
|
|
9719
|
-
|
|
9720
|
-
|
|
9721
|
-
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
9725
|
-
|
|
9726
|
-
|
|
9727
|
-
|
|
9728
|
-
|
|
9729
|
-
|
|
9730
|
-
|
|
9731
|
-
|
|
9732
|
-
|
|
9733
|
-
|
|
9734
|
-
|
|
9735
|
-
|
|
9736
|
-
|
|
9737
|
-
|
|
9738
|
-
|
|
9739
|
-
|
|
9740
|
-
|
|
9741
|
-
|
|
9742
|
-
|
|
9743
|
-
|
|
9744
|
-
|
|
9745
|
-
|
|
9746
|
-
|
|
9747
|
-
|
|
9748
|
-
|
|
9749
|
-
|
|
9750
|
-
|
|
9751
|
-
|
|
9752
|
-
|
|
9753
|
-
|
|
9754
|
-
|
|
9755
|
-
|
|
9756
|
-
|
|
9757
|
-
|
|
9758
|
-
|
|
9759
|
-
|
|
9760
|
-
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
-
|
|
9766
|
-
|
|
9767
|
-
|
|
9768
|
-
|
|
9769
|
-
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
|
|
9773
|
-
|
|
9774
|
-
|
|
9775
|
-
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
|
|
9779
|
-
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
const supportedFormats = getSupportedGPUTextureFormats();
|
|
9783
|
-
if (supportedFormats.has("astc")) {
|
|
9784
|
-
return "astc-4x4";
|
|
9785
|
-
} else if (supportedFormats.has("dxt")) {
|
|
9786
|
-
return {
|
|
9787
|
-
alpha: "bc3",
|
|
9788
|
-
noAlpha: "bc1"
|
|
9789
|
-
};
|
|
9790
|
-
} else if (supportedFormats.has("pvrtc")) {
|
|
9791
|
-
return {
|
|
9792
|
-
alpha: "pvrtc1-4-rgba",
|
|
9793
|
-
noAlpha: "pvrtc1-4-rgb"
|
|
9794
|
-
};
|
|
9795
|
-
} else if (supportedFormats.has("etc1")) {
|
|
9796
|
-
return "etc1";
|
|
9797
|
-
} else if (supportedFormats.has("etc2")) {
|
|
9798
|
-
return "etc2";
|
|
9799
|
-
}
|
|
9800
|
-
return "rgb565";
|
|
9801
|
-
}
|
|
9802
|
-
var OutputFormat;
|
|
9803
|
-
var init_parse_basis = __esm({
|
|
9804
|
-
"../textures/src/lib/parsers/parse-basis.ts"() {
|
|
9805
|
-
init_basis_module_loader();
|
|
9806
|
-
init_gl_extensions();
|
|
9807
|
-
init_texture_formats();
|
|
9808
|
-
init_parse_ktx();
|
|
9809
|
-
OutputFormat = {
|
|
9810
|
-
etc1: {
|
|
9811
|
-
basisFormat: 0,
|
|
9812
|
-
compressed: true,
|
|
9813
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL
|
|
9814
|
-
},
|
|
9815
|
-
etc2: { basisFormat: 1, compressed: true },
|
|
9816
|
-
bc1: {
|
|
9817
|
-
basisFormat: 2,
|
|
9818
|
-
compressed: true,
|
|
9819
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT
|
|
9820
|
-
},
|
|
9821
|
-
bc3: {
|
|
9822
|
-
basisFormat: 3,
|
|
9823
|
-
compressed: true,
|
|
9824
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT
|
|
9825
|
-
},
|
|
9826
|
-
bc4: { basisFormat: 4, compressed: true },
|
|
9827
|
-
bc5: { basisFormat: 5, compressed: true },
|
|
9828
|
-
"bc7-m6-opaque-only": { basisFormat: 6, compressed: true },
|
|
9829
|
-
"bc7-m5": { basisFormat: 7, compressed: true },
|
|
9830
|
-
"pvrtc1-4-rgb": {
|
|
9831
|
-
basisFormat: 8,
|
|
9832
|
-
compressed: true,
|
|
9833
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG
|
|
9834
|
-
},
|
|
9835
|
-
"pvrtc1-4-rgba": {
|
|
9836
|
-
basisFormat: 9,
|
|
9837
|
-
compressed: true,
|
|
9838
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
|
|
9839
|
-
},
|
|
9840
|
-
"astc-4x4": {
|
|
9841
|
-
basisFormat: 10,
|
|
9842
|
-
compressed: true,
|
|
9843
|
-
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR
|
|
9844
|
-
},
|
|
9845
|
-
"atc-rgb": { basisFormat: 11, compressed: true },
|
|
9846
|
-
"atc-rgba-interpolated-alpha": { basisFormat: 12, compressed: true },
|
|
9847
|
-
rgba32: { basisFormat: 13, compressed: false },
|
|
9848
|
-
rgb565: { basisFormat: 14, compressed: false },
|
|
9849
|
-
bgr565: { basisFormat: 15, compressed: false },
|
|
9850
|
-
rgba4444: { basisFormat: 16, compressed: false }
|
|
9851
|
-
};
|
|
9852
|
-
}
|
|
9853
|
-
});
|
|
9854
|
-
|
|
9855
|
-
// ../textures/src/basis-loader.ts
|
|
9856
|
-
var BasisWorkerLoader, BasisLoader;
|
|
9857
|
-
var init_basis_loader = __esm({
|
|
9858
|
-
"../textures/src/basis-loader.ts"() {
|
|
9859
|
-
init_version6();
|
|
9860
|
-
init_parse_basis();
|
|
9861
|
-
BasisWorkerLoader = {
|
|
9862
|
-
name: "Basis",
|
|
9863
|
-
id: "basis",
|
|
9864
|
-
module: "textures",
|
|
9865
|
-
version: VERSION8,
|
|
9866
|
-
worker: true,
|
|
9867
|
-
extensions: ["basis", "ktx2"],
|
|
9868
|
-
mimeTypes: ["application/octet-stream", "image/ktx2"],
|
|
9869
|
-
tests: ["sB"],
|
|
9870
|
-
binary: true,
|
|
9871
|
-
options: {
|
|
9872
|
-
basis: {
|
|
9873
|
-
format: "auto",
|
|
9874
|
-
libraryPath: "libs/",
|
|
9875
|
-
containerFormat: "auto",
|
|
9876
|
-
module: "transcoder"
|
|
9700
|
+
getApplicationData(key) {
|
|
9701
|
+
const data = this.json[key];
|
|
9702
|
+
return data;
|
|
9703
|
+
}
|
|
9704
|
+
getExtraData(key) {
|
|
9705
|
+
const extras = this.json.extras || {};
|
|
9706
|
+
return extras[key];
|
|
9707
|
+
}
|
|
9708
|
+
hasExtension(extensionName) {
|
|
9709
|
+
const isUsedExtension = this.getUsedExtensions().find((name12) => name12 === extensionName);
|
|
9710
|
+
const isRequiredExtension = this.getRequiredExtensions().find((name12) => name12 === extensionName);
|
|
9711
|
+
return typeof isUsedExtension === "string" || typeof isRequiredExtension === "string";
|
|
9712
|
+
}
|
|
9713
|
+
getExtension(extensionName) {
|
|
9714
|
+
const isExtension = this.getUsedExtensions().find((name12) => name12 === extensionName);
|
|
9715
|
+
const extensions = this.json.extensions || {};
|
|
9716
|
+
return isExtension ? extensions[extensionName] : null;
|
|
9717
|
+
}
|
|
9718
|
+
getRequiredExtension(extensionName) {
|
|
9719
|
+
const isRequired = this.getRequiredExtensions().find((name12) => name12 === extensionName);
|
|
9720
|
+
return isRequired ? this.getExtension(extensionName) : null;
|
|
9721
|
+
}
|
|
9722
|
+
getRequiredExtensions() {
|
|
9723
|
+
return this.json.extensionsRequired || [];
|
|
9724
|
+
}
|
|
9725
|
+
getUsedExtensions() {
|
|
9726
|
+
return this.json.extensionsUsed || [];
|
|
9727
|
+
}
|
|
9728
|
+
getRemovedExtensions() {
|
|
9729
|
+
return this.json.extensionsRemoved || [];
|
|
9730
|
+
}
|
|
9731
|
+
getObjectExtension(object, extensionName) {
|
|
9732
|
+
const extensions = object.extensions || {};
|
|
9733
|
+
return extensions[extensionName];
|
|
9734
|
+
}
|
|
9735
|
+
getScene(index) {
|
|
9736
|
+
return this.getObject("scenes", index);
|
|
9737
|
+
}
|
|
9738
|
+
getNode(index) {
|
|
9739
|
+
return this.getObject("nodes", index);
|
|
9740
|
+
}
|
|
9741
|
+
getSkin(index) {
|
|
9742
|
+
return this.getObject("skins", index);
|
|
9743
|
+
}
|
|
9744
|
+
getMesh(index) {
|
|
9745
|
+
return this.getObject("meshes", index);
|
|
9746
|
+
}
|
|
9747
|
+
getMaterial(index) {
|
|
9748
|
+
return this.getObject("materials", index);
|
|
9749
|
+
}
|
|
9750
|
+
getAccessor(index) {
|
|
9751
|
+
return this.getObject("accessors", index);
|
|
9752
|
+
}
|
|
9753
|
+
getTexture(index) {
|
|
9754
|
+
return this.getObject("textures", index);
|
|
9755
|
+
}
|
|
9756
|
+
getSampler(index) {
|
|
9757
|
+
return this.getObject("samplers", index);
|
|
9758
|
+
}
|
|
9759
|
+
getImage(index) {
|
|
9760
|
+
return this.getObject("images", index);
|
|
9761
|
+
}
|
|
9762
|
+
getBufferView(index) {
|
|
9763
|
+
return this.getObject("bufferViews", index);
|
|
9764
|
+
}
|
|
9765
|
+
getBuffer(index) {
|
|
9766
|
+
return this.getObject("buffers", index);
|
|
9767
|
+
}
|
|
9768
|
+
getObject(array, index) {
|
|
9769
|
+
if (typeof index === "object") {
|
|
9770
|
+
return index;
|
|
9771
|
+
}
|
|
9772
|
+
const object = this.json[array] && this.json[array][index];
|
|
9773
|
+
if (!object) {
|
|
9774
|
+
throw new Error(`glTF file error: Could not find ${array}[${index}]`);
|
|
9877
9775
|
}
|
|
9776
|
+
return object;
|
|
9878
9777
|
}
|
|
9879
|
-
|
|
9880
|
-
|
|
9881
|
-
|
|
9882
|
-
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
|
|
9886
|
-
|
|
9887
|
-
|
|
9888
|
-
|
|
9889
|
-
|
|
9890
|
-
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
|
|
9894
|
-
|
|
9895
|
-
|
|
9896
|
-
|
|
9897
|
-
|
|
9898
|
-
|
|
9899
|
-
|
|
9900
|
-
|
|
9901
|
-
|
|
9902
|
-
|
|
9903
|
-
|
|
9904
|
-
|
|
9905
|
-
|
|
9906
|
-
|
|
9907
|
-
|
|
9908
|
-
|
|
9909
|
-
|
|
9910
|
-
|
|
9911
|
-
|
|
9912
|
-
|
|
9913
|
-
|
|
9914
|
-
|
|
9915
|
-
|
|
9916
|
-
|
|
9917
|
-
|
|
9918
|
-
|
|
9919
|
-
|
|
9920
|
-
|
|
9921
|
-
|
|
9922
|
-
|
|
9923
|
-
|
|
9924
|
-
|
|
9925
|
-
|
|
9926
|
-
|
|
9927
|
-
|
|
9928
|
-
|
|
9929
|
-
|
|
9930
|
-
|
|
9931
|
-
});
|
|
9932
|
-
byteOffset += GLB_FILE_HEADER_SIZE;
|
|
9933
|
-
switch (glb.version) {
|
|
9934
|
-
case 1:
|
|
9935
|
-
return parseGLBV1(glb, dataView, byteOffset);
|
|
9936
|
-
case 2:
|
|
9937
|
-
return parseGLBV2(glb, dataView, byteOffset, options = {});
|
|
9938
|
-
default:
|
|
9939
|
-
throw new Error(`Invalid GLB version ${glb.version}. Only supports version 1 and 2.`);
|
|
9940
|
-
}
|
|
9941
|
-
}
|
|
9942
|
-
function parseGLBV1(glb, dataView, byteOffset) {
|
|
9943
|
-
assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
|
|
9944
|
-
const contentLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN2);
|
|
9945
|
-
const contentFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
|
|
9946
|
-
byteOffset += GLB_CHUNK_HEADER_SIZE;
|
|
9947
|
-
assert2(contentFormat === GLB_V1_CONTENT_FORMAT_JSON);
|
|
9948
|
-
parseJSONChunk(glb, dataView, byteOffset, contentLength);
|
|
9949
|
-
byteOffset += contentLength;
|
|
9950
|
-
byteOffset += parseBINChunk(glb, dataView, byteOffset, glb.header.byteLength);
|
|
9951
|
-
return byteOffset;
|
|
9952
|
-
}
|
|
9953
|
-
function parseGLBV2(glb, dataView, byteOffset, options) {
|
|
9954
|
-
assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
|
|
9955
|
-
parseGLBChunksSync(glb, dataView, byteOffset, options);
|
|
9956
|
-
return byteOffset + glb.header.byteLength;
|
|
9957
|
-
}
|
|
9958
|
-
function parseGLBChunksSync(glb, dataView, byteOffset, options) {
|
|
9959
|
-
while (byteOffset + 8 <= glb.header.byteLength) {
|
|
9960
|
-
const chunkLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN2);
|
|
9961
|
-
const chunkFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
|
|
9962
|
-
byteOffset += GLB_CHUNK_HEADER_SIZE;
|
|
9963
|
-
switch (chunkFormat) {
|
|
9964
|
-
case GLB_CHUNK_TYPE_JSON:
|
|
9965
|
-
parseJSONChunk(glb, dataView, byteOffset, chunkLength);
|
|
9966
|
-
break;
|
|
9967
|
-
case GLB_CHUNK_TYPE_BIN:
|
|
9968
|
-
parseBINChunk(glb, dataView, byteOffset, chunkLength);
|
|
9969
|
-
break;
|
|
9970
|
-
case GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED:
|
|
9971
|
-
if (!options.strict) {
|
|
9972
|
-
parseJSONChunk(glb, dataView, byteOffset, chunkLength);
|
|
9778
|
+
getTypedArrayForBufferView(bufferView) {
|
|
9779
|
+
bufferView = this.getBufferView(bufferView);
|
|
9780
|
+
const bufferIndex = bufferView.buffer;
|
|
9781
|
+
const binChunk = this.gltf.buffers[bufferIndex];
|
|
9782
|
+
assert7(binChunk);
|
|
9783
|
+
const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;
|
|
9784
|
+
return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);
|
|
9785
|
+
}
|
|
9786
|
+
getTypedArrayForAccessor(accessor) {
|
|
9787
|
+
accessor = this.getAccessor(accessor);
|
|
9788
|
+
const bufferView = this.getBufferView(accessor.bufferView);
|
|
9789
|
+
const buffer = this.getBuffer(bufferView.buffer);
|
|
9790
|
+
const arrayBuffer = buffer.data;
|
|
9791
|
+
const { ArrayType, length: length4 } = getAccessorArrayTypeAndLength(accessor, bufferView);
|
|
9792
|
+
const byteOffset = bufferView.byteOffset + accessor.byteOffset;
|
|
9793
|
+
return new ArrayType(arrayBuffer, byteOffset, length4);
|
|
9794
|
+
}
|
|
9795
|
+
getTypedArrayForImageData(image) {
|
|
9796
|
+
image = this.getAccessor(image);
|
|
9797
|
+
const bufferView = this.getBufferView(image.bufferView);
|
|
9798
|
+
const buffer = this.getBuffer(bufferView.buffer);
|
|
9799
|
+
const arrayBuffer = buffer.data;
|
|
9800
|
+
const byteOffset = bufferView.byteOffset || 0;
|
|
9801
|
+
return new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength);
|
|
9802
|
+
}
|
|
9803
|
+
addApplicationData(key, data) {
|
|
9804
|
+
this.json[key] = data;
|
|
9805
|
+
return this;
|
|
9806
|
+
}
|
|
9807
|
+
addExtraData(key, data) {
|
|
9808
|
+
this.json.extras = this.json.extras || {};
|
|
9809
|
+
this.json.extras[key] = data;
|
|
9810
|
+
return this;
|
|
9811
|
+
}
|
|
9812
|
+
addObjectExtension(object, extensionName, data) {
|
|
9813
|
+
object.extensions = object.extensions || {};
|
|
9814
|
+
object.extensions[extensionName] = data;
|
|
9815
|
+
this.registerUsedExtension(extensionName);
|
|
9816
|
+
return this;
|
|
9817
|
+
}
|
|
9818
|
+
setObjectExtension(object, extensionName, data) {
|
|
9819
|
+
const extensions = object.extensions || {};
|
|
9820
|
+
extensions[extensionName] = data;
|
|
9821
|
+
}
|
|
9822
|
+
removeObjectExtension(object, extensionName) {
|
|
9823
|
+
const extensions = object?.extensions || {};
|
|
9824
|
+
if (extensions[extensionName]) {
|
|
9825
|
+
this.json.extensionsRemoved = this.json.extensionsRemoved || [];
|
|
9826
|
+
const extensionsRemoved = this.json.extensionsRemoved;
|
|
9827
|
+
if (!extensionsRemoved.includes(extensionName)) {
|
|
9828
|
+
extensionsRemoved.push(extensionName);
|
|
9829
|
+
}
|
|
9973
9830
|
}
|
|
9974
|
-
|
|
9975
|
-
|
|
9976
|
-
|
|
9977
|
-
|
|
9978
|
-
}
|
|
9979
|
-
|
|
9980
|
-
|
|
9981
|
-
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
9992
|
-
|
|
9993
|
-
}
|
|
9994
|
-
function parseBINChunk(glb, dataView, byteOffset, chunkLength) {
|
|
9995
|
-
glb.header.hasBinChunk = true;
|
|
9996
|
-
glb.binChunks.push({
|
|
9997
|
-
byteOffset,
|
|
9998
|
-
byteLength: chunkLength,
|
|
9999
|
-
arrayBuffer: dataView.buffer
|
|
10000
|
-
});
|
|
10001
|
-
return padToNBytes(chunkLength, 4);
|
|
10002
|
-
}
|
|
10003
|
-
var LITTLE_ENDIAN2, MAGIC_glTF, GLB_FILE_HEADER_SIZE, GLB_CHUNK_HEADER_SIZE, GLB_CHUNK_TYPE_JSON, GLB_CHUNK_TYPE_BIN, GLB_V1_CONTENT_FORMAT_JSON, GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED, GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED;
|
|
10004
|
-
var init_parse_glb = __esm({
|
|
10005
|
-
"../gltf/src/lib/parsers/parse-glb.ts"() {
|
|
10006
|
-
init_src2();
|
|
10007
|
-
LITTLE_ENDIAN2 = true;
|
|
10008
|
-
MAGIC_glTF = 1735152710;
|
|
10009
|
-
GLB_FILE_HEADER_SIZE = 12;
|
|
10010
|
-
GLB_CHUNK_HEADER_SIZE = 8;
|
|
10011
|
-
GLB_CHUNK_TYPE_JSON = 1313821514;
|
|
10012
|
-
GLB_CHUNK_TYPE_BIN = 5130562;
|
|
10013
|
-
GLB_V1_CONTENT_FORMAT_JSON = 0;
|
|
10014
|
-
GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED = 0;
|
|
10015
|
-
GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED = 1;
|
|
10016
|
-
}
|
|
10017
|
-
});
|
|
10018
|
-
|
|
10019
|
-
// ../gltf/src/lib/gltf-utils/resolve-url.ts
|
|
10020
|
-
function resolveUrl(url, options) {
|
|
10021
|
-
const absolute = url.startsWith("data:") || url.startsWith("http:") || url.startsWith("https:");
|
|
10022
|
-
if (absolute) {
|
|
10023
|
-
return url;
|
|
10024
|
-
}
|
|
10025
|
-
const baseUrl = options.baseUri || options.uri;
|
|
10026
|
-
if (!baseUrl) {
|
|
10027
|
-
throw new Error(`'baseUri' must be provided to resolve relative url ${url}`);
|
|
10028
|
-
}
|
|
10029
|
-
return baseUrl.substr(0, baseUrl.lastIndexOf("/") + 1) + url;
|
|
10030
|
-
}
|
|
10031
|
-
var init_resolve_url = __esm({
|
|
10032
|
-
"../gltf/src/lib/gltf-utils/resolve-url.ts"() {
|
|
10033
|
-
}
|
|
10034
|
-
});
|
|
10035
|
-
|
|
10036
|
-
// ../gltf/src/lib/gltf-utils/get-typed-array.ts
|
|
10037
|
-
function getTypedArrayForBufferView(json, buffers, bufferViewIndex) {
|
|
10038
|
-
const bufferView = json.bufferViews[bufferViewIndex];
|
|
10039
|
-
assert7(bufferView);
|
|
10040
|
-
const bufferIndex = bufferView.buffer;
|
|
10041
|
-
const binChunk = buffers[bufferIndex];
|
|
10042
|
-
assert7(binChunk);
|
|
10043
|
-
const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;
|
|
10044
|
-
return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);
|
|
10045
|
-
}
|
|
10046
|
-
var init_get_typed_array = __esm({
|
|
10047
|
-
"../gltf/src/lib/gltf-utils/get-typed-array.ts"() {
|
|
10048
|
-
init_assert6();
|
|
10049
|
-
}
|
|
10050
|
-
});
|
|
10051
|
-
|
|
10052
|
-
// ../gltf/src/lib/gltf-utils/gltf-utils.ts
|
|
10053
|
-
function getAccessorTypeFromSize(size) {
|
|
10054
|
-
const type = TYPES[size - 1];
|
|
10055
|
-
return type || TYPES[0];
|
|
10056
|
-
}
|
|
10057
|
-
function getComponentTypeFromArray(typedArray) {
|
|
10058
|
-
const componentType = ARRAY_TO_COMPONENT_TYPE.get(typedArray.constructor);
|
|
10059
|
-
if (!componentType) {
|
|
10060
|
-
throw new Error("Illegal typed array");
|
|
10061
|
-
}
|
|
10062
|
-
return componentType;
|
|
10063
|
-
}
|
|
10064
|
-
function getAccessorArrayTypeAndLength(accessor, bufferView) {
|
|
10065
|
-
const ArrayType = ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY[accessor.componentType];
|
|
10066
|
-
const components = ATTRIBUTE_TYPE_TO_COMPONENTS[accessor.type];
|
|
10067
|
-
const bytesPerComponent = ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE[accessor.componentType];
|
|
10068
|
-
const length4 = accessor.count * components;
|
|
10069
|
-
const byteLength = accessor.count * components * bytesPerComponent;
|
|
10070
|
-
assert7(byteLength >= 0 && byteLength <= bufferView.byteLength);
|
|
10071
|
-
return { ArrayType, length: length4, byteLength };
|
|
10072
|
-
}
|
|
10073
|
-
function getMemoryUsageGLTF(gltf) {
|
|
10074
|
-
let { images, bufferViews } = gltf;
|
|
10075
|
-
images = images || [];
|
|
10076
|
-
bufferViews = bufferViews || [];
|
|
10077
|
-
const imageBufferViews = images.map((i2) => i2.bufferView);
|
|
10078
|
-
bufferViews = bufferViews.filter((view) => !imageBufferViews.includes(view));
|
|
10079
|
-
const bufferMemory = bufferViews.reduce((acc, view) => acc + view.byteLength, 0);
|
|
10080
|
-
const pixelCount = images.reduce((acc, image) => {
|
|
10081
|
-
const { width, height } = image.image;
|
|
10082
|
-
return acc + width * height;
|
|
10083
|
-
}, 0);
|
|
10084
|
-
return bufferMemory + Math.ceil(4 * pixelCount * MIPMAP_FACTOR);
|
|
10085
|
-
}
|
|
10086
|
-
var MIPMAP_FACTOR, TYPES, ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT, ARRAY_TO_COMPONENT_TYPE, ATTRIBUTE_TYPE_TO_COMPONENTS, ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE, ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY;
|
|
10087
|
-
var init_gltf_utils = __esm({
|
|
10088
|
-
"../gltf/src/lib/gltf-utils/gltf-utils.ts"() {
|
|
10089
|
-
init_assert6();
|
|
10090
|
-
MIPMAP_FACTOR = 1.33;
|
|
10091
|
-
TYPES = ["SCALAR", "VEC2", "VEC3", "VEC4"];
|
|
10092
|
-
ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT = [
|
|
10093
|
-
[Int8Array, 5120],
|
|
10094
|
-
[Uint8Array, 5121],
|
|
10095
|
-
[Int16Array, 5122],
|
|
10096
|
-
[Uint16Array, 5123],
|
|
10097
|
-
[Uint32Array, 5125],
|
|
10098
|
-
[Float32Array, 5126],
|
|
10099
|
-
[Float64Array, 5130]
|
|
10100
|
-
];
|
|
10101
|
-
ARRAY_TO_COMPONENT_TYPE = new Map(ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT);
|
|
10102
|
-
ATTRIBUTE_TYPE_TO_COMPONENTS = {
|
|
10103
|
-
SCALAR: 1,
|
|
10104
|
-
VEC2: 2,
|
|
10105
|
-
VEC3: 3,
|
|
10106
|
-
VEC4: 4,
|
|
10107
|
-
MAT2: 4,
|
|
10108
|
-
MAT3: 9,
|
|
10109
|
-
MAT4: 16
|
|
10110
|
-
};
|
|
10111
|
-
ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE = {
|
|
10112
|
-
5120: 1,
|
|
10113
|
-
5121: 1,
|
|
10114
|
-
5122: 2,
|
|
10115
|
-
5123: 2,
|
|
10116
|
-
5125: 4,
|
|
10117
|
-
5126: 4
|
|
10118
|
-
};
|
|
10119
|
-
ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY = {
|
|
10120
|
-
5120: Int8Array,
|
|
10121
|
-
5121: Uint8Array,
|
|
10122
|
-
5122: Int16Array,
|
|
10123
|
-
5123: Uint16Array,
|
|
10124
|
-
5125: Uint32Array,
|
|
10125
|
-
5126: Float32Array
|
|
10126
|
-
};
|
|
10127
|
-
}
|
|
10128
|
-
});
|
|
10129
|
-
|
|
10130
|
-
// ../gltf/src/lib/api/gltf-scenegraph.ts
|
|
10131
|
-
function makeDefaultGLTFJson() {
|
|
10132
|
-
return {
|
|
10133
|
-
asset: {
|
|
10134
|
-
version: "2.0",
|
|
10135
|
-
generator: "loaders.gl"
|
|
10136
|
-
},
|
|
10137
|
-
buffers: [],
|
|
10138
|
-
extensions: {},
|
|
10139
|
-
extensionsRequired: [],
|
|
10140
|
-
extensionsUsed: []
|
|
10141
|
-
};
|
|
10142
|
-
}
|
|
10143
|
-
var GLTFScenegraph;
|
|
10144
|
-
var init_gltf_scenegraph = __esm({
|
|
10145
|
-
"../gltf/src/lib/api/gltf-scenegraph.ts"() {
|
|
10146
|
-
init_src8();
|
|
10147
|
-
init_src2();
|
|
10148
|
-
init_assert6();
|
|
10149
|
-
init_gltf_utils();
|
|
10150
|
-
GLTFScenegraph = class {
|
|
10151
|
-
constructor(gltf) {
|
|
10152
|
-
this.gltf = {
|
|
10153
|
-
json: gltf?.json || makeDefaultGLTFJson(),
|
|
10154
|
-
buffers: gltf?.buffers || [],
|
|
10155
|
-
images: gltf?.images || []
|
|
10156
|
-
};
|
|
10157
|
-
this.sourceBuffers = [];
|
|
10158
|
-
this.byteLength = 0;
|
|
10159
|
-
if (this.gltf.buffers && this.gltf.buffers[0]) {
|
|
10160
|
-
this.byteLength = this.gltf.buffers[0].byteLength;
|
|
10161
|
-
this.sourceBuffers = [this.gltf.buffers[0]];
|
|
10162
|
-
}
|
|
10163
|
-
}
|
|
10164
|
-
get json() {
|
|
10165
|
-
return this.gltf.json;
|
|
10166
|
-
}
|
|
10167
|
-
getApplicationData(key) {
|
|
10168
|
-
const data = this.json[key];
|
|
10169
|
-
return data;
|
|
10170
|
-
}
|
|
10171
|
-
getExtraData(key) {
|
|
10172
|
-
const extras = this.json.extras || {};
|
|
10173
|
-
return extras[key];
|
|
10174
|
-
}
|
|
10175
|
-
hasExtension(extensionName) {
|
|
10176
|
-
const isUsedExtension = this.getUsedExtensions().find((name10) => name10 === extensionName);
|
|
10177
|
-
const isRequiredExtension = this.getRequiredExtensions().find((name10) => name10 === extensionName);
|
|
10178
|
-
return typeof isUsedExtension === "string" || typeof isRequiredExtension === "string";
|
|
10179
|
-
}
|
|
10180
|
-
getExtension(extensionName) {
|
|
10181
|
-
const isExtension = this.getUsedExtensions().find((name10) => name10 === extensionName);
|
|
10182
|
-
const extensions = this.json.extensions || {};
|
|
10183
|
-
return isExtension ? extensions[extensionName] : null;
|
|
10184
|
-
}
|
|
10185
|
-
getRequiredExtension(extensionName) {
|
|
10186
|
-
const isRequired = this.getRequiredExtensions().find((name10) => name10 === extensionName);
|
|
10187
|
-
return isRequired ? this.getExtension(extensionName) : null;
|
|
10188
|
-
}
|
|
10189
|
-
getRequiredExtensions() {
|
|
10190
|
-
return this.json.extensionsRequired || [];
|
|
10191
|
-
}
|
|
10192
|
-
getUsedExtensions() {
|
|
10193
|
-
return this.json.extensionsUsed || [];
|
|
10194
|
-
}
|
|
10195
|
-
getRemovedExtensions() {
|
|
10196
|
-
return this.json.extensionsRemoved || [];
|
|
10197
|
-
}
|
|
10198
|
-
getObjectExtension(object, extensionName) {
|
|
10199
|
-
const extensions = object.extensions || {};
|
|
10200
|
-
return extensions[extensionName];
|
|
10201
|
-
}
|
|
10202
|
-
getScene(index) {
|
|
10203
|
-
return this.getObject("scenes", index);
|
|
10204
|
-
}
|
|
10205
|
-
getNode(index) {
|
|
10206
|
-
return this.getObject("nodes", index);
|
|
10207
|
-
}
|
|
10208
|
-
getSkin(index) {
|
|
10209
|
-
return this.getObject("skins", index);
|
|
10210
|
-
}
|
|
10211
|
-
getMesh(index) {
|
|
10212
|
-
return this.getObject("meshes", index);
|
|
10213
|
-
}
|
|
10214
|
-
getMaterial(index) {
|
|
10215
|
-
return this.getObject("materials", index);
|
|
10216
|
-
}
|
|
10217
|
-
getAccessor(index) {
|
|
10218
|
-
return this.getObject("accessors", index);
|
|
10219
|
-
}
|
|
10220
|
-
getTexture(index) {
|
|
10221
|
-
return this.getObject("textures", index);
|
|
10222
|
-
}
|
|
10223
|
-
getSampler(index) {
|
|
10224
|
-
return this.getObject("samplers", index);
|
|
10225
|
-
}
|
|
10226
|
-
getImage(index) {
|
|
10227
|
-
return this.getObject("images", index);
|
|
10228
|
-
}
|
|
10229
|
-
getBufferView(index) {
|
|
10230
|
-
return this.getObject("bufferViews", index);
|
|
10231
|
-
}
|
|
10232
|
-
getBuffer(index) {
|
|
10233
|
-
return this.getObject("buffers", index);
|
|
10234
|
-
}
|
|
10235
|
-
getObject(array, index) {
|
|
10236
|
-
if (typeof index === "object") {
|
|
10237
|
-
return index;
|
|
10238
|
-
}
|
|
10239
|
-
const object = this.json[array] && this.json[array][index];
|
|
10240
|
-
if (!object) {
|
|
10241
|
-
throw new Error(`glTF file error: Could not find ${array}[${index}]`);
|
|
10242
|
-
}
|
|
10243
|
-
return object;
|
|
10244
|
-
}
|
|
10245
|
-
getTypedArrayForBufferView(bufferView) {
|
|
10246
|
-
bufferView = this.getBufferView(bufferView);
|
|
10247
|
-
const bufferIndex = bufferView.buffer;
|
|
10248
|
-
const binChunk = this.gltf.buffers[bufferIndex];
|
|
10249
|
-
assert7(binChunk);
|
|
10250
|
-
const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;
|
|
10251
|
-
return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);
|
|
10252
|
-
}
|
|
10253
|
-
getTypedArrayForAccessor(accessor) {
|
|
10254
|
-
accessor = this.getAccessor(accessor);
|
|
10255
|
-
const bufferView = this.getBufferView(accessor.bufferView);
|
|
10256
|
-
const buffer = this.getBuffer(bufferView.buffer);
|
|
10257
|
-
const arrayBuffer = buffer.data;
|
|
10258
|
-
const { ArrayType, length: length4 } = getAccessorArrayTypeAndLength(accessor, bufferView);
|
|
10259
|
-
const byteOffset = bufferView.byteOffset + accessor.byteOffset;
|
|
10260
|
-
return new ArrayType(arrayBuffer, byteOffset, length4);
|
|
10261
|
-
}
|
|
10262
|
-
getTypedArrayForImageData(image) {
|
|
10263
|
-
image = this.getAccessor(image);
|
|
10264
|
-
const bufferView = this.getBufferView(image.bufferView);
|
|
10265
|
-
const buffer = this.getBuffer(bufferView.buffer);
|
|
10266
|
-
const arrayBuffer = buffer.data;
|
|
10267
|
-
const byteOffset = bufferView.byteOffset || 0;
|
|
10268
|
-
return new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength);
|
|
10269
|
-
}
|
|
10270
|
-
addApplicationData(key, data) {
|
|
10271
|
-
this.json[key] = data;
|
|
10272
|
-
return this;
|
|
10273
|
-
}
|
|
10274
|
-
addExtraData(key, data) {
|
|
10275
|
-
this.json.extras = this.json.extras || {};
|
|
10276
|
-
this.json.extras[key] = data;
|
|
10277
|
-
return this;
|
|
10278
|
-
}
|
|
10279
|
-
addObjectExtension(object, extensionName, data) {
|
|
10280
|
-
object.extensions = object.extensions || {};
|
|
10281
|
-
object.extensions[extensionName] = data;
|
|
10282
|
-
this.registerUsedExtension(extensionName);
|
|
10283
|
-
return this;
|
|
10284
|
-
}
|
|
10285
|
-
setObjectExtension(object, extensionName, data) {
|
|
10286
|
-
const extensions = object.extensions || {};
|
|
10287
|
-
extensions[extensionName] = data;
|
|
10288
|
-
}
|
|
10289
|
-
removeObjectExtension(object, extensionName) {
|
|
10290
|
-
const extensions = object?.extensions || {};
|
|
10291
|
-
if (extensions[extensionName]) {
|
|
10292
|
-
this.json.extensionsRemoved = this.json.extensionsRemoved || [];
|
|
10293
|
-
const extensionsRemoved = this.json.extensionsRemoved;
|
|
10294
|
-
if (!extensionsRemoved.includes(extensionName)) {
|
|
10295
|
-
extensionsRemoved.push(extensionName);
|
|
10296
|
-
}
|
|
10297
|
-
}
|
|
10298
|
-
delete extensions[extensionName];
|
|
10299
|
-
}
|
|
10300
|
-
addExtension(extensionName, extensionData = {}) {
|
|
10301
|
-
assert7(extensionData);
|
|
10302
|
-
this.json.extensions = this.json.extensions || {};
|
|
10303
|
-
this.json.extensions[extensionName] = extensionData;
|
|
10304
|
-
this.registerUsedExtension(extensionName);
|
|
10305
|
-
return extensionData;
|
|
10306
|
-
}
|
|
10307
|
-
addRequiredExtension(extensionName, extensionData = {}) {
|
|
10308
|
-
assert7(extensionData);
|
|
10309
|
-
this.addExtension(extensionName, extensionData);
|
|
10310
|
-
this.registerRequiredExtension(extensionName);
|
|
10311
|
-
return extensionData;
|
|
10312
|
-
}
|
|
10313
|
-
registerUsedExtension(extensionName) {
|
|
10314
|
-
this.json.extensionsUsed = this.json.extensionsUsed || [];
|
|
10315
|
-
if (!this.json.extensionsUsed.find((ext) => ext === extensionName)) {
|
|
10316
|
-
this.json.extensionsUsed.push(extensionName);
|
|
9831
|
+
delete extensions[extensionName];
|
|
9832
|
+
}
|
|
9833
|
+
addExtension(extensionName, extensionData = {}) {
|
|
9834
|
+
assert7(extensionData);
|
|
9835
|
+
this.json.extensions = this.json.extensions || {};
|
|
9836
|
+
this.json.extensions[extensionName] = extensionData;
|
|
9837
|
+
this.registerUsedExtension(extensionName);
|
|
9838
|
+
return extensionData;
|
|
9839
|
+
}
|
|
9840
|
+
addRequiredExtension(extensionName, extensionData = {}) {
|
|
9841
|
+
assert7(extensionData);
|
|
9842
|
+
this.addExtension(extensionName, extensionData);
|
|
9843
|
+
this.registerRequiredExtension(extensionName);
|
|
9844
|
+
return extensionData;
|
|
9845
|
+
}
|
|
9846
|
+
registerUsedExtension(extensionName) {
|
|
9847
|
+
this.json.extensionsUsed = this.json.extensionsUsed || [];
|
|
9848
|
+
if (!this.json.extensionsUsed.find((ext) => ext === extensionName)) {
|
|
9849
|
+
this.json.extensionsUsed.push(extensionName);
|
|
10317
9850
|
}
|
|
10318
9851
|
}
|
|
10319
9852
|
registerRequiredExtension(extensionName) {
|
|
@@ -10493,66 +10026,1432 @@
|
|
|
10493
10026
|
}
|
|
10494
10027
|
}
|
|
10495
10028
|
}
|
|
10496
|
-
_addAttributes(attributes = {}) {
|
|
10497
|
-
const result = {};
|
|
10498
|
-
for (const attributeKey in attributes) {
|
|
10499
|
-
const attributeData = attributes[attributeKey];
|
|
10500
|
-
const attrName = this._getGltfAttributeName(attributeKey);
|
|
10501
|
-
const accessor = this.addBinaryBuffer(attributeData.value, attributeData);
|
|
10502
|
-
result[attrName] = accessor;
|
|
10503
|
-
}
|
|
10504
|
-
return result;
|
|
10029
|
+
_addAttributes(attributes = {}) {
|
|
10030
|
+
const result = {};
|
|
10031
|
+
for (const attributeKey in attributes) {
|
|
10032
|
+
const attributeData = attributes[attributeKey];
|
|
10033
|
+
const attrName = this._getGltfAttributeName(attributeKey);
|
|
10034
|
+
const accessor = this.addBinaryBuffer(attributeData.value, attributeData);
|
|
10035
|
+
result[attrName] = accessor;
|
|
10036
|
+
}
|
|
10037
|
+
return result;
|
|
10038
|
+
}
|
|
10039
|
+
_addIndices(indices) {
|
|
10040
|
+
return this.addBinaryBuffer(indices, { size: 1 });
|
|
10041
|
+
}
|
|
10042
|
+
_getGltfAttributeName(attributeName) {
|
|
10043
|
+
switch (attributeName.toLowerCase()) {
|
|
10044
|
+
case "position":
|
|
10045
|
+
case "positions":
|
|
10046
|
+
case "vertices":
|
|
10047
|
+
return "POSITION";
|
|
10048
|
+
case "normal":
|
|
10049
|
+
case "normals":
|
|
10050
|
+
return "NORMAL";
|
|
10051
|
+
case "color":
|
|
10052
|
+
case "colors":
|
|
10053
|
+
return "COLOR_0";
|
|
10054
|
+
case "texcoord":
|
|
10055
|
+
case "texcoords":
|
|
10056
|
+
return "TEXCOORD_0";
|
|
10057
|
+
default:
|
|
10058
|
+
return attributeName;
|
|
10059
|
+
}
|
|
10060
|
+
}
|
|
10061
|
+
_getAccessorMinMax(buffer, size) {
|
|
10062
|
+
const result = { min: null, max: null };
|
|
10063
|
+
if (buffer.length < size) {
|
|
10064
|
+
return result;
|
|
10065
|
+
}
|
|
10066
|
+
result.min = [];
|
|
10067
|
+
result.max = [];
|
|
10068
|
+
const initValues = buffer.subarray(0, size);
|
|
10069
|
+
for (const value of initValues) {
|
|
10070
|
+
result.min.push(value);
|
|
10071
|
+
result.max.push(value);
|
|
10072
|
+
}
|
|
10073
|
+
for (let index = size; index < buffer.length; index += size) {
|
|
10074
|
+
for (let componentIndex = 0; componentIndex < size; componentIndex++) {
|
|
10075
|
+
result.min[0 + componentIndex] = Math.min(result.min[0 + componentIndex], buffer[index + componentIndex]);
|
|
10076
|
+
result.max[0 + componentIndex] = Math.max(result.max[0 + componentIndex], buffer[index + componentIndex]);
|
|
10077
|
+
}
|
|
10078
|
+
}
|
|
10079
|
+
return result;
|
|
10080
|
+
}
|
|
10081
|
+
};
|
|
10082
|
+
}
|
|
10083
|
+
});
|
|
10084
|
+
|
|
10085
|
+
// ../gltf/src/lib/extensions/data-processing.ts
|
|
10086
|
+
function getArrayElementByteSize(attributeType, componentType) {
|
|
10087
|
+
return ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE2[componentType] * ATTRIBUTE_TYPE_TO_COMPONENTS2[attributeType];
|
|
10088
|
+
}
|
|
10089
|
+
function convertRawBufferToMetadataArray(typedArray, attributeType, componentType, elementCount = 1) {
|
|
10090
|
+
const numberOfComponents = ATTRIBUTE_TYPE_TO_COMPONENTS2[attributeType];
|
|
10091
|
+
const ArrayType = ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY2[componentType];
|
|
10092
|
+
const length4 = elementCount * numberOfComponents;
|
|
10093
|
+
const size = ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE2[componentType];
|
|
10094
|
+
const offset = typedArray.byteOffset % size ? Math.ceil(typedArray.byteOffset / size) * size : typedArray.byteOffset;
|
|
10095
|
+
return new ArrayType(typedArray.buffer, offset, length4);
|
|
10096
|
+
}
|
|
10097
|
+
function getPrimitiveTextureData(scenegraph, textureInfo, primitive) {
|
|
10098
|
+
const json = scenegraph.gltf.json;
|
|
10099
|
+
const texCoordAccessorKey = `TEXCOORD_${textureInfo.texCoord || 0}`;
|
|
10100
|
+
const texCoordAccessorIndex = primitive.attributes[texCoordAccessorKey];
|
|
10101
|
+
const texCoordBufferView = scenegraph.getBufferView(texCoordAccessorIndex);
|
|
10102
|
+
const texCoordArray = scenegraph.getTypedArrayForBufferView(texCoordBufferView);
|
|
10103
|
+
const textureCoordinates = new Float32Array(texCoordArray.buffer, texCoordArray.byteOffset, texCoordArray.length / 4);
|
|
10104
|
+
const textureIndex = textureInfo.index;
|
|
10105
|
+
const imageIndex = json.textures?.[textureIndex]?.source;
|
|
10106
|
+
if (typeof imageIndex !== "undefined") {
|
|
10107
|
+
const mimeType = json.images?.[imageIndex]?.mimeType;
|
|
10108
|
+
const parsedImage = scenegraph.gltf.images?.[imageIndex];
|
|
10109
|
+
if (parsedImage && typeof parsedImage.width !== "undefined") {
|
|
10110
|
+
const textureData = [];
|
|
10111
|
+
for (let index = 0; index < textureCoordinates.length; index += 2) {
|
|
10112
|
+
const value = getImageValueByCoordinates(parsedImage, mimeType, textureCoordinates, index, textureInfo.channels);
|
|
10113
|
+
textureData.push(value);
|
|
10114
|
+
}
|
|
10115
|
+
return textureData;
|
|
10116
|
+
}
|
|
10117
|
+
}
|
|
10118
|
+
return null;
|
|
10119
|
+
}
|
|
10120
|
+
function primitivePropertyDataToAttributes(scenegraph, attributeName, propertyData, featureTable, primitive) {
|
|
10121
|
+
if (propertyData === null)
|
|
10122
|
+
return;
|
|
10123
|
+
const featureIndices = [];
|
|
10124
|
+
for (const texelData of propertyData) {
|
|
10125
|
+
let index = featureTable.findIndex((item) => item === texelData);
|
|
10126
|
+
if (index === -1) {
|
|
10127
|
+
index = featureTable.push(texelData) - 1;
|
|
10128
|
+
}
|
|
10129
|
+
featureIndices.push(index);
|
|
10130
|
+
}
|
|
10131
|
+
const typedArray = new Uint32Array(featureIndices);
|
|
10132
|
+
const bufferIndex = scenegraph.gltf.buffers.push({
|
|
10133
|
+
arrayBuffer: typedArray.buffer,
|
|
10134
|
+
byteOffset: typedArray.byteOffset,
|
|
10135
|
+
byteLength: typedArray.byteLength
|
|
10136
|
+
}) - 1;
|
|
10137
|
+
const bufferViewIndex = scenegraph.addBufferView(typedArray, bufferIndex, 0);
|
|
10138
|
+
const accessorIndex = scenegraph.addAccessor(bufferViewIndex, {
|
|
10139
|
+
size: 1,
|
|
10140
|
+
componentType: getComponentTypeFromArray(typedArray),
|
|
10141
|
+
count: typedArray.length
|
|
10142
|
+
});
|
|
10143
|
+
primitive.attributes[attributeName] = accessorIndex;
|
|
10144
|
+
}
|
|
10145
|
+
function getImageValueByCoordinates(parsedImage, mimeType, textureCoordinates, index, channels = [0]) {
|
|
10146
|
+
const CHANNELS_MAP = [
|
|
10147
|
+
{ offset: 0, shift: 0 },
|
|
10148
|
+
{ offset: 1, shift: 8 },
|
|
10149
|
+
{ offset: 2, shift: 16 },
|
|
10150
|
+
{ offset: 3, shift: 24 }
|
|
10151
|
+
];
|
|
10152
|
+
const u = textureCoordinates[index];
|
|
10153
|
+
const v = textureCoordinates[index + 1];
|
|
10154
|
+
let components = 1;
|
|
10155
|
+
if (mimeType && (mimeType.indexOf("image/jpeg") !== -1 || mimeType.indexOf("image/png") !== -1))
|
|
10156
|
+
components = 4;
|
|
10157
|
+
const offset = coordinatesToOffset(u, v, parsedImage, components);
|
|
10158
|
+
let value = 0;
|
|
10159
|
+
for (const c of channels) {
|
|
10160
|
+
const map2 = CHANNELS_MAP[c];
|
|
10161
|
+
const imageOffset = offset + map2.offset;
|
|
10162
|
+
const imageData = getImageData(parsedImage);
|
|
10163
|
+
if (imageData.data.length <= imageOffset) {
|
|
10164
|
+
throw new Error(`${imageData.data.length} <= ${imageOffset}`);
|
|
10165
|
+
}
|
|
10166
|
+
const imageValue = imageData.data[imageOffset];
|
|
10167
|
+
value |= imageValue << map2.shift;
|
|
10168
|
+
}
|
|
10169
|
+
return value;
|
|
10170
|
+
}
|
|
10171
|
+
function coordinatesToOffset(u, v, parsedImage, componentsCount = 1) {
|
|
10172
|
+
const w = parsedImage.width;
|
|
10173
|
+
const iX = emod(u) * (w - 1);
|
|
10174
|
+
const indX = Math.round(iX);
|
|
10175
|
+
const h = parsedImage.height;
|
|
10176
|
+
const iY = emod(v) * (h - 1);
|
|
10177
|
+
const indY = Math.round(iY);
|
|
10178
|
+
const components = parsedImage.components ? parsedImage.components : componentsCount;
|
|
10179
|
+
const offset = (indY * w + indX) * components;
|
|
10180
|
+
return offset;
|
|
10181
|
+
}
|
|
10182
|
+
var ATTRIBUTE_TYPE_TO_COMPONENTS2, ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY2, ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE2;
|
|
10183
|
+
var init_data_processing = __esm({
|
|
10184
|
+
"../gltf/src/lib/extensions/data-processing.ts"() {
|
|
10185
|
+
init_gltf_utils();
|
|
10186
|
+
init_src8();
|
|
10187
|
+
init_src7();
|
|
10188
|
+
ATTRIBUTE_TYPE_TO_COMPONENTS2 = {
|
|
10189
|
+
SCALAR: 1,
|
|
10190
|
+
VEC2: 2,
|
|
10191
|
+
VEC3: 3,
|
|
10192
|
+
VEC4: 4,
|
|
10193
|
+
MAT2: 4,
|
|
10194
|
+
MAT3: 9,
|
|
10195
|
+
MAT4: 16,
|
|
10196
|
+
BOOLEAN: 1,
|
|
10197
|
+
STRING: 1,
|
|
10198
|
+
ENUM: 1
|
|
10199
|
+
};
|
|
10200
|
+
ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY2 = {
|
|
10201
|
+
INT8: Int8Array,
|
|
10202
|
+
UINT8: Uint8Array,
|
|
10203
|
+
INT16: Int16Array,
|
|
10204
|
+
UINT16: Uint16Array,
|
|
10205
|
+
INT32: Int32Array,
|
|
10206
|
+
UINT32: Uint32Array,
|
|
10207
|
+
INT64: BigInt64Array,
|
|
10208
|
+
UINT64: BigUint64Array,
|
|
10209
|
+
FLOAT32: Float32Array,
|
|
10210
|
+
FLOAT64: Float64Array
|
|
10211
|
+
};
|
|
10212
|
+
ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE2 = {
|
|
10213
|
+
INT8: 1,
|
|
10214
|
+
UINT8: 1,
|
|
10215
|
+
INT16: 2,
|
|
10216
|
+
UINT16: 2,
|
|
10217
|
+
INT32: 4,
|
|
10218
|
+
UINT32: 4,
|
|
10219
|
+
INT64: 8,
|
|
10220
|
+
UINT64: 8,
|
|
10221
|
+
FLOAT32: 4,
|
|
10222
|
+
FLOAT64: 8
|
|
10223
|
+
};
|
|
10224
|
+
}
|
|
10225
|
+
});
|
|
10226
|
+
|
|
10227
|
+
// ../gltf/src/lib/extensions/EXT_structural_metadata.ts
|
|
10228
|
+
var EXT_structural_metadata_exports = {};
|
|
10229
|
+
__export(EXT_structural_metadata_exports, {
|
|
10230
|
+
decode: () => decode,
|
|
10231
|
+
getPropertyTablePopulated: () => getPropertyTablePopulated,
|
|
10232
|
+
name: () => name
|
|
10233
|
+
});
|
|
10234
|
+
async function decode(gltfData, options) {
|
|
10235
|
+
const scenegraph = new GLTFScenegraph(gltfData);
|
|
10236
|
+
decodeExtStructuralMetadata(scenegraph, options);
|
|
10237
|
+
}
|
|
10238
|
+
function getPropertyTablePopulated(scenegraph, propertyTableIndex) {
|
|
10239
|
+
const extension = scenegraph.getExtension(EXT_STRUCTURAL_METADATA_NAME);
|
|
10240
|
+
const propertyTable = extension?.propertyTables?.[propertyTableIndex];
|
|
10241
|
+
if (extension?.schema && propertyTable) {
|
|
10242
|
+
processPropertyTable(scenegraph, extension.schema, propertyTable);
|
|
10243
|
+
return propertyTable;
|
|
10244
|
+
}
|
|
10245
|
+
throw new Error(`Incorrect data in the EXT_structural_metadata extension: no property table with index ${propertyTableIndex}`);
|
|
10246
|
+
}
|
|
10247
|
+
function decodeExtStructuralMetadata(scenegraph, options) {
|
|
10248
|
+
const extension = scenegraph.getExtension(EXT_STRUCTURAL_METADATA_NAME);
|
|
10249
|
+
if (!extension?.schema) {
|
|
10250
|
+
return;
|
|
10251
|
+
}
|
|
10252
|
+
const propertyTextures = extension.propertyTextures;
|
|
10253
|
+
const json = scenegraph.gltf.json;
|
|
10254
|
+
if (propertyTextures && json.meshes && options?.gltf?.loadImages) {
|
|
10255
|
+
for (const mesh of json.meshes) {
|
|
10256
|
+
for (const primitive of mesh.primitives) {
|
|
10257
|
+
processPrimitivePropertyTextures(scenegraph, propertyTextures, primitive, extension);
|
|
10258
|
+
}
|
|
10259
|
+
}
|
|
10260
|
+
}
|
|
10261
|
+
const schemaClasses = extension.schema.classes;
|
|
10262
|
+
const propertyTables = extension.propertyTables;
|
|
10263
|
+
if (schemaClasses && propertyTables) {
|
|
10264
|
+
for (const schemaName in schemaClasses) {
|
|
10265
|
+
const propertyTable = findPropertyTableByClass(propertyTables, schemaName);
|
|
10266
|
+
if (propertyTable) {
|
|
10267
|
+
processPropertyTable(scenegraph, extension.schema, propertyTable);
|
|
10268
|
+
}
|
|
10269
|
+
}
|
|
10270
|
+
}
|
|
10271
|
+
}
|
|
10272
|
+
function processPrimitivePropertyTextures(scenegraph, propertyTextures, primitive, extension) {
|
|
10273
|
+
if (!propertyTextures) {
|
|
10274
|
+
return;
|
|
10275
|
+
}
|
|
10276
|
+
const primitiveExtension = primitive.extensions?.[EXT_STRUCTURAL_METADATA_NAME];
|
|
10277
|
+
const primitivePropertyTextureIndices = primitiveExtension?.propertyTextures;
|
|
10278
|
+
if (!primitivePropertyTextureIndices) {
|
|
10279
|
+
return;
|
|
10280
|
+
}
|
|
10281
|
+
for (const primitivePropertyTextureIndex of primitivePropertyTextureIndices) {
|
|
10282
|
+
const propertyTexture = propertyTextures[primitivePropertyTextureIndex];
|
|
10283
|
+
processPrimitivePropertyTexture(scenegraph, propertyTexture, primitive, extension);
|
|
10284
|
+
}
|
|
10285
|
+
}
|
|
10286
|
+
function processPrimitivePropertyTexture(scenegraph, propertyTexture, primitive, extension) {
|
|
10287
|
+
if (!propertyTexture.properties) {
|
|
10288
|
+
return;
|
|
10289
|
+
}
|
|
10290
|
+
if (!extension.dataAttributeNames) {
|
|
10291
|
+
extension.dataAttributeNames = [];
|
|
10292
|
+
}
|
|
10293
|
+
const className = propertyTexture.class;
|
|
10294
|
+
for (const propName in propertyTexture.properties) {
|
|
10295
|
+
const attributeName = `${className}_${propName}`;
|
|
10296
|
+
const textureInfoTopLevel = propertyTexture.properties?.[propName];
|
|
10297
|
+
if (!textureInfoTopLevel) {
|
|
10298
|
+
continue;
|
|
10299
|
+
}
|
|
10300
|
+
if (!textureInfoTopLevel.data) {
|
|
10301
|
+
textureInfoTopLevel.data = [];
|
|
10302
|
+
}
|
|
10303
|
+
const featureTextureTable = textureInfoTopLevel.data;
|
|
10304
|
+
const propertyData = getPrimitiveTextureData(scenegraph, textureInfoTopLevel, primitive);
|
|
10305
|
+
if (propertyData === null) {
|
|
10306
|
+
continue;
|
|
10307
|
+
}
|
|
10308
|
+
primitivePropertyDataToAttributes(scenegraph, attributeName, propertyData, featureTextureTable, primitive);
|
|
10309
|
+
textureInfoTopLevel.data = featureTextureTable;
|
|
10310
|
+
extension.dataAttributeNames.push(attributeName);
|
|
10311
|
+
}
|
|
10312
|
+
}
|
|
10313
|
+
function processPropertyTable(scenegraph, schema, propertyTable) {
|
|
10314
|
+
const schemaClass = schema.classes?.[propertyTable.class];
|
|
10315
|
+
if (!schemaClass) {
|
|
10316
|
+
throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${propertyTable.class}`);
|
|
10317
|
+
}
|
|
10318
|
+
const numberOfElements = propertyTable.count;
|
|
10319
|
+
for (const propertyName in schemaClass.properties) {
|
|
10320
|
+
const classProperty = schemaClass.properties[propertyName];
|
|
10321
|
+
const propertyTableProperty = propertyTable.properties?.[propertyName];
|
|
10322
|
+
if (propertyTableProperty) {
|
|
10323
|
+
const data = getPropertyDataFromBinarySource(scenegraph, schema, classProperty, numberOfElements, propertyTableProperty);
|
|
10324
|
+
propertyTableProperty.data = data;
|
|
10325
|
+
}
|
|
10326
|
+
}
|
|
10327
|
+
}
|
|
10328
|
+
function getPropertyDataFromBinarySource(scenegraph, schema, classProperty, numberOfElements, propertyTableProperty) {
|
|
10329
|
+
let data = [];
|
|
10330
|
+
const valuesBufferView = propertyTableProperty.values;
|
|
10331
|
+
const valuesDataBytes = scenegraph.getTypedArrayForBufferView(valuesBufferView);
|
|
10332
|
+
let arrayOffsets = null;
|
|
10333
|
+
if (classProperty.array && typeof classProperty.count === "undefined" && typeof propertyTableProperty.arrayOffsets !== "undefined" && typeof propertyTableProperty.arrayOffsetType !== "undefined") {
|
|
10334
|
+
arrayOffsets = getOffsetArray(scenegraph, propertyTableProperty.arrayOffsets, propertyTableProperty.arrayOffsetType, numberOfElements);
|
|
10335
|
+
}
|
|
10336
|
+
let stringOffsets = null;
|
|
10337
|
+
if (typeof propertyTableProperty.stringOffsets !== "undefined" && typeof propertyTableProperty.stringOffsetType !== "undefined") {
|
|
10338
|
+
stringOffsets = getOffsetArray(scenegraph, propertyTableProperty.stringOffsets, propertyTableProperty.stringOffsetType, numberOfElements);
|
|
10339
|
+
}
|
|
10340
|
+
switch (classProperty.type) {
|
|
10341
|
+
case "SCALAR":
|
|
10342
|
+
case "VEC2":
|
|
10343
|
+
case "VEC3":
|
|
10344
|
+
case "VEC4":
|
|
10345
|
+
case "MAT2":
|
|
10346
|
+
case "MAT3":
|
|
10347
|
+
case "MAT4": {
|
|
10348
|
+
data = getPropertyDataNumeric(classProperty, numberOfElements, valuesDataBytes, arrayOffsets);
|
|
10349
|
+
break;
|
|
10350
|
+
}
|
|
10351
|
+
case "BOOLEAN": {
|
|
10352
|
+
throw new Error(`Not implemented - classProperty.type=${classProperty.type}`);
|
|
10353
|
+
}
|
|
10354
|
+
case "STRING": {
|
|
10355
|
+
data = getPropertyDataString(classProperty, numberOfElements, valuesDataBytes, arrayOffsets, stringOffsets);
|
|
10356
|
+
break;
|
|
10357
|
+
}
|
|
10358
|
+
case "ENUM": {
|
|
10359
|
+
data = getPropertyDataENUM(schema, classProperty, numberOfElements, valuesDataBytes, arrayOffsets);
|
|
10360
|
+
break;
|
|
10361
|
+
}
|
|
10362
|
+
default:
|
|
10363
|
+
throw new Error(`Unknown classProperty type ${classProperty.type}`);
|
|
10364
|
+
}
|
|
10365
|
+
return data;
|
|
10366
|
+
}
|
|
10367
|
+
function getOffsetArray(scenegraph, offsets, offsetType, numberOfElements) {
|
|
10368
|
+
const arrayOffsetsBufferView = offsets;
|
|
10369
|
+
const arrayOffsetsBytes = scenegraph.getTypedArrayForBufferView(arrayOffsetsBufferView);
|
|
10370
|
+
const arrayOffsets = convertRawBufferToMetadataArray(arrayOffsetsBytes, "SCALAR", offsetType, numberOfElements + 1);
|
|
10371
|
+
return arrayOffsets;
|
|
10372
|
+
}
|
|
10373
|
+
function getPropertyDataNumeric(classProperty, numberOfElements, valuesDataBytes, arrayOffsets) {
|
|
10374
|
+
const isArray2 = classProperty.array;
|
|
10375
|
+
const arrayCount = classProperty.count;
|
|
10376
|
+
const elementSize = getArrayElementByteSize(classProperty.type, classProperty.componentType);
|
|
10377
|
+
const elementCount = valuesDataBytes.byteLength / elementSize;
|
|
10378
|
+
let valuesData;
|
|
10379
|
+
if (classProperty.componentType) {
|
|
10380
|
+
valuesData = convertRawBufferToMetadataArray(valuesDataBytes, classProperty.type, classProperty.componentType, elementCount);
|
|
10381
|
+
} else {
|
|
10382
|
+
valuesData = valuesDataBytes;
|
|
10383
|
+
}
|
|
10384
|
+
if (isArray2) {
|
|
10385
|
+
if (arrayOffsets) {
|
|
10386
|
+
return handleVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytes.length, elementSize);
|
|
10387
|
+
}
|
|
10388
|
+
if (arrayCount) {
|
|
10389
|
+
return handleFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);
|
|
10390
|
+
}
|
|
10391
|
+
return [];
|
|
10392
|
+
}
|
|
10393
|
+
const attributeValueArray = [];
|
|
10394
|
+
for (let index = 0; index < numberOfElements; index++) {
|
|
10395
|
+
const value = valuesData[index];
|
|
10396
|
+
attributeValueArray.push(value);
|
|
10397
|
+
}
|
|
10398
|
+
return attributeValueArray;
|
|
10399
|
+
}
|
|
10400
|
+
function handleVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytesLength, elementSize) {
|
|
10401
|
+
const attributeValueArray = [];
|
|
10402
|
+
for (let index = 0; index < numberOfElements; index++) {
|
|
10403
|
+
const array = [];
|
|
10404
|
+
const arrayOffset = arrayOffsets[index];
|
|
10405
|
+
const arrayByteSize = arrayOffsets[index + 1] - arrayOffsets[index];
|
|
10406
|
+
if (arrayByteSize + arrayOffset <= valuesDataBytesLength) {
|
|
10407
|
+
const typedArrayOffset = arrayOffset / elementSize;
|
|
10408
|
+
const elementCount = arrayByteSize / elementSize;
|
|
10409
|
+
for (let i2 = 0; i2 < elementCount; i2++) {
|
|
10410
|
+
const value = valuesData[typedArrayOffset + i2];
|
|
10411
|
+
array.push(value);
|
|
10412
|
+
}
|
|
10413
|
+
}
|
|
10414
|
+
attributeValueArray.push(array);
|
|
10415
|
+
}
|
|
10416
|
+
return attributeValueArray;
|
|
10417
|
+
}
|
|
10418
|
+
function handleFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount) {
|
|
10419
|
+
const attributeValueArray = [];
|
|
10420
|
+
for (let index = 0; index < numberOfElements; index++) {
|
|
10421
|
+
const array = [];
|
|
10422
|
+
for (let i2 = 0; i2 < arrayCount; i2++) {
|
|
10423
|
+
const value = valuesData[i2];
|
|
10424
|
+
array.push(value);
|
|
10425
|
+
}
|
|
10426
|
+
attributeValueArray.push(array);
|
|
10427
|
+
}
|
|
10428
|
+
return attributeValueArray;
|
|
10429
|
+
}
|
|
10430
|
+
function getPropertyDataString(classProperty, numberOfElements, valuesDataBytes, arrayOffsets, stringOffsets) {
|
|
10431
|
+
if (arrayOffsets) {
|
|
10432
|
+
throw new Error(`Not implemented - classProperty.type=${classProperty.type}`);
|
|
10433
|
+
}
|
|
10434
|
+
if (stringOffsets) {
|
|
10435
|
+
const stringsArray = [];
|
|
10436
|
+
const textDecoder = new TextDecoder("utf8");
|
|
10437
|
+
let stringOffset = 0;
|
|
10438
|
+
for (let index = 0; index < numberOfElements; index++) {
|
|
10439
|
+
const stringByteSize = stringOffsets[index + 1] - stringOffsets[index];
|
|
10440
|
+
if (stringByteSize + stringOffset <= valuesDataBytes.length) {
|
|
10441
|
+
const stringData = valuesDataBytes.subarray(stringOffset, stringByteSize + stringOffset);
|
|
10442
|
+
const stringAttribute = textDecoder.decode(stringData);
|
|
10443
|
+
stringsArray.push(stringAttribute);
|
|
10444
|
+
stringOffset += stringByteSize;
|
|
10445
|
+
}
|
|
10446
|
+
}
|
|
10447
|
+
return stringsArray;
|
|
10448
|
+
}
|
|
10449
|
+
return [];
|
|
10450
|
+
}
|
|
10451
|
+
function getPropertyDataENUM(schema, classProperty, numberOfElements, valuesDataBytes, arrayOffsets) {
|
|
10452
|
+
const data = [];
|
|
10453
|
+
const isArray2 = classProperty.array;
|
|
10454
|
+
const arrayCount = classProperty.count;
|
|
10455
|
+
const enumType = classProperty.enumType;
|
|
10456
|
+
if (!enumType) {
|
|
10457
|
+
throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");
|
|
10458
|
+
}
|
|
10459
|
+
const enumEntry = schema.enums?.[enumType];
|
|
10460
|
+
if (!enumEntry) {
|
|
10461
|
+
throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${enumType}`);
|
|
10462
|
+
}
|
|
10463
|
+
const enumValueType = enumEntry.valueType || "UINT16";
|
|
10464
|
+
const elementSize = getArrayElementByteSize(classProperty.type, enumValueType);
|
|
10465
|
+
const elementCount = valuesDataBytes.byteLength / elementSize;
|
|
10466
|
+
const valuesData = convertRawBufferToMetadataArray(valuesDataBytes, classProperty.type, enumValueType, elementCount);
|
|
10467
|
+
if (isArray2) {
|
|
10468
|
+
if (arrayOffsets) {
|
|
10469
|
+
return handleVariableLengthArrayENUM(valuesData, numberOfElements, arrayOffsets, valuesDataBytes.length, elementSize, enumEntry);
|
|
10470
|
+
}
|
|
10471
|
+
if (arrayCount) {
|
|
10472
|
+
return handleFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry);
|
|
10473
|
+
}
|
|
10474
|
+
return [];
|
|
10475
|
+
}
|
|
10476
|
+
for (let index = 0; index < numberOfElements; index++) {
|
|
10477
|
+
const enumValue = valuesData[index];
|
|
10478
|
+
const enumObject = getEnumByValue(enumEntry, enumValue);
|
|
10479
|
+
if (enumObject) {
|
|
10480
|
+
data.push(enumObject.name);
|
|
10481
|
+
}
|
|
10482
|
+
}
|
|
10483
|
+
return data;
|
|
10484
|
+
}
|
|
10485
|
+
function handleVariableLengthArrayENUM(valuesData, numberOfElements, arrayOffsets, valuesDataBytesLength, elementSize, enumEntry) {
|
|
10486
|
+
const attributeValueArray = [];
|
|
10487
|
+
for (let index = 0; index < numberOfElements; index++) {
|
|
10488
|
+
const array = [];
|
|
10489
|
+
const arrayOffset = arrayOffsets[index];
|
|
10490
|
+
const arrayByteSize = arrayOffsets[index + 1] - arrayOffsets[index];
|
|
10491
|
+
if (arrayByteSize + arrayOffset <= valuesDataBytesLength) {
|
|
10492
|
+
const typedArrayOffset = arrayOffset / elementSize;
|
|
10493
|
+
const elementCount = arrayByteSize / elementSize;
|
|
10494
|
+
for (let i2 = 0; i2 < elementCount; i2++) {
|
|
10495
|
+
const value = valuesData[typedArrayOffset + i2];
|
|
10496
|
+
const enumObject = getEnumByValue(enumEntry, value);
|
|
10497
|
+
if (enumObject) {
|
|
10498
|
+
array.push(enumObject.name);
|
|
10499
|
+
}
|
|
10500
|
+
}
|
|
10501
|
+
}
|
|
10502
|
+
attributeValueArray.push(array);
|
|
10503
|
+
}
|
|
10504
|
+
return attributeValueArray;
|
|
10505
|
+
}
|
|
10506
|
+
function handleFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry) {
|
|
10507
|
+
const attributeValueArray = [];
|
|
10508
|
+
for (let index = 0; index < numberOfElements; index++) {
|
|
10509
|
+
const array = [];
|
|
10510
|
+
for (let i2 = 0; i2 < arrayCount; i2++) {
|
|
10511
|
+
const value = valuesData[i2];
|
|
10512
|
+
const enumObject = getEnumByValue(enumEntry, value);
|
|
10513
|
+
if (enumObject) {
|
|
10514
|
+
array.push(enumObject.name);
|
|
10515
|
+
}
|
|
10516
|
+
}
|
|
10517
|
+
attributeValueArray.push(array);
|
|
10518
|
+
}
|
|
10519
|
+
return attributeValueArray;
|
|
10520
|
+
}
|
|
10521
|
+
function findPropertyTableByClass(propertyTables, schemaClassName) {
|
|
10522
|
+
for (let i2 = 0, len2 = propertyTables.length; i2 < len2; i2++) {
|
|
10523
|
+
const propertyTable = propertyTables[i2];
|
|
10524
|
+
if (propertyTable.class === schemaClassName) {
|
|
10525
|
+
return propertyTable;
|
|
10526
|
+
}
|
|
10527
|
+
}
|
|
10528
|
+
return null;
|
|
10529
|
+
}
|
|
10530
|
+
function getEnumByValue(enumEntry, value) {
|
|
10531
|
+
for (const enumValue of enumEntry.values) {
|
|
10532
|
+
if (enumValue.value === value) {
|
|
10533
|
+
return enumValue;
|
|
10534
|
+
}
|
|
10535
|
+
}
|
|
10536
|
+
return null;
|
|
10537
|
+
}
|
|
10538
|
+
var EXT_STRUCTURAL_METADATA_NAME, name;
|
|
10539
|
+
var init_EXT_structural_metadata = __esm({
|
|
10540
|
+
"../gltf/src/lib/extensions/EXT_structural_metadata.ts"() {
|
|
10541
|
+
init_gltf_scenegraph();
|
|
10542
|
+
init_data_processing();
|
|
10543
|
+
EXT_STRUCTURAL_METADATA_NAME = "EXT_structural_metadata";
|
|
10544
|
+
name = EXT_STRUCTURAL_METADATA_NAME;
|
|
10545
|
+
}
|
|
10546
|
+
});
|
|
10547
|
+
|
|
10548
|
+
// ../gltf/src/lib/extensions/EXT_mesh_features.ts
|
|
10549
|
+
var EXT_mesh_features_exports = {};
|
|
10550
|
+
__export(EXT_mesh_features_exports, {
|
|
10551
|
+
decode: () => decode2,
|
|
10552
|
+
name: () => name2
|
|
10553
|
+
});
|
|
10554
|
+
async function decode2(gltfData, options) {
|
|
10555
|
+
const scenegraph = new GLTFScenegraph(gltfData);
|
|
10556
|
+
decodeExtMeshFeatures(scenegraph, options);
|
|
10557
|
+
}
|
|
10558
|
+
function decodeExtMeshFeatures(scenegraph, options) {
|
|
10559
|
+
const json = scenegraph.gltf.json;
|
|
10560
|
+
if (!json.meshes) {
|
|
10561
|
+
return;
|
|
10562
|
+
}
|
|
10563
|
+
for (const mesh of json.meshes) {
|
|
10564
|
+
for (const primitive of mesh.primitives) {
|
|
10565
|
+
processMeshPrimitiveFeatures(scenegraph, primitive, options);
|
|
10566
|
+
}
|
|
10567
|
+
}
|
|
10568
|
+
}
|
|
10569
|
+
function processMeshPrimitiveFeatures(scenegraph, primitive, options) {
|
|
10570
|
+
const extension = primitive.extensions?.[EXT_MESH_FEATURES_NAME];
|
|
10571
|
+
const featureIds = extension?.featureIds;
|
|
10572
|
+
if (!featureIds)
|
|
10573
|
+
return;
|
|
10574
|
+
if (!extension.dataAttributeNames) {
|
|
10575
|
+
extension.dataAttributeNames = [];
|
|
10576
|
+
}
|
|
10577
|
+
let featureIdCount = 0;
|
|
10578
|
+
for (const featureId of featureIds) {
|
|
10579
|
+
let propertyTable = null;
|
|
10580
|
+
if (typeof featureId.propertyTable === "number") {
|
|
10581
|
+
propertyTable = getPropertyTablePopulated(scenegraph, featureId.propertyTable);
|
|
10582
|
+
}
|
|
10583
|
+
let propertyData = null;
|
|
10584
|
+
if (typeof featureId.attribute !== "undefined") {
|
|
10585
|
+
const accessorKey = `_FEATURE_ID_${featureId.attribute}`;
|
|
10586
|
+
const accessorIndex = primitive.attributes[accessorKey];
|
|
10587
|
+
const propertyDataTypedArray = scenegraph.getTypedArrayForAccessor(accessorIndex);
|
|
10588
|
+
propertyData = Array.prototype.slice.call(propertyDataTypedArray);
|
|
10589
|
+
} else if (typeof featureId.texture !== "undefined" && options?.gltf?.loadImages) {
|
|
10590
|
+
propertyData = getPrimitiveTextureData(scenegraph, featureId.texture, primitive);
|
|
10591
|
+
} else {
|
|
10592
|
+
}
|
|
10593
|
+
const attributeName = featureId.label || propertyTable?.name || `featureAttribute${featureIdCount}`;
|
|
10594
|
+
const featureTable = [];
|
|
10595
|
+
if (propertyData) {
|
|
10596
|
+
primitivePropertyDataToAttributes(scenegraph, attributeName, propertyData, featureTable, primitive);
|
|
10597
|
+
}
|
|
10598
|
+
extension.dataAttributeNames.push(attributeName);
|
|
10599
|
+
featureId.data = featureTable;
|
|
10600
|
+
featureIdCount++;
|
|
10601
|
+
}
|
|
10602
|
+
}
|
|
10603
|
+
var EXT_MESH_FEATURES_NAME, name2;
|
|
10604
|
+
var init_EXT_mesh_features = __esm({
|
|
10605
|
+
"../gltf/src/lib/extensions/EXT_mesh_features.ts"() {
|
|
10606
|
+
init_gltf_scenegraph();
|
|
10607
|
+
init_data_processing();
|
|
10608
|
+
init_EXT_structural_metadata();
|
|
10609
|
+
EXT_MESH_FEATURES_NAME = "EXT_mesh_features";
|
|
10610
|
+
name2 = EXT_MESH_FEATURES_NAME;
|
|
10611
|
+
}
|
|
10612
|
+
});
|
|
10613
|
+
|
|
10614
|
+
// ../gltf/src/lib/extensions/deprecated/EXT_feature_metadata.ts
|
|
10615
|
+
var EXT_feature_metadata_exports = {};
|
|
10616
|
+
__export(EXT_feature_metadata_exports, {
|
|
10617
|
+
decode: () => decode3,
|
|
10618
|
+
name: () => name3
|
|
10619
|
+
});
|
|
10620
|
+
async function decode3(gltfData, options) {
|
|
10621
|
+
const scenegraph = new GLTFScenegraph(gltfData);
|
|
10622
|
+
decodeExtFeatureMetadata(scenegraph, options);
|
|
10623
|
+
}
|
|
10624
|
+
function decodeExtFeatureMetadata(scenegraph, options) {
|
|
10625
|
+
const extension = scenegraph.getExtension(EXT_FEATURE_METADATA_NAME);
|
|
10626
|
+
if (!extension)
|
|
10627
|
+
return;
|
|
10628
|
+
const schemaClasses = extension.schema?.classes;
|
|
10629
|
+
const { featureTables } = extension;
|
|
10630
|
+
if (schemaClasses && featureTables) {
|
|
10631
|
+
for (const schemaName in schemaClasses) {
|
|
10632
|
+
const schemaClass = schemaClasses[schemaName];
|
|
10633
|
+
const featureTable = findFeatureTableByName(featureTables, schemaName);
|
|
10634
|
+
if (featureTable) {
|
|
10635
|
+
handleFeatureTableProperties(scenegraph, featureTable, schemaClass);
|
|
10636
|
+
}
|
|
10637
|
+
}
|
|
10638
|
+
}
|
|
10639
|
+
const { featureTextures } = extension;
|
|
10640
|
+
if (schemaClasses && featureTextures && options.gltf?.loadImages) {
|
|
10641
|
+
for (const schemaName in schemaClasses) {
|
|
10642
|
+
const schemaClass = schemaClasses[schemaName];
|
|
10643
|
+
const featureTexture = findFeatureTextureByName(featureTextures, schemaName);
|
|
10644
|
+
if (featureTexture) {
|
|
10645
|
+
handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass);
|
|
10646
|
+
}
|
|
10647
|
+
}
|
|
10648
|
+
}
|
|
10649
|
+
}
|
|
10650
|
+
function handleFeatureTableProperties(scenegraph, featureTable, schemaClass) {
|
|
10651
|
+
for (const propertyName in schemaClass.properties) {
|
|
10652
|
+
const schemaProperty = schemaClass.properties[propertyName];
|
|
10653
|
+
const featureTableProperty = featureTable?.properties?.[propertyName];
|
|
10654
|
+
const numberOfFeatures = featureTable.count;
|
|
10655
|
+
if (featureTableProperty) {
|
|
10656
|
+
const data = getPropertyDataFromBinarySource2(scenegraph, schemaProperty, numberOfFeatures, featureTableProperty);
|
|
10657
|
+
featureTableProperty.data = data;
|
|
10658
|
+
}
|
|
10659
|
+
}
|
|
10660
|
+
}
|
|
10661
|
+
function handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass) {
|
|
10662
|
+
const attributeName = featureTexture.class;
|
|
10663
|
+
for (const propertyName in schemaClass.properties) {
|
|
10664
|
+
const featureTextureProperty = featureTexture?.properties?.[propertyName];
|
|
10665
|
+
if (featureTextureProperty) {
|
|
10666
|
+
const data = getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName);
|
|
10667
|
+
featureTextureProperty.data = data;
|
|
10668
|
+
}
|
|
10669
|
+
}
|
|
10670
|
+
}
|
|
10671
|
+
function getPropertyDataFromBinarySource2(scenegraph, schemaProperty, numberOfFeatures, featureTableProperty) {
|
|
10672
|
+
const bufferView = featureTableProperty.bufferView;
|
|
10673
|
+
const dataArray = scenegraph.getTypedArrayForBufferView(bufferView);
|
|
10674
|
+
switch (schemaProperty.type) {
|
|
10675
|
+
case "STRING": {
|
|
10676
|
+
const stringOffsetBufferView = featureTableProperty.stringOffsetBufferView;
|
|
10677
|
+
const offsetsData = scenegraph.getTypedArrayForBufferView(stringOffsetBufferView);
|
|
10678
|
+
return getStringAttributes(dataArray, offsetsData, numberOfFeatures);
|
|
10679
|
+
}
|
|
10680
|
+
default:
|
|
10681
|
+
}
|
|
10682
|
+
return dataArray;
|
|
10683
|
+
}
|
|
10684
|
+
function getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName) {
|
|
10685
|
+
const json = scenegraph.gltf.json;
|
|
10686
|
+
if (!json.meshes) {
|
|
10687
|
+
return [];
|
|
10688
|
+
}
|
|
10689
|
+
const featureTextureTable = [];
|
|
10690
|
+
for (const mesh of json.meshes) {
|
|
10691
|
+
for (const primitive of mesh.primitives) {
|
|
10692
|
+
processPrimitiveTextures(scenegraph, attributeName, featureTextureProperty, featureTextureTable, primitive);
|
|
10693
|
+
}
|
|
10694
|
+
}
|
|
10695
|
+
return featureTextureTable;
|
|
10696
|
+
}
|
|
10697
|
+
function processPrimitiveTextures(scenegraph, attributeName, featureTextureProperty, featureTextureTable, primitive) {
|
|
10698
|
+
const json = scenegraph.gltf.json;
|
|
10699
|
+
const textureData = [];
|
|
10700
|
+
const texCoordAccessorKey = `TEXCOORD_${featureTextureProperty.texture.texCoord}`;
|
|
10701
|
+
const texCoordAccessorIndex = primitive.attributes[texCoordAccessorKey];
|
|
10702
|
+
const texCoordBufferView = scenegraph.getBufferView(texCoordAccessorIndex);
|
|
10703
|
+
const texCoordArray = scenegraph.getTypedArrayForBufferView(texCoordBufferView);
|
|
10704
|
+
const textureCoordinates = new Float32Array(texCoordArray.buffer, texCoordArray.byteOffset, texCoordArray.length / 4);
|
|
10705
|
+
const textureIndex = featureTextureProperty.texture.index;
|
|
10706
|
+
const texture = json.textures?.[textureIndex];
|
|
10707
|
+
const imageIndex = texture?.source;
|
|
10708
|
+
if (typeof imageIndex !== "undefined") {
|
|
10709
|
+
const image = json.images?.[imageIndex];
|
|
10710
|
+
const mimeType = image?.mimeType;
|
|
10711
|
+
const parsedImage = scenegraph.gltf.images?.[imageIndex];
|
|
10712
|
+
if (parsedImage) {
|
|
10713
|
+
for (let index = 0; index < textureCoordinates.length; index += 2) {
|
|
10714
|
+
const value = getImageValueByCoordinates2(parsedImage, mimeType, textureCoordinates, index, featureTextureProperty.channels);
|
|
10715
|
+
textureData.push(value);
|
|
10716
|
+
}
|
|
10717
|
+
}
|
|
10718
|
+
}
|
|
10719
|
+
const featureIndices = [];
|
|
10720
|
+
for (const texelData of textureData) {
|
|
10721
|
+
let index = featureTextureTable.findIndex((item) => item === texelData);
|
|
10722
|
+
if (index === -1) {
|
|
10723
|
+
index = featureTextureTable.push(texelData) - 1;
|
|
10724
|
+
}
|
|
10725
|
+
featureIndices.push(index);
|
|
10726
|
+
}
|
|
10727
|
+
const typedArray = new Uint32Array(featureIndices);
|
|
10728
|
+
const bufferIndex = scenegraph.gltf.buffers.push({
|
|
10729
|
+
arrayBuffer: typedArray.buffer,
|
|
10730
|
+
byteOffset: 0,
|
|
10731
|
+
byteLength: typedArray.byteLength
|
|
10732
|
+
}) - 1;
|
|
10733
|
+
const bufferViewIndex = scenegraph.addBufferView(typedArray, bufferIndex, 0);
|
|
10734
|
+
const accessorIndex = scenegraph.addAccessor(bufferViewIndex, {
|
|
10735
|
+
size: 1,
|
|
10736
|
+
componentType: getComponentTypeFromArray(typedArray),
|
|
10737
|
+
count: typedArray.length
|
|
10738
|
+
});
|
|
10739
|
+
primitive.attributes[attributeName] = accessorIndex;
|
|
10740
|
+
}
|
|
10741
|
+
function getImageValueByCoordinates2(parsedImage, mimeType, textureCoordinates, index, channels) {
|
|
10742
|
+
const CHANNELS_MAP = {
|
|
10743
|
+
r: { offset: 0, shift: 0 },
|
|
10744
|
+
g: { offset: 1, shift: 8 },
|
|
10745
|
+
b: { offset: 2, shift: 16 },
|
|
10746
|
+
a: { offset: 3, shift: 24 }
|
|
10747
|
+
};
|
|
10748
|
+
const u = textureCoordinates[index];
|
|
10749
|
+
const v = textureCoordinates[index + 1];
|
|
10750
|
+
let components = 1;
|
|
10751
|
+
if (mimeType && (mimeType.indexOf("image/jpeg") !== -1 || mimeType.indexOf("image/png") !== -1))
|
|
10752
|
+
components = 4;
|
|
10753
|
+
const offset = coordinatesToOffset2(u, v, parsedImage, components);
|
|
10754
|
+
let value = 0;
|
|
10755
|
+
for (const c of channels) {
|
|
10756
|
+
const map2 = CHANNELS_MAP[c];
|
|
10757
|
+
const val = getVal(parsedImage, offset + map2.offset);
|
|
10758
|
+
value |= val << map2.shift;
|
|
10759
|
+
}
|
|
10760
|
+
return value;
|
|
10761
|
+
}
|
|
10762
|
+
function getVal(parsedImage, offset) {
|
|
10763
|
+
const imageData = getImageData(parsedImage);
|
|
10764
|
+
if (imageData.data.length <= offset) {
|
|
10765
|
+
throw new Error(`${imageData.data.length} <= ${offset}`);
|
|
10766
|
+
}
|
|
10767
|
+
return imageData.data[offset];
|
|
10768
|
+
}
|
|
10769
|
+
function coordinatesToOffset2(u, v, parsedImage, componentsCount = 1) {
|
|
10770
|
+
const w = parsedImage.width;
|
|
10771
|
+
const iX = emod(u) * (w - 1);
|
|
10772
|
+
const indX = Math.round(iX);
|
|
10773
|
+
const h = parsedImage.height;
|
|
10774
|
+
const iY = emod(v) * (h - 1);
|
|
10775
|
+
const indY = Math.round(iY);
|
|
10776
|
+
const components = parsedImage.components ? parsedImage.components : componentsCount;
|
|
10777
|
+
const offset = (indY * w + indX) * components;
|
|
10778
|
+
return offset;
|
|
10779
|
+
}
|
|
10780
|
+
function findFeatureTableByName(featureTables, schemaClassName) {
|
|
10781
|
+
for (const featureTableName in featureTables) {
|
|
10782
|
+
const featureTable = featureTables[featureTableName];
|
|
10783
|
+
if (featureTable.class === schemaClassName) {
|
|
10784
|
+
return featureTable;
|
|
10785
|
+
}
|
|
10786
|
+
}
|
|
10787
|
+
return null;
|
|
10788
|
+
}
|
|
10789
|
+
function findFeatureTextureByName(featureTextures, schemaClassName) {
|
|
10790
|
+
for (const featureTexturesName in featureTextures) {
|
|
10791
|
+
const featureTable = featureTextures[featureTexturesName];
|
|
10792
|
+
if (featureTable.class === schemaClassName) {
|
|
10793
|
+
return featureTable;
|
|
10794
|
+
}
|
|
10795
|
+
}
|
|
10796
|
+
return null;
|
|
10797
|
+
}
|
|
10798
|
+
function getStringAttributes(data, offsetsData, stringsCount) {
|
|
10799
|
+
const stringsArray = [];
|
|
10800
|
+
const textDecoder = new TextDecoder("utf8");
|
|
10801
|
+
let stringOffset = 0;
|
|
10802
|
+
const bytesPerStringSize = 4;
|
|
10803
|
+
for (let index = 0; index < stringsCount; index++) {
|
|
10804
|
+
const stringByteSize = offsetsData[(index + 1) * bytesPerStringSize] - offsetsData[index * bytesPerStringSize];
|
|
10805
|
+
const stringData = data.subarray(stringOffset, stringByteSize + stringOffset);
|
|
10806
|
+
const stringAttribute = textDecoder.decode(stringData);
|
|
10807
|
+
stringsArray.push(stringAttribute);
|
|
10808
|
+
stringOffset += stringByteSize;
|
|
10809
|
+
}
|
|
10810
|
+
return stringsArray;
|
|
10811
|
+
}
|
|
10812
|
+
var EXT_FEATURE_METADATA_NAME, name3;
|
|
10813
|
+
var init_EXT_feature_metadata = __esm({
|
|
10814
|
+
"../gltf/src/lib/extensions/deprecated/EXT_feature_metadata.ts"() {
|
|
10815
|
+
init_gltf_scenegraph();
|
|
10816
|
+
init_src8();
|
|
10817
|
+
init_gltf_utils();
|
|
10818
|
+
init_src7();
|
|
10819
|
+
EXT_FEATURE_METADATA_NAME = "EXT_feature_metadata";
|
|
10820
|
+
name3 = EXT_FEATURE_METADATA_NAME;
|
|
10821
|
+
}
|
|
10822
|
+
});
|
|
10823
|
+
|
|
10824
|
+
// ../gltf/src/lib/utils/version.ts
|
|
10825
|
+
var VERSION7;
|
|
10826
|
+
var init_version5 = __esm({
|
|
10827
|
+
"../gltf/src/lib/utils/version.ts"() {
|
|
10828
|
+
VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
10829
|
+
}
|
|
10830
|
+
});
|
|
10831
|
+
|
|
10832
|
+
// ../textures/src/lib/utils/version.ts
|
|
10833
|
+
var VERSION8;
|
|
10834
|
+
var init_version6 = __esm({
|
|
10835
|
+
"../textures/src/lib/utils/version.ts"() {
|
|
10836
|
+
VERSION8 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
|
|
10837
|
+
}
|
|
10838
|
+
});
|
|
10839
|
+
|
|
10840
|
+
// ../textures/src/lib/parsers/basis-module-loader.ts
|
|
10841
|
+
async function loadBasisTranscoderModule(options) {
|
|
10842
|
+
const modules = options.modules || {};
|
|
10843
|
+
if (modules.basis) {
|
|
10844
|
+
return modules.basis;
|
|
10845
|
+
}
|
|
10846
|
+
loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTranscoder(options);
|
|
10847
|
+
return await loadBasisTranscoderPromise;
|
|
10848
|
+
}
|
|
10849
|
+
async function loadBasisTranscoder(options) {
|
|
10850
|
+
let BASIS = null;
|
|
10851
|
+
let wasmBinary = null;
|
|
10852
|
+
[BASIS, wasmBinary] = await Promise.all([
|
|
10853
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, "textures", options),
|
|
10854
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, "textures", options)
|
|
10855
|
+
]);
|
|
10856
|
+
BASIS = BASIS || globalThis.BASIS;
|
|
10857
|
+
return await initializeBasisTranscoderModule(BASIS, wasmBinary);
|
|
10858
|
+
}
|
|
10859
|
+
function initializeBasisTranscoderModule(BasisModule, wasmBinary) {
|
|
10860
|
+
const options = {};
|
|
10861
|
+
if (wasmBinary) {
|
|
10862
|
+
options.wasmBinary = wasmBinary;
|
|
10863
|
+
}
|
|
10864
|
+
return new Promise((resolve2) => {
|
|
10865
|
+
BasisModule(options).then((module) => {
|
|
10866
|
+
const { BasisFile, initializeBasis } = module;
|
|
10867
|
+
initializeBasis();
|
|
10868
|
+
resolve2({ BasisFile });
|
|
10869
|
+
});
|
|
10870
|
+
});
|
|
10871
|
+
}
|
|
10872
|
+
async function loadBasisEncoderModule(options) {
|
|
10873
|
+
const modules = options.modules || {};
|
|
10874
|
+
if (modules.basisEncoder) {
|
|
10875
|
+
return modules.basisEncoder;
|
|
10876
|
+
}
|
|
10877
|
+
loadBasisEncoderPromise = loadBasisEncoderPromise || loadBasisEncoder(options);
|
|
10878
|
+
return await loadBasisEncoderPromise;
|
|
10879
|
+
}
|
|
10880
|
+
async function loadBasisEncoder(options) {
|
|
10881
|
+
let BASIS_ENCODER = null;
|
|
10882
|
+
let wasmBinary = null;
|
|
10883
|
+
[BASIS_ENCODER, wasmBinary] = await Promise.all([
|
|
10884
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options),
|
|
10885
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options)
|
|
10886
|
+
]);
|
|
10887
|
+
BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
|
|
10888
|
+
return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
|
|
10889
|
+
}
|
|
10890
|
+
function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
|
|
10891
|
+
const options = {};
|
|
10892
|
+
if (wasmBinary) {
|
|
10893
|
+
options.wasmBinary = wasmBinary;
|
|
10894
|
+
}
|
|
10895
|
+
return new Promise((resolve2) => {
|
|
10896
|
+
BasisEncoderModule(options).then((module) => {
|
|
10897
|
+
const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module;
|
|
10898
|
+
initializeBasis();
|
|
10899
|
+
resolve2({ BasisFile, KTX2File, BasisEncoder });
|
|
10900
|
+
});
|
|
10901
|
+
});
|
|
10902
|
+
}
|
|
10903
|
+
var BASIS_EXTERNAL_LIBRARIES, loadBasisTranscoderPromise, loadBasisEncoderPromise;
|
|
10904
|
+
var init_basis_module_loader = __esm({
|
|
10905
|
+
"../textures/src/lib/parsers/basis-module-loader.ts"() {
|
|
10906
|
+
init_src();
|
|
10907
|
+
BASIS_EXTERNAL_LIBRARIES = {
|
|
10908
|
+
TRANSCODER: "basis_transcoder.js",
|
|
10909
|
+
TRANSCODER_WASM: "basis_transcoder.wasm",
|
|
10910
|
+
ENCODER: "basis_encoder.js",
|
|
10911
|
+
ENCODER_WASM: "basis_encoder.wasm"
|
|
10912
|
+
};
|
|
10913
|
+
}
|
|
10914
|
+
});
|
|
10915
|
+
|
|
10916
|
+
// ../textures/src/lib/gl-extensions.ts
|
|
10917
|
+
var GL_EXTENSIONS_CONSTANTS;
|
|
10918
|
+
var init_gl_extensions = __esm({
|
|
10919
|
+
"../textures/src/lib/gl-extensions.ts"() {
|
|
10920
|
+
GL_EXTENSIONS_CONSTANTS = {
|
|
10921
|
+
COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
|
|
10922
|
+
COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
|
|
10923
|
+
COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
|
|
10924
|
+
COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779,
|
|
10925
|
+
COMPRESSED_R11_EAC: 37488,
|
|
10926
|
+
COMPRESSED_SIGNED_R11_EAC: 37489,
|
|
10927
|
+
COMPRESSED_RG11_EAC: 37490,
|
|
10928
|
+
COMPRESSED_SIGNED_RG11_EAC: 37491,
|
|
10929
|
+
COMPRESSED_RGB8_ETC2: 37492,
|
|
10930
|
+
COMPRESSED_RGBA8_ETC2_EAC: 37493,
|
|
10931
|
+
COMPRESSED_SRGB8_ETC2: 37494,
|
|
10932
|
+
COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
|
|
10933
|
+
COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
|
|
10934
|
+
COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
|
|
10935
|
+
COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
|
|
10936
|
+
COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
|
|
10937
|
+
COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
|
|
10938
|
+
COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
|
|
10939
|
+
COMPRESSED_RGB_ETC1_WEBGL: 36196,
|
|
10940
|
+
COMPRESSED_RGB_ATC_WEBGL: 35986,
|
|
10941
|
+
COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
|
|
10942
|
+
COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
|
|
10943
|
+
COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
|
|
10944
|
+
COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
|
|
10945
|
+
COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
|
|
10946
|
+
COMPRESSED_RGBA_ASTC_6X5_KHR: 37811,
|
|
10947
|
+
COMPRESSED_RGBA_ASTC_6X6_KHR: 37812,
|
|
10948
|
+
COMPRESSED_RGBA_ASTC_8X5_KHR: 37813,
|
|
10949
|
+
COMPRESSED_RGBA_ASTC_8X6_KHR: 37814,
|
|
10950
|
+
COMPRESSED_RGBA_ASTC_8X8_KHR: 37815,
|
|
10951
|
+
COMPRESSED_RGBA_ASTC_10X5_KHR: 37816,
|
|
10952
|
+
COMPRESSED_RGBA_ASTC_10X6_KHR: 37817,
|
|
10953
|
+
COMPRESSED_RGBA_ASTC_10X8_KHR: 37818,
|
|
10954
|
+
COMPRESSED_RGBA_ASTC_10X10_KHR: 37819,
|
|
10955
|
+
COMPRESSED_RGBA_ASTC_12X10_KHR: 37820,
|
|
10956
|
+
COMPRESSED_RGBA_ASTC_12X12_KHR: 37821,
|
|
10957
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: 37840,
|
|
10958
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: 37841,
|
|
10959
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: 37842,
|
|
10960
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: 37843,
|
|
10961
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: 37844,
|
|
10962
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: 37845,
|
|
10963
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: 37846,
|
|
10964
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: 37847,
|
|
10965
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: 37848,
|
|
10966
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: 37849,
|
|
10967
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: 37850,
|
|
10968
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
|
|
10969
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
|
|
10970
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
|
|
10971
|
+
COMPRESSED_RED_RGTC1_EXT: 36283,
|
|
10972
|
+
COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
|
|
10973
|
+
COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
|
|
10974
|
+
COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
|
|
10975
|
+
COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
|
|
10976
|
+
COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
|
|
10977
|
+
COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
|
|
10978
|
+
COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: 35919
|
|
10979
|
+
};
|
|
10980
|
+
}
|
|
10981
|
+
});
|
|
10982
|
+
|
|
10983
|
+
// ../textures/src/lib/utils/texture-formats.ts
|
|
10984
|
+
function getSupportedGPUTextureFormats(gl) {
|
|
10985
|
+
if (!formats) {
|
|
10986
|
+
gl = gl || getWebGLContext() || void 0;
|
|
10987
|
+
formats = new Set();
|
|
10988
|
+
for (const prefix of BROWSER_PREFIXES) {
|
|
10989
|
+
for (const extension in WEBGL_EXTENSIONS) {
|
|
10990
|
+
if (gl && gl.getExtension(`${prefix}${extension}`)) {
|
|
10991
|
+
const gpuTextureFormat = WEBGL_EXTENSIONS[extension];
|
|
10992
|
+
formats.add(gpuTextureFormat);
|
|
10993
|
+
}
|
|
10994
|
+
}
|
|
10995
|
+
}
|
|
10996
|
+
}
|
|
10997
|
+
return formats;
|
|
10998
|
+
}
|
|
10999
|
+
function getWebGLContext() {
|
|
11000
|
+
try {
|
|
11001
|
+
const canvas = document.createElement("canvas");
|
|
11002
|
+
return canvas.getContext("webgl");
|
|
11003
|
+
} catch (error) {
|
|
11004
|
+
return null;
|
|
11005
|
+
}
|
|
11006
|
+
}
|
|
11007
|
+
var BROWSER_PREFIXES, WEBGL_EXTENSIONS, formats;
|
|
11008
|
+
var init_texture_formats = __esm({
|
|
11009
|
+
"../textures/src/lib/utils/texture-formats.ts"() {
|
|
11010
|
+
BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
|
|
11011
|
+
WEBGL_EXTENSIONS = {
|
|
11012
|
+
WEBGL_compressed_texture_s3tc: "dxt",
|
|
11013
|
+
WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb",
|
|
11014
|
+
WEBGL_compressed_texture_etc1: "etc1",
|
|
11015
|
+
WEBGL_compressed_texture_etc: "etc2",
|
|
11016
|
+
WEBGL_compressed_texture_pvrtc: "pvrtc",
|
|
11017
|
+
WEBGL_compressed_texture_atc: "atc",
|
|
11018
|
+
WEBGL_compressed_texture_astc: "astc",
|
|
11019
|
+
EXT_texture_compression_rgtc: "rgtc"
|
|
11020
|
+
};
|
|
11021
|
+
formats = null;
|
|
11022
|
+
}
|
|
11023
|
+
});
|
|
11024
|
+
|
|
11025
|
+
// ../../node_modules/ktx-parse/dist/ktx-parse.modern.js
|
|
11026
|
+
var t, n, i, s, a, r, o, l, f;
|
|
11027
|
+
var init_ktx_parse_modern = __esm({
|
|
11028
|
+
"../../node_modules/ktx-parse/dist/ktx-parse.modern.js"() {
|
|
11029
|
+
t = new Uint8Array([0]);
|
|
11030
|
+
!function(t2) {
|
|
11031
|
+
t2[t2.NONE = 0] = "NONE", t2[t2.BASISLZ = 1] = "BASISLZ", t2[t2.ZSTD = 2] = "ZSTD", t2[t2.ZLIB = 3] = "ZLIB";
|
|
11032
|
+
}(n || (n = {})), function(t2) {
|
|
11033
|
+
t2[t2.BASICFORMAT = 0] = "BASICFORMAT";
|
|
11034
|
+
}(i || (i = {})), function(t2) {
|
|
11035
|
+
t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.ETC1S = 163] = "ETC1S", t2[t2.UASTC = 166] = "UASTC";
|
|
11036
|
+
}(s || (s = {})), function(t2) {
|
|
11037
|
+
t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.SRGB = 1] = "SRGB";
|
|
11038
|
+
}(a || (a = {})), function(t2) {
|
|
11039
|
+
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";
|
|
11040
|
+
}(r || (r = {})), function(t2) {
|
|
11041
|
+
t2[t2.ALPHA_STRAIGHT = 0] = "ALPHA_STRAIGHT", t2[t2.ALPHA_PREMULTIPLIED = 1] = "ALPHA_PREMULTIPLIED";
|
|
11042
|
+
}(o || (o = {})), function(t2) {
|
|
11043
|
+
t2[t2.RGB = 0] = "RGB", t2[t2.RRR = 3] = "RRR", t2[t2.GGG = 4] = "GGG", t2[t2.AAA = 15] = "AAA";
|
|
11044
|
+
}(l || (l = {})), function(t2) {
|
|
11045
|
+
t2[t2.RGB = 0] = "RGB", t2[t2.RGBA = 3] = "RGBA", t2[t2.RRR = 4] = "RRR", t2[t2.RRRG = 5] = "RRRG";
|
|
11046
|
+
}(f || (f = {}));
|
|
11047
|
+
}
|
|
11048
|
+
});
|
|
11049
|
+
|
|
11050
|
+
// ../textures/src/lib/parsers/parse-ktx.ts
|
|
11051
|
+
function isKTX(data) {
|
|
11052
|
+
const id = new Uint8Array(data);
|
|
11053
|
+
const notKTX = id.byteLength < KTX2_ID.length || id[0] !== KTX2_ID[0] || id[1] !== KTX2_ID[1] || id[2] !== KTX2_ID[2] || id[3] !== KTX2_ID[3] || id[4] !== KTX2_ID[4] || id[5] !== KTX2_ID[5] || id[6] !== KTX2_ID[6] || id[7] !== KTX2_ID[7] || id[8] !== KTX2_ID[8] || id[9] !== KTX2_ID[9] || id[10] !== KTX2_ID[10] || id[11] !== KTX2_ID[11];
|
|
11054
|
+
return !notKTX;
|
|
11055
|
+
}
|
|
11056
|
+
var KTX2_ID;
|
|
11057
|
+
var init_parse_ktx = __esm({
|
|
11058
|
+
"../textures/src/lib/parsers/parse-ktx.ts"() {
|
|
11059
|
+
init_ktx_parse_modern();
|
|
11060
|
+
KTX2_ID = [
|
|
11061
|
+
171,
|
|
11062
|
+
75,
|
|
11063
|
+
84,
|
|
11064
|
+
88,
|
|
11065
|
+
32,
|
|
11066
|
+
50,
|
|
11067
|
+
48,
|
|
11068
|
+
187,
|
|
11069
|
+
13,
|
|
11070
|
+
10,
|
|
11071
|
+
26,
|
|
11072
|
+
10
|
|
11073
|
+
];
|
|
11074
|
+
}
|
|
11075
|
+
});
|
|
11076
|
+
|
|
11077
|
+
// ../textures/src/lib/parsers/parse-basis.ts
|
|
11078
|
+
async function parseBasis(data, options) {
|
|
11079
|
+
if (options.basis.containerFormat === "auto") {
|
|
11080
|
+
if (isKTX(data)) {
|
|
11081
|
+
const fileConstructors = await loadBasisEncoderModule(options);
|
|
11082
|
+
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
11083
|
+
}
|
|
11084
|
+
const { BasisFile } = await loadBasisTranscoderModule(options);
|
|
11085
|
+
return parseBasisFile(BasisFile, data, options);
|
|
11086
|
+
}
|
|
11087
|
+
switch (options.basis.module) {
|
|
11088
|
+
case "encoder":
|
|
11089
|
+
const fileConstructors = await loadBasisEncoderModule(options);
|
|
11090
|
+
switch (options.basis.containerFormat) {
|
|
11091
|
+
case "ktx2":
|
|
11092
|
+
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
11093
|
+
case "basis":
|
|
11094
|
+
default:
|
|
11095
|
+
return parseBasisFile(fileConstructors.BasisFile, data, options);
|
|
10505
11096
|
}
|
|
10506
|
-
|
|
10507
|
-
|
|
11097
|
+
case "transcoder":
|
|
11098
|
+
default:
|
|
11099
|
+
const { BasisFile } = await loadBasisTranscoderModule(options);
|
|
11100
|
+
return parseBasisFile(BasisFile, data, options);
|
|
11101
|
+
}
|
|
11102
|
+
}
|
|
11103
|
+
function parseBasisFile(BasisFile, data, options) {
|
|
11104
|
+
const basisFile = new BasisFile(new Uint8Array(data));
|
|
11105
|
+
try {
|
|
11106
|
+
if (!basisFile.startTranscoding()) {
|
|
11107
|
+
throw new Error("Failed to start basis transcoding");
|
|
11108
|
+
}
|
|
11109
|
+
const imageCount = basisFile.getNumImages();
|
|
11110
|
+
const images = [];
|
|
11111
|
+
for (let imageIndex = 0; imageIndex < imageCount; imageIndex++) {
|
|
11112
|
+
const levelsCount = basisFile.getNumLevels(imageIndex);
|
|
11113
|
+
const levels = [];
|
|
11114
|
+
for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
|
|
11115
|
+
levels.push(transcodeImage(basisFile, imageIndex, levelIndex, options));
|
|
10508
11116
|
}
|
|
10509
|
-
|
|
10510
|
-
|
|
10511
|
-
|
|
10512
|
-
|
|
10513
|
-
|
|
10514
|
-
|
|
10515
|
-
|
|
10516
|
-
|
|
10517
|
-
|
|
10518
|
-
|
|
10519
|
-
|
|
10520
|
-
|
|
10521
|
-
|
|
10522
|
-
|
|
10523
|
-
|
|
10524
|
-
|
|
10525
|
-
|
|
11117
|
+
images.push(levels);
|
|
11118
|
+
}
|
|
11119
|
+
return images;
|
|
11120
|
+
} finally {
|
|
11121
|
+
basisFile.close();
|
|
11122
|
+
basisFile.delete();
|
|
11123
|
+
}
|
|
11124
|
+
}
|
|
11125
|
+
function transcodeImage(basisFile, imageIndex, levelIndex, options) {
|
|
11126
|
+
const width = basisFile.getImageWidth(imageIndex, levelIndex);
|
|
11127
|
+
const height = basisFile.getImageHeight(imageIndex, levelIndex);
|
|
11128
|
+
const hasAlpha = basisFile.getHasAlpha();
|
|
11129
|
+
const { compressed, format, basisFormat } = getBasisOptions(options, hasAlpha);
|
|
11130
|
+
const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
|
|
11131
|
+
const decodedData = new Uint8Array(decodedSize);
|
|
11132
|
+
if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
|
|
11133
|
+
throw new Error("failed to start Basis transcoding");
|
|
11134
|
+
}
|
|
11135
|
+
return {
|
|
11136
|
+
width,
|
|
11137
|
+
height,
|
|
11138
|
+
data: decodedData,
|
|
11139
|
+
compressed,
|
|
11140
|
+
format,
|
|
11141
|
+
hasAlpha
|
|
11142
|
+
};
|
|
11143
|
+
}
|
|
11144
|
+
function parseKTX2File(KTX2File, data, options) {
|
|
11145
|
+
const ktx2File = new KTX2File(new Uint8Array(data));
|
|
11146
|
+
try {
|
|
11147
|
+
if (!ktx2File.startTranscoding()) {
|
|
11148
|
+
throw new Error("failed to start KTX2 transcoding");
|
|
11149
|
+
}
|
|
11150
|
+
const levelsCount = ktx2File.getLevels();
|
|
11151
|
+
const levels = [];
|
|
11152
|
+
for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
|
|
11153
|
+
levels.push(transcodeKTX2Image(ktx2File, levelIndex, options));
|
|
11154
|
+
break;
|
|
11155
|
+
}
|
|
11156
|
+
return [levels];
|
|
11157
|
+
} finally {
|
|
11158
|
+
ktx2File.close();
|
|
11159
|
+
ktx2File.delete();
|
|
11160
|
+
}
|
|
11161
|
+
}
|
|
11162
|
+
function transcodeKTX2Image(ktx2File, levelIndex, options) {
|
|
11163
|
+
const { alphaFlag, height, width } = ktx2File.getImageLevelInfo(levelIndex, 0, 0);
|
|
11164
|
+
const { compressed, format, basisFormat } = getBasisOptions(options, alphaFlag);
|
|
11165
|
+
const decodedSize = ktx2File.getImageTranscodedSizeInBytes(levelIndex, 0, 0, basisFormat);
|
|
11166
|
+
const decodedData = new Uint8Array(decodedSize);
|
|
11167
|
+
if (!ktx2File.transcodeImage(decodedData, levelIndex, 0, 0, basisFormat, 0, -1, -1)) {
|
|
11168
|
+
throw new Error("Failed to transcode KTX2 image");
|
|
11169
|
+
}
|
|
11170
|
+
return {
|
|
11171
|
+
width,
|
|
11172
|
+
height,
|
|
11173
|
+
data: decodedData,
|
|
11174
|
+
compressed,
|
|
11175
|
+
levelSize: decodedSize,
|
|
11176
|
+
hasAlpha: alphaFlag,
|
|
11177
|
+
format
|
|
11178
|
+
};
|
|
11179
|
+
}
|
|
11180
|
+
function getBasisOptions(options, hasAlpha) {
|
|
11181
|
+
let format = options && options.basis && options.basis.format;
|
|
11182
|
+
if (format === "auto") {
|
|
11183
|
+
format = selectSupportedBasisFormat();
|
|
11184
|
+
}
|
|
11185
|
+
if (typeof format === "object") {
|
|
11186
|
+
format = hasAlpha ? format.alpha : format.noAlpha;
|
|
11187
|
+
}
|
|
11188
|
+
format = format.toLowerCase();
|
|
11189
|
+
return OutputFormat[format];
|
|
11190
|
+
}
|
|
11191
|
+
function selectSupportedBasisFormat() {
|
|
11192
|
+
const supportedFormats = getSupportedGPUTextureFormats();
|
|
11193
|
+
if (supportedFormats.has("astc")) {
|
|
11194
|
+
return "astc-4x4";
|
|
11195
|
+
} else if (supportedFormats.has("dxt")) {
|
|
11196
|
+
return {
|
|
11197
|
+
alpha: "bc3",
|
|
11198
|
+
noAlpha: "bc1"
|
|
11199
|
+
};
|
|
11200
|
+
} else if (supportedFormats.has("pvrtc")) {
|
|
11201
|
+
return {
|
|
11202
|
+
alpha: "pvrtc1-4-rgba",
|
|
11203
|
+
noAlpha: "pvrtc1-4-rgb"
|
|
11204
|
+
};
|
|
11205
|
+
} else if (supportedFormats.has("etc1")) {
|
|
11206
|
+
return "etc1";
|
|
11207
|
+
} else if (supportedFormats.has("etc2")) {
|
|
11208
|
+
return "etc2";
|
|
11209
|
+
}
|
|
11210
|
+
return "rgb565";
|
|
11211
|
+
}
|
|
11212
|
+
var OutputFormat;
|
|
11213
|
+
var init_parse_basis = __esm({
|
|
11214
|
+
"../textures/src/lib/parsers/parse-basis.ts"() {
|
|
11215
|
+
init_basis_module_loader();
|
|
11216
|
+
init_gl_extensions();
|
|
11217
|
+
init_texture_formats();
|
|
11218
|
+
init_parse_ktx();
|
|
11219
|
+
OutputFormat = {
|
|
11220
|
+
etc1: {
|
|
11221
|
+
basisFormat: 0,
|
|
11222
|
+
compressed: true,
|
|
11223
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL
|
|
11224
|
+
},
|
|
11225
|
+
etc2: { basisFormat: 1, compressed: true },
|
|
11226
|
+
bc1: {
|
|
11227
|
+
basisFormat: 2,
|
|
11228
|
+
compressed: true,
|
|
11229
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT
|
|
11230
|
+
},
|
|
11231
|
+
bc3: {
|
|
11232
|
+
basisFormat: 3,
|
|
11233
|
+
compressed: true,
|
|
11234
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT
|
|
11235
|
+
},
|
|
11236
|
+
bc4: { basisFormat: 4, compressed: true },
|
|
11237
|
+
bc5: { basisFormat: 5, compressed: true },
|
|
11238
|
+
"bc7-m6-opaque-only": { basisFormat: 6, compressed: true },
|
|
11239
|
+
"bc7-m5": { basisFormat: 7, compressed: true },
|
|
11240
|
+
"pvrtc1-4-rgb": {
|
|
11241
|
+
basisFormat: 8,
|
|
11242
|
+
compressed: true,
|
|
11243
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG
|
|
11244
|
+
},
|
|
11245
|
+
"pvrtc1-4-rgba": {
|
|
11246
|
+
basisFormat: 9,
|
|
11247
|
+
compressed: true,
|
|
11248
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
|
|
11249
|
+
},
|
|
11250
|
+
"astc-4x4": {
|
|
11251
|
+
basisFormat: 10,
|
|
11252
|
+
compressed: true,
|
|
11253
|
+
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR
|
|
11254
|
+
},
|
|
11255
|
+
"atc-rgb": { basisFormat: 11, compressed: true },
|
|
11256
|
+
"atc-rgba-interpolated-alpha": { basisFormat: 12, compressed: true },
|
|
11257
|
+
rgba32: { basisFormat: 13, compressed: false },
|
|
11258
|
+
rgb565: { basisFormat: 14, compressed: false },
|
|
11259
|
+
bgr565: { basisFormat: 15, compressed: false },
|
|
11260
|
+
rgba4444: { basisFormat: 16, compressed: false }
|
|
11261
|
+
};
|
|
11262
|
+
}
|
|
11263
|
+
});
|
|
11264
|
+
|
|
11265
|
+
// ../textures/src/basis-loader.ts
|
|
11266
|
+
var BasisWorkerLoader, BasisLoader;
|
|
11267
|
+
var init_basis_loader = __esm({
|
|
11268
|
+
"../textures/src/basis-loader.ts"() {
|
|
11269
|
+
init_version6();
|
|
11270
|
+
init_parse_basis();
|
|
11271
|
+
BasisWorkerLoader = {
|
|
11272
|
+
name: "Basis",
|
|
11273
|
+
id: "basis",
|
|
11274
|
+
module: "textures",
|
|
11275
|
+
version: VERSION8,
|
|
11276
|
+
worker: true,
|
|
11277
|
+
extensions: ["basis", "ktx2"],
|
|
11278
|
+
mimeTypes: ["application/octet-stream", "image/ktx2"],
|
|
11279
|
+
tests: ["sB"],
|
|
11280
|
+
binary: true,
|
|
11281
|
+
options: {
|
|
11282
|
+
basis: {
|
|
11283
|
+
format: "auto",
|
|
11284
|
+
libraryPath: "libs/",
|
|
11285
|
+
containerFormat: "auto",
|
|
11286
|
+
module: "transcoder"
|
|
10526
11287
|
}
|
|
10527
11288
|
}
|
|
10528
|
-
|
|
10529
|
-
|
|
10530
|
-
|
|
10531
|
-
|
|
10532
|
-
|
|
10533
|
-
|
|
10534
|
-
|
|
10535
|
-
|
|
10536
|
-
|
|
10537
|
-
|
|
10538
|
-
|
|
11289
|
+
};
|
|
11290
|
+
BasisLoader = {
|
|
11291
|
+
...BasisWorkerLoader,
|
|
11292
|
+
parse: parseBasis
|
|
11293
|
+
};
|
|
11294
|
+
}
|
|
11295
|
+
});
|
|
11296
|
+
|
|
11297
|
+
// ../textures/src/index.ts
|
|
11298
|
+
var init_src9 = __esm({
|
|
11299
|
+
"../textures/src/index.ts"() {
|
|
11300
|
+
init_basis_loader();
|
|
11301
|
+
init_parse_basis();
|
|
11302
|
+
}
|
|
11303
|
+
});
|
|
11304
|
+
|
|
11305
|
+
// ../gltf/src/lib/parsers/parse-glb.ts
|
|
11306
|
+
function getMagicString4(dataView, byteOffset = 0) {
|
|
11307
|
+
return `${String.fromCharCode(dataView.getUint8(byteOffset + 0))}${String.fromCharCode(dataView.getUint8(byteOffset + 1))}${String.fromCharCode(dataView.getUint8(byteOffset + 2))}${String.fromCharCode(dataView.getUint8(byteOffset + 3))}`;
|
|
11308
|
+
}
|
|
11309
|
+
function isGLB(arrayBuffer, byteOffset = 0, options = {}) {
|
|
11310
|
+
const dataView = new DataView(arrayBuffer);
|
|
11311
|
+
const { magic = MAGIC_glTF } = options;
|
|
11312
|
+
const magic1 = dataView.getUint32(byteOffset, false);
|
|
11313
|
+
return magic1 === magic || magic1 === MAGIC_glTF;
|
|
11314
|
+
}
|
|
11315
|
+
function parseGLBSync(glb, arrayBuffer, byteOffset = 0, options = {}) {
|
|
11316
|
+
const dataView = new DataView(arrayBuffer);
|
|
11317
|
+
const type = getMagicString4(dataView, byteOffset + 0);
|
|
11318
|
+
const version = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
|
|
11319
|
+
const byteLength = dataView.getUint32(byteOffset + 8, LITTLE_ENDIAN2);
|
|
11320
|
+
Object.assign(glb, {
|
|
11321
|
+
header: {
|
|
11322
|
+
byteOffset,
|
|
11323
|
+
byteLength,
|
|
11324
|
+
hasBinChunk: false
|
|
11325
|
+
},
|
|
11326
|
+
type,
|
|
11327
|
+
version,
|
|
11328
|
+
json: {},
|
|
11329
|
+
binChunks: []
|
|
11330
|
+
});
|
|
11331
|
+
byteOffset += GLB_FILE_HEADER_SIZE;
|
|
11332
|
+
switch (glb.version) {
|
|
11333
|
+
case 1:
|
|
11334
|
+
return parseGLBV1(glb, dataView, byteOffset);
|
|
11335
|
+
case 2:
|
|
11336
|
+
return parseGLBV2(glb, dataView, byteOffset, options = {});
|
|
11337
|
+
default:
|
|
11338
|
+
throw new Error(`Invalid GLB version ${glb.version}. Only supports version 1 and 2.`);
|
|
11339
|
+
}
|
|
11340
|
+
}
|
|
11341
|
+
function parseGLBV1(glb, dataView, byteOffset) {
|
|
11342
|
+
assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
|
|
11343
|
+
const contentLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN2);
|
|
11344
|
+
const contentFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
|
|
11345
|
+
byteOffset += GLB_CHUNK_HEADER_SIZE;
|
|
11346
|
+
assert2(contentFormat === GLB_V1_CONTENT_FORMAT_JSON);
|
|
11347
|
+
parseJSONChunk(glb, dataView, byteOffset, contentLength);
|
|
11348
|
+
byteOffset += contentLength;
|
|
11349
|
+
byteOffset += parseBINChunk(glb, dataView, byteOffset, glb.header.byteLength);
|
|
11350
|
+
return byteOffset;
|
|
11351
|
+
}
|
|
11352
|
+
function parseGLBV2(glb, dataView, byteOffset, options) {
|
|
11353
|
+
assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
|
|
11354
|
+
parseGLBChunksSync(glb, dataView, byteOffset, options);
|
|
11355
|
+
return byteOffset + glb.header.byteLength;
|
|
11356
|
+
}
|
|
11357
|
+
function parseGLBChunksSync(glb, dataView, byteOffset, options) {
|
|
11358
|
+
while (byteOffset + 8 <= glb.header.byteLength) {
|
|
11359
|
+
const chunkLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN2);
|
|
11360
|
+
const chunkFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
|
|
11361
|
+
byteOffset += GLB_CHUNK_HEADER_SIZE;
|
|
11362
|
+
switch (chunkFormat) {
|
|
11363
|
+
case GLB_CHUNK_TYPE_JSON:
|
|
11364
|
+
parseJSONChunk(glb, dataView, byteOffset, chunkLength);
|
|
11365
|
+
break;
|
|
11366
|
+
case GLB_CHUNK_TYPE_BIN:
|
|
11367
|
+
parseBINChunk(glb, dataView, byteOffset, chunkLength);
|
|
11368
|
+
break;
|
|
11369
|
+
case GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED:
|
|
11370
|
+
if (!options.strict) {
|
|
11371
|
+
parseJSONChunk(glb, dataView, byteOffset, chunkLength);
|
|
10539
11372
|
}
|
|
10540
|
-
|
|
10541
|
-
|
|
10542
|
-
|
|
10543
|
-
|
|
10544
|
-
}
|
|
11373
|
+
break;
|
|
11374
|
+
case GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED:
|
|
11375
|
+
if (!options.strict) {
|
|
11376
|
+
parseBINChunk(glb, dataView, byteOffset, chunkLength);
|
|
10545
11377
|
}
|
|
10546
|
-
|
|
10547
|
-
|
|
10548
|
-
|
|
11378
|
+
break;
|
|
11379
|
+
default:
|
|
11380
|
+
break;
|
|
11381
|
+
}
|
|
11382
|
+
byteOffset += padToNBytes(chunkLength, 4);
|
|
11383
|
+
}
|
|
11384
|
+
return byteOffset;
|
|
11385
|
+
}
|
|
11386
|
+
function parseJSONChunk(glb, dataView, byteOffset, chunkLength) {
|
|
11387
|
+
const jsonChunk = new Uint8Array(dataView.buffer, byteOffset, chunkLength);
|
|
11388
|
+
const textDecoder = new TextDecoder("utf8");
|
|
11389
|
+
const jsonText = textDecoder.decode(jsonChunk);
|
|
11390
|
+
glb.json = JSON.parse(jsonText);
|
|
11391
|
+
return padToNBytes(chunkLength, 4);
|
|
11392
|
+
}
|
|
11393
|
+
function parseBINChunk(glb, dataView, byteOffset, chunkLength) {
|
|
11394
|
+
glb.header.hasBinChunk = true;
|
|
11395
|
+
glb.binChunks.push({
|
|
11396
|
+
byteOffset,
|
|
11397
|
+
byteLength: chunkLength,
|
|
11398
|
+
arrayBuffer: dataView.buffer
|
|
11399
|
+
});
|
|
11400
|
+
return padToNBytes(chunkLength, 4);
|
|
11401
|
+
}
|
|
11402
|
+
var LITTLE_ENDIAN2, MAGIC_glTF, GLB_FILE_HEADER_SIZE, GLB_CHUNK_HEADER_SIZE, GLB_CHUNK_TYPE_JSON, GLB_CHUNK_TYPE_BIN, GLB_V1_CONTENT_FORMAT_JSON, GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED, GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED;
|
|
11403
|
+
var init_parse_glb = __esm({
|
|
11404
|
+
"../gltf/src/lib/parsers/parse-glb.ts"() {
|
|
11405
|
+
init_src2();
|
|
11406
|
+
LITTLE_ENDIAN2 = true;
|
|
11407
|
+
MAGIC_glTF = 1735152710;
|
|
11408
|
+
GLB_FILE_HEADER_SIZE = 12;
|
|
11409
|
+
GLB_CHUNK_HEADER_SIZE = 8;
|
|
11410
|
+
GLB_CHUNK_TYPE_JSON = 1313821514;
|
|
11411
|
+
GLB_CHUNK_TYPE_BIN = 5130562;
|
|
11412
|
+
GLB_V1_CONTENT_FORMAT_JSON = 0;
|
|
11413
|
+
GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED = 0;
|
|
11414
|
+
GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED = 1;
|
|
11415
|
+
}
|
|
11416
|
+
});
|
|
11417
|
+
|
|
11418
|
+
// ../gltf/src/lib/gltf-utils/resolve-url.ts
|
|
11419
|
+
function resolveUrl(url, options) {
|
|
11420
|
+
const absolute = url.startsWith("data:") || url.startsWith("http:") || url.startsWith("https:");
|
|
11421
|
+
if (absolute) {
|
|
11422
|
+
return url;
|
|
11423
|
+
}
|
|
11424
|
+
const baseUrl = options.baseUri || options.uri;
|
|
11425
|
+
if (!baseUrl) {
|
|
11426
|
+
throw new Error(`'baseUri' must be provided to resolve relative url ${url}`);
|
|
11427
|
+
}
|
|
11428
|
+
return baseUrl.substr(0, baseUrl.lastIndexOf("/") + 1) + url;
|
|
11429
|
+
}
|
|
11430
|
+
var init_resolve_url = __esm({
|
|
11431
|
+
"../gltf/src/lib/gltf-utils/resolve-url.ts"() {
|
|
11432
|
+
}
|
|
11433
|
+
});
|
|
11434
|
+
|
|
11435
|
+
// ../gltf/src/lib/gltf-utils/get-typed-array.ts
|
|
11436
|
+
function getTypedArrayForBufferView(json, buffers, bufferViewIndex) {
|
|
11437
|
+
const bufferView = json.bufferViews[bufferViewIndex];
|
|
11438
|
+
assert7(bufferView);
|
|
11439
|
+
const bufferIndex = bufferView.buffer;
|
|
11440
|
+
const binChunk = buffers[bufferIndex];
|
|
11441
|
+
assert7(binChunk);
|
|
11442
|
+
const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;
|
|
11443
|
+
return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);
|
|
11444
|
+
}
|
|
11445
|
+
var init_get_typed_array = __esm({
|
|
11446
|
+
"../gltf/src/lib/gltf-utils/get-typed-array.ts"() {
|
|
11447
|
+
init_assert6();
|
|
10549
11448
|
}
|
|
10550
11449
|
});
|
|
10551
11450
|
|
|
10552
11451
|
// ../gltf/src/meshopt/meshopt-decoder.ts
|
|
10553
11452
|
async function meshoptDecodeGltfBuffer(target, count, size, source, mode, filter = "NONE") {
|
|
10554
11453
|
const instance = await loadWasmInstance();
|
|
10555
|
-
|
|
11454
|
+
decode4(instance, instance.exports[DECODERS[mode]], target, count, size, source, instance.exports[FILTERS[filter || "NONE"]]);
|
|
10556
11455
|
}
|
|
10557
11456
|
async function loadWasmInstance() {
|
|
10558
11457
|
if (!wasmPromise) {
|
|
@@ -10582,7 +11481,7 @@
|
|
|
10582
11481
|
}
|
|
10583
11482
|
return result.buffer.slice(0, write);
|
|
10584
11483
|
}
|
|
10585
|
-
function
|
|
11484
|
+
function decode4(instance, fun, target, count, size, source, filter) {
|
|
10586
11485
|
const sbrk = instance.exports.sbrk;
|
|
10587
11486
|
const count4 = count + 3 & ~3;
|
|
10588
11487
|
const tp = sbrk(count4 * size);
|
|
@@ -10743,10 +11642,10 @@
|
|
|
10743
11642
|
// ../gltf/src/lib/extensions/EXT_meshopt_compression.ts
|
|
10744
11643
|
var EXT_meshopt_compression_exports = {};
|
|
10745
11644
|
__export(EXT_meshopt_compression_exports, {
|
|
10746
|
-
decode: () =>
|
|
10747
|
-
name: () =>
|
|
11645
|
+
decode: () => decode5,
|
|
11646
|
+
name: () => name4
|
|
10748
11647
|
});
|
|
10749
|
-
async function
|
|
11648
|
+
async function decode5(gltfData, options) {
|
|
10750
11649
|
const scenegraph = new GLTFScenegraph(gltfData);
|
|
10751
11650
|
if (!options?.gltf?.decompressMeshes || !options.gltf?.loadBuffers) {
|
|
10752
11651
|
return;
|
|
@@ -10777,20 +11676,20 @@
|
|
|
10777
11676
|
scenegraph.removeObjectExtension(bufferView, EXT_MESHOPT_COMPRESSION);
|
|
10778
11677
|
}
|
|
10779
11678
|
}
|
|
10780
|
-
var EXT_MESHOPT_COMPRESSION,
|
|
11679
|
+
var EXT_MESHOPT_COMPRESSION, name4;
|
|
10781
11680
|
var init_EXT_meshopt_compression = __esm({
|
|
10782
11681
|
"../gltf/src/lib/extensions/EXT_meshopt_compression.ts"() {
|
|
10783
11682
|
init_gltf_scenegraph();
|
|
10784
11683
|
init_meshopt_decoder();
|
|
10785
11684
|
EXT_MESHOPT_COMPRESSION = "EXT_meshopt_compression";
|
|
10786
|
-
|
|
11685
|
+
name4 = EXT_MESHOPT_COMPRESSION;
|
|
10787
11686
|
}
|
|
10788
11687
|
});
|
|
10789
11688
|
|
|
10790
11689
|
// ../gltf/src/lib/extensions/EXT_texture_webp.ts
|
|
10791
11690
|
var EXT_texture_webp_exports = {};
|
|
10792
11691
|
__export(EXT_texture_webp_exports, {
|
|
10793
|
-
name: () =>
|
|
11692
|
+
name: () => name5,
|
|
10794
11693
|
preprocess: () => preprocess
|
|
10795
11694
|
});
|
|
10796
11695
|
function preprocess(gltfData, options) {
|
|
@@ -10811,20 +11710,20 @@
|
|
|
10811
11710
|
}
|
|
10812
11711
|
scenegraph.removeExtension(EXT_TEXTURE_WEBP);
|
|
10813
11712
|
}
|
|
10814
|
-
var EXT_TEXTURE_WEBP,
|
|
11713
|
+
var EXT_TEXTURE_WEBP, name5;
|
|
10815
11714
|
var init_EXT_texture_webp = __esm({
|
|
10816
11715
|
"../gltf/src/lib/extensions/EXT_texture_webp.ts"() {
|
|
10817
11716
|
init_src8();
|
|
10818
11717
|
init_gltf_scenegraph();
|
|
10819
11718
|
EXT_TEXTURE_WEBP = "EXT_texture_webp";
|
|
10820
|
-
|
|
11719
|
+
name5 = EXT_TEXTURE_WEBP;
|
|
10821
11720
|
}
|
|
10822
11721
|
});
|
|
10823
11722
|
|
|
10824
11723
|
// ../gltf/src/lib/extensions/KHR_texture_basisu.ts
|
|
10825
11724
|
var KHR_texture_basisu_exports = {};
|
|
10826
11725
|
__export(KHR_texture_basisu_exports, {
|
|
10827
|
-
name: () =>
|
|
11726
|
+
name: () => name6,
|
|
10828
11727
|
preprocess: () => preprocess2
|
|
10829
11728
|
});
|
|
10830
11729
|
function preprocess2(gltfData, options) {
|
|
@@ -10839,23 +11738,23 @@
|
|
|
10839
11738
|
}
|
|
10840
11739
|
scene.removeExtension(KHR_TEXTURE_BASISU);
|
|
10841
11740
|
}
|
|
10842
|
-
var KHR_TEXTURE_BASISU,
|
|
11741
|
+
var KHR_TEXTURE_BASISU, name6;
|
|
10843
11742
|
var init_KHR_texture_basisu = __esm({
|
|
10844
11743
|
"../gltf/src/lib/extensions/KHR_texture_basisu.ts"() {
|
|
10845
11744
|
init_gltf_scenegraph();
|
|
10846
11745
|
KHR_TEXTURE_BASISU = "KHR_texture_basisu";
|
|
10847
|
-
|
|
11746
|
+
name6 = KHR_TEXTURE_BASISU;
|
|
10848
11747
|
}
|
|
10849
11748
|
});
|
|
10850
11749
|
|
|
10851
11750
|
// ../gltf/src/lib/gltf-utils/gltf-attribute-utils.ts
|
|
10852
11751
|
function getGLTFAccessors(attributes) {
|
|
10853
11752
|
const accessors = {};
|
|
10854
|
-
for (const
|
|
10855
|
-
const attribute = attributes[
|
|
10856
|
-
if (
|
|
11753
|
+
for (const name12 in attributes) {
|
|
11754
|
+
const attribute = attributes[name12];
|
|
11755
|
+
if (name12 !== "indices") {
|
|
10857
11756
|
const glTFAccessor = getGLTFAccessor(attribute);
|
|
10858
|
-
accessors[
|
|
11757
|
+
accessors[name12] = glTFAccessor;
|
|
10859
11758
|
}
|
|
10860
11759
|
}
|
|
10861
11760
|
return accessors;
|
|
@@ -10909,9 +11808,9 @@
|
|
|
10909
11808
|
// ../gltf/src/lib/extensions/KHR_draco_mesh_compression.ts
|
|
10910
11809
|
var KHR_draco_mesh_compression_exports = {};
|
|
10911
11810
|
__export(KHR_draco_mesh_compression_exports, {
|
|
10912
|
-
decode: () =>
|
|
11811
|
+
decode: () => decode6,
|
|
10913
11812
|
encode: () => encode,
|
|
10914
|
-
name: () =>
|
|
11813
|
+
name: () => name7,
|
|
10915
11814
|
preprocess: () => preprocess3
|
|
10916
11815
|
});
|
|
10917
11816
|
function preprocess3(gltfData, options, context) {
|
|
@@ -10921,7 +11820,7 @@
|
|
|
10921
11820
|
}
|
|
10922
11821
|
}
|
|
10923
11822
|
}
|
|
10924
|
-
async function
|
|
11823
|
+
async function decode6(gltfData, options, context) {
|
|
10925
11824
|
if (!options?.gltf?.decompressMeshes) {
|
|
10926
11825
|
return;
|
|
10927
11826
|
}
|
|
@@ -11006,7 +11905,7 @@
|
|
|
11006
11905
|
}
|
|
11007
11906
|
}
|
|
11008
11907
|
}
|
|
11009
|
-
var KHR_DRACO_MESH_COMPRESSION,
|
|
11908
|
+
var KHR_DRACO_MESH_COMPRESSION, name7;
|
|
11010
11909
|
var init_KHR_draco_mesh_compression = __esm({
|
|
11011
11910
|
"../gltf/src/lib/extensions/KHR_draco_mesh_compression.ts"() {
|
|
11012
11911
|
init_src2();
|
|
@@ -11014,7 +11913,7 @@
|
|
|
11014
11913
|
init_gltf_scenegraph();
|
|
11015
11914
|
init_gltf_attribute_utils();
|
|
11016
11915
|
KHR_DRACO_MESH_COMPRESSION = "KHR_draco_mesh_compression";
|
|
11017
|
-
|
|
11916
|
+
name7 = KHR_DRACO_MESH_COMPRESSION;
|
|
11018
11917
|
}
|
|
11019
11918
|
});
|
|
11020
11919
|
|
|
@@ -11045,10 +11944,10 @@
|
|
|
11045
11944
|
// ../gltf/src/lib/extensions/KHR_texture_transform.ts
|
|
11046
11945
|
var KHR_texture_transform_exports = {};
|
|
11047
11946
|
__export(KHR_texture_transform_exports, {
|
|
11048
|
-
decode: () =>
|
|
11049
|
-
name: () =>
|
|
11947
|
+
decode: () => decode7,
|
|
11948
|
+
name: () => name8
|
|
11050
11949
|
});
|
|
11051
|
-
async function
|
|
11950
|
+
async function decode7(gltfData, options) {
|
|
11052
11951
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
11053
11952
|
const hasExtension = gltfScenegraph.hasExtension(EXT_MESHOPT_TRANSFORM);
|
|
11054
11953
|
if (!hasExtension || !options.gltf?.loadBuffers) {
|
|
@@ -11190,7 +12089,7 @@
|
|
|
11190
12089
|
const scaleMatrix = scratchScaleMatrix.set(scale5[0], 0, 0, 0, scale5[1], 0, 0, 0, 1);
|
|
11191
12090
|
return translationMatrix.multiplyRight(rotationMatrix).multiplyRight(scaleMatrix);
|
|
11192
12091
|
}
|
|
11193
|
-
var EXT_MESHOPT_TRANSFORM,
|
|
12092
|
+
var EXT_MESHOPT_TRANSFORM, name8, scratchVector7, scratchRotationMatrix, scratchScaleMatrix;
|
|
11194
12093
|
var init_KHR_texture_transform = __esm({
|
|
11195
12094
|
"../gltf/src/lib/extensions/KHR_texture_transform.ts"() {
|
|
11196
12095
|
init_esm();
|
|
@@ -11198,7 +12097,7 @@
|
|
|
11198
12097
|
init_gltf_constants();
|
|
11199
12098
|
init_gltf_scenegraph();
|
|
11200
12099
|
EXT_MESHOPT_TRANSFORM = "KHR_texture_transform";
|
|
11201
|
-
|
|
12100
|
+
name8 = EXT_MESHOPT_TRANSFORM;
|
|
11202
12101
|
scratchVector7 = new Vector3();
|
|
11203
12102
|
scratchRotationMatrix = new Matrix3();
|
|
11204
12103
|
scratchScaleMatrix = new Matrix3();
|
|
@@ -11208,11 +12107,11 @@
|
|
|
11208
12107
|
// ../gltf/src/lib/extensions/deprecated/KHR_lights_punctual.ts
|
|
11209
12108
|
var KHR_lights_punctual_exports = {};
|
|
11210
12109
|
__export(KHR_lights_punctual_exports, {
|
|
11211
|
-
decode: () =>
|
|
12110
|
+
decode: () => decode8,
|
|
11212
12111
|
encode: () => encode2,
|
|
11213
|
-
name: () =>
|
|
12112
|
+
name: () => name9
|
|
11214
12113
|
});
|
|
11215
|
-
async function
|
|
12114
|
+
async function decode8(gltfData) {
|
|
11216
12115
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
11217
12116
|
const { json } = gltfScenegraph;
|
|
11218
12117
|
const extension = gltfScenegraph.getExtension(KHR_LIGHTS_PUNCTUAL);
|
|
@@ -11245,24 +12144,24 @@
|
|
|
11245
12144
|
delete gltfScenegraph.json.lights;
|
|
11246
12145
|
}
|
|
11247
12146
|
}
|
|
11248
|
-
var KHR_LIGHTS_PUNCTUAL,
|
|
12147
|
+
var KHR_LIGHTS_PUNCTUAL, name9;
|
|
11249
12148
|
var init_KHR_lights_punctual = __esm({
|
|
11250
12149
|
"../gltf/src/lib/extensions/deprecated/KHR_lights_punctual.ts"() {
|
|
11251
12150
|
init_assert6();
|
|
11252
12151
|
init_gltf_scenegraph();
|
|
11253
12152
|
KHR_LIGHTS_PUNCTUAL = "KHR_lights_punctual";
|
|
11254
|
-
|
|
12153
|
+
name9 = KHR_LIGHTS_PUNCTUAL;
|
|
11255
12154
|
}
|
|
11256
12155
|
});
|
|
11257
12156
|
|
|
11258
12157
|
// ../gltf/src/lib/extensions/deprecated/KHR_materials_unlit.ts
|
|
11259
12158
|
var KHR_materials_unlit_exports = {};
|
|
11260
12159
|
__export(KHR_materials_unlit_exports, {
|
|
11261
|
-
decode: () =>
|
|
12160
|
+
decode: () => decode9,
|
|
11262
12161
|
encode: () => encode3,
|
|
11263
|
-
name: () =>
|
|
12162
|
+
name: () => name10
|
|
11264
12163
|
});
|
|
11265
|
-
async function
|
|
12164
|
+
async function decode9(gltfData) {
|
|
11266
12165
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
11267
12166
|
const { json } = gltfScenegraph;
|
|
11268
12167
|
for (const material of json.materials || []) {
|
|
@@ -11270,310 +12169,97 @@
|
|
|
11270
12169
|
if (extension) {
|
|
11271
12170
|
material.unlit = true;
|
|
11272
12171
|
}
|
|
11273
|
-
gltfScenegraph.removeObjectExtension(material, KHR_MATERIALS_UNLIT);
|
|
11274
|
-
}
|
|
11275
|
-
gltfScenegraph.removeExtension(KHR_MATERIALS_UNLIT);
|
|
11276
|
-
}
|
|
11277
|
-
function encode3(gltfData) {
|
|
11278
|
-
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
11279
|
-
const { json } = gltfScenegraph;
|
|
11280
|
-
if (gltfScenegraph.materials) {
|
|
11281
|
-
for (const material of json.materials || []) {
|
|
11282
|
-
if (material.unlit) {
|
|
11283
|
-
delete material.unlit;
|
|
11284
|
-
gltfScenegraph.addObjectExtension(material, KHR_MATERIALS_UNLIT, {});
|
|
11285
|
-
gltfScenegraph.addExtension(KHR_MATERIALS_UNLIT);
|
|
11286
|
-
}
|
|
11287
|
-
}
|
|
11288
|
-
}
|
|
11289
|
-
}
|
|
11290
|
-
var KHR_MATERIALS_UNLIT, name7;
|
|
11291
|
-
var init_KHR_materials_unlit = __esm({
|
|
11292
|
-
"../gltf/src/lib/extensions/deprecated/KHR_materials_unlit.ts"() {
|
|
11293
|
-
init_gltf_scenegraph();
|
|
11294
|
-
KHR_MATERIALS_UNLIT = "KHR_materials_unlit";
|
|
11295
|
-
name7 = KHR_MATERIALS_UNLIT;
|
|
11296
|
-
}
|
|
11297
|
-
});
|
|
11298
|
-
|
|
11299
|
-
// ../gltf/src/lib/extensions/deprecated/KHR_techniques_webgl.ts
|
|
11300
|
-
var KHR_techniques_webgl_exports = {};
|
|
11301
|
-
__export(KHR_techniques_webgl_exports, {
|
|
11302
|
-
decode: () => decode7,
|
|
11303
|
-
encode: () => encode4,
|
|
11304
|
-
name: () => name8
|
|
11305
|
-
});
|
|
11306
|
-
async function decode7(gltfData) {
|
|
11307
|
-
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
11308
|
-
const { json } = gltfScenegraph;
|
|
11309
|
-
const extension = gltfScenegraph.getExtension(KHR_TECHNIQUES_WEBGL);
|
|
11310
|
-
if (extension) {
|
|
11311
|
-
const techniques = resolveTechniques(extension, gltfScenegraph);
|
|
11312
|
-
for (const material of json.materials || []) {
|
|
11313
|
-
const materialExtension = gltfScenegraph.getObjectExtension(material, KHR_TECHNIQUES_WEBGL);
|
|
11314
|
-
if (materialExtension) {
|
|
11315
|
-
material.technique = Object.assign({}, materialExtension, techniques[materialExtension.technique]);
|
|
11316
|
-
material.technique.values = resolveValues(material.technique, gltfScenegraph);
|
|
11317
|
-
}
|
|
11318
|
-
gltfScenegraph.removeObjectExtension(material, KHR_TECHNIQUES_WEBGL);
|
|
11319
|
-
}
|
|
11320
|
-
gltfScenegraph.removeExtension(KHR_TECHNIQUES_WEBGL);
|
|
11321
|
-
}
|
|
11322
|
-
}
|
|
11323
|
-
async function encode4(gltfData, options) {
|
|
11324
|
-
}
|
|
11325
|
-
function resolveTechniques(techniquesExtension, gltfScenegraph) {
|
|
11326
|
-
const { programs = [], shaders = [], techniques = [] } = techniquesExtension;
|
|
11327
|
-
const textDecoder = new TextDecoder();
|
|
11328
|
-
shaders.forEach((shader) => {
|
|
11329
|
-
if (Number.isFinite(shader.bufferView)) {
|
|
11330
|
-
shader.code = textDecoder.decode(gltfScenegraph.getTypedArrayForBufferView(shader.bufferView));
|
|
11331
|
-
} else {
|
|
11332
|
-
throw new Error("KHR_techniques_webgl: no shader code");
|
|
11333
|
-
}
|
|
11334
|
-
});
|
|
11335
|
-
programs.forEach((program) => {
|
|
11336
|
-
program.fragmentShader = shaders[program.fragmentShader];
|
|
11337
|
-
program.vertexShader = shaders[program.vertexShader];
|
|
11338
|
-
});
|
|
11339
|
-
techniques.forEach((technique) => {
|
|
11340
|
-
technique.program = programs[technique.program];
|
|
11341
|
-
});
|
|
11342
|
-
return techniques;
|
|
11343
|
-
}
|
|
11344
|
-
function resolveValues(technique, gltfScenegraph) {
|
|
11345
|
-
const values = Object.assign({}, technique.values);
|
|
11346
|
-
Object.keys(technique.uniforms || {}).forEach((uniform) => {
|
|
11347
|
-
if (technique.uniforms[uniform].value && !(uniform in values)) {
|
|
11348
|
-
values[uniform] = technique.uniforms[uniform].value;
|
|
11349
|
-
}
|
|
11350
|
-
});
|
|
11351
|
-
Object.keys(values).forEach((uniform) => {
|
|
11352
|
-
if (typeof values[uniform] === "object" && values[uniform].index !== void 0) {
|
|
11353
|
-
values[uniform].texture = gltfScenegraph.getTexture(values[uniform].index);
|
|
11354
|
-
}
|
|
11355
|
-
});
|
|
11356
|
-
return values;
|
|
11357
|
-
}
|
|
11358
|
-
var KHR_TECHNIQUES_WEBGL, name8;
|
|
11359
|
-
var init_KHR_techniques_webgl = __esm({
|
|
11360
|
-
"../gltf/src/lib/extensions/deprecated/KHR_techniques_webgl.ts"() {
|
|
11361
|
-
init_gltf_scenegraph();
|
|
11362
|
-
KHR_TECHNIQUES_WEBGL = "KHR_techniques_webgl";
|
|
11363
|
-
name8 = KHR_TECHNIQUES_WEBGL;
|
|
11364
|
-
}
|
|
11365
|
-
});
|
|
11366
|
-
|
|
11367
|
-
// ../gltf/src/lib/extensions/deprecated/EXT_feature_metadata.ts
|
|
11368
|
-
var EXT_feature_metadata_exports = {};
|
|
11369
|
-
__export(EXT_feature_metadata_exports, {
|
|
11370
|
-
decode: () => decode8,
|
|
11371
|
-
name: () => name9
|
|
11372
|
-
});
|
|
11373
|
-
async function decode8(gltfData, options) {
|
|
11374
|
-
const scenegraph = new GLTFScenegraph(gltfData);
|
|
11375
|
-
decodeExtFeatureMetadata(scenegraph, options);
|
|
11376
|
-
}
|
|
11377
|
-
function decodeExtFeatureMetadata(scenegraph, options) {
|
|
11378
|
-
const extension = scenegraph.getExtension(EXT_FEATURE_METADATA);
|
|
11379
|
-
if (!extension)
|
|
11380
|
-
return;
|
|
11381
|
-
const schemaClasses = extension.schema?.classes;
|
|
11382
|
-
const { featureTables } = extension;
|
|
11383
|
-
if (schemaClasses && featureTables) {
|
|
11384
|
-
for (const schemaName in schemaClasses) {
|
|
11385
|
-
const schemaClass = schemaClasses[schemaName];
|
|
11386
|
-
const featureTable = findFeatureTableByName(featureTables, schemaName);
|
|
11387
|
-
if (featureTable) {
|
|
11388
|
-
handleFeatureTableProperties(scenegraph, featureTable, schemaClass);
|
|
11389
|
-
}
|
|
11390
|
-
}
|
|
11391
|
-
}
|
|
11392
|
-
const { featureTextures } = extension;
|
|
11393
|
-
if (schemaClasses && featureTextures && options.gltf?.loadImages) {
|
|
11394
|
-
for (const schemaName in schemaClasses) {
|
|
11395
|
-
const schemaClass = schemaClasses[schemaName];
|
|
11396
|
-
const featureTexture = findFeatureTextureByName(featureTextures, schemaName);
|
|
11397
|
-
if (featureTexture) {
|
|
11398
|
-
handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass);
|
|
11399
|
-
}
|
|
11400
|
-
}
|
|
11401
|
-
}
|
|
11402
|
-
}
|
|
11403
|
-
function handleFeatureTableProperties(scenegraph, featureTable, schemaClass) {
|
|
11404
|
-
for (const propertyName in schemaClass.properties) {
|
|
11405
|
-
const schemaProperty = schemaClass.properties[propertyName];
|
|
11406
|
-
const featureTableProperty = featureTable?.properties?.[propertyName];
|
|
11407
|
-
const numberOfFeatures = featureTable.count;
|
|
11408
|
-
if (featureTableProperty) {
|
|
11409
|
-
const data = getPropertyDataFromBinarySource(scenegraph, schemaProperty, numberOfFeatures, featureTableProperty);
|
|
11410
|
-
featureTableProperty.data = data;
|
|
11411
|
-
}
|
|
11412
|
-
}
|
|
11413
|
-
}
|
|
11414
|
-
function handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass) {
|
|
11415
|
-
const attributeName = featureTexture.class;
|
|
11416
|
-
for (const propertyName in schemaClass.properties) {
|
|
11417
|
-
const featureTextureProperty = featureTexture?.properties?.[propertyName];
|
|
11418
|
-
if (featureTextureProperty) {
|
|
11419
|
-
const data = getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName);
|
|
11420
|
-
featureTextureProperty.data = data;
|
|
11421
|
-
}
|
|
11422
|
-
}
|
|
11423
|
-
}
|
|
11424
|
-
function getPropertyDataFromBinarySource(scenegraph, schemaProperty, numberOfFeatures, featureTableProperty) {
|
|
11425
|
-
const bufferView = featureTableProperty.bufferView;
|
|
11426
|
-
const dataArray = scenegraph.getTypedArrayForBufferView(bufferView);
|
|
11427
|
-
switch (schemaProperty.type) {
|
|
11428
|
-
case "STRING": {
|
|
11429
|
-
const stringOffsetBufferView = featureTableProperty.stringOffsetBufferView;
|
|
11430
|
-
const offsetsData = scenegraph.getTypedArrayForBufferView(stringOffsetBufferView);
|
|
11431
|
-
return getStringAttributes(dataArray, offsetsData, numberOfFeatures);
|
|
11432
|
-
}
|
|
11433
|
-
default:
|
|
11434
|
-
}
|
|
11435
|
-
return dataArray;
|
|
11436
|
-
}
|
|
11437
|
-
function getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName) {
|
|
11438
|
-
const json = scenegraph.gltf.json;
|
|
11439
|
-
if (!json.meshes) {
|
|
11440
|
-
return [];
|
|
11441
|
-
}
|
|
11442
|
-
const featureTextureTable = [];
|
|
11443
|
-
for (const mesh of json.meshes) {
|
|
11444
|
-
for (const primitive of mesh.primitives) {
|
|
11445
|
-
processPrimitiveTextures(scenegraph, attributeName, featureTextureProperty, featureTextureTable, primitive);
|
|
11446
|
-
}
|
|
11447
|
-
}
|
|
11448
|
-
return featureTextureTable;
|
|
11449
|
-
}
|
|
11450
|
-
function processPrimitiveTextures(scenegraph, attributeName, featureTextureProperty, featureTextureTable, primitive) {
|
|
11451
|
-
const json = scenegraph.gltf.json;
|
|
11452
|
-
const textureData = [];
|
|
11453
|
-
const texCoordAccessorKey = `TEXCOORD_${featureTextureProperty.texture.texCoord}`;
|
|
11454
|
-
const texCoordAccessorIndex = primitive.attributes[texCoordAccessorKey];
|
|
11455
|
-
const texCoordBufferView = scenegraph.getBufferView(texCoordAccessorIndex);
|
|
11456
|
-
const texCoordArray = scenegraph.getTypedArrayForBufferView(texCoordBufferView);
|
|
11457
|
-
const textureCoordinates = new Float32Array(texCoordArray.buffer, texCoordArray.byteOffset, texCoordArray.length / 4);
|
|
11458
|
-
const textureIndex = featureTextureProperty.texture.index;
|
|
11459
|
-
const texture = json.textures?.[textureIndex];
|
|
11460
|
-
const imageIndex = texture?.source;
|
|
11461
|
-
if (typeof imageIndex !== "undefined") {
|
|
11462
|
-
const image = json.images?.[imageIndex];
|
|
11463
|
-
const mimeType = image?.mimeType;
|
|
11464
|
-
const parsedImage = scenegraph.gltf.images?.[imageIndex];
|
|
11465
|
-
if (parsedImage) {
|
|
11466
|
-
for (let index = 0; index < textureCoordinates.length; index += 2) {
|
|
11467
|
-
const value = getImageValueByCoordinates(parsedImage, mimeType, textureCoordinates, index, featureTextureProperty.channels);
|
|
11468
|
-
textureData.push(value);
|
|
11469
|
-
}
|
|
11470
|
-
}
|
|
11471
|
-
}
|
|
11472
|
-
const featureIndices = [];
|
|
11473
|
-
for (const texelData of textureData) {
|
|
11474
|
-
let index = featureTextureTable.findIndex((item) => item === texelData);
|
|
11475
|
-
if (index === -1) {
|
|
11476
|
-
index = featureTextureTable.push(texelData) - 1;
|
|
11477
|
-
}
|
|
11478
|
-
featureIndices.push(index);
|
|
11479
|
-
}
|
|
11480
|
-
const typedArray = new Uint32Array(featureIndices);
|
|
11481
|
-
const bufferIndex = scenegraph.gltf.buffers.push({
|
|
11482
|
-
arrayBuffer: typedArray.buffer,
|
|
11483
|
-
byteOffset: 0,
|
|
11484
|
-
byteLength: typedArray.byteLength
|
|
11485
|
-
}) - 1;
|
|
11486
|
-
const bufferViewIndex = scenegraph.addBufferView(typedArray, bufferIndex, 0);
|
|
11487
|
-
const accessorIndex = scenegraph.addAccessor(bufferViewIndex, {
|
|
11488
|
-
size: 1,
|
|
11489
|
-
componentType: getComponentTypeFromArray(typedArray),
|
|
11490
|
-
count: typedArray.length
|
|
11491
|
-
});
|
|
11492
|
-
primitive.attributes[attributeName] = accessorIndex;
|
|
11493
|
-
}
|
|
11494
|
-
function getImageValueByCoordinates(parsedImage, mimeType, textureCoordinates, index, channels) {
|
|
11495
|
-
const CHANNELS_MAP = {
|
|
11496
|
-
r: { offset: 0, shift: 0 },
|
|
11497
|
-
g: { offset: 1, shift: 8 },
|
|
11498
|
-
b: { offset: 2, shift: 16 },
|
|
11499
|
-
a: { offset: 3, shift: 24 }
|
|
11500
|
-
};
|
|
11501
|
-
const u = textureCoordinates[index];
|
|
11502
|
-
const v = textureCoordinates[index + 1];
|
|
11503
|
-
let components = 1;
|
|
11504
|
-
if (mimeType && (mimeType.indexOf("image/jpeg") !== -1 || mimeType.indexOf("image/png") !== -1))
|
|
11505
|
-
components = 4;
|
|
11506
|
-
const offset = coordinatesToOffset(u, v, parsedImage, components);
|
|
11507
|
-
let value = 0;
|
|
11508
|
-
for (const c of channels) {
|
|
11509
|
-
const map2 = CHANNELS_MAP[c];
|
|
11510
|
-
const val = getVal(parsedImage, offset + map2.offset);
|
|
11511
|
-
value |= val << map2.shift;
|
|
12172
|
+
gltfScenegraph.removeObjectExtension(material, KHR_MATERIALS_UNLIT);
|
|
11512
12173
|
}
|
|
11513
|
-
|
|
12174
|
+
gltfScenegraph.removeExtension(KHR_MATERIALS_UNLIT);
|
|
11514
12175
|
}
|
|
11515
|
-
function
|
|
11516
|
-
const
|
|
11517
|
-
|
|
11518
|
-
|
|
12176
|
+
function encode3(gltfData) {
|
|
12177
|
+
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
12178
|
+
const { json } = gltfScenegraph;
|
|
12179
|
+
if (gltfScenegraph.materials) {
|
|
12180
|
+
for (const material of json.materials || []) {
|
|
12181
|
+
if (material.unlit) {
|
|
12182
|
+
delete material.unlit;
|
|
12183
|
+
gltfScenegraph.addObjectExtension(material, KHR_MATERIALS_UNLIT, {});
|
|
12184
|
+
gltfScenegraph.addExtension(KHR_MATERIALS_UNLIT);
|
|
12185
|
+
}
|
|
12186
|
+
}
|
|
11519
12187
|
}
|
|
11520
|
-
return imageData.data[offset];
|
|
11521
|
-
}
|
|
11522
|
-
function coordinatesToOffset(u, v, parsedImage, componentsCount = 1) {
|
|
11523
|
-
const w = parsedImage.width;
|
|
11524
|
-
const iX = emod(u) * (w - 1);
|
|
11525
|
-
const indX = Math.round(iX);
|
|
11526
|
-
const h = parsedImage.height;
|
|
11527
|
-
const iY = emod(v) * (h - 1);
|
|
11528
|
-
const indY = Math.round(iY);
|
|
11529
|
-
const components = parsedImage.components ? parsedImage.components : componentsCount;
|
|
11530
|
-
const offset = (indY * w + indX) * components;
|
|
11531
|
-
return offset;
|
|
11532
|
-
}
|
|
11533
|
-
function emod(n2) {
|
|
11534
|
-
const a2 = (n2 % 1 + 1) % 1;
|
|
11535
|
-
return a2;
|
|
11536
12188
|
}
|
|
11537
|
-
|
|
11538
|
-
|
|
11539
|
-
|
|
11540
|
-
|
|
11541
|
-
|
|
12189
|
+
var KHR_MATERIALS_UNLIT, name10;
|
|
12190
|
+
var init_KHR_materials_unlit = __esm({
|
|
12191
|
+
"../gltf/src/lib/extensions/deprecated/KHR_materials_unlit.ts"() {
|
|
12192
|
+
init_gltf_scenegraph();
|
|
12193
|
+
KHR_MATERIALS_UNLIT = "KHR_materials_unlit";
|
|
12194
|
+
name10 = KHR_MATERIALS_UNLIT;
|
|
12195
|
+
}
|
|
12196
|
+
});
|
|
12197
|
+
|
|
12198
|
+
// ../gltf/src/lib/extensions/deprecated/KHR_techniques_webgl.ts
|
|
12199
|
+
var KHR_techniques_webgl_exports = {};
|
|
12200
|
+
__export(KHR_techniques_webgl_exports, {
|
|
12201
|
+
decode: () => decode10,
|
|
12202
|
+
encode: () => encode4,
|
|
12203
|
+
name: () => name11
|
|
12204
|
+
});
|
|
12205
|
+
async function decode10(gltfData) {
|
|
12206
|
+
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
12207
|
+
const { json } = gltfScenegraph;
|
|
12208
|
+
const extension = gltfScenegraph.getExtension(KHR_TECHNIQUES_WEBGL);
|
|
12209
|
+
if (extension) {
|
|
12210
|
+
const techniques = resolveTechniques(extension, gltfScenegraph);
|
|
12211
|
+
for (const material of json.materials || []) {
|
|
12212
|
+
const materialExtension = gltfScenegraph.getObjectExtension(material, KHR_TECHNIQUES_WEBGL);
|
|
12213
|
+
if (materialExtension) {
|
|
12214
|
+
material.technique = Object.assign({}, materialExtension, techniques[materialExtension.technique]);
|
|
12215
|
+
material.technique.values = resolveValues(material.technique, gltfScenegraph);
|
|
12216
|
+
}
|
|
12217
|
+
gltfScenegraph.removeObjectExtension(material, KHR_TECHNIQUES_WEBGL);
|
|
11542
12218
|
}
|
|
12219
|
+
gltfScenegraph.removeExtension(KHR_TECHNIQUES_WEBGL);
|
|
11543
12220
|
}
|
|
11544
|
-
return null;
|
|
11545
12221
|
}
|
|
11546
|
-
function
|
|
11547
|
-
|
|
11548
|
-
|
|
11549
|
-
|
|
11550
|
-
|
|
12222
|
+
async function encode4(gltfData, options) {
|
|
12223
|
+
}
|
|
12224
|
+
function resolveTechniques(techniquesExtension, gltfScenegraph) {
|
|
12225
|
+
const { programs = [], shaders = [], techniques = [] } = techniquesExtension;
|
|
12226
|
+
const textDecoder = new TextDecoder();
|
|
12227
|
+
shaders.forEach((shader) => {
|
|
12228
|
+
if (Number.isFinite(shader.bufferView)) {
|
|
12229
|
+
shader.code = textDecoder.decode(gltfScenegraph.getTypedArrayForBufferView(shader.bufferView));
|
|
12230
|
+
} else {
|
|
12231
|
+
throw new Error("KHR_techniques_webgl: no shader code");
|
|
11551
12232
|
}
|
|
11552
|
-
}
|
|
11553
|
-
|
|
12233
|
+
});
|
|
12234
|
+
programs.forEach((program) => {
|
|
12235
|
+
program.fragmentShader = shaders[program.fragmentShader];
|
|
12236
|
+
program.vertexShader = shaders[program.vertexShader];
|
|
12237
|
+
});
|
|
12238
|
+
techniques.forEach((technique) => {
|
|
12239
|
+
technique.program = programs[technique.program];
|
|
12240
|
+
});
|
|
12241
|
+
return techniques;
|
|
11554
12242
|
}
|
|
11555
|
-
function
|
|
11556
|
-
const
|
|
11557
|
-
|
|
11558
|
-
|
|
11559
|
-
|
|
11560
|
-
|
|
11561
|
-
|
|
11562
|
-
|
|
11563
|
-
|
|
11564
|
-
|
|
11565
|
-
|
|
11566
|
-
}
|
|
11567
|
-
return
|
|
12243
|
+
function resolveValues(technique, gltfScenegraph) {
|
|
12244
|
+
const values = Object.assign({}, technique.values);
|
|
12245
|
+
Object.keys(technique.uniforms || {}).forEach((uniform) => {
|
|
12246
|
+
if (technique.uniforms[uniform].value && !(uniform in values)) {
|
|
12247
|
+
values[uniform] = technique.uniforms[uniform].value;
|
|
12248
|
+
}
|
|
12249
|
+
});
|
|
12250
|
+
Object.keys(values).forEach((uniform) => {
|
|
12251
|
+
if (typeof values[uniform] === "object" && values[uniform].index !== void 0) {
|
|
12252
|
+
values[uniform].texture = gltfScenegraph.getTexture(values[uniform].index);
|
|
12253
|
+
}
|
|
12254
|
+
});
|
|
12255
|
+
return values;
|
|
11568
12256
|
}
|
|
11569
|
-
var
|
|
11570
|
-
var
|
|
11571
|
-
"../gltf/src/lib/extensions/deprecated/
|
|
12257
|
+
var KHR_TECHNIQUES_WEBGL, name11;
|
|
12258
|
+
var init_KHR_techniques_webgl = __esm({
|
|
12259
|
+
"../gltf/src/lib/extensions/deprecated/KHR_techniques_webgl.ts"() {
|
|
11572
12260
|
init_gltf_scenegraph();
|
|
11573
|
-
|
|
11574
|
-
|
|
11575
|
-
EXT_FEATURE_METADATA = "EXT_feature_metadata";
|
|
11576
|
-
name9 = EXT_FEATURE_METADATA;
|
|
12261
|
+
KHR_TECHNIQUES_WEBGL = "KHR_techniques_webgl";
|
|
12262
|
+
name11 = KHR_TECHNIQUES_WEBGL;
|
|
11577
12263
|
}
|
|
11578
12264
|
});
|
|
11579
12265
|
|
|
@@ -11598,6 +12284,8 @@
|
|
|
11598
12284
|
var EXTENSIONS2;
|
|
11599
12285
|
var init_gltf_extensions = __esm({
|
|
11600
12286
|
"../gltf/src/lib/api/gltf-extensions.ts"() {
|
|
12287
|
+
init_EXT_mesh_features();
|
|
12288
|
+
init_EXT_structural_metadata();
|
|
11601
12289
|
init_EXT_meshopt_compression();
|
|
11602
12290
|
init_EXT_texture_webp();
|
|
11603
12291
|
init_KHR_texture_basisu();
|
|
@@ -11608,6 +12296,8 @@
|
|
|
11608
12296
|
init_KHR_techniques_webgl();
|
|
11609
12297
|
init_EXT_feature_metadata();
|
|
11610
12298
|
EXTENSIONS2 = [
|
|
12299
|
+
EXT_mesh_features_exports,
|
|
12300
|
+
EXT_structural_metadata_exports,
|
|
11611
12301
|
EXT_meshopt_compression_exports,
|
|
11612
12302
|
EXT_texture_webp_exports,
|
|
11613
12303
|
KHR_texture_basisu_exports,
|
|
@@ -11993,13 +12683,13 @@
|
|
|
11993
12683
|
var GLTFLoader;
|
|
11994
12684
|
var init_gltf_loader = __esm({
|
|
11995
12685
|
"../gltf/src/gltf-loader.ts"() {
|
|
11996
|
-
|
|
12686
|
+
init_version5();
|
|
11997
12687
|
init_parse_gltf();
|
|
11998
12688
|
GLTFLoader = {
|
|
11999
12689
|
name: "glTF",
|
|
12000
12690
|
id: "gltf",
|
|
12001
12691
|
module: "gltf",
|
|
12002
|
-
version:
|
|
12692
|
+
version: VERSION7,
|
|
12003
12693
|
extensions: ["gltf", "glb"],
|
|
12004
12694
|
mimeTypes: ["model/gltf+json", "model/gltf-binary"],
|
|
12005
12695
|
text: true,
|
|
@@ -12662,7 +13352,7 @@
|
|
|
12662
13352
|
byteOffset += 4;
|
|
12663
13353
|
tile.tiles = [];
|
|
12664
13354
|
while (tile.tiles.length < tile.tilesLength && (tile.byteLength || 0) - byteOffset > 12) {
|
|
12665
|
-
const subtile = {};
|
|
13355
|
+
const subtile = { shape: "tile3d" };
|
|
12666
13356
|
tile.tiles.push(subtile);
|
|
12667
13357
|
byteOffset = await parse3DTile2(arrayBuffer, byteOffset, options, context, subtile);
|
|
12668
13358
|
}
|
|
@@ -12680,7 +13370,7 @@
|
|
|
12680
13370
|
tile.gltfUpAxis = options?.["3d-tiles"]?.assetGltfUpAxis ? options["3d-tiles"].assetGltfUpAxis : "Y";
|
|
12681
13371
|
if (options?.["3d-tiles"]?.loadGLTF) {
|
|
12682
13372
|
if (!context) {
|
|
12683
|
-
return;
|
|
13373
|
+
return arrayBuffer.byteLength;
|
|
12684
13374
|
}
|
|
12685
13375
|
const gltfWithBuffers = await parseFromContext(arrayBuffer, GLTFLoader, options, context);
|
|
12686
13376
|
tile.gltf = postProcessGLTF(gltfWithBuffers);
|
|
@@ -12688,6 +13378,7 @@
|
|
|
12688
13378
|
} else {
|
|
12689
13379
|
tile.gltfArrayBuffer = arrayBuffer;
|
|
12690
13380
|
}
|
|
13381
|
+
return arrayBuffer.byteLength;
|
|
12691
13382
|
}
|
|
12692
13383
|
var init_parse_3d_tile_gltf = __esm({
|
|
12693
13384
|
"src/lib/parsers/parse-3d-tile-gltf.ts"() {
|
|
@@ -12697,7 +13388,7 @@
|
|
|
12697
13388
|
});
|
|
12698
13389
|
|
|
12699
13390
|
// src/lib/parsers/parse-3d-tile.ts
|
|
12700
|
-
async function parse3DTile(arrayBuffer, byteOffset = 0, options, context, tile = {}) {
|
|
13391
|
+
async function parse3DTile(arrayBuffer, byteOffset = 0, options, context, tile = { shape: "tile3d" }) {
|
|
12701
13392
|
tile.byteOffset = byteOffset;
|
|
12702
13393
|
tile.type = getMagicString3(arrayBuffer, byteOffset);
|
|
12703
13394
|
switch (tile.type) {
|
|
@@ -13017,7 +13708,7 @@
|
|
|
13017
13708
|
for (const key of propNames) {
|
|
13018
13709
|
const value = object[key];
|
|
13019
13710
|
if (typeof value === "function") {
|
|
13020
|
-
if (!predefined.find((
|
|
13711
|
+
if (!predefined.find((name12) => key === name12)) {
|
|
13021
13712
|
object[key] = value.bind(obj);
|
|
13022
13713
|
}
|
|
13023
13714
|
}
|
|
@@ -13850,7 +14541,7 @@
|
|
|
13850
14541
|
LongPrototype.toInt = function toInt() {
|
|
13851
14542
|
return this.unsigned ? this.low >>> 0 : this.low;
|
|
13852
14543
|
};
|
|
13853
|
-
LongPrototype.toNumber = function
|
|
14544
|
+
LongPrototype.toNumber = function toNumber2() {
|
|
13854
14545
|
if (this.unsigned)
|
|
13855
14546
|
return (this.high >>> 0) * TWO_PWR_32_DBL + (this.low >>> 0);
|
|
13856
14547
|
return this.high * TWO_PWR_32_DBL + (this.low >>> 0);
|
|
@@ -15071,6 +15762,7 @@
|
|
|
15071
15762
|
const normalizedRoot = await normalizeTileHeaders(tilesetJson, basePath, options || {});
|
|
15072
15763
|
const tilesetJsonPostprocessed = {
|
|
15073
15764
|
...tilesetJson,
|
|
15765
|
+
shape: "tileset3d",
|
|
15074
15766
|
loader: Tiles3DLoader,
|
|
15075
15767
|
url: tilesetUrl,
|
|
15076
15768
|
queryString: context?.queryString || "",
|
|
@@ -15085,6 +15777,7 @@
|
|
|
15085
15777
|
async function parseTile(arrayBuffer, options, context) {
|
|
15086
15778
|
const tile = {
|
|
15087
15779
|
content: {
|
|
15780
|
+
shape: "tile3d",
|
|
15088
15781
|
featureIds: null
|
|
15089
15782
|
}
|
|
15090
15783
|
};
|
|
@@ -15218,143 +15911,6 @@
|
|
|
15218
15911
|
}
|
|
15219
15912
|
});
|
|
15220
15913
|
|
|
15221
|
-
// ../zip/src/file-provider/file-handle.ts
|
|
15222
|
-
var import_fs, _FileHandle, FileHandle;
|
|
15223
|
-
var init_file_handle = __esm({
|
|
15224
|
-
"../zip/src/file-provider/file-handle.ts"() {
|
|
15225
|
-
import_fs = __toModule(require_fs());
|
|
15226
|
-
_FileHandle = class {
|
|
15227
|
-
constructor(fileDescriptor, stats) {
|
|
15228
|
-
this.read = (buffer, offset, length4, position) => {
|
|
15229
|
-
return new Promise((s2) => {
|
|
15230
|
-
(0, import_fs.read)(this.fileDescriptor, buffer, offset, length4, position, (_err, bytesRead, buffer2) => s2({ bytesRead, buffer: buffer2 }));
|
|
15231
|
-
});
|
|
15232
|
-
};
|
|
15233
|
-
this.fileDescriptor = fileDescriptor;
|
|
15234
|
-
this.stats = stats;
|
|
15235
|
-
}
|
|
15236
|
-
async close() {
|
|
15237
|
-
return new Promise((resolve2) => {
|
|
15238
|
-
(0, import_fs.close)(this.fileDescriptor, (_err) => resolve2());
|
|
15239
|
-
});
|
|
15240
|
-
}
|
|
15241
|
-
get stat() {
|
|
15242
|
-
return this.stats;
|
|
15243
|
-
}
|
|
15244
|
-
};
|
|
15245
|
-
FileHandle = _FileHandle;
|
|
15246
|
-
FileHandle.open = async (path) => {
|
|
15247
|
-
const [fd, stats] = await Promise.all([
|
|
15248
|
-
new Promise((s2) => {
|
|
15249
|
-
(0, import_fs.open)(path, void 0, void 0, (_err, fd2) => s2(fd2));
|
|
15250
|
-
}),
|
|
15251
|
-
new Promise((s2) => {
|
|
15252
|
-
(0, import_fs.stat)(path, { bigint: true }, (_err, stats2) => s2(stats2));
|
|
15253
|
-
})
|
|
15254
|
-
]);
|
|
15255
|
-
return new _FileHandle(fd, stats);
|
|
15256
|
-
};
|
|
15257
|
-
}
|
|
15258
|
-
});
|
|
15259
|
-
|
|
15260
|
-
// ../zip/src/file-provider/file-handle-file.ts
|
|
15261
|
-
var FileHandleFile;
|
|
15262
|
-
var init_file_handle_file = __esm({
|
|
15263
|
-
"../zip/src/file-provider/file-handle-file.ts"() {
|
|
15264
|
-
init_file_handle();
|
|
15265
|
-
FileHandleFile = class {
|
|
15266
|
-
static async from(path) {
|
|
15267
|
-
const fileDescriptor = await FileHandle.open(path);
|
|
15268
|
-
return new FileHandleFile(fileDescriptor, fileDescriptor.stat.size);
|
|
15269
|
-
}
|
|
15270
|
-
constructor(fileDescriptor, size) {
|
|
15271
|
-
this.fileDescriptor = fileDescriptor;
|
|
15272
|
-
this.size = size;
|
|
15273
|
-
}
|
|
15274
|
-
async destroy() {
|
|
15275
|
-
await this.fileDescriptor.close();
|
|
15276
|
-
}
|
|
15277
|
-
async getUint8(offset) {
|
|
15278
|
-
const val = new Uint8Array((await this.fileDescriptor.read(Buffer.alloc(1), 0, 1, offset)).buffer.buffer).at(0);
|
|
15279
|
-
if (val === void 0) {
|
|
15280
|
-
throw new Error("something went wrong");
|
|
15281
|
-
}
|
|
15282
|
-
return val;
|
|
15283
|
-
}
|
|
15284
|
-
async getUint16(offset) {
|
|
15285
|
-
const val = new Uint16Array((await this.fileDescriptor.read(Buffer.alloc(2), 0, 2, offset)).buffer.buffer).at(0);
|
|
15286
|
-
if (val === void 0) {
|
|
15287
|
-
throw new Error("something went wrong");
|
|
15288
|
-
}
|
|
15289
|
-
return val;
|
|
15290
|
-
}
|
|
15291
|
-
async getUint32(offset) {
|
|
15292
|
-
const val = new Uint32Array((await this.fileDescriptor.read(Buffer.alloc(4), 0, 4, offset)).buffer.buffer).at(0);
|
|
15293
|
-
if (val === void 0) {
|
|
15294
|
-
throw new Error("something went wrong");
|
|
15295
|
-
}
|
|
15296
|
-
return val;
|
|
15297
|
-
}
|
|
15298
|
-
async getBigUint64(offset) {
|
|
15299
|
-
const val = new BigInt64Array((await this.fileDescriptor.read(Buffer.alloc(8), 0, 8, offset)).buffer.buffer).at(0);
|
|
15300
|
-
if (val === void 0) {
|
|
15301
|
-
throw new Error("something went wrong");
|
|
15302
|
-
}
|
|
15303
|
-
return val;
|
|
15304
|
-
}
|
|
15305
|
-
async slice(startOffsset, endOffset) {
|
|
15306
|
-
const bigLength = endOffset - startOffsset;
|
|
15307
|
-
if (bigLength > Number.MAX_SAFE_INTEGER) {
|
|
15308
|
-
throw new Error("too big slice");
|
|
15309
|
-
}
|
|
15310
|
-
const length4 = Number(bigLength);
|
|
15311
|
-
return (await this.fileDescriptor.read(Buffer.alloc(length4), 0, length4, startOffsset)).buffer.buffer;
|
|
15312
|
-
}
|
|
15313
|
-
get length() {
|
|
15314
|
-
return this.size;
|
|
15315
|
-
}
|
|
15316
|
-
};
|
|
15317
|
-
}
|
|
15318
|
-
});
|
|
15319
|
-
|
|
15320
|
-
// ../zip/src/file-provider/data-view-file.ts
|
|
15321
|
-
var toNumber2, DataViewFile;
|
|
15322
|
-
var init_data_view_file = __esm({
|
|
15323
|
-
"../zip/src/file-provider/data-view-file.ts"() {
|
|
15324
|
-
toNumber2 = (bigint) => {
|
|
15325
|
-
if (bigint > Number.MAX_SAFE_INTEGER) {
|
|
15326
|
-
throw new Error("Offset is out of bounds");
|
|
15327
|
-
}
|
|
15328
|
-
return Number(bigint);
|
|
15329
|
-
};
|
|
15330
|
-
DataViewFile = class {
|
|
15331
|
-
constructor(file) {
|
|
15332
|
-
this.file = file;
|
|
15333
|
-
}
|
|
15334
|
-
async destroy() {
|
|
15335
|
-
}
|
|
15336
|
-
async getUint8(offset) {
|
|
15337
|
-
return this.file.getUint8(toNumber2(offset));
|
|
15338
|
-
}
|
|
15339
|
-
async getUint16(offset) {
|
|
15340
|
-
return this.file.getUint16(toNumber2(offset), true);
|
|
15341
|
-
}
|
|
15342
|
-
async getUint32(offset) {
|
|
15343
|
-
return this.file.getUint32(toNumber2(offset), true);
|
|
15344
|
-
}
|
|
15345
|
-
async getBigUint64(offset) {
|
|
15346
|
-
return this.file.getBigUint64(toNumber2(offset), true);
|
|
15347
|
-
}
|
|
15348
|
-
async slice(startOffset, endOffset) {
|
|
15349
|
-
return this.file.buffer.slice(toNumber2(startOffset), toNumber2(endOffset));
|
|
15350
|
-
}
|
|
15351
|
-
get length() {
|
|
15352
|
-
return BigInt(this.file.byteLength);
|
|
15353
|
-
}
|
|
15354
|
-
};
|
|
15355
|
-
}
|
|
15356
|
-
});
|
|
15357
|
-
|
|
15358
15914
|
// ../zip/src/parse-zip/search-from-the-end.ts
|
|
15359
15915
|
var searchFromTheEnd;
|
|
15360
15916
|
var init_search_from_the_end = __esm({
|
|
@@ -15823,16 +16379,6 @@
|
|
|
15823
16379
|
}
|
|
15824
16380
|
});
|
|
15825
16381
|
|
|
15826
|
-
// ../zip/src/file-provider/file-provider.ts
|
|
15827
|
-
var isFileProvider;
|
|
15828
|
-
var init_file_provider = __esm({
|
|
15829
|
-
"../zip/src/file-provider/file-provider.ts"() {
|
|
15830
|
-
isFileProvider = (fileProvider) => {
|
|
15831
|
-
return fileProvider?.getUint8 && fileProvider?.slice && fileProvider?.length;
|
|
15832
|
-
};
|
|
15833
|
-
}
|
|
15834
|
-
});
|
|
15835
|
-
|
|
15836
16382
|
// ../compression/src/lib/compression.ts
|
|
15837
16383
|
var Compression;
|
|
15838
16384
|
var init_compression = __esm({
|
|
@@ -20140,9 +20686,9 @@
|
|
|
20140
20686
|
var COMPRESSION_METHODS, ZipFileSystem;
|
|
20141
20687
|
var init_zip_filesystem = __esm({
|
|
20142
20688
|
"../zip/src/filesystems/zip-filesystem.ts"() {
|
|
20143
|
-
|
|
20144
|
-
|
|
20145
|
-
|
|
20689
|
+
init_src2();
|
|
20690
|
+
init_src2();
|
|
20691
|
+
init_src2();
|
|
20146
20692
|
init_cd_file_header();
|
|
20147
20693
|
init_local_file_header();
|
|
20148
20694
|
init_src11();
|
|
@@ -20235,7 +20781,6 @@
|
|
|
20235
20781
|
// ../zip/src/index.ts
|
|
20236
20782
|
var init_src12 = __esm({
|
|
20237
20783
|
"../zip/src/index.ts"() {
|
|
20238
|
-
init_data_view_file();
|
|
20239
20784
|
init_cd_file_header();
|
|
20240
20785
|
init_local_file_header();
|
|
20241
20786
|
init_search_from_the_end();
|
|
@@ -20328,7 +20873,7 @@
|
|
|
20328
20873
|
var VERSION10, Tiles3DArchiveFileLoader;
|
|
20329
20874
|
var init_d_tiles_archive_loader = __esm({
|
|
20330
20875
|
"src/3d-tiles-archive-loader.ts"() {
|
|
20331
|
-
|
|
20876
|
+
init_src2();
|
|
20332
20877
|
init_d_tiles_archive_parser();
|
|
20333
20878
|
VERSION10 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
20334
20879
|
Tiles3DArchiveFileLoader = {
|