I’m having problems with transition from lookat to setview in versions 1.7 and 1.7.1.
In my flight simulator I use setview for a first-person cockpit view and lookat for a wingman view. Transitioning the camera from setview to lookat works fine. That is, after the camera is defined and updating, I switch from using setview to using lookat and the camera behaves as expected.
However, transitioning from lookat to setview results in the camera heading and tilt being fixed to zero but with roll still updating.
Reverting to version 1.6 fixes the problem.
This is just a guess, but since you mentioned that problems occur when “transitioning from lookat to setview” I’d like to point out that setView will set the transform back to how it was after it is done, but that is not the case with lookAt.
Perhaps when “transitioning from lookAt to setView” try adding this line
or if a non-underscore method exist.
However since I don’t know the specific code you’re using I can only guess.
That fixed it.
If I reset the transform each time before using the setView then the problem goes away:
position : new Cesium.Cartesian3.fromDegrees(eyePointLng, eyePointLat, eyePointAlt),
heading : angleWrap(acState.headingView + camHeadingBias) * Math.PI/180,
pitch : (-acState.tiltView + camTiltBias) * Math.PI/180,
roll : -acState.rollView * Math.PI/180
I don’t understand completely why I have to do this in 1.7 but didn’t in 1.6. Is there a change in strategy I’m not grasping?
In 1.7 Camera.prototype.lookAt is a very simple wrapper for .lookAtTransform Basically it sets the local ENU as the transform parameter for .lookAtTransform . Even the 1.6 Cesium .lookAtTransform didn’t set the transform back to what it was originally.
However 1.6 Cesium had 2 options (while 1.7 has one)
-if over 2 parameters (eye,target,up) it wouldn’t mess with the transform at all
-if 2 parameters (target,offset) it would mess with the transform and not set it back
Perhaps you used the eye,target,up option for Cesium 1.6?
Here’s my code for the lookAt command. I’m using target and offset (2 parameters).
center = Cesium.Cartesian3.fromDegrees(viewLng, viewLat, viewAlt + undulation);
heading = Cesium.Math.toRadians(viewHeading);
pitch = Cesium.Math.toRadians(viewTilt - 90);
range = viewRange;
viewer.scene.camera.lookAt(center, new Cesium.HeadingPitchRange(heading, pitch, range));
The code does work in 1.6. However, in 1.7 I have to reset the transform with IDENTITY before switching to setView as you pointed out. I’ve confirmed this by direct swapping between 1.6 and 1.7.
Maybe the documentation can be updated to describe the transform reset/no reset depending on the number of parameters used?
Thanks much for the help,
I’m not sure why, .lookAt is basically identical in both 1.6 and 1.7.1 when using just 2 parameters (1.7.0 is a bit different than 1.7.1 however, but I haven’t looked at 1.7.0 yet)
In 1.8 camera.setTransform is slated to be removed, but camera._setTransform will still be there (.lookAtTransform uses it.) However passing a single parameter (transform) with lookAtTransform does the same as calling _setTransform , which I see is what you’ve done already.
Perhaps the code could check the Cesium version and act accordingly.