@kitware/vtk.js 25.0.2 → 25.1.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.
- package/Rendering/Core/Prop/Constants.d.ts +9 -0
- package/Rendering/Core/Prop/Constants.js +9 -0
- package/Rendering/Core/Prop.d.ts +69 -35
- package/Rendering/Core/Prop.js +27 -10
- package/Rendering/Core/Property2D.js +6 -2
- package/Rendering/Core/ScalarBarActor.js +113 -141
- package/Rendering/Core/VolumeProperty.d.ts +1 -1
- package/Rendering/OpenGL/PolyDataMapper.js +16 -2
- package/Rendering/Profiles/All.js +2 -0
- package/Rendering/Profiles/Geometry.js +2 -0
- package/Rendering/WebGPU/Actor.js +20 -6
- package/Rendering/WebGPU/Actor2D.js +149 -0
- package/Rendering/WebGPU/CellArrayMapper.js +69 -22
- package/Rendering/WebGPU/Glyph3DMapper.js +10 -1
- package/Rendering/WebGPU/OrderIndependentTranslucentPass.js +1 -1
- package/Rendering/WebGPU/PolyDataMapper2D.js +99 -0
- package/Rendering/WebGPU/Profiles/All.js +2 -0
- package/Rendering/WebGPU/Profiles/Geometry.js +2 -0
- package/Rendering/WebGPU.js +2 -0
- package/Widgets/Core/AbstractWidgetFactory.js +8 -8
- package/Widgets/Widgets3D/AngleWidget.js +8 -4
- package/Widgets/Widgets3D/DistanceWidget.js +8 -4
- package/Widgets/Widgets3D/EllipseWidget.js +2 -2
- package/Widgets/Widgets3D/ImageCroppingWidget.js +10 -6
- package/Widgets/Widgets3D/ImplicitPlaneWidget.js +12 -4
- package/Widgets/Widgets3D/InteractiveOrientationWidget.js +12 -4
- package/Widgets/Widgets3D/LabelWidget.js +4 -3
- package/Widgets/Widgets3D/LineWidget.js +9 -5
- package/Widgets/Widgets3D/PaintWidget.js +13 -9
- package/Widgets/Widgets3D/PolyLineWidget.js +8 -4
- package/Widgets/Widgets3D/RectangleWidget.js +2 -3
- package/Widgets/Widgets3D/ResliceCursorWidget.js +12 -5
- package/Widgets/Widgets3D/ShapeWidget/behavior.js +1 -1
- package/Widgets/Widgets3D/SphereWidget.js +8 -3
- package/Widgets/Widgets3D/SplineWidget.js +16 -13
- package/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { mat4 } from 'gl-matrix';
|
|
2
|
+
import macro from '../../macros.js';
|
|
3
|
+
import vtkProp from '../Core/Prop.js';
|
|
4
|
+
import vtkViewNode from '../SceneGraph/ViewNode.js';
|
|
5
|
+
import { registerOverride } from './ViewNodeFactory.js';
|
|
6
|
+
|
|
7
|
+
var CoordinateSystem = vtkProp.CoordinateSystem; // ----------------------------------------------------------------------------
|
|
8
|
+
// vtkWebGPUActor methods
|
|
9
|
+
// ----------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
function vtkWebGPUActor2D(publicAPI, model) {
|
|
12
|
+
// Set our className
|
|
13
|
+
model.classHierarchy.push('vtkWebGPUActor2D'); // Builds myself.
|
|
14
|
+
|
|
15
|
+
publicAPI.buildPass = function (prepass) {
|
|
16
|
+
if (prepass) {
|
|
17
|
+
model.WebGPURenderer = publicAPI.getFirstAncestorOfType('vtkWebGPURenderer');
|
|
18
|
+
model.WebGPURenderWindow = model.WebGPURenderer.getFirstAncestorOfType('vtkWebGPURenderWindow');
|
|
19
|
+
|
|
20
|
+
if (model.propID === undefined) {
|
|
21
|
+
model.propID = model.WebGPURenderWindow.getUniquePropID();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
publicAPI.prepareNodes();
|
|
25
|
+
publicAPI.addMissingNode(model.renderable.getMapper());
|
|
26
|
+
publicAPI.removeUnusedNodes();
|
|
27
|
+
}
|
|
28
|
+
}; // we draw textures, then mapper, then post pass textures
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
publicAPI.traverseOpaquePass = function (renderPass) {
|
|
32
|
+
if (!model.renderable || !model.renderable.getNestedVisibility() || !model.renderable.getIsOpaque() || model.WebGPURenderer.getSelector() && !model.renderable.getNestedPickable()) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
publicAPI.apply(renderPass, true);
|
|
37
|
+
|
|
38
|
+
if (model.children[0]) {
|
|
39
|
+
model.children[0].traverse(renderPass);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
publicAPI.apply(renderPass, false);
|
|
43
|
+
}; // we draw textures, then mapper, then post pass textures
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
publicAPI.traverseTranslucentPass = function (renderPass) {
|
|
47
|
+
if (!model.renderable || !model.renderable.getNestedVisibility() || model.renderable.getIsOpaque() || model.WebGPURenderer.getSelector() && !model.renderable.getNestedPickable()) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
publicAPI.apply(renderPass, true);
|
|
52
|
+
|
|
53
|
+
if (model.children[0]) {
|
|
54
|
+
model.children[0].traverse(renderPass);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
publicAPI.apply(renderPass, false);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
publicAPI.queryPass = function (prepass, renderPass) {
|
|
61
|
+
if (prepass) {
|
|
62
|
+
if (!model.renderable || !model.renderable.getVisibility()) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (model.renderable.getIsOpaque()) {
|
|
67
|
+
renderPass.incrementOpaqueActorCount();
|
|
68
|
+
} else {
|
|
69
|
+
renderPass.incrementTranslucentActorCount();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
publicAPI.getBufferShift = function (wgpuRen) {
|
|
75
|
+
publicAPI.getKeyMatrices(wgpuRen);
|
|
76
|
+
return model.bufferShift;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
publicAPI.getKeyMatrices = function (wgpuRen) {
|
|
80
|
+
// has the actor or stabilization center changed?
|
|
81
|
+
if (Math.max(model.renderable.getMTime(), wgpuRen.getStabilizedTime()) > model.keyMatricesTime.getMTime()) {
|
|
82
|
+
// compute the net shift, only apply stabilized coords with world coordinates
|
|
83
|
+
model.bufferShift[0] = 0.0;
|
|
84
|
+
model.bufferShift[1] = 0.0;
|
|
85
|
+
model.bufferShift[2] = 0.0;
|
|
86
|
+
var center = wgpuRen.getStabilizedCenterByReference();
|
|
87
|
+
|
|
88
|
+
if (model.renderable.getCoordinateSystem() === CoordinateSystem.WORLD) {
|
|
89
|
+
model.bufferShift[0] -= center[0];
|
|
90
|
+
model.bufferShift[1] -= center[1];
|
|
91
|
+
model.bufferShift[2] -= center[2];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
mat4.identity(model.keyMatrices.bcwc);
|
|
95
|
+
mat4.identity(model.keyMatrices.normalMatrix); // only meed the buffer shift to get to world
|
|
96
|
+
|
|
97
|
+
mat4.translate(model.keyMatrices.bcwc, model.keyMatrices.bcwc, [-model.bufferShift[0], -model.bufferShift[1], -model.bufferShift[2]]); // to get to stabilized we also need the center
|
|
98
|
+
|
|
99
|
+
if (model.renderable.getCoordinateSystem() === CoordinateSystem.WORLD) {
|
|
100
|
+
mat4.translate(model.keyMatrices.bcsc, model.keyMatrices.bcwc, [-center[0], -center[1], -center[2]]);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
model.keyMatricesTime.modified();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return model.keyMatrices;
|
|
107
|
+
};
|
|
108
|
+
} // ----------------------------------------------------------------------------
|
|
109
|
+
// Object factory
|
|
110
|
+
// ----------------------------------------------------------------------------
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
var DEFAULT_VALUES = {
|
|
114
|
+
keyMatricesTime: null,
|
|
115
|
+
keyMatrices: null,
|
|
116
|
+
propID: undefined,
|
|
117
|
+
bufferShift: undefined
|
|
118
|
+
}; // ----------------------------------------------------------------------------
|
|
119
|
+
|
|
120
|
+
function extend(publicAPI, model) {
|
|
121
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
122
|
+
Object.assign(model, DEFAULT_VALUES, initialValues); // Inheritance
|
|
123
|
+
|
|
124
|
+
vtkViewNode.extend(publicAPI, model, initialValues);
|
|
125
|
+
model.keyMatricesTime = {};
|
|
126
|
+
macro.obj(model.keyMatricesTime, {
|
|
127
|
+
mtime: 0
|
|
128
|
+
});
|
|
129
|
+
model.keyMatrices = {
|
|
130
|
+
normalMatrix: new Float64Array(16),
|
|
131
|
+
bcwc: new Float64Array(16),
|
|
132
|
+
bcsc: new Float64Array(16)
|
|
133
|
+
};
|
|
134
|
+
macro.get(publicAPI, model, ['propID', 'keyMatricesTime']);
|
|
135
|
+
model.bufferShift = [0, 0, 0, 0]; // Object methods
|
|
136
|
+
|
|
137
|
+
vtkWebGPUActor2D(publicAPI, model);
|
|
138
|
+
} // ----------------------------------------------------------------------------
|
|
139
|
+
|
|
140
|
+
var newInstance = macro.newInstance(extend); // ----------------------------------------------------------------------------
|
|
141
|
+
|
|
142
|
+
var index = {
|
|
143
|
+
newInstance: newInstance,
|
|
144
|
+
extend: extend
|
|
145
|
+
}; // Register ourself to WebGPU backend if imported
|
|
146
|
+
|
|
147
|
+
registerOverride('vtkActor2D', newInstance);
|
|
148
|
+
|
|
149
|
+
export { index as default, extend, newInstance };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { mat3, mat4 } from 'gl-matrix';
|
|
2
2
|
import { newInstance as newInstance$1, setGet } from '../../macros.js';
|
|
3
3
|
import vtkMapper from '../Core/Mapper.js';
|
|
4
|
+
import vtkProp from '../Core/Prop.js';
|
|
4
5
|
import vtkProperty from '../Core/Property.js';
|
|
6
|
+
import vtkProperty2D from '../Core/Property2D.js';
|
|
5
7
|
import vtkTexture from '../Core/Texture.js';
|
|
6
8
|
import vtkWebGPUBufferManager from './BufferManager.js';
|
|
7
9
|
import vtkWebGPUShaderCache from './ShaderCache.js';
|
|
@@ -12,6 +14,8 @@ var BufferUsage = vtkWebGPUBufferManager.BufferUsage,
|
|
|
12
14
|
PrimitiveTypes = vtkWebGPUBufferManager.PrimitiveTypes;
|
|
13
15
|
var Representation = vtkProperty.Representation;
|
|
14
16
|
var ScalarMode = vtkMapper.ScalarMode;
|
|
17
|
+
var CoordinateSystem = vtkProp.CoordinateSystem;
|
|
18
|
+
var DisplayLocation = vtkProperty2D.DisplayLocation;
|
|
15
19
|
var vtkWebGPUPolyDataVS = "\n//VTK::Renderer::Dec\n\n//VTK::Color::Dec\n\n//VTK::Normal::Dec\n\n//VTK::TCoord::Dec\n\n//VTK::Select::Dec\n\n//VTK::Mapper::Dec\n\n//VTK::IOStructs::Dec\n\n@vertex\nfn main(\n//VTK::IOStructs::Input\n)\n//VTK::IOStructs::Output\n{\n var output : vertexOutput;\n\n var vertex: vec4<f32> = vertexBC;\n\n //VTK::Color::Impl\n\n //VTK::Normal::Impl\n\n //VTK::TCoord::Impl\n\n //VTK::Select::Impl\n\n //VTK::Position::Impl\n\n return output;\n}\n";
|
|
16
20
|
var vtkWebGPUPolyDataFS = "\n//VTK::Renderer::Dec\n\n//VTK::Color::Dec\n\n// optional surface normal declaration\n//VTK::Normal::Dec\n\n//VTK::TCoord::Dec\n\n//VTK::Select::Dec\n\n//VTK::RenderEncoder::Dec\n\n//VTK::Mapper::Dec\n\n//VTK::IOStructs::Dec\n\n@fragment\nfn main(\n//VTK::IOStructs::Input\n)\n//VTK::IOStructs::Output\n{\n var output : fragmentOutput;\n\n var ambientColor: vec4<f32> = mapperUBO.AmbientColor;\n var diffuseColor: vec4<f32> = mapperUBO.DiffuseColor;\n var opacity: f32 = mapperUBO.Opacity;\n\n //VTK::Color::Impl\n\n //VTK::Normal::Impl\n\n //VTK::Light::Impl\n\n var computedColor: vec4<f32> = vec4<f32>(ambientColor.rgb * mapperUBO.AmbientIntensity\n + diffuse * mapperUBO.DiffuseIntensity\n + specular * mapperUBO.SpecularIntensity,\n opacity);\n\n //VTK::TCoord::Impl\n\n //VTK::Select::Impl\n\n if (computedColor.a == 0.0) { discard; };\n\n //VTK::Position::Impl\n\n //VTK::RenderEncoder::Impl\n return output;\n}\n";
|
|
17
21
|
|
|
@@ -29,7 +33,16 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
|
|
|
29
33
|
|
|
30
34
|
publicAPI.buildPass = function (prepass) {
|
|
31
35
|
if (prepass) {
|
|
32
|
-
model.
|
|
36
|
+
if (model.is2D) {
|
|
37
|
+
model.WebGPUActor = publicAPI.getFirstAncestorOfType('vtkWebGPUActor2D');
|
|
38
|
+
model.forceZValue = true;
|
|
39
|
+
} else {
|
|
40
|
+
model.WebGPUActor = publicAPI.getFirstAncestorOfType('vtkWebGPUActor');
|
|
41
|
+
model.forceZValue = false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
model.coordinateSystem = model.WebGPUActor.getRenderable().getCoordinateSystem();
|
|
45
|
+
model.useRendererMatrix = model.coordinateSystem !== CoordinateSystem.DISPLAY;
|
|
33
46
|
model.WebGPURenderer = model.WebGPUActor.getFirstAncestorOfType('vtkWebGPURenderer');
|
|
34
47
|
model.WebGPURenderWindow = model.WebGPURenderer.getParent();
|
|
35
48
|
model.device = model.WebGPURenderWindow.getDevice();
|
|
@@ -62,19 +75,31 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
|
|
|
62
75
|
model.UBO.setArray('BCWCMatrix', keyMats.bcwc);
|
|
63
76
|
model.UBO.setArray('BCSCMatrix', keyMats.bcsc);
|
|
64
77
|
model.UBO.setArray('MCWCNormals', keyMats.normalMatrix);
|
|
65
|
-
|
|
66
|
-
model.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
78
|
+
|
|
79
|
+
if (model.is2D) {
|
|
80
|
+
model.UBO.setValue('ZValue', model.WebGPUActor.getRenderable().getProperty().getDisplayLocation() === DisplayLocation.FOREGROUND ? 1.0 : 0.0);
|
|
81
|
+
var aColor = ppty.getColorByReference();
|
|
82
|
+
model.UBO.setValue('AmbientIntensity', 1.0);
|
|
83
|
+
model.UBO.setArray('AmbientColor', [aColor[0], aColor[1], aColor[2], 1.0]);
|
|
84
|
+
model.UBO.setValue('DiffuseIntensity', 0.0);
|
|
85
|
+
model.UBO.setValue('SpecularIntensity', 0.0);
|
|
86
|
+
} else {
|
|
87
|
+
var _aColor = ppty.getAmbientColorByReference();
|
|
88
|
+
|
|
89
|
+
model.UBO.setValue('AmbientIntensity', ppty.getAmbient());
|
|
90
|
+
model.UBO.setArray('AmbientColor', [_aColor[0], _aColor[1], _aColor[2], 1.0]);
|
|
91
|
+
model.UBO.setValue('DiffuseIntensity', ppty.getDiffuse());
|
|
92
|
+
_aColor = ppty.getDiffuseColorByReference();
|
|
93
|
+
model.UBO.setArray('DiffuseColor', [_aColor[0], _aColor[1], _aColor[2], 1.0]);
|
|
94
|
+
model.UBO.setValue('SpecularIntensity', ppty.getSpecular());
|
|
95
|
+
model.UBO.setValue('SpecularPower', ppty.getSpecularPower());
|
|
96
|
+
_aColor = ppty.getSpecularColorByReference();
|
|
97
|
+
model.UBO.setArray('SpecularColor', [_aColor[0], _aColor[1], _aColor[2], 1.0]);
|
|
98
|
+
_aColor = ppty.getEdgeColorByReference();
|
|
99
|
+
model.UBO.setArray('EdgeColor', [_aColor[0], _aColor[1], _aColor[2], 1.0]);
|
|
100
|
+
}
|
|
101
|
+
|
|
75
102
|
model.UBO.setValue('LineWidth', ppty.getLineWidth());
|
|
76
|
-
aColor = ppty.getEdgeColorByReference();
|
|
77
|
-
model.UBO.setArray('EdgeColor', [aColor[0], aColor[1], aColor[2], 1.0]);
|
|
78
103
|
model.UBO.setValue('Opacity', ppty.getOpacity());
|
|
79
104
|
model.UBO.setValue('PropID', model.WebGPUActor.getPropID());
|
|
80
105
|
var device = model.WebGPURenderWindow.getDevice();
|
|
@@ -106,15 +131,28 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
|
|
|
106
131
|
vDesc.addBuiltinOutput('vec4<f32>', '@builtin(position) Position');
|
|
107
132
|
var code = vDesc.getCode();
|
|
108
133
|
|
|
134
|
+
if (model.useRendererMatrix) {
|
|
135
|
+
code = vtkWebGPUShaderCache.substitute(code, '//VTK::Position::Impl', [' var pCoord: vec4<f32> = rendererUBO.SCPCMatrix*mapperUBO.BCSCMatrix*vertexBC;', '//VTK::Position::Impl']).result;
|
|
136
|
+
|
|
137
|
+
if (model.forceZValue) {
|
|
138
|
+
code = vtkWebGPUShaderCache.substitute(code, '//VTK::Position::Impl', ['pCoord = vec4<f32>(pCoord.xyz/pCoord.w, 1.0);', 'pCoord.z = mapperUBO.ZValue;', '//VTK::Position::Impl']).result;
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
code = vtkWebGPUShaderCache.substitute(code, '//VTK::Position::Impl', [' var pCoord: vec4<f32> = mapperUBO.BCSCMatrix*vertexBC;', ' pCoord.x = 2.0* pCoord.x / rendererUBO.viewportSize.x - 1.0;', ' pCoord.y = 2.0* pCoord.y / rendererUBO.viewportSize.y - 1.0;', ' pCoord.z = 0.5 - 0.5 * pCoord.z;', '//VTK::Position::Impl']).result;
|
|
142
|
+
|
|
143
|
+
if (model.forceZValue) {
|
|
144
|
+
code = vtkWebGPUShaderCache.substitute(code, '//VTK::Position::Impl', [' pCoord.z = mapperUBO.ZValue;', '//VTK::Position::Impl']).result;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
109
148
|
if (publicAPI.haveWideLines()) {
|
|
110
149
|
vDesc.addBuiltinInput('u32', '@builtin(instance_index) instanceIndex'); // widen the edge
|
|
111
150
|
|
|
112
|
-
code = vtkWebGPUShaderCache.substitute(code, '//VTK::Position::Impl', [' var tmpPos: vec4<f32> =
|
|
113
|
-
'
|
|
114
|
-
} else {
|
|
115
|
-
code = vtkWebGPUShaderCache.substitute(code, '//VTK::Position::Impl', [' output.Position = rendererUBO.SCPCMatrix*mapperUBO.BCSCMatrix*vertexBC;']).result;
|
|
151
|
+
code = vtkWebGPUShaderCache.substitute(code, '//VTK::Position::Impl', [' var tmpPos: vec4<f32> = pCoord;', ' var numSteps: f32 = ceil(mapperUBO.LineWidth - 1.0);', ' var offset: f32 = (mapperUBO.LineWidth - 1.0) * (f32(input.instanceIndex / 2u) - numSteps/2.0) / numSteps;', ' var tmpPos2: vec3<f32> = tmpPos.xyz / tmpPos.w;', ' tmpPos2.x = tmpPos2.x + 2.0 * (f32(input.instanceIndex) % 2.0) * offset / rendererUBO.viewportSize.x;', ' tmpPos2.y = tmpPos2.y + 2.0 * (f32(input.instanceIndex + 1u) % 2.0) * offset / rendererUBO.viewportSize.y;', ' tmpPos2.z = min(1.0, tmpPos2.z + 0.00001);', // could become a setting
|
|
152
|
+
' pCoord = vec4<f32>(tmpPos2.xyz * tmpPos.w, tmpPos.w);', '//VTK::Position::Impl']).result;
|
|
116
153
|
}
|
|
117
154
|
|
|
155
|
+
code = vtkWebGPUShaderCache.substitute(code, '//VTK::Position::Impl', [' output.Position = pCoord;']).result;
|
|
118
156
|
vDesc.setCode(code);
|
|
119
157
|
};
|
|
120
158
|
|
|
@@ -265,6 +303,8 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
|
|
|
265
303
|
};
|
|
266
304
|
|
|
267
305
|
publicAPI.buildVertexInput = function () {
|
|
306
|
+
var _model$renderable$get, _model$renderable;
|
|
307
|
+
|
|
268
308
|
var pd = model.currentInput;
|
|
269
309
|
var cells = model.cellArray;
|
|
270
310
|
var primType = model.primitiveType;
|
|
@@ -327,7 +367,8 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
|
|
|
327
367
|
|
|
328
368
|
var usage = publicAPI.getUsage(representation, primType);
|
|
329
369
|
|
|
330
|
-
if (
|
|
370
|
+
if (!model.is2D && ( // no lighting on Property2D
|
|
371
|
+
usage === BufferUsage.Triangles || usage === BufferUsage.Strips)) {
|
|
331
372
|
var normals = pd.getPointData().getNormals();
|
|
332
373
|
var _buffRequest2 = {
|
|
333
374
|
format: 'snorm8x4',
|
|
@@ -398,7 +439,7 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
|
|
|
398
439
|
|
|
399
440
|
var tcoords = null;
|
|
400
441
|
|
|
401
|
-
if (model.renderable.getInterpolateScalarsBeforeMapping() && model.renderable.getColorCoordinates()) {
|
|
442
|
+
if ((_model$renderable$get = (_model$renderable = model.renderable).getInterpolateScalarsBeforeMapping) !== null && _model$renderable$get !== void 0 && _model$renderable$get.call(_model$renderable) && model.renderable.getColorCoordinates()) {
|
|
402
443
|
tcoords = model.renderable.getColorCoordinates();
|
|
403
444
|
} else {
|
|
404
445
|
tcoords = pd.getPointData().getTCoords();
|
|
@@ -414,12 +455,14 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
|
|
|
414
455
|
};
|
|
415
456
|
|
|
416
457
|
publicAPI.updateTextures = function () {
|
|
458
|
+
var _model$renderable$get2, _model$renderable2;
|
|
459
|
+
|
|
417
460
|
// we keep track of new and used textures so
|
|
418
461
|
// that we can clean up any unused textures so we don't hold onto them
|
|
419
462
|
var usedTextures = [];
|
|
420
463
|
var newTextures = []; // do we have a scalar color texture
|
|
421
464
|
|
|
422
|
-
var idata = model.renderable.getColorTextureMap
|
|
465
|
+
var idata = (_model$renderable$get2 = (_model$renderable2 = model.renderable).getColorTextureMap) === null || _model$renderable$get2 === void 0 ? void 0 : _model$renderable$get2.call(_model$renderable2);
|
|
423
466
|
|
|
424
467
|
if (idata) {
|
|
425
468
|
if (!model.colorTexture) {
|
|
@@ -491,7 +534,7 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
|
|
|
491
534
|
|
|
492
535
|
|
|
493
536
|
publicAPI.computePipelineHash = function () {
|
|
494
|
-
var pipelineHash =
|
|
537
|
+
var pipelineHash = "pd".concat(model.useRendererMatrix ? 'r' : '').concat(model.forceZValue ? 'z' : '');
|
|
495
538
|
|
|
496
539
|
if (model.primitiveType === PrimitiveTypes.TriangleEdges || model.primitiveType === PrimitiveTypes.TriangleStripEdges) {
|
|
497
540
|
pipelineHash += 'edge';
|
|
@@ -542,6 +585,8 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
|
|
|
542
585
|
if (publicAPI.haveWideLines()) {
|
|
543
586
|
var ppty = actor.getProperty();
|
|
544
587
|
publicAPI.setNumberOfInstances(Math.ceil(ppty.getLineWidth() * 2.0));
|
|
588
|
+
} else {
|
|
589
|
+
publicAPI.setNumberOfInstances(1);
|
|
545
590
|
}
|
|
546
591
|
};
|
|
547
592
|
} // ----------------------------------------------------------------------------
|
|
@@ -550,6 +595,7 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
|
|
|
550
595
|
|
|
551
596
|
|
|
552
597
|
var DEFAULT_VALUES = {
|
|
598
|
+
is2D: false,
|
|
553
599
|
cellArray: null,
|
|
554
600
|
currentInput: null,
|
|
555
601
|
cellOffset: 0,
|
|
@@ -584,9 +630,10 @@ function extend(publicAPI, model) {
|
|
|
584
630
|
model.UBO.addEntry('LineWidth', 'f32');
|
|
585
631
|
model.UBO.addEntry('Opacity', 'f32');
|
|
586
632
|
model.UBO.addEntry('SpecularPower', 'f32');
|
|
633
|
+
model.UBO.addEntry('ZValue', 'f32');
|
|
587
634
|
model.UBO.addEntry('PropID', 'u32'); // Build VTK API
|
|
588
635
|
|
|
589
|
-
setGet(publicAPI, model, ['cellArray', 'currentInput', 'cellOffset', 'primitiveType', 'renderEncoder']);
|
|
636
|
+
setGet(publicAPI, model, ['cellArray', 'currentInput', 'cellOffset', 'is2D', 'primitiveType', 'renderEncoder']);
|
|
590
637
|
model.textures = []; // Object methods
|
|
591
638
|
|
|
592
639
|
vtkWebGPUCellArrayMapper(publicAPI, model);
|
|
@@ -16,6 +16,15 @@ function vtkWebGPUGlyph3DCellArrayMapper(publicAPI, model) {
|
|
|
16
16
|
|
|
17
17
|
var superClass = _objectSpread({}, publicAPI);
|
|
18
18
|
|
|
19
|
+
publicAPI.setGlyphInstances = function (val) {
|
|
20
|
+
model.glyphInstances = val;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
publicAPI.updateBuffers = function () {
|
|
24
|
+
superClass.updateBuffers();
|
|
25
|
+
publicAPI.setNumberOfInstances(model.glyphInstances);
|
|
26
|
+
};
|
|
27
|
+
|
|
19
28
|
publicAPI.replaceShaderPosition = function (hash, pipeline, vertexInput) {
|
|
20
29
|
var vDesc = pipeline.getShaderDescription('vertex');
|
|
21
30
|
vDesc.addBuiltinInput('u32', '@builtin(instance_index) instanceIndex');
|
|
@@ -115,7 +124,7 @@ function vtkWebGPUGlyph3DMapper(publicAPI, model) {
|
|
|
115
124
|
|
|
116
125
|
for (var i = 0; i < model.children.length; i++) {
|
|
117
126
|
var cellMapper = model.children[i];
|
|
118
|
-
cellMapper.
|
|
127
|
+
cellMapper.setGlyphInstances(model.numInstances);
|
|
119
128
|
}
|
|
120
129
|
}
|
|
121
130
|
};
|
|
@@ -174,7 +174,7 @@ function vtkWebGPUOrderIndependentTranslucentPass(publicAPI, model) {
|
|
|
174
174
|
fDesc.addOutput('vec4<f32>', 'outColor');
|
|
175
175
|
fDesc.addBuiltinInput('vec4<f32>', '@builtin(position) fragPos');
|
|
176
176
|
var code = fDesc.getCode();
|
|
177
|
-
code = vtkWebGPUShaderCache.substitute(code, '//VTK::RenderEncoder::Impl', ['output.outColor = vec4<f32>(computedColor.rgb
|
|
177
|
+
code = vtkWebGPUShaderCache.substitute(code, '//VTK::RenderEncoder::Impl', ['output.outColor = vec4<f32>(computedColor.rgb, computedColor.a);']).result;
|
|
178
178
|
fDesc.setCode(code);
|
|
179
179
|
});
|
|
180
180
|
model.translucentFinalEncoder.setPipelineHash('oitpf');
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import { newInstance as newInstance$1 } from '../../macros.js';
|
|
3
|
+
import vtkWebGPUBufferManager from './BufferManager.js';
|
|
4
|
+
import vtkWebGPUCellArrayMapper from './CellArrayMapper.js';
|
|
5
|
+
import vtkViewNode from '../SceneGraph/ViewNode.js';
|
|
6
|
+
import { registerOverride } from './ViewNodeFactory.js';
|
|
7
|
+
|
|
8
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
+
|
|
10
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
+
var PrimitiveTypes = vtkWebGPUBufferManager.PrimitiveTypes; // ----------------------------------------------------------------------------
|
|
12
|
+
// vtkWebGPUPolyDataMapper methods
|
|
13
|
+
// ----------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
function vtkWebGPUPolyDataMapper2D(publicAPI, model) {
|
|
16
|
+
// Set our className
|
|
17
|
+
model.classHierarchy.push('vtkWebGPUPolyDataMapper2D');
|
|
18
|
+
|
|
19
|
+
publicAPI.createCellArrayMapper = function () {
|
|
20
|
+
return vtkWebGPUCellArrayMapper.newInstance();
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
publicAPI.buildPass = function (prepass) {
|
|
24
|
+
if (prepass) {
|
|
25
|
+
model.WebGPUActor = publicAPI.getFirstAncestorOfType('vtkWebGPUActor2D');
|
|
26
|
+
|
|
27
|
+
if (!model.renderable.getStatic()) {
|
|
28
|
+
model.renderable.update();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var poly = model.renderable.getInputData();
|
|
32
|
+
model.renderable.mapScalars(poly, 1.0);
|
|
33
|
+
publicAPI.updateCellArrayMappers(poly);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
publicAPI.updateCellArrayMappers = function (poly) {
|
|
38
|
+
var prims = [poly.getVerts(), poly.getLines(), poly.getPolys(), poly.getStrips()]; // we instantiate a cell array mapper for each cellArray that has cells
|
|
39
|
+
// and they handle the rendering of that cell array
|
|
40
|
+
|
|
41
|
+
var cellMappers = [];
|
|
42
|
+
var cellOffset = 0;
|
|
43
|
+
|
|
44
|
+
for (var i = PrimitiveTypes.Points; i <= PrimitiveTypes.Triangles; i++) {
|
|
45
|
+
if (prims[i].getNumberOfValues() > 0) {
|
|
46
|
+
if (!model.primitives[i]) {
|
|
47
|
+
model.primitives[i] = publicAPI.createCellArrayMapper();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
var cellMapper = model.primitives[i];
|
|
51
|
+
cellMapper.setCellArray(prims[i]);
|
|
52
|
+
cellMapper.setCurrentInput(poly);
|
|
53
|
+
cellMapper.setCellOffset(cellOffset);
|
|
54
|
+
cellMapper.setPrimitiveType(i);
|
|
55
|
+
cellMapper.setRenderable(model.renderable);
|
|
56
|
+
cellMapper.setIs2D(true);
|
|
57
|
+
cellOffset += prims[i].getNumberOfCells();
|
|
58
|
+
cellMappers.push(cellMapper);
|
|
59
|
+
} else {
|
|
60
|
+
model.primitives[i] = null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
publicAPI.prepareNodes();
|
|
65
|
+
publicAPI.addMissingChildren(cellMappers);
|
|
66
|
+
publicAPI.removeUnusedNodes();
|
|
67
|
+
};
|
|
68
|
+
} // ----------------------------------------------------------------------------
|
|
69
|
+
// Object factory
|
|
70
|
+
// ----------------------------------------------------------------------------
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
function defaultValues(initialValues) {
|
|
74
|
+
return _objectSpread({
|
|
75
|
+
primitives: []
|
|
76
|
+
}, initialValues);
|
|
77
|
+
} // ----------------------------------------------------------------------------
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
function extend(publicAPI, model) {
|
|
81
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
82
|
+
Object.assign(model, defaultValues(initialValues)); // Inheritance
|
|
83
|
+
|
|
84
|
+
vtkViewNode.extend(publicAPI, model, initialValues);
|
|
85
|
+
model.primitives = []; // Object methods
|
|
86
|
+
|
|
87
|
+
vtkWebGPUPolyDataMapper2D(publicAPI, model);
|
|
88
|
+
} // ----------------------------------------------------------------------------
|
|
89
|
+
|
|
90
|
+
var newInstance = newInstance$1(extend, 'vtkWebGPUPolyDataMapper2D'); // ----------------------------------------------------------------------------
|
|
91
|
+
|
|
92
|
+
var index = {
|
|
93
|
+
newInstance: newInstance,
|
|
94
|
+
extend: extend
|
|
95
|
+
}; // Register ourself to WebGPU backend if imported
|
|
96
|
+
|
|
97
|
+
registerOverride('vtkMapper2D', newInstance);
|
|
98
|
+
|
|
99
|
+
export { index as default, extend, newInstance };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import '../Camera.js';
|
|
2
2
|
import '../Renderer.js';
|
|
3
3
|
import '../Actor.js';
|
|
4
|
+
import '../Actor2D.js';
|
|
4
5
|
import '../CubeAxesActor.js';
|
|
5
6
|
import '../PolyDataMapper.js';
|
|
7
|
+
import '../PolyDataMapper2D.js';
|
|
6
8
|
import '../ScalarBarActor.js';
|
|
7
9
|
import '../Texture.js';
|
|
8
10
|
import '../Glyph3DMapper.js';
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import '../Camera.js';
|
|
2
2
|
import '../Renderer.js';
|
|
3
3
|
import '../Actor.js';
|
|
4
|
+
import '../Actor2D.js';
|
|
4
5
|
import '../CubeAxesActor.js';
|
|
5
6
|
import '../PolyDataMapper.js';
|
|
7
|
+
import '../PolyDataMapper2D.js';
|
|
6
8
|
import '../ScalarBarActor.js';
|
|
7
9
|
import '../Texture.js';
|
|
8
10
|
import '../PixelSpaceCallbackMapper.js';
|
package/Rendering/WebGPU.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import vtkRenderWindow from './WebGPU/RenderWindow.js';
|
|
2
2
|
import './WebGPU/Actor.js';
|
|
3
|
+
import './WebGPU/Actor2D.js';
|
|
3
4
|
import './WebGPU/Camera.js';
|
|
4
5
|
import './WebGPU/CubeAxesActor.js';
|
|
5
6
|
import './WebGPU/ForwardPass.js';
|
|
@@ -9,6 +10,7 @@ import './WebGPU/ImageMapper.js';
|
|
|
9
10
|
import './WebGPU/ImageSlice.js';
|
|
10
11
|
import './WebGPU/PixelSpaceCallbackMapper.js';
|
|
11
12
|
import './WebGPU/PolyDataMapper.js';
|
|
13
|
+
import './WebGPU/PolyDataMapper2D.js';
|
|
12
14
|
import './WebGPU/Renderer.js';
|
|
13
15
|
import './WebGPU/ScalarBarActor.js';
|
|
14
16
|
import './WebGPU/SphereMapper.js';
|
|
@@ -187,19 +187,19 @@ function vtkAbstractWidgetFactory(publicAPI, model) {
|
|
|
187
187
|
var unsubscribe = NoOp;
|
|
188
188
|
publicAPI.delete = macro.chain(publicAPI.delete, function () {
|
|
189
189
|
return unsubscribe();
|
|
190
|
-
});
|
|
190
|
+
});
|
|
191
191
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
}, 0);
|
|
192
|
+
if (model.widgetState) {
|
|
193
|
+
unsubscribe = model.widgetState.onModified(function () {
|
|
194
|
+
return publicAPI.invokeWidgetChange(model.widgetState);
|
|
195
|
+
}).unsubscribe;
|
|
196
|
+
}
|
|
199
197
|
} // ----------------------------------------------------------------------------
|
|
200
198
|
|
|
201
199
|
|
|
202
200
|
function extend(publicAPI, model) {
|
|
201
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
202
|
+
Object.assign(model, initialValues);
|
|
203
203
|
macro.obj(publicAPI, model);
|
|
204
204
|
macro.get(publicAPI, model, ['widgetState']);
|
|
205
205
|
macro.event(publicAPI, model, 'WidgetChange');
|
|
@@ -22,8 +22,6 @@ function vtkAngleWidget(publicAPI, model) {
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
model.methodsToLink = ['activeScaleFactor', 'activeColor', 'useActiveColor', 'glyphResolution', 'defaultScale', 'scaleInPixels'];
|
|
25
|
-
model.behavior = widgetBehavior;
|
|
26
|
-
model.widgetState = generateState();
|
|
27
25
|
|
|
28
26
|
publicAPI.getRepresentationsForViewType = function (viewType) {
|
|
29
27
|
switch (viewType) {
|
|
@@ -87,12 +85,18 @@ function vtkAngleWidget(publicAPI, model) {
|
|
|
87
85
|
} // ----------------------------------------------------------------------------
|
|
88
86
|
|
|
89
87
|
|
|
90
|
-
var
|
|
88
|
+
var defaultValues = function defaultValues(initialValues) {
|
|
89
|
+
return _objectSpread({
|
|
90
|
+
// manipulator: null,
|
|
91
|
+
behavior: widgetBehavior,
|
|
92
|
+
widgetState: generateState()
|
|
93
|
+
}, initialValues);
|
|
91
94
|
}; // ----------------------------------------------------------------------------
|
|
92
95
|
|
|
96
|
+
|
|
93
97
|
function extend(publicAPI, model) {
|
|
94
98
|
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
95
|
-
Object.assign(model,
|
|
99
|
+
Object.assign(model, defaultValues(initialValues));
|
|
96
100
|
vtkAbstractWidgetFactory.extend(publicAPI, model, initialValues);
|
|
97
101
|
macro.setGet(publicAPI, model, ['manipulator']);
|
|
98
102
|
vtkAngleWidget(publicAPI, model);
|
|
@@ -22,8 +22,6 @@ function vtkDistanceWidget(publicAPI, model) {
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
model.methodsToLink = ['activeScaleFactor', 'activeColor', 'useActiveColor', 'glyphResolution', 'defaultScale', 'scaleInPixels'];
|
|
25
|
-
model.behavior = widgetBehavior;
|
|
26
|
-
model.widgetState = generateState();
|
|
27
25
|
|
|
28
26
|
publicAPI.getRepresentationsForViewType = function (viewType) {
|
|
29
27
|
switch (viewType) {
|
|
@@ -82,12 +80,18 @@ function vtkDistanceWidget(publicAPI, model) {
|
|
|
82
80
|
} // ----------------------------------------------------------------------------
|
|
83
81
|
|
|
84
82
|
|
|
85
|
-
var
|
|
83
|
+
var defaultValues = function defaultValues(initialValues) {
|
|
84
|
+
return _objectSpread({
|
|
85
|
+
// manipulator: null,
|
|
86
|
+
behavior: widgetBehavior,
|
|
87
|
+
widgetState: generateState()
|
|
88
|
+
}, initialValues);
|
|
86
89
|
}; // ----------------------------------------------------------------------------
|
|
87
90
|
|
|
91
|
+
|
|
88
92
|
function extend(publicAPI, model) {
|
|
89
93
|
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
90
|
-
Object.assign(model,
|
|
94
|
+
Object.assign(model, defaultValues(initialValues));
|
|
91
95
|
vtkAbstractWidgetFactory.extend(publicAPI, model, initialValues);
|
|
92
96
|
macro.setGet(publicAPI, model, ['manipulator']);
|
|
93
97
|
vtkDistanceWidget(publicAPI, model);
|
|
@@ -21,7 +21,6 @@ function vtkEllipseWidget(publicAPI, model) {
|
|
|
21
21
|
model.classHierarchy.push('vtkEllipseWidget'); // --- Widget Requirement ---------------------------------------------------
|
|
22
22
|
|
|
23
23
|
model.methodsToLink = [].concat(_toConsumableArray(model.methodsToLink), ['activeScaleFactor', 'activeColor', 'useActiveColor', 'glyphResolution', 'defaultScale', 'drawBorder', 'drawFace', 'opacity']);
|
|
24
|
-
model.behavior = widgetBehavior;
|
|
25
24
|
|
|
26
25
|
publicAPI.getRepresentationsForViewType = function (viewType) {
|
|
27
26
|
switch (viewType) {
|
|
@@ -49,7 +48,6 @@ function vtkEllipseWidget(publicAPI, model) {
|
|
|
49
48
|
// --------------------------------------------------------------------------
|
|
50
49
|
|
|
51
50
|
|
|
52
|
-
model.widgetState = generateState();
|
|
53
51
|
publicAPI.setManipulator(model.manipulator || vtkPlanePointManipulator.newInstance({
|
|
54
52
|
useCameraNormal: true
|
|
55
53
|
}));
|
|
@@ -60,6 +58,8 @@ function defaultValues(initialValues) {
|
|
|
60
58
|
var _None;
|
|
61
59
|
|
|
62
60
|
return _objectSpread({
|
|
61
|
+
behavior: widgetBehavior,
|
|
62
|
+
widgetState: generateState(),
|
|
63
63
|
modifierBehavior: {
|
|
64
64
|
None: (_None = {}, _defineProperty(_None, BehaviorCategory.PLACEMENT, ShapeBehavior[BehaviorCategory.PLACEMENT].CLICK_AND_DRAG), _defineProperty(_None, BehaviorCategory.POINTS, ShapeBehavior[BehaviorCategory.POINTS].CENTER_TO_CORNER), _defineProperty(_None, BehaviorCategory.RATIO, ShapeBehavior[BehaviorCategory.RATIO].FREE), _None),
|
|
65
65
|
Shift: _defineProperty({}, BehaviorCategory.RATIO, ShapeBehavior[BehaviorCategory.RATIO].FIXED),
|