@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
@@ -3,7 +3,7 @@ import { mat3, mat4, vec3 } from 'gl-matrix';
3
3
  import { newInstance as newInstance$1, setGet, obj, vtkErrorMacro as vtkErrorMacro$1 } from '../../macros.js';
4
4
  import vtkHelper from './Helper.js';
5
5
  import vtkMapper from '../Core/Mapper.js';
6
- import { l as normalize, u as uninitializeBounds } from '../../Common/Core/Math/index.js';
6
+ import { g as normalize, u as uninitializeBounds } from '../../Common/Core/Math/index.js';
7
7
  import vtkOpenGLTexture from './Texture.js';
8
8
  import vtkProperty from '../Core/Property.js';
9
9
  import vtkShaderProgram from './ShaderProgram.js';
@@ -9,7 +9,7 @@ import { v as vtkPolyData2DVS } from './glsl/vtkPolyData2DVS.glsl.js';
9
9
  import vtkReplacementShaderMapper from './ReplacementShaderMapper.js';
10
10
  import vtkShaderProgram from './ShaderProgram.js';
11
11
  import vtkViewNode from '../SceneGraph/ViewNode.js';
12
- import { J as round } from '../../Common/Core/Math/index.js';
12
+ import { E as round } from '../../Common/Core/Math/index.js';
13
13
  import { Representation } from '../Core/Property/Constants.js';
14
14
  import { DisplayLocation } from '../Core/Property2D/Constants.js';
15
15
  import { registerOverride } from './ViewNodeFactory.js';
@@ -0,0 +1,10 @@
1
+ export declare enum XrSessionTypes {
2
+ HmdVR = 0,
3
+ MobileAR = 1,
4
+ LookingGlassVR = 2
5
+ }
6
+
7
+ declare const _default: {
8
+ XrSessionTypes: typeof XrSessionTypes;
9
+ };
10
+ export default _default;
@@ -0,0 +1,13 @@
1
+ var XrSessionTypes = {
2
+ HmdVR: 0,
3
+ // Head-mounted display (HMD), two-camera virtual reality session
4
+ MobileAR: 1,
5
+ // Mobile device, single-camera augmented reality session
6
+ LookingGlassVR: 2 // Looking Glass hologram display, N-camera virtual reality session
7
+
8
+ };
9
+ var Constants = {
10
+ XrSessionTypes: XrSessionTypes
11
+ };
12
+
13
+ export { XrSessionTypes, Constants as default };
@@ -0,0 +1,70 @@
1
+ // This is used to access the underlying 3D context
2
+ var GET_UNDERLYING_CONTEXT = '__getUnderlyingContext';
3
+ function createContextProxyHandler() {
4
+ var cache = new Map();
5
+ var getParameterHandler = {
6
+ apply: function apply(target, gl, args) {
7
+ if (cache.has(args[0])) {
8
+ return cache.get(args[0]);
9
+ }
10
+
11
+ return target.apply(gl, args);
12
+ }
13
+ }; // only supports single-value setters
14
+
15
+ function cachedSetterHandler(key) {
16
+ return {
17
+ apply: function apply(target, gl, args) {
18
+ cache.set(key, args[0]);
19
+ return target.apply(gl, args);
20
+ }
21
+ };
22
+ } // When a property is accessed on the webgl context proxy,
23
+ // it's accessed is intercepted. If the property name matches
24
+ // any of the keys of `propHandlers`, then that handler is called
25
+ // with the following arguments: (gl, prop, receiver, propValue)
26
+ // - gl (WebGL2RenderingContext): the underlying webgl context
27
+ // - propName (string): the property name
28
+ // - receiver (Proxy): the webgl context proxy
29
+ // - propValue (unknown): the value of `gl[propName]`
30
+
31
+
32
+ var propHandlers = Object.create(null); // Sets getParameter(property) as a cached getter proxy.
33
+ // propValue.bind(gl) is to avoid Illegal Invocation errors.
34
+
35
+ propHandlers.getParameter = function (gl, prop, receiver, propValue) {
36
+ return new Proxy(propValue.bind(gl), getParameterHandler);
37
+ }; // Sets depthMask(flag) as a cached setter proxy.
38
+
39
+
40
+ propHandlers.depthMask = function (gl, prop, receiver, propValue) {
41
+ return new Proxy(propValue.bind(gl), cachedSetterHandler(gl.DEPTH_WRITEMASK));
42
+ };
43
+
44
+ return {
45
+ get: function get(gl, prop, receiver) {
46
+ if (prop === GET_UNDERLYING_CONTEXT) return function () {
47
+ return gl;
48
+ };
49
+ var value = Reflect.get(gl, prop, gl);
50
+
51
+ if (value instanceof Function) {
52
+ // prevents Illegal Invocation errors
53
+ value = value.bind(gl);
54
+ }
55
+
56
+ var propHandler = propHandlers[prop];
57
+
58
+ if (propHandler) {
59
+ return propHandler(gl, prop, receiver, value);
60
+ }
61
+
62
+ return value;
63
+ }
64
+ };
65
+ }
66
+ var ContextProxy = {
67
+ createContextProxyHandler: createContextProxyHandler
68
+ };
69
+
70
+ export { GET_UNDERLYING_CONTEXT, createContextProxyHandler, ContextProxy as default };
@@ -21,6 +21,13 @@ export interface IOptions {
21
21
  scale: number
22
22
  }
