@kitware/vtk.js 22.1.5 → 22.2.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/IO/Core/ImageStream/DefaultProtocol.d.ts +8 -8
- package/IO/Core/ImageStream.d.ts +17 -15
- package/Interaction/Manipulators/MouseBoxSelectorManipulator.js +12 -9
- package/Rendering/Core/RenderWindowInteractor.js +3 -13
- package/Rendering/Core/ScalarBarActor.d.ts +39 -3
- package/Rendering/Core/ScalarBarActor.js +28 -8
- package/Rendering/Misc/SynchronizableRenderWindow.d.ts +73 -0
- package/Rendering/OpenGL/RenderWindow.d.ts +107 -106
- package/Rendering/OpenGL/VolumeMapper.js +64 -68
- package/package.json +1 -1
|
@@ -3,23 +3,23 @@ import { Size, Vector3 } from '@kitware/vtk.js/types';
|
|
|
3
3
|
declare function createMethods(session: any): {
|
|
4
4
|
subscribeToImageStream: (callback: any) => any;
|
|
5
5
|
unsubscribeToImageStream: (subscription: any) => any;
|
|
6
|
-
registerView: (viewId:
|
|
7
|
-
unregisterView: (viewId:
|
|
8
|
-
enableView: (viewId:
|
|
6
|
+
registerView: (viewId: string) => any;
|
|
7
|
+
unregisterView: (viewId: string) => any;
|
|
8
|
+
enableView: (viewId: string, enabled: boolean) => any;
|
|
9
9
|
render: (options?: {
|
|
10
10
|
size: Size;
|
|
11
11
|
view: number;
|
|
12
12
|
}) => any;
|
|
13
13
|
resetCamera: (view?: number) => any;
|
|
14
|
-
invalidateCache: (viewId:
|
|
15
|
-
setQuality: (viewId:
|
|
16
|
-
setSize: (viewId:
|
|
14
|
+
invalidateCache: (viewId: string) => any;
|
|
15
|
+
setQuality: (viewId: string, quality: number, ratio?: number) => any;
|
|
16
|
+
setSize: (viewId: string, width?: number, height?: number) => any;
|
|
17
17
|
setServerAnimationFPS: (fps?: number) => any;
|
|
18
18
|
getServerAnimationFPS: () => number;
|
|
19
19
|
startAnimation: (viewId?: number) => any;
|
|
20
20
|
stopAnimation: (viewId?: number) => any;
|
|
21
|
-
updateCamera: (viewId:
|
|
21
|
+
updateCamera: (viewId: string, focalPoint: Vector3, viewUp: Vector3, position: Vector3, forceUpdate?: boolean) => any;
|
|
22
22
|
updateCameraParameters: (viewId?: number, parameters?: {}, forceUpdate?: boolean) => any;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export default createMethods;
|
|
25
|
+
export default createMethods;
|
package/IO/Core/ImageStream.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { vtkObject } from '@kitware/vtk.js/interfaces';
|
|
2
2
|
import { Size } from '@kitware/vtk.js/types';
|
|
3
|
-
|
|
3
|
+
import vtkViewStream from '@kitware/vtk.js/IO/Core/ImageStream/ViewStream';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
*
|
|
@@ -10,54 +10,56 @@ export interface IImageStreamInitialValues {
|
|
|
10
10
|
serverAnimationFPS?: number,
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
// Return type of wslink/src/WebsocketConnection, getSession() method.
|
|
14
|
+
type WebsocketSession = any;
|
|
13
15
|
|
|
14
16
|
export interface vtkImageStream extends vtkObject {
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
|
-
*
|
|
19
|
+
*
|
|
18
20
|
*/
|
|
19
|
-
connect(): void;
|
|
21
|
+
connect(session: WebsocketSession): void;
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
|
-
*
|
|
23
|
-
* @param {
|
|
24
|
-
* @param {Size} [size] The size of the view.
|
|
24
|
+
*
|
|
25
|
+
* @param {String} [viewId] The ID of the view.
|
|
26
|
+
* @param {Size} [size] The size of the view.
|
|
25
27
|
*/
|
|
26
|
-
createViewStream(viewId?:
|
|
28
|
+
createViewStream(viewId?: string, size?: Size): vtkViewStream;
|
|
27
29
|
|
|
28
30
|
/**
|
|
29
|
-
*
|
|
31
|
+
*
|
|
30
32
|
*/
|
|
31
33
|
delete(): void;
|
|
32
34
|
|
|
33
35
|
/**
|
|
34
|
-
*
|
|
36
|
+
*
|
|
35
37
|
*/
|
|
36
38
|
disconnect(): void;
|
|
37
39
|
|
|
38
40
|
/**
|
|
39
|
-
*
|
|
41
|
+
*
|
|
40
42
|
*/
|
|
41
43
|
getProtocol(): any;
|
|
42
44
|
|
|
43
45
|
/**
|
|
44
|
-
*
|
|
46
|
+
*
|
|
45
47
|
*/
|
|
46
48
|
getServerAnimationFPS(): number;
|
|
47
49
|
|
|
48
50
|
/**
|
|
49
|
-
*
|
|
51
|
+
*
|
|
50
52
|
*/
|
|
51
53
|
registerViewStream(): void;
|
|
52
54
|
|
|
53
55
|
/**
|
|
54
|
-
*
|
|
55
|
-
* @param serverAnimationFPS
|
|
56
|
+
*
|
|
57
|
+
* @param serverAnimationFPS
|
|
56
58
|
*/
|
|
57
59
|
setServerAnimationFPS(serverAnimationFPS: number): boolean;
|
|
58
60
|
|
|
59
61
|
/**
|
|
60
|
-
*
|
|
62
|
+
*
|
|
61
63
|
*/
|
|
62
64
|
unregisterViewStream(): void;
|
|
63
65
|
}
|
|
@@ -56,9 +56,7 @@ function vtkMouseBoxSelectionManipulator(publicAPI, model) {
|
|
|
56
56
|
|
|
57
57
|
var _container$getBoundin = container.getBoundingClientRect(),
|
|
58
58
|
width = _container$getBoundin.width,
|
|
59
|
-
height = _container$getBoundin.height
|
|
60
|
-
top = _container$getBoundin.top,
|
|
61
|
-
left = _container$getBoundin.left;
|
|
59
|
+
height = _container$getBoundin.height;
|
|
62
60
|
|
|
63
61
|
var _getBounds = getBounds(),
|
|
64
62
|
_getBounds2 = _slicedToArray(_getBounds, 4),
|
|
@@ -67,10 +65,8 @@ function vtkMouseBoxSelectionManipulator(publicAPI, model) {
|
|
|
67
65
|
yMin = _getBounds2[2],
|
|
68
66
|
yMax = _getBounds2[3];
|
|
69
67
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
div.style.left = "".concat(xShift + width * xMin / viewWidth, "px");
|
|
73
|
-
div.style.top = "".concat(yShift + height - height * yMax / viewHeight, "px");
|
|
68
|
+
div.style.left = "".concat(width * xMin / viewWidth, "px");
|
|
69
|
+
div.style.top = "".concat(height - height * yMax / viewHeight, "px");
|
|
74
70
|
div.style.width = "".concat(width * (xMax - xMin) / viewWidth, "px");
|
|
75
71
|
div.style.height = "".concat(height * (yMax - yMin) / viewHeight, "px");
|
|
76
72
|
} //-------------------------------------------------------------------------
|
|
@@ -80,15 +76,21 @@ function vtkMouseBoxSelectionManipulator(publicAPI, model) {
|
|
|
80
76
|
previousPosition = position;
|
|
81
77
|
|
|
82
78
|
if (model.renderSelection) {
|
|
79
|
+
var _view;
|
|
80
|
+
|
|
83
81
|
// Need window size and location to convert to style
|
|
84
82
|
if (!view) {
|
|
85
83
|
view = interactor.getView();
|
|
86
84
|
}
|
|
87
85
|
|
|
88
|
-
if (!container && view) {
|
|
86
|
+
if (!container && (_view = view) !== null && _view !== void 0 && _view.getContainer) {
|
|
89
87
|
container = view.getContainer();
|
|
90
88
|
}
|
|
91
89
|
|
|
90
|
+
if (!container) {
|
|
91
|
+
container = model.container;
|
|
92
|
+
}
|
|
93
|
+
|
|
92
94
|
if (!div) {
|
|
93
95
|
div = document.createElement('div');
|
|
94
96
|
applyStyle(div, model.selectionStyle);
|
|
@@ -155,6 +157,7 @@ function vtkMouseBoxSelectionManipulator(publicAPI, model) {
|
|
|
155
157
|
|
|
156
158
|
function DEFAULT_VALUES(initialValues) {
|
|
157
159
|
return _objectSpread(_objectSpread({
|
|
160
|
+
// container: null,
|
|
158
161
|
renderSelection: true
|
|
159
162
|
}, initialValues), {}, {
|
|
160
163
|
selectionStyle: _objectSpread(_objectSpread({}, DEFAULT_STYLE), initialValues.selectionStyle)
|
|
@@ -172,7 +175,7 @@ function extend(publicAPI, model) {
|
|
|
172
175
|
|
|
173
176
|
event(publicAPI, model, 'BoxSelectInput'); // Trigger while dragging
|
|
174
177
|
|
|
175
|
-
setGet(publicAPI, model, ['renderSelection', 'selectionStyle']); // Object specific methods
|
|
178
|
+
setGet(publicAPI, model, ['renderSelection', 'selectionStyle', 'container']); // Object specific methods
|
|
176
179
|
|
|
177
180
|
vtkMouseBoxSelectionManipulator(publicAPI, model);
|
|
178
181
|
} // ----------------------------------------------------------------------------
|
|
@@ -328,8 +328,6 @@ function vtkRenderWindowInteractor(publicAPI, model) {
|
|
|
328
328
|
if (animationRequesters.size === 1 && !model.xrAnimation) {
|
|
329
329
|
model._animationStartTime = Date.now();
|
|
330
330
|
model._animationFrameCount = 0;
|
|
331
|
-
model.lastFrameTime = 0.1;
|
|
332
|
-
model.lastFrameStart = Date.now();
|
|
333
331
|
model.animationRequest = requestAnimationFrame(publicAPI.handleAnimation);
|
|
334
332
|
publicAPI.startAnimationEvent();
|
|
335
333
|
}
|
|
@@ -375,7 +373,7 @@ function vtkRenderWindowInteractor(publicAPI, model) {
|
|
|
375
373
|
model.xrAnimation = false;
|
|
376
374
|
|
|
377
375
|
if (animationRequesters.size !== 0) {
|
|
378
|
-
model.
|
|
376
|
+
model.recentAnimationFrameRate = 10.0;
|
|
379
377
|
model.animationRequest = requestAnimationFrame(publicAPI.handleAnimation);
|
|
380
378
|
}
|
|
381
379
|
};
|
|
@@ -456,19 +454,12 @@ function vtkRenderWindowInteractor(publicAPI, model) {
|
|
|
456
454
|
|
|
457
455
|
if (currTime - model._animationStartTime > 1000.0 && model._animationFrameCount > 1) {
|
|
458
456
|
model.recentAnimationFrameRate = 1000.0 * (model._animationFrameCount - 1) / (currTime - model._animationStartTime);
|
|
457
|
+
model.lastFrameTime = 1.0 / model.recentAnimationFrameRate;
|
|
459
458
|
publicAPI.animationFrameRateUpdateEvent();
|
|
460
459
|
model._animationStartTime = currTime;
|
|
461
460
|
model._animationFrameCount = 1;
|
|
462
461
|
}
|
|
463
462
|
|
|
464
|
-
if (model.FrameTime === -1.0) {
|
|
465
|
-
model.lastFrameTime = 0.1;
|
|
466
|
-
} else {
|
|
467
|
-
model.lastFrameTime = (currTime - model.lastFrameStart) / 1000.0;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
model.lastFrameTime = Math.max(0.01, model.lastFrameTime);
|
|
471
|
-
model.lastFrameStart = currTime;
|
|
472
463
|
publicAPI.animationEvent();
|
|
473
464
|
forceRender();
|
|
474
465
|
model.animationRequest = requestAnimationFrame(publicAPI.handleAnimation);
|
|
@@ -933,7 +924,6 @@ function vtkRenderWindowInteractor(publicAPI, model) {
|
|
|
933
924
|
};
|
|
934
925
|
|
|
935
926
|
publicAPI.handleVisibilityChange = function () {
|
|
936
|
-
model.lastFrameStart = Date.now();
|
|
937
927
|
model._animationStartTime = Date.now();
|
|
938
928
|
model._animationFrameCount = 0;
|
|
939
929
|
};
|
|
@@ -957,7 +947,7 @@ function vtkRenderWindowInteractor(publicAPI, model) {
|
|
|
957
947
|
|
|
958
948
|
superDelete();
|
|
959
949
|
}; // Use the Page Visibility API to detect when we switch away from or back to
|
|
960
|
-
// this tab, and reset the
|
|
950
|
+
// this tab, and reset the animationFrameStart. When tabs are not active, browsers
|
|
961
951
|
// will stop calling requestAnimationFrame callbacks.
|
|
962
952
|
|
|
963
953
|
|
|
@@ -38,7 +38,10 @@ export interface IScalarBarActorInitialValues extends IActorInitialValues {
|
|
|
38
38
|
axisTitlePixelOffset?: number,
|
|
39
39
|
axisTextStyle?: IStyle,
|
|
40
40
|
tickLabelPixelOffset?: number,
|
|
41
|
-
tickTextStyle?: IStyle
|
|
41
|
+
tickTextStyle?: IStyle,
|
|
42
|
+
drawNanAnnotation?: boolean,
|
|
43
|
+
drawBelowRangeSwatch?: boolean,
|
|
44
|
+
drawAboveRangeSwatch?: boolean,
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
export interface vtkScalarBarActor extends vtkActor {
|
|
@@ -135,6 +138,21 @@ export interface vtkScalarBarActor extends vtkActor {
|
|
|
135
138
|
*/
|
|
136
139
|
getScalarsToColors(): vtkScalarsToColors;
|
|
137
140
|
|
|
141
|
+
/**
|
|
142
|
+
*
|
|
143
|
+
*/
|
|
144
|
+
getDrawNanAnnotation(): boolean
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
*
|
|
148
|
+
*/
|
|
149
|
+
getDrawBelowRangeSwatch(): boolean
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
*
|
|
153
|
+
*/
|
|
154
|
+
getDrawAboveRangeSwatch(): boolean
|
|
155
|
+
|
|
138
156
|
/**
|
|
139
157
|
*
|
|
140
158
|
*/
|
|
@@ -212,8 +230,26 @@ export interface vtkScalarBarActor extends vtkActor {
|
|
|
212
230
|
setScalarsToColors(scalarsToColors: vtkScalarsToColors): boolean;
|
|
213
231
|
|
|
214
232
|
/**
|
|
215
|
-
*
|
|
216
|
-
* @param
|
|
233
|
+
* Set whether the NaN annotation should be rendered or not.
|
|
234
|
+
* @param {Boolean} drawNanAnnotation
|
|
235
|
+
*/
|
|
236
|
+
setDrawNanAnnotation(drawNanAnnotation: boolean): boolean;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Set whether the Below range swatch should be rendered or not
|
|
240
|
+
* @param {Boolean} drawBelowRangeSwatch
|
|
241
|
+
*/
|
|
242
|
+
setDrawBelowRangeSwatch(drawBelowRangeSwatch: boolean): boolean;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Set whether the Above range swatch should be rendered or not
|
|
246
|
+
* @param {Boolean} drawAboveRangeSwatch
|
|
247
|
+
*/
|
|
248
|
+
setDrawAboveRangeSwatch(drawAboveRangeSwatch: boolean): boolean;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
*
|
|
252
|
+
* @param tickLabelPixelOffset
|
|
217
253
|
*/
|
|
218
254
|
setTickLabelPixelOffset(tickLabelPixelOffset: number): boolean;
|
|
219
255
|
|
|
@@ -319,6 +319,8 @@ function vtkScalarBarActor(publicAPI, model) {
|
|
|
319
319
|
|
|
320
320
|
|
|
321
321
|
publicAPI.recomputeBarSegments = function (textSizes) {
|
|
322
|
+
var _model$scalarsToColor, _model$scalarsToColor2, _model$scalarsToColor3, _model$scalarsToColor4;
|
|
323
|
+
|
|
322
324
|
// first compute the barSize/Position
|
|
323
325
|
var segSize = publicAPI.computeBarSize(textSizes);
|
|
324
326
|
model.barSegments = [];
|
|
@@ -337,22 +339,22 @@ function vtkScalarBarActor(publicAPI, model) {
|
|
|
337
339
|
startPos[barAxis] += segSize[barAxis] + segSpace;
|
|
338
340
|
}
|
|
339
341
|
|
|
340
|
-
if (
|
|
342
|
+
if (model.drawNanAnnotation && model.scalarsToColors.getNanColor) {
|
|
341
343
|
pushSeg('NaN', [NaN, NaN, NaN, NaN]);
|
|
342
344
|
}
|
|
343
345
|
|
|
344
|
-
if (
|
|
346
|
+
if (model.drawBelowRangeSwatch && (_model$scalarsToColor = (_model$scalarsToColor2 = model.scalarsToColors).getUseBelowRangeColor) !== null && _model$scalarsToColor !== void 0 && _model$scalarsToColor.call(_model$scalarsToColor2)) {
|
|
345
347
|
pushSeg('Below', [-0.1, -0.1, -0.1, -0.1]);
|
|
346
348
|
}
|
|
347
349
|
|
|
348
|
-
var haveAbove =
|
|
350
|
+
var haveAbove = (_model$scalarsToColor3 = (_model$scalarsToColor4 = model.scalarsToColors).getUseAboveRangeColor) === null || _model$scalarsToColor3 === void 0 ? void 0 : _model$scalarsToColor3.call(_model$scalarsToColor4); // extra space around the ticks section
|
|
349
351
|
|
|
350
352
|
startPos[barAxis] += segSpace;
|
|
351
353
|
var oldSegSize = segSize[barAxis];
|
|
352
354
|
segSize[barAxis] = haveAbove ? 1.0 - 2.0 * segSpace - segSize[barAxis] - startPos[barAxis] : 1.0 - segSpace - startPos[barAxis];
|
|
353
355
|
pushSeg('ticks', model.vertical ? [0, 0, 0.995, 0.995] : [0, 0.995, 0.995, 0]);
|
|
354
356
|
|
|
355
|
-
if (haveAbove) {
|
|
357
|
+
if (model.drawAboveRangeSwatch && haveAbove) {
|
|
356
358
|
segSize[barAxis] = oldSegSize;
|
|
357
359
|
startPos[barAxis] += segSpace;
|
|
358
360
|
pushSeg('Above', [1.1, 1.1, 1.1, 1.1]);
|
|
@@ -551,11 +553,26 @@ function vtkScalarBarActor(publicAPI, model) {
|
|
|
551
553
|
};
|
|
552
554
|
|
|
553
555
|
publicAPI.updatePolyDataForBarSegments = function () {
|
|
556
|
+
var _model$scalarsToColor5, _model$scalarsToColor6, _model$scalarsToColor7, _model$scalarsToColor8;
|
|
557
|
+
|
|
554
558
|
var cmat = model.camera.getCompositeProjectionMatrix(model.lastAspectRatio, -1, 1);
|
|
555
559
|
mat4.transpose(cmat, cmat);
|
|
556
560
|
mat4.invert(invmat, cmat);
|
|
557
|
-
var
|
|
558
|
-
|
|
561
|
+
var numberOfExtraColors = 0;
|
|
562
|
+
|
|
563
|
+
if (model.drawNanAnnotation && model.scalarsToColors.getNanColor) {
|
|
564
|
+
numberOfExtraColors += 1;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
if (model.drawBelowRangeSwatch && (_model$scalarsToColor5 = (_model$scalarsToColor6 = model.scalarsToColors).getUseBelowRangeColor) !== null && _model$scalarsToColor5 !== void 0 && _model$scalarsToColor5.call(_model$scalarsToColor6)) {
|
|
568
|
+
numberOfExtraColors += 1;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
if (model.drawAboveRangeSwatch && (_model$scalarsToColor7 = (_model$scalarsToColor8 = model.scalarsToColors).getUseAboveRangeColor) !== null && _model$scalarsToColor7 !== void 0 && _model$scalarsToColor7.call(_model$scalarsToColor8)) {
|
|
572
|
+
numberOfExtraColors += 1;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
var numPts = 4 * (1 + numberOfExtraColors);
|
|
559
576
|
var numQuads = numPts; // handle vector component mode
|
|
560
577
|
|
|
561
578
|
var numComps = 1;
|
|
@@ -667,7 +684,10 @@ function defaultValues(initialValues) {
|
|
|
667
684
|
fontStyle: 'normal',
|
|
668
685
|
fontSize: 14,
|
|
669
686
|
fontFamily: 'serif'
|
|
670
|
-
}
|
|
687
|
+
},
|
|
688
|
+
drawNanAnnotation: true,
|
|
689
|
+
drawBelowRangeSwatch: true,
|
|
690
|
+
drawAboveRangeSwatch: true
|
|
671
691
|
}, initialValues);
|
|
672
692
|
} // ----------------------------------------------------------------------------
|
|
673
693
|
|
|
@@ -738,7 +758,7 @@ function extend(publicAPI, model) {
|
|
|
738
758
|
|
|
739
759
|
publicAPI.update();
|
|
740
760
|
});
|
|
741
|
-
macro.setGet(publicAPI, model, ['automated', 'autoLayout', 'axisTitlePixelOffset', 'axisLabel', 'scalarsToColors', 'tickLabelPixelOffset']);
|
|
761
|
+
macro.setGet(publicAPI, model, ['automated', 'autoLayout', 'axisTitlePixelOffset', 'axisLabel', 'scalarsToColors', 'tickLabelPixelOffset', 'drawNanAnnotation', 'drawBelowRangeSwatch', 'drawAboveRangeSwatch']);
|
|
742
762
|
macro.get(publicAPI, model, ['axisTextStyle', 'tickTextStyle']);
|
|
743
763
|
macro.getArray(publicAPI, model, ['boxPosition', 'boxSize']);
|
|
744
764
|
macro.setArray(publicAPI, model, ['boxPosition', 'boxSize'], 2); // Object methods
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { vtkRenderWindow, IRenderWindowInitialValues } from '@kitware/vtk.js/Rendering/Rendering/Core/RenderWindow';
|
|
2
|
+
|
|
3
|
+
// Keeps state for client / server scene synchronization.
|
|
4
|
+
export interface SynchContext {
|
|
5
|
+
// Set a function that fetches the data array for the given object.
|
|
6
|
+
setFetchArrayFunction(fetcher: (hash: string, dataType: any) => Promise<ArrayBuffer>): void;
|
|
7
|
+
// Invokes the fetcher registered by setFetchArrayFunction.
|
|
8
|
+
getArray(sha: string, dataType: any, context: SynchContext): Promise<ArrayBuffer>;
|
|
9
|
+
emptyCachedArrays(): void;
|
|
10
|
+
freeOldArrays(threshold: number, context: SynchContext): void;
|
|
11
|
+
|
|
12
|
+
// instanceMap
|
|
13
|
+
getInstance(id: any): any;
|
|
14
|
+
getInstanceId(instance: any): any | null;
|
|
15
|
+
registerInstance(id: any, instance: any): void;
|
|
16
|
+
unregister(id: any): void;
|
|
17
|
+
emptyCachedInstances(): void;
|
|
18
|
+
|
|
19
|
+
// sceneMtimeHandler
|
|
20
|
+
getMtime(): number;
|
|
21
|
+
incrementMtime(viewId: string): number;
|
|
22
|
+
setActiveViewId(viewId: string): void;
|
|
23
|
+
getActiveViewId(): string;
|
|
24
|
+
|
|
25
|
+
// TODO: fill progresshandler
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface IInitialValues extends IRenderWindowInitialValues {
|
|
29
|
+
synchronizerContextName?: string; // default: 'default':
|
|
30
|
+
synchronizerContext?: SynchContext | null;
|
|
31
|
+
synchronizedViewId?: string | null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Server-side view state.
|
|
35
|
+
export interface ViewState {
|
|
36
|
+
id: ViewId;
|
|
37
|
+
// vtk object type.
|
|
38
|
+
type: string;
|
|
39
|
+
// vtk object mtime.
|
|
40
|
+
mtime: number;
|
|
41
|
+
// ID of the parent. Null for the root.
|
|
42
|
+
parent?: string | null;
|
|
43
|
+
properties?: {[key: string]: any};
|
|
44
|
+
// Child objects.
|
|
45
|
+
dependencies?: ViewState[];
|
|
46
|
+
extra?: any;
|
|
47
|
+
// List of [methodName, args] to be invoked on the object.
|
|
48
|
+
calls?: [string, string[]][];
|
|
49
|
+
// ViewState may contain other arbitrary key / value pairs.
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface vtkSynchronizableRenderWindowInstance extends vtkRenderWindow {
|
|
54
|
+
getSynchronizerContext(): SynchContext;
|
|
55
|
+
|
|
56
|
+
// methods added by createSyncFunction
|
|
57
|
+
synchronize(state: ViewState): Promise<boolean>;
|
|
58
|
+
setSynchronizedViewId(viewId: string): void;
|
|
59
|
+
getSynchronizedViewId(): string;
|
|
60
|
+
updateGarbageCollectorThreshold(v: number): void;
|
|
61
|
+
getManagedInstanceIds(): Array<string>;
|
|
62
|
+
clearOneTimeUpdaters(): void;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function newInstance(props: IInitialValues): vtkSynchronizableRenderWindowInstance;
|
|
66
|
+
export function getSynchronizerContext(name?: string): SynchContext;
|
|
67
|
+
|
|
68
|
+
export const vtkSynchronizableRenderWindow: {
|
|
69
|
+
newInstance: typeof newInstance;
|
|
70
|
+
getSynchronizerContext: typeof getSynchronizerContext;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export default vtkSynchronizableRenderWindow;
|
|
@@ -3,6 +3,7 @@ import { Size, Vector2, Vector3 } from '@kitware/vtk.js/types';
|
|
|
3
3
|
import { vtkRenderer } from '@kitware/vtk.js/Rendering/Core/Renderer';
|
|
4
4
|
import { VtkDataTypes } from '@kitware/vtk.js/Common/Core/DataArray';
|
|
5
5
|
import vtkTexture from '@kitware/vtk.js/Rendering/Core/Texture';
|
|
6
|
+
import vtkViewStream from '@kitware/vtk.js/IO/Core/ImageStream/ViewStream';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
*
|
|
@@ -18,7 +19,7 @@ export interface IOptions {
|
|
|
18
19
|
resetCamera: boolean,
|
|
19
20
|
size: Size,
|
|
20
21
|
scale: number
|
|
21
|
-
}
|
|
22
|
+
}
|
|
22
23
|
|
|
23
24
|
type vtkOpenGLRenderWindowBase = vtkObject & Omit<vtkAlgorithm,
|
|
24
25
|
| 'getInputData'
|
|
@@ -32,7 +33,7 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
|
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
35
|
* Builds myself.
|
|
35
|
-
* @param {Boolean} prepass
|
|
36
|
+
* @param {Boolean} prepass
|
|
36
37
|
*/
|
|
37
38
|
buildPass(prepass: boolean): void;
|
|
38
39
|
|
|
@@ -45,12 +46,12 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
|
|
|
45
46
|
initialize(): void;
|
|
46
47
|
|
|
47
48
|
/**
|
|
48
|
-
*
|
|
49
|
+
*
|
|
49
50
|
*/
|
|
50
51
|
makeCurrent(): void;
|
|
51
52
|
|
|
52
53
|
/**
|
|
53
|
-
*
|
|
54
|
+
*
|
|
54
55
|
* @param {HTMLElement} el The container element.
|
|
55
56
|
*/
|
|
56
57
|
setContainer(el: HTMLElement): void;
|
|
@@ -91,170 +92,170 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
|
|
|
91
92
|
getViewportCenter(viewport: vtkRenderer): Vector2;
|
|
92
93
|
|
|
93
94
|
/**
|
|
94
|
-
*
|
|
95
|
-
* @param {Number} x
|
|
96
|
-
* @param {Number} y
|
|
97
|
-
* @param {Number} z
|
|
95
|
+
*
|
|
96
|
+
* @param {Number} x
|
|
97
|
+
* @param {Number} y
|
|
98
|
+
* @param {Number} z
|
|
98
99
|
*/
|
|
99
100
|
displayToNormalizedDisplay(x: number, y: number, z: number): Vector3;
|
|
100
101
|
|
|
101
102
|
/**
|
|
102
|
-
*
|
|
103
|
-
* @param {Number} x
|
|
104
|
-
* @param {Number} y
|
|
105
|
-
* @param {Number} z
|
|
103
|
+
*
|
|
104
|
+
* @param {Number} x
|
|
105
|
+
* @param {Number} y
|
|
106
|
+
* @param {Number} z
|
|
106
107
|
*/
|
|
107
108
|
normalizedDisplayToDisplay(x: number, y: number, z: number): Vector3;
|
|
108
109
|
|
|
109
110
|
/**
|
|
110
|
-
*
|
|
111
|
-
* @param {Number} x
|
|
112
|
-
* @param {Number} y
|
|
113
|
-
* @param {Number} z
|
|
114
|
-
* @param {vtkRenderer} renderer
|
|
111
|
+
*
|
|
112
|
+
* @param {Number} x
|
|
113
|
+
* @param {Number} y
|
|
114
|
+
* @param {Number} z
|
|
115
|
+
* @param {vtkRenderer} renderer
|
|
115
116
|
*/
|
|
116
117
|
worldToView(x: number, y: number, z: number, renderer: vtkRenderer): Vector3;
|
|
117
118
|
|
|
118
119
|
/**
|
|
119
|
-
*
|
|
120
|
-
* @param {Number} x
|
|
121
|
-
* @param {Number} y
|
|
122
|
-
* @param {Number} z
|
|
123
|
-
* @param {vtkRenderer} renderer
|
|
120
|
+
*
|
|
121
|
+
* @param {Number} x
|
|
122
|
+
* @param {Number} y
|
|
123
|
+
* @param {Number} z
|
|
124
|
+
* @param {vtkRenderer} renderer
|
|
124
125
|
*/
|
|
125
126
|
viewToWorld(x: number, y: number, z: number, renderer: vtkRenderer): Vector3;
|
|
126
127
|
|
|
127
128
|
/**
|
|
128
|
-
*
|
|
129
|
-
* @param {Number} x
|
|
130
|
-
* @param {Number} y
|
|
131
|
-
* @param {Number} z
|
|
132
|
-
* @param {vtkRenderer} renderer
|
|
129
|
+
*
|
|
130
|
+
* @param {Number} x
|
|
131
|
+
* @param {Number} y
|
|
132
|
+
* @param {Number} z
|
|
133
|
+
* @param {vtkRenderer} renderer
|
|
133
134
|
*/
|
|
134
135
|
worldToDisplay(x: number, y: number, z: number, renderer: vtkRenderer): Vector3;
|
|
135
136
|
|
|
136
137
|
/**
|
|
137
|
-
*
|
|
138
|
-
* @param {Number} x
|
|
139
|
-
* @param {Number} y
|
|
140
|
-
* @param {Number} z
|
|
141
|
-
* @param {vtkRenderer} renderer
|
|
138
|
+
*
|
|
139
|
+
* @param {Number} x
|
|
140
|
+
* @param {Number} y
|
|
141
|
+
* @param {Number} z
|
|
142
|
+
* @param {vtkRenderer} renderer
|
|
142
143
|
*/
|
|
143
144
|
displayToWorld(x: number, y: number, z: number, renderer: vtkRenderer): Vector3;
|
|
144
145
|
|
|
145
146
|
/**
|
|
146
|
-
*
|
|
147
|
-
* @param {Number} x
|
|
148
|
-
* @param {Number} y
|
|
149
|
-
* @param {Number} z
|
|
150
|
-
* @param {vtkRenderer} renderer
|
|
147
|
+
*
|
|
148
|
+
* @param {Number} x
|
|
149
|
+
* @param {Number} y
|
|
150
|
+
* @param {Number} z
|
|
151
|
+
* @param {vtkRenderer} renderer
|
|
151
152
|
*/
|
|
152
153
|
normalizedDisplayToViewport(x: number, y: number, z: number, renderer: vtkRenderer): Vector3;
|
|
153
154
|
|
|
154
155
|
/**
|
|
155
|
-
*
|
|
156
|
-
* @param {Number} x
|
|
157
|
-
* @param {Number} y
|
|
158
|
-
* @param {Number} z
|
|
159
|
-
* @param {vtkRenderer} renderer
|
|
156
|
+
*
|
|
157
|
+
* @param {Number} x
|
|
158
|
+
* @param {Number} y
|
|
159
|
+
* @param {Number} z
|
|
160
|
+
* @param {vtkRenderer} renderer
|
|
160
161
|
*/
|
|
161
162
|
viewportToNormalizedViewport(x: number, y: number, z: number, renderer: vtkRenderer): Vector3;
|
|
162
163
|
|
|
163
164
|
/**
|
|
164
|
-
*
|
|
165
|
-
* @param {Number} x
|
|
166
|
-
* @param {Number} y
|
|
167
|
-
* @param {Number} z
|
|
165
|
+
*
|
|
166
|
+
* @param {Number} x
|
|
167
|
+
* @param {Number} y
|
|
168
|
+
* @param {Number} z
|
|
168
169
|
*/
|
|
169
170
|
normalizedViewportToViewport(x: number, y: number, z: number): Vector3;
|
|
170
171
|
|
|
171
172
|
/**
|
|
172
|
-
*
|
|
173
|
-
* @param {Number} x
|
|
174
|
-
* @param {Number} y
|
|
175
|
-
* @param {Number} z
|
|
173
|
+
*
|
|
174
|
+
* @param {Number} x
|
|
175
|
+
* @param {Number} y
|
|
176
|
+
* @param {Number} z
|
|
176
177
|
*/
|
|
177
178
|
displayToLocalDisplay(x: number, y: number, z: number): Vector3;
|
|
178
179
|
|
|
179
180
|
/**
|
|
180
|
-
*
|
|
181
|
-
* @param {Number} x
|
|
182
|
-
* @param {Number} y
|
|
183
|
-
* @param {Number} z
|
|
184
|
-
* @param {vtkRenderer} renderer
|
|
181
|
+
*
|
|
182
|
+
* @param {Number} x
|
|
183
|
+
* @param {Number} y
|
|
184
|
+
* @param {Number} z
|
|
185
|
+
* @param {vtkRenderer} renderer
|
|
185
186
|
*/
|
|
186
187
|
viewportToNormalizedDisplay(x: number, y: number, z: number, renderer: vtkRenderer): Vector3;
|
|
187
188
|
|
|
188
189
|
/**
|
|
189
|
-
*
|
|
190
|
-
* @param {Number} x1
|
|
191
|
-
* @param {Number} y1
|
|
192
|
-
* @param {Number} x2
|
|
193
|
-
* @param {Number} y2
|
|
190
|
+
*
|
|
191
|
+
* @param {Number} x1
|
|
192
|
+
* @param {Number} y1
|
|
193
|
+
* @param {Number} x2
|
|
194
|
+
* @param {Number} y2
|
|
194
195
|
*/
|
|
195
196
|
getPixelData(x1: number, y1: number, x2: number, y2: number): Uint8Array;
|
|
196
197
|
|
|
197
198
|
/**
|
|
198
|
-
*
|
|
199
|
-
* @param options
|
|
199
|
+
*
|
|
200
|
+
* @param options
|
|
200
201
|
*/
|
|
201
202
|
get3DContext(options: object): WebGLRenderingContext | null;
|
|
202
203
|
|
|
203
204
|
/**
|
|
204
|
-
*
|
|
205
|
+
*
|
|
205
206
|
*/
|
|
206
207
|
startVR(): void;
|
|
207
208
|
|
|
208
209
|
/**
|
|
209
|
-
*
|
|
210
|
+
*
|
|
210
211
|
*/
|
|
211
212
|
stopVR(): void;
|
|
212
213
|
|
|
213
214
|
/**
|
|
214
|
-
*
|
|
215
|
+
*
|
|
215
216
|
*/
|
|
216
217
|
vrRender(): void;
|
|
217
218
|
|
|
218
219
|
/**
|
|
219
|
-
*
|
|
220
|
+
*
|
|
220
221
|
*/
|
|
221
222
|
restoreContext(): void;
|
|
222
223
|
|
|
223
224
|
/**
|
|
224
|
-
*
|
|
225
|
-
* @param {vtkTexture} texture
|
|
225
|
+
*
|
|
226
|
+
* @param {vtkTexture} texture
|
|
226
227
|
*/
|
|
227
228
|
activateTexture(texture: vtkTexture): void;
|
|
228
229
|
|
|
229
230
|
/**
|
|
230
|
-
*
|
|
231
|
-
* @param {vtkTexture} texture
|
|
231
|
+
*
|
|
232
|
+
* @param {vtkTexture} texture
|
|
232
233
|
*/
|
|
233
234
|
deactivateTexture(texture: vtkTexture): void;
|
|
234
235
|
|
|
235
236
|
/**
|
|
236
|
-
*
|
|
237
|
-
* @param {vtkTexture} texture
|
|
237
|
+
*
|
|
238
|
+
* @param {vtkTexture} texture
|
|
238
239
|
*/
|
|
239
240
|
getTextureUnitForTexture(texture: vtkTexture): number;
|
|
240
241
|
|
|
241
242
|
/**
|
|
242
|
-
*
|
|
243
|
-
* @param vtktype
|
|
244
|
-
* @param numComps
|
|
245
|
-
* @param useFloat
|
|
243
|
+
*
|
|
244
|
+
* @param vtktype
|
|
245
|
+
* @param numComps
|
|
246
|
+
* @param useFloat
|
|
246
247
|
*/
|
|
247
248
|
getDefaultTextureInternalFormat(vtktype: VtkDataTypes, numComps: number, useFloat: boolean): void;
|
|
248
249
|
|
|
249
250
|
/**
|
|
250
|
-
*
|
|
251
|
-
* @param {HTMLImageElement} img
|
|
251
|
+
*
|
|
252
|
+
* @param {HTMLImageElement} img
|
|
252
253
|
*/
|
|
253
254
|
setBackgroundImage(img: HTMLImageElement): void;
|
|
254
255
|
|
|
255
256
|
/**
|
|
256
|
-
*
|
|
257
|
-
* @param {Boolean} value
|
|
257
|
+
*
|
|
258
|
+
* @param {Boolean} value
|
|
258
259
|
*/
|
|
259
260
|
setUseBackgroundImage(value: boolean): void;
|
|
260
261
|
|
|
@@ -269,70 +270,70 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
|
|
|
269
270
|
* size. If no `size` or `scale` are provided, the current renderwindow
|
|
270
271
|
* size is assumed. The default format is "image/png". Returns a promise
|
|
271
272
|
* that resolves to the captured screenshot.
|
|
272
|
-
* @param {String} format
|
|
273
|
-
* @param {IOptions} options
|
|
273
|
+
* @param {String} format
|
|
274
|
+
* @param {IOptions} options
|
|
274
275
|
*/
|
|
275
276
|
captureNextImage(format: string, options: IOptions): Promise<string> | null;
|
|
276
277
|
|
|
277
278
|
/**
|
|
278
|
-
*
|
|
279
|
+
*
|
|
279
280
|
*/
|
|
280
281
|
getGLInformations(): object;
|
|
281
282
|
|
|
282
283
|
/**
|
|
283
|
-
*
|
|
284
|
+
*
|
|
284
285
|
*/
|
|
285
286
|
traverseAllPasses(): void;
|
|
286
287
|
|
|
287
288
|
/**
|
|
288
|
-
*
|
|
289
|
+
*
|
|
289
290
|
*/
|
|
290
291
|
disableCullFace(): void;
|
|
291
292
|
|
|
292
293
|
/**
|
|
293
|
-
*
|
|
294
|
+
*
|
|
294
295
|
*/
|
|
295
296
|
enableCullFace(): void;
|
|
296
297
|
|
|
297
298
|
/**
|
|
298
|
-
*
|
|
299
|
-
* @param stream
|
|
299
|
+
*
|
|
300
|
+
* @param stream
|
|
300
301
|
*/
|
|
301
|
-
setViewStream(stream:
|
|
302
|
+
setViewStream(stream: vtkViewStream): boolean;
|
|
302
303
|
|
|
303
304
|
/**
|
|
304
|
-
*
|
|
305
|
-
* @param {Vector2} size
|
|
305
|
+
*
|
|
306
|
+
* @param {Vector2} size
|
|
306
307
|
*/
|
|
307
308
|
setSize(size: Vector2): void;
|
|
308
309
|
|
|
309
310
|
/**
|
|
310
|
-
*
|
|
311
|
-
* @param {Number} x
|
|
312
|
-
* @param {Number} y
|
|
311
|
+
*
|
|
312
|
+
* @param {Number} x
|
|
313
|
+
* @param {Number} y
|
|
313
314
|
*/
|
|
314
315
|
setSize(x: number, y: number): void;
|
|
315
316
|
|
|
316
317
|
/**
|
|
317
|
-
*
|
|
318
|
+
*
|
|
318
319
|
*/
|
|
319
320
|
getSize(): Vector2;
|
|
320
321
|
|
|
321
322
|
/**
|
|
322
|
-
*
|
|
323
|
-
* @param {Vector2} size
|
|
323
|
+
*
|
|
324
|
+
* @param {Vector2} size
|
|
324
325
|
*/
|
|
325
326
|
setVrResolution(size: Vector2): void;
|
|
326
327
|
|
|
327
328
|
/**
|
|
328
|
-
*
|
|
329
|
-
* @param {Number} x
|
|
330
|
-
* @param {Number} y
|
|
329
|
+
*
|
|
330
|
+
* @param {Number} x
|
|
331
|
+
* @param {Number} y
|
|
331
332
|
*/
|
|
332
333
|
setVrResolution(x: number, y: number): void;
|
|
333
334
|
|
|
334
335
|
/**
|
|
335
|
-
*
|
|
336
|
+
*
|
|
336
337
|
*/
|
|
337
338
|
getVrResolution(): Vector2;
|
|
338
339
|
}
|
|
@@ -353,20 +354,20 @@ export function extend(publicAPI: object, model: object, initialValues?: IOpenGL
|
|
|
353
354
|
export function newInstance(initialValues?: IOpenGLRenderWindowInitialValues): vtkOpenGLRenderWindow;
|
|
354
355
|
|
|
355
356
|
/**
|
|
356
|
-
*
|
|
357
|
-
* @param cb
|
|
357
|
+
*
|
|
358
|
+
* @param cb
|
|
358
359
|
*/
|
|
359
360
|
export function pushMonitorGLContextCount(cb: any): void;
|
|
360
361
|
|
|
361
362
|
/**
|
|
362
|
-
*
|
|
363
|
-
* @param cb
|
|
363
|
+
*
|
|
364
|
+
* @param cb
|
|
364
365
|
*/
|
|
365
366
|
export function popMonitorGLContextCount(cb: any): void;
|
|
366
367
|
|
|
367
368
|
/**
|
|
368
369
|
* WebGL rendering window
|
|
369
|
-
*
|
|
370
|
+
*
|
|
370
371
|
* vtkOpenGLRenderWindow is designed to view/render a vtkRenderWindow.
|
|
371
372
|
*/
|
|
372
373
|
export declare const vtkOpenGLRenderWindow: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
-
import { newInstance as newInstance$1, obj, setGet, vtkWarningMacro as vtkWarningMacro$1, vtkErrorMacro as vtkErrorMacro$1 } from '../../macros.js';
|
|
2
|
+
import { newInstance as newInstance$1, obj, setGet, chain, vtkWarningMacro as vtkWarningMacro$1, vtkErrorMacro as vtkErrorMacro$1 } from '../../macros.js';
|
|
3
3
|
import { mat4, mat3, vec3 } from 'gl-matrix';
|
|
4
4
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
5
5
|
import { VtkDataTypes } from '../../Common/Core/DataArray/Constants.js';
|
|
@@ -672,90 +672,86 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
672
672
|
program.setUniform3fv("vClipPlaneNormals", clipPlaneNormals);
|
|
673
673
|
program.setUniformfv("vClipPlaneDistances", clipPlaneDistances);
|
|
674
674
|
}
|
|
675
|
-
};
|
|
675
|
+
}; // unsubscribe from our listeners
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
publicAPI.delete = chain(function () {
|
|
679
|
+
if (model._animationRateSubscription) {
|
|
680
|
+
model._animationRateSubscription.unsubscribe();
|
|
681
|
+
|
|
682
|
+
model._animationRateSubscription = null;
|
|
683
|
+
}
|
|
684
|
+
}, publicAPI.delete);
|
|
676
685
|
|
|
677
686
|
publicAPI.getRenderTargetSize = function () {
|
|
678
|
-
if (model.
|
|
679
|
-
|
|
680
|
-
return [model.fvp[0] * sz[0], model.fvp[1] * sz[1]];
|
|
687
|
+
if (model._useSmallViewport) {
|
|
688
|
+
return [model._smallViewportWidth, model._smallViewportHeight];
|
|
681
689
|
}
|
|
682
690
|
|
|
683
691
|
return model.openGLRenderWindow.getFramebufferSize();
|
|
684
692
|
};
|
|
685
693
|
|
|
686
694
|
publicAPI.renderPieceStart = function (ren, actor) {
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
695
|
+
var rwi = ren.getVTKWindow().getInteractor();
|
|
696
|
+
model._useSmallViewport = false;
|
|
697
|
+
|
|
698
|
+
if (rwi.isAnimating() && model._lastScale > 1.5) {
|
|
699
|
+
model._useSmallViewport = true;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
if (!model._animationRateSubscription) {
|
|
703
|
+
// when the animation frame rate changes recompute the scale factor
|
|
704
|
+
model._animationRateSubscription = rwi.onAnimationFrameRateUpdate(function () {
|
|
705
|
+
if (model.renderable.getAutoAdjustSampleDistances()) {
|
|
706
|
+
var frate = rwi.getRecentAnimationFrameRate();
|
|
707
|
+
var adjustment = rwi.getDesiredUpdateRate() / frate; // only change if we are off by 15%
|
|
708
|
+
|
|
709
|
+
if (adjustment > 1.15 || adjustment < 0.85) {
|
|
710
|
+
model._lastScale *= adjustment;
|
|
711
|
+
} // clamp scale to some reasonable values.
|
|
712
|
+
// Below 1.5 we will just be using full resolution as that is close enough
|
|
713
|
+
// Above 400 seems like a lot so we limit to that 1/20th per axis
|
|
704
714
|
|
|
705
|
-
model.targetXYF = txyf;
|
|
706
|
-
} else {
|
|
707
|
-
model.targetXYF = Math.sqrt(model.avgFrameTime * rwi.getStillUpdateRate() / model.avgWindowArea);
|
|
708
|
-
} // have some inertia to change states around 1.43
|
|
709
715
|
|
|
716
|
+
if (model._lastScale > 400) {
|
|
717
|
+
model._lastScale = 400;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
if (model._lastScale < 1.5) {
|
|
721
|
+
model._lastScale = 1.5;
|
|
722
|
+
}
|
|
723
|
+
} else {
|
|
724
|
+
model._lastScale = model.renderable.getImageSampleDistance() * model.renderable.getImageSampleDistance();
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
var size = model.openGLRenderWindow.getFramebufferSize();
|
|
728
|
+
model._smallViewportWidth = Math.ceil(size[0] / Math.sqrt(model._lastScale));
|
|
729
|
+
model._smallViewportHeight = Math.ceil(size[1] / Math.sqrt(model._lastScale));
|
|
730
|
+
});
|
|
731
|
+
} // use/create/resize framebuffer if needed
|
|
710
732
|
|
|
711
|
-
if (model.targetXYF < 1.53 && model.targetXYF > 1.33) {
|
|
712
|
-
model.targetXYF = model.lastXYF;
|
|
713
|
-
} // and add some inertia to change at all
|
|
714
733
|
|
|
734
|
+
if (model._useSmallViewport) {
|
|
735
|
+
var size = model.openGLRenderWindow.getFramebufferSize(); // adjust viewportSize to always be at most the dest fo size
|
|
715
736
|
|
|
716
|
-
if (
|
|
717
|
-
model.
|
|
737
|
+
if (model._smallViewportHeight > size[1]) {
|
|
738
|
+
model._smallViewportHeight = size[1];
|
|
718
739
|
}
|
|
719
740
|
|
|
720
|
-
model.
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
} // only use FBO beyond this value
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
if (model.lastXYF <= 1.43) {
|
|
727
|
-
model.lastXYF = 1.0;
|
|
728
|
-
} // console.log(`last target ${model.lastXYF} ${model.targetXYF}`);
|
|
729
|
-
// console.log(`awin aft ${model.avgWindowArea} ${model.avgFrameTime}`);
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
var xyf = model.lastXYF;
|
|
733
|
-
var size = model.openGLRenderWindow.getFramebufferSize(); // const newSize = [
|
|
734
|
-
// Math.floor((size[0] / xyf) + 0.5),
|
|
735
|
-
// Math.floor((size[1] / xyf) + 0.5)];
|
|
736
|
-
// const diag = vtkBoundingBox.getDiagonalLength(model.currentInput.getBounds());
|
|
737
|
-
// // so what is the resulting sample size roughly
|
|
738
|
-
// console.log(`sam size ${diag / newSize[0]} ${diag / newSize[1]} ${model.renderable.getImageSampleDistance()}`);
|
|
739
|
-
// // if the sample distance is getting far from the image sample dist
|
|
740
|
-
// if (2.0 * diag / (newSize[0] + newSize[1]) > 4 * model.renderable.getSampleDistance()) {
|
|
741
|
-
// model.renderable.setSampleDistance(4.0 * model.renderable.getSampleDistance());
|
|
742
|
-
// }
|
|
743
|
-
// if (2.0 * diag / (newSize[0] + newSize[1]) < 0.25 * model.renderable.getSampleDistance()) {
|
|
744
|
-
// model.renderable.setSampleDistance(0.25 * model.renderable.getSampleDistance());
|
|
745
|
-
// }
|
|
746
|
-
// create/resize framebuffer if needed
|
|
741
|
+
if (model._smallViewportWidth > size[0]) {
|
|
742
|
+
model._smallViewportWidth = size[0];
|
|
743
|
+
}
|
|
747
744
|
|
|
748
|
-
if (xyf > 1.43) {
|
|
749
745
|
model.framebuffer.saveCurrentBindingsAndBuffers();
|
|
750
746
|
|
|
751
747
|
if (model.framebuffer.getGLFramebuffer() === null) {
|
|
752
|
-
model.framebuffer.create(
|
|
748
|
+
model.framebuffer.create(size[0], size[1]);
|
|
753
749
|
model.framebuffer.populateFramebuffer();
|
|
754
750
|
} else {
|
|
755
751
|
var fbSize = model.framebuffer.getSize();
|
|
756
752
|
|
|
757
|
-
if (fbSize[0] !==
|
|
758
|
-
model.framebuffer.create(
|
|
753
|
+
if (fbSize[0] !== size[0] || fbSize[1] !== size[1]) {
|
|
754
|
+
model.framebuffer.create(size[0], size[1]);
|
|
759
755
|
model.framebuffer.populateFramebuffer();
|
|
760
756
|
}
|
|
761
757
|
}
|
|
@@ -765,8 +761,8 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
765
761
|
gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
766
762
|
gl.colorMask(true, true, true, true);
|
|
767
763
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
768
|
-
gl.viewport(0, 0,
|
|
769
|
-
model.fvp = [
|
|
764
|
+
gl.viewport(0, 0, model._smallViewportWidth, model._smallViewportHeight);
|
|
765
|
+
model.fvp = [model._smallViewportWidth / size[0], model._smallViewportHeight / size[1]];
|
|
770
766
|
}
|
|
771
767
|
|
|
772
768
|
model.context.disable(model.context.DEPTH_TEST); // make sure the BOs are up to date
|
|
@@ -817,7 +813,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
817
813
|
model.zBufferTexture.deactivate();
|
|
818
814
|
}
|
|
819
815
|
|
|
820
|
-
if (model.
|
|
816
|
+
if (model._useSmallViewport) {
|
|
821
817
|
// now copy the framebuffer with the volume into the
|
|
822
818
|
// regular buffer
|
|
823
819
|
model.framebuffer.restorePreviousBindingsAndBuffers();
|
|
@@ -1006,8 +1002,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
1006
1002
|
var dims = image.getDimensions();
|
|
1007
1003
|
model.scalarTexture.releaseGraphicsResources(model.openGLRenderWindow);
|
|
1008
1004
|
model.scalarTexture.resetFormatAndType();
|
|
1009
|
-
model.scalarTexture.create3DFilterableFromRaw(dims[0], dims[1], dims[2], numComp, scalars.getDataType(), scalars.getData(), model.renderable.getPreferSizeOverAccuracy());
|
|
1010
|
-
|
|
1005
|
+
model.scalarTexture.create3DFilterableFromRaw(dims[0], dims[1], dims[2], numComp, scalars.getDataType(), scalars.getData(), model.renderable.getPreferSizeOverAccuracy());
|
|
1011
1006
|
model.scalarTextureString = toString;
|
|
1012
1007
|
}
|
|
1013
1008
|
|
|
@@ -1125,7 +1120,8 @@ function extend(publicAPI, model) {
|
|
|
1125
1120
|
model.idxNormalMatrix = mat3.identity(new Float64Array(9));
|
|
1126
1121
|
model.modelToView = mat4.identity(new Float64Array(16));
|
|
1127
1122
|
model.projectionToView = mat4.identity(new Float64Array(16));
|
|
1128
|
-
model.projectionToWorld = mat4.identity(new Float64Array(16));
|
|
1123
|
+
model.projectionToWorld = mat4.identity(new Float64Array(16));
|
|
1124
|
+
model._lastScale = 1.0; // Build VTK API
|
|
1129
1125
|
|
|
1130
1126
|
setGet(publicAPI, model, ['context']); // Object methods
|
|
1131
1127
|
|