I am looking for the best approach in locking the y-axis. So that the camera rotates left and right only.
I have looked into
scene.getScreenSpaceCameraController().enableRotate = false;
But this locks all directions
Can we lock up and down?
Or is there some other way?
Lorenzo, I don’t personally know how to do it, but I’m bumping this so Dan can hopefully answer. If it’s not trivial, then I’ll write up a feature request, so that we don’t forget about it.
There is no way to restrict the camera to rotate left and right only. You could add a custom render loop where you could do this:
// perform built in camera updates
var camera = scene.getCamera();
// set the camera position to be in the plane of the equator
camera.position.z = 0.0;
// reset the direction to point towards the center of the earth
// orient so that ‘up’ is pointing north
Cartesian3.cross(camera.direction, camera.up, camera.right);
// render scene
This code would only work in 3D. If you need help with 2D or Columbus view modes, let us know.
I'm looking in to doing basically the same thing myself, for the purposes of making something comparable to a traditional desktop globe, tilted at an angle with a pivot through the poles.
It's been a few years, and I could see this being a feature which had been added in the mean-time. Is your method above still the best way to achieve this kind of effect?
I don’t think anything has been implemented to handle that type of functionality. The solution provided above should still work.
Ah, okay. The given solution seems a little rough (though that might just be my implementation!), but it works.
Thanks for letting me know!
i am trying lock the axis so camera does not roll.
i want my camera to move left to right ant up and down (specially in VR mode). guyz please help this causes problem in my project.
Is there a newer method for this function with the Cesium 1.43？
在 2013年8月16日星期五 UTC+8上午1:25:32，Lorenzo Campanis写道：
Not currently, I would still use the solution described above.