How to keep click and drag to move camera behavior after a call to Camera#lookAt ?

24 views
Skip to first unread message

brend...@gmail.com

unread,
Mar 21, 2018, 3:59:37 AM3/21/18
to cesium-dev
1. A concise explanation of the problem you're experiencing.

I would like to enable the ability to click and drag to move the camera while maintaining a constant height above the ellipsoid as in the demo on the Cesium homepage. I would also like to initialize the camera to be looking at a particular point from a particular distance away with a particular orientation.

If I do not make a call to camera#lookAt this click and drag to move the camera behavior works as I would like it to. After I make a call to camera#lookAt, the click and drag behavior is to pivot around the target specified.

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.

const cartoTarget = Cesium.Cartographic.fromDegrees({{location.latLng.longitude}}, {{location.latLng.latitude}}, heightAboveEllipsoidM);
const target = Cesium.Cartographic.toCartesian(cartoTarget);
viewer.camera.lookAt(target, new Cesium.HeadingPitchRange(heading, pitch, range));

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

Just seeking the desired behavior. Open to suggestions.

4. The Cesium version you're using, your operating system and browser.

I am using Cesium 1.43, macOS 10.13.3, Chrome 65.0.3325.162

Gabby Getz

unread,
Mar 23, 2018, 3:03:39 PM3/23/18
to cesium-dev
After you call lookAt, add this line:

viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);

To reset the camera controls to what you are looking for.

Thanks,
Gabby
Reply all
Reply to author
Forward
0 new messages