diff --git a/Source/Scene/CameraFlightPath.js b/Source/Scene/CameraFlightPath.js index 25e35ed79972..4b7b28df3e94 100644 --- a/Source/Scene/CameraFlightPath.js +++ b/Source/Scene/CameraFlightPath.js @@ -62,7 +62,7 @@ define([ var altitude = optionAltitude; var maxHeight = Math.max(startHeight, endHeight); - if (!defined(optionAltitude)) { + if (!defined(altitude)) { var start = camera.position; var end = destination; var up = camera.up; @@ -76,7 +76,7 @@ define([ altitude = Math.min(getAltitude(frustum, verticalDistance, horizontalDistance) * 0.20, 1000000000.0); } - if ((defined(optionAltitude) && optionAltitude < altitude) || maxHeight < altitude) { + if (maxHeight < altitude) { var power = 8.0; var factor = 1000000.0; diff --git a/Specs/Scene/CameraFlightPathSpec.js b/Specs/Scene/CameraFlightPathSpec.js index af51313beb65..38bf6a6f2dbb 100644 --- a/Specs/Scene/CameraFlightPathSpec.js +++ b/Specs/Scene/CameraFlightPathSpec.js @@ -382,4 +382,45 @@ defineSuite([ flight.complete(); expect(camera.position).toEqualEpsilon(endPosition, CesiumMath.EPSILON12); }); + + it('does not go above the maximum height', function() { + var camera = scene.camera; + + var startPosition = Cartesian3.fromDegrees(0.0, 0.0, 1000.0); + var endPosition = Cartesian3.fromDegrees(10.0, 0.0, 1000.0); + var duration = 5.0; + + camera.setView({ + destination : startPosition + }); + + var flight = CameraFlightPath.createTween(scene, { + destination : endPosition, + duration : duration + }); + + var maximumHeight = Number.NEGATIVE_INFINITY; + var i; + for (i = 0; i <= duration; ++i) { + flight.update({ time : i }); + maximumHeight = Math.max(maximumHeight, camera.positionCartographic.height); + } + + maximumHeight *= 0.5; + + camera.setView({ + destination : startPosition + }); + + flight = CameraFlightPath.createTween(scene, { + destination : endPosition, + duration : duration, + maximumHeight : maximumHeight + }); + + for (i = 0; i <= duration; ++i) { + flight.update({ time : i }); + expect(camera.positionCartographic.height).toBeLessThan(maximumHeight); + } + }); }, 'WebGL');