Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added frustumSplits option to DebugCameraPrimitive #8849

Merged
merged 3 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 9 additions & 4 deletions Source/Scene/DebugCameraPrimitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);

Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions Source/Scene/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -3351,6 +3351,7 @@ function updateDebugFrustumPlanes(scene) {
scene._debugFrustumPlanes = new DebugCameraPrimitive({
camera: scene.camera,
updateOnChange: false,
frustumSplits: frameState.frustumSplits,
});
} else {
scene._debugFrustumPlanes =
Expand Down
1 change: 1 addition & 0 deletions Specs/Scene/DebugCameraPrimitiveSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down