Change the scene mode in Cesium gradually in every Interval

309 views
Skip to first unread message

Abdullah....@ingrammicro.com

unread,
Nov 16, 2017, 3:22:37 AM11/16/17
to cesium-dev
I have a task which I want to change the scene mode in Cesium in every interval.
I managed to change the scene mode in every Interval using refresh feature. However, the output is not so nice as it changes quickly. So is it possible to change the scene mode gradually I mean slowly? My code is found below.
    
    <!DOCTYPE html>
        <html lang="en">
        <head>
          <!-- Use correct character set. -->
          <meta charset="utf-8">
          <!-- Tell IE to use the latest, best version. -->
          <meta http-equiv="X-UA-Compatible" content="IE=edge">
          <!-- Make the application on mobile take up the full browser screen and disable user scaling. -->
          <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
          <title>Hello World!</title>
          <script src="../Build/Cesium/Cesium.js"></script>
          <style>
              @import url(../Build/Cesium/Widgets/widgets.css);
              html, body, #cesiumContainer {
                  width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden;
              }
          </style>
        </head>
        <body>
          <div id="cesiumContainer"></div>
          <script type="text/javascript">
                var viewer = new Cesium.Viewer('cesiumContainer');
        var scene = viewer.scene;
        scene.mode= Cesium.SceneMode.SCENE3D;
        var scenename = "3D";
        console.log("Scene Mode 3D");
        
         //updateFromServer();
        var intervalID = window.setInterval(updateFromServer, 6000);
        
        function updateFromServer() {
            if (scenename === "3D")
            {
                scene.mode= Cesium.SceneMode.SCENE2D;
                scenename = "2D";
                console.log("Scene Mode 2D");
            }
            else
            {
                scene.mode= Cesium.SceneMode.SCENE3D;
                scenename = "3D";
                console.log("Scene Mode 3D");
            }
        }
        
          </script>
        </body>
        </html>
My code is that by default the scene mode is  3D. I create a variable which is 3D. When it is 3D, it will change to 2D and vice versa.

Can you help me to change the scene mode gradually.

Gabby Getz

unread,
Nov 20, 2017, 5:13:15 PM11/20/17
to cesium-dev
Instead of setting scene.mode directly, try using the scene.morph functions. They take the duration the the transition as a parameter.

Thanks,
Gabby

--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages