-
Notifications
You must be signed in to change notification settings - Fork 18
/
types.ts
155 lines (145 loc) · 3.21 KB
/
types.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*!
* Copyright 2021 Cognite AS
*/
import * as THREE from 'three';
/**
* Configuration of {@link AxisViewTool}.
*/
export type AxisBoxConfig = {
/**
* Size in pixels of the axis tool.
*/
size?: number;
/**
* Position, either absolute or relative.
*/
position?: AbsolutePosition | RelativePosition;
/**
* How long the camera animation lasts when
* clicking a face of the orientation box.
*/
animationSpeed?: number;
/**
* Configuration for each of the faces of the orientation box.
* Note that Reveal uses a right-handed Y up coordinate system,
* which might differ from the original model space. To account
* for this, you might want to reassign labels of the faces.
*/
faces?: {
xPositiveFace?: AxisBoxFaceConfig;
xNegativeFace?: AxisBoxFaceConfig;
yPositiveFace?: AxisBoxFaceConfig;
yNegativeFace?: AxisBoxFaceConfig;
zPositiveFace?: AxisBoxFaceConfig;
zNegativeFace?: AxisBoxFaceConfig;
};
/**
* Configuration of the compass "base" of the tool.
*/
compass?: AxisBoxCompassConfig;
};
/**
* Absolute position in pixels.
*/
export type AbsolutePosition = {
xAbsolute: number;
yAbsolute: number;
};
/**
* Relative position from a corner of the viewer
* and a given padding.
*/
export type RelativePosition = {
corner: Corner;
padding: THREE.Vector2;
};
/**
* Configuration of each face of the orientation box.
*/
export type AxisBoxFaceConfig = {
/**
* Label of the respective face, e.g. 'X' or 'Right'.
*/
label?: string;
fontSize?: number;
fontColor?: THREE.Color;
outlineSize?: number;
outlineColor?: THREE.Color;
faceColor?: THREE.Color;
};
/**
* Configuration of the compass.
*/
export type AxisBoxCompassConfig = {
/**
* Label of the orientation indicator. Defaults
* to 'N' for north.
*/
ringLabel?: string;
/**
* Offset in radians of the orientation indicator.
*/
labelDelta?: number;
fontSize?: number;
fontColor?: THREE.Color;
tickColor?: THREE.Color;
};
/**
* A corner of the viewer.
*/
export enum Corner {
TopRight,
TopLeft,
BottomLeft,
BottomRight
}
export const defaultAxisBoxCompassConfig: AxisBoxCompassConfig = {
ringLabel: 'N',
labelDelta: Math.PI,
fontSize: undefined,
fontColor: new THREE.Color(0xff0000),
tickColor: new THREE.Color(0x949494)
};
export const defaultFaceConfig: AxisBoxFaceConfig = {
label: '',
fontSize: undefined,
fontColor: new THREE.Color(0x333333),
outlineSize: undefined,
outlineColor: new THREE.Color(0x333333),
faceColor: new THREE.Color(0x949494)
};
export const defaultAxisBoxConfig: Required<AxisBoxConfig> = {
size: 128,
position: {
corner: Corner.BottomRight,
padding: new THREE.Vector2()
},
animationSpeed: 200,
faces: {
xPositiveFace: {
...defaultFaceConfig,
label: 'Right'
},
xNegativeFace: {
...defaultFaceConfig,
label: 'Left'
},
yPositiveFace: {
...defaultFaceConfig,
label: 'Up'
},
yNegativeFace: {
...defaultFaceConfig,
label: 'Down'
},
zPositiveFace: {
...defaultFaceConfig,
label: 'Front'
},
zNegativeFace: {
...defaultFaceConfig,
label: 'Back'
}
},
compass: defaultAxisBoxCompassConfig
};