Class: CameraEventAggregator

CameraEventAggregator

new CameraEventAggregator(canvas)

汇总输入事件。例如,假设在帧间接收到以下输入:鼠标左键向下、鼠标移动、鼠标移动、鼠标左键向上。这些事件将聚合成一个事件,并标明鼠标的起始和结束位置。

Name Type Default Description
canvas Canvas document 可选

要处理事件的元素。

See:

Members

anyButtonDownBoolean

获取鼠标键是否已按下、触摸是否已开始或滚轮是否已移动。

currentMousePositionCartesian2

获取当前鼠标位置。

Methods

destroy(){undefined}

移除该对象持有的鼠标监听器。

一旦对象被销毁,就不应再使用;调用除isDestroyed之外的任何函数都将导致DeveloperError 异常。 因此,请按照示例中的方法将返回值(undefined)赋值给对象。

See:
Throws:

该对象已被销毁,即 destroy() 被调用。

Type
DeveloperError
Returns:
Type Description
undefined
Example
handler = handler && handler.destroy();

getButtonPressTime(type, modifier){Date}

获取按下按钮或开始触摸的时间。

Name Type Description
type CameraEventType

相机事件类型。

modifier KeyboardEventModifier 可选

键盘修饰符。

Returns:
Type Description
Date 按下按钮或开始触摸的时间。

getButtonReleaseTime(type, modifier){Date}

获取按钮释放或触摸结束的时间。

Name Type Description
type CameraEventType

相机事件类型。

modifier KeyboardEventModifier 可选

键盘修饰符。

Returns:
Type Description
Date 按钮释放或触摸结束的时间。

getLastMovement(type, modifier){Object|undefined}

获取最后一次移动事件(非汇总事件)的开始和结束位置。

Name Type Description
type CameraEventType

相机事件类型。

modifier KeyboardEventModifier 可选

键盘修饰符。

Returns:
Type Description
Object | undefined 具有两个 Cartesian2 属性的对象:起始位置和终止位置,或未定义

getMovement(type, modifier){Object}

获取当前事件的起始和结束位置。

Name Type Description
type CameraEventType

相机事件类型。

modifier KeyboardEventModifier 可选

键盘修饰符。

Returns:
Type Description
Object 一个具有两个 Cartesian2 属性的对象:起始位置和终点位置

getStartMousePosition(type, modifier){Cartesian2}

获取开始聚合的鼠标位置。

Name Type Description
type CameraEventType

相机事件类型。

modifier KeyboardEventModifier 可选

键盘修饰符。

Returns:
Type Description
Cartesian2 鼠标位置。

isButtonDown(type, modifier){Boolean}

获取鼠标按钮是否按下或触摸是否开始。

Name Type Description
type CameraEventType

相机事件类型。

modifier KeyboardEventModifier 可选

键盘修饰符。

Returns:
Type Description
Boolean 鼠标按钮是否按下或触摸是否开始。

isDestroyed(){Boolean}

如果该对象已被销毁,则返回 true;否则返回 false。

如果该对象已被破坏,则不应使用;调用任何函数,除了 isDestroyed将导致DeveloperError异常。

See:
Returns:
Type Description
Boolean 如果该对象已被销毁,则为 true;否则为 false

isMoving(type, modifier){Boolean}

获取鼠标按下或触摸是否已开始并已移动。

Name Type Description
type CameraEventType

相机事件类型。

modifier KeyboardEventModifier 可选

键盘修饰符。

Returns:
Type Description
Boolean 如果已开始按下鼠标键或触摸并已移动,则返回 true;否则返回 false

reset()

表示所有事件都已处理完毕,应重置聚合器以处理新事件。