Skip to main content

GyroControl

Since version 4.0.0

Camera's rotation control by gyroscope

class GyroControl extends Component<GyroControlEvents> implements CameraControl

Extends

Implements

Properties

Whether this control is animating the camera

Whether this control is enabled or not

When true, ignore gyroscope's roll(z-axis rotation) value.

caution

Setting false will ignore camera's range limit.
Options like yawRange, pitchRange are ignored, and CylinderProjection also can't force it's camera range limit.

Methods

Return availability of the gyroscope.

caution

This will always return false until user permission under environments like iOS which requires user permission when using gyroscope.

Request user permission for gyroscope sensor.
This can be used in environments like iOS which requires user permission when using gyroscope sensors.

Constructor

Create new GyroControl instance
new GyroControl(enableBlocked: boolean, options: Partial<GyroControlOptions>): GyroControl

Parameters

enableBlocked

boolean

Whether to disable control on init

options

{}

Options for control

Properties

animating

readonly
animating

boolean

Whether this control is animating the camera

enabled

readonly
enabled

boolean

Whether this control is enabled or not

ignoreRoll

>=4.0.0
ignoreRoll

boolean

true

When true, ignore gyroscope's roll(z-axis rotation) value.

caution

Setting false will ignore camera's range limit.
Options like yawRange, pitchRange are ignored, and CylinderProjection also can't force it's camera range limit.

Methods

isAvailable

static
isAvailable

Promise<boolean>

isAvailable(): Promise<boolean>

Return availability of the gyroscope.

caution

This will always return false until user permission under environments like iOS which requires user permission when using gyroscope.

Example
const gyroAvailable = await GyroControl.isAvailable();

requestSensorPermission

static
requestSensorPermission

Promise<boolean>

requestSensorPermission(): Promise<boolean>

Request user permission for gyroscope sensor.
This can be used in environments like iOS which requires user permission when using gyroscope sensors.

Returns

Whether the permission is granted

destroy

destroy

void

destroy(): void

disable

disable

void

disable(): void

enable

enable

void

enable(): void

hasOn

inherited
hasOn

boolean

hasOn<K>(eventName: K): boolean

Parameters

eventName

K

off

inherited
off

GyroControl

off<K>(eventName: K, handlerToDetach: EventCallback<GyroControlEvents, K, GyroControl>): GyroControl

Parameters

eventName

K

handlerToDetach

EventCallback<GyroControlEvents, K, GyroControl>

on

inherited
on

GyroControl

on(eventHash: Partial<{ change: ((event: { delta: void; isKeyboard: boolean; isTouch: boolean }) => any); disable: ((event: { updateCursor: boolean }) => any); enable: ((event: { control: CameraControl; updateCursor: boolean }) => any); inputEnd: ((event: { inputType: "zoom" | "rotate" } & { isKeyboard: boolean; isTouch: boolean; scrolling: boolean }) => any); inputStart: ((event: { inputType: "zoom" | "rotate" } & { isKeyboard: boolean; isTouch: boolean; srcEvent: MouseEvent | TouchEvent | KeyboardEvent }) => any); staticClick: ((event: { isTouch: boolean }) => any) }>): GyroControl

Parameters

eventHash

Partial<{ change: ((event: { delta: void; isKeyboard: boolean; isTouch: boolean }) => any); disable: ((event: { updateCursor: boolean }) => any); enable: ((event: { control: CameraControl; updateCursor: boolean }) => any); inputEnd: ((event: { inputType: "zoom" | "rotate" } & { isKeyboard: boolean; isTouch: boolean; scrolling: boolean }) => any); inputStart: ((event: { inputType: "zoom" | "rotate" } & { isKeyboard: boolean; isTouch: boolean; srcEvent: MouseEvent | TouchEvent | KeyboardEvent }) => any); staticClick: ((event: { isTouch: boolean }) => any) }>

once

inherited
once

GyroControl

once(eventHash: Partial<{ change: ((event: { delta: void; isKeyboard: boolean; isTouch: boolean }) => any); disable: ((event: { updateCursor: boolean }) => any); enable: ((event: { control: CameraControl; updateCursor: boolean }) => any); inputEnd: ((event: { inputType: "zoom" | "rotate" } & { isKeyboard: boolean; isTouch: boolean; scrolling: boolean }) => any); inputStart: ((event: { inputType: "zoom" | "rotate" } & { isKeyboard: boolean; isTouch: boolean; srcEvent: MouseEvent | TouchEvent | KeyboardEvent }) => any); staticClick: ((event: { isTouch: boolean }) => any) }>): GyroControl

Parameters

eventHash

Partial<{ change: ((event: { delta: void; isKeyboard: boolean; isTouch: boolean }) => any); disable: ((event: { updateCursor: boolean }) => any); enable: ((event: { control: CameraControl; updateCursor: boolean }) => any); inputEnd: ((event: { inputType: "zoom" | "rotate" } & { isKeyboard: boolean; isTouch: boolean; scrolling: boolean }) => any); inputStart: ((event: { inputType: "zoom" | "rotate" } & { isKeyboard: boolean; isTouch: boolean; srcEvent: MouseEvent | TouchEvent | KeyboardEvent }) => any); staticClick: ((event: { isTouch: boolean }) => any) }>

sync

sync

void

sync(): void

trigger

inherited
trigger

GyroControl

trigger<K>(event: K, ...params: EventTriggerParams<GyroControlEvents, K>): GyroControl

Parameters

event

K

params

EventTriggerParams<GyroControlEvents, K>