@loaders.gl/tile-converter 4.0.0-alpha.6 → 4.0.0-alpha.7

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 (77) hide show
  1. package/bin/converter.js +1 -1
  2. package/dist/3d-tiles-attributes-worker.js +2 -2
  3. package/dist/3d-tiles-attributes-worker.js.map +3 -3
  4. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  5. package/dist/3d-tiles-converter/3d-tiles-converter.js +4 -3
  6. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +0 -8
  7. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
  8. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +2 -15
  9. package/dist/converter.min.js +75 -76
  10. package/dist/deps-installer/deps-installer.js +3 -3
  11. package/dist/dist.min.js +1870 -1581
  12. package/dist/es5/3d-tiles-attributes-worker.js +1 -1
  13. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +0 -3
  14. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  15. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +2 -10
  16. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  17. package/dist/es5/deps-installer/deps-installer.js +4 -4
  18. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  19. package/dist/es5/i3s-attributes-worker.js +1 -1
  20. package/dist/es5/i3s-attributes-worker.js.map +1 -1
  21. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +2 -2
  22. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  23. package/dist/es5/i3s-converter/helpers/geometry-converter.js +25 -17
  24. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  25. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +1 -4
  26. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  27. package/dist/es5/i3s-converter/i3s-converter.js +0 -7
  28. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  29. package/dist/es5/lib/utils/geometry-utils.js +15 -0
  30. package/dist/es5/lib/utils/geometry-utils.js.map +1 -0
  31. package/dist/es5/pgm-loader.js +1 -1
  32. package/dist/esm/3d-tiles-attributes-worker.js +1 -1
  33. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +0 -3
  34. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  35. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +2 -8
  36. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  37. package/dist/esm/deps-installer/deps-installer.js +4 -4
  38. package/dist/esm/deps-installer/deps-installer.js.map +1 -1
  39. package/dist/esm/i3s-attributes-worker.js +1 -1
  40. package/dist/esm/i3s-attributes-worker.js.map +1 -1
  41. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +2 -2
  42. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  43. package/dist/esm/i3s-converter/helpers/geometry-converter.js +19 -11
  44. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  45. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +1 -4
  46. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  47. package/dist/esm/i3s-converter/i3s-converter.js +0 -7
  48. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  49. package/dist/esm/lib/utils/geometry-utils.js +8 -0
  50. package/dist/esm/lib/utils/geometry-utils.js.map +1 -0
  51. package/dist/esm/pgm-loader.js +1 -1
  52. package/dist/i3s-attributes-worker.d.ts +10 -2
  53. package/dist/i3s-attributes-worker.d.ts.map +1 -1
  54. package/dist/i3s-attributes-worker.js +2 -2
  55. package/dist/i3s-attributes-worker.js.map +3 -3
  56. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +4 -2
  57. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
  58. package/dist/i3s-converter/helpers/batch-ids-extensions.js +2 -2
  59. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  60. package/dist/i3s-converter/helpers/geometry-converter.js +51 -43
  61. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  62. package/dist/i3s-converter/helpers/gltf-attributes.js +1 -4
  63. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  64. package/dist/i3s-converter/i3s-converter.js +7 -6
  65. package/dist/lib/utils/geometry-utils.d.ts +9 -0
  66. package/dist/lib/utils/geometry-utils.d.ts.map +1 -0
  67. package/dist/lib/utils/geometry-utils.js +18 -0
  68. package/package.json +15 -16
  69. package/src/3d-tiles-converter/3d-tiles-converter.ts +4 -3
  70. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +2 -16
  71. package/src/deps-installer/deps-installer.ts +3 -3
  72. package/src/i3s-attributes-worker.ts +11 -2
  73. package/src/i3s-converter/helpers/batch-ids-extensions.ts +13 -14
  74. package/src/i3s-converter/helpers/geometry-converter.ts +105 -78
  75. package/src/i3s-converter/helpers/gltf-attributes.ts +1 -4
  76. package/src/i3s-converter/i3s-converter.ts +8 -7
  77. package/src/lib/utils/geometry-utils.ts +14 -0
