@loaders.gl/tiles-3d 5.0.0-beta.2 → 5.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/3d-tiles/3d-tiles-archive-loader.js +1 -1
  2. package/dist/3d-tiles/dist.dev.js +502 -342
  3. package/dist/3d-tiles/dist.min.js +19 -19
  4. package/dist/3d-tiles/index.cjs +307 -183
  5. package/dist/3d-tiles/index.cjs.map +3 -3
  6. package/dist/3d-tiles/lib/classes/tile-3d-batch-table.d.ts.map +1 -1
  7. package/dist/3d-tiles/lib/classes/tile-3d-batch-table.js +12 -8
  8. package/dist/3d-tiles/lib/classes/tile-3d-batch-table.js.map +1 -1
  9. package/dist/3d-tiles/lib/utils/version.js +1 -1
  10. package/dist/3d-tiles-archive-writer.cjs +1 -1
  11. package/dist/cesium-ion-loader-with-parser.cjs +301 -177
  12. package/dist/cesium-ion-loader-with-parser.cjs.map +3 -3
  13. package/dist/copc/copc-source-loader.js +1 -1
  14. package/dist/copc/copc-writer.js +1 -1
  15. package/dist/copc/index.cjs +358 -9
  16. package/dist/copc/index.cjs.map +3 -3
  17. package/dist/dist.min.js +2 -2
  18. package/dist/i3s/arcgis-webscene-loader.js +1 -1
  19. package/dist/i3s/dist.dev.js +3731 -694
  20. package/dist/i3s/dist.min.js +43 -35
  21. package/dist/i3s/i3s-attribute-loader.js +1 -1
  22. package/dist/i3s/i3s-building-scene-layer-loader.js +1 -1
  23. package/dist/i3s/i3s-content-loader.js +1 -1
  24. package/dist/i3s/i3s-lepcc-loader-types.js +1 -1
  25. package/dist/i3s/i3s-loader.js +1 -1
  26. package/dist/i3s/i3s-node-page-loader.js +1 -1
  27. package/dist/i3s/i3s-slpk-loader.js +1 -1
  28. package/dist/i3s/i3s-slpk-writer.js +1 -1
  29. package/dist/i3s/index.cjs +2542 -373
  30. package/dist/i3s/index.cjs.map +3 -3
  31. package/dist/i3s-content-worker-node.js +11 -11
  32. package/dist/i3s-content-worker-node.js.map +4 -4
  33. package/dist/i3s-content-worker.js +392 -56
  34. package/dist/i3s-lepcc-worker-node.js +369 -37
  35. package/dist/i3s-lepcc-worker-node.js.map +4 -4
  36. package/dist/i3s-lepcc-worker.js +340 -33
  37. package/dist/i3s-mesh-writer.cjs +2464 -295
  38. package/dist/i3s-mesh-writer.cjs.map +3 -3
  39. package/dist/i3s-slpk-writer.cjs +1 -1
  40. package/dist/index.cjs +1 -1
  41. package/dist/point-cloud-tile-source-loader-types.js +1 -1
  42. package/dist/point-cloud-tile-source-loader.cjs +1 -1
  43. package/dist/potree/dist.dev.js +84 -28
  44. package/dist/potree/dist.min.js +26 -26
  45. package/dist/potree/index.cjs +11 -6
  46. package/dist/potree/index.cjs.map +1 -1
  47. package/dist/potree/potree-bin-loader.js +1 -1
  48. package/dist/potree/potree-hierarchy-chunk-loader.js +1 -1
  49. package/dist/potree/potree-loader-types.js +1 -1
  50. package/dist/potree/potree-source-loader.js +1 -1
  51. package/dist/potree/potree-writer.js +1 -1
  52. package/dist/potree-loader.cjs +1 -1
  53. package/package.json +13 -13
  54. package/src/3d-tiles/lib/classes/tile-3d-batch-table.ts +12 -8
@@ -14,8 +14,8 @@ var __esm = (fn, res, err) => function __init() {
14
14
  }
15
15
  };
16
16
  var __export = (target, all) => {
17
- for (var name20 in all)
18
- __defProp(target, name20, { get: all[name20], enumerable: true });
17
+ for (var name22 in all)
18
+ __defProp(target, name22, { get: all[name22], enumerable: true });
19
19
  };
