ScreenSpaceMapCameraController
Cesium v1.147 · 中文

一个允许在屏幕空间中沿椭球切线方向平移摄像机的相机控制器。 通过点击并拖动鼠标实现。

new Cesium.ScreenSpaceMapCameraController(options)

创建 ScreenSpaceMapCameraController 的实例。
Name Type Description
options ScreenSpaceMapCameraController.ControllerOptions optional 配置控制器的选项。
Examples:
viewer.scene.screenSpaceCameraController.enableInputs = false;

const mapCameraController = new Cesium.ScreenSpaceMapCameraController();
viewer.addController(mapCameraController);
// 配置控制器使用右鼠标按钮进行平移,而不是默认的左鼠标按钮。
const mapCameraController = new Cesium.ScreenSpaceMapCameraController({
dragInputs: [{ button: Cesium.MouseButton.RIGHT}]
});
viewer.addController(mapCameraController);

Members

映射平移的拖拽输入绑定。每个绑定都是鼠标按钮 和可选键盘修饰符的组合。
See:
决定控制器是否启用以及是否由宿主场景进行更新。
启用或禁用平移时的惯性。当启用时,用户在停止拖拽后摄像机仍会继续移动,并根据 ScreenSpaceMapCameraController#inertialDecay 逐渐减速。
Default Value: true
摄像机平移速度随时间衰减的速率。
Default Value: 6.0
一个位于 [0, 1) 范围内的参数,用于限制输入范围 为每动画帧窗口宽度/高度的百分比。 这有助于在低帧率情况下保持摄像机控制。
Default Value: 0.1
摄像机平移的米每像素速度。
Default Value: 1.0
用于选择平移起点世界位置的回调函数。该函数接收 Scene、屏幕空间位置 Cartesian2 以及用于存储结果的 Cartesian3 实例作为参数。该函数应返回要平移的起点世界位置 Cartesian3,如果无法选择位置则返回 undefined。如果返回 undefined,则摄像机将相对于摄像机下方的椭球表面进行平移。
Default Value: defaultPickWorldPosition
Example:
const mapCameraController = new Cesium.ScreenSpaceMapCameraController();
mapCameraController.pickWorldPosition = function (scene, windowPosition, result) {
// 从深度缓冲区选择世界位置
return scene.pickPosition(windowPosition, result);
};
viewer.addController(mapCameraController);

Methods

当控制器被添加到 DOM 时调用。需实现 connectedCallback 来设置任何 DOM 事件监听器。
Name Type Description
element HTMLElement 包含 Cesium 场景的 DOM 元素。

disconnectedCallback(element)

当控制器从 DOM 中移除时调用。需实现 disconnectedCallback 来取消任何 DOM 事件监听器。
Name Type Description
element HTMLElement 包含 Cesium 场景的 DOM 元素。
当控制器首次更新时调用,即在调用 update 之前。需实现 firstUpdate 以在相关场景开始渲染循环后执行一次性操作。例如初始化模拟时间值或将primitive添加到场景中。
Name Type Description
scene Scene
time JulianDate 当前模拟时间。
See:
每帧调用一次。需实现 update 来修改相机或场景的其他部分。
Name Type Description
scene Scene
time JulianDate 当前模拟时间。
See:

Type Definitions

Cesium.ScreenSpaceMapCameraController.ControllerOptions

Properties:
Name Type Attributes Description
dragInputs Array.<ScreenSpaceInputBindings.InputBinding> <optional>
控制平移的拖拽输入绑定。
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.