Skip to content

Commit e00ae96

Browse files
authored
Merge pull request #3171 from Jo-Byr/typescript-keyboardcameramanipulator
feat(KeyboardCameraManipulator): Add typescript
2 parents 04ece80 + 678489c commit e00ae96

File tree

1 file changed

+113
-0
lines changed
  • Sources/Interaction/Manipulators/KeyboardCameraManipulator

1 file changed

+113
-0
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import { Vector3 } from '../../../types';
2+
import { vtkObject } from '../../../interfaces';
3+
import vtkCompositeKeyboardManipulator from '../CompositeKeyboardManipulator';
4+
import vtkRenderWindowInteractor from '../../../Rendering/Core/RenderWindowInteractor';
5+
import vtkCamera from '../../../Rendering/Core/Camera';
6+
import vtkRenderer from '../../../Rendering/Core/Renderer';
7+
8+
export interface vtkKeyboardCameraManipulator
9+
extends vtkObject,
10+
vtkCompositeKeyboardManipulator {
11+
/**
12+
* Returns whether a movement is ongoing.
13+
*/
14+
inMotion(): boolean;
15+
16+
/**
17+
* Reset the movement speed to be proportional to the longest length of the renderer's bounds.
18+
*/
19+
resetMovementSpeed(): void;
20+
21+
/**
22+
* Initialize a movement of the current camera.
23+
*/
24+
startMovement(): void;
25+
26+
/**
27+
* Cancel any ongoing camera movement.
28+
*/
29+
endMovement(): void;
30+
31+
/**
32+
* Update active camera direction, depending on currently pressed keys.
33+
*/
34+
calculateCurrentDirection(): void;
35+
36+
/**
37+
* Returns the direction vector of the given camera for the given key.
38+
* @param key the movedkey
39+
* @param camera the camera
40+
*/
41+
getDirectionFromKey(key: KeyboardEvent['key'], camera: vtkCamera): Vector3;
42+
43+
/**
44+
* Moves the given camera, in the given direction, at the given speed.
45+
* @param camera the moved camera
46+
* @param direction the direction of the movemnt
47+
* @param speed the speed
48+
*/
49+
moveCamera(camera: vtkCamera, direction: Vector3, speed: number): void;
50+
51+
/**
52+
* Handles a keypress event.
53+
* @param interactor the interactor
54+
* @param renderer the renderer
55+
* @param key the key
56+
*/
57+
onKeyPress(
58+
interactor: vtkRenderWindowInteractor,
59+
renderer: vtkRenderer,
60+
key: KeyboardEvent['key']
61+
): void;
62+
63+
/**
64+
* Handles a keydown event.
65+
* @param interactor the interactor
66+
* @param renderer the renderer
67+
* @param key the key
68+
*/
69+
onKeyDown(
70+
interactor: vtkRenderWindowInteractor,
71+
renderer: vtkRenderer,
72+
key: KeyboardEvent['key']
73+
): void;
74+
75+
/**
76+
* Handles a keyup event.
77+
* @param interactor the interactor
78+
* @param renderer the renderer
79+
* @param key the key
80+
*/
81+
onKeyUp(
82+
interactor: vtkRenderWindowInteractor,
83+
renderer: vtkRenderer,
84+
key: KeyboardEvent['key']
85+
): void;
86+
}
87+
88+
export interface IKeyboardCameraManipulatorInitialValues {
89+
movementSpeed?: number;
90+
moveForwardKeys?: KeyboardEvent['key'][];
91+
moveLeftKeys?: KeyboardEvent['key'][];
92+
moveBackwardKeys?: KeyboardEvent['key'][];
93+
moveRightKeys?: KeyboardEvent['key'][];
94+
moveUpKeys?: KeyboardEvent['key'][];
95+
moveDownKeys?: KeyboardEvent['key'][];
96+
}
97+
98+
export function newInstance(
99+
initialValues?: IKeyboardCameraManipulatorInitialValues
100+
): vtkKeyboardCameraManipulator;
101+
102+
export function extend(
103+
publicAPI: object,
104+
model: object,
105+
initialValues?: IKeyboardCameraManipulatorInitialValues
106+
): void;
107+
108+
export const vtkKeyboardCameraManipulator: {
109+
newInstance: typeof newInstance;
110+
extend: typeof extend;
111+
};
112+
113+
export default vtkKeyboardCameraManipulator;

0 commit comments

Comments
 (0)