What unit is "amount" ??

I am trying to find an easy way of setting the initial scene zoom.
The default one is out of the bounds i need, and since there is no such field in Viewer constructor, i am trying to zoom into my desired altitude with Camera.zoomIn() after cesium init, but it only takes “amount” as parameter.

I tried and tried to somehow define by experimenting how does that “amount” relate to the minimum or maximumZoomDistance i am setting on ScreenSpaceCameraController but failed to find the connection.

All after all, this is what is happening:

  • new Cesium.Viewer

  • screenSpaceCameraController.maximumZoomDistance = 15000000

  • screenSpaceCameraController.minimumZoomDistance = 1500000

  • Pages load, and the globe is further than maximZoomDistance.

  • Mousewheel zoomOut, and the globe zoomsIn, it jumps into the proper maximumZoomDistance now

  • From now on zoom with wheel seems to be working correctly, but

  • doing camera.zoomOut() and camera.zoomIn() (like on plus button click) ignores maximum and minimumZoomDistance, and can zoom out of those bounds.

What do?

Why do the zoomIn and zoomOut don’t care abot that m…ZoomDistance, how do i set the initial altitude level, and what is “amount”? Is it messured in meters? Is it mesured in liters? Is it a type-o and should spell “almond”?

A delicious, moist cake for any helpful post.

Cheers.

zoomIn

ScreenSpaceCameraController

Cesium normally uses SI units, so amount would be in meters.
I can only assume that the min/max settings apply to zoom actions by the user (e.g. scroll or touch), and that they do not apply to zooming thru the API. Your would then need to apply the min/max thresholds to the code you write.

Willem

Camera.viewRectangle is probably the API you want to use for controlling the area that is in view.

Well it’s not in meters. Or it’s in different meters than camera.positon and screenSpaceCameraController.minmaxZoomDistance.

I do not want a viewRectangle api. What i need is a method of setting minimum, maximum and initial zoom.

Like minimum - camera 5 meters from the surface of the earth, maximum - 1000 meters, and initial 50 meters.

That doesn’t seem like a wierd functionality to expect, or one that woulnd’t be assumed useful.

I don’t need to set a bbox, constrain the area in view or tie a camera to a magic stick. One parameter to limit.

If i have found any methods of doing that they are either not working (minmax not working for zoomIn), or not homonogeus (if i set initial camera.position.z as maximumZoomDistance i can still scrollZoom a little further).

I am missing something really obvious here, or id there really no unified way of restricting zoom ?

Looking at the code, there is currently no unified way to restrict zoom. The parameters in ScreenSpaceCameraController only affect changes to the camera which are triggered by mouse/touch input.

The camera.zoom methods do not interact with the ScreenSpaceCameraController which is why you use them they do not respect the settings of that controller.

You could intercept the movement event(s) and evaluate the height from the camera’s position (Cartesian3) then determine if it’s within the min/max. If so you let the event proceed, otherwise you just do nothing.

The camera tutorial shows how to capture the input events and act upon them.