@kitware/vtk.js 32.5.0 → 33.0.0-beta.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.
@@ -8,14 +8,7 @@ export declare enum BlendMode {
8
8
  LABELMAP_EDGE_PROJECTION_BLEND = 6,
9
9
  }
10
10
 
11
- export declare enum FilterMode {
12
- OFF = 0,
13
- NORMALIZED = 1,
14
- RAW = 2,
15
- }
16
-
17
11
  declare const _default: {
18
12
  BlendMode: typeof BlendMode;
19
- FilterMode: typeof FilterMode;
20
13
  };
21
14
  export default _default;
@@ -7,14 +7,8 @@ const BlendMode = {
7
7
  RADON_TRANSFORM_BLEND: 5,
8
8
  LABELMAP_EDGE_PROJECTION_BLEND: 6
9
9
  };
10
- const FilterMode = {
11
- OFF: 0,
12
- NORMALIZED: 1,
13
- RAW: 2
14
- };
15
10
  var Constants = {
16
- BlendMode,
17
- FilterMode
11
+ BlendMode
18
12
  };
19
13
 
20
- export { BlendMode, FilterMode, Constants as default };
14
+ export { BlendMode, Constants as default };
@@ -1,29 +1,21 @@
1
1
  import vtkPiecewiseFunction from './../../Common/DataModel/PiecewiseFunction';
2
- import { Bounds, Range } from './../../types';
2
+ import { Bounds } from './../../types';
3
3
  import vtkAbstractMapper3D, {
4
4
  IAbstractMapper3DInitialValues,
5
5
  } from './AbstractMapper3D';
6
- import { BlendMode, FilterMode } from './VolumeMapper/Constants';
6
+ import { BlendMode } from './VolumeMapper/Constants';
7
7
 
8
8
  /**
9
9
  *
10
10
  */
11
11
  export interface IVolumeMapperInitialValues
12
12
  extends IAbstractMapper3DInitialValues {
13
- anisotropy?: number;
14
13
  autoAdjustSampleDistances?: boolean;
15
- averageIPScalarRange?: Range;
16
14
  blendMode?: BlendMode;
17
15
  bounds?: Bounds;
18
- computeNormalFromOpacity?: boolean;
19
- getVolumeShadowSamplingDistFactor?: number;
20
- globalIlluminationReach?: number;
21
- imageSampleDistance?: number;
22
- localAmbientOcclusion?: boolean;
23
16
  maximumSamplesPerRay?: number;
24
17
  sampleDistance?: number;
25
- LAOKernelRadius?: number;
26
- LAOKernelSize?: number;
18
+ volumeShadowSamplingDistFactor?: number;
27
19
  }
28
20
 
