@kitware/vtk.js 32.5.1 → 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.
- package/BREAKING_CHANGES.md +3 -0
- package/Rendering/Core/Actor.d.ts +5 -20
- package/Rendering/Core/Actor.js +5 -68
- package/Rendering/Core/ImageSlice.d.ts +7 -23
- package/Rendering/Core/ImageSlice.js +9 -68
- package/Rendering/Core/Prop3D.d.ts +39 -2
- package/Rendering/Core/Prop3D.js +81 -2
- package/Rendering/Core/Volume.d.ts +5 -20
- package/Rendering/Core/Volume.js +2 -70
- package/Rendering/Core/VolumeMapper/Constants.d.ts +0 -7
- package/Rendering/Core/VolumeMapper/Constants.js +2 -8
- package/Rendering/Core/VolumeMapper.d.ts +16 -140
- package/Rendering/Core/VolumeMapper.js +17 -52
- package/Rendering/Core/VolumeProperty/Constants.d.ts +12 -3
- package/Rendering/Core/VolumeProperty/Constants.js +11 -4
- package/Rendering/Core/VolumeProperty.d.ts +120 -4
- package/Rendering/Core/VolumeProperty.js +49 -4
- package/Rendering/OpenGL/ImageCPRMapper.js +27 -19
- package/Rendering/OpenGL/ImageMapper.js +27 -27
- package/Rendering/OpenGL/ImageResliceMapper.js +261 -172
- package/Rendering/OpenGL/PolyDataMapper.js +1 -8
- package/Rendering/OpenGL/RenderWindow/resourceSharingHelper.d.ts +3 -3
- package/Rendering/OpenGL/RenderWindow/resourceSharingHelper.js +8 -5
- package/Rendering/OpenGL/VolumeMapper.js +710 -772
- package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
- package/Rendering/WebGPU/VolumePassFSQ.js +2 -2
- package/macros2.js +1 -1
- package/package.json +1 -1
|
@@ -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,
|
|
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';
|
|
@@ -181,9 +181,13 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
|
|
|
181
181
|
const iComps = ppty.getIndependentComponents();
|
|
182
182
|
const numIComps = iComps ? numComp : 1;
|
|
183
183
|
const textureHeight = iComps ? 2 * numIComps : 1;
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
184
|
+
const colorTransferFunctions = [];
|
|
185
|
+
for (let component = 0; component < numIComps; ++component) {
|
|
186
|
+
colorTransferFunctions.push(ppty.getRGBTransferFunction(component));
|
|
187
|
+
}
|
|
188
|
+
const colorTextureHash = getTransferFunctionsHash(colorTransferFunctions, iComps, numIComps);
|
|
189
|
+
const firstColorTransferFunc = ppty.getRGBTransferFunction();
|
|
190
|
+
const cachedColorEntry = model._openGLRenderWindow.getGraphicsResourceForObject(firstColorTransferFunc);
|
|
187
191
|
const reBuildColorTexture = !cachedColorEntry?.oglObject?.getHandle() || cachedColorEntry?.hash !== colorTextureHash;
|
|
188
192
|
if (reBuildColorTexture) {
|
|
189
193
|
const cWidth = 1024;
|
|
@@ -191,7 +195,7 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
|
|
|
191
195
|
const cTable = new Uint8ClampedArray(cSize);
|
|
192
196
|
model.colorTexture = vtkOpenGLTexture.newInstance();
|
|
193
197
|
model.colorTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
|
|
194
|
-
if (
|
|
198
|
+
if (firstColorTransferFunc) {
|
|
195
199
|
const tmpTable = new Float32Array(cWidth * 3);
|
|
196
200
|
for (let c = 0; c < numIComps; c++) {
|
|
197
201
|
const cfun = ppty.getRGBTransferFunction(c);
|
|
@@ -219,13 +223,13 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
|
|
|
219
223
|
model.colorTexture.resetFormatAndType();
|
|
220
224
|
model.colorTexture.create2DFromRaw(cWidth, 1, 3, VtkDataTypes.UNSIGNED_CHAR, cTable);
|
|
221
225
|
}
|
|
222
|
-
if (
|
|
223
|
-
model._openGLRenderWindow.setGraphicsResourceForObject(
|
|
224
|
-
if (
|
|
225
|
-
model._openGLRenderWindow.registerGraphicsResourceUser(
|
|
226
|
+
if (firstColorTransferFunc) {
|
|
227
|
+
model._openGLRenderWindow.setGraphicsResourceForObject(firstColorTransferFunc, model.colorTexture, colorTextureHash);
|
|
228
|
+
if (firstColorTransferFunc !== model._colorTransferFunc) {
|
|
229
|
+
model._openGLRenderWindow.registerGraphicsResourceUser(firstColorTransferFunc, publicAPI);
|
|
226
230
|
model._openGLRenderWindow.unregisterGraphicsResourceUser(model._colorTransferFunc, publicAPI);
|
|
227
231
|
}
|
|
228
|
-
model._colorTransferFunc =
|
|
232
|
+
model._colorTransferFunc = firstColorTransferFunc;
|
|
229
233
|
}
|
|
230
234
|
} else {
|
|
231
235
|
model.colorTexture = cachedColorEntry.oglObject;
|
|
@@ -234,9 +238,13 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
|
|
|
234
238
|
// Build piecewise function buffer. This buffer is used either
|
|
235
239
|
// for component weighting or opacity, depending on whether we're
|
|
236
240
|
// rendering components independently or not.
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
241
|
+
const opacityFunctions = [];
|
|
242
|
+
for (let component = 0; component < numIComps; ++component) {
|
|
243
|
+
opacityFunctions.push(ppty.getPiecewiseFunction(component));
|
|
244
|
+
}
|
|
245
|
+
const pwfTextureHash = getTransferFunctionsHash(opacityFunctions, iComps, numIComps);
|
|
246
|
+
const firstPwFunc = ppty.getPiecewiseFunction();
|
|
247
|
+
const cachedPwfEntry = model._openGLRenderWindow.getGraphicsResourceForObject(firstPwFunc);
|
|
240
248
|
const reBuildPwf = !cachedPwfEntry?.oglObject?.getHandle() || cachedPwfEntry?.hash !== pwfTextureHash;
|
|
241
249
|
if (reBuildPwf) {
|
|
242
250
|
const pwfWidth = 1024;
|
|
@@ -244,7 +252,7 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
|
|
|
244
252
|
const pwfTable = new Uint8ClampedArray(pwfSize);
|
|
245
253
|
model.pwfTexture = vtkOpenGLTexture.newInstance();
|
|
246
254
|
model.pwfTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
|
|
247
|
-
if (
|
|
255
|
+
if (firstPwFunc) {
|
|
248
256
|
const pwfFloatTable = new Float32Array(pwfSize);
|
|
249
257
|
const tmpTable = new Float32Array(pwfWidth);
|
|
250
258
|
for (let c = 0; c < numIComps; ++c) {
|
|
@@ -276,13 +284,13 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
|
|
|
276
284
|
model.pwfTexture.resetFormatAndType();
|
|
277
285
|
model.pwfTexture.create2DFromRaw(pwfWidth, 1, 1, VtkDataTypes.UNSIGNED_CHAR, pwfTable);
|
|
278
286
|
}
|
|
279
|
-
if (
|
|
280
|
-
model._openGLRenderWindow.setGraphicsResourceForObject(
|
|
281
|
-
if (
|
|
282
|
-
model._openGLRenderWindow.registerGraphicsResourceUser(
|
|
287
|
+
if (firstPwFunc) {
|
|
288
|
+
model._openGLRenderWindow.setGraphicsResourceForObject(firstPwFunc, model.pwfTexture, pwfTextureHash);
|
|
289
|
+
if (firstPwFunc !== model._pwFunc) {
|
|
290
|
+
model._openGLRenderWindow.registerGraphicsResourceUser(firstPwFunc, publicAPI);
|
|
283
291
|
model._openGLRenderWindow.unregisterGraphicsResourceUser(model._pwFunc, publicAPI);
|
|
284
292
|
}
|
|
285
|
-
model._pwFunc =
|
|
293
|
+
model._pwFunc = firstPwFunc;
|
|
286
294
|
}
|
|
287
295
|
} else {
|
|
288
296
|
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 {
|
|
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';
|
|
@@ -548,13 +547,6 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
548
547
|
publicAPI.renderPieceDraw(ren, actor);
|
|
549
548
|
publicAPI.renderPieceFinish(ren, actor);
|
|
550
549
|
};
|
|
551
|
-
publicAPI.computeBounds = (ren, actor) => {
|
|
552
|
-
if (!publicAPI.getInput()) {
|
|
553
|
-
uninitializeBounds(model.bounds);
|
|
554
|
-
return;
|
|
555
|
-
}
|
|
556
|
-
model.bounds = publicAPI.getInput().getBounds();
|
|
557
|
-
};
|
|
558
550
|
publicAPI.updateBufferObjects = (ren, actor) => {
|
|
559
551
|
// Rebuild buffers if needed
|
|
560
552
|
if (publicAPI.getNeedToRebuildBufferObjects(ren, actor)) {
|
|
@@ -578,9 +570,13 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
578
570
|
const iComps = actorProperty.getIndependentComponents();
|
|
579
571
|
const numIComps = iComps ? numComp : 1;
|
|
580
572
|
const textureHeight = iComps ? 2 * numIComps : 1;
|
|
581
|
-
const
|
|
582
|
-
|
|
583
|
-
|
|
573
|
+
const colorTransferFunctions = [];
|
|
574
|
+
for (let component = 0; component < numIComps; ++component) {
|
|
575
|
+
colorTransferFunctions.push(actorProperty.getRGBTransferFunction(component));
|
|
576
|
+
}
|
|
577
|
+
const cfunToString = getTransferFunctionsHash(colorTransferFunctions, iComps, numIComps);
|
|
578
|
+
const firstColorTransferFunc = actorProperty.getRGBTransferFunction();
|
|
579
|
+
const cTex = model._openGLRenderWindow.getGraphicsResourceForObject(firstColorTransferFunc);
|
|
584
580
|
const reBuildC = !cTex?.oglObject?.getHandle() || cTex?.hash !== cfunToString;
|
|
585
581
|
if (reBuildC) {
|
|
586
582
|
model.colorTexture = vtkOpenGLTexture.newInstance({
|
|
@@ -598,7 +594,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
598
594
|
model.colorTexture.setMinificationFilter(Filter.LINEAR);
|
|
599
595
|
model.colorTexture.setMagnificationFilter(Filter.LINEAR);
|
|
600
596
|
}
|
|
601
|
-
if (
|
|
597
|
+
if (firstColorTransferFunc) {
|
|
602
598
|
const tmpTable = new Float32Array(cWidth * 3);
|
|
603
599
|
for (let c = 0; c < numIComps; c++) {
|
|
604
600
|
const cfun = actorProperty.getRGBTransferFunction(c);
|
|
@@ -625,13 +621,13 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
625
621
|
}
|
|
626
622
|
model.colorTexture.create2DFromRaw(cWidth, 1, 3, VtkDataTypes.UNSIGNED_CHAR, cTable);
|
|
627
623
|
}
|
|
628
|
-
if (
|
|
629
|
-
model._openGLRenderWindow.setGraphicsResourceForObject(
|
|
630
|
-
if (
|
|
631
|
-
model._openGLRenderWindow.registerGraphicsResourceUser(
|
|
624
|
+
if (firstColorTransferFunc) {
|
|
625
|
+
model._openGLRenderWindow.setGraphicsResourceForObject(firstColorTransferFunc, model.colorTexture, cfunToString);
|
|
626
|
+
if (firstColorTransferFunc !== model._colorTransferFunc) {
|
|
627
|
+
model._openGLRenderWindow.registerGraphicsResourceUser(firstColorTransferFunc, publicAPI);
|
|
632
628
|
model._openGLRenderWindow.unregisterGraphicsResourceUser(model._colorTransferFunc, publicAPI);
|
|
633
629
|
}
|
|
634
|
-
model._colorTransferFunc =
|
|
630
|
+
model._colorTransferFunc = firstColorTransferFunc;
|
|
635
631
|
}
|
|
636
632
|
} else {
|
|
637
633
|
model.colorTexture = cTex.oglObject;
|
|
@@ -640,9 +636,13 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
640
636
|
// Build piecewise function buffer. This buffer is used either
|
|
641
637
|
// for component weighting or opacity, depending on whether we're
|
|
642
638
|
// rendering components independently or not.
|
|
643
|
-
const
|
|
644
|
-
|
|
645
|
-
|
|
639
|
+
const opacityFunctions = [];
|
|
640
|
+
for (let component = 0; component < numIComps; ++component) {
|
|
641
|
+
opacityFunctions.push(actorProperty.getPiecewiseFunction(component));
|
|
642
|
+
}
|
|
643
|
+
const pwfunToString = getTransferFunctionsHash(opacityFunctions, iComps, numIComps);
|
|
644
|
+
const firstPwFunc = actorProperty.getPiecewiseFunction();
|
|
645
|
+
const pwfTex = model._openGLRenderWindow.getGraphicsResourceForObject(firstPwFunc);
|
|
646
646
|
// rebuild opacity tfun?
|
|
647
647
|
const reBuildPwf = !pwfTex?.oglObject?.getHandle() || pwfTex?.hash !== pwfunToString;
|
|
648
648
|
if (reBuildPwf) {
|
|
@@ -661,7 +661,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
661
661
|
model.pwfTexture.setMinificationFilter(Filter.LINEAR);
|
|
662
662
|
model.pwfTexture.setMagnificationFilter(Filter.LINEAR);
|
|
663
663
|
}
|
|
664
|
-
if (
|
|
664
|
+
if (firstPwFunc) {
|
|
665
665
|
const pwfFloatTable = new Float32Array(pwfSize);
|
|
666
666
|
const tmpTable = new Float32Array(pwfWidth);
|
|
667
667
|
for (let c = 0; c < numIComps; ++c) {
|
|
@@ -692,13 +692,13 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
692
692
|
pwfTable.fill(255.0);
|
|
693
693
|
model.pwfTexture.create2DFromRaw(pwfWidth, 1, 1, VtkDataTypes.UNSIGNED_CHAR, pwfTable);
|
|
694
694
|
}
|
|
695
|
-
if (
|
|
696
|
-
model._openGLRenderWindow.setGraphicsResourceForObject(
|
|
697
|
-
if (
|
|
698
|
-
model._openGLRenderWindow.registerGraphicsResourceUser(
|
|
695
|
+
if (firstPwFunc) {
|
|
696
|
+
model._openGLRenderWindow.setGraphicsResourceForObject(firstPwFunc, model.pwfTexture, pwfunToString);
|
|
697
|
+
if (firstPwFunc !== model._pwFunc) {
|
|
698
|
+
model._openGLRenderWindow.registerGraphicsResourceUser(firstPwFunc, publicAPI);
|
|
699
699
|
model._openGLRenderWindow.unregisterGraphicsResourceUser(model._pwFunc, publicAPI);
|
|
700
700
|
}
|
|
701
|
-
model._pwFunc =
|
|
701
|
+
model._pwFunc = firstPwFunc;
|
|
702
702
|
}
|
|
703
703
|
} else {
|
|
704
704
|
model.pwfTexture = pwfTex.oglObject;
|