From 678489c9c54a77292fdc4a60e3a15842e6d2056f Mon Sep 17 00:00:00 2001 From: Jo-Byr Date: Thu, 7 Nov 2024 13:09:39 +0100 Subject: [PATCH] feat(KeyboardCameraManipulator): Add typescript Add index.d.ts file for vtkKeyboardCameraManipulator --- .../KeyboardCameraManipulator/index.d.ts | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 Sources/Interaction/Manipulators/KeyboardCameraManipulator/index.d.ts diff --git a/Sources/Interaction/Manipulators/KeyboardCameraManipulator/index.d.ts b/Sources/Interaction/Manipulators/KeyboardCameraManipulator/index.d.ts new file mode 100644 index 00000000000..d47bd8188fa --- /dev/null +++ b/Sources/Interaction/Manipulators/KeyboardCameraManipulator/index.d.ts @@ -0,0 +1,113 @@ +import { Vector3 } from '../../../types'; +import { vtkObject } from '../../../interfaces'; +import vtkCompositeKeyboardManipulator from '../CompositeKeyboardManipulator'; +import vtkRenderWindowInteractor from '../../../Rendering/Core/RenderWindowInteractor'; +import vtkCamera from '../../../Rendering/Core/Camera'; +import vtkRenderer from '../../../Rendering/Core/Renderer'; + +export interface vtkKeyboardCameraManipulator + extends vtkObject, + vtkCompositeKeyboardManipulator { + /** + * Returns whether a movement is ongoing. + */ + inMotion(): boolean; + + /** + * Reset the movement speed to be proportional to the longest length of the renderer's bounds. + */ + resetMovementSpeed(): void; + + /** + * Initialize a movement of the current camera. + */ + startMovement(): void; + + /** + * Cancel any ongoing camera movement. + */ + endMovement(): void; + + /** + * Update active camera direction, depending on currently pressed keys. + */ + calculateCurrentDirection(): void; + + /** + * Returns the direction vector of the given camera for the given key. + * @param key the movedkey + * @param camera the camera + */ + getDirectionFromKey(key: KeyboardEvent['key'], camera: vtkCamera): Vector3; + + /** + * Moves the given camera, in the given direction, at the given speed. + * @param camera the moved camera + * @param direction the direction of the movemnt + * @param speed the speed + */ + moveCamera(camera: vtkCamera, direction: Vector3, speed: number): void; + + /** + * Handles a keypress event. + * @param interactor the interactor + * @param renderer the renderer + * @param key the key + */ + onKeyPress( + interactor: vtkRenderWindowInteractor, + renderer: vtkRenderer, + key: KeyboardEvent['key'] + ): void; + + /** + * Handles a keydown event. + * @param interactor the interactor + * @param renderer the renderer + * @param key the key + */ + onKeyDown( + interactor: vtkRenderWindowInteractor, + renderer: vtkRenderer, + key: KeyboardEvent['key'] + ): void; + + /** + * Handles a keyup event. + * @param interactor the interactor + * @param renderer the renderer + * @param key the key + */ + onKeyUp( + interactor: vtkRenderWindowInteractor, + renderer: vtkRenderer, + key: KeyboardEvent['key'] + ): void; +} + +export interface IKeyboardCameraManipulatorInitialValues { + movementSpeed?: number; + moveForwardKeys?: KeyboardEvent['key'][]; + moveLeftKeys?: KeyboardEvent['key'][]; + moveBackwardKeys?: KeyboardEvent['key'][]; + moveRightKeys?: KeyboardEvent['key'][]; + moveUpKeys?: KeyboardEvent['key'][]; + moveDownKeys?: KeyboardEvent['key'][]; +} + +export function newInstance( + initialValues?: IKeyboardCameraManipulatorInitialValues +): vtkKeyboardCameraManipulator; + +export function extend( + publicAPI: object, + model: object, + initialValues?: IKeyboardCameraManipulatorInitialValues +): void; + +export const vtkKeyboardCameraManipulator: { + newInstance: typeof newInstance; + extend: typeof extend; +}; + +export default vtkKeyboardCameraManipulator;