From 5f3539302ec0fd5591f86d330682d15f517a91f4 Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Thu, 21 Dec 2023 13:51:55 -0500
Subject: [PATCH 01/23] Enable dynamicScreenSpaceError, document parameters
---
.../engine/Source/Scene/Cesium3DTileset.js | 66 ++++++++++++-------
1 file changed, 41 insertions(+), 25 deletions(-)
diff --git a/packages/engine/Source/Scene/Cesium3DTileset.js b/packages/engine/Source/Scene/Cesium3DTileset.js
index 0f5f3b56bcb9..dc55bef4019f 100644
--- a/packages/engine/Source/Scene/Cesium3DTileset.js
+++ b/packages/engine/Source/Scene/Cesium3DTileset.js
@@ -75,10 +75,10 @@ import Cesium3DTilesetSkipTraversal from "./Cesium3DTilesetSkipTraversal.js";
* @property {boolean} [preloadWhenHidden=false] Preload tiles when tileset.show
is false
. Loads tiles as if the tileset is visible but does not render them.
* @property {boolean} [preloadFlightDestinations=true] Optimization option. Preload tiles at the camera's flight destination while the camera is in flight.
* @property {boolean} [preferLeaves=false] Optimization option. Prefer loading of leaves first.
- * @property {boolean} [dynamicScreenSpaceError=false] Optimization option. Reduce the screen space error for tiles that are further away from the camera.
- * @property {number} [dynamicScreenSpaceErrorDensity=0.00278] Density used to adjust the dynamic screen space error, similar to fog density.
- * @property {number} [dynamicScreenSpaceErrorFactor=4.0] A factor used to increase the computed dynamic screen space error.
- * @property {number} [dynamicScreenSpaceErrorHeightFalloff=0.25] A ratio of the tileset's height at which the density starts to falloff.
+ * @property {boolean} [dynamicScreenSpaceError=true] Optimization option. Reduce the screen space error for tiles that are further away from the camera so that lower resolution tiles are used.
+ * @property {number} [dynamicScreenSpaceErrorDensity=0.00278] Similar to fog density, this value determines how far away from the camera that screen space error falls off. Larger values will cause tiles closer to the camera to be affected by dynamicScreenSpaceError.
+ * @property {number} [dynamicScreenSpaceErrorFactor=4.0] The maximum screen space error adjustment in px to apply to a tile for tiles far away on the horizon. Increase this value to make the SSE adjustment stronger, which in turn will select lower LOD tiles near the horizon.
+ * @property {number} [dynamicScreenSpaceErrorHeightFalloff=0.25] A ratio of the tileset's height above which the density decreases for dynamic screen space error. This way, dynamicScreenSpaceError has the strongest effect when the camera is close to street level.
* @property {number} [progressiveResolutionHeightFraction=0.3] Optimization option. If between (0.0, 0.5], tiles at or above the screen space error for the reduced screen resolution of progressiveResolutionHeightFraction*screenHeight
will be prioritized first. This can help get a quick layer of tiles down while full resolution tiles continue to load.
* @property {boolean} [foveatedScreenSpaceError=true] Optimization option. Prioritize loading tiles in the center of the screen by temporarily raising the screen space error for tiles around the edge of the screen. Screen space error returns to normal once all the tiles in the center of the screen as determined by the {@link Cesium3DTileset#foveatedConeSize} are loaded.
* @property {number} [foveatedConeSize=0.1] Optimization option. Used when {@link Cesium3DTileset#foveatedScreenSpaceError} is true to control the cone size that determines which tiles are deferred. Tiles that are inside this cone are loaded immediately. Tiles outside the cone are potentially deferred based on how far outside the cone they are and their screen space error. This is controlled by {@link Cesium3DTileset#foveatedInterpolationCallback} and {@link Cesium3DTileset#foveatedMinimumScreenSpaceErrorRelaxation}. Setting this to 0.0 means the cone will be the line formed by the camera position and its view direction. Setting this to 1.0 means the cone encompasses the entire field of view of the camera, disabling the effect.
@@ -361,18 +361,18 @@ function Cesium3DTileset(options) {
this._pass = undefined; // Cesium3DTilePass
/**
- * Optimization option. Whether the tileset should refine based on a dynamic screen space error. Tiles that are further
- * away will be rendered with lower detail than closer tiles. This improves performance by rendering fewer
- * tiles and making less requests, but may result in a slight drop in visual quality for tiles in the distance.
- * The algorithm is biased towards "street views" where the camera is close to the ground plane of the tileset and looking
- * at the horizon. In addition results are more accurate for tightly fitting bounding volumes like box and region.
+ * Optimization option. Whether the tileset should adjust the screen space error for tiles on the horizon. Tiles that
+ * are far away will be adjusted to render at lower detail than tiles closer at the camera. This improves performance
+ * by loading and rendering fewer tiles, but may result in a slight drop in visual quality in the distance. This
+ * optimization is strongest when the camera is close to the ground plane of the tileset and looking at the horizon.
+ * Furthermore, the results are more accurate for tightly fitting bounding volumes like box and region.
*
* @type {boolean}
* @default false
*/
this.dynamicScreenSpaceError = defaultValue(
options.dynamicScreenSpaceError,
- false
+ true
);
/**
@@ -416,18 +416,22 @@ function Cesium3DTileset(options) {
this.foveatedTimeDelay = defaultValue(options.foveatedTimeDelay, 0.2);
/**
- * A scalar that determines the density used to adjust the dynamic screen space error, similar to {@link Fog}. Increasing this
- * value has the effect of increasing the maximum screen space error for all tiles, but in a non-linear fashion.
- * The error starts at 0.0 and increases exponentially until a midpoint is reached, and then approaches 1.0 asymptotically.
- * This has the effect of keeping high detail in the closer tiles and lower detail in the further tiles, with all tiles
- * beyond a certain distance all roughly having an error of 1.0.
+ * A parameter that controls how far away from the camera screen space error (SSE) falls off when
+ * dynamicScreenSpaceError
is enabled. This is similar to the density
parameter of
+ * {@link Fog}. This value must be non-negative.
+ *
+ * dynamicScreenSpaceError
causes the tile SSE to fall off with distance from the camera like a bell
+ * curve. At the camera, no adjustment is made (peak of bell curve). For tiles further away, the SSE is reduced
+ * up to a limit for tiles on the horizon. The maximum reduction is determined by the
+ * dynamicScreenSpaceErrorFactor
. Reducing the SSE allows the rendering algorithm to select
+ * lower-resolution tiles.
+ *
*
- * The dynamic error is in the range [0.0, 1.0) and is multiplied by dynamicScreenSpaceErrorFactor
to produce the
- * final dynamic error. This dynamic error is then subtracted from the tile's actual screen space error.
+ * Increasing the density makes the bell curve narrower. This means that the SSE adjustment will start happening
+ * closer to the camera. This is analgous to moving fog closer to the camera.
*
*
- * Increasing dynamicScreenSpaceErrorDensity
has the effect of moving the error midpoint closer to the camera.
- * It is analogous to moving fog closer to the camera.
+ * When the density is 0, no tiles will have their SSE adjusted.
*
*
* @type {number}
@@ -436,8 +440,19 @@ function Cesium3DTileset(options) {
this.dynamicScreenSpaceErrorDensity = 0.00278;
/**
- * A factor used to increase the screen space error of tiles for dynamic screen space error. As this value increases less tiles
- * are requested for rendering and tiles in the distance will have lower detail. If set to zero, the feature will be disabled.
+ * The maximum screen space error (SSE) reduction when {@link Cesium3DTileset#dynamicScreenSpaceError} is used. The
+ * value must be non-negative.
+ *
+ * Increasing the SSE factor increases the maximum amount to reduce a tile's SSE. This maximum reduction happens
+ * for tiles near the horizon. For tiles closer to the camera, the SSE adjustment can be small as 0 (at the camera).
+ * In between, the SSE falls off like a bell curve. See {@link Cesium3DTileset#dynamicScreenSpaceErrorDensity}
+ *
+ *
+ * When the SSE factor is set to 0, the adjustment will be 0 for all tiles.
+ *
+ * A factor used to increase the screen space error of tiles for dynamic screen space error. As this value increases
+ * less tiles are requested for rendering and tiles in the distance will have lower detail. If set to zero, the
+ * feature will be disabled.
*
* @type {number}
* @default 4.0
@@ -445,9 +460,9 @@ function Cesium3DTileset(options) {
this.dynamicScreenSpaceErrorFactor = 4.0;
/**
- * A ratio of the tileset's height at which the density starts to falloff. If the camera is below this height the
- * full computed density is applied, otherwise the density falls off. This has the effect of higher density at
- * street level views.
+ * A ratio of the tileset's height above which the effects of {@link Cesium3DTileset#dynamicScreenSpaceError} begin
+ * to fall off. This determines what is considered "street level" for the tileset. The dynamic screen space error
+ * optimization is intended for when the camera is at street level and pointed at the horizon.
*
* Valid values are between 0.0 and 1.0.
*
@@ -457,7 +472,8 @@ function Cesium3DTileset(options) {
*/
this.dynamicScreenSpaceErrorHeightFalloff = 0.25;
- this._dynamicScreenSpaceErrorComputedDensity = 0.0; // Updated based on the camera position and direction
+ // Updated based on the camera position and direction
+ this._dynamicScreenSpaceErrorComputedDensity = 0.0;
/**
* Determines whether the tileset casts or receives shadows from light sources.
From 642c7a376fd7daf1e53d3e9c974107369e1ff6b8 Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Thu, 21 Dec 2023 13:59:03 -0500
Subject: [PATCH 02/23] Update CHANGES.md
---
CHANGES.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CHANGES.md b/CHANGES.md
index ba1296873239..28bc2d05be98 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -4,6 +4,10 @@
#### @cesium/engine
+##### Additions :tada:
+
+- The `Cesium3DTileset.dynamicScreenSpaceError` optimization is now enabled by default, as this improves performance for street-level horizon views. TODO: PR link
+
##### Fixes :wrench:
- Changes the default `RequestScheduler.maximumRequestsPerServer` from 6 to 18. This should improve performance on HTTP/2 servers and above [#11627](https://github.com/CesiumGS/cesium/issues/11627)
From 5a0679d4bd166b839f12f7570ce17bd0d6375aa8 Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Thu, 21 Dec 2023 15:32:25 -0500
Subject: [PATCH 03/23] Add missing defaultValue() calls
---
.../engine/Source/Scene/Cesium3DTileset.js | 30 ++++++++++++++-----
1 file changed, 23 insertions(+), 7 deletions(-)
diff --git a/packages/engine/Source/Scene/Cesium3DTileset.js b/packages/engine/Source/Scene/Cesium3DTileset.js
index dc55bef4019f..cfa854fd7f7d 100644
--- a/packages/engine/Source/Scene/Cesium3DTileset.js
+++ b/packages/engine/Source/Scene/Cesium3DTileset.js
@@ -17,6 +17,7 @@ import IonResource from "../Core/IonResource.js";
import JulianDate from "../Core/JulianDate.js";
import ManagedArray from "../Core/ManagedArray.js";
import CesiumMath from "../Core/Math.js";
+import Matrix3 from "../Core/Matrix3.js";
import Matrix4 from "../Core/Matrix4.js";
import Resource from "../Core/Resource.js";
import RuntimeError from "../Core/RuntimeError.js";
@@ -437,7 +438,10 @@ function Cesium3DTileset(options) {
* @type {number}
* @default 0.00278
*/
- this.dynamicScreenSpaceErrorDensity = 0.00278;
+ this.dynamicScreenSpaceErrorDensity = defaultValue(
+ options.dynamicScreenSpaceErrorDensity,
+ 0.00278
+ );
/**
* The maximum screen space error (SSE) reduction when {@link Cesium3DTileset#dynamicScreenSpaceError} is used. The
@@ -457,7 +461,10 @@ function Cesium3DTileset(options) {
* @type {number}
* @default 4.0
*/
- this.dynamicScreenSpaceErrorFactor = 4.0;
+ this.dynamicScreenSpaceErrorFactor = defaultValue(
+ options.dynamicScreenSpaceErrorFactor,
+ 4.0
+ );
/**
* A ratio of the tileset's height above which the effects of {@link Cesium3DTileset#dynamicScreenSpaceError} begin
@@ -470,7 +477,10 @@ function Cesium3DTileset(options) {
* @type {number}
* @default 0.25
*/
- this.dynamicScreenSpaceErrorHeightFalloff = 0.25;
+ this.dynamicScreenSpaceErrorHeightFalloff = defaultValue(
+ options.dynamicScreenSpaceErrorHeightFalloff,
+ 0.25
+ );
// Updated based on the camera position and direction
this._dynamicScreenSpaceErrorComputedDensity = 0.0;
@@ -2282,6 +2292,7 @@ const scratchMatrix = new Matrix4();
const scratchCenter = new Cartesian3();
const scratchPosition = new Cartesian3();
const scratchDirection = new Cartesian3();
+const scratchHalfHeight = new Cartesian3();
/**
* @private
@@ -2346,10 +2357,15 @@ function updateDynamicScreenSpaceError(tileset, frameState) {
direction = Cartesian3.normalize(direction, direction);
height = positionLocal.z;
if (tileBoundingVolume instanceof TileOrientedBoundingBox) {
- // Assuming z-up, the last component stores the half-height of the box
- const boxHeight = root._header.boundingVolume.box[11];
- minimumHeight = centerLocal.z - boxHeight;
- maximumHeight = centerLocal.z + boxHeight;
+ // Assuming z-up, the last column
+ const halfHeightVector = Matrix3.getColumn(
+ boundingVolume.halfAxes,
+ 2,
+ scratchHalfHeight
+ );
+ const halfHeight = Cartesian3.magnitude(halfHeightVector);
+ minimumHeight = centerLocal.z - halfHeight;
+ maximumHeight = centerLocal.z + halfHeight;
} else if (tileBoundingVolume instanceof TileBoundingSphere) {
const radius = boundingVolume.radius;
minimumHeight = centerLocal.z - radius;
From fde33ff77c03f3353d43f5759d685d089d8752b4 Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Thu, 21 Dec 2023 15:34:11 -0500
Subject: [PATCH 04/23] Turn down dynamicSSE to fix picking tests
---
packages/engine/Specs/Scene/PickingSpec.js | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/packages/engine/Specs/Scene/PickingSpec.js b/packages/engine/Specs/Scene/PickingSpec.js
index 4474051a0adc..6e9c2198945c 100644
--- a/packages/engine/Specs/Scene/PickingSpec.js
+++ b/packages/engine/Specs/Scene/PickingSpec.js
@@ -134,6 +134,11 @@ describe(
function createTileset(url) {
const options = {
maximumScreenSpaceError: 0,
+ // Since unit tests render to a tiny canvas, tileset rendering is
+ // extremely sensitive to changes in screen space error. Turn the
+ // dynamic screen space error down significantly so we don't cull tiles
+ // needed for the unit tests.
+ dynamicScreenSpaceErrorFactor: 0.0001,
};
return Cesium3DTilesTester.loadTileset(scene, url, options).then(
function (tileset) {
From b309cbff2f57b05268bc6973e06a531521d06940 Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Thu, 21 Dec 2023 15:44:53 -0500
Subject: [PATCH 05/23] Turn off dynamic SSE instead
---
packages/engine/Specs/Scene/PickingSpec.js | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/packages/engine/Specs/Scene/PickingSpec.js b/packages/engine/Specs/Scene/PickingSpec.js
index 6e9c2198945c..af868c13044f 100644
--- a/packages/engine/Specs/Scene/PickingSpec.js
+++ b/packages/engine/Specs/Scene/PickingSpec.js
@@ -134,11 +134,10 @@ describe(
function createTileset(url) {
const options = {
maximumScreenSpaceError: 0,
- // Since unit tests render to a tiny canvas, tileset rendering is
- // extremely sensitive to changes in screen space error. Turn the
- // dynamic screen space error down significantly so we don't cull tiles
- // needed for the unit tests.
- dynamicScreenSpaceErrorFactor: 0.0001,
+ // The camera is zoomed pretty far out for these tests, so
+ // turn off dynamicScreenSpaceError so tiles don't get culled
+ // unintentionally.
+ dynamicScreenSpaceError: false,
};
return Cesium3DTilesTester.loadTileset(scene, url, options).then(
function (tileset) {
From 6dad6f6d911aad06e2403197b95bdd58d091dd7e Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Thu, 21 Dec 2023 16:20:06 -0500
Subject: [PATCH 06/23] Fix inspector dynamicScreenSpaceErrorDensity slider
---
.../Cesium3DTilesInspectorViewModel.js | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/packages/widgets/Source/Cesium3DTilesInspector/Cesium3DTilesInspectorViewModel.js b/packages/widgets/Source/Cesium3DTilesInspector/Cesium3DTilesInspectorViewModel.js
index 42ec352db523..b19aed8e7b08 100644
--- a/packages/widgets/Source/Cesium3DTilesInspector/Cesium3DTilesInspectorViewModel.js
+++ b/packages/widgets/Source/Cesium3DTilesInspector/Cesium3DTilesInspectorViewModel.js
@@ -740,7 +740,11 @@ function Cesium3DTilesInspectorViewModel(scene, performanceContainer) {
return Math.pow(dynamicScreenSpaceErrorDensity(), 1 / 6);
},
set: function (value) {
- dynamicScreenSpaceErrorDensity(Math.pow(value, 6));
+ const scaledValue = Math.pow(value, 6);
+ dynamicScreenSpaceErrorDensity(scaledValue);
+ if (defined(that._tileset)) {
+ that._tileset.dynamicScreenSpaceErrorDensity = scaledValue;
+ }
},
});
From 12f226f01999311c59d0cc015e42531e40ff4784 Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Thu, 21 Dec 2023 16:25:18 -0500
Subject: [PATCH 07/23] Update changelog for inspector fix
---
CHANGES.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGES.md b/CHANGES.md
index 28bc2d05be98..45d3f7d908dc 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -13,6 +13,7 @@
- Changes the default `RequestScheduler.maximumRequestsPerServer` from 6 to 18. This should improve performance on HTTP/2 servers and above [#11627](https://github.com/CesiumGS/cesium/issues/11627)
- Corrected JSDoc and Typescript definitions that marked optional arguments as required in `ImageryProvider` constructor [#11625](https://github.com/CesiumGS/cesium/issues/11625)
- The `Quaternion.computeAxis` function created an axis that was `(0,0,0)` for the unit quaternion, and an axis that was `(NaN,NaN,NaN)` for the quaternion `(0,0,0,-1)` (which describes a rotation about 360 degrees). Now, it returns the x-axis `(1,0,0)` in both of these cases.
+- Fixed a bug where the 3D Tiles Inspector's `dynamicScreenSpaceErrorDensity` slider did not update the tileset [#6143](https://github.com/CesiumGS/cesium/issues/6143)
### 1.112 - 2023-12-01
From 236f8d6c47dfebaa7bad3367e92cb67a1247b026 Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Thu, 21 Dec 2023 16:54:31 -0500
Subject: [PATCH 08/23] Add PR number to the changelog
---
CHANGES.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CHANGES.md b/CHANGES.md
index 45d3f7d908dc..ac49f8389ebb 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -6,7 +6,7 @@
##### Additions :tada:
-- The `Cesium3DTileset.dynamicScreenSpaceError` optimization is now enabled by default, as this improves performance for street-level horizon views. TODO: PR link
+- The `Cesium3DTileset.dynamicScreenSpaceError` optimization is now enabled by default, as this improves performance for street-level horizon views. [#11718](https://github.com/CesiumGS/cesium/pull/11718)
##### Fixes :wrench:
From e6e8179b7304360cf95f8cc15f79d63386452b8d Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Tue, 2 Jan 2024 09:10:52 -0500
Subject: [PATCH 09/23] PR feedback
---
packages/engine/Source/Scene/Cesium3DTileset.js | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/packages/engine/Source/Scene/Cesium3DTileset.js b/packages/engine/Source/Scene/Cesium3DTileset.js
index cfa854fd7f7d..96cb09920680 100644
--- a/packages/engine/Source/Scene/Cesium3DTileset.js
+++ b/packages/engine/Source/Scene/Cesium3DTileset.js
@@ -454,9 +454,6 @@ function Cesium3DTileset(options) {
*
* When the SSE factor is set to 0, the adjustment will be 0 for all tiles.
*
- * A factor used to increase the screen space error of tiles for dynamic screen space error. As this value increases
- * less tiles are requested for rendering and tiles in the distance will have lower detail. If set to zero, the
- * feature will be disabled.
*
* @type {number}
* @default 4.0
@@ -2357,7 +2354,8 @@ function updateDynamicScreenSpaceError(tileset, frameState) {
direction = Cartesian3.normalize(direction, direction);
height = positionLocal.z;
if (tileBoundingVolume instanceof TileOrientedBoundingBox) {
- // Assuming z-up, the last column
+ // Assuming z-up, the last column is the local z direction and
+ // represents the height of the bounding box.
const halfHeightVector = Matrix3.getColumn(
boundingVolume.halfAxes,
2,
From e6bb5f558b78d950008d9a8e59c1c9e88ccefc76 Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Tue, 2 Jan 2024 09:17:37 -0500
Subject: [PATCH 10/23] The fog was unrealistically close to the camera
---
packages/engine/Source/Scene/Cesium3DTileset.js | 10 +++++-----
.../Cesium3DTilesInspectorViewModel.js | 6 +++---
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/packages/engine/Source/Scene/Cesium3DTileset.js b/packages/engine/Source/Scene/Cesium3DTileset.js
index 96cb09920680..ce6140de61b5 100644
--- a/packages/engine/Source/Scene/Cesium3DTileset.js
+++ b/packages/engine/Source/Scene/Cesium3DTileset.js
@@ -77,7 +77,7 @@ import Cesium3DTilesetSkipTraversal from "./Cesium3DTilesetSkipTraversal.js";
* @property {boolean} [preloadFlightDestinations=true] Optimization option. Preload tiles at the camera's flight destination while the camera is in flight.
* @property {boolean} [preferLeaves=false] Optimization option. Prefer loading of leaves first.
* @property {boolean} [dynamicScreenSpaceError=true] Optimization option. Reduce the screen space error for tiles that are further away from the camera so that lower resolution tiles are used.
- * @property {number} [dynamicScreenSpaceErrorDensity=0.00278] Similar to fog density, this value determines how far away from the camera that screen space error falls off. Larger values will cause tiles closer to the camera to be affected by dynamicScreenSpaceError.
+ * @property {number} [dynamicScreenSpaceErrorDensity=2.0e-4] Similar to fog density, this value determines how far away from the camera that screen space error falls off. Larger values will cause tiles closer to the camera to be affected by dynamicScreenSpaceError.
* @property {number} [dynamicScreenSpaceErrorFactor=4.0] The maximum screen space error adjustment in px to apply to a tile for tiles far away on the horizon. Increase this value to make the SSE adjustment stronger, which in turn will select lower LOD tiles near the horizon.
* @property {number} [dynamicScreenSpaceErrorHeightFalloff=0.25] A ratio of the tileset's height above which the density decreases for dynamic screen space error. This way, dynamicScreenSpaceError has the strongest effect when the camera is close to street level.
* @property {number} [progressiveResolutionHeightFraction=0.3] Optimization option. If between (0.0, 0.5], tiles at or above the screen space error for the reduced screen resolution of progressiveResolutionHeightFraction*screenHeight
will be prioritized first. This can help get a quick layer of tiles down while full resolution tiles continue to load.
@@ -167,7 +167,7 @@ import Cesium3DTilesetSkipTraversal from "./Cesium3DTilesetSkipTraversal.js";
* const tileset = await Cesium.Cesium3DTileset.fromUrl(
* "http://localhost:8002/tilesets/Seattle/tileset.json", {
* dynamicScreenSpaceError: true,
- * dynamicScreenSpaceErrorDensity: 0.00278,
+ * dynamicScreenSpaceErrorDensity: 2.0e-4,
* dynamicScreenSpaceErrorFactor: 4.0,
* dynamicScreenSpaceErrorHeightFalloff: 0.25
* });
@@ -436,11 +436,11 @@ function Cesium3DTileset(options) {
*
*
* @type {number}
- * @default 0.00278
+ * @default 2.0e-4
*/
this.dynamicScreenSpaceErrorDensity = defaultValue(
options.dynamicScreenSpaceErrorDensity,
- 0.00278
+ 2.0e-4
);
/**
@@ -1991,7 +1991,7 @@ Cesium3DTileset.fromIonAssetId = async function (assetId, options) {
* const tileset = await Cesium.Cesium3DTileset.fromUrl(
* "http://localhost:8002/tilesets/Seattle/tileset.json", {
* dynamicScreenSpaceError: true,
- * dynamicScreenSpaceErrorDensity: 0.00278,
+ * dynamicScreenSpaceErrorDensity: 2.0e-4,
* dynamicScreenSpaceErrorFactor: 4.0,
* dynamicScreenSpaceErrorHeightFalloff: 0.25
* });
diff --git a/packages/widgets/Source/Cesium3DTilesInspector/Cesium3DTilesInspectorViewModel.js b/packages/widgets/Source/Cesium3DTilesInspector/Cesium3DTilesInspectorViewModel.js
index b19aed8e7b08..41208c1b0ea2 100644
--- a/packages/widgets/Source/Cesium3DTilesInspector/Cesium3DTilesInspectorViewModel.js
+++ b/packages/widgets/Source/Cesium3DTilesInspector/Cesium3DTilesInspectorViewModel.js
@@ -722,9 +722,9 @@ function Cesium3DTilesInspectorViewModel(scene, performanceContainer) {
* Gets or sets the dynamic screen space error density. This property is observable.
*
* @type {number}
- * @default 0.00278
+ * @default 2.0e-4
*/
- this.dynamicScreenSpaceErrorDensity = 0.00278;
+ this.dynamicScreenSpaceErrorDensity = 2.0e-4;
/**
* Gets or sets the dynamic screen space error density slider value.
@@ -732,7 +732,7 @@ function Cesium3DTilesInspectorViewModel(scene, performanceContainer) {
* This property is observable.
*
* @type {number}
- * @default 0.00278
+ * @default 2.0e-4
*/
this.dynamicScreenSpaceErrorDensitySliderValue = undefined;
knockout.defineProperty(this, "dynamicScreenSpaceErrorDensitySliderValue", {
From 112792603ff21922c0a44f4520bb8e49f2f94194 Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Tue, 2 Jan 2024 12:07:31 -0500
Subject: [PATCH 11/23] Put changelog entry in breaking changes section
---
CHANGES.md | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/CHANGES.md b/CHANGES.md
index 6bfba281f2f6..5365a8fd59b2 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,5 +1,15 @@
# Change Log
+### 1.114 - 2024-02-01
+
+#### @cesium/engine
+
+##### Breaking Changes :mega:
+
+- The `Cesium3DTileset.dynamicScreenSpaceError` optimization is now enabled by default, as this improves performance for street-level horizon views. [#11718](https://github.com/CesiumGS/cesium/pull/11718)
+- The default value of `Cesium3DTileset.dynamicScreenSpaceErrorDensity` was changed from 0.00278 to 0.0002 to be more consistent with terrain [#11718](https://github.com/CesiumGS/cesium/pull/11718)
+- The default value of `Cesium3DTileset.dynamicScreenSpaceErrorFactor` was changed from 4 to 24 for improved performance when dynamic screen space error is used. [#11718](https://github.com/CesiumGS/cesium/pull/11718)
+
### 1.113 - 2024-01-02
#### @cesium/engine
@@ -7,7 +17,6 @@
##### Additions :tada:
- Vertical exaggeration can now be applied to a `Cesium3DTileset`. Exaggeration of `Terrain` and `Cesium3DTileset` can be controlled simultaneously via the new `Scene` properties `Scene.verticalExaggeration` and `Scene.verticalExaggerationRelativeHeight`. [#11655](https://github.com/CesiumGS/cesium/pull/11655)
-- The `Cesium3DTileset.dynamicScreenSpaceError` optimization is now enabled by default, as this improves performance for street-level horizon views. [#11718](https://github.com/CesiumGS/cesium/pull/11718)
##### Fixes :wrench:
From 1604f8e79498dae01e2cac200c45fdbc8a588562 Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Tue, 2 Jan 2024 12:08:18 -0500
Subject: [PATCH 12/23] PR feedback
---
packages/engine/Source/Scene/Cesium3DTileset.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/engine/Source/Scene/Cesium3DTileset.js b/packages/engine/Source/Scene/Cesium3DTileset.js
index ce6140de61b5..ead53b930df6 100644
--- a/packages/engine/Source/Scene/Cesium3DTileset.js
+++ b/packages/engine/Source/Scene/Cesium3DTileset.js
@@ -369,7 +369,7 @@ function Cesium3DTileset(options) {
* Furthermore, the results are more accurate for tightly fitting bounding volumes like box and region.
*
* @type {boolean}
- * @default false
+ * @default true
*/
this.dynamicScreenSpaceError = defaultValue(
options.dynamicScreenSpaceError,
From bddb6cc37645c61f0fdd5b50f339a55ada0c8ce6 Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Tue, 2 Jan 2024 12:08:37 -0500
Subject: [PATCH 13/23] Increase SSE Factor slider maximum
---
.../Source/Cesium3DTilesInspector/Cesium3DTilesInspector.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/widgets/Source/Cesium3DTilesInspector/Cesium3DTilesInspector.js b/packages/widgets/Source/Cesium3DTilesInspector/Cesium3DTilesInspector.js
index a88bb400ae96..742434dc7361 100644
--- a/packages/widgets/Source/Cesium3DTilesInspector/Cesium3DTilesInspector.js
+++ b/packages/widgets/Source/Cesium3DTilesInspector/Cesium3DTilesInspector.js
@@ -215,7 +215,7 @@ function Cesium3DTilesInspector(container, scene) {
"Screen Space Error Factor",
"dynamicScreenSpaceErrorFactor",
1,
- 10,
+ 32,
0.1
)
);
From bb93b35b4c10d4660e61d6463229f1aad448082c Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Tue, 2 Jan 2024 13:47:11 -0500
Subject: [PATCH 14/23] Revise the parameter documentation
---
.../engine/Source/Scene/Cesium3DTileset.js | 60 +++++++++----------
1 file changed, 29 insertions(+), 31 deletions(-)
diff --git a/packages/engine/Source/Scene/Cesium3DTileset.js b/packages/engine/Source/Scene/Cesium3DTileset.js
index ead53b930df6..cc723f1a3efc 100644
--- a/packages/engine/Source/Scene/Cesium3DTileset.js
+++ b/packages/engine/Source/Scene/Cesium3DTileset.js
@@ -76,10 +76,10 @@ import Cesium3DTilesetSkipTraversal from "./Cesium3DTilesetSkipTraversal.js";
* @property {boolean} [preloadWhenHidden=false] Preload tiles when tileset.show
is false
. Loads tiles as if the tileset is visible but does not render them.
* @property {boolean} [preloadFlightDestinations=true] Optimization option. Preload tiles at the camera's flight destination while the camera is in flight.
* @property {boolean} [preferLeaves=false] Optimization option. Prefer loading of leaves first.
- * @property {boolean} [dynamicScreenSpaceError=true] Optimization option. Reduce the screen space error for tiles that are further away from the camera so that lower resolution tiles are used.
- * @property {number} [dynamicScreenSpaceErrorDensity=2.0e-4] Similar to fog density, this value determines how far away from the camera that screen space error falls off. Larger values will cause tiles closer to the camera to be affected by dynamicScreenSpaceError.
- * @property {number} [dynamicScreenSpaceErrorFactor=4.0] The maximum screen space error adjustment in px to apply to a tile for tiles far away on the horizon. Increase this value to make the SSE adjustment stronger, which in turn will select lower LOD tiles near the horizon.
- * @property {number} [dynamicScreenSpaceErrorHeightFalloff=0.25] A ratio of the tileset's height above which the density decreases for dynamic screen space error. This way, dynamicScreenSpaceError has the strongest effect when the camera is close to street level.
+ * @property {boolean} [dynamicScreenSpaceError=true] Optimization option. For street-level horizon views, use lower resolution tiles far from the camera. This reduces the amount of data loaded and improves tileset loading time with a slight drop in visual quality in the distance.
+ * @property {number} [dynamicScreenSpaceErrorDensity=2.0e-4] Similar to {@link Fog#density}, this option controls the camera distance at which the {@link Cesium3DTileset#dynamicScreenSpaceError} optimization applies. Larger values will cause tiles closer to the camera to be affected.
+ * @property {number} [dynamicScreenSpaceErrorFactor=4.0] A parameter that controls the intensity of the {@link Cesium3DTileset#dynamicScreenSpaceError} optimization for tiles on the horizon. Larger values cause lower resolution tiles to load, improving runtime performance at a slight reduction of visual quality.
+ * @property {number} [dynamicScreenSpaceErrorHeightFalloff=0.25] A ratio of the tileset's height that determines where "street level" camera views occur. When the camera is below this height, the {@link Cesium3DTileset#dynamicScreenSpaceError} optimization will have the maximum effect, and it will roll off above this value.
* @property {number} [progressiveResolutionHeightFraction=0.3] Optimization option. If between (0.0, 0.5], tiles at or above the screen space error for the reduced screen resolution of progressiveResolutionHeightFraction*screenHeight
will be prioritized first. This can help get a quick layer of tiles down while full resolution tiles continue to load.
* @property {boolean} [foveatedScreenSpaceError=true] Optimization option. Prioritize loading tiles in the center of the screen by temporarily raising the screen space error for tiles around the edge of the screen. Screen space error returns to normal once all the tiles in the center of the screen as determined by the {@link Cesium3DTileset#foveatedConeSize} are loaded.
* @property {number} [foveatedConeSize=0.1] Optimization option. Used when {@link Cesium3DTileset#foveatedScreenSpaceError} is true to control the cone size that determines which tiles are deferred. Tiles that are inside this cone are loaded immediately. Tiles outside the cone are potentially deferred based on how far outside the cone they are and their screen space error. This is controlled by {@link Cesium3DTileset#foveatedInterpolationCallback} and {@link Cesium3DTileset#foveatedMinimumScreenSpaceErrorRelaxation}. Setting this to 0.0 means the cone will be the line formed by the camera position and its view direction. Setting this to 1.0 means the cone encompasses the entire field of view of the camera, disabling the effect.
@@ -362,11 +362,11 @@ function Cesium3DTileset(options) {
this._pass = undefined; // Cesium3DTilePass
/**
- * Optimization option. Whether the tileset should adjust the screen space error for tiles on the horizon. Tiles that
- * are far away will be adjusted to render at lower detail than tiles closer at the camera. This improves performance
- * by loading and rendering fewer tiles, but may result in a slight drop in visual quality in the distance. This
- * optimization is strongest when the camera is close to the ground plane of the tileset and looking at the horizon.
- * Furthermore, the results are more accurate for tightly fitting bounding volumes like box and region.
+ * Optimization option. For street-level horizon views, use lower resolution tiles far from the camera. This reduces
+ * the amount of data loaded and improves tileset loading time with a slight drop in visual quality in the distance.
+ *
+ * This optimization is strongest when the camera is close to the ground plane of the tileset and looking at the
+ * horizon. Furthermore, the results are more accurate for tightly fitting bounding volumes like box and region.
*
* @type {boolean}
* @default true
@@ -417,22 +417,21 @@ function Cesium3DTileset(options) {
this.foveatedTimeDelay = defaultValue(options.foveatedTimeDelay, 0.2);
/**
- * A parameter that controls how far away from the camera screen space error (SSE) falls off when
- * dynamicScreenSpaceError
is enabled. This is similar to the density
parameter of
- * {@link Fog}. This value must be non-negative.
+ * Similar to {@link Fog#density}, this option controls the camera distance at which the {@link Cesium3DTileset#dynamicScreenSpaceError}
+ * optimization applies. Larger values will cause tiles closer to the camera to be affected. This value must be
+ * non-negative.
*
- * dynamicScreenSpaceError
causes the tile SSE to fall off with distance from the camera like a bell
- * curve. At the camera, no adjustment is made (peak of bell curve). For tiles further away, the SSE is reduced
- * up to a limit for tiles on the horizon. The maximum reduction is determined by the
- * dynamicScreenSpaceErrorFactor
. Reducing the SSE allows the rendering algorithm to select
- * lower-resolution tiles.
+ * This optimization works by rolling off the tile screen space error (SSE) with camera distance like a bell curve.
+ * This has the effect of selecting lower resolution tiles far from the camera. Near the camera, no adjustment is
+ * made. For tiles further away, the SSE is reduced by up to {@link Cesium3DTileset#dynamicScreenSpaceErrorFactor}
+ * (measured in pixels of error).
*
*
- * Increasing the density makes the bell curve narrower. This means that the SSE adjustment will start happening
- * closer to the camera. This is analgous to moving fog closer to the camera.
+ * Increasing the density makes the bell curve narrower so tiles closer to the camera are affected. This is analagous
+ * to moving fog closer to the camera.
*
*
- * When the density is 0, no tiles will have their SSE adjusted.
+ * When the density is 0, the optimization will have no effect on the tileset.
*
*
* @type {number}
@@ -444,15 +443,16 @@ function Cesium3DTileset(options) {
);
/**
- * The maximum screen space error (SSE) reduction when {@link Cesium3DTileset#dynamicScreenSpaceError} is used. The
- * value must be non-negative.
+ * A parameter that controls the intensity of the {@link Cesium3DTileset#dynamicScreenSpaceError} optimization for
+ * tiles on the horizon. Larger values cause lower resolution tiles to load, improving runtime performance at a slight
+ * reduction of visual quality. The value must be non-negative.
*
- * Increasing the SSE factor increases the maximum amount to reduce a tile's SSE. This maximum reduction happens
- * for tiles near the horizon. For tiles closer to the camera, the SSE adjustment can be small as 0 (at the camera).
- * In between, the SSE falls off like a bell curve. See {@link Cesium3DTileset#dynamicScreenSpaceErrorDensity}
+ * More specifically, this parameter represents the maximum adjustment to screen space error (SSE) in pixels for tiles
+ * far away from the camera. See {@link Cesium3DTileset#dynamicScreenSpaceErrorDensity} for more details about how
+ * this optimization works.
*
*
- * When the SSE factor is set to 0, the adjustment will be 0 for all tiles.
+ * When the SSE factor is set to 0, the optimization will have no effect on the tileset.
*
*
* @type {number}
@@ -464,12 +464,10 @@ function Cesium3DTileset(options) {
);
/**
- * A ratio of the tileset's height above which the effects of {@link Cesium3DTileset#dynamicScreenSpaceError} begin
- * to fall off. This determines what is considered "street level" for the tileset. The dynamic screen space error
- * optimization is intended for when the camera is at street level and pointed at the horizon.
+ * A ratio of the tileset's height that determines "street level" for the {@link Cesium3DTileset#dynamicScreenSpaceError}
+ * optimization. When the camera is below this height, the dynamic screen space error optimization will have the maximum
+ * effect, and it will roll off above this value. Valid values are between 0.0 and 1.0.
*
- * Valid values are between 0.0 and 1.0.
- *
*
* @type {number}
* @default 0.25
From f5e610123e354a16ecffd478dd96af559a1beb63 Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Tue, 2 Jan 2024 13:54:55 -0500
Subject: [PATCH 15/23] Add a changelog entry for fixing the ignored parameters
---
CHANGES.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGES.md b/CHANGES.md
index 1f3d2ab90cb2..dd4c8e9fccbe 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -13,6 +13,7 @@
##### Fixes :wrench:
- Fixed a bug where the 3D Tiles Inspector's `dynamicScreenSpaceErrorDensity` slider did not update the tileset [#6143](https://github.com/CesiumGS/cesium/issues/6143)
+- Fixed a bug where the `Cesium3DTileset` constructor was ignoring the options `dynamicScreenSpaceError`, `dynamicScreenSpaceErrorDensity`, `dynamicScreenSpaceErrorFactor` and `dynamicScreenSpaceErrorHeightFalloff`. [#11677](https://github.com/CesiumGS/cesium/issues/11677)
### 1.113 - 2024-01-02
From f36c303a333265e4e6b8a1cad64ae48b89bddc20 Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Tue, 2 Jan 2024 16:02:02 -0500
Subject: [PATCH 16/23] Reorganize changelog
---
CHANGES.md | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index dd4c8e9fccbe..e5b161633820 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -6,15 +6,18 @@
##### Breaking Changes :mega:
-- The `Cesium3DTileset.dynamicScreenSpaceError` optimization is now enabled by default, as this improves performance for street-level horizon views. [#11718](https://github.com/CesiumGS/cesium/pull/11718)
-- The default value of `Cesium3DTileset.dynamicScreenSpaceErrorDensity` was changed from 0.00278 to 0.0002 to be more consistent with terrain [#11718](https://github.com/CesiumGS/cesium/pull/11718)
-- The default value of `Cesium3DTileset.dynamicScreenSpaceErrorFactor` was changed from 4 to 24 for improved performance when dynamic screen space error is used. [#11718](https://github.com/CesiumGS/cesium/pull/11718)
+- The `Cesium3DTileset.dynamicScreenSpaceError` optimization is now enabled by default, as this improves performance for street-level horizon views. Furthermore, the default settings of this feature were tuned for improved performance. `Cesium3DTileset.dynamicScreenSpaceErrorDensity` was changed from 0.00278 to 0.0002. `Cesium3DTileset.dynamicScreenSpaceErrorFactor` was changed from 4 to 24. [#11718](https://github.com/CesiumGS/cesium/pull/11718)
##### Fixes :wrench:
-- Fixed a bug where the 3D Tiles Inspector's `dynamicScreenSpaceErrorDensity` slider did not update the tileset [#6143](https://github.com/CesiumGS/cesium/issues/6143)
- Fixed a bug where the `Cesium3DTileset` constructor was ignoring the options `dynamicScreenSpaceError`, `dynamicScreenSpaceErrorDensity`, `dynamicScreenSpaceErrorFactor` and `dynamicScreenSpaceErrorHeightFalloff`. [#11677](https://github.com/CesiumGS/cesium/issues/11677)
+#### @cesium/widgets
+
+##### Fixes :wrench:
+
+- Fixed a bug where the 3D Tiles Inspector's `dynamicScreenSpaceErrorDensity` slider did not update the tileset [#6143](https://github.com/CesiumGS/cesium/issues/6143)
+
### 1.113 - 2024-01-02
#### @cesium/engine
From 75dde943685aa657f13f85bb48421cc7f670b017 Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Tue, 2 Jan 2024 16:49:46 -0500
Subject: [PATCH 17/23] Update default setting for SSE factor to 24
---
packages/engine/Source/Scene/Cesium3DTileset.js | 10 +++++-----
.../Cesium3DTilesInspectorViewModel.js | 4 ++--
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/packages/engine/Source/Scene/Cesium3DTileset.js b/packages/engine/Source/Scene/Cesium3DTileset.js
index cc723f1a3efc..09592281a59d 100644
--- a/packages/engine/Source/Scene/Cesium3DTileset.js
+++ b/packages/engine/Source/Scene/Cesium3DTileset.js
@@ -78,7 +78,7 @@ import Cesium3DTilesetSkipTraversal from "./Cesium3DTilesetSkipTraversal.js";
* @property {boolean} [preferLeaves=false] Optimization option. Prefer loading of leaves first.
* @property {boolean} [dynamicScreenSpaceError=true] Optimization option. For street-level horizon views, use lower resolution tiles far from the camera. This reduces the amount of data loaded and improves tileset loading time with a slight drop in visual quality in the distance.
* @property {number} [dynamicScreenSpaceErrorDensity=2.0e-4] Similar to {@link Fog#density}, this option controls the camera distance at which the {@link Cesium3DTileset#dynamicScreenSpaceError} optimization applies. Larger values will cause tiles closer to the camera to be affected.
- * @property {number} [dynamicScreenSpaceErrorFactor=4.0] A parameter that controls the intensity of the {@link Cesium3DTileset#dynamicScreenSpaceError} optimization for tiles on the horizon. Larger values cause lower resolution tiles to load, improving runtime performance at a slight reduction of visual quality.
+ * @property {number} [dynamicScreenSpaceErrorFactor=24.0] A parameter that controls the intensity of the {@link Cesium3DTileset#dynamicScreenSpaceError} optimization for tiles on the horizon. Larger values cause lower resolution tiles to load, improving runtime performance at a slight reduction of visual quality.
* @property {number} [dynamicScreenSpaceErrorHeightFalloff=0.25] A ratio of the tileset's height that determines where "street level" camera views occur. When the camera is below this height, the {@link Cesium3DTileset#dynamicScreenSpaceError} optimization will have the maximum effect, and it will roll off above this value.
* @property {number} [progressiveResolutionHeightFraction=0.3] Optimization option. If between (0.0, 0.5], tiles at or above the screen space error for the reduced screen resolution of progressiveResolutionHeightFraction*screenHeight
will be prioritized first. This can help get a quick layer of tiles down while full resolution tiles continue to load.
* @property {boolean} [foveatedScreenSpaceError=true] Optimization option. Prioritize loading tiles in the center of the screen by temporarily raising the screen space error for tiles around the edge of the screen. Screen space error returns to normal once all the tiles in the center of the screen as determined by the {@link Cesium3DTileset#foveatedConeSize} are loaded.
@@ -168,7 +168,7 @@ import Cesium3DTilesetSkipTraversal from "./Cesium3DTilesetSkipTraversal.js";
* "http://localhost:8002/tilesets/Seattle/tileset.json", {
* dynamicScreenSpaceError: true,
* dynamicScreenSpaceErrorDensity: 2.0e-4,
- * dynamicScreenSpaceErrorFactor: 4.0,
+ * dynamicScreenSpaceErrorFactor: 24.0,
* dynamicScreenSpaceErrorHeightFalloff: 0.25
* });
* scene.primitives.add(tileset);
@@ -456,11 +456,11 @@ function Cesium3DTileset(options) {
*
*
* @type {number}
- * @default 4.0
+ * @default 24.0
*/
this.dynamicScreenSpaceErrorFactor = defaultValue(
options.dynamicScreenSpaceErrorFactor,
- 4.0
+ 24.0
);
/**
@@ -1990,7 +1990,7 @@ Cesium3DTileset.fromIonAssetId = async function (assetId, options) {
* "http://localhost:8002/tilesets/Seattle/tileset.json", {
* dynamicScreenSpaceError: true,
* dynamicScreenSpaceErrorDensity: 2.0e-4,
- * dynamicScreenSpaceErrorFactor: 4.0,
+ * dynamicScreenSpaceErrorFactor: 24.0,
* dynamicScreenSpaceErrorHeightFalloff: 0.25
* });
* scene.primitives.add(tileset);
diff --git a/packages/widgets/Source/Cesium3DTilesInspector/Cesium3DTilesInspectorViewModel.js b/packages/widgets/Source/Cesium3DTilesInspector/Cesium3DTilesInspectorViewModel.js
index 41208c1b0ea2..093545e1572b 100644
--- a/packages/widgets/Source/Cesium3DTilesInspector/Cesium3DTilesInspectorViewModel.js
+++ b/packages/widgets/Source/Cesium3DTilesInspector/Cesium3DTilesInspectorViewModel.js
@@ -767,9 +767,9 @@ function Cesium3DTilesInspectorViewModel(scene, performanceContainer) {
* Gets or sets the dynamic screen space error factor. This property is observable.
*
* @type {number}
- * @default 4.0
+ * @default 24.0
*/
- this.dynamicScreenSpaceErrorFactor = 4.0;
+ this.dynamicScreenSpaceErrorFactor = 24.0;
const pickTileset = getPickTileset(this);
const pickActive = knockout.observable();
From 71157a0693c188d5340f6da1311ff0788a36635d Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Wed, 3 Jan 2024 11:18:52 -0500
Subject: [PATCH 18/23] Add spec for ensuring the constructor options work
---
.../engine/Specs/Scene/Cesium3DTilesetSpec.js | 37 ++++++++++++++++++-
1 file changed, 35 insertions(+), 2 deletions(-)
diff --git a/packages/engine/Specs/Scene/Cesium3DTilesetSpec.js b/packages/engine/Specs/Scene/Cesium3DTilesetSpec.js
index 2e3381f89d49..b6fc08faa464 100644
--- a/packages/engine/Specs/Scene/Cesium3DTilesetSpec.js
+++ b/packages/engine/Specs/Scene/Cesium3DTilesetSpec.js
@@ -1106,13 +1106,13 @@ describe(
const center = Cartesian3.fromRadians(centerLongitude, centerLatitude);
scene.camera.lookAt(center, new HeadingPitchRange(0.0, 0.0, distance));
- // Set dynamic SSE to false (default)
+ // Turn off dynamic SSE
tileset.dynamicScreenSpaceError = false;
scene.renderForSpecs();
expect(statistics.visited).toEqual(1);
expect(statistics.numberOfCommands).toEqual(1);
- // Set dynamic SSE to true, now the root is not rendered
+ // Turn on dynamic SSE, now the root is not rendered
tileset.dynamicScreenSpaceError = true;
tileset.dynamicScreenSpaceErrorDensity = 1.0;
tileset.dynamicScreenSpaceErrorFactor = 10.0;
@@ -1153,6 +1153,39 @@ describe(
return testDynamicScreenSpaceError(withTransformSphereUrl, 144.0);
});
+ it("dynamic screen space error constructor options work", function () {
+ const options = {
+ dynamicScreenSpaceError: true,
+ dynamicScreenSpaceErrorDensity: 1.0,
+ dynamicScreenSpaceErrorFactor: 10.0,
+ dynamicScreenSpaceErrorHeightFalloff: 0.5,
+ };
+ const distance = 103.0;
+ return Cesium3DTilesTester.loadTileset(
+ scene,
+ withTransformBoxUrl,
+ options
+ ).then(function (tileset) {
+ // Make sure the values match the constructor, not hard-coded defaults
+ // like in https://github.com/CesiumGS/cesium/issues/11677
+ expect(tileset.dynamicScreenSpaceError).toBe(true);
+ expect(tileset.dynamicScreenSpaceErrorDensity).toBe(1.0);
+ expect(tileset.dynamicScreenSpaceErrorFactor).toBe(10.0);
+ expect(tileset.dynamicScreenSpaceErrorHeightFalloff).toBe(0.5);
+
+ const statistics = tileset._statistics;
+
+ // Horizon view, only root is in view, however due to dynamic SSE,
+ // it will not render.
+ const center = Cartesian3.fromRadians(centerLongitude, centerLatitude);
+ scene.camera.lookAt(center, new HeadingPitchRange(0.0, 0.0, distance));
+
+ scene.renderForSpecs();
+ expect(statistics.visited).toEqual(0);
+ expect(statistics.numberOfCommands).toEqual(0);
+ });
+ });
+
it("additive refinement - selects root when sse is met", function () {
viewRootOnly();
return Cesium3DTilesTester.loadTileset(scene, tilesetUrl).then(function (
From 0a1a80daa65941bbae4f13f8b8280c258b26eb58 Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Wed, 3 Jan 2024 16:03:40 -0500
Subject: [PATCH 19/23] Turn off dynamicSSE for debugging test
---
packages/engine/Source/Scene/Cesium3DTile.js | 2 ++
packages/engine/Specs/Scene/PickingSpec.js | 4 ----
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/packages/engine/Source/Scene/Cesium3DTile.js b/packages/engine/Source/Scene/Cesium3DTile.js
index 7edd883817d8..f71c56e978cb 100644
--- a/packages/engine/Source/Scene/Cesium3DTile.js
+++ b/packages/engine/Source/Scene/Cesium3DTile.js
@@ -943,6 +943,8 @@ Cesium3DTile.prototype.getScreenSpaceError = function (
const factor = tileset.dynamicScreenSpaceErrorFactor;
const dynamicError = CesiumMath.fog(distance, density) * factor;
error -= dynamicError;
+
+ error = Math.max(error, 0);
}
}
diff --git a/packages/engine/Specs/Scene/PickingSpec.js b/packages/engine/Specs/Scene/PickingSpec.js
index af868c13044f..4474051a0adc 100644
--- a/packages/engine/Specs/Scene/PickingSpec.js
+++ b/packages/engine/Specs/Scene/PickingSpec.js
@@ -134,10 +134,6 @@ describe(
function createTileset(url) {
const options = {
maximumScreenSpaceError: 0,
- // The camera is zoomed pretty far out for these tests, so
- // turn off dynamicScreenSpaceError so tiles don't get culled
- // unintentionally.
- dynamicScreenSpaceError: false,
};
return Cesium3DTilesTester.loadTileset(scene, url, options).then(
function (tileset) {
From d85bcafd84d4c57c6aea7a37227cd1193fe33b7b Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Wed, 3 Jan 2024 16:44:21 -0500
Subject: [PATCH 20/23] Disable dynamicSSE for picking tests, mention issue
---
packages/engine/Specs/Scene/PickingSpec.js | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/packages/engine/Specs/Scene/PickingSpec.js b/packages/engine/Specs/Scene/PickingSpec.js
index 4474051a0adc..19cb2c659667 100644
--- a/packages/engine/Specs/Scene/PickingSpec.js
+++ b/packages/engine/Specs/Scene/PickingSpec.js
@@ -134,9 +134,16 @@ describe(
function createTileset(url) {
const options = {
maximumScreenSpaceError: 0,
+ // Dynamic screen space error seems to cause a race condition in
+ // waitForTilesLoaded.
+ // See https://github.com/CesiumGS/cesium/issues/11732
+ dynamicScreenSpaceError: false,
};
return Cesium3DTilesTester.loadTileset(scene, url, options).then(
function (tileset) {
+ // The tilesets used in these tests have transforms that are not
+ // what we want for our camera setup. Re-position the tileset
+ // in view of the camera
const cartographic = Rectangle.center(largeRectangle);
const cartesian = Cartographic.toCartesian(cartographic);
tileset.root.transform = Matrix4.IDENTITY;
From dcc5a61f6b4590927ccfcda7840575a00aefb2b6 Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Wed, 3 Jan 2024 16:46:22 -0500
Subject: [PATCH 21/23] Negative SSE wasn't the issue
---
packages/engine/Source/Scene/Cesium3DTile.js | 2 --
1 file changed, 2 deletions(-)
diff --git a/packages/engine/Source/Scene/Cesium3DTile.js b/packages/engine/Source/Scene/Cesium3DTile.js
index f71c56e978cb..7edd883817d8 100644
--- a/packages/engine/Source/Scene/Cesium3DTile.js
+++ b/packages/engine/Source/Scene/Cesium3DTile.js
@@ -943,8 +943,6 @@ Cesium3DTile.prototype.getScreenSpaceError = function (
const factor = tileset.dynamicScreenSpaceErrorFactor;
const dynamicError = CesiumMath.fog(distance, density) * factor;
error -= dynamicError;
-
- error = Math.max(error, 0);
}
}
From e4dc64673b0c80d9104697783e1e321c2ff959ea Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Thu, 4 Jan 2024 10:29:12 -0500
Subject: [PATCH 22/23] Use async function for new tests
---
.../engine/Specs/Scene/Cesium3DTilesetSpec.js | 75 +++++++++----------
1 file changed, 36 insertions(+), 39 deletions(-)
diff --git a/packages/engine/Specs/Scene/Cesium3DTilesetSpec.js b/packages/engine/Specs/Scene/Cesium3DTilesetSpec.js
index b6fc08faa464..d0ba216f7cfd 100644
--- a/packages/engine/Specs/Scene/Cesium3DTilesetSpec.js
+++ b/packages/engine/Specs/Scene/Cesium3DTilesetSpec.js
@@ -1096,30 +1096,27 @@ describe(
});
});
- function testDynamicScreenSpaceError(url, distance) {
- return Cesium3DTilesTester.loadTileset(scene, url).then(function (
- tileset
- ) {
- const statistics = tileset._statistics;
+ async function testDynamicScreenSpaceError(url, distance) {
+ const tileset = await Cesium3DTilesTester.loadTileset(scene, url);
+ const statistics = tileset._statistics;
- // Horizon view, only root is visible
- const center = Cartesian3.fromRadians(centerLongitude, centerLatitude);
- scene.camera.lookAt(center, new HeadingPitchRange(0.0, 0.0, distance));
+ // Horizon view, only root is visible
+ const center = Cartesian3.fromRadians(centerLongitude, centerLatitude);
+ scene.camera.lookAt(center, new HeadingPitchRange(0.0, 0.0, distance));
- // Turn off dynamic SSE
- tileset.dynamicScreenSpaceError = false;
- scene.renderForSpecs();
- expect(statistics.visited).toEqual(1);
- expect(statistics.numberOfCommands).toEqual(1);
+ // Turn off dynamic SSE
+ tileset.dynamicScreenSpaceError = false;
+ scene.renderForSpecs();
+ expect(statistics.visited).toEqual(1);
+ expect(statistics.numberOfCommands).toEqual(1);
- // Turn on dynamic SSE, now the root is not rendered
- tileset.dynamicScreenSpaceError = true;
- tileset.dynamicScreenSpaceErrorDensity = 1.0;
- tileset.dynamicScreenSpaceErrorFactor = 10.0;
- scene.renderForSpecs();
- expect(statistics.visited).toEqual(0);
- expect(statistics.numberOfCommands).toEqual(0);
- });
+ // Turn on dynamic SSE, now the root is not rendered
+ tileset.dynamicScreenSpaceError = true;
+ tileset.dynamicScreenSpaceErrorDensity = 1.0;
+ tileset.dynamicScreenSpaceErrorFactor = 10.0;
+ scene.renderForSpecs();
+ expect(statistics.visited).toEqual(0);
+ expect(statistics.numberOfCommands).toEqual(0);
}
function numberOfChildrenWithoutContent(tile) {
@@ -1153,7 +1150,7 @@ describe(
return testDynamicScreenSpaceError(withTransformSphereUrl, 144.0);
});
- it("dynamic screen space error constructor options work", function () {
+ it("dynamic screen space error constructor options work", async function () {
const options = {
dynamicScreenSpaceError: true,
dynamicScreenSpaceErrorDensity: 1.0,
@@ -1161,29 +1158,29 @@ describe(
dynamicScreenSpaceErrorHeightFalloff: 0.5,
};
const distance = 103.0;
- return Cesium3DTilesTester.loadTileset(
+ const tileset = await Cesium3DTilesTester.loadTileset(
scene,
withTransformBoxUrl,
options
- ).then(function (tileset) {
- // Make sure the values match the constructor, not hard-coded defaults
- // like in https://github.com/CesiumGS/cesium/issues/11677
- expect(tileset.dynamicScreenSpaceError).toBe(true);
- expect(tileset.dynamicScreenSpaceErrorDensity).toBe(1.0);
- expect(tileset.dynamicScreenSpaceErrorFactor).toBe(10.0);
- expect(tileset.dynamicScreenSpaceErrorHeightFalloff).toBe(0.5);
+ );
- const statistics = tileset._statistics;
+ // Make sure the values match the constructor, not hard-coded defaults
+ // like in https://github.com/CesiumGS/cesium/issues/11677
+ expect(tileset.dynamicScreenSpaceError).toBe(true);
+ expect(tileset.dynamicScreenSpaceErrorDensity).toBe(1.0);
+ expect(tileset.dynamicScreenSpaceErrorFactor).toBe(10.0);
+ expect(tileset.dynamicScreenSpaceErrorHeightFalloff).toBe(0.5);
- // Horizon view, only root is in view, however due to dynamic SSE,
- // it will not render.
- const center = Cartesian3.fromRadians(centerLongitude, centerLatitude);
- scene.camera.lookAt(center, new HeadingPitchRange(0.0, 0.0, distance));
+ const statistics = tileset._statistics;
- scene.renderForSpecs();
- expect(statistics.visited).toEqual(0);
- expect(statistics.numberOfCommands).toEqual(0);
- });
+ // Horizon view, only root is in view, however due to dynamic SSE,
+ // it will not render.
+ const center = Cartesian3.fromRadians(centerLongitude, centerLatitude);
+ scene.camera.lookAt(center, new HeadingPitchRange(0.0, 0.0, distance));
+
+ scene.renderForSpecs();
+ expect(statistics.visited).toEqual(0);
+ expect(statistics.numberOfCommands).toEqual(0);
});
it("additive refinement - selects root when sse is met", function () {
From a28e7010ad9e4c5cd40c9d94da5ce513d3dba387 Mon Sep 17 00:00:00 2001
From: Peter Gagliardi
Date: Thu, 4 Jan 2024 10:40:42 -0500
Subject: [PATCH 23/23] Add spec for density slider
---
.../Cesium3DTilesInspectorViewModelSpec.js | 24 ++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/packages/widgets/Specs/Cesium3DTilesInspector/Cesium3DTilesInspectorViewModelSpec.js b/packages/widgets/Specs/Cesium3DTilesInspector/Cesium3DTilesInspectorViewModelSpec.js
index d681f7cba70a..51267ff50f61 100644
--- a/packages/widgets/Specs/Cesium3DTilesInspector/Cesium3DTilesInspectorViewModelSpec.js
+++ b/packages/widgets/Specs/Cesium3DTilesInspector/Cesium3DTilesInspectorViewModelSpec.js
@@ -1,4 +1,9 @@
-import { Cesium3DTileset, Cesium3DTileStyle, Globe } from "@cesium/engine";
+import {
+ Cesium3DTileset,
+ Cesium3DTileStyle,
+ Globe,
+ Math as CesiumMath,
+} from "@cesium/engine";
import { Cesium3DTilesInspectorViewModel } from "../../index.js";
import createScene from "../../../../Specs/createScene.js";
@@ -255,6 +260,23 @@ describe(
expect(viewModel.tileset.dynamicScreenSpaceErrorFactor).toBe(2);
expect(viewModel.tileset.dynamicScreenSpaceErrorDensity).toBe(0.1);
});
+
+ it("dynamicScreenSpaceErrorDensity slider uses an exponential scale", function () {
+ // The HTML slider produces a linear range, but the actual density value
+ // varies exponentially.
+ const rawSliderValue = 0.2;
+ const scaledValue = Math.pow(rawSliderValue, 6);
+
+ viewModel.dynamicScreenSpaceErrorDensitySliderValue = rawSliderValue;
+ expect(
+ viewModel.dynamicScreenSpaceErrorDensitySliderValue
+ ).toEqualEpsilon(rawSliderValue, CesiumMath.EPSILON8);
+
+ expect(viewModel.tileset.dynamicScreenSpaceErrorDensity).toEqualEpsilon(
+ scaledValue,
+ CesiumMath.EPSILON8
+ );
+ });
});
describe("style options", function () {