1. A concise explanation of the problem you’re experiencing.
Hello, I’m new to Cesium and I’m trying ro “simply” rotate the camera around the center of the window with buttons (what you can do with CTRL+mouse click, and the basic function of every 3d map).
I can’t find any tutorial so I’ve deeped in the documentation.
I think that I should trace a ray from the camera to the center of the window, get the intersection point with the 3d terrain as Cartesian3 (the intersection point could be on a mountain, not only on flat terrain),
and use camera.lookAt(target, offset) with the intersection point as target, and the new heading/pitch of the camera.
But I’m really confused because:
- var ray = viewer.camera.getPickRay(windowCoordinates)
It require windowCoordinates. How can I get the center of the window?
- camera.lookAt(target, offset)
It require HeadingPitchRange.
How can I get the Range?
- I’m not sure that camera.lookAt is the right method to just modify pitch and heading and keep the same target.
Any help would be much appreciated
Thank-you
2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.
// find intersection of ray through a pixel and the globe
var windowCoordinates = new Cesium.Cartesian2(300, 300);
var ray = viewer.camera.getPickRay(windowCoordinates);
var intersection = Cesium.IntersectionTests.rayEllipsoid(ray, ellipsoid);
var point = Cesium.Ray.getPoint(ray, intersection.start);
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
I need to rotate the camera around the center point in the window of the terrain (what you can actually do clic with CTRL+mouse click on the map)
4. The Cesium version you’re using, your operating system and browser.
1.60