23
23
 
24
+ export interface I3DContextOptions {
25
+ preserveDrawingBuffer?: boolean;
26
+ depth?: boolean;
27
+ alpha?: boolean;
28
+ powerPreference?: string;
29
+ }
30
+
24
31
  type vtkOpenGLRenderWindowBase = vtkObject & Omit<vtkAlgorithm,
25
32
  | 'getInputData'
26
33
  | 'setInputData'
@@ -197,9 +204,9 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
197
204
 
198
205
  /**
199
206
  *
200
- * @param options
207
+ * @param {I3DContextOptions} options
201
208
  */
202
- get3DContext(options: object): Nullable<WebGLRenderingContext>;
209
+ get3DContext(options: I3DContextOptions): Nullable<WebGLRenderingContext>;
203
210
 
204
211
  /**
205
212
  *
@@ -223,7 +223,8 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
223
223
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
224
224
  preserveDrawingBuffer: false,
225
225
  depth: true,
226
- alpha: true
226
+ alpha: true,
227
+ powerPreference: 'high-performance'
227
228
  };
228
229
  var result = null; // Do we have webxr support
229
230
 
@@ -0,0 +1,3 @@
1
+ var vtkImageResliceMapperFS = "//VTK::System::Dec\n\n/*=========================================================================\n\n Program: Visualization Toolkit\n Module: vtkImageResliceMapperFS.glsl\n\n Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n All rights reserved.\n See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n\n This software is distributed WITHOUT ANY WARRANTY; without even\n the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n PURPOSE. See the above copyright notice for more information.\n\n=========================================================================*/\n// Template for the gpu image mapper fragment shader\n\n// VC position of this fragment\n//VTK::PositionVC::Dec\n\n// Texture coordinates\n//VTK::TCoord::Dec\n\n// picking support\n//VTK::Picking::Dec\n\n// handle coincident offsets\n//VTK::Coincident::Dec\n\n//VTK::ZBuffer::Dec\n\n// the output of this shader\n//VTK::Output::Dec\n\nvoid main()\n{\n // VC position of this fragment. This should not branch/return/discard.\n //VTK::PositionVC::Impl\n\n // Place any calls that require uniform flow (e.g. dFdx) here.\n //VTK::UniformFlow::Impl\n\n // Set gl_FragDepth here (gl_FragCoord.z by default)\n //VTK::Depth::Impl\n\n // Early depth peeling abort:\n //VTK::DepthPeeling::PreColor\n\n //VTK::TCoord::Impl\n\n if (gl_FragData[0].a <= 0.0)\n {\n discard;\n }\n\n //VTK::DepthPeeling::Impl\n\n //VTK::Picking::Impl\n\n // handle coincident offsets\n //VTK::Coincident::Impl\n\n //VTK::ZBuffer::Impl\n\n //VTK::RenderPassFragmentShader::Impl\n}\n";
2
+
3
+ export { vtkImageResliceMapperFS as v };
@@ -0,0 +1,3 @@
1
+ var vtkImageResliceMapperVS = "//VTK::System::Dec\n\n/*=========================================================================\n\n Program: Visualization Toolkit\n Module: vtkImageResliceMapperVS.glsl\n\n Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n All rights reserved.\n See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n\n This software is distributed WITHOUT ANY WARRANTY; without even\n the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n PURPOSE. See the above copyright notice for more information.\n\n=========================================================================*/\n\n// all variables that represent positions or directions have a suffix\n// indicating the coordinate system they are in. The possible values are\n// MC - Model coordinates\n// WC - World coordinates\n// VC - View coordinates\n// DC - Display coordinates\n// TC - Texture coordinates\n\n// frag position in VC\n//VTK::PositionVC::Dec\n\n// Texture coordinates\n//VTK::TCoord::Dec\n\n// picking support\n//VTK::Picking::Dec\n\n// camera and actor matrix values\n//VTK::Camera::Dec\n\nvoid main()\n{\n //VTK::PositionVC::Impl\n\n //VTK::TCoord::Impl\n\n //VTK::Picking::Impl\n}\n";
2
+
3
+ export { vtkImageResliceMapperVS as v };
@@ -0,0 +1,151 @@
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
+ } else {
102
+ mat4.copy(model.keyMatrices.bcsc, model.keyMatrices.bcwc);
103
+ }
104
+
105
+ model.keyMatricesTime.modified();
106
+ }
107
+
108
+ return model.keyMatrices;
109
+ };
110
+ } // ----------------------------------------------------------------------------
111
+ // Object factory
112
+ // ----------------------------------------------------------------------------
113
+
114
+
115
+ var DEFAULT_VALUES = {
116
+ keyMatricesTime: null,
117
+ keyMatrices: null,
118
+ propID: undefined,
119
+ bufferShift: undefined
120
+ }; // ----------------------------------------------------------------------------
121
+
122
+ function extend(publicAPI, model) {
123
+ var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
124
+ Object.assign(model, DEFAULT_VALUES, initialValues); // Inheritance
125
+
126
+ vtkViewNode.extend(publicAPI, model, initialValues);
127
+ model.keyMatricesTime = {};
128
+ macro.obj(model.keyMatricesTime, {
129
+ mtime: 0
130
+ });
131
+ model.keyMatrices = {
132
+ normalMatrix: new Float64Array(16),
133
+ bcwc: new Float64Array(16),
134
+ bcsc: new Float64Array(16)
135
+ };
136
+ macro.get(publicAPI, model, ['propID', 'keyMatricesTime']);
137
+ model.bufferShift = [0, 0, 0, 0]; // Object methods
138
+
139
+ vtkWebGPUActor2D(publicAPI, model);
140
+ } // ----------------------------------------------------------------------------
141
+
142
+ var newInstance = macro.newInstance(extend); // ----------------------------------------------------------------------------
143
+
144
+ var index = {
145
+ newInstance: newInstance,
146
+ extend: extend
147
+ }; // Register ourself to WebGPU backend if imported
148
+
149
+ registerOverride('vtkActor2D', newInstance);
150
+
151
+ export { index as default, extend, newInstance };
@@ -1,6 +1,6 @@
1
1
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
2
  import { newInstance as newInstance$1, obj, setGet, newTypedArray, vtkDebugMacro as vtkDebugMacro$1 } from '../../macros.js';
3
- import { j as cross, l as normalize } from '../../Common/Core/Math/index.js';
3
+ import { k as cross, g as normalize } from '../../Common/Core/Math/index.js';
4
4
  import vtkWebGPUBuffer from './Buffer.js';
5
5
  import vtkWebGPUTypes from './Types.js';
6
6
  import vtkProperty from '../Core/Property.js';