API to Zoom level on TrackedEntity?

387 views
Skip to first unread message

staffan....@gmail.com

unread,
Dec 6, 2017, 5:44:39 AM12/6/17
to cesium-dev
1. A concise explanation of the problem you're experiencing.
(Not a bug, a question on how to access and set zoom level)
When you select a new tracked entity, the viewer is set to a fixed zoom level that it keeps while tracking the moving entity.
Using the scroll wheel on the mouse you can change this zoom level for the current tracking sequence. However if I try to do this by code "viewer.camera.Zoomout(1000);", this zoom-out is quickly replaced with the previous zoom-level on the next frame.

How can I access current zoom level, and how can I adjust zoom level with a similar result as when I scroll the mouse wheel?


2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.
(Not a bug, a question on how to access and set zoom level)


3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

Check this as an example: http://www.paralogg.se/cesium/0F300687F300491
(default Zoom level is too close to start with, and when you have multiple entities and switches entity to follow, the zoom levels gets too close again...)


4. The Cesium version you're using, your operating system and browser.
Current Cesium version, running on Google Cloud (Appengine), and you choose your browser... :)

staffan....@gmail.com

unread,
Oct 2, 2018, 4:16:28 AM10/2/18
to cesium-dev
Replying to my own question, to help others having the same problem:
"viewer.camera.position.clone()" and "viewer.camera.position" did the trick.

By cloning current viewer camera position, it could be applied to the following of another entity. My code below (on toggle of entity to follow):

function toggleFollow(flNumber) {

if (follow==flNumber) {
follow = "0"
savedCamera = viewer.camera.position.clone(); // save camera offset before we unfollow all (else we would loose this)
viewer.trackedEntity = undefined;
//console.log(savedCamera);
showPPCfor('');
} else {
follow = flNumber;
viewer.trackedEntity = wingEntity[flNumber];
// if we unfollowed all, no camera offset is available, so use the saved one
if (Math.abs(viewer.camera.position['x'])+Math.abs(viewer.camera.position['y'])+Math.abs(viewer.camera.position['z']) > 100000) {
wingEntity[flNumber].viewFrom= savedCamera;
} else { // use the latest if available
wingEntity[flNumber].viewFrom= viewer.camera.position;
}

fruit...@outlook.com

unread,
Nov 20, 2018, 10:27:33 PM11/20/18
to cesium-dev
If I used viewForm, It is invalid when I modify again

Omar Shehata

unread,
Nov 21, 2018, 7:45:42 AM11/21/18
to cesium-dev
I'm not sure what you mean. Can you post your code or ideally a Sandcastle example so I can try it out?

You might also try some of these suggestions in this thread:


If you find something that works please do post what it was here.
Reply all
Reply to author
Forward
0 new messages