@kitware/vtk.js 21.5.1 → 21.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CONTRIBUTING.md
CHANGED
|
@@ -62,7 +62,7 @@ Please follow the coding style:
|
|
|
62
62
|
If committing changes to `vtk.js@next` or `vtk.js@next-major`, then set your base branch to be `next`
|
|
63
63
|
or `next-major`, respectively. For more info see the section on release channels below.
|
|
64
64
|
|
|
65
|
-
8. vtk.js uses GitHub for code review and
|
|
65
|
+
8. vtk.js uses GitHub for code review and Github Actions to validate proposed patches before they are merged.
|
|
66
66
|
|
|
67
67
|
## Release Channels
|
|
68
68
|
|
|
@@ -110,7 +110,7 @@ you are satisfied with the staging branch changes, you can then merge into eithe
|
|
|
110
110
|
|
|
111
111
|
To create and debug a test:
|
|
112
112
|
- Create a testFuncNameToTest.js in a "test" folder of the class to test.
|
|
113
|
-
-
|
|
113
|
+
- If you want to run just your test, use `test.only(...)` instead of `test(...)`.
|
|
114
114
|
- Run `npm run test:debug`
|
|
115
115
|
- In the opened window, click the Debug button and place breakpoints in browser debugger.
|
|
116
116
|
|
|
@@ -1,269 +1,318 @@
|
|
|
1
1
|
import { vtkObject } from '@kitware/vtk.js/interfaces';
|
|
2
2
|
|
|
3
3
|
export enum ColorSpace {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
RGB,
|
|
5
|
+
HSV,
|
|
6
|
+
LAB,
|
|
7
|
+
DIVERGING,
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export enum Scale {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
LINEAR,
|
|
12
|
+
LOG10,
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/* TODO: use VtkScalarsToColors instead of VtkObject */
|
|
16
16
|
export interface vtkColorTransferFunction extends vtkObject {
|
|
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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Add a point defined in RGB
|
|
19
|
+
* @param {Number} x The index of the point.
|
|
20
|
+
* @param {Number} r Defines the red component (between 0 and 1).
|
|
21
|
+
* @param {Number} g Defines the green component (between 0 and 1).
|
|
22
|
+
* @param {Number} b Defines the blue component (between 0 and 1).
|
|
23
|
+
*/
|
|
24
|
+
addRGBPoint(x: number, r: number, g: number, b: number): number;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Add a point defined in RGB
|
|
28
|
+
* @param {Number} x The index of the point.
|
|
29
|
+
* @param {Number} r Defines the red component (between 0 and 1).
|
|
30
|
+
* @param {Number} g Defines the green component (between 0 and 1).
|
|
31
|
+
* @param {Number} b Defines the blue component (between 0 and 1).
|
|
32
|
+
* @param {Number} [midpoint]
|
|
33
|
+
* @param {Number} [sharpness]
|
|
34
|
+
*/
|
|
35
|
+
addRGBPointLong(
|
|
36
|
+
x: number,
|
|
37
|
+
r: number,
|
|
38
|
+
g: number,
|
|
39
|
+
b: number,
|
|
40
|
+
midpoint?: number,
|
|
41
|
+
sharpness?: number
|
|
42
|
+
): number;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Add a point defined in HSV
|
|
46
|
+
* @param {Number} x The index of the point.
|
|
47
|
+
* @param {Number} h Defines the hue of the color (between 0 and 1).
|
|
48
|
+
* @param {Number} s Defines the saturation of the color (between 0 and 1).
|
|
49
|
+
* @param {Number} v Defines the value of the color (between 0 and 1).
|
|
50
|
+
*/
|
|
51
|
+
addHSVPoint(x: number, h: number, s: number, v: number): number;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Add a line defined in RGB
|
|
55
|
+
* @param {Number} x1 The index of the first point.
|
|
56
|
+
* @param {Number} r1 Defines the red component of the first point(between 0 and 1).
|
|
57
|
+
* @param {Number} g1 Defines the green component of the first point(between 0 and 1).
|
|
58
|
+
* @param {Number} b1 Defines the red component of the first point (between 0 and 1).
|
|
59
|
+
* @param {Number} x2 The index of the second point.
|
|
60
|
+
* @param {Number} r2 Defines the red component of the second point (between 0 and 1).
|
|
61
|
+
* @param {Number} g2 Defines the green component of the second point (between 0 and 1).
|
|
62
|
+
* @param {Number} b2 Defines the blue component of the second point (between 0 and 1).
|
|
63
|
+
*/
|
|
64
|
+
addRGBSegment(
|
|
65
|
+
x1: number,
|
|
66
|
+
r1: number,
|
|
67
|
+
g1: number,
|
|
68
|
+
b1: number,
|
|
69
|
+
x2: number,
|
|
70
|
+
r2: number,
|
|
71
|
+
g2: number,
|
|
72
|
+
b2: number
|
|
73
|
+
): void;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Add a line defined in HSV
|
|
77
|
+
* @param {Number} x1 The index of the first point.
|
|
78
|
+
* @param {Number} h1 Defines the hue of the color of the first point (between 0 and 1).
|
|
79
|
+
* @param {Number} s1 Defines the saturation of the color of the first point (between 0 and 1).
|
|
80
|
+
* @param {Number} v1 Defines the value of the color of the first point (between 0 and 1).
|
|
81
|
+
* @param {Number} x2 The index of the second point.
|
|
82
|
+
* @param {Number} h2 Defines the hue of the colorof the second point (between 0 and 1).
|
|
83
|
+
* @param {Number} s2 Defines the saturation of the color of the second point (between 0 and 1).
|
|
84
|
+
* @param {Number} v2 Defines the value of the color of the second point (between 0 and 1).
|
|
85
|
+
*/
|
|
86
|
+
addHSVSegment(
|
|
87
|
+
x1: number,
|
|
88
|
+
h1: number,
|
|
89
|
+
s1: number,
|
|
90
|
+
v1: number,
|
|
91
|
+
x2: number,
|
|
92
|
+
h2: number,
|
|
93
|
+
s2: number,
|
|
94
|
+
v2: number
|
|
95
|
+
): void;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Add a point defined in HSV
|
|
99
|
+
* @param {Number} x The index of the point.
|
|
100
|
+
* @param {Number} h Defines the hue of the color (between 0 and 1).
|
|
101
|
+
* @param {Number} s Defines the saturation of the color (between 0 and 1).
|
|
102
|
+
* @param {Number} v Defines the value of the color (between 0 and 1).
|
|
103
|
+
* @param {Number} [midpoint]
|
|
104
|
+
* @param {Number} [sharpness]
|
|
105
|
+
*/
|
|
106
|
+
addHSVPointLong(
|
|
107
|
+
x: number,
|
|
108
|
+
h: number,
|
|
109
|
+
s: number,
|
|
110
|
+
v: number,
|
|
111
|
+
midpoint?: number,
|
|
112
|
+
sharpness?: number
|
|
113
|
+
): number;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Get the number of points which specify this function
|
|
117
|
+
*/
|
|
118
|
+
getSize(): number;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Set nodes directly
|
|
122
|
+
* @param nodes
|
|
123
|
+
*
|
|
124
|
+
* @returns true if a change happen
|
|
125
|
+
*/
|
|
126
|
+
setNodes(nodes: any): boolean;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Sort the vector in increasing order, then fill in
|
|
130
|
+
* the Range
|
|
131
|
+
*
|
|
132
|
+
* @returns true if a change happen
|
|
133
|
+
*/
|
|
134
|
+
sortAndUpdateRange(): boolean;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @returns true if a change happen
|
|
138
|
+
*/
|
|
139
|
+
updateRange(): boolean;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Remove a point
|
|
143
|
+
* @param {Number} x The index of the point.
|
|
144
|
+
*/
|
|
145
|
+
removePoint(x: number): number;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Moves point from oldX to newX.
|
|
149
|
+
*
|
|
150
|
+
* It removed the point from oldX. If any point existed at newX, it will also be removed.
|
|
151
|
+
* @param {Number} oldX The old index of the point.
|
|
152
|
+
* @param {Number} newX The new index of the point.
|
|
153
|
+
*/
|
|
154
|
+
movePoint(oldX: number, newX: number): void;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Remove all points
|
|
158
|
+
*/
|
|
159
|
+
removeAllPoints(): void;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Get the RGBA color evaluated at the specified location
|
|
163
|
+
* @param {Number} x The index of the point.
|
|
164
|
+
*/
|
|
165
|
+
mapValue(x: number): any;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Get the RGB color evaluated at the specified location
|
|
169
|
+
* @param {Number} x The index of the point.
|
|
170
|
+
* @param {Number[]} rgb The Array of the RGB color to fill.
|
|
171
|
+
*/
|
|
172
|
+
getColor(x: number, rgb: number[]): void;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Get the red color evaluated at the specified location
|
|
176
|
+
* @param {Number} x The index of the point.
|
|
177
|
+
*/
|
|
178
|
+
getRedValue(x: number): number;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Get the green color evaluated at the specified location
|
|
182
|
+
* @param {Number} x The index of the point.
|
|
183
|
+
*/
|
|
184
|
+
getGreenValue(x: number): number;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Get the blue color evaluated at the specified location
|
|
188
|
+
* @param {Number} x The index of the point.
|
|
189
|
+
*/
|
|
190
|
+
getBlueValue(x: number): number;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Get a table of RGB colors at regular intervals along the function
|
|
194
|
+
* @param {Number} xStart The index of the first point.
|
|
195
|
+
* @param {Number} xEnd The index of the second point.
|
|
196
|
+
* @param {Number} size
|
|
197
|
+
* @param {Number[]} table
|
|
198
|
+
*/
|
|
199
|
+
getTable(xStart: number, xEnd: number, size: number, table: number[]): void;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @param {Number} xStart The index of the first point.
|
|
203
|
+
* @param {Number} xEnd The index of the first point.
|
|
204
|
+
* @param {Number} size
|
|
205
|
+
* @param {Boolean} withAlpha
|
|
206
|
+
*/
|
|
207
|
+
getUint8Table(
|
|
208
|
+
xStart: number,
|
|
209
|
+
xEnd: number,
|
|
210
|
+
size: number,
|
|
211
|
+
withAlpha: boolean
|
|
212
|
+
): Float32Array;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Construct a color transfer function from a table.
|
|
216
|
+
* @param {Number} xStart The index of the first point.
|
|
217
|
+
* @param {Number} xEnd The index of the first point.
|
|
218
|
+
* @param {Number} size
|
|
219
|
+
* @param {Number[]} table
|
|
220
|
+
*/
|
|
221
|
+
buildFunctionFromTable(
|
|
222
|
+
xStart: number,
|
|
223
|
+
xEnd: number,
|
|
224
|
+
size: number,
|
|
225
|
+
table: number[]
|
|
226
|
+
): void;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* For the node specified by index, set/get the location (X), R, G, and B
|
|
230
|
+
* values, midpoint, and sharpness values at the node.
|
|
231
|
+
* @param {Number} index
|
|
232
|
+
* @param {Number[]} val
|
|
233
|
+
*/
|
|
234
|
+
getNodeValue(index: number, val: number[]): number;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* For a specified index value, set the node parameters
|
|
238
|
+
* @param {Number} index
|
|
239
|
+
* @param {Number[]} val
|
|
240
|
+
*/
|
|
241
|
+
setNodeValue(index: number, val: number[]): number;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Get the number of available colors for mapping to.
|
|
245
|
+
*/
|
|
246
|
+
getNumberOfAvailableColors(): number;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Get the color given an integer index.
|
|
250
|
+
* @param {Number} idx The index of the point.
|
|
251
|
+
* @param {Number[]} rgba An Array of the RGBA color.
|
|
252
|
+
*/
|
|
253
|
+
getIndexedColor(idx: number, rgba: number[]): void;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Defines the nodes from an array ptr with the layout [X1, R1, G1, B1, X2,
|
|
257
|
+
* R2, G2, B2, ..., Xn, Rn, Gn, Bn] where n is the number of nodes.
|
|
258
|
+
* @param {Number} nb
|
|
259
|
+
* @param ptr
|
|
260
|
+
*/
|
|
261
|
+
fillFromDataPointer(nb: number, ptr: any): void;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Set the range of scalars being mapped.
|
|
265
|
+
* @param {Number} min
|
|
266
|
+
* @param {Number} max
|
|
267
|
+
*/
|
|
268
|
+
setMappingRange(min: number, max: number): void;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Remove all points out of the new range, and make sure there is a point at
|
|
272
|
+
* each end of that range.
|
|
273
|
+
* @param {Number[]} range
|
|
274
|
+
*/
|
|
275
|
+
adjustRange(range: number[]): number;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Estimates the minimum size of a table such that it would correctly sample this function.
|
|
279
|
+
* @param {Number} x1
|
|
280
|
+
* @param {Number} x2
|
|
281
|
+
*/
|
|
282
|
+
estimateMinNumberOfSamples(x1: number, x2: number): number;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Traverses the nodes to find the minimum distance.
|
|
286
|
+
*/
|
|
287
|
+
findMinimumXDistance(): number;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
*
|
|
291
|
+
* @param input
|
|
292
|
+
* @param output
|
|
293
|
+
* @param outFormat
|
|
294
|
+
* @param inputOffset
|
|
295
|
+
*/
|
|
296
|
+
mapScalarsThroughTable(
|
|
297
|
+
input: any,
|
|
298
|
+
output: any,
|
|
299
|
+
outFormat: any,
|
|
300
|
+
inputOffset: any
|
|
301
|
+
): void;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Map a set of scalars through the lookup table.
|
|
305
|
+
* @param input
|
|
306
|
+
* @param output
|
|
307
|
+
* @param outFormat
|
|
308
|
+
* @param inputOffset
|
|
309
|
+
*/
|
|
310
|
+
mapData(input: any, output: any, outFormat: any, inputOffset: any): void;
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* @param colorMap
|
|
314
|
+
*/
|
|
315
|
+
applyColorMap(colorMap: any): void;
|
|
267
316
|
}
|
|
268
317
|
|
|
269
318
|
/**
|
|
@@ -273,7 +322,11 @@ export interface vtkColorTransferFunction extends vtkObject {
|
|
|
273
322
|
* @param model object on which data structure will be bounds (protected)
|
|
274
323
|
* @param {object} [initialValues] (default: {})
|
|
275
324
|
*/
|
|
276
|
-
export function extend(
|
|
325
|
+
export function extend(
|
|
326
|
+
publicAPI: object,
|
|
327
|
+
model: object,
|
|
328
|
+
initialValues?: object
|
|
329
|
+
): void;
|
|
277
330
|
|
|
278
331
|
/**
|
|
279
332
|
* Method use to create a new instance of vtkColorTransferFunction
|
|
@@ -303,7 +356,7 @@ export function newInstance(initialValues?: object): vtkColorTransferFunction;
|
|
|
303
356
|
*/
|
|
304
357
|
|
|
305
358
|
export declare const vtkColorTransferFunction: {
|
|
306
|
-
|
|
307
|
-
|
|
359
|
+
newInstance: typeof newInstance;
|
|
360
|
+
extend: typeof extend;
|
|
308
361
|
};
|
|
309
362
|
export default vtkColorTransferFunction;
|
|
@@ -22,6 +22,19 @@ var SCREENSHOT_PLACEHOLDER = {
|
|
|
22
22
|
width: '100%',
|
|
23
23
|
height: '100%'
|
|
24
24
|
};
|
|
25
|
+
var DEFAULT_RESET_FACTORS = {
|
|
26
|
+
vr: {
|
|
27
|
+
rescaleFactor: 1.0,
|
|
28
|
+
translateZ: -0.7 // 0.7 m forward from the camera
|
|
29
|
+
|
|
30
|
+
},
|
|
31
|
+
ar: {
|
|
32
|
+
rescaleFactor: 0.25,
|
|
33
|
+
// scale down AR for viewing comfort by default
|
|
34
|
+
translateZ: -0.5 // 0.5 m forward from the camera
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
};
|
|
25
38
|
|
|
26
39
|
function checkRenderTargetSupport(gl, format, type) {
|
|
27
40
|
// create temporary frame buffer and texture
|
|
@@ -283,7 +296,7 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
|
|
|
283
296
|
model.oldCanvasSize = model.size.slice();
|
|
284
297
|
|
|
285
298
|
if (!(model.xrSession !== null)) {
|
|
286
|
-
_context.next =
|
|
299
|
+
_context.next = 15;
|
|
287
300
|
break;
|
|
288
301
|
}
|
|
289
302
|
|
|
@@ -300,15 +313,16 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
|
|
|
300
313
|
model.xrSession.requestReferenceSpace('local').then(function (refSpace) {
|
|
301
314
|
model.xrReferenceSpace = refSpace;
|
|
302
315
|
});
|
|
316
|
+
publicAPI.resetXRScene();
|
|
303
317
|
model.renderable.getInteractor().switchToXRAnimation();
|
|
304
318
|
model.xrSceneFrame = model.xrSession.requestAnimationFrame(publicAPI.xrRender);
|
|
305
|
-
_context.next =
|
|
319
|
+
_context.next = 16;
|
|
306
320
|
break;
|
|
307
321
|
|
|
308
|
-
case
|
|
322
|
+
case 15:
|
|
309
323
|
throw new Error('Failed to enter VR with a null xrSession.');
|
|
310
324
|
|
|
311
|
-
case
|
|
325
|
+
case 16:
|
|
312
326
|
case "end":
|
|
313
327
|
return _context.stop();
|
|
314
328
|
}
|
|
@@ -321,6 +335,36 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
|
|
|
321
335
|
};
|
|
322
336
|
}();
|
|
323
337
|
|
|
338
|
+
publicAPI.resetXRScene = function () {
|
|
339
|
+
var inputRescaleFactor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_RESET_FACTORS.vr.rescaleFactor;
|
|
340
|
+
var inputTranslateZ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_RESET_FACTORS.vr.translateZ;
|
|
341
|
+
// Adjust world-to-physical parameters for different modalities
|
|
342
|
+
// Default parameter values are for VR (model.xrSessionIsAR == false)
|
|
343
|
+
var rescaleFactor = inputRescaleFactor;
|
|
344
|
+
var translateZ = inputTranslateZ;
|
|
345
|
+
|
|
346
|
+
if (model.xrSessionIsAR && rescaleFactor === DEFAULT_RESET_FACTORS.vr.rescaleFactor) {
|
|
347
|
+
// Scale down by default in AR
|
|
348
|
+
rescaleFactor = DEFAULT_RESET_FACTORS.ar.rescaleFactor;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (model.xrSessionIsAR && translateZ === DEFAULT_RESET_FACTORS.vr.translateZ) {
|
|
352
|
+
// Default closer to the camera in AR
|
|
353
|
+
translateZ = DEFAULT_RESET_FACTORS.ar.translateZ;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
var ren = model.renderable.getRenderers()[0];
|
|
357
|
+
ren.resetCamera();
|
|
358
|
+
var camera = ren.getActiveCamera();
|
|
359
|
+
var physicalScale = camera.getPhysicalScale();
|
|
360
|
+
var physicalTranslation = camera.getPhysicalTranslation();
|
|
361
|
+
physicalScale /= rescaleFactor;
|
|
362
|
+
translateZ *= physicalScale;
|
|
363
|
+
physicalTranslation[2] += translateZ;
|
|
364
|
+
camera.setPhysicalScale(physicalScale);
|
|
365
|
+
camera.setPhysicalTranslation(physicalTranslation);
|
|
366
|
+
};
|
|
367
|
+
|
|
324
368
|
publicAPI.stopXR = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
325
369
|
var gl, ren;
|
|
326
370
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|