29
21
  export interface vtkVolumeMapper extends vtkAbstractMapper3D {
@@ -49,6 +41,12 @@ export interface vtkVolumeMapper extends vtkAbstractMapper3D {
49
41
  */
50
42
  getSampleDistance(): number;
51
43
 
44
+ /**
45
+ * Get the multipler for volume shadow sampling distance
46
+ * @default 5.0
47
+ */
48
+ getVolumeShadowSamplingDistFactor(): number;
49
+
52
50
  /**
53
51
  * Sampling distance in the XY image dimensions.
54
52
  * Default value of 1 meaning 1 ray cast per pixel. If set to 0.5, 4 rays will be cast per pixel.
@@ -84,71 +82,6 @@ export interface vtkVolumeMapper extends vtkAbstractMapper3D {
84
82
  */
85
83
  getInteractionSampleDistanceFactor(): number;
86
84
 
87
- /**
88
- *
89
- */
90
- getAverageIPScalarRange(): Range;
91
-
92
- /**
93
- *
94
- */
95
- getAverageIPScalarRangeByReference(): Range;
96
-
97
- /**
98
- * Get the blending coefficient that interpolates between surface and volume rendering
99
- * @default 0.0
100
- */
101
- getVolumetricScatteringBlending(): number;
102
-
103
- /**
104
- * Get the global illumination reach of volume shadow
105
- * @default 0.0
106
- */
107
- getGlobalIlluminationReach(): number;
108
-
109
- /**
110
- * Get the multipler for volume shadow sampling distance
111
- * @default 5.0
112
- */
113
- getVolumeShadowSamplingDistFactor(): number;
114
-
115
- /**
116
- * Get anisotropy of volume shadow scatter
117
- * @default 0.0
118
- */
119
- getAnisotropy(): number;
120
-
121
- /**
122
- * Get local ambient occlusion flag
123
- * @default false
124
- */
125
- getLocalAmbientOcclusion(): boolean;
126
-
127
- /**
128
- * Get kernel size for local ambient occlusion
129
- * @default 15
130
- */
131
- getLAOKernelSize(): number;
132
-
133
- /**
134
- * Get kernel radius for local ambient occlusion
135
- * @default 7
136
- */
137
- getLAOKernelRadius(): number;
138
-
139
- /**
140
- *
141
- * @param x
142
- * @param y
143
- */
144
- setAverageIPScalarRange(x: number, y: number): boolean;
145
-
146
- /**
147
- *
148
- * @param {Range} averageIPScalarRange
149
- */
150
- setAverageIPScalarRangeFrom(averageIPScalarRange: Range): boolean;
151
-
152
85
  /**
153
86
  * Set blend mode to COMPOSITE_BLEND
154
87
  * @param {BlendMode} blendMode
@@ -186,6 +119,13 @@ export interface vtkVolumeMapper extends vtkAbstractMapper3D {
186
119
  */
187
120
  setSampleDistance(sampleDistance: number): boolean;
188
121
 
122
+ /**
123
+ * Set the multipler for volume shadow sampling distance. This function is only effective when volumeScatterBlendCoef is greater than 0.
124
+ * For VSSampleDistanceFactor >= 1.0, volume shadow sampling distance = VSSampleDistanceFactor * SampleDistance.
125
+ * @param VSSampleDistanceFactor
126
+ */
127
+ setVolumeShadowSamplingDistFactor(VSSampleDistanceFactor: number): void;
128
+
189
129
  /**
190
130
  *
191
131
  * @param imageSampleDistance
@@ -218,69 +158,6 @@ export interface vtkVolumeMapper extends vtkAbstractMapper3D {
218
158
  interactionSampleDistanceFactor: number
219
159
  ): boolean;
220
160
 
221
- /**
222
- * Set the normal computation to be dependent on the transfer function.
223
- * By default, the mapper relies on the scalar gradient for computing normals at sample locations
224
- * for lighting calculations. This is an approximation and can lead to inaccurate results.
225
- * When enabled, this property makes the mapper compute normals based on the accumulated opacity
226
- * at sample locations. This can generate a more accurate representation of edge structures in the
227
- * data but adds an overhead and drops frame rate.
228
- * @param computeNormalFromOpacity
229
- */
230
- setComputeNormalFromOpacity(computeNormalFromOpacity: boolean): boolean;
231
-
232
- /**
233
- * Set the blending coefficient that determines the interpolation between surface and volume rendering.
234
- * Default value of 0.0 means shadow effect is computed with phong model.
235
- * Value of 1.0 means shadow is created by volume occlusion.
236
- * @param volumeScatterBlendCoef
237
- */
238
- setVolumetricScatteringBlending(volumeScatterBlendCoef: number): void;
239
-
240
- /**
241
- * Set the global illumination reach of volume shadow. This function is only effective when volumeScatterBlendCoef is greater than 0.
242
- * Default value of 0.0 means only the neighboring voxel is considered when creating global shadow.
243
- * Value of 1.0 means the shadow ray traverses through the entire volume.
244
- * @param globalIlluminationReach
245
- */
246
- setGlobalIlluminationReach(globalIlluminationReach: number): void;
247
-
248
- /**
249
- * Set the multipler for volume shadow sampling distance. This function is only effective when volumeScatterBlendCoef is greater than 0.
250
- * For VSSampleDistanceFactor >= 1.0, volume shadow sampling distance = VSSampleDistanceFactor * SampleDistance.
251
- * @param VSSampleDistanceFactor
252
- */
253
- setVolumeShadowSamplingDistFactor(VSSampleDistanceFactor: number): void;
254
-
255
- /**
256
- * Set anisotropy of volume shadow scatter. This function is only effective when volumeScatterBlendCoef is greater than 0.
257
- * Default value of 0.0 means light scatters uniformly in all directions.
258
- * Value of -1.0 means light scatters backward, value of 1.0 means light scatters forward.
259
- * @param anisotropy
260
- */
261
- setAnisotropy(anisotropy: number): void;
262
-
263
- /**
264
- * Set whether to turn on local ambient occlusion (LAO). LAO is only effective if shading is on and volumeScatterBlendCoef is set to 0.
265
- * LAO effect is added to ambient lighting, so the ambient component of the actor needs to be great than 0.
266
- * @param localAmbientOcclusion
267
- */
268
- setLocalAmbientOcclusion(localAmbientOcclusion: boolean): void;
269
-
270
- /**
271
- * Set kernel size for local ambient occlusion. It specifies the number of rays that are randomly sampled in the hemisphere.
272
- * Value is clipped between 1 and 32.
273
- * @param LAOKernelSize
274
- */
275
- setLAOKernelSize(LAOKernelSize: number): void;
276
-
277
- /**
278
- * Set kernel radius for local ambient occlusion. It specifies the number of samples that are considered on each random ray.
279
- * Value must be greater than or equal to 1.
280
- * @param LAOKernelRadius
281
- */
282
- setLAOKernelRadius(LAOKernelRadius: number): void;
283
-
284
161
  /**
285
162
  *
286
163
  */
@@ -346,6 +223,5 @@ export declare const vtkVolumeMapper: {
346
223
  newInstance: typeof newInstance;
347
224
  extend: typeof extend;
348
225
  BlendMode: typeof BlendMode;
349
- FilterMode: typeof FilterMode;
350
226
  };
351
227
  export default vtkVolumeMapper;
@@ -1,12 +1,11 @@
1
1
  import { m as macro } from '../../macros2.js';
2
- import { H as createUninitializedBounds, E as clampValue, K as floor } from '../../Common/Core/Math/index.js';
3
2
  import Constants from './VolumeMapper/Constants.js';
4
3
  import vtkAbstractMapper3D from './AbstractMapper3D.js';
4
+ import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
5
5
  import vtkPiecewiseFunction from '../../Common/DataModel/PiecewiseFunction.js';
6
6
 
7
7
  const {
8
- BlendMode,
9
- FilterMode
8
+ BlendMode
10
9
  } = Constants;
11
10
  function createRadonTransferFunction(firstAbsorbentMaterialHounsfieldValue, firstAbsorbentMaterialAbsorption, maxAbsorbentMaterialHounsfieldValue, maxAbsorbentMaterialAbsorption, outputTransferFunction) {
12
11
  let ofun = null;
@@ -21,6 +20,7 @@ function createRadonTransferFunction(firstAbsorbentMaterialHounsfieldValue, firs
21
20
  ofun.addPoint(maxAbsorbentMaterialHounsfieldValue, maxAbsorbentMaterialAbsorption);
22
21
  return ofun;
23
22
  }
23
+ const methodNamesMovedToVolumeProperties = ['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'];
24
24
 
25
25
  // ----------------------------------------------------------------------------
26
26
  // Static API
@@ -41,20 +41,12 @@ function vtkVolumeMapper(publicAPI, model) {
41
41
  ...publicAPI
42
42
  };
43
43
  publicAPI.getBounds = () => {
44
- const input = publicAPI.getInputData();
45
- if (!input) {
46
- model.bounds = createUninitializedBounds();
47
- } else {
48
- if (!model.static) {
49
- publicAPI.update();
50
- }
51
- model.bounds = input.getBounds();
44
+ if (!model.static) {
45
+ publicAPI.update();
52
46
  }
47
+ model.bounds = [...publicAPI.getInputData().getBounds()];
53
48
  return model.bounds;
54
49
  };
55
- publicAPI.update = () => {
56
- publicAPI.getInputData();
57
- };
58
50
  publicAPI.setBlendModeToComposite = () => {
59
51
  publicAPI.setBlendMode(BlendMode.COMPOSITE_BLEND);
60
52
  };
@@ -74,35 +66,23 @@ function vtkVolumeMapper(publicAPI, model) {
74
66
  publicAPI.setBlendMode(BlendMode.RADON_TRANSFORM_BLEND);
75
67
  };
76
68
  publicAPI.getBlendModeAsString = () => macro.enumToString(BlendMode, model.blendMode);
77
- publicAPI.setAverageIPScalarRange = (min, max) => {
78
- console.warn('setAverageIPScalarRange is deprecated use setIpScalarRange');
79
- publicAPI.setIpScalarRange(min, max);
80
- };
81
- publicAPI.getFilterModeAsString = () => macro.enumToString(FilterMode, model.filterMode);
82
- publicAPI.setFilterModeToOff = () => {
83
- publicAPI.setFilterMode(FilterMode.OFF);
84
- };
85
- publicAPI.setFilterModeToNormalized = () => {
86
- publicAPI.setFilterMode(FilterMode.NORMALIZED);
87
- };
88
- publicAPI.setFilterModeToRaw = () => {
89
- publicAPI.setFilterMode(FilterMode.RAW);
90
- };
91
- publicAPI.setGlobalIlluminationReach = gl => superClass.setGlobalIlluminationReach(clampValue(gl, 0.0, 1.0));
92
- publicAPI.setVolumetricScatteringBlending = vsb => superClass.setVolumetricScatteringBlending(clampValue(vsb, 0.0, 1.0));
93
69
  publicAPI.setVolumeShadowSamplingDistFactor = vsdf => superClass.setVolumeShadowSamplingDistFactor(vsdf >= 1.0 ? vsdf : 1.0);
94
- publicAPI.setAnisotropy = at => superClass.setAnisotropy(clampValue(at, -0.99, 0.99));
95
- publicAPI.setLAOKernelSize = ks => superClass.setLAOKernelSize(floor(clampValue(ks, 1, 32)));
96
- publicAPI.setLAOKernelRadius = kr => superClass.setLAOKernelRadius(kr >= 1 ? kr : 1);
70
+
71
+ // Instead of a "undefined is not a function" error, give more context and advice for these widely used methods
72
+ methodNamesMovedToVolumeProperties.forEach(removedMethodName => {
73
+ const removedMethod = () => {
74
+ throw new Error(`The method "volumeMapper.${removedMethodName}()" doesn't exist anymore. ` + `It is a rendering property that has been moved to the volume property. ` + `Replace your code with:\n` + `volumeActor.getProperty().${removedMethodName}()\n`);
75
+ };
76
+ publicAPI[removedMethodName] = removedMethod;
77
+ });
97
78
  }
98
79
 
99
80
  // ----------------------------------------------------------------------------
100
81
  // Object factory
101
82
  // ----------------------------------------------------------------------------
102
83
 
103
- // TODO: what values to use for averageIPScalarRange to get GLSL to use max / min values like [-Math.inf, Math.inf]?
104
84
  const DEFAULT_VALUES = {
105
- bounds: [1, -1, 1, -1, 1, -1],
85
+ bounds: [...vtkBoundingBox.INIT_BOUNDS],
106
86
  sampleDistance: 1.0,
107
87
  imageSampleDistance: 1.0,
108
88
  maximumSamplesPerRay: 1000,
@@ -110,21 +90,7 @@ const DEFAULT_VALUES = {
110
90
  initialInteractionScale: 1.0,
111
91
  interactionSampleDistanceFactor: 1.0,
112
92
  blendMode: BlendMode.COMPOSITE_BLEND,
113
- ipScalarRange: [-1000000.0, 1000000.0],
114
- filterMode: FilterMode.OFF,
115
- // ignored by WebGL so no behavior change
116
- preferSizeOverAccuracy: false,
117
- // Whether to use halfFloat representation of float, when it is inaccurate
118
- computeNormalFromOpacity: false,
119
- // volume shadow parameters
120
- volumetricScatteringBlending: 0.0,
121
- globalIlluminationReach: 0.0,
122
- volumeShadowSamplingDistFactor: 5.0,
123
- anisotropy: 0.0,
124
- // local ambient occlusion
125
- localAmbientOcclusion: false,
126
- LAOKernelSize: 15,
127
- LAOKernelRadius: 7
93
+ volumeShadowSamplingDistFactor: 5.0
128
94
  };
129
95
 
130
96
  // ----------------------------------------------------------------------------
@@ -133,8 +99,7 @@ function extend(publicAPI, model) {
133
99
  let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
134
100
  Object.assign(model, DEFAULT_VALUES, initialValues);
135
101
  vtkAbstractMapper3D.extend(publicAPI, model, initialValues);
136
- macro.setGet(publicAPI, model, ['sampleDistance', 'imageSampleDistance', 'maximumSamplesPerRay', 'autoAdjustSampleDistances', 'initialInteractionScale', 'interactionSampleDistanceFactor', 'blendMode', 'filterMode', 'preferSizeOverAccuracy', 'computeNormalFromOpacity', 'volumetricScatteringBlending', 'globalIlluminationReach', 'volumeShadowSamplingDistFactor', 'anisotropy', 'localAmbientOcclusion', 'LAOKernelSize', 'LAOKernelRadius']);
137
- macro.setGetArray(publicAPI, model, ['ipScalarRange'], 2);
102
+ macro.setGet(publicAPI, model, ['sampleDistance', 'imageSampleDistance', 'maximumSamplesPerRay', 'autoAdjustSampleDistances', 'initialInteractionScale', 'interactionSampleDistanceFactor', 'blendMode', 'volumeShadowSamplingDistFactor']);
138
103
  macro.event(publicAPI, model, 'lightingActivated');
139
104
 
140
105
  // Object methods
@@ -10,9 +10,7 @@ export declare enum OpacityMode {
10
10
  }
11
11
 
12
12
  export declare enum ColorMixPreset {
13
- // Add a `//VTK::CustomColorMix` tag to the Fragment shader
14
- // See usage in file `testColorMix` and in function `setColorMixPreset`
15
- CUSTOM = 0,
13
+ DEFAULT = 0,
16
14
 
17
15
  // Two components preset
18
16
  // Out color: sum of colors weighted by opacity
@@ -23,11 +21,22 @@ export declare enum ColorMixPreset {
23
21
  // Out color: color of the first component, colorized by second component with an intensity that is the second component's opacity
24
22
  // Out opacity: opacity of the first component
25
23
  COLORIZE = 2,
24
+
25
+ // Add a `//VTK::CustomColorMix` tag to the Fragment shader
26
+ // See usage in file `testColorMix` and in function `setColorMixPreset`
27
+ CUSTOM = 3,
28
+ }
29
+
30
+ export declare enum FilterMode {
31
+ OFF = 0,
32
+ NORMALIZED = 1,
33
+ RAW = 2,
26
34
  }
27
35
 
28
36
  declare const _default: {
29
37
  InterpolationType: typeof InterpolationType;
30
38
  OpacityMode: typeof OpacityMode;
31
39
  ColorMixPreset: typeof ColorMixPreset;
40
+ FilterMode: typeof FilterMode;
32
41
  };
33
42
  export default _default;
@@ -8,14 +8,21 @@ const OpacityMode = {
8
8
  PROPORTIONAL: 1
9
9
  };
10
10
  const ColorMixPreset = {
11
- CUSTOM: 0,
11
+ DEFAULT: 0,
12
12
  ADDITIVE: 1,
13
- COLORIZE: 2
13
+ COLORIZE: 2,
14
+ CUSTOM: 3
15
+ };
16
+ const FilterMode = {
17
+ OFF: 0,
18
+ NORMALIZED: 1,
19
+ RAW: 2
14
20
  };
15
21
  var Constants = {
16
22
  InterpolationType,
17
23
  OpacityMode,
18
- ColorMixPreset
24
+ ColorMixPreset,
25
+ FilterMode
19
26
  };
20
27
 
21
- export { ColorMixPreset, InterpolationType, OpacityMode, Constants as default };
28
+ export { ColorMixPreset, FilterMode, InterpolationType, OpacityMode, Constants as default };
@@ -13,6 +13,7 @@ export interface IVolumePropertyInitialValues {
13
13
  specularPower?: number;
14
14
  useLabelOutline?: boolean;
15
15
  labelOutlineThickness?: number | number[];
16
+ colorMixPreset?: ColorMixPreset;
16
17
  }
17
18
 
18
19
  export interface vtkVolumeProperty extends vtkObject {
@@ -71,7 +72,7 @@ export interface vtkVolumeProperty extends vtkObject {
71
72
  /**
72
73
  *
73
74
  */
74
- getColorMixPreset(): Nullable<ColorMixPreset>;
75
+ getColorMixPreset(): ColorMixPreset;
75
76
 
76
77
  /**
77
78
  *
@@ -194,7 +195,7 @@ export interface vtkVolumeProperty extends vtkObject {
194
195
 
195
196
  /**
196
197
  * Set the color mix code to a preset value
197
- * Set to null to use no preset
198
+ * Defaults to ColorMixPreset.DEFAULT
198
199
  * See the test `testColorMix` for an example on how to use this preset.
199
200
  *
200
201
  * If set to `CUSTOM`, a tag `//VTK::CustomColorMix` is made available to the
@@ -202,9 +203,9 @@ export interface vtkVolumeProperty extends vtkObject {
202
203
  * will be used to mix the colors from each component.
203
204
  * Each component is available as a rgba vec4: `comp0`, `comp1`...
204
205
  * There are other useful functions or variable available. To find them,
205
- * see `//VTK::CustomComponentsColorMix::Impl` tag in `vtkVolumeFS.glsl`.
206
+ * see `//VTK::CustomColorMix` tag in `vtkVolumeFS.glsl`.
206
207
  */
207
- setColorMixPreset(preset: Nullable<ColorMixPreset>): boolean;
208
+ setColorMixPreset(preset: ColorMixPreset): boolean;
208
209
 
209
210
  /**
210
211
  * Does the data have independent components, or do some define color only?
@@ -370,6 +371,121 @@ export interface vtkVolumeProperty extends vtkObject {
370
371
  * Get the interpolation type for sampling a volume as a string.
371
372
  */
372
373
  getInterpolationTypeAsString(): string;
374
+
375
+ /**
376
+ *
377
+ */
378
+ getAverageIPScalarRange(): Range;
379
+
380
+ /**
381
+ *
382
+ */
383
+ getAverageIPScalarRangeByReference(): Range;
384
+
385
+ /**
386
+ * Get the blending coefficient that interpolates between surface and volume rendering
387
+ * @default 0.0
388
+ */
389
+ getVolumetricScatteringBlending(): number;
390
+
391
+ /**
392
+ * Get the global illumination reach of volume shadow
393
+ * @default 0.0
394
+ */
395
+ getGlobalIlluminationReach(): number;
396
+
397
+ /**
398
+ * Get anisotropy of volume shadow scatter
399
+ * @default 0.0
400
+ */
401
+ getAnisotropy(): number;
402
+
403
+ /**
404
+ * Get local ambient occlusion flag
405
+ * @default false
406
+ */
407
+ getLocalAmbientOcclusion(): boolean;
408
+
409
+ /**
410
+ * Get kernel size for local ambient occlusion
411
+ * @default 15
412
+ */
413
+ getLAOKernelSize(): number;
414
+
415
+ /**
416
+ * Get kernel radius for local ambient occlusion
417
+ * @default 7
418
+ */
419
+ getLAOKernelRadius(): number;
420
+
421
+ /**
422
+ *
423
+ * @param x
424
+ * @param y
425
+ */
426
+ setAverageIPScalarRange(x: number, y: number): boolean;
427
+
428
+ /**
429
+ *
430
+ * @param {Range} averageIPScalarRange
431
+ */
432
+ setAverageIPScalarRangeFrom(averageIPScalarRange: Range): boolean;
433
+
434
+ /**
435
+ * Set the normal computation to be dependent on the transfer function.
436
+ * By default, the mapper relies on the scalar gradient for computing normals at sample locations
437
+ * for lighting calculations. This is an approximation and can lead to inaccurate results.
438
+ * When enabled, this property makes the mapper compute normals based on the accumulated opacity
439
+ * at sample locations. This can generate a more accurate representation of edge structures in the
440
+ * data but adds an overhead and drops frame rate.
441
+ * @param computeNormalFromOpacity
442
+ */
443
+ setComputeNormalFromOpacity(computeNormalFromOpacity: boolean): boolean;
444
+
445
+ /**
446
+ * Set the blending coefficient that determines the interpolation between surface and volume rendering.
447
+ * Default value of 0.0 means shadow effect is computed with phong model.
448
+ * Value of 1.0 means shadow is created by volume occlusion.
449
+ * @param volumeScatterBlendCoef
450
+ */
451
+ setVolumetricScatteringBlending(volumeScatterBlendCoef: number): void;
452
+
453
+ /**
454
+ * Set the global illumination reach of volume shadow. This function is only effective when volumeScatterBlendCoef is greater than 0.
455
+ * Default value of 0.0 means only the neighboring voxel is considered when creating global shadow.
456
+ * Value of 1.0 means the shadow ray traverses through the entire volume.
457
+ * @param globalIlluminationReach
458
+ */
459
+ setGlobalIlluminationReach(globalIlluminationReach: number): void;
460
+
461
+ /**
462
+ * Set anisotropy of volume shadow scatter. This function is only effective when volumeScatterBlendCoef is greater than 0.
463
+ * Default value of 0.0 means light scatters uniformly in all directions.
464
+ * Value of -1.0 means light scatters backward, value of 1.0 means light scatters forward.
465
+ * @param anisotropy
466
+ */
467
+ setAnisotropy(anisotropy: number): void;
468
+
469
+ /**
470
+ * Set whether to turn on local ambient occlusion (LAO). LAO is only effective if shading is on and volumeScatterBlendCoef is set to 0.
471
+ * LAO effect is added to ambient lighting, so the ambient component of the actor needs to be great than 0.
472
+ * @param localAmbientOcclusion
473
+ */
474
+ setLocalAmbientOcclusion(localAmbientOcclusion: boolean): void;
475
+
476
+ /**
477
+ * Set kernel size for local ambient occlusion. It specifies the number of rays that are randomly sampled in the hemisphere.
478
+ * Value is clipped between 1 and 32.
479
+ * @param LAOKernelSize
480
+ */
481
+ setLAOKernelSize(LAOKernelSize: number): void;
482
+
483
+ /**
484
+ * Set kernel radius for local ambient occlusion. It specifies the number of samples that are considered on each random ray.
485
+ * Value must be greater than or equal to 1.
486
+ * @param LAOKernelRadius
487
+ */
488
+ setLAOKernelRadius(LAOKernelRadius: number): void;
373
489
  }
374
490
 
375
491
  /**
@@ -1,11 +1,14 @@
1
1
  import { m as macro } from '../../macros2.js';
2
+ import { E as clampValue, K as floor } from '../../Common/Core/Math/index.js';
2
3
  import vtkColorTransferFunction from './ColorTransferFunction.js';
3
4
  import vtkPiecewiseFunction from '../../Common/DataModel/PiecewiseFunction.js';
4
5
  import Constants from './VolumeProperty/Constants.js';
5
6
 
6
7
  const {
7
8
  InterpolationType,
8
- OpacityMode
9
+ OpacityMode,
10
+ FilterMode,
11
+ ColorMixPreset
9
12
  } = Constants;
10
13
  const {
11
14
  vtkErrorMacro
@@ -19,6 +22,9 @@ const VTK_MAX_VRCOMP = 4;
19
22
  function vtkVolumeProperty(publicAPI, model) {
20
23
  // Set our className
21
24
  model.classHierarchy.push('vtkVolumeProperty');
25
+ const superClass = {
26
+ ...publicAPI
27
+ };
22
28
  publicAPI.getMTime = () => {
23
29
  let mTime = model.mtime;
24
30
  let time;
@@ -197,6 +203,25 @@ function vtkVolumeProperty(publicAPI, model) {
197
203
  const cap = macro.capitalize(val);
198
204
  publicAPI[`get${cap}`] = index => model.componentData[index][`${val}`];
199
205
  });
206
+ publicAPI.setAverageIPScalarRange = (min, max) => {
207
+ console.warn('setAverageIPScalarRange is deprecated use setIpScalarRange');
208
+ publicAPI.setIpScalarRange(min, max);
209
+ };
210
+ publicAPI.getFilterModeAsString = () => macro.enumToString(FilterMode, model.filterMode);
211
+ publicAPI.setFilterModeToOff = () => {
212
+ publicAPI.setFilterMode(FilterMode.OFF);
213
+ };
214
+ publicAPI.setFilterModeToNormalized = () => {
215
+ publicAPI.setFilterMode(FilterMode.NORMALIZED);
216
+ };
217
+ publicAPI.setFilterModeToRaw = () => {
218
+ publicAPI.setFilterMode(FilterMode.RAW);
219
+ };
220
+ publicAPI.setGlobalIlluminationReach = gl => superClass.setGlobalIlluminationReach(clampValue(gl, 0.0, 1.0));
221
+ publicAPI.setVolumetricScatteringBlending = vsb => superClass.setVolumetricScatteringBlending(clampValue(vsb, 0.0, 1.0));
222
+ publicAPI.setAnisotropy = at => superClass.setAnisotropy(clampValue(at, -0.99, 0.99));
223
+ publicAPI.setLAOKernelSize = ks => superClass.setLAOKernelSize(floor(clampValue(ks, 1, 32)));
224
+ publicAPI.setLAOKernelRadius = kr => superClass.setLAOKernelRadius(kr >= 1 ? kr : 1);
200
225
  }
201
226
 
202
227
  // ----------------------------------------------------------------------------
@@ -204,7 +229,7 @@ function vtkVolumeProperty(publicAPI, model) {
204
229
  // ----------------------------------------------------------------------------
205
230
 
206
231
  const DEFAULT_VALUES = {
207
- colorMixPreset: null,
232
+ colorMixPreset: ColorMixPreset.DEFAULT,
208
233
  independentComponents: true,
209
234
  interpolationType: InterpolationType.FAST_LINEAR,
210
235
  shade: false,
@@ -214,7 +239,22 @@ const DEFAULT_VALUES = {
214
239
  specularPower: 10.0,
215
240
  useLabelOutline: false,
216
241
  labelOutlineThickness: [1],
217
- labelOutlineOpacity: 1.0
242
+ labelOutlineOpacity: 1.0,
243
+ // Properties moved from volume mapper
244
+ ipScalarRange: [-1000000.0, 1000000.0],
245
+ filterMode: FilterMode.OFF,
246
+ // ignored by WebGL so no behavior change
247
+ preferSizeOverAccuracy: false,
248
+ // Whether to use halfFloat representation of float, when it is inaccurate
249
+ computeNormalFromOpacity: false,
250
+ // volume shadow parameters
251
+ volumetricScatteringBlending: 0.0,
252
+ globalIlluminationReach: 0.0,
253
+ anisotropy: 0.0,
254
+ // local ambient occlusion
255
+ localAmbientOcclusion: false,
256
+ LAOKernelSize: 15,
257
+ LAOKernelRadius: 7
218
258
  };
219
259
 
220
260
  // ----------------------------------------------------------------------------
@@ -245,7 +285,12 @@ function extend(publicAPI, model) {
245
285
  });
246
286
  }
247
287
  }
248
- macro.setGet(publicAPI, model, ['colorMixPreset', 'independentComponents', 'interpolationType', 'shade', 'ambient', 'diffuse', 'specular', 'specularPower', 'useLabelOutline', 'labelOutlineOpacity']);
288
+ macro.setGet(publicAPI, model, ['colorMixPreset', 'independentComponents', 'interpolationType', 'shade', 'ambient', 'diffuse', 'specular', 'specularPower', 'useLabelOutline', 'labelOutlineOpacity',
289
+ // Properties moved from volume mapper
290
+ 'filterMode', 'preferSizeOverAccuracy', 'computeNormalFromOpacity', 'volumetricScatteringBlending', 'globalIlluminationReach', 'anisotropy', 'localAmbientOcclusion', 'LAOKernelSize', 'LAOKernelRadius']);
291
+
292
+ // Property moved from volume mapper
293
+ macro.setGetArray(publicAPI, model, ['ipScalarRange'], 2);
249
294
  macro.setGetArray(publicAPI, model, ['labelOutlineThickness']);
250
295
 
251
296
  // Object methods