@loaders.gl/tile-converter 3.4.0-alpha.4 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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();
@@ -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
  }
@@ -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) {
@@ -49560,9 +49582,6 @@ var DoublyLinkedList = class {
49560
49582
  };
49561
49583
 
49562
49584
  // ../tiles/src/tileset/tileset-cache.ts
49563
- function defined(x) {
49564
- return x !== void 0 && x !== null;
49565
- }
49566
49585
  var TilesetCache = class {
49567
49586
  constructor() {
49568
49587
  this._list = new DoublyLinkedList();
@@ -49574,12 +49593,12 @@ var TilesetCache = class {
49574
49593
  }
49575
49594
  touch(tile) {
49576
49595
  const node2 = tile._cacheNode;
49577
- if (defined(node2)) {
49596
+ if (node2) {
49578
49597
  this._list.splice(this._sentinel, node2);
49579
49598
  }
49580
49599
  }
49581
49600
  add(tileset, tile, addCallback) {
49582
- if (!defined(tile._cacheNode)) {
49601
+ if (!tile._cacheNode) {
49583
49602
  tile._cacheNode = this._list.add(tile);
49584
49603
  if (addCallback) {
49585
49604
  addCallback(tileset, tile);
@@ -49588,11 +49607,11 @@ var TilesetCache = class {
49588
49607
  }
49589
49608
  unloadTile(tileset, tile, unloadCallback) {
49590
49609
  const node2 = tile._cacheNode;
49591
- if (!defined(node2)) {
49610
+ if (!node2) {
49592
49611
  return;
49593
49612
  }
49594
49613
  this._list.remove(node2);
49595
- tile._cacheNode = void 0;
49614
+ tile._cacheNode = null;
49596
49615
  if (unloadCallback) {
49597
49616
  unloadCallback(tileset, tile);
49598
49617
  }
@@ -49843,7 +49862,7 @@ var TILE3D_OPTIMIZATION_HINT = {
49843
49862
  var import_core4 = __toModule(require_es5());
49844
49863
  var import_culling3 = __toModule(require_es53());
49845
49864
  var import_geospatial4 = __toModule(require_es52());
49846
- function defined2(x) {
49865
+ function defined(x) {
49847
49866
  return x !== void 0 && x !== null;
49848
49867
  }
49849
49868
  var scratchPoint = new import_core4.Vector3();
@@ -49919,7 +49938,7 @@ function createBox(box, transform11, result) {
49919
49938
  zAxis[1],
49920
49939
  zAxis[2]
49921
49940
  ]);
49922
- if (defined2(result)) {
49941
+ if (defined(result)) {
49923
49942
  result.center = center;
49924
49943
  result.halfAxes = halfAxes;
49925
49944
  return result;
@@ -49932,7 +49951,7 @@ function createSphere(sphere, transform11, result) {
49932
49951
  const scale = transform11.getScale(scratchScale);
49933
49952
  const uniformScale = Math.max(Math.max(scale[0], scale[1]), scale[2]);
49934
49953
  const radius = sphere[3] * uniformScale;
49935
- if (defined2(result)) {
49954
+ if (defined(result)) {
49936
49955
  result.center = center;
49937
49956
  result.radius = radius;
49938
49957
  return result;
@@ -50196,16 +50215,16 @@ var DEFAULT_PROPS4 = {
50196
50215
  };
50197
50216
  var TilesetTraverser = class {
50198
50217
  constructor(options) {
50218
+ this.root = null;
50219
+ this.selectedTiles = {};
50220
+ this.requestedTiles = {};
50221
+ this.emptyTiles = {};
50199
50222
  this.lastUpdate = new Date().getTime();
50200
50223
  this.updateDebounceTime = 1e3;
50201
- this.options = { ...DEFAULT_PROPS4, ...options };
50202
50224
  this._traversalStack = new ManagedArray();
50203
50225
  this._emptyTraversalStack = new ManagedArray();
50204
50226
  this._frameNumber = null;
50205
- this.root = null;
50206
- this.selectedTiles = {};
50207
- this.requestedTiles = {};
50208
- this.emptyTiles = {};
50227
+ this.options = { ...DEFAULT_PROPS4, ...options };
50209
50228
  }
50210
50229
  traversalFinished(frameState) {
50211
50230
  return true;
@@ -50219,9 +50238,6 @@ var TilesetTraverser = class {
50219
50238
  this.executeTraversal(root, frameState);
50220
50239
  }
50221
50240
  reset() {
50222
- this.requestedTiles = {};
50223
- this.selectedTiles = {};
50224
- this.emptyTiles = {};
50225
50241
  this._traversalStack.reset();
50226
50242
  this._emptyTraversalStack.reset();
50227
50243
  }
@@ -50268,7 +50284,6 @@ var TilesetTraverser = class {
50268
50284
  for (const child of children) {
50269
50285
  this.updateTile(child, frameState);
50270
50286
  }
50271
- return true;
50272
50287
  }
50273
50288
  updateAndPushChildren(tile, frameState, stack2, depth) {
50274
50289
  const { loadSiblings, skipLevelOfDetail } = this.options;
@@ -50347,7 +50362,7 @@ var TilesetTraverser = class {
50347
50362
  shouldSelectTile(tile) {
50348
50363
  return tile.contentAvailable && !this.options.skipLevelOfDetail;
50349
50364
  }
50350
- shouldRefine(tile, frameState, useParentMetric) {
50365
+ shouldRefine(tile, frameState, useParentMetric = false) {
50351
50366
  let screenSpaceError = tile._screenSpaceError;
50352
50367
  if (useParentMetric) {
50353
50368
  screenSpaceError = tile.getScreenSpaceError(frameState, true);
@@ -50409,19 +50424,11 @@ var TilesetTraverser = class {
50409
50424
 
50410
50425
  // ../tiles/src/tileset/tile-3d.ts
50411
50426
  var scratchVector3 = new import_core7.Vector3();
50412
- function defined3(x) {
50427
+ function defined2(x) {
50413
50428
  return x !== void 0 && x !== null;
50414
50429
  }
50415
50430
  var Tile3D = class {
50416
50431
  constructor(tileset, header, parentHeader, extendedId = "") {
50417
- this.header = header;
50418
- this.tileset = tileset;
50419
- this.id = extendedId || header.id;
50420
- this.url = header.url;
50421
- this.parent = parentHeader;
50422
- this.refine = this._getRefine(header.refine);
50423
- this.type = header.type;
50424
- this.contentUrl = header.contentUrl;
50425
50432
  this.lodMetricType = "geometricError";
50426
50433
  this.lodMetricValue = 0;
50427
50434
  this.boundingVolume = null;
@@ -50429,40 +50436,46 @@ var Tile3D = class {
50429
50436
  this.contentState = TILE_CONTENT_STATE.UNLOADED;
50430
50437
  this.gpuMemoryUsageInBytes = 0;
50431
50438
  this.children = [];
50432
- this.hasEmptyContent = false;
50433
- this.hasTilesetContent = false;
50434
50439
  this.depth = 0;
50435
50440
  this.viewportIds = [];
50436
- this.userData = {};
50441
+ this.transform = new import_core7.Matrix4();
50437
50442
  this.extensions = null;
50438
- this._priority = 0;
50439
- this._touchedFrame = 0;
50440
- this._visitedFrame = 0;
50441
- this._selectedFrame = 0;
50442
- this._requestedFrame = 0;
50443
- this._screenSpaceError = 0;
50443
+ this.implicitTiling = null;
50444
+ this.userData = {};
50445
+ this.hasEmptyContent = false;
50446
+ this.hasTilesetContent = false;
50447
+ this.traverser = new TilesetTraverser({});
50444
50448
  this._cacheNode = null;
50445
50449
  this._frameNumber = null;
50446
- this._cacheNode = null;
50447
- this.traverser = new TilesetTraverser({});
50448
- this._shouldRefine = false;
50450
+ this._expireDate = null;
50451
+ this._expiredContent = null;
50449
50452
  this._distanceToCamera = 0;
50450
- this._centerZDepth = 0;
50453
+ this._screenSpaceError = 0;
50451
50454
  this._visible = void 0;
50452
- this._inRequestVolume = false;
50453
- this._stackLength = 0;
50454
- this._selectionDepth = 0;
50455
50455
  this._initialTransform = new import_core7.Matrix4();
50456
- this.transform = new import_core7.Matrix4();
50456
+ this._priority = 0;
50457
+ this._selectedFrame = 0;
50458
+ this._requestedFrame = 0;
50459
+ this._selectionDepth = 0;
50460
+ this._touchedFrame = 0;
50461
+ this._centerZDepth = 0;
50462
+ this._shouldRefine = false;
50463
+ this._stackLength = 0;
50464
+ this._visitedFrame = 0;
50465
+ this._inRequestVolume = false;
50466
+ this.header = header;
50467
+ this.tileset = tileset;
50468
+ this.id = extendedId || header.id;
50469
+ this.url = header.url;
50470
+ this.parent = parentHeader;
50471
+ this.refine = this._getRefine(header.refine);
50472
+ this.type = header.type;
50473
+ this.contentUrl = header.contentUrl;
50457
50474
  this._initializeLodMetric(header);
50458
50475
  this._initializeTransforms(header);
50459
50476
  this._initializeBoundingVolumes(header);
50460
50477
  this._initializeContent(header);
50461
50478
  this._initializeRenderingState(header);
50462
- this._lodJudge = null;
50463
- this._expireDate = null;
50464
- this._expiredContent = null;
50465
- this.implicitTiling = null;
50466
50479
  Object.seal(this);
50467
50480
  }
50468
50481
  destroy() {
@@ -50529,6 +50542,9 @@ var Tile3D = class {
50529
50542
  unselect() {
50530
50543
  this._selectedFrame = 0;
50531
50544
  }
50545
+ _getGpuMemoryUsageInBytes() {
50546
+ return this.content.gpuMemoryUsageInBytes || this.content.byteLength || 0;
50547
+ }
50532
50548
  _getPriority() {
50533
50549
  const traverser = this.tileset._traverser;
50534
50550
  const { skipLevelOfDetail } = traverser.options;
@@ -50645,7 +50661,7 @@ var Tile3D = class {
50645
50661
  return !viewerRequestVolume || viewerRequestVolume.distanceSquaredTo(frameState.camera.position) <= 0;
50646
50662
  }
50647
50663
  updateExpiration() {
50648
- if (defined3(this._expireDate) && this.contentReady && !this.hasEmptyContent) {
50664
+ if (defined2(this._expireDate) && this.contentReady && !this.hasEmptyContent) {
50649
50665
  const now = Date.now();
50650
50666
  if (Date.lessThan(this._expireDate, now)) {
50651
50667
  this.contentState = TILE_CONTENT_STATE.EXPIRED;
@@ -50728,6 +50744,8 @@ var Tile3D = class {
50728
50744
  }
50729
50745
  if (this._isTileset()) {
50730
50746
  this.hasTilesetContent = true;
50747
+ } else {
50748
+ this.gpuMemoryUsageInBytes = this._getGpuMemoryUsageInBytes();
50731
50749
  }
50732
50750
  }
50733
50751
  _updateBoundingVolume(header) {
@@ -51005,57 +51023,56 @@ var TILES_LOAD_FAILED = "Failed Tile Loads";
51005
51023
  var POINTS_COUNT = "Points/Vertices";
51006
51024
  var TILES_GPU_MEMORY = "Tile Memory Use";
51007
51025
  var Tileset3D = class {
51008
- constructor(json, options) {
51009
- this.contentFormats = { draco: false, meshopt: false, dds: false, ktx2: false };
51010
- this.updatePromise = null;
51011
- assert2(json);
51012
- this.options = { ...DEFAULT_PROPS5, ...options };
51013
- this.tileset = json;
51014
- this.loader = json.loader;
51015
- this.type = json.type;
51016
- this.url = json.url;
51017
- this.basePath = json.basePath || path_exports.dirname(this.url);
51018
- this.modelMatrix = this.options.modelMatrix;
51019
- this.ellipsoid = this.options.ellipsoid;
51020
- this.lodMetricType = json.lodMetricType;
51021
- this.lodMetricValue = json.lodMetricValue;
51022
- this.refine = json.root.refine;
51023
- this.loadOptions = this.options.loadOptions || {};
51026
+ constructor(tileset, options) {
51024
51027
  this.root = null;
51025
51028
  this.roots = {};
51029
+ this.asset = {};
51030
+ this.description = "";
51031
+ this.extras = null;
51032
+ this.attributions = {};
51033
+ this.credits = {};
51034
+ this.contentFormats = { draco: false, meshopt: false, dds: false, ktx2: false };
51026
51035
  this.cartographicCenter = null;
51027
51036
  this.cartesianCenter = null;
51028
51037
  this.zoom = 1;
51029
51038
  this.boundingVolume = null;
51039
+ this.dynamicScreenSpaceErrorComputedDensity = 0;
51040
+ this.maximumMemoryUsage = 32;
51041
+ this.gpuMemoryUsageInBytes = 0;
51042
+ this._frameNumber = 0;
51043
+ this._queryParams = {};
51044
+ this._extensionsUsed = [];
51045
+ this._tiles = {};
51046
+ this._pendingCount = 0;
51047
+ this.selectedTiles = [];
51030
51048
  this.traverseCounter = 0;
51031
51049
  this.geometricError = 0;
51032
- this._traverser = this._initializeTraverser();
51050
+ this.lastUpdatedVieports = null;
51051
+ this._requestedTiles = [];
51052
+ this._emptyTiles = [];
51053
+ this.frameStateData = {};
51033
51054
  this._cache = new TilesetCache();
51055
+ this.updatePromise = null;
51056
+ this.options = { ...DEFAULT_PROPS5, ...options };
51057
+ this.tileset = tileset;
51058
+ this.loader = tileset.loader;
51059
+ this.type = tileset.type;
51060
+ this.url = tileset.url;
51061
+ this.basePath = tileset.basePath || path_exports.dirname(this.url);
51062
+ this.modelMatrix = this.options.modelMatrix;
51063
+ this.ellipsoid = this.options.ellipsoid;
51064
+ this.lodMetricType = tileset.lodMetricType;
51065
+ this.lodMetricValue = tileset.lodMetricValue;
51066
+ this.refine = tileset.root.refine;
51067
+ this.loadOptions = this.options.loadOptions || {};
51068
+ this._traverser = this._initializeTraverser();
51034
51069
  this._requestScheduler = new RequestScheduler({
51035
51070
  throttleRequests: this.options.throttleRequests,
51036
51071
  maxRequests: this.options.maxRequests
51037
51072
  });
51038
- this._frameNumber = 0;
51039
- this._pendingCount = 0;
51040
- this._tiles = {};
51041
- this.selectedTiles = [];
51042
- this._emptyTiles = [];
51043
- this._requestedTiles = [];
51044
- this.frameStateData = {};
51045
- this.lastUpdatedVieports = null;
51046
- this._queryParams = {};
51047
- this._queryParamsString = "";
51048
- this.maximumMemoryUsage = this.options.maximumMemoryUsage || 32;
51049
- this.gpuMemoryUsageInBytes = 0;
51050
51073
  this.stats = new Stats({ id: this.url });
51051
51074
  this._initializeStats();
51052
- this._extensionsUsed = void 0;
51053
- this.dynamicScreenSpaceErrorComputedDensity = 0;
51054
- this.extras = null;
51055
- this.asset = {};
51056
- this.credits = {};
51057
- this.description = this.options.description || "";
51058
- this.tilesetInitializationPromise = this._initializeTileSet(json);
51075
+ this.tilesetInitializationPromise = this._initializeTileSet(tileset);
51059
51076
  }
51060
51077
  destroy() {
51061
51078
  this._destroy();
@@ -51070,10 +51087,8 @@ var Tileset3D = class {
51070
51087
  return this._frameNumber;
51071
51088
  }
51072
51089
  get queryParams() {
51073
- if (!this._queryParamsString) {
51074
- this._queryParamsString = getQueryParamString(this._queryParams);
51075
- }
51076
- return this._queryParamsString;
51090
+ const search = new URLSearchParams(this._queryParams).toString();
51091
+ return search ? `?${search}` : "";
51077
51092
  }
51078
51093
  setProps(props) {
51079
51094
  this.options = { ...this.options, ...props };
@@ -51086,10 +51101,10 @@ var Tileset3D = class {
51086
51101
  if (isDataUrl) {
51087
51102
  return tilePath;
51088
51103
  }
51089
- return `${tilePath}${this.queryParams}`;
51104
+ return `${tilePath}${tilePath.includes("?") ? "&" : "?"}${this.queryParams}`;
51090
51105
  }
51091
51106
  hasExtension(extensionName) {
51092
- return Boolean(this._extensionsUsed && this._extensionsUsed.indexOf(extensionName) > -1);
51107
+ return Boolean(this._extensionsUsed.indexOf(extensionName) > -1);
51093
51108
  }
51094
51109
  update(viewports = null) {
51095
51110
  this.tilesetInitializationPromise.then(() => {
@@ -51276,7 +51291,6 @@ var Tileset3D = class {
51276
51291
  }
51277
51292
  calculateViewPropsTiles3D() {
51278
51293
  const root = this.root;
51279
- assert2(root);
51280
51294
  const { center } = root.boundingVolume;
51281
51295
  if (!center) {
51282
51296
  console.warn("center was not pre-calculated for the root tile");
@@ -51319,6 +51333,13 @@ var Tileset3D = class {
51319
51333
  const children = tile.header.children || [];
51320
51334
  for (const childHeader of children) {
51321
51335
  const childTile = new Tile3D(this, childHeader, tile);
51336
+ if (childTile.contentUrl?.includes("?session=")) {
51337
+ const url = new URL(childTile.contentUrl);
51338
+ const session = url.searchParams.get("session");
51339
+ if (session) {
51340
+ this._queryParams.session = session;
51341
+ }
51342
+ }
51322
51343
  tile.children.push(childTile);
51323
51344
  childTile.depth = tile.depth + 1;
51324
51345
  stack2.push(childTile);
@@ -51354,7 +51375,7 @@ var Tileset3D = class {
51354
51375
  this._onStartTileLoading();
51355
51376
  loaded = await tile.loadContent();
51356
51377
  } catch (error) {
51357
- this._onTileLoadError(tile, error);
51378
+ this._onTileLoadError(tile, error instanceof Error ? error : new Error("load failed"));
51358
51379
  } finally {
51359
51380
  this._onEndTileLoading();
51360
51381
  this._onTileLoad(tile, loaded);
@@ -51424,11 +51445,11 @@ var Tileset3D = class {
51424
51445
  _updateCacheStats(tile) {
51425
51446
  this.stats.get(TILES_LOADED).incrementCount();
51426
51447
  this.stats.get(TILES_IN_MEMORY).incrementCount();
51427
- this.gpuMemoryUsageInBytes += tile.content.byteLength || 0;
51448
+ this.gpuMemoryUsageInBytes += tile.gpuMemoryUsageInBytes || 0;
51428
51449
  this.stats.get(TILES_GPU_MEMORY).count = this.gpuMemoryUsageInBytes;
51429
51450
  }
51430
51451
  _unloadTile(tile) {
51431
- this.gpuMemoryUsageInBytes -= tile.content && tile.content.byteLength || 0;
51452
+ this.gpuMemoryUsageInBytes -= tile.gpuMemoryUsageInBytes || 0;
51432
51453
  this.stats.get(TILES_IN_MEMORY).decrementCount();
51433
51454
  this.stats.get(TILES_UNLOADED).incrementCount();
51434
51455
  this.stats.get(TILES_GPU_MEMORY).count = this.gpuMemoryUsageInBytes;
@@ -51470,6 +51491,11 @@ var Tileset3D = class {
51470
51491
  tile.destroy();
51471
51492
  }
51472
51493
  _initializeTiles3DTileset(tilesetJson) {
51494
+ if (tilesetJson.queryString) {
51495
+ const searchParams = new URLSearchParams(tilesetJson.queryString);
51496
+ const queryParams = Object.fromEntries(searchParams.entries());
51497
+ this._queryParams = { ...this._queryParams, ...queryParams };
51498
+ }
51473
51499
  this.asset = tilesetJson.asset;
51474
51500
  if (!this.asset) {
51475
51501
  throw new Error("Tileset must have an asset property.");
@@ -51486,7 +51512,7 @@ var Tileset3D = class {
51486
51512
  this.description = this.options.description || "";
51487
51513
  this.properties = tilesetJson.properties;
51488
51514
  this.geometricError = tilesetJson.geometricError;
51489
- this._extensionsUsed = tilesetJson.extensionsUsed;
51515
+ this._extensionsUsed = tilesetJson.extensionsUsed || [];
51490
51516
  this.extras = tilesetJson.extras;
51491
51517
  }
51492
51518
  _initializeI3STileset() {
@@ -51495,20 +51521,6 @@ var Tileset3D = class {
51495
51521
  }
51496
51522
  }
51497
51523
  };
51498
- function getQueryParamString(queryParams) {
51499
- const queryParamStrings = [];
51500
- for (const key of Object.keys(queryParams)) {
51501
- queryParamStrings.push(`${key}=${queryParams[key]}`);
51502
- }
51503
- switch (queryParamStrings.length) {
51504
- case 0:
51505
- return "";
51506
- case 1:
51507
- return `?${queryParamStrings[0]}`;
51508
- default:
51509
- return `?${queryParamStrings.join("&")}`;
51510
- }
51511
- }
51512
51524
 
51513
51525
  // ../3d-tiles/src/lib/utils/version.ts
51514
51526
  var VERSION6 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
@@ -52875,7 +52887,7 @@ function createTypedArrayFromAccessor(tile3DAccessor, buffer, byteOffset, length
52875
52887
  }
52876
52888
 
52877
52889
  // ../3d-tiles/src/lib/classes/tile-3d-batch-table-hierarchy.ts
52878
- var defined4 = (x) => x !== void 0;
52890
+ var defined3 = (x) => x !== void 0;
52879
52891
  function initializeHierarchy(batchTable, jsonHeader, binaryBody) {
52880
52892
  if (!jsonHeader) {
52881
52893
  return null;
@@ -52903,15 +52915,15 @@ function initializeHierarchyValues(hierarchyJson, binaryBody) {
52903
52915
  let parentCounts = hierarchyJson.parentCounts;
52904
52916
  let parentIds = hierarchyJson.parentIds;
52905
52917
  let parentIdsLength = instancesLength;
52906
- if (defined4(classIds.byteOffset)) {
52918
+ if (defined3(classIds.byteOffset)) {
52907
52919
  classIds.componentType = defaultValue(classIds.componentType, GL.UNSIGNED_SHORT);
52908
52920
  classIds.type = AttributeType.SCALAR;
52909
52921
  binaryAccessor = getBinaryAccessor(classIds);
52910
52922
  classIds = binaryAccessor.createArrayBufferView(binaryBody.buffer, binaryBody.byteOffset + classIds.byteOffset, instancesLength);
52911
52923
  }
52912
52924
  let parentIndexes;
52913
- if (defined4(parentCounts)) {
52914
- if (defined4(parentCounts.byteOffset)) {
52925
+ if (defined3(parentCounts)) {
52926
+ if (defined3(parentCounts.byteOffset)) {
52915
52927
  parentCounts.componentType = defaultValue(parentCounts.componentType, GL.UNSIGNED_SHORT);
52916
52928
  parentCounts.type = AttributeType.SCALAR;
52917
52929
  binaryAccessor = getBinaryAccessor(parentCounts);
@@ -52924,7 +52936,7 @@ function initializeHierarchyValues(hierarchyJson, binaryBody) {
52924
52936
  parentIdsLength += parentCounts[i];
52925
52937
  }
52926
52938
  }
52927
- if (defined4(parentIds) && defined4(parentIds.byteOffset)) {
52939
+ if (defined3(parentIds) && defined3(parentIds.byteOffset)) {
52928
52940
  parentIds.componentType = defaultValue(parentIds.componentType, GL.UNSIGNED_SHORT);
52929
52941
  parentIds.type = AttributeType.SCALAR;
52930
52942
  binaryAccessor = getBinaryAccessor(parentIds);
@@ -52988,7 +53000,7 @@ function traverseHierarchyMultipleParents(hierarchy, instanceIndex, endCondition
52988
53000
  }
52989
53001
  visited[instanceIndex] = visitedMarker;
52990
53002
  const result = endConditionCallback(hierarchy, instanceIndex);
52991
- if (defined4(result)) {
53003
+ if (defined3(result)) {
52992
53004
  return result;
52993
53005
  }
52994
53006
  const parentCount = parentCounts[instanceIndex];
@@ -53006,7 +53018,7 @@ function traverseHierarchySingleParent(hierarchy, instanceIndex, endConditionCal
53006
53018
  let hasParent = true;
53007
53019
  while (hasParent) {
53008
53020
  const result = endConditionCallback(hierarchy, instanceIndex);
53009
- if (defined4(result)) {
53021
+ if (defined3(result)) {
53010
53022
  return result;
53011
53023
  }
53012
53024
  const parentId = hierarchy.parentIds[instanceIndex];
@@ -53029,14 +53041,14 @@ function validateInstance(hierarchy, instanceIndex, stack2) {
53029
53041
  const parentIndexes = hierarchy.parentIndexes;
53030
53042
  const classIds = hierarchy.classIds;
53031
53043
  const instancesLength = classIds.length;
53032
- if (!defined4(parentIds)) {
53044
+ if (!defined3(parentIds)) {
53033
53045
  return;
53034
53046
  }
53035
53047
  assert(instanceIndex < instancesLength, `Parent index ${instanceIndex} exceeds the total number of instances: ${instancesLength}`);
53036
53048
  assert(stack2.indexOf(instanceIndex) === -1, "Circular dependency detected in the batch table hierarchy.");
53037
53049
  stack2.push(instanceIndex);
53038
- const parentCount = defined4(parentCounts) ? parentCounts[instanceIndex] : 1;
53039
- const parentIndex = defined4(parentCounts) ? parentIndexes[instanceIndex] : instanceIndex;
53050
+ const parentCount = defined3(parentCounts) ? parentCounts[instanceIndex] : 1;
53051
+ const parentIndex = defined3(parentCounts) ? parentIndexes[instanceIndex] : instanceIndex;
53040
53052
  for (let i = 0; i < parentCount; ++i) {
53041
53053
  const parentId = parentIds[parentIndex + i];
53042
53054
  if (parentId !== instanceIndex) {
@@ -53047,7 +53059,7 @@ function validateInstance(hierarchy, instanceIndex, stack2) {
53047
53059
  }
53048
53060
 
53049
53061
  // ../3d-tiles/src/lib/classes/tile-3d-batch-table.ts
53050
- function defined5(x) {
53062
+ function defined4(x) {
53051
53063
  return x !== void 0 && x !== null;
53052
53064
  }
53053
53065
  var clone = (x, y) => x;
@@ -53089,7 +53101,7 @@ var Tile3DBatchTableParser = class {
53089
53101
  const instanceClass = hierarchy.classes[classId];
53090
53102
  return instanceClass.name === className;
53091
53103
  });
53092
- return defined5(result);
53104
+ return defined4(result);
53093
53105
  }
53094
53106
  return false;
53095
53107
  }
@@ -53109,11 +53121,11 @@ var Tile3DBatchTableParser = class {
53109
53121
  hasProperty(batchId, name10) {
53110
53122
  this._checkBatchId(batchId);
53111
53123
  assert2(typeof name10 === "string", name10);
53112
- return defined5(this._properties[name10]) || this._hasPropertyInHierarchy(batchId, name10);
53124
+ return defined4(this._properties[name10]) || this._hasPropertyInHierarchy(batchId, name10);
53113
53125
  }
53114
53126
  getPropertyNames(batchId, results) {
53115
53127
  this._checkBatchId(batchId);
53116
- results = defined5(results) ? results : [];
53128
+ results = defined4(results) ? results : [];
53117
53129
  results.length = 0;
53118
53130
  const propertyNames = Object.keys(this._properties);
53119
53131
  results.push(...propertyNames);
@@ -53127,17 +53139,17 @@ var Tile3DBatchTableParser = class {
53127
53139
  assert2(typeof name10 === "string", name10);
53128
53140
  if (this._binaryProperties) {
53129
53141
  const binaryProperty = this._binaryProperties[name10];
53130
- if (defined5(binaryProperty)) {
53142
+ if (defined4(binaryProperty)) {
53131
53143
  return this._getBinaryProperty(binaryProperty, batchId);
53132
53144
  }
53133
53145
  }
53134
53146
  const propertyValues = this._properties[name10];
53135
- if (defined5(propertyValues)) {
53147
+ if (defined4(propertyValues)) {
53136
53148
  return clone(propertyValues[batchId], true);
53137
53149
  }
53138
53150
  if (this._hierarchy) {
53139
53151
  const hierarchyProperty = this._getHierarchyProperty(batchId, name10);
53140
- if (defined5(hierarchyProperty)) {
53152
+ if (defined4(hierarchyProperty)) {
53141
53153
  return hierarchyProperty;
53142
53154
  }
53143
53155
  }
@@ -53160,7 +53172,7 @@ var Tile3DBatchTableParser = class {
53160
53172
  }
53161
53173
  }
53162
53174
  let propertyValues = this._properties[name10];
53163
- if (!defined5(propertyValues)) {
53175
+ if (!defined4(propertyValues)) {
53164
53176
  this._properties[name10] = new Array(featureCount);
53165
53177
  propertyValues = this._properties[name10];
53166
53178
  }
@@ -53212,9 +53224,9 @@ var Tile3DBatchTableParser = class {
53212
53224
  const result = traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
53213
53225
  const classId = hierarchy.classIds[instanceIndex];
53214
53226
  const instances = hierarchy.classes[classId].instances;
53215
- return defined5(instances[name10]);
53227
+ return defined4(instances[name10]);
53216
53228
  });
53217
- return defined5(result);
53229
+ return defined4(result);
53218
53230
  }
53219
53231
  _getPropertyNamesInHierarchy(batchId, results) {
53220
53232
  traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
@@ -53235,8 +53247,8 @@ var Tile3DBatchTableParser = class {
53235
53247
  const instanceClass = hierarchy.classes[classId];
53236
53248
  const indexInClass = hierarchy.classIndexes[instanceIndex];
53237
53249
  const propertyValues = instanceClass.instances[name10];
53238
- if (defined5(propertyValues)) {
53239
- if (defined5(propertyValues.typedArray)) {
53250
+ if (defined4(propertyValues)) {
53251
+ if (defined4(propertyValues.typedArray)) {
53240
53252
  return this._getBinaryProperty(propertyValues, indexInClass);
53241
53253
  }
53242
53254
  return clone(propertyValues[indexInClass], true);
@@ -53250,9 +53262,9 @@ var Tile3DBatchTableParser = class {
53250
53262
  const instanceClass = hierarchy.classes[classId];
53251
53263
  const indexInClass = hierarchy.classIndexes[instanceIndex];
53252
53264
  const propertyValues = instanceClass.instances[name10];
53253
- if (defined5(propertyValues)) {
53265
+ if (defined4(propertyValues)) {
53254
53266
  assert2(instanceIndex === batchId, `Inherited property "${name10}" is read-only.`);
53255
- if (defined5(propertyValues.typedArray)) {
53267
+ if (defined4(propertyValues.typedArray)) {
53256
53268
  this._setBinaryProperty(propertyValues, indexInClass, value);
53257
53269
  } else {
53258
53270
  propertyValues[indexInClass] = clone(value, true);
@@ -53261,7 +53273,7 @@ var Tile3DBatchTableParser = class {
53261
53273
  }
53262
53274
  return false;
53263
53275
  });
53264
- return defined5(result);
53276
+ return defined4(result);
53265
53277
  }
53266
53278
  };
53267
53279
 
@@ -55114,6 +55126,19 @@ function getAccessorArrayTypeAndLength(accessor, bufferView) {
55114
55126
  assert7(byteLength >= 0 && byteLength <= bufferView.byteLength);
55115
55127
  return { ArrayType, length, byteLength };
55116
55128
  }
55129
+ function getMemoryUsageGLTF(gltf) {
55130
+ let { images, bufferViews } = gltf;
55131
+ images = images || [];
55132
+ bufferViews = bufferViews || [];
55133
+ const imageBufferViews = images.map((i) => i.bufferView);
55134
+ bufferViews = bufferViews.filter((view) => !imageBufferViews.includes(view));
55135
+ const bufferMemory = bufferViews.reduce((acc, view) => acc + view.byteLength, 0);
55136
+ const pixelCount = images.reduce((acc, image) => {
55137
+ const { width, height } = image.image;
55138
+ return acc + width * height;
55139
+ }, 0);
55140
+ return bufferMemory + Math.ceil(4 * pixelCount * 1.33);
55141
+ }
55117
55142
 
55118
55143
  // ../gltf/src/lib/api/gltf-scenegraph.ts
55119
55144
  var DEFAULT_GLTF_JSON = {
@@ -57199,6 +57224,7 @@ async function extractGLTF(tile, gltfFormat, options, context) {
57199
57224
  }
57200
57225
  if (tile.gltfArrayBuffer) {
57201
57226
  tile.gltf = await parse9(tile.gltfArrayBuffer, GLTFLoader, options, context);
57227
+ tile.gpuMemoryUsageInBytes = getMemoryUsageGLTF(tile.gltf);
57202
57228
  delete tile.gltfArrayBuffer;
57203
57229
  delete tile.gltfByteOffset;
57204
57230
  delete tile.gltfByteLength;
@@ -57406,6 +57432,7 @@ async function parseGltf3DTile(tile, arrayBuffer, options, context) {
57406
57432
  tile.gltfUpAxis = options["3d-tiles"] && options["3d-tiles"].assetGltfUpAxis ? options["3d-tiles"].assetGltfUpAxis : "Y";
57407
57433
  const { parse: parse9 } = context;
57408
57434
  tile.gltf = await parse9(arrayBuffer, GLTFLoader, options, context);
57435
+ tile.gpuMemoryUsageInBytes = getMemoryUsageGLTF(tile.gltf);
57409
57436
  }
57410
57437
 
57411
57438
  // ../3d-tiles/src/lib/parsers/parse-3d-tile.ts
@@ -58887,7 +58914,7 @@ function getTileType(tile) {
58887
58914
  if (!tile.contentUrl) {
58888
58915
  return TILE_TYPE.EMPTY;
58889
58916
  }
58890
- const contentUrl = tile.contentUrl;
58917
+ const contentUrl = tile.contentUrl.split("?")[0];
58891
58918
  const fileExtension = contentUrl.split(".").pop();
58892
58919
  switch (fileExtension) {
58893
58920
  case "pnts":
@@ -59064,6 +59091,7 @@ async function parseTileset(data, options, context) {
59064
59091
  const tilesetJson = JSON.parse(new TextDecoder().decode(data));
59065
59092
  tilesetJson.loader = options.loader || Tiles3DLoader;
59066
59093
  tilesetJson.url = context.url;
59094
+ tilesetJson.queryString = context.queryString;
59067
59095
  tilesetJson.basePath = getBaseUri(tilesetJson);
59068
59096
  tilesetJson.root = await normalizeTileHeaders(tilesetJson, options);
59069
59097
  tilesetJson.type = TILESET_TYPE.TILES3D;