How to only rotate the globe?

1,255 views
Skip to first unread message

sabm...@gmail.com

unread,
Dec 27, 2015, 9:31:36 PM12/27/15
to cesium-dev
Hi all,

Is there a way for me to auto-rotate the globe?
Previously, I found this few lines of codes in this thread, I think, and tested it out:

var lastNow = Date.now();
viewer.clock.onTick.addEventListener(function(clock) {
var now = Date.now();
var spinRate = 0.08;
var delta = (now - lastNow) / 1000;
lastNow = now;
viewer.scene.camera.rotate(Cesium.Cartesian3.UNIT_Z, -spinRate * delta);
});

So with these lines of codes, the globe/camera (i'm not sure which) was able to rotate on its own. However as I changed the view to either 2D Map or 2.5D Columbus View, they will rotate as well.

Therefore my question is, how do I only make the 3D globe rotate?

Appreciate any help!

Thanks.

Alan

Willem van der Gugten

unread,
Dec 28, 2015, 6:54:39 AM12/28/15
to cesium-dev, sabm...@gmail.com
You could check the scene.mode (http://cesiumjs.org/Cesium/Build/Documentation/Scene.html#mode) in your event handler and only rotate when the mode is 3D.
You probably also need to reset e.g. lastNow to avoid sudden jumps when going back to 3D.
I did not see an event for a scene.mode change.

Willem

Hannah Pinkos

unread,
Dec 28, 2015, 7:33:15 PM12/28/15
to cesium-dev, sabm...@gmail.com
Hello Alan,

Take a look at the 'View in ICRF' example in this demo: http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Camera.html&label=Showcases
Is that what you're looking for?

Best,

Hannah
Reply all
Reply to author
Forward
0 new messages