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

Avoid parameter reassignment in Camera.flyToBoundingSphere and Camera.viewBoundingSphere #8438

Merged
merged 3 commits into from
Jan 29, 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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Change Log
* Fixed a bug where rapidly updating a `PolylineCollection` could result in an instanceIndex is out of range error. [#8546](https://github.com/AnalyticalGraphicsInc/cesium/pull/8546)
* Fixed a crash that could occur when an entity was deleted while the corresponding `Primitive` was being created asynchronously. [#8569](https://github.com/AnalyticalGraphicsInc/cesium/pull/8569)
* Fixed a crash when calling `camera.lookAt` with the origin as the target. This could happen when looking at a tileset with the origin as its center. [#8571](https://github.com/AnalyticalGraphicsInc/cesium/pull/8571)
* Fixed a bug where `camera.viewBoundingSphere` was modifying the `offset` parameter [#8438](https://github.com/AnalyticalGraphicsInc/cesium/pull/8438)

### 1.65.0 - 2020-01-06

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
* [Tinco Andringa](https://github.com/tinco)
* [André Borud](https://github.com/andreborud)
* [Nathan Schulte](https://github.com/nmschulte)
* [Jan Wąsak](https://github.com/jhnwsk)
4 changes: 1 addition & 3 deletions Source/Scene/Camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -2868,9 +2868,7 @@ import SceneMode from './SceneMode.js';
var MINIMUM_ZOOM = 100.0;

function adjustBoundingSphereOffset(camera, boundingSphere, offset) {
if (!defined(offset)) {
offset = HeadingPitchRange.clone(Camera.DEFAULT_OFFSET);
}
offset = HeadingPitchRange.clone(defined(offset) ? offset : Camera.DEFAULT_OFFSET);

var minimumZoom = camera._scene.screenSpaceCameraController.minimumZoomDistance;
var maximumZoom = camera._scene.screenSpaceCameraController.maximumZoomDistance;
Expand Down
31 changes: 31 additions & 0 deletions Specs/Scene/CameraSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2660,6 +2660,23 @@ describe('Scene/Camera', function() {
expect(camera.pitch).toEqualEpsilon(pitch, CesiumMath.EPSILON5);
});

it('viewBoundingSphere does not modify offset.range when it is zero', function() {
scene.mode = SceneMode.SCENE3D;

var heading = CesiumMath.toRadians(45.0);
var pitch = CesiumMath.toRadians(-45.0);
var range = 0.0;
var offset = new HeadingPitchRange(heading, pitch, range);

var sphere = new BoundingSphere(Cartesian3.fromDegrees(-117.16, 32.71, 0.0), 10.0);
camera.viewBoundingSphere(sphere, offset);
camera._setTransform(Matrix4.IDENTITY);

expect(offset.heading).toEqual(CesiumMath.toRadians(45.0));
expect(offset.pitch).toEqual(CesiumMath.toRadians(-45.0));
expect(offset.range).toEqual(0.0);
});

it('viewBoundingSphere in 2D', function() {
var frustum = new OrthographicOffCenterFrustum();
frustum.left = -10.0;
Expand Down Expand Up @@ -2775,6 +2792,20 @@ describe('Scene/Camera', function() {
expect(CesiumMath.equalsEpsilon(distance, maxValue, 0.1)).toBe(true);
});

it('flyToBoundingSphere does not modify options.offset range if it is zero ', function() {
scene.mode = SceneMode.SCENE3D;
var options = {
offset: new HeadingPitchRange(0.0, -1.5, 0.0)
};

var sphere = new BoundingSphere(Cartesian3.fromDegrees(-117.16, 32.71, 0.0), 100000.0);
camera.flyToBoundingSphere(sphere, options);

expect(options.offset.heading).toEqual(0.0);
expect(options.offset.pitch).toEqual(-1.5);
expect(options.offset.range).toEqual(0.0);
});

it('distanceToBoundingSphere', function() {
scene.mode = SceneMode.SCENE3D;

Expand Down