diff --git a/CHANGES.md b/CHANGES.md index aa13b9f20e12..7e5c73cd451f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ Change Log ========== +### 1.38 - 2017-10-02 + +* Zoom about mouse now maintains camera heading, pitch, and roll [#4639](https://github.com/AnalyticalGraphicsInc/cesium/pull/5603) + ### 1.37 - 2017-09-01 * Breaking changes diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 119d7c8ecb62..66b0f0a0c4fa 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -86,6 +86,8 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu * [Jason Crow](https://github.com/jason-crow) * [Flightradar24 AB](https://www.flightradar24.com) * [Aleksei Kalmykov](https://github.com/kalmykov) +* [BIT Systems](http://www.caci.com/bit-systems) + * [William Wall](https://github.com/wallw-bits) * [virtualcitySYSTEMS GmbH](https://www.virtualcitysystems.de) * [Jannes Bolling](https://github.com/jbo023) diff --git a/Source/Scene/ScreenSpaceCameraController.js b/Source/Scene/ScreenSpaceCameraController.js index 59fd6f251463..6a503930d742 100644 --- a/Source/Scene/ScreenSpaceCameraController.js +++ b/Source/Scene/ScreenSpaceCameraController.js @@ -8,6 +8,7 @@ define([ '../Core/destroyObject', '../Core/DeveloperError', '../Core/Ellipsoid', + '../Core/HeadingPitchRoll', '../Core/IntersectionTests', '../Core/isArray', '../Core/KeyboardEventModifier', @@ -35,6 +36,7 @@ define([ destroyObject, DeveloperError, Ellipsoid, + HeadingPitchRoll, IntersectionTests, isArray, KeyboardEventModifier, @@ -446,6 +448,9 @@ define([ var scratchCartesian = new Cartesian3(); var scratchCartesianTwo = new Cartesian3(); var scratchCartesianThree = new Cartesian3(); + var scratchZoomViewOptions = { + orientation: new HeadingPitchRoll() + }; function handleZoom(object, startPosition, movement, zoomFactor, distanceMeasure, unitPositionDotDirection) { var percentage = 1.0; @@ -485,6 +490,11 @@ define([ var camera = scene.camera; var mode = scene.mode; + var orientation = scratchZoomViewOptions.orientation; + orientation.heading = camera.heading; + orientation.pitch = camera.pitch; + orientation.roll = camera.roll; + if (camera.frustum instanceof OrthographicFrustum) { if (Math.abs(distance) > 0.0) { camera.zoomIn(distance); @@ -646,6 +656,7 @@ define([ Cartesian3.cross(camera.direction, camera.up, camera.right); Cartesian3.cross(camera.right, camera.direction, camera.up); + camera.setView(scratchZoomViewOptions); return; } @@ -691,6 +702,8 @@ define([ } else { camera.zoomIn(distance); } + + camera.setView(scratchZoomViewOptions); } var translate2DStart = new Ray(); diff --git a/Specs/Scene/ScreenSpaceCameraControllerSpec.js b/Specs/Scene/ScreenSpaceCameraControllerSpec.js index 088d263eb09b..6b71846515ae 100644 --- a/Specs/Scene/ScreenSpaceCameraControllerSpec.js +++ b/Specs/Scene/ScreenSpaceCameraControllerSpec.js @@ -849,19 +849,31 @@ defineSuite([ it('zoom in 3D with wheel', function() { setUp3D(); var position = Cartesian3.clone(camera.position); + var heading = camera.heading; + var pitch = camera.pitch; + var roll = camera.roll; simulateMouseWheel(120); updateController(); expect(Cartesian3.magnitude(position)).toBeGreaterThan(Cartesian3.magnitude(camera.position)); + expect(camera.heading).toBeCloseTo(heading, 10); + expect(camera.pitch).toBeCloseTo(pitch, 10); + expect(camera.roll).toBeCloseTo(roll, 10); }); it('zoom out in 3D with wheel', function() { setUp3D(); var position = Cartesian3.clone(camera.position); + var heading = camera.heading; + var pitch = camera.pitch; + var roll = camera.roll; simulateMouseWheel(-120); updateController(); expect(Cartesian3.magnitude(position)).toBeLessThan(Cartesian3.magnitude(camera.position)); + expect(camera.heading).toBeCloseTo(heading, 10); + expect(camera.pitch).toBeCloseTo(pitch, 10); + expect(camera.roll).toBeCloseTo(roll, 10); }); it('zoom in 3D with orthographic projection', function() {