@rings-webgpu/core 1.0.31 → 1.0.33

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.
@@ -42146,7 +42146,7 @@ class PostProcessingComponent extends ComponentBase {
42146
42146
  }
42147
42147
  }
42148
42148
 
42149
- const version = "1.0.30";
42149
+ const version = "1.0.32";
42150
42150
 
42151
42151
  class Engine3D {
42152
42152
  /**
@@ -64067,25 +64067,10 @@ class LRUCache {
64067
64067
  class PriorityQueue {
64068
64068
  maxJobs = 6;
64069
64069
  // Maximum concurrent tasks
64070
- autoUpdate = true;
64071
- // Auto update
64072
64070
  priorityCallback = null;
64073
64071
  _items = [];
64074
64072
  _callbacks = /* @__PURE__ */ new Map();
64075
64073
  _currJobs = 0;
64076
- _scheduled = false;
64077
- _schedulingCallback;
64078
- constructor() {
64079
- this._schedulingCallback = (func) => {
64080
- requestAnimationFrame(func);
64081
- };
64082
- }
64083
- /**
64084
- * Set scheduling callback (can be used to customize scheduling strategy)
64085
- */
64086
- set schedulingCallback(cb) {
64087
- this._schedulingCallback = cb;
64088
- }
64089
64074
  /**
64090
64075
  * Check if there are tasks running or queued
64091
64076
  */
@@ -64127,9 +64112,6 @@ class PriorityQueue {
64127
64112
  };
64128
64113
  this._items.unshift(item);
64129
64114
  this._callbacks.set(item, data);
64130
- if (this.autoUpdate) {
64131
- this._scheduleJobRun();
64132
- }
64133
64115
  return promise;
64134
64116
  }
64135
64117
  /**
@@ -64161,17 +64143,11 @@ class PriorityQueue {
64161
64143
  toRemove.forEach((item) => this.remove(item));
64162
64144
  }
64163
64145
  /**
64164
- * Schedule task run
64146
+ * Update queue - process pending tasks
64147
+ * Should be called by TilesRenderer in its update() method
64165
64148
  */
64166
- _scheduleJobRun() {
64167
- if (this._scheduled) {
64168
- return;
64169
- }
64170
- this._scheduled = true;
64171
- this._schedulingCallback(() => {
64172
- this._scheduled = false;
64173
- this._tryRunJobs();
64174
- });
64149
+ update() {
64150
+ this._tryRunJobs();
64175
64151
  }
64176
64152
  /**
64177
64153
  * Try to run tasks
@@ -64182,9 +64158,6 @@ class PriorityQueue {
64182
64158
  let iterated = 0;
64183
64159
  const completedCallback = () => {
64184
64160
  this._currJobs--;
64185
- if (this.autoUpdate) {
64186
- this._scheduleJobRun();
64187
- }
64188
64161
  };
64189
64162
  while (maxJobs > this._currJobs && this._items.length > 0 && iterated < maxJobs) {
64190
64163
  this._currJobs++;
@@ -64864,6 +64837,8 @@ class TilesRenderer {
64864
64837
  _root = null;
64865
64838
  // Active and visible tiles set
64866
64839
  _activeTiles = /* @__PURE__ */ new Set();
64840
+ // Tiles that should be hidden but are delayed due to children loading
64841
+ _delayedHideTiles = /* @__PURE__ */ new Set();
64867
64842
  // Rings-specific: Scene group
64868
64843
  group;
64869
64844
  // Rings-specific: Camera management
@@ -64932,6 +64907,7 @@ class TilesRenderer {
64932
64907
  basePath,
64933
64908
  null
64934
64909
  );
64910
+ this.queueTileForDownload(rootTile);
64935
64911
  this._root = rootTile;
64936
64912
  const boundingVolume = new BoundingVolume(rootTile.boundingVolume);
64937
64913
  const sphere = new BoundingSphere();
@@ -64980,6 +64956,7 @@ class TilesRenderer {
64980
64956
  _usedSet.forEach((tile) => lruCache.markUnused(tile));
64981
64957
  _usedSet.clear();
64982
64958
  this.updateCameraInfo();
64959
+ this._checkDelayedHideTiles();
64983
64960
  markUsedTiles(root, this);
64984
64961
  markUsedSetLeaves(root, this);
64985
64962
  markVisibleTiles(root, this);
@@ -64992,6 +64969,8 @@ class TilesRenderer {
64992
64969
  this.requestTileContents(queuedTiles[i]);
64993
64970
  }
64994
64971
  queuedTiles.length = 0;
64972
+ loadQueue.update();
64973
+ processNodeQueue.update();
64995
64974
  lruCache.scheduleUnload();
64996
64975
  const runningTasks = loadQueue.running || processNodeQueue.running;
64997
64976
  if (runningTasks === false && this.isLoading === true) {
@@ -65449,6 +65428,9 @@ class TilesRenderer {
65449
65428
  setTileActive(tile, active) {
65450
65429
  if (active) {
65451
65430
  this._activeTiles.add(tile);
65431
+ if (this._delayedHideTiles.has(tile)) {
65432
+ this._delayedHideTiles.delete(tile);
65433
+ }
65452
65434
  } else {
65453
65435
  this._activeTiles.delete(tile);
65454
65436
  }
@@ -65468,7 +65450,61 @@ class TilesRenderer {
65468
65450
  }
65469
65451
  scene.transform.enable = true;
65470
65452
  } else {
65471
- scene.transform.enable = false;
65453
+ if (!this._delayedHideTiles.has(tile)) {
65454
+ this._delayedHideTiles.add(tile);
65455
+ }
65456
+ }
65457
+ }
65458
+ _checkIsLoadingTileWillBeActive(tile) {
65459
+ return tile.used && (tile.loadingState === LOADING || tile.loadingState === PARSING || !this._activeTiles.has(tile) || !this._visibleTiles.has(tile)) && tile.loadingState !== UNLOADED && tile.loadingState !== FAILED && tile.hasRenderableContent;
65460
+ }
65461
+ /**
65462
+ * Get children tiles that are loading and will be active
65463
+ * Check if child is used in current frame (will be displayed) but not yet loaded
65464
+ */
65465
+ _getLoadingChildrenThatWillBeActive(tile) {
65466
+ const loadingChildren = [];
65467
+ const children = tile.children;
65468
+ for (let i = 0, l = children.length; i < l; i++) {
65469
+ const child = children[i];
65470
+ if (this._checkIsLoadingTileWillBeActive(child)) {
65471
+ loadingChildren.push(child);
65472
+ }
65473
+ if (child.children && child.children.length > 0) {
65474
+ loadingChildren.push(...this._getLoadingChildrenThatWillBeActive(child));
65475
+ }
65476
+ }
65477
+ return loadingChildren;
65478
+ }
65479
+ /**
65480
+ * Get parents tiles that are loading and will be active
65481
+ * Check if parent is used in current frame (will be displayed) but not yet loaded
65482
+ */
65483
+ _getLoadingParentsThatWillBeActive(tile) {
65484
+ const loadingParents = [];
65485
+ const parent = tile.parent;
65486
+ if (parent) {
65487
+ if (this._checkIsLoadingTileWillBeActive(parent)) {
65488
+ loadingParents.push(parent);
65489
+ }
65490
+ }
65491
+ return loadingParents;
65492
+ }
65493
+ /**
65494
+ * Check and process delayed hide tiles when a child finishes loading
65495
+ */
65496
+ _checkDelayedHideTiles() {
65497
+ for (const tile of this._delayedHideTiles) {
65498
+ const stillLoadingChildren = this._getLoadingChildrenThatWillBeActive(tile);
65499
+ const stillLoadingParents = this._getLoadingParentsThatWillBeActive(tile);
65500
+ const stillLoading = [...stillLoadingChildren, ...stillLoadingParents];
65501
+ if (stillLoading.length === 0) {
65502
+ this._delayedHideTiles.delete(tile);
65503
+ const scene = tile.cached.scene;
65504
+ if (scene) {
65505
+ scene.transform.enable = false;
65506
+ }
65507
+ }
65472
65508
  }
65473
65509
  }
65474
65510
  /**
@@ -65477,6 +65513,9 @@ class TilesRenderer {
65477
65513
  setTileVisible(tile, visible) {
65478
65514
  if (visible) {
65479
65515
  this._visibleTiles.add(tile);
65516
+ if (this._delayedHideTiles.has(tile)) {
65517
+ this._delayedHideTiles.delete(tile);
65518
+ }
65480
65519
  } else {
65481
65520
  this._visibleTiles.delete(tile);
65482
65521
  }
@@ -65484,7 +65523,13 @@ class TilesRenderer {
65484
65523
  if (!scene) {
65485
65524
  return;
65486
65525
  }
65487
- scene.transform.enable = visible;
65526
+ if (visible) {
65527
+ scene.transform.enable = true;
65528
+ } else {
65529
+ if (!this._delayedHideTiles.has(tile)) {
65530
+ this._delayedHideTiles.add(tile);
65531
+ }
65532
+ }
65488
65533
  }
65489
65534
  /**
65490
65535
  * Add tile to download queue