@kitware/vtk.js 33.0.0-beta.3 → 33.0.0-beta.4

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.
Files changed (33) hide show
  1. package/Common/Core/DataArray.d.ts +17 -0
  2. package/Common/Core/DataArray.js +36 -0
  3. package/Rendering/Core/AbstractImageMapper.d.ts +81 -0
  4. package/Rendering/Core/AbstractImageMapper.js +5 -2
  5. package/Rendering/Core/AbstractPicker.d.ts +13 -13
  6. package/Rendering/Core/AbstractPicker.js +1 -1
  7. package/Rendering/Core/Actor2D.d.ts +22 -0
  8. package/Rendering/Core/Actor2D.js +1 -1
  9. package/Rendering/Core/CellPicker.js +4 -1
  10. package/Rendering/Core/ImageCPRMapper.js +5 -4
  11. package/Rendering/Core/ImageProperty.d.ts +20 -1
  12. package/Rendering/Core/ImageProperty.js +7 -5
  13. package/Rendering/Core/ImageResliceMapper.d.ts +1 -2
  14. package/Rendering/Core/ImageResliceMapper.js +5 -4
  15. package/Rendering/Core/Viewport.js +13 -3
  16. package/Rendering/Core/VolumeMapper.d.ts +70 -0
  17. package/Rendering/Core/VolumeMapper.js +10 -5
  18. package/Rendering/Core/VolumeProperty.d.ts +20 -1
  19. package/Rendering/Core/VolumeProperty.js +7 -5
  20. package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager/CameraSynchronizer.js +2 -2
  21. package/Rendering/OpenGL/ImageCPRMapper.js +18 -2
  22. package/Rendering/OpenGL/ImageMapper.js +28 -4
  23. package/Rendering/OpenGL/ImageResliceMapper.js +20 -4
  24. package/Rendering/OpenGL/Renderer.js +1 -1
  25. package/Rendering/OpenGL/Texture.d.ts +29 -8
  26. package/Rendering/OpenGL/Texture.js +154 -23
  27. package/Rendering/OpenGL/VolumeMapper.js +22 -4
  28. package/Rendering/SceneGraph/ViewNode.js +12 -2
  29. package/Rendering/WebXR/RenderWindowHelper.js +9 -0
  30. package/Widgets/Core/WidgetManager.d.ts +12 -1
  31. package/Widgets/Representations/WidgetRepresentation.d.ts +1 -7
  32. package/Widgets/Widgets3D/ResliceCursorWidget.d.ts +1 -8
  33. package/package.json +11 -11
