cartesianToCanvasCoordinates
fun cartesianToCanvasCoordinates(position: Cartesian3, result: Cartesian2? = definedExternally): Cartesian2(source)
Transforms a position in cartesian coordinates to canvas coordinates. This is commonly used to place an HTML element at the same screen position as an object in the scene.
// Output the canvas position of longitude/latitude (0, 0) every time the mouse moves.
const scene = widget.scene;
const position = Cartesian3.fromDegrees(0.0, 0.0);
const handler = new ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(movement) {
console.log(scene.cartesianToCanvasCoordinates(position));
}, ScreenSpaceEventType.MOUSE_MOVE);
Content copied to clipboard
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
position
The position in cartesian coordinates.
result
An optional object to return the input position transformed to canvas coordinates.