@kitware/vtk.js 28.2.0 → 28.2.1

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,6 +1,11 @@
1
+ ## From 27.x to 28
2
+
3
+ - **vtkManipulator.handleEvent**: Change all `handleEvent` signatures of manipulators. Used to be `handleEvent(callData, glRenderWindow): vec3`, it is now `handleEvent(callData, glRenderWindow): { worldCoords: Nullable<vec3>, worldDirection?: mat3 }`.
4
+ - To upgrade: all instances of `const coords = manipulator.handleEvent(...)` must now be `const { worldCoords } = manipulator.handleEvent(...)`.
5
+
1
6
  ## From 26.x to 27
2
7
 
3
- - Change all `handleEvent` signatures of manipulators. Used to be `handleEvent(callData, glRenderWindow): vec3`, it is now `handleEvent(callData, glRenderWindow): { worldCoords: Nullable<vec3>, worldDirection?: mat3 }`.
8
+ - **abstractimagemapper**: Before this change, the vtkAbstractImageMapper extended vtkAbstractMapper. Now, it extends vtkAbstractMapper3D. Applications with custom sub-classes of vtkAbstractImageMapper that have their own overrides for {set/get}Bounds and {set/get}Center would shadow the superclass methods.
4
9
 
5
10
  ## From 25.x to 26
6
11
 
@@ -794,26 +794,26 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
794
794
 
795
795
  var orthoSlicing = true;
796
796
  var orthoAxis = 2;
797
+ var slicePD = model.renderable.getSlicePolyData();
798
+ var slicePlane = model.renderable.getSlicePlane();
797
799
 