package/dist/dist.min.js CHANGED
@@ -9363,7 +9363,7 @@ var require_perspective_frustum = __commonJS({
9363
9363
  var _defineProperty2 = _interopRequireDefault(require_defineProperty());
9364
9364
  var _core = require_es5();
9365
9365
  var _perspectiveOffCenterFrustum = _interopRequireDefault(require_perspective_off_center_frustum());
9366
- var defined6 = function defined7(val) {
9366
+ var defined5 = function defined6(val) {
9367
9367
  return val !== null && typeof val !== "undefined";
9368
9368
  };
9369
9369
  var PerspectiveFrustum = function() {
@@ -9406,7 +9406,7 @@ var require_perspective_frustum = __commonJS({
9406
9406
  }, {
9407
9407
  key: "equals",
9408
9408
  value: function equals2(other) {
9409
- if (!defined6(other) || !(other instanceof PerspectiveFrustum2)) {
9409
+ if (!defined5(other) || !(other instanceof PerspectiveFrustum2)) {
9410
9410
  return false;
9411
9411
  }
9412
9412
  this._update();
@@ -46874,7 +46874,7 @@ var WorkerPool = class {
46874
46874
  }
46875
46875
  }
46876
46876
  returnWorkerToQueue(worker) {
46877
- const shouldDestroyWorker = this.isDestroyed || !this.reuseWorkers || this.count > this._getMaxConcurrency();
46877
+ const shouldDestroyWorker = !isBrowser2 || this.isDestroyed || !this.reuseWorkers || this.count > this._getMaxConcurrency();
46878
46878
  if (shouldDestroyWorker) {
46879
46879
  worker.destroy();
46880
46880
  this.count--;
@@ -46969,7 +46969,7 @@ function getWorkerName(worker) {
46969
46969
  }
46970
46970
  function getWorkerURL(worker, options = {}) {
46971
46971
  const workerOptions = options[worker.id] || {};
46972
- const workerFile = `${worker.id}-worker.js`;
46972
+ const workerFile = isBrowser2 ? `${worker.id}-worker.js` : `${worker.id}-worker-node.js`;
46973
46973
  let url = workerOptions.workerUrl;
46974
46974
  if (!url && worker.id === "compression") {
46975
46975
  url = options.workerUrl;
@@ -47485,7 +47485,7 @@ function _defineProperty(obj, key, value) {
47485
47485
  return obj;
47486
47486
  }
47487
47487
 
47488
- // ../../node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js
47488
+ // ../loader-utils/node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js
47489
47489
  function getHiResTimestamp() {
47490
47490
  let timestamp;
47491
47491
  if (typeof window !== "undefined" && window.performance) {
@@ -47499,7 +47499,7 @@ function getHiResTimestamp() {
47499
47499
  return timestamp;
47500
47500
  }
47501
47501
 
47502
- // ../../node_modules/@probe.gl/stats/dist/lib/stat.js
47502
+ // ../loader-utils/node_modules/@probe.gl/stats/dist/lib/stat.js
47503
47503
  var Stat = class {
47504
47504
  constructor(name10, type) {
47505
47505
  _defineProperty(this, "name", void 0);
@@ -47611,7 +47611,7 @@ var Stat = class {
47611
47611
  }
47612
47612
  };
47613
47613
 
47614
- // ../../node_modules/@probe.gl/stats/dist/lib/stats.js
47614
+ // ../loader-utils/node_modules/@probe.gl/stats/dist/lib/stats.js
47615
47615
  var Stats = class {
47616
47616
  constructor(options) {
47617
47617
  _defineProperty(this, "id", void 0);
@@ -48098,40 +48098,55 @@ function parseMIMETypeFromURL(url) {
48098
48098
  return "";
48099
48099
  }
48100
48100
 
48101
- // ../core/src/lib/utils/resource-utils.ts
48101
+ // ../core/src/lib/utils/url-utils.ts
48102
48102
  var QUERY_STRING_PATTERN = /\?.*/;
48103
- function getResourceUrlAndType(resource) {
48103
+ function extractQueryString(url) {
48104
+ const matches3 = url.match(QUERY_STRING_PATTERN);
48105
+ return matches3 && matches3[0];
48106
+ }
48107
+ function stripQueryString(url) {
48108
+ return url.replace(QUERY_STRING_PATTERN, "");
48109
+ }
48110
+
48111
+ // ../core/src/lib/utils/resource-utils.ts
48112
+ function getResourceUrl(resource) {
48104
48113
  if (isResponse(resource)) {
48105
- const url = stripQueryString(resource.url || "");
48106
- const contentTypeHeader = resource.headers.get("content-type") || "";
48107
- return {
48108
- url,
48109
- type: parseMIMEType(contentTypeHeader) || parseMIMETypeFromURL(url)
48110
- };
48114
+ const response = resource;
48115
+ return response.url;
48111
48116
  }
48112
48117
  if (isBlob(resource)) {
48113
- return {
48114
- url: stripQueryString(resource.name || ""),
48115
- type: resource.type || ""
48116
- };
48118
+ const blob = resource;
48119
+ return blob.name || "";
48117
48120
  }
48118
48121
  if (typeof resource === "string") {
48119
- return {
48120
- url: stripQueryString(resource),
48121
- type: parseMIMETypeFromURL(resource)
48122
- };
48122
+ return resource;
48123
48123
  }
48124
- return {
48125
- url: "",
48126
- type: ""
48127
- };
48124
+ return "";
48125
+ }
48126
+ function getResourceMIMEType(resource) {
48127
+ if (isResponse(resource)) {
48128
+ const response = resource;
48129
+ const contentTypeHeader = response.headers.get("content-type") || "";
48130
+ const noQueryUrl = stripQueryString(response.url);
48131
+ return parseMIMEType(contentTypeHeader) || parseMIMETypeFromURL(noQueryUrl);
48132
+ }
48133
+ if (isBlob(resource)) {
48134
+ const blob = resource;
48135
+ return blob.type || "";
48136
+ }
48137
+ if (typeof resource === "string") {
48138
+ return parseMIMETypeFromURL(resource);
48139
+ }
48140
+ return "";
48128
48141
  }
48129
48142
  function getResourceContentLength(resource) {
48130
48143
  if (isResponse(resource)) {
48131
- return resource.headers["content-length"] || -1;
48144
+ const response = resource;
48145
+ return response.headers["content-length"] || -1;
48132
48146
  }
48133
48147
  if (isBlob(resource)) {
48134
- return resource.size;
48148
+ const blob = resource;
48149
+ return blob.size;
48135
48150
  }
48136
48151
  if (typeof resource === "string") {
48137
48152
  return resource.length;
@@ -48144,9 +48159,6 @@ function getResourceContentLength(resource) {
48144
48159
  }
48145
48160
  return -1;
48146
48161
  }
48147
- function stripQueryString(url) {
48148
- return url.replace(QUERY_STRING_PATTERN, "");
48149
- }
48150
48162
 
48151
48163
  // ../core/src/lib/utils/response-utils.ts
48152
48164
  async function makeResponse(resource) {
@@ -48158,7 +48170,8 @@ async function makeResponse(resource) {
48158
48170
  if (contentLength >= 0) {
48159
48171
  headers["content-length"] = String(contentLength);
48160
48172
  }
48161
- const { url, type } = getResourceUrlAndType(resource);
48173
+ const url = getResourceUrl(resource);
48174
+ const type = getResourceMIMEType(resource);
48162
48175
  if (type) {
48163
48176
  headers["content-type"] = type;
48164
48177
  }
@@ -48244,7 +48257,7 @@ async function writeFile2(filePath, arrayBufferOrString, options) {
48244
48257
  assert2(false);
48245
48258
  }
48246
48259
 
48247
- // ../../node_modules/@probe.gl/env/dist/lib/is-electron.js
48260
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-electron.js
48248
48261
  function isElectron(mockUserAgent) {
48249
48262
  if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
48250
48263
  return true;
@@ -48260,13 +48273,13 @@ function isElectron(mockUserAgent) {
48260
48273
  return false;
48261
48274
  }
48262
48275
 
48263
- // ../../node_modules/@probe.gl/env/dist/lib/is-browser.js
48276
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-browser.js
48264
48277
  function isBrowser3() {
48265
48278
  const isNode = typeof process === "object" && String(process) === "[object process]" && !process.browser;
48266
48279
  return !isNode || isElectron();
48267
48280
  }
48268
48281
 
48269
- // ../../node_modules/@probe.gl/env/dist/lib/globals.js
48282
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/globals.js
48270
48283
  var self_3 = globalThis.self || globalThis.window || globalThis.global;
48271
48284
  var window_3 = globalThis.window || globalThis.self || globalThis.global;
48272
48285
  var document_3 = globalThis.document || {};
@@ -48274,7 +48287,7 @@ var process_ = globalThis.process || {};
48274
48287
  var console_ = globalThis.console;
48275
48288
  var navigator_ = globalThis.navigator || {};
48276
48289
 
48277
- // ../../node_modules/@probe.gl/env/dist/utils/globals.js
48290
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/utils/globals.js
48278
48291
  var VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
48279
48292
  var isBrowser4 = isBrowser3();
48280
48293
 
@@ -49027,8 +49040,9 @@ function selectLoaderSync(data, loaders = [], options, context) {
49027
49040
  return loader;
49028
49041
  }
49029
49042
  function selectLoaderInternal(data, loaders, options, context) {
49030
- const { url, type } = getResourceUrlAndType(data);
49031
- const testUrl = url || context?.url;
49043
+ const url = getResourceUrl(data);
49044
+ const type = getResourceMIMEType(data);
49045
+ const testUrl = stripQueryString(url) || context?.url;
49032
49046
  let loader = null;
49033
49047
  let reason = "";
49034
49048
  if (options?.mimeType) {
@@ -49057,7 +49071,8 @@ function validHTTPResponse(data) {
49057
49071
  return true;
49058
49072
  }
49059
49073
  function getNoValidLoaderMessage(data) {
49060
- const { url, type } = getResourceUrlAndType(data);
49074
+ const url = getResourceUrl(data);
49075
+ const type = getResourceMIMEType(data);
49061
49076
  let message = "No valid loader found (";
49062
49077
  message += url ? `${path_exports.filename(url)}, ` : "no url provided, ";
49063
49078
  message += `MIME type: ${type ? `"${type}"` : "not provided"}, `;
@@ -49331,18 +49346,25 @@ function getFetchFunction(options, context) {
49331
49346
  }
49332
49347
 
49333
49348
  // ../core/src/lib/loader-utils/loader-context.ts
49334
- function getLoaderContext(context, options, previousContext = null) {
49335
- if (previousContext) {
49336
- return previousContext;
49349
+ function getLoaderContext(context, options, parentContext) {
49350
+ if (parentContext) {
49351
+ return parentContext;
49337
49352
  }
49338
- const resolvedContext = {
49353
+ const newContext = {
49339
49354
  fetch: getFetchFunction(options, context),
49340
49355
  ...context
49341
49356
  };
49342
- if (!Array.isArray(resolvedContext.loaders)) {
49343
- resolvedContext.loaders = null;
49357
+ if (newContext.url) {
49358
+ const baseUrl = stripQueryString(newContext.url);
49359
+ newContext.baseUrl = baseUrl;
49360
+ newContext.queryString = extractQueryString(newContext.url);
49361
+ newContext.filename = path_exports.filename(baseUrl);
49362
+ newContext.baseUrl = path_exports.dirname(baseUrl);
49363
+ }
49364
+ if (!Array.isArray(newContext.loaders)) {
49365
+ newContext.loaders = null;
49344
49366
  }
49345
- return resolvedContext;
49367
+ return newContext;
49346
49368
  }
49347
49369
  function getLoadersFromContext(loaders, context) {
49348
49370
  if (!context && loaders && !Array.isArray(loaders)) {
@@ -49369,7 +49391,7 @@ async function parse(data, loaders, options, context) {
49369
49391
  }
49370
49392
  data = await data;
49371
49393
  options = options || {};
49372
- const { url } = getResourceUrlAndType(data);
49394
+ const url = getResourceUrl(data);
49373
49395
  const typedLoaders = loaders;
49374
49396
  const candidateLoaders = getLoadersFromContext(typedLoaders, context);
49375
49397
  const loader = await selectLoader(data, candidateLoaders, options);
@@ -49377,7 +49399,7 @@ async function parse(data, loaders, options, context) {
49377
49399
  return null;
49378
49400
  }
49379
49401
  options = normalizeOptions(options, loader, candidateLoaders, url);
49380
- context = getLoaderContext({ url, parse, loaders: candidateLoaders }, options, context);
49402
+ context = getLoaderContext({ url, parse, loaders: candidateLoaders }, options, context || null);
49381
49403
  return await parseWithLoader(loader, data, options, context);
49382
49404
  }
49383
49405
  async function parseWithLoader(loader, data, options, context) {
@@ -49491,6 +49513,197 @@ function getTemporaryFilename(filename2) {
49491
49513
  var import_core10 = __toModule(require_es5());
49492
49514
  var import_geospatial6 = __toModule(require_es52());
49493
49515
 
49516
+ // ../tiles/node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js
49517
+ function getHiResTimestamp3() {
49518
+ let timestamp;
49519
+ if (typeof window !== "undefined" && window.performance) {
49520
+ timestamp = window.performance.now();
49521
+ } else if (typeof process !== "undefined" && process.hrtime) {
49522
+ const timeParts = process.hrtime();
49523
+ timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
49524
+ } else {
49525
+ timestamp = Date.now();
49526
+ }
49527
+ return timestamp;
49528
+ }
49529
+
49530
+ // ../tiles/node_modules/@probe.gl/stats/dist/lib/stat.js
49531
+ var Stat2 = class {
49532
+ constructor(name10, type) {
49533
+ _defineProperty(this, "name", void 0);
49534
+ _defineProperty(this, "type", void 0);
49535
+ _defineProperty(this, "sampleSize", 1);
49536
+ _defineProperty(this, "time", 0);
49537
+ _defineProperty(this, "count", 0);
49538
+ _defineProperty(this, "samples", 0);
49539
+ _defineProperty(this, "lastTiming", 0);
49540
+ _defineProperty(this, "lastSampleTime", 0);
49541
+ _defineProperty(this, "lastSampleCount", 0);
49542
+ _defineProperty(this, "_count", 0);
49543
+ _defineProperty(this, "_time", 0);
49544
+ _defineProperty(this, "_samples", 0);
49545
+ _defineProperty(this, "_startTime", 0);
49546
+ _defineProperty(this, "_timerPending", false);
49547
+ this.name = name10;
49548
+ this.type = type;
49549
+ this.reset();
49550
+ }
49551
+ reset() {
49552
+ this.time = 0;
49553
+ this.count = 0;
49554
+ this.samples = 0;
49555
+ this.lastTiming = 0;
49556
+ this.lastSampleTime = 0;
49557
+ this.lastSampleCount = 0;
49558
+ this._count = 0;
49559
+ this._time = 0;
49560
+ this._samples = 0;
49561
+ this._startTime = 0;
49562
+ this._timerPending = false;
49563
+ return this;
49564
+ }
49565
+ setSampleSize(samples) {
49566
+ this.sampleSize = samples;
49567
+ return this;
49568
+ }
49569
+ incrementCount() {
49570
+ this.addCount(1);
49571
+ return this;
49572
+ }
49573
+ decrementCount() {
49574
+ this.subtractCount(1);
49575
+ return this;
49576
+ }
49577
+ addCount(value) {
49578
+ this._count += value;
49579
+ this._samples++;
49580
+ this._checkSampling();
49581
+ return this;
49582
+ }
49583
+ subtractCount(value) {
49584
+ this._count -= value;
49585
+ this._samples++;
49586
+ this._checkSampling();
49587
+ return this;
49588
+ }
49589
+ addTime(time) {
49590
+ this._time += time;
49591
+ this.lastTiming = time;
49592
+ this._samples++;
49593
+ this._checkSampling();
49594
+ return this;
49595
+ }
49596
+ timeStart() {
49597
+ this._startTime = getHiResTimestamp3();
49598
+ this._timerPending = true;
49599
+ return this;
49600
+ }
49601
+ timeEnd() {
49602
+ if (!this._timerPending) {
49603
+ return this;
49604
+ }
49605
+ this.addTime(getHiResTimestamp3() - this._startTime);
49606
+ this._timerPending = false;
49607
+ this._checkSampling();
49608
+ return this;
49609
+ }
49610
+ getSampleAverageCount() {
49611
+ return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0;
49612
+ }
49613
+ getSampleAverageTime() {
49614
+ return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0;
49615
+ }
49616
+ getSampleHz() {
49617
+ return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1e3) : 0;
49618
+ }
49619
+ getAverageCount() {
49620
+ return this.samples > 0 ? this.count / this.samples : 0;
49621
+ }
49622
+ getAverageTime() {
49623
+ return this.samples > 0 ? this.time / this.samples : 0;
49624
+ }
49625
+ getHz() {
49626
+ return this.time > 0 ? this.samples / (this.time / 1e3) : 0;
49627
+ }
49628
+ _checkSampling() {
49629
+ if (this._samples === this.sampleSize) {
49630
+ this.lastSampleTime = this._time;
49631
+ this.lastSampleCount = this._count;
49632
+ this.count += this._count;
49633
+ this.time += this._time;
49634
+ this.samples += this._samples;
49635
+ this._time = 0;
49636
+ this._count = 0;
49637
+ this._samples = 0;
49638
+ }
49639
+ }
49640
+ };
49641
+
49642
+ // ../tiles/node_modules/@probe.gl/stats/dist/lib/stats.js
49643
+ var Stats2 = class {
49644
+ constructor(options) {
49645
+ _defineProperty(this, "id", void 0);
49646
+ _defineProperty(this, "stats", {});
49647
+ this.id = options.id;
49648
+ this.stats = {};
49649
+ this._initializeStats(options.stats);
49650
+ Object.seal(this);
49651
+ }
49652
+ get(name10) {
49653
+ let type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "count";
49654
+ return this._getOrCreate({
49655
+ name: name10,
49656
+ type
49657
+ });
49658
+ }
49659
+ get size() {
49660
+ return Object.keys(this.stats).length;
49661
+ }
49662
+ reset() {
49663
+ for (const stat2 of Object.values(this.stats)) {
49664
+ stat2.reset();
49665
+ }
49666
+ return this;
49667
+ }
49668
+ forEach(fn) {
49669
+ for (const stat2 of Object.values(this.stats)) {
49670
+ fn(stat2);
49671
+ }
49672
+ }
49673
+ getTable() {
49674
+ const table = {};
49675
+ this.forEach((stat2) => {
49676
+ table[stat2.name] = {
49677
+ time: stat2.time || 0,
49678
+ count: stat2.count || 0,
49679
+ average: stat2.getAverageTime() || 0,
49680
+ hz: stat2.getHz() || 0
49681
+ };
49682
+ });
49683
+ return table;
49684
+ }
49685
+ _initializeStats() {
49686
+ let stats = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
49687
+ stats.forEach((stat2) => this._getOrCreate(stat2));
49688
+ }
49689
+ _getOrCreate(stat2) {
49690
+ const {
49691
+ name: name10,
49692
+ type
49693
+ } = stat2;
49694
+ let result = this.stats[name10];
49695
+ if (!result) {
49696
+ if (stat2 instanceof Stat2) {
49697
+ result = stat2;
49698
+ } else {
49699
+ result = new Stat2(name10, type);
49700
+ }
49701
+ this.stats[name10] = result;
49702
+ }
49703
+ return result;
49704
+ }
49705
+ };
49706
+
49494
49707
  // ../tiles/src/utils/doubly-linked-list-node.ts
49495
49708
  var DoublyLinkedListNode = class {
49496
49709
  constructor(item, previous, next) {
@@ -49565,9 +49778,6 @@ var DoublyLinkedList = class {
49565
49778
  };
49566
49779
 
49567
49780
  // ../tiles/src/tileset/tileset-cache.ts
49568
- function defined(x) {
49569
- return x !== void 0 && x !== null;
49570
- }
49571
49781
  var TilesetCache = class {
49572
49782
  constructor() {
49573
49783
  this._list = new DoublyLinkedList();
@@ -49579,12 +49789,12 @@ var TilesetCache = class {
49579
49789
  }
49580
49790
  touch(tile) {
49581
49791
  const node2 = tile._cacheNode;
49582
- if (defined(node2)) {
49792
+ if (node2) {
49583
49793
  this._list.splice(this._sentinel, node2);
49584
49794
  }
49585
49795
  }
49586
49796
  add(tileset, tile, addCallback) {
49587
- if (!defined(tile._cacheNode)) {
49797
+ if (!tile._cacheNode) {
49588
49798
  tile._cacheNode = this._list.add(tile);
49589
49799
  if (addCallback) {
49590
49800
  addCallback(tileset, tile);
@@ -49593,11 +49803,11 @@ var TilesetCache = class {
49593
49803
  }
49594
49804
  unloadTile(tileset, tile, unloadCallback) {
49595
49805
  const node2 = tile._cacheNode;
49596
- if (!defined(node2)) {
49806
+ if (!node2) {
49597
49807
  return;
49598
49808
  }
49599
49809
  this._list.remove(node2);
49600
- tile._cacheNode = void 0;
49810
+ tile._cacheNode = null;
49601
49811
  if (unloadCallback) {
49602
49812
  unloadCallback(tileset, tile);
49603
49813
  }
@@ -49848,7 +50058,7 @@ var TILE3D_OPTIMIZATION_HINT = {
49848
50058
  var import_core4 = __toModule(require_es5());
49849
50059
  var import_culling3 = __toModule(require_es53());
49850
50060
  var import_geospatial4 = __toModule(require_es52());
49851
- function defined2(x) {
50061
+ function defined(x) {
49852
50062
  return x !== void 0 && x !== null;
49853
50063
  }
49854
50064
  var scratchPoint = new import_core4.Vector3();
@@ -49924,7 +50134,7 @@ function createBox(box, transform11, result) {
49924
50134
  zAxis[1],
49925
50135
  zAxis[2]
49926
50136
  ]);
49927
- if (defined2(result)) {
50137
+ if (defined(result)) {
49928
50138
  result.center = center;
49929
50139
  result.halfAxes = halfAxes;
49930
50140
  return result;
@@ -49937,7 +50147,7 @@ function createSphere(sphere, transform11, result) {
49937
50147
  const scale = transform11.getScale(scratchScale);
49938
50148
  const uniformScale = Math.max(Math.max(scale[0], scale[1]), scale[2]);
49939
50149
  const radius = sphere[3] * uniformScale;
49940
- if (defined2(result)) {
50150
+ if (defined(result)) {
49941
50151
  result.center = center;
49942
50152
  result.radius = radius;
49943
50153
  return result;
@@ -50201,16 +50411,16 @@ var DEFAULT_PROPS4 = {
50201
50411
  };
50202
50412
  var TilesetTraverser = class {
50203
50413
  constructor(options) {
50414
+ this.root = null;
50415
+ this.selectedTiles = {};
50416
+ this.requestedTiles = {};
50417
+ this.emptyTiles = {};
50204
50418
  this.lastUpdate = new Date().getTime();
50205
50419
  this.updateDebounceTime = 1e3;
50206
- this.options = { ...DEFAULT_PROPS4, ...options };
50207
50420
  this._traversalStack = new ManagedArray();
50208
50421
  this._emptyTraversalStack = new ManagedArray();
50209
50422
  this._frameNumber = null;
50210
- this.root = null;
50211
- this.selectedTiles = {};
50212
- this.requestedTiles = {};
50213
- this.emptyTiles = {};
50423
+ this.options = { ...DEFAULT_PROPS4, ...options };
50214
50424
  }
50215
50425
  traversalFinished(frameState) {
50216
50426
  return true;
@@ -50273,7 +50483,6 @@ var TilesetTraverser = class {
50273
50483
  for (const child of children) {
50274
50484
  this.updateTile(child, frameState);
50275
50485
  }
50276
- return true;
50277
50486
  }
50278
50487
  updateAndPushChildren(tile, frameState, stack2, depth) {
50279
50488
  const { loadSiblings, skipLevelOfDetail } = this.options;
@@ -50352,7 +50561,7 @@ var TilesetTraverser = class {
50352
50561
  shouldSelectTile(tile) {
50353
50562
  return tile.contentAvailable && !this.options.skipLevelOfDetail;
50354
50563
  }
50355
- shouldRefine(tile, frameState, useParentMetric) {
50564
+ shouldRefine(tile, frameState, useParentMetric = false) {
50356
50565
  let screenSpaceError = tile._screenSpaceError;
50357
50566
  if (useParentMetric) {
50358
50567
  screenSpaceError = tile.getScreenSpaceError(frameState, true);
@@ -50414,19 +50623,11 @@ var TilesetTraverser = class {
50414
50623
 
50415
50624
  // ../tiles/src/tileset/tile-3d.ts
50416
50625
  var scratchVector3 = new import_core7.Vector3();
50417
- function defined3(x) {
50626
+ function defined2(x) {
50418
50627
  return x !== void 0 && x !== null;
50419
50628
  }
50420
50629
  var Tile3D = class {
50421
50630
  constructor(tileset, header, parentHeader, extendedId = "") {
50422
- this.header = header;
50423
- this.tileset = tileset;
50424
- this.id = extendedId || header.id;
50425
- this.url = header.url;
50426
- this.parent = parentHeader;
50427
- this.refine = this._getRefine(header.refine);
50428
- this.type = header.type;
50429
- this.contentUrl = header.contentUrl;
50430
50631
  this.lodMetricType = "geometricError";
50431
50632
  this.lodMetricValue = 0;
50432
50633
  this.boundingVolume = null;
@@ -50434,40 +50635,47 @@ var Tile3D = class {
50434
50635
  this.contentState = TILE_CONTENT_STATE.UNLOADED;
50435
50636
  this.gpuMemoryUsageInBytes = 0;
50436
50637
  this.children = [];
50437
- this.hasEmptyContent = false;
50438
- this.hasTilesetContent = false;
50439
50638
  this.depth = 0;
50440
50639
  this.viewportIds = [];
50441
- this.userData = {};
50640
+ this.transform = new import_core7.Matrix4();
50442
50641
  this.extensions = null;
50443
- this._priority = 0;
50444
- this._touchedFrame = 0;
50445
- this._visitedFrame = 0;
50446
- this._selectedFrame = 0;
50447
- this._requestedFrame = 0;
50448
- this._screenSpaceError = 0;
50642
+ this.implicitTiling = null;
50643
+ this.userData = {};
50644
+ this.hasEmptyContent = false;
50645
+ this.hasTilesetContent = false;
50646
+ this.traverser = new TilesetTraverser({});
50449
50647
  this._cacheNode = null;
50450
50648
  this._frameNumber = null;
50451
- this._cacheNode = null;
50452
- this.traverser = new TilesetTraverser({});
50453
- this._shouldRefine = false;
50649
+ this._expireDate = null;
50650
+ this._expiredContent = null;
50454
50651
  this._distanceToCamera = 0;
50455
- this._centerZDepth = 0;
50652
+ this._screenSpaceError = 0;
50456
50653
  this._visible = void 0;
50457
- this._inRequestVolume = false;
50458
- this._stackLength = 0;
50459
- this._selectionDepth = 0;
50460
50654
  this._initialTransform = new import_core7.Matrix4();
50461
- this.transform = new import_core7.Matrix4();
50655
+ this._priority = 0;
50656
+ this._selectedFrame = 0;
50657
+ this._requestedFrame = 0;
50658
+ this._selectionDepth = 0;
50659
+ this._touchedFrame = 0;
50660
+ this._centerZDepth = 0;
50661
+ this._shouldRefine = false;
50662
+ this._stackLength = 0;
50663
+ this._visitedFrame = 0;
50664
+ this._inRequestVolume = false;
50665
+ this._lodJudge = null;
50666
+ this.header = header;
50667
+ this.tileset = tileset;
50668
+ this.id = extendedId || header.id;
50669
+ this.url = header.url;
50670
+ this.parent = parentHeader;
50671
+ this.refine = this._getRefine(header.refine);
50672
+ this.type = header.type;
50673
+ this.contentUrl = header.contentUrl;
50462
50674
  this._initializeLodMetric(header);
50463
50675
  this._initializeTransforms(header);
50464
50676
  this._initializeBoundingVolumes(header);
50465
50677
  this._initializeContent(header);
50466
50678
  this._initializeRenderingState(header);
50467
- this._lodJudge = null;
50468
- this._expireDate = null;
50469
- this._expiredContent = null;
50470
- this.implicitTiling = null;
50471
50679
  Object.seal(this);
50472
50680
  }
50473
50681
  destroy() {
@@ -50534,6 +50742,9 @@ var Tile3D = class {
50534
50742
  unselect() {
50535
50743
  this._selectedFrame = 0;
50536
50744
  }
50745
+ _getGpuMemoryUsageInBytes() {
50746
+ return this.content.gpuMemoryUsageInBytes || this.content.byteLength || 0;
50747
+ }
50537
50748
  _getPriority() {
50538
50749
  const traverser = this.tileset._traverser;
50539
50750
  const { skipLevelOfDetail } = traverser.options;
@@ -50650,7 +50861,7 @@ var Tile3D = class {
50650
50861
  return !viewerRequestVolume || viewerRequestVolume.distanceSquaredTo(frameState.camera.position) <= 0;
50651
50862
  }
50652
50863
  updateExpiration() {
50653
- if (defined3(this._expireDate) && this.contentReady && !this.hasEmptyContent) {
50864
+ if (defined2(this._expireDate) && this.contentReady && !this.hasEmptyContent) {
50654
50865
  const now = Date.now();
50655
50866
  if (Date.lessThan(this._expireDate, now)) {
50656
50867
  this.contentState = TILE_CONTENT_STATE.EXPIRED;
@@ -50733,6 +50944,8 @@ var Tile3D = class {
50733
50944
  }
50734
50945
  if (this._isTileset()) {
50735
50946
  this.hasTilesetContent = true;
50947
+ } else {
50948
+ this.gpuMemoryUsageInBytes = this._getGpuMemoryUsageInBytes();
50736
50949
  }
50737
50950
  }
50738
50951
  _updateBoundingVolume(header) {
@@ -51010,57 +51223,56 @@ var TILES_LOAD_FAILED = "Failed Tile Loads";
51010
51223
  var POINTS_COUNT = "Points/Vertices";
51011
51224
  var TILES_GPU_MEMORY = "Tile Memory Use";
51012
51225
  var Tileset3D = class {
51013
- constructor(json, options) {
51014
- this.contentFormats = { draco: false, meshopt: false, dds: false, ktx2: false };
51015
- this.updatePromise = null;
51016
- assert2(json);
51017
- this.options = { ...DEFAULT_PROPS5, ...options };
51018
- this.tileset = json;
51019
- this.loader = json.loader;
51020
- this.type = json.type;
51021
- this.url = json.url;
51022
- this.basePath = json.basePath || path_exports.dirname(this.url);
51023
- this.modelMatrix = this.options.modelMatrix;
51024
- this.ellipsoid = this.options.ellipsoid;
51025
- this.lodMetricType = json.lodMetricType;
51026
- this.lodMetricValue = json.lodMetricValue;
51027
- this.refine = json.root.refine;
51028
- this.loadOptions = this.options.loadOptions || {};
51226
+ constructor(tileset, options) {
51029
51227
  this.root = null;
51030
51228
  this.roots = {};
51229
+ this.asset = {};
51230
+ this.description = "";
51231
+ this.extras = null;
51232
+ this.attributions = {};
51233
+ this.credits = {};
51234
+ this.contentFormats = { draco: false, meshopt: false, dds: false, ktx2: false };
51031
51235
  this.cartographicCenter = null;
51032
51236
  this.cartesianCenter = null;
51033
51237
  this.zoom = 1;
51034
51238
  this.boundingVolume = null;
51239
+ this.dynamicScreenSpaceErrorComputedDensity = 0;
51240
+ this.maximumMemoryUsage = 32;
51241
+ this.gpuMemoryUsageInBytes = 0;
51242
+ this._frameNumber = 0;
51243
+ this._queryParams = {};
51244
+ this._extensionsUsed = [];
51245
+ this._tiles = {};
51246
+ this._pendingCount = 0;
51247
+ this.selectedTiles = [];
51035
51248
  this.traverseCounter = 0;
51036
51249
  this.geometricError = 0;
51037
- this._traverser = this._initializeTraverser();
51250
+ this.lastUpdatedVieports = null;
51251
+ this._requestedTiles = [];
51252
+ this._emptyTiles = [];
51253
+ this.frameStateData = {};
51038
51254
  this._cache = new TilesetCache();
51255
+ this.updatePromise = null;
51256
+ this.options = { ...DEFAULT_PROPS5, ...options };
51257
+ this.tileset = tileset;
51258
+ this.loader = tileset.loader;
51259
+ this.type = tileset.type;
51260
+ this.url = tileset.url;
51261
+ this.basePath = tileset.basePath || path_exports.dirname(this.url);
51262
+ this.modelMatrix = this.options.modelMatrix;
51263
+ this.ellipsoid = this.options.ellipsoid;
51264
+ this.lodMetricType = tileset.lodMetricType;
51265
+ this.lodMetricValue = tileset.lodMetricValue;
51266
+ this.refine = tileset.root.refine;
51267
+ this.loadOptions = this.options.loadOptions || {};
51268
+ this._traverser = this._initializeTraverser();
51039
51269
  this._requestScheduler = new RequestScheduler({
51040
51270
  throttleRequests: this.options.throttleRequests,
51041
51271
  maxRequests: this.options.maxRequests
51042
51272
  });
51043
- this._frameNumber = 0;
51044
- this._pendingCount = 0;
51045
- this._tiles = {};
51046
- this.selectedTiles = [];
51047
- this._emptyTiles = [];
51048
- this._requestedTiles = [];
51049
- this.frameStateData = {};
51050
- this.lastUpdatedVieports = null;
51051
- this._queryParams = {};
51052
- this._queryParamsString = "";
51053
- this.maximumMemoryUsage = this.options.maximumMemoryUsage || 32;
51054
- this.gpuMemoryUsageInBytes = 0;
51055
- this.stats = new Stats({ id: this.url });
51273
+ this.stats = new Stats2({ id: this.url });
51056
51274
  this._initializeStats();
51057
- this._extensionsUsed = void 0;
51058
- this.dynamicScreenSpaceErrorComputedDensity = 0;
51059
- this.extras = null;
51060
- this.asset = {};
51061
- this.credits = {};
51062
- this.description = this.options.description || "";
51063
- this.tilesetInitializationPromise = this._initializeTileSet(json);
51275
+ this.tilesetInitializationPromise = this._initializeTileSet(tileset);
51064
51276
  }
51065
51277
  destroy() {
51066
51278
  this._destroy();
@@ -51075,10 +51287,7 @@ var Tileset3D = class {
51075
51287
  return this._frameNumber;
51076
51288
  }
51077
51289
  get queryParams() {
51078
- if (!this._queryParamsString) {
51079
- this._queryParamsString = getQueryParamString(this._queryParams);
51080
- }
51081
- return this._queryParamsString;
51290
+ return new URLSearchParams(this._queryParams).toString();
51082
51291
  }
51083
51292
  setProps(props) {
51084
51293
  this.options = { ...this.options, ...props };
@@ -51091,10 +51300,10 @@ var Tileset3D = class {
51091
51300
  if (isDataUrl) {
51092
51301
  return tilePath;
51093
51302
  }
51094
- return `${tilePath}${this.queryParams}`;
51303
+ return `${tilePath}${tilePath.includes("?") ? "&" : "?"}${this.queryParams}`;
51095
51304
  }
51096
51305
  hasExtension(extensionName) {
51097
- return Boolean(this._extensionsUsed && this._extensionsUsed.indexOf(extensionName) > -1);
51306
+ return Boolean(this._extensionsUsed.indexOf(extensionName) > -1);
51098
51307
  }
51099
51308
  update(viewports = null) {
51100
51309
  this.tilesetInitializationPromise.then(() => {
@@ -51281,7 +51490,6 @@ var Tileset3D = class {
51281
51490
  }
51282
51491
  calculateViewPropsTiles3D() {
51283
51492
  const root = this.root;
51284
- assert2(root);
51285
51493
  const { center } = root.boundingVolume;
51286
51494
  if (!center) {
51287
51495
  console.warn("center was not pre-calculated for the root tile");
@@ -51324,6 +51532,13 @@ var Tileset3D = class {
51324
51532
  const children = tile.header.children || [];
51325
51533
  for (const childHeader of children) {
51326
51534
  const childTile = new Tile3D(this, childHeader, tile);
51535
+ if (childTile.contentUrl?.includes("?session=")) {
51536
+ const url = new URL(childTile.contentUrl);
51537
+ const session = url.searchParams.get("session");
51538
+ if (session) {
51539
+ this._queryParams.session = session;
51540
+ }
51541
+ }
51327
51542
  tile.children.push(childTile);
51328
51543
  childTile.depth = tile.depth + 1;
51329
51544
  stack2.push(childTile);
@@ -51359,7 +51574,7 @@ var Tileset3D = class {
51359
51574
  this._onStartTileLoading();
51360
51575
  loaded = await tile.loadContent();
51361
51576
  } catch (error) {
51362
- this._onTileLoadError(tile, error);
51577
+ this._onTileLoadError(tile, error instanceof Error ? error : new Error("load failed"));
51363
51578
  } finally {
51364
51579
  this._onEndTileLoading();
51365
51580
  this._onTileLoad(tile, loaded);
@@ -51429,11 +51644,11 @@ var Tileset3D = class {
51429
51644
  _updateCacheStats(tile) {
51430
51645
  this.stats.get(TILES_LOADED).incrementCount();
51431
51646
  this.stats.get(TILES_IN_MEMORY).incrementCount();
51432
- this.gpuMemoryUsageInBytes += tile.content.byteLength || 0;
51647
+ this.gpuMemoryUsageInBytes += tile.gpuMemoryUsageInBytes || 0;
51433
51648
  this.stats.get(TILES_GPU_MEMORY).count = this.gpuMemoryUsageInBytes;
51434
51649
  }
51435
51650
  _unloadTile(tile) {
51436
- this.gpuMemoryUsageInBytes -= tile.content && tile.content.byteLength || 0;
51651
+ this.gpuMemoryUsageInBytes -= tile.gpuMemoryUsageInBytes || 0;
51437
51652
  this.stats.get(TILES_IN_MEMORY).decrementCount();
51438
51653
  this.stats.get(TILES_UNLOADED).incrementCount();
51439
51654
  this.stats.get(TILES_GPU_MEMORY).count = this.gpuMemoryUsageInBytes;
@@ -51475,11 +51690,16 @@ var Tileset3D = class {
51475
51690
  tile.destroy();
51476
51691
  }
51477
51692
  _initializeTiles3DTileset(tilesetJson) {
51693
+ if (tilesetJson.queryString) {
51694
+ const searchParams = new URLSearchParams(tilesetJson.queryString);
51695
+ const queryParams = Object.fromEntries(searchParams.entries());
51696
+ this._queryParams = { ...this._queryParams, ...queryParams };
51697
+ }
51478
51698
  this.asset = tilesetJson.asset;
51479
51699
  if (!this.asset) {
51480
51700
  throw new Error("Tileset must have an asset property.");
51481
51701
  }
51482
- if (this.asset.version !== "0.0" && this.asset.version !== "1.0") {
51702
+ if (this.asset.version !== "0.0" && this.asset.version !== "1.0" && this.asset.version !== "1.1") {
51483
51703
  throw new Error("The tileset must be 3D Tiles version 0.0 or 1.0.");
51484
51704
  }
51485
51705
  if ("tilesetVersion" in this.asset) {
@@ -51491,7 +51711,7 @@ var Tileset3D = class {
51491
51711
  this.description = this.options.description || "";
51492
51712
  this.properties = tilesetJson.properties;
51493
51713
  this.geometricError = tilesetJson.geometricError;
51494
- this._extensionsUsed = tilesetJson.extensionsUsed;
51714
+ this._extensionsUsed = tilesetJson.extensionsUsed || [];
51495
51715
  this.extras = tilesetJson.extras;
51496
51716
  }
51497
51717
  _initializeI3STileset() {
@@ -51500,20 +51720,6 @@ var Tileset3D = class {
51500
51720
  }
51501
51721
  }
51502
51722
  };
51503
- function getQueryParamString(queryParams) {
51504
- const queryParamStrings = [];
51505
- for (const key of Object.keys(queryParams)) {
51506
- queryParamStrings.push(`${key}=${queryParams[key]}`);
51507
- }
51508
- switch (queryParamStrings.length) {
51509
- case 0:
51510
- return "";
51511
- case 1:
51512
- return `?${queryParamStrings[0]}`;
51513
- default:
51514
- return `?${queryParamStrings.join("&")}`;
51515
- }
51516
- }
51517
51723
 
51518
51724
  // ../3d-tiles/src/lib/utils/version.ts
51519
51725
  var VERSION6 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
@@ -51557,7 +51763,7 @@ var DEFAULT_DRACO_OPTIONS = {
51557
51763
  };
51558
51764
  var DracoLoader = {
51559
51765
  name: "Draco",
51560
- id: isBrowser2 ? "draco" : "draco-nodejs",
51766
+ id: "draco",
51561
51767
  module: "draco",
51562
51768
  version: VERSION7,
51563
51769
  worker: true,
@@ -52075,7 +52281,7 @@ function initializeDracoDecoder(DracoDecoderModule, wasmBinary) {
52075
52281
 
52076
52282
  // ../draco/src/index.ts
52077
52283
  var DracoWriterWorker = {
52078
- id: isBrowser2 ? "draco-writer" : "draco-writer-nodejs",
52284
+ id: "draco-writer",
52079
52285
  name: "Draco compressed geometry writer",
52080
52286
  module: "draco",
52081
52287
  version: VERSION7,
@@ -52439,7 +52645,7 @@ function createTypedArrayFromAccessor(tile3DAccessor, buffer, byteOffset, length
52439
52645
  }
52440
52646
 
52441
52647
  // ../3d-tiles/src/lib/classes/tile-3d-batch-table-hierarchy.ts
52442
- var defined4 = (x) => x !== void 0;
52648
+ var defined3 = (x) => x !== void 0;
52443
52649
  function initializeHierarchy(batchTable, jsonHeader, binaryBody) {
52444
52650
  if (!jsonHeader) {
52445
52651
  return null;
@@ -52467,15 +52673,15 @@ function initializeHierarchyValues(hierarchyJson, binaryBody) {
52467
52673
  let parentCounts = hierarchyJson.parentCounts;
52468
52674
  let parentIds = hierarchyJson.parentIds;
52469
52675
  let parentIdsLength = instancesLength;
52470
- if (defined4(classIds.byteOffset)) {
52676
+ if (defined3(classIds.byteOffset)) {
52471
52677
  classIds.componentType = defaultValue(classIds.componentType, GL.UNSIGNED_SHORT);
52472
52678
  classIds.type = AttributeType.SCALAR;
52473
52679
  binaryAccessor = getBinaryAccessor(classIds);
52474
52680
  classIds = binaryAccessor.createArrayBufferView(binaryBody.buffer, binaryBody.byteOffset + classIds.byteOffset, instancesLength);
52475
52681
  }
52476
52682
  let parentIndexes;
52477
- if (defined4(parentCounts)) {
52478
- if (defined4(parentCounts.byteOffset)) {
52683
+ if (defined3(parentCounts)) {
52684
+ if (defined3(parentCounts.byteOffset)) {
52479
52685
  parentCounts.componentType = defaultValue(parentCounts.componentType, GL.UNSIGNED_SHORT);
52480
52686
  parentCounts.type = AttributeType.SCALAR;
52481
52687
  binaryAccessor = getBinaryAccessor(parentCounts);
@@ -52488,7 +52694,7 @@ function initializeHierarchyValues(hierarchyJson, binaryBody) {
52488
52694
  parentIdsLength += parentCounts[i];
52489
52695
  }
52490
52696
  }
52491
- if (defined4(parentIds) && defined4(parentIds.byteOffset)) {
52697
+ if (defined3(parentIds) && defined3(parentIds.byteOffset)) {
52492
52698
  parentIds.componentType = defaultValue(parentIds.componentType, GL.UNSIGNED_SHORT);
52493
52699
  parentIds.type = AttributeType.SCALAR;
52494
52700
  binaryAccessor = getBinaryAccessor(parentIds);
@@ -52552,7 +52758,7 @@ function traverseHierarchyMultipleParents(hierarchy, instanceIndex, endCondition
52552
52758
  }
52553
52759
  visited[instanceIndex] = visitedMarker;
52554
52760
  const result = endConditionCallback(hierarchy, instanceIndex);
52555
- if (defined4(result)) {
52761
+ if (defined3(result)) {
52556
52762
  return result;
52557
52763
  }
52558
52764
  const parentCount = parentCounts[instanceIndex];
@@ -52570,7 +52776,7 @@ function traverseHierarchySingleParent(hierarchy, instanceIndex, endConditionCal
52570
52776
  let hasParent = true;
52571
52777
  while (hasParent) {
52572
52778
  const result = endConditionCallback(hierarchy, instanceIndex);
52573
- if (defined4(result)) {
52779
+ if (defined3(result)) {
52574
52780
  return result;
52575
52781
  }
52576
52782
  const parentId = hierarchy.parentIds[instanceIndex];
@@ -52593,14 +52799,14 @@ function validateInstance(hierarchy, instanceIndex, stack2) {
52593
52799
  const parentIndexes = hierarchy.parentIndexes;
52594
52800
  const classIds = hierarchy.classIds;
52595
52801
  const instancesLength = classIds.length;
52596
- if (!defined4(parentIds)) {
52802
+ if (!defined3(parentIds)) {
52597
52803
  return;
52598
52804
  }
52599
52805
  assert(instanceIndex < instancesLength, `Parent index ${instanceIndex} exceeds the total number of instances: ${instancesLength}`);
52600
52806
  assert(stack2.indexOf(instanceIndex) === -1, "Circular dependency detected in the batch table hierarchy.");
52601
52807
  stack2.push(instanceIndex);
52602
- const parentCount = defined4(parentCounts) ? parentCounts[instanceIndex] : 1;
52603
- const parentIndex = defined4(parentCounts) ? parentIndexes[instanceIndex] : instanceIndex;
52808
+ const parentCount = defined3(parentCounts) ? parentCounts[instanceIndex] : 1;
52809
+ const parentIndex = defined3(parentCounts) ? parentIndexes[instanceIndex] : instanceIndex;
52604
52810
  for (let i = 0; i < parentCount; ++i) {
52605
52811
  const parentId = parentIds[parentIndex + i];
52606
52812
  if (parentId !== instanceIndex) {
@@ -52611,7 +52817,7 @@ function validateInstance(hierarchy, instanceIndex, stack2) {
52611
52817
  }
52612
52818
 
52613
52819
  // ../3d-tiles/src/lib/classes/tile-3d-batch-table.ts
52614
- function defined5(x) {
52820
+ function defined4(x) {
52615
52821
  return x !== void 0 && x !== null;
52616
52822
  }
52617
52823
  var clone = (x, y) => x;
@@ -52653,7 +52859,7 @@ var Tile3DBatchTableParser = class {
52653
52859
  const instanceClass = hierarchy.classes[classId];
52654
52860
  return instanceClass.name === className;
52655
52861
  });
52656
- return defined5(result);
52862
+ return defined4(result);
52657
52863
  }
52658
52864
  return false;
52659
52865
  }
@@ -52673,11 +52879,11 @@ var Tile3DBatchTableParser = class {
52673
52879
  hasProperty(batchId, name10) {
52674
52880
  this._checkBatchId(batchId);
52675
52881
  assert2(typeof name10 === "string", name10);
52676
- return defined5(this._properties[name10]) || this._hasPropertyInHierarchy(batchId, name10);
52882
+ return defined4(this._properties[name10]) || this._hasPropertyInHierarchy(batchId, name10);
52677
52883
  }
52678
52884
  getPropertyNames(batchId, results) {
52679
52885
  this._checkBatchId(batchId);
52680
- results = defined5(results) ? results : [];
52886
+ results = defined4(results) ? results : [];
52681
52887
  results.length = 0;
52682
52888
  const propertyNames = Object.keys(this._properties);
52683
52889
  results.push(...propertyNames);
@@ -52691,17 +52897,17 @@ var Tile3DBatchTableParser = class {
52691
52897
  assert2(typeof name10 === "string", name10);
52692
52898
  if (this._binaryProperties) {
52693
52899
  const binaryProperty = this._binaryProperties[name10];
52694
- if (defined5(binaryProperty)) {
52900
+ if (defined4(binaryProperty)) {
52695
52901
  return this._getBinaryProperty(binaryProperty, batchId);
52696
52902
  }
52697
52903
  }
52698
52904
  const propertyValues = this._properties[name10];
52699
- if (defined5(propertyValues)) {
52905
+ if (defined4(propertyValues)) {
52700
52906
  return clone(propertyValues[batchId], true);
52701
52907
  }
52702
52908
  if (this._hierarchy) {
52703
52909
  const hierarchyProperty = this._getHierarchyProperty(batchId, name10);
52704
- if (defined5(hierarchyProperty)) {
52910
+ if (defined4(hierarchyProperty)) {
52705
52911
  return hierarchyProperty;
52706
52912
  }
52707
52913
  }
@@ -52724,7 +52930,7 @@ var Tile3DBatchTableParser = class {
52724
52930
  }
52725
52931
  }
52726
52932
  let propertyValues = this._properties[name10];
52727
- if (!defined5(propertyValues)) {
52933
+ if (!defined4(propertyValues)) {
52728
52934
  this._properties[name10] = new Array(featureCount);
52729
52935
  propertyValues = this._properties[name10];
52730
52936
  }
@@ -52776,9 +52982,9 @@ var Tile3DBatchTableParser = class {
52776
52982
  const result = traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
52777
52983
  const classId = hierarchy.classIds[instanceIndex];
52778
52984
  const instances = hierarchy.classes[classId].instances;
52779
- return defined5(instances[name10]);
52985
+ return defined4(instances[name10]);
52780
52986
  });
52781
- return defined5(result);
52987
+ return defined4(result);
52782
52988
  }
52783
52989
  _getPropertyNamesInHierarchy(batchId, results) {
52784
52990
  traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
@@ -52799,8 +53005,8 @@ var Tile3DBatchTableParser = class {
52799
53005
  const instanceClass = hierarchy.classes[classId];
52800
53006
  const indexInClass = hierarchy.classIndexes[instanceIndex];
52801
53007
  const propertyValues = instanceClass.instances[name10];
52802
- if (defined5(propertyValues)) {
52803
- if (defined5(propertyValues.typedArray)) {
53008
+ if (defined4(propertyValues)) {
53009
+ if (defined4(propertyValues.typedArray)) {
52804
53010
  return this._getBinaryProperty(propertyValues, indexInClass);
52805
53011
  }
52806
53012
  return clone(propertyValues[indexInClass], true);
@@ -52814,9 +53020,9 @@ var Tile3DBatchTableParser = class {
52814
53020
  const instanceClass = hierarchy.classes[classId];
52815
53021
  const indexInClass = hierarchy.classIndexes[instanceIndex];
52816
53022
  const propertyValues = instanceClass.instances[name10];
52817
- if (defined5(propertyValues)) {
53023
+ if (defined4(propertyValues)) {
52818
53024
  assert2(instanceIndex === batchId, `Inherited property "${name10}" is read-only.`);
52819
- if (defined5(propertyValues.typedArray)) {
53025
+ if (defined4(propertyValues.typedArray)) {
52820
53026
  this._setBinaryProperty(propertyValues, indexInClass, value);
52821
53027
  } else {
52822
53028
  propertyValues[indexInClass] = clone(value, true);
@@ -52825,7 +53031,7 @@ var Tile3DBatchTableParser = class {
52825
53031
  }
52826
53032
  return false;
52827
53033
  });
52828
- return defined5(result);
53034
+ return defined4(result);
52829
53035
  }
52830
53036
  };
52831
53037
 
@@ -53215,326 +53421,825 @@ async function loadDraco(tile, dracoData, options, context) {
53215
53421
  // ../gltf/src/lib/utils/version.ts
53216
53422
  var VERSION8 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
53217
53423
 
53218
- // ../textures/src/lib/utils/version.ts
53219
- var VERSION9 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
53424
+ // ../images/src/lib/utils/version.ts
53425
+ var VERSION9 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
53220
53426
 
53221
- // ../textures/src/lib/parsers/basis-module-loader.ts
53222
- var VERSION10 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
53223
- var BASIS_CDN_ENCODER_WASM = `https://unpkg.com/@loaders.gl/textures@${VERSION10}/dist/libs/basis_encoder.wasm`;
53224
- var BASIS_CDN_ENCODER_JS = `https://unpkg.com/@loaders.gl/textures@${VERSION10}/dist/libs/basis_encoder.js`;
53225
- var loadBasisTranscoderPromise;
53226
- async function loadBasisTrascoderModule(options) {
53227
- const modules = options.modules || {};
53228
- if (modules.basis) {
53229
- return modules.basis;
53427
+ // ../images/src/lib/category-api/image-type.ts
53428
+ var { _parseImageNode } = globalThis;
53429
+ var IMAGE_SUPPORTED = typeof Image !== "undefined";
53430
+ var IMAGE_BITMAP_SUPPORTED = typeof ImageBitmap !== "undefined";
53431
+ var NODE_IMAGE_SUPPORTED = Boolean(_parseImageNode);
53432
+ var DATA_SUPPORTED = isBrowser ? true : NODE_IMAGE_SUPPORTED;
53433
+ function isImageTypeSupported(type) {
53434
+ switch (type) {
53435
+ case "auto":
53436
+ return IMAGE_BITMAP_SUPPORTED || IMAGE_SUPPORTED || DATA_SUPPORTED;
53437
+ case "imagebitmap":
53438
+ return IMAGE_BITMAP_SUPPORTED;
53439
+ case "image":
53440
+ return IMAGE_SUPPORTED;
53441
+ case "data":
53442
+ return DATA_SUPPORTED;
53443
+ default:
53444
+ throw new Error(`@loaders.gl/images: image ${type} not supported in this environment`);
53230
53445
  }
53231
- loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTrascoder(options);
53232
- return await loadBasisTranscoderPromise;
53233
- }
53234
- async function loadBasisTrascoder(options) {
53235
- let BASIS = null;
53236
- let wasmBinary = null;
53237
- [BASIS, wasmBinary] = await Promise.all([
53238
- await loadLibrary("basis_transcoder.js", "textures", options),
53239
- await loadLibrary("basis_transcoder.wasm", "textures", options)
53240
- ]);
53241
- BASIS = BASIS || globalThis.BASIS;
53242
- return await initializeBasisTrascoderModule(BASIS, wasmBinary);
53243
53446
  }
53244
- function initializeBasisTrascoderModule(BasisModule, wasmBinary) {
53245
- const options = {};
53246
- if (wasmBinary) {
53247
- options.wasmBinary = wasmBinary;
53447
+ function getDefaultImageType() {
53448
+ if (IMAGE_BITMAP_SUPPORTED) {
53449
+ return "imagebitmap";
53248
53450
  }
53249
- return new Promise((resolve2) => {
53250
- BasisModule(options).then((module2) => {
53251
- const { BasisFile, initializeBasis } = module2;
53252
- initializeBasis();
53253
- resolve2({ BasisFile });
53254
- });
53255
- });
53451
+ if (IMAGE_SUPPORTED) {
53452
+ return "image";
53453
+ }
53454
+ if (DATA_SUPPORTED) {
53455
+ return "data";
53456
+ }
53457
+ throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js");
53256
53458
  }
53257
- var loadBasisEncoderPromise;
53258
- async function loadBasisEncoderModule(options) {
53259
- const modules = options.modules || {};
53260
- if (modules.basisEncoder) {
53261
- return modules.basisEncoder;
53459
+
53460
+ // ../images/src/lib/category-api/parsed-image-api.ts
53461
+ function getImageType(image) {
53462
+ const format = getImageTypeOrNull(image);
53463
+ if (!format) {
53464
+ throw new Error("Not an image");
53262
53465
  }
53263
- loadBasisEncoderPromise = loadBasisEncoderPromise || loadBasisEncoder(options);
53264
- return await loadBasisEncoderPromise;
53466
+ return format;
53265
53467
  }
53266
- async function loadBasisEncoder(options) {
53267
- let BASIS_ENCODER = null;
53268
- let wasmBinary = null;
53269
- [BASIS_ENCODER, wasmBinary] = await Promise.all([
53270
- await loadLibrary(BASIS_CDN_ENCODER_JS, "textures", options),
53271
- await loadLibrary(BASIS_CDN_ENCODER_WASM, "textures", options)
53272
- ]);
53273
- BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
53274
- return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
53468
+ function getImageSize(image) {
53469
+ return getImageData(image);
53275
53470
  }
53276
- function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
53277
- const options = {};
53278
- if (wasmBinary) {
53279
- options.wasmBinary = wasmBinary;
53471
+ function getImageData(image) {
53472
+ switch (getImageType(image)) {
53473
+ case "data":
53474
+ return image;
53475
+ case "image":
53476
+ case "imagebitmap":
53477
+ const canvas = document.createElement("canvas");
53478
+ const context = canvas.getContext("2d");
53479
+ if (!context) {
53480
+ throw new Error("getImageData");
53481
+ }
53482
+ canvas.width = image.width;
53483
+ canvas.height = image.height;
53484
+ context.drawImage(image, 0, 0);
53485
+ return context.getImageData(0, 0, image.width, image.height);
53486
+ default:
53487
+ throw new Error("getImageData");
53280
53488
  }
53281
- return new Promise((resolve2) => {
53282
- BasisEncoderModule(options).then((module2) => {
53283
- const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module2;
53284
- initializeBasis();
53285
- resolve2({ BasisFile, KTX2File, BasisEncoder });
53286
- });
53287
- });
53489
+ }
53490
+ function getImageTypeOrNull(image) {
53491
+ if (typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap) {
53492
+ return "imagebitmap";
53493
+ }
53494
+ if (typeof Image !== "undefined" && image instanceof Image) {
53495
+ return "image";
53496
+ }
53497
+ if (image && typeof image === "object" && image.data && image.width && image.height) {
53498
+ return "data";
53499
+ }
53500
+ return null;
53288
53501
  }
53289
53502
 
53290
- // ../textures/src/lib/gl-extensions.ts
53291
- var GL_EXTENSIONS_CONSTANTS = {
53292
- COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
53293
- COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
53294
- COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
53295
- COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779,
53296
- COMPRESSED_R11_EAC: 37488,
53297
- COMPRESSED_SIGNED_R11_EAC: 37489,
53298
- COMPRESSED_RG11_EAC: 37490,
53299
- COMPRESSED_SIGNED_RG11_EAC: 37491,
53300
- COMPRESSED_RGB8_ETC2: 37492,
53301
- COMPRESSED_RGBA8_ETC2_EAC: 37493,
53302
- COMPRESSED_SRGB8_ETC2: 37494,
53303
- COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
53304
- COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
53305
- COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
53306
- COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
53307
- COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
53308
- COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
53309
- COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
53310
- COMPRESSED_RGB_ETC1_WEBGL: 36196,
53311
- COMPRESSED_RGB_ATC_WEBGL: 35986,
53312
- COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
53313
- COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
53314
- COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
53315
- COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
53316
- COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
53317
- COMPRESSED_RGBA_ASTC_6X5_KHR: 37811,
53318
- COMPRESSED_RGBA_ASTC_6X6_KHR: 37812,
53319
- COMPRESSED_RGBA_ASTC_8X5_KHR: 37813,
53320
- COMPRESSED_RGBA_ASTC_8X6_KHR: 37814,
53321
- COMPRESSED_RGBA_ASTC_8X8_KHR: 37815,
53322
- COMPRESSED_RGBA_ASTC_10X5_KHR: 37816,
53323
- COMPRESSED_RGBA_ASTC_10X6_KHR: 37817,
53324
- COMPRESSED_RGBA_ASTC_10X8_KHR: 37818,
53325
- COMPRESSED_RGBA_ASTC_10X10_KHR: 37819,
53326
- COMPRESSED_RGBA_ASTC_12X10_KHR: 37820,
53327
- COMPRESSED_RGBA_ASTC_12X12_KHR: 37821,
53328
- COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: 37840,
53329
- COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: 37841,
53330
- COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: 37842,
53331
- COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: 37843,
53332
- COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: 37844,
53333
- COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: 37845,
53334
- COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: 37846,
53335
- COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: 37847,
53336
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: 37848,
53337
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: 37849,
53338
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: 37850,
53339
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
53340
- COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
53341
- COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
53342
- COMPRESSED_RED_RGTC1_EXT: 36283,
53343
- COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
53344
- COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
53345
- COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
53346
- COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
53347
- COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
53348
- COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
53349
- COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: 35919
53350
- };
53351
-
53352
- // ../textures/src/lib/utils/texture-formats.ts
53353
- var BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
53354
- var WEBGL_EXTENSIONS = {
53355
- WEBGL_compressed_texture_s3tc: "dxt",
53356
- WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb",
53357
- WEBGL_compressed_texture_etc1: "etc1",
53358
- WEBGL_compressed_texture_etc: "etc2",
53359
- WEBGL_compressed_texture_pvrtc: "pvrtc",
53360
- WEBGL_compressed_texture_atc: "atc",
53361
- WEBGL_compressed_texture_astc: "astc",
53362
- EXT_texture_compression_rgtc: "rgtc"
53363
- };
53364
- var formats = null;
53365
- function getSupportedGPUTextureFormats(gl) {
53366
- if (!formats) {
53367
- gl = gl || getWebGLContext() || void 0;
53368
- formats = new Set();
53369
- for (const prefix of BROWSER_PREFIXES) {
53370
- for (const extension in WEBGL_EXTENSIONS) {
53371
- if (gl && gl.getExtension(`${prefix}${extension}`)) {
53372
- const gpuTextureFormat = WEBGL_EXTENSIONS[extension];
53373
- formats.add(gpuTextureFormat);
53374
- }
53503
+ // ../images/src/lib/parsers/svg-utils.ts
53504
+ var SVG_DATA_URL_PATTERN = /^data:image\/svg\+xml/;
53505
+ var SVG_URL_PATTERN = /\.svg((\?|#).*)?$/;
53506
+ function isSVG(url) {
53507
+ return url && (SVG_DATA_URL_PATTERN.test(url) || SVG_URL_PATTERN.test(url));
53508
+ }
53509
+ function getBlobOrSVGDataUrl(arrayBuffer, url) {
53510
+ if (isSVG(url)) {
53511
+ const textDecoder = new TextDecoder();
53512
+ let xmlText = textDecoder.decode(arrayBuffer);
53513
+ try {
53514
+ if (typeof unescape === "function" && typeof encodeURIComponent === "function") {
53515
+ xmlText = unescape(encodeURIComponent(xmlText));
53375
53516
  }
53517
+ } catch (error) {
53518
+ throw new Error(error.message);
53376
53519
  }
53520
+ const src = `data:image/svg+xml;base64,${btoa(xmlText)}`;
53521
+ return src;
53377
53522
  }
53378
- return formats;
53523
+ return getBlob(arrayBuffer, url);
53379
53524
  }
53380
- function getWebGLContext() {
53381
- try {
53382
- const canvas = document.createElement("canvas");
53383
- return canvas.getContext("webgl");
53384
- } catch (error) {
53385
- return null;
53525
+ function getBlob(arrayBuffer, url) {
53526
+ if (isSVG(url)) {
53527
+ throw new Error("SVG cannot be parsed directly to imagebitmap");
53386
53528
  }
53529
+ return new Blob([new Uint8Array(arrayBuffer)]);
53387
53530
  }
53388
53531
 
53389
- // ../textures/src/lib/parsers/parse-ktx.ts
53390
- var import_ktx_parse = __toModule(require_ktx_parse());
53532
+ // ../images/src/lib/parsers/parse-to-image.ts
53533
+ async function parseToImage(arrayBuffer, options, url) {
53534
+ const blobOrDataUrl = getBlobOrSVGDataUrl(arrayBuffer, url);
53535
+ const URL2 = self.URL || self.webkitURL;
53536
+ const objectUrl = typeof blobOrDataUrl !== "string" && URL2.createObjectURL(blobOrDataUrl);
53537
+ try {
53538
+ return await loadToImage(objectUrl || blobOrDataUrl, options);
53539
+ } finally {
53540
+ if (objectUrl) {
53541
+ URL2.revokeObjectURL(objectUrl);
53542
+ }
53543
+ }
53544
+ }
53545
+ async function loadToImage(url, options) {
53546
+ const image = new Image();
53547
+ image.src = url;
53548
+ if (options.image && options.image.decode && image.decode) {
53549
+ await image.decode();
53550
+ return image;
53551
+ }
53552
+ return await new Promise((resolve2, reject) => {
53553
+ try {
53554
+ image.onload = () => resolve2(image);
53555
+ image.onerror = (err) => reject(new Error(`Could not load image ${url}: ${err}`));
53556
+ } catch (error) {
53557
+ reject(error);
53558
+ }
53559
+ });
53560
+ }
53391
53561
 
53392
- // ../textures/src/lib/utils/extract-mipmap-images.ts
53393
- function extractMipmapImages(data, options) {
53394
- const images = new Array(options.mipMapLevels);
53395
- let levelWidth = options.width;
53396
- let levelHeight = options.height;
53397
- let offset = 0;
53398
- for (let i = 0; i < options.mipMapLevels; ++i) {
53399
- const levelSize = getLevelSize(options, levelWidth, levelHeight, data, i);
53400
- const levelData = getLevelData(data, i, offset, levelSize);
53401
- images[i] = {
53402
- compressed: true,
53403
- format: options.internalFormat,
53404
- data: levelData,
53405
- width: levelWidth,
53406
- height: levelHeight,
53407
- levelSize
53408
- };
53409
- levelWidth = Math.max(1, levelWidth >> 1);
53410
- levelHeight = Math.max(1, levelHeight >> 1);
53411
- offset += levelSize;
53562
+ // ../images/src/lib/parsers/parse-to-image-bitmap.ts
53563
+ var EMPTY_OBJECT = {};
53564
+ var imagebitmapOptionsSupported = true;
53565
+ async function parseToImageBitmap(arrayBuffer, options, url) {
53566
+ let blob;
53567
+ if (isSVG(url)) {
53568
+ const image = await parseToImage(arrayBuffer, options, url);
53569
+ blob = image;
53570
+ } else {
53571
+ blob = getBlob(arrayBuffer, url);
53412
53572
  }
53413
- return images;
53573
+ const imagebitmapOptions = options && options.imagebitmap;
53574
+ return await safeCreateImageBitmap(blob, imagebitmapOptions);
53414
53575
  }
53415
- function getLevelData(data, index, offset, levelSize) {
53416
- if (!Array.isArray(data)) {
53417
- return new Uint8Array(data.buffer, data.byteOffset + offset, levelSize);
53576
+ async function safeCreateImageBitmap(blob, imagebitmapOptions = null) {
53577
+ if (isEmptyObject(imagebitmapOptions) || !imagebitmapOptionsSupported) {
53578
+ imagebitmapOptions = null;
53418
53579
  }
53419
- return data[index].levelData;
53580
+ if (imagebitmapOptions) {
53581
+ try {
53582
+ return await createImageBitmap(blob, imagebitmapOptions);
53583
+ } catch (error) {
53584
+ console.warn(error);
53585
+ imagebitmapOptionsSupported = false;
53586
+ }
53587
+ }
53588
+ return await createImageBitmap(blob);
53420
53589
  }
53421
- function getLevelSize(options, levelWidth, levelHeight, data, index) {
53422
- if (!Array.isArray(data)) {
53423
- return options.sizeFunction(levelWidth, levelHeight);
53590
+ function isEmptyObject(object) {
53591
+ for (const key in object || EMPTY_OBJECT) {
53592
+ return false;
53424
53593
  }
53425
- return options.sizeFunction(data[index]);
53594
+ return true;
53426
53595
  }
53427
53596
 
53428
- // ../textures/src/lib/utils/ktx-format-helper.ts
53429
- var VULKAN_TO_WEBGL_FORMAT_MAP = {
53430
- 131: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT,
53431
- 132: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB_S3TC_DXT1_EXT,
53432
- 133: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT1_EXT,
53433
- 134: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
53434
- 135: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT3_EXT,
53435
- 136: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
53436
- 137: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT,
53437
- 138: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
53438
- 139: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RED_RGTC1_EXT,
53439
- 140: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SIGNED_RED_RGTC1_EXT,
53440
- 141: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RED_GREEN_RGTC2_EXT,
53441
- 142: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,
53442
- 147: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB8_ETC2,
53443
- 148: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ETC2,
53444
- 149: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
53445
- 150: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
53446
- 151: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA8_ETC2_EAC,
53447
- 152: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
53448
- 153: GL_EXTENSIONS_CONSTANTS.COMPRESSED_R11_EAC,
53449
- 154: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SIGNED_R11_EAC,
53450
- 155: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RG11_EAC,
53451
- 156: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SIGNED_RG11_EAC,
53452
- 157: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4x4_KHR,
53453
- 158: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
53454
- 159: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5x4_KHR,
53455
- 160: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR,
53456
- 161: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5x5_KHR,
53457
- 162: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
53458
- 163: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6x5_KHR,
53459
- 164: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
53460
- 165: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6x6_KHR,
53461
- 166: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
53462
- 167: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x5_KHR,
53463
- 168: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
53464
- 169: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x6_KHR,
53465
- 170: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
53466
- 171: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x8_KHR,
53467
- 172: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
53468
- 173: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x5_KHR,
53469
- 174: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
53470
- 175: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x6_KHR,
53471
- 176: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
53472
- 177: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x8_KHR,
53473
- 178: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
53474
- 179: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x10_KHR,
53475
- 180: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
53476
- 181: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x10_KHR,
53477
- 182: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
53478
- 183: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x12_KHR,
53479
- 184: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
53480
- 1000054e3: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
53481
- 1000054001: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
53482
- 1000066e3: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4x4_KHR,
53483
- 1000066001: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5x4_KHR,
53484
- 1000066002: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5x5_KHR,
53485
- 1000066003: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6x5_KHR,
53486
- 1000066004: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6x6_KHR,
53487
- 1000066005: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x5_KHR,
53488
- 1000066006: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x6_KHR,
53489
- 1000066007: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x8_KHR,
53490
- 1000066008: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x5_KHR,
53491
- 1000066009: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x6_KHR,
53492
- 1000066010: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x8_KHR,
53493
- 1000066011: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x10_KHR,
53494
- 1000066012: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x10_KHR,
53495
- 1000066013: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x12_KHR
53496
- };
53497
- function mapVkFormatToWebGL(vkFormat) {
53498
- return VULKAN_TO_WEBGL_FORMAT_MAP[vkFormat];
53597
+ // ../images/src/lib/category-api/parse-isobmff-binary.ts
53598
+ function getISOBMFFMediaType(buffer) {
53599
+ if (!checkString(buffer, "ftyp", 4)) {
53600
+ return null;
53601
+ }
53602
+ if ((buffer[8] & 96) === 0) {
53603
+ return null;
53604
+ }
53605
+ return decodeMajorBrand(buffer);
53499
53606
  }
53500
-
53501
- // ../textures/src/lib/parsers/parse-ktx.ts
53502
- var KTX2_ID = [
53503
- 171,
53504
- 75,
53505
- 84,
53506
- 88,
53507
- 32,
53508
- 50,
53509
- 48,
53510
- 187,
53511
- 13,
53512
- 10,
53513
- 26,
53514
- 10
53515
- ];
53516
- function isKTX(data) {
53517
- const id = new Uint8Array(data);
53518
- const notKTX = id.byteLength < KTX2_ID.length || id[0] !== KTX2_ID[0] || id[1] !== KTX2_ID[1] || id[2] !== KTX2_ID[2] || id[3] !== KTX2_ID[3] || id[4] !== KTX2_ID[4] || id[5] !== KTX2_ID[5] || id[6] !== KTX2_ID[6] || id[7] !== KTX2_ID[7] || id[8] !== KTX2_ID[8] || id[9] !== KTX2_ID[9] || id[10] !== KTX2_ID[10] || id[11] !== KTX2_ID[11];
53519
- return !notKTX;
53607
+ function decodeMajorBrand(buffer) {
53608
+ const brandMajor = getUTF8String(buffer, 8, 12).replace("\0", " ").trim();
53609
+ switch (brandMajor) {
53610
+ case "avif":
53611
+ case "avis":
53612
+ return { extension: "avif", mimeType: "image/avif" };
53613
+ default:
53614
+ return null;
53615
+ }
53520
53616
  }
53521
- function parseKTX(arrayBuffer) {
53522
- const uint8Array = new Uint8Array(arrayBuffer);
53523
- const ktx = (0, import_ktx_parse.read)(uint8Array);
53524
- const mipMapLevels = Math.max(1, ktx.levels.length);
53525
- const width = ktx.pixelWidth;
53526
- const height = ktx.pixelHeight;
53527
- const internalFormat = mapVkFormatToWebGL(ktx.vkFormat);
53528
- return extractMipmapImages(ktx.levels, {
53529
- mipMapLevels,
53530
- width,
53531
- height,
53532
- sizeFunction: (level) => level.uncompressedByteLength,
53533
- internalFormat
53534
- });
53617
+ function getUTF8String(array, start, end) {
53618
+ return String.fromCharCode(...array.slice(start, end));
53535
53619
  }
53536
-
53537
- // ../textures/src/lib/parsers/parse-basis.ts
53620
+ function stringToBytes(string) {
53621
+ return [...string].map((character) => character.charCodeAt(0));
53622
+ }
53623
+ function checkString(buffer, header, offset = 0) {
53624
+ const headerBytes = stringToBytes(header);
53625
+ for (let i = 0; i < headerBytes.length; ++i) {
53626
+ if (headerBytes[i] !== buffer[i + offset]) {
53627
+ return false;
53628
+ }
53629
+ }
53630
+ return true;
53631
+ }
53632
+
53633
+ // ../images/src/lib/category-api/binary-image-api.ts
53634
+ var BIG_ENDIAN = false;
53635
+ var LITTLE_ENDIAN = true;
53636
+ function getBinaryImageMetadata(binaryData) {
53637
+ const dataView = toDataView(binaryData);
53638
+ return getPngMetadata(dataView) || getJpegMetadata(dataView) || getGifMetadata(dataView) || getBmpMetadata(dataView) || getISOBMFFMetadata(dataView);
53639
+ }
53640
+ function getISOBMFFMetadata(binaryData) {
53641
+ const buffer = new Uint8Array(binaryData instanceof DataView ? binaryData.buffer : binaryData);
53642
+ const mediaType = getISOBMFFMediaType(buffer);
53643
+ if (!mediaType) {
53644
+ return null;
53645
+ }
53646
+ return {
53647
+ mimeType: mediaType.mimeType,
53648
+ width: 0,
53649
+ height: 0
53650
+ };
53651
+ }
53652
+ function getPngMetadata(binaryData) {
53653
+ const dataView = toDataView(binaryData);
53654
+ const isPng = dataView.byteLength >= 24 && dataView.getUint32(0, BIG_ENDIAN) === 2303741511;
53655
+ if (!isPng) {
53656
+ return null;
53657
+ }
53658
+ return {
53659
+ mimeType: "image/png",
53660
+ width: dataView.getUint32(16, BIG_ENDIAN),
53661
+ height: dataView.getUint32(20, BIG_ENDIAN)
53662
+ };
53663
+ }
53664
+ function getGifMetadata(binaryData) {
53665
+ const dataView = toDataView(binaryData);
53666
+ const isGif = dataView.byteLength >= 10 && dataView.getUint32(0, BIG_ENDIAN) === 1195984440;
53667
+ if (!isGif) {
53668
+ return null;
53669
+ }
53670
+ return {
53671
+ mimeType: "image/gif",
53672
+ width: dataView.getUint16(6, LITTLE_ENDIAN),
53673
+ height: dataView.getUint16(8, LITTLE_ENDIAN)
53674
+ };
53675
+ }
53676
+ function getBmpMetadata(binaryData) {
53677
+ const dataView = toDataView(binaryData);
53678
+ const isBmp = dataView.byteLength >= 14 && dataView.getUint16(0, BIG_ENDIAN) === 16973 && dataView.getUint32(2, LITTLE_ENDIAN) === dataView.byteLength;
53679
+ if (!isBmp) {
53680
+ return null;
53681
+ }
53682
+ return {
53683
+ mimeType: "image/bmp",
53684
+ width: dataView.getUint32(18, LITTLE_ENDIAN),
53685
+ height: dataView.getUint32(22, LITTLE_ENDIAN)
53686
+ };
53687
+ }
53688
+ function getJpegMetadata(binaryData) {
53689
+ const dataView = toDataView(binaryData);
53690
+ const isJpeg = dataView.byteLength >= 3 && dataView.getUint16(0, BIG_ENDIAN) === 65496 && dataView.getUint8(2) === 255;
53691
+ if (!isJpeg) {
53692
+ return null;
53693
+ }
53694
+ const { tableMarkers, sofMarkers } = getJpegMarkers();
53695
+ let i = 2;
53696
+ while (i + 9 < dataView.byteLength) {
53697
+ const marker2 = dataView.getUint16(i, BIG_ENDIAN);
53698
+ if (sofMarkers.has(marker2)) {
53699
+ return {
53700
+ mimeType: "image/jpeg",
53701
+ height: dataView.getUint16(i + 5, BIG_ENDIAN),
53702
+ width: dataView.getUint16(i + 7, BIG_ENDIAN)
53703
+ };
53704
+ }
53705
+ if (!tableMarkers.has(marker2)) {
53706
+ return null;
53707
+ }
53708
+ i += 2;
53709
+ i += dataView.getUint16(i, BIG_ENDIAN);
53710
+ }
53711
+ return null;
53712
+ }
53713
+ function getJpegMarkers() {
53714
+ const tableMarkers = new Set([65499, 65476, 65484, 65501, 65534]);
53715
+ for (let i = 65504; i < 65520; ++i) {
53716
+ tableMarkers.add(i);
53717
+ }
53718
+ const sofMarkers = new Set([
53719
+ 65472,
53720
+ 65473,
53721
+ 65474,
53722
+ 65475,
53723
+ 65477,
53724
+ 65478,
53725
+ 65479,
53726
+ 65481,
53727
+ 65482,
53728
+ 65483,
53729
+ 65485,
53730
+ 65486,
53731
+ 65487,
53732
+ 65502
53733
+ ]);
53734
+ return { tableMarkers, sofMarkers };
53735
+ }
53736
+ function toDataView(data) {
53737
+ if (data instanceof DataView) {
53738
+ return data;
53739
+ }
53740
+ if (ArrayBuffer.isView(data)) {
53741
+ return new DataView(data.buffer);
53742
+ }
53743
+ if (data instanceof ArrayBuffer) {
53744
+ return new DataView(data);
53745
+ }
53746
+ throw new Error("toDataView");
53747
+ }
53748
+
53749
+ // ../images/src/lib/parsers/parse-to-node-image.ts
53750
+ async function parseToNodeImage(arrayBuffer, options) {
53751
+ const { mimeType } = getBinaryImageMetadata(arrayBuffer) || {};
53752
+ const _parseImageNode2 = globalThis._parseImageNode;
53753
+ assert2(_parseImageNode2);
53754
+ return await _parseImageNode2(arrayBuffer, mimeType);
53755
+ }
53756
+
53757
+ // ../images/src/lib/parsers/parse-image.ts
53758
+ async function parseImage(arrayBuffer, options, context) {
53759
+ options = options || {};
53760
+ const imageOptions = options.image || {};
53761
+ const imageType = imageOptions.type || "auto";
53762
+ const { url } = context || {};
53763
+ const loadType = getLoadableImageType(imageType);
53764
+ let image;
53765
+ switch (loadType) {
53766
+ case "imagebitmap":
53767
+ image = await parseToImageBitmap(arrayBuffer, options, url);
53768
+ break;
53769
+ case "image":
53770
+ image = await parseToImage(arrayBuffer, options, url);
53771
+ break;
53772
+ case "data":
53773
+ image = await parseToNodeImage(arrayBuffer, options);
53774
+ break;
53775
+ default:
53776
+ assert2(false);
53777
+ }
53778
+ if (imageType === "data") {
53779
+ image = getImageData(image);
53780
+ }
53781
+ return image;
53782
+ }
53783
+ function getLoadableImageType(type) {
53784
+ switch (type) {
53785
+ case "auto":
53786
+ case "data":
53787
+ return getDefaultImageType();
53788
+ default:
53789
+ isImageTypeSupported(type);
53790
+ return type;
53791
+ }
53792
+ }
53793
+
53794
+ // ../images/src/image-loader.ts
53795
+ var EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "svg", "avif"];
53796
+ var MIME_TYPES = [
53797
+ "image/png",
53798
+ "image/jpeg",
53799
+ "image/gif",
53800
+ "image/webp",
53801
+ "image/avif",
53802
+ "image/bmp",
53803
+ "image/vnd.microsoft.icon",
53804
+ "image/svg+xml"
53805
+ ];
53806
+ var DEFAULT_IMAGE_LOADER_OPTIONS = {
53807
+ image: {
53808
+ type: "auto",
53809
+ decode: true
53810
+ }
53811
+ };
53812
+ var ImageLoader = {
53813
+ id: "image",
53814
+ module: "images",
53815
+ name: "Images",
53816
+ version: VERSION9,
53817
+ mimeTypes: MIME_TYPES,
53818
+ extensions: EXTENSIONS,
53819
+ parse: parseImage,
53820
+ tests: [(arrayBuffer) => Boolean(getBinaryImageMetadata(new DataView(arrayBuffer)))],
53821
+ options: DEFAULT_IMAGE_LOADER_OPTIONS
53822
+ };
53823
+
53824
+ // ../images/src/lib/encoders/encode-image.ts
53825
+ var { _encodeImageNode } = globalThis;
53826
+ async function encodeImage(image, options) {
53827
+ options = options || {};
53828
+ options.image = options.image || {};
53829
+ return _encodeImageNode ? _encodeImageNode(image, { type: options.image.mimeType }) : encodeImageInBrowser(image, options);
53830
+ }
53831
+ var qualityParamSupported = true;
53832
+ async function encodeImageInBrowser(image, options) {
53833
+ const { mimeType, jpegQuality } = options.image;
53834
+ const { width, height } = getImageSize(image);
53835
+ const canvas = document.createElement("canvas");
53836
+ canvas.width = width;
53837
+ canvas.height = height;
53838
+ drawImageToCanvas(image, canvas);
53839
+ const blob = await new Promise((resolve2) => {
53840
+ if (jpegQuality && qualityParamSupported) {
53841
+ try {
53842
+ canvas.toBlob(resolve2, mimeType, jpegQuality);
53843
+ return;
53844
+ } catch (error) {
53845
+ qualityParamSupported = false;
53846
+ }
53847
+ }
53848
+ canvas.toBlob(resolve2, mimeType);
53849
+ });
53850
+ if (!blob) {
53851
+ throw new Error("image encoding failed");
53852
+ }
53853
+ return await blob.arrayBuffer();
53854
+ }
53855
+ function drawImageToCanvas(image, canvas, x = 0, y = 0) {
53856
+ if (x === 0 && y === 0 && typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap) {
53857
+ const context2 = canvas.getContext("bitmaprenderer");
53858
+ if (context2) {
53859
+ context2.transferFromImageBitmap(image);
53860
+ return canvas;
53861
+ }
53862
+ }
53863
+ const context = canvas.getContext("2d");
53864
+ if (image.data) {
53865
+ const clampedArray = new Uint8ClampedArray(image.data);
53866
+ const imageData = new ImageData(clampedArray, image.width, image.height);
53867
+ context.putImageData(imageData, 0, 0);
53868
+ return canvas;
53869
+ }
53870
+ context.drawImage(image, 0, 0);
53871
+ return canvas;
53872
+ }
53873
+
53874
+ // ../images/src/image-writer.ts
53875
+ var ImageWriter = {
53876
+ name: "Images",
53877
+ id: "image",
53878
+ module: "images",
53879
+ version: VERSION9,
53880
+ extensions: ["jpeg"],
53881
+ options: {
53882
+ image: {
53883
+ mimeType: "image/png",
53884
+ jpegQuality: null
53885
+ }
53886
+ },
53887
+ encode: encodeImage
53888
+ };
53889
+
53890
+ // ../images/src/lib/category-api/image-format.ts
53891
+ var mimeTypeSupportedSync = {};
53892
+ function isImageFormatSupported(mimeType) {
53893
+ if (mimeTypeSupportedSync[mimeType] === void 0) {
53894
+ const supported = isBrowser ? checkBrowserImageFormatSupport(mimeType) : checkNodeImageFormatSupport(mimeType);
53895
+ mimeTypeSupportedSync[mimeType] = supported;
53896
+ }
53897
+ return mimeTypeSupportedSync[mimeType];
53898
+ }
53899
+ function checkNodeImageFormatSupport(mimeType) {
53900
+ const NODE_FORMAT_SUPPORT = ["image/png", "image/jpeg", "image/gif"];
53901
+ const { _parseImageNode: _parseImageNode2, _imageFormatsNode = NODE_FORMAT_SUPPORT } = globalThis;
53902
+ return Boolean(_parseImageNode2) && _imageFormatsNode.includes(mimeType);
53903
+ }
53904
+ function checkBrowserImageFormatSupport(mimeType) {
53905
+ switch (mimeType) {
53906
+ case "image/avif":
53907
+ case "image/webp":
53908
+ return testBrowserImageFormatSupport(mimeType);
53909
+ default:
53910
+ return true;
53911
+ }
53912
+ }
53913
+ function testBrowserImageFormatSupport(mimeType) {
53914
+ try {
53915
+ const element = document.createElement("canvas");
53916
+ const dataURL = element.toDataURL(mimeType);
53917
+ return dataURL.indexOf(`data:${mimeType}`) === 0;
53918
+ } catch {
53919
+ return false;
53920
+ }
53921
+ }
53922
+
53923
+ // ../textures/src/lib/utils/version.ts
53924
+ var VERSION10 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
53925
+
53926
+ // ../textures/src/lib/parsers/basis-module-loader.ts
53927
+ var VERSION11 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
53928
+ var BASIS_CDN_ENCODER_WASM = `https://unpkg.com/@loaders.gl/textures@${VERSION11}/dist/libs/basis_encoder.wasm`;
53929
+ var BASIS_CDN_ENCODER_JS = `https://unpkg.com/@loaders.gl/textures@${VERSION11}/dist/libs/basis_encoder.js`;
53930
+ var loadBasisTranscoderPromise;
53931
+ async function loadBasisTrascoderModule(options) {
53932
+ const modules = options.modules || {};
53933
+ if (modules.basis) {
53934
+ return modules.basis;
53935
+ }
53936
+ loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTrascoder(options);
53937
+ return await loadBasisTranscoderPromise;
53938
+ }
53939
+ async function loadBasisTrascoder(options) {
53940
+ let BASIS = null;
53941
+ let wasmBinary = null;
53942
+ [BASIS, wasmBinary] = await Promise.all([
53943
+ await loadLibrary("basis_transcoder.js", "textures", options),
53944
+ await loadLibrary("basis_transcoder.wasm", "textures", options)
53945
+ ]);
53946
+ BASIS = BASIS || globalThis.BASIS;
53947
+ return await initializeBasisTrascoderModule(BASIS, wasmBinary);
53948
+ }
53949
+ function initializeBasisTrascoderModule(BasisModule, wasmBinary) {
53950
+ const options = {};
53951
+ if (wasmBinary) {
53952
+ options.wasmBinary = wasmBinary;
53953
+ }
53954
+ return new Promise((resolve2) => {
53955
+ BasisModule(options).then((module2) => {
53956
+ const { BasisFile, initializeBasis } = module2;
53957
+ initializeBasis();
53958
+ resolve2({ BasisFile });
53959
+ });
53960
+ });
53961
+ }
53962
+ var loadBasisEncoderPromise;
53963
+ async function loadBasisEncoderModule(options) {
53964
+ const modules = options.modules || {};
53965
+ if (modules.basisEncoder) {
53966
+ return modules.basisEncoder;
53967
+ }
53968
+ loadBasisEncoderPromise = loadBasisEncoderPromise || loadBasisEncoder(options);
53969
+ return await loadBasisEncoderPromise;
53970
+ }
53971
+ async function loadBasisEncoder(options) {
53972
+ let BASIS_ENCODER = null;
53973
+ let wasmBinary = null;
53974
+ [BASIS_ENCODER, wasmBinary] = await Promise.all([
53975
+ await loadLibrary(BASIS_CDN_ENCODER_JS, "textures", options),
53976
+ await loadLibrary(BASIS_CDN_ENCODER_WASM, "textures", options)
53977
+ ]);
53978
+ BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
53979
+ return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
53980
+ }
53981
+ function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
53982
+ const options = {};
53983
+ if (wasmBinary) {
53984
+ options.wasmBinary = wasmBinary;
53985
+ }
53986
+ return new Promise((resolve2) => {
53987
+ BasisEncoderModule(options).then((module2) => {
53988
+ const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module2;
53989
+ initializeBasis();
53990
+ resolve2({ BasisFile, KTX2File, BasisEncoder });
53991
+ });
53992
+ });
53993
+ }
53994
+
53995
+ // ../textures/src/lib/gl-extensions.ts
53996
+ var GL_EXTENSIONS_CONSTANTS = {
53997
+ COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
53998
+ COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
53999
+ COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
54000
+ COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779,
54001
+ COMPRESSED_R11_EAC: 37488,
54002
+ COMPRESSED_SIGNED_R11_EAC: 37489,
54003
+ COMPRESSED_RG11_EAC: 37490,
54004
+ COMPRESSED_SIGNED_RG11_EAC: 37491,
54005
+ COMPRESSED_RGB8_ETC2: 37492,
54006
+ COMPRESSED_RGBA8_ETC2_EAC: 37493,
54007
+ COMPRESSED_SRGB8_ETC2: 37494,
54008
+ COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
54009
+ COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
54010
+ COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
54011
+ COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
54012
+ COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
54013
+ COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
54014
+ COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
54015
+ COMPRESSED_RGB_ETC1_WEBGL: 36196,
54016
+ COMPRESSED_RGB_ATC_WEBGL: 35986,
54017
+ COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
54018
+ COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
54019
+ COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
54020
+ COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
54021
+ COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
54022
+ COMPRESSED_RGBA_ASTC_6X5_KHR: 37811,
54023
+ COMPRESSED_RGBA_ASTC_6X6_KHR: 37812,
54024
+ COMPRESSED_RGBA_ASTC_8X5_KHR: 37813,
54025
+ COMPRESSED_RGBA_ASTC_8X6_KHR: 37814,
54026
+ COMPRESSED_RGBA_ASTC_8X8_KHR: 37815,
54027
+ COMPRESSED_RGBA_ASTC_10X5_KHR: 37816,
54028
+ COMPRESSED_RGBA_ASTC_10X6_KHR: 37817,
54029
+ COMPRESSED_RGBA_ASTC_10X8_KHR: 37818,
54030
+ COMPRESSED_RGBA_ASTC_10X10_KHR: 37819,
54031
+ COMPRESSED_RGBA_ASTC_12X10_KHR: 37820,
54032
+ COMPRESSED_RGBA_ASTC_12X12_KHR: 37821,
54033
+ COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: 37840,
54034
+ COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: 37841,
54035
+ COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: 37842,
54036
+ COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: 37843,
54037
+ COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: 37844,
54038
+ COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: 37845,
54039
+ COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: 37846,
54040
+ COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: 37847,
54041
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: 37848,
54042
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: 37849,
54043
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: 37850,
54044
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
54045
+ COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
54046
+ COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
54047
+ COMPRESSED_RED_RGTC1_EXT: 36283,
54048
+ COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
54049
+ COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
54050
+ COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
54051
+ COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
54052
+ COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
54053
+ COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
54054
+ COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: 35919
54055
+ };
54056
+
54057
+ // ../textures/src/lib/utils/texture-formats.ts
54058
+ var BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
54059
+ var WEBGL_EXTENSIONS = {
54060
+ WEBGL_compressed_texture_s3tc: "dxt",
54061
+ WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb",
54062
+ WEBGL_compressed_texture_etc1: "etc1",
54063
+ WEBGL_compressed_texture_etc: "etc2",
54064
+ WEBGL_compressed_texture_pvrtc: "pvrtc",
54065
+ WEBGL_compressed_texture_atc: "atc",
54066
+ WEBGL_compressed_texture_astc: "astc",
54067
+ EXT_texture_compression_rgtc: "rgtc"
54068
+ };
54069
+ var formats = null;
54070
+ function getSupportedGPUTextureFormats(gl) {
54071
+ if (!formats) {
54072
+ gl = gl || getWebGLContext() || void 0;
54073
+ formats = new Set();
54074
+ for (const prefix of BROWSER_PREFIXES) {
54075
+ for (const extension in WEBGL_EXTENSIONS) {
54076
+ if (gl && gl.getExtension(`${prefix}${extension}`)) {
54077
+ const gpuTextureFormat = WEBGL_EXTENSIONS[extension];
54078
+ formats.add(gpuTextureFormat);
54079
+ }
54080
+ }
54081
+ }
54082
+ }
54083
+ return formats;
54084
+ }
54085
+ function getWebGLContext() {
54086
+ try {
54087
+ const canvas = document.createElement("canvas");
54088
+ return canvas.getContext("webgl");
54089
+ } catch (error) {
54090
+ return null;
54091
+ }
54092
+ }
54093
+
54094
+ // ../textures/src/lib/parsers/parse-ktx.ts
54095
+ var import_ktx_parse = __toModule(require_ktx_parse());
54096
+
54097
+ // ../textures/src/lib/utils/extract-mipmap-images.ts
54098
+ function extractMipmapImages(data, options) {
54099
+ const images = new Array(options.mipMapLevels);
54100
+ let levelWidth = options.width;
54101
+ let levelHeight = options.height;
54102
+ let offset = 0;
54103
+ for (let i = 0; i < options.mipMapLevels; ++i) {
54104
+ const levelSize = getLevelSize(options, levelWidth, levelHeight, data, i);
54105
+ const levelData = getLevelData(data, i, offset, levelSize);
54106
+ images[i] = {
54107
+ compressed: true,
54108
+ format: options.internalFormat,
54109
+ data: levelData,
54110
+ width: levelWidth,
54111
+ height: levelHeight,
54112
+ levelSize
54113
+ };
54114
+ levelWidth = Math.max(1, levelWidth >> 1);
54115
+ levelHeight = Math.max(1, levelHeight >> 1);
54116
+ offset += levelSize;
54117
+ }
54118
+ return images;
54119
+ }
54120
+ function getLevelData(data, index, offset, levelSize) {
54121
+ if (!Array.isArray(data)) {
54122
+ return new Uint8Array(data.buffer, data.byteOffset + offset, levelSize);
54123
+ }
54124
+ return data[index].levelData;
54125
+ }
54126
+ function getLevelSize(options, levelWidth, levelHeight, data, index) {
54127
+ if (!Array.isArray(data)) {
54128
+ return options.sizeFunction(levelWidth, levelHeight);
54129
+ }
54130
+ return options.sizeFunction(data[index]);
54131
+ }
54132
+
54133
+ // ../textures/src/lib/utils/ktx-format-helper.ts
54134
+ var VULKAN_TO_WEBGL_FORMAT_MAP = {
54135
+ 131: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT,
54136
+ 132: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB_S3TC_DXT1_EXT,
54137
+ 133: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT1_EXT,
54138
+ 134: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
54139
+ 135: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT3_EXT,
54140
+ 136: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
54141
+ 137: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT,
54142
+ 138: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
54143
+ 139: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RED_RGTC1_EXT,
54144
+ 140: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SIGNED_RED_RGTC1_EXT,
54145
+ 141: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RED_GREEN_RGTC2_EXT,
54146
+ 142: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,
54147
+ 147: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB8_ETC2,
54148
+ 148: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ETC2,
54149
+ 149: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
54150
+ 150: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
54151
+ 151: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA8_ETC2_EAC,
54152
+ 152: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
54153
+ 153: GL_EXTENSIONS_CONSTANTS.COMPRESSED_R11_EAC,
54154
+ 154: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SIGNED_R11_EAC,
54155
+ 155: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RG11_EAC,
54156
+ 156: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SIGNED_RG11_EAC,
54157
+ 157: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4x4_KHR,
54158
+ 158: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
54159
+ 159: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5x4_KHR,
54160
+ 160: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR,
54161
+ 161: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5x5_KHR,
54162
+ 162: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
54163
+ 163: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6x5_KHR,
54164
+ 164: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
54165
+ 165: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6x6_KHR,
54166
+ 166: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
54167
+ 167: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x5_KHR,
54168
+ 168: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
54169
+ 169: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x6_KHR,
54170
+ 170: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
54171
+ 171: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x8_KHR,
54172
+ 172: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
54173
+ 173: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x5_KHR,
54174
+ 174: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
54175
+ 175: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x6_KHR,
54176
+ 176: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
54177
+ 177: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x8_KHR,
54178
+ 178: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
54179
+ 179: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x10_KHR,
54180
+ 180: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
54181
+ 181: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x10_KHR,
54182
+ 182: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
54183
+ 183: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x12_KHR,
54184
+ 184: GL_EXTENSIONS_CONSTANTS.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
54185
+ 1000054e3: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
54186
+ 1000054001: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
54187
+ 1000066e3: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4x4_KHR,
54188
+ 1000066001: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5x4_KHR,
54189
+ 1000066002: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_5x5_KHR,
54190
+ 1000066003: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6x5_KHR,
54191
+ 1000066004: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_6x6_KHR,
54192
+ 1000066005: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x5_KHR,
54193
+ 1000066006: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x6_KHR,
54194
+ 1000066007: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_8x8_KHR,
54195
+ 1000066008: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x5_KHR,
54196
+ 1000066009: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x6_KHR,
54197
+ 1000066010: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x8_KHR,
54198
+ 1000066011: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_10x10_KHR,
54199
+ 1000066012: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x10_KHR,
54200
+ 1000066013: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_12x12_KHR
54201
+ };
54202
+ function mapVkFormatToWebGL(vkFormat) {
54203
+ return VULKAN_TO_WEBGL_FORMAT_MAP[vkFormat];
54204
+ }
54205
+
54206
+ // ../textures/src/lib/parsers/parse-ktx.ts
54207
+ var KTX2_ID = [
54208
+ 171,
54209
+ 75,
54210
+ 84,
54211
+ 88,
54212
+ 32,
54213
+ 50,
54214
+ 48,
54215
+ 187,
54216
+ 13,
54217
+ 10,
54218
+ 26,
54219
+ 10
54220
+ ];
54221
+ function isKTX(data) {
54222
+ const id = new Uint8Array(data);
54223
+ const notKTX = id.byteLength < KTX2_ID.length || id[0] !== KTX2_ID[0] || id[1] !== KTX2_ID[1] || id[2] !== KTX2_ID[2] || id[3] !== KTX2_ID[3] || id[4] !== KTX2_ID[4] || id[5] !== KTX2_ID[5] || id[6] !== KTX2_ID[6] || id[7] !== KTX2_ID[7] || id[8] !== KTX2_ID[8] || id[9] !== KTX2_ID[9] || id[10] !== KTX2_ID[10] || id[11] !== KTX2_ID[11];
54224
+ return !notKTX;
54225
+ }
54226
+ function parseKTX(arrayBuffer) {
54227
+ const uint8Array = new Uint8Array(arrayBuffer);
54228
+ const ktx = (0, import_ktx_parse.read)(uint8Array);
54229
+ const mipMapLevels = Math.max(1, ktx.levels.length);
54230
+ const width = ktx.pixelWidth;
54231
+ const height = ktx.pixelHeight;
54232
+ const internalFormat = mapVkFormatToWebGL(ktx.vkFormat);
54233
+ return extractMipmapImages(ktx.levels, {
54234
+ mipMapLevels,
54235
+ width,
54236
+ height,
54237
+ sizeFunction: (level) => level.uncompressedByteLength,
54238
+ internalFormat
54239
+ });
54240
+ }
54241
+
54242
+ // ../textures/src/lib/parsers/parse-basis.ts
53538
54243
  var OutputFormat = {
53539
54244
  etc1: {
53540
54245
  basisFormat: 0,
@@ -53716,9 +54421,9 @@ function selectSupportedBasisFormat() {
53716
54421
  // ../textures/src/basis-loader.ts
53717
54422
  var BasisWorkerLoader = {
53718
54423
  name: "Basis",
53719
- id: isBrowser2 ? "basis" : "basis-nodejs",
54424
+ id: "basis",
53720
54425
  module: "textures",
53721
- version: VERSION9,
54426
+ version: VERSION10,
53722
54427
  worker: true,
53723
54428
  extensions: ["basis", "ktx2"],
53724
54429
  mimeTypes: ["application/octet-stream", "image/ktx2"],
@@ -53955,624 +54660,125 @@ function pvrtc2bppSize(width, height) {
53955
54660
  height = Math.max(height, 8);
53956
54661
  return width * height / 4;
53957
54662
  }
53958
- function pvrtc4bppSize(width, height) {
53959
- width = Math.max(width, 8);
53960
- height = Math.max(height, 8);
53961
- return width * height / 2;
53962
- }
53963
- function dxtEtcSmallSize(width, height) {
53964
- return Math.floor((width + 3) / 4) * Math.floor((height + 3) / 4) * 8;
53965
- }
53966
- function dxtEtcAstcBigSize(width, height) {
53967
- return Math.floor((width + 3) / 4) * Math.floor((height + 3) / 4) * 16;
53968
- }
53969
- function atc5x4Size(width, height) {
53970
- return Math.floor((width + 4) / 5) * Math.floor((height + 3) / 4) * 16;
53971
- }
53972
- function atc5x5Size(width, height) {
53973
- return Math.floor((width + 4) / 5) * Math.floor((height + 4) / 5) * 16;
53974
- }
53975
- function atc6x5Size(width, height) {
53976
- return Math.floor((width + 5) / 6) * Math.floor((height + 4) / 5) * 16;
53977
- }
53978
- function atc6x6Size(width, height) {
53979
- return Math.floor((width + 5) / 6) * Math.floor((height + 5) / 6) * 16;
53980
- }
53981
- function atc8x5Size(width, height) {
53982
- return Math.floor((width + 7) / 8) * Math.floor((height + 4) / 5) * 16;
53983
- }
53984
- function atc8x6Size(width, height) {
53985
- return Math.floor((width + 7) / 8) * Math.floor((height + 5) / 6) * 16;
53986
- }
53987
- function atc8x8Size(width, height) {
53988
- return Math.floor((width + 7) / 8) * Math.floor((height + 7) / 8) * 16;
53989
- }
53990
- function atc10x5Size(width, height) {
53991
- return Math.floor((width + 9) / 10) * Math.floor((height + 4) / 5) * 16;
53992
- }
53993
- function atc10x6Size(width, height) {
53994
- return Math.floor((width + 9) / 10) * Math.floor((height + 5) / 6) * 16;
53995
- }
53996
- function atc10x8Size(width, height) {
53997
- return Math.floor((width + 9) / 10) * Math.floor((height + 7) / 8) * 16;
53998
- }
53999
- function atc10x10Size(width, height) {
54000
- return Math.floor((width + 9) / 10) * Math.floor((height + 9) / 10) * 16;
54001
- }
54002
- function atc12x10Size(width, height) {
54003
- return Math.floor((width + 11) / 12) * Math.floor((height + 9) / 10) * 16;
54004
- }
54005
- function atc12x12Size(width, height) {
54006
- return Math.floor((width + 11) / 12) * Math.floor((height + 11) / 12) * 16;
54007
- }
54008
-
54009
- // ../textures/src/lib/parsers/parse-compressed-texture.ts
54010
- function parseCompressedTexture(data) {
54011
- if (isKTX(data)) {
54012
- return parseKTX(data);
54013
- }
54014
- if (isDDS(data)) {
54015
- return parseDDS(data);
54016
- }
54017
- if (isPVR(data)) {
54018
- return parsePVR(data);
54019
- }
54020
- throw new Error("Texture container format not recognized");
54021
- }
54022
-
54023
- // ../textures/src/compressed-texture-loader.ts
54024
- var DEFAULT_TEXTURE_LOADER_OPTIONS = {
54025
- "compressed-texture": {
54026
- libraryPath: "libs/",
54027
- useBasis: false
54028
- }
54029
- };
54030
- var CompressedTextureWorkerLoader = {
54031
- name: "Texture Containers",
54032
- id: "compressed-texture",
54033
- module: "textures",
54034
- version: VERSION9,
54035
- worker: true,
54036
- extensions: [
54037
- "ktx",
54038
- "ktx2",
54039
- "dds",
54040
- "pvr"
54041
- ],
54042
- mimeTypes: [
54043
- "image/ktx2",
54044
- "image/ktx",
54045
- "image/vnd-ms.dds",
54046
- "image/x-dds",
54047
- "application/octet-stream"
54048
- ],
54049
- binary: true,
54050
- options: DEFAULT_TEXTURE_LOADER_OPTIONS
54051
- };
54052
- var CompressedTextureLoader = {
54053
- ...CompressedTextureWorkerLoader,
54054
- parse: async (arrayBuffer, options) => {
54055
- if (options["compressed-texture"].useBasis) {
54056
- options.basis = {
54057
- format: {
54058
- alpha: "BC3",
54059
- noAlpha: "BC1"
54060
- },
54061
- ...options.basis,
54062
- containerFormat: "ktx2",
54063
- module: "encoder"
54064
- };
54065
- return (await parseBasis(arrayBuffer, options))[0];
54066
- }
54067
- return parseCompressedTexture(arrayBuffer);
54068
- }
54069
- };
54070
-
54071
- // ../images/src/lib/utils/version.ts
54072
- var VERSION11 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
54073
-
54074
- // ../images/src/lib/category-api/image-type.ts
54075
- var { _parseImageNode } = globalThis;
54076
- var IMAGE_SUPPORTED = typeof Image !== "undefined";
54077
- var IMAGE_BITMAP_SUPPORTED = typeof ImageBitmap !== "undefined";
54078
- var NODE_IMAGE_SUPPORTED = Boolean(_parseImageNode);
54079
- var DATA_SUPPORTED = isBrowser ? true : NODE_IMAGE_SUPPORTED;
54080
- function isImageTypeSupported(type) {
54081
- switch (type) {
54082
- case "auto":
54083
- return IMAGE_BITMAP_SUPPORTED || IMAGE_SUPPORTED || DATA_SUPPORTED;
54084
- case "imagebitmap":
54085
- return IMAGE_BITMAP_SUPPORTED;
54086
- case "image":
54087
- return IMAGE_SUPPORTED;
54088
- case "data":
54089
- return DATA_SUPPORTED;
54090
- default:
54091
- throw new Error(`@loaders.gl/images: image ${type} not supported in this environment`);
54092
- }
54093
- }
54094
- function getDefaultImageType() {
54095
- if (IMAGE_BITMAP_SUPPORTED) {
54096
- return "imagebitmap";
54097
- }
54098
- if (IMAGE_SUPPORTED) {
54099
- return "image";
54100
- }
54101
- if (DATA_SUPPORTED) {
54102
- return "data";
54103
- }
54104
- throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js");
54105
- }
54106
-
54107
- // ../images/src/lib/category-api/parsed-image-api.ts
54108
- function getImageType(image) {
54109
- const format = getImageTypeOrNull(image);
54110
- if (!format) {
54111
- throw new Error("Not an image");
54112
- }
54113
- return format;
54114
- }
54115
- function getImageSize(image) {
54116
- return getImageData(image);
54117
- }
54118
- function getImageData(image) {
54119
- switch (getImageType(image)) {
54120
- case "data":
54121
- return image;
54122
- case "image":
54123
- case "imagebitmap":
54124
- const canvas = document.createElement("canvas");
54125
- const context = canvas.getContext("2d");
54126
- if (!context) {
54127
- throw new Error("getImageData");
54128
- }
54129
- canvas.width = image.width;
54130
- canvas.height = image.height;
54131
- context.drawImage(image, 0, 0);
54132
- return context.getImageData(0, 0, image.width, image.height);
54133
- default:
54134
- throw new Error("getImageData");
54135
- }
54136
- }
54137
- function getImageTypeOrNull(image) {
54138
- if (typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap) {
54139
- return "imagebitmap";
54140
- }
54141
- if (typeof Image !== "undefined" && image instanceof Image) {
54142
- return "image";
54143
- }
54144
- if (image && typeof image === "object" && image.data && image.width && image.height) {
54145
- return "data";
54146
- }
54147
- return null;
54148
- }
54149
-
54150
- // ../images/src/lib/parsers/svg-utils.ts
54151
- var SVG_DATA_URL_PATTERN = /^data:image\/svg\+xml/;
54152
- var SVG_URL_PATTERN = /\.svg((\?|#).*)?$/;
54153
- function isSVG(url) {
54154
- return url && (SVG_DATA_URL_PATTERN.test(url) || SVG_URL_PATTERN.test(url));
54155
- }
54156
- function getBlobOrSVGDataUrl(arrayBuffer, url) {
54157
- if (isSVG(url)) {
54158
- const textDecoder = new TextDecoder();
54159
- let xmlText = textDecoder.decode(arrayBuffer);
54160
- try {
54161
- if (typeof unescape === "function" && typeof encodeURIComponent === "function") {
54162
- xmlText = unescape(encodeURIComponent(xmlText));
54163
- }
54164
- } catch (error) {
54165
- throw new Error(error.message);
54166
- }
54167
- const src = `data:image/svg+xml;base64,${btoa(xmlText)}`;
54168
- return src;
54169
- }
54170
- return getBlob(arrayBuffer, url);
54171
- }
54172
- function getBlob(arrayBuffer, url) {
54173
- if (isSVG(url)) {
54174
- throw new Error("SVG cannot be parsed directly to imagebitmap");
54175
- }
54176
- return new Blob([new Uint8Array(arrayBuffer)]);
54177
- }
54178
-
54179
- // ../images/src/lib/parsers/parse-to-image.ts
54180
- async function parseToImage(arrayBuffer, options, url) {
54181
- const blobOrDataUrl = getBlobOrSVGDataUrl(arrayBuffer, url);
54182
- const URL2 = self.URL || self.webkitURL;
54183
- const objectUrl = typeof blobOrDataUrl !== "string" && URL2.createObjectURL(blobOrDataUrl);
54184
- try {
54185
- return await loadToImage(objectUrl || blobOrDataUrl, options);
54186
- } finally {
54187
- if (objectUrl) {
54188
- URL2.revokeObjectURL(objectUrl);
54189
- }
54190
- }
54191
- }
54192
- async function loadToImage(url, options) {
54193
- const image = new Image();
54194
- image.src = url;
54195
- if (options.image && options.image.decode && image.decode) {
54196
- await image.decode();
54197
- return image;
54198
- }
54199
- return await new Promise((resolve2, reject) => {
54200
- try {
54201
- image.onload = () => resolve2(image);
54202
- image.onerror = (err) => reject(new Error(`Could not load image ${url}: ${err}`));
54203
- } catch (error) {
54204
- reject(error);
54205
- }
54206
- });
54207
- }
54208
-
54209
- // ../images/src/lib/parsers/parse-to-image-bitmap.ts
54210
- var EMPTY_OBJECT = {};
54211
- var imagebitmapOptionsSupported = true;
54212
- async function parseToImageBitmap(arrayBuffer, options, url) {
54213
- let blob;
54214
- if (isSVG(url)) {
54215
- const image = await parseToImage(arrayBuffer, options, url);
54216
- blob = image;
54217
- } else {
54218
- blob = getBlob(arrayBuffer, url);
54219
- }
54220
- const imagebitmapOptions = options && options.imagebitmap;
54221
- return await safeCreateImageBitmap(blob, imagebitmapOptions);
54222
- }
54223
- async function safeCreateImageBitmap(blob, imagebitmapOptions = null) {
54224
- if (isEmptyObject(imagebitmapOptions) || !imagebitmapOptionsSupported) {
54225
- imagebitmapOptions = null;
54226
- }
54227
- if (imagebitmapOptions) {
54228
- try {
54229
- return await createImageBitmap(blob, imagebitmapOptions);
54230
- } catch (error) {
54231
- console.warn(error);
54232
- imagebitmapOptionsSupported = false;
54233
- }
54234
- }
54235
- return await createImageBitmap(blob);
54236
- }
54237
- function isEmptyObject(object) {
54238
- for (const key in object || EMPTY_OBJECT) {
54239
- return false;
54240
- }
54241
- return true;
54663
+ function pvrtc4bppSize(width, height) {
54664
+ width = Math.max(width, 8);
54665
+ height = Math.max(height, 8);
54666
+ return width * height / 2;
54242
54667
  }
54243
-
54244
- // ../images/src/lib/category-api/parse-isobmff-binary.ts
54245
- function getISOBMFFMediaType(buffer) {
54246
- if (!checkString(buffer, "ftyp", 4)) {
54247
- return null;
54248
- }
54249
- if ((buffer[8] & 96) === 0) {
54250
- return null;
54251
- }
54252
- return decodeMajorBrand(buffer);
54668
+ function dxtEtcSmallSize(width, height) {
54669
+ return Math.floor((width + 3) / 4) * Math.floor((height + 3) / 4) * 8;
54253
54670
  }
54254
- function decodeMajorBrand(buffer) {
54255
- const brandMajor = getUTF8String(buffer, 8, 12).replace("\0", " ").trim();
54256
- switch (brandMajor) {
54257
- case "avif":
54258
- case "avis":
54259
- return { extension: "avif", mimeType: "image/avif" };
54260
- default:
54261
- return null;
54262
- }
54671
+ function dxtEtcAstcBigSize(width, height) {
54672
+ return Math.floor((width + 3) / 4) * Math.floor((height + 3) / 4) * 16;
54263
54673
  }
54264
- function getUTF8String(array, start, end) {
54265
- return String.fromCharCode(...array.slice(start, end));
54674
+ function atc5x4Size(width, height) {
54675
+ return Math.floor((width + 4) / 5) * Math.floor((height + 3) / 4) * 16;
54266
54676
  }
54267
- function stringToBytes(string) {
54268
- return [...string].map((character) => character.charCodeAt(0));
54677
+ function atc5x5Size(width, height) {
54678
+ return Math.floor((width + 4) / 5) * Math.floor((height + 4) / 5) * 16;
54269
54679
  }
54270
- function checkString(buffer, header, offset = 0) {
54271
- const headerBytes = stringToBytes(header);
54272
- for (let i = 0; i < headerBytes.length; ++i) {
54273
- if (headerBytes[i] !== buffer[i + offset]) {
54274
- return false;
54275
- }
54276
- }
54277
- return true;
54680
+ function atc6x5Size(width, height) {
54681
+ return Math.floor((width + 5) / 6) * Math.floor((height + 4) / 5) * 16;
54278
54682
  }
54279
-
54280
- // ../images/src/lib/category-api/binary-image-api.ts
54281
- var BIG_ENDIAN = false;
54282
- var LITTLE_ENDIAN = true;
54283
- function getBinaryImageMetadata(binaryData) {
54284
- const dataView = toDataView(binaryData);
54285
- return getPngMetadata(dataView) || getJpegMetadata(dataView) || getGifMetadata(dataView) || getBmpMetadata(dataView) || getISOBMFFMetadata(dataView);
54683
+ function atc6x6Size(width, height) {
54684
+ return Math.floor((width + 5) / 6) * Math.floor((height + 5) / 6) * 16;
54286
54685
  }
54287
- function getISOBMFFMetadata(binaryData) {
54288
- const buffer = new Uint8Array(binaryData instanceof DataView ? binaryData.buffer : binaryData);
54289
- const mediaType = getISOBMFFMediaType(buffer);
54290
- if (!mediaType) {
54291
- return null;
54292
- }
54293
- return {
54294
- mimeType: mediaType.mimeType,
54295
- width: 0,
54296
- height: 0
54297
- };
54686
+ function atc8x5Size(width, height) {
54687
+ return Math.floor((width + 7) / 8) * Math.floor((height + 4) / 5) * 16;
54298
54688
  }
54299
- function getPngMetadata(binaryData) {
54300
- const dataView = toDataView(binaryData);
54301
- const isPng = dataView.byteLength >= 24 && dataView.getUint32(0, BIG_ENDIAN) === 2303741511;
54302
- if (!isPng) {
54303
- return null;
54304
- }
54305
- return {
54306
- mimeType: "image/png",
54307
- width: dataView.getUint32(16, BIG_ENDIAN),
54308
- height: dataView.getUint32(20, BIG_ENDIAN)
54309
- };
54689
+ function atc8x6Size(width, height) {
54690
+ return Math.floor((width + 7) / 8) * Math.floor((height + 5) / 6) * 16;
54310
54691
  }
54311
- function getGifMetadata(binaryData) {
54312
- const dataView = toDataView(binaryData);
54313
- const isGif = dataView.byteLength >= 10 && dataView.getUint32(0, BIG_ENDIAN) === 1195984440;
54314
- if (!isGif) {
54315
- return null;
54316
- }
54317
- return {
54318
- mimeType: "image/gif",
54319
- width: dataView.getUint16(6, LITTLE_ENDIAN),
54320
- height: dataView.getUint16(8, LITTLE_ENDIAN)
54321
- };
54692
+ function atc8x8Size(width, height) {
54693
+ return Math.floor((width + 7) / 8) * Math.floor((height + 7) / 8) * 16;
54322
54694
  }
54323
- function getBmpMetadata(binaryData) {
54324
- const dataView = toDataView(binaryData);
54325
- const isBmp = dataView.byteLength >= 14 && dataView.getUint16(0, BIG_ENDIAN) === 16973 && dataView.getUint32(2, LITTLE_ENDIAN) === dataView.byteLength;
54326
- if (!isBmp) {
54327
- return null;
54328
- }
54329
- return {
54330
- mimeType: "image/bmp",
54331
- width: dataView.getUint32(18, LITTLE_ENDIAN),
54332
- height: dataView.getUint32(22, LITTLE_ENDIAN)
54333
- };
54695
+ function atc10x5Size(width, height) {
54696
+ return Math.floor((width + 9) / 10) * Math.floor((height + 4) / 5) * 16;
54334
54697
  }
54335
- function getJpegMetadata(binaryData) {
54336
- const dataView = toDataView(binaryData);
54337
- const isJpeg = dataView.byteLength >= 3 && dataView.getUint16(0, BIG_ENDIAN) === 65496 && dataView.getUint8(2) === 255;
54338
- if (!isJpeg) {
54339
- return null;
54340
- }
54341
- const { tableMarkers, sofMarkers } = getJpegMarkers();
54342
- let i = 2;
54343
- while (i + 9 < dataView.byteLength) {
54344
- const marker2 = dataView.getUint16(i, BIG_ENDIAN);
54345
- if (sofMarkers.has(marker2)) {
54346
- return {
54347
- mimeType: "image/jpeg",
54348
- height: dataView.getUint16(i + 5, BIG_ENDIAN),
54349
- width: dataView.getUint16(i + 7, BIG_ENDIAN)
54350
- };
54351
- }
54352
- if (!tableMarkers.has(marker2)) {
54353
- return null;
54354
- }
54355
- i += 2;
54356
- i += dataView.getUint16(i, BIG_ENDIAN);
54357
- }
54358
- return null;
54698
+ function atc10x6Size(width, height) {
54699
+ return Math.floor((width + 9) / 10) * Math.floor((height + 5) / 6) * 16;
54359
54700
  }
54360
- function getJpegMarkers() {
54361
- const tableMarkers = new Set([65499, 65476, 65484, 65501, 65534]);
54362
- for (let i = 65504; i < 65520; ++i) {
54363
- tableMarkers.add(i);
54364
- }
54365
- const sofMarkers = new Set([
54366
- 65472,
54367
- 65473,
54368
- 65474,
54369
- 65475,
54370
- 65477,
54371
- 65478,
54372
- 65479,
54373
- 65481,
54374
- 65482,
54375
- 65483,
54376
- 65485,
54377
- 65486,
54378
- 65487,
54379
- 65502
54380
- ]);
54381
- return { tableMarkers, sofMarkers };
54701
+ function atc10x8Size(width, height) {
54702
+ return Math.floor((width + 9) / 10) * Math.floor((height + 7) / 8) * 16;
54382
54703
  }
54383
- function toDataView(data) {
54384
- if (data instanceof DataView) {
54385
- return data;
54386
- }
54387
- if (ArrayBuffer.isView(data)) {
54388
- return new DataView(data.buffer);
54389
- }
54390
- if (data instanceof ArrayBuffer) {
54391
- return new DataView(data);
54392
- }
54393
- throw new Error("toDataView");
54704
+ function atc10x10Size(width, height) {
54705
+ return Math.floor((width + 9) / 10) * Math.floor((height + 9) / 10) * 16;
54394
54706
  }
54395
-
54396
- // ../images/src/lib/parsers/parse-to-node-image.ts
54397
- async function parseToNodeImage(arrayBuffer, options) {
54398
- const { mimeType } = getBinaryImageMetadata(arrayBuffer) || {};
54399
- const _parseImageNode2 = globalThis._parseImageNode;
54400
- assert2(_parseImageNode2);
54401
- return await _parseImageNode2(arrayBuffer, mimeType);
54707
+ function atc12x10Size(width, height) {
54708
+ return Math.floor((width + 11) / 12) * Math.floor((height + 9) / 10) * 16;
54709
+ }
54710
+ function atc12x12Size(width, height) {
54711
+ return Math.floor((width + 11) / 12) * Math.floor((height + 11) / 12) * 16;
54402
54712
  }
54403
54713
 
54404
- // ../images/src/lib/parsers/parse-image.ts
54405
- async function parseImage(arrayBuffer, options, context) {
54406
- options = options || {};
54407
- const imageOptions = options.image || {};
54408
- const imageType = imageOptions.type || "auto";
54409
- const { url } = context || {};
54410
- const loadType = getLoadableImageType(imageType);
54411
- let image;
54412
- switch (loadType) {
54413
- case "imagebitmap":
54414
- image = await parseToImageBitmap(arrayBuffer, options, url);
54415
- break;
54416
- case "image":
54417
- image = await parseToImage(arrayBuffer, options, url);
54418
- break;
54419
- case "data":
54420
- image = await parseToNodeImage(arrayBuffer, options);
54421
- break;
54422
- default:
54423
- assert2(false);
54714
+ // ../textures/src/lib/parsers/parse-compressed-texture.ts
54715
+ function parseCompressedTexture(data) {
54716
+ if (isKTX(data)) {
54717
+ return parseKTX(data);
54424
54718
  }
54425
- if (imageType === "data") {
54426
- image = getImageData(image);
54719
+ if (isDDS(data)) {
54720
+ return parseDDS(data);
54427
54721
  }
54428
- return image;
54429
- }
54430
- function getLoadableImageType(type) {
54431
- switch (type) {
54432
- case "auto":
54433
- case "data":
54434
- return getDefaultImageType();
54435
- default:
54436
- isImageTypeSupported(type);
54437
- return type;
54722
+ if (isPVR(data)) {
54723
+ return parsePVR(data);
54438
54724
  }
54725
+ throw new Error("Texture container format not recognized");
54439
54726
  }
54440
54727
 
54441
- // ../images/src/image-loader.ts
54442
- var EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "svg", "avif"];
54443
- var MIME_TYPES = [
54444
- "image/png",
54445
- "image/jpeg",
54446
- "image/gif",
54447
- "image/webp",
54448
- "image/avif",
54449
- "image/bmp",
54450
- "image/vnd.microsoft.icon",
54451
- "image/svg+xml"
54452
- ];
54453
- var DEFAULT_IMAGE_LOADER_OPTIONS = {
54454
- image: {
54455
- type: "auto",
54456
- decode: true
54728
+ // ../textures/src/compressed-texture-loader.ts
54729
+ var DEFAULT_TEXTURE_LOADER_OPTIONS = {
54730
+ "compressed-texture": {
54731
+ libraryPath: "libs/",
54732
+ useBasis: false
54457
54733
  }
54458
54734
  };
54459
- var ImageLoader = {
54460
- id: "image",
54461
- module: "images",
54462
- name: "Images",
54463
- version: VERSION11,
54464
- mimeTypes: MIME_TYPES,
54465
- extensions: EXTENSIONS,
54466
- parse: parseImage,
54467
- tests: [(arrayBuffer) => Boolean(getBinaryImageMetadata(new DataView(arrayBuffer)))],
54468
- options: DEFAULT_IMAGE_LOADER_OPTIONS
54735
+ var CompressedTextureWorkerLoader = {
54736
+ name: "Texture Containers",
54737
+ id: "compressed-texture",
54738
+ module: "textures",
54739
+ version: VERSION10,
54740
+ worker: true,
54741
+ extensions: [
54742
+ "ktx",
54743
+ "ktx2",
54744
+ "dds",
54745
+ "pvr"
54746
+ ],
54747
+ mimeTypes: [
54748
+ "image/ktx2",
54749
+ "image/ktx",
54750
+ "image/vnd-ms.dds",
54751
+ "image/x-dds",
54752
+ "application/octet-stream"
54753
+ ],
54754
+ binary: true,
54755
+ options: DEFAULT_TEXTURE_LOADER_OPTIONS
54469
54756
  };
54470
-
54471
- // ../images/src/lib/encoders/encode-image.ts
54472
- var { _encodeImageNode } = globalThis;
54473
- async function encodeImage(image, options) {
54474
- options = options || {};
54475
- options.image = options.image || {};
54476
- return _encodeImageNode ? _encodeImageNode(image, { type: options.image.mimeType }) : encodeImageInBrowser(image, options);
54477
- }
54478
- var qualityParamSupported = true;
54479
- async function encodeImageInBrowser(image, options) {
54480
- const { mimeType, jpegQuality } = options.image;
54481
- const { width, height } = getImageSize(image);
54482
- const canvas = document.createElement("canvas");
54483
- canvas.width = width;
54484
- canvas.height = height;
54485
- drawImageToCanvas(image, canvas);
54486
- const blob = await new Promise((resolve2) => {
54487
- if (jpegQuality && qualityParamSupported) {
54488
- try {
54489
- canvas.toBlob(resolve2, mimeType, jpegQuality);
54490
- return;
54491
- } catch (error) {
54492
- qualityParamSupported = false;
54493
- }
54494
- }
54495
- canvas.toBlob(resolve2, mimeType);
54496
- });
54497
- if (!blob) {
54498
- throw new Error("image encoding failed");
54499
- }
54500
- return await blob.arrayBuffer();
54501
- }
54502
- function drawImageToCanvas(image, canvas, x = 0, y = 0) {
54503
- if (x === 0 && y === 0 && typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap) {
54504
- const context2 = canvas.getContext("bitmaprenderer");
54505
- if (context2) {
54506
- context2.transferFromImageBitmap(image);
54507
- return canvas;
54757
+ var CompressedTextureLoader = {
54758
+ ...CompressedTextureWorkerLoader,
54759
+ parse: async (arrayBuffer, options) => {
54760
+ if (options["compressed-texture"].useBasis) {
54761
+ options.basis = {
54762
+ format: {
54763
+ alpha: "BC3",
54764
+ noAlpha: "BC1"
54765
+ },
54766
+ ...options.basis,
54767
+ containerFormat: "ktx2",
54768
+ module: "encoder"
54769
+ };
54770
+ return (await parseBasis(arrayBuffer, options))[0];
54508
54771
  }
54772
+ return parseCompressedTexture(arrayBuffer);
54509
54773
  }
54510
- const context = canvas.getContext("2d");
54511
- if (image.data) {
54512
- const clampedArray = new Uint8ClampedArray(image.data);
54513
- const imageData = new ImageData(clampedArray, image.width, image.height);
54514
- context.putImageData(imageData, 0, 0);
54515
- return canvas;
54516
- }
54517
- context.drawImage(image, 0, 0);
54518
- return canvas;
54519
- }
54520
-
54521
- // ../images/src/image-writer.ts
54522
- var ImageWriter = {
54523
- name: "Images",
54524
- id: "image",
54525
- module: "images",
54526
- version: VERSION11,
54527
- extensions: ["jpeg"],
54528
- options: {
54529
- image: {
54530
- mimeType: "image/png",
54531
- jpegQuality: null
54532
- }
54533
- },
54534
- encode: encodeImage
54535
54774
  };
54536
54775
 
54537
- // ../images/src/lib/category-api/image-format.ts
54538
- var mimeTypeSupportedSync = {};
54539
- function isImageFormatSupported(mimeType) {
54540
- if (mimeTypeSupportedSync[mimeType] === void 0) {
54541
- const supported = isBrowser ? checkBrowserImageFormatSupport(mimeType) : checkNodeImageFormatSupport(mimeType);
54542
- mimeTypeSupportedSync[mimeType] = supported;
54543
- }
54544
- return mimeTypeSupportedSync[mimeType];
54545
- }
54546
- function checkNodeImageFormatSupport(mimeType) {
54547
- const NODE_FORMAT_SUPPORT = ["image/png", "image/jpeg", "image/gif"];
54548
- const { _parseImageNode: _parseImageNode2, _imageFormatsNode = NODE_FORMAT_SUPPORT } = globalThis;
54549
- return Boolean(_parseImageNode2) && _imageFormatsNode.includes(mimeType);
54550
- }
54551
- function checkBrowserImageFormatSupport(mimeType) {
54552
- switch (mimeType) {
54553
- case "image/avif":
54554
- case "image/webp":
54555
- return testBrowserImageFormatSupport(mimeType);
54556
- default:
54557
- return true;
54558
- }
54559
- }
54560
- function testBrowserImageFormatSupport(mimeType) {
54561
- try {
54562
- const element = document.createElement("canvas");
54563
- const dataURL = element.toDataURL(mimeType);
54564
- return dataURL.indexOf(`data:${mimeType}`) === 0;
54565
- } catch {
54566
- return false;
54567
- }
54568
- }
54569
-
54570
54776
  // ../textures/src/index.ts
54571
54777
  var KTX2BasisWriterWorker = {
54572
54778
  name: "Basis Universal Supercompressed GPU Texture",
54573
- id: isBrowser ? "ktx2-basis-writer" : "ktx2-basis-writer-nodejs",
54779
+ id: "ktx2-basis-writer",
54574
54780
  module: "textures",
54575
- version: VERSION9,
54781
+ version: VERSION10,
54576
54782
  extensions: ["ktx2"],
54577
54783
  worker: true,
54578
54784
  options: {
@@ -54590,6 +54796,113 @@ function assert6(condition, message) {
54590
54796
  }
54591
54797
  }
54592
54798
 
54799
+ // ../gltf/src/lib/parsers/parse-glb.ts
54800
+ var LITTLE_ENDIAN2 = true;
54801
+ var MAGIC_glTF = 1735152710;
54802
+ var GLB_FILE_HEADER_SIZE = 12;
54803
+ var GLB_CHUNK_HEADER_SIZE = 8;
54804
+ var GLB_CHUNK_TYPE_JSON = 1313821514;
54805
+ var GLB_CHUNK_TYPE_BIN = 5130562;
54806
+ var GLB_V1_CONTENT_FORMAT_JSON = 0;
54807
+ var GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED = 0;
54808
+ var GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED = 1;
54809
+ function getMagicString4(dataView, byteOffset = 0) {
54810
+ return `${String.fromCharCode(dataView.getUint8(byteOffset + 0))}${String.fromCharCode(dataView.getUint8(byteOffset + 1))}${String.fromCharCode(dataView.getUint8(byteOffset + 2))}${String.fromCharCode(dataView.getUint8(byteOffset + 3))}`;
54811
+ }
54812
+ function isGLB(arrayBuffer, byteOffset = 0, options = {}) {
54813
+ const dataView = new DataView(arrayBuffer);
54814
+ const { magic = MAGIC_glTF } = options;
54815
+ const magic1 = dataView.getUint32(byteOffset, false);
54816
+ return magic1 === magic || magic1 === MAGIC_glTF;
54817
+ }
54818
+ function parseGLBSync(glb, arrayBuffer, byteOffset = 0, options = {}) {
54819
+ const dataView = new DataView(arrayBuffer);
54820
+ const type = getMagicString4(dataView, byteOffset + 0);
54821
+ const version2 = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
54822
+ const byteLength = dataView.getUint32(byteOffset + 8, LITTLE_ENDIAN2);
54823
+ Object.assign(glb, {
54824
+ header: {
54825
+ byteOffset,
54826
+ byteLength,
54827
+ hasBinChunk: false
54828
+ },
54829
+ type,
54830
+ version: version2,
54831
+ json: {},
54832
+ binChunks: []
54833
+ });
54834
+ byteOffset += GLB_FILE_HEADER_SIZE;
54835
+ switch (glb.version) {
54836
+ case 1:
54837
+ return parseGLBV1(glb, dataView, byteOffset);
54838
+ case 2:
54839
+ return parseGLBV2(glb, dataView, byteOffset, options = {});
54840
+ default:
54841
+ throw new Error(`Invalid GLB version ${glb.version}. Only supports version 1 and 2.`);
54842
+ }
54843
+ }
54844
+ function parseGLBV1(glb, dataView, byteOffset) {
54845
+ assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
54846
+ const contentLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN2);
54847
+ const contentFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
54848
+ byteOffset += GLB_CHUNK_HEADER_SIZE;
54849
+ assert2(contentFormat === GLB_V1_CONTENT_FORMAT_JSON);
54850
+ parseJSONChunk(glb, dataView, byteOffset, contentLength);
54851
+ byteOffset += contentLength;
54852
+ byteOffset += parseBINChunk(glb, dataView, byteOffset, glb.header.byteLength);
54853
+ return byteOffset;
54854
+ }
54855
+ function parseGLBV2(glb, dataView, byteOffset, options) {
54856
+ assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
54857
+ parseGLBChunksSync(glb, dataView, byteOffset, options);
54858
+ return byteOffset + glb.header.byteLength;
54859
+ }
54860
+ function parseGLBChunksSync(glb, dataView, byteOffset, options) {
54861
+ while (byteOffset + 8 <= glb.header.byteLength) {
54862
+ const chunkLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN2);
54863
+ const chunkFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
54864
+ byteOffset += GLB_CHUNK_HEADER_SIZE;
54865
+ switch (chunkFormat) {
54866
+ case GLB_CHUNK_TYPE_JSON:
54867
+ parseJSONChunk(glb, dataView, byteOffset, chunkLength);
54868
+ break;
54869
+ case GLB_CHUNK_TYPE_BIN:
54870
+ parseBINChunk(glb, dataView, byteOffset, chunkLength);
54871
+ break;
54872
+ case GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED:
54873
+ if (!options.strict) {
54874
+ parseJSONChunk(glb, dataView, byteOffset, chunkLength);
54875
+ }
54876
+ break;
54877
+ case GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED:
54878
+ if (!options.strict) {
54879
+ parseBINChunk(glb, dataView, byteOffset, chunkLength);
54880
+ }
54881
+ break;
54882
+ default:
54883
+ break;
54884
+ }
54885
+ byteOffset += padToNBytes(chunkLength, 4);
54886
+ }
54887
+ return byteOffset;
54888
+ }
54889
+ function parseJSONChunk(glb, dataView, byteOffset, chunkLength) {
54890
+ const jsonChunk = new Uint8Array(dataView.buffer, byteOffset, chunkLength);
54891
+ const textDecoder = new TextDecoder("utf8");
54892
+ const jsonText = textDecoder.decode(jsonChunk);
54893
+ glb.json = JSON.parse(jsonText);
54894
+ return padToNBytes(chunkLength, 4);
54895
+ }
54896
+ function parseBINChunk(glb, dataView, byteOffset, chunkLength) {
54897
+ glb.header.hasBinChunk = true;
54898
+ glb.binChunks.push({
54899
+ byteOffset,
54900
+ byteLength: chunkLength,
54901
+ arrayBuffer: dataView.buffer
54902
+ });
54903
+ return padToNBytes(chunkLength, 4);
54904
+ }
54905
+
54593
54906
  // ../gltf/src/lib/gltf-utils/resolve-url.ts
54594
54907
  function resolveUrl(url, options) {
54595
54908
  const absolute = url.startsWith("data:") || url.startsWith("http:") || url.startsWith("https:");
@@ -54622,6 +54935,7 @@ __export(EXT_meshopt_compression_exports, {
54622
54935
  });
54623
54936
 
54624
54937
  // ../gltf/src/lib/gltf-utils/gltf-utils.ts
54938
+ var MIPMAP_FACTOR = 1.33;
54625
54939
  var TYPES = ["SCALAR", "VEC2", "VEC3", "VEC4"];
54626
54940
  var ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT = [
54627
54941
  [Int8Array, 5120],
@@ -54678,20 +54992,38 @@ function getAccessorArrayTypeAndLength(accessor, bufferView) {
54678
54992
  assert6(byteLength >= 0 && byteLength <= bufferView.byteLength);
54679
54993
  return { ArrayType, length, byteLength };
54680
54994
  }
54995
+ function getMemoryUsageGLTF(gltf) {
54996
+ let { images, bufferViews } = gltf;
54997
+ images = images || [];
54998
+ bufferViews = bufferViews || [];
54999
+ const imageBufferViews = images.map((i) => i.bufferView);
55000
+ bufferViews = bufferViews.filter((view) => !imageBufferViews.includes(view));
55001
+ const bufferMemory = bufferViews.reduce((acc, view) => acc + view.byteLength, 0);
55002
+ const pixelCount = images.reduce((acc, image) => {
55003
+ const { width, height } = image.image;
55004
+ return acc + width * height;
55005
+ }, 0);
55006
+ return bufferMemory + Math.ceil(4 * pixelCount * MIPMAP_FACTOR);
55007
+ }
54681
55008
 
54682
55009
  // ../gltf/src/lib/api/gltf-scenegraph.ts
54683
- var DEFAULT_GLTF_JSON = {
54684
- asset: {
54685
- version: "2.0",
54686
- generator: "loaders.gl"
54687
- },
54688
- buffers: []
54689
- };
55010
+ function makeDefaultGLTFJson() {
55011
+ return {
55012
+ asset: {
55013
+ version: "2.0",
55014
+ generator: "loaders.gl"
55015
+ },
55016
+ buffers: [],
55017
+ extensions: {},
55018
+ extensionsRequired: [],
55019
+ extensionsUsed: []
55020
+ };
55021
+ }
54690
55022
  var GLTFScenegraph = class {
54691
55023
  constructor(gltf) {
54692
- this.gltf = gltf || {
54693
- json: { ...DEFAULT_GLTF_JSON },
54694
- buffers: []
55024
+ this.gltf = {
55025
+ json: gltf?.json || makeDefaultGLTFJson(),
55026
+ buffers: gltf?.buffers || []
54695
55027
  };
54696
55028
  this.sourceBuffers = [];
54697
55029
  this.byteLength = 0;
@@ -54711,10 +55043,15 @@ var GLTFScenegraph = class {
54711
55043
  const extras = this.json.extras || {};
54712
55044
  return extras[key];
54713
55045
  }
55046
+ hasExtension(extensionName) {
55047
+ const isUsedExtension = this.getUsedExtensions().find((name10) => name10 === extensionName);
55048
+ const isRequiredExtension = this.getRequiredExtensions().find((name10) => name10 === extensionName);
55049
+ return typeof isUsedExtension === "string" || typeof isRequiredExtension === "string";
55050
+ }
54714
55051
  getExtension(extensionName) {
54715
55052
  const isExtension = this.getUsedExtensions().find((name10) => name10 === extensionName);
54716
55053
  const extensions = this.json.extensions || {};
54717
- return isExtension ? extensions[extensionName] || true : null;
55054
+ return isExtension ? extensions[extensionName] : null;
54718
55055
  }
54719
55056
  getRequiredExtension(extensionName) {
54720
55057
  const isRequired = this.getRequiredExtensions().find((name10) => name10 === extensionName);
@@ -54821,10 +55158,15 @@ var GLTFScenegraph = class {
54821
55158
  extensions[extensionName] = data;
54822
55159
  }
54823
55160
  removeObjectExtension(object, extensionName) {
54824
- const extensions = object.extensions || {};
54825
- const extension = extensions[extensionName];
55161
+ const extensions = object?.extensions || {};
55162
+ if (extensions[extensionName]) {
55163
+ this.json.extensionsRemoved = this.json.extensionsRemoved || [];
55164
+ const extensionsRemoved = this.json.extensionsRemoved;
55165
+ if (!extensionsRemoved.includes(extensionName)) {
55166
+ extensionsRemoved.push(extensionName);
55167
+ }
55168
+ }
54826
55169
  delete extensions[extensionName];
54827
- return extension;
54828
55170
  }
54829
55171
  addExtension(extensionName, extensionData = {}) {
54830
55172
  assert6(extensionData);
@@ -54853,8 +55195,15 @@ var GLTFScenegraph = class {
54853
55195
  }
54854
55196
  }
54855
55197
  removeExtension(extensionName) {
54856
- if (!this.getExtension(extensionName)) {
54857
- return;
55198
+ if (this.json.extensions?.[extensionName]) {
55199
+ this.json.extensionsRemoved = this.json.extensionsRemoved || [];
55200
+ const extensionsRemoved = this.json.extensionsRemoved;
55201
+ if (!extensionsRemoved.includes(extensionName)) {
55202
+ extensionsRemoved.push(extensionName);
55203
+ }
55204
+ }
55205
+ if (this.json.extensions) {
55206
+ delete this.json.extensions[extensionName];
54858
55207
  }
54859
55208
  if (this.json.extensionsRequired) {
54860
55209
  this._removeStringFromArray(this.json.extensionsRequired, extensionName);
@@ -54862,16 +55211,6 @@ var GLTFScenegraph = class {
54862
55211
  if (this.json.extensionsUsed) {
54863
55212
  this._removeStringFromArray(this.json.extensionsUsed, extensionName);
54864
55213
  }
54865
- if (this.json.extensions) {
54866
- delete this.json.extensions[extensionName];
54867
- }
54868
- if (!Array.isArray(this.json.extensionsRemoved)) {
54869
- this.json.extensionsRemoved = [];
54870
- }
54871
- const extensionsRemoved = this.json.extensionsRemoved;
54872
- if (!extensionsRemoved.includes(extensionName)) {
54873
- extensionsRemoved.push(extensionName);
54874
- }
54875
55214
  }
54876
55215
  setDefaultScene(sceneIndex) {
54877
55216
  this.json.scene = sceneIndex;
@@ -55297,9 +55636,8 @@ async function decodeMeshoptBufferView(scenegraph, bufferView) {
55297
55636
  const source = new Uint8Array(buffer.arrayBuffer, buffer.byteOffset + byteOffset, byteLength);
55298
55637
  const result = new Uint8Array(scenegraph.gltf.buffers[bufferView.buffer].arrayBuffer, bufferView.byteOffset, bufferView.byteLength);
55299
55638
  await meshoptDecodeGltfBuffer(result, count, byteStride, source, mode, filter);
55300
- return result;
55639
+ scenegraph.removeObjectExtension(bufferView, EXT_MESHOPT_COMPRESSION);
55301
55640
  }
55302
- return null;
55303
55641
  }
55304
55642
 
55305
55643
  // ../gltf/src/lib/extensions/EXT_texture_webp.ts
@@ -55344,8 +55682,8 @@ function preprocess2(gltfData, options) {
55344
55682
  const extension = scene.getObjectExtension(texture, KHR_TEXTURE_BASISU);
55345
55683
  if (extension) {
55346
55684
  texture.source = extension.source;
55685
+ scene.removeObjectExtension(texture, KHR_TEXTURE_BASISU);
55347
55686
  }
55348
- scene.removeObjectExtension(texture, KHR_TEXTURE_BASISU);
55349
55687
  }
55350
55688
  scene.removeExtension(KHR_TEXTURE_BASISU);
55351
55689
  }
@@ -55469,6 +55807,7 @@ async function decompressPrimitive(scenegraph, primitive, options, context) {
55469
55807
  if (decodedData.indices) {
55470
55808
  primitive.indices = getGLTFAccessor(decodedData.indices);
55471
55809
  }
55810
+ scenegraph.removeObjectExtension(primitive, KHR_DRACO_MESH_COMPRESSION);
55472
55811
  checkPrimitive(primitive);
55473
55812
  }
55474
55813
  function compressMesh(attributes, indices, mode = 4, options, context) {
@@ -55543,8 +55882,8 @@ var scratchRotationMatrix = new import_core15.Matrix3();
55543
55882
  var scratchScaleMatrix = new import_core15.Matrix3();
55544
55883
  async function decode4(gltfData, options) {
55545
55884
  const gltfScenegraph = new GLTFScenegraph(gltfData);
55546
- const extension = gltfScenegraph.getExtension(EXT_MESHOPT_TRANSFORM);
55547
- if (!extension) {
55885
+ const hasExtension = gltfScenegraph.hasExtension(EXT_MESHOPT_TRANSFORM);
55886
+ if (!hasExtension) {
55548
55887
  return;
55549
55888
  }
55550
55889
  const materials = gltfData.json.materials || [];
@@ -55678,10 +56017,10 @@ function createAttribute(newTexCoord, originalAccessor, primitive, gltfData, new
55678
56017
  }
55679
56018
  function makeTransformationMatrix(extensionData) {
55680
56019
  const { offset = [0, 0], rotation = 0, scale = [1, 1] } = extensionData;
55681
- const translationMatirx = new import_core15.Matrix3().set(1, 0, 0, 0, 1, 0, offset[0], offset[1], 1);
55682
- const rotationMatirx = scratchRotationMatrix.set(Math.cos(rotation), Math.sin(rotation), 0, -Math.sin(rotation), Math.cos(rotation), 0, 0, 0, 1);
56020
+ const translationMatrix = new import_core15.Matrix3().set(1, 0, 0, 0, 1, 0, offset[0], offset[1], 1);
56021
+ const rotationMatrix = scratchRotationMatrix.set(Math.cos(rotation), Math.sin(rotation), 0, -Math.sin(rotation), Math.cos(rotation), 0, 0, 0, 1);
55683
56022
  const scaleMatrix = scratchScaleMatrix.set(scale[0], 0, 0, 0, scale[1], 0, 0, 0, 1);
55684
- return translationMatirx.multiplyRight(rotationMatirx).multiplyRight(scaleMatrix);
56023
+ return translationMatrix.multiplyRight(rotationMatrix).multiplyRight(scaleMatrix);
55685
56024
  }
55686
56025
 
55687
56026
  // ../gltf/src/lib/extensions/deprecated/KHR_lights_punctual.ts
@@ -56145,428 +56484,6 @@ function normalizeGLTFV1(gltf, options = {}) {
56145
56484
  return new GLTFV1Normalizer().normalize(gltf, options);
56146
56485
  }
56147
56486
 
56148
- // ../gltf/src/lib/api/post-process-gltf.ts
56149
- var COMPONENTS2 = {
56150
- SCALAR: 1,
56151
- VEC2: 2,
56152
- VEC3: 3,
56153
- VEC4: 4,
56154
- MAT2: 4,
56155
- MAT3: 9,
56156
- MAT4: 16
56157
- };
56158
- var BYTES2 = {
56159
- 5120: 1,
56160
- 5121: 1,
56161
- 5122: 2,
56162
- 5123: 2,
56163
- 5125: 4,
56164
- 5126: 4
56165
- };
56166
- var GL_SAMPLER = {
56167
- TEXTURE_MAG_FILTER: 10240,
56168
- TEXTURE_MIN_FILTER: 10241,
56169
- TEXTURE_WRAP_S: 10242,
56170
- TEXTURE_WRAP_T: 10243,
56171
- REPEAT: 10497,
56172
- LINEAR: 9729,
56173
- NEAREST_MIPMAP_LINEAR: 9986
56174
- };
56175
- var SAMPLER_PARAMETER_GLTF_TO_GL = {
56176
- magFilter: GL_SAMPLER.TEXTURE_MAG_FILTER,
56177
- minFilter: GL_SAMPLER.TEXTURE_MIN_FILTER,
56178
- wrapS: GL_SAMPLER.TEXTURE_WRAP_S,
56179
- wrapT: GL_SAMPLER.TEXTURE_WRAP_T
56180
- };
56181
- var DEFAULT_SAMPLER = {
56182
- [GL_SAMPLER.TEXTURE_MAG_FILTER]: GL_SAMPLER.LINEAR,
56183
- [GL_SAMPLER.TEXTURE_MIN_FILTER]: GL_SAMPLER.NEAREST_MIPMAP_LINEAR,
56184
- [GL_SAMPLER.TEXTURE_WRAP_S]: GL_SAMPLER.REPEAT,
56185
- [GL_SAMPLER.TEXTURE_WRAP_T]: GL_SAMPLER.REPEAT
56186
- };
56187
- function getBytesFromComponentType(componentType) {
56188
- return BYTES2[componentType];
56189
- }
56190
- function getSizeFromAccessorType(type) {
56191
- return COMPONENTS2[type];
56192
- }
56193
- var GLTFPostProcessor = class {
56194
- constructor() {
56195
- this.baseUri = "";
56196
- this.json = {};
56197
- this.buffers = [];
56198
- this.images = [];
56199
- }
56200
- postProcess(gltf, options = {}) {
56201
- const { json, buffers = [], images = [], baseUri = "" } = gltf;
56202
- assert6(json);
56203
- this.baseUri = baseUri;
56204
- this.json = json;
56205
- this.buffers = buffers;
56206
- this.images = images;
56207
- this._resolveTree(this.json, options);
56208
- return this.json;
56209
- }
56210
- _resolveTree(json, options = {}) {
56211
- if (json.bufferViews) {
56212
- json.bufferViews = json.bufferViews.map((bufView, i) => this._resolveBufferView(bufView, i));
56213
- }
56214
- if (json.images) {
56215
- json.images = json.images.map((image, i) => this._resolveImage(image, i));
56216
- }
56217
- if (json.samplers) {
56218
- json.samplers = json.samplers.map((sampler, i) => this._resolveSampler(sampler, i));
56219
- }
56220
- if (json.textures) {
56221
- json.textures = json.textures.map((texture, i) => this._resolveTexture(texture, i));
56222
- }
56223
- if (json.accessors) {
56224
- json.accessors = json.accessors.map((accessor, i) => this._resolveAccessor(accessor, i));
56225
- }
56226
- if (json.materials) {
56227
- json.materials = json.materials.map((material, i) => this._resolveMaterial(material, i));
56228
- }
56229
- if (json.meshes) {
56230
- json.meshes = json.meshes.map((mesh, i) => this._resolveMesh(mesh, i));
56231
- }
56232
- if (json.nodes) {
56233
- json.nodes = json.nodes.map((node2, i) => this._resolveNode(node2, i));
56234
- }
56235
- if (json.skins) {
56236
- json.skins = json.skins.map((skin, i) => this._resolveSkin(skin, i));
56237
- }
56238
- if (json.scenes) {
56239
- json.scenes = json.scenes.map((scene, i) => this._resolveScene(scene, i));
56240
- }
56241
- if (json.scene !== void 0) {
56242
- json.scene = json.scenes[this.json.scene];
56243
- }
56244
- }
56245
- getScene(index) {
56246
- return this._get("scenes", index);
56247
- }
56248
- getNode(index) {
56249
- return this._get("nodes", index);
56250
- }
56251
- getSkin(index) {
56252
- return this._get("skins", index);
56253
- }
56254
- getMesh(index) {
56255
- return this._get("meshes", index);
56256
- }
56257
- getMaterial(index) {
56258
- return this._get("materials", index);
56259
- }
56260
- getAccessor(index) {
56261
- return this._get("accessors", index);
56262
- }
56263
- getCamera(index) {
56264
- return null;
56265
- }
56266
- getTexture(index) {
56267
- return this._get("textures", index);
56268
- }
56269
- getSampler(index) {
56270
- return this._get("samplers", index);
56271
- }
56272
- getImage(index) {
56273
- return this._get("images", index);
56274
- }
56275
- getBufferView(index) {
56276
- return this._get("bufferViews", index);
56277
- }
56278
- getBuffer(index) {
56279
- return this._get("buffers", index);
56280
- }
56281
- _get(array, index) {
56282
- if (typeof index === "object") {
56283
- return index;
56284
- }
56285
- const object = this.json[array] && this.json[array][index];
56286
- if (!object) {
56287
- console.warn(`glTF file error: Could not find ${array}[${index}]`);
56288
- }
56289
- return object;
56290
- }
56291
- _resolveScene(scene, index) {
56292
- scene.id = scene.id || `scene-${index}`;
56293
- scene.nodes = (scene.nodes || []).map((node2) => this.getNode(node2));
56294
- return scene;
56295
- }
56296
- _resolveNode(node2, index) {
56297
- node2.id = node2.id || `node-${index}`;
56298
- if (node2.children) {
56299
- node2.children = node2.children.map((child) => this.getNode(child));
56300
- }
56301
- if (node2.mesh !== void 0) {
56302
- node2.mesh = this.getMesh(node2.mesh);
56303
- } else if (node2.meshes !== void 0 && node2.meshes.length) {
56304
- node2.mesh = node2.meshes.reduce((accum, meshIndex) => {
56305
- const mesh = this.getMesh(meshIndex);
56306
- accum.id = mesh.id;
56307
- accum.primitives = accum.primitives.concat(mesh.primitives);
56308
- return accum;
56309
- }, { primitives: [] });
56310
- }
56311
- if (node2.camera !== void 0) {
56312
- node2.camera = this.getCamera(node2.camera);
56313
- }
56314
- if (node2.skin !== void 0) {
56315
- node2.skin = this.getSkin(node2.skin);
56316
- }
56317
- return node2;
56318
- }
56319
- _resolveSkin(skin, index) {
56320
- skin.id = skin.id || `skin-${index}`;
56321
- skin.inverseBindMatrices = this.getAccessor(skin.inverseBindMatrices);
56322
- return skin;
56323
- }
56324
- _resolveMesh(mesh, index) {
56325
- mesh.id = mesh.id || `mesh-${index}`;
56326
- if (mesh.primitives) {
56327
- mesh.primitives = mesh.primitives.map((primitive) => {
56328
- primitive = { ...primitive };
56329
- const attributes = primitive.attributes;
56330
- primitive.attributes = {};
56331
- for (const attribute in attributes) {
56332
- primitive.attributes[attribute] = this.getAccessor(attributes[attribute]);
56333
- }
56334
- if (primitive.indices !== void 0) {
56335
- primitive.indices = this.getAccessor(primitive.indices);
56336
- }
56337
- if (primitive.material !== void 0) {
56338
- primitive.material = this.getMaterial(primitive.material);
56339
- }
56340
- return primitive;
56341
- });
56342
- }
56343
- return mesh;
56344
- }
56345
- _resolveMaterial(material, index) {
56346
- material.id = material.id || `material-${index}`;
56347
- if (material.normalTexture) {
56348
- material.normalTexture = { ...material.normalTexture };
56349
- material.normalTexture.texture = this.getTexture(material.normalTexture.index);
56350
- }
56351
- if (material.occlusionTexture) {
56352
- material.occlustionTexture = { ...material.occlustionTexture };
56353
- material.occlusionTexture.texture = this.getTexture(material.occlusionTexture.index);
56354
- }
56355
- if (material.emissiveTexture) {
56356
- material.emmisiveTexture = { ...material.emmisiveTexture };
56357
- material.emissiveTexture.texture = this.getTexture(material.emissiveTexture.index);
56358
- }
56359
- if (!material.emissiveFactor) {
56360
- material.emissiveFactor = material.emmisiveTexture ? [1, 1, 1] : [0, 0, 0];
56361
- }
56362
- if (material.pbrMetallicRoughness) {
56363
- material.pbrMetallicRoughness = { ...material.pbrMetallicRoughness };
56364
- const mr = material.pbrMetallicRoughness;
56365
- if (mr.baseColorTexture) {
56366
- mr.baseColorTexture = { ...mr.baseColorTexture };
56367
- mr.baseColorTexture.texture = this.getTexture(mr.baseColorTexture.index);
56368
- }
56369
- if (mr.metallicRoughnessTexture) {
56370
- mr.metallicRoughnessTexture = { ...mr.metallicRoughnessTexture };
56371
- mr.metallicRoughnessTexture.texture = this.getTexture(mr.metallicRoughnessTexture.index);
56372
- }
56373
- }
56374
- return material;
56375
- }
56376
- _resolveAccessor(accessor, index) {
56377
- accessor.id = accessor.id || `accessor-${index}`;
56378
- if (accessor.bufferView !== void 0) {
56379
- accessor.bufferView = this.getBufferView(accessor.bufferView);
56380
- }
56381
- accessor.bytesPerComponent = getBytesFromComponentType(accessor.componentType);
56382
- accessor.components = getSizeFromAccessorType(accessor.type);
56383
- accessor.bytesPerElement = accessor.bytesPerComponent * accessor.components;
56384
- if (accessor.bufferView) {
56385
- const buffer = accessor.bufferView.buffer;
56386
- const { ArrayType, byteLength } = getAccessorArrayTypeAndLength(accessor, accessor.bufferView);
56387
- const byteOffset = (accessor.bufferView.byteOffset || 0) + (accessor.byteOffset || 0) + buffer.byteOffset;
56388
- let cutBuffer = buffer.arrayBuffer.slice(byteOffset, byteOffset + byteLength);
56389
- if (accessor.bufferView.byteStride) {
56390
- cutBuffer = this._getValueFromInterleavedBuffer(buffer, byteOffset, accessor.bufferView.byteStride, accessor.bytesPerElement, accessor.count);
56391
- }
56392
- accessor.value = new ArrayType(cutBuffer);
56393
- }
56394
- return accessor;
56395
- }
56396
- _getValueFromInterleavedBuffer(buffer, byteOffset, byteStride, bytesPerElement, count) {
56397
- const result = new Uint8Array(count * bytesPerElement);
56398
- for (let i = 0; i < count; i++) {
56399
- const elementOffset = byteOffset + i * byteStride;
56400
- result.set(new Uint8Array(buffer.arrayBuffer.slice(elementOffset, elementOffset + bytesPerElement)), i * bytesPerElement);
56401
- }
56402
- return result.buffer;
56403
- }
56404
- _resolveTexture(texture, index) {
56405
- texture.id = texture.id || `texture-${index}`;
56406
- texture.sampler = "sampler" in texture ? this.getSampler(texture.sampler) : DEFAULT_SAMPLER;
56407
- texture.source = this.getImage(texture.source);
56408
- return texture;
56409
- }
56410
- _resolveSampler(sampler, index) {
56411
- sampler.id = sampler.id || `sampler-${index}`;
56412
- sampler.parameters = {};
56413
- for (const key in sampler) {
56414
- const glEnum = this._enumSamplerParameter(key);
56415
- if (glEnum !== void 0) {
56416
- sampler.parameters[glEnum] = sampler[key];
56417
- }
56418
- }
56419
- return sampler;
56420
- }
56421
- _enumSamplerParameter(key) {
56422
- return SAMPLER_PARAMETER_GLTF_TO_GL[key];
56423
- }
56424
- _resolveImage(image, index) {
56425
- image.id = image.id || `image-${index}`;
56426
- if (image.bufferView !== void 0) {
56427
- image.bufferView = this.getBufferView(image.bufferView);
56428
- }
56429
- const preloadedImage = this.images[index];
56430
- if (preloadedImage) {
56431
- image.image = preloadedImage;
56432
- }
56433
- return image;
56434
- }
56435
- _resolveBufferView(bufferView, index) {
56436
- const bufferIndex = bufferView.buffer;
56437
- const result = {
56438
- id: `bufferView-${index}`,
56439
- ...bufferView,
56440
- buffer: this.buffers[bufferIndex]
56441
- };
56442
- const arrayBuffer = this.buffers[bufferIndex].arrayBuffer;
56443
- let byteOffset = this.buffers[bufferIndex].byteOffset || 0;
56444
- if ("byteOffset" in bufferView) {
56445
- byteOffset += bufferView.byteOffset;
56446
- }
56447
- result.data = new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength);
56448
- return result;
56449
- }
56450
- _resolveCamera(camera, index) {
56451
- camera.id = camera.id || `camera-${index}`;
56452
- if (camera.perspective) {
56453
- }
56454
- if (camera.orthographic) {
56455
- }
56456
- return camera;
56457
- }
56458
- };
56459
- function postProcessGLTF(gltf, options) {
56460
- return new GLTFPostProcessor().postProcess(gltf, options);
56461
- }
56462
-
56463
- // ../gltf/src/lib/parsers/parse-glb.ts
56464
- var MAGIC_glTF = 1735152710;
56465
- var GLB_FILE_HEADER_SIZE = 12;
56466
- var GLB_CHUNK_HEADER_SIZE = 8;
56467
- var GLB_CHUNK_TYPE_JSON = 1313821514;
56468
- var GLB_CHUNK_TYPE_BIN = 5130562;
56469
- var GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED = 0;
56470
- var GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED = 1;
56471
- var GLB_V1_CONTENT_FORMAT_JSON = 0;
56472
- var LE = true;
56473
- function getMagicString4(dataView, byteOffset = 0) {
56474
- return `${String.fromCharCode(dataView.getUint8(byteOffset + 0))}${String.fromCharCode(dataView.getUint8(byteOffset + 1))}${String.fromCharCode(dataView.getUint8(byteOffset + 2))}${String.fromCharCode(dataView.getUint8(byteOffset + 3))}`;
56475
- }
56476
- function isGLB(arrayBuffer, byteOffset = 0, options = {}) {
56477
- const dataView = new DataView(arrayBuffer);
56478
- const { magic = MAGIC_glTF } = options;
56479
- const magic1 = dataView.getUint32(byteOffset, false);
56480
- return magic1 === magic || magic1 === MAGIC_glTF;
56481
- }
56482
- function parseGLBSync(glb, arrayBuffer, byteOffset = 0, options = {}) {
56483
- const dataView = new DataView(arrayBuffer);
56484
- const type = getMagicString4(dataView, byteOffset + 0);
56485
- const version2 = dataView.getUint32(byteOffset + 4, LE);
56486
- const byteLength = dataView.getUint32(byteOffset + 8, LE);
56487
- Object.assign(glb, {
56488
- header: {
56489
- byteOffset,
56490
- byteLength,
56491
- hasBinChunk: false
56492
- },
56493
- type,
56494
- version: version2,
56495
- json: {},
56496
- binChunks: []
56497
- });
56498
- byteOffset += GLB_FILE_HEADER_SIZE;
56499
- switch (glb.version) {
56500
- case 1:
56501
- return parseGLBV1(glb, dataView, byteOffset);
56502
- case 2:
56503
- return parseGLBV2(glb, dataView, byteOffset, options = {});
56504
- default:
56505
- throw new Error(`Invalid GLB version ${glb.version}. Only supports v1 and v2.`);
56506
- }
56507
- }
56508
- function parseGLBV1(glb, dataView, byteOffset) {
56509
- assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
56510
- const contentLength = dataView.getUint32(byteOffset + 0, LE);
56511
- const contentFormat = dataView.getUint32(byteOffset + 4, LE);
56512
- byteOffset += GLB_CHUNK_HEADER_SIZE;
56513
- assert2(contentFormat === GLB_V1_CONTENT_FORMAT_JSON);
56514
- parseJSONChunk(glb, dataView, byteOffset, contentLength);
56515
- byteOffset += contentLength;
56516
- byteOffset += parseBINChunk(glb, dataView, byteOffset, glb.header.byteLength);
56517
- return byteOffset;
56518
- }
56519
- function parseGLBV2(glb, dataView, byteOffset, options) {
56520
- assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE);
56521
- parseGLBChunksSync(glb, dataView, byteOffset, options);
56522
- return byteOffset + glb.header.byteLength;
56523
- }
56524
- function parseGLBChunksSync(glb, dataView, byteOffset, options) {
56525
- while (byteOffset + 8 <= glb.header.byteLength) {
56526
- const chunkLength = dataView.getUint32(byteOffset + 0, LE);
56527
- const chunkFormat = dataView.getUint32(byteOffset + 4, LE);
56528
- byteOffset += GLB_CHUNK_HEADER_SIZE;
56529
- switch (chunkFormat) {
56530
- case GLB_CHUNK_TYPE_JSON:
56531
- parseJSONChunk(glb, dataView, byteOffset, chunkLength);
56532
- break;
56533
- case GLB_CHUNK_TYPE_BIN:
56534
- parseBINChunk(glb, dataView, byteOffset, chunkLength);
56535
- break;
56536
- case GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED:
56537
- if (!options.strict) {
56538
- parseJSONChunk(glb, dataView, byteOffset, chunkLength);
56539
- }
56540
- break;
56541
- case GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED:
56542
- if (!options.strict) {
56543
- parseBINChunk(glb, dataView, byteOffset, chunkLength);
56544
- }
56545
- break;
56546
- default:
56547
- break;
56548
- }
56549
- byteOffset += padToNBytes(chunkLength, 4);
56550
- }
56551
- return byteOffset;
56552
- }
56553
- function parseJSONChunk(glb, dataView, byteOffset, chunkLength) {
56554
- const jsonChunk = new Uint8Array(dataView.buffer, byteOffset, chunkLength);
56555
- const textDecoder = new TextDecoder("utf8");
56556
- const jsonText = textDecoder.decode(jsonChunk);
56557
- glb.json = JSON.parse(jsonText);
56558
- return padToNBytes(chunkLength, 4);
56559
- }
56560
- function parseBINChunk(glb, dataView, byteOffset, chunkLength) {
56561
- glb.header.hasBinChunk = true;
56562
- glb.binChunks.push({
56563
- byteOffset,
56564
- byteLength: chunkLength,
56565
- arrayBuffer: dataView.buffer
56566
- });
56567
- return padToNBytes(chunkLength, 4);
56568
- }
56569
-
56570
56487
  // ../gltf/src/lib/parsers/parse-gltf.ts
56571
56488
  async function parseGLTF(gltf, arrayBufferOrString, byteOffset = 0, options, context) {
56572
56489
  parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options);
@@ -56583,7 +56500,7 @@ async function parseGLTF(gltf, arrayBufferOrString, byteOffset = 0, options, con
56583
56500
  const promise = decodeExtensions(gltf, options, context);
56584
56501
  promises.push(promise);
56585
56502
  await Promise.all(promises);
56586
- return options?.gltf?.postProcess ? postProcessGLTF(gltf, options) : gltf;
56503
+ return gltf;
56587
56504
  }
56588
56505
  function parseGLTFContainerSync(gltf, data, byteOffset, options) {
56589
56506
  if (options.uri) {
@@ -56708,8 +56625,7 @@ var GLTFLoader = {
56708
56625
  normalize: true,
56709
56626
  loadBuffers: true,
56710
56627
  loadImages: true,
56711
- decompressMeshes: true,
56712
- postProcess: true
56628
+ decompressMeshes: true
56713
56629
  },
56714
56630
  log: console
56715
56631
  },
@@ -56719,7 +56635,8 @@ var GLTFLoader = {
56719
56635
  decompress: "gltf.decompressMeshes",
56720
56636
  postProcess: "gltf.postProcess",
56721
56637
  gltf: {
56722
- decompress: "gltf.decompressMeshes"
56638
+ decompress: "gltf.decompressMeshes",
56639
+ postProcess: "removed in v4"
56723
56640
  }
56724
56641
  }
56725
56642
  };
@@ -56731,6 +56648,373 @@ async function parse3(arrayBuffer, options = {}, context) {
56731
56648
  return await parseGLTF(gltf, arrayBuffer, byteOffset, options, context);
56732
56649
  }
56733
56650
 
56651
+ // ../gltf/src/lib/api/post-process-gltf.ts
56652
+ var COMPONENTS2 = {
56653
+ SCALAR: 1,
56654
+ VEC2: 2,
56655
+ VEC3: 3,
56656
+ VEC4: 4,
56657
+ MAT2: 4,
56658
+ MAT3: 9,
56659
+ MAT4: 16
56660
+ };
56661
+ var BYTES2 = {
56662
+ 5120: 1,
56663
+ 5121: 1,
56664
+ 5122: 2,
56665
+ 5123: 2,
56666
+ 5125: 4,
56667
+ 5126: 4
56668
+ };
56669
+ var GL_SAMPLER = {
56670
+ TEXTURE_MAG_FILTER: 10240,
56671
+ TEXTURE_MIN_FILTER: 10241,
56672
+ TEXTURE_WRAP_S: 10242,
56673
+ TEXTURE_WRAP_T: 10243,
56674
+ REPEAT: 10497,
56675
+ LINEAR: 9729,
56676
+ NEAREST_MIPMAP_LINEAR: 9986
56677
+ };
56678
+ var SAMPLER_PARAMETER_GLTF_TO_GL = {
56679
+ magFilter: GL_SAMPLER.TEXTURE_MAG_FILTER,
56680
+ minFilter: GL_SAMPLER.TEXTURE_MIN_FILTER,
56681
+ wrapS: GL_SAMPLER.TEXTURE_WRAP_S,
56682
+ wrapT: GL_SAMPLER.TEXTURE_WRAP_T
56683
+ };
56684
+ var DEFAULT_SAMPLER_PARAMETERS = {
56685
+ [GL_SAMPLER.TEXTURE_MAG_FILTER]: GL_SAMPLER.LINEAR,
56686
+ [GL_SAMPLER.TEXTURE_MIN_FILTER]: GL_SAMPLER.NEAREST_MIPMAP_LINEAR,
56687
+ [GL_SAMPLER.TEXTURE_WRAP_S]: GL_SAMPLER.REPEAT,
56688
+ [GL_SAMPLER.TEXTURE_WRAP_T]: GL_SAMPLER.REPEAT
56689
+ };
56690
+ function makeDefaultSampler() {
56691
+ return {
56692
+ id: "default-sampler",
56693
+ parameters: DEFAULT_SAMPLER_PARAMETERS
56694
+ };
56695
+ }
56696
+ function getBytesFromComponentType(componentType) {
56697
+ return BYTES2[componentType];
56698
+ }
56699
+ function getSizeFromAccessorType(type) {
56700
+ return COMPONENTS2[type];
56701
+ }
56702
+ var GLTFPostProcessor = class {
56703
+ constructor() {
56704
+ this.baseUri = "";
56705
+ this.buffers = [];
56706
+ this.images = [];
56707
+ }
56708
+ postProcess(gltf, options = {}) {
56709
+ const { json, buffers = [], images = [] } = gltf;
56710
+ const { baseUri = "" } = gltf;
56711
+ assert6(json);
56712
+ this.baseUri = baseUri;
56713
+ this.buffers = buffers;
56714
+ this.images = images;
56715
+ this.jsonUnprocessed = json;
56716
+ this.json = this._resolveTree(gltf.json, options);
56717
+ return this.json;
56718
+ }
56719
+ _resolveTree(gltf, options = {}) {
56720
+ const json = { ...gltf };
56721
+ this.json = json;
56722
+ if (gltf.bufferViews) {
56723
+ json.bufferViews = gltf.bufferViews.map((bufView, i) => this._resolveBufferView(bufView, i));
56724
+ }
56725
+ if (gltf.images) {
56726
+ json.images = gltf.images.map((image, i) => this._resolveImage(image, i));
56727
+ }
56728
+ if (gltf.samplers) {
56729
+ json.samplers = gltf.samplers.map((sampler, i) => this._resolveSampler(sampler, i));
56730
+ }
56731
+ if (gltf.textures) {
56732
+ json.textures = gltf.textures.map((texture, i) => this._resolveTexture(texture, i));
56733
+ }
56734
+ if (gltf.accessors) {
56735
+ json.accessors = gltf.accessors.map((accessor, i) => this._resolveAccessor(accessor, i));
56736
+ }
56737
+ if (gltf.materials) {
56738
+ json.materials = gltf.materials.map((material, i) => this._resolveMaterial(material, i));
56739
+ }
56740
+ if (gltf.meshes) {
56741
+ json.meshes = gltf.meshes.map((mesh, i) => this._resolveMesh(mesh, i));
56742
+ }
56743
+ if (gltf.nodes) {
56744
+ json.nodes = gltf.nodes.map((node2, i) => this._resolveNode(node2, i));
56745
+ json.nodes = json.nodes.map((node2, i) => this._resolveNodeChildren(node2));
56746
+ }
56747
+ if (gltf.skins) {
56748
+ json.skins = gltf.skins.map((skin, i) => this._resolveSkin(skin, i));
56749
+ }
56750
+ if (gltf.scenes) {
56751
+ json.scenes = gltf.scenes.map((scene, i) => this._resolveScene(scene, i));
56752
+ }
56753
+ if (typeof this.json.scene === "number" && json.scenes) {
56754
+ json.scene = json.scenes[this.json.scene];
56755
+ }
56756
+ return json;
56757
+ }
56758
+ getScene(index) {
56759
+ return this._get(this.json.scenes, index);
56760
+ }
56761
+ getNode(index) {
56762
+ return this._get(this.json.nodes, index);
56763
+ }
56764
+ getSkin(index) {
56765
+ return this._get(this.json.skins, index);
56766
+ }
56767
+ getMesh(index) {
56768
+ return this._get(this.json.meshes, index);
56769
+ }
56770
+ getMaterial(index) {
56771
+ return this._get(this.json.materials, index);
56772
+ }
56773
+ getAccessor(index) {
56774
+ return this._get(this.json.accessors, index);
56775
+ }
56776
+ getCamera(index) {
56777
+ return this._get(this.json.cameras, index);
56778
+ }
56779
+ getTexture(index) {
56780
+ return this._get(this.json.textures, index);
56781
+ }
56782
+ getSampler(index) {
56783
+ return this._get(this.json.samplers, index);
56784
+ }
56785
+ getImage(index) {
56786
+ return this._get(this.json.images, index);
56787
+ }
56788
+ getBufferView(index) {
56789
+ return this._get(this.json.bufferViews, index);
56790
+ }
56791
+ getBuffer(index) {
56792
+ return this._get(this.json.buffers, index);
56793
+ }
56794
+ _get(array, index) {
56795
+ if (typeof index === "object") {
56796
+ return index;
56797
+ }
56798
+ const object = array && array[index];
56799
+ if (!object) {
56800
+ console.warn(`glTF file error: Could not find ${array}[${index}]`);
56801
+ }
56802
+ return object;
56803
+ }
56804
+ _resolveScene(scene, index) {
56805
+ return {
56806
+ ...scene,
56807
+ id: scene.id || `scene-${index}`,
56808
+ nodes: (scene.nodes || []).map((node2) => this.getNode(node2))
56809
+ };
56810
+ }
56811
+ _resolveNode(gltfNode, index) {
56812
+ const node2 = {
56813
+ ...gltfNode,
56814
+ id: gltfNode?.id || `node-${index}`
56815
+ };
56816
+ if (gltfNode.mesh !== void 0) {
56817
+ node2.mesh = this.getMesh(gltfNode.mesh);
56818
+ }
56819
+ if (gltfNode.camera !== void 0) {
56820
+ node2.camera = this.getCamera(gltfNode.camera);
56821
+ }
56822
+ if (gltfNode.skin !== void 0) {
56823
+ node2.skin = this.getSkin(gltfNode.skin);
56824
+ }
56825
+ if (gltfNode.meshes !== void 0 && gltfNode.meshes.length) {
56826
+ node2.mesh = gltfNode.meshes.reduce((accum, meshIndex) => {
56827
+ const mesh = this.getMesh(meshIndex);
56828
+ accum.id = mesh.id;
56829
+ accum.primitives = accum.primitives.concat(mesh.primitives);
56830
+ return accum;
56831
+ }, { primitives: [] });
56832
+ }
56833
+ return node2;
56834
+ }
56835
+ _resolveNodeChildren(node2) {
56836
+ if (node2.children) {
56837
+ node2.children = node2.children.map((child) => this.getNode(child));
56838
+ }
56839
+ return node2;
56840
+ }
56841
+ _resolveSkin(gltfSkin, index) {
56842
+ const inverseBindMatrices = typeof gltfSkin.inverseBindMatrices === "number" ? this.getAccessor(gltfSkin.inverseBindMatrices) : void 0;
56843
+ return {
56844
+ ...gltfSkin,
56845
+ id: gltfSkin.id || `skin-${index}`,
56846
+ inverseBindMatrices
56847
+ };
56848
+ }
56849
+ _resolveMesh(gltfMesh, index) {
56850
+ const mesh = {
56851
+ ...gltfMesh,
56852
+ id: gltfMesh.id || `mesh-${index}`,
56853
+ primitives: []
56854
+ };
56855
+ if (gltfMesh.primitives) {
56856
+ mesh.primitives = gltfMesh.primitives.map((gltfPrimitive) => {
56857
+ const primitive = {
56858
+ ...gltfPrimitive,
56859
+ attributes: {},
56860
+ indices: void 0,
56861
+ material: void 0
56862
+ };
56863
+ const attributes = gltfPrimitive.attributes;
56864
+ for (const attribute in attributes) {
56865
+ primitive.attributes[attribute] = this.getAccessor(attributes[attribute]);
56866
+ }
56867
+ if (gltfPrimitive.indices !== void 0) {
56868
+ primitive.indices = this.getAccessor(gltfPrimitive.indices);
56869
+ }
56870
+ if (gltfPrimitive.material !== void 0) {
56871
+ primitive.material = this.getMaterial(gltfPrimitive.material);
56872
+ }
56873
+ return primitive;
56874
+ });
56875
+ }
56876
+ return mesh;
56877
+ }
56878
+ _resolveMaterial(gltfMaterial, index) {
56879
+ const material = {
56880
+ ...gltfMaterial,
56881
+ id: gltfMaterial.id || `material-${index}`
56882
+ };
56883
+ if (material.normalTexture) {
56884
+ material.normalTexture = { ...material.normalTexture };
56885
+ material.normalTexture.texture = this.getTexture(material.normalTexture.index);
56886
+ }
56887
+ if (material.occlusionTexture) {
56888
+ material.occlusionTexture = { ...material.occlusionTexture };
56889
+ material.occlusionTexture.texture = this.getTexture(material.occlusionTexture.index);
56890
+ }
56891
+ if (material.emissiveTexture) {
56892
+ material.emissiveTexture = { ...material.emissiveTexture };
56893
+ material.emissiveTexture.texture = this.getTexture(material.emissiveTexture.index);
56894
+ }
56895
+ if (!material.emissiveFactor) {
56896
+ material.emissiveFactor = material.emissiveTexture ? [1, 1, 1] : [0, 0, 0];
56897
+ }
56898
+ if (material.pbrMetallicRoughness) {
56899
+ material.pbrMetallicRoughness = { ...material.pbrMetallicRoughness };
56900
+ const mr = material.pbrMetallicRoughness;
56901
+ if (mr.baseColorTexture) {
56902
+ mr.baseColorTexture = { ...mr.baseColorTexture };
56903
+ mr.baseColorTexture.texture = this.getTexture(mr.baseColorTexture.index);
56904
+ }
56905
+ if (mr.metallicRoughnessTexture) {
56906
+ mr.metallicRoughnessTexture = { ...mr.metallicRoughnessTexture };
56907
+ mr.metallicRoughnessTexture.texture = this.getTexture(mr.metallicRoughnessTexture.index);
56908
+ }
56909
+ }
56910
+ return material;
56911
+ }
56912
+ _resolveAccessor(gltfAccessor, index) {
56913
+ const bytesPerComponent = getBytesFromComponentType(gltfAccessor.componentType);
56914
+ const components = getSizeFromAccessorType(gltfAccessor.type);
56915
+ const bytesPerElement = bytesPerComponent * components;
56916
+ const accessor = {
56917
+ ...gltfAccessor,
56918
+ id: gltfAccessor.id || `accessor-${index}`,
56919
+ bytesPerComponent,
56920
+ components,
56921
+ bytesPerElement,
56922
+ value: void 0,
56923
+ bufferView: void 0,
56924
+ sparse: void 0
56925
+ };
56926
+ if (gltfAccessor.bufferView !== void 0) {
56927
+ accessor.bufferView = this.getBufferView(gltfAccessor.bufferView);
56928
+ }
56929
+ if (accessor.bufferView) {
56930
+ const buffer = accessor.bufferView.buffer;
56931
+ const { ArrayType, byteLength } = getAccessorArrayTypeAndLength(accessor, accessor.bufferView);
56932
+ const byteOffset = (accessor.bufferView.byteOffset || 0) + (accessor.byteOffset || 0) + buffer.byteOffset;
56933
+ let cutBuffer = buffer.arrayBuffer.slice(byteOffset, byteOffset + byteLength);
56934
+ if (accessor.bufferView.byteStride) {
56935
+ cutBuffer = this._getValueFromInterleavedBuffer(buffer, byteOffset, accessor.bufferView.byteStride, accessor.bytesPerElement, accessor.count);
56936
+ }
56937
+ accessor.value = new ArrayType(cutBuffer);
56938
+ }
56939
+ return accessor;
56940
+ }
56941
+ _getValueFromInterleavedBuffer(buffer, byteOffset, byteStride, bytesPerElement, count) {
56942
+ const result = new Uint8Array(count * bytesPerElement);
56943
+ for (let i = 0; i < count; i++) {
56944
+ const elementOffset = byteOffset + i * byteStride;
56945
+ result.set(new Uint8Array(buffer.arrayBuffer.slice(elementOffset, elementOffset + bytesPerElement)), i * bytesPerElement);
56946
+ }
56947
+ return result.buffer;
56948
+ }
56949
+ _resolveTexture(gltfTexture, index) {
56950
+ return {
56951
+ ...gltfTexture,
56952
+ id: gltfTexture.id || `texture-${index}`,
56953
+ sampler: typeof gltfTexture.sampler === "number" ? this.getSampler(gltfTexture.sampler) : makeDefaultSampler(),
56954
+ source: typeof gltfTexture.source === "number" ? this.getImage(gltfTexture.source) : void 0
56955
+ };
56956
+ }
56957
+ _resolveSampler(gltfSampler, index) {
56958
+ const sampler = {
56959
+ id: gltfSampler.id || `sampler-${index}`,
56960
+ ...gltfSampler,
56961
+ parameters: {}
56962
+ };
56963
+ for (const key in sampler) {
56964
+ const glEnum = this._enumSamplerParameter(key);
56965
+ if (glEnum !== void 0) {
56966
+ sampler.parameters[glEnum] = sampler[key];
56967
+ }
56968
+ }
56969
+ return sampler;
56970
+ }
56971
+ _enumSamplerParameter(key) {
56972
+ return SAMPLER_PARAMETER_GLTF_TO_GL[key];
56973
+ }
56974
+ _resolveImage(gltfImage, index) {
56975
+ const image = {
56976
+ ...gltfImage,
56977
+ id: gltfImage.id || `image-${index}`,
56978
+ image: null,
56979
+ bufferView: gltfImage.bufferView !== void 0 ? this.getBufferView(gltfImage.bufferView) : void 0
56980
+ };
56981
+ const preloadedImage = this.images[index];
56982
+ if (preloadedImage) {
56983
+ image.image = preloadedImage;
56984
+ }
56985
+ return image;
56986
+ }
56987
+ _resolveBufferView(gltfBufferView, index) {
56988
+ const bufferIndex = gltfBufferView.buffer;
56989
+ const arrayBuffer = this.buffers[bufferIndex].arrayBuffer;
56990
+ let byteOffset = this.buffers[bufferIndex].byteOffset || 0;
56991
+ if (gltfBufferView.byteOffset) {
56992
+ byteOffset += gltfBufferView.byteOffset;
56993
+ }
56994
+ const bufferView = {
56995
+ id: `bufferView-${index}`,
56996
+ ...gltfBufferView,
56997
+ buffer: this.buffers[bufferIndex],
56998
+ data: new Uint8Array(arrayBuffer, byteOffset, gltfBufferView.byteLength)
56999
+ };
57000
+ return bufferView;
57001
+ }
57002
+ _resolveCamera(gltfCamera, index) {
57003
+ const camera = {
57004
+ ...gltfCamera,
57005
+ id: gltfCamera.id || `camera-${index}`
57006
+ };
57007
+ if (camera.perspective) {
57008
+ }
57009
+ if (camera.orthographic) {
57010
+ }
57011
+ return camera;
57012
+ }
57013
+ };
57014
+ function postProcessGLTF(gltf, options) {
57015
+ return new GLTFPostProcessor().postProcess(gltf, options);
57016
+ }
57017
+
56734
57018
  // ../3d-tiles/src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts
56735
57019
  var GLTF_FORMAT = {
56736
57020
  URI: 0,
@@ -56762,7 +57046,9 @@ async function extractGLTF(tile, gltfFormat, options, context) {
56762
57046
  tile.gltfByteOffset = 0;
56763
57047
  }
56764
57048
  if (tile.gltfArrayBuffer) {
56765
- tile.gltf = await parse7(tile.gltfArrayBuffer, GLTFLoader, options, context);
57049
+ const gltfWithBuffers = await parse7(tile.gltfArrayBuffer, GLTFLoader, options, context);
57050
+ tile.gltf = postProcessGLTF(gltfWithBuffers);
57051
+ tile.gpuMemoryUsageInBytes = getMemoryUsageGLTF(tile.gltf);
56766
57052
  delete tile.gltfArrayBuffer;
56767
57053
  delete tile.gltfByteOffset;
56768
57054
  delete tile.gltfByteLength;
@@ -56969,7 +57255,9 @@ async function parseGltf3DTile(tile, arrayBuffer, options, context) {
56969
57255
  tile.rotateYtoZ = true;
56970
57256
  tile.gltfUpAxis = options["3d-tiles"] && options["3d-tiles"].assetGltfUpAxis ? options["3d-tiles"].assetGltfUpAxis : "Y";
56971
57257
  const { parse: parse7 } = context;
56972
- tile.gltf = await parse7(arrayBuffer, GLTFLoader, options, context);
57258
+ const gltfWithBuffers = await parse7(arrayBuffer, GLTFLoader, options, context);
57259
+ tile.gltf = postProcessGLTF(gltfWithBuffers);
57260
+ tile.gpuMemoryUsageInBytes = getMemoryUsageGLTF(tile.gltf);
56973
57261
  }
56974
57262
 
56975
57263
  // ../3d-tiles/src/lib/parsers/parse-3d-tile.ts
@@ -58451,7 +58739,7 @@ function getTileType(tile) {
58451
58739
  if (!tile.contentUrl) {
58452
58740
  return TILE_TYPE.EMPTY;
58453
58741
  }
58454
- const contentUrl = tile.contentUrl;
58742
+ const contentUrl = tile.contentUrl.split("?")[0];
58455
58743
  const fileExtension = contentUrl.split(".").pop();
58456
58744
  switch (fileExtension) {
58457
58745
  case "pnts":
@@ -58611,8 +58899,27 @@ var Tiles3DLoader = {
58611
58899
  }
58612
58900
  }
58613
58901
  };
58614
- function getBaseUri(tileset) {
58615
- return path_exports.dirname(tileset.url);
58902
+ async function parse4(data, options = {}, context) {
58903
+ const loaderOptions = options["3d-tiles"] || {};
58904
+ let isTileset;
58905
+ if (loaderOptions.isTileset === "auto") {
58906
+ isTileset = context?.url && context.url.indexOf(".json") !== -1;
58907
+ } else {
58908
+ isTileset = loaderOptions.isTileset;
58909
+ }
58910
+ return await isTileset ? parseTileset(data, options, context) : parseTile(data, options, context);
58911
+ }
58912
+ async function parseTileset(data, options, context) {
58913
+ const tilesetJson = JSON.parse(new TextDecoder().decode(data));
58914
+ tilesetJson.loader = options?.loader || Tiles3DLoader;
58915
+ tilesetJson.url = context?.url || "";
58916
+ tilesetJson.queryString = context?.queryString || "";
58917
+ tilesetJson.basePath = getBaseUri(tilesetJson);
58918
+ tilesetJson.root = await normalizeTileHeaders(tilesetJson, options || {});
58919
+ tilesetJson.type = TILESET_TYPE.TILES3D;
58920
+ tilesetJson.lodMetricType = LOD_METRIC_TYPE.GEOMETRIC_ERROR;
58921
+ tilesetJson.lodMetricValue = tilesetJson.root?.lodMetricValue || 0;
58922
+ return tilesetJson;
58616
58923
  }
58617
58924
  async function parseTile(arrayBuffer, options, context) {
58618
58925
  const tile = {
@@ -58624,31 +58931,8 @@ async function parseTile(arrayBuffer, options, context) {
58624
58931
  await parse3DTile(arrayBuffer, byteOffset, options, context, tile.content);
58625
58932
  return tile.content;
58626
58933
  }
58627
- async function parseTileset(data, options, context) {
58628
- const tilesetJson = JSON.parse(new TextDecoder().decode(data));
58629
- tilesetJson.loader = options.loader || Tiles3DLoader;
58630
- tilesetJson.url = context.url;
58631
- tilesetJson.basePath = getBaseUri(tilesetJson);
58632
- tilesetJson.root = await normalizeTileHeaders(tilesetJson, options);
58633
- tilesetJson.type = TILESET_TYPE.TILES3D;
58634
- tilesetJson.lodMetricType = LOD_METRIC_TYPE.GEOMETRIC_ERROR;
58635
- tilesetJson.lodMetricValue = tilesetJson.root?.lodMetricValue || 0;
58636
- return tilesetJson;
58637
- }
58638
- async function parse4(data, options, context) {
58639
- const loaderOptions = options["3d-tiles"] || {};
58640
- let isTileset;
58641
- if (loaderOptions.isTileset === "auto") {
58642
- isTileset = context.url && context.url.indexOf(".json") !== -1;
58643
- } else {
58644
- isTileset = loaderOptions.isTileset;
58645
- }
58646
- if (isTileset) {
58647
- data = await parseTileset(data, options, context);
58648
- } else {
58649
- data = await parseTile(data, options, context);
58650
- }
58651
- return data;
58934
+ function getBaseUri(tileset) {
58935
+ return path_exports.dirname(tileset.url);
58652
58936
  }
58653
58937
 
58654
58938
  // ../3d-tiles/src/lib/ion/ion.ts
@@ -59422,10 +59706,7 @@ function prepareDataForAttributesConversion(tileContent) {
59422
59706
  let nodes = tileContent.gltf?.scene?.nodes || tileContent.gltf?.scenes?.[0]?.nodes || tileContent.gltf?.nodes || [];
59423
59707
  const images = tileContent.gltf?.images?.map((imageObject) => {
59424
59708
  if (imageObject?.image?.compressed) {
59425
- return {
59426
- data: null,
59427
- compressed: true
59428
- };
59709
+ return null;
59429
59710
  } else {
59430
59711
  const data = imageObject?.image?.data;
59431
59712
  const dataCopy = new Uint8Array(data.length);
@@ -59557,7 +59838,7 @@ function generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, image
59557
59838
  const image = images[textureIndex];
59558
59839
  const batchIds = [];
59559
59840
  const channels = CHANNELS_MAP[featureChannel];
59560
- if (!image.compressed) {
59841
+ if (image && image?.width && image?.height && image?.components) {
59561
59842
  for (let index = 0; index < textureCoordinates.length; index += 2) {
59562
59843
  const u = textureCoordinates[index];
59563
59844
  const v = textureCoordinates[index + 1];
@@ -59568,7 +59849,7 @@ function generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, image
59568
59849
  batchIds.push(batchId);
59569
59850
  }
59570
59851
  } else {
59571
- console.warn(`Can't get batch Ids from ${image.mimeType} compressed texture`);
59852
+ console.warn(`Can't get batch Ids from ${image?.mimeType || ""} compressed texture`);
59572
59853
  }
59573
59854
  return batchIds;
59574
59855
  }
@@ -59715,6 +59996,15 @@ function setupDoubleAttribute(storageAttribute) {
59715
59996
  };
59716
59997
  }
59717
59998
 
59999
+ // src/lib/utils/geometry-utils.ts
60000
+ var generateSyntheticIndices = (vertexCount) => {
60001
+ const result = new Uint32Array(vertexCount);
60002
+ for (let index = 0; index < vertexCount; index++) {
60003
+ result[index] = index;
60004
+ }
60005
+ return result;
60006
+ };
60007
+
59718
60008
  // src/i3s-converter/helpers/geometry-converter.ts
59719
60009
  var DEFAULT_ROUGHNESS_FACTOR = 1;
59720
60010
  var DEFAULT_METALLIC_FACTOR = 1;
@@ -59903,17 +60193,18 @@ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, att
59903
60193
  let outputAttributes = null;
59904
60194
  let materialUvRegion;
59905
60195
  if (primitive.material) {
59906
- outputAttributes = attributesMap.get(primitive.material.uniqueId);
59907
- materialUvRegion = outputAttributes?.mergedMaterials.find(({ originalMaterialId }) => originalMaterialId === primitive.material?.uniqueId)?.uvRegion;
60196
+ outputAttributes = attributesMap.get(primitive.material.id);
60197
+ materialUvRegion = outputAttributes?.mergedMaterials.find(({ originalMaterialId }) => originalMaterialId === primitive.material?.id)?.uvRegion;
59908
60198
  } else if (attributesMap.has("default")) {
59909
60199
  outputAttributes = attributesMap.get("default");
59910
60200
  }
59911
60201
  assert2(outputAttributes !== null, "Primitive - material mapping failed");
60202
+ assert2(primitive.mode === GL2.TRIANGLES || primitive.mode === GL2.TRIANGLE_STRIP, `Primitive - unsupported mode ${primitive.mode}`);
59912
60203
  const attributes = primitive.attributes;
59913
60204
  if (!outputAttributes) {
59914
60205
  continue;
59915
60206
  }
59916
- const indices = getIndices(primitive);
60207
+ const indices = normalizeIndices(primitive);
59917
60208
  outputAttributes.positions = concatenateTypedArrays(outputAttributes.positions, transformVertexArray({
59918
60209
  vertices: attributes.POSITION.value,
59919
60210
  cartographicOrigin,
@@ -59941,8 +60232,12 @@ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, att
59941
60232
  outputAttributes.featureIndicesGroups.push(flattenBatchIds(getBatchIds(attributes, primitive, images), indices));
59942
60233
  }
59943
60234
  }
59944
- function getIndices(primitive) {
60235
+ function normalizeIndices(primitive) {
59945
60236
  let indices = primitive.indices?.value;
60237
+ if (!indices) {
60238
+ const positions = primitive.attributes.POSITION.value;
60239
+ return generateSyntheticIndices(positions.length / VALUES_PER_VERTEX2);
60240
+ }
59946
60241
  if (indices && primitive.mode === GL2.TRIANGLE_STRIP) {
59947
60242
  const TypedArrayConstructor = indices.constructor;
59948
60243
  const newIndices = new TypedArrayConstructor((indices.length - 2) * 3);
@@ -60157,9 +60452,8 @@ function convertMaterial(sourceMaterial) {
60157
60452
  textureSetDefinitionId: 0
60158
60453
  };
60159
60454
  }
60160
- const uniqueId = v4();
60161
- sourceMaterial.uniqueId = uniqueId;
60162
- let mergedMaterials = [{ originalMaterialId: uniqueId }];
60455
+ sourceMaterial.id = Number.isFinite(sourceMaterial.id) ? sourceMaterial.id : v4();
60456
+ let mergedMaterials = [{ originalMaterialId: sourceMaterial.id }];
60163
60457
  if (!texture) {
60164
60458
  const baseColorFactor = sourceMaterial?.pbrMetallicRoughness?.baseColorFactor;
60165
60459
  material.pbrMetallicRoughness.baseColorFactor = baseColorFactor && baseColorFactor.map((c) => Math.round(c * 255)) || void 0;
@@ -60247,13 +60541,16 @@ function extractSharedResourcesTextureInfo(texture, nodeId) {
60247
60541
  {
60248
60542
  id: generateImageId(texture, nodeId),
60249
60543
  size: texture.source?.image.width,
60250
- length: [texture.source?.image.data.length]
60544
+ length: texture.source?.image.data.length ? [texture.source?.image.data.length] : void 0
60251
60545
  }
60252
60546
  ]
60253
60547
  };
60254
60548
  }
60255
60549
  function generateImageId(texture, nodeId) {
60256
- const { width, height } = texture.source?.image;
60550
+ const { width, height } = texture.source?.image || {};
60551
+ if (!width || !height) {
60552
+ return "";
60553
+ }
60257
60554
  const levelCountOfTexture = 1;
60258
60555
  const indexOfLevel = 0;
60259
60556
  const indexOfTextureInStore = nodeId + 1;
@@ -61605,12 +61902,7 @@ var I3SConverter = class {
61605
61902
  loadOptions: {
61606
61903
  _nodeWorkers: true,
61607
61904
  reuseWorkers: true,
61608
- basis: { format: "rgba32" },
61609
- "basis-nodejs": {
61610
- format: "rgba32",
61611
- workerUrl: "./modules/textures/dist/basis-nodejs-worker.js"
61612
- },
61613
- "draco-nodejs": { workerUrl: "./modules/draco/dist/draco-nodejs-worker.js" }
61905
+ basis: { format: "rgba32" }
61614
61906
  }
61615
61907
  };
61616
61908
  if (preloadOptions.headers) {
@@ -62777,7 +63069,7 @@ function getFeatureIdsFromFeatureIndexMetadata(featureIndex) {
62777
63069
  var VERSION15 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
62778
63070
  var I3SContentLoader = {
62779
63071
  name: "I3S Content (Indexed Scene Layers)",
62780
- id: isBrowser2 ? "i3s-content" : "i3s-content-nodejs",
63072
+ id: "i3s-content",
62781
63073
  module: "i3s",
62782
63074
  worker: true,
62783
63075
  version: VERSION15,
@@ -63243,9 +63535,6 @@ var Tiles3DConverter = class {
63243
63535
  loadOptions: {
63244
63536
  _nodeWorkers: true,
63245
63537
  reuseWorkers: true,
63246
- "i3s-content-nodejs": {
63247
- workerUrl: "./modules/i3s/dist/i3s-content-nodejs-worker.js"
63248
- },
63249
63538
  i3s: { coordinateSystem: COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false }
63250
63539
  }
63251
63540
  });