@kitware/vtk.js 33.2.0 → 34.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.
Files changed (45) hide show
  1. package/BREAKING_CHANGES.md +10 -0
  2. package/Interaction/Manipulators/KeyboardCameraManipulator.d.ts +113 -0
  3. package/Rendering/Core/Actor.d.ts +5 -20
  4. package/Rendering/Core/Actor.js +5 -68
  5. package/Rendering/Core/ImageCPRMapper.d.ts +1 -20
  6. package/Rendering/Core/ImageCPRMapper.js +1 -2
  7. package/Rendering/Core/ImageProperty.d.ts +20 -1
  8. package/Rendering/Core/ImageProperty.js +7 -5
  9. package/Rendering/Core/ImageResliceMapper.d.ts +1 -20
  10. package/Rendering/Core/ImageResliceMapper.js +1 -2
  11. package/Rendering/Core/ImageSlice.d.ts +7 -23
  12. package/Rendering/Core/ImageSlice.js +9 -68
  13. package/Rendering/Core/Prop3D.d.ts +39 -2
  14. package/Rendering/Core/Prop3D.js +81 -2
  15. package/Rendering/Core/RenderWindowInteractor.d.ts +6 -0
  16. package/Rendering/Core/RenderWindowInteractor.js +7 -5
  17. package/Rendering/Core/Volume.d.ts +5 -20
  18. package/Rendering/Core/Volume.js +2 -70
  19. package/Rendering/Core/VolumeMapper/Constants.d.ts +0 -7
  20. package/Rendering/Core/VolumeMapper/Constants.js +2 -8
  21. package/Rendering/Core/VolumeMapper.d.ts +16 -173
  22. package/Rendering/Core/VolumeMapper.js +16 -51
  23. package/Rendering/Core/VolumeProperty/Constants.d.ts +12 -3
  24. package/Rendering/Core/VolumeProperty/Constants.js +11 -4
  25. package/Rendering/Core/VolumeProperty.d.ts +140 -5
  26. package/Rendering/Core/VolumeProperty.js +54 -7
  27. package/Rendering/OpenGL/Framebuffer.js +7 -1
  28. package/Rendering/OpenGL/ImageCPRMapper.js +72 -27
  29. package/Rendering/OpenGL/ImageMapper.js +71 -33
  30. package/Rendering/OpenGL/ImageResliceMapper.js +306 -183
  31. package/Rendering/OpenGL/OrderIndependentTranslucentPass.js +20 -3
  32. package/Rendering/OpenGL/PolyDataMapper.js +8 -9
  33. package/Rendering/OpenGL/RenderWindow/resourceSharingHelper.d.ts +3 -3
  34. package/Rendering/OpenGL/RenderWindow/resourceSharingHelper.js +8 -5
  35. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D/pingpong.js +7 -1
  36. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +20 -3
  37. package/Rendering/OpenGL/Texture.d.ts +110 -62
  38. package/Rendering/OpenGL/Texture.js +145 -37
  39. package/Rendering/OpenGL/VolumeMapper.js +763 -783
  40. package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
  41. package/Rendering/WebGPU/VolumePassFSQ.js +2 -2
  42. package/index.d.ts +1 -0
  43. package/macros.js +1 -1
  44. package/macros2.js +8 -3
  45. package/package.json +1 -1
@@ -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,26 +66,15 @@ 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
  // ----------------------------------------------------------------------------
