diff --git a/CHANGES.md b/CHANGES.md index f010a9375087..5e7b0392c1d3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,12 +5,14 @@ ##### 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: - Fixed a bug that could cause rendering of a glTF model to become corrupt when switching from a Uint16 to a Uint32 index buffer to accomodate new vertices added for edge outlining. [#8820](https://github.com/CesiumGS/cesium/pull/8820) -- 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 a removed billboard could prevent changing of the `TerrainProvider`. [#8766](https://github.com/CesiumGS/cesium/pull/8766) - Fixed an issue with 3D Tiles point cloud styling where `${feature.propertyName}` and `${feature["propertyName"]}` syntax would cause a crash. Also fixed an issue where property names with non-alphanumeric characters would crash. [#8785](https://github.com/CesiumGS/cesium/pull/8785) +- 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,