@kitware/vtk.js 33.0.0-beta.4 → 33.0.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.
Files changed (44) hide show
  1. package/BREAKING_CHANGES.md +0 -3
  2. package/Common/Core/ScalarsToColors/Constants.js +7 -2
  3. package/Common/Core/ScalarsToColors.js +3 -1
  4. package/Rendering/Core/Actor.d.ts +20 -5
  5. package/Rendering/Core/Actor.js +68 -5
  6. package/Rendering/Core/ColorTransferFunction.js +26 -35
  7. package/Rendering/Core/ImageCPRMapper.d.ts +20 -1
  8. package/Rendering/Core/ImageCPRMapper.js +2 -1
  9. package/Rendering/Core/ImageProperty.d.ts +1 -20
  10. package/Rendering/Core/ImageProperty.js +5 -7
  11. package/Rendering/Core/ImageResliceMapper.d.ts +20 -1
  12. package/Rendering/Core/ImageResliceMapper.js +2 -1
  13. package/Rendering/Core/ImageSlice.d.ts +23 -7
  14. package/Rendering/Core/ImageSlice.js +68 -9
  15. package/Rendering/Core/Mapper.js +8 -16
  16. package/Rendering/Core/Prop3D.d.ts +2 -39
  17. package/Rendering/Core/Prop3D.js +2 -81
  18. package/Rendering/Core/ScalarBarActor.js +4 -2
  19. package/Rendering/Core/Volume.d.ts +20 -5
  20. package/Rendering/Core/Volume.js +70 -2
  21. package/Rendering/Core/VolumeMapper/Constants.d.ts +7 -0
  22. package/Rendering/Core/VolumeMapper/Constants.js +8 -2
  23. package/Rendering/Core/VolumeMapper.d.ts +173 -16
  24. package/Rendering/Core/VolumeMapper.js +51 -16
  25. package/Rendering/Core/VolumeProperty/Constants.d.ts +3 -12
  26. package/Rendering/Core/VolumeProperty/Constants.js +4 -11
  27. package/Rendering/Core/VolumeProperty.d.ts +5 -140
  28. package/Rendering/Core/VolumeProperty.js +7 -54
  29. package/Rendering/OpenGL/CellArrayBufferObject/helpers.js +45 -0
  30. package/Rendering/OpenGL/CellArrayBufferObject.js +6 -25
  31. package/Rendering/OpenGL/ImageCPRMapper.js +21 -30
  32. package/Rendering/OpenGL/ImageMapper.js +27 -27
  33. package/Rendering/OpenGL/ImageResliceMapper.js +183 -271
  34. package/Rendering/OpenGL/PolyDataMapper.js +8 -1
  35. package/Rendering/OpenGL/RenderWindow/resourceSharingHelper.d.ts +3 -3
  36. package/Rendering/OpenGL/RenderWindow/resourceSharingHelper.js +5 -8
  37. package/Rendering/OpenGL/SphereMapper.js +33 -13
  38. package/Rendering/OpenGL/VolumeMapper.js +784 -722
  39. package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
  40. package/Rendering/WebGPU/VolumePassFSQ.js +2 -2
  41. package/index.d.ts +0 -1
  42. package/macros2.js +1 -1
  43. package/package.json +1 -1
  44. package/Interaction/Manipulators/KeyboardCameraManipulator.d.ts +0 -113
@@ -2,7 +2,7 @@ import { mat3, mat4, vec3 } from 'gl-matrix';
2
2
  import { n as newInstance$1, e as setGet, o as obj, c as macro } from '../../macros2.js';
3
3
  import vtkHelper from './Helper.js';
4
4
  import vtkMapper from '../Core/Mapper.js';
5
- import { l as normalize } from '../../Common/Core/Math/index.js';
5
+ import { l as normalize, u as uninitializeBounds } from '../../Common/Core/Math/index.js';
6
6
  import vtkOpenGLTexture from './Texture.js';
7
7
  import vtkProp from '../Core/Prop.js';
8
8
  import vtkProperty from '../Core/Property.js';
@@ -941,6 +941,13 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
941
941
  publicAPI.renderPieceDraw(ren, actor);
942
942
  publicAPI.renderPieceFinish(ren, actor);
943
943
  };
