Skip to content

Commit 12d0f63

Browse files
bourdaisjfinetjul
authored andcommitted
fix(3d interactions): update doc and TS definitions
1 parent 60cc0f9 commit 12d0f63

File tree

7 files changed

+83
-43
lines changed

7 files changed

+83
-43
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import vtkCompositeVRManipulator from '../CompositeVRManipulator';
2+
3+
export interface vtk3DControllerModelSelectorManipulator
4+
extends vtkCompositeVRManipulator {}
5+
6+
export interface I3DControllerModelSelectorManipulatorInitialValues
7+
extends vtkCompositeVRManipulator {}
8+
9+
export function extend(
10+
publicAPI: object,
11+
model: object,
12+
initialValues?: I3DControllerModelSelectorManipulatorInitialValues
13+
): void;
14+
15+
export const vtk3DControllerModelSelectorManipulator: {
16+
extend: typeof extend;
17+
};
18+
19+
export default vtk3DControllerModelSelectorManipulator;

Sources/Interaction/Manipulators/3DControllerModelSelectorManipulator/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ function vtk3DControllerModelSelectorManipulator(publicAPI, model) {
115115
const camera = renderer.getActiveCamera();
116116
camera.getPhysicalToWorldMatrix(physicalToWorldMatrix);
117117

118+
const { targetPosition, targetOrientation } = eventData;
119+
118120
// Since targetPosition is in physical coordinates,
119121
// transform it using the physicalToWorldMatrix to get it in world coordinates
120122
const targetRayWorldPosition = vec3.transformMat4(
@@ -160,7 +162,7 @@ function vtk3DControllerModelSelectorManipulator(publicAPI, model) {
160162
const currentTargetRayWorldPosition = new Float64Array(3);
161163
const currentTargetRayOrientation = new Float64Array(4);
162164

163-
publicAPI.onMove3D = (_interactorStyle, renderer, _state, eventData) => {
165+
publicAPI.onMove3D = (interactorStyle, renderer, state, eventData) => {
164166
// If we are not interacting with any prop, we have nothing to do.
165167
// Also check for dragable
166168
if (state !== States.IS_CAMERA_POSE || pickedProp == null) {

Sources/Interaction/Manipulators/CompositeVRManipulator/index.d.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
import { States } from '../../../Rendering/Core/InteractorStyle/Constants';
22
import vtkRenderer from '../../../Rendering/Core/Renderer';
3-
import vtkRenderWindowInteractor from '../../../Rendering/Core/RenderWindowInteractor';
3+
import vtkInteractorObserver from '../../../Rendering/Core/InteractorObserver';
44
import {
55
Device,
66
Input,
77
} from '../../../Rendering/Core/RenderWindowInteractor/Constants';
8+
import {
9+
I3DEvent,
10+
IButton3DEvent,
11+
} from '../../../Rendering/Core/RenderWindowInteractor';
812

913
export interface vtkCompositeVRManipulator {
1014
onButton3D(
11-
interactor: vtkRenderWindowInteractor,
15+
interactorStyle: vtkInteractorObserver,
1216
renderer: vtkRenderer,
1317
state: States,
14-
device: Device,
15-
input: Input,
16-
pressed: boolean
18+
eventData: IButton3DEvent
1719
): void;
1820

1921
onMove3D(
20-
interactor: vtkRenderWindowInteractor,
22+
interactorStyle: vtkInteractorObserver,
2123
renderer: vtkRenderer,
2224
state: States,
23-
device: Device,
24-
input: Input,
25-
pressed: boolean
25+
eventData: I3DEvent
2626
): void;
2727
}
2828

Sources/Interaction/Manipulators/CompositeVRManipulator/index.js

+2-16
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,8 @@ function vtkCompositeVRManipulator(publicAPI, model) {
1212
// Set our className
1313
model.classHierarchy.push('vtkCompositeVRManipulator');
1414

15-
publicAPI.onButton3D = (
16-
interactor,
17-
renderer,
18-
state,
19-
device,
20-
input,
21-
pressed
22-
) => {};
23-
publicAPI.onMove3D = (
24-
interactor,
25-
renderer,
26-
state,
27-
device,
28-
input,
29-
pressed
30-
) => {};
15+
publicAPI.onButton3D = (interactorStyle, renderer, state, eventData) => {};
16+
publicAPI.onMove3D = (interactorStyle, renderer, state, eventData) => {};
3117
}
3218

3319
// ----------------------------------------------------------------------------

Sources/Interaction/Manipulators/VRButtonPanManipulator/index.js

+7-12
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,15 @@ function vtkVRButtonPanManipulator(publicAPI, model) {
1414
// Set our className
1515
model.classHierarchy.push('vtkVRButtonPanManipulator');
1616

17-
publicAPI.onButton3D = (
18-
interactorStyle,
19-
renderer,
20-
state,
21-
device,
22-
input,
23-
pressed
24-
) => {
25-
if (pressed) {
17+
publicAPI.onButton3D = (interactorStyle, renderer, state, eventData) => {
18+
if (eventData.pressed) {
2619
interactorStyle.startCameraPose();
2720
} else if (state === States.IS_CAMERA_POSE) {
2821
interactorStyle.endCameraPose();
2922
}
3023
};
3124

32-
publicAPI.onMove3D = (interactorStyle, renderer, state, data) => {
25+
publicAPI.onMove3D = (interactorStyle, renderer, state, eventData) => {
3326
if (state !== States.IS_CAMERA_POSE) {
3427
return;
3528
}
@@ -40,13 +33,15 @@ function vtkVRButtonPanManipulator(publicAPI, model) {
4033
const oldTrans = camera.getPhysicalTranslation();
4134

4235
// look at the y axis to determine how fast / what direction to move
43-
const speed = data.gamepad.axes[1];
36+
const speed = eventData.gamepad.axes[1];
4437

4538
// 0.05 meters / frame movement
4639
const pscale = speed * 0.05 * camera.getPhysicalScale();
4740

4841
// convert orientation to world coordinate direction
49-
const dir = camera.physicalOrientationToWorldDirection(data.orientation);
42+
const dir = camera.physicalOrientationToWorldDirection(
43+
eventData.orientation
44+
);
5045

5146
camera.setPhysicalTranslation(
5247
oldTrans[0] + dir[0] * pscale,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import vtkInteractorStyleManipulator, { IInteractorStyleManipulatorInitialValues } from '../../../Interaction/Style/InteractorStyleManipulator';
2+
3+
export interface vtkInteractorStyleHMDXR extends vtkInteractorStyleManipulator {}
4+
5+
export interface IInteractorStyleHMDXRInitialValues extends IInteractorStyleManipulatorInitialValues {}
6+
7+
export function newInstance(
8+
initialValues?: IInteractorStyleHMDXRInitialValues
9+
): vtkInteractorStyleHMDXR;
10+
11+
export function extend(
12+
publicAPI: object,
13+
model: object,
14+
initialValues?: IInteractorStyleHMDXRInitialValues
15+
): void;
16+
17+
export const vtkInteractorStyleHMDXR: {
18+
newInstance: typeof newInstance;
19+
extend: typeof extend;
20+
};
21+
22+
export default vtkInteractorStyleHMDXR;

Sources/Rendering/Core/RenderWindowInteractor/index.d.ts

+21-5
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,20 @@ export interface IRenderWindowInteractorEvent {
8181
type: InteractorEventType;
8282
}
8383

84+
export interface I3DEvent {
85+
gamepad: Gamepad;
86+
position: DOMPointReadOnly;
87+
orientation: DOMPointReadOnly;
88+
targetPosition: DOMPointReadOnly;
89+
targetOrientation: DOMPointReadOnly;
90+
device: Device;
91+
}
92+
93+
export interface IButton3DEvent extends I3DEvent {
94+
pressed: boolean;
95+
input: Input;
96+
}
97+
8498
export interface vtkRenderWindowInteractor extends vtkObject {
8599

86100
/**
@@ -678,10 +692,11 @@ export interface vtkRenderWindowInteractor extends vtkObject {
678692
animationEvent(args: any): any;
679693

680694
/**
681-
*
695+
* Triggers the 'Button3D' event.
696+
*
682697
* @param args
683698
*/
684-
button3DEvent(args: any): any;
699+
button3DEvent(eventPayload: IButton3DEvent): void;
685700

686701
/**
687702
*
@@ -804,10 +819,11 @@ export interface vtkRenderWindowInteractor extends vtkObject {
804819
mouseWheelEvent(args: any): any;
805820

806821
/**
807-
*
808-
* @param args
822+
* Triggers the 'Move3D' event.
823+
*
824+
* @param eventPayload
809825
*/
810-
move3DEvent(args: any): any;
826+
move3DEvent(eventPayload: I3DEvent): void;
811827

812828
/**
813829
*

0 commit comments

Comments
 (0)