@loaders.gl/tiles 4.4.0-alpha.14 → 4.4.0-alpha.16

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.dev.js CHANGED
@@ -5421,10 +5421,33 @@ var __exports__ = (() => {
5421
5421
  const toFixedFrameMatrix = fromFixedFrameMatrix.invert();
5422
5422
  tile.cartographicModelMatrix = toFixedFrameMatrix.multiplyRight(modelMatrix);
5423
5423
  tile.cartographicOrigin = cartographicOrigin;
5424
+ const rootNode = _getRootNode(tile);
5425
+ if (rootNode) {
5426
+ tile.cartesianModelMatrix = new Matrix4(modelMatrix).multiplyRight(rootNode.matrix);
5427
+ tile.cartographicModelMatrix.multiplyRight(rootNode.matrix);
5428
+ rootNode.matrix = Matrix4.IDENTITY;
5429
+ }
5424
5430
  if (!tile.coordinateSystem) {
5425
5431
  tile.modelMatrix = tile.cartographicModelMatrix;
5426
5432
  }
5427
5433
  }
5434
+ var TRANSLATION_LIMIT_SQUARED = 1e6 ** 2;
5435
+ function _getRootNode(tile) {
5436
+ const gltf = tile.gltf;
5437
+ if (!gltf) {
5438
+ return null;
5439
+ }
5440
+ const sceneIndex = typeof gltf.scene === "number" ? gltf.scene : 0;
5441
+ const scene = gltf.scenes?.[sceneIndex];
5442
+ const rootNode = scene?.nodes?.[0];
5443
+ if (!rootNode?.matrix)
5444
+ return null;
5445
+ const m = rootNode.matrix;
5446
+ const translationMagnitude = m[12] * m[12] + m[13] * m[13] + m[14] * m[14];
5447
+ if (translationMagnitude <= TRANSLATION_LIMIT_SQUARED)
5448
+ return null;
5449
+ return rootNode;
5450
+ }
5428
5451
 
5429
5452
  // ../../node_modules/@math.gl/culling/dist/constants.js
5430
5453
  var INTERSECTION = {
@@ -6921,6 +6944,13 @@ var __exports__ = (() => {
6921
6944
  _inRequestVolume = false;
6922
6945
  _lodJudge = null;
6923
6946
  // TODO i3s specific, needs to remove
6947
+ /**
6948
+ * Indicates whether the tile has been drawn by the renderer.
6949
+ * Defaults to true for backwards compatibility — renderers that support
6950
+ * transition hold (e.g. deck.gl 9.3+) should set this to false on tile load,
6951
+ * then back to true after first draw to avoid flashes (see deck.gl #7914).
6952
+ */
6953
+ tileDrawn = true;
6924
6954
  /**
6925
6955
  * @constructs
6926
6956
  * Create a Tile3D instance
@@ -7145,6 +7175,7 @@ var __exports__ = (() => {
7145
7175
  }
7146
7176
  this.header.content = null;
7147
7177
  this.contentState = TILE_CONTENT_STATE.UNLOADED;
7178
+ this.tileDrawn = true;
7148
7179
  return true;
7149
7180
  }
7150
7181
  /**
@@ -7638,6 +7669,8 @@ var __exports__ = (() => {
7638
7669
  onTileError: () => {
7639
7670
  },
7640
7671
  onTraversalComplete: (selectedTiles) => selectedTiles,
7672
+ onUpdate: () => {
7673
+ },
7641
7674
  contentLoader: void 0,
7642
7675
  viewDistanceScale: 1,
7643
7676
  maximumScreenSpaceError: 8,
@@ -7731,6 +7764,8 @@ var __exports__ = (() => {
7731
7764
  _traverser;
7732
7765
  _cache = new TilesetCache();
7733
7766
  _requestScheduler;
7767
+ /** Tile IDs held visible during transitions until replacements have drawn */
7768
+ _heldTiles = /* @__PURE__ */ new Set();
7734
7769
  // Promise tracking
7735
7770
  updatePromise = null;
7736
7771
  tilesetInitializationPromise;
@@ -7943,6 +7978,7 @@ var __exports__ = (() => {
7943
7978
  * Update tiles relying on data from all traversers
7944
7979
  */
7945
7980
  _updateTiles() {
7981
+ const previousSelectedTiles = this.selectedTiles;
7946
7982
  this.selectedTiles = [];
7947
7983
  this._requestedTiles = [];
7948
7984
  this._emptyTiles = [];
@@ -7953,12 +7989,42 @@ var __exports__ = (() => {
7953
7989
  this._emptyTiles = this._emptyTiles.concat(frameStateDataValue._emptyTiles);
7954
7990
  }
7955
7991
  this.selectedTiles = this.options.onTraversalComplete(this.selectedTiles);
7992
+ const selectedIds = new Set(this.selectedTiles.map((t) => t.id));
7993
+ const hasUndrawnTiles = this.selectedTiles.some((t) => !t.tileDrawn);
7994
+ let heldBackCount = 0;
7995
+ if (hasUndrawnTiles) {
7996
+ for (const tileId of selectedIds) {
7997
+ this._heldTiles.add(tileId);
7998
+ }
7999
+ for (const tileId of this._heldTiles) {
8000
+ if (selectedIds.has(tileId))
8001
+ continue;
8002
+ const tile = this._tiles[tileId];
8003
+ if (tile && tile.contentAvailable) {
8004
+ tile._selectedFrame = this._frameNumber;
8005
+ this.selectedTiles.push(tile);
8006
+ heldBackCount++;
8007
+ } else {
8008
+ this._heldTiles.delete(tileId);
8009
+ }
8010
+ }
8011
+ } else {
8012
+ this._heldTiles = selectedIds;
8013
+ }
8014
+ if (heldBackCount > 0) {
8015
+ setTimeout(() => {
8016
+ this.selectTiles();
8017
+ }, 0);
8018
+ }
7956
8019
  for (const tile of this.selectedTiles) {
7957
8020
  this._tiles[tile.id] = tile;
7958
8021
  }
7959
8022
  this._loadTiles();
7960
8023
  this._unloadTiles();
7961
8024
  this._updateStats();
8025
+ if (this._tilesChanged(previousSelectedTiles, this.selectedTiles)) {
8026
+ this.options.onUpdate();
8027
+ }
7962
8028
  }
7963
8029
  _tilesChanged(oldSelectedTiles, selectedTiles) {
7964
8030
  if (oldSelectedTiles.length !== selectedTiles.length) {