lookAtTransform

fun lookAtTransform(transform: Matrix4)(source)

Sets the camera position and orientation using a target and transformation matrix. The offset can be either a cartesian or heading/pitch/range. If the offset is a cartesian, then it is an offset from the center of the reference frame defined by the transformation matrix. If the offset is heading/pitch/range, then the heading and the pitch angles are defined in the reference frame defined by the transformation matrix. The heading is the angle from y axis and increasing towards the x axis. Pitch is the rotation from the xy-plane. Positive pitch angles are below the plane. Negative pitch angles are above the plane. The range is the distance from the center.

In 2D, there must be a top down view. The camera will be placed above the center of the reference frame. The height above the target will be the magnitude of the offset. The heading will be determined from the offset. If the heading cannot be determined from the offset, the heading will be north.

// 1. Using a cartesian offset
const transform = Transforms.eastNorthUpToFixedFrame(Cartesian3.fromDegrees(-98.0, 40.0));
viewer.camera.lookAtTransform(transform, new Cartesian3(0.0, -4790000.0, 3930000.0));

// 2. Using a HeadingPitchRange offset
const transform = Transforms.eastNorthUpToFixedFrame(Cartesian3.fromDegrees(-72.0, 40.0));
const heading = Math.toRadians(50.0);
const pitch = Math.toRadians(-20.0);
const range = 5000.0;
viewer.camera.lookAtTransform(transform, new HeadingPitchRange(heading, pitch, range));

Parameters

transform

The transformation matrix defining the reference frame.

offset

The offset from the target in a reference frame centered at the target.

See also


fun lookAtTransform(transform: Matrix4, offset: Cartesian3)(source)