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

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 (41) hide show
  1. package/BREAKING_CHANGES.md +2 -0
  2. package/Common/Core/DataArray.d.ts +17 -0
  3. package/Common/Core/DataArray.js +36 -0
  4. package/Rendering/Core/AbstractImageMapper.d.ts +81 -0
  5. package/Rendering/Core/AbstractImageMapper.js +5 -2
  6. package/Rendering/Core/AbstractPicker.d.ts +13 -13
  7. package/Rendering/Core/AbstractPicker.js +1 -1
  8. package/Rendering/Core/Actor2D.d.ts +22 -0
  9. package/Rendering/Core/Actor2D.js +1 -1
  10. package/Rendering/Core/CellPicker.js +4 -1
  11. package/Rendering/Core/ImageCPRMapper.js +5 -4
  12. package/Rendering/Core/ImageProperty.d.ts +20 -1
  13. package/Rendering/Core/ImageProperty.js +7 -5
  14. package/Rendering/Core/ImageResliceMapper.d.ts +1 -2
  15. package/Rendering/Core/ImageResliceMapper.js +5 -4
  16. package/Rendering/Core/Viewport.js +13 -3
  17. package/Rendering/Core/VolumeMapper.d.ts +70 -0
  18. package/Rendering/Core/VolumeMapper.js +10 -5
  19. package/Rendering/Core/VolumeProperty.d.ts +20 -1
  20. package/Rendering/Core/VolumeProperty.js +7 -5
  21. package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager/CameraSynchronizer.js +2 -2
  22. package/Rendering/OpenGL/Framebuffer.js +7 -1
  23. package/Rendering/OpenGL/ImageCPRMapper.js +59 -7
  24. package/Rendering/OpenGL/ImageMapper.js +71 -9
  25. package/Rendering/OpenGL/ImageResliceMapper.js +60 -9
  26. package/Rendering/OpenGL/OrderIndependentTranslucentPass.js +20 -3
  27. package/Rendering/OpenGL/PolyDataMapper.js +7 -1
  28. package/Rendering/OpenGL/Renderer.js +1 -1
  29. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D/pingpong.js +7 -1
  30. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +20 -3
  31. package/Rendering/OpenGL/Texture.d.ts +131 -62
  32. package/Rendering/OpenGL/Texture.js +287 -48
  33. package/Rendering/OpenGL/VolumeMapper.js +70 -10
  34. package/Rendering/SceneGraph/ViewNode.js +12 -2
  35. package/Rendering/WebXR/RenderWindowHelper.js +9 -0
  36. package/Widgets/Core/WidgetManager.d.ts +12 -1
  37. package/Widgets/Representations/WidgetRepresentation.d.ts +1 -7
  38. package/Widgets/Widgets3D/ResliceCursorWidget.d.ts +1 -8
  39. package/macros.js +1 -1
  40. package/macros2.js +7 -2
  41. package/package.json +11 -11
@@ -1,6 +1,8 @@
1
1
  ## From 32.x to 33
2
2
 
3
3
  - **vtkMapper**: many properties have moved to `vtkVolumeProperty`. The full list of changed methods is: `getAnisotropy`, `getComputeNormalFromOpacity`, `getFilterMode`, `getFilterModeAsString`, `getGlobalIlluminationReach`, `getIpScalarRange`, `getIpScalarRangeByReference`, `getLAOKernelRadius`, `getLAOKernelSize`, `getLocalAmbientOcclusion`, `getPreferSizeOverAccuracy`, `getVolumetricScatteringBlending`, `setAnisotropy`, `setAverageIPScalarRange`, `setComputeNormalFromOpacity`, `setFilterMode`, `setFilterModeToNormalized`, `setFilterModeToOff`, `setFilterModeToRaw`, `setGlobalIlluminationReach`, `setIpScalarRange`, `setIpScalarRangeFrom`, `setLAOKernelRadius`, `setLAOKernelSize`, `setLocalAmbientOcclusion`, `setPreferSizeOverAccuracy`, `setVolumetricScatteringBlending`.
