-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Fix viewer.flyTo ignoring and resetting minimumZoomDistance #5668
Changes from 5 commits
04e31a8
d1c876a
2676a5e
bcb14c7
e04bf0f
875b4c8
4ba2964
9d00cbd
0ccf646
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -317,9 +317,6 @@ define([ | |
var hasViewFrom = defined(viewFromProperty); | ||
|
||
if (!hasViewFrom && defined(boundingSphere)) { | ||
var controller = scene.screenSpaceCameraController; | ||
controller.minimumZoomDistance = Math.min(controller.minimumZoomDistance, boundingSphere.radius * 0.5); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mramato do you remember why this was added? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because our default minimumZoomDistance (at least at the time) was fairly large, so it was impossible to zoom to a model because you would end up 50 meters away. What is the current default minimumZoomDistance? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mramato If no minimumZoom is specified, it goes to 1, and the flyTo will go to about 100 units away if the bounding sphere for that model has a radius of 0. But this problem is fixed by the clamping of the zoom to the |
||
|
||
//The default HPR is not ideal for high altitude objects so | ||
//we scale the pitch as we get further from the earth for a more | ||
//downward view. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2853,18 +2853,24 @@ define([ | |
return Math.max(right, top) * 1.50; | ||
} | ||
|
||
var MINIMUM_ZOOM = 100.0; | ||
|
||
function adjustBoundingSphereOffset(camera, boundingSphere, offset) { | ||
if (!defined(offset)) { | ||
offset = HeadingPitchRange.clone(Camera.DEFAULT_OFFSET); | ||
} | ||
|
||
var DEFAULT_ZOOM = 100.0; | ||
var MINIMUM_ZOOM = camera._scene.screenSpaceCameraController.minimumZoomDistance; | ||
var MAXIMUM_ZOOM = camera._scene.screenSpaceCameraController.maximumZoomDistance; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As per our Coding Guide, these should be camel case, see https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Documentation/Contributors/CodingGuide/README.md#naming |
||
var range = offset.range; | ||
if (!defined(range) || range === 0.0) { | ||
var radius = boundingSphere.radius; | ||
if (radius === 0.0) { | ||
// If the minimumZoomDistance hasn't been set yet, it is equal to 1, | ||
if (radius < MINIMUM_ZOOM && MINIMUM_ZOOM > 1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little confused why we can't default to the minimum zoom always. Also see There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was taking the approach that if the radius is 0, it would go to the default zoom unless the minimum zoom had been set already. If you zoom all the way to 1, it doesn't look very good, just a bunch of grey, because it is too close to the surface. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok I see. However checking if it's < 1 doesn't guarantee the minimumZoom hasn't been set. Would it make sense to set minimumZoom to default to a higher value? @hpinkos |
||
offset.range = MINIMUM_ZOOM; | ||
} else if(radius > MAXIMUM_ZOOM) { | ||
offset.range = MAXIMUM_ZOOM; | ||
} else if(radius === 0) { | ||
offset.range = DEFAULT_ZOOM; | ||
} else if (camera.frustum instanceof OrthographicFrustum || camera._mode === SceneMode.SCENE2D) { | ||
offset.range = distanceToBoundingSphere2D(camera, radius); | ||
} else { | ||
|
@@ -2950,7 +2956,6 @@ define([ | |
//>>includeEnd('debug'); | ||
|
||
options = defaultValue(options, defaultValue.EMPTY_OBJECT); | ||
|
||
var scene2D = this._mode === SceneMode.SCENE2D || this._mode === SceneMode.COLUMBUS_VIEW; | ||
this._setTransform(Matrix4.IDENTITY); | ||
var offset = adjustBoundingSphereOffset(this, boundingSphere, options.offset); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2605,6 +2605,36 @@ defineSuite([ | |
expect(distance).toBeLessThan(sphere.radius * 3.0); | ||
}); | ||
|
||
it('flyToBoundingSphere does not zoom closer than minimumZoomDistance', function() { | ||
scene.mode = SceneMode.SCENE3D; | ||
var MIN_VALUE = 1000; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, use camel case |
||
scene.screenSpaceCameraController.minimumZoomDistance = MIN_VALUE; | ||
|
||
var sphere = new BoundingSphere(Cartesian3.fromDegrees(-117.16, 32.71, 0.0), 10.0); | ||
|
||
camera.flyToBoundingSphere(sphere, { | ||
duration : 0.0 | ||
}); | ||
|
||
var distance = Cartesian3.distance(camera.position, sphere.center); | ||
expect(CesiumMath.equalsEpsilon(distance, MIN_VALUE, 0.1)).toBe(true); | ||
}); | ||
|
||
it('flyToBoundingSphere does not zoom further than maximumZoomDistance', function() { | ||
scene.mode = SceneMode.SCENE3D; | ||
var MAX_VALUE = 10000; | ||
scene.screenSpaceCameraController.maximumZoomDistance = MAX_VALUE; | ||
|
||
var sphere = new BoundingSphere(Cartesian3.fromDegrees(-117.16, 32.71, 0.0), 100000); | ||
|
||
camera.flyToBoundingSphere(sphere, { | ||
duration : 0.0 | ||
}); | ||
|
||
var distance = Cartesian3.distance(camera.position, sphere.center); | ||
expect(CesiumMath.equalsEpsilon(distance, MAX_VALUE, 0.1)).toBe(true); | ||
}); | ||
|
||
it('distanceToBoundingSphere', function() { | ||
scene.mode = SceneMode.SCENE3D; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
viewer
->Viewer