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:
修改后的 result 参数,如果未提供则为新的 Cartesian2 实例。如果输入位置靠近椭球体中心,则可能为
undefined。
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:
修改后的 result 参数,如果未提供则为新的 Cartesian2 实例。如果输入位置靠近椭球体中心,则可能为
undefined。
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);
