@loaders.gl/tiles 5.0.0-alpha.8 → 5.0.0-alpha.9

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/index.cjs CHANGED
@@ -5786,19 +5786,19 @@ function getTilesetSemanticValue(tileset, semantic) {
5786
5786
  // dist/spatial/spatial-coordinate-transformer.js
5787
5787
  var import_core10 = require("@math.gl/core");
5788
5788
  var import_geospatial7 = require("@math.gl/geospatial");
5789
- var import_proj42 = require("@math.gl/proj4");
5789
+ var import_projection2 = require("@math.gl/projection");
5790
5790
 
5791
5791
  // dist/spatial/spatial-resource-registry.js
5792
5792
  var import_geoid = require("@math.gl/geoid");
5793
- var import_proj4 = require("@math.gl/proj4");
5793
+ var import_projection = require("@math.gl/projection");
5794
5794
  var geoidModels = /* @__PURE__ */ new Map();
5795
5795
  function registerSpatialCrs(name, definition) {
5796
5796
  validateResourceName(name, "CRS");
5797
- import_proj4.Projection.defineProjectionAliases({ [name]: definition });
5797
+ import_projection.Projection.defineProjectionAliases({ [name]: definition });
5798
5798
  }
5799
5799
  function registerSpatialDatumGrid(name, data) {
5800
5800
  validateResourceName(name, "datum grid");
5801
- import_proj4.Projection.registerDatumGrid(name, data);
5801
+ import_projection.Projection.registerDatumGrid(name, data);
5802
5802
  }
5803
5803
  function registerGeoidModel(name, geoid) {
5804
5804
  validateResourceName(name, "geoid model");
@@ -5853,24 +5853,24 @@ var SpatialCoordinateTransformer = class {
5853
5853
  this.sourceIsGeographic = isWgs84Geographic(spatialReference.sourceCrs);
5854
5854
  this.outputIsGeographic = isWgs84Geographic(outputCrs);
5855
5855
  if (spatialReference.sourceCrs && spatialReference.targetCrs && !this.sourceIsGeocentric && !this.outputIsGeocentric) {
5856
- this.horizontalProjection = new import_proj42.Projection({
5857
- from: getHorizontalProj4Definition(spatialReference.sourceCrs),
5858
- to: getHorizontalProj4Definition(spatialReference.targetCrs),
5856
+ this.horizontalProjection = new import_projection2.Projection({
5857
+ from: getHorizontalProjectionDefinition(spatialReference.sourceCrs),
5858
+ to: getHorizontalProjectionDefinition(spatialReference.targetCrs),
5859
5859
  enforceAxis: false
5860
5860
  });
5861
5861
  }
5862
5862
  if (requiresHeightTransformation(spatialReference) || this.sourceIsGeocentric || this.outputIsGeocentric) {
5863
5863
  if (!this.sourceIsGeographic && !this.sourceIsGeocentric) {
5864
- this.geographicProjection = new import_proj42.Projection({
5865
- from: getHorizontalProj4Definition(spatialReference.sourceCrs),
5864
+ this.geographicProjection = new import_projection2.Projection({
5865
+ from: getHorizontalProjectionDefinition(spatialReference.sourceCrs),
5866
5866
  to: WGS84_GEOGRAPHIC_CRS,
5867
5867
  enforceAxis: false
5868
5868
  });
5869
5869
  }
5870
5870
  if (!this.outputIsGeographic && !this.outputIsGeocentric) {
5871
- this.heightOutputProjection = new import_proj42.Projection({
5871
+ this.heightOutputProjection = new import_projection2.Projection({
5872
5872
  from: WGS84_GEOGRAPHIC_CRS,
5873
- to: getHorizontalProj4Definition(outputCrs),
5873
+ to: getHorizontalProjectionDefinition(outputCrs),
5874
5874
  enforceAxis: false
5875
5875
  });
5876
5876
  }
@@ -6015,7 +6015,7 @@ function inverseTransposeMultiply(jacobianColumns, vector) {
6015
6015
  ];
6016
6016
  return inverseTranspose.map((row) => (row[0] * vector[0] + row[1] * vector[1] + row[2] * vector[2]) / determinant);
6017
6017
  }
6018
- function getHorizontalProj4Definition(definition) {
6018
+ function getHorizontalProjectionDefinition(definition) {
6019
6019
  if (!definition) {
6020
6020
  throw new Error("Cannot construct a projection because the CRS is unknown");
6021
6021
  }
@@ -6024,7 +6024,7 @@ function getHorizontalProj4Definition(definition) {
6024
6024
  if (horizontalComponents.length !== 1) {
6025
6025
  throw new Error("CompoundCRS requires exactly one horizontal component");
6026
6026
  }
6027
- return getHorizontalProj4Definition(horizontalComponents[0]);
6027
+ return getHorizontalProjectionDefinition(horizontalComponents[0]);
6028
6028
  }
6029
6029
  return definition;
6030
6030
  }
@@ -6778,6 +6778,8 @@ var Tiles3DSource = class {
6778
6778
  tileUrlCache = /* @__PURE__ */ new Map();
6779
6779
  /** Original content descriptors retained across {@link Tile3D.unloadContent} calls. */
6780
6780
  tileContentHeaders = /* @__PURE__ */ new WeakMap();
6781
+ /** Installed nested roots by parent placement and ordered nested-content slot, across reloads. */
6782
+ nestedTilesetRoots = /* @__PURE__ */ new WeakMap();
6781
6783
  /** Source-local namespaces assigned to distinct embedded glTF package file collections. */
6782
6784
  packageNamespaces = /* @__PURE__ */ new WeakMap();
6783
6785
  /** Next source-local package namespace. */
@@ -7171,7 +7173,9 @@ var Tiles3DSource = class {
7171
7173
  return this.extensionsUsed.includes(extensionName);
7172
7174
  }
7173
7175
  /**
7174
- * Updates content-format flags and installs nested tileset subtrees.
7176
+ * Updates content-format flags and installs nested tileset subtrees once per content slot.
7177
+ * Reloading payloads retains attached roots and their descendants, including duplicate URLs
7178
+ * declared in separate slots or parent placements. Detached roots are reinstalled in declaration order.
7175
7179
  */
7176
7180
  onTileLoaded(tileset, tile, loadResult) {
7177
7181
  const contents = tile.contents.length ? tile.contents : [tile.content];
@@ -7189,8 +7193,20 @@ var Tiles3DSource = class {
7189
7193
  this.contentFormats.ktx2 = true;
7190
7194
  }
7191
7195
  const nestedTilesets = loadResult.nestedTilesets || (loadResult.nestedTileset ? [loadResult.nestedTileset] : []);
7192
- for (const nestedTileset of nestedTilesets) {
7193
- tileset._initializeTileHeaders(this.prepareNestedTileset(tileset, nestedTileset), tile);
7196
+ const installedRoots = this.nestedTilesetRoots.get(tile) || [];
7197
+ for (const [nestedIndex, nestedTileset] of nestedTilesets.entries()) {
7198
+ const installedRoot = installedRoots[nestedIndex];
7199
+ if (installedRoot && tile.children.includes(installedRoot)) {
7200
+ continue;
7201
+ }
7202
+ const nextRoot = installedRoots.slice(nestedIndex + 1).find((root) => tile.children.includes(root));
7203
+ const nestedRoot = tileset._initializeTileHeaders(this.prepareNestedTileset(tileset, nestedTileset), tile);
7204
+ if (nextRoot) {
7205
+ tile.children.splice(tile.children.indexOf(nestedRoot), 1);
7206
+ tile.children.splice(tile.children.indexOf(nextRoot), 0, nestedRoot);
7207
+ }
7208
+ installedRoots[nestedIndex] = nestedRoot;
7209
+ this.nestedTilesetRoots.set(tile, installedRoots);
7194
7210
  }
7195
7211
  }
7196
7212
  /**