[cesium-dev] How can I "fly" the camera a "look at" position?

Hi Steve(n),

you can use the function below to find cartesian coordinate
given position and heading/pitch/range.

Caveat: IIRC, Quaternion.fromHeadingPitchRoll is a bit
idiosyncratic in that it does not operate in local eye space,
thats why angle and local view vector are not as you would
expect.

(cf https://github.com/AnalyticalGraphicsInc/cesium/issues/3256)

function transformCartesianHeadingPitchRangeToCartesian(positionCartesian, heading, pitch, range, result) {
         var position = Cartesian3.clone(positionCartesian, result);
         var ellipsoid = this.scene.mapProjection.ellipsoid;

         // Find a point from which we can see the target with specified pitch and roll
         var quaternion = Quaternion.fromHeadingPitchRoll(heading - CesiumMath.PI_OVER_TWO, pitch, 0.0, new Quaternion());
         var pitchRollMatrix3 = Matrix3.fromQuaternion(quaternion, new Matrix3());

         var localViewDir = Matrix3.multiplyByVector(pitchRollMatrix3, Cartesian3.fromElements(1.0, 0.0, 0.0), new Cartesian3());
         var orientationMatrix3 = Matrix4.getRotation(Transforms.eastNorthUpToFixedFrame(position, ellipsoid), new Matrix3());

         // Transform from local to global cartesian
         var direction = Matrix3.multiplyByVector(orientationMatrix3, localViewDir, localViewDir);
         Cartesian3.multiplyByScalar(direction, -range, direction);
         Cartesian3.add(position, direction, position);
         return position;
}

Manuel