@kitware/vtk.js 33.3.2 → 34.0.0-beta.2

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 (56) hide show
  1. package/BREAKING_CHANGES.md +10 -0
  2. package/IO/Geometry/GLTFImporter/Decoder.js +21 -35
  3. package/IO/Geometry/GLTFImporter/ORMTexture.worker.js +42 -0
  4. package/IO/Geometry/GLTFImporter/Parser.js +6 -15
  5. package/IO/Geometry/GLTFImporter/Reader.js +10 -7
  6. package/IO/Geometry/GLTFImporter/Utils.js +27 -9
  7. package/Interaction/Manipulators/KeyboardCameraManipulator.d.ts +113 -0
  8. package/Rendering/Core/Actor.d.ts +5 -20
  9. package/Rendering/Core/Actor.js +5 -68
  10. package/Rendering/Core/ImageCPRMapper.d.ts +1 -20
  11. package/Rendering/Core/ImageCPRMapper.js +1 -2
  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 -20
  15. package/Rendering/Core/ImageResliceMapper.js +1 -2
  16. package/Rendering/Core/ImageSlice.d.ts +7 -23
  17. package/Rendering/Core/ImageSlice.js +9 -68
  18. package/Rendering/Core/Prop3D.d.ts +39 -2
  19. package/Rendering/Core/Prop3D.js +81 -2
  20. package/Rendering/Core/RenderWindowInteractor.d.ts +6 -0
  21. package/Rendering/Core/RenderWindowInteractor.js +7 -5
  22. package/Rendering/Core/Volume.d.ts +5 -20
  23. package/Rendering/Core/Volume.js +2 -70
  24. package/Rendering/Core/VolumeMapper/Constants.d.ts +0 -7
  25. package/Rendering/Core/VolumeMapper/Constants.js +2 -8
  26. package/Rendering/Core/VolumeMapper.d.ts +16 -173
  27. package/Rendering/Core/VolumeMapper.js +16 -51
  28. package/Rendering/Core/VolumeProperty/Constants.d.ts +12 -3
  29. package/Rendering/Core/VolumeProperty/Constants.js +11 -4
  30. package/Rendering/Core/VolumeProperty.d.ts +140 -5
  31. package/Rendering/Core/VolumeProperty.js +54 -7
  32. package/Rendering/OpenGL/Framebuffer.js +7 -1
  33. package/Rendering/OpenGL/ImageCPRMapper.js +72 -27
  34. package/Rendering/OpenGL/ImageMapper.js +71 -33
  35. package/Rendering/OpenGL/ImageResliceMapper.js +306 -183
  36. package/Rendering/OpenGL/OrderIndependentTranslucentPass.js +20 -3
  37. package/Rendering/OpenGL/PolyDataMapper.js +8 -9
  38. package/Rendering/OpenGL/RenderWindow/resourceSharingHelper.d.ts +3 -3
  39. package/Rendering/OpenGL/RenderWindow/resourceSharingHelper.js +8 -5
  40. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D/pingpong.js +7 -1
  41. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +20 -3
  42. package/Rendering/OpenGL/Texture.d.ts +110 -62
  43. package/Rendering/OpenGL/Texture.js +145 -37
  44. package/Rendering/OpenGL/VolumeMapper.js +763 -783
  45. package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
  46. package/Rendering/WebGPU/CellArrayMapper.js +17 -17
  47. package/Rendering/WebGPU/PolyDataMapper.js +15 -35
  48. package/Rendering/WebGPU/Renderer.js +1 -1
  49. package/Rendering/WebGPU/Texture.js +12 -13
  50. package/Rendering/WebGPU/TextureManager.js +7 -12
  51. package/Rendering/WebGPU/VolumePassFSQ.js +2 -2
  52. package/_virtual/rollup-plugin-worker-loader__module_Sources/IO/Geometry/GLTFImporter/ORMTexture.worker.js +296 -0
  53. package/index.d.ts +1 -0
  54. package/macros.js +1 -1
  55. package/macros2.js +8 -3
  56. package/package.json +1 -1
