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:
修改后的结果参数或新的二维笛卡尔实例(如果未提供)。如果输入位置接近椭球体中心,则可能为
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:
修改后的结果参数或新的二维笛卡尔实例(如果未提供)。如果输入位置接近椭球体中心,则可能为
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);
