Skip to content
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 @@ -9,6 +9,7 @@ Beta Releases
* Breaking changes:
* Renamed `Viewer.automaticallyTrackFirstDataSourceClock` to `Viewer.automaticallyTrackDataSourceClocks`.
* Added new `SelectionIndicator` and `InfoBox` widgets to `Viewer`, activated by `viewerDynamicObjectMixin`.
* Fix developer error when zooming in 2D. If the zoom would create an invalid frustum, nothing is done. [#1432](https://github.com/AnalyticalGraphicsInc/cesium/issues/1432)
* `OpenStreetMapImageryProvider` now supports imagery with a minimum level.
* Improved the quality of imagery near the poles when the imagery source uses a `GeographicTilingScheme`.
* `CesiumTerrainProvider` now supports mesh-based terrain like the tiles created by STK Terrain Server.
Expand Down
5 changes: 5 additions & 0 deletions Source/Scene/CameraController.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,11 @@ define([
newLeft = -maxRight;
}

if (newRight <= newLeft) {
newRight = 1.0;
newLeft = -1.0;
}

var ratio = frustum.top / frustum.right;
frustum.right = newRight;
frustum.left = newLeft;
Expand Down
6 changes: 4 additions & 2 deletions Source/Scene/ScreenSpaceCameraController.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,11 @@ define([
var p1 = Cartesian3.subtract(end, position, scratchTranslateP1);
var direction = Cartesian3.subtract(p0, p1, scratchTranslateP0);
var distance = Cartesian3.magnitude(direction);
Cartesian3.normalize(direction, direction);

cameraController.move(direction, distance);
if (distance > 0.0) {
Cartesian3.normalize(direction, direction);
cameraController.move(direction, distance);
}
}

function zoom2D(controller, movement) {
Expand Down
25 changes: 24 additions & 1 deletion Specs/Scene/CameraControllerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ defineSuite([
expect(camera.frustum.bottom).toEqual(-0.75, CesiumMath.EPSILON10);
});

it('clamps zoom in 2D', function() {
it('clamps zoom out in 2D', function() {
var frustum = new OrthographicFrustum();
frustum.near = 1.0;
frustum.far = 2.0;
Expand All @@ -442,6 +442,29 @@ defineSuite([
expect(frustum.bottom).toEqual(-frustum.top);
});

it('clamps zoom in in 2D', function() {
var frustum = new OrthographicFrustum();
frustum.near = 1.0;
frustum.far = 2.0;
frustum.left = -2.0;
frustum.right = 2.0;
frustum.top = 1.0;
frustum.bottom = -1.0;
camera.frustum = frustum;

var ellipsoid = Ellipsoid.WGS84;
var projection = new GeographicProjection(ellipsoid);
controller.update(SceneMode.SCENE2D, { projection : projection });

var max = projection.project(new Cartographic(Math.PI, CesiumMath.toRadians(85.05112878)));
var factor = 1000.0;
var dx = max.x * factor;

controller.zoomIn(dx * 2.0);
expect(frustum.right).toEqual(1.0);
expect(frustum.left).toEqual(-1.0);
});

it('zooms in 3D', function() {
controller.zoomIn(zoomAmount);
expect(camera.position).toEqualEpsilon(new Cartesian3(0.0, 0.0, 1.0 - zoomAmount), CesiumMath.EPSILON10);
Expand Down