SceneTransforms
Functions that do scene-dependent transforms between rendering-related coordinate systems.
Source:
Methods
-
<static> wgs84ToDrawingBufferCoordinates
-
Transforms a position in WGS84 coordinates to drawing buffer coordinates. This may produce different results from SceneTransforms.wgs84ToWindowCoordinates when the browser zoom is not 100%, or on high-DPI displays.
Parameters:
Name Type Argument Default Description scene
Scene The scene. position
Cartesian3 The position in WGS84 (world) coordinates. result
Cartesian2 <optional>
undefined An optional object to return the input position transformed to window coordinates. Throws:
-
DeveloperError : scene is required.
-
DeveloperError : position is required.
Returns:
Cartesian2 The modified result parameter or a new Cartesian3 instance if one was not provided. This may beundefined
if the input position is near the center of the ellipsoid.Example
// Output the window position of longitude/latitude (0, 0) every time the mouse moves. var scene = widget.scene; var ellipsoid = widget.centralBody.getEllipsoid(); var position = ellipsoid.cartographicToCartesian(new Cartographic(0.0, 0.0)); var handler = new Cesium.ScreenSpaceEventHandler(scene.getCanvas()); handler.setInputAction(function(movement) { console.log(Cesium.SceneTransforms.wgs84ToWindowCoordinates(scene, position)); }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
-
-
<static> wgs84ToWindowCoordinates
-
Transforms a position in WGS84 coordinates to window coordinates. This is commonly used to place an HTML element at the same screen position as an object in the scene.
Parameters:
Name Type Argument Default Description scene
Scene The scene. position
Cartesian3 The position in WGS84 (world) coordinates. result
Cartesian2 <optional>
undefined An optional object to return the input position transformed to window coordinates. Throws:
-
DeveloperError : scene is required.
-
DeveloperError : position is required.
Returns:
Cartesian2 The modified result parameter or a new Cartesian3 instance if one was not provided. This may beundefined
if the input position is near the center of the ellipsoid.Example
// Output the window position of longitude/latitude (0, 0) every time the mouse moves. var scene = widget.scene; var ellipsoid = widget.centralBody.getEllipsoid(); var position = ellipsoid.cartographicToCartesian(new Cartographic(0.0, 0.0)); var handler = new Cesium.ScreenSpaceEventHandler(scene.getCanvas()); handler.setInputAction(function(movement) { console.log(Cesium.SceneTransforms.wgs84ToWindowCoordinates(scene, position)); }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
-