@@ -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
@@ -11,7 +11,7 @@ import vtkOpenGLTexture from './Texture.js';
11
11
  import vtkReplacementShaderMapper from './ReplacementShaderMapper.js';
12
12
  import vtkShaderProgram from './ShaderProgram.js';
13
13
  import vtkViewNode from '../SceneGraph/ViewNode.js';
14
- import { getImageDataHash, getTransferFunctionHash } from './RenderWindow/resourceSharingHelper.js';
14
+ import { getImageDataHash, getTransferFunctionsHash } from './RenderWindow/resourceSharingHelper.js';
15
15
  import { v as vtkPolyDataVS } from './glsl/vtkPolyDataVS.glsl.js';
16
16
  import { v as vtkPolyDataFS } from './glsl/vtkPolyDataFS.glsl.js';
17
17
  import { registerOverride } from './ViewNodeFactory.js';
@@ -147,6 +147,7 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
147
147
  publicAPI.buildBufferObjects = (ren, actor) => {
148
148
  const image = model.currentImageDataInput;
149
149
  const centerline = model.currentCenterlineInput;
150
+ const property = actor.getProperty();
150
151
 
151
152
  // Rebuild the volumeTexture if the data has changed
152
153
  const scalars = image?.getPointData()?.getScalars();
@@ -156,7 +157,7 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
156
157
  const cachedScalarsEntry = model._openGLRenderWindow.getGraphicsResourceForObject(scalars);
157
158
  const volumeTextureHash = getImageDataHash(image, scalars);
158
159
  const reBuildTex = !cachedScalarsEntry?.oglObject?.getHandle() || cachedScalarsEntry?.hash !== volumeTextureHash;
159
- const updatedExtents = model.renderable.getUpdatedExtents();
160
+ const updatedExtents = property.getUpdatedExtents();
160
161
  const hasUpdatedExtents = !!updatedExtents.length;
161
162
  if (reBuildTex) {
162
163
  model.volumeTexture = vtkOpenGLTexture.newInstance();
@@ -166,7 +167,13 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
166
167
  // Use norm16 for scalar texture if the extension is available
167
168
  model.volumeTexture.setOglNorm16Ext(model.context.getExtension('EXT_texture_norm16'));
168
169
  model.volumeTexture.resetFormatAndType();
169
- model.volumeTexture.create3DFilterableFromDataArray(dims[0], dims[1], dims[2], scalars, model.renderable.getPreferSizeOverAccuracy());
170
+ model.volumeTexture.create3DFilterableFromDataArray({
171
+ width: dims[0],
172
+ height: dims[1],
173
+ depth: dims[2],
174
+ dataArray: scalars,
175
+ preferSizeOverAccuracy: model.renderable.getPreferSizeOverAccuracy()
176
+ });
170
177
  model._openGLRenderWindow.setGraphicsResourceForObject(scalars, model.volumeTexture, volumeTextureHash);
171
178
  if (scalars !== model._scalars) {
172
179
  model._openGLRenderWindow.registerGraphicsResourceUser(scalars, publicAPI);
@@ -179,9 +186,15 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
179
186
  if (hasUpdatedExtents) {
180
187
  // If hasUpdatedExtents, then the texture is partially updated.
181
188
  // clear the array to acknowledge the update.
182
- model.renderable.setUpdatedExtents([]);
189
+ property.setUpdatedExtents([]);
183
190
  const dims = image.getDimensions();
184
- model.volumeTexture.create3DFilterableFromDataArray(dims[0], dims[1], dims[2], scalars, false, updatedExtents);
191
+ model.volumeTexture.create3DFilterableFromDataArray({
192
+ width: dims[0],
193
+ height: dims[1],
194
+ depth: dims[2],
195
+ dataArray: scalars,
196
+ updatedExtents
197
+ });
185
198
  }
186
199
 
187
200
  // Rebuild the color texture if needed
@@ -190,9 +203,13 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
190
203
  const iComps = ppty.getIndependentComponents();
191
204
  const numIComps = iComps ? numComp : 1;
192
205
  const textureHeight = iComps ? 2 * numIComps : 1;
193
- const colorTransferFunc = ppty.getRGBTransferFunction();
194
- const colorTextureHash = getTransferFunctionHash(colorTransferFunc, iComps, numIComps);
195
- const cachedColorEntry = model._openGLRenderWindow.getGraphicsResourceForObject(colorTransferFunc);
206
+ const colorTransferFunctions = [];
207
+ for (let component = 0; component < numIComps; ++component) {
208
+ colorTransferFunctions.push(ppty.getRGBTransferFunction(component));
209
+ }
210
+ const colorTextureHash = getTransferFunctionsHash(colorTransferFunctions, iComps, numIComps);
211
+ const firstColorTransferFunc = ppty.getRGBTransferFunction();
212
+ const cachedColorEntry = model._openGLRenderWindow.getGraphicsResourceForObject(firstColorTransferFunc);
196
213
  const reBuildColorTexture = !cachedColorEntry?.oglObject?.getHandle() || cachedColorEntry?.hash !== colorTextureHash;
197
214
  if (reBuildColorTexture) {
198
215
  let cWidth = model.renderable.getColorTextureWidth();
@@ -203,7 +220,7 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
203
220
  const cTable = new Uint8ClampedArray(cSize);
204
221
  model.colorTexture = vtkOpenGLTexture.newInstance();
205
222
  model.colorTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
206
- if (colorTransferFunc) {
223
+ if (firstColorTransferFunc) {
207
224
  const tmpTable = new Float32Array(cWidth * 3);
208
225
  for (let c = 0; c < numIComps; c++) {
209
226
  const cfun = ppty.getRGBTransferFunction(c);
@@ -221,7 +238,13 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
221
238
  }
222
239
  }
223
240
  model.colorTexture.resetFormatAndType();
224
- model.colorTexture.create2DFromRaw(cWidth, textureHeight, 3, VtkDataTypes.UNSIGNED_CHAR, cTable);
241
+ model.colorTexture.create2DFromRaw({
242
+ width: cWidth,
243
+ height: textureHeight,
244
+ numComps: 3,
245
+ dataType: VtkDataTypes.UNSIGNED_CHAR,
246
+ data: cTable
247
+ });
225
248
  } else {
226
249
  for (let i = 0; i < cWidth * 3; ++i) {
227
250
  cTable[i] = 255.0 * i / ((cWidth - 1) * 3);
@@ -229,15 +252,21 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
229
252
  cTable[i + 2] = 255.0 * i / ((cWidth - 1) * 3);
230
253
  }
231
254
  model.colorTexture.resetFormatAndType();
232
- model.colorTexture.create2DFromRaw(cWidth, 1, 3, VtkDataTypes.UNSIGNED_CHAR, cTable);
255
+ model.colorTexture.create2DFromRaw({
256
+ width: cWidth,
257
+ height: 1,
258
+ numComps: 3,
259
+ dataType: VtkDataTypes.UNSIGNED_CHAR,
260
+ data: cTable
261
+ });
233
262
  }
234
- if (colorTransferFunc) {
235
- model._openGLRenderWindow.setGraphicsResourceForObject(colorTransferFunc, model.colorTexture, colorTextureHash);
236
- if (colorTransferFunc !== model._colorTransferFunc) {
237
- model._openGLRenderWindow.registerGraphicsResourceUser(colorTransferFunc, publicAPI);
263
+ if (firstColorTransferFunc) {
264
+ model._openGLRenderWindow.setGraphicsResourceForObject(firstColorTransferFunc, model.colorTexture, colorTextureHash);
265
+ if (firstColorTransferFunc !== model._colorTransferFunc) {
266
+ model._openGLRenderWindow.registerGraphicsResourceUser(firstColorTransferFunc, publicAPI);
238
267
  model._openGLRenderWindow.unregisterGraphicsResourceUser(model._colorTransferFunc, publicAPI);
239
268
  }
240
- model._colorTransferFunc = colorTransferFunc;
269
+ model._colorTransferFunc = firstColorTransferFunc;
241
270
  }
242
271
  } else {
243
272
  model.colorTexture = cachedColorEntry.oglObject;
@@ -246,9 +275,13 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
246
275
  // Build piecewise function buffer. This buffer is used either
247
276
  // for component weighting or opacity, depending on whether we're
248
277
  // rendering components independently or not.
249
- const pwFunc = ppty.getPiecewiseFunction();
250
- const pwfTextureHash = getTransferFunctionHash(pwFunc, iComps, numIComps);
251
- const cachedPwfEntry = model._openGLRenderWindow.getGraphicsResourceForObject(pwFunc);
278
+ const opacityFunctions = [];
279
+ for (let component = 0; component < numIComps; ++component) {
280
+ opacityFunctions.push(ppty.getPiecewiseFunction(component));
281
+ }
282
+ const pwfTextureHash = getTransferFunctionsHash(opacityFunctions, iComps, numIComps);
283
+ const firstPwFunc = ppty.getPiecewiseFunction();
284
+ const cachedPwfEntry = model._openGLRenderWindow.getGraphicsResourceForObject(firstPwFunc);
252
285
  const reBuildPwf = !cachedPwfEntry?.oglObject?.getHandle() || cachedPwfEntry?.hash !== pwfTextureHash;
253
286
  if (reBuildPwf) {
254
287
  let pwfWidth = model.renderable.getOpacityTextureWidth();
@@ -259,7 +292,7 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
259
292
  const pwfTable = new Uint8ClampedArray(pwfSize);
260
293
  model.pwfTexture = vtkOpenGLTexture.newInstance();
261
294
  model.pwfTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
262
- if (pwFunc) {
295
+ if (firstPwFunc) {
263
296
  const pwfFloatTable = new Float32Array(pwfSize);
264
297
  const tmpTable = new Float32Array(pwfWidth);
265
298
  for (let c = 0; c < numIComps; ++c) {
@@ -284,20 +317,32 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
284
317
  }
285
318
  }
286
319
  model.pwfTexture.resetFormatAndType();
287
- model.pwfTexture.create2DFromRaw(pwfWidth, textureHeight, 1, VtkDataTypes.FLOAT, pwfFloatTable);
320
+ model.pwfTexture.create2DFromRaw({
321
+ width: pwfWidth,
322
+ height: textureHeight,
323
+ numComps: 1,
324
+ dataType: VtkDataTypes.FLOAT,
325
+ data: pwfFloatTable
326
+ });
288
327
  } else {
289
328
  // default is opaque
290
329
  pwfTable.fill(255.0);
291
330
  model.pwfTexture.resetFormatAndType();
292
- model.pwfTexture.create2DFromRaw(pwfWidth, 1, 1, VtkDataTypes.UNSIGNED_CHAR, pwfTable);
331
+ model.pwfTexture.create2DFromRaw({
332
+ width: pwfWidth,
333
+ height: 1,
334
+ numComps: 1,
335
+ dataType: VtkDataTypes.UNSIGNED_CHAR,
336
+ data: pwfTable
337
+ });
293
338
  }
294
- if (pwFunc) {
295
- model._openGLRenderWindow.setGraphicsResourceForObject(pwFunc, model.pwfTexture, pwfTextureHash);
296
- if (pwFunc !== model._pwFunc) {
297
- model._openGLRenderWindow.registerGraphicsResourceUser(pwFunc, publicAPI);
339
+ if (firstPwFunc) {
340
+ model._openGLRenderWindow.setGraphicsResourceForObject(firstPwFunc, model.pwfTexture, pwfTextureHash);
341
+ if (firstPwFunc !== model._pwFunc) {
342
+ model._openGLRenderWindow.registerGraphicsResourceUser(firstPwFunc, publicAPI);
298
343
  model._openGLRenderWindow.unregisterGraphicsResourceUser(model._pwFunc, publicAPI);
299
344
  }
300
- model._pwFunc = pwFunc;
345
+ model._pwFunc = firstPwFunc;
301
346
  }
302
347
  } else {
303
348
  model.pwfTexture = cachedPwfEntry.oglObject;
@@ -4,14 +4,13 @@ import { n as newInstance$1, e as setGet, o as obj, r as vtkErrorMacro$1, h as c
4
4
  import vtkDataArray from '../../Common/Core/DataArray.js';
5
5
  import { VtkDataTypes } from '../../Common/Core/DataArray/Constants.js';
6
6
  import vtkHelper from './Helper.js';
7
- import { u as uninitializeBounds } from '../../Common/Core/Math/index.js';
8
7
  import vtkOpenGLTexture from './Texture.js';
9
8
  import vtkShaderProgram from './ShaderProgram.js';
10
9
  import vtkViewNode from '../SceneGraph/ViewNode.js';
11
10
  import { Representation } from '../Core/Property/Constants.js';
12
11
  import { Filter, Wrap } from './Texture/Constants.js';
13
12
  import { InterpolationType } from '../Core/ImageProperty/Constants.js';
14
- import { getTransferFunctionHash } from './RenderWindow/resourceSharingHelper.js';
13
+ import { getTransferFunctionsHash } from './RenderWindow/resourceSharingHelper.js';
15
14
  import { v as vtkPolyDataVS } from './glsl/vtkPolyDataVS.glsl.js';
16
15
  import { v as vtkPolyDataFS } from './glsl/vtkPolyDataFS.glsl.js';
17
16
  import vtkReplacementShaderMapper from './ReplacementShaderMapper.js';
@@ -555,13 +554,6 @@ function vtkOpenGLImageMapper(publicAPI, model) {
555
554
  publicAPI.renderPieceDraw(ren, actor);
556
555
  publicAPI.renderPieceFinish(ren, actor);
557
556
  };
558
- publicAPI.computeBounds = (ren, actor) => {
559
- if (!publicAPI.getInput()) {
560
- uninitializeBounds(model.bounds);
561
- return;
562
- }
563
- model.bounds = publicAPI.getInput().getBounds();
564
- };
565
557
  publicAPI.updateBufferObjects = (ren, actor) => {
566
558
  // Rebuild buffers if needed
567
559
  if (publicAPI.getNeedToRebuildBufferObjects(ren, actor)) {
@@ -585,9 +577,13 @@ function vtkOpenGLImageMapper(publicAPI, model) {
585
577
  const iComps = actorProperty.getIndependentComponents();
586
578
  const numIComps = iComps ? numComp : 1;
587
579
  const textureHeight = iComps ? 2 * numIComps : 1;
588
- const colorTransferFunc = actorProperty.getRGBTransferFunction();
589
- const cfunToString = getTransferFunctionHash(colorTransferFunc, iComps, numIComps);
590
- const cTex = model._openGLRenderWindow.getGraphicsResourceForObject(colorTransferFunc);
580
+ const colorTransferFunctions = [];
581
+ for (let component = 0; component < numIComps; ++component) {
582
+ colorTransferFunctions.push(actorProperty.getRGBTransferFunction(component));
583
+ }
584
+ const cfunToString = getTransferFunctionsHash(colorTransferFunctions, iComps, numIComps);
585
+ const firstColorTransferFunc = actorProperty.getRGBTransferFunction();
586
+ const cTex = model._openGLRenderWindow.getGraphicsResourceForObject(firstColorTransferFunc);
591
587
  const reBuildC = !cTex?.oglObject?.getHandle() || cTex?.hash !== cfunToString;
592
588
  if (reBuildC) {
593
589
  model.colorTexture = vtkOpenGLTexture.newInstance({
@@ -608,7 +604,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
608
604
  model.colorTexture.setMinificationFilter(Filter.LINEAR);
609
605
  model.colorTexture.setMagnificationFilter(Filter.LINEAR);
610
606
  }
611
- if (colorTransferFunc) {
607
+ if (firstColorTransferFunc) {
612
608
  const tmpTable = new Float32Array(cWidth * 3);
613
609
  for (let c = 0; c < numIComps; c++) {
614
610
  const cfun = actorProperty.getRGBTransferFunction(c);
@@ -626,22 +622,34 @@ function vtkOpenGLImageMapper(publicAPI, model) {
626
622
  }
627
623
  }
628
624
  model.colorTexture.resetFormatAndType();
629
- model.colorTexture.create2DFromRaw(cWidth, textureHeight, 3, VtkDataTypes.UNSIGNED_CHAR, cTable);
625
+ model.colorTexture.create2DFromRaw({
626
+ width: cWidth,
627
+ height: textureHeight,
628
+ numComps: 3,
629
+ dataType: VtkDataTypes.UNSIGNED_CHAR,
630
+ data: cTable
631
+ });
630
632
  } else {
631
633
  for (let i = 0; i < cWidth * 3; ++i) {
632
634
  cTable[i] = 255.0 * i / ((cWidth - 1) * 3);
633
635
  cTable[i + 1] = 255.0 * i / ((cWidth - 1) * 3);
634
636
  cTable[i + 2] = 255.0 * i / ((cWidth - 1) * 3);
635
637
  }
636
- model.colorTexture.create2DFromRaw(cWidth, 1, 3, VtkDataTypes.UNSIGNED_CHAR, cTable);
638
+ model.colorTexture.create2DFromRaw({
639
+ width: cWidth,
640
+ height: 1,
641
+ numComps: 3,
642
+ dataType: VtkDataTypes.UNSIGNED_CHAR,
643
+ data: cTable
644
+ });
637
645
  }
638
- if (colorTransferFunc) {
639
- model._openGLRenderWindow.setGraphicsResourceForObject(colorTransferFunc, model.colorTexture, cfunToString);
640
- if (colorTransferFunc !== model._colorTransferFunc) {
641
- model._openGLRenderWindow.registerGraphicsResourceUser(colorTransferFunc, publicAPI);
646
+ if (firstColorTransferFunc) {
647
+ model._openGLRenderWindow.setGraphicsResourceForObject(firstColorTransferFunc, model.colorTexture, cfunToString);
648
+ if (firstColorTransferFunc !== model._colorTransferFunc) {
649
+ model._openGLRenderWindow.registerGraphicsResourceUser(firstColorTransferFunc, publicAPI);
642
650
  model._openGLRenderWindow.unregisterGraphicsResourceUser(model._colorTransferFunc, publicAPI);
643
651
  }
644
- model._colorTransferFunc = colorTransferFunc;
652
+ model._colorTransferFunc = firstColorTransferFunc;
645
653
  }
646
654
  } else {
647
655
  model.colorTexture = cTex.oglObject;
@@ -650,9 +658,13 @@ function vtkOpenGLImageMapper(publicAPI, model) {
650
658
  // Build piecewise function buffer. This buffer is used either
651
659
  // for component weighting or opacity, depending on whether we're
652
660
  // rendering components independently or not.
653
- const pwFunc = actorProperty.getPiecewiseFunction();
654
- const pwfunToString = getTransferFunctionHash(pwFunc, iComps, numIComps);
655
- const pwfTex = model._openGLRenderWindow.getGraphicsResourceForObject(pwFunc);
661
+ const opacityFunctions = [];
662
+ for (let component = 0; component < numIComps; ++component) {
663
+ opacityFunctions.push(actorProperty.getPiecewiseFunction(component));
664
+ }
665
+ const pwfunToString = getTransferFunctionsHash(opacityFunctions, iComps, numIComps);
666
+ const firstPwFunc = actorProperty.getPiecewiseFunction();
667
+ const pwfTex = model._openGLRenderWindow.getGraphicsResourceForObject(firstPwFunc);
656
668
  // rebuild opacity tfun?
657
669
  const reBuildPwf = !pwfTex?.oglObject?.getHandle() || pwfTex?.hash !== pwfunToString;
658
670
  if (reBuildPwf) {
@@ -674,7 +686,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
674
686
  model.pwfTexture.setMinificationFilter(Filter.LINEAR);
675
687
  model.pwfTexture.setMagnificationFilter(Filter.LINEAR);
676
688
  }
677
- if (pwFunc) {
689
+ if (firstPwFunc) {
678
690
  const pwfFloatTable = new Float32Array(pwfSize);
679
691
  const tmpTable = new Float32Array(pwfWidth);
680
692
  for (let c = 0; c < numIComps; ++c) {
@@ -699,19 +711,31 @@ function vtkOpenGLImageMapper(publicAPI, model) {
699
711
  }
700
712
  }
701
713
  model.pwfTexture.resetFormatAndType();
702
- model.pwfTexture.create2DFromRaw(pwfWidth, textureHeight, 1, VtkDataTypes.FLOAT, pwfFloatTable);
714
+ model.pwfTexture.create2DFromRaw({
715
+ width: pwfWidth,
716
+ height: textureHeight,
717
+ numComps: 1,
718
+ dataType: VtkDataTypes.FLOAT,
719
+ data: pwfFloatTable
720
+ });
703
721
  } else {
704
722
  // default is opaque
705
723
  pwfTable.fill(255.0);
706
- model.pwfTexture.create2DFromRaw(pwfWidth, 1, 1, VtkDataTypes.UNSIGNED_CHAR, pwfTable);
724
+ model.pwfTexture.create2DFromRaw({
725
+ width: pwfWidth,
726
+ height: 1,
727
+ numComps: 1,
728
+ dataType: VtkDataTypes.UNSIGNED_CHAR,
729
+ data: pwfTable
730
+ });
707
731
  }
708
- if (pwFunc) {
709
- model._openGLRenderWindow.setGraphicsResourceForObject(pwFunc, model.pwfTexture, pwfunToString);
710
- if (pwFunc !== model._pwFunc) {
711
- model._openGLRenderWindow.registerGraphicsResourceUser(pwFunc, publicAPI);
732
+ if (firstPwFunc) {
733
+ model._openGLRenderWindow.setGraphicsResourceForObject(firstPwFunc, model.pwfTexture, pwfunToString);
734
+ if (firstPwFunc !== model._pwFunc) {
735
+ model._openGLRenderWindow.registerGraphicsResourceUser(firstPwFunc, publicAPI);
712
736
  model._openGLRenderWindow.unregisterGraphicsResourceUser(model._pwFunc, publicAPI);
713
737
  }
714
- model._pwFunc = pwFunc;
738
+ model._pwFunc = firstPwFunc;
715
739
  }
716
740
  } else {
717
741
  model.pwfTexture = pwfTex.oglObject;
@@ -887,7 +911,15 @@ function vtkOpenGLImageMapper(publicAPI, model) {
887
911
  // Don't share this resource as `scalars` is created in this function
888
912
  // so it is impossible to share
889
913
  model.openGLTexture.resetFormatAndType();
890
- model.openGLTexture.create2DFilterableFromRaw(dims[0], dims[1], numComp, imgScalars.getDataType(), scalars, model.renderable.getPreferSizeOverAccuracy?.(), ranges);
914
+ model.openGLTexture.create2DFilterableFromRaw({
915
+ width: dims[0],
916
+ height: dims[1],
917
+ numComps: numComp,
918
+ dataType: imgScalars.getDataType(),
919
+ data: scalars,
920
+ preferSizeOverAccuracy: !!model.renderable.getPreferSizeOverAccuracy?.(),
921
+ ranges
922
+ });
891
923
  model.openGLTexture.activate();
892
924
  model.openGLTexture.sendParameters();
893
925
  model.openGLTexture.deactivate();
@@ -957,7 +989,13 @@ function vtkOpenGLImageMapper(publicAPI, model) {
957
989
  model.labelOutlineThicknessTexture.setMagnificationFilter(Filter.NEAREST);
958
990
 
959
991
  // Create a 2D texture (acting as 1D) from the raw data
960
- model.labelOutlineThicknessTexture.create2DFromRaw(lWidth, lHeight, 1, VtkDataTypes.UNSIGNED_CHAR, lTable);
992
+ model.labelOutlineThicknessTexture.create2DFromRaw({
993
+ width: lWidth,
994
+ height: lHeight,
995
+ numComps: 1,
996
+ dataType: VtkDataTypes.UNSIGNED_CHAR,
997
+ data: lTable
998
+ });
961
999
  if (labelOutlineThicknessArray) {
962
1000
  model._openGLRenderWindow.setGraphicsResourceForObject(labelOutlineThicknessArray, model.labelOutlineThicknessTexture, toString);
963
1001
  if (labelOutlineThicknessArray !== model._labelOutlineThicknessArray) {