@kitware/vtk.js 23.4.2 → 23.4.4

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 (180) hide show
  1. package/Common/Core/Math/Constants.js +12 -0
  2. package/Common/Core/Math/index.js +1 -1
  3. package/Common/Core/Math.js +1 -1
  4. package/Common/Core/ScalarsToColors/Constants.d.ts +18 -0
  5. package/Common/DataModel/AbstractPointLocator.d.ts +54 -0
  6. package/Common/DataModel/AbstractPointLocator.js +40 -0
  7. package/Common/DataModel/BoundingBox.d.ts +659 -0
  8. package/Common/DataModel/Collection.d.ts +118 -0
  9. package/Common/DataModel/Collection.js +113 -0
  10. package/Common/DataModel/DataSet/Constants.d.ts +27 -0
  11. package/Common/DataModel/EdgeLocator.d.ts +79 -0
  12. package/Common/DataModel/EdgeLocator.js +85 -0
  13. package/Common/DataModel/ITKHelper.d.ts +54 -0
  14. package/Common/DataModel/IncrementalOctreeNode.d.ts +297 -0
  15. package/Common/DataModel/IncrementalOctreeNode.js +640 -0
  16. package/Common/DataModel/IncrementalOctreePointLocator.d.ts +61 -0
  17. package/Common/DataModel/IncrementalOctreePointLocator.js +398 -0
  18. package/Common/DataModel/Locator.d.ts +43 -0
  19. package/Common/DataModel/Locator.js +37 -0
  20. package/Common/DataModel/Plane.js +1 -1
  21. package/Common/DataModel/PolyData/Constants.d.ts +6 -0
  22. package/Common/DataModel/PolyLine.d.ts +63 -0
  23. package/Common/DataModel/PolyLine.js +77 -0
  24. package/Common/DataModel/Polygon/Constants.js +12 -0
  25. package/Common/DataModel/Polygon.js +1 -1
  26. package/Common/DataModel/Quad/Constants.js +9 -0
  27. package/Common/DataModel/Quad.d.ts +91 -0
  28. package/Common/DataModel/Quad.js +235 -0
  29. package/Common/DataModel/SelectionNode/Constants.d.ts +27 -0
  30. package/Common/DataModel/Spline1D/Constants.js +17 -0
  31. package/Common/DataModel/Spline3D/Constants.d.ts +9 -0
  32. package/Common/Transform/Transform.js +51 -0
  33. package/Filters/Core/PolyDataNormals.js +124 -0
  34. package/Filters/General/ClipClosedSurface/Constants.js +10 -0
  35. package/Filters/General/ClipClosedSurface.d.ts +95 -0
  36. package/Filters/General/ClipClosedSurface.js +972 -0
  37. package/Filters/General/ContourTriangulator/Constants.js +6 -0
  38. package/Filters/General/ContourTriangulator/helper.js +1951 -0
  39. package/Filters/General/ContourTriangulator.d.ts +136 -0
  40. package/Filters/General/ContourTriangulator.js +202 -0
  41. package/Filters/General/ImageMarchingCubes.js +1 -1
  42. package/Filters/General/MoleculeToRepresentation.js +1 -1
  43. package/Filters/General/OBBTree/OBBNode.js +82 -0
  44. package/Filters/General/OBBTree/helper.js +92 -0
  45. package/Filters/General/OBBTree.js +1243 -0
  46. package/Filters/General/TubeFilter.js +1 -1
  47. package/Filters/Sources/LineSource.js +1 -1
  48. package/Filters/Sources/PlaneSource.js +1 -1
  49. package/Filters/Texture/TextureMapToPlane.js +1 -1
  50. package/Interaction/Manipulators/CompositeCameraManipulator.d.ts +68 -0
  51. package/Interaction/Manipulators/CompositeGestureManipulator.d.ts +168 -0
  52. package/Interaction/Manipulators/CompositeKeyboardManipulator.d.ts +48 -0
  53. package/Interaction/Manipulators/CompositeMouseManipulator.d.ts +149 -0
  54. package/Interaction/Manipulators/CompositeVRManipulator.d.ts +44 -0
  55. package/Interaction/Manipulators/GestureCameraManipulator.d.ts +34 -0
  56. package/Interaction/Manipulators/KeyboardCameraManipulator.js +1 -1
  57. package/Interaction/Manipulators/MouseBoxSelectorManipulator.d.ts +88 -0
  58. package/Interaction/Manipulators/MouseCameraAxisRotateManipulator.js +1 -1
  59. package/Interaction/Manipulators/MouseCameraTrackballMultiRotateManipulator.d.ts +32 -0
  60. package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.d.ts +33 -0
  61. package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.js +1 -1
  62. package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.d.ts +33 -0
  63. package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.d.ts +67 -0
  64. package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +1 -1
  65. package/Interaction/Manipulators/MouseCameraTrackballZoomManipulator.d.ts +45 -0
  66. package/Interaction/Manipulators/MouseCameraTrackballZoomToMouseManipulator.d.ts +26 -0
  67. package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
  68. package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
  69. package/Interaction/Manipulators/MouseRangeManipulator.d.ts +53 -0
  70. package/Interaction/Style/InteractorStyleImage.d.ts +107 -0
  71. package/Interaction/Style/InteractorStyleMPRSlice.js +1 -1
  72. package/Interaction/Style/InteractorStyleManipulator.d.ts +348 -0
  73. package/Interaction/Style/InteractorStyleTrackballCamera.d.ts +170 -0
  74. package/Interaction/Widgets/ImageCroppingRegionsWidget.js +1 -1
  75. package/Interaction/Widgets/LabelRepresentation.js +1 -1
  76. package/Interaction/Widgets/OrientationMarkerWidget/Constants.d.ts +11 -0
  77. package/Interaction/Widgets/ResliceCursor/ResliceCursor.js +1 -1
  78. package/Interaction/Widgets/ResliceCursor/ResliceCursorLineRepresentation.js +1 -1
  79. package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation.js +1 -1
  80. package/Proxy/Core/AbstractRepresentationProxy.d.ts +24 -0
  81. package/Proxy/Core/LookupTableProxy.d.ts +45 -0
  82. package/Proxy/Core/PiecewiseFunctionProxy.d.ts +62 -0
  83. package/Proxy/Core/ProxyManager.d.ts +115 -0
  84. package/Proxy/Core/SourceProxy.d.ts +22 -0
  85. package/Proxy/Core/View2DProxy.d.ts +7 -0
  86. package/Proxy/Core/View2DProxy.js +1 -1
  87. package/Proxy/Core/ViewProxy.d.ts +86 -0
  88. package/Proxy/Representations/SliceRepresentationProxy.d.ts +27 -0
  89. package/Proxy/Representations/VolumeRepresentationProxy.d.ts +44 -0
  90. package/README.md +2 -2
  91. package/Rendering/Core/AbstractImageMapper/helper.js +127 -0
  92. package/Rendering/Core/AbstractImageMapper.d.ts +82 -0
  93. package/Rendering/Core/AbstractImageMapper.js +44 -0
  94. package/Rendering/Core/Camera.js +1 -1
  95. package/Rendering/Core/CellPicker.js +1 -1
  96. package/Rendering/Core/ColorTransferFunction/ColorMaps.d.ts +24 -0
  97. package/Rendering/Core/ColorTransferFunction/Constants.d.ts +17 -0
  98. package/Rendering/Core/ColorTransferFunction.js +1 -1
  99. package/Rendering/Core/Coordinate/Constants.d.ts +14 -0
  100. package/Rendering/Core/Coordinate.js +1 -1
  101. package/Rendering/Core/Glyph3DMapper/Constants.d.ts +17 -0
  102. package/Rendering/Core/Glyph3DMapper.js +1 -1
  103. package/Rendering/Core/HardwareSelector.d.ts +84 -0
  104. package/Rendering/Core/ImageArrayMapper.d.ts +253 -0
  105. package/Rendering/Core/ImageArrayMapper.js +242 -0
  106. package/Rendering/Core/ImageMapper/Constants.d.ts +14 -0
  107. package/Rendering/Core/ImageMapper.js +1 -1
  108. package/Rendering/Core/ImageProperty/Constants.d.ts +9 -0
  109. package/Rendering/Core/ImageResliceMapper/Constants.d.ts +11 -0
  110. package/Rendering/Core/ImageResliceMapper/Constants.js +11 -0
  111. package/Rendering/Core/ImageResliceMapper.d.ts +245 -0
  112. package/Rendering/Core/ImageResliceMapper.js +70 -0
  113. package/Rendering/Core/InteractorObserver.d.ts +132 -0
  114. package/Rendering/Core/InteractorStyle/Constants.d.ts +16 -0
  115. package/Rendering/Core/InteractorStyle.d.ts +229 -0
  116. package/Rendering/Core/Light.js +1 -1
  117. package/Rendering/Core/Mapper/Constants.d.ts +26 -0
  118. package/Rendering/Core/Mapper.js +1 -1
  119. package/Rendering/Core/Picker.js +1 -1
  120. package/Rendering/Core/Prop/Constants.d.ts +9 -0
  121. package/Rendering/Core/Prop/Constants.js +9 -0
  122. package/Rendering/Core/Property/Constants.d.ts +24 -0
  123. package/Rendering/Core/Property2D/Constants.d.ts +9 -0
  124. package/Rendering/Core/RenderWindow.js +1 -1
  125. package/Rendering/Core/RenderWindowInteractor/Constants.d.ts +31 -0
  126. package/Rendering/Core/Renderer.js +1 -1
  127. package/Rendering/Core/VolumeMapper/Constants.d.ts +20 -0
  128. package/Rendering/Core/VolumeMapper.js +1 -1
  129. package/Rendering/Core/VolumeProperty/Constants.d.ts +16 -0
  130. package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager/CameraSynchronizer.js +129 -0
  131. package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager.js +131 -0
  132. package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.d.ts +80 -0
  133. package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.js +763 -0
  134. package/Rendering/OpenGL/HardwareSelector/Constants.d.ts +8 -0
  135. package/Rendering/OpenGL/HardwareSelector.d.ts +339 -0
  136. package/Rendering/OpenGL/ImageResliceMapper.js +996 -0
  137. package/Rendering/OpenGL/PolyDataMapper.js +1 -1
  138. package/Rendering/OpenGL/PolyDataMapper2D.js +1 -1
  139. package/Rendering/OpenGL/RenderWindow/Constants.d.ts +10 -0
  140. package/Rendering/OpenGL/RenderWindow/Constants.js +13 -0
  141. package/Rendering/OpenGL/RenderWindow/ContextProxy.js +70 -0
  142. package/Rendering/OpenGL/RenderWindow.d.ts +9 -2
  143. package/Rendering/OpenGL/RenderWindow.js +2 -1
  144. package/Rendering/OpenGL/glsl/vtkImageResliceMapperFS.glsl.js +3 -0
  145. package/Rendering/OpenGL/glsl/vtkImageResliceMapperVS.glsl.js +3 -0
  146. package/Rendering/WebGPU/Actor2D.js +151 -0
  147. package/Rendering/WebGPU/BufferManager.js +1 -1
  148. package/Rendering/WebGPU/CellArrayMapper.js +853 -0
  149. package/Rendering/WebGPU/IndexBuffer.js +397 -0
  150. package/Rendering/WebGPU/PolyDataMapper2D.js +99 -0
  151. package/Rendering/WebGPU/RenderWindow.js +3 -1
  152. package/Rendering/WebGPU/SimpleMapper.js +290 -0
  153. package/Widgets/Core/AbstractWidget.d.ts +187 -0
  154. package/Widgets/Core/AbstractWidgetFactory.d.ts +131 -0
  155. package/Widgets/Core/StateBuilder/color3Mixin.js +24 -0
  156. package/Widgets/Core/StateBuilder/orientationMixin.js +1 -1
  157. package/Widgets/Core/StateBuilder.d.ts +29 -0
  158. package/Widgets/Core/WidgetManager/Constants.d.ts +27 -0
  159. package/Widgets/Core/WidgetManager.d.ts +231 -0
  160. package/Widgets/Core/WidgetState.d.ts +81 -0
  161. package/Widgets/Manipulators/AbstractManipulator.d.ts +221 -0
  162. package/Widgets/Manipulators/AbstractManipulator.js +57 -0
  163. package/Widgets/Manipulators/LineManipulator.js +1 -1
  164. package/Widgets/Manipulators/TrackballManipulator.js +1 -1
  165. package/Widgets/Representations/GlyphRepresentation.js +325 -0
  166. package/Widgets/Representations/LineHandleRepresentation.js +116 -0
  167. package/Widgets/Representations/ResliceCursorContextRepresentation.js +1 -1
  168. package/Widgets/Representations/WidgetRepresentation.js +1 -1
  169. package/Widgets/Widgets3D/AngleWidget.js +1 -1
  170. package/Widgets/Widgets3D/InteractiveOrientationWidget.d.ts +40 -0
  171. package/Widgets/Widgets3D/LabelWidget/behavior.js +157 -0
  172. package/Widgets/Widgets3D/LabelWidget/state.js +22 -0
  173. package/Widgets/Widgets3D/LabelWidget.js +78 -0
  174. package/Widgets/Widgets3D/LineWidget/behavior.js +1 -1
  175. package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
  176. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
  177. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
  178. package/Widgets/Widgets3D/ResliceCursorWidget.js +1 -1
  179. package/index.d.ts +133 -74
  180. package/package.json +1 -1