@@ -102,7 +83,7 @@ function vtkVolumeMapper(publicAPI, model) {
102
83
 
103
84
  // TODO: what values to use for averageIPScalarRange to get GLSL to use max / min values like [-Math.inf, Math.inf]?
104
85
  const defaultValues = initialValues => ({
105
- bounds: [1, -1, 1, -1, 1, -1],
86
+ bounds: [...vtkBoundingBox.INIT_BOUNDS],
106
87
  sampleDistance: 1.0,
107
88
  imageSampleDistance: 1.0,
108
89
  maximumSamplesPerRay: 1000,
@@ -110,22 +91,7 @@ const defaultValues = initialValues => ({
110
91
  initialInteractionScale: 1.0,
111
92
  interactionSampleDistanceFactor: 1.0,
112
93
  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
94
  volumeShadowSamplingDistFactor: 5.0,
123
- anisotropy: 0.0,
124
- // local ambient occlusion
125
- localAmbientOcclusion: false,
126
- LAOKernelSize: 15,
127
- LAOKernelRadius: 7,
128
- updatedExtents: [],
129
95
  colorTextureWidth: 1024,
130
96
  opacityTextureWidth: 1024,
131
97
  labelOutlineTextureWidth: 1024,
@@ -138,8 +104,7 @@ function extend(publicAPI, model) {
138
104
  let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
139
105
  Object.assign(model, defaultValues(initialValues));
140
106
  vtkAbstractMapper3D.extend(publicAPI, model, initialValues);
141
- macro.setGet(publicAPI, model, ['sampleDistance', 'imageSampleDistance', 'maximumSamplesPerRay', 'autoAdjustSampleDistances', 'initialInteractionScale', 'interactionSampleDistanceFactor', 'blendMode', 'filterMode', 'preferSizeOverAccuracy', 'computeNormalFromOpacity', 'volumetricScatteringBlending', 'globalIlluminationReach', 'volumeShadowSamplingDistFactor', 'anisotropy', 'localAmbientOcclusion', 'LAOKernelSize', 'LAOKernelRadius', 'updatedExtents', 'colorTextureWidth', 'opacityTextureWidth', 'labelOutlineTextureWidth']);
142
- macro.setGetArray(publicAPI, model, ['ipScalarRange'], 2);
107
+ macro.setGet(publicAPI, model, ['sampleDistance', 'imageSampleDistance', 'maximumSamplesPerRay', 'autoAdjustSampleDistances', 'initialInteractionScale', 'interactionSampleDistanceFactor', 'blendMode', 'volumeShadowSamplingDistFactor', 'colorTextureWidth', 'opacityTextureWidth', 'labelOutlineTextureWidth']);
143
108
  macro.event(publicAPI, model, 'lightingActivated');
144
109
 
145
110
  // 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 };
@@ -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
 
@@ -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,140 @@ 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;
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[];
373
508
  }
374
509
 
375
510
  /**
@@ -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,14 +203,33 @@ 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
  // ----------------------------------------------------------------------------
203
228
  // Object factory
204
229
  // ----------------------------------------------------------------------------
205
230
 
206
- const DEFAULT_VALUES = {
207
- colorMixPreset: null,
231
+ const defaultValues = initialValues => ({
232
+ colorMixPreset: ColorMixPreset.DEFAULT,
208
233
  independentComponents: true,
209
234
  interpolationType: InterpolationType.FAST_LINEAR,
210
235
  shade: false,
@@ -214,14 +239,31 @@ const DEFAULT_VALUES = {
214
239
  specularPower: 10.0,
215
240
  useLabelOutline: false,
216
241
  labelOutlineThickness: [1],
217
- labelOutlineOpacity: 1.0
218
- };
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,
258
+ updatedExtents: [],
259
+ ...initialValues
260
+ });
219
261
 
220
262
  // ----------------------------------------------------------------------------
221
263
 
222
264
  function extend(publicAPI, model) {
223
265
  let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
224
- Object.assign(model, DEFAULT_VALUES, initialValues);
266
+ Object.assign(model, defaultValues(initialValues));
225
267
 
226
268
  // Build VTK API
227
269
  macro.obj(publicAPI, model);
@@ -245,7 +287,12 @@ function extend(publicAPI, model) {
245
287
  });
246
288
  }
247
289
  }
248
- macro.setGet(publicAPI, model, ['colorMixPreset', 'independentComponents', 'interpolationType', 'shade', 'ambient', 'diffuse', 'specular', 'specularPower', 'useLabelOutline', 'labelOutlineOpacity']);
290
+ macro.setGet(publicAPI, model, ['colorMixPreset', 'independentComponents', 'interpolationType', 'shade', 'ambient', 'diffuse', 'specular', 'specularPower', 'useLabelOutline', 'labelOutlineOpacity',
291
+ // Properties moved from volume mapper
292
+ 'filterMode', 'preferSizeOverAccuracy', 'computeNormalFromOpacity', 'volumetricScatteringBlending', 'globalIlluminationReach', 'anisotropy', 'localAmbientOcclusion', 'LAOKernelSize', 'LAOKernelRadius', 'updatedExtents']);
293
+
294
+ // Property moved from volume mapper
295
+ macro.setGetArray(publicAPI, model, ['ipScalarRange'], 2);
249
296
  macro.setGetArray(publicAPI, model, ['labelOutlineThickness']);
250
297
 
251
298
  // Object methods
@@ -162,7 +162,13 @@ function vtkFramebuffer(publicAPI, model) {
162
162
  texture.setOpenGLRenderWindow(model._openGLRenderWindow);
163
163
  texture.setMinificationFilter(Filter.LINEAR);
164
164
  texture.setMagnificationFilter(Filter.LINEAR);
165
- texture.create2DFromRaw(model.glFramebuffer.width, model.glFramebuffer.height, 4, VtkDataTypes.UNSIGNED_CHAR, null);
165
+ texture.create2DFromRaw({
166
+ width: model.glFramebuffer.width,
167
+ height: model.glFramebuffer.height,
168
+ numComps: 4,
169
+ dataType: VtkDataTypes.UNSIGNED_CHAR,
170
+ data: null
171
+ });
166
172
  publicAPI.setColorBuffer(texture);
167
173
 
168
174
  // for now do not count on having a depth buffer texture