English中文

SceneTransforms

在与渲染相关的坐标系之间进行与场景相关的转换的函数。 Functions that do scene-dependent transforms between rendering-related coordinate systems.

方法 Methods

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

将世界坐标中的位置转换为绘图缓冲区坐标。当浏览器缩放不是 100% 或在高 DPI 显示器上时,这可能会产生与 SceneTransforms.worldToWindowCooperatives 不同的结果。 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.
名称 Name 类型 Type 说明 Description
scene Scene 现场。 The scene.
position Cartesian3 世界坐标(WGS84 或替代椭球体)中的位置。 The position in world (WGS84 or alternative ellipsoid) coordinates.
result Cartesian2 可选 optional 一个可选对象,用于返回转换为窗口坐标的输入位置。 An optional object to return the input position transformed to window coordinates.
返回: Returns:
修改后的结果参数或新的 Cartesian2 实例(如果未提供)。这可能是 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.
示例: 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 元素放置在与场景中的对象相同的屏幕位置。 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.
名称 Name 类型 Type 说明 Description
scene Scene 现场。 The scene.
position Cartesian3 世界坐标(WGS84 或替代椭球体)中的位置。 The position in world (WGS84 or alternative ellipsoid) coordinates.
result Cartesian2 可选 optional 一个可选对象,用于返回转换为窗口坐标的输入位置。 An optional object to return the input position transformed to window coordinates.
返回: Returns:
修改后的结果参数或新的 Cartesian2 实例(如果未提供)。这可能是 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.
示例: 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.