@kitware/vtk.js 26.9.8 → 26.9.11

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.
@@ -6,7 +6,7 @@ import vtkLookupTableProxy from './LookupTableProxy';
6
6
  import vtkPiecewiseFunctionProxy from './PiecewiseFunctionProxy';
7
7
  import { VtkProxy } from './../../macros';
8
8
 
9
- export type ProxyConfiguration = Object;
9
+ export type ProxyConfiguration = object;
10
10
 
11
11
  export interface ProxyRegistrationChangeInfo {
12
12
  action: 'register' | 'unregister';
@@ -16,6 +16,10 @@ export interface ProxyRegistrationChangeInfo {
16
16
  proxy: VtkProxy;
17
17
  }
18
18
 
19
+ export interface IProxyManagerInitialValues {
20
+ proxyConfiguration?: ProxyConfiguration;
21
+ }
22
+
19
23
  export interface vtkProxyManager extends vtkObject {
20
24
  // core //
21
25
 
@@ -78,4 +82,34 @@ export interface vtkProxyManager extends vtkObject {
78
82
  ): void;
79
83
  }
80
84
 
85
+ /**
86
+ * Decorates a given publicAPI + model with vtkProxyManager characteristics.
87
+ *
88
+ * @param publicAPI
89
+ * @param model
90
+ * @param {IProxyManagerInitialValues} [initialValues]
91
+ */
92
+ export function extend(
93
+ publicAPI: object,
94
+ model: object,
95
+ initialValues?: IProxyManagerInitialValues
96
+ ): void;
97
+
98
+ /**
99
+ * Creates a vtkProxyManager.
100
+ * @param {IProxyManagerInitialValues} [initialValues]
101
+ */
102
+ export function newInstance(
103
+ initialValues?: IProxyManagerInitialValues
104
+ ): vtkProxyManager;
105
+
106
+ /**
107
+ * vtkProxyManager is the central manager for managing proxy resources
108
+ * in vtk.js.
109
+ */
110
+ export declare const vtkProxyManager: {
111
+ newInstance: typeof newInstance;
112
+ extend: typeof extend;
113
+ };
114
+
81
115
  export default vtkProxyManager;
@@ -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
- model.lights = [].concat(model.lights, light);
197
- publicAPI.modified();
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 !!model.props.filter(function (item) {
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 = model.props.concat(prop);
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
- } // Process remaining behaviors...
48
- // TODO - widgets(orientation, ...)
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
@@ -416,9 +416,7 @@ function vtkRenderWindowUpdater(instance, state, context) {
416
416
  }
417
417
 
418
418
  context.unregisterInstance(context.getInstanceId(viewProp));
419
- }); // Now just remove all the view props
420
-
421
- renderer.removeAllViewProps();
419
+ });
422
420
  });
423
421
  });
424
422
  }
@@ -121,6 +121,9 @@ function createInstanceMap() {
121
121
 
122
122
  function registerInstance(id, instance) {
123
123
  instances[id] = instance;
124
+ instance.set({
125
+ remoteId: id
126
+ }, true, true);
124
127
  }
125
128
 
126
129
  function unregisterInstance(id) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "26.9.8",
3
+ "version": "26.9.11",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",