Search code examples
3d2dcesiumjs

How do I send camera to default cesium


When I play around with the camera, I have a button that when it's clicked I want it to return the camera as it was the first it got loaded. I'm using Cartesian3. I have it hardcoded but i don't want to do that. It doesn't seem like a good solution. Any Ideas?

    const cartesian = {
        heading: 6.283185299720323,
        pitch: -1.5707963267948966,
        roll: 0,
        x: 7868870.957809198,
        y: -59770008.94028264,
        z: 42461843.97941323
    }
    this.globeDispatcher.setCesiumCameraState(cartesian);

Solution

  • There's a flyHome function on the Cesium camera.

    viewer.scene.camera.flyHome(duration);
    

    The optional parameter duration can be zero for an immediate jump home, or can be a number of seconds to travel.