diff --git a/CHANGES.md b/CHANGES.md index ed244a0b0c4a..b78a21bfeba6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,6 +12,7 @@ - Improved performance and reduced memory usage of `Event` class. [#12896](https://github.com/CesiumGS/cesium/pull/12896) - Fixes vertical misalignment of glyphs in labels with small fonts [#8474](https://github.com/CesiumGS/cesium/issues/8474) - Prevent runtime errors for certain forms of invalid PNTS files [#12872](https://github.com/CesiumGS/cesium/issues/12872) +- Improved tile selection check for Gaussian splats. Allows proper LoD rendering. #### Additions :tada: diff --git a/packages/engine/Source/Scene/GaussianSplatPrimitive.js b/packages/engine/Source/Scene/GaussianSplatPrimitive.js index 78538c47c416..8f1b3d5a49d6 100644 --- a/packages/engine/Source/Scene/GaussianSplatPrimitive.js +++ b/packages/engine/Source/Scene/GaussianSplatPrimitive.js @@ -838,10 +838,24 @@ GaussianSplatPrimitive.prototype.update = function (frameState) { return; } - if ( - tileset._selectedTiles.length !== 0 && - tileset._selectedTiles.length !== this.selectedTileLength - ) { + const selectionChanged = () => { + const currentSelection = tileset._selectedTiles; + if (this._previousSelectionLength !== currentSelection.length) { + this._previousSelectionLength = currentSelection.length; + return true; + } + for (let i = 0; i < currentSelection.length; i++) { + if (!currentSelection[i]._wasSelectedLastFrame) { + this._previousSelectionLength = currentSelection.length; + return true; + } + } + + this._previousSelectionLength = currentSelection.length; + return false; + }; + + if (selectionChanged()) { this._numSplats = 0; this._positions = undefined; this._rotations = undefined;