@kitware/vtk.js 31.0.0 → 31.0.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.
@@ -419,6 +419,7 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
419
419
  const image = model.currentInput;
420
420
  const dim = image.getDimensions();
421
421
  mat4.copy(model.tmpMat4, image.getIndexToWorld());
422
+ mat4.translate(model.tmpMat4, model.tmpMat4, [-0.5, -0.5, -0.5]);
422
423
  mat4.scale(model.tmpMat4, model.tmpMat4, dim);
423
424
  mat4.invert(model.tmpMat4, model.tmpMat4);
424
425
  if (inverseShiftScaleMatrix) {
@@ -427,7 +428,7 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
427
428
  program.setUniformMatrix('WCTCMatrix', model.tmpMat4);
428
429
  }
429
430
  if (program.isUniformUsed('vboScaling')) {
430
- program.setUniform3fv('vboScaling', cellBO.getCABO().getCoordScale());
431
+ program.setUniform3fv('vboScaling', cellBO.getCABO().getCoordScale() ?? [1, 1, 1]);
431
432
  }
432
433
  cellBO.getAttributeUpdateTime().modified();
433
434
  }
@@ -730,15 +731,16 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
730
731
  resGeomString = resGeomString.concat(`PolyData${slicePD.getMTime()}`);
731
732
  } else if (slicePlane) {
732
733
  resGeomString = resGeomString.concat(`Plane${slicePlane.getMTime()}`);
734
+ // Compute a world-to-image-orientation matrix.
735
+ const w2io = mat3.create();
733
736
  if (image) {
734
737
  resGeomString = resGeomString.concat(`Image${image.getMTime()}`);
738
+ // Ignore the translation component since we are
739
+ // using it on vectors rather than positions.
740
+ mat3.set(w2io, ...image.getDirection());
741
+ mat3.invert(w2io, w2io);
735
742
  }
736
743
  // Check to see if we can bypass oblique slicing related bounds computation
737
- // Compute a world-to-image-orientation matrix.
738
- // Ignore the translation component since we are
739
- // using it on vectors rather than positions.
740
- const w2io = mat3.fromValues(image?.getDirection());
741
- mat3.invert(w2io, w2io);
742
744
  // transform the cutting plane normal to image local coords
743
745
  const imageLocalNormal = [...slicePlane.getNormal()];
744
746
  vec3.transformMat3(imageLocalNormal, imageLocalNormal, w2io);
@@ -803,8 +805,7 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
803
805
  const ptsArray = new Float32Array(12);
804
806
  const indexSpacePlaneOrigin = image.worldToIndex(slicePlane.getOrigin(), [0, 0, 0]);
805
807
  const otherAxes = [(orthoAxis + 1) % 3, (orthoAxis + 2) % 3].sort();
806
- const dim = image.getDimensions();
807
- const ext = [0, dim[0] - 1, 0, dim[1] - 1, 0, dim[2] - 1];
808
+ const ext = image.getSpatialExtent();
808
809
  let ptIdx = 0;
809
810
  for (let i = 0; i < 2; ++i) {
810
811
  for (let j = 0; j < 2; ++j) {
@@ -1,6 +1,6 @@
1
1
  import { Nullable, Size, Vector2, Vector3 } from './../../types';
2
+ import { vtkAlgorithm } from './../../interfaces';
2
3
  import { VtkDataTypes } from './../../Common/Core/DataArray';
3
- import { vtkAlgorithm, vtkObject } from './../../interfaces';
4
4
  import vtkBufferObject from './BufferObject';
5
5
  import vtkCellArray from './../../Common/Core/CellArray';
6
6
  import vtkDataArray from './../../Common/Core/DataArray';
@@ -8,6 +8,7 @@ import vtkOpenGLTexture from './Texture';
8
8
  import vtkPoints from './../../Common/Core/Points';
9
9
  import vtkRenderer from './../Core/Renderer';
10
10
  import vtkTexture from './../Core/Texture';
11
+ import vtkViewNode from './../SceneGraph/ViewNode';
11
12
  import vtkViewStream from './../../IO/Core/ImageStream/ViewStream';
12
13
 
13
14
  /**
@@ -41,18 +42,7 @@ export interface ICaptureOptions {
41
42
  scale?: number;
42
43
  }
43
44
 
44
- type vtkOpenGLRenderWindowBase = vtkObject &
45
- Omit<
46
- vtkAlgorithm,
47
- | 'getInputData'
48
- | 'setInputData'
49
- | 'setInputConnection'
50
- | 'getInputConnection'
51
- | 'addInputConnection'
52
- | 'addInputData'
53
- >;
54
-
55
- export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
45
+ export interface vtkOpenGLRenderWindow extends vtkViewNode {
56
46
  /**
57
47
  * Builds myself.
58
48
  * @param {Boolean} prepass
@@ -98,6 +88,11 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
98
88
  */
99
89
  getCanvas(): Nullable<HTMLCanvasElement>;
100
90
 
91
+ /**
92
+ * Set the webgl canvas.
93
+ */
94
+ setCanvas(canvas: Nullable<HTMLCanvasElement>): boolean;
95
+
101
96
  /**
102
97
  * Check if a point is in the viewport.
103
98
  * @param {Number} x The x coordinate.
@@ -582,7 +582,7 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
582
582
  };
583
583
  publicAPI.copyParentContent = () => {
584
584
  const rootParent = model.rootOpenGLRenderWindow;
585
- if (!rootParent || !model.context2D) {
585
+ if (!rootParent || !model.context2D || model.children.some(oglRenderer => !!oglRenderer.getSelector?.())) {
586
586
  return;
587
587
  }
588
588
  const parentCanvas = rootParent.getCanvas();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "31.0.0",
3
+ "version": "31.0.2",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",