programmatically tiltup/tiltdown

77 views
Skip to first unread message

legen...@gmail.com

unread,
Jun 26, 2018, 10:01:55 AM6/26/18
to cesium-dev
I want to do the tiltup / tiltdown operation programmatically by pressing the mouse scroll button. I read it for camera documentation but I could not make any necessary calculations. Could you share sample code?

example :
https://ibb.co/mrLzvT

Gabby Getz

unread,
Jun 27, 2018, 10:18:08 AM6/27/18
to cesium-dev
Hi there,

Set the ScreenSpaceCameraController.tiltEventTypes to the CameraEventType you want, in this case CameraEventType.WHEEL.

Thanks,
Gabby

legen...@gmail.com

unread,
Jun 27, 2018, 11:02:39 AM6/27/18
to cesium-dev
Hi,


Thank you for answer but i don't want to subscribe an event or set up controls. I want to programatically tilt the camera as it is in the example.

Thanks

27 Haziran 2018 Çarşamba 17:18:08 UTC+3 tarihinde Gabby Getz yazdı:

Omar Shehata

unread,
Jun 28, 2018, 1:46:44 PM6/28/18
to cesium-dev
Try using the camera's lookAt function. It lets you specify a point and an orientation/distance. Here's an example of making it tilt. 

var viewer = new Cesium.Viewer('cesiumContainer');
var origin = Cesium.Cartesian3.fromDegrees(100,1);

var sphere = new Cesium.BoundingSphere(origin, 1e2);
viewer.camera.viewBoundingSphere(sphere);

var time = 0;


viewer.scene.postUpdate.addEventListener(function() {
    time += 0.05;

    var angle = (Math.cos(time) + 1) * 0.5 * 25 + 15;
    var heading = Cesium.Math.toRadians(0.0);
    var pitch = Cesium.Math.toRadians(-angle);
    var range = 1e2;
    viewer.camera.lookAt(
        origin, 
        new Cesium.HeadingPitchRange(heading, pitch, range)
    );
});

Does this do what you want?
Message has been deleted

legen...@gmail.com

unread,
Jun 28, 2018, 3:35:44 PM6/28/18
to cesium-dev
Thank you Omar. That's exactly what I want!


28 Haziran 2018 Perşembe 20:46:44 UTC+3 tarihinde Omar Shehata yazdı:
Reply all
Reply to author
Forward
0 new messages