@kitware/vtk.js 28.12.4 → 28.13.0
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/Imaging/Core/ImageReslice.js +21 -50
- package/Interaction/UI/FPSMonitor.js +1 -0
- package/Proxy/Core/View2DProxy.js +3 -0
- package/Rendering/Core/ImageProperty.js +14 -5
- package/Rendering/Core/Mapper2D.js +10 -0
- package/Rendering/Core/RenderWindow.js +17 -8
- package/Rendering/Core/VolumeProperty.js +20 -8
- package/Rendering/OpenGL/BufferObject.js +5 -2
- package/Rendering/OpenGL/Helper.js +1 -0
- package/Rendering/OpenGL/ImageMapper.js +77 -43
- package/Rendering/OpenGL/ImageResliceMapper.js +76 -40
- package/Rendering/OpenGL/PolyDataMapper.js +8 -0
- package/Rendering/OpenGL/PolyDataMapper2D.js +8 -0
- package/Rendering/OpenGL/RenderWindow.d.ts +37 -1
- package/Rendering/OpenGL/RenderWindow.js +84 -0
- package/Rendering/OpenGL/Renderer.js +7 -1
- package/Rendering/OpenGL/ShaderCache.js +23 -22
- package/Rendering/OpenGL/ShaderProgram.js +12 -2
- package/Rendering/OpenGL/Texture.js +9 -3
- package/Rendering/OpenGL/TextureUnitManager.js +5 -0
- package/Rendering/OpenGL/VolumeMapper.js +52 -11
- package/package.json +1 -1
|
@@ -22,6 +22,9 @@ const {
|
|
|
22
22
|
vtkErrorMacro
|
|
23
23
|
} = macro;
|
|
24
24
|
|
|
25
|
+
// ----------------------------------------------------------------------------
|
|
26
|
+
// helper methods
|
|
27
|
+
// ----------------------------------------------------------------------------
|
|
25
28
|
// TODO: Do we want this in some shared utility? Shouldwe just use lodash.isEqual
|
|
26
29
|
function arrayEquals(a, b) {
|
|
27
30
|
if (a.length !== b.length) {
|
|
@@ -34,6 +37,13 @@ function arrayEquals(a, b) {
|
|
|
34
37
|
}
|
|
35
38
|
return true;
|
|
36
39
|
}
|
|
40
|
+
function computeFnToString(property, pwfun, numberOfComponents) {
|
|
41
|
+
if (pwfun) {
|
|
42
|
+
const iComps = property.getIndependentComponents();
|
|
43
|
+
return `${pwfun.getMTime()}-${iComps}-${numberOfComponents}`;
|
|
44
|
+
}
|
|
45
|
+
return '0';
|
|
46
|
+
}
|
|
37
47
|
|
|
38
48
|
// ----------------------------------------------------------------------------
|
|
39
49
|
// vtkOpenGLVolumeMapper methods
|
|
@@ -283,7 +293,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
283
293
|
}
|
|
284
294
|
|
|
285
295
|
// has something changed that would require us to recreate the shader?
|
|
286
|
-
if (cellBO.getProgram() === 0 || needRebuild || model.lastHaveSeenDepthRequest !== model.haveSeenDepthRequest || !!model.lastZBufferTexture !== !!model.zBufferTexture || cellBO.getShaderSourceTime().getMTime() < publicAPI.getMTime() || cellBO.getShaderSourceTime().getMTime() < model.renderable.getMTime()) {
|
|
296
|
+
if (cellBO.getProgram()?.getHandle() === 0 || needRebuild || model.lastHaveSeenDepthRequest !== model.haveSeenDepthRequest || !!model.lastZBufferTexture !== !!model.zBufferTexture || cellBO.getShaderSourceTime().getMTime() < publicAPI.getMTime() || cellBO.getShaderSourceTime().getMTime() < model.renderable.getMTime()) {
|
|
287
297
|
model.lastZBufferTexture = model.zBufferTexture;
|
|
288
298
|
return true;
|
|
289
299
|
}
|
|
@@ -944,6 +954,10 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
944
954
|
if (!scalars) {
|
|
945
955
|
return;
|
|
946
956
|
}
|
|
957
|
+
if (model._scalars !== scalars) {
|
|
958
|
+
model._openGLRenderWindow.releaseGraphicsResourcesForObject(model._scalars);
|
|
959
|
+
model._scalars = scalars;
|
|
960
|
+
}
|
|
947
961
|
const vprop = actor.getProperty();
|
|
948
962
|
if (!model.jitterTexture.getHandle()) {
|
|
949
963
|
const oTable = new Uint8Array(32 * 32);
|
|
@@ -957,10 +971,12 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
957
971
|
const numComp = scalars.getNumberOfComponents();
|
|
958
972
|
const iComps = vprop.getIndependentComponents();
|
|
959
973
|
const numIComps = iComps ? numComp : 1;
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
let toString =
|
|
963
|
-
|
|
974
|
+
const scalarOpacityFunc = vprop.getScalarOpacity();
|
|
975
|
+
const opTex = model._openGLRenderWindow.getGraphicsResourceForObject(scalarOpacityFunc);
|
|
976
|
+
let toString = computeFnToString(vprop, scalarOpacityFunc, numIComps);
|
|
977
|
+
const reBuildOp = !opTex.vtkObj || opTex.hash !== toString || model.opacityTextureString !== toString;
|
|
978
|
+
if (reBuildOp) {
|
|
979
|
+
// rebuild opacity tfun?
|
|
964
980
|
const oWidth = 1024;
|
|
965
981
|
const oSize = oWidth * 2 * numIComps;
|
|
966
982
|
const ofTable = new Float32Array(oSize);
|
|
@@ -977,6 +993,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
977
993
|
}
|
|
978
994
|
}
|
|
979
995
|
model.opacityTexture.releaseGraphicsResources(model._openGLRenderWindow);
|
|
996
|
+
model.opacityTexture.resetFormatAndType();
|
|
980
997
|
model.opacityTexture.setMinificationFilter(Filter.LINEAR);
|
|
981
998
|
model.opacityTexture.setMagnificationFilter(Filter.LINEAR);
|
|
982
999
|
|
|
@@ -994,11 +1011,20 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
994
1011
|
model.opacityTexture.create2DFromRaw(oWidth, 2 * numIComps, 1, VtkDataTypes.UNSIGNED_CHAR, oTable);
|
|
995
1012
|
}
|
|
996
1013
|
model.opacityTextureString = toString;
|
|
1014
|
+
if (scalarOpacityFunc) {
|
|
1015
|
+
model._openGLRenderWindow.setGraphicsResourceForObject(scalarOpacityFunc, model.opacityTexture, model.opacityTextureString);
|
|
1016
|
+
}
|
|
1017
|
+
} else {
|
|
1018
|
+
model.opacityTexture = opTex.vtkObj;
|
|
1019
|
+
model.opacityTextureString = opTex.hash;
|
|
997
1020
|
}
|
|
998
1021
|
|
|
999
1022
|
// rebuild color tfun?
|
|
1000
|
-
|
|
1001
|
-
|
|
1023
|
+
const colorTransferFunc = vprop.getRGBTransferFunction();
|
|
1024
|
+
toString = computeFnToString(vprop, colorTransferFunc, numIComps);
|
|
1025
|
+
const cTex = model._openGLRenderWindow.getGraphicsResourceForObject(colorTransferFunc);
|
|
1026
|
+
const reBuildC = !cTex?.vtkObj || cTex?.hash !== toString || model.colorTextureString !== toString;
|
|
1027
|
+
if (reBuildC) {
|
|
1002
1028
|
const cWidth = 1024;
|
|
1003
1029
|
const cSize = cWidth * 2 * numIComps * 3;
|
|
1004
1030
|
const cTable = new Uint8Array(cSize);
|
|
@@ -1013,15 +1039,23 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
1013
1039
|
}
|
|
1014
1040
|
}
|
|
1015
1041
|
model.colorTexture.releaseGraphicsResources(model._openGLRenderWindow);
|
|
1042
|
+
model.colorTexture.resetFormatAndType();
|
|
1016
1043
|
model.colorTexture.setMinificationFilter(Filter.LINEAR);
|
|
1017
1044
|
model.colorTexture.setMagnificationFilter(Filter.LINEAR);
|
|
1018
1045
|
model.colorTexture.create2DFromRaw(cWidth, 2 * numIComps, 3, VtkDataTypes.UNSIGNED_CHAR, cTable);
|
|
1019
1046
|
model.colorTextureString = toString;
|
|
1047
|
+
if (colorTransferFunc) {
|
|
1048
|
+
model._openGLRenderWindow.setGraphicsResourceForObject(colorTransferFunc, model.colorTexture, model.colorTextureString);
|
|
1049
|
+
}
|
|
1050
|
+
} else {
|
|
1051
|
+
model.colorTexture = cTex.vtkObj;
|
|
1052
|
+
model.colorTextureString = cTex.hash;
|
|
1020
1053
|
}
|
|
1021
|
-
|
|
1054
|
+
const tex = model._openGLRenderWindow.getGraphicsResourceForObject(scalars);
|
|
1022
1055
|
// rebuild the scalarTexture if the data has changed
|
|
1023
|
-
toString = `${image.getMTime()}`;
|
|
1024
|
-
|
|
1056
|
+
toString = `${image.getMTime()}A${scalars.getMTime()}`;
|
|
1057
|
+
const reBuildTex = !tex?.vtkObj || tex?.hash !== toString || model.scalarTextureString !== toString;
|
|
1058
|
+
if (reBuildTex) {
|
|
1025
1059
|
// Build the textures
|
|
1026
1060
|
const dims = image.getDimensions();
|
|
1027
1061
|
// Use norm16 for scalar texture if the extension is available
|
|
@@ -1030,6 +1064,12 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
1030
1064
|
model.scalarTexture.resetFormatAndType();
|
|
1031
1065
|
model.scalarTexture.create3DFilterableFromDataArray(dims[0], dims[1], dims[2], scalars, model.renderable.getPreferSizeOverAccuracy());
|
|
1032
1066
|
model.scalarTextureString = toString;
|
|
1067
|
+
if (scalars) {
|
|
1068
|
+
model._openGLRenderWindow.setGraphicsResourceForObject(scalars, model.scalarTexture, model.scalarTextureString);
|
|
1069
|
+
}
|
|
1070
|
+
} else {
|
|
1071
|
+
model.scalarTexture = tex.vtkObj;
|
|
1072
|
+
model.scalarTextureString = tex.hash;
|
|
1033
1073
|
}
|
|
1034
1074
|
if (!model.tris.getCABO().getElementCount()) {
|
|
1035
1075
|
// build the CABO
|
|
@@ -1122,7 +1162,8 @@ const DEFAULT_VALUES = {
|
|
|
1122
1162
|
modelToView: null,
|
|
1123
1163
|
projectionToView: null,
|
|
1124
1164
|
avgWindowArea: 0.0,
|
|
1125
|
-
avgFrameTime: 0.0
|
|
1165
|
+
avgFrameTime: 0.0,
|
|
1166
|
+
_scalars: null
|
|
1126
1167
|
};
|
|
1127
1168
|
|
|
1128
1169
|
// ----------------------------------------------------------------------------
|