Skip to content

Commit 1562391

Browse files
committed
feat(KeyboardCameraManipulator): Allow renderer and interactor to be set externally
This is being done so that clients like paraview glance may call resetMovementSpeed() before the user has performed a move action. This is required to generate a valid movement speed.
1 parent 060817c commit 1562391

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

  • Sources/Interaction/Manipulators/KeyboardCameraManipulator

Sources/Interaction/Manipulators/KeyboardCameraManipulator/index.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ function vtkKeyboardCameraManipulator(publicAPI, model) {
1616
model.classHierarchy.push('vtkKeyboardCameraManipulator');
1717

1818
const internal = {
19-
interactor: null,
20-
renderer: null,
2119
keysDown: [],
2220
direction: [0, 0, 0],
2321
skipUpdateDirection: false,
@@ -34,7 +32,7 @@ function vtkKeyboardCameraManipulator(publicAPI, model) {
3432
publicAPI.resetMovementSpeed = () => {
3533
// Reset the movement speed to be proportional to the longest length
3634
// of the renderer's bounds.
37-
const { renderer } = internal;
35+
const { renderer } = model;
3836

3937
const bounds = renderer.computeVisiblePropBounds();
4038

@@ -55,7 +53,7 @@ function vtkKeyboardCameraManipulator(publicAPI, model) {
5553
publicAPI.resetMovementSpeed();
5654
}
5755

58-
const { interactor, renderer } = internal;
56+
const { interactor, renderer } = model;
5957

6058
const move = () => {
6159
if (internal.keysDown.length === 0) {
@@ -98,7 +96,7 @@ function vtkKeyboardCameraManipulator(publicAPI, model) {
9896
internal.animationSub = null;
9997
}
10098

101-
internal.interactor.cancelAnimation(ANIMATION_REQUESTER);
99+
model.interactor.cancelAnimation(ANIMATION_REQUESTER);
102100

103101
if (internal.cameraModifiedSub) {
104102
internal.cameraModifiedSub.unsubscribe();
@@ -116,7 +114,7 @@ function vtkKeyboardCameraManipulator(publicAPI, model) {
116114
// Reset
117115
internal.direction = [0, 0, 0];
118116

119-
const { renderer } = internal;
117+
const { renderer } = model;
120118

121119
if (!renderer) {
122120
return;
@@ -218,7 +216,7 @@ function vtkKeyboardCameraManipulator(publicAPI, model) {
218216
}
219217

220218
if (!publicAPI.inMotion()) {
221-
Object.assign(internal, { interactor, renderer });
219+
Object.assign(model, { interactor, renderer });
222220
publicAPI.startMovement();
223221
}
224222
};
@@ -255,6 +253,8 @@ const DEFAULT_VALUES = {
255253
moveRightKeys: ['d', 'D', 'ArrowRight'],
256254
moveUpKeys: [' '],
257255
moveDownKeys: ['Shift'],
256+
interactor: null,
257+
renderer: null,
258258
};
259259

260260
// ----------------------------------------------------------------------------
@@ -275,6 +275,8 @@ export function extend(publicAPI, model, initialValues = {}) {
275275
'moveRightKeys',
276276
'moveUpKeys',
277277
'moveDownKeys',
278+
'interactor',
279+
'renderer',
278280
]);
279281

280282
// Object specific methods

0 commit comments

Comments
 (0)