@kitware/vtk.js 29.4.5 → 29.4.6

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.
@@ -1,8 +1,14 @@
1
1
  import { m as macro } from '../../macros2.js';
2
- import { s as subtract, j as cross, d as dot, w as multiplyScalar, k as add } from '../../Common/Core/Math/index.js';
2
+ import { d as dot, s as subtract, j as cross, w as multiplyScalar, k as add } from '../../Common/Core/Math/index.js';
3
3
  import vtkAbstractManipulator from './AbstractManipulator.js';
4
+ import { EPSILON } from '../../Common/Core/Math/Constants.js';
4
5
 
5
6
  function projectDisplayToLine(x, y, lineOrigin, lineDirection, renderer, glRenderWindow) {
7
+ // if the active camera viewPlaneNormal and line direction are parallel, no change is allowed
8
+ const dotProduct = Math.abs(dot(renderer.getActiveCamera().getViewPlaneNormal(), lineDirection));
9
+ if (1 - dotProduct < EPSILON) {
10
+ return [];
11
+ }
6
12
  const near = glRenderWindow.displayToWorld(x, y, 0, renderer);
7
13
  const far = glRenderWindow.displayToWorld(x, y, 1, renderer);
8
14
  const viewDir = [0, 0, 0];
@@ -15,11 +15,13 @@ function vtkPickerManipulator(publicAPI, model) {
15
15
  pokedRenderer
16
16
  } = callData;
17
17
  model.picker.pick([position.x, position.y, 0.0], pokedRenderer);
18
- if (model.picker.getActors().length > 0) {
18
+ if (model.picker.getPickedPositions().length > 0) {
19
19
  model.position = model.picker.getPickedPositions()[0];
20
+ } else {
21
+ model.position = null;
20
22
  }
21
23
  return {
22
- worldCoords: model.position || null
24
+ worldCoords: model.position
23
25
  };
24
26
  };
25
27
  }
@@ -3,8 +3,17 @@ import { vec3 } from 'gl-matrix';
3
3
 
4
4
  function widgetBehavior(publicAPI, model) {
5
5
  model.painting = model._factory.getPainting();
6
- publicAPI.handleLeftButtonPress = () => {
7
- if (!model.activeState || !model.activeState.getActive()) {
6
+ publicAPI.handleLeftButtonPress = callData => {
7
+ const manipulator = model.activeState?.getManipulator?.() ?? model.manipulator;
8
+ if (!(manipulator && model.activeState && model.activeState.getActive())) {
9
+ model.painting = false;
10
+ return macro.VOID;
11
+ }
12
+ const {
13
+ worldCoords
14
+ } = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
15
+ if (!worldCoords?.length) {
16
+ model.painting = false;
8
17
  return macro.VOID;
9
18
  }
10
19
  model.painting = true;
@@ -20,11 +29,12 @@ function widgetBehavior(publicAPI, model) {
20
29
  model.widgetState.clearTrailList();
21
30
  }
22
31
  model.painting = false;
23
- return model.hasFocus ? macro.EVENT_ABORT : macro.VOID;
32
+ return macro.VOID;
24
33
  };
25
34
  publicAPI.handleEvent = callData => {
26
35
  const manipulator = model.activeState?.getManipulator?.() ?? model.manipulator;
27
36
  if (!(manipulator && model.activeState && model.activeState.getActive())) {
37
+ model.painting = false;
28
38
  return macro.VOID;
29
39
  }
30
40
  const normal = model._camera.getDirectionOfProjection();
@@ -45,6 +55,8 @@ function widgetBehavior(publicAPI, model) {
45
55
  if (model.painting) {
46
56
  const trailCircle = model.widgetState.addTrail();
47
57
  trailCircle.set(model.activeState.get('origin', 'up', 'right', 'direction', 'scale1'));
58
+ } else {
59
+ return macro.VOID;
48
60
  }
49
61
  publicAPI.invokeInteractionEvent();
50
62
  return macro.EVENT_ABORT;
@@ -30,13 +30,13 @@ function widgetBehavior(publicAPI, model) {
30
30
  }
31
31
  const worldCoords = currentWorldCoords(e);
32
32
  if (model.activeState === moveHandle) {
33
- if (!moveHandle.getOrigin()) {
33
+ if (!moveHandle.getOrigin() && worldCoords) {
34
34
  moveHandle.setOrigin(worldCoords);
35
+ model.previousPosition = [...worldCoords];
35
36
  }
36
37
  }
37
38
  model._isDragging = true;
38
39
  model._apiSpecificRenderWindow.setCursor('grabbing');
39
- model.previousPosition = [...currentWorldCoords(e)];
40
40
  publicAPI.invokeStartInteractionEvent();
41
41
  return macro.EVENT_ABORT;
42
42
  };
@@ -63,8 +63,10 @@ function widgetBehavior(publicAPI, model) {
63
63
  }
64
64
  if (!model.activeState) throw Error('no activestate');
65
65
  const worldCoords = currentWorldCoords(e);
66
- model.activeState.setOrigin(worldCoords);
67
- model.previousPosition = worldCoords;
66
+ if (worldCoords) {
67
+ model.activeState.setOrigin(worldCoords);
68
+ model.previousPosition = worldCoords;
69
+ }
68
70
  return macro.VOID;
69
71
  };
70
72
  publicAPI.grabFocus = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "29.4.5",
3
+ "version": "29.4.6",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",