@kitware/vtk.js 28.10.2 → 28.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (565) hide show
  1. package/Common/Core/Base64.js +53 -82
  2. package/Common/Core/CellArray.js +52 -60
  3. package/Common/Core/ClassHierarchy.js +8 -36
  4. package/Common/Core/DataArray/Constants.js +6 -6
  5. package/Common/Core/DataArray.js +185 -270
  6. package/Common/Core/Endian.js +14 -17
  7. package/Common/Core/HalfFloat.js +17 -34
  8. package/Common/Core/ImageHelper.js +17 -25
  9. package/Common/Core/LookupTable.js +131 -144
  10. package/Common/Core/Math/Constants.js +8 -8
  11. package/Common/Core/Math/index.js +754 -942
  12. package/Common/Core/Math.js +2 -4
  13. package/Common/Core/MatrixBuilder.js +99 -151
  14. package/Common/Core/Points.js +43 -43
  15. package/Common/Core/PriorityQueue.js +30 -28
  16. package/Common/Core/ProgressHandler.js +31 -32
  17. package/Common/Core/ScalarsToColors/Constants.js +4 -4
  18. package/Common/Core/ScalarsToColors.js +196 -253
  19. package/Common/Core/StringArray.js +48 -73
  20. package/Common/Core/URLExtract.js +10 -29
  21. package/Common/Core/VariantArray.js +48 -73
  22. package/Common/Core.js +11 -11
  23. package/Common/DataModel/AbstractPointLocator.js +19 -17
  24. package/Common/DataModel/BoundingBox.js +322 -490
  25. package/Common/DataModel/Box.js +46 -63
  26. package/Common/DataModel/CardinalSpline1D.js +92 -102
  27. package/Common/DataModel/Cell.js +41 -61
  28. package/Common/DataModel/CellLinks.js +91 -127
  29. package/Common/DataModel/CellTypes/Constants.js +7 -6
  30. package/Common/DataModel/CellTypes.js +55 -74
  31. package/Common/DataModel/Collection.js +45 -61
  32. package/Common/DataModel/Cone.js +28 -20
  33. package/Common/DataModel/Cylinder.js +41 -35
  34. package/Common/DataModel/DataSet/Constants.js +11 -5
  35. package/Common/DataModel/DataSet.js +37 -25
  36. package/Common/DataModel/DataSetAttributes/Constants.js +18 -18
  37. package/Common/DataModel/DataSetAttributes/FieldData.js +103 -194
  38. package/Common/DataModel/DataSetAttributes.js +96 -138
  39. package/Common/DataModel/EdgeLocator.js +45 -70
  40. package/Common/DataModel/ITKHelper.js +67 -137
  41. package/Common/DataModel/ImageData.js +115 -172
  42. package/Common/DataModel/ImplicitBoolean/Constants.js +2 -2
  43. package/Common/DataModel/ImplicitBoolean.js +66 -96
  44. package/Common/DataModel/IncrementalOctreeNode.js +201 -231
  45. package/Common/DataModel/IncrementalOctreePointLocator.js +160 -198
  46. package/Common/DataModel/KochanekSpline1D.js +78 -81
  47. package/Common/DataModel/Line/Constants.js +2 -2
  48. package/Common/DataModel/Line.js +82 -105
  49. package/Common/DataModel/Locator.js +17 -10
  50. package/Common/DataModel/Molecule.js +26 -17
  51. package/Common/DataModel/PiecewiseFunction.js +218 -239
  52. package/Common/DataModel/Plane.js +90 -113
  53. package/Common/DataModel/PointSet.js +30 -26
  54. package/Common/DataModel/PolyData/Constants.js +2 -2
  55. package/Common/DataModel/PolyData.js +95 -120
  56. package/Common/DataModel/PolyLine.js +44 -61
  57. package/Common/DataModel/Polygon/Constants.js +4 -4
  58. package/Common/DataModel/Polygon.js +128 -169
  59. package/Common/DataModel/Quad/Constants.js +2 -2
  60. package/Common/DataModel/Quad.js +61 -100
  61. package/Common/DataModel/SelectionNode/Constants.js +5 -4
  62. package/Common/DataModel/SelectionNode.js +25 -21
  63. package/Common/DataModel/Sphere.js +40 -35
  64. package/Common/DataModel/Spline1D/Constants.js +3 -2
  65. package/Common/DataModel/Spline1D.js +34 -18
  66. package/Common/DataModel/Spline3D/Constants.js +2 -2
  67. package/Common/DataModel/Spline3D.js +46 -41
  68. package/Common/DataModel/StructuredData/Constants.js +2 -2
  69. package/Common/DataModel/StructuredData.js +9 -20
  70. package/Common/DataModel/Triangle.js +207 -250
  71. package/Common/DataModel.js +19 -19
  72. package/Common/System/MobileVR.js +56 -61
  73. package/Common/System/TimerLog.js +1 -1
  74. package/Common/System.js +2 -2
  75. package/Common/Transform/LandmarkTransform/Constants.js +2 -2
  76. package/Common/Transform/LandmarkTransform.js +133 -117
  77. package/Common/Transform/Transform.js +42 -57
  78. package/Common/Transform.js +2 -2
  79. package/Common/index.js +4 -4
  80. package/Filters/Core/Cutter.js +134 -146
  81. package/Filters/Core/PolyDataNormals.js +44 -50
  82. package/Filters/Core.js +2 -2
  83. package/Filters/Cornerstone/ImageDataToCornerstoneImage.js +45 -33
  84. package/Filters/Cornerstone.js +1 -1
  85. package/Filters/General/AppendPolyData.js +84 -100
  86. package/Filters/General/Calculator.js +95 -163
  87. package/Filters/General/ClipClosedSurface/Constants.js +2 -2
  88. package/Filters/General/ClipClosedSurface.js +341 -416
  89. package/Filters/General/ClosedPolyLineToSurfaceFilter.js +141 -156
  90. package/Filters/General/ContourTriangulator/Constants.js +2 -2
  91. package/Filters/General/ContourTriangulator/helper.js +684 -812
  92. package/Filters/General/ContourTriangulator.js +92 -89
  93. package/Filters/General/ImageCropFilter.js +77 -78
  94. package/Filters/General/ImageDataOutlineFilter.js +42 -36
  95. package/Filters/General/ImageMarchingCubes/caseTable.js +9 -521
  96. package/Filters/General/ImageMarchingCubes.js +99 -112
  97. package/Filters/General/ImageMarchingSquares/caseTable.js +9 -41
  98. package/Filters/General/ImageMarchingSquares.js +93 -118
  99. package/Filters/General/ImageOutlineFilter.js +53 -54
  100. package/Filters/General/ImageSliceFilter.js +39 -30
  101. package/Filters/General/ImageStreamline.js +107 -124
  102. package/Filters/General/LineFilter.js +26 -15
  103. package/Filters/General/MoleculeToRepresentation.js +136 -149
  104. package/Filters/General/OBBTree/OBBNode.js +36 -34
  105. package/Filters/General/OBBTree/helper.js +19 -24
  106. package/Filters/General/OBBTree.js +396 -488
  107. package/Filters/General/OutlineFilter.js +52 -34
  108. package/Filters/General/PaintFilter/PaintFilter.worker.js +93 -130
  109. package/Filters/General/PaintFilter.js +150 -162
  110. package/Filters/General/ScalarToRGBA.js +38 -33
  111. package/Filters/General/TriangleFilter.js +65 -62
  112. package/Filters/General/TubeFilter/Constants.js +4 -4
  113. package/Filters/General/TubeFilter.js +376 -496
  114. package/Filters/General/WarpScalar.js +58 -60
  115. package/Filters/General/WindowedSincPolyDataFilter.js +258 -330
  116. package/Filters/General.js +21 -21
  117. package/Filters/Sources/Arrow2DSource/Constants.js +2 -2
  118. package/Filters/Sources/Arrow2DSource.js +56 -56
  119. package/Filters/Sources/ArrowSource.js +39 -29
  120. package/Filters/Sources/CircleSource.js +43 -43
  121. package/Filters/Sources/ConcentricCylinderSource.js +151 -174
  122. package/Filters/Sources/ConeSource.js +51 -42
  123. package/Filters/Sources/CubeSource.js +75 -96
  124. package/Filters/Sources/Cursor3D.js +94 -109
  125. package/Filters/Sources/CylinderSource.js +90 -90
  126. package/Filters/Sources/ImageGridSource.js +43 -43
  127. package/Filters/Sources/LineSource.js +49 -39
  128. package/Filters/Sources/PlaneSource.js +97 -104
  129. package/Filters/Sources/PointSource.js +46 -37
  130. package/Filters/Sources/RTAnalyticSource.js +50 -48
  131. package/Filters/Sources/SLICSource.js +63 -73
  132. package/Filters/Sources/SphereSource.js +88 -78
  133. package/Filters/Sources/ViewFinderSource.js +26 -23
  134. package/Filters/Sources.js +14 -14
  135. package/Filters/Texture/TextureMapToPlane.js +95 -97
  136. package/Filters/Texture/TextureMapToSphere.js +46 -54
  137. package/Filters/Texture.js +2 -2
  138. package/Filters/index.js +5 -5
  139. package/IO/Core/BinaryHelper.js +12 -18
  140. package/IO/Core/DataAccessHelper/HtmlDataAccessHelper.js +43 -59
  141. package/IO/Core/DataAccessHelper/HttpDataAccessHelper.js +76 -113
  142. package/IO/Core/DataAccessHelper/JSZipDataAccessHelper.js +62 -112
  143. package/IO/Core/DataAccessHelper/LiteHttpDataAccessHelper.js +76 -113
  144. package/IO/Core/DataAccessHelper.js +6 -6
  145. package/IO/Core/HttpDataSetReader.js +136 -139
  146. package/IO/Core/HttpDataSetSeriesReader.js +64 -75
  147. package/IO/Core/HttpSceneLoader.js +130 -179
  148. package/IO/Core/ImageStream/DefaultProtocol.js +29 -43
  149. package/IO/Core/ImageStream/ViewStream.js +100 -103
  150. package/IO/Core/ImageStream.js +62 -54
  151. package/IO/Core/ResourceLoader.js +10 -9
  152. package/IO/Core/Serializer/ArraySerializer.js +40 -40
  153. package/IO/Core/Serializer/FieldDataSerializer.js +18 -28
  154. package/IO/Core/Serializer/ImageDataSerializer.js +22 -23
  155. package/IO/Core/Serializer/PolyDataSerializer.js +17 -21
  156. package/IO/Core/Serializer.js +6 -13
  157. package/IO/Core/WSLinkClient.js +90 -76
  158. package/IO/Core/ZipMultiDataSetReader.js +46 -44
  159. package/IO/Core/ZipMultiDataSetWriter.js +43 -34
  160. package/IO/Core.js +7 -7
  161. package/IO/Geometry/DracoReader.js +118 -121
  162. package/IO/Geometry/PLYReader.js +163 -223
  163. package/IO/Geometry/PLYWriter/Constants.js +5 -5
  164. package/IO/Geometry/PLYWriter.js +139 -154
  165. package/IO/Geometry/STLReader.js +123 -146
  166. package/IO/Geometry/STLWriter/Constants.js +2 -2
  167. package/IO/Geometry/STLWriter.js +83 -82
  168. package/IO/Geometry.js +5 -5
  169. package/IO/Legacy/LegacyAsciiParser.js +78 -139
  170. package/IO/Legacy/PolyDataReader.js +48 -36
  171. package/IO/Legacy.js +2 -2
  172. package/IO/Misc/ElevationReader.js +67 -60
  173. package/IO/Misc/HttpDataSetLODsLoader.js +41 -38
  174. package/IO/Misc/ITKImageReader.js +58 -45
  175. package/IO/Misc/ITKPolyDataReader.js +50 -38
  176. package/IO/Misc/JSONNucleoReader.js +49 -42
  177. package/IO/Misc/JSONReader.js +38 -33
  178. package/IO/Misc/MTLReader.js +74 -119
  179. package/IO/Misc/OBJReader.js +153 -206
  180. package/IO/Misc/PDBReader.js +70 -68
  181. package/IO/Misc/SkyboxReader.js +77 -82
  182. package/IO/Misc.js +9 -9
  183. package/IO/XML/XMLImageDataReader.js +36 -38
  184. package/IO/XML/XMLImageDataWriter.js +28 -21
  185. package/IO/XML/XMLPolyDataReader.js +49 -46
  186. package/IO/XML/XMLPolyDataWriter.js +43 -42
  187. package/IO/XML/XMLReader.js +262 -304
  188. package/IO/XML/XMLWriter/Constants.js +3 -3
  189. package/IO/XML/XMLWriter.js +70 -84
  190. package/IO/XML.js +6 -6
  191. package/IO/index.js +5 -5
  192. package/Imaging/Core/AbstractImageInterpolator/Constants.js +4 -4
  193. package/Imaging/Core/AbstractImageInterpolator/InterpolationInfo.js +30 -27
  194. package/Imaging/Core/AbstractImageInterpolator.js +74 -87
  195. package/Imaging/Core/ImageInterpolator.js +201 -252
  196. package/Imaging/Core/ImagePointDataIterator.js +96 -122
  197. package/Imaging/Core/ImageReslice/Constants.js +2 -2
  198. package/Imaging/Core/ImageReslice.js +327 -464
  199. package/Imaging/Core.js +4 -4
  200. package/Imaging/Hybrid/SampleFunction.js +58 -51
  201. package/Imaging/Hybrid.js +1 -1
  202. package/Imaging/index.js +2 -2
  203. package/Interaction/Animations/TimeStepBasedAnimationHandler.js +39 -54
  204. package/Interaction/Manipulators/CompositeCameraManipulator.js +22 -13
  205. package/Interaction/Manipulators/CompositeGestureManipulator.js +31 -43
  206. package/Interaction/Manipulators/CompositeKeyboardManipulator.js +15 -11
  207. package/Interaction/Manipulators/CompositeMouseManipulator.js +27 -33
  208. package/Interaction/Manipulators/CompositeVRManipulator.js +22 -15
  209. package/Interaction/Manipulators/GestureCameraManipulator.js +54 -36
  210. package/Interaction/Manipulators/KeyboardCameraManipulator.js +95 -97
  211. package/Interaction/Manipulators/MouseBoxSelectorManipulator.js +70 -89
  212. package/Interaction/Manipulators/MouseCameraAxisRotateManipulator.js +67 -54
  213. package/Interaction/Manipulators/MouseCameraSliceManipulator.js +40 -38
  214. package/Interaction/Manipulators/MouseCameraTrackballFirstPersonManipulator.js +83 -68
  215. package/Interaction/Manipulators/MouseCameraTrackballMultiRotateManipulator.js +32 -28
  216. package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.js +47 -40
  217. package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +55 -43
  218. package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +56 -46
  219. package/Interaction/Manipulators/MouseCameraTrackballZoomManipulator.js +41 -46
  220. package/Interaction/Manipulators/MouseCameraTrackballZoomToMouseManipulator.js +29 -27
  221. package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +123 -146
  222. package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +144 -166
  223. package/Interaction/Manipulators/MouseRangeManipulator.js +127 -132
  224. package/Interaction/Manipulators/VRButtonPanManipulator.js +33 -23
  225. package/Interaction/Manipulators.js +21 -21
  226. package/Interaction/Misc/DeviceOrientationToCamera.js +25 -47
  227. package/Interaction/Misc.js +1 -1
  228. package/Interaction/Style/InteractorStyleImage.js +101 -121
  229. package/Interaction/Style/InteractorStyleMPRSlice.js +111 -128
  230. package/Interaction/Style/InteractorStyleManipulator/Presets.js +9 -17
  231. package/Interaction/Style/InteractorStyleManipulator.js +254 -329
  232. package/Interaction/Style/InteractorStyleRemoteMouse.js +195 -180
  233. package/Interaction/Style/InteractorStyleTrackballCamera.js +154 -157
  234. package/Interaction/Style/InteractorStyleUnicam.js +30 -38
  235. package/Interaction/Style.js +5 -5
  236. package/Interaction/UI/CornerAnnotation/CornerAnnotation.module.css.js +1 -1
  237. package/Interaction/UI/CornerAnnotation.js +65 -48
  238. package/Interaction/UI/FPSMonitor.js +104 -105
  239. package/Interaction/UI/Icons.js +1 -1
  240. package/Interaction/UI/Slider/Constants.js +2 -2
  241. package/Interaction/UI/Slider.js +78 -95
  242. package/Interaction/UI/VolumeController.js +104 -97
  243. package/Interaction/UI.js +5 -5
  244. package/Interaction/Widgets/OrientationMarkerWidget/Constants.js +2 -2
  245. package/Interaction/Widgets/OrientationMarkerWidget.js +90 -135
  246. package/Interaction/Widgets/PiecewiseGaussianWidget/ComputeHistogram.worker.js +0 -3
  247. package/Interaction/Widgets/PiecewiseGaussianWidget.js +381 -498
  248. package/Interaction/Widgets.js +2 -2
  249. package/Interaction/index.js +5 -5
  250. package/Proxy/Animation/AbstractAnimationProxy.js +22 -15
  251. package/Proxy/Animation/AnimationProxyManager.js +43 -51
  252. package/Proxy/Animation/TimeStepBasedAnimationHandlerProxy.js +26 -19
  253. package/Proxy/Core/AbstractRepresentationProxy.js +97 -151
  254. package/Proxy/Core/LookupTableProxy/Constants.js +4 -4
  255. package/Proxy/Core/LookupTableProxy.js +49 -52
  256. package/Proxy/Core/PiecewiseFunctionProxy/Constants.js +4 -4
  257. package/Proxy/Core/PiecewiseFunctionProxy.js +63 -72
  258. package/Proxy/Core/ProxyManager/core.js +83 -106
  259. package/Proxy/Core/ProxyManager/properties.js +53 -76
  260. package/Proxy/Core/ProxyManager/state.js +100 -110
  261. package/Proxy/Core/ProxyManager/view.js +45 -55
  262. package/Proxy/Core/ProxyManager.js +16 -8
  263. package/Proxy/Core/SourceProxy.js +41 -38
  264. package/Proxy/Core/View2DProxy.js +143 -199
  265. package/Proxy/Core/ViewProxy.js +223 -269
  266. package/Proxy/Core.js +7 -7
  267. package/Proxy/Representations/GeometryRepresentationProxy.js +34 -20
  268. package/Proxy/Representations/GlyphRepresentationProxy.js +42 -41
  269. package/Proxy/Representations/MoleculeRepresentationProxy.js +32 -22
  270. package/Proxy/Representations/ResliceRepresentationProxy.js +48 -32
  271. package/Proxy/Representations/SkyboxRepresentationProxy.js +30 -29
  272. package/Proxy/Representations/SliceRepresentationProxy.js +93 -112
  273. package/Proxy/Representations/SlicedGeometryRepresentationProxy.js +46 -42
  274. package/Proxy/Representations/VolumeRepresentationProxy.js +108 -133
  275. package/Proxy/Representations.js +7 -7
  276. package/Proxy/index.js +2 -2
  277. package/Rendering/Core/AbstractImageMapper/helper.js +44 -49
  278. package/Rendering/Core/AbstractImageMapper.js +18 -19
  279. package/Rendering/Core/AbstractMapper.js +39 -55
  280. package/Rendering/Core/AbstractMapper3D.js +26 -31
  281. package/Rendering/Core/AbstractPicker.js +25 -21
  282. package/Rendering/Core/Actor.js +71 -93
  283. package/Rendering/Core/Actor2D.js +64 -78
  284. package/Rendering/Core/AnnotatedCubeActor/Presets.js +5 -11
  285. package/Rendering/Core/AnnotatedCubeActor.js +94 -79
  286. package/Rendering/Core/AxesActor.js +65 -87
  287. package/Rendering/Core/Camera.js +246 -271
  288. package/Rendering/Core/CellPicker.js +125 -148
  289. package/Rendering/Core/ColorTransferFunction/ColorMaps.js +20 -21
  290. package/Rendering/Core/ColorTransferFunction/ColorMapsLite.js +20 -21
  291. package/Rendering/Core/ColorTransferFunction/Constants.js +4 -4
  292. package/Rendering/Core/ColorTransferFunction.js +460 -546
  293. package/Rendering/Core/Coordinate/Constants.js +2 -2
  294. package/Rendering/Core/Coordinate.js +119 -198
  295. package/Rendering/Core/CubeAxesActor.js +294 -320
  296. package/Rendering/Core/Follower.js +46 -45
  297. package/Rendering/Core/Glyph3DMapper/Constants.js +4 -4
  298. package/Rendering/Core/Glyph3DMapper.js +96 -148
  299. package/Rendering/Core/HardwareSelector.js +36 -69
  300. package/Rendering/Core/ImageArrayMapper.js +87 -126
  301. package/Rendering/Core/ImageCPRMapper.js +134 -209
  302. package/Rendering/Core/ImageMapper/Constants.js +2 -2
  303. package/Rendering/Core/ImageMapper.js +85 -144
  304. package/Rendering/Core/ImageProperty/Constants.js +2 -2
  305. package/Rendering/Core/ImageProperty.js +66 -81
  306. package/Rendering/Core/ImageResliceMapper/Constants.js +2 -2
  307. package/Rendering/Core/ImageResliceMapper.js +36 -29
  308. package/Rendering/Core/ImageSlice.js +85 -127
  309. package/Rendering/Core/InteractorObserver.js +82 -73
  310. package/Rendering/Core/InteractorStyle/Constants.js +2 -2
  311. package/Rendering/Core/InteractorStyle.js +56 -58
  312. package/Rendering/Core/Light.js +43 -49
  313. package/Rendering/Core/Mapper/CoincidentTopologyHelper.js +37 -48
  314. package/Rendering/Core/Mapper/Constants.js +6 -6
  315. package/Rendering/Core/Mapper/Static.js +15 -12
  316. package/Rendering/Core/Mapper.js +194 -259
  317. package/Rendering/Core/Mapper2D.js +61 -100
  318. package/Rendering/Core/Picker.js +124 -143
  319. package/Rendering/Core/PixelSpaceCallbackMapper.js +40 -37
  320. package/Rendering/Core/PointPicker.js +68 -79
  321. package/Rendering/Core/Prop/Constants.js +2 -2
  322. package/Rendering/Core/Prop.js +58 -106
  323. package/Rendering/Core/Prop3D.js +54 -83
  324. package/Rendering/Core/Property/Constants.js +6 -6
  325. package/Rendering/Core/Property.js +45 -74
  326. package/Rendering/Core/Property2D/Constants.js +2 -2
  327. package/Rendering/Core/Property2D.js +33 -42
  328. package/Rendering/Core/RenderWindow.js +70 -82
  329. package/Rendering/Core/RenderWindowInteractor/Constants.js +7 -7
  330. package/Rendering/Core/RenderWindowInteractor.js +324 -439
  331. package/Rendering/Core/Renderer.js +192 -256
  332. package/Rendering/Core/ScalarBarActor.js +267 -272
  333. package/Rendering/Core/Skybox.js +26 -24
  334. package/Rendering/Core/SphereMapper.js +22 -12
  335. package/Rendering/Core/StickMapper.js +22 -12
  336. package/Rendering/Core/SurfaceLICInterface/Constants.js +6 -6
  337. package/Rendering/Core/SurfaceLICInterface.js +13 -9
  338. package/Rendering/Core/SurfaceLICMapper.js +23 -15
  339. package/Rendering/Core/Texture.js +99 -141
  340. package/Rendering/Core/Viewport.js +60 -88
  341. package/Rendering/Core/Volume.js +55 -77
  342. package/Rendering/Core/VolumeMapper/Constants.js +4 -4
  343. package/Rendering/Core/VolumeMapper.js +59 -91
  344. package/Rendering/Core/VolumeProperty/Constants.js +4 -4
  345. package/Rendering/Core/VolumeProperty.js +78 -115
  346. package/Rendering/Core.js +47 -49
  347. package/Rendering/Misc/CanvasView.js +62 -61
  348. package/Rendering/Misc/FullScreenRenderWindow.js +60 -62
  349. package/Rendering/Misc/GenericRenderWindow.js +48 -37
  350. package/Rendering/Misc/RemoteView.js +86 -80
  351. package/Rendering/Misc/RenderWindowWithControlBar.js +54 -48
  352. package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager/CameraSynchronizer.js +43 -51
  353. package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager.js +52 -82
  354. package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.js +258 -308
  355. package/Rendering/Misc/SynchronizableRenderWindow.js +133 -163
  356. package/Rendering/Misc/TextureLODsDownloader.js +72 -74
  357. package/Rendering/Misc.js +7 -7
  358. package/Rendering/OpenGL/Actor.js +57 -68
  359. package/Rendering/OpenGL/Actor2D.js +56 -56
  360. package/Rendering/OpenGL/BufferObject/Constants.js +2 -2
  361. package/Rendering/OpenGL/BufferObject.js +50 -65
  362. package/Rendering/OpenGL/Camera.js +35 -29
  363. package/Rendering/OpenGL/CellArrayBufferObject.js +119 -149
  364. package/Rendering/OpenGL/Convolution2DPass.js +87 -81
  365. package/Rendering/OpenGL/CubeAxesActor.js +28 -21
  366. package/Rendering/OpenGL/ForwardPass.js +53 -64
  367. package/Rendering/OpenGL/Framebuffer.js +61 -101
  368. package/Rendering/OpenGL/Glyph3DMapper.js +165 -196
  369. package/Rendering/OpenGL/HardwareSelector/Constants.js +2 -2
  370. package/Rendering/OpenGL/HardwareSelector.js +272 -397
  371. package/Rendering/OpenGL/Helper.js +58 -73
  372. package/Rendering/OpenGL/ImageCPRMapper.js +339 -421
  373. package/Rendering/OpenGL/ImageMapper.js +268 -361
  374. package/Rendering/OpenGL/ImageResliceMapper.js +306 -438
  375. package/Rendering/OpenGL/ImageSlice.js +48 -54
  376. package/Rendering/OpenGL/OrderIndependentTranslucentPass.js +102 -84
  377. package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +43 -42
  378. package/Rendering/OpenGL/PolyDataMapper.js +358 -492
  379. package/Rendering/OpenGL/PolyDataMapper2D.js +153 -205
  380. package/Rendering/OpenGL/RadialDistortionPass.js +86 -89
  381. package/Rendering/OpenGL/RenderWindow/Constants.js +2 -2
  382. package/Rendering/OpenGL/RenderWindow/ContextProxy.js +20 -29
  383. package/Rendering/OpenGL/RenderWindow.js +356 -510
  384. package/Rendering/OpenGL/Renderer.js +77 -89
  385. package/Rendering/OpenGL/ReplacementShaderMapper.js +28 -46
  386. package/Rendering/OpenGL/ScalarBarActor.js +28 -21
  387. package/Rendering/OpenGL/Shader.js +37 -31
  388. package/Rendering/OpenGL/ShaderCache.js +67 -74
  389. package/Rendering/OpenGL/ShaderProgram.js +136 -248
  390. package/Rendering/OpenGL/Skybox.js +99 -60
  391. package/Rendering/OpenGL/SphereMapper.js +94 -108
  392. package/Rendering/OpenGL/StickMapper.js +110 -114
  393. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D/pingpong.js +91 -157
  394. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D.js +142 -151
  395. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +142 -216
  396. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICMapper.js +79 -100
  397. package/Rendering/OpenGL/SurfaceLIC.js +2 -2
  398. package/Rendering/OpenGL/Texture/Constants.js +4 -4
  399. package/Rendering/OpenGL/Texture.js +443 -608
  400. package/Rendering/OpenGL/TextureUnitManager.js +47 -43
  401. package/Rendering/OpenGL/VertexArrayObject.js +92 -131
  402. package/Rendering/OpenGL/ViewNodeFactory.js +25 -13
  403. package/Rendering/OpenGL/Volume.js +38 -34
  404. package/Rendering/OpenGL/VolumeMapper.js +437 -547
  405. package/Rendering/OpenGL.js +28 -28
  406. package/Rendering/SceneGraph/RenderPass.js +34 -31
  407. package/Rendering/SceneGraph/RenderWindowViewNode.js +68 -94
  408. package/Rendering/SceneGraph/ViewNode.js +82 -111
  409. package/Rendering/SceneGraph/ViewNodeFactory.js +31 -26
  410. package/Rendering/SceneGraph.js +4 -4
  411. package/Rendering/WebGPU/Actor.js +49 -49
  412. package/Rendering/WebGPU/Actor2D.js +45 -44
  413. package/Rendering/WebGPU/BindGroup.js +43 -50
  414. package/Rendering/WebGPU/Buffer.js +41 -50
  415. package/Rendering/WebGPU/BufferManager/Constants.js +4 -4
  416. package/Rendering/WebGPU/BufferManager.js +111 -141
  417. package/Rendering/WebGPU/Camera.js +65 -67
  418. package/Rendering/WebGPU/CellArrayMapper.js +621 -388
  419. package/Rendering/WebGPU/CubeAxesActor.js +28 -19
  420. package/Rendering/WebGPU/Device.js +78 -133
  421. package/Rendering/WebGPU/ForwardPass.js +75 -72
  422. package/Rendering/WebGPU/FullScreenQuad.js +25 -18
  423. package/Rendering/WebGPU/Glyph3DMapper.js +62 -74
  424. package/Rendering/WebGPU/HardwareSelectionPass.js +45 -38
  425. package/Rendering/WebGPU/HardwareSelector.js +200 -276
  426. package/Rendering/WebGPU/ImageMapper.js +180 -171
  427. package/Rendering/WebGPU/ImageSlice.js +45 -44
  428. package/Rendering/WebGPU/IndexBuffer.js +166 -200
  429. package/Rendering/WebGPU/OpaquePass.js +37 -36
  430. package/Rendering/WebGPU/OrderIndependentTranslucentPass.js +72 -45
  431. package/Rendering/WebGPU/Pipeline.js +37 -51
  432. package/Rendering/WebGPU/PixelSpaceCallbackMapper.js +27 -19
  433. package/Rendering/WebGPU/PolyDataMapper.js +50 -53
  434. package/Rendering/WebGPU/PolyDataMapper2D.js +39 -39
  435. package/Rendering/WebGPU/RenderEncoder.js +68 -88
  436. package/Rendering/WebGPU/RenderWindow.js +262 -376
  437. package/Rendering/WebGPU/Renderer.js +224 -208
  438. package/Rendering/WebGPU/Sampler.js +27 -21
  439. package/Rendering/WebGPU/ScalarBarActor.js +28 -19
  440. package/Rendering/WebGPU/ShaderCache.js +43 -41
  441. package/Rendering/WebGPU/ShaderDescription.js +52 -59
  442. package/Rendering/WebGPU/ShaderModule.js +26 -17
  443. package/Rendering/WebGPU/SimpleMapper.js +185 -121
  444. package/Rendering/WebGPU/SphereMapper.js +200 -130
  445. package/Rendering/WebGPU/StickMapper.js +289 -152
  446. package/Rendering/WebGPU/StorageBuffer.js +100 -115
  447. package/Rendering/WebGPU/Texture.js +79 -99
  448. package/Rendering/WebGPU/TextureManager.js +52 -54
  449. package/Rendering/WebGPU/TextureView.js +40 -43
  450. package/Rendering/WebGPU/Types.js +53 -70
  451. package/Rendering/WebGPU/UniformBuffer.js +158 -184
  452. package/Rendering/WebGPU/VertexInput.js +64 -90
  453. package/Rendering/WebGPU/ViewNodeFactory.js +25 -13
  454. package/Rendering/WebGPU/Volume.js +52 -51
  455. package/Rendering/WebGPU/VolumePass.js +218 -239
  456. package/Rendering/WebGPU/VolumePassFSQ.js +625 -306
  457. package/Rendering/WebGPU.js +1 -1
  458. package/Rendering/index.js +5 -5
  459. package/Widgets/Core/AbstractWidget/Constants.js +2 -2
  460. package/Widgets/Core/AbstractWidget.js +49 -58
  461. package/Widgets/Core/AbstractWidgetFactory.js +101 -122
  462. package/Widgets/Core/StateBuilder/boundsMixin.js +23 -28
  463. package/Widgets/Core/StateBuilder/color3Mixin.js +10 -7
  464. package/Widgets/Core/StateBuilder/colorMixin.js +10 -6
  465. package/Widgets/Core/StateBuilder/cornerMixin.js +16 -15
  466. package/Widgets/Core/StateBuilder/directionMixin.js +20 -18
  467. package/Widgets/Core/StateBuilder/manipulatorMixin.js +26 -18
  468. package/Widgets/Core/StateBuilder/nameMixin.js +10 -6
  469. package/Widgets/Core/StateBuilder/orientationMixin.js +19 -16
  470. package/Widgets/Core/StateBuilder/originMixin.js +25 -32
  471. package/Widgets/Core/StateBuilder/scale1Mixin.js +10 -6
  472. package/Widgets/Core/StateBuilder/scale3Mixin.js +10 -6
  473. package/Widgets/Core/StateBuilder/shapeMixin.js +12 -6
  474. package/Widgets/Core/StateBuilder/textMixin.js +10 -6
  475. package/Widgets/Core/StateBuilder/visibleMixin.js +10 -6
  476. package/Widgets/Core/StateBuilder.js +120 -149
  477. package/Widgets/Core/WidgetManager/Constants.js +7 -7
  478. package/Widgets/Core/WidgetManager.js +249 -421
  479. package/Widgets/Core/WidgetState.js +48 -57
  480. package/Widgets/Core.js +5 -5
  481. package/Widgets/Manipulators/AbstractManipulator.js +20 -14
  482. package/Widgets/Manipulators/CPRManipulator.js +55 -71
  483. package/Widgets/Manipulators/LineManipulator.js +31 -28
  484. package/Widgets/Manipulators/PickerManipulator.d.ts +48 -0
  485. package/Widgets/Manipulators/PickerManipulator.js +65 -0
  486. package/Widgets/Manipulators/PlaneManipulator.js +26 -23
  487. package/Widgets/Manipulators/TrackballManipulator.js +39 -35
  488. package/Widgets/Manipulators.js +4 -2
  489. package/Widgets/Representations/ArrowHandleRepresentation.js +148 -162
  490. package/Widgets/Representations/CircleContextRepresentation.js +44 -38
  491. package/Widgets/Representations/ContextRepresentation.js +17 -14
  492. package/Widgets/Representations/ConvexFaceContextRepresentation.js +50 -47
  493. package/Widgets/Representations/CroppingOutlineRepresentation.js +38 -27
  494. package/Widgets/Representations/CubeHandleRepresentation.js +21 -18
  495. package/Widgets/Representations/GlyphRepresentation.js +107 -152
  496. package/Widgets/Representations/HandleRepresentation.js +17 -14
  497. package/Widgets/Representations/ImplicitPlaneRepresentation.js +97 -91
  498. package/Widgets/Representations/LineHandleRepresentation.js +44 -41
  499. package/Widgets/Representations/OutlineContextRepresentation.js +42 -36
  500. package/Widgets/Representations/PolyLineRepresentation.js +60 -75
  501. package/Widgets/Representations/RectangleContextRepresentation.js +42 -37
  502. package/Widgets/Representations/SphereContextRepresentation.js +19 -27
  503. package/Widgets/Representations/SphereHandleRepresentation.js +31 -27
  504. package/Widgets/Representations/SplineContextRepresentation.js +46 -70
  505. package/Widgets/Representations/WidgetRepresentation/Constants.js +2 -2
  506. package/Widgets/Representations/WidgetRepresentation.js +99 -134
  507. package/Widgets/Representations.js +13 -13
  508. package/Widgets/Widgets3D/AngleWidget/behavior.js +41 -63
  509. package/Widgets/Widgets3D/AngleWidget.js +40 -38
  510. package/Widgets/Widgets3D/DistanceWidget/behavior.js +40 -61
  511. package/Widgets/Widgets3D/DistanceWidget.js +38 -36
  512. package/Widgets/Widgets3D/EllipseWidget/behavior.js +14 -19
  513. package/Widgets/Widgets3D/EllipseWidget/state.js +4 -2
  514. package/Widgets/Widgets3D/EllipseWidget.js +37 -26
  515. package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +26 -56
  516. package/Widgets/Widgets3D/ImageCroppingWidget/helpers.js +14 -17
  517. package/Widgets/Widgets3D/ImageCroppingWidget/state.js +20 -16
  518. package/Widgets/Widgets3D/ImageCroppingWidget.js +80 -98
  519. package/Widgets/Widgets3D/ImplicitPlaneWidget.js +55 -77
  520. package/Widgets/Widgets3D/InteractiveOrientationWidget/behavior.js +17 -18
  521. package/Widgets/Widgets3D/InteractiveOrientationWidget/state.js +15 -7
  522. package/Widgets/Widgets3D/InteractiveOrientationWidget.js +30 -29
  523. package/Widgets/Widgets3D/LabelWidget/behavior.js +37 -62
  524. package/Widgets/Widgets3D/LabelWidget.js +31 -25
  525. package/Widgets/Widgets3D/LineWidget/Constants.js +8 -8
  526. package/Widgets/Widgets3D/LineWidget/behavior.js +77 -114
  527. package/Widgets/Widgets3D/LineWidget/helpers.js +13 -20
  528. package/Widgets/Widgets3D/LineWidget/state.js +2 -1
  529. package/Widgets/Widgets3D/LineWidget.js +39 -35
  530. package/Widgets/Widgets3D/PaintWidget/behavior.js +24 -59
  531. package/Widgets/Widgets3D/PaintWidget.js +39 -37
  532. package/Widgets/Widgets3D/PolyLineWidget/behavior.js +44 -68
  533. package/Widgets/Widgets3D/PolyLineWidget.js +36 -31
  534. package/Widgets/Widgets3D/RectangleWidget/behavior.js +6 -11
  535. package/Widgets/Widgets3D/RectangleWidget/state.js +4 -2
  536. package/Widgets/Widgets3D/RectangleWidget.js +37 -25
  537. package/Widgets/Widgets3D/ResliceCursorWidget/Constants.js +35 -21
  538. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +133 -209
  539. package/Widgets/Widgets3D/ResliceCursorWidget/cprBehavior.js +26 -41
  540. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +89 -116
  541. package/Widgets/Widgets3D/ResliceCursorWidget/state.js +33 -40
  542. package/Widgets/Widgets3D/ResliceCursorWidget.js +186 -227
  543. package/Widgets/Widgets3D/SeedWidget/behavior.js +82 -0
  544. package/Widgets/Widgets3D/SeedWidget/state.js +18 -0
  545. package/Widgets/Widgets3D/SeedWidget.d.ts +44 -0
  546. package/Widgets/Widgets3D/SeedWidget.js +43 -0
  547. package/Widgets/Widgets3D/ShapeWidget/Constants.js +19 -19
  548. package/Widgets/Widgets3D/ShapeWidget/behavior.js +150 -252
  549. package/Widgets/Widgets3D/ShapeWidget.js +24 -27
  550. package/Widgets/Widgets3D/SphereWidget/behavior.js +35 -69
  551. package/Widgets/Widgets3D/SphereWidget/state.js +9 -5
  552. package/Widgets/Widgets3D/SphereWidget.js +34 -44
  553. package/Widgets/Widgets3D/SplineWidget/behavior.js +85 -120
  554. package/Widgets/Widgets3D/SplineWidget.js +43 -39
  555. package/Widgets/Widgets3D.js +15 -15
  556. package/Widgets/index.js +4 -4
  557. package/_virtual/rollup-plugin-worker-loader__module_Sources/Filters/General/PaintFilter/PaintFilter.worker.js +95 -207
  558. package/_virtual/rollup-plugin-worker-loader__module_Sources/Interaction/Widgets/PiecewiseGaussianWidget/ComputeHistogram.worker.js +0 -3
  559. package/favicon.js +5 -6
  560. package/index.d.ts +4 -2
  561. package/index.js +4 -3
  562. package/macros.js +4 -1931
  563. package/macros2.js +1684 -0
  564. package/package.json +6 -6
  565. package/vtk.js +18 -31
@@ -1,7 +1,5 @@
1
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
- import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
3
1
  import { mat3, mat4, vec3 } from 'gl-matrix';
4
- import { newInstance as newInstance$1, setGet, obj, vtkErrorMacro as vtkErrorMacro$1 } from '../../macros.js';
2
+ import { n as newInstance$1, e as setGet, o as obj, c as macro } from '../../macros2.js';
5
3
  import vtkHelper from './Helper.js';
6
4
  import vtkMapper from '../Core/Mapper.js';
7
5
  import { l as normalize, u as uninitializeBounds } from '../../Common/Core/Math/index.js';
@@ -17,44 +15,54 @@ import { registerOverride } from './ViewNodeFactory.js';
17
15
  import { PassTypes } from './HardwareSelector/Constants.js';
18
16
  import vtkDataSet from '../../Common/DataModel/DataSet.js';
19
17
 
20
- 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; }
18
+ const {
19
+ FieldAssociations
20
+ } = vtkDataSet;
21
21
 
22
- 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; }
23
- var FieldAssociations = vtkDataSet.FieldAssociations;
24
22
  /* eslint-disable no-lonely-if */
25
23
 
26
- var primTypes = vtkHelper.primTypes;
27
- var Representation = vtkProperty.Representation,
28
- Shading = vtkProperty.Shading;
29
- var ScalarMode = vtkMapper.ScalarMode;
30
- var Filter = vtkOpenGLTexture.Filter,
31
- Wrap = vtkOpenGLTexture.Wrap;
32
- var vtkErrorMacro = vtkErrorMacro$1;
33
- var StartEvent = {
24
+ const {
25
+ primTypes
26
+ } = vtkHelper;
27
+ const {
28
+ Representation,
29
+ Shading
30
+ } = vtkProperty;
31
+ const {
32
+ ScalarMode
33
+ } = vtkMapper;
34
+ const {
35
+ Filter,
36
+ Wrap
37
+ } = vtkOpenGLTexture;
38
+ const {
39
+ vtkErrorMacro
40
+ } = macro;
41
+ const StartEvent = {
34
42
  type: 'StartEvent'
35
43
  };
36
- var EndEvent = {
44
+ const EndEvent = {
37
45
  type: 'EndEvent'
38
46
  };
39
- var CoordinateSystem = vtkProp.CoordinateSystem; // ----------------------------------------------------------------------------
47
+ const {
48
+ CoordinateSystem
49
+ } = vtkProp;
50
+
51
+ // ----------------------------------------------------------------------------
40
52
  // vtkOpenGLPolyDataMapper methods
41
53
  // ----------------------------------------------------------------------------
42
54
 
43
55
  function getPickState(renderer) {
44
- var selector = renderer.getSelector();
45
-
56
+ const selector = renderer.getSelector();
46
57
  if (selector) {
47
58
  return selector.getCurrentPass();
48
59
  }
49
-
50
60
  return PassTypes.MIN_KNOWN_PASS - 1;
51
61
  }
52
-
53
62
  function vtkOpenGLPolyDataMapper(publicAPI, model) {
54
63
  // Set our className
55
64
  model.classHierarchy.push('vtkOpenGLPolyDataMapper');
56
-
57
- publicAPI.buildPass = function (prepass) {
65
+ publicAPI.buildPass = prepass => {
58
66
  if (prepass) {
59
67
  model.currentRenderPass = null;
60
68
  model.openGLActor = publicAPI.getFirstAncestorOfType('vtkOpenGLActor');
@@ -62,17 +70,16 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
62
70
  model._openGLRenderWindow = model._openGLRenderer.getParent();
63
71
  model.openGLCamera = model._openGLRenderer.getViewNodeFor(model._openGLRenderer.getRenderable().getActiveCamera());
64
72
  }
65
- }; // Renders myself
66
-
73
+ };
67
74
 
68
- publicAPI.translucentPass = function (prepass, renderPass) {
75
+ // Renders myself
76
+ publicAPI.translucentPass = (prepass, renderPass) => {
69
77
  if (prepass) {
70
78
  model.currentRenderPass = renderPass;
71
79
  publicAPI.render();
72
80
  }
73
81
  };
74
-
75
- publicAPI.zBufferPass = function (prepass) {
82
+ publicAPI.zBufferPass = prepass => {
76
83
  if (prepass) {
77
84
  model.haveSeenDepthRequest = true;
78
85
  model.renderDepth = true;
@@ -80,70 +87,56 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
80
87
  model.renderDepth = false;
81
88
  }
82
89
  };
83
-
84
- publicAPI.opaqueZBufferPass = function (prepass) {
85
- return publicAPI.zBufferPass(prepass);
86
- };
87
-
88
- publicAPI.opaquePass = function (prepass) {
90
+ publicAPI.opaqueZBufferPass = prepass => publicAPI.zBufferPass(prepass);
91
+ publicAPI.opaquePass = prepass => {
89
92
  if (prepass) {
90
93
  publicAPI.render();
91
94
  }
92
95
  };
93
-
94
- publicAPI.render = function () {
95
- var ctx = model._openGLRenderWindow.getContext();
96
-
96
+ publicAPI.render = () => {
97
+ const ctx = model._openGLRenderWindow.getContext();
97
98
  if (model.context !== ctx) {
98
99
  model.context = ctx;
99
-
100
- for (var i = primTypes.Start; i < primTypes.End; i++) {
100
+ for (let i = primTypes.Start; i < primTypes.End; i++) {
101
101
  model.primitives[i].setOpenGLRenderWindow(model._openGLRenderWindow);
102
102
  }
103
103
  }
104
-
105
- var actor = model.openGLActor.getRenderable();
106
-
107
- var ren = model._openGLRenderer.getRenderable();
108
-
104
+ const actor = model.openGLActor.getRenderable();
105
+ const ren = model._openGLRenderer.getRenderable();
109
106
  publicAPI.renderPiece(ren, actor);
110
107
  };
111
-
112
- publicAPI.getShaderTemplate = function (shaders, ren, actor) {
108
+ publicAPI.getShaderTemplate = (shaders, ren, actor) => {
113
109
  shaders.Vertex = vtkPolyDataVS;
114
110
  shaders.Fragment = vtkPolyDataFS;
115
111
  shaders.Geometry = '';
116
112
  };
113
+ publicAPI.replaceShaderColor = (shaders, ren, actor) => {
114
+ let VSSource = shaders.Vertex;
115
+ let GSSource = shaders.Geometry;
116
+ let FSSource = shaders.Fragment;
117
+ const lastLightComplexity = model.lastBoundBO.getReferenceByName('lastLightComplexity');
117
118
 
118
- publicAPI.replaceShaderColor = function (shaders, ren, actor) {
119
- var VSSource = shaders.Vertex;
120
- var GSSource = shaders.Geometry;
121
- var FSSource = shaders.Fragment;
122
- var lastLightComplexity = model.lastBoundBO.getReferenceByName('lastLightComplexity'); // create the material/color property declarations, and VS implementation
119
+ // create the material/color property declarations, and VS implementation
123
120
  // these are always defined
124
-
125
- var colorDec = ['uniform float ambient;', 'uniform float diffuse;', 'uniform float specular;', 'uniform float opacityUniform; // the fragment opacity', 'uniform vec3 ambientColorUniform;', 'uniform vec3 diffuseColorUniform;']; // add more for specular
126
-
121
+ let colorDec = ['uniform float ambient;', 'uniform float diffuse;', 'uniform float specular;', 'uniform float opacityUniform; // the fragment opacity', 'uniform vec3 ambientColorUniform;', 'uniform vec3 diffuseColorUniform;'];
122
+ // add more for specular
127
123
  if (lastLightComplexity) {
128
124
  colorDec = colorDec.concat(['uniform vec3 specularColorUniform;', 'uniform float specularPowerUniform;']);
129
- } // now handle the more complex fragment shader implementation
125
+ }
126
+
127
+ // now handle the more complex fragment shader implementation
130
128
  // the following are always defined variables. We start
131
129
  // by assigning a default value from the uniform
132
-
133
-
134
- var colorImpl = ['vec3 ambientColor;', ' vec3 diffuseColor;', ' float opacity;'];
135
-
130
+ let colorImpl = ['vec3 ambientColor;', ' vec3 diffuseColor;', ' float opacity;'];
136
131
  if (lastLightComplexity) {
137
132
  colorImpl = colorImpl.concat([' vec3 specularColor;', ' float specularPower;']);
138
133
  }
139
-
140
134
  colorImpl = colorImpl.concat([' ambientColor = ambientColorUniform;', ' diffuseColor = diffuseColorUniform;', ' opacity = opacityUniform;']);
141
-
142
135
  if (lastLightComplexity) {
143
136
  colorImpl = colorImpl.concat([' specularColor = specularColorUniform;', ' specularPower = specularPowerUniform;']);
144
- } // add scalar vertex coloring
145
-
137
+ }
146
138
 
139
+ // add scalar vertex coloring
147
140
  if (model.lastBoundBO.getCABO().getColorComponents() !== 0 && !model.drawingEdges) {
148
141
  colorDec = colorDec.concat(['varying vec4 vertexColorVSOutput;']);
149
142
  VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Color::Dec', ['attribute vec4 scalarColor;', 'varying vec4 vertexColorVSOutput;']).result;
@@ -151,7 +144,6 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
151
144
  GSSource = vtkShaderProgram.substitute(GSSource, '//VTK::Color::Dec', ['in vec4 vertexColorVSOutput[];', 'out vec4 vertexColorGSOutput;']).result;
152
145
  GSSource = vtkShaderProgram.substitute(GSSource, '//VTK::Color::Impl', ['vertexColorGSOutput = vertexColorVSOutput[i];']).result;
153
146
  }
154
-
155
147
  if (model.lastBoundBO.getCABO().getColorComponents() !== 0 && !model.drawingEdges) {
156
148
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Color::Impl', colorImpl.concat([' diffuseColor = vertexColorVSOutput.rgb;', ' ambientColor = vertexColorVSOutput.rgb;', ' opacity = opacity*vertexColorVSOutput.a;'])).result;
157
149
  } else {
@@ -160,7 +152,6 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
160
152
  } else {
161
153
  if (actor.getBackfaceProperty() && !model.drawingEdges) {
162
154
  colorDec = colorDec.concat(['uniform float opacityUniformBF; // the fragment opacity', 'uniform float ambientIntensityBF; // the material ambient', 'uniform float diffuseIntensityBF; // the material diffuse', 'uniform vec3 ambientColorUniformBF; // ambient material color', 'uniform vec3 diffuseColorUniformBF; // diffuse material color']);
163
-
164
155
  if (lastLightComplexity) {
165
156
  colorDec = colorDec.concat(['uniform float specularIntensityBF; // the material specular intensity', 'uniform vec3 specularColorUniformBF; // intensity weighted color', 'uniform float specularPowerUniformBF;']);
166
157
  colorImpl = colorImpl.concat(['if (gl_FrontFacing == false) {', ' ambientColor = ambientIntensityBF * ambientColorUniformBF;', ' diffuseColor = diffuseIntensityBF * diffuseColorUniformBF;', ' specularColor = specularIntensityBF * specularColorUniformBF;', ' specularPower = specularPowerUniformBF;', ' opacity = opacityUniformBF; }']);
@@ -168,96 +159,86 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
168
159
  colorImpl = colorImpl.concat(['if (gl_FrontFacing == false) {', ' ambientColor = ambientIntensityBF * ambientColorUniformBF;', ' diffuseColor = diffuseIntensityBF * diffuseColorUniformBF;', ' opacity = opacityUniformBF; }']);
169
160
  }
170
161
  }
171
-
172
162
  if (model.haveCellScalars && !model.drawingEdges) {
173
163
  colorDec = colorDec.concat(['uniform samplerBuffer texture1;']);
174
164
  }
175
-
176
165
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Color::Impl', colorImpl).result;
177
166
  }
178
167
  }
179
-
180
168
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Color::Dec', colorDec).result;
181
169
  shaders.Vertex = VSSource;
182
170
  shaders.Geometry = GSSource;
183
171
  shaders.Fragment = FSSource;
184
172
  };
185
-
186
- publicAPI.replaceShaderLight = function (shaders, ren, actor) {
187
- var FSSource = shaders.Fragment; // check for shadow maps
188
-
189
- var shadowFactor = '';
190
- var lastLightComplexity = model.lastBoundBO.getReferenceByName('lastLightComplexity');
191
- var lastLightCount = model.lastBoundBO.getReferenceByName('lastLightCount');
192
- var sstring = [];
193
-
173
+ publicAPI.replaceShaderLight = (shaders, ren, actor) => {
174
+ let FSSource = shaders.Fragment;
175
+
176
+ // check for shadow maps
177
+ const shadowFactor = '';
178
+ const lastLightComplexity = model.lastBoundBO.getReferenceByName('lastLightComplexity');
179
+ const lastLightCount = model.lastBoundBO.getReferenceByName('lastLightCount');
180
+ let sstring = [];
194
181
  switch (lastLightComplexity) {
195
182
  case 0:
196
183
  // no lighting or RENDER_VALUES
197
184
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Light::Impl', [' gl_FragData[0] = vec4(ambientColor * ambient + diffuseColor * diffuse, opacity);', ' //VTK::Light::Impl'], false).result;
198
185
  break;
199
-
200
186
  case 1:
201
187
  // headlight
202
188
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Light::Impl', [' float df = max(0.0, normalVCVSOutput.z);', ' float sf = pow(df, specularPower);', ' vec3 diffuseL = df * diffuseColor;', ' vec3 specularL = sf * specularColor;', ' gl_FragData[0] = vec4(ambientColor * ambient + diffuseL * diffuse + specularL * specular, opacity);', ' //VTK::Light::Impl'], false).result;
203
189
  break;
204
-
205
190
  case 2:
206
191
  // light kit
207
- for (var lc = 0; lc < lastLightCount; ++lc) {
208
- sstring = sstring.concat(["uniform vec3 lightColor".concat(lc, ";"), "uniform vec3 lightDirectionVC".concat(lc, "; // normalized"), "uniform vec3 lightHalfAngleVC".concat(lc, "; // normalized")]);
192
+ for (let lc = 0; lc < lastLightCount; ++lc) {
193
+ sstring = sstring.concat([`uniform vec3 lightColor${lc};`, `uniform vec3 lightDirectionVC${lc}; // normalized`, `uniform vec3 lightHalfAngleVC${lc}; // normalized`]);
209
194
  }
210
-
211
195
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Light::Dec', sstring).result;
212
196
  sstring = ['vec3 diffuseL = vec3(0,0,0);', ' vec3 specularL = vec3(0,0,0);', ' float df;'];
213
-
214
- for (var _lc = 0; _lc < lastLightCount; ++_lc) {
215
- sstring = sstring.concat([" df = max(0.0, dot(normalVCVSOutput, -lightDirectionVC".concat(_lc, "));"), " diffuseL += ((df".concat(shadowFactor, ") * lightColor").concat(_lc, ");"), " if (dot(normalVCVSOutput, lightDirectionVC".concat(_lc, ") < 0.0)"), ' {', " float sf = sign(df)*pow(max(1e-5,\n dot(reflect(lightDirectionVC".concat(_lc, ",normalVCVSOutput),\n normalize(-vertexVC.xyz))),\n specularPower);"), " specularL += (sf".concat(shadowFactor, " * lightColor").concat(_lc, ");"), ' }']);
197
+ for (let lc = 0; lc < lastLightCount; ++lc) {
198
+ sstring = sstring.concat([` df = max(0.0, dot(normalVCVSOutput, -lightDirectionVC${lc}));`, ` diffuseL += ((df${shadowFactor}) * lightColor${lc});`, ` if (dot(normalVCVSOutput, lightDirectionVC${lc}) < 0.0)`, ' {', ` float sf = sign(df)*pow(max(1e-5,
199
+ dot(reflect(lightDirectionVC${lc},normalVCVSOutput),
200
+ normalize(-vertexVC.xyz))),
201
+ specularPower);`, ` specularL += (sf${shadowFactor} * lightColor${lc});`, ' }']);
216
202
  }
217
-
218
203
  sstring = sstring.concat([' diffuseL = diffuseL * diffuseColor;', ' specularL = specularL * specularColor;', ' gl_FragData[0] = vec4(ambientColor * ambient + diffuseL * diffuse + specularL * specular, opacity);', ' //VTK::Light::Impl']);
219
204
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Light::Impl', sstring, false).result;
220
205
  break;
221
-
222
206
  case 3:
223
207
  // positional
224
- for (var _lc2 = 0; _lc2 < lastLightCount; ++_lc2) {
225
- sstring = sstring.concat(["uniform vec3 lightColor".concat(_lc2, ";"), "uniform vec3 lightDirectionVC".concat(_lc2, "; // normalized"), "uniform vec3 lightHalfAngleVC".concat(_lc2, "; // normalized"), "uniform vec3 lightPositionVC".concat(_lc2, ";"), "uniform vec3 lightAttenuation".concat(_lc2, ";"), "uniform float lightConeAngle".concat(_lc2, ";"), "uniform float lightExponent".concat(_lc2, ";"), "uniform int lightPositional".concat(_lc2, ";")]);
208
+ for (let lc = 0; lc < lastLightCount; ++lc) {
209
+ sstring = sstring.concat([`uniform vec3 lightColor${lc};`, `uniform vec3 lightDirectionVC${lc}; // normalized`, `uniform vec3 lightHalfAngleVC${lc}; // normalized`, `uniform vec3 lightPositionVC${lc};`, `uniform vec3 lightAttenuation${lc};`, `uniform float lightConeAngle${lc};`, `uniform float lightExponent${lc};`, `uniform int lightPositional${lc};`]);
226
210
  }
227
-
228
211
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Light::Dec', sstring).result;
229
212
  sstring = ['vec3 diffuseL = vec3(0,0,0);', ' vec3 specularL = vec3(0,0,0);', ' vec3 vertLightDirectionVC;', ' float attenuation;', ' float df;'];
230
-
231
- for (var _lc3 = 0; _lc3 < lastLightCount; ++_lc3) {
232
- sstring = sstring.concat([' attenuation = 1.0;', " if (lightPositional".concat(_lc3, " == 0)"), ' {', " vertLightDirectionVC = lightDirectionVC".concat(_lc3, ";"), ' }', ' else', ' {', " vertLightDirectionVC = vertexVC.xyz - lightPositionVC".concat(_lc3, ";"), ' float distanceVC = length(vertLightDirectionVC);', ' vertLightDirectionVC = normalize(vertLightDirectionVC);', ' attenuation = 1.0 /', " (lightAttenuation".concat(_lc3, ".x"), " + lightAttenuation".concat(_lc3, ".y * distanceVC"), " + lightAttenuation".concat(_lc3, ".z * distanceVC * distanceVC);"), ' // per OpenGL standard cone angle is 90 or less for a spot light', " if (lightConeAngle".concat(_lc3, " <= 90.0)"), ' {', " float coneDot = dot(vertLightDirectionVC, lightDirectionVC".concat(_lc3, ");"), ' // if inside the cone', " if (coneDot >= cos(radians(lightConeAngle".concat(_lc3, ")))"), ' {', " attenuation = attenuation * pow(coneDot, lightExponent".concat(_lc3, ");"), ' }', ' else', ' {', ' attenuation = 0.0;', ' }', ' }', ' }', ' df = max(0.0, attenuation*dot(normalVCVSOutput, -vertLightDirectionVC));', " diffuseL += ((df".concat(shadowFactor, ") * lightColor").concat(_lc3, ");"), ' if (dot(normalVCVSOutput, vertLightDirectionVC) < 0.0)', ' {', " float sf = sign(df)*attenuation*pow(max(1e-5,\n dot(reflect(lightDirectionVC".concat(_lc3, ",\n normalVCVSOutput),\n normalize(-vertexVC.xyz))),\n specularPower);"), " specularL += ((sf".concat(shadowFactor, ") * lightColor").concat(_lc3, ");"), ' }']);
213
+ for (let lc = 0; lc < lastLightCount; ++lc) {
214
+ sstring = sstring.concat([' attenuation = 1.0;', ` if (lightPositional${lc} == 0)`, ' {', ` vertLightDirectionVC = lightDirectionVC${lc};`, ' }', ' else', ' {', ` vertLightDirectionVC = vertexVC.xyz - lightPositionVC${lc};`, ' float distanceVC = length(vertLightDirectionVC);', ' vertLightDirectionVC = normalize(vertLightDirectionVC);', ' attenuation = 1.0 /', ` (lightAttenuation${lc}.x`, ` + lightAttenuation${lc}.y * distanceVC`, ` + lightAttenuation${lc}.z * distanceVC * distanceVC);`, ' // per OpenGL standard cone angle is 90 or less for a spot light', ` if (lightConeAngle${lc} <= 90.0)`, ' {', ` float coneDot = dot(vertLightDirectionVC, lightDirectionVC${lc});`, ' // if inside the cone', ` if (coneDot >= cos(radians(lightConeAngle${lc})))`, ' {', ` attenuation = attenuation * pow(coneDot, lightExponent${lc});`, ' }', ' else', ' {', ' attenuation = 0.0;', ' }', ' }', ' }', ' df = max(0.0, attenuation*dot(normalVCVSOutput, -vertLightDirectionVC));', ` diffuseL += ((df${shadowFactor}) * lightColor${lc});`, ' if (dot(normalVCVSOutput, vertLightDirectionVC) < 0.0)', ' {', ` float sf = sign(df)*attenuation*pow(max(1e-5,
215
+ dot(reflect(lightDirectionVC${lc},
216
+ normalVCVSOutput),
217
+ normalize(-vertexVC.xyz))),
218
+ specularPower);`, ` specularL += ((sf${shadowFactor}) * lightColor${lc});`, ' }']);
233
219
  }
234
-
235
220
  sstring = sstring.concat([' diffuseL = diffuseL * diffuseColor;', ' specularL = specularL * specularColor;', ' gl_FragData[0] = vec4(ambientColor * ambient + diffuseL * diffuse + specularL * specular, opacity);', ' //VTK::Light::Impl']);
236
221
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Light::Impl', sstring, false).result;
237
222
  break;
238
-
239
223
  default:
240
224
  vtkErrorMacro('bad light complexity');
241
225
  }
242
-
243
226
  shaders.Fragment = FSSource;
244
227
  };
245
-
246
- publicAPI.replaceShaderNormal = function (shaders, ren, actor) {
247
- var lastLightComplexity = model.lastBoundBO.getReferenceByName('lastLightComplexity');
248
-
228
+ publicAPI.replaceShaderNormal = (shaders, ren, actor) => {
229
+ const lastLightComplexity = model.lastBoundBO.getReferenceByName('lastLightComplexity');
249
230
  if (lastLightComplexity > 0) {
250
- var VSSource = shaders.Vertex;
251
- var GSSource = shaders.Geometry;
252
- var FSSource = shaders.Fragment;
253
-
231
+ let VSSource = shaders.Vertex;
232
+ let GSSource = shaders.Geometry;
233
+ let FSSource = shaders.Fragment;
254
234
  if (model.lastBoundBO.getCABO().getNormalOffset()) {
255
235
  VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Normal::Dec', ['attribute vec3 normalMC;', 'uniform mat3 normalMatrix;', 'varying vec3 normalVCVSOutput;']).result;
256
236
  VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Normal::Impl', ['normalVCVSOutput = normalMatrix * normalMC;']).result;
257
237
  GSSource = vtkShaderProgram.substitute(GSSource, '//VTK::Normal::Dec', ['in vec3 normalVCVSOutput[];', 'out vec3 normalVCGSOutput;']).result;
258
238
  GSSource = vtkShaderProgram.substitute(GSSource, '//VTK::Normal::Impl', ['normalVCGSOutput = normalVCVSOutput[i];']).result;
259
239
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Normal::Dec', ['varying vec3 normalVCVSOutput;']).result;
260
- FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Normal::Impl', ['vec3 normalVCVSOutput = normalize(normalVCVSOutput);', // if (!gl_FrontFacing) does not work in intel hd4000 mac
240
+ FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Normal::Impl', ['vec3 normalVCVSOutput = normalize(normalVCVSOutput);',
241
+ // if (!gl_FrontFacing) does not work in intel hd4000 mac
261
242
  // if (int(gl_FrontFacing) == 0) does not work on mesa
262
243
  ' if (gl_FrontFacing == false) { normalVCVSOutput = -normalVCVSOutput; }']).result;
263
244
  } else {
@@ -282,32 +263,32 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
282
263
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Normal::Impl', ['vec3 normalVCVSOutput;', ' if (abs(fdx.x) > 0.0)', ' { fdx = normalize(fdx); normalVCVSOutput = normalize(cross(vec3(fdx.y, -fdx.x, 0.0), fdx)); }', ' else { fdy = normalize(fdy); normalVCVSOutput = normalize(cross(vec3(fdy.y, -fdy.x, 0.0), fdy));}']).result;
283
264
  } else {
284
265
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Normal::Dec', ['uniform int cameraParallel;']).result;
285
- FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::UniformFlow::Impl', [// ' vec3 fdx = vec3(dFdx(vertexVC.x),dFdx(vertexVC.y),dFdx(vertexVC.z));',
266
+ FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::UniformFlow::Impl', [
267
+ // ' vec3 fdx = vec3(dFdx(vertexVC.x),dFdx(vertexVC.y),dFdx(vertexVC.z));',
286
268
  // ' vec3 fdy = vec3(dFdy(vertexVC.x),dFdy(vertexVC.y),dFdy(vertexVC.z));',
287
269
  ' vec3 fdx = dFdx(vertexVC.xyz);', ' vec3 fdy = dFdy(vertexVC.xyz);', ' //VTK::UniformFlow::Impl'] // For further replacements
288
270
  ).result;
289
- FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Normal::Impl', [' fdx = normalize(fdx);', ' fdy = normalize(fdy);', ' vec3 normalVCVSOutput = normalize(cross(fdx,fdy));', // the code below is faster, but does not work on some devices
271
+ FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Normal::Impl', [' fdx = normalize(fdx);', ' fdy = normalize(fdy);', ' vec3 normalVCVSOutput = normalize(cross(fdx,fdy));',
272
+ // the code below is faster, but does not work on some devices
290
273
  // 'vec3 normalVC = normalize(cross(dFdx(vertexVC.xyz), dFdy(vertexVC.xyz)));',
291
274
  ' if (cameraParallel == 1 && normalVCVSOutput.z < 0.0) { normalVCVSOutput = -1.0*normalVCVSOutput; }', ' if (cameraParallel == 0 && dot(normalVCVSOutput,vertexVC.xyz) > 0.0) { normalVCVSOutput = -1.0*normalVCVSOutput; }']).result;
292
275
  }
293
276
  }
294
277
  }
295
-
296
278
  shaders.Vertex = VSSource;
297
279
  shaders.Geometry = GSSource;
298
280
  shaders.Fragment = FSSource;
299
281
  }
300
282
  };
301
-
302
- publicAPI.replaceShaderPositionVC = function (shaders, ren, actor) {
283
+ publicAPI.replaceShaderPositionVC = (shaders, ren, actor) => {
303
284
  // replace common shader code
304
285
  model.lastBoundBO.replaceShaderPositionVC(shaders, ren, actor);
305
- var VSSource = shaders.Vertex;
306
- var GSSource = shaders.Geometry;
307
- var FSSource = shaders.Fragment; // do we need the vertex in the shader in View Coordinates
308
-
309
- var lastLightComplexity = model.lastBoundBO.getReferenceByName('lastLightComplexity');
286
+ let VSSource = shaders.Vertex;
287
+ let GSSource = shaders.Geometry;
288
+ let FSSource = shaders.Fragment;
310
289
 
290
+ // do we need the vertex in the shader in View Coordinates
291
+ const lastLightComplexity = model.lastBoundBO.getReferenceByName('lastLightComplexity');
311
292
  if (lastLightComplexity > 0) {
312
293
  VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::PositionVC::Dec', ['varying vec4 vertexVCVSOutput;']).result;
313
294
  VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::PositionVC::Impl', ['vertexVCVSOutput = MCVCMatrix * vertexMC;', ' gl_Position = MCPCMatrix * vertexMC;']).result;
@@ -320,60 +301,50 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
320
301
  VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Camera::Dec', ['uniform mat4 MCPCMatrix;']).result;
321
302
  VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::PositionVC::Impl', [' gl_Position = MCPCMatrix * vertexMC;']).result;
322
303
  }
323
-
324
304
  shaders.Vertex = VSSource;
325
305
  shaders.Geometry = GSSource;
326
306
  shaders.Fragment = FSSource;
327
307
  };
328
-
329
- publicAPI.replaceShaderTCoord = function (shaders, ren, actor) {
308
+ publicAPI.replaceShaderTCoord = (shaders, ren, actor) => {
330
309
  if (model.lastBoundBO.getCABO().getTCoordOffset()) {
331
- var VSSource = shaders.Vertex;
332
- var GSSource = shaders.Geometry;
333
- var FSSource = shaders.Fragment;
334
-
310
+ let VSSource = shaders.Vertex;
311
+ let GSSource = shaders.Geometry;
312
+ let FSSource = shaders.Fragment;
335
313
  if (model.drawingEdges) {
336
314
  return;
337
315
  }
316
+ VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::TCoord::Impl', 'tcoordVCVSOutput = tcoordMC;').result;
338
317
 
339
- VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::TCoord::Impl', 'tcoordVCVSOutput = tcoordMC;').result; // we only handle the first texture by default
318
+ // we only handle the first texture by default
340
319
  // additional textures are activated and we set the uniform
341
320
  // for the texture unit they are assigned to, but you have to
342
321
  // add in the shader code to do something with them
343
-
344
- var tus = model.openGLActor.getActiveTextures();
345
- var tNumComp = 2;
346
- var tcdim = 2;
347
-
322
+ const tus = model.openGLActor.getActiveTextures();
323
+ let tNumComp = 2;
324
+ let tcdim = 2;
348
325
  if (tus && tus.length > 0) {
349
326
  tNumComp = tus[0].getComponents();
350
-
351
327
  if (tus[0].getTarget() === model.context.TEXTURE_CUBE_MAP) {
352
328
  tcdim = 3;
353
329
  }
354
330
  }
355
-
356
331
  if (model.renderable.getColorTextureMap()) {
357
332
  tNumComp = model.renderable.getColorTextureMap().getPointData().getScalars().getNumberOfComponents();
358
333
  tcdim = 2;
359
334
  }
360
-
361
335
  if (tcdim === 2) {
362
336
  VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::TCoord::Dec', 'attribute vec2 tcoordMC; varying vec2 tcoordVCVSOutput;').result;
363
337
  GSSource = vtkShaderProgram.substitute(GSSource, '//VTK::TCoord::Dec', ['in vec2 tcoordVCVSOutput[];', 'out vec2 tcoordVCGSOutput;']).result;
364
338
  GSSource = vtkShaderProgram.substitute(GSSource, '//VTK::TCoord::Impl', 'tcoordVCGSOutput = tcoordVCVSOutput[i];').result;
365
339
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::TCoord::Dec', ['varying vec2 tcoordVCVSOutput;', 'uniform sampler2D texture1;']).result;
366
-
367
340
  if (tus && tus.length >= 1) {
368
341
  switch (tNumComp) {
369
342
  case 1:
370
343
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::TCoord::Impl', [' vec4 tcolor = texture2D(texture1, tcoordVCVSOutput);', ' ambientColor = ambientColor*tcolor.r;', ' diffuseColor = diffuseColor*tcolor.r;']).result;
371
344
  break;
372
-
373
345
  case 2:
374
346
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::TCoord::Impl', [' vec4 tcolor = texture2D(texture1, tcoordVCVSOutput);', ' ambientColor = ambientColor*tcolor.r;', ' diffuseColor = diffuseColor*tcolor.r;', ' opacity = opacity * tcolor.g;']).result;
375
347
  break;
376
-
377
348
  default:
378
349
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::TCoord::Impl', [' vec4 tcolor = texture2D(texture1, tcoordVCVSOutput);', ' ambientColor = ambientColor*tcolor.rgb;', ' diffuseColor = diffuseColor*tcolor.rgb;', ' opacity = opacity * tcolor.a;']).result;
379
350
  }
@@ -383,55 +354,45 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
383
354
  GSSource = vtkShaderProgram.substitute(GSSource, '//VTK::TCoord::Dec', ['in vec3 tcoordVCVSOutput[];', 'out vec3 tcoordVCGSOutput;']).result;
384
355
  GSSource = vtkShaderProgram.substitute(GSSource, '//VTK::TCoord::Impl', 'tcoordVCGSOutput = tcoordVCVSOutput[i];').result;
385
356
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::TCoord::Dec', ['varying vec3 tcoordVCVSOutput;', 'uniform samplerCube texture1;']).result;
386
-
387
357
  switch (tNumComp) {
388
358
  case 1:
389
359
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::TCoord::Impl', [' vec4 tcolor = textureCube(texture1, tcoordVCVSOutput);', ' ambientColor = ambientColor*tcolor.r;', ' diffuseColor = diffuseColor*tcolor.r;']).result;
390
360
  break;
391
-
392
361
  case 2:
393
362
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::TCoord::Impl', [' vec4 tcolor = textureCube(texture1, tcoordVCVSOutput);', ' ambientColor = ambientColor*tcolor.r;', ' diffuseColor = diffuseColor*tcolor.r;', ' opacity = opacity * tcolor.g;']).result;
394
363
  break;
395
-
396
364
  default:
397
365
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::TCoord::Impl', [' vec4 tcolor = textureCube(texture1, tcoordVCVSOutput);', ' ambientColor = ambientColor*tcolor.rgb;', ' diffuseColor = diffuseColor*tcolor.rgb;', ' opacity = opacity * tcolor.a;']).result;
398
366
  }
399
367
  }
400
-
401
368
  shaders.Vertex = VSSource;
402
369
  shaders.Geometry = GSSource;
403
370
  shaders.Fragment = FSSource;
404
371
  }
405
372
  };
406
-
407
- publicAPI.replaceShaderClip = function (shaders, ren, actor) {
408
- var VSSource = shaders.Vertex;
409
- var FSSource = shaders.Fragment;
410
-
373
+ publicAPI.replaceShaderClip = (shaders, ren, actor) => {
374
+ let VSSource = shaders.Vertex;
375
+ let FSSource = shaders.Fragment;
411
376
  if (model.renderable.getNumberOfClippingPlanes()) {
412
- var numClipPlanes = model.renderable.getNumberOfClippingPlanes();
413
- VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Clip::Dec', ['uniform int numClipPlanes;', "uniform vec4 clipPlanes[".concat(numClipPlanes, "];"), "varying float clipDistancesVSOutput[".concat(numClipPlanes, "];")]).result;
414
- VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Clip::Impl', ["for (int planeNum = 0; planeNum < ".concat(numClipPlanes, "; planeNum++)"), ' {', ' if (planeNum >= numClipPlanes)', ' {', ' break;', ' }', ' clipDistancesVSOutput[planeNum] = dot(clipPlanes[planeNum], vertexMC);', ' }']).result;
415
- FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Clip::Dec', ['uniform int numClipPlanes;', "varying float clipDistancesVSOutput[".concat(numClipPlanes, "];")]).result;
416
- FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Clip::Impl', ["for (int planeNum = 0; planeNum < ".concat(numClipPlanes, "; planeNum++)"), ' {', ' if (planeNum >= numClipPlanes)', ' {', ' break;', ' }', ' if (clipDistancesVSOutput[planeNum] < 0.0) discard;', ' }']).result;
377
+ const numClipPlanes = model.renderable.getNumberOfClippingPlanes();
378
+ VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Clip::Dec', ['uniform int numClipPlanes;', `uniform vec4 clipPlanes[${numClipPlanes}];`, `varying float clipDistancesVSOutput[${numClipPlanes}];`]).result;
379
+ VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Clip::Impl', [`for (int planeNum = 0; planeNum < ${numClipPlanes}; planeNum++)`, ' {', ' if (planeNum >= numClipPlanes)', ' {', ' break;', ' }', ' clipDistancesVSOutput[planeNum] = dot(clipPlanes[planeNum], vertexMC);', ' }']).result;
380
+ FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Clip::Dec', ['uniform int numClipPlanes;', `varying float clipDistancesVSOutput[${numClipPlanes}];`]).result;
381
+ FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Clip::Impl', [`for (int planeNum = 0; planeNum < ${numClipPlanes}; planeNum++)`, ' {', ' if (planeNum >= numClipPlanes)', ' {', ' break;', ' }', ' if (clipDistancesVSOutput[planeNum] < 0.0) discard;', ' }']).result;
417
382
  }
418
-
419
383
  shaders.Vertex = VSSource;
420
384
  shaders.Fragment = FSSource;
421
385
  };
422
-
423
- publicAPI.getCoincidentParameters = function (ren, actor) {
386
+ publicAPI.getCoincidentParameters = (ren, actor) => {
424
387
  // 1. ResolveCoincidentTopology is On and non zero for this primitive
425
388
  // type
426
- var cp = {
389
+ let cp = {
427
390
  factor: 0.0,
428
391
  offset: 0.0
429
392
  };
430
- var prop = actor.getProperty();
431
-
393
+ const prop = actor.getProperty();
432
394
  if (model.renderable.getResolveCoincidentTopology() || prop.getEdgeVisibility() && prop.getRepresentation() === Representation.SURFACE) {
433
- var primType = model.lastBoundBO.getPrimitiveType();
434
-
395
+ const primType = model.lastBoundBO.getPrimitiveType();
435
396
  if (primType === primTypes.Points || prop.getRepresentation() === Representation.POINTS) {
436
397
  cp = model.renderable.getCoincidentTopologyPointOffsetParameter();
437
398
  } else if (primType === primTypes.Lines || prop.getRepresentation() === Representation.WIREFRAME) {
@@ -439,60 +400,49 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
439
400
  } else if (primType === primTypes.Tris || primType === primTypes.TriStrips) {
440
401
  cp = model.renderable.getCoincidentTopologyPolygonOffsetParameters();
441
402
  }
442
-
443
403
  if (primType === primTypes.TrisEdges || primType === primTypes.TriStripsEdges) {
444
404
  cp = model.renderable.getCoincidentTopologyPolygonOffsetParameters();
445
405
  cp.factor /= 2.0;
446
406
  cp.offset /= 2.0;
447
407
  }
448
- } // hardware picking always offset due to saved zbuffer
449
- // This gets you above the saved surface depth buffer.
450
-
451
-
452
- var selector = model._openGLRenderer.getSelector();
408
+ }
453
409
 
410
+ // hardware picking always offset due to saved zbuffer
411
+ // This gets you above the saved surface depth buffer.
412
+ const selector = model._openGLRenderer.getSelector();
454
413
  if (selector && selector.getFieldAssociation() === FieldAssociations.FIELD_ASSOCIATION_POINTS) {
455
414
  cp.offset -= 2.0;
456
415
  }
457
-
458
416
  return cp;
459
417
  };
460
-
461
- publicAPI.replaceShaderPicking = function (shaders, ren, actor) {
462
- var FSSource = shaders.Fragment;
463
- var VSSource = shaders.Vertex;
418
+ publicAPI.replaceShaderPicking = (shaders, ren, actor) => {
419
+ let FSSource = shaders.Fragment;
420
+ let VSSource = shaders.Vertex;
464
421
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Picking::Dec', ['uniform int picking;', '//VTK::Picking::Dec']).result;
465
-
466
422
  if (!model._openGLRenderer.getSelector()) {
467
423
  return;
468
424
  }
469
-
470
425
  if (model.lastSelectionState === PassTypes.ID_LOW24 || model.lastSelectionState === PassTypes.ID_HIGH24) {
471
426
  VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Picking::Dec', ['flat out int vertexIDVSOutput;\n', 'uniform int VertexIDOffset;\n']).result;
472
427
  VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Picking::Impl', ' vertexIDVSOutput = gl_VertexID + VertexIDOffset;\n').result;
473
428
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Picking::Dec', 'flat in int vertexIDVSOutput;\n').result;
474
429
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Picking::Impl', [' int idx = vertexIDVSOutput;', '//VTK::Picking::Impl']).result;
475
430
  }
476
-
477
431
  switch (model.lastSelectionState) {
478
432
  case PassTypes.ID_LOW24:
479
433
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Picking::Impl', ' gl_FragData[0] = vec4(float(idx%256)/255.0, float((idx/256)%256)/255.0, float((idx/65536)%256)/255.0, 1.0);').result;
480
434
  break;
481
-
482
435
  case PassTypes.ID_HIGH24:
483
436
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Picking::Impl', ' gl_FragData[0] = vec4(float(idx)/255.0, 0.0, 0.0, 1.0);').result;
484
437
  break;
485
-
486
438
  default:
487
439
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Picking::Dec', 'uniform vec3 mapperIndex;').result;
488
440
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Picking::Impl', ' gl_FragData[0] = picking != 0 ? vec4(mapperIndex,1.0) : gl_FragData[0];').result;
489
441
  }
490
-
491
442
  shaders.Fragment = FSSource;
492
443
  shaders.Vertex = VSSource;
493
444
  };
494
-
495
- publicAPI.replaceShaderValues = function (shaders, ren, actor) {
445
+ publicAPI.replaceShaderValues = (shaders, ren, actor) => {
496
446
  publicAPI.replaceShaderColor(shaders, ren, actor);
497
447
  publicAPI.replaceShaderNormal(shaders, ren, actor);
498
448
  publicAPI.replaceShaderLight(shaders, ren, actor);
@@ -501,72 +451,67 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
501
451
  publicAPI.replaceShaderClip(shaders, ren, actor);
502
452
  publicAPI.replaceShaderCoincidentOffset(shaders, ren, actor);
503
453
  publicAPI.replaceShaderPositionVC(shaders, ren, actor);
504
-
505
454
  if (model.haveSeenDepthRequest) {
506
- var FSSource = shaders.Fragment;
455
+ let FSSource = shaders.Fragment;
507
456
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::ZBuffer::Dec', 'uniform int depthRequest;').result;
508
457
  FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::ZBuffer::Impl', ['if (depthRequest == 1) {', 'float iz = floor(gl_FragCoord.z*65535.0 + 0.1);', 'float rf = floor(iz/256.0)/255.0;', 'float gf = mod(iz,256.0)/255.0;', 'gl_FragData[0] = vec4(rf, gf, 0.0, 1.0); }']).result;
509
458
  shaders.Fragment = FSSource;
510
459
  }
511
460
  };
512
-
513
- publicAPI.getNeedToRebuildShaders = function (cellBO, ren, actor) {
514
- var lightComplexity = 0;
515
- var numberOfLights = 0;
516
- var primType = cellBO.getPrimitiveType();
517
- var poly = model.currentInput; // different algo from C++ as of 5/2019
518
-
519
- var needLighting = false;
520
- var pointNormals = poly.getPointData().getNormals();
521
- var cellNormals = poly.getCellData().getNormals();
522
- var flat = actor.getProperty().getInterpolation() === Shading.FLAT;
523
- var representation = actor.getProperty().getRepresentation();
524
- var mode = cellBO.getOpenGLMode(representation, primType); // 1) all surfaces need lighting
525
-
461
+ publicAPI.getNeedToRebuildShaders = (cellBO, ren, actor) => {
462
+ let lightComplexity = 0;
463
+ let numberOfLights = 0;
464
+ const primType = cellBO.getPrimitiveType();
465
+ const poly = model.currentInput;
466
+
467
+ // different algo from C++ as of 5/2019
468
+ let needLighting = false;
469
+ const pointNormals = poly.getPointData().getNormals();
470
+ const cellNormals = poly.getCellData().getNormals();
471
+ const flat = actor.getProperty().getInterpolation() === Shading.FLAT;
472
+ const representation = actor.getProperty().getRepresentation();
473
+ const mode = cellBO.getOpenGLMode(representation, primType);
474
+ // 1) all surfaces need lighting
526
475
  if (mode === model.context.TRIANGLES) {
527
- needLighting = true; // 2) all cell normals without point normals need lighting
476
+ needLighting = true;
477
+ // 2) all cell normals without point normals need lighting
528
478
  } else if (cellNormals && !pointNormals) {
529
- needLighting = true; // 3) Phong + pointNormals need lighting
479
+ needLighting = true;
480
+ // 3) Phong + pointNormals need lighting
530
481
  } else if (!flat && pointNormals) {
531
- needLighting = true; // 4) Phong Lines need lighting
482
+ needLighting = true;
483
+ // 4) Phong Lines need lighting
532
484
  } else if (!flat && mode === model.context.LINES) {
533
485
  needLighting = true;
534
- } // 5) everything else is unlit
535
- // do we need lighting?
536
-
486
+ }
487
+ // 5) everything else is unlit
537
488
 
489
+ // do we need lighting?
538
490
  if (actor.getProperty().getLighting() && needLighting) {
539
491
  // consider the lighting complexity to determine which case applies
540
492
  // simple headlight, Light Kit, the whole feature set of VTK
541
493
  lightComplexity = 0;
542
- var lights = ren.getLightsByReference();
543
-
544
- for (var index = 0; index < lights.length; ++index) {
545
- var light = lights[index];
546
- var status = light.getSwitch();
547
-
494
+ const lights = ren.getLightsByReference();
495
+ for (let index = 0; index < lights.length; ++index) {
496
+ const light = lights[index];
497
+ const status = light.getSwitch();
548
498
  if (status > 0) {
549
499
  numberOfLights++;
550
-
551
500
  if (lightComplexity === 0) {
552
501
  lightComplexity = 1;
553
502
  }
554
503
  }
555
-
556
504
  if (lightComplexity === 1 && (numberOfLights > 1 || light.getIntensity() !== 1.0 || !light.lightTypeIsHeadLight())) {
557
505
  lightComplexity = 2;
558
506
  }
559
-
560
507
  if (lightComplexity < 3 && light.getPositional()) {
561
508
  lightComplexity = 3;
562
509
  }
563
510
  }
564
511
  }
565
-
566
- var needRebuild = false;
567
- var lastLightComplexity = model.lastBoundBO.getReferenceByName('lastLightComplexity');
568
- var lastLightCount = model.lastBoundBO.getReferenceByName('lastLightCount');
569
-
512
+ let needRebuild = false;
513
+ const lastLightComplexity = model.lastBoundBO.getReferenceByName('lastLightComplexity');
514
+ const lastLightCount = model.lastBoundBO.getReferenceByName('lastLightCount');
570
515
  if (lastLightComplexity !== lightComplexity || lastLightCount !== numberOfLights) {
571
516
  model.lastBoundBO.set({
572
517
  lastLightComplexity: lightComplexity
@@ -575,56 +520,48 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
575
520
  lastLightCount: numberOfLights
576
521
  }, true);
577
522
  needRebuild = true;
578
- } // has the render pass shader replacement changed? Two options
579
-
523
+ }
580
524
 
525
+ // has the render pass shader replacement changed? Two options
581
526
  if (!model.currentRenderPass && model.lastRenderPassShaderReplacement || model.currentRenderPass && model.currentRenderPass.getShaderReplacement() !== model.lastRenderPassShaderReplacement) {
582
527
  needRebuild = true;
583
- } // has something changed that would require us to recreate the shader?
528
+ }
529
+
530
+ // has something changed that would require us to recreate the shader?
584
531
  // candidates are
585
532
  // property modified (representation interpolation and lighting)
586
533
  // input modified
587
534
  // light complexity changed
588
535
  // render pass shader replacement changed
589
-
590
-
591
536
  if (model.lastHaveSeenDepthRequest !== model.haveSeenDepthRequest || cellBO.getShaderSourceTime().getMTime() < model.renderable.getMTime() || cellBO.getShaderSourceTime().getMTime() < model.currentInput.getMTime() || cellBO.getShaderSourceTime().getMTime() < model.selectionStateChanged.getMTime() || needRebuild) {
592
537
  model.lastHaveSeenDepthRequest = model.haveSeenDepthRequest;
593
538
  return true;
594
539
  }
595
-
596
540
  return false;
597
541
  };
598
-
599
- publicAPI.invokeShaderCallbacks = function (cellBO, ren, actor) {
600
- var listCallbacks = model.renderable.getViewSpecificProperties().ShadersCallbacks;
601
-
542
+ publicAPI.invokeShaderCallbacks = (cellBO, ren, actor) => {
543
+ const listCallbacks = model.renderable.getViewSpecificProperties().ShadersCallbacks;
602
544
  if (listCallbacks) {
603
- listCallbacks.forEach(function (object) {
545
+ listCallbacks.forEach(object => {
604
546
  object.callback(object.userData, cellBO, ren, actor);
605
547
  });
606
548
  }
607
549
  };
608
-
609
- publicAPI.setMapperShaderParameters = function (cellBO, ren, actor) {
550
+ publicAPI.setMapperShaderParameters = (cellBO, ren, actor) => {
610
551
  // Now to update the VAO too, if necessary.
611
552
  if (cellBO.getProgram().isUniformUsed('PrimitiveIDOffset')) {
612
553
  cellBO.getProgram().setUniformi('PrimitiveIDOffset', model.primitiveIDOffset);
613
554
  }
614
-
615
555
  if (cellBO.getProgram().isUniformUsed('VertexIDOffset')) {
616
556
  cellBO.getProgram().setUniformi('VertexIDOffset', model.vertexIDOffset);
617
557
  }
618
-
619
558
  if (cellBO.getCABO().getElementCount() && (model.VBOBuildTime.getMTime() > cellBO.getAttributeUpdateTime().getMTime() || cellBO.getShaderSourceTime().getMTime() > cellBO.getAttributeUpdateTime().getMTime())) {
620
- var lastLightComplexity = model.lastBoundBO.getReferenceByName('lastLightComplexity');
621
-
559
+ const lastLightComplexity = model.lastBoundBO.getReferenceByName('lastLightComplexity');
622
560
  if (cellBO.getProgram().isAttributeUsed('vertexMC')) {
623
561
  if (!cellBO.getVAO().addAttributeArray(cellBO.getProgram(), cellBO.getCABO(), 'vertexMC', cellBO.getCABO().getVertexOffset(), cellBO.getCABO().getStride(), model.context.FLOAT, 3, false)) {
624
562
  vtkErrorMacro('Error setting vertexMC in shader VAO.');
625
563
  }
626
564
  }
627
-
628
565
  if (cellBO.getProgram().isAttributeUsed('normalMC') && cellBO.getCABO().getNormalOffset() && lastLightComplexity > 0) {
629
566
  if (!cellBO.getVAO().addAttributeArray(cellBO.getProgram(), cellBO.getCABO(), 'normalMC', cellBO.getCABO().getNormalOffset(), cellBO.getCABO().getStride(), model.context.FLOAT, 3, false)) {
630
567
  vtkErrorMacro('Error setting normalMC in shader VAO.');
@@ -632,15 +569,13 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
632
569
  } else {
633
570
  cellBO.getVAO().removeAttributeArray('normalMC');
634
571
  }
635
-
636
- model.renderable.getCustomShaderAttributes().forEach(function (attrName, idx) {
637
- if (cellBO.getProgram().isAttributeUsed("".concat(attrName, "MC"))) {
638
- if (!cellBO.getVAO().addAttributeArray(cellBO.getProgram(), cellBO.getCABO(), "".concat(attrName, "MC"), cellBO.getCABO().getCustomData()[idx].offset, cellBO.getCABO().getStride(), model.context.FLOAT, cellBO.getCABO().getCustomData()[idx].components, false)) {
639
- vtkErrorMacro("Error setting ".concat(attrName, "MC in shader VAO."));
572
+ model.renderable.getCustomShaderAttributes().forEach((attrName, idx) => {
573
+ if (cellBO.getProgram().isAttributeUsed(`${attrName}MC`)) {
574
+ if (!cellBO.getVAO().addAttributeArray(cellBO.getProgram(), cellBO.getCABO(), `${attrName}MC`, cellBO.getCABO().getCustomData()[idx].offset, cellBO.getCABO().getStride(), model.context.FLOAT, cellBO.getCABO().getCustomData()[idx].components, false)) {
575
+ vtkErrorMacro(`Error setting ${attrName}MC in shader VAO.`);
640
576
  }
641
577
  }
642
578
  });
643
-
644
579
  if (cellBO.getProgram().isAttributeUsed('tcoordMC') && cellBO.getCABO().getTCoordOffset()) {
645
580
  if (!cellBO.getVAO().addAttributeArray(cellBO.getProgram(), cellBO.getCABO(), 'tcoordMC', cellBO.getCABO().getTCoordOffset(), cellBO.getCABO().getStride(), model.context.FLOAT, cellBO.getCABO().getTCoordComponents(), false)) {
646
581
  vtkErrorMacro('Error setting tcoordMC in shader VAO.');
@@ -648,7 +583,6 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
648
583
  } else {
649
584
  cellBO.getVAO().removeAttributeArray('tcoordMC');
650
585
  }
651
-
652
586
  if (cellBO.getProgram().isAttributeUsed('scalarColor') && cellBO.getCABO().getColorComponents()) {
653
587
  if (!cellBO.getVAO().addAttributeArray(cellBO.getProgram(), cellBO.getCABO().getColorBO(), 'scalarColor', cellBO.getCABO().getColorOffset(), cellBO.getCABO().getColorBOStride(), model.context.UNSIGNED_BYTE, 4, true)) {
654
588
  vtkErrorMacro('Error setting scalarColor in shader VAO.');
@@ -656,186 +590,159 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
656
590
  } else {
657
591
  cellBO.getVAO().removeAttributeArray('scalarColor');
658
592
  }
659
-
660
593
  cellBO.getAttributeUpdateTime().modified();
661
594
  }
662
-
663
595
  if (model.renderable.getNumberOfClippingPlanes()) {
664
596
  // add all the clipping planes
665
- var numClipPlanes = model.renderable.getNumberOfClippingPlanes();
666
- var planeEquations = [];
667
- var shiftScaleEnabled = cellBO.getCABO().getCoordShiftAndScaleEnabled();
668
- var inverseShiftScaleMatrix = shiftScaleEnabled ? cellBO.getCABO().getInverseShiftAndScaleMatrix() : null;
669
- var mat = inverseShiftScaleMatrix ? mat4.copy(model.tmpMat4, actor.getMatrix()) : actor.getMatrix();
670
-
597
+ const numClipPlanes = model.renderable.getNumberOfClippingPlanes();
598
+ const planeEquations = [];
599
+ const shiftScaleEnabled = cellBO.getCABO().getCoordShiftAndScaleEnabled();
600
+ const inverseShiftScaleMatrix = shiftScaleEnabled ? cellBO.getCABO().getInverseShiftAndScaleMatrix() : null;
601
+ const mat = inverseShiftScaleMatrix ? mat4.copy(model.tmpMat4, actor.getMatrix()) : actor.getMatrix();
671
602
  if (inverseShiftScaleMatrix) {
672
603
  mat4.transpose(mat, mat);
673
604
  mat4.multiply(mat, mat, inverseShiftScaleMatrix);
674
605
  mat4.transpose(mat, mat);
675
606
  }
676
-
677
- for (var i = 0; i < numClipPlanes; i++) {
678
- var planeEquation = [];
607
+ for (let i = 0; i < numClipPlanes; i++) {
608
+ const planeEquation = [];
679
609
  model.renderable.getClippingPlaneInDataCoords(mat, i, planeEquation);
680
-
681
- for (var j = 0; j < 4; j++) {
610
+ for (let j = 0; j < 4; j++) {
682
611
  planeEquations.push(planeEquation[j]);
683
612
  }
684
613
  }
685
-
686
614
  cellBO.getProgram().setUniformi('numClipPlanes', numClipPlanes);
687
615
  cellBO.getProgram().setUniform4fv('clipPlanes', planeEquations);
688
616
  }
689
-
690
617
  if (model.internalColorTexture && cellBO.getProgram().isUniformUsed('texture1')) {
691
618
  cellBO.getProgram().setUniformi('texture1', model.internalColorTexture.getTextureUnit());
692
619
  }
693
-
694
- var tus = model.openGLActor.getActiveTextures();
695
-
620
+ const tus = model.openGLActor.getActiveTextures();
696
621
  if (tus) {
697
- for (var index = 0; index < tus.length; ++index) {
698
- var tex = tus[index];
699
- var texUnit = tex.getTextureUnit();
700
- var tname = "texture".concat(texUnit + 1);
701
-
622
+ for (let index = 0; index < tus.length; ++index) {
623
+ const tex = tus[index];
624
+ const texUnit = tex.getTextureUnit();
625
+ const tname = `texture${texUnit + 1}`;
702
626
  if (cellBO.getProgram().isUniformUsed(tname)) {
703
627
  cellBO.getProgram().setUniformi(tname, texUnit);
704
628
  }
705
629
  }
706
- } // handle depth requests
707
-
630
+ }
708
631
 
632
+ // handle depth requests
709
633
  if (model.haveSeenDepthRequest) {
710
634
  cellBO.getProgram().setUniformi('depthRequest', model.renderDepth ? 1 : 0);
711
- } // handle coincident
712
-
635
+ }
713
636
 
637
+ // handle coincident
714
638
  if (cellBO.getProgram().isUniformUsed('coffset')) {
715
- var cp = publicAPI.getCoincidentParameters(ren, actor);
716
- cellBO.getProgram().setUniformf('coffset', cp.offset); // cfactor isn't always used when coffset is.
717
-
639
+ const cp = publicAPI.getCoincidentParameters(ren, actor);
640
+ cellBO.getProgram().setUniformf('coffset', cp.offset);
641
+ // cfactor isn't always used when coffset is.
718
642
  if (cellBO.getProgram().isUniformUsed('cfactor')) {
719
643
  cellBO.getProgram().setUniformf('cfactor', cp.factor);
720
644
  }
721
- } // handle wide lines
722
-
645
+ }
723
646
 
647
+ // handle wide lines
724
648
  cellBO.setMapperShaderParameters(ren, actor, model._openGLRenderer.getTiledSizeAndOrigin());
725
-
726
- var selector = model._openGLRenderer.getSelector();
727
-
649
+ const selector = model._openGLRenderer.getSelector();
728
650
  cellBO.getProgram().setUniform3fArray('mapperIndex', selector ? selector.getPropColorValue() : [0.0, 0.0, 0.0]);
729
651
  cellBO.getProgram().setUniformi('picking', selector ? selector.getCurrentPass() + 1 : 0);
730
652
  };
731
-
732
- publicAPI.setLightingShaderParameters = function (cellBO, ren, actor) {
653
+ publicAPI.setLightingShaderParameters = (cellBO, ren, actor) => {
733
654
  // for unlit and headlight there are no lighting parameters
734
- var lastLightComplexity = model.lastBoundBO.getReferenceByName('lastLightComplexity');
735
-
655
+ const lastLightComplexity = model.lastBoundBO.getReferenceByName('lastLightComplexity');
736
656
  if (lastLightComplexity < 2) {
737
657
  return;
738
658
  }
739
-
740
- var program = cellBO.getProgram(); // bind some light settings
741
-
742
- var numberOfLights = 0;
743
- var lights = ren.getLightsByReference();
744
-
745
- for (var index = 0; index < lights.length; ++index) {
746
- var light = lights[index];
747
- var status = light.getSwitch();
748
-
659
+ const program = cellBO.getProgram();
660
+
661
+ // bind some light settings
662
+ let numberOfLights = 0;
663
+ const lights = ren.getLightsByReference();
664
+ for (let index = 0; index < lights.length; ++index) {
665
+ const light = lights[index];
666
+ const status = light.getSwitch();
749
667
  if (status > 0.0) {
750
- var dColor = light.getColorByReference();
751
- var intensity = light.getIntensity();
668
+ const dColor = light.getColorByReference();
669
+ const intensity = light.getIntensity();
752
670
  model.lightColor[0] = dColor[0] * intensity;
753
671
  model.lightColor[1] = dColor[1] * intensity;
754
- model.lightColor[2] = dColor[2] * intensity; // get required info from light
755
-
756
- var ld = light.getDirection();
757
- var transform = ren.getActiveCamera().getViewMatrix();
758
-
759
- var newLightDirection = _toConsumableArray(ld);
760
-
672
+ model.lightColor[2] = dColor[2] * intensity;
673
+ // get required info from light
674
+ const ld = light.getDirection();
675
+ const transform = ren.getActiveCamera().getViewMatrix();
676
+ const newLightDirection = [...ld];
761
677
  if (light.lightTypeIsSceneLight()) {
762
678
  newLightDirection[0] = transform[0] * ld[0] + transform[1] * ld[1] + transform[2] * ld[2];
763
679
  newLightDirection[1] = transform[4] * ld[0] + transform[5] * ld[1] + transform[6] * ld[2];
764
680
  newLightDirection[2] = transform[8] * ld[0] + transform[9] * ld[1] + transform[10] * ld[2];
765
681
  normalize(newLightDirection);
766
682
  }
767
-
768
683
  model.lightDirection[0] = newLightDirection[0];
769
684
  model.lightDirection[1] = newLightDirection[1];
770
685
  model.lightDirection[2] = newLightDirection[2];
771
686
  normalize(model.lightDirection);
772
- program.setUniform3fArray("lightColor".concat(numberOfLights), model.lightColor);
773
- program.setUniform3fArray("lightDirectionVC".concat(numberOfLights), model.lightDirection);
687
+ program.setUniform3fArray(`lightColor${numberOfLights}`, model.lightColor);
688
+ program.setUniform3fArray(`lightDirectionVC${numberOfLights}`, model.lightDirection);
774
689
  numberOfLights++;
775
690
  }
776
- } // we are done unless we have positional lights
777
-
691
+ }
778
692
 
693
+ // we are done unless we have positional lights
779
694
  if (lastLightComplexity < 3) {
780
695
  return;
781
- } // for lightkit case there are some parameters to set
782
-
696
+ }
783
697
 
784
- var cam = ren.getActiveCamera();
785
- var viewTF = cam.getViewMatrix();
698
+ // for lightkit case there are some parameters to set
699
+ const cam = ren.getActiveCamera();
700
+ const viewTF = cam.getViewMatrix();
786
701
  mat4.transpose(viewTF, viewTF);
787
702
  numberOfLights = 0;
788
-
789
- for (var _index = 0; _index < lights.length; ++_index) {
790
- var _light = lights[_index];
791
-
792
- var _status = _light.getSwitch();
793
-
794
- if (_status > 0.0) {
795
- var lp = _light.getTransformedPosition();
796
-
797
- var np = new Float64Array(3);
703
+ for (let index = 0; index < lights.length; ++index) {
704
+ const light = lights[index];
705
+ const status = light.getSwitch();
706
+ if (status > 0.0) {
707
+ const lp = light.getTransformedPosition();
708
+ const np = new Float64Array(3);
798
709
  vec3.transformMat4(np, lp, viewTF);
799
- program.setUniform3fArray("lightAttenuation".concat(numberOfLights), _light.getAttenuationValuesByReference());
800
- program.setUniformi("lightPositional".concat(numberOfLights), _light.getPositional());
801
- program.setUniformf("lightExponent".concat(numberOfLights), _light.getExponent());
802
- program.setUniformf("lightConeAngle".concat(numberOfLights), _light.getConeAngle());
803
- program.setUniform3fArray("lightPositionVC".concat(numberOfLights), [np[0], np[1], np[2]]);
710
+ program.setUniform3fArray(`lightAttenuation${numberOfLights}`, light.getAttenuationValuesByReference());
711
+ program.setUniformi(`lightPositional${numberOfLights}`, light.getPositional());
712
+ program.setUniformf(`lightExponent${numberOfLights}`, light.getExponent());
713
+ program.setUniformf(`lightConeAngle${numberOfLights}`, light.getConeAngle());
714
+ program.setUniform3fArray(`lightPositionVC${numberOfLights}`, [np[0], np[1], np[2]]);
804
715
  numberOfLights++;
805
716
  }
806
717
  }
807
718
  };
808
-
809
719
  function safeMatrixMultiply(matrixArray, matrixType, tmpMat) {
810
720
  matrixType.identity(tmpMat);
811
- return matrixArray.reduce(function (res, matrix, index) {
721
+ return matrixArray.reduce((res, matrix, index) => {
812
722
  if (index === 0) {
813
723
  return matrix ? matrixType.copy(res, matrix) : matrixType.identity(res);
814
724
  }
815
-
816
725
  return matrix ? matrixType.multiply(res, res, matrix) : res;
817
726
  }, tmpMat);
818
727
  }
728
+ publicAPI.setCameraShaderParameters = (cellBO, ren, actor) => {
729
+ const program = cellBO.getProgram();
819
730
 
820
- publicAPI.setCameraShaderParameters = function (cellBO, ren, actor) {
821
- var program = cellBO.getProgram(); // [WMVP]C == {world, model, view, projection} coordinates
731
+ // [WMVP]C == {world, model, view, projection} coordinates
822
732
  // E.g., WCPC == world to projection coordinate transformation
823
-
824
- var keyMats = model.openGLCamera.getKeyMatrices(ren);
825
- var cam = ren.getActiveCamera();
826
- var camm = model.openGLCamera.getKeyMatrixTime().getMTime();
827
- var progm = program.getLastCameraMTime();
828
- var shiftScaleEnabled = cellBO.getCABO().getCoordShiftAndScaleEnabled();
829
- var inverseShiftScaleMatrix = shiftScaleEnabled ? cellBO.getCABO().getInverseShiftAndScaleMatrix() : null;
830
- var actorIsIdentity = actor.getIsIdentity();
831
- var actMats = actorIsIdentity ? {
733
+ const keyMats = model.openGLCamera.getKeyMatrices(ren);
734
+ const cam = ren.getActiveCamera();
735
+ const camm = model.openGLCamera.getKeyMatrixTime().getMTime();
736
+ const progm = program.getLastCameraMTime();
737
+ const shiftScaleEnabled = cellBO.getCABO().getCoordShiftAndScaleEnabled();
738
+ const inverseShiftScaleMatrix = shiftScaleEnabled ? cellBO.getCABO().getInverseShiftAndScaleMatrix() : null;
739
+ const actorIsIdentity = actor.getIsIdentity();
740
+ const actMats = actorIsIdentity ? {
832
741
  mcwc: null,
833
742
  normalMatrix: null
834
743
  } : model.openGLActor.getKeyMatrices();
835
-
836
744
  if (actor.getCoordinateSystem() === CoordinateSystem.DISPLAY) {
837
- var size = model._openGLRenderer.getTiledSizeAndOrigin();
838
-
745
+ const size = model._openGLRenderer.getTiledSizeAndOrigin();
839
746
  mat4.identity(model.tmpMat4);
840
747
  model.tmpMat4[0] = 2.0 / size.usize;
841
748
  model.tmpMat4[12] = -1.0;
@@ -846,56 +753,50 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
846
753
  } else {
847
754
  program.setUniformMatrix('MCPCMatrix', safeMatrixMultiply([keyMats.wcpc, actMats.mcwc, inverseShiftScaleMatrix], mat4, model.tmpMat4));
848
755
  }
849
-
850
756
  if (program.isUniformUsed('MCVCMatrix')) {
851
757
  program.setUniformMatrix('MCVCMatrix', safeMatrixMultiply([keyMats.wcvc, actMats.mcwc, inverseShiftScaleMatrix], mat4, model.tmpMat4));
852
758
  }
853
-
854
759
  if (program.isUniformUsed('normalMatrix')) {
855
760
  program.setUniformMatrix3x3('normalMatrix', safeMatrixMultiply([keyMats.normalMatrix, actMats.normalMatrix], mat3, model.tmpMat3));
856
761
  }
857
-
858
762
  if (progm !== camm) {
859
763
  if (program.isUniformUsed('cameraParallel')) {
860
764
  program.setUniformi('cameraParallel', cam.getParallelProjection());
861
765
  }
862
-
863
766
  program.setLastCameraMTime(camm);
864
767
  }
865
-
866
768
  if (!actorIsIdentity) {
867
769
  // reset the cam mtime as actor modified the shader values
868
770
  program.setLastCameraMTime(0);
869
771
  }
870
772
  };
871
-
872
- publicAPI.setPropertyShaderParameters = function (cellBO, ren, actor) {
873
- var program = cellBO.getProgram();
874
- var ppty = actor.getProperty();
875
- var opacity = ppty.getOpacity();
876
- var aColor = model.drawingEdges ? ppty.getEdgeColorByReference() : ppty.getAmbientColorByReference();
877
- var dColor = model.drawingEdges ? ppty.getEdgeColorByReference() : ppty.getDiffuseColorByReference();
878
- var aIntensity = model.drawingEdges ? 1.0 : ppty.getAmbient();
879
- var dIntensity = model.drawingEdges ? 0.0 : ppty.getDiffuse();
880
- var sIntensity = model.drawingEdges ? 0.0 : ppty.getSpecular();
881
- var specularPower = ppty.getSpecularPower();
773
+ publicAPI.setPropertyShaderParameters = (cellBO, ren, actor) => {
774
+ const program = cellBO.getProgram();
775
+ let ppty = actor.getProperty();
776
+ let opacity = ppty.getOpacity();
777
+ let aColor = model.drawingEdges ? ppty.getEdgeColorByReference() : ppty.getAmbientColorByReference();
778
+ let dColor = model.drawingEdges ? ppty.getEdgeColorByReference() : ppty.getDiffuseColorByReference();
779
+ let aIntensity = model.drawingEdges ? 1.0 : ppty.getAmbient();
780
+ let dIntensity = model.drawingEdges ? 0.0 : ppty.getDiffuse();
781
+ let sIntensity = model.drawingEdges ? 0.0 : ppty.getSpecular();
782
+ const specularPower = ppty.getSpecularPower();
882
783
  program.setUniformf('opacityUniform', opacity);
883
784
  program.setUniform3fArray('ambientColorUniform', aColor);
884
785
  program.setUniform3fArray('diffuseColorUniform', dColor);
885
786
  program.setUniformf('ambient', aIntensity);
886
- program.setUniformf('diffuse', dIntensity); // we are done unless we have lighting
887
-
888
- var lastLightComplexity = model.lastBoundBO.getReferenceByName('lastLightComplexity');
787
+ program.setUniformf('diffuse', dIntensity);
889
788
 
789
+ // we are done unless we have lighting
790
+ const lastLightComplexity = model.lastBoundBO.getReferenceByName('lastLightComplexity');
890
791
  if (lastLightComplexity < 1) {
891
792
  return;
892
793
  }
893
-
894
- var sColor = ppty.getSpecularColorByReference();
794
+ let sColor = ppty.getSpecularColorByReference();
895
795
  program.setUniform3fArray('specularColorUniform', sColor);
896
796
  program.setUniformf('specularPowerUniform', specularPower);
897
- program.setUniformf('specular', sIntensity); // now set the backface properties if we have them
797
+ program.setUniformf('specular', sIntensity);
898
798
 
799
+ // now set the backface properties if we have them
899
800
  if (program.isUniformUsed('ambientIntensityBF')) {
900
801
  ppty = actor.getBackfaceProperty();
901
802
  opacity = ppty.getOpacity();
@@ -909,91 +810,77 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
909
810
  program.setUniformf('diffuseIntensityBF', dIntensity);
910
811
  program.setUniformf('opacityUniformBF', opacity);
911
812
  program.setUniform3fArray('ambientColorUniformBF', aColor);
912
- program.setUniform3fArray('diffuseColorUniformBF', dColor); // we are done unless we have lighting
813
+ program.setUniform3fArray('diffuseColorUniformBF', dColor);
913
814
 
815
+ // we are done unless we have lighting
914
816
  if (lastLightComplexity < 1) {
915
817
  return;
916
818
  }
917
-
918
819
  program.setUniformf('specularIntensityBF', sIntensity);
919
820
  program.setUniform3fArray('specularColorUniformBF', sColor);
920
821
  program.setUniformf('specularPowerUniformBF', specularPower);
921
822
  }
922
823
  };
923
-
924
- publicAPI.updateMaximumPointCellIds = function (ren, actor) {
925
- var _model$selectionWebGL, _model$selectionWebGL2, _model$selectionWebGL3, _model$selectionWebGL4;
926
-
927
- var selector = model._openGLRenderer.getSelector();
928
-
824
+ publicAPI.updateMaximumPointCellIds = (ren, actor) => {
825
+ const selector = model._openGLRenderer.getSelector();
929
826
  if (!selector) {
930
827
  return;
931
828
  }
932
-
933
- if ((_model$selectionWebGL = model.selectionWebGLIdsToVTKIds) !== null && _model$selectionWebGL !== void 0 && (_model$selectionWebGL2 = _model$selectionWebGL.points) !== null && _model$selectionWebGL2 !== void 0 && _model$selectionWebGL2.length) {
934
- var length = model.selectionWebGLIdsToVTKIds.points.length;
829
+ if (model.selectionWebGLIdsToVTKIds?.points?.length) {
830
+ const length = model.selectionWebGLIdsToVTKIds.points.length;
935
831
  selector.setMaximumPointId(length - 1);
936
832
  }
937
-
938
- if ((_model$selectionWebGL3 = model.selectionWebGLIdsToVTKIds) !== null && _model$selectionWebGL3 !== void 0 && (_model$selectionWebGL4 = _model$selectionWebGL3.cells) !== null && _model$selectionWebGL4 !== void 0 && _model$selectionWebGL4.length) {
939
- var _length = model.selectionWebGLIdsToVTKIds.cells.length;
940
- selector.setMaximumCellId(_length - 1);
833
+ if (model.selectionWebGLIdsToVTKIds?.cells?.length) {
834
+ const length = model.selectionWebGLIdsToVTKIds.cells.length;
835
+ selector.setMaximumCellId(length - 1);
941
836
  }
942
-
943
- var fieldAssociation = selector.getFieldAssociation();
944
-
837
+ const fieldAssociation = selector.getFieldAssociation();
945
838
  if (fieldAssociation === FieldAssociations.FIELD_ASSOCIATION_POINTS) {
946
839
  model.pointPicking = true;
947
840
  }
948
841
  };
949
-
950
- publicAPI.renderPieceStart = function (ren, actor) {
842
+ publicAPI.renderPieceStart = (ren, actor) => {
951
843
  model.primitiveIDOffset = 0;
952
844
  model.vertexIDOffset = 0;
953
- var picking = getPickState(model._openGLRenderer);
954
-
845
+ const picking = getPickState(model._openGLRenderer);
955
846
  if (model.lastSelectionState !== picking) {
956
847
  model.selectionStateChanged.modified();
957
848
  model.lastSelectionState = picking;
958
849
  }
959
-
960
850
  if (model._openGLRenderer.getSelector()) {
961
851
  switch (picking) {
962
852
  default:
963
853
  model._openGLRenderer.getSelector().renderProp(actor);
964
-
965
854
  }
966
- } // make sure the BOs are up to date
855
+ }
967
856
 
857
+ // make sure the BOs are up to date
858
+ publicAPI.updateBufferObjects(ren, actor);
968
859
 
969
- publicAPI.updateBufferObjects(ren, actor); // If we are coloring by texture, then load the texture map.
860
+ // If we are coloring by texture, then load the texture map.
970
861
  // Use Map as indicator, because texture hangs around.
971
-
972
862
  if (model.renderable.getColorTextureMap()) {
973
863
  model.internalColorTexture.activate();
974
- } // Bind the OpenGL, this is shared between the different primitive/cell types.
975
-
864
+ }
976
865
 
866
+ // Bind the OpenGL, this is shared between the different primitive/cell types.
977
867
  model.lastBoundBO = null;
978
868
  };
979
-
980
- publicAPI.renderPieceDraw = function (ren, actor) {
981
- var representation = actor.getProperty().getRepresentation();
982
- var drawSurfaceWithEdges = actor.getProperty().getEdgeVisibility() && representation === Representation.SURFACE;
983
-
984
- var selector = model._openGLRenderer.getSelector(); // If we are picking points, we need to tell it to the helper
985
-
986
-
987
- var pointPicking = selector && selector.getFieldAssociation() === FieldAssociations.FIELD_ASSOCIATION_POINTS && (model.lastSelectionState === PassTypes.ID_LOW24 || model.lastSelectionState === PassTypes.ID_HIGH24); // for every primitive type
988
-
989
- for (var i = primTypes.Start; i < primTypes.End; i++) {
869
+ publicAPI.renderPieceDraw = (ren, actor) => {
870
+ const representation = actor.getProperty().getRepresentation();
871
+ const drawSurfaceWithEdges = actor.getProperty().getEdgeVisibility() && representation === Representation.SURFACE;
872
+ const selector = model._openGLRenderer.getSelector();
873
+ // If we are picking points, we need to tell it to the helper
874
+ const pointPicking = selector && selector.getFieldAssociation() === FieldAssociations.FIELD_ASSOCIATION_POINTS && (model.lastSelectionState === PassTypes.ID_LOW24 || model.lastSelectionState === PassTypes.ID_HIGH24);
875
+
876
+ // for every primitive type
877
+ for (let i = primTypes.Start; i < primTypes.End; i++) {
990
878
  model.primitives[i].setPointPicking(pointPicking);
991
- var cabo = model.primitives[i].getCABO();
992
-
879
+ const cabo = model.primitives[i].getCABO();
993
880
  if (cabo.getElementCount()) {
994
881
  // are we drawing edges
995
- model.drawingEdges = drawSurfaceWithEdges && (i === primTypes.TrisEdges || i === primTypes.TriStripsEdges); // don't draw edges when rendering depth or rendering for picking
996
-
882
+ model.drawingEdges = drawSurfaceWithEdges && (i === primTypes.TrisEdges || i === primTypes.TriStripsEdges);
883
+ // don't draw edges when rendering depth or rendering for picking
997
884
  if (!model.drawingEdges || !(model.renderDepth || model.lastSelectionState >= 0)) {
998
885
  model.lastBoundBO = model.primitives[i];
999
886
  model.primitiveIDOffset += model.primitives[i].drawArrays(ren, actor, representation, publicAPI);
@@ -1002,184 +889,156 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
1002
889
  }
1003
890
  }
1004
891
  };
1005
-
1006
- publicAPI.renderPieceFinish = function (ren, actor) {
892
+ publicAPI.renderPieceFinish = (ren, actor) => {
1007
893
  if (model.LastBoundBO) {
1008
894
  model.LastBoundBO.getVAO().release();
1009
895
  }
1010
-
1011
896
  if (model.renderable.getColorTextureMap()) {
1012
897
  model.internalColorTexture.deactivate();
1013
898
  }
1014
899
  };
1015
-
1016
- publicAPI.renderPiece = function (ren, actor) {
900
+ publicAPI.renderPiece = (ren, actor) => {
1017
901
  // Make sure that we have been properly initialized.
1018
902
  // if (ren.getRenderWindow().checkAbortStatus()) {
1019
903
  // return;
1020
904
  // }
1021
- publicAPI.invokeEvent(StartEvent);
1022
905
 
906
+ publicAPI.invokeEvent(StartEvent);
1023
907
  if (!model.renderable.getStatic()) {
1024
908
  model.renderable.update();
1025
909
  }
1026
-
1027
910
  model.currentInput = model.renderable.getInputData();
1028
911
  publicAPI.invokeEvent(EndEvent);
1029
-
1030
912
  if (!model.currentInput) {
1031
913
  vtkErrorMacro('No input!');
1032
914
  return;
1033
- } // if there are no points then we are done
1034
-
915
+ }
1035
916
 
917
+ // if there are no points then we are done
1036
918
  if (!model.currentInput.getPoints || !model.currentInput.getPoints().getNumberOfValues()) {
1037
919
  return;
1038
- } // apply faceCulling
1039
-
1040
-
1041
- var gl = model.context;
1042
- var backfaceCulling = actor.getProperty().getBackfaceCulling();
1043
- var frontfaceCulling = actor.getProperty().getFrontfaceCulling();
920
+ }
1044
921
 
922
+ // apply faceCulling
923
+ const gl = model.context;
924
+ const backfaceCulling = actor.getProperty().getBackfaceCulling();
925
+ const frontfaceCulling = actor.getProperty().getFrontfaceCulling();
1045
926
  if (!backfaceCulling && !frontfaceCulling) {
1046
927
  model._openGLRenderWindow.disableCullFace();
1047
928
  } else if (frontfaceCulling) {
1048
929
  model._openGLRenderWindow.enableCullFace();
1049
-
1050
930
  gl.cullFace(gl.FRONT);
1051
931
  } else {
1052
932
  model._openGLRenderWindow.enableCullFace();
1053
-
1054
933
  gl.cullFace(gl.BACK);
1055
934
  }
1056
-
1057
935
  publicAPI.renderPieceStart(ren, actor);
1058
936
  publicAPI.renderPieceDraw(ren, actor);
1059
937
  publicAPI.renderPieceFinish(ren, actor);
1060
938
  };
1061
-
1062
- publicAPI.computeBounds = function (ren, actor) {
939
+ publicAPI.computeBounds = (ren, actor) => {
1063
940
  if (!publicAPI.getInput()) {
1064
941
  uninitializeBounds(model.bounds);
1065
942
  return;
1066
943
  }
1067
-
1068
944
  model.bounds = publicAPI.getInput().getBounds();
1069
945
  };
1070
-
1071
- publicAPI.updateBufferObjects = function (ren, actor) {
946
+ publicAPI.updateBufferObjects = (ren, actor) => {
1072
947
  // Rebuild buffers if needed
1073
948
  if (publicAPI.getNeedToRebuildBufferObjects(ren, actor)) {
1074
949
  publicAPI.buildBufferObjects(ren, actor);
1075
950
  }
1076
951
  };
1077
-
1078
- publicAPI.getNeedToRebuildBufferObjects = function (ren, actor) {
952
+ publicAPI.getNeedToRebuildBufferObjects = (ren, actor) => {
1079
953
  // first do a coarse check
1080
954
  // Note that the actor's mtime includes it's properties mtime
1081
- var vmtime = model.VBOBuildTime.getMTime();
1082
-
955
+ const vmtime = model.VBOBuildTime.getMTime();
1083
956
  if (vmtime < publicAPI.getMTime() || vmtime < model.renderable.getMTime() || vmtime < actor.getMTime() || vmtime < model.currentInput.getMTime()) {
1084
957
  return true;
1085
958
  }
1086
-
1087
959
  return false;
1088
960
  };
1089
-
1090
- publicAPI.buildBufferObjects = function (ren, actor) {
1091
- var poly = model.currentInput;
1092
-
961
+ publicAPI.buildBufferObjects = (ren, actor) => {
962
+ const poly = model.currentInput;
1093
963
  if (poly === null) {
1094
964
  return;
1095
965
  }
1096
-
1097
966
  model.renderable.mapScalars(poly, 1.0);
1098
- var c = model.renderable.getColorMapColors();
967
+ const c = model.renderable.getColorMapColors();
1099
968
  model.haveCellScalars = false;
1100
- var scalarMode = model.renderable.getScalarMode();
1101
-
969
+ const scalarMode = model.renderable.getScalarMode();
1102
970
  if (model.renderable.getScalarVisibility()) {
1103
971
  // We must figure out how the scalars should be mapped to the polydata.
1104
972
  if ((scalarMode === ScalarMode.USE_CELL_DATA || scalarMode === ScalarMode.USE_CELL_FIELD_DATA || scalarMode === ScalarMode.USE_FIELD_DATA || !poly.getPointData().getScalars()) && scalarMode !== ScalarMode.USE_POINT_FIELD_DATA && c) {
1105
973
  model.haveCellScalars = true;
1106
974
  }
1107
- } // Do we have normals?
1108
-
1109
-
1110
- var n = actor.getProperty().getInterpolation() !== Shading.FLAT ? poly.getPointData().getNormals() : null;
975
+ }
1111
976
 
977
+ // Do we have normals?
978
+ let n = actor.getProperty().getInterpolation() !== Shading.FLAT ? poly.getPointData().getNormals() : null;
1112
979
  if (n === null && poly.getCellData().getNormals()) {
1113
980
  model.haveCellNormals = true;
1114
981
  n = poly.getCellData().getNormals();
1115
- } // rebuild the VBO if the data has changed we create a string for the VBO what
982
+ }
983
+
984
+ // rebuild the VBO if the data has changed we create a string for the VBO what
1116
985
  // can change the VBO? points normals tcoords colors so what can change those?
1117
986
  // the input data is clearly one as it can change all four items tcoords may
1118
987
  // haveTextures or not colors may change based on quite a few mapping
1119
988
  // parameters in the mapper
1120
989
 
1121
-
1122
- var representation = actor.getProperty().getRepresentation();
1123
- var tcoords = poly.getPointData().getTCoords();
1124
-
990
+ const representation = actor.getProperty().getRepresentation();
991
+ let tcoords = poly.getPointData().getTCoords();
1125
992
  if (!model.openGLActor.getActiveTextures()) {
1126
993
  tcoords = null;
1127
- } // handle color mapping via texture
1128
-
994
+ }
1129
995
 
996
+ // handle color mapping via texture
1130
997
  if (model.renderable.getColorCoordinates()) {
1131
998
  tcoords = model.renderable.getColorCoordinates();
1132
-
1133
999
  if (!model.internalColorTexture) {
1134
1000
  model.internalColorTexture = vtkOpenGLTexture.newInstance({
1135
1001
  resizable: true
1136
1002
  });
1137
1003
  }
1138
-
1139
- var tex = model.internalColorTexture; // the following 4 lines allow for NPOT textures
1140
-
1004
+ const tex = model.internalColorTexture;
1005
+ // the following 4 lines allow for NPOT textures
1141
1006
  tex.setMinificationFilter(Filter.NEAREST);
1142
1007
  tex.setMagnificationFilter(Filter.NEAREST);
1143
1008
  tex.setWrapS(Wrap.CLAMP_TO_EDGE);
1144
1009
  tex.setWrapT(Wrap.CLAMP_TO_EDGE);
1145
1010
  tex.setOpenGLRenderWindow(model._openGLRenderWindow);
1146
- var input = model.renderable.getColorTextureMap();
1147
- var ext = input.getExtent();
1148
- var inScalars = input.getPointData().getScalars();
1011
+ const input = model.renderable.getColorTextureMap();
1012
+ const ext = input.getExtent();
1013
+ const inScalars = input.getPointData().getScalars();
1149
1014
  tex.create2DFromRaw(ext[1] - ext[0] + 1, ext[3] - ext[2] + 1, inScalars.getNumberOfComponents(), inScalars.getDataType(), inScalars.getData());
1150
1015
  tex.activate();
1151
1016
  tex.sendParameters();
1152
1017
  tex.deactivate();
1153
1018
  }
1154
-
1155
- var toString = "".concat(poly.getMTime(), "A").concat(representation, "B").concat(poly.getMTime()) + "C".concat(n ? n.getMTime() : 1, "D").concat(c ? c.getMTime() : 1) + "E".concat(actor.getProperty().getEdgeVisibility()) + "F".concat(tcoords ? tcoords.getMTime() : 1);
1156
-
1019
+ const toString = `${poly.getMTime()}A${representation}B${poly.getMTime()}` + `C${n ? n.getMTime() : 1}D${c ? c.getMTime() : 1}` + `E${actor.getProperty().getEdgeVisibility()}` + `F${tcoords ? tcoords.getMTime() : 1}`;
1157
1020
  if (model.VBOBuildString !== toString) {
1158
1021
  // Build the VBOs
1159
- var points = poly.getPoints();
1160
- var options = {
1161
- points: points,
1022
+ const points = poly.getPoints();
1023
+ const options = {
1024
+ points,
1162
1025
  normals: n,
1163
- tcoords: tcoords,
1026
+ tcoords,
1164
1027
  colors: c,
1165
1028
  cellOffset: 0,
1166
1029
  vertexOffset: 0,
1167
1030
  // Used to keep track of vertex ids across primitives for selection
1168
1031
  haveCellScalars: model.haveCellScalars,
1169
1032
  haveCellNormals: model.haveCellNormals,
1170
- customAttributes: model.renderable.getCustomShaderAttributes().map(function (arrayName) {
1171
- return poly.getPointData().getArrayByName(arrayName);
1172
- })
1033
+ customAttributes: model.renderable.getCustomShaderAttributes().map(arrayName => poly.getPointData().getArrayByName(arrayName))
1173
1034
  };
1174
-
1175
1035
  if (model.renderable.getPopulateSelectionSettings()) {
1176
1036
  model.selectionWebGLIdsToVTKIds = {
1177
1037
  points: null,
1178
1038
  cells: null
1179
1039
  };
1180
1040
  }
1181
-
1182
- var primitives = [{
1041
+ const primitives = [{
1183
1042
  inRep: 'verts',
1184
1043
  cells: poly.getVerts()
1185
1044
  }, {
@@ -1198,9 +1057,8 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
1198
1057
  inRep: 'strips',
1199
1058
  cells: poly.getStrips()
1200
1059
  }];
1201
- var drawSurfaceWithEdges = actor.getProperty().getEdgeVisibility() && representation === Representation.SURFACE;
1202
-
1203
- for (var i = primTypes.Start; i < primTypes.End; i++) {
1060
+ const drawSurfaceWithEdges = actor.getProperty().getEdgeVisibility() && representation === Representation.SURFACE;
1061
+ for (let i = primTypes.Start; i < primTypes.End; i++) {
1204
1062
  if (i !== primTypes.TrisEdges && i !== primTypes.TriStripsEdges) {
1205
1063
  options.cellOffset += model.primitives[i].getCABO().createVBO(primitives[i].cells, primitives[i].inRep, representation, options, model.selectionWebGLIdsToVTKIds);
1206
1064
  options.vertexOffset += model.primitives[i].getCABO().getElementCount();
@@ -1210,34 +1068,34 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
1210
1068
  // VBOs for edges in "surface with edges" are the last to be built,
1211
1069
  // they are not used when picking with a hardware selector so they
1212
1070
  // don't need selectionWebGLIdsToVTKIds and don't update cellOffset and vertexOffset
1213
- model.primitives[i].getCABO().createVBO(primitives[i].cells, primitives[i].inRep, Representation.WIREFRAME, _objectSpread(_objectSpread({}, options), {}, {
1071
+ model.primitives[i].getCABO().createVBO(primitives[i].cells, primitives[i].inRep, Representation.WIREFRAME, {
1072
+ ...options,
1214
1073
  tcoords: null,
1215
1074
  colors: null,
1216
1075
  haveCellScalars: false,
1217
1076
  haveCellNormals: false
1218
- }));
1077
+ });
1219
1078
  } else {
1220
1079
  // otherwise free them
1221
1080
  model.primitives[i].releaseGraphicsResources();
1222
1081
  }
1223
1082
  }
1224
1083
  }
1225
-
1226
1084
  if (model.renderable.getPopulateSelectionSettings()) {
1227
1085
  model.renderable.setSelectionWebGLIdsToVTKIds(model.selectionWebGLIdsToVTKIds);
1228
1086
  publicAPI.updateMaximumPointCellIds();
1229
1087
  }
1230
-
1231
1088
  model.VBOBuildTime.modified();
1232
1089
  model.VBOBuildString = toString;
1233
1090
  }
1234
1091
  };
1235
- } // ----------------------------------------------------------------------------
1092
+ }
1093
+
1094
+ // ----------------------------------------------------------------------------
1236
1095
  // Object factory
1237
1096
  // ----------------------------------------------------------------------------
1238
1097
 
1239
-
1240
- var DEFAULT_VALUES = {
1098
+ const DEFAULT_VALUES = {
1241
1099
  context: null,
1242
1100
  VBOBuildTime: 0,
1243
1101
  VBOBuildString: null,
@@ -1261,12 +1119,15 @@ var DEFAULT_VALUES = {
1261
1119
  selectionStateChanged: null,
1262
1120
  selectionWebGLIdsToVTKIds: null,
1263
1121
  pointPicking: false
1264
- }; // ----------------------------------------------------------------------------
1122
+ };
1123
+
1124
+ // ----------------------------------------------------------------------------
1265
1125
 
1266
1126
  function extend(publicAPI, model) {
1267
- var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1268
- Object.assign(model, DEFAULT_VALUES, initialValues); // Inheritance
1127
+ let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1128
+ Object.assign(model, DEFAULT_VALUES, initialValues);
1269
1129
 
1130
+ // Inheritance
1270
1131
  vtkViewNode.extend(publicAPI, model, initialValues);
1271
1132
  vtkReplacementShaderMapper.implementReplaceShaderCoincidentOffset(publicAPI, model, initialValues);
1272
1133
  vtkReplacementShaderMapper.implementBuildShadersWithReplacements(publicAPI, model, initialValues);
@@ -1274,8 +1135,7 @@ function extend(publicAPI, model) {
1274
1135
  model.primTypes = primTypes;
1275
1136
  model.tmpMat3 = mat3.identity(new Float64Array(9));
1276
1137
  model.tmpMat4 = mat4.identity(new Float64Array(16));
1277
-
1278
- for (var i = primTypes.Start; i < primTypes.End; i++) {
1138
+ for (let i = primTypes.Start; i < primTypes.End; i++) {
1279
1139
  model.primitives[i] = vtkHelper.newInstance();
1280
1140
  model.primitives[i].setPrimitiveType(i);
1281
1141
  model.primitives[i].set({
@@ -1283,9 +1143,9 @@ function extend(publicAPI, model) {
1283
1143
  lastLightCount: 0,
1284
1144
  lastSelectionPass: false
1285
1145
  }, true);
1286
- } // Build VTK API
1287
-
1146
+ }
1288
1147
 
1148
+ // Build VTK API
1289
1149
  setGet(publicAPI, model, ['context']);
1290
1150
  model.VBOBuildTime = {};
1291
1151
  obj(model.VBOBuildTime, {
@@ -1294,18 +1154,24 @@ function extend(publicAPI, model) {
1294
1154
  model.selectionStateChanged = {};
1295
1155
  obj(model.selectionStateChanged, {
1296
1156
  mtime: 0
1297
- }); // Object methods
1157
+ });
1298
1158
 
1159
+ // Object methods
1299
1160
  vtkOpenGLPolyDataMapper(publicAPI, model);
1300
- } // ----------------------------------------------------------------------------
1161
+ }
1162
+
1163
+ // ----------------------------------------------------------------------------
1164
+
1165
+ const newInstance = newInstance$1(extend, 'vtkOpenGLPolyDataMapper');
1301
1166
 
1302
- var newInstance = newInstance$1(extend, 'vtkOpenGLPolyDataMapper'); // ----------------------------------------------------------------------------
1167
+ // ----------------------------------------------------------------------------
1303
1168
 
1304
1169
  var vtkOpenGLPolyDataMapper$1 = {
1305
- newInstance: newInstance,
1306
- extend: extend
1307
- }; // Register ourself to OpenGL backend if imported
1170
+ newInstance,
1171
+ extend
1172
+ };
1308
1173
 
1174
+ // Register ourself to OpenGL backend if imported
1309
1175
  registerOverride('vtkMapper', newInstance);
1310
1176
 
1311
1177
  export { vtkOpenGLPolyDataMapper$1 as default, extend, newInstance };