/
index.ts
134 lines (126 loc) · 3.7 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import { Group, Mesh, Vector3 } from "three";
/**
* Names for default handles
*/
export enum DEFAULT_HANDLE_GROUP_NAME {
/**
* name for default translation handle along the +ve x-axis
*/
XPT = "xpt_handle",
/**
* name for default translation handle along the +ve y-axis
*/
YPT = "ypt_handle",
/**
* name for default translation handle along the +ve z-axis
*/
ZPT = "zpt_handle",
/**
* name for default translation handle along the -ve x-axis
*/
XNT = "xnt_handle",
/**
* name for default translation handle along the -ve y-axis
*/
YNT = "ynt_handle",
/**
* name for default translation handle along the -ve z-axis
*/
ZNT = "znt_handle",
/**
* name for default rotation handle along the x-axis
*/
XR = "xr_handle",
/**
* name for default rotation handle along the y-axis
*/
YR = "yr_handle",
/**
* name for default rotation handle along the z-axis
*/
ZR = "zr_handle",
/**
* name for default rotation handle in the eye-plane
*/
ER = "er_handle",
/**
* name for default translation handle in the eye-plane
*/
PICK = "pick_handle",
/**
* name for default translation handle in the xy plane
*/
PICK_PLANE_XY = "pick_plane_xy_handle",
/**
* name for default translation handle in the yz plane
*/
PICK_PLANE_YZ = "pick_plane_yz_handle",
/**
* name for default translation handle in the zx plane
*/
PICK_PLANE_ZX = "pick_plane_zx_handle",
}
/**
* Base class for all handles
* @noInheritDoc
*/
export abstract class HandleGroup extends Group {
/**
* returns an array of all the interactive objects that form a handle;
* note that a handle can have non-interactive objects as well.
*/
public abstract getInteractiveObjects(): Mesh[];
/**
* sets the color for the handle; this may involve setting colors for multiple
* constituent meshes that form the handle (interactive or non-interactive)
* @param color - hex code for the color
*/
public abstract setColor(color: string): void;
}
/**
* This class can be extended to create custom translation handles.
* It requires setting the properties `parallel` and `up`.
*/
export abstract class TranslationGroup extends HandleGroup {
/**
* This is a unit vector that runs parallel to the direction of the translation handle.
* For example, in case of [[Controls.translationXP]], it is
* `THREE.Vector3(1,0,0)` (along the x-axis).
*/
public abstract parallel: Vector3;
/**
* This is a unit vector that runs perpendicular to the direction of the translation handles.
* For example, in case of [[Controls.translationXP]], it is
* `THREE.Vector3(0,1,0)` (along the y-axis).
*/
public up = new Vector3();
}
/**
* This class can be extended to create custom rotation handles.
* It requires setting the property `up`.
*/
export abstract class RotationGroup extends HandleGroup {
/**
* This is a unit vector that runs along the axis of the rotation handles.
* For example, in case of [[Controls.rotationX]], it is
* `THREE.Vector3(1,0,0)` (along the x-axis).
*/
public up = new Vector3();
}
/**
* This class can be extended to create custom pick handle (translates in eye-plane).
*/
export abstract class PickGroup extends HandleGroup {}
/**
* This class can be extended to create custom pick plane handles.
* It requires setting the property `up`.
*/
export abstract class PickPlaneGroup extends HandleGroup {
/**
* This is a unit vector that is perpendicular to the plane handles.
* For example, in case of [[Controls.pickPlaneXY]], it is
* `THREE.Vector3(0,0,1)` (along the z-axis).
*/
public up = new Vector3();
}
export type IHandle = RotationGroup | TranslationGroup | PickGroup | PickPlaneGroup;