@kitware/vtk.js 28.10.2 → 28.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +754 -942
- 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 +85 -144
- 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 +192 -256
- 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 +443 -608
- 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 +40 -38
- 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 +133 -209
- package/Widgets/Widgets3D/ResliceCursorWidget/cprBehavior.js +26 -41
- package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +89 -116
- 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,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
|
-
import { newInstance as newInstance$1, obj, setGet, chain, vtkWarningMacro as vtkWarningMacro$1, vtkErrorMacro as vtkErrorMacro$1 } from '../../macros.js';
|
|
1
|
+
import { n as newInstance$1, o as obj, e as setGet, h as chain, c as macro } from '../../macros2.js';
|
|
4
2
|
import { mat4, mat3, vec3 } from 'gl-matrix';
|
|
5
3
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
6
4
|
import { VtkDataTypes } from '../../Common/Core/DataArray/Constants.js';
|
|
@@ -19,586 +17,533 @@ import { v as vtkVolumeVS } from './glsl/vtkVolumeVS.glsl.js';
|
|
|
19
17
|
import { v as vtkVolumeFS } from './glsl/vtkVolumeFS.glsl.js';
|
|
20
18
|
import { registerOverride } from './ViewNodeFactory.js';
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
vtkErrorMacro = vtkErrorMacro$1; // TODO: Do we want this in some shared utility? Shouldwe just use lodash.isEqual
|
|
20
|
+
const {
|
|
21
|
+
vtkWarningMacro,
|
|
22
|
+
vtkErrorMacro
|
|
23
|
+
} = macro;
|
|
27
24
|
|
|
25
|
+
// TODO: Do we want this in some shared utility? Shouldwe just use lodash.isEqual
|
|
28
26
|
function arrayEquals(a, b) {
|
|
29
27
|
if (a.length !== b.length) {
|
|
30
28
|
return false;
|
|
31
29
|
}
|
|
32
|
-
|
|
33
|
-
for (var i = 0; i < a.length; ++i) {
|
|
30
|
+
for (let i = 0; i < a.length; ++i) {
|
|
34
31
|
if (a[i] !== b[i]) {
|
|
35
32
|
return false;
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
|
-
|
|
39
35
|
return true;
|
|
40
|
-
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// ----------------------------------------------------------------------------
|
|
41
39
|
// vtkOpenGLVolumeMapper methods
|
|
42
40
|
// ----------------------------------------------------------------------------
|
|
43
41
|
|
|
44
|
-
|
|
45
42
|
function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
46
43
|
// Set our className
|
|
47
44
|
model.classHierarchy.push('vtkOpenGLVolumeMapper');
|
|
48
|
-
|
|
49
|
-
publicAPI.buildPass = function () {
|
|
45
|
+
publicAPI.buildPass = () => {
|
|
50
46
|
model.zBufferTexture = null;
|
|
51
|
-
};
|
|
52
|
-
// intermixed volume rendering
|
|
53
|
-
|
|
47
|
+
};
|
|
54
48
|
|
|
55
|
-
|
|
49
|
+
// ohh someone is doing a zbuffer pass, use that for
|
|
50
|
+
// intermixed volume rendering
|
|
51
|
+
publicAPI.zBufferPass = (prepass, renderPass) => {
|
|
56
52
|
if (prepass) {
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
const zbt = renderPass.getZBufferTexture();
|
|
59
54
|
if (zbt !== model.zBufferTexture) {
|
|
60
55
|
model.zBufferTexture = zbt;
|
|
61
56
|
}
|
|
62
57
|
}
|
|
63
58
|
};
|
|
59
|
+
publicAPI.opaqueZBufferPass = (prepass, renderPass) => publicAPI.zBufferPass(prepass, renderPass);
|
|
64
60
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}; // Renders myself
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
publicAPI.volumePass = function (prepass, renderPass) {
|
|
61
|
+
// Renders myself
|
|
62
|
+
publicAPI.volumePass = (prepass, renderPass) => {
|
|
71
63
|
if (prepass) {
|
|
72
64
|
model._openGLRenderWindow = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderWindow');
|
|
73
65
|
model.context = model._openGLRenderWindow.getContext();
|
|
74
66
|
model.tris.setOpenGLRenderWindow(model._openGLRenderWindow);
|
|
75
67
|
model.jitterTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
|
|
76
|
-
model.framebuffer.setOpenGLRenderWindow(model._openGLRenderWindow);
|
|
68
|
+
model.framebuffer.setOpenGLRenderWindow(model._openGLRenderWindow);
|
|
77
69
|
|
|
70
|
+
// Per Component?
|
|
78
71
|
model.scalarTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
|
|
79
72
|
model.colorTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
|
|
80
73
|
model.opacityTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
|
|
81
74
|
model.openGLVolume = publicAPI.getFirstAncestorOfType('vtkOpenGLVolume');
|
|
82
|
-
|
|
75
|
+
const actor = model.openGLVolume.getRenderable();
|
|
83
76
|
model._openGLRenderer = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderer');
|
|
84
|
-
|
|
85
|
-
var ren = model._openGLRenderer.getRenderable();
|
|
86
|
-
|
|
77
|
+
const ren = model._openGLRenderer.getRenderable();
|
|
87
78
|
model.openGLCamera = model._openGLRenderer.getViewNodeFor(ren.getActiveCamera());
|
|
88
79
|
publicAPI.renderPiece(ren, actor);
|
|
89
80
|
}
|
|
90
81
|
};
|
|
91
|
-
|
|
92
|
-
publicAPI.buildShaders = function (shaders, ren, actor) {
|
|
82
|
+
publicAPI.buildShaders = (shaders, ren, actor) => {
|
|
93
83
|
publicAPI.getShaderTemplate(shaders, ren, actor);
|
|
94
84
|
publicAPI.replaceShaderValues(shaders, ren, actor);
|
|
95
85
|
};
|
|
96
|
-
|
|
97
|
-
publicAPI.getShaderTemplate = function (shaders, ren, actor) {
|
|
86
|
+
publicAPI.getShaderTemplate = (shaders, ren, actor) => {
|
|
98
87
|
shaders.Vertex = vtkVolumeVS;
|
|
99
88
|
shaders.Fragment = vtkVolumeFS;
|
|
100
89
|
shaders.Geometry = '';
|
|
101
90
|
};
|
|
91
|
+
publicAPI.replaceShaderValues = (shaders, ren, actor) => {
|
|
92
|
+
let FSSource = shaders.Fragment;
|
|
102
93
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
var iType = actor.getProperty().getInterpolationType();
|
|
107
|
-
|
|
94
|
+
// define some values in the shader
|
|
95
|
+
const iType = actor.getProperty().getInterpolationType();
|
|
108
96
|
if (iType === InterpolationType.LINEAR) {
|
|
109
97
|
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::TrilinearOn', '#define vtkTrilinearOn').result;
|
|
110
98
|
}
|
|
111
|
-
|
|
112
|
-
var vtkImageLabelOutline = actor.getProperty().getUseLabelOutline();
|
|
113
|
-
|
|
99
|
+
const vtkImageLabelOutline = actor.getProperty().getUseLabelOutline();
|
|
114
100
|
if (vtkImageLabelOutline === true) {
|
|
115
101
|
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::ImageLabelOutlineOn', '#define vtkImageLabelOutlineOn').result;
|
|
116
102
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
var iComps = actor.getProperty().getIndependentComponents();
|
|
121
|
-
|
|
103
|
+
const numComp = model.scalarTexture.getComponents();
|
|
104
|
+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::NumComponents', `#define vtkNumComponents ${numComp}`).result;
|
|
105
|
+
const iComps = actor.getProperty().getIndependentComponents();
|
|
122
106
|
if (iComps) {
|
|
123
|
-
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::IndependentComponentsOn', '#define vtkIndependentComponentsOn').result;
|
|
124
|
-
|
|
125
|
-
var proportionalComponents = [];
|
|
107
|
+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::IndependentComponentsOn', '#define vtkIndependentComponentsOn').result;
|
|
126
108
|
|
|
127
|
-
|
|
109
|
+
// Define any proportional components
|
|
110
|
+
const proportionalComponents = [];
|
|
111
|
+
for (let nc = 0; nc < numComp; nc++) {
|
|
128
112
|
if (actor.getProperty().getOpacityMode(nc) === OpacityMode.PROPORTIONAL) {
|
|
129
|
-
proportionalComponents.push(
|
|
113
|
+
proportionalComponents.push(`#define vtkComponent${nc}Proportional`);
|
|
130
114
|
}
|
|
131
115
|
}
|
|
132
|
-
|
|
133
116
|
if (proportionalComponents.length > 0) {
|
|
134
117
|
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::vtkProportionalComponents', proportionalComponents.join('\n')).result;
|
|
135
118
|
}
|
|
136
|
-
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// WebGL only supports loops over constants
|
|
137
122
|
// and does not support while loops so we
|
|
138
123
|
// have to hard code how many steps/samples to take
|
|
139
124
|
// We do a break so most systems will gracefully
|
|
140
125
|
// early terminate, but it is always possible
|
|
141
126
|
// a system will execute every step regardless
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
var spc = model.currentInput.getSpacing();
|
|
146
|
-
var vsize = new Float64Array(3);
|
|
127
|
+
const ext = model.currentInput.getSpatialExtent();
|
|
128
|
+
const spc = model.currentInput.getSpacing();
|
|
129
|
+
const vsize = new Float64Array(3);
|
|
147
130
|
vec3.set(vsize, (ext[1] - ext[0]) * spc[0], (ext[3] - ext[2]) * spc[1], (ext[5] - ext[4]) * spc[2]);
|
|
148
|
-
|
|
149
|
-
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::MaximumSamplesValue',
|
|
131
|
+
const maxSamples = vec3.length(vsize) / publicAPI.getCurrentSampleDistance(ren);
|
|
132
|
+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::MaximumSamplesValue', `${Math.ceil(maxSamples)}`).result;
|
|
150
133
|
|
|
151
|
-
|
|
134
|
+
// set light complexity
|
|
135
|
+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::LightComplexity', `#define vtkLightComplexity ${model.lastLightComplexity}`).result;
|
|
152
136
|
|
|
137
|
+
// set shadow blending flag
|
|
153
138
|
if (model.lastLightComplexity > 0) {
|
|
154
139
|
if (model.renderable.getVolumetricScatteringBlending() > 0.0) {
|
|
155
|
-
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::VolumeShadowOn',
|
|
140
|
+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::VolumeShadowOn', `#define VolumeShadowOn`).result;
|
|
156
141
|
}
|
|
157
|
-
|
|
158
142
|
if (model.renderable.getVolumetricScatteringBlending() < 1.0) {
|
|
159
|
-
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::SurfaceShadowOn',
|
|
143
|
+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::SurfaceShadowOn', `#define SurfaceShadowOn`).result;
|
|
160
144
|
}
|
|
161
|
-
|
|
162
145
|
if (model.renderable.getLocalAmbientOcclusion() && actor.getProperty().getAmbient() > 0.0) {
|
|
163
|
-
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::localAmbientOcclusionOn',
|
|
146
|
+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::localAmbientOcclusionOn', `#define localAmbientOcclusionOn`).result;
|
|
164
147
|
}
|
|
165
|
-
}
|
|
166
|
-
|
|
148
|
+
}
|
|
167
149
|
|
|
150
|
+
// if using gradient opacity define that
|
|
168
151
|
model.gopacity = actor.getProperty().getUseGradientOpacity(0);
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (actor.getProperty().getUseGradientOpacity(_nc)) {
|
|
152
|
+
for (let nc = 1; iComps && !model.gopacity && nc < numComp; ++nc) {
|
|
153
|
+
if (actor.getProperty().getUseGradientOpacity(nc)) {
|
|
172
154
|
model.gopacity = true;
|
|
173
155
|
}
|
|
174
156
|
}
|
|
175
|
-
|
|
176
157
|
if (model.gopacity) {
|
|
177
158
|
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::GradientOpacityOn', '#define vtkGradientOpacityOn').result;
|
|
178
|
-
}
|
|
179
|
-
|
|
159
|
+
}
|
|
180
160
|
|
|
161
|
+
// set normal from density
|
|
181
162
|
if (model.renderable.getComputeNormalFromOpacity()) {
|
|
182
|
-
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::vtkComputeNormalFromOpacity',
|
|
183
|
-
}
|
|
184
|
-
|
|
163
|
+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::vtkComputeNormalFromOpacity', `#define vtkComputeNormalFromOpacity`).result;
|
|
164
|
+
}
|
|
185
165
|
|
|
166
|
+
// if we have a ztexture then declare it and use it
|
|
186
167
|
if (model.zBufferTexture !== null) {
|
|
187
168
|
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::ZBuffer::Dec', ['uniform sampler2D zBufferTexture;', 'uniform float vpWidth;', 'uniform float vpHeight;']).result;
|
|
188
169
|
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::ZBuffer::Impl', ['vec4 depthVec = texture2D(zBufferTexture, vec2(gl_FragCoord.x / vpWidth, gl_FragCoord.y/vpHeight));', 'float zdepth = (depthVec.r*256.0 + depthVec.g)/257.0;', 'zdepth = zdepth * 2.0 - 1.0;', 'if (cameraParallel == 0) {', 'zdepth = -2.0 * camFar * camNear / (zdepth*(camFar-camNear)-(camFar+camNear)) - camNear;}', 'else {', 'zdepth = (zdepth + 1.0) * 0.5 * (camFar - camNear);}\n', 'zdepth = -zdepth/rayDir.z;', 'dists.y = min(zdepth,dists.y);']).result;
|
|
189
|
-
}
|
|
190
|
-
|
|
170
|
+
}
|
|
191
171
|
|
|
192
|
-
|
|
172
|
+
// Set the BlendMode approach
|
|
173
|
+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::BlendMode', `${model.renderable.getBlendMode()}`).result;
|
|
193
174
|
shaders.Fragment = FSSource;
|
|
194
175
|
publicAPI.replaceShaderLight(shaders, ren, actor);
|
|
195
176
|
publicAPI.replaceShaderClippingPlane(shaders, ren, actor);
|
|
196
177
|
};
|
|
197
|
-
|
|
198
|
-
publicAPI.replaceShaderLight = function (shaders, ren, actor) {
|
|
178
|
+
publicAPI.replaceShaderLight = (shaders, ren, actor) => {
|
|
199
179
|
if (model.lastLightComplexity === 0) {
|
|
200
180
|
return;
|
|
201
181
|
}
|
|
202
|
-
|
|
203
|
-
|
|
182
|
+
let FSSource = shaders.Fragment;
|
|
183
|
+
// check for shadow maps - not implemented yet, skip
|
|
204
184
|
// const shadowFactor = '';
|
|
185
|
+
|
|
205
186
|
// to-do: single out the case when complexity = 1
|
|
206
|
-
// only account for lights that are switched on
|
|
207
187
|
|
|
208
|
-
|
|
209
|
-
|
|
188
|
+
// only account for lights that are switched on
|
|
189
|
+
let lightNum = 0;
|
|
190
|
+
ren.getLights().forEach(light => {
|
|
210
191
|
if (light.getSwitch()) {
|
|
211
192
|
lightNum += 1;
|
|
212
193
|
}
|
|
213
194
|
});
|
|
214
|
-
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Light::Dec', [
|
|
215
|
-
|
|
195
|
+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Light::Dec', [`uniform int lightNum;`, `uniform bool twoSidedLighting;`, `uniform vec3 lightColor[${lightNum}];`, `uniform vec3 lightDirectionVC[${lightNum}]; // normalized`, `uniform vec3 lightHalfAngleVC[${lightNum}];`, '//VTK::Light::Dec'], false).result;
|
|
196
|
+
// support any number of lights
|
|
216
197
|
if (model.lastLightComplexity === 3) {
|
|
217
|
-
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Light::Dec', [
|
|
198
|
+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::Light::Dec', [`uniform vec3 lightPositionVC[${lightNum}];`, `uniform vec3 lightAttenuation[${lightNum}];`, `uniform float lightConeAngle[${lightNum}];`, `uniform float lightExponent[${lightNum}];`, `uniform int lightPositional[${lightNum}];`], false).result;
|
|
218
199
|
}
|
|
219
|
-
|
|
220
200
|
if (model.renderable.getVolumetricScatteringBlending() > 0.0) {
|
|
221
|
-
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::VolumeShadow::Dec', [
|
|
201
|
+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::VolumeShadow::Dec', [`uniform float volumetricScatteringBlending;`, `uniform float giReach;`, `uniform float volumeShadowSamplingDistFactor;`, `uniform float anisotropy;`, `uniform float anisotropy2;`], false).result;
|
|
222
202
|
}
|
|
223
|
-
|
|
224
203
|
if (model.renderable.getLocalAmbientOcclusion() && actor.getProperty().getAmbient() > 0.0) {
|
|
225
|
-
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::LAO::Dec', [
|
|
204
|
+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::LAO::Dec', [`uniform int kernelRadius;`, `uniform vec2 kernelSample[${model.renderable.getLAOKernelRadius()}];`, `uniform int kernelSize;`], false).result;
|
|
226
205
|
}
|
|
227
|
-
|
|
228
206
|
shaders.Fragment = FSSource;
|
|
229
207
|
};
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
var FSSource = shaders.Fragment;
|
|
233
|
-
|
|
208
|
+
publicAPI.replaceShaderClippingPlane = (shaders, ren, actor) => {
|
|
209
|
+
let FSSource = shaders.Fragment;
|
|
234
210
|
if (model.renderable.getClippingPlanes().length > 0) {
|
|
235
|
-
|
|
236
|
-
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::ClipPlane::Dec', [
|
|
237
|
-
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::ClipPlane::Impl', [
|
|
211
|
+
const clipPlaneSize = model.renderable.getClippingPlanes().length;
|
|
212
|
+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::ClipPlane::Dec', [`uniform vec3 vClipPlaneNormals[6];`, `uniform float vClipPlaneDistances[6];`, `uniform vec3 vClipPlaneOrigins[6];`, `uniform int clip_numPlanes;`, '//VTK::ClipPlane::Dec', '#define vtkClippingPlanesOn'], false).result;
|
|
213
|
+
FSSource = vtkShaderProgram.substitute(FSSource, '//VTK::ClipPlane::Impl', [`for(int i = 0; i < ${clipPlaneSize}; i++) {`, ' float rayDirRatio = dot(rayDir, vClipPlaneNormals[i]);', ' float equationResult = dot(vertexVCVSOutput, vClipPlaneNormals[i]) + vClipPlaneDistances[i];', ' if (rayDirRatio == 0.0)', ' {', ' if (equationResult < 0.0) dists.x = dists.y;', ' continue;', ' }', ' float result = -1.0 * equationResult / rayDirRatio;', ' if (rayDirRatio < 0.0) dists.y = min(dists.y, result);', ' else dists.x = max(dists.x, result);', '}', '//VTK::ClipPlane::Impl'], false).result;
|
|
238
214
|
}
|
|
239
|
-
|
|
240
215
|
shaders.Fragment = FSSource;
|
|
241
216
|
};
|
|
242
|
-
|
|
243
|
-
publicAPI.getNeedToRebuildShaders = function (cellBO, ren, actor) {
|
|
217
|
+
publicAPI.getNeedToRebuildShaders = (cellBO, ren, actor) => {
|
|
244
218
|
// do we need lighting?
|
|
245
|
-
|
|
246
|
-
|
|
219
|
+
let lightComplexity = 0;
|
|
247
220
|
if (actor.getProperty().getShade() && model.renderable.getBlendMode() === BlendMode.COMPOSITE_BLEND) {
|
|
248
221
|
// consider the lighting complexity to determine which case applies
|
|
249
222
|
// simple headlight, Light Kit, the whole feature set of VTK
|
|
250
223
|
lightComplexity = 0;
|
|
251
224
|
model.numberOfLights = 0;
|
|
252
|
-
ren.getLights().forEach(
|
|
253
|
-
|
|
254
|
-
|
|
225
|
+
ren.getLights().forEach(light => {
|
|
226
|
+
const status = light.getSwitch();
|
|
255
227
|
if (status > 0) {
|
|
256
228
|
model.numberOfLights++;
|
|
257
|
-
|
|
258
229
|
if (lightComplexity === 0) {
|
|
259
230
|
lightComplexity = 1;
|
|
260
231
|
}
|
|
261
232
|
}
|
|
262
|
-
|
|
263
233
|
if (lightComplexity === 1 && (model.numberOfLights > 1 || light.getIntensity() !== 1.0 || !light.lightTypeIsHeadLight())) {
|
|
264
234
|
lightComplexity = 2;
|
|
265
235
|
}
|
|
266
|
-
|
|
267
236
|
if (lightComplexity < 3 && light.getPositional()) {
|
|
268
237
|
lightComplexity = 3;
|
|
269
238
|
}
|
|
270
239
|
});
|
|
271
240
|
}
|
|
272
|
-
|
|
273
|
-
var needRebuild = false;
|
|
274
|
-
|
|
241
|
+
let needRebuild = false;
|
|
275
242
|
if (model.lastLightComplexity !== lightComplexity) {
|
|
276
243
|
model.lastLightComplexity = lightComplexity;
|
|
277
244
|
needRebuild = true;
|
|
278
245
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
var proportionalComponents = [];
|
|
284
|
-
|
|
246
|
+
const numComp = model.scalarTexture.getComponents();
|
|
247
|
+
const iComps = actor.getProperty().getIndependentComponents();
|
|
248
|
+
let usesProportionalComponents = false;
|
|
249
|
+
const proportionalComponents = [];
|
|
285
250
|
if (iComps) {
|
|
286
251
|
// Define any proportional components
|
|
287
|
-
for (
|
|
252
|
+
for (let nc = 0; nc < numComp; nc++) {
|
|
288
253
|
proportionalComponents.push(actor.getProperty().getOpacityMode(nc));
|
|
289
254
|
}
|
|
290
|
-
|
|
291
255
|
if (proportionalComponents.length > 0) {
|
|
292
256
|
usesProportionalComponents = true;
|
|
293
257
|
}
|
|
294
258
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
var vsize = new Float64Array(3);
|
|
259
|
+
const ext = model.currentInput.getSpatialExtent();
|
|
260
|
+
const spc = model.currentInput.getSpacing();
|
|
261
|
+
const vsize = new Float64Array(3);
|
|
299
262
|
vec3.set(vsize, (ext[1] - ext[0]) * spc[0], (ext[3] - ext[2]) * spc[1], (ext[5] - ext[4]) * spc[2]);
|
|
300
|
-
|
|
301
|
-
|
|
263
|
+
const maxSamples = vec3.length(vsize) / publicAPI.getCurrentSampleDistance(ren);
|
|
264
|
+
const state = {
|
|
302
265
|
interpolationType: actor.getProperty().getInterpolationType(),
|
|
303
266
|
useLabelOutline: actor.getProperty().getUseLabelOutline(),
|
|
304
|
-
numComp
|
|
305
|
-
usesProportionalComponents
|
|
306
|
-
iComps
|
|
307
|
-
maxSamples
|
|
267
|
+
numComp,
|
|
268
|
+
usesProportionalComponents,
|
|
269
|
+
iComps,
|
|
270
|
+
maxSamples,
|
|
308
271
|
useGradientOpacity: actor.getProperty().getUseGradientOpacity(0),
|
|
309
272
|
blendMode: model.renderable.getBlendMode(),
|
|
310
|
-
proportionalComponents
|
|
311
|
-
};
|
|
312
|
-
// since they are used in the shader template replacement step.
|
|
273
|
+
proportionalComponents
|
|
274
|
+
};
|
|
313
275
|
|
|
276
|
+
// We only need to rebuild the shader if one of these variables has changed,
|
|
277
|
+
// since they are used in the shader template replacement step.
|
|
314
278
|
if (!model.previousState || model.previousState.interpolationType !== state.interpolationType || model.previousState.useLabelOutline !== state.useLabelOutline || model.previousState.numComp !== state.numComp || model.previousState.usesProportionalComponents !== state.usesProportionalComponents || model.previousState.iComps !== state.iComps || model.previousState.maxSamples !== state.maxSamples || model.previousState.useGradientOpacity !== state.useGradientOpacity || model.previousState.blendMode !== state.blendMode || !arrayEquals(model.previousState.proportionalComponents, state.proportionalComponents)) {
|
|
315
|
-
model.previousState =
|
|
279
|
+
model.previousState = {
|
|
280
|
+
...state
|
|
281
|
+
};
|
|
316
282
|
return true;
|
|
317
|
-
}
|
|
318
|
-
|
|
283
|
+
}
|
|
319
284
|
|
|
285
|
+
// has something changed that would require us to recreate the shader?
|
|
320
286
|
if (cellBO.getProgram() === 0 || needRebuild || model.lastHaveSeenDepthRequest !== model.haveSeenDepthRequest || !!model.lastZBufferTexture !== !!model.zBufferTexture || cellBO.getShaderSourceTime().getMTime() < publicAPI.getMTime() || cellBO.getShaderSourceTime().getMTime() < model.renderable.getMTime()) {
|
|
321
287
|
model.lastZBufferTexture = model.zBufferTexture;
|
|
322
288
|
return true;
|
|
323
289
|
}
|
|
324
|
-
|
|
325
290
|
return false;
|
|
326
291
|
};
|
|
292
|
+
publicAPI.updateShaders = (cellBO, ren, actor) => {
|
|
293
|
+
model.lastBoundBO = cellBO;
|
|
327
294
|
|
|
328
|
-
|
|
329
|
-
model.lastBoundBO = cellBO; // has something changed that would require us to recreate the shader?
|
|
330
|
-
|
|
295
|
+
// has something changed that would require us to recreate the shader?
|
|
331
296
|
if (publicAPI.getNeedToRebuildShaders(cellBO, ren, actor)) {
|
|
332
|
-
|
|
297
|
+
const shaders = {
|
|
333
298
|
Vertex: null,
|
|
334
299
|
Fragment: null,
|
|
335
300
|
Geometry: null
|
|
336
301
|
};
|
|
337
|
-
publicAPI.buildShaders(shaders, ren, actor);
|
|
338
|
-
|
|
339
|
-
var newShader = model._openGLRenderWindow.getShaderCache().readyShaderProgramArray(shaders.Vertex, shaders.Fragment, shaders.Geometry); // if the shader changed reinitialize the VAO
|
|
302
|
+
publicAPI.buildShaders(shaders, ren, actor);
|
|
340
303
|
|
|
304
|
+
// compile and bind the program if needed
|
|
305
|
+
const newShader = model._openGLRenderWindow.getShaderCache().readyShaderProgramArray(shaders.Vertex, shaders.Fragment, shaders.Geometry);
|
|
341
306
|
|
|
307
|
+
// if the shader changed reinitialize the VAO
|
|
342
308
|
if (newShader !== cellBO.getProgram()) {
|
|
343
|
-
cellBO.setProgram(newShader);
|
|
344
|
-
|
|
309
|
+
cellBO.setProgram(newShader);
|
|
310
|
+
// reset the VAO as the shader has changed
|
|
345
311
|
cellBO.getVAO().releaseGraphicsResources();
|
|
346
312
|
}
|
|
347
|
-
|
|
348
313
|
cellBO.getShaderSourceTime().modified();
|
|
349
314
|
} else {
|
|
350
315
|
model._openGLRenderWindow.getShaderCache().readyShaderProgram(cellBO.getProgram());
|
|
351
316
|
}
|
|
352
|
-
|
|
353
317
|
cellBO.getVAO().bind();
|
|
354
318
|
publicAPI.setMapperShaderParameters(cellBO, ren, actor);
|
|
355
319
|
publicAPI.setCameraShaderParameters(cellBO, ren, actor);
|
|
356
320
|
publicAPI.setPropertyShaderParameters(cellBO, ren, actor);
|
|
357
321
|
publicAPI.getClippingPlaneShaderParameters(cellBO, ren, actor);
|
|
358
322
|
};
|
|
359
|
-
|
|
360
|
-
publicAPI.setMapperShaderParameters = function (cellBO, ren, actor) {
|
|
323
|
+
publicAPI.setMapperShaderParameters = (cellBO, ren, actor) => {
|
|
361
324
|
// Now to update the VAO too, if necessary.
|
|
362
|
-
|
|
363
|
-
|
|
325
|
+
const program = cellBO.getProgram();
|
|
364
326
|
if (cellBO.getCABO().getElementCount() && (model.VBOBuildTime.getMTime() > cellBO.getAttributeUpdateTime().getMTime() || cellBO.getShaderSourceTime().getMTime() > cellBO.getAttributeUpdateTime().getMTime())) {
|
|
365
327
|
if (program.isAttributeUsed('vertexDC')) {
|
|
366
328
|
if (!cellBO.getVAO().addAttributeArray(program, cellBO.getCABO(), 'vertexDC', cellBO.getCABO().getVertexOffset(), cellBO.getCABO().getStride(), model.context.FLOAT, 3, model.context.FALSE)) {
|
|
367
329
|
vtkErrorMacro('Error setting vertexDC in shader VAO.');
|
|
368
330
|
}
|
|
369
331
|
}
|
|
370
|
-
|
|
371
332
|
cellBO.getAttributeUpdateTime().modified();
|
|
372
333
|
}
|
|
373
|
-
|
|
374
334
|
program.setUniformi('texture1', model.scalarTexture.getTextureUnit());
|
|
375
335
|
program.setUniformf('sampleDistance', publicAPI.getCurrentSampleDistance(ren));
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
for (var i = 0; i < 4; i++) {
|
|
336
|
+
const volInfo = model.scalarTexture.getVolumeInfo();
|
|
337
|
+
const ipScalarRange = model.renderable.getIpScalarRange();
|
|
338
|
+
const minVals = [];
|
|
339
|
+
const maxVals = [];
|
|
340
|
+
for (let i = 0; i < 4; i++) {
|
|
382
341
|
// convert iprange from 0-1 into data range values
|
|
383
342
|
minVals[i] = ipScalarRange[0] * volInfo.dataComputedScale[i] + volInfo.dataComputedOffset[i];
|
|
384
|
-
maxVals[i] = ipScalarRange[1] * volInfo.dataComputedScale[i] + volInfo.dataComputedOffset[i];
|
|
385
|
-
|
|
343
|
+
maxVals[i] = ipScalarRange[1] * volInfo.dataComputedScale[i] + volInfo.dataComputedOffset[i];
|
|
344
|
+
// convert data ranges into texture values
|
|
386
345
|
minVals[i] = (minVals[i] - volInfo.offset[i]) / volInfo.scale[i];
|
|
387
346
|
maxVals[i] = (maxVals[i] - volInfo.offset[i]) / volInfo.scale[i];
|
|
388
347
|
}
|
|
389
|
-
|
|
390
348
|
program.setUniform4f('ipScalarRangeMin', minVals[0], minVals[1], minVals[2], minVals[3]);
|
|
391
|
-
program.setUniform4f('ipScalarRangeMax', maxVals[0], maxVals[1], maxVals[2], maxVals[3]);
|
|
349
|
+
program.setUniform4f('ipScalarRangeMax', maxVals[0], maxVals[1], maxVals[2], maxVals[3]);
|
|
392
350
|
|
|
351
|
+
// if we have a zbuffer texture then set it
|
|
393
352
|
if (model.zBufferTexture !== null) {
|
|
394
353
|
program.setUniformi('zBufferTexture', model.zBufferTexture.getTextureUnit());
|
|
395
|
-
|
|
354
|
+
const size = model._useSmallViewport ? [model._smallViewportWidth, model._smallViewportHeight] : model._openGLRenderWindow.getFramebufferSize();
|
|
396
355
|
program.setUniformf('vpWidth', size[0]);
|
|
397
356
|
program.setUniformf('vpHeight', size[1]);
|
|
398
357
|
}
|
|
399
358
|
};
|
|
400
|
-
|
|
401
|
-
publicAPI.setCameraShaderParameters = function (cellBO, ren, actor) {
|
|
359
|
+
publicAPI.setCameraShaderParameters = (cellBO, ren, actor) => {
|
|
402
360
|
// // [WMVP]C == {world, model, view, projection} coordinates
|
|
403
361
|
// // E.g., WCPC == world to projection coordinate transformation
|
|
404
|
-
|
|
405
|
-
|
|
362
|
+
const keyMats = model.openGLCamera.getKeyMatrices(ren);
|
|
363
|
+
const actMats = model.openGLVolume.getKeyMatrices();
|
|
406
364
|
mat4.multiply(model.modelToView, keyMats.wcvc, actMats.mcwc);
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
365
|
+
const program = cellBO.getProgram();
|
|
366
|
+
const cam = model.openGLCamera.getRenderable();
|
|
367
|
+
const crange = cam.getClippingRange();
|
|
410
368
|
program.setUniformf('camThick', crange[1] - crange[0]);
|
|
411
369
|
program.setUniformf('camNear', crange[0]);
|
|
412
370
|
program.setUniformf('camFar', crange[1]);
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
// we will only render those fragments.
|
|
416
|
-
|
|
417
|
-
var pos = new Float64Array(3);
|
|
418
|
-
var dir = new Float64Array(3);
|
|
419
|
-
var dcxmin = 1.0;
|
|
420
|
-
var dcxmax = -1.0;
|
|
421
|
-
var dcymin = 1.0;
|
|
422
|
-
var dcymax = -1.0;
|
|
371
|
+
const bounds = model.currentInput.getBounds();
|
|
372
|
+
const dims = model.currentInput.getDimensions();
|
|
423
373
|
|
|
424
|
-
|
|
374
|
+
// compute the viewport bounds of the volume
|
|
375
|
+
// we will only render those fragments.
|
|
376
|
+
const pos = new Float64Array(3);
|
|
377
|
+
const dir = new Float64Array(3);
|
|
378
|
+
let dcxmin = 1.0;
|
|
379
|
+
let dcxmax = -1.0;
|
|
380
|
+
let dcymin = 1.0;
|
|
381
|
+
let dcymax = -1.0;
|
|
382
|
+
for (let i = 0; i < 8; ++i) {
|
|
425
383
|
vec3.set(pos, bounds[i % 2], bounds[2 + Math.floor(i / 2) % 2], bounds[4 + Math.floor(i / 4)]);
|
|
426
384
|
vec3.transformMat4(pos, pos, model.modelToView);
|
|
427
|
-
|
|
428
385
|
if (!cam.getParallelProjection()) {
|
|
429
|
-
vec3.normalize(dir, pos);
|
|
386
|
+
vec3.normalize(dir, pos);
|
|
387
|
+
|
|
388
|
+
// now find the projection of this point onto a
|
|
430
389
|
// nearZ distance plane. Since the camera is at 0,0,0
|
|
431
390
|
// in VC the ray is just t*pos and
|
|
432
391
|
// t is -nearZ/dir.z
|
|
433
392
|
// intersection becomes pos.x/pos.z
|
|
434
|
-
|
|
435
|
-
var t = -crange[0] / pos[2];
|
|
393
|
+
const t = -crange[0] / pos[2];
|
|
436
394
|
vec3.scale(pos, dir, t);
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
|
|
395
|
+
}
|
|
396
|
+
// now convert to DC
|
|
440
397
|
vec3.transformMat4(pos, pos, keyMats.vcpc);
|
|
441
398
|
dcxmin = Math.min(pos[0], dcxmin);
|
|
442
399
|
dcxmax = Math.max(pos[0], dcxmax);
|
|
443
400
|
dcymin = Math.min(pos[1], dcymin);
|
|
444
401
|
dcymax = Math.max(pos[1], dcymax);
|
|
445
402
|
}
|
|
446
|
-
|
|
447
403
|
program.setUniformf('dcxmin', dcxmin);
|
|
448
404
|
program.setUniformf('dcxmax', dcxmax);
|
|
449
405
|
program.setUniformf('dcymin', dcymin);
|
|
450
406
|
program.setUniformf('dcymax', dcymax);
|
|
451
|
-
|
|
452
407
|
if (program.isUniformUsed('cameraParallel')) {
|
|
453
408
|
program.setUniformi('cameraParallel', cam.getParallelProjection());
|
|
454
409
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
var vsize = new Float64Array(3);
|
|
410
|
+
const ext = model.currentInput.getSpatialExtent();
|
|
411
|
+
const spc = model.currentInput.getSpacing();
|
|
412
|
+
const vsize = new Float64Array(3);
|
|
459
413
|
vec3.set(vsize, (ext[1] - ext[0]) * spc[0], (ext[3] - ext[2]) * spc[1], (ext[5] - ext[4]) * spc[2]);
|
|
460
414
|
program.setUniform3f('vSpacing', spc[0], spc[1], spc[2]);
|
|
461
415
|
vec3.set(pos, ext[0], ext[2], ext[4]);
|
|
462
416
|
model.currentInput.indexToWorldVec3(pos, pos);
|
|
463
417
|
vec3.transformMat4(pos, pos, model.modelToView);
|
|
464
|
-
program.setUniform3f('vOriginVC', pos[0], pos[1], pos[2]);
|
|
418
|
+
program.setUniform3f('vOriginVC', pos[0], pos[1], pos[2]);
|
|
465
419
|
|
|
466
|
-
|
|
420
|
+
// apply the image directions
|
|
421
|
+
const i2wmat4 = model.currentInput.getIndexToWorld();
|
|
467
422
|
mat4.multiply(model.idxToView, model.modelToView, i2wmat4);
|
|
468
423
|
mat3.multiply(model.idxNormalMatrix, keyMats.normalMatrix, actMats.normalMatrix);
|
|
469
424
|
mat3.multiply(model.idxNormalMatrix, model.idxNormalMatrix, model.currentInput.getDirectionByReference());
|
|
470
|
-
|
|
471
|
-
|
|
425
|
+
const maxSamples = vec3.length(vsize) / publicAPI.getCurrentSampleDistance(ren);
|
|
472
426
|
if (maxSamples > model.renderable.getMaximumSamplesPerRay()) {
|
|
473
|
-
vtkWarningMacro(
|
|
427
|
+
vtkWarningMacro(`The number of steps required ${Math.ceil(maxSamples)} is larger than the
|
|
428
|
+
specified maximum number of steps ${model.renderable.getMaximumSamplesPerRay()}.
|
|
429
|
+
Please either change the
|
|
430
|
+
volumeMapper sampleDistance or its maximum number of samples.`);
|
|
474
431
|
}
|
|
475
|
-
|
|
476
|
-
var vctoijk = new Float64Array(3);
|
|
432
|
+
const vctoijk = new Float64Array(3);
|
|
477
433
|
vec3.set(vctoijk, 1.0, 1.0, 1.0);
|
|
478
434
|
vec3.divide(vctoijk, vctoijk, vsize);
|
|
479
435
|
program.setUniform3f('vVCToIJK', vctoijk[0], vctoijk[1], vctoijk[2]);
|
|
480
436
|
program.setUniform3i('volumeDimensions', dims[0], dims[1], dims[2]);
|
|
481
|
-
|
|
482
437
|
if (!model._openGLRenderWindow.getWebgl2()) {
|
|
483
|
-
|
|
438
|
+
const volInfo = model.scalarTexture.getVolumeInfo();
|
|
484
439
|
program.setUniformf('texWidth', model.scalarTexture.getWidth());
|
|
485
440
|
program.setUniformf('texHeight', model.scalarTexture.getHeight());
|
|
486
441
|
program.setUniformi('xreps', volInfo.xreps);
|
|
487
442
|
program.setUniformi('xstride', volInfo.xstride);
|
|
488
443
|
program.setUniformi('ystride', volInfo.ystride);
|
|
489
|
-
}
|
|
490
|
-
// then use a point on the plane to compute the distance
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
var normal = new Float64Array(3);
|
|
494
|
-
var pos2 = new Float64Array(3);
|
|
444
|
+
}
|
|
495
445
|
|
|
496
|
-
|
|
497
|
-
|
|
446
|
+
// map normals through normal matrix
|
|
447
|
+
// then use a point on the plane to compute the distance
|
|
448
|
+
const normal = new Float64Array(3);
|
|
449
|
+
const pos2 = new Float64Array(3);
|
|
450
|
+
for (let i = 0; i < 6; ++i) {
|
|
451
|
+
switch (i) {
|
|
498
452
|
case 1:
|
|
499
453
|
vec3.set(normal, -1.0, 0.0, 0.0);
|
|
500
454
|
vec3.set(pos2, ext[0], ext[2], ext[4]);
|
|
501
455
|
break;
|
|
502
|
-
|
|
503
456
|
case 2:
|
|
504
457
|
vec3.set(normal, 0.0, 1.0, 0.0);
|
|
505
458
|
vec3.set(pos2, ext[1], ext[3], ext[5]);
|
|
506
459
|
break;
|
|
507
|
-
|
|
508
460
|
case 3:
|
|
509
461
|
vec3.set(normal, 0.0, -1.0, 0.0);
|
|
510
462
|
vec3.set(pos2, ext[0], ext[2], ext[4]);
|
|
511
463
|
break;
|
|
512
|
-
|
|
513
464
|
case 4:
|
|
514
465
|
vec3.set(normal, 0.0, 0.0, 1.0);
|
|
515
466
|
vec3.set(pos2, ext[1], ext[3], ext[5]);
|
|
516
467
|
break;
|
|
517
|
-
|
|
518
468
|
case 5:
|
|
519
469
|
vec3.set(normal, 0.0, 0.0, -1.0);
|
|
520
470
|
vec3.set(pos2, ext[0], ext[2], ext[4]);
|
|
521
471
|
break;
|
|
522
|
-
|
|
523
472
|
case 0:
|
|
524
473
|
default:
|
|
525
474
|
vec3.set(normal, 1.0, 0.0, 0.0);
|
|
526
475
|
vec3.set(pos2, ext[1], ext[3], ext[5]);
|
|
527
476
|
break;
|
|
528
477
|
}
|
|
529
|
-
|
|
530
478
|
vec3.transformMat3(normal, normal, model.idxNormalMatrix);
|
|
531
479
|
vec3.transformMat4(pos2, pos2, model.idxToView);
|
|
532
|
-
|
|
533
|
-
// specify the planes in view coordinates
|
|
480
|
+
const dist = -1.0 * vec3.dot(pos2, normal);
|
|
534
481
|
|
|
535
|
-
|
|
536
|
-
|
|
482
|
+
// we have the plane in view coordinates
|
|
483
|
+
// specify the planes in view coordinates
|
|
484
|
+
program.setUniform3f(`vPlaneNormal${i}`, normal[0], normal[1], normal[2]);
|
|
485
|
+
program.setUniformf(`vPlaneDistance${i}`, dist);
|
|
537
486
|
}
|
|
538
|
-
|
|
539
487
|
if (actor.getProperty().getUseLabelOutline()) {
|
|
540
|
-
|
|
541
|
-
|
|
488
|
+
const image = model.currentInput;
|
|
489
|
+
const worldToIndex = image.getWorldToIndex();
|
|
542
490
|
program.setUniformMatrix('vWCtoIDX', worldToIndex);
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
_camera$getClippingRa2 = _slicedToArray(_camera$getClippingRa, 2),
|
|
547
|
-
cRange0 = _camera$getClippingRa2[0],
|
|
548
|
-
cRange1 = _camera$getClippingRa2[1];
|
|
491
|
+
const camera = ren.getActiveCamera();
|
|
492
|
+
const [cRange0, cRange1] = camera.getClippingRange();
|
|
493
|
+
const distance = camera.getDistance();
|
|
549
494
|
|
|
550
|
-
|
|
495
|
+
// set the clipping range to be model.distance and model.distance + 0.1
|
|
551
496
|
// since we use the in the keyMats.wcpc (world to projection) matrix
|
|
552
497
|
// the projection matrix calculation relies on the clipping range to be
|
|
553
498
|
// set correctly. This is done inside the interactorStyleMPRSlice which
|
|
554
499
|
// limits use cases where the interactor style is not used.
|
|
555
500
|
|
|
556
501
|
camera.setClippingRange(distance, distance + 0.1);
|
|
557
|
-
|
|
502
|
+
const labelOutlineKeyMats = model.openGLCamera.getKeyMatrices(ren);
|
|
558
503
|
|
|
559
|
-
|
|
504
|
+
// Get the projection coordinate to world coordinate transformation matrix.
|
|
505
|
+
mat4.invert(model.projectionToWorld, labelOutlineKeyMats.wcpc);
|
|
560
506
|
|
|
561
|
-
|
|
507
|
+
// reset the clipping range since the keyMats are cached
|
|
508
|
+
camera.setClippingRange(cRange0, cRange1);
|
|
562
509
|
|
|
510
|
+
// to re compute the matrices for the current camera and cache them
|
|
563
511
|
model.openGLCamera.getKeyMatrices(ren);
|
|
564
512
|
program.setUniformMatrix('PCWCMatrix', model.projectionToWorld);
|
|
565
|
-
|
|
513
|
+
const size = publicAPI.getRenderTargetSize();
|
|
566
514
|
program.setUniformf('vpWidth', size[0]);
|
|
567
515
|
program.setUniformf('vpHeight', size[1]);
|
|
568
|
-
|
|
516
|
+
const offset = publicAPI.getRenderTargetOffset();
|
|
569
517
|
program.setUniformf('vpOffsetX', offset[0] / size[0]);
|
|
570
518
|
program.setUniformf('vpOffsetY', offset[1] / size[1]);
|
|
571
519
|
}
|
|
572
|
-
|
|
573
520
|
mat4.invert(model.projectionToView, keyMats.vcpc);
|
|
574
|
-
program.setUniformMatrix('PCVCMatrix', model.projectionToView);
|
|
521
|
+
program.setUniformMatrix('PCVCMatrix', model.projectionToView);
|
|
575
522
|
|
|
523
|
+
// handle lighting values
|
|
576
524
|
if (model.lastLightComplexity === 0) {
|
|
577
525
|
return;
|
|
578
526
|
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
var status = light.getSwitch();
|
|
586
|
-
|
|
527
|
+
let lightNum = 0;
|
|
528
|
+
const lightColor = [];
|
|
529
|
+
const lightDir = [];
|
|
530
|
+
const halfAngle = [];
|
|
531
|
+
ren.getLights().forEach(light => {
|
|
532
|
+
const status = light.getSwitch();
|
|
587
533
|
if (status > 0) {
|
|
588
|
-
|
|
589
|
-
|
|
534
|
+
const dColor = light.getColor();
|
|
535
|
+
const intensity = light.getIntensity();
|
|
590
536
|
lightColor[0 + lightNum * 3] = dColor[0] * intensity;
|
|
591
537
|
lightColor[1 + lightNum * 3] = dColor[1] * intensity;
|
|
592
538
|
lightColor[2 + lightNum * 3] = dColor[2] * intensity;
|
|
593
|
-
|
|
539
|
+
const ldir = light.getDirection();
|
|
594
540
|
vec3.set(normal, ldir[0], ldir[1], ldir[2]);
|
|
595
541
|
vec3.transformMat3(normal, normal, keyMats.normalMatrix); // in view coordinat
|
|
596
|
-
|
|
597
542
|
vec3.normalize(normal, normal);
|
|
598
543
|
lightDir[0 + lightNum * 3] = normal[0];
|
|
599
544
|
lightDir[1 + lightNum * 3] = normal[1];
|
|
600
|
-
lightDir[2 + lightNum * 3] = normal[2];
|
|
601
|
-
|
|
545
|
+
lightDir[2 + lightNum * 3] = normal[2];
|
|
546
|
+
// camera DOP is 0,0,-1.0 in VC
|
|
602
547
|
halfAngle[0 + lightNum * 3] = -0.5 * normal[0];
|
|
603
548
|
halfAngle[1 + lightNum * 3] = -0.5 * normal[1];
|
|
604
549
|
halfAngle[2 + lightNum * 3] = -0.5 * (normal[2] - 1.0);
|
|
@@ -610,26 +555,24 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
610
555
|
program.setUniform3fv('lightColor', lightColor);
|
|
611
556
|
program.setUniform3fv('lightDirectionVC', lightDir);
|
|
612
557
|
program.setUniform3fv('lightHalfAngleVC', halfAngle);
|
|
613
|
-
|
|
614
558
|
if (model.lastLightComplexity === 3) {
|
|
615
559
|
lightNum = 0;
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
ren.getLights().forEach(
|
|
622
|
-
|
|
623
|
-
|
|
560
|
+
const lightPositionVC = [];
|
|
561
|
+
const lightAttenuation = [];
|
|
562
|
+
const lightConeAngle = [];
|
|
563
|
+
const lightExponent = [];
|
|
564
|
+
const lightPositional = [];
|
|
565
|
+
ren.getLights().forEach(light => {
|
|
566
|
+
const status = light.getSwitch();
|
|
624
567
|
if (status > 0) {
|
|
625
|
-
|
|
568
|
+
const attenuation = light.getAttenuationValues();
|
|
626
569
|
lightAttenuation[0 + lightNum * 3] = attenuation[0];
|
|
627
570
|
lightAttenuation[1 + lightNum * 3] = attenuation[1];
|
|
628
571
|
lightAttenuation[2 + lightNum * 3] = attenuation[2];
|
|
629
572
|
lightExponent[lightNum] = light.getExponent();
|
|
630
573
|
lightConeAngle[lightNum] = light.getConeAngle();
|
|
631
574
|
lightPositional[lightNum] = light.getPositional();
|
|
632
|
-
|
|
575
|
+
const lp = light.getTransformedPosition();
|
|
633
576
|
vec3.transformMat4(lp, lp, model.modelToView);
|
|
634
577
|
lightPositionVC[0 + lightNum * 3] = lp[0];
|
|
635
578
|
lightPositionVC[1 + lightNum * 3] = lp[1];
|
|
@@ -643,111 +586,98 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
643
586
|
program.setUniformfv('lightExponent', lightExponent);
|
|
644
587
|
program.setUniformiv('lightPositional', lightPositional);
|
|
645
588
|
}
|
|
646
|
-
|
|
647
589
|
if (model.renderable.getVolumetricScatteringBlending() > 0.0) {
|
|
648
590
|
program.setUniformf('giReach', model.renderable.getGlobalIlluminationReach());
|
|
649
591
|
program.setUniformf('volumetricScatteringBlending', model.renderable.getVolumetricScatteringBlending());
|
|
650
592
|
program.setUniformf('volumeShadowSamplingDistFactor', model.renderable.getVolumeShadowSamplingDistFactor());
|
|
651
593
|
program.setUniformf('anisotropy', model.renderable.getAnisotropy());
|
|
652
|
-
program.setUniformf('anisotropy2',
|
|
594
|
+
program.setUniformf('anisotropy2', model.renderable.getAnisotropy() ** 2.0);
|
|
653
595
|
}
|
|
654
|
-
|
|
655
596
|
if (model.renderable.getLocalAmbientOcclusion() && actor.getProperty().getAmbient() > 0.0) {
|
|
656
|
-
|
|
597
|
+
const ks = model.renderable.getLAOKernelSize();
|
|
657
598
|
program.setUniformi('kernelSize', ks);
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
kernelSample[
|
|
662
|
-
kernelSample[_i2 * 2 + 1] = Math.random() * 0.5;
|
|
599
|
+
const kernelSample = [];
|
|
600
|
+
for (let i = 0; i < ks; i++) {
|
|
601
|
+
kernelSample[i * 2] = Math.random() * 0.5;
|
|
602
|
+
kernelSample[i * 2 + 1] = Math.random() * 0.5;
|
|
663
603
|
}
|
|
664
|
-
|
|
665
604
|
program.setUniform2fv('kernelSample', kernelSample);
|
|
666
605
|
program.setUniformi('kernelRadius', model.renderable.getLAOKernelRadius());
|
|
667
606
|
}
|
|
668
607
|
};
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
var program = cellBO.getProgram();
|
|
608
|
+
publicAPI.setPropertyShaderParameters = (cellBO, ren, actor) => {
|
|
609
|
+
const program = cellBO.getProgram();
|
|
672
610
|
program.setUniformi('ctexture', model.colorTexture.getTextureUnit());
|
|
673
611
|
program.setUniformi('otexture', model.opacityTexture.getTextureUnit());
|
|
674
612
|
program.setUniformi('jtexture', model.jitterTexture.getTextureUnit());
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
var numComp = model.scalarTexture.getComponents();
|
|
679
|
-
var iComps = actor.getProperty().getIndependentComponents();
|
|
613
|
+
const volInfo = model.scalarTexture.getVolumeInfo();
|
|
614
|
+
const vprop = actor.getProperty();
|
|
680
615
|
|
|
616
|
+
// set the component mix when independent
|
|
617
|
+
const numComp = model.scalarTexture.getComponents();
|
|
618
|
+
const iComps = actor.getProperty().getIndependentComponents();
|
|
681
619
|
if (iComps && numComp >= 2) {
|
|
682
|
-
for (
|
|
683
|
-
program.setUniformf(
|
|
620
|
+
for (let i = 0; i < numComp; i++) {
|
|
621
|
+
program.setUniformf(`mix${i}`, actor.getProperty().getComponentWeight(i));
|
|
684
622
|
}
|
|
685
|
-
} // three levels of shift scale combined into one
|
|
686
|
-
// for performance in the fragment shader
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
for (var _i3 = 0; _i3 < numComp; _i3++) {
|
|
690
|
-
var target = iComps ? _i3 : 0;
|
|
691
|
-
var sscale = volInfo.scale[_i3];
|
|
692
|
-
var ofun = vprop.getScalarOpacity(target);
|
|
693
|
-
var oRange = ofun.getRange();
|
|
694
|
-
var oscale = sscale / (oRange[1] - oRange[0]);
|
|
695
|
-
var oshift = (volInfo.offset[_i3] - oRange[0]) / (oRange[1] - oRange[0]);
|
|
696
|
-
program.setUniformf("oshift".concat(_i3), oshift);
|
|
697
|
-
program.setUniformf("oscale".concat(_i3), oscale);
|
|
698
|
-
var cfun = vprop.getRGBTransferFunction(target);
|
|
699
|
-
var cRange = cfun.getRange();
|
|
700
|
-
var cshift = (volInfo.offset[_i3] - cRange[0]) / (cRange[1] - cRange[0]);
|
|
701
|
-
var cScale = sscale / (cRange[1] - cRange[0]);
|
|
702
|
-
program.setUniformf("cshift".concat(_i3), cshift);
|
|
703
|
-
program.setUniformf("cscale".concat(_i3), cScale);
|
|
704
623
|
}
|
|
705
624
|
|
|
625
|
+
// three levels of shift scale combined into one
|
|
626
|
+
// for performance in the fragment shader
|
|
627
|
+
for (let i = 0; i < numComp; i++) {
|
|
628
|
+
const target = iComps ? i : 0;
|
|
629
|
+
const sscale = volInfo.scale[i];
|
|
630
|
+
const ofun = vprop.getScalarOpacity(target);
|
|
631
|
+
const oRange = ofun.getRange();
|
|
632
|
+
const oscale = sscale / (oRange[1] - oRange[0]);
|
|
633
|
+
const oshift = (volInfo.offset[i] - oRange[0]) / (oRange[1] - oRange[0]);
|
|
634
|
+
program.setUniformf(`oshift${i}`, oshift);
|
|
635
|
+
program.setUniformf(`oscale${i}`, oscale);
|
|
636
|
+
const cfun = vprop.getRGBTransferFunction(target);
|
|
637
|
+
const cRange = cfun.getRange();
|
|
638
|
+
const cshift = (volInfo.offset[i] - cRange[0]) / (cRange[1] - cRange[0]);
|
|
639
|
+
const cScale = sscale / (cRange[1] - cRange[0]);
|
|
640
|
+
program.setUniformf(`cshift${i}`, cshift);
|
|
641
|
+
program.setUniformf(`cscale${i}`, cScale);
|
|
642
|
+
}
|
|
706
643
|
if (model.gopacity) {
|
|
707
644
|
if (iComps) {
|
|
708
|
-
for (
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
645
|
+
for (let nc = 0; nc < numComp; ++nc) {
|
|
646
|
+
const sscale = volInfo.scale[nc];
|
|
647
|
+
const useGO = vprop.getUseGradientOpacity(nc);
|
|
712
648
|
if (useGO) {
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
program.setUniformf(
|
|
716
|
-
program.setUniformf(
|
|
717
|
-
|
|
718
|
-
program.setUniformf(
|
|
719
|
-
program.setUniformf(
|
|
649
|
+
const gomin = vprop.getGradientOpacityMinimumOpacity(nc);
|
|
650
|
+
const gomax = vprop.getGradientOpacityMaximumOpacity(nc);
|
|
651
|
+
program.setUniformf(`gomin${nc}`, gomin);
|
|
652
|
+
program.setUniformf(`gomax${nc}`, gomax);
|
|
653
|
+
const goRange = [vprop.getGradientOpacityMinimumValue(nc), vprop.getGradientOpacityMaximumValue(nc)];
|
|
654
|
+
program.setUniformf(`goscale${nc}`, sscale * (gomax - gomin) / (goRange[1] - goRange[0]));
|
|
655
|
+
program.setUniformf(`goshift${nc}`, -goRange[0] * (gomax - gomin) / (goRange[1] - goRange[0]) + gomin);
|
|
720
656
|
} else {
|
|
721
|
-
program.setUniformf(
|
|
722
|
-
program.setUniformf(
|
|
723
|
-
program.setUniformf(
|
|
724
|
-
program.setUniformf(
|
|
657
|
+
program.setUniformf(`gomin${nc}`, 1.0);
|
|
658
|
+
program.setUniformf(`gomax${nc}`, 1.0);
|
|
659
|
+
program.setUniformf(`goscale${nc}`, 0.0);
|
|
660
|
+
program.setUniformf(`goshift${nc}`, 1.0);
|
|
725
661
|
}
|
|
726
662
|
}
|
|
727
663
|
} else {
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
program.setUniformf('
|
|
735
|
-
program.setUniformf('
|
|
736
|
-
var _goRange = [vprop.getGradientOpacityMinimumValue(0), vprop.getGradientOpacityMaximumValue(0)];
|
|
737
|
-
program.setUniformf('goscale0', _sscale2 * (_gomax - _gomin) / (_goRange[1] - _goRange[0]));
|
|
738
|
-
program.setUniformf('goshift0', -_goRange[0] * (_gomax - _gomin) / (_goRange[1] - _goRange[0]) + _gomin);
|
|
664
|
+
const sscale = volInfo.scale[numComp - 1];
|
|
665
|
+
const gomin = vprop.getGradientOpacityMinimumOpacity(0);
|
|
666
|
+
const gomax = vprop.getGradientOpacityMaximumOpacity(0);
|
|
667
|
+
program.setUniformf('gomin0', gomin);
|
|
668
|
+
program.setUniformf('gomax0', gomax);
|
|
669
|
+
const goRange = [vprop.getGradientOpacityMinimumValue(0), vprop.getGradientOpacityMaximumValue(0)];
|
|
670
|
+
program.setUniformf('goscale0', sscale * (gomax - gomin) / (goRange[1] - goRange[0]));
|
|
671
|
+
program.setUniformf('goshift0', -goRange[0] * (gomax - gomin) / (goRange[1] - goRange[0]) + gomin);
|
|
739
672
|
}
|
|
740
673
|
}
|
|
741
|
-
|
|
742
|
-
var vtkImageLabelOutline = actor.getProperty().getUseLabelOutline();
|
|
743
|
-
|
|
674
|
+
const vtkImageLabelOutline = actor.getProperty().getUseLabelOutline();
|
|
744
675
|
if (vtkImageLabelOutline === true) {
|
|
745
|
-
|
|
746
|
-
|
|
676
|
+
const labelOutlineThickness = actor.getProperty().getLabelOutlineThickness();
|
|
677
|
+
const labelOutlineOpacity = actor.getProperty().getLabelOutlineOpacity();
|
|
747
678
|
program.setUniformi('outlineThickness', labelOutlineThickness);
|
|
748
679
|
program.setUniformf('outlineOpacity', labelOutlineOpacity);
|
|
749
680
|
}
|
|
750
|
-
|
|
751
681
|
if (model.lastLightComplexity > 0) {
|
|
752
682
|
program.setUniformf('vAmbient', vprop.getAmbient());
|
|
753
683
|
program.setUniformf('vDiffuse', vprop.getDiffuse());
|
|
@@ -755,22 +685,20 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
755
685
|
program.setUniformf('vSpecularPower', vprop.getSpecularPower());
|
|
756
686
|
}
|
|
757
687
|
};
|
|
758
|
-
|
|
759
|
-
publicAPI.getClippingPlaneShaderParameters = function (cellBO, ren, actor) {
|
|
688
|
+
publicAPI.getClippingPlaneShaderParameters = (cellBO, ren, actor) => {
|
|
760
689
|
if (model.renderable.getClippingPlanes().length > 0) {
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
var clipPlanePos = clipPlanes[i].getOrigin();
|
|
690
|
+
const keyMats = model.openGLCamera.getKeyMatrices(ren);
|
|
691
|
+
const clipPlaneNormals = [];
|
|
692
|
+
const clipPlaneDistances = [];
|
|
693
|
+
const clipPlaneOrigins = [];
|
|
694
|
+
const clipPlanes = model.renderable.getClippingPlanes();
|
|
695
|
+
const clipPlaneSize = clipPlanes.length;
|
|
696
|
+
for (let i = 0; i < clipPlaneSize; ++i) {
|
|
697
|
+
const clipPlaneNormal = clipPlanes[i].getNormal();
|
|
698
|
+
const clipPlanePos = clipPlanes[i].getOrigin();
|
|
771
699
|
vec3.transformMat3(clipPlaneNormal, clipPlaneNormal, keyMats.normalMatrix);
|
|
772
700
|
vec3.transformMat4(clipPlanePos, clipPlanePos, keyMats.wcvc);
|
|
773
|
-
|
|
701
|
+
const clipPlaneDist = -1.0 * vec3.dot(clipPlanePos, clipPlaneNormal);
|
|
774
702
|
clipPlaneNormals.push(clipPlaneNormal[0]);
|
|
775
703
|
clipPlaneNormals.push(clipPlaneNormal[1]);
|
|
776
704
|
clipPlaneNormals.push(clipPlaneNormal[2]);
|
|
@@ -779,87 +707,73 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
779
707
|
clipPlaneOrigins.push(clipPlanePos[1]);
|
|
780
708
|
clipPlaneOrigins.push(clipPlanePos[2]);
|
|
781
709
|
}
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
program.
|
|
785
|
-
program.
|
|
786
|
-
program.
|
|
787
|
-
program.setUniformi("clip_numPlanes", clipPlaneSize);
|
|
710
|
+
const program = cellBO.getProgram();
|
|
711
|
+
program.setUniform3fv(`vClipPlaneNormals`, clipPlaneNormals);
|
|
712
|
+
program.setUniformfv(`vClipPlaneDistances`, clipPlaneDistances);
|
|
713
|
+
program.setUniform3fv(`vClipPlaneOrigins`, clipPlaneOrigins);
|
|
714
|
+
program.setUniformi(`clip_numPlanes`, clipPlaneSize);
|
|
788
715
|
}
|
|
789
|
-
};
|
|
790
|
-
|
|
716
|
+
};
|
|
791
717
|
|
|
792
|
-
|
|
718
|
+
// unsubscribe from our listeners
|
|
719
|
+
publicAPI.delete = chain(() => {
|
|
793
720
|
if (model._animationRateSubscription) {
|
|
794
721
|
model._animationRateSubscription.unsubscribe();
|
|
795
|
-
|
|
796
722
|
model._animationRateSubscription = null;
|
|
797
723
|
}
|
|
798
724
|
}, publicAPI.delete);
|
|
799
|
-
|
|
800
|
-
publicAPI.getRenderTargetSize = function () {
|
|
725
|
+
publicAPI.getRenderTargetSize = () => {
|
|
801
726
|
if (model._useSmallViewport) {
|
|
802
727
|
return [model._smallViewportWidth, model._smallViewportHeight];
|
|
803
728
|
}
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
729
|
+
const {
|
|
730
|
+
usize,
|
|
731
|
+
vsize
|
|
732
|
+
} = model._openGLRenderer.getTiledSizeAndOrigin();
|
|
809
733
|
return [usize, vsize];
|
|
810
734
|
};
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
735
|
+
publicAPI.getRenderTargetOffset = () => {
|
|
736
|
+
const {
|
|
737
|
+
lowerLeftU,
|
|
738
|
+
lowerLeftV
|
|
739
|
+
} = model._openGLRenderer.getTiledSizeAndOrigin();
|
|
817
740
|
return [lowerLeftU, lowerLeftV];
|
|
818
741
|
};
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
var baseSampleDistance = model.renderable.getSampleDistance();
|
|
823
|
-
|
|
742
|
+
publicAPI.getCurrentSampleDistance = ren => {
|
|
743
|
+
const rwi = ren.getVTKWindow().getInteractor();
|
|
744
|
+
const baseSampleDistance = model.renderable.getSampleDistance();
|
|
824
745
|
if (rwi.isAnimating()) {
|
|
825
|
-
|
|
746
|
+
const factor = model.renderable.getInteractionSampleDistanceFactor();
|
|
826
747
|
return baseSampleDistance * factor;
|
|
827
748
|
}
|
|
828
|
-
|
|
829
749
|
return baseSampleDistance;
|
|
830
750
|
};
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
var rwi = ren.getVTKWindow().getInteractor();
|
|
834
|
-
|
|
751
|
+
publicAPI.renderPieceStart = (ren, actor) => {
|
|
752
|
+
const rwi = ren.getVTKWindow().getInteractor();
|
|
835
753
|
if (!model._lastScale) {
|
|
836
754
|
model._lastScale = model.renderable.getInitialInteractionScale();
|
|
837
755
|
}
|
|
838
|
-
|
|
839
756
|
model._useSmallViewport = false;
|
|
840
|
-
|
|
841
757
|
if (rwi.isAnimating() && model._lastScale > 1.5) {
|
|
842
758
|
model._useSmallViewport = true;
|
|
843
759
|
}
|
|
844
|
-
|
|
845
760
|
if (!model._animationRateSubscription) {
|
|
846
761
|
// when the animation frame rate changes recompute the scale factor
|
|
847
|
-
model._animationRateSubscription = rwi.onAnimationFrameRateUpdate(
|
|
762
|
+
model._animationRateSubscription = rwi.onAnimationFrameRateUpdate(() => {
|
|
848
763
|
if (model.renderable.getAutoAdjustSampleDistances()) {
|
|
849
|
-
|
|
850
|
-
|
|
764
|
+
const frate = rwi.getRecentAnimationFrameRate();
|
|
765
|
+
const adjustment = rwi.getDesiredUpdateRate() / frate;
|
|
851
766
|
|
|
767
|
+
// only change if we are off by 15%
|
|
852
768
|
if (adjustment > 1.15 || adjustment < 0.85) {
|
|
853
769
|
model._lastScale *= adjustment;
|
|
854
|
-
}
|
|
770
|
+
}
|
|
771
|
+
// clamp scale to some reasonable values.
|
|
855
772
|
// Below 1.5 we will just be using full resolution as that is close enough
|
|
856
773
|
// Above 400 seems like a lot so we limit to that 1/20th per axis
|
|
857
|
-
|
|
858
|
-
|
|
859
774
|
if (model._lastScale > 400) {
|
|
860
775
|
model._lastScale = 400;
|
|
861
776
|
}
|
|
862
|
-
|
|
863
777
|
if (model._lastScale < 1.5) {
|
|
864
778
|
model._lastScale = 1.5;
|
|
865
779
|
}
|
|
@@ -867,81 +781,78 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
867
781
|
model._lastScale = model.renderable.getImageSampleDistance() * model.renderable.getImageSampleDistance();
|
|
868
782
|
}
|
|
869
783
|
});
|
|
870
|
-
}
|
|
871
|
-
|
|
784
|
+
}
|
|
872
785
|
|
|
786
|
+
// use/create/resize framebuffer if needed
|
|
873
787
|
if (model._useSmallViewport) {
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
var scaleFactor = 1 / Math.sqrt(model._lastScale);
|
|
788
|
+
const size = model._openGLRenderWindow.getFramebufferSize();
|
|
789
|
+
const scaleFactor = 1 / Math.sqrt(model._lastScale);
|
|
877
790
|
model._smallViewportWidth = Math.ceil(scaleFactor * size[0]);
|
|
878
|
-
model._smallViewportHeight = Math.ceil(scaleFactor * size[1]);
|
|
791
|
+
model._smallViewportHeight = Math.ceil(scaleFactor * size[1]);
|
|
879
792
|
|
|
793
|
+
// adjust viewportSize to always be at most the dest fo size
|
|
880
794
|
if (model._smallViewportHeight > size[1]) {
|
|
881
795
|
model._smallViewportHeight = size[1];
|
|
882
796
|
}
|
|
883
|
-
|
|
884
797
|
if (model._smallViewportWidth > size[0]) {
|
|
885
798
|
model._smallViewportWidth = size[0];
|
|
886
799
|
}
|
|
887
|
-
|
|
888
800
|
model.framebuffer.saveCurrentBindingsAndBuffers();
|
|
889
|
-
|
|
890
801
|
if (model.framebuffer.getGLFramebuffer() === null) {
|
|
891
802
|
model.framebuffer.create(size[0], size[1]);
|
|
892
803
|
model.framebuffer.populateFramebuffer();
|
|
893
804
|
} else {
|
|
894
|
-
|
|
895
|
-
|
|
805
|
+
const fbSize = model.framebuffer.getSize();
|
|
896
806
|
if (fbSize[0] !== size[0] || fbSize[1] !== size[1]) {
|
|
897
807
|
model.framebuffer.create(size[0], size[1]);
|
|
898
808
|
model.framebuffer.populateFramebuffer();
|
|
899
809
|
}
|
|
900
810
|
}
|
|
901
|
-
|
|
902
811
|
model.framebuffer.bind();
|
|
903
|
-
|
|
812
|
+
const gl = model.context;
|
|
904
813
|
gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
905
814
|
gl.colorMask(true, true, true, true);
|
|
906
815
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
907
816
|
gl.viewport(0, 0, model._smallViewportWidth, model._smallViewportHeight);
|
|
908
817
|
model.fvp = [model._smallViewportWidth / size[0], model._smallViewportHeight / size[1]];
|
|
909
818
|
}
|
|
819
|
+
model.context.disable(model.context.DEPTH_TEST);
|
|
910
820
|
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
publicAPI.updateBufferObjects(ren, actor); // set interpolation on the texture based on property setting
|
|
914
|
-
|
|
915
|
-
var iType = actor.getProperty().getInterpolationType();
|
|
821
|
+
// make sure the BOs are up to date
|
|
822
|
+
publicAPI.updateBufferObjects(ren, actor);
|
|
916
823
|
|
|
824
|
+
// set interpolation on the texture based on property setting
|
|
825
|
+
const iType = actor.getProperty().getInterpolationType();
|
|
917
826
|
if (iType === InterpolationType.NEAREST) {
|
|
918
827
|
model.scalarTexture.setMinificationFilter(Filter.NEAREST);
|
|
919
828
|
model.scalarTexture.setMagnificationFilter(Filter.NEAREST);
|
|
920
829
|
} else {
|
|
921
830
|
model.scalarTexture.setMinificationFilter(Filter.LINEAR);
|
|
922
831
|
model.scalarTexture.setMagnificationFilter(Filter.LINEAR);
|
|
923
|
-
}
|
|
924
|
-
|
|
832
|
+
}
|
|
925
833
|
|
|
926
|
-
|
|
834
|
+
// Bind the OpenGL, this is shared between the different primitive/cell types.
|
|
835
|
+
model.lastBoundBO = null;
|
|
927
836
|
|
|
837
|
+
// if we have a zbuffer texture then activate it
|
|
928
838
|
if (model.zBufferTexture !== null) {
|
|
929
839
|
model.zBufferTexture.activate();
|
|
930
840
|
}
|
|
931
841
|
};
|
|
842
|
+
publicAPI.renderPieceDraw = (ren, actor) => {
|
|
843
|
+
const gl = model.context;
|
|
932
844
|
|
|
933
|
-
|
|
934
|
-
var gl = model.context; // render the texture
|
|
935
|
-
|
|
845
|
+
// render the texture
|
|
936
846
|
model.scalarTexture.activate();
|
|
937
847
|
model.opacityTexture.activate();
|
|
938
848
|
model.colorTexture.activate();
|
|
939
849
|
model.jitterTexture.activate();
|
|
940
|
-
publicAPI.updateShaders(model.tris, ren, actor);
|
|
850
|
+
publicAPI.updateShaders(model.tris, ren, actor);
|
|
851
|
+
|
|
852
|
+
// First we do the triangles, update the shader, set uniforms, etc.
|
|
941
853
|
// for (let i = 0; i < 11; ++i) {
|
|
942
854
|
// gl.drawArrays(gl.TRIANGLES, 66 * i, 66);
|
|
943
855
|
// }
|
|
944
|
-
|
|
945
856
|
gl.drawArrays(gl.TRIANGLES, 0, model.tris.getCABO().getElementCount());
|
|
946
857
|
model.tris.getVAO().release();
|
|
947
858
|
model.scalarTexture.deactivate();
|
|
@@ -949,50 +860,45 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
949
860
|
model.opacityTexture.deactivate();
|
|
950
861
|
model.jitterTexture.deactivate();
|
|
951
862
|
};
|
|
952
|
-
|
|
953
|
-
publicAPI.renderPieceFinish = function (ren, actor) {
|
|
863
|
+
publicAPI.renderPieceFinish = (ren, actor) => {
|
|
954
864
|
// if we have a zbuffer texture then deactivate it
|
|
955
865
|
if (model.zBufferTexture !== null) {
|
|
956
866
|
model.zBufferTexture.deactivate();
|
|
957
867
|
}
|
|
958
|
-
|
|
959
868
|
if (model._useSmallViewport) {
|
|
960
869
|
// now copy the framebuffer with the volume into the
|
|
961
870
|
// regular buffer
|
|
962
871
|
model.framebuffer.restorePreviousBindingsAndBuffers();
|
|
963
|
-
|
|
964
872
|
if (model.copyShader === null) {
|
|
965
873
|
model.copyShader = model._openGLRenderWindow.getShaderCache().readyShaderProgramArray(['//VTK::System::Dec', 'attribute vec4 vertexDC;', 'uniform vec2 tfactor;', 'varying vec2 tcoord;', 'void main() { tcoord = vec2(vertexDC.x*0.5 + 0.5, vertexDC.y*0.5 + 0.5) * tfactor; gl_Position = vertexDC; }'].join('\n'), ['//VTK::System::Dec', '//VTK::Output::Dec', 'uniform sampler2D texture1;', 'varying vec2 tcoord;', 'void main() { gl_FragData[0] = texture2D(texture1,tcoord); }'].join('\n'), '');
|
|
966
|
-
|
|
874
|
+
const program = model.copyShader;
|
|
967
875
|
model.copyVAO = vtkVertexArrayObject.newInstance();
|
|
968
876
|
model.copyVAO.setOpenGLRenderWindow(model._openGLRenderWindow);
|
|
969
877
|
model.tris.getCABO().bind();
|
|
970
|
-
|
|
971
878
|
if (!model.copyVAO.addAttributeArray(program, model.tris.getCABO(), 'vertexDC', model.tris.getCABO().getVertexOffset(), model.tris.getCABO().getStride(), model.context.FLOAT, 3, model.context.FALSE)) {
|
|
972
879
|
vtkErrorMacro('Error setting vertexDC in copy shader VAO.');
|
|
973
880
|
}
|
|
974
881
|
} else {
|
|
975
882
|
model._openGLRenderWindow.getShaderCache().readyShaderProgram(model.copyShader);
|
|
976
883
|
}
|
|
884
|
+
const size = model._openGLRenderWindow.getFramebufferSize();
|
|
885
|
+
model.context.viewport(0, 0, size[0], size[1]);
|
|
977
886
|
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
model.context.viewport(0, 0, size[0], size[1]); // activate texture
|
|
981
|
-
|
|
982
|
-
var tex = model.framebuffer.getColorTexture();
|
|
887
|
+
// activate texture
|
|
888
|
+
const tex = model.framebuffer.getColorTexture();
|
|
983
889
|
tex.activate();
|
|
984
890
|
model.copyShader.setUniformi('texture', tex.getTextureUnit());
|
|
985
891
|
model.copyShader.setUniform2f('tfactor', model.fvp[0], model.fvp[1]);
|
|
986
|
-
|
|
987
|
-
gl.blendFuncSeparate(gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
|
|
892
|
+
const gl = model.context;
|
|
893
|
+
gl.blendFuncSeparate(gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
|
|
988
894
|
|
|
895
|
+
// render quad
|
|
989
896
|
model.context.drawArrays(model.context.TRIANGLES, 0, model.tris.getCABO().getElementCount());
|
|
990
897
|
tex.deactivate();
|
|
991
898
|
gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
|
|
992
899
|
}
|
|
993
900
|
};
|
|
994
|
-
|
|
995
|
-
publicAPI.renderPiece = function (ren, actor) {
|
|
901
|
+
publicAPI.renderPiece = (ren, actor) => {
|
|
996
902
|
publicAPI.invokeEvent({
|
|
997
903
|
type: 'StartEvent'
|
|
998
904
|
});
|
|
@@ -1001,168 +907,139 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
1001
907
|
publicAPI.invokeEvent({
|
|
1002
908
|
type: 'EndEvent'
|
|
1003
909
|
});
|
|
1004
|
-
|
|
1005
910
|
if (!model.currentInput) {
|
|
1006
911
|
vtkErrorMacro('No input!');
|
|
1007
912
|
return;
|
|
1008
913
|
}
|
|
1009
|
-
|
|
1010
914
|
publicAPI.renderPieceStart(ren, actor);
|
|
1011
915
|
publicAPI.renderPieceDraw(ren, actor);
|
|
1012
916
|
publicAPI.renderPieceFinish(ren, actor);
|
|
1013
917
|
};
|
|
1014
|
-
|
|
1015
|
-
publicAPI.computeBounds = function (ren, actor) {
|
|
918
|
+
publicAPI.computeBounds = (ren, actor) => {
|
|
1016
919
|
if (!publicAPI.getInput()) {
|
|
1017
920
|
uninitializeBounds(model.Bounds);
|
|
1018
921
|
return;
|
|
1019
922
|
}
|
|
1020
|
-
|
|
1021
923
|
model.bounds = publicAPI.getInput().getBounds();
|
|
1022
924
|
};
|
|
1023
|
-
|
|
1024
|
-
publicAPI.updateBufferObjects = function (ren, actor) {
|
|
925
|
+
publicAPI.updateBufferObjects = (ren, actor) => {
|
|
1025
926
|
// Rebuild buffers if needed
|
|
1026
927
|
if (publicAPI.getNeedToRebuildBufferObjects(ren, actor)) {
|
|
1027
928
|
publicAPI.buildBufferObjects(ren, actor);
|
|
1028
929
|
}
|
|
1029
930
|
};
|
|
1030
|
-
|
|
1031
|
-
publicAPI.getNeedToRebuildBufferObjects = function (ren, actor) {
|
|
931
|
+
publicAPI.getNeedToRebuildBufferObjects = (ren, actor) => {
|
|
1032
932
|
// first do a coarse check
|
|
1033
933
|
if (model.VBOBuildTime.getMTime() < publicAPI.getMTime() || model.VBOBuildTime.getMTime() < actor.getMTime() || model.VBOBuildTime.getMTime() < model.renderable.getMTime() || model.VBOBuildTime.getMTime() < actor.getProperty().getMTime() || model.VBOBuildTime.getMTime() < model.currentInput.getMTime()) {
|
|
1034
934
|
return true;
|
|
1035
935
|
}
|
|
1036
|
-
|
|
1037
936
|
return false;
|
|
1038
937
|
};
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
var image = model.currentInput;
|
|
1042
|
-
|
|
938
|
+
publicAPI.buildBufferObjects = (ren, actor) => {
|
|
939
|
+
const image = model.currentInput;
|
|
1043
940
|
if (!image) {
|
|
1044
941
|
return;
|
|
1045
942
|
}
|
|
1046
|
-
|
|
1047
|
-
var scalars = image.getPointData() && image.getPointData().getScalars();
|
|
1048
|
-
|
|
943
|
+
const scalars = image.getPointData() && image.getPointData().getScalars();
|
|
1049
944
|
if (!scalars) {
|
|
1050
945
|
return;
|
|
1051
946
|
}
|
|
1052
|
-
|
|
1053
|
-
var vprop = actor.getProperty();
|
|
1054
|
-
|
|
947
|
+
const vprop = actor.getProperty();
|
|
1055
948
|
if (!model.jitterTexture.getHandle()) {
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
for (var i = 0; i < 32 * 32; ++i) {
|
|
949
|
+
const oTable = new Uint8Array(32 * 32);
|
|
950
|
+
for (let i = 0; i < 32 * 32; ++i) {
|
|
1059
951
|
oTable[i] = 255.0 * Math.random();
|
|
1060
952
|
}
|
|
1061
|
-
|
|
1062
953
|
model.jitterTexture.setMinificationFilter(Filter.LINEAR);
|
|
1063
954
|
model.jitterTexture.setMagnificationFilter(Filter.LINEAR);
|
|
1064
955
|
model.jitterTexture.create2DFromRaw(32, 32, 1, VtkDataTypes.UNSIGNED_CHAR, oTable);
|
|
1065
956
|
}
|
|
957
|
+
const numComp = scalars.getNumberOfComponents();
|
|
958
|
+
const iComps = vprop.getIndependentComponents();
|
|
959
|
+
const numIComps = iComps ? numComp : 1;
|
|
1066
960
|
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
var numIComps = iComps ? numComp : 1; // rebuild opacity tfun?
|
|
1070
|
-
|
|
1071
|
-
var toString = "".concat(vprop.getMTime());
|
|
1072
|
-
|
|
961
|
+
// rebuild opacity tfun?
|
|
962
|
+
let toString = `${vprop.getMTime()}`;
|
|
1073
963
|
if (model.opacityTextureString !== toString) {
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
ofTable[c * oWidth * 2 +
|
|
1087
|
-
ofTable[c * oWidth * 2 + _i4 + oWidth] = ofTable[c * oWidth * 2 + _i4];
|
|
964
|
+
const oWidth = 1024;
|
|
965
|
+
const oSize = oWidth * 2 * numIComps;
|
|
966
|
+
const ofTable = new Float32Array(oSize);
|
|
967
|
+
const tmpTable = new Float32Array(oWidth);
|
|
968
|
+
for (let c = 0; c < numIComps; ++c) {
|
|
969
|
+
const ofun = vprop.getScalarOpacity(c);
|
|
970
|
+
const opacityFactor = publicAPI.getCurrentSampleDistance(ren) / vprop.getScalarOpacityUnitDistance(c);
|
|
971
|
+
const oRange = ofun.getRange();
|
|
972
|
+
ofun.getTable(oRange[0], oRange[1], oWidth, tmpTable, 1);
|
|
973
|
+
// adjust for sample distance etc
|
|
974
|
+
for (let i = 0; i < oWidth; ++i) {
|
|
975
|
+
ofTable[c * oWidth * 2 + i] = 1.0 - (1.0 - tmpTable[i]) ** opacityFactor;
|
|
976
|
+
ofTable[c * oWidth * 2 + i + oWidth] = ofTable[c * oWidth * 2 + i];
|
|
1088
977
|
}
|
|
1089
978
|
}
|
|
1090
|
-
|
|
1091
979
|
model.opacityTexture.releaseGraphicsResources(model._openGLRenderWindow);
|
|
1092
980
|
model.opacityTexture.setMinificationFilter(Filter.LINEAR);
|
|
1093
|
-
model.opacityTexture.setMagnificationFilter(Filter.LINEAR);
|
|
981
|
+
model.opacityTexture.setMagnificationFilter(Filter.LINEAR);
|
|
982
|
+
|
|
983
|
+
// use float texture where possible because we really need the resolution
|
|
1094
984
|
// for this table. Errors in low values of opacity accumulate to
|
|
1095
985
|
// visible artifacts. High values of opacity quickly terminate without
|
|
1096
986
|
// artifacts.
|
|
1097
|
-
|
|
1098
987
|
if (model._openGLRenderWindow.getWebgl2() || model.context.getExtension('OES_texture_float') && model.context.getExtension('OES_texture_float_linear')) {
|
|
1099
988
|
model.opacityTexture.create2DFromRaw(oWidth, 2 * numIComps, 1, VtkDataTypes.FLOAT, ofTable);
|
|
1100
989
|
} else {
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
_oTable[_i5] = 255.0 * ofTable[_i5];
|
|
990
|
+
const oTable = new Uint8Array(oSize);
|
|
991
|
+
for (let i = 0; i < oSize; ++i) {
|
|
992
|
+
oTable[i] = 255.0 * ofTable[i];
|
|
1105
993
|
}
|
|
1106
|
-
|
|
1107
|
-
model.opacityTexture.create2DFromRaw(oWidth, 2 * numIComps, 1, VtkDataTypes.UNSIGNED_CHAR, _oTable);
|
|
994
|
+
model.opacityTexture.create2DFromRaw(oWidth, 2 * numIComps, 1, VtkDataTypes.UNSIGNED_CHAR, oTable);
|
|
1108
995
|
}
|
|
1109
|
-
|
|
1110
996
|
model.opacityTextureString = toString;
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
toString = "".concat(vprop.getMTime());
|
|
997
|
+
}
|
|
1115
998
|
|
|
999
|
+
// rebuild color tfun?
|
|
1000
|
+
toString = `${vprop.getMTime()}`;
|
|
1116
1001
|
if (model.colorTextureString !== toString) {
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
for (var _i6 = 0; _i6 < cWidth * 3; ++_i6) {
|
|
1129
|
-
cTable[_c * cWidth * 6 + _i6] = 255.0 * _tmpTable[_i6];
|
|
1130
|
-
cTable[_c * cWidth * 6 + _i6 + cWidth * 3] = 255.0 * _tmpTable[_i6];
|
|
1002
|
+
const cWidth = 1024;
|
|
1003
|
+
const cSize = cWidth * 2 * numIComps * 3;
|
|
1004
|
+
const cTable = new Uint8Array(cSize);
|
|
1005
|
+
const tmpTable = new Float32Array(cWidth * 3);
|
|
1006
|
+
for (let c = 0; c < numIComps; ++c) {
|
|
1007
|
+
const cfun = vprop.getRGBTransferFunction(c);
|
|
1008
|
+
const cRange = cfun.getRange();
|
|
1009
|
+
cfun.getTable(cRange[0], cRange[1], cWidth, tmpTable, 1);
|
|
1010
|
+
for (let i = 0; i < cWidth * 3; ++i) {
|
|
1011
|
+
cTable[c * cWidth * 6 + i] = 255.0 * tmpTable[i];
|
|
1012
|
+
cTable[c * cWidth * 6 + i + cWidth * 3] = 255.0 * tmpTable[i];
|
|
1131
1013
|
}
|
|
1132
1014
|
}
|
|
1133
|
-
|
|
1134
1015
|
model.colorTexture.releaseGraphicsResources(model._openGLRenderWindow);
|
|
1135
1016
|
model.colorTexture.setMinificationFilter(Filter.LINEAR);
|
|
1136
1017
|
model.colorTexture.setMagnificationFilter(Filter.LINEAR);
|
|
1137
1018
|
model.colorTexture.create2DFromRaw(cWidth, 2 * numIComps, 3, VtkDataTypes.UNSIGNED_CHAR, cTable);
|
|
1138
1019
|
model.colorTextureString = toString;
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
toString = "".concat(image.getMTime());
|
|
1020
|
+
}
|
|
1143
1021
|
|
|
1022
|
+
// rebuild the scalarTexture if the data has changed
|
|
1023
|
+
toString = `${image.getMTime()}`;
|
|
1144
1024
|
if (model.scalarTextureString !== toString) {
|
|
1145
1025
|
// Build the textures
|
|
1146
|
-
|
|
1147
|
-
|
|
1026
|
+
const dims = image.getDimensions();
|
|
1027
|
+
// Use norm16 for scalar texture if the extension is available
|
|
1148
1028
|
model.scalarTexture.setOglNorm16Ext(model.context.getExtension('EXT_texture_norm16'));
|
|
1149
1029
|
model.scalarTexture.releaseGraphicsResources(model._openGLRenderWindow);
|
|
1150
1030
|
model.scalarTexture.resetFormatAndType();
|
|
1151
1031
|
model.scalarTexture.create3DFilterableFromDataArray(dims[0], dims[1], dims[2], scalars, model.renderable.getPreferSizeOverAccuracy());
|
|
1152
1032
|
model.scalarTextureString = toString;
|
|
1153
1033
|
}
|
|
1154
|
-
|
|
1155
1034
|
if (!model.tris.getCABO().getElementCount()) {
|
|
1156
1035
|
// build the CABO
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
ptsArray[
|
|
1161
|
-
ptsArray[
|
|
1162
|
-
ptsArray[_i7 * 3 + 2] = -1.0;
|
|
1036
|
+
const ptsArray = new Float32Array(12);
|
|
1037
|
+
for (let i = 0; i < 4; i++) {
|
|
1038
|
+
ptsArray[i * 3] = i % 2 * 2 - 1.0;
|
|
1039
|
+
ptsArray[i * 3 + 1] = i > 1 ? 1.0 : -1.0;
|
|
1040
|
+
ptsArray[i * 3 + 2] = -1.0;
|
|
1163
1041
|
}
|
|
1164
|
-
|
|
1165
|
-
var cellArray = new Uint16Array(8);
|
|
1042
|
+
const cellArray = new Uint16Array(8);
|
|
1166
1043
|
cellArray[0] = 3;
|
|
1167
1044
|
cellArray[1] = 0;
|
|
1168
1045
|
cellArray[2] = 1;
|
|
@@ -1170,7 +1047,9 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
1170
1047
|
cellArray[4] = 3;
|
|
1171
1048
|
cellArray[5] = 0;
|
|
1172
1049
|
cellArray[6] = 3;
|
|
1173
|
-
cellArray[7] = 2;
|
|
1050
|
+
cellArray[7] = 2;
|
|
1051
|
+
|
|
1052
|
+
// const dim = 12.0;
|
|
1174
1053
|
// const ptsArray = new Float32Array(3 * dim * dim);
|
|
1175
1054
|
// for (let i = 0; i < dim; i++) {
|
|
1176
1055
|
// for (let j = 0; j < dim; j++) {
|
|
@@ -1180,6 +1059,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
1180
1059
|
// ptsArray[offset + 2] = -1.0;
|
|
1181
1060
|
// }
|
|
1182
1061
|
// }
|
|
1062
|
+
|
|
1183
1063
|
// const cellArray = new Uint16Array(8 * (dim - 1) * (dim - 1));
|
|
1184
1064
|
// for (let i = 0; i < dim - 1; i++) {
|
|
1185
1065
|
// for (let j = 0; j < dim - 1; j++) {
|
|
@@ -1195,29 +1075,29 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
1195
1075
|
// }
|
|
1196
1076
|
// }
|
|
1197
1077
|
|
|
1198
|
-
|
|
1078
|
+
const points = vtkDataArray.newInstance({
|
|
1199
1079
|
numberOfComponents: 3,
|
|
1200
1080
|
values: ptsArray
|
|
1201
1081
|
});
|
|
1202
1082
|
points.setName('points');
|
|
1203
|
-
|
|
1083
|
+
const cells = vtkDataArray.newInstance({
|
|
1204
1084
|
numberOfComponents: 1,
|
|
1205
1085
|
values: cellArray
|
|
1206
1086
|
});
|
|
1207
1087
|
model.tris.getCABO().createVBO(cells, 'polys', Representation.SURFACE, {
|
|
1208
|
-
points
|
|
1088
|
+
points,
|
|
1209
1089
|
cellOffset: 0
|
|
1210
1090
|
});
|
|
1211
1091
|
}
|
|
1212
|
-
|
|
1213
1092
|
model.VBOBuildTime.modified();
|
|
1214
1093
|
};
|
|
1215
|
-
}
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
// ----------------------------------------------------------------------------
|
|
1216
1097
|
// Object factory
|
|
1217
1098
|
// ----------------------------------------------------------------------------
|
|
1218
1099
|
|
|
1219
|
-
|
|
1220
|
-
var DEFAULT_VALUES = {
|
|
1100
|
+
const DEFAULT_VALUES = {
|
|
1221
1101
|
context: null,
|
|
1222
1102
|
VBOBuildTime: null,
|
|
1223
1103
|
scalarTexture: null,
|
|
@@ -1243,12 +1123,15 @@ var DEFAULT_VALUES = {
|
|
|
1243
1123
|
projectionToView: null,
|
|
1244
1124
|
avgWindowArea: 0.0,
|
|
1245
1125
|
avgFrameTime: 0.0
|
|
1246
|
-
};
|
|
1126
|
+
};
|
|
1127
|
+
|
|
1128
|
+
// ----------------------------------------------------------------------------
|
|
1247
1129
|
|
|
1248
1130
|
function extend(publicAPI, model) {
|
|
1249
|
-
|
|
1250
|
-
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
1131
|
+
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1132
|
+
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
1251
1133
|
|
|
1134
|
+
// Inheritance
|
|
1252
1135
|
vtkViewNode.extend(publicAPI, model, initialValues);
|
|
1253
1136
|
model.VBOBuildTime = {};
|
|
1254
1137
|
obj(model.VBOBuildTime, {
|
|
@@ -1266,20 +1149,27 @@ function extend(publicAPI, model) {
|
|
|
1266
1149
|
model.idxNormalMatrix = mat3.identity(new Float64Array(9));
|
|
1267
1150
|
model.modelToView = mat4.identity(new Float64Array(16));
|
|
1268
1151
|
model.projectionToView = mat4.identity(new Float64Array(16));
|
|
1269
|
-
model.projectionToWorld = mat4.identity(new Float64Array(16));
|
|
1152
|
+
model.projectionToWorld = mat4.identity(new Float64Array(16));
|
|
1270
1153
|
|
|
1271
|
-
|
|
1154
|
+
// Build VTK API
|
|
1155
|
+
setGet(publicAPI, model, ['context']);
|
|
1272
1156
|
|
|
1157
|
+
// Object methods
|
|
1273
1158
|
vtkOpenGLVolumeMapper(publicAPI, model);
|
|
1274
|
-
}
|
|
1159
|
+
}
|
|
1275
1160
|
|
|
1276
|
-
|
|
1161
|
+
// ----------------------------------------------------------------------------
|
|
1162
|
+
|
|
1163
|
+
const newInstance = newInstance$1(extend, 'vtkOpenGLVolumeMapper');
|
|
1164
|
+
|
|
1165
|
+
// ----------------------------------------------------------------------------
|
|
1277
1166
|
|
|
1278
1167
|
var vtkVolumeMapper = {
|
|
1279
|
-
newInstance
|
|
1280
|
-
extend
|
|
1281
|
-
};
|
|
1168
|
+
newInstance,
|
|
1169
|
+
extend
|
|
1170
|
+
};
|
|
1282
1171
|
|
|
1172
|
+
// Register ourself to OpenGL backend if imported
|
|
1283
1173
|
registerOverride('vtkVolumeMapper', newInstance);
|
|
1284
1174
|
|
|
1285
1175
|
export { vtkVolumeMapper as default, extend, newInstance };
|