798
- if (model.renderable.getSlicePolyData()) {
799
- resGeomString = resGeomString.concat("PolyData".concat(model.renderable.getSlicePolyData().getMTime()));
800
- } else if (model.renderable.getSlicePlane()) {
801
- resGeomString = resGeomString.concat("Plane".concat(model.renderable.getSlicePlane().getMTime()));
800
+ if (slicePD) {
801
+ resGeomString = resGeomString.concat("PolyData".concat(slicePD.getMTime()));
802
+ } else if (slicePlane) {
803
+ resGeomString = resGeomString.concat("Plane".concat(slicePlane.getMTime()));
802
804
 
803
805
  if (image) {
804
806
  resGeomString = resGeomString.concat("Image".concat(image.getMTime()));
805
807
  } // Check to see if we can bypass oblique slicing related bounds computation
806
808
 
807
809
 
808
- var _isVectorAxisAligned = isVectorAxisAligned(model.renderable.getSlicePlane().getNormal());
810
+ var _isVectorAxisAligned = isVectorAxisAligned(slicePlane.getNormal());
809
811
 
810
812
  var _isVectorAxisAligned2 = _slicedToArray(_isVectorAxisAligned, 2);
811
813
 
812
814
  orthoSlicing = _isVectorAxisAligned2[0];
813
815
  orthoAxis = _isVectorAxisAligned2[1];
814
816
  } else {
815
- var _model$renderable$get;
816
-
817
817
  // Create a default slice plane here
818
818
  var plane = vtkPlane.newInstance();
819
819
  plane.setNormal(0, 0, 1);
@@ -825,7 +825,7 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
825
825
 
826
826
  plane.setOrigin(bds[0], bds[2], 0.5 * (bds[5] + bds[4]));
827
827
  model.renderable.setSlicePlane(plane);
828
- resGeomString = resGeomString.concat("Plane".concat((_model$renderable$get = model.renderable.getSlicePlane()) === null || _model$renderable$get === void 0 ? void 0 : _model$renderable$get.getMTime()));
828
+ resGeomString = resGeomString.concat("Plane".concat(slicePlane === null || slicePlane === void 0 ? void 0 : slicePlane.getMTime()));
829
829
 
830
830
  if (image) {
831
831
  resGeomString = resGeomString.concat("Image".concat(image.getMTime()));
@@ -833,9 +833,17 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
833
833
  }
834
834
 
835
835
  if (!model.resliceGeom || model.resliceGeomUpdateString !== resGeomString) {
836
- if (model.renderable.getSlicePolyData()) {
837
- model.resliceGeom = model.renderable.getSlicePolyData();
838
- } else if (model.renderable.getSlicePlane()) {
836
+ var _model$resliceGeom;
837
+
838
+ if (slicePD) {
839
+ if (!model.resliceGeom) {
840
+ model.resliceGeom = vtkPolyData.newInstance();
841
+ }
842
+
843
+ model.resliceGeom.getPoints().setData(slicePD.getPoints().getData(), 3);
844
+ model.resliceGeom.getPolys().setData(slicePD.getPolys().getData(), 1);
845
+ model.resliceGeom.getPointData().setNormals(slicePD.getPointData().getNormals());
846
+ } else if (slicePlane) {
839
847
  var bounds = image ? imageBounds : [0, 1, 0, 1, 0, 1];
840
848
 
841
849
  if (!orthoSlicing) {
@@ -846,14 +854,22 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
846
854
  cube.setZLength(bounds[5] - bounds[4]);
847
855
  var cutter = vtkCutter.newInstance();
848
856
  cutter.setInputConnection(cube.getOutputPort());
849
- cutter.setCutFunction(model.renderable.getSlicePlane());
857
+ cutter.setCutFunction(slicePlane);
850
858
  var pds = vtkClosedPolyLineToSurfaceFilter.newInstance();
851
859
  pds.setInputConnection(cutter.getOutputPort());
852
860
  pds.update();
853
- model.resliceGeom = pds.getOutputData(); // The above method does not generate point normals
861
+
862
+ if (!model.resliceGeom) {
863
+ model.resliceGeom = vtkPolyData.newInstance();
864
+ }
865
+
866
+ var planePD = pds.getOutputData();
867
+ model.resliceGeom.getPoints().setData(planePD.getPoints().getData(), 3);
868
+ model.resliceGeom.getPolys().setData(planePD.getPolys().getData(), 1);
869
+ model.resliceGeom.getPointData().setNormals(planePD.getPointData().getNormals()); // The above method does not generate point normals
854
870
  // Set it manually here.
855
871
 
856
- var n = model.renderable.getSlicePlane().getNormal();
872
+ var n = slicePlane.getNormal();
857
873
  var npts = model.resliceGeom.getNumberOfPoints();
858
874
  vtkMath.normalize(n);
859
875
  var normalsData = new Float32Array(npts * 3);
@@ -872,7 +888,7 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
872
888
  model.resliceGeom.getPointData().setNormals(normals);
873
889
  } else {
874
890
  var ptsArray = new Float32Array(12);
875
- var o = model.renderable.getSlicePlane().getOrigin();
891
+ var o = slicePlane.getOrigin();
876
892
  var otherAxes = [(orthoAxis + 1) % 3, (orthoAxis + 2) % 3].sort();
877
893
  var ptIdx = 0;
878
894
 
@@ -895,7 +911,7 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
895
911
  cellArray[6] = 3;
896
912
  cellArray[7] = 2;
897
913
 
898
- var _n = model.renderable.getSlicePlane().getNormal();
914
+ var _n = slicePlane.getNormal();
899
915
 
900
916
  vtkMath.normalize(_n);
901
917
 
@@ -921,13 +937,13 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
921
937
  });
922
938
 
923
939
  model.resliceGeom.getPointData().setNormals(_normals);
924
- model.resliceGeom.modified();
925
940
  }
926
941
  } else {
927
942
  vtkErrorMacro('Something went wrong.', 'A default slice plane should have been created in the beginning of', 'updateResliceGeometry.');
928
943
  }
929
944
 
930
945
  model.resliceGeomUpdateString = resGeomString;
946
+ (_model$resliceGeom = model.resliceGeom) === null || _model$resliceGeom === void 0 ? void 0 : _model$resliceGeom.modified();
931
947
  }
932
948
  };
933
949
 
@@ -121,7 +121,9 @@ function widgetBehavior(publicAPI, model) {
121
121
 
122
122
  // Move origin along normal axis
123
123
  model.lineManipulator.setWidgetNormal(model.activeState.getNormal());
124
- var worldCoords = model.lineManipulator.handleEvent(callData, model._apiSpecificRenderWindow);
124
+
125
+ var _model$lineManipulato = model.lineManipulator.handleEvent(callData, model._apiSpecificRenderWindow),
126
+ worldCoords = _model$lineManipulato.worldCoords;
125
127
 
126
128
  if ((_model$widgetState = model.widgetState).containsPoint.apply(_model$widgetState, _toConsumableArray(worldCoords))) {
127
129
  model.activeState.setOrigin(worldCoords);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "28.2.0",
3
+ "version": "28.2.1",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",