@@ -1034,7 +1034,10 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
1034
1034
  if (reBuildOp) {
1035
1035
  const newOpacityTexture = vtkOpenGLTexture.newInstance();
1036
1036
  newOpacityTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
1037
- const oWidth = 1024;
1037
+ let oWidth = model.renderable.getOpacityTextureWidth();
1038
+ if (oWidth <= 0) {
1039
+ oWidth = model.context.getParameter(model.context.MAX_TEXTURE_SIZE);
1040
+ }
1038
1041
  const oSize = oWidth * 2 * numIComps;
1039
1042
  const ofTable = new Float32Array(oSize);
1040
1043
  const tmpTable = new Float32Array(oWidth);
@@ -1088,7 +1091,10 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
1088
1091
  if (reBuildC) {
1089
1092
  const newColorTexture = vtkOpenGLTexture.newInstance();
1090
1093
  newColorTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
1091
- const cWidth = 1024;
1094
+ let cWidth = model.renderable.getColorTextureWidth();
1095
+ if (cWidth <= 0) {
1096
+ cWidth = model.context.getParameter(model.context.MAX_TEXTURE_SIZE);
1097
+ }
1092
1098
  const cSize = cWidth * 2 * numIComps * 3;
1093
1099
  const cTable = new Uint8ClampedArray(cSize);
1094
1100
  const tmpTable = new Float32Array(cWidth * 3);
@@ -1125,7 +1131,9 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
1125
1131
  const tex = model._openGLRenderWindow.getGraphicsResourceForObject(scalars);
1126
1132
  const scalarsHash = getImageDataHash(imageData, scalars);
1127
1133
  const reBuildTex = !tex?.oglObject?.getHandle() || tex?.hash !== scalarsHash;
1128
- if (reBuildTex) {
1134
+ const updatedExtents = volumeProperty.getUpdatedExtents();
1135
+ const hasUpdatedExtents = !!updatedExtents.length;
1136
+ if (reBuildTex && !hasUpdatedExtents) {
1129
1137
  const newScalarTexture = vtkOpenGLTexture.newInstance();
1130
1138
  newScalarTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
1131
1139
  // Build the textures
@@ -1139,6 +1147,13 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
1139
1147
  } else {
1140
1148
  model.scalarTextures[component] = tex.oglObject;
1141
1149
  }
1150
+ if (hasUpdatedExtents) {
1151
+ // If hasUpdatedExtents, then the texture is partially updated.
1152
+ // clear the array to acknowledge the update.
1153
+ volumeProperty.setUpdatedExtents([]);
1154
+ const dims = imageData.getDimensions();
1155
+ model.scalarTextures[component].create3DFilterableFromDataArray(dims[0], dims[1], dims[2], scalars, false, updatedExtents);
1156
+ }
1142
1157
  replaceGraphicsResource(model._openGLRenderWindow, model._scalarTexturesCore[component], scalars);
1143
1158
  model._scalarTexturesCore[component] = scalars;
1144
1159
  });
@@ -1151,7 +1166,10 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
1151
1166
  if (reBuildL) {
1152
1167
  const newLabelOutlineThicknessTexture = vtkOpenGLTexture.newInstance();
1153
1168
  newLabelOutlineThicknessTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
1154
- const lWidth = 1024;
1169
+ let lWidth = model.renderable.getLabelOutlineTextureWidth();
1170
+ if (lWidth <= 0) {
1171
+ lWidth = model.context.getParameter(model.context.MAX_TEXTURE_SIZE);
1172
+ }
1155
1173
  const lHeight = 1;
1156
1174
  const lSize = lWidth * lHeight;
1157
1175
  const lTable = new Uint8Array(lSize);
@@ -105,13 +105,23 @@ function vtkViewNode(publicAPI, model) {
105
105
 
106
106
  // add missing nodes/children for the passed in renderables. This should
107
107
  // be called only in between prepareNodes and removeUnusedNodes
108
- publicAPI.addMissingNodes = dataObjs => {
108
+ publicAPI.addMissingNodes = function (dataObjs) {
109
+ let enforceOrder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
109
110
  if (!dataObjs || !dataObjs.length) {
110
111
  return;
111
112
  }
112
113
  for (let index = 0; index < dataObjs.length; ++index) {
113
114
  const dobj = dataObjs[index];
114
- publicAPI.addMissingNode(dobj);
115
+ const node = publicAPI.addMissingNode(dobj);
116
+ if (enforceOrder && node !== undefined && model.children[index] !== node) {
117
+ for (let i = index + 1; i < model.children.length; ++i) {
118
+ if (model.children[i] === node) {
119
+ model.children.splice(i, 1);
120
+ model.children.splice(index, 0, node);
121
+ break;
122
+ }
123
+ }
124
+ }
115
125
  }
116
126
  };
117
127
 
@@ -140,6 +140,15 @@ function vtkWebXRRenderWindowHelper(publicAPI, model) {
140
140
  model.renderWindow.getRenderable().getInteractor().returnFromXRAnimation();
141
141
  const gl = model.renderWindow.get3DContext();
142
142
  gl.bindFramebuffer(gl.FRAMEBUFFER, null);
143
+
144
+ // Remove controllers ray
145
+ const ren = model.renderWindow.getRenderable().getRenderers()[0];
146
+ model.xrSession.inputSources.forEach(inputSource => {
147
+ if (model.inputSourceToRay[inputSource.handedness]) {
148
+ ren.removeActor(model.inputSourceToRay[inputSource.handedness].actor);
149
+ model.inputSourceToRay[inputSource.handedness].visible = false;
150
+ }
151
+ });
143
152
  await model.xrSession.end().catch(error => {
144
153
  if (!(error instanceof DOMException)) {
145
154
  throw error;
@@ -12,6 +12,14 @@ import { vtkObject } from './../../interfaces';
12
12
  import { CaptureOn, ViewTypes } from './WidgetManager/Constants';
13
13
  import { Nullable } from './../../types';
14
14
 
15
+ export interface IDisplayScaleParams {
16
+ dispHeightFactor: number;
17
+ cameraPosition: number[];
18
+ cameraDir: number[];
19
+ isParallel: boolean;
20
+ rendererPixelDims: number[];
21
+ }
22
+
15
23
  export interface ISelectedData {
16
24
  requestCount: number;
17
25
  propID: number;
@@ -45,7 +53,10 @@ export function extractRenderingComponents(
45
53
  * (vertical) distance that matches a display distance of 30px for a coordinate
46
54
  * `coord`, you would compute `30 * getPixelWorldHeightAtCoord(coord)`.
47
55
  */
48
- export function getPixelWorldHeightAtCoord(coord: []): Number;
56
+ export function getPixelWorldHeightAtCoord(
57
+ coord: [],
58
+ displayScaleParams: IDisplayScaleParams
59
+ ): Number;
49
60
 
50
61
  export interface vtkWidgetManager extends vtkObject {
51
62
  /**
@@ -2,13 +2,7 @@ import vtkDataArray from './../../Common/Core/DataArray';
2
2
  import vtkPolyData from './../../Common/DataModel/PolyData';
3
3
  import { vtkObject } from './../../interfaces';
4
4
  import vtkProp from './../../Rendering/Core/Prop';
5
- export interface IDisplayScaleParams {
6
- dispHeightFactor: number;
7
- cameraPosition: number[];
8
- cameraDir: number[];
9
- isParallel: boolean;
10
- rendererPixelDims: number[];
11
- }
5
+ import { IDisplayScaleParams } from './../Core/WidgetManager';
12
6
 
13
7
  export interface IWidgetRepresentationInitialValues {
14
8
  labels?: Array<any>;
@@ -12,14 +12,7 @@ import vtkRenderer from './../../Rendering/Core/Renderer';
12
12
  import vtkPlaneManipulator from './../Manipulators/PlaneManipulator';
13
13
  import { ViewTypes } from './../Core/WidgetManager/Constants';
14
14
  import { Vector2, Vector3 } from './../../types';
15
-
16
- export interface IDisplayScaleParams {
17
- dispHeightFactor: number;
18
- cameraPosition: Vector3;
19
- cameraDir: Vector3;
20
- isParallel: false;
21
- rendererPixelDims: Vector2;
22
- }
15
+ import { IDisplayScaleParams } from './../Core/WidgetManager';
23
16
 
24
17
  export interface vtkResliceCursorWidget<
25
18
  WidgetInstance extends vtkAbstractWidget = vtkResliceCursorWidgetDefaultInstance
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "33.0.0-beta.3",
3
+ "version": "33.0.0-beta.4",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",
@@ -141,19 +141,20 @@
141
141
  "reformat-only": "prettier --single-quote --trailing-comma es5 --print-width 80 --arrow-parens always --write",
142
142
  "lint-fix": "eslint --fix Sources Examples",
143
143
  "lint": "eslint Sources Examples",
144
- "doc": "kw-doc -c ./Documentation/config.js",
145
- "doc:www": "npm t -- --single-run && kw-doc -c ./Documentation/config.js -s",
146
- "doc:minified": "kw-doc -c ./Documentation/config.js -m",
147
- "doc:generate-api": "node ./Documentation/generate-api-docs.js",
144
+ "doc": "npm run build:pre && kw-doc -c ./Documentation/config.js",
145
+ "doc:www": "npm t -- --single-run && npm run build:pre && kw-doc -c ./Documentation/config.js -s",
146
+ "doc:minified": "npm run build:pre && kw-doc -c ./Documentation/config.js -m",
147
+ "doc:generate-api": "npm run build:pre && node ./Documentation/generate-api-docs.js",
148
148
  "example": "node ./Utilities/ExampleRunner/example-runner-cli.js -c ./Documentation/config.js",
149
149
  "example:https": "node ./Utilities/ExampleRunner/example-runner-cli.js --server-type https -c ./Documentation/config.js",
150
150
  "example:webgpu": "cross-env WEBGPU=1 NO_WEBGL=1 node ./Utilities/ExampleRunner/example-runner-cli.js --server-type https -c ./Documentation/config.js",
151
+ "build:pre": "patch-package",
151
152
  "dev:esm": "npm run build:esm -- -w",
152
- "dev:umd": "webpack --watch --config webpack.dev.js --progress",
153
+ "dev:umd": "npm run build:pre && webpack --watch --config webpack.dev.js --progress",
153
154
  "build": "npm run build:release",
154
- "build:esm": "rollup -c rollup.config.js",
155
- "build:umd": "webpack --config webpack.prod.js --progress",
156
- "build:release": "npm run lint && concurrently \"cross-env NOLINT=1 npm run build:esm\" \"cross-env NOLINT=1 npm run build:umd\"",
155
+ "build:esm": "npm run build:pre && rollup -c rollup.config.js",
156
+ "build:umd": "npm run build:pre && webpack --config webpack.prod.js --progress",
157
+ "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\"",
157
158
  "release:create-packages": "node ./Utilities/ci/build-npm-package.js",
158
159
  "test": "karma start ./karma.conf.js",
159
160
  "test:headless": "karma start ./karma.conf.js --browsers ChromeHeadlessNoSandbox --single-run",
@@ -163,8 +164,7 @@
163
164
  "test:firefox-debug": "karma start ./karma.conf.js --browsers Firefox --no-single-run",
164
165
  "commit": "git cz",
165
166
  "semantic-release": "semantic-release",
166
- "prepare": "node ./Utilities/prepare.js",
167
- "postinstall": "patch-package"
167
+ "prepare": "node ./Utilities/prepare.js"
168
168
  },
169
169
  "config": {
170
170
  "commitizen": {