worldToWindowCoordinates

fun worldToWindowCoordinates(scene: Scene, position: Cartesian3, result: Cartesian2? = definedExternally): Cartesian2?(source)

Transforms a position in world (WGS84 or alternative ellipsoid) coordinates to window coordinates. This is commonly used to place an HTML element at the same screen position as an object in the scene.

// Output the window position of longitude/latitude (0, 0) every time the mouse moves.
const position = Cartesian3.fromDegrees(0.0, 0.0);
const handler = new ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(movement) {
console.log(SceneTransforms.worldToWindowCoordinates(scene, position));
}, ScreenSpaceEventType.MOUSE_MOVE);

Return

The modified result parameter or a new Cartesian2 instance if one was not provided. This may be undefined if the input position is near the center of the ellipsoid.

Parameters

scene

The scene.

position

The position in world (WGS84 or alternative ellipsoid) coordinates.

result

An optional object to return the input position transformed to window coordinates.

See also