@kitware/vtk.js 26.9.9 → 26.9.12
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/Rendering/Core/Renderer.d.ts +6 -0
- package/Rendering/Core/Renderer.js +8 -2
- package/Rendering/Core/Viewport.js +2 -4
- package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager.js +78 -2
- package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.js +25 -14
- package/Rendering/Misc/SynchronizableRenderWindow.js +3 -0
- package/package.json +1 -1
|
@@ -63,6 +63,12 @@ export interface vtkRenderer extends vtkViewport {
|
|
|
63
63
|
*/
|
|
64
64
|
addActor(actor: vtkProp): boolean;
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Check if the renderer already has the specified light.
|
|
68
|
+
* @param {vtkLight} light The vtkLight instance.
|
|
69
|
+
*/
|
|
70
|
+
hasLight(light: vtkLight): boolean;
|
|
71
|
+
|
|
66
72
|
/**
|
|
67
73
|
* Add a light to the list of lights.
|
|
68
74
|
* @param {vtkLight} light The vtkLight instance.
|
|
@@ -192,9 +192,15 @@ function vtkRenderer(publicAPI, model) {
|
|
|
192
192
|
publicAPI.modified();
|
|
193
193
|
};
|
|
194
194
|
|
|
195
|
+
publicAPI.hasLight = function (light) {
|
|
196
|
+
return model.lights.includes(light);
|
|
197
|
+
};
|
|
198
|
+
|
|
195
199
|
publicAPI.addLight = function (light) {
|
|
196
|
-
|
|
197
|
-
|
|
200
|
+
if (light && !publicAPI.hasLight(light)) {
|
|
201
|
+
model.lights.push(light);
|
|
202
|
+
publicAPI.modified();
|
|
203
|
+
}
|
|
198
204
|
};
|
|
199
205
|
|
|
200
206
|
publicAPI.removeLight = function (light) {
|
|
@@ -20,14 +20,12 @@ function vtkViewport(publicAPI, model) {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
publicAPI.hasViewProp = function (prop) {
|
|
23
|
-
return
|
|
24
|
-
return item === prop;
|
|
25
|
-
}).length;
|
|
23
|
+
return model.props.includes(prop);
|
|
26
24
|
};
|
|
27
25
|
|
|
28
26
|
publicAPI.addViewProp = function (prop) {
|
|
29
27
|
if (prop && !publicAPI.hasViewProp(prop)) {
|
|
30
|
-
model.props
|
|
28
|
+
model.props.push(prop);
|
|
31
29
|
}
|
|
32
30
|
};
|
|
33
31
|
|
|
@@ -1,6 +1,54 @@
|
|
|
1
|
+
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
2
|
+
import _createClass from '@babel/runtime/helpers/createClass';
|
|
1
3
|
import vtkCameraSynchronizer from './BehaviorManager/CameraSynchronizer.js';
|
|
2
4
|
|
|
3
5
|
var BEHAVIORS = {};
|
|
6
|
+
|
|
7
|
+
var CameraSync = /*#__PURE__*/function () {
|
|
8
|
+
function CameraSync(ctx, config) {
|
|
9
|
+
_classCallCheck(this, CameraSync);
|
|
10
|
+
|
|
11
|
+
this.ctx = ctx;
|
|
12
|
+
this.behavior = vtkCameraSynchronizer.newInstance(this.getProperties(config));
|
|
13
|
+
this.behavior.update();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
_createClass(CameraSync, [{
|
|
17
|
+
key: "getProperties",
|
|
18
|
+
value: function getProperties(_ref) {
|
|
19
|
+
var actorBounds = _ref.actorBounds,
|
|
20
|
+
srcRenderer = _ref.srcRenderer,
|
|
21
|
+
dstRenderer = _ref.dstRenderer;
|
|
22
|
+
var distance = 3.4 * Math.max(actorBounds[1] - actorBounds[0], actorBounds[3] - actorBounds[2], actorBounds[5] - actorBounds[4]);
|
|
23
|
+
var focalPoint = [0.5 * (actorBounds[0] + actorBounds[1]), 0.5 * (actorBounds[2] + actorBounds[3]), 0.5 * (actorBounds[4] + actorBounds[5])];
|
|
24
|
+
var mode = vtkCameraSynchronizer.SynchronizationMode.MODE_ORIENTATION;
|
|
25
|
+
return {
|
|
26
|
+
distance: distance,
|
|
27
|
+
focalPoint: focalPoint,
|
|
28
|
+
mode: mode,
|
|
29
|
+
srcRenderer: this.ctx.getInstance(srcRenderer),
|
|
30
|
+
dstRenderer: this.ctx.getInstance(dstRenderer)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
34
|
+
key: "update",
|
|
35
|
+
value: function update(config) {
|
|
36
|
+
this.behavior.set(this.getProperties(config));
|
|
37
|
+
this.behavior.update();
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
key: "delete",
|
|
41
|
+
value: function _delete() {
|
|
42
|
+
this.behavior.delete();
|
|
43
|
+
}
|
|
44
|
+
}]);
|
|
45
|
+
|
|
46
|
+
return CameraSync;
|
|
47
|
+
}();
|
|
48
|
+
|
|
49
|
+
var BEHAVIORS_TYPES = {
|
|
50
|
+
CameraSync: CameraSync
|
|
51
|
+
};
|
|
4
52
|
function applyBehaviors(renderWindow, state, context) {
|
|
5
53
|
if (!state.behaviors || !renderWindow.getSynchronizedViewId) {
|
|
6
54
|
return;
|
|
@@ -44,9 +92,37 @@ function applyBehaviors(renderWindow, state, context) {
|
|
|
44
92
|
localBehaviors.autoOrientationAxes.delete();
|
|
45
93
|
delete localBehaviors.autoOrientationAxes;
|
|
46
94
|
}
|
|
47
|
-
}
|
|
48
|
-
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
var currentSets = Object.keys(state.behaviors);
|
|
98
|
+
var existingSets = Object.keys(localBehaviors);
|
|
99
|
+
|
|
100
|
+
for (var _i = 0; _i < currentSets.length; _i++) {
|
|
101
|
+
var key = currentSets[_i];
|
|
102
|
+
|
|
103
|
+
if (!localBehaviors[key]) {
|
|
104
|
+
var config = state.behaviors[key];
|
|
105
|
+
|
|
106
|
+
if (BEHAVIORS_TYPES[config.type]) {
|
|
107
|
+
localBehaviors[key] = new BEHAVIORS_TYPES[config.type](context, config);
|
|
108
|
+
} else {
|
|
109
|
+
console.log('No mapping for', config);
|
|
110
|
+
}
|
|
111
|
+
} else {
|
|
112
|
+
localBehaviors[key].update(state.behaviors[key]);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
for (var _i2 = 0; _i2 < existingSets.length; _i2++) {
|
|
117
|
+
var _key = currentSets[_i2];
|
|
118
|
+
|
|
119
|
+
if (!state.behaviors[_key]) {
|
|
120
|
+
// Need to delete previously created behavior
|
|
121
|
+
localBehaviors[_key].delete();
|
|
49
122
|
|
|
123
|
+
delete localBehaviors[_key];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
50
126
|
}
|
|
51
127
|
var BehaviorManager = {
|
|
52
128
|
applyBehaviors: applyBehaviors
|
|
@@ -282,7 +282,7 @@ function genericUpdater(instance, state, context) {
|
|
|
282
282
|
|
|
283
283
|
if (state.arrays) {
|
|
284
284
|
var arraysToBind = [];
|
|
285
|
-
var promises = state.arrays.map(function (arrayMetadata) {
|
|
285
|
+
var promises = Object.values(state.arrays).map(function (arrayMetadata) {
|
|
286
286
|
context.start(); // -> start(arrays)
|
|
287
287
|
|
|
288
288
|
return context.getArray(arrayMetadata.hash, arrayMetadata.dataType, context).then(createNewArrayHandler(instance, arrayMetadata, arraysToBind)).catch(function (error) {
|
|
@@ -416,9 +416,7 @@ function vtkRenderWindowUpdater(instance, state, context) {
|
|
|
416
416
|
}
|
|
417
417
|
|
|
418
418
|
context.unregisterInstance(context.getInstanceId(viewProp));
|
|
419
|
-
});
|
|
420
|
-
|
|
421
|
-
renderer.removeAllViewProps();
|
|
419
|
+
});
|
|
422
420
|
});
|
|
423
421
|
});
|
|
424
422
|
}
|
|
@@ -505,31 +503,41 @@ function removeUnavailableArrays(fields, availableNames) {
|
|
|
505
503
|
function createDataSetUpdate() {
|
|
506
504
|
var piecesToFetch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
507
505
|
return function (instance, state, context) {
|
|
508
|
-
var _state$arrays;
|
|
509
|
-
|
|
510
506
|
context.start(); // -> start(dataset-update)
|
|
511
507
|
// Make sure we provide container for std arrays
|
|
512
508
|
|
|
509
|
+
var localProperties = _objectSpread({}, state.properties);
|
|
510
|
+
|
|
513
511
|
if (!state.arrays) {
|
|
514
|
-
state.arrays =
|
|
512
|
+
state.arrays = {};
|
|
515
513
|
} // Array members
|
|
516
514
|
// => convert old format to generic state.arrays
|
|
517
515
|
|
|
518
516
|
|
|
519
|
-
piecesToFetch.
|
|
517
|
+
for (var i = 0; i < piecesToFetch.length; i++) {
|
|
518
|
+
var key = piecesToFetch[i];
|
|
519
|
+
|
|
520
520
|
if (state.properties[key]) {
|
|
521
521
|
var arrayMeta = state.properties[key];
|
|
522
522
|
arrayMeta.registration = "set".concat(capitalize(key));
|
|
523
|
-
|
|
524
|
-
|
|
523
|
+
var arrayKey = "".concat(arrayMeta.hash, "_").concat(arrayMeta.dataType);
|
|
524
|
+
state.arrays[arrayKey] = arrayMeta;
|
|
525
|
+
delete localProperties[key];
|
|
525
526
|
}
|
|
526
|
-
}
|
|
527
|
+
} // Extract dataset fields
|
|
528
|
+
|
|
527
529
|
|
|
528
530
|
var fieldsArrays = state.properties.fields || [];
|
|
529
531
|
|
|
530
|
-
(
|
|
532
|
+
for (var _i2 = 0; _i2 < fieldsArrays.length; _i2++) {
|
|
533
|
+
var _arrayMeta = fieldsArrays[_i2];
|
|
534
|
+
|
|
535
|
+
var _arrayKey = "".concat(_arrayMeta.hash, "_").concat(_arrayMeta.dataType);
|
|
531
536
|
|
|
532
|
-
|
|
537
|
+
state.arrays[_arrayKey] = _arrayMeta;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
delete localProperties.fields; // Reset any pre-existing fields array
|
|
533
541
|
|
|
534
542
|
var arrayToKeep = {
|
|
535
543
|
pointData: new Set(),
|
|
@@ -544,7 +552,10 @@ function createDataSetUpdate() {
|
|
|
544
552
|
removeUnavailableArrays(instance.getPointData(), arrayToKeep.pointData);
|
|
545
553
|
removeUnavailableArrays(instance.getCellData(), arrayToKeep.cellData); // Generic handling
|
|
546
554
|
|
|
547
|
-
var
|
|
555
|
+
var cleanState = _objectSpread({}, state);
|
|
556
|
+
|
|
557
|
+
cleanState.properties = localProperties;
|
|
558
|
+
var res = genericUpdater(instance, cleanState, context); // Finish what we started
|
|
548
559
|
|
|
549
560
|
context.end(); // -> end(dataset-update)
|
|
550
561
|
|