4
+ - **vtkOpenGLTexture**: The public `create2D*` and `create3D*` methods used to have positional parameters. These methods now use named parameters via passing in an object record.
5
+
4
6
  ## From 31.x to 32
5
7
 
6
8
  - **vtkMapper**: remove `mapScalarsToTexture` from the public API. The function becomes protected and its API changes. This shouldn't cause any issue in most cases.
@@ -83,6 +83,23 @@ export interface vtkDataArray extends vtkObject {
83
83
  */
84
84
  setRange(rangeValue: vtkRange, componentIndex: number): Range;
85
85
 
86
+ /**
87
+ * Returns an array of the ranges for each component of the DataArray.
88
+ * Defaults to computing all the ranges if they aren't already computed.
89
+ *
90
+ * If the number of components is greater than 1, the last element in the
91
+ * ranges array is the min,max magnitude of the dataset. This is the same as
92
+ * calling `getRange(-1)`.
93
+ *
94
+ * Passing `getRanges(false)` will return a clone of the ranges that have
95
+ * already been computed. This is useful when you want to avoid recomputing
96
+ * the ranges, which can be expensive.
97
+ *
98
+ * @param {boolean} [computeRanges] (default: true)
99
+ * @returns {vtkRange[]}
100
+ */
101
+ getRanges(computeRanges: boolean): vtkRange[];
102
+
86
103
  /**
87
104
  * Set the given tuple at the given index.
88
105
  * @param {Number} idx
@@ -268,6 +268,35 @@ function vtkDataArray(publicAPI, model) {
268
268
  model.rangeTuple[1] = range.max;
269
269
  return model.rangeTuple;
270
270
  };
271
+ publicAPI.getRanges = function () {
272
+ let computeRanges = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
273
+ if (!computeRanges) {
274
+ return structuredClone(model.ranges);
275
+ }
276
+ /** @type {import('../../../interfaces').vtkRange[]} */
277
+ const ranges = [];
278
+ for (let i = 0; i < model.numberOfComponents; i++) {
279
+ const [min, max] = publicAPI.getRange(i);
280
+ /** @type {import('../../../interfaces').vtkRange} */
281
+ const range = {
282
+ min,
283
+ max
284
+ };
285
+ ranges.push(range);
286
+ }
287
+ // where the number of components is greater than 1, the last element in
288
+ // the range array is the min,max magnitude of the entire dataset.
289
+ if (model.numberOfComponents > 1) {
290
+ const [min, max] = publicAPI.getRange(-1);
291
+ /** @type {import('../../../interfaces').vtkRange} */
292
+ const range = {
293
+ min,
294
+ max
295
+ };
296
+ ranges.push(range);
297
+ }
298
+ return ranges;
299
+ };
271
300
  publicAPI.setTuple = (idx, tuple) => {
272
301
  const offset = idx * model.numberOfComponents;
273
302
  for (let i = 0; i < model.numberOfComponents; i++) {
@@ -426,12 +455,19 @@ function vtkDataArray(publicAPI, model) {
426
455
  }
427
456
  return sortedObj;
428
457
  };
458
+
459
+ /**
460
+ * @param {import("./index").vtkDataArray} other
461
+ */
429
462
  publicAPI.deepCopy = other => {
430
463
  // Retain current dataType and array reference before shallowCopy call.
431
464
  const currentType = publicAPI.getDataType();
432
465
  const currentArray = model.values;
433
466
  publicAPI.shallowCopy(other);
434
467
 
468
+ // set the ranges
469
+ model.ranges = structuredClone(other.getRanges());
470
+
435
471
  // Avoid array reallocation if size already sufficient
436
472
  // and dataTypes match.
437
473
  if (currentArray?.length >= other.getNumberOfValues() && currentType === other.getDataType()) {
@@ -122,6 +122,87 @@ export interface vtkAbstractImageMapper extends vtkAbstractMapper3D {
122
122
  * @param customDisplayExtent
123
123
  */
124
124
  setCustomDisplayExtentFrom(customDisplayExtent: number[]): boolean;
125
+
126
+ /**
127
+ * Set the opacity texture width.
128
+ *
129
+ * The default width (1024) should be fine in most instances.
130
+ * Only set this property if your opacity function range width is
131
+ * larger than 1024.
132
+ *
133
+ * A reasonable max texture size would be either 2048 or 4096, as those
134
+ * widths are supported by the vast majority of devices. Any width larger
135
+ * than that will have issues with device support.
136
+ *
137
+ * Specifying a width that is less than or equal to 0 will use the largest
138
+ * possible texture width on the device. Use this with caution! The max texture
139
+ * width of one device may not be the same for another device.
140
+ *
141
+ * You can find more information about supported texture widths at the following link:
142
+ * https://web3dsurvey.com/webgl/parameters/MAX_TEXTURE_SIZE
143
+ *
144
+ * @param {Number} width the texture width (defaults to 1024)
145
+ */
146
+ setOpacityTextureWidth(width: number): boolean;
147
+
148
+ /**
149
+ * Get the opacity texture width.
150
+ */
151
+ getOpacityTextureWidth(): number;
152
+
153
+ /**
154
+ * Set the color texture width.
155
+ *
156
+ * The default width (1024) should be fine in most instances.
157
+ * Only set this property if your color transfer function range width is
158
+ * larger than 1024.
159
+ *
160
+ * A reasonable max texture size would be either 2048 or 4096, as those
161
+ * widths are supported by the vast majority of devices. Any width larger
162
+ * than that will have issues with device support.
163
+ *
164
+ * Specifying a width that is less than or equal to 0 will use the largest
165
+ * possible texture width on the device. Use this with caution! The max texture
166
+ * width of one device may not be the same for another device.
167
+ *
168
+ * You can find more information about supported texture widths at the following link:
169
+ * https://web3dsurvey.com/webgl/parameters/MAX_TEXTURE_SIZE
170
+ *
171
+ * @param {Number} width the texture width (defaults to 1024)
172
+ */
173
+ setColorTextureWidth(width: number): boolean;
174
+
175
+ /**
176
+ * Get the color texture width.
177
+ */
178
+ getColorTextureWidth(): number;
179
+
180
+ /**
181
+ * Set the label outline texture width.
182
+ *
183
+ * The default width (1024) should be fine in most instances.
184
+ * Only set this property if you have more than 1024 labels
185
+ * that you want to render with thickness.
186
+ *
187
+ * A reasonable max texture size would be either 2048 or 4096, as those
188
+ * widths are supported by the vast majority of devices. Any width larger
189
+ * than that will have issues with device support.
190
+ *
191
+ * Specifying a width that is less than or equal to 0 will use the largest
192
+ * possible texture width on the device. Use this with caution! The max texture
193
+ * width of one device may not be the same for another device.
194
+ *
195
+ * You can find more information about supported texture widths at the following link:
196
+ * https://web3dsurvey.com/webgl/parameters/MAX_TEXTURE_SIZE
197
+ *
198
+ * @param {Number} width the texture width (defaults to 1024)
199
+ */
200
+ setLabelOutlineTextureWidth(width: number): boolean;
201
+
202
+ /**
203
+ * Get the label outline texture width.
204
+ */
205
+ getLabelOutlineTextureWidth(): number;
125
206
  }
126
207
 
127
208
  /**
@@ -24,7 +24,10 @@ const DEFAULT_VALUES = {
24
24
  slice: 0,
25
25
  customDisplayExtent: [0, 0, 0, 0, 0, 0],
26
26
  useCustomExtents: false,
27
- backgroundColor: [0, 0, 0, 1]
27
+ backgroundColor: [0, 0, 0, 1],
28
+ colorTextureWidth: 1024,
29
+ opacityTextureWidth: 1024,
30
+ labelOutlineTextureWidth: 1024
28
31
  };
29
32
 
30
33
  // ----------------------------------------------------------------------------
@@ -35,7 +38,7 @@ function extend(publicAPI, model) {
35
38
 
36
39
  // Build VTK API
37
40
  vtkAbstractMapper3D.extend(publicAPI, model, initialValues);
38
- macro.setGet(publicAPI, model, ['slice', 'useCustomExtents']);
41
+ macro.setGet(publicAPI, model, ['slice', 'useCustomExtents', 'colorTextureWidth', 'opacityTextureWidth', 'labelOutlineTextureWidth']);
39
42
  macro.setGetArray(publicAPI, model, ['customDisplayExtent'], 6);
40
43
  macro.setGetArray(publicAPI, model, ['backgroundColor'], 4);
41
44
  vtkAbstractImageMapper(publicAPI, model);
@@ -1,6 +1,6 @@
1
1
  import { vtkObject } from './../../interfaces';
2
2
  import { Vector3 } from './../../types';
3
- import vtkActor from './Actor';
3
+ import vtkProp3D from './Prop3D';
4
4
  import vtkRenderer from './Renderer';
5
5
 
6
6
  /**
@@ -10,8 +10,8 @@ export interface IAbstractPickerInitialValues {
10
10
  renderer?: vtkRenderer;
11
11
  selectionPoint?: Vector3;
12
12
  pickPosition?: Vector3;
13
- pickFromList?: number;
14
- pickList?: vtkActor[];
13
+ pickFromList?: boolean;
14
+ pickList?: vtkProp3D[];
15
15
  }
16
16
 
17
17
  /**
@@ -20,15 +20,15 @@ export interface IAbstractPickerInitialValues {
20
20
  export interface vtkAbstractPicker extends vtkObject {
21
21
  /**
22
22
  *
23
- * @param {vtkActor} actor
23
+ * @param {vtkProp3D} prop
24
24
  */
25
- addPickList(actor: vtkActor): void;
25
+ addPickList(prop: vtkProp3D): void;
26
26
 
27
27
  /**
28
28
  *
29
- * @param {vtkActor} actor
29
+ * @param {vtkProp3D} prop
30
30
  */
31
- deletePickList(actor: vtkActor): void;
31
+ deletePickList(prop: vtkProp3D): void;
32
32
 
33
33
  /**
34
34
  *
@@ -38,7 +38,7 @@ export interface vtkAbstractPicker extends vtkObject {
38
38
  /**
39
39
  *
40
40
  */
41
- getPickList(): boolean;
41
+ getPickList(): vtkProp3D[];
42
42
 
43
43
  /**
44
44
  * Get the picked position
@@ -82,17 +82,17 @@ export interface vtkAbstractPicker extends vtkObject {
82
82
 
83
83
  /**
84
84
  *
85
- * @param {Number} pickFromList
86
- * @default 0
85
+ * @param {Boolean} pickFromList
86
+ * @default false
87
87
  */
88
- setPickFromList(pickFromList: number): boolean;
88
+ setPickFromList(pickFromList: boolean): boolean;
89
89
 
90
90
  /**
91
91
  *
92
- * @param {vtkActor[]} pickList
92
+ * @param {vtkProp3D[]} pickList
93
93
  * @default []
94
94
  */
95
- setPickList(pickList: vtkActor[]): boolean;
95
+ setPickList(pickList: vtkProp3D[]): boolean;
96
96
  }
97
97
 
98
98
  /**
@@ -38,7 +38,7 @@ const DEFAULT_VALUES = {
38
38
  renderer: null,
39
39
  selectionPoint: [0.0, 0.0, 0.0],
40
40
  pickPosition: [0.0, 0.0, 0.0],
41
- pickFromList: 0,
41
+ pickFromList: false,
42
42
  pickList: []
43
43
  };
44
44
 
@@ -54,6 +54,28 @@ export interface vtkActor2D extends vtkProp {
54
54
  */
55
55
  getMapper(): vtkMapper2D;
56
56
 
57
+ /**
58
+ * Set the layer number for this 2D actor.
59
+ * The scenegraph uses this layer number to sort actor 2D overlays/underlays on top of each other.
60
+ * The actor2D with the highest layer number is going to be rendered at the very front i.e. it is
61
+ * the top-most layer.
62
+ * If two actor2D instances share the same layer number, they are rendered in the order in which
63
+ * they were added to the renderer via `addActor` or `addActor2D`.
64
+ * By default, each actor2D has a layer number of 0.
65
+ */
66
+ setLayerNumber(layer: number): void;
67
+
68
+ /**
69
+ * Get the layer number for this 2D actor.
70
+ * The scenegraph uses this layer number to sort actor 2D overlays/underlays on top of each other.
71
+ * The actor2D with the highest layer number is going to be rendered at the very front i.e. it is
72
+ * the top-most layer.
73
+ * If two actor2D instances share the same layer number, they are rendered in the order in which
74
+ * they were added to the renderer via `addActor` or `addActor2D`.
75
+ * By default, each actor2D has a layer number of 0.
76
+ */
77
+ getLayerNumber(): number;
78
+
57
79
  /**
58
80
  *
59
81
  */
@@ -145,7 +145,7 @@ function extend(publicAPI, model) {
145
145
 
146
146
  // Build VTK API
147
147
  macro.set(publicAPI, model, ['property']);
148
- macro.setGet(publicAPI, model, ['mapper']);
148
+ macro.setGet(publicAPI, model, ['mapper', 'layerNumber']);
149
149
 
150
150
  // Object methods
151
151
  vtkActor2D(publicAPI, model);
@@ -219,7 +219,10 @@ function vtkCellPicker(publicAPI, model) {
219
219
 
220
220
  // calculate opacity table
221
221
  const numIComps = 1;
222
- const oWidth = 1024;
222
+ let oWidth = mapper.getOpacityTextureWidth();
223
+ if (oWidth <= 0) {
224
+ oWidth = 1024;
225
+ }
223
226
  const tmpTable = new Float32Array(oWidth);
224
227
  const opacityArray = new Float32Array(oWidth);
225
228
  let ofun;
@@ -270,7 +270,7 @@ function vtkImageCPRMapper(publicAPI, model) {
270
270
  // Object factory
271
271
  // ----------------------------------------------------------------------------
272
272
 
273
- const DEFAULT_VALUES = {
273
+ const defaultValues = initialValues => ({
274
274
  width: 10,
275
275
  uniformOrientation: [0, 0, 0, 1],
276
276
  useUniformOrientation: false,
@@ -282,14 +282,15 @@ const DEFAULT_VALUES = {
282
282
  normalDirection: [0, 0, 1],
283
283
  projectionSlabThickness: 1,
284
284
  projectionSlabNumberOfSamples: 1,
285
- projectionMode: ProjectionMode.MAX
286
- };
285
+ projectionMode: ProjectionMode.MAX,
286
+ ...initialValues
287
+ });
287
288
 
288
289
  // ----------------------------------------------------------------------------
289
290
 
290
291
  function extend(publicAPI, model) {
291
292
  let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
292
- Object.assign(model, DEFAULT_VALUES, initialValues);
293
+ Object.assign(model, defaultValues(initialValues));
293
294
 
294
295
  // Inheritance
295
296
  vtkAbstractImageMapper.extend(publicAPI, model, initialValues);
@@ -1,5 +1,5 @@
1
1
  import { vtkObject } from './../../interfaces';
2
- import { Nullable } from './../../types';
2
+ import { Extent, Nullable } from './../../types';
3
3
  import vtkColorTransferFunction from './ColorTransferFunction';
4
4
  import vtkPiecewiseFunction from './../../Common/DataModel/PiecewiseFunction';
5
5
  import { InterpolationType } from './ImageProperty/Constants';
@@ -231,6 +231,25 @@ export interface vtkImageProperty extends vtkObject {
231
231
  * @param {Boolean} useLookupTableScalarRange
232
232
  */
233
233
  setUseLookupTableScalarRange(useLookupTableScalarRange: boolean): boolean;
234
+
235
+ /**
236
+ * Informs the mapper to only update the specified extents at the next render.
237
+ *
238
+ * If there are zero extents, the mapper updates the entire volume texture.
239
+ * Otherwise, the mapper will only update the texture by the specified extents
240
+ * during the next render call.
241
+ *
242
+ * This array is cleared after a successful render.
243
+ * @param extents
244
+ */
245
+ setUpdatedExtents(extents: Extent[]): boolean;
246
+
247
+ /**
248
+ * Retrieves the updated extents.
249
+ *
250
+ * This array is cleared after every successful render.
251
+ */
252
+ getUpdatedExtents(): Extent[];
234
253
  }
235
254
 
236
255
  /**
@@ -136,7 +136,7 @@ function vtkImageProperty(publicAPI, model) {
136
136
  // ----------------------------------------------------------------------------
137
137
  // Object factory
138
138
  // ----------------------------------------------------------------------------
139
- const DEFAULT_VALUES = {
139
+ const defaultValues = initialValues => ({
140
140
  independentComponents: false,
141
141
  interpolationType: InterpolationType.LINEAR,
142
142
  colorWindow: 255,
@@ -147,14 +147,16 @@ const DEFAULT_VALUES = {
147
147
  useLookupTableScalarRange: false,
148
148
  useLabelOutline: false,
149
149
  labelOutlineThickness: [1],
150
- labelOutlineOpacity: 1.0
151
- };
150
+ labelOutlineOpacity: 1.0,
151
+ updatedExtents: [],
152
+ ...initialValues
153
+ });
152
154
 
153
155
  // ----------------------------------------------------------------------------
154
156
 
155
157
  function extend(publicAPI, model) {
156
158
  let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
157
- Object.assign(model, DEFAULT_VALUES, initialValues);
159
+ Object.assign(model, defaultValues(initialValues));
158
160
 
159
161
  // Build VTK API
160
162
  macro.obj(publicAPI, model);
@@ -168,7 +170,7 @@ function extend(publicAPI, model) {
168
170
  });
169
171
  }
170
172
  }
171
- macro.setGet(publicAPI, model, ['independentComponents', 'interpolationType', 'colorWindow', 'colorLevel', 'ambient', 'diffuse', 'opacity', 'useLookupTableScalarRange', 'useLabelOutline', 'labelOutlineOpacity']);
173
+ macro.setGet(publicAPI, model, ['independentComponents', 'interpolationType', 'colorWindow', 'colorLevel', 'ambient', 'diffuse', 'opacity', 'useLookupTableScalarRange', 'useLabelOutline', 'labelOutlineOpacity', 'updatedExtents']);
172
174
  macro.setGetArray(publicAPI, model, ['labelOutlineThickness']);
173
175
 
174
176
  // Object methods
@@ -1,10 +1,9 @@
1
1
  import vtkAbstractImageMapper, {
2
2
  IAbstractImageMapperInitialValues,
3
3
  } from './AbstractImageMapper';
4
- import vtkImageData from './../../Common/DataModel/ImageData';
5
4
  import vtkPlane from './../../Common/DataModel/Plane';
6
5
  import vtkPolyData from './../../Common/DataModel/PolyData';
7
- import { Bounds, Nullable, Vector3 } from './../../types';
6
+ import { Bounds } from './../../types';
8
7
  import { SlabTypes } from './ImageResliceMapper/Constants';
9
8
  import CoincidentTopologyHelper, {
10
9
  StaticCoincidentTopologyMethods,
@@ -38,19 +38,20 @@ function vtkImageResliceMapper(publicAPI, model) {
38
38
  // Object factory
39
39
  // ----------------------------------------------------------------------------
40
40
 
41
- const DEFAULT_VALUES = {
41
+ const defaultValues = initialValues => ({
42
42
  slabThickness: 0.0,
43
43
  slabTrapezoidIntegration: 0,
44
44
  slabType: SlabTypes.MEAN,
45
45
  slicePlane: null,
46
- slicePolyData: null
47
- };
46
+ slicePolyData: null,
47
+ ...initialValues
48
+ });
48
49
 
49
50
  // ----------------------------------------------------------------------------
50
51
 
51
52
  function extend(publicAPI, model) {
52
53
  let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
53
- Object.assign(model, DEFAULT_VALUES, initialValues);
54
+ Object.assign(model, defaultValues(initialValues));
54
55
 
55
56
  // Build VTK API
56
57
  vtkAbstractImageMapper.extend(publicAPI, model, initialValues);
@@ -46,10 +46,20 @@ function vtkViewport(publicAPI, model) {
46
46
  return allProps;
47
47
  }
48
48
  publicAPI.getViewPropsWithNestedProps = () => {
49
- const allPropsArray = [];
50
- for (let i = 0; i < model.props.length; i++) {
51
- gatherProps(model.props[i], allPropsArray);
49
+ let allPropsArray = [];
50
+ // Handle actor2D instances separately so that they can be overlayed and layered
51
+ const actors2D = publicAPI.getActors2D();
52
+ // Sort the actor2D list using its layer number
53
+ actors2D.sort((a, b) => a.getLayerNumber() - b.getLayerNumber());
54
+ // Filter out all the actor2D instances
55
+ const newPropList = model.props.filter(item => !actors2D.includes(item));
56
+ for (let i = 0; i < newPropList.length; i++) {
57
+ gatherProps(newPropList[i], allPropsArray);
52
58
  }
59
+ // Finally, add the actor2D props at the end of the list
60
+ // This works because, when traversing the render pass in vtkOpenGLRenderer, the children are
61
+ // traversed in the order that they are added to the list
62
+ allPropsArray = allPropsArray.concat(actors2D);
53
63
  return allPropsArray;
54
64
  };
55
65
  publicAPI.addActor2D = publicAPI.addViewProp;
@@ -162,6 +162,76 @@ export interface vtkVolumeMapper extends vtkAbstractMapper3D {
162
162
  *
163
163
  */
164
164
  update(): void;
165
+
166
+ /**
167
+ * Set the opacity texture width.
168
+ *
169
+ * The default width (1024) should be fine in most instances.
170
+ * Only set this property if your opacity function range width is
171
+ * larger than 1024.
172
+ *
173
+ * @param {Number} width the texture width (defaults to 1024)
174
+ */
175
+ setOpacityTextureWidth(width: number): boolean;
176
+
177
+ /**
178
+ * Get the opacity texture width.
179
+ */
180
+ getOpacityTextureWidth(): number;
181
+
182
+ /**
183
+ * Set the color texture width.
184
+ *
185
+ * The default width (1024) should be fine in most instances.
186
+ * Only set this property if your color transfer function range width is
187
+ * larger than 1024.
188
+ *
189
+ * A reasonable max texture size would be either 2048 or 4096, as those
190
+ * widths are supported by the vast majority of devices. Any width larger
191
+ * than that will have issues with device support.
192
+ *
193
+ * Specifying a width that is less than or equal to 0 will use the largest
194
+ * possible texture width on the device. Use this with caution! The max texture
195
+ * width of one device may not be the same for another device.
196
+ *
197
+ * You can find more information about supported texture widths at the following link:
198
+ * https://web3dsurvey.com/webgl/parameters/MAX_TEXTURE_SIZE
199
+ *
200
+ * @param {Number} width the texture width (defaults to 1024)
201
+ */
202
+ setColorTextureWidth(width: number): boolean;
203
+
204
+ /**
205
+ * Get the color texture width.
206
+ */
207
+ getColorTextureWidth(): number;
208
+
209
+ /**
210
+ * Set the label outline texture width.
211
+ *
212
+ * The default width (1024) should be fine in most instances.
213
+ * Only set this property if you have more than 1024 labels
214
+ * that you want to render with thickness.
215
+ *
216
+ * A reasonable max texture size would be either 2048 or 4096, as those
217
+ * widths are supported by the vast majority of devices. Any width larger
218
+ * than that will have issues with device support.
219
+ *
220
+ * Specifying a width that is less than or equal to 0 will use the largest
221
+ * possible texture width on the device. Use this with caution! The max texture
222
+ * width of one device may not be the same for another device.
223
+ *
224
+ * You can find more information about supported texture widths at the following link:
225
+ * https://web3dsurvey.com/webgl/parameters/MAX_TEXTURE_SIZE
226
+ *
227
+ * @param {Number} width the texture width (defaults to 1024)
228
+ */
229
+ setLabelOutlineTextureWidth(width: number): boolean;
230
+
231
+ /**
232
+ * Get the label outline texture width.
233
+ */
234
+ getLabelOutlineTextureWidth(): number;
165
235
  }
166
236
 
167
237
  /**
@@ -81,7 +81,8 @@ function vtkVolumeMapper(publicAPI, model) {
81
81
  // Object factory
82
82
  // ----------------------------------------------------------------------------
83
83
 
84
- const DEFAULT_VALUES = {
84
+ // TODO: what values to use for averageIPScalarRange to get GLSL to use max / min values like [-Math.inf, Math.inf]?
85
+ const defaultValues = initialValues => ({
85
86
  bounds: [...vtkBoundingBox.INIT_BOUNDS],
86
87
  sampleDistance: 1.0,
87
88
  imageSampleDistance: 1.0,
@@ -90,16 +91,20 @@ const DEFAULT_VALUES = {
90
91
  initialInteractionScale: 1.0,
91
92
  interactionSampleDistanceFactor: 1.0,
92
93
  blendMode: BlendMode.COMPOSITE_BLEND,
93
- volumeShadowSamplingDistFactor: 5.0
94
- };
94
+ volumeShadowSamplingDistFactor: 5.0,
95
+ colorTextureWidth: 1024,
96
+ opacityTextureWidth: 1024,
97
+ labelOutlineTextureWidth: 1024,
98
+ ...initialValues
99
+ });
95
100
 
96
101
  // ----------------------------------------------------------------------------
97
102
 
98
103
  function extend(publicAPI, model) {
99
104
  let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
100
- Object.assign(model, DEFAULT_VALUES, initialValues);
105
+ Object.assign(model, defaultValues(initialValues));
101
106
  vtkAbstractMapper3D.extend(publicAPI, model, initialValues);
102
- macro.setGet(publicAPI, model, ['sampleDistance', 'imageSampleDistance', 'maximumSamplesPerRay', 'autoAdjustSampleDistances', 'initialInteractionScale', 'interactionSampleDistanceFactor', 'blendMode', 'volumeShadowSamplingDistFactor']);
107
+ macro.setGet(publicAPI, model, ['sampleDistance', 'imageSampleDistance', 'maximumSamplesPerRay', 'autoAdjustSampleDistances', 'initialInteractionScale', 'interactionSampleDistanceFactor', 'blendMode', 'volumeShadowSamplingDistFactor', 'colorTextureWidth', 'opacityTextureWidth', 'labelOutlineTextureWidth']);
103
108
  macro.event(publicAPI, model, 'lightingActivated');
104
109
 
105
110
  // Object methods
@@ -1,6 +1,6 @@
1
1
  import vtkPiecewiseFunction from './../../Common/DataModel/PiecewiseFunction';
2
2
  import { vtkObject } from './../../interfaces';
3
- import { Nullable } from './../../types';
3
+ import { Extent, Nullable } from './../../types';
4
4
  import vtkColorTransferFunction from './ColorTransferFunction';
5
5
  import { ColorMixPreset, InterpolationType, OpacityMode } from './VolumeProperty/Constants';
6
6
 
@@ -486,6 +486,25 @@ export interface vtkVolumeProperty extends vtkObject {
486
486
  * @param LAOKernelRadius
487
487
  */
488
488
  setLAOKernelRadius(LAOKernelRadius: number): void;
489
+
490
+ /**
491
+ * Informs the mapper to only update the specified extents at the next render.
492
+ *
493
+ * If there are zero extents, the mapper updates the entire volume texture.
494
+ * Otherwise, the mapper will only update the texture by the specified extents
495
+ * during the next render call.
496
+ *
497
+ * This array is cleared after a successful render.
498
+ * @param extents
499
+ */
500
+ setUpdatedExtents(extents: Extent[]): boolean;
501
+
502
+ /**
503
+ * Retrieves the updated extents.
504
+ *
505
+ * This array is cleared after every successful render.
506
+ */
507
+ getUpdatedExtents(): Extent[];
489
508
  }
490
509
 
491
510
  /**