@@ -0,0 +1,290 @@
1
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
2
+ import macro from '../../macros.js';
3
+ import vtkViewNode from '../SceneGraph/ViewNode.js';
4
+ import vtkWebGPUBindGroup from './BindGroup.js';
5
+ import vtkWebGPUPipeline from './Pipeline.js';
6
+ import vtkWebGPUShaderCache from './ShaderCache.js';
7
+ import vtkWebGPUShaderDescription from './ShaderDescription.js';
8
+ import vtkWebGPUVertexInput from './VertexInput.js';
9
+
10
+ var vtkWebGPUSimpleMapperVS = "\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";
11
+ var vtkWebGPUSimpleMapperFS = "\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::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 //VTK::Color::Impl\n\n //VTK::Normal::Impl\n\n //VTK::Light::Impl\n\n //VTK::TCoord::Impl\n\n //VTK::Select::Impl\n\n // var computedColor:vec4<f32> = vec4<f32>(1.0,0.5,0.5,1.0);\n\n //VTK::RenderEncoder::Impl\n return output;\n}\n"; // ----------------------------------------------------------------------------
12
+ // vtkWebGPUSimpleMapper methods
13
+ // ----------------------------------------------------------------------------
14
+
15
+ function vtkWebGPUSimpleMapper(publicAPI, model) {
16
+ // Set our className
17
+ model.classHierarchy.push('vtkWebGPUSimpleMapper');
18
+
19
+ publicAPI.generateShaderDescriptions = function (hash, pipeline, vertexInput) {
20
+ // create the shader descriptions
21
+ var vDesc = vtkWebGPUShaderDescription.newInstance({
22
+ type: 'vertex',
23
+ hash: hash,
24
+ code: model.vertexShaderTemplate
25
+ });
26
+ var fDesc = vtkWebGPUShaderDescription.newInstance({
27
+ type: 'fragment',
28
+ hash: hash,
29
+ code: model.fragmentShaderTemplate
30
+ }); // add them to the pipeline
31
+
32
+ var sdrs = pipeline.getShaderDescriptions();
33
+ sdrs.push(vDesc);
34
+ sdrs.push(fDesc); // look for replacements to invoke
35
+
36
+ var scode = model.vertexShaderTemplate + model.fragmentShaderTemplate; // eslint-disable-next-line prefer-regex-literals
37
+
38
+ var re = new RegExp('//VTK::[^:]*::', 'g');
39
+ var unique = scode.match(re).filter(function (v, i, a) {
40
+ return a.indexOf(v) === i;
41
+ });
42
+ var fnames = unique.map(function (v) {
43
+ return "replaceShader".concat(v.substring(7, v.length - 2));
44
+ }); // now invoke shader replacement functions
45
+
46
+ for (var i = 0; i < fnames.length; i++) {
47
+ var fname = fnames[i];
48
+
49
+ if (fname !== 'replaceShaderIOStructs' && model.shaderReplacements.has(fname)) {
50
+ model.shaderReplacements.get(fname)(hash, pipeline, vertexInput);
51
+ }
52
+ } // always replace the IOStructs last as other replacement funcs may
53
+ // add inputs or outputs
54
+
55
+
56
+ publicAPI.replaceShaderIOStructs(hash, pipeline, vertexInput); // console.log(vDesc.getCode());
57
+ // console.log(fDesc.getCode());
58
+ };
59
+
60
+ publicAPI.replaceShaderIOStructs = function (hash, pipeline, vertexInput) {
61
+ var vDesc = pipeline.getShaderDescription('vertex');
62
+ vDesc.replaceShaderCode(null, vertexInput);
63
+ var fDesc = pipeline.getShaderDescription('fragment');
64
+ fDesc.replaceShaderCode(vDesc);
65
+ };
66
+
67
+ publicAPI.replaceShaderRenderEncoder = function (hash, pipeline, vertexInput) {
68
+ model.renderEncoder.replaceShaderCode(pipeline);
69
+ };
70
+
71
+ model.shaderReplacements.set('replaceShaderRenderEncoder', publicAPI.replaceShaderRenderEncoder);
72
+
73
+ publicAPI.replaceShaderRenderer = function (hash, pipeline, vertexInput) {
74
+ if (!model.WebGPURenderer) {
75
+ return;
76
+ }
77
+
78
+ var ubocode = model.WebGPURenderer.getBindGroup().getShaderCode(pipeline);
79
+ var vDesc = pipeline.getShaderDescription('vertex');
80
+ var code = vDesc.getCode();
81
+ code = vtkWebGPUShaderCache.substitute(code, '//VTK::Renderer::Dec', [ubocode]).result;
82
+ vDesc.setCode(code);
83
+ var fDesc = pipeline.getShaderDescription('fragment');
84
+ code = fDesc.getCode();
85
+ code = vtkWebGPUShaderCache.substitute(code, '//VTK::Renderer::Dec', [ubocode]).result;
86
+ fDesc.setCode(code);
87
+ };
88
+
89
+ model.shaderReplacements.set('replaceShaderRenderer', publicAPI.replaceShaderRenderer);
90
+
91
+ publicAPI.replaceShaderMapper = function (hash, pipeline, vertexInput) {
92
+ var ubocode = model.bindGroup.getShaderCode(pipeline);
93
+ var vDesc = pipeline.getShaderDescription('vertex');
94
+ var code = vDesc.getCode();
95
+ code = vtkWebGPUShaderCache.substitute(code, '//VTK::Mapper::Dec', [ubocode]).result;
96
+ vDesc.setCode(code);
97
+ var fDesc = pipeline.getShaderDescription('fragment');
98
+ fDesc.addBuiltinInput('bool', '@builtin(front_facing) frontFacing');
99
+ code = fDesc.getCode();
100
+ code = vtkWebGPUShaderCache.substitute(code, '//VTK::Mapper::Dec', [ubocode]).result;
101
+ fDesc.setCode(code);
102
+ };
103
+
104
+ model.shaderReplacements.set('replaceShaderMapper', publicAPI.replaceShaderMapper);
105
+
106
+ publicAPI.replaceShaderPosition = function (hash, pipeline, vertexInput) {
107
+ var vDesc = pipeline.getShaderDescription('vertex');
108
+ vDesc.addBuiltinOutput('vec4<f32>', '@builtin(position) Position');
109
+ var code = vDesc.getCode();
110
+ code = vtkWebGPUShaderCache.substitute(code, '//VTK::Position::Impl', [' output.Position = rendererUBO.SCPCMatrix*vertexBC;']).result;
111
+ vDesc.setCode(code);
112
+ };
113
+
114
+ model.shaderReplacements.set('replaceShaderPosition', publicAPI.replaceShaderPosition);
115
+
116
+ publicAPI.replaceShaderTCoord = function (hash, pipeline, vertexInput) {
117
+ var vDesc = pipeline.getShaderDescription('vertex');
118
+ vDesc.addOutput('vec2<f32>', 'tcoordVS');
119
+ };
120
+
121
+ model.shaderReplacements.set('replaceShaderTCoord', publicAPI.replaceShaderTCoord);
122
+
123
+ publicAPI.addTextureView = function (view) {
124
+ // is it already there?
125
+ if (model.textureViews.includes(view)) {
126
+ return;
127
+ }
128
+
129
+ model.textureViews.push(view);
130
+ }; // do everything required for this mapper to be rerady to draw
131
+ // but do not bind or do the actual draw commands as the pipeline
132
+ // is not neccessarily bound yet
133
+
134
+
135
+ publicAPI.prepareToDraw = function (renderEncoder) {
136
+ model.renderEncoder = renderEncoder; // do anything needed to get our input data up to date
137
+
138
+ publicAPI.updateInput(); // make sure buffers are created and up to date
139
+
140
+ publicAPI.updateBuffers(); // update bindings and bind groups/layouts
141
+ // does not acutally bind them, that is done in draw(...)
142
+
143
+ publicAPI.updateBindings(); // update the pipeline, includes computing the hash, and if needed
144
+ // creating the pipeline, shader code etc
145
+
146
+ publicAPI.updatePipeline();
147
+ };
148
+
149
+ publicAPI.updateInput = function () {};
150
+
151
+ publicAPI.updateBuffers = function () {};
152
+
153
+ publicAPI.updateBindings = function () {
154
+ // bindings can change without a pipeline change
155
+ // as long as their layout remains the same.
156
+ // That is why this is done even when the pipeline
157
+ // hash doesn't change.
158
+ model.bindGroup.setBindables(publicAPI.getBindables());
159
+ };
160
+
161
+ publicAPI.computePipelineHash = function () {};
162
+
163
+ publicAPI.registerDrawCallback = function (encoder) {
164
+ encoder.registerDrawCallback(model.pipeline, publicAPI.draw);
165
+ };
166
+
167
+ publicAPI.prepareAndDraw = function (encoder) {
168
+ publicAPI.prepareToDraw(encoder);
169
+ encoder.setPipeline(model.pipeline);
170
+ publicAPI.draw(encoder);
171
+ }; // do the rest of the calls required to draw this mapper
172
+ // at this point the command encouder and pipeline are
173
+ // created and bound
174
+
175
+
176
+ publicAPI.draw = function (renderEncoder) {
177
+ var pipeline = renderEncoder.getBoundPipeline(); // bind the mapper bind group
178
+
179
+ renderEncoder.activateBindGroup(model.bindGroup);
180
+
181
+ if (model.WebGPURenderer) {
182
+ model.WebGPURenderer.bindUBO(renderEncoder);
183
+ } // bind the vertex input
184
+
185
+
186
+ pipeline.bindVertexInput(renderEncoder, model.vertexInput);
187
+ var indexBuffer = model.vertexInput.getIndexBuffer();
188
+
189
+ if (indexBuffer) {
190
+ renderEncoder.drawIndexed(indexBuffer.getIndexCount(), model.numberOfInstances, 0, 0, 0);
191
+ } else {
192
+ renderEncoder.draw(model.numberOfVertices, model.numberOfInstances, 0, 0);
193
+ }
194
+ };
195
+
196
+ publicAPI.getBindables = function () {
197
+ var bindables = _toConsumableArray(model.additionalBindables);
198
+
199
+ if (model.UBO) {
200
+ bindables.push(model.UBO);
201
+ }
202
+
203
+ if (model.SSBO) {
204
+ bindables.push(model.SSBO);
205
+ } // add texture BindGroupLayouts
206
+
207
+
208
+ for (var t = 0; t < model.textureViews.length; t++) {
209
+ bindables.push(model.textureViews[t]);
210
+ var samp = model.textureViews[t].getSampler();
211
+
212
+ if (samp) {
213
+ bindables.push(samp);
214
+ }
215
+ }
216
+
217
+ return bindables;
218
+ };
219
+
220
+ publicAPI.updatePipeline = function () {
221
+ publicAPI.computePipelineHash();
222
+ model.pipeline = model.device.getPipeline(model.pipelineHash); // build the pipeline if needed
223
+
224
+ if (!model.pipeline) {
225
+ model.pipeline = vtkWebGPUPipeline.newInstance();
226
+ model.pipeline.setDevice(model.device);
227
+
228
+ if (model.WebGPURenderer) {
229
+ model.pipeline.addBindGroupLayout(model.WebGPURenderer.getBindGroup());
230
+ }
231
+
232
+ model.pipeline.addBindGroupLayout(model.bindGroup);
233
+ publicAPI.generateShaderDescriptions(model.pipelineHash, model.pipeline, model.vertexInput);
234
+ model.pipeline.setTopology(model.topology);
235
+ model.pipeline.setRenderEncoder(model.renderEncoder);
236
+ model.pipeline.setVertexState(model.vertexInput.getVertexInputInformation());
237
+ model.device.createPipeline(model.pipelineHash, model.pipeline);
238
+ }
239
+ };
240
+ } // ----------------------------------------------------------------------------
241
+ // Object factory
242
+ // ----------------------------------------------------------------------------
243
+
244
+
245
+ var DEFAULT_VALUES = {
246
+ additionalBindables: undefined,
247
+ bindGroup: null,
248
+ device: null,
249
+ fragmentShaderTemplate: null,
250
+ numberOfInstances: 1,
251
+ numberOfVertices: 0,
252
+ pipelineHash: null,
253
+ shaderReplacements: null,
254
+ SSBO: null,
255
+ textureViews: null,
256
+ topology: 'triangle-list',
257
+ UBO: null,
258
+ vertexShaderTemplate: null,
259
+ WebGPURenderer: null
260
+ }; // ----------------------------------------------------------------------------
261
+
262
+ function extend(publicAPI, model) {
263
+ var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
264
+ Object.assign(model, DEFAULT_VALUES, initialValues); // Inheritance
265
+
266
+ vtkViewNode.extend(publicAPI, model, initialValues);
267
+ model.textureViews = [];
268
+ model.vertexInput = vtkWebGPUVertexInput.newInstance();
269
+ model.bindGroup = vtkWebGPUBindGroup.newInstance({
270
+ label: 'mapperBG'
271
+ });
272
+ model.additionalBindables = [];
273
+ model.fragmentShaderTemplate = model.fragmentShaderTemplate || vtkWebGPUSimpleMapperFS;
274
+ model.vertexShaderTemplate = model.vertexShaderTemplate || vtkWebGPUSimpleMapperVS;
275
+ model.shaderReplacements = new Map(); // Build VTK API
276
+
277
+ macro.get(publicAPI, model, ['pipeline', 'vertexInput']);
278
+ macro.setGet(publicAPI, model, ['additionalBindables', 'device', 'fragmentShaderTemplate', 'interpolate', 'numberOfInstances', 'numberOfVertices', 'pipelineHash', 'shaderReplacements', 'SSBO', 'textureViews', 'topology', 'UBO', 'vertexShaderTemplate', 'WebGPURenderer']); // Object methods
279
+
280
+ vtkWebGPUSimpleMapper(publicAPI, model);
281
+ } // ----------------------------------------------------------------------------
282
+
283
+ var newInstance = macro.newInstance(extend, 'vtkWebGPUSimpleMapper'); // ----------------------------------------------------------------------------
284
+
285
+ var vtkWebGPUSimpleMapper$1 = {
286
+ newInstance: newInstance,
287
+ extend: extend
288
+ };
289
+
290
+ export { vtkWebGPUSimpleMapper$1 as default, extend, newInstance };
@@ -0,0 +1,187 @@
1
+ import vtkInteractorObserver from './../../Rendering/Core/InteractorObserver';
2
+ import vtkProp from './../../Rendering/Core/Prop';
3
+ import vtkRenderer from './../../Rendering/Core/Renderer';
4
+ import vtkWidgetManager from './WidgetManager';
5
+ import vtkWidgetRepresentation from './../Representations/WidgetRepresentation';
6
+ import vtkWidgetState from './WidgetState';
7
+ import { Bounds } from './../../types';
8
+ import { RenderingTypes } from './WidgetManager/Constants';
9
+ import { EventHandler, vtkSubscription } from './../../interfaces';
10
+
11
+ export interface vtkAbstractWidget extends vtkProp, vtkInteractorObserver {
12
+ /**
13
+ * Get the bounds of the widget
14
+ */
15
+ getBounds(): Bounds;
16
+
17
+ /**
18
+ * Get all representations of the widget.
19
+ */
20
+ getNestedProps(): vtkWidgetRepresentation[];
21
+
22
+ /**
23
+ * Activate a handle, identified by both a state and a representation.
24
+ * Will also invoke appropriate events.
25
+ *
26
+ * @param locator An object describing the handle to activate.
27
+ */
28
+ activateHandle(locator: {
29
+ selectedState: vtkWidgetState;
30
+ representation: vtkWidgetRepresentation;
31
+ }): void;
32
+
33
+ /**
34
+ * Deactivate all the handles on the widget instance.
35
+ */
36
+ deactivateAllHandles(): void;
37
+
38
+ /**
39
+ * Returns true if the widget instance holds the given actor, false otherwise.
40
+ *
41
+ * @param {vtkProp} actor
42
+ */
43
+ hasActor(actor: vtkProp): boolean;
44
+
45
+ /**
46
+ * Make the widget instance grab the focus.
47
+ * Should not be called directly or this will lead to unexpected behavior.
48
+ * To grab the focus on a widget, one should call `vtkWidgetManager.grabFocus(widgetInstanceToGiveFocusTo)`
49
+ */
50
+ grabFocus(): void;
51
+
52
+ /**
53
+ * Make the widget instance release the focus.
54
+ */
55
+ loseFocus(): void;
56
+
57
+ /**
58
+ * Returns true if the widget instance holds the focus, false otherwise.
59
+ */
60
+ hasFocus(): boolean;
61
+
62
+ /**
63
+ * Place a widget at the given bounds.
64
+ *
65
+ * @param {Bounds} bounds
66
+ */
67
+ placeWidget(bounds: Bounds): void;
68
+
69
+ /**
70
+ * Get the place factor.
71
+ */
72
+ getPlaceFactor(): number;
73
+
74
+ /**
75
+ * Set the place factor.
76
+ *
77
+ * @param {Number} factor The place factor.
78
+ */
79
+ setPlaceFactor(factor: number): void;
80
+
81
+ /**
82
+ * Get the `vtkWidgetRepresentation` instance associated with the given `vtkActor` instance.
83
+ *
84
+ * @param {vtkProp} actor
85
+ */
86
+ getRepresentationFromActor(actor: vtkProp): vtkWidgetRepresentation;
87
+
88
+ /**
89
+ * Update all the widget representations for render.
90
+ *
91
+ * @param {RenderingTypes} renderingType Default value if `RenderingTypes.FRONT_BUFFER`
92
+ */
93
+ updateRepresentationForRender(renderingType: RenderingTypes): void;
94
+
95
+ /**
96
+ * Get all the underlyings view widgets.
97
+ */
98
+ getViewWidgets(): vtkAbstractWidget[];
99
+
100
+
101
+ /**
102
+ * Set the context visibility.
103
+ *
104
+ * @param {Boolean} visible
105
+ */
106
+ setContextVisibility(visible: boolean): void;
107
+
108
+ /**
109
+ * Get the context visibility.
110
+ */
111
+ getContextVisibility(): boolean;
112
+
113
+ /**
114
+ * Defines if the handles should be visible or not.
115
+ *
116
+ * @param {Boolean} visible
117
+ */
118
+ setHandleVisibility(visible: boolean): void;
119
+
120
+ /**
121
+ * Returns true if the handles are visible, false otherwise.
122
+ */
123
+ getHandleVisibility(): boolean;
124
+
125
+ /**
126
+ * Set the widget manager associated with the widget instance.
127
+ *
128
+ * @param {vtkWidgetManager} wm The widget manager instance
129
+ */
130
+ setWidgetManager(wm: vtkWidgetManager): void;
131
+
132
+ /**
133
+ * Get the widget manager associated with the widget instance.
134
+ */
135
+ getWidgetManager(): vtkWidgetManager;
136
+
137
+ /**
138
+ * Get all the representations of the widget instance.
139
+ */
140
+ getRepresentations(): vtkWidgetRepresentation[];
141
+
142
+ /**
143
+ * Get the the state of the widget instance.
144
+ */
145
+ getWidgetState(): vtkWidgetState;
146
+
147
+ /**
148
+ * Register a callback to be invoked when the `ActivateHandle` event occurs.
149
+ *
150
+ * @param {EventHandler} cb The callback to register
151
+ * @param {Number} [priority] Priority of this subscription
152
+ */
153
+ onActivateHandle(cb: EventHandler, priority?: number): Readonly<vtkSubscription>;
154
+
155
+ /**
156
+ * Invoke the `ActivateHandle` event with the given payload.
157
+ *
158
+ * @param args The event payload
159
+ */
160
+ invokeActivateHandle(...args: unknown[]): void;
161
+ }
162
+
163
+ /**
164
+ * Method used to decorate a given object (publicAPI+model) with vtkAbstractWidget characteristics.
165
+ *
166
+ * @param publicAPI object on which methods will be bounds (public)
167
+ * @param model object on which data structure will be bounds (protected)
168
+ * @param initialValues (default: {})
169
+ */
170
+ export function extend(publicAPI: object, model: object, initialValues? : object): void;
171
+
172
+ /**
173
+ * Method used to create a new instance of vtkAbstractWidget
174
+ *
175
+ * @param initialValues For pre-setting some of its content
176
+ */
177
+ export function newInstance(initialValues?: object): vtkAbstractWidget;
178
+
179
+ /**
180
+ * vtkAbstractWidget is an abstract class to construct a widget.
181
+ */
182
+ export declare const vtkAbstractWidget: {
183
+ newInstance: typeof newInstance,
184
+ extend: typeof extend,
185
+ };
186
+
187
+ export default vtkAbstractWidget;
@@ -0,0 +1,131 @@
1
+ import vtkAbstractWidget from './AbstractWidget';
2
+ import vtkRenderer from './../../Rendering/Core/Renderer';
3
+ import vtkWidgetState from './WidgetState';
4
+ import { ViewTypes } from './WidgetManager/Constants';
5
+ import { Bounds, Nullable } from './../../types';
6
+ import { EventHandler, vtkSubscription, vtkObject } from './../../interfaces';
7
+
8
+ export interface IGetWidgetForViewParams {
9
+ viewId: number;
10
+ renderer?: vtkRenderer;
11
+ viewType?: ViewTypes;
12
+ initialValues?: object;
13
+ }
14
+
15
+ export interface vtkAbstractWidgetFactory extends vtkObject {
16
+ /**
17
+ * Will return the widget associated with the view with Id id `locator.viewId`.
18
+ * If there is no widget associated with the view, a new widget will be constructed, provided
19
+ * that the renderer, viewType, and optionally initialValues are also provided.
20
+ *
21
+ * @param {IGetWidgetForViewParams} locator
22
+ */
23
+ getWidgetForView(locator: IGetWidgetForViewParams): Nullable<vtkAbstractWidget>;
24
+
25
+ /**
26
+ * Get a list of all the view ids.
27
+ */
28
+ getViewIds(): string[];
29
+
30
+ /**
31
+ * Get a list of all the instances of the widget.
32
+ */
33
+ getViewWidgets(): vtkAbstractWidget[];
34
+
35
+ /**
36
+ * Set the visiblity on each underlying view widget.
37
+ *
38
+ * @param {Boolean} visible
39
+ */
40
+ setVisibility(visible: boolean): void
41
+
42
+ /**
43
+ * Set the pickable flag for each underlying view widget.
44
+ *
45
+ * @param {Boolean} pickable
46
+ */
47
+ setPickable(pickable: boolean): void
48
+
49
+ /**
50
+ * Set the dragable flag for each underlying view widget.
51
+ *
52
+ * @param {Boolean} dragable
53
+ */
54
+ setDragable(dragable: boolean): void
55
+
56
+ /**
57
+ * Set the context visibility for each associated view widget.
58
+ *
59
+ * @param {Boolean} visible
60
+ */
61
+ setContextVisibility(visible: boolean): void
62
+
63
+ /**
64
+ * Set the handles visibility for each underlying view widget.
65
+ *
66
+ * @param {Boolean} visible
67
+ */
68
+ setHandleVisiblity(visible: boolean): void
69
+
70
+ /**
71
+ * Place a new widget at the given bounds.
72
+ *
73
+ * @param {Bounds} bounds
74
+ */
75
+ placeWidget(bounds: Bounds);
76
+
77
+ /**
78
+ * Get the place factor.
79
+ */
80
+ getPlaceFactor(): number;
81
+
82
+ /**
83
+ * Set the place factor.
84
+ *
85
+ * @param {Number} factor
86
+ */
87
+ setPlaceFactor(factor: number): void;
88
+
89
+ /**
90
+ * Get the `vtkWidgetState` instance
91
+ */
92
+ getWidgetState(): vtkWidgetState;
93
+
94
+ /**
95
+ * Register a callback to be called when the WidgetChange event arise.
96
+ *
97
+ * @param {EventHandler} cb The callback to be invoked.
98
+ * @param {Number} [priority] The priority of this subscription
99
+ */
100
+ onWidgetChangeEvent(cb: EventHandler, priority?: number): Readonly<vtkSubscription>;
101
+
102
+ /**
103
+ * Invoke the WidgetChange event
104
+ *
105
+ * @param args The event payload
106
+ */
107
+ invokeWidgetChangeEvent(...args: unknown[]): void;
108
+ }
109
+
110
+ /**
111
+ * Method used to decorate a given object (publicAPI+model) with vtkAbstractWidgetFactory characteristics.
112
+ *
113
+ * @param publicAPI object on which methods will be bounds (public)
114
+ * @param model object on which data structure will be bounds (protected)
115
+ * @param initialValues (default: {})
116
+ */
117
+ export function extend(publicAPI: object, model: object, initialValues? : object): void;
118
+
119
+ /**
120
+ * Method used to create a new instance of vtkAbstractWidgetFactory
121
+ *
122
+ * @param initialValues for pre-setting some of its content
123
+ */
124
+ export function newInstance(initialValues?: object): vtkAbstractWidgetFactory;
125
+
126
+ export declare const vtkAbstractWidgetFactory: {
127
+ newInstance: typeof newInstance,
128
+ extend: typeof extend,
129
+ };
130
+
131
+ export default vtkAbstractWidgetFactory;
@@ -0,0 +1,24 @@
1
+ import macro from '../../../macros.js';
2
+
3
+ /**
4
+ * RGB Uint8 color mixin. Not to be used in conjunction with `color` mixin.
5
+ * @see color
6
+ */
7
+
8
+ var DEFAULT_VALUES = {
9
+ color3: [255, 255, 255],
10
+ opacity: 255
11
+ }; // ----------------------------------------------------------------------------
12
+
13
+ function extend(publicAPI, model) {
14
+ var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
15
+ Object.assign(model, DEFAULT_VALUES, initialValues);
16
+ macro.setGetArray(publicAPI, model, ['color3'], 3, 255);
17
+ macro.setGet(publicAPI, model, ['opacity']);
18
+ } // ----------------------------------------------------------------------------
19
+
20
+ var color3 = {
21
+ extend: extend
22
+ };
23
+
24
+ export { color3 as default, extend };
@@ -1,5 +1,5 @@
1
1
  import macro from '../../../macros.js';
