GyroControl
Camera's rotation control by gyroscope
class GyroControl extends Component<GyroControlEvents> implements CameraControl
Extends
- Component<GyroControlEvents>
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.
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.
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
new GyroControl(enableBlocked: boolean, options: Partial<GyroControlOptions>): GyroControl
Parameters
boolean
Whether to disable control on init
Options for control
Properties
animating
animatingboolean
Whether this control is animating the camera
enabled
enabledboolean
Whether this control is enabled or not
ignoreRoll
ignoreRollboolean
true
When true
, ignore gyroscope's roll(z-axis rotation) value.
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
isAvailablePromise<boolean>
isAvailable(): Promise<boolean>
Return availability of the gyroscope.
This will always return false until user permission under environments like iOS which requires user permission when using gyroscope.
const gyroAvailable = await GyroControl.isAvailable();
requestSensorPermission
requestSensorPermissionPromise<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
destroyvoid
destroy(): void
disable
disablevoid
disable(): void
enable
enablevoid
enable(): void
hasOn
hasOnboolean
hasOn<K>(eventName: K): boolean
Parameters
K
off
off
off<K>(eventName: K, handlerToDetach: EventCallback<GyroControlEvents, K, GyroControl>): GyroControl
Parameters
K
EventCallback<GyroControlEvents, K, GyroControl>
on
on
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
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
once
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
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
syncvoid
sync(): void
trigger
trigger
trigger<K>(event: K, ...params: EventTriggerParams<GyroControlEvents, K>): GyroControl
Parameters
K
EventTriggerParams<GyroControlEvents, K>