944
+ publicAPI.computeBounds = (ren, actor) => {
945
+ if (!publicAPI.getInput()) {
946
+ uninitializeBounds(model.bounds);
947
+ return;
948
+ }
949
+ model.bounds = publicAPI.getInput().getBounds();
950
+ };
944
951
  publicAPI.updateBufferObjects = (ren, actor) => {
945
952
  // Rebuild buffers if needed
946
953
  if (publicAPI.getNeedToRebuildBufferObjects(ren, actor)) {
@@ -9,8 +9,8 @@ import { vtkObject } from '../../../interfaces';
9
9
  * @param useIndependentComponents A boolean taken from the image or volume property, using getIndependentComponents()
10
10
  * @param numberOfComponents Taken from the data array, using getNumberOfComponents()
11
11
  */
12
- export function getTransferFunctionsHash(
13
- transferFunctions: (vtkObject | null | undefined)[],
12
+ export function getTransferFunctionHash(
13
+ transferFunction: vtkObject | undefined,
14
14
  useIndependentComponents: boolean,
15
15
  numberOfComponents: number
16
16
  ): string;
@@ -27,7 +27,7 @@ export function getImageDataHash(
27
27
  ): string;
28
28
 
29
29
  declare const defaultExport: {
30
- getTransferFunctionsHash: typeof getTransferFunctionsHash;
30
+ getTransferFunctionHash: typeof getTransferFunctionHash;
31
31
  getImageDataHash: typeof getImageDataHash;
32
32
  };
33
33
 
@@ -1,17 +1,14 @@
1
1
  // See typescript header for documentation
2
2
 
3
- function getTransferFunctionsHash(transferFunctions, useIndependentComponents, numberOfComponents) {
4
- return transferFunctions.length > 0 ? `${transferFunctions.map(tf => tf?.getMTime() ?? 'x').join('/')}-${useIndependentComponents}-${numberOfComponents}` : '0';
3
+ function getTransferFunctionHash(transferFunction, useIndependentComponents, numberOfComponents) {
4
+ return transferFunction ? `${transferFunction.getMTime()}-${useIndependentComponents}-${numberOfComponents}` : '0';
5
5
  }
6
6
  function getImageDataHash(image, scalars) {
7
- // Don't use the image data, as the scalars will define the texture
8
- // If using the image data in the hash, it will cause issues when two image data
9
- // using the same scalars are in the same mapper (for example the VolumeMapper)
10
- return `${scalars.getMTime()}`;
7
+ return `${image.getMTime()}A${scalars.getMTime()}`;
11
8
  }
12
9
  var resourceSharingHelper = {
13
- getTransferFunctionsHash,
10
+ getTransferFunctionHash,
14
11
  getImageDataHash
15
12
  };
16
13
 
17
- export { resourceSharingHelper as default, getImageDataHash, getTransferFunctionsHash };
14
+ export { resourceSharingHelper as default, getImageDataHash, getTransferFunctionHash };
@@ -8,6 +8,7 @@ import vtkOpenGLPolyDataMapper from './PolyDataMapper.js';
8
8
  import { v as vtkSphereMapperVS } from './glsl/vtkSphereMapperVS.glsl.js';
9
9
  import { v as vtkPolyDataFS } from './glsl/vtkPolyDataFS.glsl.js';
10
10
  import { registerOverride } from './ViewNodeFactory.js';
11
+ import { computeCoordShiftAndScale } from './CellArrayBufferObject/helpers.js';
11
12
 
12
13
  const {
13
14
  vtkErrorMacro
@@ -112,14 +113,24 @@ function vtkOpenGLSphereMapper(publicAPI, model) {
112
113
  if (program.isUniformUsed('VCPCMatrix')) {
113
114
  program.setUniformMatrix('VCPCMatrix', keyMats.vcpc);
114
115
  }
116
+
117
+ // mat4.create() defaults to Float32Array b/c of gl-matrix's settings.
118
+ // We need Float64Array to avoid loss of precision with large coordinates.
119
+ const tmp4 = new Float64Array(16);
115
120
  if (program.isUniformUsed('MCVCMatrix')) {
116
121
  if (!actor.getIsIdentity()) {
117
122
  const actMats = model.openGLActor.getKeyMatrices();
118
- const tmp4 = new Float64Array(16);
119
123
  mat4.multiply(tmp4, keyMats.wcvc, actMats.mcwc);
124
+ if (cellBO.getCABO().getCoordShiftAndScaleEnabled()) {
125
+ mat4.multiply(tmp4, tmp4, cellBO.getCABO().getInverseShiftAndScaleMatrix());
126
+ }
120
127
  program.setUniformMatrix('MCVCMatrix', tmp4);
121
128
  } else {
122
- program.setUniformMatrix('MCVCMatrix', keyMats.wcvc);
129
+ mat4.copy(tmp4, keyMats.wcvc);
130
+ if (cellBO.getCABO().getCoordShiftAndScaleEnabled()) {
131
+ mat4.multiply(tmp4, tmp4, cellBO.getCABO().getInverseShiftAndScaleMatrix());
132
+ }
133
+ program.setUniformMatrix('MCVCMatrix', tmp4);
123
134
  }
124
135
  }
125
136
  if (program.isUniformUsed('cameraParallel')) {
@@ -166,6 +177,14 @@ function vtkOpenGLSphereMapper(publicAPI, model) {
166
177
  const cos30 = Math.cos(radiansFromDegrees(30.0));
167
178
  let pointIdx = 0;
168
179
  let colorIdx = 0;
180
+ const {
181
+ useShiftAndScale,
182
+ coordShift,
183
+ coordScale
184
+ } = computeCoordShiftAndScale(points);
185
+ if (useShiftAndScale) {
186
+ vbo.setCoordShiftAndScale(coordShift, coordScale);
187
+ }
169
188
 
170
189
  //
171
190
  // Generate points and point data for sides
@@ -178,9 +197,12 @@ function vtkOpenGLSphereMapper(publicAPI, model) {
178
197
  radius = scales[i];
179
198
  }
180
199
  pointIdx = i * 3;
181
- packedVBO[vboIdx++] = pointArray[pointIdx++];
182
- packedVBO[vboIdx++] = pointArray[pointIdx++];
183
- packedVBO[vboIdx++] = pointArray[pointIdx++];
200
+ const ptX = (pointArray[pointIdx++] - coordShift[0]) * coordScale[0];
201
+ const ptY = (pointArray[pointIdx++] - coordShift[1]) * coordScale[1];
202
+ const ptZ = (pointArray[pointIdx++] - coordShift[2]) * coordScale[2];
203
+ packedVBO[vboIdx++] = ptX;
204
+ packedVBO[vboIdx++] = ptY;
205
+ packedVBO[vboIdx++] = ptZ;
184
206
  packedVBO[vboIdx++] = -2.0 * radius * cos30;
185
207
  packedVBO[vboIdx++] = -radius;
186
208
  if (colorData) {
@@ -190,10 +212,9 @@ function vtkOpenGLSphereMapper(publicAPI, model) {
190
212
  packedUCVBO[ucIdx++] = colorData[colorIdx + 2];
191
213
  packedUCVBO[ucIdx++] = colorData[colorIdx + 3];
192
214
  }
193
- pointIdx = i * 3;
194
- packedVBO[vboIdx++] = pointArray[pointIdx++];
195
- packedVBO[vboIdx++] = pointArray[pointIdx++];
196
- packedVBO[vboIdx++] = pointArray[pointIdx++];
215
+ packedVBO[vboIdx++] = ptX;
216
+ packedVBO[vboIdx++] = ptY;
217
+ packedVBO[vboIdx++] = ptZ;
197
218
  packedVBO[vboIdx++] = 2.0 * radius * cos30;
198
219
  packedVBO[vboIdx++] = -radius;
199
220
  if (colorData) {
@@ -202,10 +223,9 @@ function vtkOpenGLSphereMapper(publicAPI, model) {
202
223
  packedUCVBO[ucIdx++] = colorData[colorIdx + 2];
203
224
  packedUCVBO[ucIdx++] = colorData[colorIdx + 3];
204
225
  }
205
- pointIdx = i * 3;
206
- packedVBO[vboIdx++] = pointArray[pointIdx++];
207
- packedVBO[vboIdx++] = pointArray[pointIdx++];
208
- packedVBO[vboIdx++] = pointArray[pointIdx++];
226
+ packedVBO[vboIdx++] = ptX;
227
+ packedVBO[vboIdx++] = ptY;
228
+ packedVBO[vboIdx++] = ptZ;
209
229
  packedVBO[vboIdx++] = 0.0;
210
230
  packedVBO[vboIdx++] = 2.0 * radius;
211
231
  if (colorData) {