@kitware/vtk.js 28.10.1 → 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.
- package/Common/Core/Base64.js +53 -82
- package/Common/Core/CellArray.js +52 -60
- package/Common/Core/ClassHierarchy.js +8 -36
- package/Common/Core/DataArray/Constants.js +6 -6
- package/Common/Core/DataArray.js +185 -270
- package/Common/Core/Endian.js +14 -17
- package/Common/Core/HalfFloat.js +17 -34
- package/Common/Core/ImageHelper.js +17 -25
- package/Common/Core/LookupTable.js +131 -144
- package/Common/Core/Math/Constants.js +8 -8
- package/Common/Core/Math/index.js +778 -903
- package/Common/Core/Math.d.ts +14 -0
- package/Common/Core/Math.js +2 -4
- package/Common/Core/MatrixBuilder.js +99 -151
- package/Common/Core/Points.js +43 -43
- package/Common/Core/PriorityQueue.js +30 -28
- package/Common/Core/ProgressHandler.js +31 -32
- package/Common/Core/ScalarsToColors/Constants.js +4 -4
- package/Common/Core/ScalarsToColors.js +196 -253
- package/Common/Core/StringArray.js +48 -73
- package/Common/Core/URLExtract.js +10 -29
- package/Common/Core/VariantArray.js +48 -73
- package/Common/Core.js +11 -11
- package/Common/DataModel/AbstractPointLocator.js +19 -17
- package/Common/DataModel/BoundingBox.js +322 -490
- package/Common/DataModel/Box.js +46 -63
- package/Common/DataModel/CardinalSpline1D.js +92 -102
- package/Common/DataModel/Cell.js +41 -61
- package/Common/DataModel/CellLinks.js +91 -127
- package/Common/DataModel/CellTypes/Constants.js +7 -6
- package/Common/DataModel/CellTypes.js +55 -74
- package/Common/DataModel/Collection.js +45 -61
- package/Common/DataModel/Cone.js +28 -20
- package/Common/DataModel/Cylinder.js +41 -35
- package/Common/DataModel/DataSet/Constants.js +11 -5
- package/Common/DataModel/DataSet.js +37 -25
- package/Common/DataModel/DataSetAttributes/Constants.js +18 -18
- package/Common/DataModel/DataSetAttributes/FieldData.js +103 -194
- package/Common/DataModel/DataSetAttributes.js +96 -138
- package/Common/DataModel/EdgeLocator.js +45 -70
- package/Common/DataModel/ITKHelper.js +67 -137
- package/Common/DataModel/ImageData.js +115 -172
- package/Common/DataModel/ImplicitBoolean/Constants.js +2 -2
- package/Common/DataModel/ImplicitBoolean.js +66 -96
- package/Common/DataModel/IncrementalOctreeNode.js +201 -231
- package/Common/DataModel/IncrementalOctreePointLocator.js +160 -198
- package/Common/DataModel/KochanekSpline1D.js +78 -81
- package/Common/DataModel/Line/Constants.js +2 -2
- package/Common/DataModel/Line.js +82 -105
- package/Common/DataModel/Locator.js +17 -10
- package/Common/DataModel/Molecule.js +26 -17
- package/Common/DataModel/PiecewiseFunction.js +218 -239
- package/Common/DataModel/Plane.js +90 -113
- package/Common/DataModel/PointSet.js +30 -26
- package/Common/DataModel/PolyData/Constants.js +2 -2
- package/Common/DataModel/PolyData.js +95 -120
- package/Common/DataModel/PolyLine.js +44 -61
- package/Common/DataModel/Polygon/Constants.js +4 -4
- package/Common/DataModel/Polygon.js +128 -169
- package/Common/DataModel/Quad/Constants.js +2 -2
- package/Common/DataModel/Quad.js +61 -100
- package/Common/DataModel/SelectionNode/Constants.js +5 -4
- package/Common/DataModel/SelectionNode.js +25 -21
- package/Common/DataModel/Sphere.js +40 -35
- package/Common/DataModel/Spline1D/Constants.js +3 -2
- package/Common/DataModel/Spline1D.js +34 -18
- package/Common/DataModel/Spline3D/Constants.js +2 -2
- package/Common/DataModel/Spline3D.js +46 -41
- package/Common/DataModel/StructuredData/Constants.js +2 -2
- package/Common/DataModel/StructuredData.js +9 -20
- package/Common/DataModel/Triangle.js +207 -250
- package/Common/DataModel.js +19 -19
- package/Common/System/MobileVR.js +56 -61
- package/Common/System/TimerLog.js +1 -1
- package/Common/System.js +2 -2
- package/Common/Transform/LandmarkTransform/Constants.js +2 -2
- package/Common/Transform/LandmarkTransform.js +133 -117
- package/Common/Transform/Transform.js +42 -57
- package/Common/Transform.js +2 -2
- package/Common/index.js +4 -4
- package/Filters/Core/Cutter.js +134 -146
- package/Filters/Core/PolyDataNormals.js +44 -50
- package/Filters/Core.js +2 -2
- package/Filters/Cornerstone/ImageDataToCornerstoneImage.js +45 -33
- package/Filters/Cornerstone.js +1 -1
- package/Filters/General/AppendPolyData.js +84 -100
- package/Filters/General/Calculator.js +95 -163
- package/Filters/General/ClipClosedSurface/Constants.js +2 -2
- package/Filters/General/ClipClosedSurface.js +341 -416
- package/Filters/General/ClosedPolyLineToSurfaceFilter.js +141 -156
- package/Filters/General/ContourTriangulator/Constants.js +2 -2
- package/Filters/General/ContourTriangulator/helper.js +684 -812
- package/Filters/General/ContourTriangulator.js +92 -89
- package/Filters/General/ImageCropFilter.js +77 -78
- package/Filters/General/ImageDataOutlineFilter.js +42 -36
- package/Filters/General/ImageMarchingCubes/caseTable.js +9 -521
- package/Filters/General/ImageMarchingCubes.js +99 -112
- package/Filters/General/ImageMarchingSquares/caseTable.js +9 -41
- package/Filters/General/ImageMarchingSquares.js +93 -118
- package/Filters/General/ImageOutlineFilter.js +53 -54
- package/Filters/General/ImageSliceFilter.js +39 -30
- package/Filters/General/ImageStreamline.js +107 -124
- package/Filters/General/LineFilter.js +26 -15
- package/Filters/General/MoleculeToRepresentation.js +136 -149
- package/Filters/General/OBBTree/OBBNode.js +36 -34
- package/Filters/General/OBBTree/helper.js +19 -24
- package/Filters/General/OBBTree.js +396 -488
- package/Filters/General/OutlineFilter.js +52 -34
- package/Filters/General/PaintFilter/PaintFilter.worker.js +93 -130
- package/Filters/General/PaintFilter.js +150 -162
- package/Filters/General/ScalarToRGBA.js +38 -33
- package/Filters/General/TriangleFilter.js +65 -62
- package/Filters/General/TubeFilter/Constants.js +4 -4
- package/Filters/General/TubeFilter.js +376 -496
- package/Filters/General/WarpScalar.js +58 -60
- package/Filters/General/WindowedSincPolyDataFilter.js +258 -330
- package/Filters/General.js +21 -21
- package/Filters/Sources/Arrow2DSource/Constants.js +2 -2
- package/Filters/Sources/Arrow2DSource.js +56 -56
- package/Filters/Sources/ArrowSource.js +39 -29
- package/Filters/Sources/CircleSource.js +43 -43
- package/Filters/Sources/ConcentricCylinderSource.js +151 -174
- package/Filters/Sources/ConeSource.js +51 -42
- package/Filters/Sources/CubeSource.js +75 -96
- package/Filters/Sources/Cursor3D.js +94 -109
- package/Filters/Sources/CylinderSource.js +90 -90
- package/Filters/Sources/ImageGridSource.js +43 -43
- package/Filters/Sources/LineSource.js +49 -39
- package/Filters/Sources/PlaneSource.js +97 -104
- package/Filters/Sources/PointSource.js +46 -37
- package/Filters/Sources/RTAnalyticSource.js +50 -48
- package/Filters/Sources/SLICSource.js +63 -73
- package/Filters/Sources/SphereSource.js +88 -78
- package/Filters/Sources/ViewFinderSource.js +26 -23
- package/Filters/Sources.js +14 -14
- package/Filters/Texture/TextureMapToPlane.js +95 -97
- package/Filters/Texture/TextureMapToSphere.js +46 -54
- package/Filters/Texture.js +2 -2
- package/Filters/index.js +5 -5
- package/IO/Core/BinaryHelper.js +12 -18
- package/IO/Core/DataAccessHelper/HtmlDataAccessHelper.js +43 -59
- package/IO/Core/DataAccessHelper/HttpDataAccessHelper.js +76 -113
- package/IO/Core/DataAccessHelper/JSZipDataAccessHelper.js +62 -112
- package/IO/Core/DataAccessHelper/LiteHttpDataAccessHelper.js +76 -113
- package/IO/Core/DataAccessHelper.js +6 -6
- package/IO/Core/HttpDataSetReader.js +136 -139
- package/IO/Core/HttpDataSetSeriesReader.js +64 -75
- package/IO/Core/HttpSceneLoader.js +130 -179
- package/IO/Core/ImageStream/DefaultProtocol.js +29 -43
- package/IO/Core/ImageStream/ViewStream.js +100 -103
- package/IO/Core/ImageStream.js +62 -54
- package/IO/Core/ResourceLoader.js +10 -9
- package/IO/Core/Serializer/ArraySerializer.js +40 -40
- package/IO/Core/Serializer/FieldDataSerializer.js +18 -28
- package/IO/Core/Serializer/ImageDataSerializer.js +22 -23
- package/IO/Core/Serializer/PolyDataSerializer.js +17 -21
- package/IO/Core/Serializer.js +6 -13
- package/IO/Core/WSLinkClient.js +90 -76
- package/IO/Core/ZipMultiDataSetReader.js +46 -44
- package/IO/Core/ZipMultiDataSetWriter.js +43 -34
- package/IO/Core.js +7 -7
- package/IO/Geometry/DracoReader.js +118 -121
- package/IO/Geometry/PLYReader.js +163 -223
- package/IO/Geometry/PLYWriter/Constants.js +5 -5
- package/IO/Geometry/PLYWriter.js +139 -154
- package/IO/Geometry/STLReader.js +123 -146
- package/IO/Geometry/STLWriter/Constants.js +2 -2
- package/IO/Geometry/STLWriter.js +83 -82
- package/IO/Geometry.js +5 -5
- package/IO/Legacy/LegacyAsciiParser.js +78 -139
- package/IO/Legacy/PolyDataReader.js +48 -36
- package/IO/Legacy.js +2 -2
- package/IO/Misc/ElevationReader.js +67 -60
- package/IO/Misc/HttpDataSetLODsLoader.js +41 -38
- package/IO/Misc/ITKImageReader.js +58 -45
- package/IO/Misc/ITKPolyDataReader.js +50 -38
- package/IO/Misc/JSONNucleoReader.js +49 -42
- package/IO/Misc/JSONReader.js +38 -33
- package/IO/Misc/MTLReader.js +74 -119
- package/IO/Misc/OBJReader.js +153 -206
- package/IO/Misc/PDBReader.js +70 -68
- package/IO/Misc/SkyboxReader.js +77 -82
- package/IO/Misc.js +9 -9
- package/IO/XML/XMLImageDataReader.js +36 -38
- package/IO/XML/XMLImageDataWriter.js +28 -21
- package/IO/XML/XMLPolyDataReader.js +49 -46
- package/IO/XML/XMLPolyDataWriter.js +43 -42
- package/IO/XML/XMLReader.js +262 -304
- package/IO/XML/XMLWriter/Constants.js +3 -3
- package/IO/XML/XMLWriter.js +70 -84
- package/IO/XML.js +6 -6
- package/IO/index.js +5 -5
- package/Imaging/Core/AbstractImageInterpolator/Constants.js +4 -4
- package/Imaging/Core/AbstractImageInterpolator/InterpolationInfo.js +30 -27
- package/Imaging/Core/AbstractImageInterpolator.js +74 -87
- package/Imaging/Core/ImageInterpolator.js +201 -252
- package/Imaging/Core/ImagePointDataIterator.js +96 -122
- package/Imaging/Core/ImageReslice/Constants.js +2 -2
- package/Imaging/Core/ImageReslice.js +327 -464
- package/Imaging/Core.js +4 -4
- package/Imaging/Hybrid/SampleFunction.js +58 -51
- package/Imaging/Hybrid.js +1 -1
- package/Imaging/index.js +2 -2
- package/Interaction/Animations/TimeStepBasedAnimationHandler.js +39 -54
- package/Interaction/Manipulators/CompositeCameraManipulator.js +22 -13
- package/Interaction/Manipulators/CompositeGestureManipulator.js +31 -43
- package/Interaction/Manipulators/CompositeKeyboardManipulator.js +15 -11
- package/Interaction/Manipulators/CompositeMouseManipulator.js +27 -33
- package/Interaction/Manipulators/CompositeVRManipulator.js +22 -15
- package/Interaction/Manipulators/GestureCameraManipulator.js +54 -36
- package/Interaction/Manipulators/KeyboardCameraManipulator.js +95 -97
- package/Interaction/Manipulators/MouseBoxSelectorManipulator.js +70 -89
- package/Interaction/Manipulators/MouseCameraAxisRotateManipulator.js +67 -54
- package/Interaction/Manipulators/MouseCameraSliceManipulator.js +40 -38
- package/Interaction/Manipulators/MouseCameraTrackballFirstPersonManipulator.js +83 -68
- package/Interaction/Manipulators/MouseCameraTrackballMultiRotateManipulator.js +32 -28
- package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.js +47 -40
- package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +55 -43
- package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +56 -46
- package/Interaction/Manipulators/MouseCameraTrackballZoomManipulator.js +41 -46
- package/Interaction/Manipulators/MouseCameraTrackballZoomToMouseManipulator.js +29 -27
- package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +123 -146
- package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +144 -166
- package/Interaction/Manipulators/MouseRangeManipulator.js +127 -132
- package/Interaction/Manipulators/VRButtonPanManipulator.js +33 -23
- package/Interaction/Manipulators.js +21 -21
- package/Interaction/Misc/DeviceOrientationToCamera.js +25 -47
- package/Interaction/Misc.js +1 -1
- package/Interaction/Style/InteractorStyleImage.js +101 -121
- package/Interaction/Style/InteractorStyleMPRSlice.js +111 -128
- package/Interaction/Style/InteractorStyleManipulator/Presets.js +9 -17
- package/Interaction/Style/InteractorStyleManipulator.js +254 -329
- package/Interaction/Style/InteractorStyleRemoteMouse.js +195 -180
- package/Interaction/Style/InteractorStyleTrackballCamera.js +154 -157
- package/Interaction/Style/InteractorStyleUnicam.js +30 -38
- package/Interaction/Style.js +5 -5
- package/Interaction/UI/CornerAnnotation/CornerAnnotation.module.css.js +1 -1
- package/Interaction/UI/CornerAnnotation.js +65 -48
- package/Interaction/UI/FPSMonitor.js +104 -105
- package/Interaction/UI/Icons.js +1 -1
- package/Interaction/UI/Slider/Constants.js +2 -2
- package/Interaction/UI/Slider.js +78 -95
- package/Interaction/UI/VolumeController.js +104 -97
- package/Interaction/UI.js +5 -5
- package/Interaction/Widgets/OrientationMarkerWidget/Constants.js +2 -2
- package/Interaction/Widgets/OrientationMarkerWidget.js +90 -135
- package/Interaction/Widgets/PiecewiseGaussianWidget/ComputeHistogram.worker.js +0 -3
- package/Interaction/Widgets/PiecewiseGaussianWidget.js +381 -498
- package/Interaction/Widgets.js +2 -2
- package/Interaction/index.js +5 -5
- package/Proxy/Animation/AbstractAnimationProxy.js +22 -15
- package/Proxy/Animation/AnimationProxyManager.js +43 -51
- package/Proxy/Animation/TimeStepBasedAnimationHandlerProxy.js +26 -19
- package/Proxy/Core/AbstractRepresentationProxy.js +97 -151
- package/Proxy/Core/LookupTableProxy/Constants.js +4 -4
- package/Proxy/Core/LookupTableProxy.js +49 -52
- package/Proxy/Core/PiecewiseFunctionProxy/Constants.js +4 -4
- package/Proxy/Core/PiecewiseFunctionProxy.js +63 -72
- package/Proxy/Core/ProxyManager/core.js +83 -106
- package/Proxy/Core/ProxyManager/properties.js +53 -76
- package/Proxy/Core/ProxyManager/state.js +100 -110
- package/Proxy/Core/ProxyManager/view.js +45 -55
- package/Proxy/Core/ProxyManager.js +16 -8
- package/Proxy/Core/SourceProxy.js +41 -38
- package/Proxy/Core/View2DProxy.js +143 -199
- package/Proxy/Core/ViewProxy.js +223 -269
- package/Proxy/Core.js +7 -7
- package/Proxy/Representations/GeometryRepresentationProxy.js +34 -20
- package/Proxy/Representations/GlyphRepresentationProxy.js +42 -41
- package/Proxy/Representations/MoleculeRepresentationProxy.js +32 -22
- package/Proxy/Representations/ResliceRepresentationProxy.js +48 -32
- package/Proxy/Representations/SkyboxRepresentationProxy.js +30 -29
- package/Proxy/Representations/SliceRepresentationProxy.js +93 -112
- package/Proxy/Representations/SlicedGeometryRepresentationProxy.js +46 -42
- package/Proxy/Representations/VolumeRepresentationProxy.js +108 -133
- package/Proxy/Representations.js +7 -7
- package/Proxy/index.js +2 -2
- package/Rendering/Core/AbstractImageMapper/helper.js +44 -49
- package/Rendering/Core/AbstractImageMapper.js +18 -19
- package/Rendering/Core/AbstractMapper.js +39 -55
- package/Rendering/Core/AbstractMapper3D.js +26 -31
- package/Rendering/Core/AbstractPicker.js +25 -21
- package/Rendering/Core/Actor.js +71 -93
- package/Rendering/Core/Actor2D.js +64 -78
- package/Rendering/Core/AnnotatedCubeActor/Presets.js +5 -11
- package/Rendering/Core/AnnotatedCubeActor.js +94 -79
- package/Rendering/Core/AxesActor.js +65 -87
- package/Rendering/Core/Camera.js +246 -271
- package/Rendering/Core/CellPicker.js +125 -148
- package/Rendering/Core/ColorTransferFunction/ColorMaps.js +20 -21
- package/Rendering/Core/ColorTransferFunction/ColorMapsLite.js +20 -21
- package/Rendering/Core/ColorTransferFunction/Constants.js +4 -4
- package/Rendering/Core/ColorTransferFunction.js +460 -546
- package/Rendering/Core/Coordinate/Constants.js +2 -2
- package/Rendering/Core/Coordinate.js +119 -198
- package/Rendering/Core/CubeAxesActor.js +294 -320
- package/Rendering/Core/Follower.js +46 -45
- package/Rendering/Core/Glyph3DMapper/Constants.js +4 -4
- package/Rendering/Core/Glyph3DMapper.js +96 -148
- package/Rendering/Core/HardwareSelector.js +36 -69
- package/Rendering/Core/ImageArrayMapper.js +87 -126
- package/Rendering/Core/ImageCPRMapper.js +134 -209
- package/Rendering/Core/ImageMapper/Constants.js +2 -2
- package/Rendering/Core/ImageMapper.js +92 -170
- package/Rendering/Core/ImageProperty/Constants.js +2 -2
- package/Rendering/Core/ImageProperty.js +66 -81
- package/Rendering/Core/ImageResliceMapper/Constants.js +2 -2
- package/Rendering/Core/ImageResliceMapper.js +36 -29
- package/Rendering/Core/ImageSlice.js +85 -127
- package/Rendering/Core/InteractorObserver.js +82 -73
- package/Rendering/Core/InteractorStyle/Constants.js +2 -2
- package/Rendering/Core/InteractorStyle.js +56 -58
- package/Rendering/Core/Light.js +43 -49
- package/Rendering/Core/Mapper/CoincidentTopologyHelper.js +37 -48
- package/Rendering/Core/Mapper/Constants.js +6 -6
- package/Rendering/Core/Mapper/Static.js +15 -12
- package/Rendering/Core/Mapper.js +194 -259
- package/Rendering/Core/Mapper2D.js +61 -100
- package/Rendering/Core/Picker.js +124 -143
- package/Rendering/Core/PixelSpaceCallbackMapper.js +40 -37
- package/Rendering/Core/PointPicker.js +68 -79
- package/Rendering/Core/Prop/Constants.js +2 -2
- package/Rendering/Core/Prop.js +58 -106
- package/Rendering/Core/Prop3D.js +54 -83
- package/Rendering/Core/Property/Constants.js +6 -6
- package/Rendering/Core/Property.js +45 -74
- package/Rendering/Core/Property2D/Constants.js +2 -2
- package/Rendering/Core/Property2D.js +33 -42
- package/Rendering/Core/RenderWindow.js +70 -82
- package/Rendering/Core/RenderWindowInteractor/Constants.js +7 -7
- package/Rendering/Core/RenderWindowInteractor.js +324 -439
- package/Rendering/Core/Renderer.js +193 -257
- package/Rendering/Core/ScalarBarActor.js +267 -272
- package/Rendering/Core/Skybox.js +26 -24
- package/Rendering/Core/SphereMapper.js +22 -12
- package/Rendering/Core/StickMapper.js +22 -12
- package/Rendering/Core/SurfaceLICInterface/Constants.js +6 -6
- package/Rendering/Core/SurfaceLICInterface.js +13 -9
- package/Rendering/Core/SurfaceLICMapper.js +23 -15
- package/Rendering/Core/Texture.js +99 -141
- package/Rendering/Core/Viewport.js +60 -88
- package/Rendering/Core/Volume.js +55 -77
- package/Rendering/Core/VolumeMapper/Constants.js +4 -4
- package/Rendering/Core/VolumeMapper.js +59 -91
- package/Rendering/Core/VolumeProperty/Constants.js +4 -4
- package/Rendering/Core/VolumeProperty.js +78 -115
- package/Rendering/Core.js +47 -49
- package/Rendering/Misc/CanvasView.js +62 -61
- package/Rendering/Misc/FullScreenRenderWindow.js +60 -62
- package/Rendering/Misc/GenericRenderWindow.js +48 -37
- package/Rendering/Misc/RemoteView.js +86 -80
- package/Rendering/Misc/RenderWindowWithControlBar.js +54 -48
- package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager/CameraSynchronizer.js +43 -51
- package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager.js +52 -82
- package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.js +258 -308
- package/Rendering/Misc/SynchronizableRenderWindow.js +133 -163
- package/Rendering/Misc/TextureLODsDownloader.js +72 -74
- package/Rendering/Misc.js +7 -7
- package/Rendering/OpenGL/Actor.js +57 -68
- package/Rendering/OpenGL/Actor2D.js +56 -56
- package/Rendering/OpenGL/BufferObject/Constants.js +2 -2
- package/Rendering/OpenGL/BufferObject.js +50 -65
- package/Rendering/OpenGL/Camera.js +35 -29
- package/Rendering/OpenGL/CellArrayBufferObject.js +119 -149
- package/Rendering/OpenGL/Convolution2DPass.js +87 -81
- package/Rendering/OpenGL/CubeAxesActor.js +28 -21
- package/Rendering/OpenGL/ForwardPass.js +53 -64
- package/Rendering/OpenGL/Framebuffer.js +61 -101
- package/Rendering/OpenGL/Glyph3DMapper.js +165 -196
- package/Rendering/OpenGL/HardwareSelector/Constants.js +2 -2
- package/Rendering/OpenGL/HardwareSelector.js +272 -397
- package/Rendering/OpenGL/Helper.js +58 -73
- package/Rendering/OpenGL/ImageCPRMapper.js +339 -421
- package/Rendering/OpenGL/ImageMapper.js +268 -361
- package/Rendering/OpenGL/ImageResliceMapper.js +306 -438
- package/Rendering/OpenGL/ImageSlice.js +48 -54
- package/Rendering/OpenGL/OrderIndependentTranslucentPass.js +102 -84
- package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +43 -42
- package/Rendering/OpenGL/PolyDataMapper.js +358 -492
- package/Rendering/OpenGL/PolyDataMapper2D.js +153 -205
- package/Rendering/OpenGL/RadialDistortionPass.js +86 -89
- package/Rendering/OpenGL/RenderWindow/Constants.js +2 -2
- package/Rendering/OpenGL/RenderWindow/ContextProxy.js +20 -29
- package/Rendering/OpenGL/RenderWindow.js +356 -510
- package/Rendering/OpenGL/Renderer.js +77 -89
- package/Rendering/OpenGL/ReplacementShaderMapper.js +28 -46
- package/Rendering/OpenGL/ScalarBarActor.js +28 -21
- package/Rendering/OpenGL/Shader.js +37 -31
- package/Rendering/OpenGL/ShaderCache.js +67 -74
- package/Rendering/OpenGL/ShaderProgram.js +136 -248
- package/Rendering/OpenGL/Skybox.js +99 -60
- package/Rendering/OpenGL/SphereMapper.js +94 -108
- package/Rendering/OpenGL/StickMapper.js +110 -114
- package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D/pingpong.js +91 -157
- package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D.js +142 -151
- package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +142 -216
- package/Rendering/OpenGL/SurfaceLIC/SurfaceLICMapper.js +79 -100
- package/Rendering/OpenGL/SurfaceLIC.js +2 -2
- package/Rendering/OpenGL/Texture/Constants.js +4 -4
- package/Rendering/OpenGL/Texture.js +444 -609
- package/Rendering/OpenGL/TextureUnitManager.js +47 -43
- package/Rendering/OpenGL/VertexArrayObject.js +92 -131
- package/Rendering/OpenGL/ViewNodeFactory.js +25 -13
- package/Rendering/OpenGL/Volume.js +38 -34
- package/Rendering/OpenGL/VolumeMapper.js +437 -547
- package/Rendering/OpenGL.js +28 -28
- package/Rendering/SceneGraph/RenderPass.js +34 -31
- package/Rendering/SceneGraph/RenderWindowViewNode.js +68 -94
- package/Rendering/SceneGraph/ViewNode.js +82 -111
- package/Rendering/SceneGraph/ViewNodeFactory.js +31 -26
- package/Rendering/SceneGraph.js +4 -4
- package/Rendering/WebGPU/Actor.js +49 -49
- package/Rendering/WebGPU/Actor2D.js +45 -44
- package/Rendering/WebGPU/BindGroup.js +43 -50
- package/Rendering/WebGPU/Buffer.js +41 -50
- package/Rendering/WebGPU/BufferManager/Constants.js +4 -4
- package/Rendering/WebGPU/BufferManager.js +111 -141
- package/Rendering/WebGPU/Camera.js +65 -67
- package/Rendering/WebGPU/CellArrayMapper.js +621 -388
- package/Rendering/WebGPU/CubeAxesActor.js +28 -19
- package/Rendering/WebGPU/Device.js +78 -133
- package/Rendering/WebGPU/ForwardPass.js +75 -72
- package/Rendering/WebGPU/FullScreenQuad.js +25 -18
- package/Rendering/WebGPU/Glyph3DMapper.js +62 -74
- package/Rendering/WebGPU/HardwareSelectionPass.js +45 -38
- package/Rendering/WebGPU/HardwareSelector.js +200 -276
- package/Rendering/WebGPU/ImageMapper.js +180 -171
- package/Rendering/WebGPU/ImageSlice.js +45 -44
- package/Rendering/WebGPU/IndexBuffer.js +166 -200
- package/Rendering/WebGPU/OpaquePass.js +37 -36
- package/Rendering/WebGPU/OrderIndependentTranslucentPass.js +72 -45
- package/Rendering/WebGPU/Pipeline.js +37 -51
- package/Rendering/WebGPU/PixelSpaceCallbackMapper.js +27 -19
- package/Rendering/WebGPU/PolyDataMapper.js +50 -53
- package/Rendering/WebGPU/PolyDataMapper2D.js +39 -39
- package/Rendering/WebGPU/RenderEncoder.js +68 -88
- package/Rendering/WebGPU/RenderWindow.js +262 -376
- package/Rendering/WebGPU/Renderer.js +224 -208
- package/Rendering/WebGPU/Sampler.js +27 -21
- package/Rendering/WebGPU/ScalarBarActor.js +28 -19
- package/Rendering/WebGPU/ShaderCache.js +43 -41
- package/Rendering/WebGPU/ShaderDescription.js +52 -59
- package/Rendering/WebGPU/ShaderModule.js +26 -17
- package/Rendering/WebGPU/SimpleMapper.js +185 -121
- package/Rendering/WebGPU/SphereMapper.js +200 -130
- package/Rendering/WebGPU/StickMapper.js +289 -152
- package/Rendering/WebGPU/StorageBuffer.js +100 -115
- package/Rendering/WebGPU/Texture.js +79 -99
- package/Rendering/WebGPU/TextureManager.js +52 -54
- package/Rendering/WebGPU/TextureView.js +40 -43
- package/Rendering/WebGPU/Types.js +53 -70
- package/Rendering/WebGPU/UniformBuffer.js +158 -184
- package/Rendering/WebGPU/VertexInput.js +64 -90
- package/Rendering/WebGPU/ViewNodeFactory.js +25 -13
- package/Rendering/WebGPU/Volume.js +52 -51
- package/Rendering/WebGPU/VolumePass.js +218 -239
- package/Rendering/WebGPU/VolumePassFSQ.js +625 -306
- package/Rendering/WebGPU.js +1 -1
- package/Rendering/index.js +5 -5
- package/Widgets/Core/AbstractWidget/Constants.js +2 -2
- package/Widgets/Core/AbstractWidget.js +49 -58
- package/Widgets/Core/AbstractWidgetFactory.js +101 -122
- package/Widgets/Core/StateBuilder/boundsMixin.js +23 -28
- package/Widgets/Core/StateBuilder/color3Mixin.js +10 -7
- package/Widgets/Core/StateBuilder/colorMixin.js +10 -6
- package/Widgets/Core/StateBuilder/cornerMixin.js +16 -15
- package/Widgets/Core/StateBuilder/directionMixin.js +20 -18
- package/Widgets/Core/StateBuilder/manipulatorMixin.js +26 -18
- package/Widgets/Core/StateBuilder/nameMixin.js +10 -6
- package/Widgets/Core/StateBuilder/orientationMixin.js +19 -16
- package/Widgets/Core/StateBuilder/originMixin.js +25 -32
- package/Widgets/Core/StateBuilder/scale1Mixin.js +10 -6
- package/Widgets/Core/StateBuilder/scale3Mixin.js +10 -6
- package/Widgets/Core/StateBuilder/shapeMixin.js +12 -6
- package/Widgets/Core/StateBuilder/textMixin.js +10 -6
- package/Widgets/Core/StateBuilder/visibleMixin.js +10 -6
- package/Widgets/Core/StateBuilder.js +120 -149
- package/Widgets/Core/WidgetManager/Constants.js +7 -7
- package/Widgets/Core/WidgetManager.js +249 -421
- package/Widgets/Core/WidgetState.js +48 -57
- package/Widgets/Core.js +5 -5
- package/Widgets/Manipulators/AbstractManipulator.js +20 -14
- package/Widgets/Manipulators/CPRManipulator.js +55 -71
- package/Widgets/Manipulators/LineManipulator.js +31 -28
- package/Widgets/Manipulators/PickerManipulator.d.ts +48 -0
- package/Widgets/Manipulators/PickerManipulator.js +65 -0
- package/Widgets/Manipulators/PlaneManipulator.js +26 -23
- package/Widgets/Manipulators/TrackballManipulator.js +39 -35
- package/Widgets/Manipulators.js +4 -2
- package/Widgets/Representations/ArrowHandleRepresentation.js +148 -162
- package/Widgets/Representations/CircleContextRepresentation.js +44 -38
- package/Widgets/Representations/ContextRepresentation.js +17 -14
- package/Widgets/Representations/ConvexFaceContextRepresentation.js +50 -47
- package/Widgets/Representations/CroppingOutlineRepresentation.js +38 -27
- package/Widgets/Representations/CubeHandleRepresentation.js +21 -18
- package/Widgets/Representations/GlyphRepresentation.js +107 -152
- package/Widgets/Representations/HandleRepresentation.js +17 -14
- package/Widgets/Representations/ImplicitPlaneRepresentation.js +97 -91
- package/Widgets/Representations/LineHandleRepresentation.js +44 -41
- package/Widgets/Representations/OutlineContextRepresentation.js +42 -36
- package/Widgets/Representations/PolyLineRepresentation.js +60 -75
- package/Widgets/Representations/RectangleContextRepresentation.js +42 -37
- package/Widgets/Representations/SphereContextRepresentation.js +19 -27
- package/Widgets/Representations/SphereHandleRepresentation.js +31 -27
- package/Widgets/Representations/SplineContextRepresentation.js +46 -70
- package/Widgets/Representations/WidgetRepresentation/Constants.js +2 -2
- package/Widgets/Representations/WidgetRepresentation.js +99 -134
- package/Widgets/Representations.js +13 -13
- package/Widgets/Widgets3D/AngleWidget/behavior.js +41 -63
- package/Widgets/Widgets3D/AngleWidget.js +41 -39
- package/Widgets/Widgets3D/DistanceWidget/behavior.js +40 -61
- package/Widgets/Widgets3D/DistanceWidget.js +38 -36
- package/Widgets/Widgets3D/EllipseWidget/behavior.js +14 -19
- package/Widgets/Widgets3D/EllipseWidget/state.js +4 -2
- package/Widgets/Widgets3D/EllipseWidget.js +37 -26
- package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +26 -56
- package/Widgets/Widgets3D/ImageCroppingWidget/helpers.js +14 -17
- package/Widgets/Widgets3D/ImageCroppingWidget/state.js +20 -16
- package/Widgets/Widgets3D/ImageCroppingWidget.js +80 -98
- package/Widgets/Widgets3D/ImplicitPlaneWidget.js +55 -77
- package/Widgets/Widgets3D/InteractiveOrientationWidget/behavior.js +17 -18
- package/Widgets/Widgets3D/InteractiveOrientationWidget/state.js +15 -7
- package/Widgets/Widgets3D/InteractiveOrientationWidget.js +30 -29
- package/Widgets/Widgets3D/LabelWidget/behavior.js +37 -62
- package/Widgets/Widgets3D/LabelWidget.js +31 -25
- package/Widgets/Widgets3D/LineWidget/Constants.js +8 -8
- package/Widgets/Widgets3D/LineWidget/behavior.js +77 -114
- package/Widgets/Widgets3D/LineWidget/helpers.js +13 -20
- package/Widgets/Widgets3D/LineWidget/state.js +2 -1
- package/Widgets/Widgets3D/LineWidget.js +39 -35
- package/Widgets/Widgets3D/PaintWidget/behavior.js +24 -59
- package/Widgets/Widgets3D/PaintWidget.js +39 -37
- package/Widgets/Widgets3D/PolyLineWidget/behavior.js +44 -68
- package/Widgets/Widgets3D/PolyLineWidget.js +36 -31
- package/Widgets/Widgets3D/RectangleWidget/behavior.js +6 -11
- package/Widgets/Widgets3D/RectangleWidget/state.js +4 -2
- package/Widgets/Widgets3D/RectangleWidget.js +37 -25
- package/Widgets/Widgets3D/ResliceCursorWidget/Constants.js +35 -21
- package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +134 -210
- package/Widgets/Widgets3D/ResliceCursorWidget/cprBehavior.js +26 -41
- package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +90 -117
- package/Widgets/Widgets3D/ResliceCursorWidget/state.js +33 -40
- package/Widgets/Widgets3D/ResliceCursorWidget.js +186 -227
- package/Widgets/Widgets3D/SeedWidget/behavior.js +82 -0
- package/Widgets/Widgets3D/SeedWidget/state.js +18 -0
- package/Widgets/Widgets3D/SeedWidget.d.ts +44 -0
- package/Widgets/Widgets3D/SeedWidget.js +43 -0
- package/Widgets/Widgets3D/ShapeWidget/Constants.js +19 -19
- package/Widgets/Widgets3D/ShapeWidget/behavior.js +150 -252
- package/Widgets/Widgets3D/ShapeWidget.js +24 -27
- package/Widgets/Widgets3D/SphereWidget/behavior.js +35 -69
- package/Widgets/Widgets3D/SphereWidget/state.js +9 -5
- package/Widgets/Widgets3D/SphereWidget.js +34 -44
- package/Widgets/Widgets3D/SplineWidget/behavior.js +85 -120
- package/Widgets/Widgets3D/SplineWidget.js +43 -39
- package/Widgets/Widgets3D.js +15 -15
- package/Widgets/index.js +4 -4
- package/_virtual/rollup-plugin-worker-loader__module_Sources/Filters/General/PaintFilter/PaintFilter.worker.js +95 -207
- package/_virtual/rollup-plugin-worker-loader__module_Sources/Interaction/Widgets/PiecewiseGaussianWidget/ComputeHistogram.worker.js +0 -3
- package/favicon.js +5 -6
- package/index.d.ts +4 -2
- package/index.js +4 -3
- package/macros.js +4 -1931
- package/macros2.js +1684 -0
- package/package.json +6 -6
- 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 {
|
|
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
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
44
|
+
const EndEvent = {
|
|
37
45
|
type: 'EndEvent'
|
|
38
46
|
};
|
|
39
|
-
|
|
47
|
+
const {
|
|
48
|
+
CoordinateSystem
|
|
49
|
+
} = vtkProp;
|
|
50
|
+
|
|
51
|
+
// ----------------------------------------------------------------------------
|
|
40
52
|
// vtkOpenGLPolyDataMapper methods
|
|
41
53
|
// ----------------------------------------------------------------------------
|
|
42
54
|
|
|
43
55
|
function getPickState(renderer) {
|
|
44
|
-
|
|
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
|
-
};
|
|
66
|
-
|
|
73
|
+
};
|
|
67
74
|
|
|
68
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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 (
|
|
208
|
-
sstring = sstring.concat([
|
|
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
|
-
|
|
215
|
-
|
|
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 (
|
|
225
|
-
sstring = sstring.concat([
|
|
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
|
-
|
|
232
|
-
|
|
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
|
-
|
|
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
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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);',
|
|
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', [
|
|
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));',
|
|
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
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
-
|
|
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
|
-
|
|
345
|
-
|
|
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
|
-
|
|
408
|
-
|
|
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
|
-
|
|
413
|
-
VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Clip::Dec', ['uniform int numClipPlanes;',
|
|
414
|
-
VSSource = vtkShaderProgram.substitute(VSSource, '//VTK::Clip::Impl', [
|
|
415
|
-
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Clip::Dec', ['uniform int numClipPlanes;',
|
|
416
|
-
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Clip::Impl', [
|
|
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
|
-
|
|
389
|
+
let cp = {
|
|
427
390
|
factor: 0.0,
|
|
428
391
|
offset: 0.0
|
|
429
392
|
};
|
|
430
|
-
|
|
431
|
-
|
|
393
|
+
const prop = actor.getProperty();
|
|
432
394
|
if (model.renderable.getResolveCoincidentTopology() || prop.getEdgeVisibility() && prop.getRepresentation() === Representation.SURFACE) {
|
|
433
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
462
|
-
|
|
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
|
-
|
|
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
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
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;
|
|
476
|
+
needLighting = true;
|
|
477
|
+
// 2) all cell normals without point normals need lighting
|
|
528
478
|
} else if (cellNormals && !pointNormals) {
|
|
529
|
-
needLighting = true;
|
|
479
|
+
needLighting = true;
|
|
480
|
+
// 3) Phong + pointNormals need lighting
|
|
530
481
|
} else if (!flat && pointNormals) {
|
|
531
|
-
needLighting = true;
|
|
482
|
+
needLighting = true;
|
|
483
|
+
// 4) Phong Lines need lighting
|
|
532
484
|
} else if (!flat && mode === model.context.LINES) {
|
|
533
485
|
needLighting = true;
|
|
534
|
-
}
|
|
535
|
-
//
|
|
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
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
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
|
-
|
|
567
|
-
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
637
|
-
|
|
638
|
-
|
|
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
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
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
|
-
|
|
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 (
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
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
|
-
}
|
|
707
|
-
|
|
630
|
+
}
|
|
708
631
|
|
|
632
|
+
// handle depth requests
|
|
709
633
|
if (model.haveSeenDepthRequest) {
|
|
710
634
|
cellBO.getProgram().setUniformi('depthRequest', model.renderDepth ? 1 : 0);
|
|
711
|
-
}
|
|
712
|
-
|
|
635
|
+
}
|
|
713
636
|
|
|
637
|
+
// handle coincident
|
|
714
638
|
if (cellBO.getProgram().isUniformUsed('coffset')) {
|
|
715
|
-
|
|
716
|
-
cellBO.getProgram().setUniformf('coffset', cp.offset);
|
|
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
|
-
}
|
|
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
|
-
|
|
735
|
-
|
|
655
|
+
const lastLightComplexity = model.lastBoundBO.getReferenceByName('lastLightComplexity');
|
|
736
656
|
if (lastLightComplexity < 2) {
|
|
737
657
|
return;
|
|
738
658
|
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
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
|
-
|
|
751
|
-
|
|
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;
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
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(
|
|
773
|
-
program.setUniform3fArray(
|
|
687
|
+
program.setUniform3fArray(`lightColor${numberOfLights}`, model.lightColor);
|
|
688
|
+
program.setUniform3fArray(`lightDirectionVC${numberOfLights}`, model.lightDirection);
|
|
774
689
|
numberOfLights++;
|
|
775
690
|
}
|
|
776
|
-
}
|
|
777
|
-
|
|
691
|
+
}
|
|
778
692
|
|
|
693
|
+
// we are done unless we have positional lights
|
|
779
694
|
if (lastLightComplexity < 3) {
|
|
780
695
|
return;
|
|
781
|
-
}
|
|
782
|
-
|
|
696
|
+
}
|
|
783
697
|
|
|
784
|
-
|
|
785
|
-
|
|
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
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
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(
|
|
800
|
-
program.setUniformi(
|
|
801
|
-
program.setUniformf(
|
|
802
|
-
program.setUniformf(
|
|
803
|
-
program.setUniform3fArray(
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
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
|
-
|
|
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
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
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);
|
|
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);
|
|
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);
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
939
|
-
|
|
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
|
-
|
|
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
|
-
}
|
|
855
|
+
}
|
|
967
856
|
|
|
857
|
+
// make sure the BOs are up to date
|
|
858
|
+
publicAPI.updateBufferObjects(ren, actor);
|
|
968
859
|
|
|
969
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
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
|
-
|
|
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);
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
967
|
+
const c = model.renderable.getColorMapColors();
|
|
1099
968
|
model.haveCellScalars = false;
|
|
1100
|
-
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
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
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
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
|
-
|
|
1160
|
-
|
|
1161
|
-
points
|
|
1022
|
+
const points = poly.getPoints();
|
|
1023
|
+
const options = {
|
|
1024
|
+
points,
|
|
1162
1025
|
normals: n,
|
|
1163
|
-
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(
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
1268
|
-
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
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
|
-
}
|
|
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
|
-
});
|
|
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
|
-
|
|
1167
|
+
// ----------------------------------------------------------------------------
|
|
1303
1168
|
|
|
1304
1169
|
var vtkOpenGLPolyDataMapper$1 = {
|
|
1305
|
-
newInstance
|
|
1306
|
-
extend
|
|
1307
|
-
};
|
|
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 };
|