20
20
  var __copyProps = (to, from, except, desc) => {
21
21
  if (from && typeof from === "object" || typeof from === "function") {
@@ -341,9 +341,9 @@ function registerJSModules(modules) {
341
341
  globalThis.loaders.modules ||= {};
342
342
  Object.assign(globalThis.loaders.modules, modules);
343
343
  }
344
- function getJSModuleOrNull(name20) {
344
+ function getJSModuleOrNull(name22) {
345
345
  var _a, _b;
346
- const module2 = (_b = (_a = globalThis.loaders) == null ? void 0 : _a.modules) == null ? void 0 : _b[name20];
346
+ const module2 = (_b = (_a = globalThis.loaders) == null ? void 0 : _a.modules) == null ? void 0 : _b[name22];
347
347
  return module2 || null;
348
348
  }
349
349
  var init_js_module_utils = __esm({
@@ -424,21 +424,347 @@ var init_globals2 = __esm({
424
424
  }
425
425
  });
426
426
 
427
- // ../core/src/worker-utils/lib/worker-farm/worker-farm.ts
427
+ // ../core/src/worker-utils/lib/worker-api/task-runtime.ts
428
+ function normalizeTaskProgress(progress) {
429
+ return { ...progress, phase: progress.phase ?? "process", unit: progress.unit ?? "items" };
430
+ }
428
431
  var import_tasks;
429
- var init_worker_farm = __esm({
430
- "../core/src/worker-utils/lib/worker-farm/worker-farm.ts"() {
432
+ var init_task_runtime = __esm({
433
+ "../core/src/worker-utils/lib/worker-api/task-runtime.ts"() {
431
434
  "use strict";
432
435
  import_tasks = require("@math.gl/core/tasks");
433
436
  }
434
437
  });
435
438
 
439
+ // ../core/src/worker-utils/lib/worker-api/get-worker-url.ts
440
+ function getCustomWorkerURL(worker, options = {}) {
441
+ var _a, _b;
442
+ const workerFile = isBrowser2 ? worker.workerFile || `${worker.id}-worker.js` : worker.workerNode || `${worker.id}-worker-node.js`;
443
+ let url = getConfiguredWorkerURL(worker, options);
444
+ const workerType = options._workerType || ((_a = options == null ? void 0 : options.core) == null ? void 0 : _a._workerType);
445
+ if (!url && workerType === "test") {
446
+ if (isBrowser2) {
447
+ url = `modules/${worker.module}/dist/${workerFile}`;
448
+ } else {
449
+ const workerSourceDirectory = worker.module === "core" && ((_b = worker.workerNode) == null ? void 0 : _b.startsWith("worker-utils/")) ? "worker-utils/workers" : "workers";
450
+ const workerSourceNode = worker.workerSourceNode || `${workerSourceDirectory}/${worker.id}-worker-node.ts`;
451
+ url = `modules/${worker.module}/src/${workerSourceNode}`;
452
+ }
453
+ }
454
+ return url || null;
455
+ }
456
+ function getConfiguredWorkerURL(worker, options = {}) {
457
+ const workerOptions = options[worker.id] || {};
458
+ return workerOptions.workerUrl || (worker.id === "compression" ? options.workerUrl : null) || null;
459
+ }
460
+ function getWorkerURL(worker, options = {}) {
461
+ const customWorkerUrl = getCustomWorkerURL(worker, options);
462
+ const descriptorWorkerUrl = typeof worker.worker === "string" ? worker.worker : null;
463
+ const url = customWorkerUrl || descriptorWorkerUrl || getDefaultWorkerURL(worker, true);
464
+ assert2(url);
465
+ return url;
466
+ }
467
+ function getDefaultWorkerURL(worker, warn = false) {
468
+ const workerFile = isBrowser2 ? worker.workerFile || `${worker.id}-worker.js` : worker.workerNode || `${worker.id}-worker-node.js`;
469
+ let version = worker.version;
470
+ if (version === "latest") {
471
+ version = NPM_TAG;
472
+ }
473
+ const versionTag = version ? `@${version}` : "";
474
+ const url = `https://unpkg.com/@loaders.gl/${worker.module}${versionTag}/dist/${workerFile}`;
475
+ if (warn) {
476
+ warnIfUsingNpmTagFallback(worker, url);
477
+ }
478
+ return url;
479
+ }
480
+ function warnIfUsingNpmTagFallback(worker, url) {
481
+ if (worker.version !== "latest") {
482
+ return;
483
+ }
484
+ const workerId = `${worker.module}:${worker.id}`;
485
+ if (warnedWorkerVersionFallbacks.has(workerId)) {
486
+ return;
487
+ }
488
+ warnedWorkerVersionFallbacks.add(workerId);
489
+ console.warn(
490
+ `loaders.gl: ${worker.name} loader worker version is "latest" because __VERSION__ was not injected. Fetching ${url} from CDN.`
491
+ );
492
+ }
493
+ var warnedWorkerVersionFallbacks;
494
+ var init_get_worker_url = __esm({
495
+ "../core/src/worker-utils/lib/worker-api/get-worker-url.ts"() {
496
+ "use strict";
497
+ init_assert2();
498
+ init_globals2();
499
+ init_npm_tag();
500
+ warnedWorkerVersionFallbacks = /* @__PURE__ */ new Set();
501
+ }
502
+ });
503
+
504
+ // ../core/src/worker-utils/lib/worker-utils/get-transfer-list.ts
505
+ function getTransferList(object, recursive = true, transfers) {
506
+ const transfersSet = transfers || /* @__PURE__ */ new Set();
507
+ if (!object) {
508
+ } else if (isTransferable(object)) {
509
+ transfersSet.add(object);
510
+ } else if (isTransferable(object.buffer)) {
511
+ transfersSet.add(object.buffer);
512
+ } else if (ArrayBuffer.isView(object)) {
513
+ } else if (recursive && typeof object === "object") {
514
+ for (const key in object) {
515
+ getTransferList(object[key], recursive, transfersSet);
516
+ }
517
+ }
518
+ return transfers === void 0 ? Array.from(transfersSet) : [];
519
+ }
520
+ function isTransferable(object) {
521
+ if (!object) {
522
+ return false;
523
+ }
524
+ if (object instanceof ArrayBuffer) {
525
+ return true;
526
+ }
527
+ if (typeof MessagePort !== "undefined" && object instanceof MessagePort) {
528
+ return true;
529
+ }
530
+ if (typeof ImageBitmap !== "undefined" && object instanceof ImageBitmap) {
531
+ return true;
532
+ }
533
+ if (typeof OffscreenCanvas !== "undefined" && object instanceof OffscreenCanvas) {
534
+ return true;
535
+ }
536
+ return false;
537
+ }
538
+ function getTransferListForWriter(object) {
539
+ if (object === null) {
540
+ return {};
541
+ }
542
+ const clone = Object.assign({}, object);
543
+ Object.keys(clone).forEach((key) => {
544
+ if (object[key] !== null && typeof object[key] === "object" && !ArrayBuffer.isView(object[key]) && !(object[key] instanceof Array)) {
545
+ clone[key] = getTransferListForWriter(object[key]);
546
+ } else if (typeof clone[key] === "function" || clone[key] instanceof RegExp) {
547
+ clone[key] = {};
548
+ } else {
549
+ clone[key] = object[key];
550
+ }
551
+ });
552
+ return clone;
553
+ }
554
+ var init_get_transfer_list = __esm({
555
+ "../core/src/worker-utils/lib/worker-utils/get-transfer-list.ts"() {
556
+ "use strict";
557
+ }
558
+ });
559
+
436
560
  // ../core/src/worker-utils/lib/worker-api/process-on-worker.ts
437
- var import_tasks2;
561
+ function canProcessOnWorker(worker, options = {}) {
562
+ const supported = isBrowser2 ? typeof Worker !== "undefined" : Boolean(options._nodeWorkers);
563
+ return Boolean(
564
+ supported && options.worker && (worker.worker || worker.loadWorker || getConfiguredWorkerURL(worker, options))
565
+ );
566
+ }
567
+ async function* processOnWorkerInBatches(worker, input, options = {}, context = {}, jobContext = {}) {
568
+ var _a;
569
+ const taskInput = wrapInput(input);
570
+ let session;
571
+ try {
572
+ session = await openSession(worker, options, context, jobContext);
573
+ for await (const result of session.handle.runTaskInBatches(taskInput, {
574
+ ...getControls(options),
575
+ options: getParserOptions(options)
576
+ }))
577
+ yield result.value;
578
+ } finally {
579
+ const closingInput = (_a = taskInput.return) == null ? void 0 : _a.call(taskInput);
580
+ void (closingInput == null ? void 0 : closingInput.catch(() => {
581
+ }));
582
+ await (session == null ? void 0 : session.close());
583
+ }
584
+ }
585
+ function getTask(worker, options) {
586
+ var _a;
587
+ if (options.source || ((_a = options.core) == null ? void 0 : _a.source))
588
+ throw new Error(
589
+ "Inline legacy worker source is unsupported; use a TaskRunner worker URL or factory"
590
+ );
591
+ const create = !getCustomWorkerURL(worker, options) && isBrowser2 ? worker.loadWorker : void 0;
592
+ const url = getWorkerURL(worker, options);
593
+ return {
594
+ id: `${worker.module}:${worker.id}`,
595
+ initialize: (state) => state,
596
+ worker: {
597
+ ...create ? { create: () => create() ?? createModuleWorker(url) } : { url },
598
+ capabilities: { atomic: true, streaming: true }
599
+ }
600
+ };
601
+ }
602
+ function getControls(options) {
603
+ return {
604
+ execution: "worker",
605
+ signal: options.signal,
606
+ inputOwnership: options.inputOwnership ?? "transfer",
607
+ outputOwnership: options.outputOwnership ?? "transfer",
608
+ onProgress: options.onProgress ? (progress) => {
609
+ var _a;
610
+ return (_a = options.onProgress) == null ? void 0 : _a.call(options, normalizeTaskProgress(progress));
611
+ } : void 0
612
+ };
613
+ }
614
+ function getParserOptions(options) {
615
+ const { signal, onProgress, ...parserOptions } = options;
616
+ return getTransferListForWriter(parserOptions);
617
+ }
618
+ async function openSession(worker, options, context, jobContext) {
619
+ var _a, _b;
620
+ (_a = options.signal) == null ? void 0 : _a.throwIfAborted();
621
+ const task = getTask(worker, options);
622
+ let state = runners.get(worker);
623
+ if (!state) {
624
+ state = {
625
+ runner: new import_tasks2.TaskRunner({
626
+ maxConcurrency: isMobile ? options.maxMobileConcurrency ?? 1 : options.maxConcurrency ?? 3
627
+ }),
628
+ requests: 0
629
+ };
630
+ runners.set(worker, state);
631
+ }
632
+ const runnerState = state;
633
+ const channel = context.process ? new MessageChannel() : void 0;
634
+ const callbackController = new AbortController();
635
+ let channelClosed = false;
636
+ const abortCallbacks = () => {
637
+ var _a2;
638
+ return callbackController.abort((_a2 = options.signal) == null ? void 0 : _a2.reason);
639
+ };
640
+ (_b = options.signal) == null ? void 0 : _b.addEventListener("abort", abortCallbacks, { once: true });
641
+ const closeChannel = () => {
642
+ var _a2;
643
+ channelClosed = true;
644
+ (_a2 = options.signal) == null ? void 0 : _a2.removeEventListener("abort", abortCallbacks);
645
+ callbackController.abort();
646
+ channel == null ? void 0 : channel.port1.close();
647
+ channel == null ? void 0 : channel.port2.close();
648
+ };
649
+ if (channel) {
650
+ channel.port1.onmessage = async ({ data }) => {
651
+ try {
652
+ const value = await context.process(
653
+ data.input,
654
+ data.options,
655
+ {
656
+ signal: callbackController.signal,
657
+ throwIfAborted: () => callbackController.signal.throwIfAborted()
658
+ },
659
+ data.context
660
+ );
661
+ if (!channelClosed && !callbackController.signal.aborted)
662
+ channel.port1.postMessage({ identifier: data.identifier, value }, getTransferList(value));
663
+ } catch (error) {
664
+ if (channelClosed || callbackController.signal.aborted) return;
665
+ channel.port1.postMessage({
666
+ identifier: data.identifier,
667
+ error: {
668
+ name: error instanceof Error ? error.name : "Error",
669
+ message: error instanceof Error ? error.message : String(error)
670
+ }
671
+ });
672
+ }
673
+ };
674
+ channel.port1.start();
675
+ }
676
+ runnerState.requests++;
677
+ activeRunners.add(runnerState);
678
+ let released = false;
679
+ const releaseRunner = () => {
680
+ if (released) return;
681
+ released = true;
682
+ runnerState.requests--;
683
+ if (!runnerState.requests) activeRunners.delete(runnerState);
684
+ };
685
+ let handle;
686
+ try {
687
+ handle = await runnerState.runner.initializeTask(
688
+ task,
689
+ {
690
+ context: structuredClone(jobContext),
691
+ ...channel ? { port: channel.port2 } : {}
692
+ },
693
+ // The callback port is setup state, independent of the caller's payload ownership.
694
+ { ...getControls(options), inputOwnership: "transfer" }
695
+ );
696
+ } catch (error) {
697
+ releaseRunner();
698
+ closeChannel();
699
+ throw error;
700
+ }
701
+ return {
702
+ handle,
703
+ /** Releases the worker and callback channel on success, failure, and early stream return. */
704
+ async close() {
705
+ try {
706
+ await handle.close();
707
+ } finally {
708
+ closeChannel();
709
+ releaseRunner();
710
+ }
711
+ }
712
+ };
713
+ }
714
+ function wrapInput(input) {
715
+ const iterator = Symbol.asyncIterator in input ? input[Symbol.asyncIterator]() : input[Symbol.iterator]();
716
+ let inputClosed = false;
717
+ return {
718
+ [Symbol.asyncIterator]() {
719
+ return this;
720
+ },
721
+ async next() {
722
+ if (inputClosed) return { done: true, value: void 0 };
723
+ const next = await iterator.next();
724
+ if (next.done || inputClosed) {
725
+ inputClosed = true;
726
+ return { done: true, value: void 0 };
727
+ }
728
+ return { done: false, value: { value: next.value } };
729
+ },
730
+ async return() {
731
+ var _a;
732
+ if (!inputClosed) {
733
+ inputClosed = true;
734
+ await ((_a = iterator.return) == null ? void 0 : _a.call(iterator));
735
+ }
736
+ return { done: true, value: void 0 };
737
+ }
738
+ };
739
+ }
740
+ function createModuleWorker(url) {
741
+ var _a;
742
+ const resolved = new URL(url, ((_a = globalThis.document) == null ? void 0 : _a.baseURI) ?? globalThis.location.href);
743
+ let workerUrl = resolved.href;
744
+ if (/^https?:$/.test(resolved.protocol) && resolved.origin !== globalThis.location.origin) {
745
+ let shimUrl = moduleWorkerUrls.get(resolved.href);
746
+ if (!shimUrl) {
747
+ shimUrl = URL.createObjectURL(
748
+ new Blob([`import ${JSON.stringify(resolved.href)};`], { type: "application/javascript" })
749
+ );
750
+ moduleWorkerUrls.set(resolved.href, shimUrl);
751
+ }
752
+ workerUrl = shimUrl;
753
+ }
754
+ return new Worker(workerUrl, { type: "module" });
755
+ }
756
+ var import_tasks2, runners, activeRunners, moduleWorkerUrls;
438
757
  var init_process_on_worker = __esm({
439
758
  "../core/src/worker-utils/lib/worker-api/process-on-worker.ts"() {
440
759
  "use strict";
441
760
  import_tasks2 = require("@math.gl/core/tasks");
761
+ init_get_worker_url();
762
+ init_task_runtime();
763
+ init_get_transfer_list();
764
+ init_globals2();
765
+ runners = /* @__PURE__ */ new WeakMap();
766
+ activeRunners = /* @__PURE__ */ new Set();
767
+ moduleWorkerUrls = /* @__PURE__ */ new Map();
442
768
  }
443
769
  });
444
770
 
@@ -606,11 +932,12 @@ var init_library_utils = __esm({
606
932
  });
607
933
 
608
934
  // ../core/src/worker-utils/index.ts
935
+ var import_tasks3;
609
936
  var init_worker_utils = __esm({
610
937
  "../core/src/worker-utils/index.ts"() {
611
938
  "use strict";
612
939
  init_globals2();
613
- init_worker_farm();
940
+ import_tasks3 = require("@math.gl/core/tasks");
614
941
  init_process_on_worker();
615
942
  init_library_utils();
616
943
  }
@@ -619,15 +946,15 @@ var init_worker_utils = __esm({
619
946
  // ../core/src/loader-utils/lib/worker-loader-utils/encode-with-worker.ts
620
947
  function canEncodeWithWorker(writer, options) {
621
948
  var _a, _b;
622
- if (!import_tasks.WorkerFarm.isSupported()) {
623
- return false;
624
- }
625
949
  const nodeWorkers = (options == null ? void 0 : options._nodeWorkers) ?? ((_a = options == null ? void 0 : options.core) == null ? void 0 : _a._nodeWorkers);
626
950
  const useWorkers = (options == null ? void 0 : options.worker) ?? ((_b = options == null ? void 0 : options.core) == null ? void 0 : _b.worker);
627
951
  if (!isBrowser && !nodeWorkers) {
628
952
  return false;
629
953
  }
630
- return Boolean(writer.worker && useWorkers);
954
+ return canProcessOnWorker(
955
+ { ...writer, options: writer.options || {} },
956
+ { worker: Boolean(useWorkers), _nodeWorkers: Boolean(nodeWorkers) }
957
+ );
631
958
  }
632
959
  var init_encode_with_worker = __esm({
633
960
  "../core/src/loader-utils/lib/worker-loader-utils/encode-with-worker.ts"() {
@@ -2350,8 +2677,8 @@ function deserializeArrowSchema(schema, options) {
2350
2677
  function serializeArrowMetadata(arrowMetadata) {
2351
2678
  return Object.fromEntries(arrowMetadata);
2352
2679
  }
2353
- function deserializeArrowMetadata(metadata) {
2354
- return metadata ? new Map(Object.entries(metadata)) : /* @__PURE__ */ new Map();
2680
+ function deserializeArrowMetadata(metadata2) {
2681
+ return metadata2 ? new Map(Object.entries(metadata2)) : /* @__PURE__ */ new Map();
2355
2682
  }
2356
2683
  function serializeArrowField(field) {
2357
2684
  return {
@@ -3055,22 +3382,22 @@ function getAttributeArrowField(schema, attributeName, column, componentType) {
3055
3382
  if (!(suppliedField == null ? void 0 : suppliedField.metadata)) {
3056
3383
  return canonicalField;
3057
3384
  }
3058
- const metadata = new Map(canonicalField.metadata);
3385
+ const metadata2 = new Map(canonicalField.metadata);
3059
3386
  for (const [key, value] of Object.entries(suppliedField.metadata)) {
3060
- metadata.set(key, value);
3387
+ metadata2.set(key, value);
3061
3388
  }
3062
3389
  return new arrow4.Field(
3063
3390
  canonicalField.name,
3064
3391
  canonicalField.type,
3065
3392
  canonicalField.nullable,
3066
- metadata
3393
+ metadata2
3067
3394
  );
3068
3395
  }
3069
3396
  const field = schema == null ? void 0 : schema.fields.find((schemaField) => schemaField.name === attributeName);
3070
3397
  if (componentType === "float16") {
3071
- const metadata = new Map(Object.entries((field == null ? void 0 : field.metadata) || {}));
3072
- metadata.set("componentType", "float16");
3073
- return new arrow4.Field(attributeName, column.type, false, metadata);
3398
+ const metadata2 = new Map(Object.entries((field == null ? void 0 : field.metadata) || {}));
3399
+ metadata2.set("componentType", "float16");
3400
+ return new arrow4.Field(attributeName, column.type, false, metadata2);
3074
3401
  }
3075
3402
  if (field && field.type.toString() !== column.type.toString()) {
3076
3403
  const deserializedField = deserializeArrowField(field);
@@ -3119,17 +3446,17 @@ function getIndicesVector(indices, vertexCount, type) {
3119
3446
  }
3120
3447
  function getMeshArrowMetadata(options) {
3121
3448
  var _a;
3122
- const metadata = { ...(_a = options.schema) == null ? void 0 : _a.metadata };
3449
+ const metadata2 = { ...(_a = options.schema) == null ? void 0 : _a.metadata };
3123
3450
  if (options.topology) {
3124
- metadata.topology ||= options.topology;
3451
+ metadata2.topology ||= options.topology;
3125
3452
  }
3126
3453
  if (Number.isFinite(options.mode)) {
3127
- metadata.mode ||= String(options.mode);
3454
+ metadata2.mode ||= String(options.mode);
3128
3455
  }
3129
3456
  if (options.boundingBox) {
3130
- metadata.boundingBox ||= JSON.stringify(options.boundingBox);
3457
+ metadata2.boundingBox ||= JSON.stringify(options.boundingBox);
3131
3458
  }
3132
- return deserializeArrowMetadata(metadata);
3459
+ return deserializeArrowMetadata(metadata2);
3133
3460
  }
3134
3461
  var arrow4, MESH_ARROW_ATTRIBUTE_ORDER;
3135
3462
  var init_convert_mesh_to_table = __esm({
@@ -3163,24 +3490,24 @@ function convertArrowTableToMesh(table) {
3163
3490
  const attributes = {};
3164
3491
  const columns = [];
3165
3492
  for (const field of fields) {
3166
- const { name: name20 } = field;
3167
- if (name20 === "indices") {
3493
+ const { name: name22 } = field;
3494
+ if (name22 === "indices") {
3168
3495
  continue;
3169
3496
  }
3170
- const attributeData = arrowTable.getChild(name20);
3497
+ const attributeData = arrowTable.getChild(name22);
3171
3498
  const size = getFixedSizeListSize(attributeData);
3172
3499
  const typedArray = getAttributeTypedArray(attributeData, size);
3173
- const metadata = getMeshAttributeMetadata(field.metadata);
3174
- const value = metadata.componentType === "float16" ? restoreFloat16Array(typedArray) : typedArray;
3500
+ const metadata2 = getMeshAttributeMetadata(field.metadata);
3501
+ const value = metadata2.componentType === "float16" ? restoreFloat16Array(typedArray) : typedArray;
3175
3502
  const shared = columns.find(
3176
3503
  (column) => column.data.length === attributeData.data.length && attributes[column.name].value.constructor === value.constructor && column.data.every((chunk, index) => shareArrowStorage(chunk, attributeData.data[index]))
3177
3504
  );
3178
- attributes[name20] = {
3505
+ attributes[name22] = {
3179
3506
  value: shared ? attributes[shared.name].value : value,
3180
3507
  size,
3181
- ...metadata
3508
+ ...metadata2
3182
3509
  };
3183
- if (!shared) columns.push({ name: name20, data: attributeData.data });
3510
+ if (!shared) columns.push({ name: name22, data: attributeData.data });
3184
3511
  }
3185
3512
  fixMetadata(schema);
3186
3513
  const topology = schema.metadata.topology;
@@ -3216,23 +3543,23 @@ function getMeshBoundingBoxFromSchema(schema) {
3216
3543
  }
3217
3544
  return null;
3218
3545
  }
3219
- function getMeshAttributeMetadata(metadata = {}) {
3546
+ function getMeshAttributeMetadata(metadata2 = {}) {
3220
3547
  const result = {};
3221
- if (metadata.byteOffset !== void 0) {
3222
- result.byteOffset = Number(metadata.byteOffset);
3548
+ if (metadata2.byteOffset !== void 0) {
3549
+ result.byteOffset = Number(metadata2.byteOffset);
3223
3550
  }
3224
- if (metadata.byteStride !== void 0) {
3225
- result.byteStride = Number(metadata.byteStride);
3551
+ if (metadata2.byteStride !== void 0) {
3552
+ result.byteStride = Number(metadata2.byteStride);
3226
3553
  }
3227
- if (metadata.normalized !== void 0) {
3228
- result.normalized = metadata.normalized === "true";
3554
+ if (metadata2.normalized !== void 0) {
3555
+ result.normalized = metadata2.normalized === "true";
3229
3556
  }
3230
- if (metadata.componentType === "float16") {
3557
+ if (metadata2.componentType === "float16") {
3231
3558
  result.componentType = "float16";
3232
3559
  }
3233
- if (metadata["loaders.gl.transform"]) {
3560
+ if (metadata2["loaders.gl.transform"]) {
3234
3561
  try {
3235
- const transform = JSON.parse(metadata["loaders.gl.transform"]);
3562
+ const transform = JSON.parse(metadata2["loaders.gl.transform"]);
3236
3563
  if (isMeshAttributeTransform(transform)) {
3237
3564
  result.transform = transform;
3238
3565
  }
@@ -3321,15 +3648,15 @@ var init_convert_table_to_mesh = __esm({
3321
3648
  });
3322
3649
 
3323
3650
  // ../core/src/schema-utils/lib/mesh/deduce-mesh-schema.ts
3324
- function deduceMeshField(name20, attribute, optionalMetadata) {
3651
+ function deduceMeshField(name22, attribute, optionalMetadata) {
3325
3652
  const type = attribute.componentType || getDataTypeFromTypedArray(attribute.value);
3326
- const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
3653
+ const metadata2 = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
3327
3654
  const dataType = attribute.size === 1 ? type : { type: "fixed-size-list", listSize: attribute.size, children: [{ name: "value", type }] };
3328
3655
  return {
3329
- name: name20,
3656
+ name: name22,
3330
3657
  type: dataType,
3331
3658
  nullable: false,
3332
- metadata
3659
+ metadata: metadata2
3333
3660
  };
3334
3661
  }
3335
3662
  function makeMeshAttributeMetadata(attribute) {
@@ -3405,7 +3732,7 @@ var init_parse_usda = __esm({
3405
3732
  }
3406
3733
  /** Parses the complete USDA layer. */
3407
3734
  parse() {
3408
- const metadata = this.tokenizer.match("(") ? this.parseMetadata(")") : {};
3735
+ const metadata2 = this.tokenizer.match("(") ? this.parseMetadata(")") : {};
3409
3736
  const rootPrims = [];
3410
3737
  while (!this.tokenizer.isAtEnd()) {
3411
3738
  if (this.isPrimDeclaration()) {
@@ -3417,7 +3744,7 @@ var init_parse_usda = __esm({
3417
3744
  return {
3418
3745
  format: "usda",
3419
3746
  url: this.url,
3420
- metadata,
3747
+ metadata: metadata2,
3421
3748
  rootPrims,
3422
3749
  layers: this.url ? [this.url] : []
3423
3750
  };
@@ -3429,19 +3756,19 @@ var init_parse_usda = __esm({
3429
3756
  const firstToken = this.tokenizer.read();
3430
3757
  const hasExplicitType = this.tokenizer.peek().kind === "string";
3431
3758
  const type = hasExplicitType ? firstToken.value : "";
3432
- const name20 = hasExplicitType ? this.tokenizer.read().value : firstToken.value;
3433
- const path = `${parentPath}/${name20}`;
3434
- const metadata = this.tokenizer.match("(") ? this.parseMetadata(")") : {};
3759
+ const name22 = hasExplicitType ? this.tokenizer.read().value : firstToken.value;
3760
+ const path = `${parentPath}/${name22}`;
3761
+ const metadata2 = this.tokenizer.match("(") ? this.parseMetadata(")") : {};
3435
3762
  this.tokenizer.expect("{");
3436
3763
  const contents = this.parsePrimContents(path);
3437
3764
  return {
3438
- name: name20,
3765
+ name: name22,
3439
3766
  path,
3440
3767
  sourceUrl: this.url,
3441
3768
  type,
3442
3769
  specifier,
3443
3770
  attributes: contents.attributes,
3444
- metadata: { ...metadata, ...contents.metadata },
3771
+ metadata: { ...metadata2, ...contents.metadata },
3445
3772
  variants: contents.variants,
3446
3773
  children: contents.children
3447
3774
  };
@@ -3449,7 +3776,7 @@ var init_parse_usda = __esm({
3449
3776
  /** Parses the attributes, variants, and child prims inside a prim body. */
3450
3777
  parsePrimContents(parentPath) {
3451
3778
  const attributes = {};
3452
- const metadata = {};
3779
+ const metadata2 = {};
3453
3780
  const children = [];
3454
3781
  const variants = {};
3455
3782
  while (!this.tokenizer.isAtEnd() && !this.tokenizer.match("}")) {
@@ -3464,7 +3791,7 @@ var init_parse_usda = __esm({
3464
3791
  }
3465
3792
  }
3466
3793
  }
3467
- return { attributes, metadata, children, variants };
3794
+ return { attributes, metadata: metadata2, children, variants };
3468
3795
  }
3469
3796
  /** Parses one named variant set. */
3470
3797
  parseVariantSet(parentPath, variants) {
@@ -3511,15 +3838,15 @@ var init_parse_usda = __esm({
3511
3838
  if (significantTokens.length === 0) {
3512
3839
  return null;
3513
3840
  }
3514
- const name20 = significantTokens[significantTokens.length - 1].value;
3841
+ const name22 = significantTokens[significantTokens.length - 1].value;
3515
3842
  const type = significantTokens.slice(0, -1).map((token) => token.value).join("");
3516
3843
  const value = this.parseValue();
3517
- const metadata = this.tokenizer.match("(") ? this.parseMetadata(")") : {};
3518
- return { name: name20, type, value, metadata };
3844
+ const metadata2 = this.tokenizer.match("(") ? this.parseMetadata(")") : {};
3845
+ return { name: name22, type, value, metadata: metadata2 };
3519
3846
  }
3520
3847
  /** Parses a metadata dictionary through the requested terminator. */
3521
3848
  parseMetadata(terminator) {
3522
- const metadata = {};
3849
+ const metadata2 = {};
3523
3850
  while (!this.tokenizer.isAtEnd() && !this.tokenizer.match(terminator)) {
3524
3851
  this.tokenizer.match(",");
3525
3852
  if (this.tokenizer.peek().value === terminator) {
@@ -3541,11 +3868,11 @@ var init_parse_usda = __esm({
3541
3868
  if (this.tokenizer.previousValue !== "=" && this.tokenizer.previousValue !== ":") {
3542
3869
  continue;
3543
3870
  }
3544
- const name20 = declarationTokens[declarationTokens.length - 1].value;
3545
- metadata[name20] = this.parseValue();
3871
+ const name22 = declarationTokens[declarationTokens.length - 1].value;
3872
+ metadata2[name22] = this.parseValue();
3546
3873
  this.tokenizer.match(",");
3547
3874
  }
3548
- return metadata;
3875
+ return metadata2;
3549
3876
  }
3550
3877
  /** Parses one scalar, list, tuple, dictionary, asset path, or scene path value. */
3551
3878
  parseValue() {
@@ -4273,9 +4600,9 @@ function serializeArrowWorkerTable(result) {
4273
4600
  if (!isArrowTableWrapper(result)) {
4274
4601
  throw new Error("Workers require Arrow table output");
4275
4602
  }
4276
- const { data, ...metadata } = result;
4603
+ const { data, ...metadata2 } = result;
4277
4604
  return {
4278
- ...structuredClone(metadata),
4605
+ ...structuredClone(metadata2),
4279
4606
  data: dehydrateArrowTable(data, { copy: "all" })
4280
4607
  };
4281
4608
  }
@@ -4374,11 +4701,11 @@ var init_arrow_transport = __esm({
4374
4701
  });
4375
4702
 
4376
4703
  // ../scene/src/obj/lib/get-obj-schema.ts
4377
- function getOBJSchema(attributes, metadata = {}) {
4704
+ function getOBJSchema(attributes, metadata2 = {}) {
4378
4705
  const stringMetadata = {};
4379
- for (const key in metadata) {
4706
+ for (const key in metadata2) {
4380
4707
  if (key !== "value") {
4381
- stringMetadata[key] = JSON.stringify(metadata[key]);
4708
+ stringMetadata[key] = JSON.stringify(metadata2[key]);
4382
4709
  }
4383
4710
  }
4384
4711
  const fields = [];
@@ -4389,11 +4716,11 @@ function getOBJSchema(attributes, metadata = {}) {
4389
4716
  }
4390
4717
  return { fields, metadata: stringMetadata };
4391
4718
  }
4392
- function getFieldFromAttribute(name20, attribute) {
4393
- const metadata = {};
4719
+ function getFieldFromAttribute(name22, attribute) {
4720
+ const metadata2 = {};
4394
4721
  for (const key in attribute) {
4395
4722
  if (key !== "value") {
4396
- metadata[key] = JSON.stringify(attribute[key]);
4723
+ metadata2[key] = JSON.stringify(attribute[key]);
4397
4724
  }
4398
4725
  }
4399
4726
  let { type } = getDataTypeFromArray(attribute.value);
@@ -4401,7 +4728,7 @@ function getFieldFromAttribute(name20, attribute) {
4401
4728
  if (!isSingleValue) {
4402
4729
  type = { type: "fixed-size-list", listSize: attribute.size, children: [{ name: "values", type }] };
4403
4730
  }
4404
- return { name: name20, type, nullable: false, metadata };
4731
+ return { name: name22, type, nullable: false, metadata: metadata2 };
4405
4732
  }
4406
4733
  var init_get_obj_schema = __esm({
4407
4734
  "../scene/src/obj/lib/get-obj-schema.ts"() {
@@ -4487,8 +4814,8 @@ function parseOBJMeshes(text) {
4487
4814
  state.addPointGeometry(pointData);
4488
4815
  } else if (OBJECT_RE.test(line)) {
4489
4816
  result = OBJECT_RE.exec(line) || [];
4490
- const name20 = (" " + result[0].substr(1).trim()).substr(1);
4491
- state.startObject(name20);
4817
+ const name22 = (" " + result[0].substr(1).trim()).substr(1);
4818
+ state.startObject(name22);
4492
4819
  } else if (MATERIAL_USE_RE.test(line)) {
4493
4820
  state.object.startMaterial(line.substring(7).trim(), state.materialLibraries);
4494
4821
  } else if (MATERIAL_RE.test(line)) {
@@ -4563,9 +4890,9 @@ var init_parse_obj_meshes = __esm({
4563
4890
  MATERIAL_RE = /^mtllib /;
4564
4891
  MATERIAL_USE_RE = /^usemtl /;
4565
4892
  MeshMaterial = class _MeshMaterial {
4566
- constructor({ index, name: name20 = "", mtllib, smooth, groupStart }) {
4893
+ constructor({ index, name: name22 = "", mtllib, smooth, groupStart }) {
4567
4894
  this.index = index;
4568
- this.name = name20;
4895
+ this.name = name22;
4569
4896
  this.mtllib = mtllib;
4570
4897
  this.smooth = smooth;
4571
4898
  this.groupStart = groupStart;
@@ -4584,8 +4911,8 @@ var init_parse_obj_meshes = __esm({
4584
4911
  }
4585
4912
  };
4586
4913
  MeshObject = class {
4587
- constructor(name20 = "") {
4588
- this.name = name20;
4914
+ constructor(name22 = "") {
4915
+ this.name = name22;
4589
4916
  this.geometry = {
4590
4917
  vertices: [],
4591
4918
  normals: [],
@@ -4596,14 +4923,14 @@ var init_parse_obj_meshes = __esm({
4596
4923
  this.smooth = true;
4597
4924
  this.fromDeclaration = null;
4598
4925
  }
4599
- startMaterial(name20, libraries) {
4926
+ startMaterial(name22, libraries) {
4600
4927
  const previous = this._finalize(false);
4601
4928
  if (previous && (previous.inherited || previous.groupCount <= 0)) {
4602
4929
  this.materials.splice(previous.index, 1);
4603
4930
  }
4604
4931
  const material = new MeshMaterial({
4605
4932
  index: this.materials.length,
4606
- name: name20,
4933
+ name: name22,
4607
4934
  mtllib: Array.isArray(libraries) && libraries.length > 0 ? libraries[libraries.length - 1] : "",
4608
4935
  smooth: previous !== void 0 ? previous.smooth : this.smooth,
4609
4936
  groupStart: previous !== void 0 ? previous.groupEnd : 0
@@ -4651,9 +4978,9 @@ var init_parse_obj_meshes = __esm({
4651
4978
  this.materialLibraries = [];
4652
4979
  this.startObject("", false);
4653
4980
  }
4654
- startObject(name20, fromDeclaration = true) {
4981
+ startObject(name22, fromDeclaration = true) {
4655
4982
  if (this.object && !this.object.fromDeclaration) {
4656
- this.object.name = name20;
4983
+ this.object.name = name22;
4657
4984
  this.object.fromDeclaration = fromDeclaration;
4658
4985
  return;
4659
4986
  }
@@ -4661,7 +4988,7 @@ var init_parse_obj_meshes = __esm({
4661
4988
  if (this.object && typeof this.object._finalize === "function") {
4662
4989
  this.object._finalize(true);
4663
4990
  }
4664
- this.object = new MeshObject(name20);
4991
+ this.object = new MeshObject(name22);
4665
4992
  this.object.fromDeclaration = fromDeclaration;
4666
4993
  if (previousMaterial && previousMaterial.name && typeof previousMaterial.clone === "function") {
4667
4994
  const declared = previousMaterial.clone(0);
@@ -5930,6 +6257,33 @@ var init_resolve_gltf_file = __esm({
5930
6257
  }
5931
6258
  });
5932
6259
 
6260
+ // ../scene/src/gltf/lib/extensions/KHR_accessor_float64.ts
6261
+ var KHR_accessor_float64_exports = {};
6262
+ __export(KHR_accessor_float64_exports, {
6263
+ name: () => name,
6264
+ preprocess: () => preprocess
6265
+ });
6266
+ function preprocess(gltf) {
6267
+ var _a, _b, _c, _d;
6268
+ const { json } = gltf;
6269
+ if (!((_a = json.extensionsUsed) == null ? void 0 : _a.includes(name)) && !((_b = json.extensionsRequired) == null ? void 0 : _b.includes(name))) return;
6270
+ if (!((_c = json.extensionsUsed) == null ? void 0 : _c.includes(name)) || !((_d = json.extensionsRequired) == null ? void 0 : _d.includes(name))) {
6271
+ throw new Error(`${name}: must be declared in extensionsUsed and extensionsRequired.`);
6272
+ }
6273
+ for (const [index, accessor] of (json.accessors || []).entries()) {
6274
+ if (accessor.componentType === 5130 && accessor.normalized) {
6275
+ throw new Error(`${name}: accessor ${index} must not be normalized.`);
6276
+ }
6277
+ }
6278
+ }
6279
+ var name;
6280
+ var init_KHR_accessor_float64 = __esm({
6281
+ "../scene/src/gltf/lib/extensions/KHR_accessor_float64.ts"() {
6282
+ "use strict";
6283
+ name = "KHR_accessor_float64";
6284
+ }
6285
+ });
6286
+
5933
6287
  // ../scene/src/gltf/lib/api/gltf-scenegraph.ts
5934
6288
  function makeDefaultGLTFJson() {
5935
6289
  return {
@@ -5984,17 +6338,17 @@ var init_gltf_scenegraph = __esm({
5984
6338
  return extras[key];
5985
6339
  }
5986
6340
  hasExtension(extensionName) {
5987
- const isUsedExtension = this.getUsedExtensions().find((name20) => name20 === extensionName);
5988
- const isRequiredExtension = this.getRequiredExtensions().find((name20) => name20 === extensionName);
6341
+ const isUsedExtension = this.getUsedExtensions().find((name22) => name22 === extensionName);
6342
+ const isRequiredExtension = this.getRequiredExtensions().find((name22) => name22 === extensionName);
5989
6343
  return typeof isUsedExtension === "string" || typeof isRequiredExtension === "string";
5990
6344
  }
5991
6345
  getExtension(extensionName) {
5992
- const isExtension = this.getUsedExtensions().find((name20) => name20 === extensionName);
6346
+ const isExtension = this.getUsedExtensions().find((name22) => name22 === extensionName);
5993
6347
  const extensions = this.json.extensions || {};
5994
6348
  return isExtension ? extensions[extensionName] : null;
5995
6349
  }
5996
6350
  getRequiredExtension(extensionName) {
5997
- const isRequired = this.getRequiredExtensions().find((name20) => name20 === extensionName);
6351
+ const isRequired = this.getRequiredExtensions().find((name22) => name22 === extensionName);
5998
6352
  return isRequired ? this.getExtension(extensionName) : null;
5999
6353
  }
6000
6354
  getRequiredExtensions() {
@@ -6255,8 +6609,8 @@ var init_gltf_scenegraph = __esm({
6255
6609
  * @param mimeType
6256
6610
  */
6257
6611
  addImage(imageData, mimeTypeOpt) {
6258
- const metadata = getBinaryImageMetadata(imageData);
6259
- const mimeType = mimeTypeOpt || (metadata == null ? void 0 : metadata.mimeType);
6612
+ const metadata2 = getBinaryImageMetadata(imageData);
6613
+ const mimeType = mimeTypeOpt || (metadata2 == null ? void 0 : metadata2.mimeType);
6260
6614
  const bufferViewIndex = this.addBufferView(imageData);
6261
6615
  const glTFImage = {
6262
6616
  bufferView: bufferViewIndex,
@@ -6396,8 +6750,8 @@ var init_gltf_scenegraph = __esm({
6396
6750
  assert3(bufferOffset !== void 0);
6397
6751
  bufferView.byteOffset = bufferOffset + (bufferView.byteOffset || 0);
6398
6752
  bufferView.buffer = 0;
6399
- for (const name20 of ["EXT_meshopt_compression", "KHR_meshopt_compression"]) {
6400
- const extension = (_b = bufferView.extensions) == null ? void 0 : _b[name20];
6753
+ for (const name22 of ["EXT_meshopt_compression", "KHR_meshopt_compression"]) {
6754
+ const extension = (_b = bufferView.extensions) == null ? void 0 : _b[name22];
6401
6755
  if (extension) {
6402
6756
  const extensionOffset = bufferOffsets[extension.buffer];
6403
6757
  assert3(extensionOffset !== void 0);
@@ -6716,7 +7070,7 @@ function iterateObjectData(objects) {
6716
7070
  })();
6717
7071
  }
6718
7072
  function mapObjectData(objects) {
6719
- return new Map(Array.from(objects, ([name20, object]) => [name20, object.data]));
7073
+ return new Map(Array.from(objects, ([name22, object]) => [name22, object.data]));
6720
7074
  }
6721
7075
  function getCollectionName(type) {
6722
7076
  switch (type) {
@@ -7139,8 +7493,8 @@ var init_gltf_iterator = __esm({
7139
7493
  }
7140
7494
  /** Return the loaded buffer companion for a raw buffer definition. */
7141
7495
  getLoadedBuffer(buffer) {
7142
- const metadata = this.getMetadata(buffer);
7143
- return this.gltf.buffers[metadata.index];
7496
+ const metadata2 = this.getMetadata(buffer);
7497
+ return this.gltf.buffers[metadata2.index];
7144
7498
  }
7145
7499
  /** Return the loaded byte range for a raw buffer-view definition. */
7146
7500
  getLoadedBufferView(bufferView) {
@@ -7594,7 +7948,7 @@ function getPrimitiveTextureData(scenegraph, textureInfo, primitive) {
7594
7948
  if (typeof imageIndex !== "undefined") {
7595
7949
  const mimeType = (_d = (_c = json.images) == null ? void 0 : _c[imageIndex]) == null ? void 0 : _d.mimeType;
7596
7950
  const parsedImage = (_e = scenegraph.gltf.images) == null ? void 0 : _e[imageIndex];
7597
- if (parsedImage && typeof parsedImage.width !== "undefined") {
7951
+ if (parsedImage && typeof parsedImage.width !== "undefined" && !("compressed" in parsedImage && parsedImage.compressed)) {
7598
7952
  const textureData = [];
7599
7953
  for (let index = 0; index < textureCoordinates.length; index += 2) {
7600
7954
  const value = getImageValueByCoordinates(
@@ -7785,7 +8139,7 @@ __export(EXT_mesh_features_exports, {
7785
8139
  createExtMeshFeatures: () => createExtMeshFeatures,
7786
8140
  decode: () => decode,
7787
8141
  encode: () => encode,
7788
- name: () => name
8142
+ name: () => name2
7789
8143
  });
7790
8144
  async function decode(gltfData, options) {
7791
8145
  const iterator = new GLTFIterator(gltfData);
@@ -7922,7 +8276,7 @@ function createAccessorKey(attributes) {
7922
8276
  const accessorKey = `${prefix}${max}`;
7923
8277
  return { accessorKey, index: max };
7924
8278
  }
7925
- var EXT_MESH_FEATURES_NAME, name;
8279
+ var EXT_MESH_FEATURES_NAME, name2;
7926
8280
  var init_EXT_mesh_features = __esm({
7927
8281
  "../scene/src/gltf/lib/extensions/EXT_mesh_features.ts"() {
7928
8282
  "use strict";
@@ -7931,7 +8285,7 @@ var init_EXT_mesh_features = __esm({
7931
8285
  init_d_tiles_utils();
7932
8286
  init_gltf_utils();
7933
8287
  EXT_MESH_FEATURES_NAME = "EXT_mesh_features";
7934
- name = EXT_MESH_FEATURES_NAME;
8288
+ name2 = EXT_MESH_FEATURES_NAME;
7935
8289
  }
7936
8290
  });
7937
8291
 
@@ -7941,7 +8295,7 @@ __export(EXT_structural_metadata_exports, {
7941
8295
  createExtStructuralMetadata: () => createExtStructuralMetadata,
7942
8296
  decode: () => decode2,
7943
8297
  encode: () => encode2,
7944
- name: () => name2
8298
+ name: () => name3
7945
8299
  });
7946
8300
  async function decode2(gltfData, options, context) {
7947
8301
  var _a;
@@ -8580,7 +8934,7 @@ function createPropertyDataString(strings) {
8580
8934
  function createBufferView(typedArray, scenegraph) {
8581
8935
  return scenegraph.addBufferView(typedArray);
8582
8936
  }
8583
- var EXT_STRUCTURAL_METADATA_NAME, name2, SCHEMA_CLASS_ID_DEFAULT, COMPONENT_TYPE_TO_ARRAY_CONSTRUCTOR;
8937
+ var EXT_STRUCTURAL_METADATA_NAME, name3, SCHEMA_CLASS_ID_DEFAULT, COMPONENT_TYPE_TO_ARRAY_CONSTRUCTOR;
8584
8938
  var init_EXT_structural_metadata = __esm({
8585
8939
  "../scene/src/gltf/lib/extensions/EXT_structural_metadata.ts"() {
8586
8940
  "use strict";
@@ -8589,7 +8943,7 @@ var init_EXT_structural_metadata = __esm({
8589
8943
  init_d_tiles_utils();
8590
8944
  init_resolve_url();
8591
8945
  EXT_STRUCTURAL_METADATA_NAME = "EXT_structural_metadata";
8592
- name2 = EXT_STRUCTURAL_METADATA_NAME;
8946
+ name3 = EXT_STRUCTURAL_METADATA_NAME;
8593
8947
  SCHEMA_CLASS_ID_DEFAULT = "schemaClassId";
8594
8948
  COMPONENT_TYPE_TO_ARRAY_CONSTRUCTOR = {
8595
8949
  INT8: Int8Array,
@@ -8612,15 +8966,19 @@ __export(KHR_gaussian_splatting_exports, {
8612
8966
  SPZ_COMPRESSION_EXTENSION_NAME: () => SPZ_COMPRESSION_EXTENSION_NAME,
8613
8967
  decode: () => decode3,
8614
8968
  getGaussianSplatPrimitives: () => getGaussianSplatPrimitives,
8615
- name: () => name3
8969
+ name: () => name4
8616
8970
  });
8617
- async function decode3(gltfData, options) {
8618
- var _a, _b, _c, _d;
8971
+ async function decode3(gltfData, options, context) {
8972
+ var _a, _b, _c, _d, _e;
8973
+ const loader = (_a = context == null ? void 0 : context.loaders) == null ? void 0 : _a.find((candidate) => {
8974
+ var _a2;
8975
+ return (_a2 = candidate.extensions) == null ? void 0 : _a2.includes("spz");
8976
+ });
8619
8977
  const descriptors = getGaussianSplatPrimitives(gltfData);
8620
8978
  const iterator = new GLTFIterator(gltfData);
8621
8979
  for (const [meshIndex, mesh] of (gltfData.json.meshes || []).entries()) {
8622
8980
  for (const [primitiveIndex, primitive] of mesh.primitives.entries()) {
8623
- const extension = (_a = primitive.extensions) == null ? void 0 : _a[name3];
8981
+ const extension = (_b = primitive.extensions) == null ? void 0 : _b[name4];
8624
8982
  if (!extension) continue;
8625
8983
  validateGaussianSplatPrimitive(
8626
8984
  gltfData.json,
@@ -8630,22 +8988,29 @@ async function decode3(gltfData, options) {
8630
8988
  primitiveIndex,
8631
8989
  iterator
8632
8990
  );
8633
- const compression = (_b = extension.extensions) == null ? void 0 : _b[SPZ_COMPRESSION_EXTENSION_NAME];
8991
+ const compression = (_c = extension.extensions) == null ? void 0 : _c[SPZ_COMPRESSION_EXTENSION_NAME];
8634
8992
  if (compression) {
8635
8993
  const descriptor = descriptors.find(
8636
8994
  (item) => item.meshIndex === meshIndex && item.primitiveIndex === primitiveIndex
8637
8995
  );
8638
8996
  if (descriptor) {
8639
- const decoder = (_c = options == null ? void 0 : options.gltf) == null ? void 0 : _c.splatDecoder;
8640
- const bufferView = (_d = gltfData.json.bufferViews) == null ? void 0 : _d[compression.bufferView];
8997
+ const decoder = (_d = options == null ? void 0 : options.gltf) == null ? void 0 : _d.splatDecoder;
8998
+ const bufferView = (_e = gltfData.json.bufferViews) == null ? void 0 : _e[compression.bufferView];
8641
8999
  if (bufferView && gltfData.buffers[bufferView.buffer]) {
8642
9000
  descriptor.compressedBytes = getBufferViewBytes(gltfData, compression.bufferView);
8643
- } else if (decoder) {
9001
+ } else if (decoder || loader) {
8644
9002
  throw new Error(
8645
9003
  `KHR_gaussian_splatting: bufferView ${compression.bufferView} is not loaded for SPZ2 decoding.`
8646
9004
  );
8647
9005
  }
8648
- if (decoder && descriptor.compressedBytes) {
9006
+ if (loader && context && descriptor.compressedBytes) {
9007
+ descriptor.decoded = await parseFromContext(
9008
+ descriptor.compressedBytes.buffer,
9009
+ loader,
9010
+ { ...options, splats: { ...options.splats, sourceCoordinateSystem: "LUF" } },
9011
+ context
9012
+ );
9013
+ } else if (decoder && descriptor.compressedBytes) {
8649
9014
  descriptor.decoded = await decoder(descriptor.compressedBytes.buffer, {
8650
9015
  sourceCoordinateSystem: "LUF"
8651
9016
  });
@@ -8679,7 +9044,7 @@ function getGaussianSplatPrimitives(gltf) {
8679
9044
  const descriptors = [];
8680
9045
  for (const [meshIndex, mesh] of (json.meshes || []).entries()) {
8681
9046
  for (const [primitiveIndex, primitive] of mesh.primitives.entries()) {
8682
- const extension = (_a = primitive.extensions) == null ? void 0 : _a[name3];
9047
+ const extension = (_a = primitive.extensions) == null ? void 0 : _a[name4];
8683
9048
  if (!extension) continue;
8684
9049
  const compressedBufferView = (_c = (_b = extension.extensions) == null ? void 0 : _b[SPZ_COMPRESSION_EXTENSION_NAME]) == null ? void 0 : _c.bufferView;
8685
9050
  descriptors.push({
@@ -8782,12 +9147,13 @@ function isAccessorLoaded(gltf, iterator, accessorIndex) {
8782
9147
  const bufferView = (accessor == null ? void 0 : accessor.bufferView) === void 0 ? void 0 : (_b = gltf.bufferViews) == null ? void 0 : _b[accessor.bufferView];
8783
9148
  return Boolean(bufferView && iterator.gltf.buffers[bufferView.buffer]);
8784
9149
  }
8785
- var name3, SPZ_COMPRESSION_EXTENSION_NAME, REQUIRED_ATTRIBUTES;
9150
+ var name4, SPZ_COMPRESSION_EXTENSION_NAME, REQUIRED_ATTRIBUTES;
8786
9151
  var init_KHR_gaussian_splatting = __esm({
8787
9152
  "../scene/src/gltf/lib/extensions/KHR_gaussian_splatting.ts"() {
8788
9153
  "use strict";
9154
+ init_loader_utils();
8789
9155
  init_gltf_iterator();
8790
- name3 = "KHR_gaussian_splatting";
9156
+ name4 = "KHR_gaussian_splatting";
8791
9157
  SPZ_COMPRESSION_EXTENSION_NAME = "KHR_gaussian_splatting_compression_spz_2";
8792
9158
  REQUIRED_ATTRIBUTES = [
8793
9159
  "POSITION",
@@ -8804,13 +9170,13 @@ var EXT_primitive_voxels_exports = {};
8804
9170
  __export(EXT_primitive_voxels_exports, {
8805
9171
  decode: () => decode4,
8806
9172
  getVoxelPrimitives: () => getVoxelPrimitives,
8807
- name: () => name4
9173
+ name: () => name5
8808
9174
  });
8809
9175
  async function decode4(gltfData) {
8810
9176
  var _a;
8811
9177
  for (const [meshIndex, mesh] of (gltfData.json.meshes || []).entries()) {
8812
9178
  for (const [primitiveIndex, primitive] of mesh.primitives.entries()) {
8813
- const extension = (_a = primitive.extensions) == null ? void 0 : _a[name4];
9179
+ const extension = (_a = primitive.extensions) == null ? void 0 : _a[name5];
8814
9180
  if (extension)
8815
9181
  validateVoxelPrimitive(gltfData.json, primitive, extension, meshIndex, primitiveIndex);
8816
9182
  }
@@ -8822,7 +9188,7 @@ function getVoxelPrimitives(gltf) {
8822
9188
  const descriptors = [];
8823
9189
  for (const [meshIndex, mesh] of (json.meshes || []).entries()) {
8824
9190
  for (const [primitiveIndex, primitive] of mesh.primitives.entries()) {
8825
- const extension = (_a = primitive.extensions) == null ? void 0 : _a[name4];
9191
+ const extension = (_a = primitive.extensions) == null ? void 0 : _a[name5];
8826
9192
  if (extension) {
8827
9193
  descriptors.push({
8828
9194
  meshIndex,
@@ -8860,11 +9226,11 @@ function validateVoxelPrimitive(gltf, primitive, extension, meshIndex, primitive
8860
9226
  }
8861
9227
  }
8862
9228
  }
8863
- var name4;
9229
+ var name5;
8864
9230
  var init_EXT_primitive_voxels = __esm({
8865
9231
  "../scene/src/gltf/lib/extensions/EXT_primitive_voxels.ts"() {
8866
9232
  "use strict";
8867
- name4 = "EXT_primitive_voxels";
9233
+ name5 = "EXT_primitive_voxels";
8868
9234
  }
8869
9235
  });
8870
9236
 
@@ -8873,15 +9239,15 @@ var KHR_mesh_primitive_restart_exports = {};
8873
9239
  __export(KHR_mesh_primitive_restart_exports, {
8874
9240
  decode: () => decode5,
8875
9241
  getPrimitiveRestartRanges: () => getPrimitiveRestartRanges,
8876
- name: () => name5
9242
+ name: () => name6
8877
9243
  });
8878
9244
  async function decode5(gltfData, options) {
8879
9245
  var _a, _b, _c;
8880
- if (!((_a = gltfData.json.extensionsUsed) == null ? void 0 : _a.includes(name5))) {
9246
+ if (!((_a = gltfData.json.extensionsUsed) == null ? void 0 : _a.includes(name6))) {
8881
9247
  return;
8882
9248
  }
8883
- if (!((_b = gltfData.json.extensionsRequired) == null ? void 0 : _b.includes(name5))) {
8884
- throw new Error(`${name5} must be declared in extensionsRequired`);
9249
+ if (!((_b = gltfData.json.extensionsRequired) == null ? void 0 : _b.includes(name6))) {
9250
+ throw new Error(`${name6} must be declared in extensionsRequired`);
8885
9251
  }
8886
9252
  if (!((_c = options.gltf) == null ? void 0 : _c.loadBuffers)) {
8887
9253
  return;
@@ -8901,14 +9267,14 @@ function decodePrimitiveRestart(iterator, primitive) {
8901
9267
  const indicesAccessor = primitive.indices;
8902
9268
  const accessor = typeof indicesAccessor === "number" ? (_a = iterator.data.accessors) == null ? void 0 : _a[indicesAccessor] : indicesAccessor;
8903
9269
  if (!accessor) {
8904
- throw new Error(`${name5}: primitive references missing indices accessor ${primitive.indices}`);
9270
+ throw new Error(`${name6}: primitive references missing indices accessor ${primitive.indices}`);
8905
9271
  }
8906
9272
  const restartIndex = getRestartIndex(accessor);
8907
9273
  const indices = iterator.getTypedArrayForAccessor(primitive.indices);
8908
9274
  const containsRestart = Array.prototype.includes.call(indices, restartIndex);
8909
9275
  if (!SUPPORTED_MODES.has(primitive.mode ?? 4)) {
8910
9276
  if (containsRestart) {
8911
- throw new Error(`${name5}: primitive restart is not valid for mode ${primitive.mode ?? 4}`);
9277
+ throw new Error(`${name6}: primitive restart is not valid for mode ${primitive.mode ?? 4}`);
8912
9278
  }
8913
9279
  return;
8914
9280
  }
@@ -8924,7 +9290,7 @@ function decodePrimitiveRestart(iterator, primitive) {
8924
9290
  }
8925
9291
  function getRestartIndex(accessor) {
8926
9292
  if (accessor.type !== "SCALAR") {
8927
- throw new Error(`${name5}: indices accessor must have SCALAR type`);
9293
+ throw new Error(`${name6}: indices accessor must have SCALAR type`);
8928
9294
  }
8929
9295
  switch (accessor.componentType) {
8930
9296
  case 5121:
@@ -8934,7 +9300,7 @@ function getRestartIndex(accessor) {
8934
9300
  case 5125:
8935
9301
  return 4294967295;
8936
9302
  default:
8937
- throw new Error(`${name5}: indices accessor must use an unsigned integer component type`);
9303
+ throw new Error(`${name6}: indices accessor must use an unsigned integer component type`);
8938
9304
  }
8939
9305
  }
8940
9306
  function getPrimitiveRestartRanges(indices, restartIndex) {
@@ -8950,12 +9316,12 @@ function getPrimitiveRestartRanges(indices, restartIndex) {
8950
9316
  }
8951
9317
  return ranges;
8952
9318
  }
8953
- var name5, SUPPORTED_MODES;
9319
+ var name6, SUPPORTED_MODES;
8954
9320
  var init_KHR_mesh_primitive_restart = __esm({
8955
9321
  "../scene/src/gltf/lib/extensions/KHR_mesh_primitive_restart.ts"() {
8956
9322
  "use strict";
8957
9323
  init_gltf_iterator();
8958
- name5 = "KHR_mesh_primitive_restart";
9324
+ name6 = "KHR_mesh_primitive_restart";
8959
9325
  SUPPORTED_MODES = /* @__PURE__ */ new Set([2, 3, 5, 6]);
8960
9326
  }
8961
9327
  });
@@ -8964,7 +9330,7 @@ var init_KHR_mesh_primitive_restart = __esm({
8964
9330
  var EXT_mesh_polygon_exports = {};
8965
9331
  __export(EXT_mesh_polygon_exports, {
8966
9332
  decode: () => decode6,
8967
- name: () => name6
9333
+ name: () => name7
8968
9334
  });
8969
9335
  async function decode6(gltfData, options) {
8970
9336
  var _a;
@@ -8974,7 +9340,7 @@ async function decode6(gltfData, options) {
8974
9340
  const iterator = new GLTFIterator(gltfData);
8975
9341
  for (const mesh of iterator.meshes) {
8976
9342
  for (const primitive of iterator.getReferences(mesh).primitives) {
8977
- const extension = iterator.getExtension(primitive, name6);
9343
+ const extension = iterator.getExtension(primitive, name7);
8978
9344
  if (extension) {
8979
9345
  Object.defineProperty(extension, "data", {
8980
9346
  configurable: true,
@@ -8989,10 +9355,10 @@ async function decode6(gltfData, options) {
8989
9355
  function decodePolygonData(iterator, primitive, extension) {
8990
9356
  var _a;
8991
9357
  if (!Number.isInteger(extension.count) || extension.count < 1) {
8992
- throw new Error(`${name6}: count must be a positive integer`);
9358
+ throw new Error(`${name7}: count must be a positive integer`);
8993
9359
  }
8994
9360
  if ((primitive.mode ?? 4) !== 4 || primitive.indices === void 0) {
8995
- throw new Error(`${name6}: primitive must use TRIANGLES mode with indices`);
9361
+ throw new Error(`${name7}: primitive must use TRIANGLES mode with indices`);
8996
9362
  }
8997
9363
  const triangleIndices = getUnsignedScalarAccessor(iterator, primitive.indices, "indices");
8998
9364
  const indicesOffsets = getUnsignedScalarAccessor(
@@ -9025,14 +9391,14 @@ function decodePolygonData(iterator, primitive, extension) {
9025
9391
  }));
9026
9392
  if ((triangleEnd - triangleStart) % 3 !== 0) {
9027
9393
  throw new Error(
9028
- `${name6}: polygon ${polygonIndex} triangle range must contain complete triangles`
9394
+ `${name7}: polygon ${polygonIndex} triangle range must contain complete triangles`
9029
9395
  );
9030
9396
  }
9031
9397
  if (loopRanges.length === 0) {
9032
- throw new Error(`${name6}: polygon ${polygonIndex} must contain at least one loop`);
9398
+ throw new Error(`${name7}: polygon ${polygonIndex} must contain at least one loop`);
9033
9399
  }
9034
9400
  if (loopRanges.some((range) => range.count < 3)) {
9035
- throw new Error(`${name6}: polygon ${polygonIndex} loops must contain at least three indices`);
9401
+ throw new Error(`${name7}: polygon ${polygonIndex} loops must contain at least three indices`);
9036
9402
  }
9037
9403
  polygons.push({
9038
9404
  triangleRange: { offset: triangleStart, count: triangleEnd - triangleStart },
@@ -9044,29 +9410,29 @@ function decodePolygonData(iterator, primitive, extension) {
9044
9410
  function getUnsignedScalarAccessor(iterator, accessorReference, label, expectedCount) {
9045
9411
  var _a;
9046
9412
  if (typeof accessorReference === "number" && (!Number.isInteger(accessorReference) || accessorReference < 0)) {
9047
- throw new Error(`${name6}: ${label} must reference an accessor`);
9413
+ throw new Error(`${name7}: ${label} must reference an accessor`);
9048
9414
  }
9049
9415
  const accessor = typeof accessorReference === "number" ? (_a = iterator.data.accessors) == null ? void 0 : _a[accessorReference] : accessorReference;
9050
9416
  if (!accessor) {
9051
- throw new Error(`${name6}: ${label} references missing accessor ${accessorReference}`);
9417
+ throw new Error(`${name7}: ${label} references missing accessor ${accessorReference}`);
9052
9418
  }
9053
9419
  if (accessor.type !== "SCALAR" || ![5121, 5123, 5125].includes(accessor.componentType)) {
9054
- throw new Error(`${name6}: ${label} must be an unsigned integer SCALAR accessor`);
9420
+ throw new Error(`${name7}: ${label} must be an unsigned integer SCALAR accessor`);
9055
9421
  }
9056
9422
  if (expectedCount !== void 0 && accessor.count !== expectedCount) {
9057
- throw new Error(`${name6}: ${label} count must equal polygon count ${expectedCount}`);
9423
+ throw new Error(`${name7}: ${label} count must equal polygon count ${expectedCount}`);
9058
9424
  }
9059
9425
  return iterator.getTypedArrayForAccessor(accessorReference);
9060
9426
  }
9061
9427
  function validateOffsets(offsets, targetLength, label) {
9062
9428
  if (Number(offsets[0]) !== 0) {
9063
- throw new Error(`${name6}: ${label} must begin at zero`);
9429
+ throw new Error(`${name7}: ${label} must begin at zero`);
9064
9430
  }
9065
9431
  let previousOffset = -1;
9066
9432
  for (let index = 0; index < offsets.length; index++) {
9067
9433
  const offset = Number(offsets[index]);
9068
9434
  if (!Number.isInteger(offset) || offset < 0 || offset >= targetLength || offset <= previousOffset) {
9069
- throw new Error(`${name6}: ${label} must contain increasing in-bounds offsets`);
9435
+ throw new Error(`${name7}: ${label} must contain increasing in-bounds offsets`);
9070
9436
  }
9071
9437
  previousOffset = offset;
9072
9438
  }
@@ -9080,16 +9446,16 @@ function getUnsignedMaximum(componentType) {
9080
9446
  case 5125:
9081
9447
  return 4294967295;
9082
9448
  default:
9083
- throw new Error(`${name6}: unsupported loop index component type ${componentType}`);
9449
+ throw new Error(`${name7}: unsupported loop index component type ${componentType}`);
9084
9450
  }
9085
9451
  }
9086
- var name6;
9452
+ var name7;
9087
9453
  var init_EXT_mesh_polygon = __esm({
9088
9454
  "../scene/src/gltf/lib/extensions/EXT_mesh_polygon.ts"() {
9089
9455
  "use strict";
9090
9456
  init_gltf_iterator();
9091
9457
  init_KHR_mesh_primitive_restart();
9092
- name6 = "EXT_mesh_polygon";
9458
+ name7 = "EXT_mesh_polygon";
9093
9459
  }
9094
9460
  });
9095
9461
 
@@ -9098,16 +9464,16 @@ var MPEG_audio_spatial_exports = {};
9098
9464
  __export(MPEG_audio_spatial_exports, {
9099
9465
  decode: () => decode7,
9100
9466
  getSpatialAudio: () => getSpatialAudio,
9101
- name: () => name7
9467
+ name: () => name8
9102
9468
  });
9103
9469
  function getSpatialAudio(gltf) {
9104
9470
  var _a, _b;
9105
9471
  const json = "asset" in gltf ? gltf : gltf.json;
9106
9472
  const descriptors = [];
9107
- const extension = (_a = json.extensions) == null ? void 0 : _a[name7];
9473
+ const extension = (_a = json.extensions) == null ? void 0 : _a[name8];
9108
9474
  if (extension) descriptors.push({ nodeIndex: null, extension });
9109
9475
  for (const [nodeIndex, node] of (json.nodes || []).entries()) {
9110
- const nodeExtension = (_b = node.extensions) == null ? void 0 : _b[name7];
9476
+ const nodeExtension = (_b = node.extensions) == null ? void 0 : _b[name8];
9111
9477
  if (nodeExtension) descriptors.push({ nodeIndex, extension: nodeExtension });
9112
9478
  }
9113
9479
  return descriptors;
@@ -9119,29 +9485,29 @@ async function decode7(gltfData) {
9119
9485
  const location = nodeIndex === null ? "root" : `node ${nodeIndex}`;
9120
9486
  for (const source of extension.sources || []) {
9121
9487
  if (!Array.isArray(source.accessors) || source.accessors.length === 0) {
9122
- throw new Error(`${name7}: ${location} source ${source.id} requires audio accessors.`);
9488
+ throw new Error(`${name8}: ${location} source ${source.id} requires audio accessors.`);
9123
9489
  }
9124
9490
  for (const accessorIndex of source.accessors) {
9125
9491
  if (!Number.isInteger(accessorIndex) || accessorIndex < 0 || !((_a = gltfData.json.accessors) == null ? void 0 : _a[accessorIndex])) {
9126
9492
  throw new Error(
9127
- `${name7}: ${location} source ${source.id} has invalid accessor ${accessorIndex}.`
9493
+ `${name8}: ${location} source ${source.id} has invalid accessor ${accessorIndex}.`
9128
9494
  );
9129
9495
  }
9130
9496
  }
9131
9497
  if (source.reverbFeedGain && source.reverbFeedGain.length !== (((_b = source.reverbFeed) == null ? void 0 : _b.length) || 0)) {
9132
9498
  throw new Error(
9133
- `${name7}: ${location} source ${source.id} has mismatched reverb feed gains.`
9499
+ `${name8}: ${location} source ${source.id} has mismatched reverb feed gains.`
9134
9500
  );
9135
9501
  }
9136
9502
  }
9137
9503
  }
9138
9504
  if (descriptors.length) gltfData.spatialAudio = descriptors;
9139
9505
  }
9140
- var name7;
9506
+ var name8;
9141
9507
  var init_MPEG_audio_spatial = __esm({
9142
9508
  "../scene/src/gltf/lib/extensions/MPEG_audio_spatial.ts"() {
9143
9509
  "use strict";
9144
- name7 = "MPEG_audio_spatial";
9510
+ name8 = "MPEG_audio_spatial";
9145
9511
  }
9146
9512
  });
9147
9513
 
@@ -9149,11 +9515,11 @@ var init_MPEG_audio_spatial = __esm({
9149
9515
  var KHR_audio_emitter_exports = {};
9150
9516
  __export(KHR_audio_emitter_exports, {
9151
9517
  decode: () => decode8,
9152
- name: () => name8
9518
+ name: () => name9
9153
9519
  });
9154
9520
  async function decode8(gltfData, options, context) {
9155
9521
  var _a, _b, _c;
9156
- const extension = (_a = gltfData.json.extensions) == null ? void 0 : _a[name8];
9522
+ const extension = (_a = gltfData.json.extensions) == null ? void 0 : _a[name9];
9157
9523
  const clips = ((extension == null ? void 0 : extension.audio) || []).map((audio) => ({ audio }));
9158
9524
  const sources = (extension == null ? void 0 : extension.sources) || [];
9159
9525
  const emitters = (extension == null ? void 0 : extension.emitters) || [];
@@ -9162,25 +9528,25 @@ async function decode8(gltfData, options, context) {
9162
9528
  }
9163
9529
  for (const emitter of emitters) {
9164
9530
  if (emitter.type !== "global" && emitter.type !== "positional") {
9165
- throw new Error(`${name8}: invalid emitter type ${emitter.type}.`);
9531
+ throw new Error(`${name9}: invalid emitter type ${emitter.type}.`);
9166
9532
  }
9167
9533
  if (emitter.type === "global" && emitter.positional !== void 0) {
9168
- throw new Error(`${name8}: global emitters cannot have positional settings.`);
9534
+ throw new Error(`${name9}: global emitters cannot have positional settings.`);
9169
9535
  }
9170
9536
  for (const sourceIndex of emitter.sources || []) getReference(sources, sourceIndex, "source");
9171
9537
  }
9172
9538
  const descriptors = [];
9173
9539
  for (const attachmentType of ["nodes", "scenes"]) {
9174
9540
  for (const [attachmentIndex, object] of (gltfData.json[attachmentType] || []).entries()) {
9175
- const attachment = (_b = object.extensions) == null ? void 0 : _b[name8];
9541
+ const attachment = (_b = object.extensions) == null ? void 0 : _b[name9];
9176
9542
  if (!attachment) continue;
9177
9543
  if (!Array.isArray(attachment.emitters) || !attachment.emitters.length) {
9178
- throw new Error(`${name8}: ${attachmentType} ${attachmentIndex} requires emitters.`);
9544
+ throw new Error(`${name9}: ${attachmentType} ${attachmentIndex} requires emitters.`);
9179
9545
  }
9180
9546
  for (const emitterIndex of attachment.emitters) {
9181
9547
  const emitter = getReference(emitters, emitterIndex, "emitter");
9182
9548
  if (attachmentType === "scenes" && emitter.type !== "global") {
9183
- throw new Error(`${name8}: scenes may only reference global emitters.`);
9549
+ throw new Error(`${name9}: scenes may only reference global emitters.`);
9184
9550
  }
9185
9551
  descriptors.push({
9186
9552
  emitterIndex,
@@ -9209,7 +9575,7 @@ async function decode8(gltfData, options, context) {
9209
9575
  }
9210
9576
  function getReference(values, index, kind) {
9211
9577
  if (!Number.isInteger(index) || index < 0 || !values[index]) {
9212
- throw new Error(`${name8}: invalid ${kind} index ${index}.`);
9578
+ throw new Error(`${name9}: invalid ${kind} index ${index}.`);
9213
9579
  }
9214
9580
  return values[index];
9215
9581
  }
@@ -9217,9 +9583,9 @@ function validateClip(gltfData, clip) {
9217
9583
  const { audio } = clip;
9218
9584
  if (audio.bufferView !== void 0) {
9219
9585
  getReference(gltfData.json.bufferViews || [], audio.bufferView, "bufferView");
9220
- if (!audio.mimeType) throw new Error(`${name8}: buffer-view audio requires mimeType.`);
9586
+ if (!audio.mimeType) throw new Error(`${name9}: buffer-view audio requires mimeType.`);
9221
9587
  } else if (!audio.uri) {
9222
- throw new Error(`${name8}: audio requires a uri or bufferView.`);
9588
+ throw new Error(`${name9}: audio requires a uri or bufferView.`);
9223
9589
  }
9224
9590
  }
9225
9591
  async function loadClip(gltfData, clip, options, context) {
@@ -9230,29 +9596,29 @@ async function loadClip(gltfData, clip, options, context) {
9230
9596
  const buffer = gltfData.buffers[bufferView.buffer];
9231
9597
  if (!buffer) {
9232
9598
  if (((_a = options.gltf) == null ? void 0 : _a.loadBuffers) === false) return;
9233
- throw new Error(`${name8}: audio buffer ${bufferView.buffer} is not loaded.`);
9599
+ throw new Error(`${name9}: audio buffer ${bufferView.buffer} is not loaded.`);
9234
9600
  }
9235
9601
  const byteOffset = bufferView.byteOffset ?? 0;
9236
9602
  const byteLength = bufferView.byteLength;
9237
9603
  if (!Number.isSafeInteger(byteOffset) || byteOffset < 0 || !Number.isSafeInteger(byteLength) || byteLength < 0 || byteOffset + byteLength > buffer.byteLength || buffer.byteOffset + byteOffset + byteLength > buffer.arrayBuffer.byteLength) {
9238
- throw new Error(`${name8}: audio bufferView exceeds its buffer.`);
9604
+ throw new Error(`${name9}: audio bufferView exceeds its buffer.`);
9239
9605
  }
9240
9606
  clip.data = new Uint8Array(buffer.arrayBuffer, buffer.byteOffset + byteOffset, byteLength);
9241
9607
  return;
9242
9608
  }
9243
- if (!(context == null ? void 0 : context.fetch)) throw new Error(`${name8}: a loader context is required to load audio.`);
9609
+ if (!(context == null ? void 0 : context.fetch)) throw new Error(`${name9}: a loader context is required to load audio.`);
9244
9610
  const url = resolveUrl(audio.uri, options, context);
9245
9611
  const response = await context.fetch(url);
9246
- if (!response.ok) throw new Error(`${name8}: failed to load audio ${url} (${response.status}).`);
9612
+ if (!response.ok) throw new Error(`${name9}: failed to load audio ${url} (${response.status}).`);
9247
9613
  clip.url = url;
9248
9614
  clip.data = new Uint8Array(await response.arrayBuffer());
9249
9615
  }
9250
- var name8;
9616
+ var name9;
9251
9617
  var init_KHR_audio_emitter = __esm({
9252
9618
  "../scene/src/gltf/lib/extensions/KHR_audio_emitter.ts"() {
9253
9619
  "use strict";
9254
9620
  init_resolve_url();
9255
- name8 = "KHR_audio_emitter";
9621
+ name9 = "KHR_audio_emitter";
9256
9622
  }
9257
9623
  });
9258
9624
 
@@ -9406,7 +9772,7 @@ var init_meshopt_decoder = __esm({
9406
9772
  }
9407
9773
  return result.buffer.slice(0, write);
9408
9774
  }
9409
- function decode17(instance2, fun, target, count, size, source, filter) {
9775
+ function decode18(instance2, fun, target, count, size, source, filter) {
9410
9776
  var sbrk = instance2.exports.sbrk;
9411
9777
  var count4 = count + 3 & ~3;
9412
9778
  var tp = sbrk(count4 * size);
@@ -9452,7 +9818,7 @@ var init_meshopt_decoder = __esm({
9452
9818
  return worker;
9453
9819
  }
9454
9820
  function initWorkers(count) {
9455
- var source = "self.ready = WebAssembly.instantiate(new Uint8Array([" + new Uint8Array(wasm) + "]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = " + workerProcess.name + ";" + decode17.toString() + workerProcess.toString();
9821
+ var source = "self.ready = WebAssembly.instantiate(new Uint8Array([" + new Uint8Array(wasm) + "]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = " + workerProcess.name + ";" + decode18.toString() + workerProcess.toString();
9456
9822
  var blob = new Blob([source], { type: "text/javascript" });
9457
9823
  var url = URL.createObjectURL(blob);
9458
9824
  for (var i = workers.length; i < count; ++i) {
@@ -9487,7 +9853,7 @@ var init_meshopt_decoder = __esm({
9487
9853
  }
9488
9854
  try {
9489
9855
  var target = new Uint8Array(data.count * data.size);
9490
- decode17(instance2, instance2.exports[data.mode], target, data.count, data.size, data.source, instance2.exports[data.filter]);
9856
+ decode18(instance2, instance2.exports[data.mode], target, data.count, data.size, data.source, instance2.exports[data.filter]);
9491
9857
  self.postMessage({ id: data.id, count: data.count, action: "resolve", value: target }, [target.buffer]);
9492
9858
  } catch (error) {
9493
9859
  self.postMessage({ id: data.id, count: data.count, action: "reject", value: error });
@@ -9501,16 +9867,16 @@ var init_meshopt_decoder = __esm({
9501
9867
  initWorkers(count);
9502
9868
  },
9503
9869
  decodeVertexBuffer: function(target, count, size, source, filter) {
9504
- decode17(instance, instance.exports.meshopt_decodeVertexBuffer, target, count, size, source, instance.exports[filters[filter]]);
9870
+ decode18(instance, instance.exports.meshopt_decodeVertexBuffer, target, count, size, source, instance.exports[filters[filter]]);
9505
9871
  },
9506
9872
  decodeIndexBuffer: function(target, count, size, source) {
9507
- decode17(instance, instance.exports.meshopt_decodeIndexBuffer, target, count, size, source);
9873
+ decode18(instance, instance.exports.meshopt_decodeIndexBuffer, target, count, size, source);
9508
9874
  },
9509
9875
  decodeIndexSequence: function(target, count, size, source) {
9510
- decode17(instance, instance.exports.meshopt_decodeIndexSequence, target, count, size, source);
9876
+ decode18(instance, instance.exports.meshopt_decodeIndexSequence, target, count, size, source);
9511
9877
  },
9512
9878
  decodeGltfBuffer: function(target, count, size, source, mode, filter) {
9513
- decode17(instance, instance.exports[decoders[mode]], target, count, size, source, instance.exports[filters[filter]]);
9879
+ decode18(instance, instance.exports[decoders[mode]], target, count, size, source, instance.exports[filters[filter]]);
9514
9880
  },
9515
9881
  decodeGltfBufferAsync: function(count, size, source, mode, filter) {
9516
9882
  if (workers.length > 0) {
@@ -9518,7 +9884,7 @@ var init_meshopt_decoder = __esm({
9518
9884
  }
9519
9885
  return ready.then(function() {
9520
9886
  var target = new Uint8Array(count * size);
9521
- decode17(instance, instance.exports[decoders[mode]], target, count, size, source, instance.exports[filters[filter]]);
9887
+ decode18(instance, instance.exports[decoders[mode]], target, count, size, source, instance.exports[filters[filter]]);
9522
9888
  return target;
9523
9889
  });
9524
9890
  }
@@ -9672,17 +10038,17 @@ var init_meshopt_compression = __esm({
9672
10038
  var EXT_meshopt_compression_exports = {};
9673
10039
  __export(EXT_meshopt_compression_exports, {
9674
10040
  decode: () => decode9,
9675
- name: () => name9
10041
+ name: () => name10
9676
10042
  });
9677
10043
  async function decode9(gltfData, options) {
9678
- await decodeMeshoptCompression(gltfData, options, name9);
10044
+ await decodeMeshoptCompression(gltfData, options, name10);
9679
10045
  }
9680
- var name9;
10046
+ var name10;
9681
10047
  var init_EXT_meshopt_compression = __esm({
9682
10048
  "../scene/src/gltf/lib/extensions/EXT_meshopt_compression.ts"() {
9683
10049
  "use strict";
9684
10050
  init_meshopt_compression();
9685
- name9 = "EXT_meshopt_compression";
10051
+ name10 = "EXT_meshopt_compression";
9686
10052
  }
9687
10053
  });
9688
10054
 
@@ -9690,28 +10056,29 @@ var init_EXT_meshopt_compression = __esm({
9690
10056
  var KHR_meshopt_compression_exports = {};
9691
10057
  __export(KHR_meshopt_compression_exports, {
9692
10058
  decode: () => decode10,
9693
- name: () => name10
10059
+ name: () => name11
9694
10060
  });
9695
10061
  async function decode10(gltfData, options) {
9696
- await decodeMeshoptCompression(gltfData, options, name10);
10062
+ await decodeMeshoptCompression(gltfData, options, name11);
9697
10063
  }
9698
- var name10;
10064
+ var name11;
9699
10065
  var init_KHR_meshopt_compression = __esm({
9700
10066
  "../scene/src/gltf/lib/extensions/KHR_meshopt_compression.ts"() {
9701
10067
  "use strict";
9702
10068
  init_meshopt_compression();
9703
- name10 = "KHR_meshopt_compression";
10069
+ name11 = "KHR_meshopt_compression";
9704
10070
  }
9705
10071
  });
9706
10072
 
9707
10073
  // ../scene/src/gltf/lib/extensions/EXT_texture_webp.ts
9708
10074
  var EXT_texture_webp_exports = {};
9709
10075
  __export(EXT_texture_webp_exports, {
9710
- name: () => name11,
9711
- preprocess: () => preprocess
10076
+ name: () => name12,
10077
+ preprocess: () => preprocess2
9712
10078
  });
9713
- function preprocess(gltfData, options) {
10079
+ function preprocess2(gltfData, options) {
9714
10080
  const iterator = new GLTFIterator(gltfData);
10081
+ if (!iterator.hasExtension(EXT_TEXTURE_WEBP)) return;
9715
10082
  if (!isImageFormatSupported("image/webp")) {
9716
10083
  if (iterator.isExtensionRequired(EXT_TEXTURE_WEBP)) {
9717
10084
  throw new Error(`gltf: Required extension ${EXT_TEXTURE_WEBP} not supported by browser`);
@@ -9727,24 +10094,24 @@ function preprocess(gltfData, options) {
9727
10094
  }
9728
10095
  iterator.removeExtension(EXT_TEXTURE_WEBP);
9729
10096
  }
9730
- var EXT_TEXTURE_WEBP, name11;
10097
+ var EXT_TEXTURE_WEBP, name12;
9731
10098
  var init_EXT_texture_webp = __esm({
9732
10099
  "../scene/src/gltf/lib/extensions/EXT_texture_webp.ts"() {
9733
10100
  "use strict";
9734
10101
  init_src();
9735
10102
  init_gltf_iterator();
9736
10103
  EXT_TEXTURE_WEBP = "EXT_texture_webp";
9737
- name11 = EXT_TEXTURE_WEBP;
10104
+ name12 = EXT_TEXTURE_WEBP;
9738
10105
  }
9739
10106
  });
9740
10107
 
9741
10108
  // ../scene/src/gltf/lib/extensions/EXT_texture_avif.ts
9742
10109
  var EXT_texture_avif_exports = {};
9743
10110
  __export(EXT_texture_avif_exports, {
9744
- name: () => name12,
9745
- preprocess: () => preprocess2
10111
+ name: () => name13,
10112
+ preprocess: () => preprocess3
9746
10113
  });
9747
- async function preprocess2(gltfData, options) {
10114
+ async function preprocess3(gltfData, options) {
9748
10115
  void options;
9749
10116
  const iterator = new GLTFIterator(gltfData);
9750
10117
  if (!iterator.hasExtension(EXT_TEXTURE_AVIF)) return;
@@ -9764,24 +10131,72 @@ async function preprocess2(gltfData, options) {
9764
10131
  }
9765
10132
  iterator.removeExtension(EXT_TEXTURE_AVIF);
9766
10133
  }
9767
- var EXT_TEXTURE_AVIF, name12;
10134
+ var EXT_TEXTURE_AVIF, name13;
9768
10135
  var init_EXT_texture_avif = __esm({
9769
10136
  "../scene/src/gltf/lib/extensions/EXT_texture_avif.ts"() {
9770
10137
  "use strict";
9771
10138
  init_src();
9772
10139
  init_gltf_iterator();
9773
10140
  EXT_TEXTURE_AVIF = "EXT_texture_avif";
9774
- name12 = EXT_TEXTURE_AVIF;
10141
+ name13 = EXT_TEXTURE_AVIF;
10142
+ }
10143
+ });
10144
+
10145
+ // ../scene/src/gltf/lib/extensions/MSFT_texture_dds.ts
10146
+ var MSFT_texture_dds_exports = {};
10147
+ __export(MSFT_texture_dds_exports, {
10148
+ decode: () => decode11,
10149
+ getDDSLoader: () => getDDSLoader,
10150
+ name: () => name14,
10151
+ preprocess: () => preprocess4
10152
+ });
10153
+ function getDDSLoader(context) {
10154
+ var _a;
10155
+ return (_a = context == null ? void 0 : context.loaders) == null ? void 0 : _a.find(
10156
+ (loader) => {
10157
+ var _a2, _b;
10158
+ return ((_a2 = loader.extensions) == null ? void 0 : _a2.includes("dds")) || ((_b = loader.mimeTypes) == null ? void 0 : _b.includes("image/vnd-ms.dds"));
10159
+ }
10160
+ );
10161
+ }
10162
+ function preprocess4(gltf, _options, context) {
10163
+ const iterator = new GLTFIterator(gltf);
10164
+ if (!iterator.hasExtension(name14)) return;
10165
+ if (!getDDSLoader(context)) {
10166
+ if (iterator.isExtensionRequired(name14)) {
10167
+ throw new Error("gltf: Required extension MSFT_texture_dds needs a DDS parser");
10168
+ }
10169
+ return;
10170
+ }
10171
+ for (const texture of iterator.textures) {
10172
+ const extension = iterator.getExtension(texture, name14);
10173
+ if (extension) texture.source = extension.source;
10174
+ }
10175
+ }
10176
+ async function decode11(gltf, options, context) {
10177
+ var _a;
10178
+ if (!getDDSLoader(context) || ((_a = options.gltf) == null ? void 0 : _a.loadImages) === false) return;
10179
+ const iterator = new GLTFIterator(gltf);
10180
+ if (!iterator.hasExtension(name14)) return;
10181
+ for (const texture of iterator.textures) iterator.removeExtension(texture, name14);
10182
+ iterator.removeExtension(name14);
10183
+ }
10184
+ var name14;
10185
+ var init_MSFT_texture_dds = __esm({
10186
+ "../scene/src/gltf/lib/extensions/MSFT_texture_dds.ts"() {
10187
+ "use strict";
10188
+ init_gltf_iterator();
10189
+ name14 = "MSFT_texture_dds";
9775
10190
  }
9776
10191
  });
9777
10192
 
9778
10193
  // ../scene/src/gltf/lib/extensions/KHR_texture_basisu.ts
9779
10194
  var KHR_texture_basisu_exports = {};
9780
10195
  __export(KHR_texture_basisu_exports, {
9781
- name: () => name13,
9782
- preprocess: () => preprocess3
10196
+ name: () => name15,
10197
+ preprocess: () => preprocess5
9783
10198
  });
9784
- function preprocess3(gltfData, options) {
10199
+ function preprocess5(gltfData, options) {
9785
10200
  void options;
9786
10201
  const iterator = new GLTFIterator(gltfData);
9787
10202
  for (const texture of iterator.textures) {
@@ -9793,13 +10208,13 @@ function preprocess3(gltfData, options) {
9793
10208
  }
9794
10209
  iterator.removeExtension(KHR_TEXTURE_BASISU);
9795
10210
  }
9796
- var KHR_TEXTURE_BASISU, name13;
10211
+ var KHR_TEXTURE_BASISU, name15;
9797
10212
  var init_KHR_texture_basisu = __esm({
9798
10213
  "../scene/src/gltf/lib/extensions/KHR_texture_basisu.ts"() {
9799
10214
  "use strict";
9800
10215
  init_gltf_iterator();
9801
10216
  KHR_TEXTURE_BASISU = "KHR_texture_basisu";
9802
- name13 = KHR_TEXTURE_BASISU;
10217
+ name15 = KHR_TEXTURE_BASISU;
9803
10218
  }
9804
10219
  });
9805
10220
 
@@ -10132,7 +10547,7 @@ function validateDracoEncoderModule(module2) {
10132
10547
  return typedModule;
10133
10548
  }
10134
10549
  function getLibraryCacheKey2(type, options) {
10135
- const libraryOverrides = Object.entries(options.modules || {}).filter(([name20]) => name20 !== "draco3d").map(([name20, value]) => `${name20}:${String(value)}`).sort().join("|");
10550
+ const libraryOverrides = Object.entries(options.modules || {}).filter(([name22]) => name22 !== "draco3d").map(([name22, value]) => `${name22}:${String(value)}`).sort().join("|");
10136
10551
  return [
10137
10552
  type,
10138
10553
  options.useLocalLibraries ? "local" : "remote",
@@ -10157,7 +10572,7 @@ var init_draco_module_loader = __esm({
10157
10572
 
10158
10573
  // ../scene/src/draco/lib/utils/get-draco-schema.ts
10159
10574
  function getDracoSchema(attributes, loaderData, indices) {
10160
- const metadata = makeMetadata(loaderData.metadata);
10575
+ const metadata2 = makeMetadata(loaderData.metadata);
10161
10576
  const fields = [];
10162
10577
  const namedLoaderDataAttributes = transformAttributesLoaderData(loaderData.attributes);
10163
10578
  for (const attributeName in attributes) {
@@ -10173,7 +10588,7 @@ function getDracoSchema(attributes, loaderData, indices) {
10173
10588
  const indicesField = getArrowFieldFromAttribute("indices", indices);
10174
10589
  fields.push(indicesField);
10175
10590
  }
10176
- return { fields, metadata };
10591
+ return { fields, metadata: metadata2 };
10177
10592
  }
10178
10593
  function transformAttributesLoaderData(loaderData) {
10179
10594
  const result = {};
@@ -10191,11 +10606,11 @@ function getArrowFieldFromAttribute(attributeName, attribute, loaderData) {
10191
10606
  const field = deduceMeshField(attributeName, attribute, metadataMap);
10192
10607
  return field;
10193
10608
  }
10194
- function makeMetadata(metadata) {
10195
- Object.entries(metadata);
10609
+ function makeMetadata(metadata2) {
10610
+ Object.entries(metadata2);
10196
10611
  const serializedMetadata = {};
10197
- for (const key in metadata) {
10198
- serializedMetadata[`${key}.string`] = JSON.stringify(metadata[key]);
10612
+ for (const key in metadata2) {
10613
+ serializedMetadata[`${key}.string`] = JSON.stringify(metadata2[key]);
10199
10614
  }
10200
10615
  return serializedMetadata;
10201
10616
  }
@@ -10414,14 +10829,14 @@ var init_draco_parser = __esm({
10414
10829
  * @returns
10415
10830
  */
10416
10831
  _getDracoLoaderData(dracoGeometry, geometry_type, options) {
10417
- const metadata = this._getTopLevelMetadata(dracoGeometry);
10832
+ const metadata2 = this._getTopLevelMetadata(dracoGeometry);
10418
10833
  const attributes = this._getDracoAttributes(dracoGeometry, options);
10419
10834
  return {
10420
10835
  geometry_type,
10421
10836
  num_attributes: dracoGeometry.num_attributes(),
10422
10837
  num_points: dracoGeometry.num_points(),
10423
10838
  num_faces: dracoGeometry instanceof this.draco.Mesh ? dracoGeometry.num_faces() : 0,
10424
- metadata,
10839
+ metadata: metadata2,
10425
10840
  attributes
10426
10841
  };
10427
10842
  }
@@ -10435,7 +10850,7 @@ var init_draco_parser = __esm({
10435
10850
  const dracoAttributes = {};
10436
10851
  for (let attributeId = 0; attributeId < dracoGeometry.num_attributes(); attributeId++) {
10437
10852
  const dracoAttribute = this.decoder.GetAttribute(dracoGeometry, attributeId);
10438
- const metadata = this._getAttributeMetadata(dracoGeometry, attributeId);
10853
+ const metadata2 = this._getAttributeMetadata(dracoGeometry, attributeId);
10439
10854
  dracoAttributes[dracoAttribute.unique_id()] = {
10440
10855
  unique_id: dracoAttribute.unique_id(),
10441
10856
  attribute_type: dracoAttribute.attribute_type(),
@@ -10445,7 +10860,7 @@ var init_draco_parser = __esm({
10445
10860
  byte_stride: dracoAttribute.byte_stride(),
10446
10861
  normalized: dracoAttribute.normalized(),
10447
10862
  attribute_index: attributeId,
10448
- metadata
10863
+ metadata: metadata2
10449
10864
  };
10450
10865
  const quantization = this._getQuantizationTransform(dracoAttribute, options);
10451
10866
  if (quantization) {
@@ -10999,11 +11414,11 @@ var init_draco_loader_types2 = __esm({
10999
11414
  // ../scene/src/gltf/lib/gltf-utils/gltf-attribute-utils.ts
11000
11415
  function getGLTFAccessors(attributes) {
11001
11416
  const accessors = {};
11002
- for (const name20 in attributes) {
11003
- const attribute = attributes[name20];
11004
- if (name20 !== "indices") {
11417
+ for (const name22 in attributes) {
11418
+ const attribute = attributes[name22];
11419
+ if (name22 !== "indices") {
11005
11420
  const glTFAccessor = getGLTFAccessor(attribute);
11006
- accessors[name20] = glTFAccessor;
11421
+ accessors[name22] = glTFAccessor;
11007
11422
  }
11008
11423
  }
11009
11424
  return accessors;
@@ -11064,11 +11479,11 @@ var init_gltf_attribute_utils = __esm({
11064
11479
  // ../scene/src/gltf/lib/extensions/KHR_draco_mesh_compression.ts
11065
11480
  var KHR_draco_mesh_compression_exports = {};
11066
11481
  __export(KHR_draco_mesh_compression_exports, {
11067
- decode: () => decode11,
11068
- name: () => name14,
11069
- preprocess: () => preprocess4
11482
+ decode: () => decode12,
11483
+ name: () => name16,
11484
+ preprocess: () => preprocess6
11070
11485
  });
11071
- function preprocess4(gltfData, options, context) {
11486
+ function preprocess6(gltfData, options, context) {
11072
11487
  const iterator = new GLTFIterator(gltfData);
11073
11488
  for (const mesh of iterator.meshes) {
11074
11489
  for (const primitive of iterator.getReferences(mesh).primitives) {
@@ -11077,7 +11492,7 @@ function preprocess4(gltfData, options, context) {
11077
11492
  }
11078
11493
  }
11079
11494
  }
11080
- async function decode11(gltfData, options, context) {
11495
+ async function decode12(gltfData, options, context) {
11081
11496
  var _a;
11082
11497
  if (!((_a = options == null ? void 0 : options.gltf) == null ? void 0 : _a.decompressMeshes)) {
11083
11498
  return;
@@ -11160,7 +11575,7 @@ function checkPrimitive(primitive) {
11160
11575
  throw new Error("glTF: Empty primitive detected: Draco decompression failure?");
11161
11576
  }
11162
11577
  }
11163
- var KHR_DRACO_MESH_COMPRESSION, name14;
11578
+ var KHR_DRACO_MESH_COMPRESSION, name16;
11164
11579
  var init_KHR_draco_mesh_compression = __esm({
11165
11580
  "../scene/src/gltf/lib/extensions/KHR_draco_mesh_compression.ts"() {
11166
11581
  "use strict";
@@ -11170,17 +11585,17 @@ var init_KHR_draco_mesh_compression = __esm({
11170
11585
  init_gltf_attribute_utils();
11171
11586
  init_get_typed_array();
11172
11587
  KHR_DRACO_MESH_COMPRESSION = "KHR_draco_mesh_compression";
11173
- name14 = KHR_DRACO_MESH_COMPRESSION;
11588
+ name16 = KHR_DRACO_MESH_COMPRESSION;
11174
11589
  }
11175
11590
  });
11176
11591
 
11177
11592
  // ../scene/src/gltf/lib/extensions/KHR_texture_transform.ts
11178
11593
  var KHR_texture_transform_exports = {};
11179
11594
  __export(KHR_texture_transform_exports, {
11180
- decode: () => decode12,
11181
- name: () => name15
11595
+ decode: () => decode13,
11596
+ name: () => name17
11182
11597
  });
11183
- async function decode12(gltfData, options) {
11598
+ async function decode13(gltfData, options) {
11184
11599
  var _a;
11185
11600
  const iterator = new GLTFIterator(gltfData);
11186
11601
  const hasExtension = iterator.hasExtension(KHR_TEXTURE_TRANSFORM);
@@ -11401,7 +11816,7 @@ function makeTransformationMatrix(extensionData) {
11401
11816
  const scaleMatrix = scratchScaleMatrix.set(scale[0], 0, 0, 0, scale[1], 0, 0, 0, 1);
11402
11817
  return translationMatrix.multiplyRight(rotationMatrix).multiplyRight(scaleMatrix);
11403
11818
  }
11404
- var import_core3, KHR_TEXTURE_TRANSFORM, name15, scratchVector, scratchRotationMatrix, scratchScaleMatrix;
11819
+ var import_core3, KHR_TEXTURE_TRANSFORM, name17, scratchVector, scratchRotationMatrix, scratchScaleMatrix;
11405
11820
  var init_KHR_texture_transform = __esm({
11406
11821
  "../scene/src/gltf/lib/extensions/KHR_texture_transform.ts"() {
11407
11822
  "use strict";
@@ -11411,7 +11826,7 @@ var init_KHR_texture_transform = __esm({
11411
11826
  init_gltf_iterator();
11412
11827
  init_loader_utils();
11413
11828
  KHR_TEXTURE_TRANSFORM = "KHR_texture_transform";
11414
- name15 = KHR_TEXTURE_TRANSFORM;
11829
+ name17 = KHR_TEXTURE_TRANSFORM;
11415
11830
  scratchVector = new import_core3.Vector3();
11416
11831
  scratchRotationMatrix = new import_core3.Matrix3();
11417
11832
  scratchScaleMatrix = new import_core3.Matrix3();
@@ -11421,11 +11836,11 @@ var init_KHR_texture_transform = __esm({
11421
11836
  // ../scene/src/gltf/lib/extensions/deprecated/KHR_lights_punctual.ts
11422
11837
  var KHR_lights_punctual_exports = {};
11423
11838
  __export(KHR_lights_punctual_exports, {
11424
- decode: () => decode13,
11839
+ decode: () => decode14,
11425
11840
  encode: () => encode3,
11426
- name: () => name16
11841
+ name: () => name18
11427
11842
  });
11428
- async function decode13(gltfData) {
11843
+ async function decode14(gltfData) {
11429
11844
  const iterator = new GLTFIterator(gltfData);
11430
11845
  const extension = iterator.getExtension(KHR_LIGHTS_PUNCTUAL);
11431
11846
  if (extension) {
@@ -11457,7 +11872,7 @@ async function encode3(gltfData) {
11457
11872
  delete gltfScenegraph.json.lights;
11458
11873
  }
11459
11874
  }
11460
- var KHR_LIGHTS_PUNCTUAL, name16;
11875
+ var KHR_LIGHTS_PUNCTUAL, name18;
11461
11876
  var init_KHR_lights_punctual = __esm({
11462
11877
  "../scene/src/gltf/lib/extensions/deprecated/KHR_lights_punctual.ts"() {
11463
11878
  "use strict";
@@ -11465,18 +11880,18 @@ var init_KHR_lights_punctual = __esm({
11465
11880
  init_gltf_iterator();
11466
11881
  init_gltf_scenegraph();
11467
11882
  KHR_LIGHTS_PUNCTUAL = "KHR_lights_punctual";
11468
- name16 = KHR_LIGHTS_PUNCTUAL;
11883
+ name18 = KHR_LIGHTS_PUNCTUAL;
11469
11884
  }
11470
11885
  });
11471
11886
 
11472
11887
  // ../scene/src/gltf/lib/extensions/deprecated/KHR_materials_unlit.ts
11473
11888
  var KHR_materials_unlit_exports = {};
11474
11889
  __export(KHR_materials_unlit_exports, {
11475
- decode: () => decode14,
11890
+ decode: () => decode15,
11476
11891
  encode: () => encode4,
11477
- name: () => name17
11892
+ name: () => name19
11478
11893
  });
11479
- async function decode14(gltfData) {
11894
+ async function decode15(gltfData) {
11480
11895
  const iterator = new GLTFIterator(gltfData);
11481
11896
  for (const material of iterator.materials) {
11482
11897
  const extension = iterator.getExtension(material, KHR_MATERIALS_UNLIT);
@@ -11501,25 +11916,25 @@ function encode4(gltfData) {
11501
11916
  for (const field of ["extensionsUsed", "extensionsRequired"])
11502
11917
  if (((_a = gltfData.json[field]) == null ? void 0 : _a.length) === 0) delete gltfData.json[field];
11503
11918
  }
11504
- var KHR_MATERIALS_UNLIT, name17;
11919
+ var KHR_MATERIALS_UNLIT, name19;
11505
11920
  var init_KHR_materials_unlit = __esm({
11506
11921
  "../scene/src/gltf/lib/extensions/deprecated/KHR_materials_unlit.ts"() {
11507
11922
  "use strict";
11508
11923
  init_gltf_iterator();
11509
11924
  init_gltf_scenegraph();
11510
11925
  KHR_MATERIALS_UNLIT = "KHR_materials_unlit";
11511
- name17 = KHR_MATERIALS_UNLIT;
11926
+ name19 = KHR_MATERIALS_UNLIT;
11512
11927
  }
11513
11928
  });
11514
11929
 
11515
11930
  // ../scene/src/gltf/lib/extensions/deprecated/KHR_techniques_webgl.ts
11516
11931
  var KHR_techniques_webgl_exports = {};
11517
11932
  __export(KHR_techniques_webgl_exports, {
11518
- decode: () => decode15,
11933
+ decode: () => decode16,
11519
11934
  encode: () => encode5,
11520
- name: () => name18
11935
+ name: () => name20
11521
11936
  });
11522
- async function decode15(gltfData) {
11937
+ async function decode16(gltfData) {
11523
11938
  const iterator = new GLTFIterator(gltfData);
11524
11939
  const extension = iterator.getExtension(KHR_TECHNIQUES_WEBGL);
11525
11940
  if (extension) {
@@ -11580,24 +11995,24 @@ function resolveValues(technique, iterator) {
11580
11995
  });
11581
11996
  return values;
11582
11997
  }
11583
- var KHR_TECHNIQUES_WEBGL, name18;
11998
+ var KHR_TECHNIQUES_WEBGL, name20;
11584
11999
  var init_KHR_techniques_webgl = __esm({
11585
12000
  "../scene/src/gltf/lib/extensions/deprecated/KHR_techniques_webgl.ts"() {
11586
12001
  "use strict";
11587
12002
  init_gltf_iterator();
11588
12003
  init_get_typed_array();
11589
12004
  KHR_TECHNIQUES_WEBGL = "KHR_techniques_webgl";
11590
- name18 = KHR_TECHNIQUES_WEBGL;
12005
+ name20 = KHR_TECHNIQUES_WEBGL;
11591
12006
  }
11592
12007
  });
11593
12008
 
11594
12009
  // ../scene/src/gltf/lib/extensions/deprecated/EXT_feature_metadata.ts
11595
12010
  var EXT_feature_metadata_exports = {};
11596
12011
  __export(EXT_feature_metadata_exports, {
11597
- decode: () => decode16,
11598
- name: () => name19
12012
+ decode: () => decode17,
12013
+ name: () => name21
11599
12014
  });
11600
- async function decode16(gltfData, options) {
12015
+ async function decode17(gltfData, options) {
11601
12016
  const iterator = new GLTFIterator(gltfData);
11602
12017
  decodeExtFeatureMetadata(iterator, options);
11603
12018
  }
@@ -11840,14 +12255,14 @@ function processPrimitiveTextures(iterator, attributeName, featureTexturePropert
11840
12255
  primitive
11841
12256
  );
11842
12257
  }
11843
- var EXT_FEATURE_METADATA_NAME, name19;
12258
+ var EXT_FEATURE_METADATA_NAME, name21;
11844
12259
  var init_EXT_feature_metadata = __esm({
11845
12260
  "../scene/src/gltf/lib/extensions/deprecated/EXT_feature_metadata.ts"() {
11846
12261
  "use strict";
11847
12262
  init_gltf_iterator();
11848
12263
  init_d_tiles_utils();
11849
12264
  EXT_FEATURE_METADATA_NAME = "EXT_feature_metadata";
11850
- name19 = EXT_FEATURE_METADATA_NAME;
12265
+ name21 = EXT_FEATURE_METADATA_NAME;
11851
12266
  }
11852
12267
  });
11853
12268
 
@@ -11884,6 +12299,7 @@ var EXTENSIONS, EXTENSIONS_ENCODING;
11884
12299
  var init_gltf_extensions = __esm({
11885
12300
  "../scene/src/gltf/lib/api/gltf-extensions.ts"() {
11886
12301
  "use strict";
12302
+ init_KHR_accessor_float64();
11887
12303
  init_EXT_mesh_features();
11888
12304
  init_EXT_structural_metadata();
11889
12305
  init_KHR_gaussian_splatting();
@@ -11895,6 +12311,7 @@ var init_gltf_extensions = __esm({
11895
12311
  init_KHR_meshopt_compression();
11896
12312
  init_EXT_texture_webp();
11897
12313
  init_EXT_texture_avif();
12314
+ init_MSFT_texture_dds();
11898
12315
  init_KHR_texture_basisu();
11899
12316
  init_KHR_draco_mesh_compression();
11900
12317
  init_KHR_texture_transform();
@@ -11904,6 +12321,7 @@ var init_gltf_extensions = __esm({
11904
12321
  init_KHR_techniques_webgl();
11905
12322
  init_EXT_feature_metadata();
11906
12323
  EXTENSIONS = [
12324
+ KHR_accessor_float64_exports,
11907
12325
  // 1.0
11908
12326
  // KHR_binary_gltf is handled separately - must be processed before other parsing starts
11909
12327
  // KHR_binary_gltf,
@@ -11922,9 +12340,11 @@ var init_gltf_extensions = __esm({
11922
12340
  EXT_mesh_polygon_exports,
11923
12341
  MPEG_audio_spatial_exports,
11924
12342
  KHR_audio_emitter_exports,
11925
- EXT_texture_avif_exports,
11926
12343
  EXT_texture_webp_exports,
11927
- // Basisu should come after webp, we want basisu to be preferred if both are provided
12344
+ EXT_texture_avif_exports,
12345
+ // Compressed textures take precedence over browser image formats when available.
12346
+ MSFT_texture_dds_exports,
12347
+ // BasisU remains preferred when both compressed alternatives are provided.
11928
12348
  KHR_texture_basisu_exports,
11929
12349
  KHR_lights_punctual_exports,
11930
12350
  KHR_materials_unlit_exports,
@@ -11941,7 +12361,7 @@ var init_gltf_extensions = __esm({
11941
12361
  });
11942
12362
 
11943
12363
  // ../scene/src/gltf/lib/extensions/KHR_binary_gltf.ts
11944
- function preprocess5(gltfData) {
12364
+ function preprocess7(gltfData) {
11945
12365
  const iterator = new GLTFIterator(gltfData);
11946
12366
  for (const image of iterator.images) {
11947
12367
  const extension = iterator.getExtension(image, KHR_BINARY_GLTF);
@@ -12083,7 +12503,7 @@ function convertGLTFV1Skins(json, resolveNodeId, reportUnsupported) {
12083
12503
  for (let skinIndex = 0; skinIndex < originalSkinCount; skinIndex++) {
12084
12504
  const skin = skins[skinIndex];
12085
12505
  const jointNames = skin.jointNames;
12086
- if (!Array.isArray(jointNames) || jointNames.length === 0 || jointNames.some((name20) => typeof name20 !== "string" || !name20) || new Set(jointNames).size !== jointNames.length) {
12506
+ if (!Array.isArray(jointNames) || jointNames.length === 0 || jointNames.some((name22) => typeof name22 !== "string" || !name22) || new Set(jointNames).size !== jointNames.length) {
12087
12507
  reportUnsupported(`skin ${skinIndex} has invalid joint names`);
12088
12508
  hasUnconvertedSkin = true;
12089
12509
  continue;
@@ -12667,7 +13087,7 @@ function hasOpaqueGLTFV1Consumers(json) {
12667
13087
  for (const [field, value] of Object.entries(object)) {
12668
13088
  if (field === "extras") continue;
12669
13089
  if (field === "extensions" && value && typeof value === "object" && Object.keys(value).some(
12670
- (name20) => !["KHR_materials_unlit", "KHR_materials_common"].includes(name20)
13090
+ (name22) => !["KHR_materials_unlit", "KHR_materials_common"].includes(name22)
12671
13091
  ))
12672
13092
  return true;
12673
13093
  pending.push(value);
@@ -12807,18 +13227,18 @@ function preserveLegacyFields(object, fields) {
12807
13227
  function isRecord(value) {
12808
13228
  return value !== null && typeof value === "object" && !Array.isArray(value);
12809
13229
  }
12810
- function convertGLTFV1AttributeName(name20) {
12811
- const indexed = /^(JOINTS?|WEIGHTS?|TEXCOORD|COLOR)(?:_(\d+))?$/.exec(name20);
13230
+ function convertGLTFV1AttributeName(name22) {
13231
+ const indexed = /^(JOINTS?|WEIGHTS?|TEXCOORD|COLOR)(?:_(\d+))?$/.exec(name22);
12812
13232
  if (indexed) {
12813
13233
  const semantic = indexed[1].startsWith("JOINT") ? "JOINTS" : indexed[1].startsWith("WEIGHT") ? "WEIGHTS" : indexed[1];
12814
13234
  const index = Number(indexed[2] || 0);
12815
13235
  if (!Number.isSafeInteger(index) || index > 999999999)
12816
- throw new Error(`glTF v1: invalid attribute set index ${name20}`);
13236
+ throw new Error(`glTF v1: invalid attribute set index ${name22}`);
12817
13237
  return `${semantic}_${index}`;
12818
13238
  }
12819
- if (["POSITION", "NORMAL", "TANGENT"].includes(name20) || name20.startsWith("_") || name20.includes(":"))
12820
- return name20;
12821
- return `_${name20}`;
13239
+ if (["POSITION", "NORMAL", "TANGENT"].includes(name22) || name22.startsWith("_") || name22.includes(":"))
13240
+ return name22;
13241
+ return `_${name22}`;
12822
13242
  }
12823
13243
  var init_clean_gltf_v1_fields = __esm({
12824
13244
  "../scene/src/gltf/lib/api/clean-gltf-v1-fields.ts"() {
@@ -13244,8 +13664,8 @@ function validateSkinInfluences(gltf, readAccessor, reportUnsupported) {
13244
13664
  checkedBindings.add(binding);
13245
13665
  for (const [primitiveIndex, primitive] of mesh.primitives.entries()) {
13246
13666
  const label = `mesh ${node.mesh} primitive ${primitiveIndex} skin ${node.skin}`;
13247
- const jointSets = Object.keys(primitive.attributes).filter((name20) => /^JOINTS_\d+$/.test(name20)).map((name20) => Number(name20.slice(7))).sort((first, second) => first - second);
13248
- const weightSets = Object.keys(primitive.attributes).filter((name20) => /^WEIGHTS_\d+$/.test(name20)).map((name20) => Number(name20.slice(8))).sort((first, second) => first - second);
13667
+ const jointSets = Object.keys(primitive.attributes).filter((name22) => /^JOINTS_\d+$/.test(name22)).map((name22) => Number(name22.slice(7))).sort((first, second) => first - second);
13668
+ const weightSets = Object.keys(primitive.attributes).filter((name22) => /^WEIGHTS_\d+$/.test(name22)).map((name22) => Number(name22.slice(8))).sort((first, second) => first - second);
13249
13669
  if (!jointSets.length && !weightSets.length) {
13250
13670
  reportUnsupported(`${label} requires JOINTS_0 and WEIGHTS_0 skin influences`);
13251
13671
  continue;
@@ -13696,7 +14116,7 @@ function collectExtensionNames(value) {
13696
14116
  if (!object || typeof object !== "object" || visited.has(object)) continue;
13697
14117
  visited.add(object);
13698
14118
  if (isRecord2(object) && isRecord2(object.extensions))
13699
- for (const name20 of Object.keys(object.extensions)) names.add(name20);
14119
+ for (const name22 of Object.keys(object.extensions)) names.add(name22);
13700
14120
  for (const [field, child] of Object.entries(object))
13701
14121
  if (field !== "extras") pending.push(child);
13702
14122
  }
@@ -13854,7 +14274,7 @@ var init_normalize_gltf_v1 = __esm({
13854
14274
  this._addAsset(json);
13855
14275
  this._orderBinaryBufferPayloads(gltf);
13856
14276
  this._convertTopLevelObjectsToArrays(json);
13857
- preprocess5(gltf);
14277
+ preprocess7(gltf);
13858
14278
  this._convertObjectIdsToArrayIndices(json);
13859
14279
  this._updateObjects(json);
13860
14280
  for (const [bufferIndex, buffer] of (json.buffers || []).entries())
@@ -14443,6 +14863,7 @@ function getReferencesImageIndices(gltf) {
14443
14863
  return Array.from(imageIndices).sort();
14444
14864
  }
14445
14865
  async function loadImage(gltf, image, index, options, context) {
14866
+ var _a, _b, _c;
14446
14867
  let arrayBuffer;
14447
14868
  if (image.uri && !image.hasOwnProperty("bufferView")) {
14448
14869
  const uri = resolveUrl(image.uri, options, context);
@@ -14459,6 +14880,33 @@ async function loadImage(gltf, image, index, options, context) {
14459
14880
  }
14460
14881
  assert3(arrayBuffer, "glTF image has no data");
14461
14882
  const gltfOptions = getGLTFImageOptions(options, image.mimeType);
14883
+ const ddsLoader = getDDSLoader(context);
14884
+ const ddsSelected = Boolean(
14885
+ ddsLoader && !((_b = (_a = options.gltf) == null ? void 0 : _a.excludeExtensions) == null ? void 0 : _b.includes("MSFT_texture_dds")) && ((_c = gltf.json.textures) == null ? void 0 : _c.some(
14886
+ (texture) => {
14887
+ var _a2, _b2;
14888
+ return texture.source === index && ((_b2 = (_a2 = texture.extensions) == null ? void 0 : _a2.MSFT_texture_dds) == null ? void 0 : _b2.source) === index;
14889
+ }
14890
+ ))
14891
+ );
14892
+ if (ddsSelected) {
14893
+ const levels = await parseFromContext(
14894
+ arrayBuffer,
14895
+ ddsLoader,
14896
+ options,
14897
+ context
14898
+ );
14899
+ assert3(levels.length > 0, "MSFT_texture_dds parser returned no texture levels");
14900
+ gltf.images = gltf.images || [];
14901
+ gltf.images[index] = {
14902
+ compressed: true,
14903
+ mipmaps: true,
14904
+ width: levels[0].width,
14905
+ height: levels[0].height,
14906
+ data: levels
14907
+ };
14908
+ return;
14909
+ }
14462
14910
  let parsedImage = await parseFromContext(
14463
14911
  arrayBuffer,
14464
14912
  [ImageLoader, BasisLoader],
@@ -14491,6 +14939,7 @@ var init_parse_gltf = __esm({
14491
14939
  init_resolve_gltf_file();
14492
14940
  init_get_typed_array();
14493
14941
  init_gltf_extensions();
14942
+ init_MSFT_texture_dds();
14494
14943
  init_normalize_gltf_v1();
14495
14944
  PACKAGE_URL_PREFIX = "gltf-package://";
14496
14945
  }
@@ -14772,9 +15221,9 @@ function validateExplicitQuantization(attributeName, componentCount, quantizatio
14772
15221
  }
14773
15222
  }
14774
15223
  function getDracoAttributeTypeName(draco, attributeType) {
14775
- for (const name20 of ["POSITION", "NORMAL", "COLOR", "TEX_COORD", "GENERIC"]) {
14776
- if (draco[name20] === attributeType) {
14777
- return name20;
15224
+ for (const name22 of ["POSITION", "NORMAL", "COLOR", "TEX_COORD", "GENERIC"]) {
15225
+ if (draco[name22] === attributeType) {
15226
+ return name22;
14778
15227
  }
14779
15228
  }
14780
15229
  return "GENERIC";
@@ -15299,9 +15748,9 @@ var init_draco_builder = __esm({
15299
15748
  * @param dracoGeometry - WASM Draco Object
15300
15749
  * @param metadata
15301
15750
  */
15302
- _addGeometryMetadata(dracoGeometry, metadata) {
15751
+ _addGeometryMetadata(dracoGeometry, metadata2) {
15303
15752
  const dracoMetadata = new this.draco.Metadata();
15304
- this._populateDracoMetadata(dracoMetadata, metadata);
15753
+ this._populateDracoMetadata(dracoMetadata, metadata2);
15305
15754
  this.dracoMeshBuilder.AddMetadata(dracoGeometry, dracoMetadata);
15306
15755
  }
15307
15756
  /**
@@ -15310,9 +15759,9 @@ var init_draco_builder = __esm({
15310
15759
  * @param uniqueAttributeId
15311
15760
  * @param metadata
15312
15761
  */
15313
- _addAttributeMetadata(dracoGeometry, uniqueAttributeId, metadata) {
15762
+ _addAttributeMetadata(dracoGeometry, uniqueAttributeId, metadata2) {
15314
15763
  const dracoAttributeMetadata = new this.draco.Metadata();
15315
- this._populateDracoMetadata(dracoAttributeMetadata, metadata);
15764
+ this._populateDracoMetadata(dracoAttributeMetadata, metadata2);
15316
15765
  this.dracoMeshBuilder.SetMetadataForAttribute(
15317
15766
  dracoGeometry,
15318
15767
  uniqueAttributeId,
@@ -15324,8 +15773,8 @@ var init_draco_builder = __esm({
15324
15773
  * @param dracoMetadata - WASM Draco Object
15325
15774
  * @param metadata
15326
15775
  */
15327
- _populateDracoMetadata(dracoMetadata, metadata) {
15328
- for (const [key, value] of getEntries(metadata)) {
15776
+ _populateDracoMetadata(dracoMetadata, metadata2) {
15777
+ for (const [key, value] of getEntries(metadata2)) {
15329
15778
  switch (typeof value) {
15330
15779
  case "number":
15331
15780
  if (Math.trunc(value) === value) {
@@ -15378,7 +15827,7 @@ function encodeDracoInBatches(data, options = {}) {
15378
15827
  const normalizedData = normalizeDracoInputBatches(data);
15379
15828
  if (canEncodeWithWorker(DracoWriterWorker, options)) {
15380
15829
  const { onProgress: _onProgress, ...workerOptions } = options;
15381
- return (0, import_tasks2.processOnWorkerInBatches)(
15830
+ return processOnWorkerInBatches(
15382
15831
  DracoWriterWorker,
15383
15832
  normalizedData,
15384
15833
  workerOptions
@@ -15821,6 +16270,1724 @@ var init_glb_writer = __esm({
15821
16270
  }
15822
16271
  });
15823
16272
 
16273
+ // ../documents/src/lib/xml-utils/uncapitalize.ts
16274
+ function uncapitalize(str) {
16275
+ return typeof str === "string" ? str.charAt(0).toLowerCase() + str.slice(1) : str;
16276
+ }
16277
+ function uncapitalizeKeys(object) {
16278
+ if (Array.isArray(object)) {
16279
+ return object.map((element) => uncapitalizeKeys(element));
16280
+ }
16281
+ if (object && typeof object === "object") {
16282
+ const newObject = {};
16283
+ for (const [key, value] of Object.entries(object)) {
16284
+ Object.defineProperty(newObject, uncapitalize(key), {
16285
+ value: uncapitalizeKeys(value),
16286
+ enumerable: true,
16287
+ configurable: true,
16288
+ writable: true
16289
+ });
16290
+ }
16291
+ return newObject;
16292
+ }
16293
+ return object;
16294
+ }
16295
+ var init_uncapitalize = __esm({
16296
+ "../documents/src/lib/xml-utils/uncapitalize.ts"() {
16297
+ "use strict";
16298
+ }
16299
+ });
16300
+
16301
+ // ../documents/src/sax-ts/sax.ts
16302
+ var DEFAULT_SAX_EVENTS, DEFAULT_SAX_PARSER_OPTIONS, EVENTS, BUFFERS, nameStart, nameBody, entityStart, entityBody, ENTITIES, SAX, SAXParser;
16303
+ var init_sax = __esm({
16304
+ "../documents/src/sax-ts/sax.ts"() {
16305
+ "use strict";
16306
+ DEFAULT_SAX_EVENTS = {
16307
+ ontext: () => {
16308
+ },
16309
+ onprocessinginstruction: () => {
16310
+ },
16311
+ onsgmldeclaration: () => {
16312
+ },
16313
+ ondoctype: () => {
16314
+ },
16315
+ oncomment: () => {
16316
+ },
16317
+ onopentagstart: () => {
16318
+ },
16319
+ onattribute: () => {
16320
+ },
16321
+ onopentag: () => {
16322
+ },
16323
+ onclosetag: () => {
16324
+ },
16325
+ onopencdata: () => {
16326
+ },
16327
+ oncdata: () => {
16328
+ },
16329
+ onclosecdata: () => {
16330
+ },
16331
+ onerror: () => {
16332
+ },
16333
+ onend: () => {
16334
+ },
16335
+ onready: () => {
16336
+ },
16337
+ onscript: () => {
16338
+ },
16339
+ onopennamespace: () => {
16340
+ },
16341
+ onclosenamespace: () => {
16342
+ }
16343
+ };
16344
+ DEFAULT_SAX_PARSER_OPTIONS = {
16345
+ ...DEFAULT_SAX_EVENTS,
16346
+ strict: false,
16347
+ MAX_BUFFER_LENGTH: 64 * 1024,
16348
+ lowercase: false,
16349
+ lowercasetags: false,
16350
+ noscript: false,
16351
+ strictEntities: false,
16352
+ preserveCase: false,
16353
+ caseInsensitiveTags: false,
16354
+ processEntities: true,
16355
+ xmlns: void 0,
16356
+ position: void 0,
16357
+ trim: void 0,
16358
+ normalize: void 0
16359
+ };
16360
+ EVENTS = [
16361
+ "text",
16362
+ "processinginstruction",
16363
+ "sgmldeclaration",
16364
+ "doctype",
16365
+ "comment",
16366
+ "opentagstart",
16367
+ "attribute",
16368
+ "opentag",
16369
+ "closetag",
16370
+ "opencdata",
16371
+ "cdata",
16372
+ "closecdata",
16373
+ "error",
16374
+ "end",
16375
+ "ready",
16376
+ "script",
16377
+ "opennamespace",
16378
+ "closenamespace"
16379
+ ];
16380
+ BUFFERS = [
16381
+ "comment",
16382
+ "sgmlDecl",
16383
+ "textNode",
16384
+ "tagName",
16385
+ "doctype",
16386
+ "procInstName",
16387
+ "procInstBody",
16388
+ "entity",
16389
+ "attribName",
16390
+ "attribValue",
16391
+ "cdata",
16392
+ "script"
16393
+ ];
16394
+ nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
16395
+ nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
16396
+ entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
16397
+ entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
16398
+ ENTITIES = {
16399
+ amp: "&",
16400
+ gt: ">",
16401
+ lt: "<",
16402
+ quot: '"',
16403
+ apos: "'",
16404
+ AElig: 198,
16405
+ Aacute: 193,
16406
+ Acirc: 194,
16407
+ Agrave: 192,
16408
+ Aring: 197,
16409
+ Atilde: 195,
16410
+ Auml: 196,
16411
+ Ccedil: 199,
16412
+ ETH: 208,
16413
+ Eacute: 201,
16414
+ Ecirc: 202,
16415
+ Egrave: 200,
16416
+ Euml: 203,
16417
+ Iacute: 205,
16418
+ Icirc: 206,
16419
+ Igrave: 204,
16420
+ Iuml: 207,
16421
+ Ntilde: 209,
16422
+ Oacute: 211,
16423
+ Ocirc: 212,
16424
+ Ograve: 210,
16425
+ Oslash: 216,
16426
+ Otilde: 213,
16427
+ Ouml: 214,
16428
+ THORN: 222,
16429
+ Uacute: 218,
16430
+ Ucirc: 219,
16431
+ Ugrave: 217,
16432
+ Uuml: 220,
16433
+ Yacute: 221,
16434
+ aacute: 225,
16435
+ acirc: 226,
16436
+ aelig: 230,
16437
+ agrave: 224,
16438
+ aring: 229,
16439
+ atilde: 227,
16440
+ auml: 228,
16441
+ ccedil: 231,
16442
+ eacute: 233,
16443
+ ecirc: 234,
16444
+ egrave: 232,
16445
+ eth: 240,
16446
+ euml: 235,
16447
+ iacute: 237,
16448
+ icirc: 238,
16449
+ igrave: 236,
16450
+ iuml: 239,
16451
+ ntilde: 241,
16452
+ oacute: 243,
16453
+ ocirc: 244,
16454
+ ograve: 242,
16455
+ oslash: 248,
16456
+ otilde: 245,
16457
+ ouml: 246,
16458
+ szlig: 223,
16459
+ thorn: 254,
16460
+ uacute: 250,
16461
+ ucirc: 251,
16462
+ ugrave: 249,
16463
+ uuml: 252,
16464
+ yacute: 253,
16465
+ yuml: 255,
16466
+ copy: 169,
16467
+ reg: 174,
16468
+ nbsp: 160,
16469
+ iexcl: 161,
16470
+ cent: 162,
16471
+ pound: 163,
16472
+ curren: 164,
16473
+ yen: 165,
16474
+ brvbar: 166,
16475
+ sect: 167,
16476
+ uml: 168,
16477
+ ordf: 170,
16478
+ laquo: 171,
16479
+ not: 172,
16480
+ shy: 173,
16481
+ macr: 175,
16482
+ deg: 176,
16483
+ plusmn: 177,
16484
+ sup1: 185,
16485
+ sup2: 178,
16486
+ sup3: 179,
16487
+ acute: 180,
16488
+ micro: 181,
16489
+ para: 182,
16490
+ middot: 183,
16491
+ cedil: 184,
16492
+ ordm: 186,
16493
+ raquo: 187,
16494
+ frac14: 188,
16495
+ frac12: 189,
16496
+ frac34: 190,
16497
+ iquest: 191,
16498
+ times: 215,
16499
+ divide: 247,
16500
+ OElig: 338,
16501
+ oelig: 339,
16502
+ Scaron: 352,
16503
+ scaron: 353,
16504
+ Yuml: 376,
16505
+ fnof: 402,
16506
+ circ: 710,
16507
+ tilde: 732,
16508
+ Alpha: 913,
16509
+ Beta: 914,
16510
+ Gamma: 915,
16511
+ Delta: 916,
16512
+ Epsilon: 917,
16513
+ Zeta: 918,
16514
+ Eta: 919,
16515
+ Theta: 920,
16516
+ Iota: 921,
16517
+ Kappa: 922,
16518
+ Lambda: 923,
16519
+ Mu: 924,
16520
+ Nu: 925,
16521
+ Xi: 926,
16522
+ Omicron: 927,
16523
+ Pi: 928,
16524
+ Rho: 929,
16525
+ Sigma: 931,
16526
+ Tau: 932,
16527
+ Upsilon: 933,
16528
+ Phi: 934,
16529
+ Chi: 935,
16530
+ Psi: 936,
16531
+ Omega: 937,
16532
+ alpha: 945,
16533
+ beta: 946,
16534
+ gamma: 947,
16535
+ delta: 948,
16536
+ epsilon: 949,
16537
+ zeta: 950,
16538
+ eta: 951,
16539
+ theta: 952,
16540
+ iota: 953,
16541
+ kappa: 954,
16542
+ lambda: 955,
16543
+ mu: 956,
16544
+ nu: 957,
16545
+ xi: 958,
16546
+ omicron: 959,
16547
+ pi: 960,
16548
+ rho: 961,
16549
+ sigmaf: 962,
16550
+ sigma: 963,
16551
+ tau: 964,
16552
+ upsilon: 965,
16553
+ phi: 966,
16554
+ chi: 967,
16555
+ psi: 968,
16556
+ omega: 969,
16557
+ thetasym: 977,
16558
+ upsih: 978,
16559
+ piv: 982,
16560
+ ensp: 8194,
16561
+ emsp: 8195,
16562
+ thinsp: 8201,
16563
+ zwnj: 8204,
16564
+ zwj: 8205,
16565
+ lrm: 8206,
16566
+ rlm: 8207,
16567
+ ndash: 8211,
16568
+ mdash: 8212,
16569
+ lsquo: 8216,
16570
+ rsquo: 8217,
16571
+ sbquo: 8218,
16572
+ ldquo: 8220,
16573
+ rdquo: 8221,
16574
+ bdquo: 8222,
16575
+ dagger: 8224,
16576
+ Dagger: 8225,
16577
+ bull: 8226,
16578
+ hellip: 8230,
16579
+ permil: 8240,
16580
+ prime: 8242,
16581
+ Prime: 8243,
16582
+ lsaquo: 8249,
16583
+ rsaquo: 8250,
16584
+ oline: 8254,
16585
+ frasl: 8260,
16586
+ euro: 8364,
16587
+ image: 8465,
16588
+ weierp: 8472,
16589
+ real: 8476,
16590
+ trade: 8482,
16591
+ alefsym: 8501,
16592
+ larr: 8592,
16593
+ uarr: 8593,
16594
+ rarr: 8594,
16595
+ darr: 8595,
16596
+ harr: 8596,
16597
+ crarr: 8629,
16598
+ lArr: 8656,
16599
+ uArr: 8657,
16600
+ rArr: 8658,
16601
+ dArr: 8659,
16602
+ hArr: 8660,
16603
+ forall: 8704,
16604
+ part: 8706,
16605
+ exist: 8707,
16606
+ empty: 8709,
16607
+ nabla: 8711,
16608
+ isin: 8712,
16609
+ notin: 8713,
16610
+ ni: 8715,
16611
+ prod: 8719,
16612
+ sum: 8721,
16613
+ minus: 8722,
16614
+ lowast: 8727,
16615
+ radic: 8730,
16616
+ prop: 8733,
16617
+ infin: 8734,
16618
+ ang: 8736,
16619
+ and: 8743,
16620
+ or: 8744,
16621
+ cap: 8745,
16622
+ cup: 8746,
16623
+ int: 8747,
16624
+ there4: 8756,
16625
+ sim: 8764,
16626
+ cong: 8773,
16627
+ asymp: 8776,
16628
+ ne: 8800,
16629
+ equiv: 8801,
16630
+ le: 8804,
16631
+ ge: 8805,
16632
+ sub: 8834,
16633
+ sup: 8835,
16634
+ nsub: 8836,
16635
+ sube: 8838,
16636
+ supe: 8839,
16637
+ oplus: 8853,
16638
+ otimes: 8855,
16639
+ perp: 8869,
16640
+ sdot: 8901,
16641
+ lceil: 8968,
16642
+ rceil: 8969,
16643
+ lfloor: 8970,
16644
+ rfloor: 8971,
16645
+ lang: 9001,
16646
+ rang: 9002,
16647
+ loz: 9674,
16648
+ spades: 9824,
16649
+ clubs: 9827,
16650
+ hearts: 9829,
16651
+ diams: 9830
16652
+ };
16653
+ Object.keys(ENTITIES).forEach((key) => {
16654
+ const e = ENTITIES[key];
16655
+ ENTITIES[key] = typeof e === "number" ? String.fromCharCode(e) : e;
16656
+ });
16657
+ SAX = class _SAX {
16658
+ EVENTS = EVENTS;
16659
+ ENTITIES = {
16660
+ // TODO: make it readonly, needed for entity-mega test
16661
+ // amp, gt, lt, quot and apos are resolved to strings instead of numerical
16662
+ // codes, IDK why
16663
+ ...ENTITIES
16664
+ };
16665
+ XML_ENTITIES = {
16666
+ amp: "&",
16667
+ gt: ">",
16668
+ lt: "<",
16669
+ quot: '"',
16670
+ apos: "'"
16671
+ };
16672
+ S = 0;
16673
+ opt;
16674
+ trackPosition = false;
16675
+ column = 0;
16676
+ line = 0;
16677
+ c = "";
16678
+ error;
16679
+ q = "";
16680
+ bufferCheckPosition;
16681
+ closed = false;
16682
+ tags = [];
16683
+ looseCase = "";
16684
+ closedRoot = false;
16685
+ sawRoot = false;
16686
+ strict = false;
16687
+ tag;
16688
+ strictEntities;
16689
+ state;
16690
+ noscript = false;
16691
+ attribList = [];
16692
+ ns;
16693
+ position = 0;
16694
+ STATE = {
16695
+ BEGIN: this.S++,
16696
+ // leading byte order mark or whitespace
16697
+ BEGIN_WHITESPACE: this.S++,
16698
+ // leading whitespace
16699
+ TEXT: this.S++,
16700
+ // general stuff
16701
+ TEXT_ENTITY: this.S++,
16702
+ // &amp and such.
16703
+ OPEN_WAKA: this.S++,
16704
+ // <
16705
+ SGML_DECL: this.S++,
16706
+ // <!BLARG
16707
+ SGML_DECL_QUOTED: this.S++,
16708
+ // <!BLARG foo "bar
16709
+ DOCTYPE: this.S++,
16710
+ // <!DOCTYPE
16711
+ DOCTYPE_QUOTED: this.S++,
16712
+ // <!DOCTYPE "//blah
16713
+ DOCTYPE_DTD: this.S++,
16714
+ // <!DOCTYPE "//blah" [ ...
16715
+ DOCTYPE_DTD_QUOTED: this.S++,
16716
+ // <!DOCTYPE "//blah" [ "foo
16717
+ COMMENT_STARTING: this.S++,
16718
+ // <!-
16719
+ COMMENT: this.S++,
16720
+ // <!--
16721
+ COMMENT_ENDING: this.S++,
16722
+ // <!-- blah -
16723
+ COMMENT_ENDED: this.S++,
16724
+ // <!-- blah --
16725
+ CDATA: this.S++,
16726
+ // <![CDATA[ something
16727
+ CDATA_ENDING: this.S++,
16728
+ // ]
16729
+ CDATA_ENDING_2: this.S++,
16730
+ // ]]
16731
+ PROC_INST: this.S++,
16732
+ // <?hi
16733
+ PROC_INST_BODY: this.S++,
16734
+ // <?hi there
16735
+ PROC_INST_ENDING: this.S++,
16736
+ // <?hi "there" ?
16737
+ OPEN_TAG: this.S++,
16738
+ // <strong
16739
+ OPEN_TAG_SLASH: this.S++,
16740
+ // <strong /
16741
+ ATTRIB: this.S++,
16742
+ // <a
16743
+ ATTRIB_NAME: this.S++,
16744
+ // <a foo
16745
+ ATTRIB_NAME_SAW_WHITE: this.S++,
16746
+ // <a foo _
16747
+ ATTRIB_VALUE: this.S++,
16748
+ // <a foo=
16749
+ ATTRIB_VALUE_QUOTED: this.S++,
16750
+ // <a foo="bar
16751
+ ATTRIB_VALUE_CLOSED: this.S++,
16752
+ // <a foo="bar"
16753
+ ATTRIB_VALUE_UNQUOTED: this.S++,
16754
+ // <a foo=bar
16755
+ ATTRIB_VALUE_ENTITY_Q: this.S++,
16756
+ // <foo bar="&quot;"
16757
+ ATTRIB_VALUE_ENTITY_U: this.S++,
16758
+ // <foo bar=&quot
16759
+ CLOSE_TAG: this.S++,
16760
+ // </a
16761
+ CLOSE_TAG_SAW_WHITE: this.S++,
16762
+ // </a >
16763
+ SCRIPT: this.S++,
16764
+ // <script> ...
16765
+ SCRIPT_ENDING: this.S++
16766
+ // <script> ... <
16767
+ };
16768
+ BUFFERS = BUFFERS;
16769
+ // private parser: (strict: boolean, opt: any) => SAXParser;
16770
+ CDATA = "[CDATA[";
16771
+ DOCTYPE = "DOCTYPE";
16772
+ XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace";
16773
+ XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/";
16774
+ rootNS = {
16775
+ xml: this.XML_NAMESPACE,
16776
+ xmlns: this.XMLNS_NAMESPACE
16777
+ };
16778
+ comment;
16779
+ sgmlDecl;
16780
+ textNode = "";
16781
+ tagName;
16782
+ doctype;
16783
+ procInstName;
16784
+ procInstBody;
16785
+ entity = "";
16786
+ attribName;
16787
+ attribValue;
16788
+ cdata = "";
16789
+ script = "";
16790
+ startTagPosition = 0;
16791
+ constructor() {
16792
+ this.S = 0;
16793
+ for (const s in this.STATE) {
16794
+ if (this.STATE.hasOwnProperty(s)) {
16795
+ this.STATE[this.STATE[s]] = s;
16796
+ }
16797
+ }
16798
+ this.S = this.STATE;
16799
+ }
16800
+ static charAt(chunk, i) {
16801
+ let result = "";
16802
+ if (i < chunk.length) {
16803
+ result = chunk.charAt(i);
16804
+ }
16805
+ return result;
16806
+ }
16807
+ static isWhitespace(c) {
16808
+ return c === " " || c === "\n" || c === "\r" || c === " ";
16809
+ }
16810
+ static isQuote(c) {
16811
+ return c === '"' || c === "'";
16812
+ }
16813
+ static isAttribEnd(c) {
16814
+ return c === ">" || _SAX.isWhitespace(c);
16815
+ }
16816
+ static isMatch(regex, c) {
16817
+ return regex.test(c);
16818
+ }
16819
+ static notMatch(regex, c) {
16820
+ return !_SAX.isMatch(regex, c);
16821
+ }
16822
+ static qname(name22, attribute) {
16823
+ const i = name22.indexOf(":");
16824
+ const qualName = i < 0 ? ["", name22] : name22.split(":");
16825
+ let prefix = qualName[0];
16826
+ let local = qualName[1];
16827
+ if (attribute && name22 === "xmlns") {
16828
+ prefix = "xmlns";
16829
+ local = "";
16830
+ }
16831
+ return { prefix, local };
16832
+ }
16833
+ write(chunk) {
16834
+ if (this.error) {
16835
+ throw this.error;
16836
+ }
16837
+ if (this.closed) {
16838
+ return this.errorFunction("Cannot write after close. Assign an onready handler.");
16839
+ }
16840
+ if (chunk === null) {
16841
+ return this.end();
16842
+ }
16843
+ if (typeof chunk === "object") {
16844
+ chunk = chunk.toString();
16845
+ }
16846
+ let i = 0;
16847
+ let c;
16848
+ while (true) {
16849
+ c = _SAX.charAt(chunk, i++);
16850
+ this.c = c;
16851
+ if (!c) {
16852
+ break;
16853
+ }
16854
+ if (this.trackPosition) {
16855
+ this.position++;
16856
+ if (c === "\n") {
16857
+ this.line++;
16858
+ this.column = 0;
16859
+ } else {
16860
+ this.column++;
16861
+ }
16862
+ }
16863
+ switch (this.state) {
16864
+ case this.S.BEGIN:
16865
+ this.state = this.S.BEGIN_WHITESPACE;
16866
+ if (c === "\uFEFF") {
16867
+ continue;
16868
+ }
16869
+ this.beginWhiteSpace(c);
16870
+ continue;
16871
+ case this.S.BEGIN_WHITESPACE:
16872
+ this.beginWhiteSpace(c);
16873
+ continue;
16874
+ case this.S.TEXT:
16875
+ if (this.sawRoot && !this.closedRoot) {
16876
+ const starti = i - 1;
16877
+ while (c && c !== "<" && c !== "&") {
16878
+ c = _SAX.charAt(chunk, i++);
16879
+ if (c && this.trackPosition) {
16880
+ this.position++;
16881
+ if (c === "\n") {
16882
+ this.line++;
16883
+ this.column = 0;
16884
+ } else {
16885
+ this.column++;
16886
+ }
16887
+ }
16888
+ }
16889
+ this.textNode += chunk.substring(starti, i - 1);
16890
+ }
16891
+ if (c === "<" && !(this.sawRoot && this.closedRoot && !this.strict)) {
16892
+ this.state = this.S.OPEN_WAKA;
16893
+ this.startTagPosition = this.position;
16894
+ } else {
16895
+ if (!_SAX.isWhitespace(c) && (!this.sawRoot || this.closedRoot)) {
16896
+ this.strictFail("Text data outside of root node.");
16897
+ }
16898
+ if (c === "&") {
16899
+ this.state = this.S.TEXT_ENTITY;
16900
+ } else {
16901
+ this.textNode += c;
16902
+ }
16903
+ }
16904
+ continue;
16905
+ case this.S.SCRIPT:
16906
+ if (c === "<") {
16907
+ this.state = this.S.SCRIPT_ENDING;
16908
+ } else {
16909
+ this.script += c;
16910
+ }
16911
+ continue;
16912
+ case this.S.SCRIPT_ENDING:
16913
+ if (c === "/") {
16914
+ this.state = this.S.CLOSE_TAG;
16915
+ } else {
16916
+ this.script += `<${c}`;
16917
+ this.state = this.S.SCRIPT;
16918
+ }
16919
+ continue;
16920
+ case this.S.OPEN_WAKA:
16921
+ if (c === "!") {
16922
+ this.state = this.S.SGML_DECL;
16923
+ this.sgmlDecl = "";
16924
+ } else if (_SAX.isWhitespace(c)) {
16925
+ } else if (_SAX.isMatch(nameStart, c)) {
16926
+ this.state = this.S.OPEN_TAG;
16927
+ this.tagName = c;
16928
+ } else if (c === "/") {
16929
+ this.state = this.S.CLOSE_TAG;
16930
+ this.tagName = "";
16931
+ } else if (c === "?") {
16932
+ this.state = this.S.PROC_INST;
16933
+ this.procInstName = this.procInstBody = "";
16934
+ } else {
16935
+ this.strictFail("Unencoded <");
16936
+ if (this.startTagPosition + 1 < this.position) {
16937
+ const pad = this.position - this.startTagPosition;
16938
+ c = new Array(pad).join(" ") + c;
16939
+ }
16940
+ this.textNode += `<${c}`;
16941
+ this.state = this.S.TEXT;
16942
+ }
16943
+ continue;
16944
+ case this.S.SGML_DECL:
16945
+ if ((this.sgmlDecl + c).toUpperCase() === this.CDATA) {
16946
+ this.emitNode("onopencdata");
16947
+ this.state = this.S.CDATA;
16948
+ this.sgmlDecl = "";
16949
+ this.cdata = "";
16950
+ } else if (this.sgmlDecl + c === "--") {
16951
+ this.state = this.S.COMMENT;
16952
+ this.comment = "";
16953
+ this.sgmlDecl = "";
16954
+ } else if ((this.sgmlDecl + c).toUpperCase() === this.DOCTYPE) {
16955
+ this.state = this.S.DOCTYPE;
16956
+ if (this.doctype || this.sawRoot) {
16957
+ this.strictFail("Inappropriately located doctype declaration");
16958
+ }
16959
+ this.doctype = "";
16960
+ this.sgmlDecl = "";
16961
+ } else if (c === ">") {
16962
+ this.emitNode("onsgmldeclaration", this.sgmlDecl);
16963
+ this.sgmlDecl = "";
16964
+ this.state = this.S.TEXT;
16965
+ } else if (_SAX.isQuote(c)) {
16966
+ this.state = this.S.SGML_DECL_QUOTED;
16967
+ this.sgmlDecl += c;
16968
+ } else {
16969
+ this.sgmlDecl += c;
16970
+ }
16971
+ continue;
16972
+ case this.S.SGML_DECL_QUOTED:
16973
+ if (c === this.q) {
16974
+ this.state = this.S.SGML_DECL;
16975
+ this.q = "";
16976
+ }
16977
+ this.sgmlDecl += c;
16978
+ continue;
16979
+ case this.S.DOCTYPE:
16980
+ if (c === ">") {
16981
+ this.state = this.S.TEXT;
16982
+ this.emitNode("ondoctype", this.doctype);
16983
+ this.doctype = true;
16984
+ } else {
16985
+ this.doctype += c;
16986
+ if (c === "[") {
16987
+ this.state = this.S.DOCTYPE_DTD;
16988
+ } else if (_SAX.isQuote(c)) {
16989
+ this.state = this.S.DOCTYPE_QUOTED;
16990
+ this.q = c;
16991
+ }
16992
+ }
16993
+ continue;
16994
+ case this.S.DOCTYPE_QUOTED:
16995
+ this.doctype += c;
16996
+ if (c === this.q) {
16997
+ this.q = "";
16998
+ this.state = this.S.DOCTYPE;
16999
+ }
17000
+ continue;
17001
+ case this.S.DOCTYPE_DTD:
17002
+ this.doctype += c;
17003
+ if (c === "]") {
17004
+ this.state = this.S.DOCTYPE;
17005
+ } else if (_SAX.isQuote(c)) {
17006
+ this.state = this.S.DOCTYPE_DTD_QUOTED;
17007
+ this.q = c;
17008
+ }
17009
+ continue;
17010
+ case this.S.DOCTYPE_DTD_QUOTED:
17011
+ this.doctype += c;
17012
+ if (c === this.q) {
17013
+ this.state = this.S.DOCTYPE_DTD;
17014
+ this.q = "";
17015
+ }
17016
+ continue;
17017
+ case this.S.COMMENT:
17018
+ if (c === "-") {
17019
+ this.state = this.S.COMMENT_ENDING;
17020
+ } else {
17021
+ this.comment += c;
17022
+ }
17023
+ continue;
17024
+ case this.S.COMMENT_ENDING:
17025
+ if (c === "-") {
17026
+ this.state = this.S.COMMENT_ENDED;
17027
+ this.comment = this.textApplyOptions(this.comment);
17028
+ if (this.comment) {
17029
+ this.emitNode("oncomment", this.comment);
17030
+ }
17031
+ this.comment = "";
17032
+ } else {
17033
+ this.comment += `-${c}`;
17034
+ this.state = this.S.COMMENT;
17035
+ }
17036
+ continue;
17037
+ case this.S.COMMENT_ENDED:
17038
+ if (c !== ">") {
17039
+ this.strictFail("Malformed comment");
17040
+ this.comment += `--${c}`;
17041
+ this.state = this.S.COMMENT;
17042
+ } else {
17043
+ this.state = this.S.TEXT;
17044
+ }
17045
+ continue;
17046
+ case this.S.CDATA:
17047
+ if (c === "]") {
17048
+ this.state = this.S.CDATA_ENDING;
17049
+ } else {
17050
+ this.cdata += c;
17051
+ }
17052
+ continue;
17053
+ case this.S.CDATA_ENDING:
17054
+ if (c === "]") {
17055
+ this.state = this.S.CDATA_ENDING_2;
17056
+ } else {
17057
+ this.cdata += `]${c}`;
17058
+ this.state = this.S.CDATA;
17059
+ }
17060
+ continue;
17061
+ case this.S.CDATA_ENDING_2:
17062
+ if (c === ">") {
17063
+ if (this.cdata) {
17064
+ this.emitNode("oncdata", this.cdata);
17065
+ }
17066
+ this.emitNode("onclosecdata");
17067
+ this.cdata = "";
17068
+ this.state = this.S.TEXT;
17069
+ } else if (c === "]") {
17070
+ this.cdata += "]";
17071
+ } else {
17072
+ this.cdata += `]]${c}`;
17073
+ this.state = this.S.CDATA;
17074
+ }
17075
+ continue;
17076
+ case this.S.PROC_INST:
17077
+ if (c === "?") {
17078
+ this.state = this.S.PROC_INST_ENDING;
17079
+ } else if (_SAX.isWhitespace(c)) {
17080
+ this.state = this.S.PROC_INST_BODY;
17081
+ } else {
17082
+ this.procInstName += c;
17083
+ }
17084
+ continue;
17085
+ case this.S.PROC_INST_BODY:
17086
+ if (!this.procInstBody && _SAX.isWhitespace(c)) {
17087
+ continue;
17088
+ } else if (c === "?") {
17089
+ this.state = this.S.PROC_INST_ENDING;
17090
+ } else {
17091
+ this.procInstBody += c;
17092
+ }
17093
+ continue;
17094
+ case this.S.PROC_INST_ENDING:
17095
+ if (c === ">") {
17096
+ this.emitNode("onprocessinginstruction", {
17097
+ name: this.procInstName,
17098
+ body: this.procInstBody
17099
+ });
17100
+ this.procInstName = this.procInstBody = "";
17101
+ this.state = this.S.TEXT;
17102
+ } else {
17103
+ this.procInstBody += `?${c}`;
17104
+ this.state = this.S.PROC_INST_BODY;
17105
+ }
17106
+ continue;
17107
+ case this.S.OPEN_TAG:
17108
+ if (_SAX.isMatch(nameBody, c)) {
17109
+ this.tagName += c;
17110
+ } else {
17111
+ this.newTag();
17112
+ if (c === ">") {
17113
+ this.openTag();
17114
+ } else if (c === "/") {
17115
+ this.state = this.S.OPEN_TAG_SLASH;
17116
+ } else {
17117
+ if (!_SAX.isWhitespace(c)) {
17118
+ this.strictFail("Invalid character in tag name");
17119
+ }
17120
+ this.state = this.S.ATTRIB;
17121
+ }
17122
+ }
17123
+ continue;
17124
+ case this.S.OPEN_TAG_SLASH:
17125
+ if (c === ">") {
17126
+ this.openTag(true);
17127
+ this.closeTag();
17128
+ } else {
17129
+ this.strictFail("Forward-slash in opening tag not followed by >");
17130
+ this.state = this.S.ATTRIB;
17131
+ }
17132
+ continue;
17133
+ case this.S.ATTRIB:
17134
+ if (_SAX.isWhitespace(c)) {
17135
+ continue;
17136
+ } else if (c === ">") {
17137
+ this.openTag();
17138
+ } else if (c === "/") {
17139
+ this.state = this.S.OPEN_TAG_SLASH;
17140
+ } else if (_SAX.isMatch(nameStart, c)) {
17141
+ this.attribName = c;
17142
+ this.attribValue = "";
17143
+ this.state = this.S.ATTRIB_NAME;
17144
+ } else {
17145
+ this.strictFail("Invalid attribute name");
17146
+ }
17147
+ continue;
17148
+ case this.S.ATTRIB_NAME:
17149
+ if (c === "=") {
17150
+ this.state = this.S.ATTRIB_VALUE;
17151
+ } else if (c === ">") {
17152
+ this.strictFail("Attribute without value");
17153
+ this.attribValue = this.attribName;
17154
+ this.attrib();
17155
+ this.openTag();
17156
+ } else if (_SAX.isWhitespace(c)) {
17157
+ this.state = this.S.ATTRIB_NAME_SAW_WHITE;
17158
+ } else if (_SAX.isMatch(nameBody, c)) {
17159
+ this.attribName += c;
17160
+ } else {
17161
+ this.strictFail("Invalid attribute name");
17162
+ }
17163
+ continue;
17164
+ case this.S.ATTRIB_NAME_SAW_WHITE:
17165
+ if (c === "=") {
17166
+ this.state = this.S.ATTRIB_VALUE;
17167
+ } else if (_SAX.isWhitespace(c)) {
17168
+ continue;
17169
+ } else {
17170
+ this.strictFail("Attribute without value");
17171
+ Object.defineProperty(this.tag.attributes, this.attribName, {
17172
+ value: "",
17173
+ enumerable: true,
17174
+ configurable: true,
17175
+ writable: true
17176
+ });
17177
+ this.attribValue = "";
17178
+ this.emitNode("onattribute", {
17179
+ name: this.attribName,
17180
+ value: ""
17181
+ });
17182
+ this.attribName = "";
17183
+ if (c === ">") {
17184
+ this.openTag();
17185
+ } else if (_SAX.isMatch(nameStart, c)) {
17186
+ this.attribName = c;
17187
+ this.state = this.S.ATTRIB_NAME;
17188
+ } else {
17189
+ this.strictFail("Invalid attribute name");
17190
+ this.state = this.S.ATTRIB;
17191
+ }
17192
+ }
17193
+ continue;
17194
+ case this.S.ATTRIB_VALUE:
17195
+ if (_SAX.isWhitespace(c)) {
17196
+ continue;
17197
+ } else if (_SAX.isQuote(c)) {
17198
+ this.q = c;
17199
+ this.state = this.S.ATTRIB_VALUE_QUOTED;
17200
+ } else {
17201
+ this.strictFail("Unquoted attribute value");
17202
+ this.state = this.S.ATTRIB_VALUE_UNQUOTED;
17203
+ this.attribValue = c;
17204
+ }
17205
+ continue;
17206
+ case this.S.ATTRIB_VALUE_QUOTED:
17207
+ if (c !== this.q) {
17208
+ if (c === "&") {
17209
+ this.state = this.S.ATTRIB_VALUE_ENTITY_Q;
17210
+ } else {
17211
+ this.attribValue += c;
17212
+ }
17213
+ continue;
17214
+ }
17215
+ this.attrib();
17216
+ this.q = "";
17217
+ this.state = this.S.ATTRIB_VALUE_CLOSED;
17218
+ continue;
17219
+ case this.S.ATTRIB_VALUE_CLOSED:
17220
+ if (_SAX.isWhitespace(c)) {
17221
+ this.state = this.S.ATTRIB;
17222
+ } else if (c === ">") {
17223
+ this.openTag();
17224
+ } else if (c === "/") {
17225
+ this.state = this.S.OPEN_TAG_SLASH;
17226
+ } else if (_SAX.isMatch(nameStart, c)) {
17227
+ this.strictFail("No whitespace between attributes");
17228
+ this.attribName = c;
17229
+ this.attribValue = "";
17230
+ this.state = this.S.ATTRIB_NAME;
17231
+ } else {
17232
+ this.strictFail("Invalid attribute name");
17233
+ }
17234
+ continue;
17235
+ case this.S.ATTRIB_VALUE_UNQUOTED:
17236
+ if (!_SAX.isAttribEnd(c)) {
17237
+ if (c === "&") {
17238
+ this.state = this.S.ATTRIB_VALUE_ENTITY_U;
17239
+ } else {
17240
+ this.attribValue += c;
17241
+ }
17242
+ continue;
17243
+ }
17244
+ this.attrib();
17245
+ if (c === ">") {
17246
+ this.openTag();
17247
+ } else {
17248
+ this.state = this.S.ATTRIB;
17249
+ }
17250
+ continue;
17251
+ case this.S.CLOSE_TAG:
17252
+ if (!this.tagName) {
17253
+ if (_SAX.isWhitespace(c)) {
17254
+ continue;
17255
+ } else if (_SAX.notMatch(nameStart, c)) {
17256
+ if (this.script) {
17257
+ this.script += `</${c}`;
17258
+ this.state = this.S.SCRIPT;
17259
+ } else {
17260
+ this.strictFail("Invalid tagname in closing tag.");
17261
+ }
17262
+ } else {
17263
+ this.tagName = c;
17264
+ }
17265
+ } else if (c === ">") {
17266
+ this.closeTag();
17267
+ } else if (_SAX.isMatch(nameBody, c)) {
17268
+ this.tagName += c;
17269
+ } else if (this.script) {
17270
+ this.script += `</${this.tagName}`;
17271
+ this.tagName = "";
17272
+ this.state = this.S.SCRIPT;
17273
+ } else {
17274
+ if (!_SAX.isWhitespace(c)) {
17275
+ this.strictFail("Invalid tagname in closing tag");
17276
+ }
17277
+ this.state = this.S.CLOSE_TAG_SAW_WHITE;
17278
+ }
17279
+ continue;
17280
+ case this.S.CLOSE_TAG_SAW_WHITE:
17281
+ if (_SAX.isWhitespace(c)) {
17282
+ continue;
17283
+ }
17284
+ if (c === ">") {
17285
+ this.closeTag();
17286
+ } else {
17287
+ this.strictFail("Invalid characters in closing tag");
17288
+ }
17289
+ continue;
17290
+ case this.S.TEXT_ENTITY:
17291
+ case this.S.ATTRIB_VALUE_ENTITY_Q:
17292
+ case this.S.ATTRIB_VALUE_ENTITY_U:
17293
+ let returnState;
17294
+ let buffer;
17295
+ switch (this.state) {
17296
+ case this.S.TEXT_ENTITY:
17297
+ returnState = this.S.TEXT;
17298
+ buffer = "textNode";
17299
+ break;
17300
+ case this.S.ATTRIB_VALUE_ENTITY_Q:
17301
+ returnState = this.S.ATTRIB_VALUE_QUOTED;
17302
+ buffer = "attribValue";
17303
+ break;
17304
+ case this.S.ATTRIB_VALUE_ENTITY_U:
17305
+ returnState = this.S.ATTRIB_VALUE_UNQUOTED;
17306
+ buffer = "attribValue";
17307
+ break;
17308
+ default:
17309
+ throw new Error(`Unknown state: ${this.state}`);
17310
+ }
17311
+ if (c === ";") {
17312
+ this[buffer] += this.parseEntity();
17313
+ this.entity = "";
17314
+ this.state = returnState;
17315
+ } else if (_SAX.isMatch(this.entity.length ? entityBody : entityStart, c)) {
17316
+ this.entity += c;
17317
+ } else {
17318
+ this.strictFail("Invalid character in entity name");
17319
+ this[buffer] += `&${this.entity}${c}`;
17320
+ this.entity = "";
17321
+ this.state = returnState;
17322
+ }
17323
+ continue;
17324
+ default:
17325
+ throw new Error(`Unknown state: ${this.state}`);
17326
+ }
17327
+ }
17328
+ if (this.position >= this.bufferCheckPosition) {
17329
+ this.checkBufferLength();
17330
+ }
17331
+ return this;
17332
+ }
17333
+ emit(event, data) {
17334
+ if (this.events.hasOwnProperty(event)) {
17335
+ const eventName = event.replace(/^on/, "");
17336
+ this.events[event](data, eventName, this);
17337
+ }
17338
+ }
17339
+ clearBuffers() {
17340
+ for (let i = 0, l = this.BUFFERS.length; i < l; i++) {
17341
+ this[this[i]] = "";
17342
+ }
17343
+ }
17344
+ flushBuffers() {
17345
+ this.closeText();
17346
+ if (this.cdata !== "") {
17347
+ this.emitNode("oncdata", this.cdata);
17348
+ this.cdata = "";
17349
+ }
17350
+ if (this.script !== "") {
17351
+ this.emitNode("onscript", this.script);
17352
+ this.script = "";
17353
+ }
17354
+ }
17355
+ end() {
17356
+ if (this.sawRoot && !this.closedRoot) this.strictFail("Unclosed root tag");
17357
+ if (this.strict && this.state !== this.S.BEGIN && this.state !== this.S.BEGIN_WHITESPACE && this.state !== this.S.TEXT) {
17358
+ this.errorFunction("Unexpected end");
17359
+ }
17360
+ this.closeText();
17361
+ this.c = "";
17362
+ this.closed = true;
17363
+ this.emit("onend");
17364
+ return new SAXParser(this.opt);
17365
+ }
17366
+ errorFunction(er) {
17367
+ this.closeText();
17368
+ if (this.trackPosition) {
17369
+ er += `
17370
+ Line: ${this.line}
17371
+ Column: ${this.column}
17372
+ Char: ${this.c}`;
17373
+ }
17374
+ const error = new Error(er);
17375
+ this.error = error;
17376
+ this.emit("onerror", error);
17377
+ return this;
17378
+ }
17379
+ attrib() {
17380
+ if (!this.strict && !this.opt.preserveCase) {
17381
+ this.attribName = this.attribName[this.looseCase]();
17382
+ }
17383
+ if (this.attribList.indexOf(this.attribName) !== -1 || Object.hasOwn(this.tag.attributes, this.attribName)) {
17384
+ this.strictFail("Duplicate attribute");
17385
+ this.attribName = this.attribValue = "";
17386
+ return;
17387
+ }
17388
+ if (this.opt.xmlns) {
17389
+ const qn = _SAX.qname(this.attribName, true);
17390
+ const prefix = qn.prefix;
17391
+ const local = qn.local;
17392
+ if (prefix === "xmlns") {
17393
+ if (local === "xml" && this.attribValue !== this.XML_NAMESPACE) {
17394
+ this.strictFail(
17395
+ `xml: prefix must be bound to ${this.XML_NAMESPACE}
17396
+ Actual: ${this.attribValue}`
17397
+ );
17398
+ } else if (local === "xmlns" && this.attribValue !== this.XMLNS_NAMESPACE) {
17399
+ this.strictFail(
17400
+ `xmlns: prefix must be bound to ${this.XMLNS_NAMESPACE}
17401
+ Actual: ${this.attribValue}`
17402
+ );
17403
+ } else {
17404
+ const tag = this.tag;
17405
+ const parent = this.tags[this.tags.length - 1] || this;
17406
+ if (tag.ns === parent.ns) {
17407
+ tag.ns = Object.create(parent.ns);
17408
+ }
17409
+ tag.ns[local] = this.attribValue;
17410
+ }
17411
+ }
17412
+ this.attribList.push([this.attribName, this.attribValue]);
17413
+ } else {
17414
+ Object.defineProperty(this.tag.attributes, this.attribName, {
17415
+ value: this.attribValue,
17416
+ enumerable: true,
17417
+ configurable: true,
17418
+ writable: true
17419
+ });
17420
+ this.emitNode("onattribute", {
17421
+ name: this.attribName,
17422
+ value: this.attribValue
17423
+ });
17424
+ }
17425
+ this.attribName = this.attribValue = "";
17426
+ }
17427
+ newTag() {
17428
+ if (!this.strict && !this.opt.preserveCase) this.tagName = this.tagName[this.looseCase]();
17429
+ const parent = this.tags[this.tags.length - 1] || this;
17430
+ const tag = { name: this.tagName, attributes: {} };
17431
+ this.tag = tag;
17432
+ if (this.opt.xmlns) {
17433
+ tag.ns = parent.ns;
17434
+ }
17435
+ this.attribList.length = 0;
17436
+ this.emitNode("onopentagstart", tag);
17437
+ }
17438
+ /** Validates an entity before optionally preserving its authored spelling. */
17439
+ parseEntity() {
17440
+ const decoded = this.decodeEntity();
17441
+ return this.opt.processEntities === false ? `&${this.entity};` : decoded;
17442
+ }
17443
+ /** Decodes predefined, configured, or numeric entities without resolving document types. */
17444
+ decodeEntity() {
17445
+ let entity = this.entity;
17446
+ const entityLC = entity.toLowerCase();
17447
+ let num = NaN;
17448
+ let numStr = "";
17449
+ if (typeof this.ENTITIES[entity] === "string" || typeof this.ENTITIES[entity] === "number") {
17450
+ return this.ENTITIES[entity];
17451
+ }
17452
+ if (typeof this.ENTITIES[entityLC] === "string" || typeof this.ENTITIES[entityLC] === "number") {
17453
+ return this.ENTITIES[entityLC];
17454
+ }
17455
+ entity = entityLC;
17456
+ if (entity.charAt(0) === "#") {
17457
+ if (entity.charAt(1) === "x") {
17458
+ entity = entity.slice(2);
17459
+ num = parseInt(entity, 16);
17460
+ numStr = num.toString(16);
17461
+ } else {
17462
+ entity = entity.slice(1);
17463
+ num = parseInt(entity, 10);
17464
+ numStr = num.toString(10);
17465
+ }
17466
+ }
17467
+ entity = entity.replace(/^0+/, "");
17468
+ if (Number.isNaN(num) || numStr.toLowerCase() !== entity) {
17469
+ this.strictFail("Invalid character entity");
17470
+ return `&${this.entity};`;
17471
+ }
17472
+ if (num < 0 || num > 1114111 || num >= 55296 && num <= 57343 || num < 32 && ![9, 10, 13].includes(num) || num === 65534 || num === 65535) {
17473
+ this.strictFail("Invalid character entity");
17474
+ return `&${this.entity};`;
17475
+ }
17476
+ return String.fromCodePoint(num);
17477
+ }
17478
+ beginWhiteSpace(c) {
17479
+ if (c === "<") {
17480
+ this.state = this.S.OPEN_WAKA;
17481
+ this.startTagPosition = this.position;
17482
+ } else if (!_SAX.isWhitespace(c)) {
17483
+ this.strictFail("Non-whitespace before first tag.");
17484
+ this.textNode = c;
17485
+ this.state = this.S.TEXT;
17486
+ } else {
17487
+ }
17488
+ }
17489
+ strictFail(message) {
17490
+ if (typeof this !== "object" || !(this instanceof SAXParser)) {
17491
+ throw new Error("bad call to strictFail");
17492
+ }
17493
+ if (this.strict) {
17494
+ this.errorFunction(message);
17495
+ }
17496
+ }
17497
+ textApplyOptions(text) {
17498
+ if (this.opt.trim) text = text.trim();
17499
+ if (this.opt.normalize) text = text.replace(/\s+/g, " ");
17500
+ return text;
17501
+ }
17502
+ emitNode(nodeType, data) {
17503
+ if (this.textNode) this.closeText();
17504
+ this.emit(nodeType, data);
17505
+ }
17506
+ closeText() {
17507
+ this.textNode = this.textApplyOptions(this.textNode);
17508
+ if (this.textNode !== void 0 && this.textNode !== "" && this.textNode !== "undefined") {
17509
+ this.emit("ontext", this.textNode);
17510
+ }
17511
+ this.textNode = "";
17512
+ }
17513
+ checkBufferLength() {
17514
+ var _a;
17515
+ const maxAllowed = Math.max(this.opt.MAX_BUFFER_LENGTH, 10);
17516
+ let maxActual = 0;
17517
+ for (let i = 0, l = this.BUFFERS.length; i < l; i++) {
17518
+ const len = ((_a = this[this.BUFFERS[i]]) == null ? void 0 : _a.length) || 0;
17519
+ if (len > maxAllowed) {
17520
+ switch (this.BUFFERS[i]) {
17521
+ case "textNode":
17522
+ this.closeText();
17523
+ break;
17524
+ case "cdata":
17525
+ this.emitNode("oncdata", this.cdata);
17526
+ this.cdata = "";
17527
+ break;
17528
+ case "script":
17529
+ this.emitNode("onscript", this.script);
17530
+ this.script = "";
17531
+ break;
17532
+ default:
17533
+ this.errorFunction(`Max buffer length exceeded: ${this.BUFFERS[i]}`);
17534
+ }
17535
+ }
17536
+ maxActual = Math.max(maxActual, len);
17537
+ }
17538
+ const m = this.opt.MAX_BUFFER_LENGTH - maxActual;
17539
+ this.bufferCheckPosition = m + this.position;
17540
+ }
17541
+ openTag(selfClosing) {
17542
+ if (this.opt.xmlns) {
17543
+ const tag = this.tag;
17544
+ const qn = _SAX.qname(this.tagName);
17545
+ tag.prefix = qn.prefix;
17546
+ tag.local = qn.local;
17547
+ tag.uri = tag.ns[qn.prefix] || "";
17548
+ if (tag.prefix && !tag.uri) {
17549
+ this.strictFail(`Unbound namespace prefix: ${JSON.stringify(this.tagName)}`);
17550
+ tag.uri = qn.prefix;
17551
+ }
17552
+ const parent = this.tags[this.tags.length - 1] || this;
17553
+ if (tag.ns && parent.ns !== tag.ns) {
17554
+ const that = this;
17555
+ Object.keys(tag.ns).forEach((p) => {
17556
+ that.emitNode("onopennamespace", {
17557
+ prefix: p,
17558
+ uri: tag.ns[p]
17559
+ });
17560
+ });
17561
+ }
17562
+ for (let i = 0, l = this.attribList.length; i < l; i++) {
17563
+ const nv = this.attribList[i];
17564
+ const name22 = nv[0];
17565
+ const value = nv[1];
17566
+ const qualName = _SAX.qname(name22, true);
17567
+ const prefix = qualName.prefix;
17568
+ const local = qualName.local;
17569
+ const uri = prefix === "" ? "" : tag.ns[prefix] || "";
17570
+ const a = {
17571
+ name: name22,
17572
+ value,
17573
+ prefix,
17574
+ local,
17575
+ uri
17576
+ };
17577
+ if (prefix && prefix !== "xmlns" && !uri) {
17578
+ this.strictFail(`Unbound namespace prefix: ${JSON.stringify(prefix)}`);
17579
+ a.uri = prefix;
17580
+ }
17581
+ Object.defineProperty(this.tag.attributes, name22, {
17582
+ value: a,
17583
+ enumerable: true,
17584
+ configurable: true,
17585
+ writable: true
17586
+ });
17587
+ this.emitNode("onattribute", a);
17588
+ }
17589
+ this.attribList.length = 0;
17590
+ }
17591
+ this.tag.isSelfClosing = Boolean(selfClosing);
17592
+ this.sawRoot = true;
17593
+ this.tags.push(this.tag);
17594
+ this.emitNode("onopentag", this.tag);
17595
+ if (!selfClosing) {
17596
+ if (!this.noscript && this.tagName.toLowerCase() === "script") {
17597
+ this.state = this.S.SCRIPT;
17598
+ } else {
17599
+ this.state = this.S.TEXT;
17600
+ }
17601
+ this.tag = null;
17602
+ this.tagName = "";
17603
+ }
17604
+ this.attribName = this.attribValue = "";
17605
+ this.attribList.length = 0;
17606
+ }
17607
+ closeTag() {
17608
+ if (!this.tagName) {
17609
+ this.strictFail("Weird empty close tag.");
17610
+ this.textNode += "</>";
17611
+ this.state = this.S.TEXT;
17612
+ return;
17613
+ }
17614
+ const caseInsensitiveTags = !this.strict && (this.opt.caseInsensitiveTags || !this.opt.preserveCase);
17615
+ if (this.script) {
17616
+ const normalizedScriptCloseTag = caseInsensitiveTags ? this.tagName.toLowerCase() : this.tagName;
17617
+ if (normalizedScriptCloseTag !== "script") {
17618
+ this.script += `</${this.tagName}>`;
17619
+ this.tagName = "";
17620
+ this.state = this.S.SCRIPT;
17621
+ return;
17622
+ }
17623
+ this.emitNode("onscript", this.script);
17624
+ this.script = "";
17625
+ }
17626
+ let t = this.tags.length;
17627
+ let tagName = this.tagName;
17628
+ const normalizedTagName = caseInsensitiveTags ? tagName.toLowerCase() : tagName;
17629
+ while (t--) {
17630
+ const close = this.tags[t];
17631
+ const normalizedOpenTagName = caseInsensitiveTags ? close.name.toLowerCase() : close.name;
17632
+ if (normalizedOpenTagName !== normalizedTagName) {
17633
+ this.strictFail("Unexpected close tag");
17634
+ } else {
17635
+ break;
17636
+ }
17637
+ }
17638
+ if (t < 0) {
17639
+ this.strictFail(`Unmatched closing tag: ${this.tagName}`);
17640
+ this.textNode += `</${this.tagName}>`;
17641
+ this.state = this.S.TEXT;
17642
+ return;
17643
+ }
17644
+ this.tagName = tagName;
17645
+ let s = this.tags.length;
17646
+ while (s-- > t) {
17647
+ const tag = this.tags.pop();
17648
+ this.tag = tag;
17649
+ this.tagName = this.tag.name;
17650
+ this.emitNode("onclosetag", this.tagName);
17651
+ const x = {};
17652
+ for (const i in tag.ns) {
17653
+ if (tag.ns.hasOwnProperty(i)) {
17654
+ x[i] = tag.ns[i];
17655
+ }
17656
+ }
17657
+ const parent = this.tags[this.tags.length - 1] || this;
17658
+ if (this.opt.xmlns && tag.ns !== parent.ns) {
17659
+ const that = this;
17660
+ Object.keys(tag.ns).forEach((p) => {
17661
+ const n = tag.ns[p];
17662
+ that.emitNode("onclosenamespace", { prefix: p, uri: n });
17663
+ });
17664
+ }
17665
+ }
17666
+ if (t === 0) this.closedRoot = true;
17667
+ this.tagName = this.attribValue = this.attribName = "";
17668
+ this.attribList.length = 0;
17669
+ this.state = this.S.TEXT;
17670
+ }
17671
+ };
17672
+ SAXParser = class extends SAX {
17673
+ static ENTITIES = ENTITIES;
17674
+ opt = DEFAULT_SAX_PARSER_OPTIONS;
17675
+ events = DEFAULT_SAX_EVENTS;
17676
+ constructor(opt) {
17677
+ super();
17678
+ this.clearBuffers();
17679
+ this.opt = opt = { ...this.opt, ...opt };
17680
+ this.events = { ...this.events, ...opt };
17681
+ this.q = this.c = "";
17682
+ this.opt.lowercase = this.opt.lowercase || this.opt.lowercasetags;
17683
+ this.bufferCheckPosition = this.opt.MAX_BUFFER_LENGTH;
17684
+ this.looseCase = this.opt.lowercase ? "toLowerCase" : "toUpperCase";
17685
+ this.tags = [];
17686
+ this.closed = this.closedRoot = this.sawRoot = false;
17687
+ this.tag = this.error = null;
17688
+ this.strict = Boolean(this.opt.strict);
17689
+ this.noscript = Boolean(this.opt.strict || this.opt.noscript);
17690
+ this.state = this.S.BEGIN;
17691
+ this.strictEntities = this.opt.strictEntities;
17692
+ this.ENTITIES = this.strictEntities ? Object.create(this.XML_ENTITIES) : Object.create(this.ENTITIES);
17693
+ this.attribList = [];
17694
+ if (this.opt.xmlns) {
17695
+ this.ns = Object.create(this.rootNS);
17696
+ }
17697
+ this.trackPosition = this.opt.position !== false;
17698
+ if (this.trackPosition) {
17699
+ this.position = this.line = this.column = 0;
17700
+ }
17701
+ this.emit("onready");
17702
+ }
17703
+ resume() {
17704
+ this.error = null;
17705
+ return this;
17706
+ }
17707
+ close() {
17708
+ return this.write(null);
17709
+ }
17710
+ flush() {
17711
+ this.flushBuffers();
17712
+ }
17713
+ };
17714
+ }
17715
+ });
17716
+
17717
+ // ../documents/src/lib/parsers/parse-xml-internal.ts
17718
+ function setXMLField(object, name22, value) {
17719
+ Object.defineProperty(object, name22, {
17720
+ value,
17721
+ enumerable: true,
17722
+ configurable: true,
17723
+ writable: true
17724
+ });
17725
+ }
17726
+ function parseXMLInternal(text, options = {}) {
17727
+ if (options.strict !== false && /[^\u0009\u000a\u000d\u0020-\ud7ff\ue000-\ufffd\u{10000}-\u{10ffff}]/u.test(text)) {
17728
+ throw new Error("XML: invalid XML character");
17729
+ }
17730
+ const maximumDepth = options.maxDepth ?? 256;
17731
+ if (!Number.isSafeInteger(maximumDepth) || maximumDepth < 1 || maximumDepth > 4096) {
17732
+ throw new Error("XML: maxDepth must be an integer between 1 and 4096");
17733
+ }
17734
+ const state = new InternalXMLParserState(options, maximumDepth);
17735
+ const parser = new SAXParser({
17736
+ strict: options.strict !== false,
17737
+ strictEntities: !options.htmlEntities,
17738
+ preserveCase: true,
17739
+ caseInsensitiveTags: options.strict === false,
17740
+ processEntities: options.processEntities !== false,
17741
+ onopentag: (tag) => state.openElement(tag.name, tag.attributes || {}),
17742
+ ontext: (value) => state.addText(value),
17743
+ oncdata: (value) => state.addText(value),
17744
+ onscript: (value) => state.addText(value),
17745
+ onclosetag: () => state.closeElement(),
17746
+ onerror: (error) => {
17747
+ throw error;
17748
+ }
17749
+ });
17750
+ parser.write(text).close();
17751
+ if (options.strict === false) {
17752
+ while (state.stack.length) state.closeElement();
17753
+ }
17754
+ if (state.result === void 0) throw new Error("XML: document requires a root element");
17755
+ return state.result;
17756
+ }
17757
+ var InternalXMLParserState;
17758
+ var init_parse_xml_internal = __esm({
17759
+ "../documents/src/lib/parsers/parse-xml-internal.ts"() {
17760
+ "use strict";
17761
+ init_sax();
17762
+ InternalXMLParserState = class {
17763
+ /** Initializes conversion options and the element nesting budget. */
17764
+ constructor(options, maximumDepth) {
17765
+ this.options = options;
17766
+ this.maximumDepth = maximumDepth;
17767
+ }
17768
+ options;
17769
+ maximumDepth;
17770
+ /** Open element stack. */
17771
+ stack = [];
17772
+ /** Parsed root document. */
17773
+ result;
17774
+ /** Starts an element, rejecting multiple roots and excessive nesting. */
17775
+ openElement(name22, attributes) {
17776
+ if (this.stack.length >= this.maximumDepth)
17777
+ throw new Error("XML: maximum nesting depth exceeded");
17778
+ if (!this.stack.length && this.result !== void 0 && this.options.strict !== false) {
17779
+ throw new Error("XML: document requires a single root element");
17780
+ }
17781
+ const elementName = this.normalizeName(name22);
17782
+ const parent = this.stack[this.stack.length - 1];
17783
+ this.stack.push({
17784
+ name: elementName,
17785
+ path: parent ? `${parent.path}.${elementName}` : elementName,
17786
+ attributes: this.normalizeAttributes(attributes),
17787
+ children: {},
17788
+ orderedChildren: [],
17789
+ text: ""
17790
+ });
17791
+ }
17792
+ /** Accumulates text without losing whitespace between text and CDATA chunks. */
17793
+ addText(text) {
17794
+ const current = this.stack[this.stack.length - 1];
17795
+ if (current) current.text += text;
17796
+ }
17797
+ /** Finishes an element and attaches it to its parent or the document root. */
17798
+ closeElement() {
17799
+ const node = this.stack.pop();
17800
+ if (!node) return;
17801
+ const value = this.finalizeElement(node);
17802
+ const parent = this.stack[this.stack.length - 1];
17803
+ if (this.options.preserveOrder) {
17804
+ if (parent) parent.orderedChildren.push(value);
17805
+ else this.result = value;
17806
+ return;
17807
+ }
17808
+ if (parent) this.addChild(parent.children, node.name, node.path, value);
17809
+ else {
17810
+ if (this.result === void 0) this.result = {};
17811
+ this.addChild(this.result, node.name, node.path, value);
17812
+ }
17813
+ }
17814
+ /** Converts a completed element, keeping grouping and coercion independent. */
17815
+ finalizeElement(node) {
17816
+ const text = this.options.trimValues === false ? node.text : node.text.trim();
17817
+ if (this.options.preserveOrder) {
17818
+ return { name: node.name, attributes: node.attributes, children: node.orderedChildren, text };
17819
+ }
17820
+ const hasAttributes = Object.keys(node.attributes).length > 0;
17821
+ if (!hasAttributes && !Object.keys(node.children).length) {
17822
+ return this.parseValue(text, this.options.parseTagValue !== false);
17823
+ }
17824
+ const object = node.children;
17825
+ if (text)
17826
+ setXMLField(
17827
+ object,
17828
+ this.options.textNodeName ?? "value",
17829
+ this.parseValue(text, this.options.parseTagValue !== false)
17830
+ );
17831
+ if (hasAttributes && this.options.attributesGroupName) {
17832
+ setXMLField(object, this.options.attributesGroupName, node.attributes);
17833
+ } else {
17834
+ for (const [name22, value] of Object.entries(node.attributes)) setXMLField(object, name22, value);
17835
+ }
17836
+ return object;
17837
+ }
17838
+ /** Appends an element while preserving repeated and explicitly array-valued fields. */
17839
+ addChild(object, name22, path, value) {
17840
+ var _a;
17841
+ if (!Object.hasOwn(object, name22)) {
17842
+ setXMLField(object, name22, ((_a = this.options.arrayPaths) == null ? void 0 : _a.includes(path)) ? [value] : value);
17843
+ } else {
17844
+ const existing = object[name22];
17845
+ if (Array.isArray(existing)) existing.push(value);
17846
+ else setXMLField(object, name22, [existing, value]);
17847
+ }
17848
+ }
17849
+ /** Applies namespace, prefix, grouping and scalar options to attributes. */
17850
+ normalizeAttributes(attributes) {
17851
+ const normalized = {};
17852
+ if (this.options.ignoreAttributes) return normalized;
17853
+ for (const [name22, value] of Object.entries(attributes)) {
17854
+ if (this.options.removeNSPrefix && (name22 === "xmlns" || name22.startsWith("xmlns:"))) continue;
17855
+ const text = this.options.trimValues === false ? value : value.trim();
17856
+ setXMLField(
17857
+ normalized,
17858
+ (this.options.attributeNamePrefix ?? "") + this.normalizeName(name22),
17859
+ this.parseValue(text, this.options.parseAttributeValue === true)
17860
+ );
17861
+ }
17862
+ return normalized;
17863
+ }
17864
+ /** Removes a namespace prefix only when requested. */
17865
+ normalizeName(name22) {
17866
+ return this.options.removeNSPrefix ? name22.slice(name22.indexOf(":") + 1) : name22;
17867
+ }
17868
+ /** Coerces only finite numeric values and lowercase XML boolean literals. */
17869
+ parseValue(value, convert) {
17870
+ if (!convert) return value;
17871
+ if (value === "true" || value === "false") return value === "true";
17872
+ if (value !== "" && value.trim() !== "" && Number.isFinite(Number(value))) return Number(value);
17873
+ return value;
17874
+ }
17875
+ };
17876
+ }
17877
+ });
17878
+
17879
+ // ../documents/src/lib/parsers/parse-xml.ts
17880
+ function parseXMLSync(text, options = {}) {
17881
+ if (Object.hasOwn(options, "_fastXML") || Object.hasOwn(options, "_sax")) {
17882
+ throw new Error("XML: backend-specific options were removed; use native XML options");
17883
+ }
17884
+ if (options._parser && !["internal", "sax"].includes(options._parser)) {
17885
+ throw new Error("XML: unsupported parser backend; use the native documents parser");
17886
+ }
17887
+ const parsed = parseXMLInternal(text, options);
17888
+ return options.uncapitalizeKeys ? uncapitalizeKeys(parsed) : parsed;
17889
+ }
17890
+ var init_parse_xml = __esm({
17891
+ "../documents/src/lib/parsers/parse-xml.ts"() {
17892
+ "use strict";
17893
+ init_uncapitalize();
17894
+ init_parse_xml_internal();
17895
+ }
17896
+ });
17897
+
17898
+ // ../documents/src/xml-parser.ts
17899
+ var init_xml_parser = __esm({
17900
+ "../documents/src/xml-parser.ts"() {
17901
+ "use strict";
17902
+ init_parse_xml();
17903
+ }
17904
+ });
17905
+
17906
+ // ../scene/src/materialx/parse-materialx.ts
17907
+ function parseMaterialX(text) {
17908
+ if (/<!DOCTYPE|<!ENTITY/i.test(text)) {
17909
+ throw new Error("MaterialX: document types and entity declarations are unsupported.");
17910
+ }
17911
+ let element;
17912
+ try {
17913
+ element = parseXMLSync(text, {
17914
+ preserveOrder: true,
17915
+ parseAttributeValue: false,
17916
+ trimValues: false
17917
+ });
17918
+ } catch (error) {
17919
+ throw new Error("MaterialX: malformed XML.", { cause: error });
17920
+ }
17921
+ if (element.name !== "materialx") {
17922
+ throw new Error("MaterialX: expected a materialx root element.");
17923
+ }
17924
+ const version = element.attributes.version;
17925
+ if (!version || !/^1\.\d+$/.test(version)) {
17926
+ throw new Error("MaterialX: expected a MaterialX 1.x version.");
17927
+ }
17928
+ return { version, root: parseElement(element, 0) };
17929
+ }
17930
+ function parseElement(element, depth) {
17931
+ return {
17932
+ category: element.name,
17933
+ attributes: element.attributes,
17934
+ children: element.children.map((child) => parseElement(child, depth + 1))
17935
+ };
17936
+ }
17937
+ var init_parse_materialx = __esm({
17938
+ "../scene/src/materialx/parse-materialx.ts"() {
17939
+ "use strict";
17940
+ init_xml_parser();
17941
+ }
17942
+ });
17943
+
17944
+ // ../scene/src/materialx-loader.ts
17945
+ var materialx_loader_exports = {};
17946
+ __export(materialx_loader_exports, {
17947
+ MaterialXLoaderWithParser: () => MaterialXLoaderWithParser
17948
+ });
17949
+ var _preload, metadata, MaterialXLoaderWithParser;
17950
+ var init_materialx_loader = __esm({
17951
+ "../scene/src/materialx-loader.ts"() {
17952
+ "use strict";
17953
+ init_materialx_loader_types();
17954
+ init_parse_materialx();
17955
+ ({ preload: _preload, ...metadata } = MaterialXLoader);
17956
+ MaterialXLoaderWithParser = {
17957
+ ...metadata,
17958
+ parse: async (data) => parseMaterialX(new TextDecoder().decode(data)),
17959
+ parseSync: (data) => parseMaterialX(new TextDecoder().decode(data)),
17960
+ parseText: async (text) => parseMaterialX(text),
17961
+ parseTextSync: parseMaterialX
17962
+ };
17963
+ }
17964
+ });
17965
+
17966
+ // ../scene/src/materialx-loader-types.ts
17967
+ async function preload9() {
17968
+ const { MaterialXLoaderWithParser: MaterialXLoaderWithParser2 } = await Promise.resolve().then(() => (init_materialx_loader(), materialx_loader_exports));
17969
+ return MaterialXLoaderWithParser2;
17970
+ }
17971
+ var MaterialXLoader;
17972
+ var init_materialx_loader_types = __esm({
17973
+ "../scene/src/materialx-loader-types.ts"() {
17974
+ "use strict";
17975
+ MaterialXLoader = {
17976
+ name: "MaterialX",
17977
+ id: "materialx",
17978
+ module: "scene",
17979
+ version: "latest",
17980
+ extensions: ["mtlx"],
17981
+ mimeTypes: ["application/xml"],
17982
+ text: true,
17983
+ dataType: null,
17984
+ batchType: null,
17985
+ options: {},
17986
+ preload: preload9
17987
+ };
17988
+ }
17989
+ });
17990
+
15824
17991
  // ../scene/src/index.ts
15825
17992
  var src_exports = {};
15826
17993
  __export(src_exports, {
@@ -15838,6 +18005,7 @@ __export(src_exports, {
15838
18005
  MTLFormat: () => MTLFormat,
15839
18006
  MTLLoader: () => MTLLoader,
15840
18007
  MTLWorkerLoader: () => MTLWorkerLoader,
18008
+ MaterialXLoader: () => MaterialXLoader,
15841
18009
  OBJFormat: () => OBJFormat,
15842
18010
  OBJLoader: () => OBJLoader,
15843
18011
  OBJWorkerLoader: () => OBJWorkerLoader,
@@ -15861,6 +18029,7 @@ var init_src2 = __esm({
15861
18029
  init_draco_loader_types();
15862
18030
  init_draco_format();
15863
18031
  init_draco_libraries();
18032
+ init_materialx_loader_types();
15864
18033
  }
15865
18034
  });
15866
18035
 
@@ -15877,17 +18046,17 @@ module.exports = __toCommonJS(i3s_mesh_writer_exports);
15877
18046
  init_src();
15878
18047
  function prepareI3SMeshTexture(attribute, vertexCount, texture) {
15879
18048
  if (texture) {
15880
- if (!(texture.data instanceof Uint8Array) || Object.keys(texture).some((name20) => !["data", "mimeType", "sampler", "transform"].includes(name20)))
18049
+ if (!(texture.data instanceof Uint8Array) || Object.keys(texture).some((name22) => !["data", "mimeType", "sampler", "transform"].includes(name22)))
15881
18050
  throw new Error("Invalid I3S base-color texture");
15882
- let metadata;
18051
+ let metadata2;
15883
18052
  try {
15884
- metadata = getBinaryImageMetadata(new DataView(texture.data.buffer, texture.data.byteOffset, texture.data.byteLength));
18053
+ metadata2 = getBinaryImageMetadata(new DataView(texture.data.buffer, texture.data.byteOffset, texture.data.byteLength));
15885
18054
  } catch {
15886
18055
  }
15887
- if (!metadata || metadata.mimeType !== texture.mimeType || !["image/png", "image/jpeg"].includes(texture.mimeType) || metadata.width <= 0 || metadata.height <= 0)
18056
+ if (!metadata2 || metadata2.mimeType !== texture.mimeType || !["image/png", "image/jpeg"].includes(texture.mimeType) || metadata2.width <= 0 || metadata2.height <= 0)
15888
18057
  throw new Error("I3S texture header must match a PNG/JPEG mimeType and positive dimensions");
15889
18058
  const sampler = texture.sampler;
15890
- if (sampler && (Object.keys(sampler).some((name20) => !["wrapS", "wrapT", "magFilter", "minFilter"].includes(name20)) || sampler.magFilter !== void 0 || sampler.minFilter !== void 0 || [sampler.wrapS, sampler.wrapT].some((value) => value !== void 0 && ![33071, 33648, 10497].includes(value))))
18059
+ if (sampler && (Object.keys(sampler).some((name22) => !["wrapS", "wrapT", "magFilter", "minFilter"].includes(name22)) || sampler.magFilter !== void 0 || sampler.minFilter !== void 0 || [sampler.wrapS, sampler.wrapT].some((value) => value !== void 0 && ![33071, 33648, 10497].includes(value))))
15891
18060
  throw new Error("I3S texture profile supports wrapping, but not explicit filtering");
15892
18061
  }
15893
18062
  if (!attribute) {
@@ -15900,7 +18069,7 @@ function prepareI3SMeshTexture(attribute, vertexCount, texture) {
15900
18069
  if (attribute.size !== 2 || values.length !== vertexCount * 2 || !(values instanceof Float32Array || normalized) || attribute.normalized && !normalized || attribute.byteOffset || attribute.byteStride || attribute.transform || attribute.componentType || values.some((value) => !Number.isFinite(value)))
15901
18070
  throw new Error("I3S TEXCOORD_0 requires finite packed Float32 or normalized unsigned UV pairs");
15902
18071
  const transform = texture == null ? void 0 : texture.transform;
15903
- if (transform && Object.keys(transform).some((name20) => !["offset", "rotation", "scale"].includes(name20)))
18072
+ if (transform && Object.keys(transform).some((name22) => !["offset", "rotation", "scale"].includes(name22)))
15904
18073
  throw new Error("Unsupported I3S texture transform");
15905
18074
  const offset = (transform == null ? void 0 : transform.offset) || [0, 0];
15906
18075
  const scale = (transform == null ? void 0 : transform.scale) || [1, 1];
@@ -15976,11 +18145,11 @@ var CompressUtilsCompressor = class extends Compressor {
15976
18145
  /** Shared import and WASM initialization for concurrent callers. */
15977
18146
  modulePromise = null;
15978
18147
  /** Creates a format-specific compress-utils encoder. */
15979
- constructor(metadata, loadModule, options = {}) {
18148
+ constructor(metadata2, loadModule, options = {}) {
15980
18149
  super(options);
15981
- this.name = metadata.name;
15982
- this.extensions = metadata.extensions || [];
15983
- this.contentEncodings = metadata.contentEncodings || [];
18150
+ this.name = metadata2.name;
18151
+ this.extensions = metadata2.extensions || [];
18152
+ this.contentEncodings = metadata2.contentEncodings || [];
15984
18153
  this.loadModule = loadModule;
15985
18154
  this.options = options;
15986
18155
  }
@@ -16292,10 +18461,10 @@ function encodeNumericValues(values, type, maxBytes) {
16292
18461
  }
16293
18462
  return output;
16294
18463
  }
16295
- function makeStorage(key, name20, valueType) {
18464
+ function makeStorage(key, name22, valueType) {
16296
18465
  return {
16297
18466
  key,
16298
- name: name20,
18467
+ name: name22,
16299
18468
  header: [
16300
18469
  { property: "count", valueType: "UInt32" },
16301
18470
  ...valueType === "String" ? [{ property: "attributeValuesByteCount", valueType: "UInt32" }] : []
@@ -16403,9 +18572,9 @@ function prepareMeshLayer(mesh, options, geometryEncoding = "raw") {
16403
18572
  if (mesh.topology !== "triangle-list" || mesh.mode !== 4 || !positions || positions.size !== 3 || !(positions.value instanceof Float32Array || positions.value instanceof Float64Array) || positions.value.length === 0 || positions.value.length % 3 || positions.value.some((value) => !Number.isFinite(value))) {
16404
18573
  throw new Error("I3S mesh writing requires finite packed triangle positions");
16405
18574
  }
16406
- for (const [name20, attribute] of Object.entries(mesh.attributes)) {
16407
- if (!["POSITION", "NORMAL", "TEXCOORD_0"].includes(name20) || attribute.byteOffset || attribute.byteStride || attribute.normalized && name20 !== "TEXCOORD_0" || attribute.transform || attribute.componentType) {
16408
- throw new Error(`Unsupported I3S mesh attribute/layout: ${name20}`);
18575
+ for (const [name22, attribute] of Object.entries(mesh.attributes)) {
18576
+ if (!["POSITION", "NORMAL", "TEXCOORD_0"].includes(name22) || attribute.byteOffset || attribute.byteStride || attribute.normalized && name22 !== "TEXCOORD_0" || attribute.transform || attribute.componentType) {
18577
+ throw new Error(`Unsupported I3S mesh attribute/layout: ${name22}`);
16409
18578
  }
16410
18579
  }
16411
18580
  const normals = mesh.attributes.NORMAL;
@@ -16631,7 +18800,7 @@ function prepareMeshLayer(mesh, options, geometryEncoding = "raw") {
16631
18800
  ]
16632
18801
  };
16633
18802
  const rawFiles = { "nodes/1/geometries/0.bin.gz": geometry };
16634
- for (const [name20, json] of Object.entries({
18803
+ for (const [name22, json] of Object.entries({
16635
18804
  "3dSceneLayer.json.gz": layer,
16636
18805
  "nodes/root/3dNodeIndexDocument.json.gz": root,
16637
18806
  "nodes/1/3dNodeIndexDocument.json.gz": leaf,
@@ -16644,7 +18813,7 @@ function prepareMeshLayer(mesh, options, geometryEncoding = "raw") {
16644
18813
  nodeCount: 2
16645
18814
  }
16646
18815
  })) {
16647
- rawFiles[name20] = new TextEncoder().encode(JSON.stringify(json)).buffer;
18816
+ rawFiles[name22] = new TextEncoder().encode(JSON.stringify(json)).buffer;
16648
18817
  }
16649
18818
  const objectIds = options.features ? attributes.buffers[0].slice(0) : encodeDefaultObjectId();
16650
18819
  const objectIdView = new DataView(objectIds);
@@ -16666,10 +18835,10 @@ function prepareMeshLayer(mesh, options, geometryEncoding = "raw") {
16666
18835
  function compressMeshLayer(prepared, maxResourceBytes) {
16667
18836
  const compressor = MESH_GZIP_COMPRESSOR;
16668
18837
  const files = {};
16669
- for (const [name20, bytes] of Object.entries(prepared.files)) {
18838
+ for (const [name22, bytes] of Object.entries(prepared.files)) {
16670
18839
  if (bytes.byteLength > maxResourceBytes)
16671
18840
  throw new Error("I3S resource exceeds maxResourceBytes");
16672
- files[name20] = name20.endsWith(".gz") ? compressor.compressSync(bytes) : bytes;
18841
+ files[name22] = name22.endsWith(".gz") ? compressor.compressSync(bytes) : bytes;
16673
18842
  }
16674
18843
  return { ...prepared, files };
16675
18844
  }
@@ -16682,8 +18851,8 @@ function getMeshTriangles(attributes, indices) {
16682
18851
  ];
16683
18852
  const triangles = [];
16684
18853
  for (let index = 0; index < indices.length; index += 3) {
16685
- const vertices = [0, 1, 2].map((corner) => names.map((name20) => {
16686
- const attribute = attributes[name20];
18854
+ const vertices = [0, 1, 2].map((corner) => names.map((name22) => {
18855
+ const attribute = attributes[name22];
16687
18856
  return Array.from({ length: attribute.size }, (_, component) => attribute.value[indices[index + corner] * attribute.size + component]).join(",");
16688
18857
  }).join("|"));
16689
18858
  triangles.push([0, 1, 2].map((corner) => [...vertices.slice(corner), ...vertices.slice(0, corner)].join(";")).sort()[0]);
@@ -16697,7 +18866,7 @@ function encodeDefaultObjectId() {
16697
18866
  }
16698
18867
  function encodeMaterial(material = {}) {
16699
18868
  var _a, _b;
16700
- if (Object.keys(material).some((name20) => ![
18869
+ if (Object.keys(material).some((name22) => ![
16701
18870
  "baseColorFactor",
16702
18871
  "baseColorTexture",
16703
18872
  "metallicFactor",
@@ -16705,7 +18874,7 @@ function encodeMaterial(material = {}) {
16705
18874
  "alphaMode",
16706
18875
  "alphaCutoff",
16707
18876
  "doubleSided"
16708
- ].includes(name20)))
18877
+ ].includes(name22)))
16709
18878
  throw new Error("Unsupported I3S material property");
16710
18879
  const { baseColorFactor, metallicFactor, roughnessFactor, alphaMode, alphaCutoff, doubleSided } = material;
16711
18880
  if (baseColorFactor !== void 0 && (baseColorFactor.length !== 4 || baseColorFactor.some((value) => !Number.isFinite(value) || value < 0 || value > 1)) || [metallicFactor, roughnessFactor].some((value) => value !== void 0 && (!Number.isFinite(value) || value < 0 || value > 1)) || alphaMode !== void 0 && !["OPAQUE", "MASK", "BLEND"].includes(alphaMode) || alphaCutoff !== void 0 && (alphaMode !== "MASK" || !Number.isFinite(alphaCutoff) || alphaCutoff < 0) || doubleSided !== void 0 && typeof doubleSided !== "boolean")