@kitware/vtk.js 30.5.0 → 30.5.2

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.
@@ -73,8 +73,9 @@ export interface vtkPoints extends vtkDataArray {
73
73
  * @param {Number} x The x coordinate.
74
74
  * @param {Number} y The y coordinate.
75
75
  * @param {Number} z The z coordinate.
76
+ * @returns {Number} Index of the inserted point.
76
77
  */
77
- insertNextPoint(x: number, y: number, z: number): void;
78
+ insertNextPoint(x: number, y: number, z: number): number;
78
79
  }
79
80
 
80
81
  /**
@@ -181,7 +181,7 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
181
181
  const numComp = scalars.getNumberOfComponents();
182
182
  let toString = `${image.getMTime()}A${scalars.getMTime()}`;
183
183
  const tex = model._openGLRenderWindow.getGraphicsResourceForObject(scalars);
184
- const reBuildTex = !tex?.vtkObj || tex?.hash !== toString || model.openGLTextureString !== toString;
184
+ const reBuildTex = !tex?.vtkObj || tex?.hash !== toString;
185
185
  if (reBuildTex) {
186
186
  if (!model.openGLTexture) {
187
187
  model.openGLTexture = vtkOpenGLTexture.newInstance();
@@ -194,13 +194,11 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
194
194
  model.openGLTexture.releaseGraphicsResources(model._openGLRenderWindow);
195
195
  model.openGLTexture.resetFormatAndType();
196
196
  model.openGLTexture.create3DFilterableFromDataArray(dims[0], dims[1], dims[2], scalars);
197
- model.openGLTextureString = toString;
198
197
  if (scalars) {
199
- model._openGLRenderWindow.setGraphicsResourceForObject(scalars, model.openGLTexture, model.openGLTextureString);
198
+ model._openGLRenderWindow.setGraphicsResourceForObject(scalars, model.openGLTexture, toString);
200
199
  }
201
200
  } else {
202
201
  model.openGLTexture = tex.vtkObj;
203
- model.openGLTextureString = tex.hash;
204
202
  }
205
203
  const ppty = actor.getProperty();
206
204
  const iComps = ppty.getIndependentComponents();
@@ -873,7 +871,6 @@ const DEFAULT_VALUES = {
873
871
  lastSlabTrapezoidIntegration: 0,
874
872
  lastSlabType: -1,
875
873
  openGLTexture: null,
876
- openGLTextureString: null,
877
874
  colorTextureString: null,
878
875
  pwfTextureString: null,
879
876
  resliceGeom: null,
@@ -1242,7 +1242,6 @@ const DEFAULT_VALUES = {
1242
1242
  context: null,
1243
1243
  VBOBuildTime: null,
1244
1244
  scalarTexture: null,
1245
- scalarTextureString: null,
1246
1245
  opacityTexture: null,
1247
1246
  opacityTextureString: null,
1248
1247
  colorTexture: null,
@@ -1,5 +1,5 @@
1
1
  import { m as macro } from '../../../macros2.js';
2
- import { handleTypeFromName, AXES, transformVec3, rotateVec3 } from './helpers.js';
2
+ import { handleTypeFromName, AXES, calculateCropperCenter, calculateDirection, transformVec3 } from './helpers.js';
3
3
 
4
4
  function widgetBehavior(publicAPI, model) {
5
5
  model._isDragging = false;
@@ -47,23 +47,20 @@ function widgetBehavior(publicAPI, model) {
47
47
  worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow).worldCoords;
48
48
  }
49
49
  if (type === 'faces') {
50
- // constraint axis is line defined by the index and center point.
51
- // Since our index point is defined inside a box [0, 2, 0, 2, 0, 2],
52
- // center point is [1, 1, 1].
53
- const constraintAxis = [1 - index[0], 1 - index[1], 1 - index[2]];
54
-
55
50
  // get center of current crop box
56
- const center = [(planes[0] + planes[1]) / 2, (planes[2] + planes[3]) / 2, (planes[4] + planes[5]) / 2];
57
-
58
- // manipulator should be a line manipulator
59
- manipulator.setHandleOrigin(transformVec3(center, indexToWorldT));
60
- manipulator.setHandleNormal(rotateVec3(constraintAxis, indexToWorldT));
51
+ const worldCenter = calculateCropperCenter(planes, indexToWorldT);
52
+ manipulator.setHandleOrigin(worldCenter);
53
+ manipulator.setHandleNormal(calculateDirection(model.activeState.getOrigin(), worldCenter));
61
54
  worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow).worldCoords;
62
55
  }
63
56
  if (type === 'edges') {
64
57
  // constrain to a plane with a normal parallel to the edge
65
58
  const edgeAxis = index.map(a => a === 1 ? a : 0);
66
- manipulator.setHandleNormal(rotateVec3(edgeAxis, indexToWorldT));
59
+ const faceName = edgeAxis.map(i => AXES[i + 1]).join('');
60
+ const handle = model.widgetState.getStatesWithLabel(faceName)[0];
61
+ // get center of current crop box
62
+ const worldCenter = calculateCropperCenter(planes, indexToWorldT);
63
+ manipulator.setHandleNormal(calculateDirection(handle.getOrigin(), worldCenter));
67
64
  worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow).worldCoords;
68
65
  }
69
66
  if (worldCoords.length) {
@@ -34,5 +34,16 @@ function handleTypeFromName(name) {
34
34
  }
35
35
  return 'faces';
36
36
  }
37
+ function calculateCropperCenter(planes, transform) {
38
+ // get center of current crop box
39
+ const center = [(planes[0] + planes[1]) / 2, (planes[2] + planes[3]) / 2, (planes[4] + planes[5]) / 2];
40
+ return transformVec3(center, transform);
41
+ }
42
+ function calculateDirection(v1, v2) {
43
+ const direction = vec3.create();
44
+ vec3.subtract(direction, v1, v2);
45
+ vec3.normalize(direction, direction);
46
+ return direction;
47
+ }
37
48
 
38
- export { AXES, handleTypeFromName, rotateVec3, transformVec3 };
49
+ export { AXES, calculateCropperCenter, calculateDirection, handleTypeFromName, rotateVec3, transformVec3 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "30.5.0",
3
+ "version": "30.5.2",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",