SceneTransforms

Functions that do scene-dependent transforms between rendering-related coordinate systems.

方法

static Cesium.SceneTransforms.worldToDrawingBufferCoordinates(scene, position, result)Cartesian2|undefined

Transforms a position in world coordinates to drawing buffer coordinates. This may produce different results from SceneTransforms.worldToWindowCoordinates when the browser zoom is not 100%, or on high-DPI displays.
参数名称 类型 描述信息
scene Scene The scene.
position Cartesian3 The position in world (WGS84 or alternative ellipsoid) coordinates.
result Cartesian2 可选 An optional object to return the input position transformed to window coordinates.
返回值:
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.
使用示例:
// Output the window position of longitude/latitude (0, 0) every time the mouse moves.
const position = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
const handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(movement) {
    console.log(Cesium.SceneTransforms.worldToDrawingBufferCoordinates(scene, position));
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);

static Cesium.SceneTransforms.worldToWindowCoordinates(scene, position, result)Cartesian2|undefined

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.
参数名称 类型 描述信息
scene Scene The scene.
position Cartesian3 The position in world (WGS84 or alternative ellipsoid) coordinates.
result Cartesian2 可选 An optional object to return the input position transformed to window coordinates.
返回值:
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.
使用示例:
// Output the window position of longitude/latitude (0, 0) every time the mouse moves.
const position = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
const handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(movement) {
    console.log(Cesium.SceneTransforms.worldToWindowCoordinates(scene, position));
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);