SceneTransforms

在与渲染相关的坐标系之间执行场景相关转换的函数。

Methods

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

将世界坐标中的位置转换为绘图缓冲区坐标。 这可能会产生不同的 当浏览器缩放不是 100% 时或在高 DPI 显示器上,则由 SceneTransforms.worldToWindowCoordinates 生成。
Name Type Description
scene Scene 场景。
position Cartesian3 在世界(WGS84 或替代椭球体)坐标中的位置。
result Cartesian2 optional 一个可选对象,用于返回转换为窗口坐标的输入位置。
Returns:
如果没有提供新的Cartesian2实例,则使用修改后的结果参数。 如果输入位置靠近椭球体的中心,则此字段可能未定义
Example:
// 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

将世界(WGS84 或替代椭球体)坐标中的位置转换为窗口坐标。 这通常用于将 HTML 元素与场景中的对象位于相同的屏幕位置。
Name Type Description
scene Scene 场景。
position Cartesian3 在世界(WGS84 或替代椭球体)坐标中的位置。
result Cartesian2 optional 一个可选对象,用于返回转换为窗口坐标的输入位置。
Returns:
如果没有提供新的Cartesian2实例,则使用修改后的结果参数。如果输入位置靠近椭球体的中心,则此字段可能未定义
Example:
// 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);
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.