From a85017e38dd5497e0eb02265f5a94cb1b1583164 Mon Sep 17 00:00:00 2001 From: Ian Lilley <ianlilleyt@gmail.com> Date: Wed, 13 May 2020 14:22:04 -0400 Subject: [PATCH 1/2] Added frustumSplits option to DebugCameraPrimitive --- CHANGES.md | 3 ++- Source/Scene/DebugCameraPrimitive.js | 13 +++++++++---- Source/Scene/Scene.js | 1 + Specs/Scene/DebugCameraPrimitiveSpec.js | 1 + 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index fe3a917080f3..f1687a4be70c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,7 +8,8 @@ ##### Fixes :wrench: -- This fixes a bug where a removed billboard can prevent changing of the terrainProvider [#8766](https://github.com/CesiumGS/cesium/pull/8766) +- This fixes a bug where a removed billboard can prevent changing of the terrainProvider. [#8766](https://github.com/CesiumGS/cesium/pull/8766) +- Fixed a bug where `DebugCameraPrimitive` was ignoring the near and far planes of the `Camera`. [#8848](https://github.com/CesiumGS/cesium/issues/8848) ### 1.69.0 - 2020-05-01 diff --git a/Source/Scene/DebugCameraPrimitive.js b/Source/Scene/DebugCameraPrimitive.js index fef7764854f3..e7c76410acba 100644 --- a/Source/Scene/DebugCameraPrimitive.js +++ b/Source/Scene/DebugCameraPrimitive.js @@ -25,6 +25,7 @@ import Primitive from "./Primitive.js"; * * @param {Object} options Object with the following properties: * @param {Camera} options.camera The camera. + * @param {Number[]} [options.frustumSplits] Distances to the near and far planes of the camera frustums. This overrides the camera's frustum near and far values. * @param {Color} [options.color=Color.CYAN] The color of the debug outline. * @param {Boolean} [options.updateOnChange=true] Whether the primitive updates when the underlying camera changes. * @param {Boolean} [options.show=true] Determines if this primitive will be shown. @@ -46,6 +47,7 @@ function DebugCameraPrimitive(options) { //>>includeEnd('debug'); this._camera = options.camera; + this._frustumSplits = options.frustumSplits; this._color = defaultValue(options.color, Color.CYAN); this._updateOnChange = defaultValue(options.updateOnChange, true); @@ -124,13 +126,16 @@ DebugCameraPrimitive.prototype.update = function (frameState) { } frustum = cameraFrustum.clone(frustum); - var frustumSplits = frameState.frustumSplits; - var numFrustums = frustumSplits.length - 1; - if (numFrustums <= 0) { - frustumSplits = scratchSplits; // Use near and far planes if no splits created + var numFrustums; + var frustumSplits = this._frustumSplits; + if (!defined(frustumSplits) || frustumSplits.length <= 1) { + // Use near and far planes if no splits created + frustumSplits = scratchSplits; frustumSplits[0] = this._camera.frustum.near; frustumSplits[1] = this._camera.frustum.far; numFrustums = 1; + } else { + numFrustums = frustumSplits.length - 1; } var position = camera.positionWC; diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index 3370802a3700..5edaa100087d 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -3351,6 +3351,7 @@ function updateDebugFrustumPlanes(scene) { scene._debugFrustumPlanes = new DebugCameraPrimitive({ camera: scene.camera, updateOnChange: false, + frustumSplits: frameState.frustumSplits, }); } else { scene._debugFrustumPlanes = diff --git a/Specs/Scene/DebugCameraPrimitiveSpec.js b/Specs/Scene/DebugCameraPrimitiveSpec.js index 661473f20d0c..8c81ed2707bc 100644 --- a/Specs/Scene/DebugCameraPrimitiveSpec.js +++ b/Specs/Scene/DebugCameraPrimitiveSpec.js @@ -55,6 +55,7 @@ describe( it("constructs with options", function () { var p = new DebugCameraPrimitive({ camera: camera, + frustumSplits: [0.1, 1000.0], color: Color.YELLOW, updateOnChange: false, show: false, From da4779cdbc38a3cf4df50701feb34c28c0d71ad7 Mon Sep 17 00:00:00 2001 From: Ian Lilley <ianlilleyt@gmail.com> Date: Wed, 13 May 2020 14:38:21 -0400 Subject: [PATCH 2/2] updated CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index f1687a4be70c..84c3a6a379e8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ ##### Additions :tada: - Added `Cesium3DTileset.extensions` to get the extensions property from the tileset JSON. [#8829](https://github.com/CesiumGS/cesium/pull/8829) +- Added `frustumSplits` option to `DebugCameraPrimitive`. [8849](https://github.com/CesiumGS/cesium/pull/8849) ##### Fixes :wrench: