How to only rotate the globe?

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

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

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