@kitware/vtk.js 34.16.2 → 34.16.3

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.
@@ -206,8 +206,10 @@ export function newInstance(
206
206
  /**
207
207
  * vtkImageMapper provides 2D image display support for vtk.
208
208
  * It can be associated with a vtkImageSlice prop and placed within a Renderer.
209
+ * Only axis-aligned slices are supported.
209
210
  *
210
211
  * This class resolves coincident topology with the same methods as vtkMapper.
212
+ * @see vtkImageResliceMapper
211
213
  */
212
214
  export declare const vtkImageMapper: {
213
215
  newInstance: typeof newInstance;
@@ -1025,7 +1025,9 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
1025
1025
  tex.sendParameters();
1026
1026
  tex.deactivate();
1027
1027
  }
1028
- const toString = `${poly.getMTime()}A${representation}B${poly.getMTime()}` + `C${n ? n.getMTime() : 1}D${c ? c.getMTime() : 1}` + `E${actor.getProperty().getEdgeVisibility()}` + `F${tcoords ? tcoords.getMTime() : 1}`;
1028
+ const customAttributes = model.renderable.getCustomShaderAttributes();
1029
+ const customAttributesArrays = customAttributes.map(arrayName => poly.getPointData().getArrayByName(arrayName));
1030
+ const toString = `${poly.getMTime()}` + `A${representation}` + `B${poly.getMTime()}` + `C${n ? n.getMTime() : 1}` + `D${c ? c.getMTime() : 1}` + `E${actor.getProperty().getEdgeVisibility()}` + `F${tcoords ? tcoords.getMTime() : 1}` + `G${customAttributesArrays.map(attributeArray => attributeArray.getMTime()).join(',')}`;
1029
1031
  if (model.VBOBuildString !== toString) {
1030
1032
  // Build the VBOs
1031
1033
  const points = poly.getPoints();
@@ -1040,7 +1042,7 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
1040
1042
  useTCoordsPerCell,
1041
1043
  haveCellScalars: model.haveCellScalars,
1042
1044
  haveCellNormals: model.haveCellNormals,
1043
- customAttributes: model.renderable.getCustomShaderAttributes().map(arrayName => poly.getPointData().getArrayByName(arrayName))
1045
+ customAttributes: customAttributesArrays
1044
1046
  };
1045
1047
  if (model.renderable.getPopulateSelectionSettings()) {
1046
1048
  model.selectionWebGLIdsToVTKIds = {
@@ -238,6 +238,9 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
238
238
  vtkDebugMacro('using webgl1');
239
239
  result = model.canvas.getContext('webgl', options) || model.canvas.getContext('experimental-webgl', options);
240
240
  }
241
+ if (!result) {
242
+ vtkErrorMacro('no webgl context');
243
+ }
241
244
  return new Proxy(result, getCachingContextHandler());
242
245
  };
243
246
  publicAPI.get2DContext = function () {
@@ -15,12 +15,21 @@ function widgetBehavior(publicAPI, model) {
15
15
  const manipulator = model.activeState?.getManipulator?.() ?? model.manipulator;
16
16
  return manipulator.handleEvent(e, model._apiSpecificRenderWindow).worldCoords;
17
17
  }
18
-
19
- // Update the handle's center. Example:
20
- // handle.setCenter([1,2,3]);
21
18
  publicAPI.setCenter = newCenter => {
22
19
  moveHandle.setOrigin(newCenter);
20
+ model._interactor.render();
21
+ };
22
+ publicAPI.startInteract = () => {
23
23
  model._widgetManager.enablePicking();
24
+ publicAPI.grabFocus();
25
+ model._apiSpecificRenderWindow.setCursor('grabbing');
26
+ publicAPI.invokeStartInteractionEvent();
27
+ };
28
+ publicAPI.endInteract = () => {
29
+ publicAPI.loseFocus();
30
+ model._apiSpecificRenderWindow.setCursor('pointer');
31
+ model.widgetState.deactivate();
32
+ publicAPI.invokeEndInteractionEvent();
24
33
  };
25
34
  publicAPI.handleLeftButtonPress = e => {
26
35
  if (!isValidHandle(model.activeState)) {
@@ -30,12 +39,10 @@ function widgetBehavior(publicAPI, model) {
30
39
  const worldCoords = currentWorldCoords(e);
31
40
  if (model.activeState === moveHandle) {
32
41
  if (!moveHandle.getOrigin() && worldCoords) {
33
- moveHandle.setOrigin(worldCoords);
42
+ publicAPI.setCenter(worldCoords);
34
43
  }
35
44
  }
36
- model._isDragging = true;
37
- model._apiSpecificRenderWindow.setCursor('grabbing');
38
- publicAPI.invokeStartInteractionEvent();
45
+ publicAPI.startInteract();
39
46
  return macro.EVENT_ABORT;
40
47
  };
41
48
  publicAPI.handleLeftButtonRelease = e => {
@@ -44,13 +51,8 @@ function widgetBehavior(publicAPI, model) {
44
51
  return macro.VOID;
45
52
  }
46
53
  if (isPlaced()) {
47
- model._widgetManager.enablePicking();
48
- model._apiSpecificRenderWindow.setCursor('pointer');
49
- model._isDragging = false;
50
- model.activeState = null;
51
- model.widgetState.deactivate();
54
+ publicAPI.endInteract();
52
55
  }
53
- publicAPI.invokeEndInteractionEvent();
54
56
  return macro.EVENT_ABORT;
55
57
  };
56
58
  publicAPI.handleMouseMove = e => {
@@ -67,7 +69,6 @@ function widgetBehavior(publicAPI, model) {
67
69
  moveHandle.setVisible(true);
68
70
  model._isDragging = true;
69
71
  model.activeState = moveHandle;
70
- model._interactor.render();
71
72
  };
72
73
  publicAPI.loseFocus = () => {
73
74
  model._isDragging = false;
@@ -20,9 +20,26 @@ export interface vtkSeedWidgetState {
20
20
  getMoveHandle(): ISeedWidgetHandleState;
21
21
  }
22
22
 
23
- // The type of object returned by vtkWidgetManager.addWidget()
23
+ // Object returned by vtkWidgetManager.addWidget().
24
+ // One instance per view.
24
25
  export interface vtkSeedWidgetHandle {
26
+ /**
27
+ * Place the seed position.
28
+ * @param center Vector3 3D position
29
+ */
25
30
  setCenter(center: Vector3): void;
31
+
32
+ /**
33
+ * Turn the seed widget as interactive.
34
+ * @see vtkSeedWidgetHandle.endInteract
35
+ */
36
+ startInteract(): void;
37
+
38
+ /**
39
+ * Stop the seed widget to be interactive.
40
+ * @see vtkSeedWidgetHandle.endInteract
41
+ */
42
+ endInteract(): void;
26
43
  }
27
44
 
28
45
  export interface vtkSeedWidget {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "34.16.2",
3
+ "version": "34.16.3",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",
@@ -98,7 +98,7 @@
98
98
  "karma-webpack": "5.0.0",
99
99
  "kw-doc": "3.1.2",
100
100
  "lil-gui": "0.19.2",
101
- "lodash": "4.17.21",
101
+ "lodash": "4.17.23",
102
102
  "magic-string": "0.26.2",
103
103
  "moment": "2.29.4",
104
104
  "patch-package": "6.4.7",
@@ -157,6 +157,7 @@
157
157
  "build": "npm run build:release",
158
158
  "build:esm": "npm run build:pre && rollup -c rollup.config.js",
159
159
  "build:umd": "npm run build:pre && webpack --config webpack.prod.js --progress",
160
+ "build:examples": "npm run build:pre && webpack --config webpack.examples.config.js --progress",
160
161
  "build:release": "npm run lint && npm run build:pre && concurrently \"cross-env NOLINT=1 npm run build:esm\" \"cross-env NOLINT=1 npm run build:umd\"",
161
162
  "release:create-packages": "node ./Utilities/ci/build-npm-package.js",
162
163
  "test": "karma start ./karma.conf.js",