2
- import { l as normalize, j as cross } from '../../../Common/Core/Math/index.js';
2
+ import { g as normalize, k as cross } from '../../../Common/Core/Math/index.js';
3
3
 
4
4
  function eq(v1, v2) {
5
5
  return v1.length === 3 && v2.length === 3 && v1[0] === v2[0] && v1[1] === v2[1] && v1[2] === v2[2];
@@ -0,0 +1,29 @@
1
+ import vtkWidgetState from './WidgetState';
2
+
3
+ export interface StateBuilder {
4
+ addDynamicMixinState(buildInfo: {
5
+ labels: string[];
6
+ mixins: string[];
7
+ name: string;
8
+ initialValues?: object;
9
+ }): StateBuilder;
10
+ addStateFromMixin(buildInfo: {
11
+ labels: string[];
12
+ mixins: string[];
13
+ name: string;
14
+ initialValues?: object;
15
+ }): StateBuilder;
16
+ addStateFromInstance(stateInfo: {
17
+ labels: string[];
18
+ name: string;
19
+ instance: vtkWidgetState;
20
+ });
21
+ addField(field: { name: string; initialValue: any });
22
+ build(...mixins: string[]): vtkWidgetState;
23
+ }
24
+
25
+ export function createBuilder(): StateBuilder;
26
+
27
+ export declare const vtkStateBuilder: {
28
+ createBuilder: typeof createBuilder;
29
+ };
@@ -0,0 +1,27 @@
1
+ export declare enum ViewTypes {
2
+ DEFAULT = 0,
3
+ GEOMETRY = 1,
4
+ SLICE = 2,
5
+ VOLUME = 3,
6
+ YZ_PLANE = 4,
7
+ XZ_PLANE = 5,
8
+ XY_PLANE = 6
9
+ }
10
+
11
+ export declare enum RenderingTypes {
12
+ PICKING_BUFFER = 0,
13
+ FRONT_BUFFER = 1
14
+ }
15
+
16
+ export declare enum CaptureOn {
17
+ MOUSE_MOVE = 0,
18
+ MOUSE_RELEASE = 1
19
+ }
20
+
21
+ declare const _default: {
22
+ ViewTypes: typeof ViewTypes;
23
+ RenderingTypes: typeof RenderingTypes;
24
+ CaptureOn: typeof CaptureOn;
25
+ }
26
+
27
+ export default _default;