@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,163 +1,146 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
1
|
import Constants from './Texture/Constants.js';
|
|
4
2
|
import HalfFloat from '../../Common/Core/HalfFloat.js';
|
|
5
|
-
import {
|
|
3
|
+
import { n as newInstance$1, o as obj, s as set, e as setGet, g as get, i as moveToProtected, a as newTypedArray, c as macro } from '../../macros2.js';
|
|
6
4
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
7
5
|
import { R as isPowerOfTwo, N as nearestPowerOfTwo } from '../../Common/Core/Math/index.js';
|
|
8
6
|
import vtkViewNode from '../SceneGraph/ViewNode.js';
|
|
9
7
|
import { registerOverride } from './ViewNodeFactory.js';
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
const {
|
|
10
|
+
Wrap,
|
|
11
|
+
Filter
|
|
12
|
+
} = Constants;
|
|
13
|
+
const {
|
|
14
|
+
VtkDataTypes
|
|
15
|
+
} = vtkDataArray;
|
|
16
|
+
const {
|
|
17
|
+
vtkDebugMacro,
|
|
18
|
+
vtkErrorMacro,
|
|
19
|
+
vtkWarningMacro
|
|
20
|
+
} = macro;
|
|
21
|
+
const {
|
|
22
|
+
toHalf
|
|
23
|
+
} = HalfFloat;
|
|
12
24
|
|
|
13
|
-
|
|
14
|
-
var Wrap = Constants.Wrap,
|
|
15
|
-
Filter = Constants.Filter;
|
|
16
|
-
var VtkDataTypes = vtkDataArray.VtkDataTypes;
|
|
17
|
-
var vtkDebugMacro = vtkDebugMacro$1,
|
|
18
|
-
vtkErrorMacro = vtkErrorMacro$1,
|
|
19
|
-
vtkWarningMacro = vtkWarningMacro$1;
|
|
20
|
-
var toHalf = HalfFloat.toHalf; // ----------------------------------------------------------------------------
|
|
25
|
+
// ----------------------------------------------------------------------------
|
|
21
26
|
// vtkOpenGLTexture methods
|
|
22
27
|
// ----------------------------------------------------------------------------
|
|
23
28
|
|
|
24
29
|
function vtkOpenGLTexture(publicAPI, model) {
|
|
25
30
|
// Set our className
|
|
26
|
-
model.classHierarchy.push('vtkOpenGLTexture');
|
|
27
|
-
|
|
31
|
+
model.classHierarchy.push('vtkOpenGLTexture');
|
|
32
|
+
// Renders myself
|
|
28
33
|
publicAPI.render = function () {
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
let renWin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
31
35
|
if (renWin) {
|
|
32
36
|
model._openGLRenderWindow = renWin;
|
|
33
37
|
} else {
|
|
34
|
-
model._openGLRenderer = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderer');
|
|
35
|
-
|
|
38
|
+
model._openGLRenderer = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderer');
|
|
39
|
+
// sync renderable properties
|
|
36
40
|
model._openGLRenderWindow = model._openGLRenderer.getParent();
|
|
37
41
|
}
|
|
38
|
-
|
|
39
42
|
model.context = model._openGLRenderWindow.getContext();
|
|
40
|
-
|
|
41
43
|
if (model.renderable.getInterpolate()) {
|
|
42
44
|
if (model.generateMipmap) {
|
|
43
45
|
publicAPI.setMinificationFilter(Filter.LINEAR_MIPMAP_LINEAR);
|
|
44
46
|
} else {
|
|
45
47
|
publicAPI.setMinificationFilter(Filter.LINEAR);
|
|
46
48
|
}
|
|
47
|
-
|
|
48
49
|
publicAPI.setMagnificationFilter(Filter.LINEAR);
|
|
49
50
|
} else {
|
|
50
51
|
publicAPI.setMinificationFilter(Filter.NEAREST);
|
|
51
52
|
publicAPI.setMagnificationFilter(Filter.NEAREST);
|
|
52
53
|
}
|
|
53
|
-
|
|
54
54
|
if (model.renderable.getRepeat()) {
|
|
55
55
|
publicAPI.setWrapR(Wrap.REPEAT);
|
|
56
56
|
publicAPI.setWrapS(Wrap.REPEAT);
|
|
57
57
|
publicAPI.setWrapT(Wrap.REPEAT);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
}
|
|
59
|
+
// clear image if input data is set
|
|
61
60
|
if (model.renderable.getInputData()) {
|
|
62
61
|
model.renderable.setImage(null);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
}
|
|
63
|
+
// create the texture if it is not done already
|
|
66
64
|
if (!model.handle || model.renderable.getMTime() > model.textureBuildTime.getMTime()) {
|
|
67
65
|
// if we have an Image
|
|
68
66
|
if (model.renderable.getImage() !== null) {
|
|
69
67
|
if (model.renderable.getInterpolate()) {
|
|
70
68
|
model.generateMipmap = true;
|
|
71
69
|
publicAPI.setMinificationFilter(Filter.LINEAR_MIPMAP_LINEAR);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
}
|
|
71
|
+
// Have an Image which may not be complete
|
|
75
72
|
if (model.renderable.getImage() && model.renderable.getImageLoaded()) {
|
|
76
73
|
publicAPI.create2DFromImage(model.renderable.getImage());
|
|
77
74
|
publicAPI.activate();
|
|
78
75
|
publicAPI.sendParameters();
|
|
79
76
|
model.textureBuildTime.modified();
|
|
80
77
|
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
}
|
|
79
|
+
// if we have a canvas
|
|
84
80
|
if (model.renderable.getCanvas() !== null) {
|
|
85
81
|
if (model.renderable.getInterpolate()) {
|
|
86
82
|
model.generateMipmap = true;
|
|
87
83
|
publicAPI.setMinificationFilter(Filter.LINEAR_MIPMAP_LINEAR);
|
|
88
84
|
}
|
|
89
|
-
|
|
90
|
-
var canvas = model.renderable.getCanvas();
|
|
85
|
+
const canvas = model.renderable.getCanvas();
|
|
91
86
|
publicAPI.create2DFromRaw(canvas.width, canvas.height, 4, VtkDataTypes.UNSIGNED_CHAR, canvas, true);
|
|
92
87
|
publicAPI.activate();
|
|
93
88
|
publicAPI.sendParameters();
|
|
94
89
|
model.textureBuildTime.modified();
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
90
|
+
}
|
|
91
|
+
// if we have jsImageData
|
|
98
92
|
if (model.renderable.getJsImageData() !== null) {
|
|
99
|
-
|
|
100
|
-
|
|
93
|
+
const jsid = model.renderable.getJsImageData();
|
|
101
94
|
if (model.renderable.getInterpolate()) {
|
|
102
95
|
model.generateMipmap = true;
|
|
103
96
|
publicAPI.setMinificationFilter(Filter.LINEAR_MIPMAP_LINEAR);
|
|
104
97
|
}
|
|
105
|
-
|
|
106
98
|
publicAPI.create2DFromRaw(jsid.width, jsid.height, 4, VtkDataTypes.UNSIGNED_CHAR, jsid.data, true);
|
|
107
99
|
publicAPI.activate();
|
|
108
100
|
publicAPI.sendParameters();
|
|
109
101
|
model.textureBuildTime.modified();
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
var input = model.renderable.getInputData(0);
|
|
114
|
-
|
|
102
|
+
}
|
|
103
|
+
// if we have InputData
|
|
104
|
+
const input = model.renderable.getInputData(0);
|
|
115
105
|
if (input && input.getPointData().getScalars()) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
for (
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
106
|
+
const ext = input.getExtent();
|
|
107
|
+
const inScalars = input.getPointData().getScalars();
|
|
108
|
+
|
|
109
|
+
// do we have a cube map? Six inputs
|
|
110
|
+
const data = [];
|
|
111
|
+
for (let i = 0; i < model.renderable.getNumberOfInputPorts(); ++i) {
|
|
112
|
+
const indata = model.renderable.getInputData(i);
|
|
113
|
+
const scalars = indata ? indata.getPointData().getScalars().getData() : null;
|
|
125
114
|
if (scalars) {
|
|
126
115
|
data.push(scalars);
|
|
127
116
|
}
|
|
128
117
|
}
|
|
129
|
-
|
|
130
118
|
if (model.renderable.getInterpolate() && inScalars.getNumberOfComponents() === 4) {
|
|
131
119
|
model.generateMipmap = true;
|
|
132
120
|
publicAPI.setMinificationFilter(Filter.LINEAR_MIPMAP_LINEAR);
|
|
133
121
|
}
|
|
134
|
-
|
|
135
122
|
if (data.length % 6 === 0) {
|
|
136
123
|
publicAPI.createCubeFromRaw(ext[1] - ext[0] + 1, ext[3] - ext[2] + 1, inScalars.getNumberOfComponents(), inScalars.getDataType(), data);
|
|
137
124
|
} else {
|
|
138
125
|
publicAPI.create2DFromRaw(ext[1] - ext[0] + 1, ext[3] - ext[2] + 1, inScalars.getNumberOfComponents(), inScalars.getDataType(), inScalars.getData());
|
|
139
126
|
}
|
|
140
|
-
|
|
141
127
|
publicAPI.activate();
|
|
142
128
|
publicAPI.sendParameters();
|
|
143
129
|
model.textureBuildTime.modified();
|
|
144
130
|
}
|
|
145
131
|
}
|
|
146
|
-
|
|
147
132
|
if (model.handle) {
|
|
148
133
|
publicAPI.activate();
|
|
149
134
|
}
|
|
150
|
-
};
|
|
151
|
-
|
|
135
|
+
};
|
|
152
136
|
|
|
153
|
-
|
|
137
|
+
//----------------------------------------------------------------------------
|
|
138
|
+
publicAPI.destroyTexture = () => {
|
|
154
139
|
// deactivate it first
|
|
155
140
|
publicAPI.deactivate();
|
|
156
|
-
|
|
157
141
|
if (model.context && model.handle) {
|
|
158
142
|
model.context.deleteTexture(model.handle);
|
|
159
143
|
}
|
|
160
|
-
|
|
161
144
|
model.handle = 0;
|
|
162
145
|
model.numberOfDimensions = 0;
|
|
163
146
|
model.target = 0;
|
|
@@ -166,59 +149,55 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
166
149
|
model.height = 0;
|
|
167
150
|
model.depth = 0;
|
|
168
151
|
publicAPI.resetFormatAndType();
|
|
169
|
-
};
|
|
170
|
-
|
|
152
|
+
};
|
|
171
153
|
|
|
172
|
-
|
|
154
|
+
//----------------------------------------------------------------------------
|
|
155
|
+
publicAPI.createTexture = () => {
|
|
173
156
|
// reuse the existing handle if we have one
|
|
174
157
|
if (!model.handle) {
|
|
175
158
|
model.handle = model.context.createTexture();
|
|
176
|
-
|
|
177
159
|
if (model.target) {
|
|
178
|
-
model.context.bindTexture(model.target, model.handle);
|
|
160
|
+
model.context.bindTexture(model.target, model.handle);
|
|
161
|
+
|
|
162
|
+
// See: http://www.openmodel.context..org/wiki/Common_Mistakes#Creating_a_complete_texture
|
|
179
163
|
// turn off mip map filter or set the base and max level correctly. here
|
|
180
164
|
// both are done.
|
|
181
|
-
|
|
182
165
|
model.context.texParameteri(model.target, model.context.TEXTURE_MIN_FILTER, publicAPI.getOpenGLFilterMode(model.minificationFilter));
|
|
183
166
|
model.context.texParameteri(model.target, model.context.TEXTURE_MAG_FILTER, publicAPI.getOpenGLFilterMode(model.magnificationFilter));
|
|
184
167
|
model.context.texParameteri(model.target, model.context.TEXTURE_WRAP_S, publicAPI.getOpenGLWrapMode(model.wrapS));
|
|
185
168
|
model.context.texParameteri(model.target, model.context.TEXTURE_WRAP_T, publicAPI.getOpenGLWrapMode(model.wrapT));
|
|
186
|
-
|
|
187
169
|
if (model._openGLRenderWindow.getWebgl2()) {
|
|
188
170
|
model.context.texParameteri(model.target, model.context.TEXTURE_WRAP_R, publicAPI.getOpenGLWrapMode(model.wrapR));
|
|
189
171
|
}
|
|
190
|
-
|
|
191
172
|
model.context.bindTexture(model.target, null);
|
|
192
173
|
}
|
|
193
174
|
}
|
|
194
|
-
};
|
|
195
|
-
|
|
175
|
+
};
|
|
196
176
|
|
|
197
|
-
|
|
177
|
+
//---------------------------------------------------------------------------
|
|
178
|
+
publicAPI.getTextureUnit = () => {
|
|
198
179
|
if (model._openGLRenderWindow) {
|
|
199
180
|
return model._openGLRenderWindow.getTextureUnitForTexture(publicAPI);
|
|
200
181
|
}
|
|
201
|
-
|
|
202
182
|
return -1;
|
|
203
|
-
};
|
|
204
|
-
|
|
183
|
+
};
|
|
205
184
|
|
|
206
|
-
|
|
185
|
+
//---------------------------------------------------------------------------
|
|
186
|
+
publicAPI.activate = () => {
|
|
207
187
|
// activate a free texture unit for this texture
|
|
208
188
|
model._openGLRenderWindow.activateTexture(publicAPI);
|
|
209
|
-
|
|
210
189
|
publicAPI.bind();
|
|
211
|
-
};
|
|
212
|
-
|
|
190
|
+
};
|
|
213
191
|
|
|
214
|
-
|
|
192
|
+
//---------------------------------------------------------------------------
|
|
193
|
+
publicAPI.deactivate = () => {
|
|
215
194
|
if (model._openGLRenderWindow) {
|
|
216
195
|
model._openGLRenderWindow.deactivateTexture(publicAPI);
|
|
217
196
|
}
|
|
218
|
-
};
|
|
219
|
-
|
|
197
|
+
};
|
|
220
198
|
|
|
221
|
-
|
|
199
|
+
//---------------------------------------------------------------------------
|
|
200
|
+
publicAPI.releaseGraphicsResources = rwin => {
|
|
222
201
|
if (rwin && model.handle) {
|
|
223
202
|
rwin.activateTexture(publicAPI);
|
|
224
203
|
rwin.deactivateTexture(publicAPI);
|
|
@@ -234,131 +213,112 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
234
213
|
model.height = 0;
|
|
235
214
|
model.depth = 0;
|
|
236
215
|
}
|
|
237
|
-
|
|
238
216
|
if (model.shaderProgram) {
|
|
239
217
|
model.shaderProgram.releaseGraphicsResources(rwin);
|
|
240
218
|
model.shaderProgram = null;
|
|
241
219
|
}
|
|
242
|
-
};
|
|
243
|
-
|
|
220
|
+
};
|
|
244
221
|
|
|
245
|
-
|
|
222
|
+
//----------------------------------------------------------------------------
|
|
223
|
+
publicAPI.bind = () => {
|
|
246
224
|
model.context.bindTexture(model.target, model.handle);
|
|
247
|
-
|
|
248
225
|
if (model.autoParameters && publicAPI.getMTime() > model.sendParametersTime.getMTime()) {
|
|
249
226
|
publicAPI.sendParameters();
|
|
250
227
|
}
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
publicAPI.isBound = function () {
|
|
255
|
-
var result = false;
|
|
228
|
+
};
|
|
256
229
|
|
|
230
|
+
//----------------------------------------------------------------------------
|
|
231
|
+
publicAPI.isBound = () => {
|
|
232
|
+
let result = false;
|
|
257
233
|
if (model.context && model.handle) {
|
|
258
|
-
|
|
259
|
-
|
|
234
|
+
let target = 0;
|
|
260
235
|
switch (model.target) {
|
|
261
236
|
case model.context.TEXTURE_2D:
|
|
262
237
|
target = model.context.TEXTURE_BINDING_2D;
|
|
263
238
|
break;
|
|
264
|
-
|
|
265
239
|
default:
|
|
266
240
|
vtkWarningMacro('impossible case');
|
|
267
241
|
break;
|
|
268
242
|
}
|
|
269
|
-
|
|
270
|
-
var oid = model.context.getIntegerv(target);
|
|
243
|
+
const oid = model.context.getIntegerv(target);
|
|
271
244
|
result = oid === model.handle;
|
|
272
245
|
}
|
|
273
|
-
|
|
274
246
|
return result;
|
|
275
|
-
};
|
|
276
|
-
|
|
247
|
+
};
|
|
277
248
|
|
|
278
|
-
|
|
249
|
+
//----------------------------------------------------------------------------
|
|
250
|
+
publicAPI.sendParameters = () => {
|
|
279
251
|
model.context.texParameteri(model.target, model.context.TEXTURE_WRAP_S, publicAPI.getOpenGLWrapMode(model.wrapS));
|
|
280
252
|
model.context.texParameteri(model.target, model.context.TEXTURE_WRAP_T, publicAPI.getOpenGLWrapMode(model.wrapT));
|
|
281
|
-
|
|
282
253
|
if (model._openGLRenderWindow.getWebgl2()) {
|
|
283
254
|
model.context.texParameteri(model.target, model.context.TEXTURE_WRAP_R, publicAPI.getOpenGLWrapMode(model.wrapR));
|
|
284
255
|
}
|
|
285
|
-
|
|
286
256
|
model.context.texParameteri(model.target, model.context.TEXTURE_MIN_FILTER, publicAPI.getOpenGLFilterMode(model.minificationFilter));
|
|
287
257
|
model.context.texParameteri(model.target, model.context.TEXTURE_MAG_FILTER, publicAPI.getOpenGLFilterMode(model.magnificationFilter));
|
|
288
|
-
|
|
289
258
|
if (model._openGLRenderWindow.getWebgl2()) {
|
|
290
259
|
model.context.texParameteri(model.target, model.context.TEXTURE_BASE_LEVEL, model.baseLevel);
|
|
291
260
|
model.context.texParameteri(model.target, model.context.TEXTURE_MAX_LEVEL, model.maxLevel);
|
|
292
|
-
}
|
|
293
|
-
// model.context.texParameterf(model.target, model.context.TEXTURE_MAX_LOD, model.maxLOD);
|
|
261
|
+
}
|
|
294
262
|
|
|
263
|
+
// model.context.texParameterf(model.target, model.context.TEXTURE_MIN_LOD, model.minLOD);
|
|
264
|
+
// model.context.texParameterf(model.target, model.context.TEXTURE_MAX_LOD, model.maxLOD);
|
|
295
265
|
|
|
296
266
|
model.sendParametersTime.modified();
|
|
297
|
-
};
|
|
298
|
-
|
|
267
|
+
};
|
|
299
268
|
|
|
300
|
-
|
|
269
|
+
//----------------------------------------------------------------------------
|
|
270
|
+
publicAPI.getInternalFormat = (vtktype, numComps) => {
|
|
301
271
|
if (!model._forceInternalFormat) {
|
|
302
272
|
model.internalFormat = publicAPI.getDefaultInternalFormat(vtktype, numComps);
|
|
303
273
|
}
|
|
304
|
-
|
|
305
274
|
if (!model.internalFormat) {
|
|
306
|
-
vtkDebugMacro(
|
|
275
|
+
vtkDebugMacro(`Unable to find suitable internal format for T=${vtktype} NC= ${numComps}`);
|
|
307
276
|
}
|
|
308
|
-
|
|
309
277
|
return model.internalFormat;
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
publicAPI.getDefaultInternalFormat = function (vtktype, numComps) {
|
|
314
|
-
var result = 0; // try default next
|
|
278
|
+
};
|
|
315
279
|
|
|
280
|
+
//----------------------------------------------------------------------------
|
|
281
|
+
publicAPI.getDefaultInternalFormat = (vtktype, numComps) => {
|
|
282
|
+
let result = 0;
|
|
283
|
+
// try default next
|
|
316
284
|
result = model._openGLRenderWindow.getDefaultTextureInternalFormat(vtktype, numComps, model.oglNorm16Ext, model.useHalfFloat);
|
|
317
|
-
|
|
318
285
|
if (result) {
|
|
319
286
|
return result;
|
|
320
287
|
}
|
|
321
|
-
|
|
322
288
|
if (!result) {
|
|
323
289
|
vtkDebugMacro('Unsupported internal texture type!');
|
|
324
|
-
vtkDebugMacro(
|
|
290
|
+
vtkDebugMacro(`Unable to find suitable internal format for T=${vtktype} NC= ${numComps}`);
|
|
325
291
|
}
|
|
326
|
-
|
|
327
292
|
return result;
|
|
328
|
-
};
|
|
329
|
-
|
|
293
|
+
};
|
|
330
294
|
|
|
331
|
-
|
|
295
|
+
//----------------------------------------------------------------------------
|
|
296
|
+
publicAPI.setInternalFormat = iFormat => {
|
|
332
297
|
model._forceInternalFormat = true;
|
|
333
|
-
|
|
334
298
|
if (iFormat !== model.internalFormat) {
|
|
335
299
|
model.internalFormat = iFormat;
|
|
336
300
|
publicAPI.modified();
|
|
337
301
|
}
|
|
338
|
-
};
|
|
339
|
-
|
|
302
|
+
};
|
|
340
303
|
|
|
341
|
-
|
|
304
|
+
//----------------------------------------------------------------------------
|
|
305
|
+
publicAPI.getFormat = (vtktype, numComps) => {
|
|
342
306
|
model.format = publicAPI.getDefaultFormat(vtktype, numComps);
|
|
343
307
|
return model.format;
|
|
344
|
-
};
|
|
345
|
-
|
|
308
|
+
};
|
|
346
309
|
|
|
347
|
-
|
|
310
|
+
//----------------------------------------------------------------------------
|
|
311
|
+
publicAPI.getDefaultFormat = (vtktype, numComps) => {
|
|
348
312
|
if (model._openGLRenderWindow.getWebgl2()) {
|
|
349
313
|
switch (numComps) {
|
|
350
314
|
case 1:
|
|
351
315
|
return model.context.RED;
|
|
352
|
-
|
|
353
316
|
case 2:
|
|
354
317
|
return model.context.RG;
|
|
355
|
-
|
|
356
318
|
case 3:
|
|
357
319
|
return model.context.RGB;
|
|
358
|
-
|
|
359
320
|
case 4:
|
|
360
321
|
return model.context.RGBA;
|
|
361
|
-
|
|
362
322
|
default:
|
|
363
323
|
return model.context.RGB;
|
|
364
324
|
}
|
|
@@ -367,32 +327,28 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
367
327
|
switch (numComps) {
|
|
368
328
|
case 1:
|
|
369
329
|
return model.context.LUMINANCE;
|
|
370
|
-
|
|
371
330
|
case 2:
|
|
372
331
|
return model.context.LUMINANCE_ALPHA;
|
|
373
|
-
|
|
374
332
|
case 3:
|
|
375
333
|
return model.context.RGB;
|
|
376
|
-
|
|
377
334
|
case 4:
|
|
378
335
|
return model.context.RGBA;
|
|
379
|
-
|
|
380
336
|
default:
|
|
381
337
|
return model.context.RGB;
|
|
382
338
|
}
|
|
383
339
|
}
|
|
384
|
-
};
|
|
385
|
-
|
|
340
|
+
};
|
|
386
341
|
|
|
387
|
-
|
|
342
|
+
//----------------------------------------------------------------------------
|
|
343
|
+
publicAPI.resetFormatAndType = () => {
|
|
388
344
|
model.format = 0;
|
|
389
345
|
model.internalFormat = 0;
|
|
390
346
|
model._forceInternalFormat = false;
|
|
391
347
|
model.openGLDataType = 0;
|
|
392
|
-
};
|
|
393
|
-
|
|
348
|
+
};
|
|
394
349
|
|
|
395
|
-
|
|
350
|
+
//----------------------------------------------------------------------------
|
|
351
|
+
publicAPI.getDefaultDataType = vtkScalarType => {
|
|
396
352
|
// DON'T DEAL with VTK_CHAR as this is platform dependent.
|
|
397
353
|
if (model._openGLRenderWindow.getWebgl2()) {
|
|
398
354
|
switch (vtkScalarType) {
|
|
@@ -402,32 +358,25 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
402
358
|
return model.context.UNSIGNED_BYTE;
|
|
403
359
|
// prefer norm16 since that is accurate compared to
|
|
404
360
|
// half float which is not
|
|
405
|
-
|
|
406
361
|
case model.oglNorm16Ext && !model.useHalfFloat && VtkDataTypes.SHORT:
|
|
407
362
|
return model.context.SHORT;
|
|
408
|
-
|
|
409
363
|
case model.oglNorm16Ext && !model.useHalfFloat && VtkDataTypes.UNSIGNED_SHORT:
|
|
410
364
|
return model.context.UNSIGNED_SHORT;
|
|
411
365
|
// use half float type
|
|
412
|
-
|
|
413
366
|
case model.useHalfFloat && VtkDataTypes.SHORT:
|
|
414
367
|
return model.context.HALF_FLOAT;
|
|
415
|
-
|
|
416
368
|
case model.useHalfFloat && VtkDataTypes.UNSIGNED_SHORT:
|
|
417
369
|
return model.context.HALF_FLOAT;
|
|
418
370
|
// case VtkDataTypes.INT:
|
|
419
371
|
// return model.context.INT;
|
|
420
372
|
// case VtkDataTypes.UNSIGNED_INT:
|
|
421
373
|
// return model.context.UNSIGNED_INT;
|
|
422
|
-
|
|
423
374
|
case VtkDataTypes.FLOAT:
|
|
424
375
|
case VtkDataTypes.VOID: // used for depth component textures.
|
|
425
|
-
|
|
426
376
|
default:
|
|
427
377
|
return model.context.FLOAT;
|
|
428
378
|
}
|
|
429
379
|
}
|
|
430
|
-
|
|
431
380
|
switch (vtkScalarType) {
|
|
432
381
|
// case VtkDataTypes.SIGNED_CHAR:
|
|
433
382
|
// return model.context.BYTE;
|
|
@@ -441,225 +390,192 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
441
390
|
// return model.context.INT;
|
|
442
391
|
// case VtkDataTypes.UNSIGNED_INT:
|
|
443
392
|
// return model.context.UNSIGNED_INT;
|
|
444
|
-
|
|
445
393
|
case VtkDataTypes.FLOAT:
|
|
446
394
|
case VtkDataTypes.VOID: // used for depth component textures.
|
|
447
|
-
|
|
448
395
|
default:
|
|
449
396
|
if (model.context.getExtension('OES_texture_float') && model.context.getExtension('OES_texture_float_linear')) {
|
|
450
397
|
return model.context.FLOAT;
|
|
451
398
|
}
|
|
452
|
-
|
|
453
399
|
{
|
|
454
|
-
|
|
455
|
-
|
|
400
|
+
const halfFloat = model.context.getExtension('OES_texture_half_float');
|
|
456
401
|
if (halfFloat && model.context.getExtension('OES_texture_half_float_linear')) {
|
|
457
402
|
return halfFloat.HALF_FLOAT_OES;
|
|
458
403
|
}
|
|
459
404
|
}
|
|
460
405
|
return model.context.UNSIGNED_BYTE;
|
|
461
406
|
}
|
|
462
|
-
};
|
|
463
|
-
|
|
407
|
+
};
|
|
464
408
|
|
|
409
|
+
//----------------------------------------------------------------------------
|
|
465
410
|
publicAPI.getOpenGLDataType = function (vtkScalarType) {
|
|
466
|
-
|
|
467
|
-
|
|
411
|
+
let forceUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
468
412
|
if (!model.openGLDataType || forceUpdate) {
|
|
469
413
|
model.openGLDataType = publicAPI.getDefaultDataType(vtkScalarType);
|
|
470
414
|
}
|
|
471
|
-
|
|
472
415
|
return model.openGLDataType;
|
|
473
416
|
};
|
|
417
|
+
publicAPI.getShiftAndScale = () => {
|
|
418
|
+
let shift = 0.0;
|
|
419
|
+
let scale = 1.0;
|
|
474
420
|
|
|
475
|
-
|
|
476
|
-
var shift = 0.0;
|
|
477
|
-
var scale = 1.0; // for all float type internal formats
|
|
478
|
-
|
|
421
|
+
// for all float type internal formats
|
|
479
422
|
switch (model.openGLDataType) {
|
|
480
423
|
case model.context.BYTE:
|
|
481
424
|
scale = 127.5;
|
|
482
425
|
shift = scale - 128.0;
|
|
483
426
|
break;
|
|
484
|
-
|
|
485
427
|
case model.context.UNSIGNED_BYTE:
|
|
486
428
|
scale = 255.0;
|
|
487
429
|
shift = 0.0;
|
|
488
430
|
break;
|
|
489
|
-
|
|
490
431
|
case model.context.SHORT:
|
|
491
432
|
scale = 32767.5;
|
|
492
433
|
shift = scale - 32768.0;
|
|
493
434
|
break;
|
|
494
|
-
|
|
495
435
|
case model.context.UNSIGNED_SHORT:
|
|
496
436
|
scale = 65536.0;
|
|
497
437
|
shift = 0.0;
|
|
498
438
|
break;
|
|
499
|
-
|
|
500
439
|
case model.context.INT:
|
|
501
440
|
scale = 2147483647.5;
|
|
502
441
|
shift = scale - 2147483648.0;
|
|
503
442
|
break;
|
|
504
|
-
|
|
505
443
|
case model.context.UNSIGNED_INT:
|
|
506
444
|
scale = 4294967295.0;
|
|
507
445
|
shift = 0.0;
|
|
508
446
|
break;
|
|
509
|
-
|
|
510
447
|
case model.context.FLOAT:
|
|
511
448
|
}
|
|
512
|
-
|
|
513
449
|
return {
|
|
514
|
-
shift
|
|
515
|
-
scale
|
|
450
|
+
shift,
|
|
451
|
+
scale
|
|
516
452
|
};
|
|
517
|
-
};
|
|
518
|
-
|
|
453
|
+
};
|
|
519
454
|
|
|
520
|
-
|
|
455
|
+
//----------------------------------------------------------------------------
|
|
456
|
+
publicAPI.getOpenGLFilterMode = emode => {
|
|
521
457
|
switch (emode) {
|
|
522
458
|
case Filter.NEAREST:
|
|
523
459
|
return model.context.NEAREST;
|
|
524
|
-
|
|
525
460
|
case Filter.LINEAR:
|
|
526
461
|
return model.context.LINEAR;
|
|
527
|
-
|
|
528
462
|
case Filter.NEAREST_MIPMAP_NEAREST:
|
|
529
463
|
return model.context.NEAREST_MIPMAP_NEAREST;
|
|
530
|
-
|
|
531
464
|
case Filter.NEAREST_MIPMAP_LINEAR:
|
|
532
465
|
return model.context.NEAREST_MIPMAP_LINEAR;
|
|
533
|
-
|
|
534
466
|
case Filter.LINEAR_MIPMAP_NEAREST:
|
|
535
467
|
return model.context.LINEAR_MIPMAP_NEAREST;
|
|
536
|
-
|
|
537
468
|
case Filter.LINEAR_MIPMAP_LINEAR:
|
|
538
469
|
return model.context.LINEAR_MIPMAP_LINEAR;
|
|
539
|
-
|
|
540
470
|
default:
|
|
541
471
|
return model.context.NEAREST;
|
|
542
472
|
}
|
|
543
|
-
};
|
|
544
|
-
|
|
473
|
+
};
|
|
545
474
|
|
|
546
|
-
|
|
475
|
+
//----------------------------------------------------------------------------
|
|
476
|
+
publicAPI.getOpenGLWrapMode = vtktype => {
|
|
547
477
|
switch (vtktype) {
|
|
548
478
|
case Wrap.CLAMP_TO_EDGE:
|
|
549
479
|
return model.context.CLAMP_TO_EDGE;
|
|
550
|
-
|
|
551
480
|
case Wrap.REPEAT:
|
|
552
481
|
return model.context.REPEAT;
|
|
553
|
-
|
|
554
482
|
case Wrap.MIRRORED_REPEAT:
|
|
555
483
|
return model.context.MIRRORED_REPEAT;
|
|
556
|
-
|
|
557
484
|
default:
|
|
558
485
|
return model.context.CLAMP_TO_EDGE;
|
|
559
486
|
}
|
|
560
|
-
};
|
|
561
|
-
|
|
487
|
+
};
|
|
562
488
|
|
|
489
|
+
//----------------------------------------------------------------------------
|
|
563
490
|
function updateArrayDataType(dataType, data) {
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
491
|
+
let depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
492
|
+
const pixData = [];
|
|
493
|
+
let pixCount = model.width * model.height * model.components;
|
|
568
494
|
if (depth) {
|
|
569
495
|
pixCount *= model.depth;
|
|
570
|
-
}
|
|
571
|
-
// then the data array must be float
|
|
572
|
-
|
|
496
|
+
}
|
|
573
497
|
|
|
498
|
+
// if the opengl data type is float
|
|
499
|
+
// then the data array must be float
|
|
574
500
|
if (dataType !== VtkDataTypes.FLOAT && model.openGLDataType === model.context.FLOAT) {
|
|
575
|
-
for (
|
|
501
|
+
for (let idx = 0; idx < data.length; idx++) {
|
|
576
502
|
if (data[idx]) {
|
|
577
|
-
|
|
503
|
+
const dataArrayToCopy = data[idx].length > pixCount ? data[idx].subarray(0, pixCount) : data[idx];
|
|
578
504
|
pixData.push(new Float32Array(dataArrayToCopy));
|
|
579
505
|
} else {
|
|
580
506
|
pixData.push(null);
|
|
581
507
|
}
|
|
582
508
|
}
|
|
583
|
-
}
|
|
584
|
-
// then the data array must be u8, we currently simply truncate the data
|
|
585
|
-
|
|
509
|
+
}
|
|
586
510
|
|
|
511
|
+
// if the opengl data type is ubyte
|
|
512
|
+
// then the data array must be u8, we currently simply truncate the data
|
|
587
513
|
if (dataType !== VtkDataTypes.UNSIGNED_CHAR && model.openGLDataType === model.context.UNSIGNED_BYTE) {
|
|
588
|
-
for (
|
|
589
|
-
if (data[
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
pixData.push(new Uint8Array(_dataArrayToCopy));
|
|
514
|
+
for (let idx = 0; idx < data.length; idx++) {
|
|
515
|
+
if (data[idx]) {
|
|
516
|
+
const dataArrayToCopy = data[idx].length > pixCount ? data[idx].subarray(0, pixCount) : data[idx];
|
|
517
|
+
pixData.push(new Uint8Array(dataArrayToCopy));
|
|
593
518
|
} else {
|
|
594
519
|
pixData.push(null);
|
|
595
520
|
}
|
|
596
521
|
}
|
|
597
|
-
}
|
|
598
|
-
// then the data array must be u16
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
var halfFloat = false;
|
|
522
|
+
}
|
|
602
523
|
|
|
524
|
+
// if the opengl data type is half float
|
|
525
|
+
// then the data array must be u16
|
|
526
|
+
let halfFloat = false;
|
|
603
527
|
if (model._openGLRenderWindow.getWebgl2()) {
|
|
604
528
|
halfFloat = model.openGLDataType === model.context.HALF_FLOAT;
|
|
605
529
|
} else {
|
|
606
|
-
|
|
530
|
+
const halfFloatExt = model.context.getExtension('OES_texture_half_float');
|
|
607
531
|
halfFloat = halfFloatExt && model.openGLDataType === halfFloatExt.HALF_FLOAT_OES;
|
|
608
532
|
}
|
|
609
|
-
|
|
610
533
|
if (halfFloat) {
|
|
611
|
-
for (
|
|
612
|
-
if (data[
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
for (var i = 0; i < pixCount; i++) {
|
|
534
|
+
for (let idx = 0; idx < data.length; idx++) {
|
|
535
|
+
if (data[idx]) {
|
|
536
|
+
const newArray = new Uint16Array(pixCount);
|
|
537
|
+
const src = data[idx];
|
|
538
|
+
for (let i = 0; i < pixCount; i++) {
|
|
617
539
|
newArray[i] = toHalf(src[i]);
|
|
618
540
|
}
|
|
619
|
-
|
|
620
541
|
pixData.push(newArray);
|
|
621
542
|
} else {
|
|
622
543
|
pixData.push(null);
|
|
623
544
|
}
|
|
624
545
|
}
|
|
625
|
-
}
|
|
626
|
-
|
|
546
|
+
}
|
|
627
547
|
|
|
548
|
+
// The output has to be filled
|
|
628
549
|
if (pixData.length === 0) {
|
|
629
|
-
for (
|
|
630
|
-
pixData.push(data[
|
|
550
|
+
for (let i = 0; i < data.length; i++) {
|
|
551
|
+
pixData.push(data[i]);
|
|
631
552
|
}
|
|
632
553
|
}
|
|
633
|
-
|
|
634
554
|
return pixData;
|
|
635
|
-
}
|
|
636
|
-
|
|
555
|
+
}
|
|
637
556
|
|
|
557
|
+
//----------------------------------------------------------------------------
|
|
638
558
|
function scaleTextureToHighestPowerOfTwo(data) {
|
|
639
559
|
if (model._openGLRenderWindow.getWebgl2()) {
|
|
640
560
|
// No need if webGL2
|
|
641
561
|
return data;
|
|
642
562
|
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
var numComps = model.components;
|
|
648
|
-
|
|
563
|
+
const pixData = [];
|
|
564
|
+
const width = model.width;
|
|
565
|
+
const height = model.height;
|
|
566
|
+
const numComps = model.components;
|
|
649
567
|
if (data && (!isPowerOfTwo(width) || !isPowerOfTwo(height))) {
|
|
650
568
|
// Scale up the texture to the next highest power of two dimensions.
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
for (var idx = 0; idx < data.length; idx++) {
|
|
569
|
+
const halfFloat = model.context.getExtension('OES_texture_half_float');
|
|
570
|
+
const newWidth = nearestPowerOfTwo(width);
|
|
571
|
+
const newHeight = nearestPowerOfTwo(height);
|
|
572
|
+
const pixCount = newWidth * newHeight * model.components;
|
|
573
|
+
for (let idx = 0; idx < data.length; idx++) {
|
|
657
574
|
if (data[idx] !== null) {
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
575
|
+
let newArray = null;
|
|
576
|
+
const jFactor = height / newHeight;
|
|
577
|
+
const iFactor = width / newWidth;
|
|
578
|
+
let usingHalf = false;
|
|
663
579
|
if (model.openGLDataType === model.context.FLOAT) {
|
|
664
580
|
newArray = new Float32Array(pixCount);
|
|
665
581
|
} else if (halfFloat && model.openGLDataType === halfFloat.HALF_FLOAT_OES) {
|
|
@@ -668,37 +584,30 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
668
584
|
} else {
|
|
669
585
|
newArray = new Uint8Array(pixCount);
|
|
670
586
|
}
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
var jhi = Math.ceil(jidx);
|
|
677
|
-
|
|
587
|
+
for (let j = 0; j < newHeight; j++) {
|
|
588
|
+
const joff = j * newWidth * numComps;
|
|
589
|
+
const jidx = j * jFactor;
|
|
590
|
+
let jlow = Math.floor(jidx);
|
|
591
|
+
let jhi = Math.ceil(jidx);
|
|
678
592
|
if (jhi >= height) {
|
|
679
593
|
jhi = height - 1;
|
|
680
594
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
var jmix1 = 1.0 - jmix;
|
|
595
|
+
const jmix = jidx - jlow;
|
|
596
|
+
const jmix1 = 1.0 - jmix;
|
|
684
597
|
jlow = jlow * width * numComps;
|
|
685
598
|
jhi = jhi * width * numComps;
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
var ihi = Math.ceil(iidx);
|
|
692
|
-
|
|
599
|
+
for (let i = 0; i < newWidth; i++) {
|
|
600
|
+
const ioff = i * numComps;
|
|
601
|
+
const iidx = i * iFactor;
|
|
602
|
+
let ilow = Math.floor(iidx);
|
|
603
|
+
let ihi = Math.ceil(iidx);
|
|
693
604
|
if (ihi >= width) {
|
|
694
605
|
ihi = width - 1;
|
|
695
606
|
}
|
|
696
|
-
|
|
697
|
-
var imix = iidx - ilow;
|
|
607
|
+
const imix = iidx - ilow;
|
|
698
608
|
ilow *= numComps;
|
|
699
609
|
ihi *= numComps;
|
|
700
|
-
|
|
701
|
-
for (var c = 0; c < numComps; c++) {
|
|
610
|
+
for (let c = 0; c < numComps; c++) {
|
|
702
611
|
if (usingHalf) {
|
|
703
612
|
newArray[joff + ioff + c] = HalfFloat.toHalf(HalfFloat.fromHalf(data[idx][jlow + ilow + c]) * jmix1 * (1.0 - imix) + HalfFloat.fromHalf(data[idx][jlow + ihi + c]) * jmix1 * imix + HalfFloat.fromHalf(data[idx][jhi + ilow + c]) * jmix * (1.0 - imix) + HalfFloat.fromHalf(data[idx][jhi + ihi + c]) * jmix * imix);
|
|
704
613
|
} else {
|
|
@@ -707,7 +616,6 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
707
616
|
}
|
|
708
617
|
}
|
|
709
618
|
}
|
|
710
|
-
|
|
711
619
|
pixData.push(newArray);
|
|
712
620
|
model.width = newWidth;
|
|
713
621
|
model.height = newHeight;
|
|
@@ -715,200 +623,174 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
715
623
|
pixData.push(null);
|
|
716
624
|
}
|
|
717
625
|
}
|
|
718
|
-
}
|
|
719
|
-
|
|
626
|
+
}
|
|
720
627
|
|
|
628
|
+
// The output has to be filled
|
|
721
629
|
if (pixData.length === 0) {
|
|
722
|
-
for (
|
|
723
|
-
pixData.push(data[
|
|
630
|
+
for (let i = 0; i < data.length; i++) {
|
|
631
|
+
pixData.push(data[i]);
|
|
724
632
|
}
|
|
725
633
|
}
|
|
726
|
-
|
|
727
634
|
return pixData;
|
|
728
|
-
}
|
|
729
|
-
|
|
635
|
+
}
|
|
730
636
|
|
|
637
|
+
//----------------------------------------------------------------------------
|
|
731
638
|
function useTexStorage(dataType) {
|
|
732
639
|
if (model._openGLRenderWindow) {
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
if (model.resizable || (_model$renderable = model.renderable) !== null && _model$renderable !== void 0 && _model$renderable.getResizable()) {
|
|
640
|
+
if (model.resizable || model.renderable?.getResizable()) {
|
|
736
641
|
// Cannot use texStorage if the texture is supposed to be resizable.
|
|
737
642
|
return false;
|
|
738
643
|
}
|
|
739
|
-
|
|
740
644
|
if (model._openGLRenderWindow.getWebgl2()) {
|
|
741
|
-
|
|
742
|
-
|
|
645
|
+
const webGLInfo = model._openGLRenderWindow.getGLInformations();
|
|
743
646
|
if (webGLInfo.RENDERER.value.match(/WebKit/gi) && navigator.platform.match(/Mac/gi) && model.oglNorm16Ext && (dataType === VtkDataTypes.UNSIGNED_SHORT || dataType === VtkDataTypes.SHORT)) {
|
|
744
647
|
// Cannot use texStorage with EXT_texture_norm16 textures on Mac M1 GPU.
|
|
745
648
|
// No errors reported but the texture is unusable.
|
|
746
649
|
return false;
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
|
|
650
|
+
}
|
|
651
|
+
// Use texStorage for WebGL2
|
|
750
652
|
return true;
|
|
751
653
|
}
|
|
752
|
-
|
|
753
654
|
return false;
|
|
754
655
|
}
|
|
755
|
-
|
|
756
656
|
return false;
|
|
757
|
-
}
|
|
758
|
-
|
|
657
|
+
}
|
|
759
658
|
|
|
659
|
+
//----------------------------------------------------------------------------
|
|
760
660
|
publicAPI.create2DFromRaw = function (width, height, numComps, dataType, data) {
|
|
761
|
-
|
|
661
|
+
let flip = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
762
662
|
// Now determine the texture parameters using the arguments.
|
|
763
663
|
publicAPI.getOpenGLDataType(dataType, true);
|
|
764
664
|
publicAPI.getInternalFormat(dataType, numComps);
|
|
765
665
|
publicAPI.getFormat(dataType, numComps);
|
|
766
|
-
|
|
767
666
|
if (!model.internalFormat || !model.format || !model.openGLDataType) {
|
|
768
667
|
vtkErrorMacro('Failed to determine texture parameters.');
|
|
769
668
|
return false;
|
|
770
669
|
}
|
|
771
|
-
|
|
772
670
|
model.target = model.context.TEXTURE_2D;
|
|
773
671
|
model.components = numComps;
|
|
774
672
|
model.width = width;
|
|
775
673
|
model.height = height;
|
|
776
674
|
model.depth = 1;
|
|
777
675
|
model.numberOfDimensions = 2;
|
|
778
|
-
|
|
779
676
|
model._openGLRenderWindow.activateTexture(publicAPI);
|
|
780
|
-
|
|
781
677
|
publicAPI.createTexture();
|
|
782
|
-
publicAPI.bind();
|
|
678
|
+
publicAPI.bind();
|
|
783
679
|
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
680
|
+
// Create an array of texture with one texture
|
|
681
|
+
const dataArray = [data];
|
|
682
|
+
const pixData = updateArrayDataType(dataType, dataArray);
|
|
683
|
+
const scaledData = scaleTextureToHighestPowerOfTwo(pixData);
|
|
787
684
|
|
|
685
|
+
// Source texture data from the PBO.
|
|
788
686
|
model.context.pixelStorei(model.context.UNPACK_FLIP_Y_WEBGL, flip);
|
|
789
687
|
model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1);
|
|
790
|
-
|
|
791
688
|
if (useTexStorage(dataType)) {
|
|
792
689
|
model.context.texStorage2D(model.target, 1, model.internalFormat, model.width, model.height);
|
|
793
|
-
|
|
794
690
|
if (scaledData[0] != null) {
|
|
795
691
|
model.context.texSubImage2D(model.target, 0, 0, 0, model.width, model.height, model.format, model.openGLDataType, scaledData[0]);
|
|
796
692
|
}
|
|
797
693
|
} else {
|
|
798
694
|
model.context.texImage2D(model.target, 0, model.internalFormat, model.width, model.height, 0, model.format, model.openGLDataType, scaledData[0]);
|
|
799
695
|
}
|
|
800
|
-
|
|
801
696
|
if (model.generateMipmap) {
|
|
802
697
|
model.context.generateMipmap(model.target);
|
|
803
|
-
}
|
|
804
|
-
|
|
698
|
+
}
|
|
805
699
|
|
|
700
|
+
// always reset the flip
|
|
806
701
|
if (flip) {
|
|
807
702
|
model.context.pixelStorei(model.context.UNPACK_FLIP_Y_WEBGL, false);
|
|
808
703
|
}
|
|
809
|
-
|
|
810
704
|
publicAPI.deactivate();
|
|
811
705
|
return true;
|
|
812
|
-
};
|
|
813
|
-
|
|
706
|
+
};
|
|
814
707
|
|
|
815
|
-
|
|
708
|
+
//----------------------------------------------------------------------------
|
|
709
|
+
publicAPI.createCubeFromRaw = (width, height, numComps, dataType, data) => {
|
|
816
710
|
// Now determine the texture parameters using the arguments.
|
|
817
711
|
publicAPI.getOpenGLDataType(dataType);
|
|
818
712
|
publicAPI.getInternalFormat(dataType, numComps);
|
|
819
713
|
publicAPI.getFormat(dataType, numComps);
|
|
820
|
-
|
|
821
714
|
if (!model.internalFormat || !model.format || !model.openGLDataType) {
|
|
822
715
|
vtkErrorMacro('Failed to determine texture parameters.');
|
|
823
716
|
return false;
|
|
824
717
|
}
|
|
825
|
-
|
|
826
718
|
model.target = model.context.TEXTURE_CUBE_MAP;
|
|
827
719
|
model.components = numComps;
|
|
828
720
|
model.width = width;
|
|
829
721
|
model.height = height;
|
|
830
722
|
model.depth = 1;
|
|
831
723
|
model.numberOfDimensions = 2;
|
|
832
|
-
|
|
833
724
|
model._openGLRenderWindow.activateTexture(publicAPI);
|
|
834
|
-
|
|
835
725
|
model.maxLevel = data.length / 6 - 1;
|
|
836
726
|
publicAPI.createTexture();
|
|
837
727
|
publicAPI.bind();
|
|
838
|
-
|
|
839
|
-
|
|
728
|
+
const pixData = updateArrayDataType(dataType, data);
|
|
729
|
+
const scaledData = scaleTextureToHighestPowerOfTwo(pixData);
|
|
730
|
+
|
|
731
|
+
// invert the data because opengl is messed up with cube maps
|
|
840
732
|
// and uses the old renderman standard with Y going down
|
|
841
733
|
// even though it is completely at odds with OpenGL standards
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
for (var i = 0; i < scaledData.length; i++) {
|
|
734
|
+
const invertedData = [];
|
|
735
|
+
let widthLevel = model.width;
|
|
736
|
+
let heightLevel = model.height;
|
|
737
|
+
for (let i = 0; i < scaledData.length; i++) {
|
|
848
738
|
if (i % 6 === 0 && i !== 0) {
|
|
849
739
|
widthLevel /= 2;
|
|
850
740
|
heightLevel /= 2;
|
|
851
741
|
}
|
|
852
|
-
|
|
853
742
|
invertedData[i] = newTypedArray(dataType, heightLevel * widthLevel * model.components);
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
var row2 = (heightLevel - y - 1) * widthLevel * model.components;
|
|
743
|
+
for (let y = 0; y < heightLevel; ++y) {
|
|
744
|
+
const row1 = y * widthLevel * model.components;
|
|
745
|
+
const row2 = (heightLevel - y - 1) * widthLevel * model.components;
|
|
858
746
|
invertedData[i].set(scaledData[i].slice(row2, row2 + widthLevel * model.components), row1);
|
|
859
747
|
}
|
|
860
|
-
}
|
|
861
|
-
|
|
748
|
+
}
|
|
862
749
|
|
|
750
|
+
// Source texture data from the PBO.
|
|
863
751
|
model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1);
|
|
864
|
-
|
|
865
752
|
if (useTexStorage(dataType)) {
|
|
866
753
|
model.context.texStorage2D(model.target, 6, model.internalFormat, model.width, model.height);
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
for (var _i3 = 0; _i3 < 6; _i3++) {
|
|
754
|
+
}
|
|
755
|
+
// We get the 6 images
|
|
756
|
+
for (let i = 0; i < 6; i++) {
|
|
871
757
|
// For each mipmap level
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
758
|
+
let j = 0;
|
|
759
|
+
let w = model.width;
|
|
760
|
+
let h = model.height;
|
|
876
761
|
while (w >= 1 && h >= 1) {
|
|
877
762
|
// In webgl 1, all levels need to be defined. So if the latest level size is
|
|
878
763
|
// 8x8, we have to add 3 more null textures (4x4, 2x2, 1x1)
|
|
879
764
|
// In webgl 2, the attribute maxLevel will be use.
|
|
880
|
-
|
|
881
|
-
|
|
765
|
+
let tempData = null;
|
|
882
766
|
if (j <= model.maxLevel) {
|
|
883
|
-
tempData = invertedData[6 * j +
|
|
767
|
+
tempData = invertedData[6 * j + i];
|
|
884
768
|
}
|
|
885
|
-
|
|
886
769
|
if (useTexStorage(dataType)) {
|
|
887
770
|
if (tempData != null) {
|
|
888
|
-
model.context.texSubImage2D(model.context.TEXTURE_CUBE_MAP_POSITIVE_X +
|
|
771
|
+
model.context.texSubImage2D(model.context.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, 0, 0, w, h, model.format, model.openGLDataType, tempData);
|
|
889
772
|
}
|
|
890
773
|
} else {
|
|
891
|
-
model.context.texImage2D(model.context.TEXTURE_CUBE_MAP_POSITIVE_X +
|
|
774
|
+
model.context.texImage2D(model.context.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, model.internalFormat, w, h, 0, model.format, model.openGLDataType, tempData);
|
|
892
775
|
}
|
|
893
|
-
|
|
894
776
|
j++;
|
|
895
777
|
w /= 2;
|
|
896
778
|
h /= 2;
|
|
897
779
|
}
|
|
898
|
-
}
|
|
899
|
-
// if it is called, all levels will be overwritten
|
|
780
|
+
}
|
|
900
781
|
|
|
782
|
+
// generateMipmap must not be called here because we manually upload all levels
|
|
783
|
+
// if it is called, all levels will be overwritten
|
|
901
784
|
|
|
902
785
|
publicAPI.deactivate();
|
|
903
786
|
return true;
|
|
904
|
-
};
|
|
905
|
-
|
|
787
|
+
};
|
|
906
788
|
|
|
907
|
-
|
|
789
|
+
//----------------------------------------------------------------------------
|
|
790
|
+
publicAPI.createDepthFromRaw = (width, height, dataType, data) => {
|
|
908
791
|
// Now determine the texture parameters using the arguments.
|
|
909
792
|
publicAPI.getOpenGLDataType(dataType);
|
|
910
793
|
model.format = model.context.DEPTH_COMPONENT;
|
|
911
|
-
|
|
912
794
|
if (model._openGLRenderWindow.getWebgl2()) {
|
|
913
795
|
if (dataType === VtkDataTypes.FLOAT) {
|
|
914
796
|
model.internalFormat = model.context.DEPTH_COMPONENT32F;
|
|
@@ -918,402 +800,358 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
918
800
|
} else {
|
|
919
801
|
model.internalFormat = model.context.DEPTH_COMPONENT;
|
|
920
802
|
}
|
|
921
|
-
|
|
922
803
|
if (!model.internalFormat || !model.format || !model.openGLDataType) {
|
|
923
804
|
vtkErrorMacro('Failed to determine texture parameters.');
|
|
924
805
|
return false;
|
|
925
806
|
}
|
|
926
|
-
|
|
927
807
|
model.target = model.context.TEXTURE_2D;
|
|
928
808
|
model.components = 1;
|
|
929
809
|
model.width = width;
|
|
930
810
|
model.height = height;
|
|
931
811
|
model.depth = 1;
|
|
932
812
|
model.numberOfDimensions = 2;
|
|
933
|
-
|
|
934
813
|
model._openGLRenderWindow.activateTexture(publicAPI);
|
|
935
|
-
|
|
936
814
|
publicAPI.createTexture();
|
|
937
|
-
publicAPI.bind();
|
|
938
|
-
// model.context.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
|
|
815
|
+
publicAPI.bind();
|
|
939
816
|
|
|
817
|
+
// Source texture data from the PBO.
|
|
818
|
+
// model.context.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
|
|
940
819
|
model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1);
|
|
941
|
-
|
|
942
820
|
if (useTexStorage(dataType)) {
|
|
943
821
|
model.context.texStorage2D(model.target, 1, model.internalFormat, model.width, model.height);
|
|
944
|
-
|
|
945
822
|
if (data != null) {
|
|
946
823
|
model.context.texSubImage2D(model.target, 0, 0, 0, model.width, model.height, model.format, model.openGLDataType, data);
|
|
947
824
|
}
|
|
948
825
|
} else {
|
|
949
826
|
model.context.texImage2D(model.target, 0, model.internalFormat, model.width, model.height, 0, model.format, model.openGLDataType, data);
|
|
950
827
|
}
|
|
951
|
-
|
|
952
828
|
if (model.generateMipmap) {
|
|
953
829
|
model.context.generateMipmap(model.target);
|
|
954
830
|
}
|
|
955
|
-
|
|
956
831
|
publicAPI.deactivate();
|
|
957
832
|
return true;
|
|
958
|
-
};
|
|
959
|
-
|
|
833
|
+
};
|
|
960
834
|
|
|
961
|
-
|
|
835
|
+
//----------------------------------------------------------------------------
|
|
836
|
+
publicAPI.create2DFromImage = image => {
|
|
962
837
|
// Now determine the texture parameters using the arguments.
|
|
963
838
|
publicAPI.getOpenGLDataType(VtkDataTypes.UNSIGNED_CHAR);
|
|
964
839
|
publicAPI.getInternalFormat(VtkDataTypes.UNSIGNED_CHAR, 4);
|
|
965
840
|
publicAPI.getFormat(VtkDataTypes.UNSIGNED_CHAR, 4);
|
|
966
|
-
|
|
967
841
|
if (!model.internalFormat || !model.format || !model.openGLDataType) {
|
|
968
842
|
vtkErrorMacro('Failed to determine texture parameters.');
|
|
969
843
|
return false;
|
|
970
844
|
}
|
|
971
|
-
|
|
972
845
|
model.target = model.context.TEXTURE_2D;
|
|
973
846
|
model.components = 4;
|
|
974
847
|
model.depth = 1;
|
|
975
848
|
model.numberOfDimensions = 2;
|
|
976
|
-
|
|
977
849
|
model._openGLRenderWindow.activateTexture(publicAPI);
|
|
978
|
-
|
|
979
850
|
publicAPI.createTexture();
|
|
980
|
-
publicAPI.bind();
|
|
981
|
-
// model.context.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
|
|
851
|
+
publicAPI.bind();
|
|
982
852
|
|
|
983
|
-
|
|
853
|
+
// Source texture data from the PBO.
|
|
854
|
+
// model.context.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
|
|
855
|
+
model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1);
|
|
984
856
|
|
|
985
|
-
|
|
986
|
-
|
|
857
|
+
// Scale up the texture to the next highest power of two dimensions (if needed) and flip y.
|
|
858
|
+
const needNearestPowerOfTwo = !model._openGLRenderWindow.getWebgl2() && (!isPowerOfTwo(image.width) || !isPowerOfTwo(image.height));
|
|
859
|
+
const canvas = document.createElement('canvas');
|
|
987
860
|
canvas.width = needNearestPowerOfTwo ? nearestPowerOfTwo(image.width) : image.width;
|
|
988
861
|
canvas.height = needNearestPowerOfTwo ? nearestPowerOfTwo(image.height) : image.height;
|
|
989
862
|
model.width = canvas.width;
|
|
990
863
|
model.height = canvas.height;
|
|
991
|
-
|
|
864
|
+
const ctx = canvas.getContext('2d');
|
|
992
865
|
ctx.translate(0, canvas.height);
|
|
993
866
|
ctx.scale(1, -1);
|
|
994
867
|
ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, canvas.width, canvas.height);
|
|
995
|
-
|
|
996
|
-
|
|
868
|
+
const safeImage = canvas;
|
|
997
869
|
if (useTexStorage(VtkDataTypes.UNSIGNED_CHAR)) {
|
|
998
870
|
model.context.texStorage2D(model.target, 1, model.internalFormat, model.width, model.height);
|
|
999
|
-
|
|
1000
871
|
if (safeImage != null) {
|
|
1001
872
|
model.context.texSubImage2D(model.target, 0, 0, 0, model.width, model.height, model.format, model.openGLDataType, safeImage);
|
|
1002
873
|
}
|
|
1003
874
|
} else {
|
|
1004
875
|
model.context.texImage2D(model.target, 0, model.internalFormat, model.width, model.height, 0, model.format, model.openGLDataType, safeImage);
|
|
1005
876
|
}
|
|
1006
|
-
|
|
1007
877
|
if (model.generateMipmap) {
|
|
1008
878
|
model.context.generateMipmap(model.target);
|
|
1009
879
|
}
|
|
1010
|
-
|
|
1011
880
|
publicAPI.deactivate();
|
|
1012
881
|
return true;
|
|
1013
|
-
};
|
|
1014
|
-
|
|
882
|
+
};
|
|
1015
883
|
|
|
884
|
+
// Compute scale and offset per component from min and max per component
|
|
1016
885
|
function computeScaleOffsets(min, max, numComps) {
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
for (var c = 0; c < numComps; ++c) {
|
|
886
|
+
const offset = new Array(numComps);
|
|
887
|
+
const scale = new Array(numComps);
|
|
888
|
+
for (let c = 0; c < numComps; ++c) {
|
|
1021
889
|
offset[c] = min[c];
|
|
1022
890
|
scale[c] = max[c] - min[c] || 1.0;
|
|
1023
891
|
}
|
|
1024
|
-
|
|
1025
892
|
return {
|
|
1026
|
-
scale
|
|
1027
|
-
offset
|
|
893
|
+
scale,
|
|
894
|
+
offset
|
|
1028
895
|
};
|
|
1029
|
-
}
|
|
1030
|
-
// for numbers outside of this range there is a precision limitation
|
|
1031
|
-
|
|
896
|
+
}
|
|
1032
897
|
|
|
898
|
+
// HalfFloat only represents numbers between [-2048, 2048] exactly accurate,
|
|
899
|
+
// for numbers outside of this range there is a precision limitation
|
|
1033
900
|
function hasExactHalfFloat(offset, scale) {
|
|
1034
901
|
// Per Component
|
|
1035
|
-
for (
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
902
|
+
for (let c = 0; c < offset.length; c++) {
|
|
903
|
+
const min = offset[c];
|
|
904
|
+
const max = scale[c] + min;
|
|
1039
905
|
if (min < -2048 || min > 2048 || max < -2048 || max > 2048) {
|
|
1040
906
|
return false;
|
|
1041
907
|
}
|
|
1042
908
|
}
|
|
1043
|
-
|
|
1044
909
|
return true;
|
|
1045
910
|
}
|
|
1046
|
-
|
|
1047
911
|
function setUseHalfFloat(dataType, offset, scale, preferSizeOverAccuracy) {
|
|
1048
912
|
publicAPI.getOpenGLDataType(dataType);
|
|
1049
|
-
|
|
1050
|
-
|
|
913
|
+
let useHalfFloat = false;
|
|
1051
914
|
if (model._openGLRenderWindow.getWebgl2()) {
|
|
1052
915
|
useHalfFloat = model.openGLDataType === model.context.HALF_FLOAT;
|
|
1053
916
|
} else {
|
|
1054
|
-
|
|
917
|
+
const halfFloatExt = model.context.getExtension('OES_texture_half_float');
|
|
1055
918
|
useHalfFloat = halfFloatExt && model.openGLDataType === halfFloatExt.HALF_FLOAT_OES;
|
|
1056
|
-
}
|
|
1057
|
-
// AND it is not preferable to have a smaller texture than an exact texture.
|
|
1058
|
-
|
|
919
|
+
}
|
|
1059
920
|
|
|
1060
|
-
|
|
921
|
+
// Don't consider halfFloat and convert back to Float when the range of data does not generate an accurate halfFloat
|
|
922
|
+
// AND it is not preferable to have a smaller texture than an exact texture.
|
|
923
|
+
const isHalfFloat = useHalfFloat && (hasExactHalfFloat(offset, scale) || preferSizeOverAccuracy);
|
|
1061
924
|
model.useHalfFloat = isHalfFloat;
|
|
1062
925
|
}
|
|
1063
|
-
|
|
1064
926
|
function processDataArray(dataArray, preferSizeOverAccuracy) {
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
// Using the vtkDataArray.getRange() enables caching
|
|
1069
|
-
|
|
1070
|
-
var minArray = new Array(numComps);
|
|
1071
|
-
var maxArray = new Array(numComps);
|
|
1072
|
-
|
|
1073
|
-
for (var c = 0; c < numComps; ++c) {
|
|
1074
|
-
var _dataArray$getRange = dataArray.getRange(c),
|
|
1075
|
-
_dataArray$getRange2 = _slicedToArray(_dataArray$getRange, 2),
|
|
1076
|
-
min = _dataArray$getRange2[0],
|
|
1077
|
-
max = _dataArray$getRange2[1];
|
|
927
|
+
const numComps = dataArray.getNumberOfComponents();
|
|
928
|
+
const dataType = dataArray.getDataType();
|
|
929
|
+
const data = dataArray.getData();
|
|
1078
930
|
|
|
931
|
+
// Compute min max from array
|
|
932
|
+
// Using the vtkDataArray.getRange() enables caching
|
|
933
|
+
const minArray = new Array(numComps);
|
|
934
|
+
const maxArray = new Array(numComps);
|
|
935
|
+
for (let c = 0; c < numComps; ++c) {
|
|
936
|
+
const [min, max] = dataArray.getRange(c);
|
|
1079
937
|
minArray[c] = min;
|
|
1080
938
|
maxArray[c] = max;
|
|
1081
939
|
}
|
|
940
|
+
const scaleOffsets = computeScaleOffsets(minArray, maxArray, numComps);
|
|
1082
941
|
|
|
1083
|
-
|
|
942
|
+
// preferSizeOverAccuracy will override norm16 due to bug with norm16 implementation
|
|
1084
943
|
// https://bugs.chromium.org/p/chromium/issues/detail?id=1408247
|
|
944
|
+
setUseHalfFloat(dataType, scaleOffsets.offset, scaleOffsets.scale, preferSizeOverAccuracy);
|
|
1085
945
|
|
|
1086
|
-
|
|
946
|
+
// since our default is to use half float, in case that we can't use it
|
|
1087
947
|
// we need to use another type
|
|
1088
|
-
|
|
1089
948
|
if (!model.useHalfFloat) {
|
|
1090
949
|
publicAPI.getOpenGLDataType(dataType, true);
|
|
1091
950
|
}
|
|
1092
|
-
|
|
1093
951
|
return {
|
|
1094
|
-
numComps
|
|
1095
|
-
dataType
|
|
1096
|
-
data
|
|
1097
|
-
scaleOffsets
|
|
952
|
+
numComps,
|
|
953
|
+
dataType,
|
|
954
|
+
data,
|
|
955
|
+
scaleOffsets
|
|
1098
956
|
};
|
|
1099
957
|
}
|
|
1100
|
-
|
|
1101
958
|
publicAPI.create2DFilterableFromRaw = function (width, height, numberOfComponents, dataType, values) {
|
|
1102
|
-
|
|
959
|
+
let preferSizeOverAccuracy = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
1103
960
|
return publicAPI.create2DFilterableFromDataArray(width, height, vtkDataArray.newInstance({
|
|
1104
|
-
numberOfComponents
|
|
1105
|
-
dataType
|
|
1106
|
-
values
|
|
961
|
+
numberOfComponents,
|
|
962
|
+
dataType,
|
|
963
|
+
values
|
|
1107
964
|
}), preferSizeOverAccuracy);
|
|
1108
965
|
};
|
|
1109
|
-
|
|
1110
966
|
publicAPI.create2DFilterableFromDataArray = function (width, height, dataArray) {
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
967
|
+
let preferSizeOverAccuracy = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
968
|
+
const {
|
|
969
|
+
numComps,
|
|
970
|
+
dataType,
|
|
971
|
+
data
|
|
972
|
+
} = processDataArray(dataArray, preferSizeOverAccuracy);
|
|
1118
973
|
publicAPI.create2DFromRaw(width, height, numComps, dataType, data);
|
|
1119
|
-
};
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
publicAPI.create3DFromRaw = function (width, height, depth, numComps, dataType, data) {
|
|
974
|
+
};
|
|
975
|
+
//----------------------------------------------------------------------------
|
|
976
|
+
publicAPI.create3DFromRaw = (width, height, depth, numComps, dataType, data) => {
|
|
1123
977
|
// Permit OpenGLDataType to be half float, if applicable, for 3D
|
|
1124
|
-
publicAPI.getOpenGLDataType(dataType);
|
|
978
|
+
publicAPI.getOpenGLDataType(dataType);
|
|
1125
979
|
|
|
980
|
+
// Now determine the texture parameters using the arguments.
|
|
1126
981
|
publicAPI.getInternalFormat(dataType, numComps);
|
|
1127
982
|
publicAPI.getFormat(dataType, numComps);
|
|
1128
|
-
|
|
1129
983
|
if (!model.internalFormat || !model.format || !model.openGLDataType) {
|
|
1130
984
|
vtkErrorMacro('Failed to determine texture parameters.');
|
|
1131
985
|
return false;
|
|
1132
986
|
}
|
|
1133
|
-
|
|
1134
987
|
model.target = model.context.TEXTURE_3D;
|
|
1135
988
|
model.components = numComps;
|
|
1136
989
|
model.width = width;
|
|
1137
990
|
model.height = height;
|
|
1138
991
|
model.depth = depth;
|
|
1139
992
|
model.numberOfDimensions = 3;
|
|
1140
|
-
|
|
1141
993
|
model._openGLRenderWindow.activateTexture(publicAPI);
|
|
1142
|
-
|
|
1143
994
|
publicAPI.createTexture();
|
|
1144
|
-
publicAPI.bind();
|
|
995
|
+
publicAPI.bind();
|
|
996
|
+
// Create an array of texture with one texture
|
|
997
|
+
const dataArray = [data];
|
|
998
|
+
const is3DArray = true;
|
|
999
|
+
const pixData = updateArrayDataType(dataType, dataArray, is3DArray);
|
|
1000
|
+
const scaledData = scaleTextureToHighestPowerOfTwo(pixData);
|
|
1145
1001
|
|
|
1146
|
-
|
|
1147
|
-
var is3DArray = true;
|
|
1148
|
-
var pixData = updateArrayDataType(dataType, dataArray, is3DArray);
|
|
1149
|
-
var scaledData = scaleTextureToHighestPowerOfTwo(pixData); // Source texture data from the PBO.
|
|
1002
|
+
// Source texture data from the PBO.
|
|
1150
1003
|
// model.context.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
|
|
1004
|
+
model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1);
|
|
1151
1005
|
|
|
1152
|
-
|
|
1006
|
+
// openGLDataType
|
|
1153
1007
|
|
|
1154
1008
|
if (useTexStorage(dataType)) {
|
|
1155
1009
|
model.context.texStorage3D(model.target, 1, model.internalFormat, model.width, model.height, model.depth);
|
|
1156
|
-
|
|
1157
1010
|
if (scaledData[0] != null) {
|
|
1158
1011
|
model.context.texSubImage3D(model.target, 0, 0, 0, 0, model.width, model.height, model.depth, model.format, model.openGLDataType, scaledData[0]);
|
|
1159
1012
|
}
|
|
1160
1013
|
} else {
|
|
1161
1014
|
model.context.texImage3D(model.target, 0, model.internalFormat, model.width, model.height, model.depth, 0, model.format, model.openGLDataType, scaledData[0]);
|
|
1162
1015
|
}
|
|
1163
|
-
|
|
1164
1016
|
if (model.generateMipmap) {
|
|
1165
1017
|
model.context.generateMipmap(model.target);
|
|
1166
1018
|
}
|
|
1167
|
-
|
|
1168
1019
|
publicAPI.deactivate();
|
|
1169
1020
|
return true;
|
|
1170
|
-
};
|
|
1021
|
+
};
|
|
1022
|
+
|
|
1023
|
+
//----------------------------------------------------------------------------
|
|
1171
1024
|
// This method simulates a 3D texture using 2D
|
|
1172
1025
|
// Prefer create3DFilterableFromDataArray to enable caching of min and max values
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
1026
|
publicAPI.create3DFilterableFromRaw = function (width, height, depth, numberOfComponents, dataType, values) {
|
|
1176
|
-
|
|
1027
|
+
let preferSizeOverAccuracy = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
1177
1028
|
return publicAPI.create3DFilterableFromDataArray(width, height, depth, vtkDataArray.newInstance({
|
|
1178
|
-
numberOfComponents
|
|
1179
|
-
dataType
|
|
1180
|
-
values
|
|
1029
|
+
numberOfComponents,
|
|
1030
|
+
dataType,
|
|
1031
|
+
values
|
|
1181
1032
|
}), preferSizeOverAccuracy);
|
|
1182
|
-
};
|
|
1183
|
-
// This method create a 3D texture from dimensions and a DataArray
|
|
1184
|
-
|
|
1033
|
+
};
|
|
1185
1034
|
|
|
1035
|
+
//----------------------------------------------------------------------------
|
|
1036
|
+
// This method create a 3D texture from dimensions and a DataArray
|
|
1186
1037
|
publicAPI.create3DFilterableFromDataArray = function (width, height, depth, dataArray) {
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
for (var c = 0; c < numComps; ++c) {
|
|
1038
|
+
let preferSizeOverAccuracy = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
1039
|
+
const {
|
|
1040
|
+
numComps,
|
|
1041
|
+
dataType,
|
|
1042
|
+
data,
|
|
1043
|
+
scaleOffsets
|
|
1044
|
+
} = processDataArray(dataArray, preferSizeOverAccuracy);
|
|
1045
|
+
const numPixelsIn = width * height * depth;
|
|
1046
|
+
const offset = [];
|
|
1047
|
+
const scale = [];
|
|
1048
|
+
for (let c = 0; c < numComps; ++c) {
|
|
1200
1049
|
offset[c] = 0.0;
|
|
1201
1050
|
scale[c] = 1.0;
|
|
1202
|
-
}
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
// store the information, we will need it later
|
|
1203
1054
|
// offset and scale are the offset and scale required to get
|
|
1204
1055
|
// the texture value back to data values ala
|
|
1205
1056
|
// data = texture * scale + offset
|
|
1206
1057
|
// and texture = (data - offset)/scale
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
1058
|
model.volumeInfo = {
|
|
1210
|
-
scale
|
|
1211
|
-
offset
|
|
1059
|
+
scale,
|
|
1060
|
+
offset,
|
|
1212
1061
|
dataComputedScale: scaleOffsets.scale,
|
|
1213
1062
|
dataComputedOffset: scaleOffsets.offset,
|
|
1214
|
-
width
|
|
1215
|
-
height
|
|
1216
|
-
depth
|
|
1217
|
-
};
|
|
1063
|
+
width,
|
|
1064
|
+
height,
|
|
1065
|
+
depth
|
|
1066
|
+
};
|
|
1067
|
+
|
|
1068
|
+
// Create a copy of scale and offset to avoid aliasing issues
|
|
1218
1069
|
// Original is read only, copy is read/write
|
|
1219
1070
|
// Use the copy as volumeInfo.scale and volumeInfo.offset
|
|
1071
|
+
const scaleOffsetsCopy = structuredClone(scaleOffsets);
|
|
1220
1072
|
|
|
1221
|
-
|
|
1222
|
-
|
|
1073
|
+
// WebGL2 path, we have 3d textures etc
|
|
1223
1074
|
if (model._openGLRenderWindow.getWebgl2()) {
|
|
1224
1075
|
if (model.oglNorm16Ext && !model.useHalfFloat && dataType === VtkDataTypes.SHORT) {
|
|
1225
|
-
for (
|
|
1226
|
-
model.volumeInfo.scale[
|
|
1076
|
+
for (let c = 0; c < numComps; ++c) {
|
|
1077
|
+
model.volumeInfo.scale[c] = 32767.0;
|
|
1227
1078
|
}
|
|
1228
|
-
|
|
1229
1079
|
return publicAPI.create3DFromRaw(width, height, depth, numComps, dataType, data);
|
|
1230
1080
|
}
|
|
1231
|
-
|
|
1232
1081
|
if (model.oglNorm16Ext && !model.useHalfFloat && dataType === VtkDataTypes.UNSIGNED_SHORT) {
|
|
1233
|
-
for (
|
|
1234
|
-
model.volumeInfo.scale[
|
|
1082
|
+
for (let c = 0; c < numComps; ++c) {
|
|
1083
|
+
model.volumeInfo.scale[c] = 65535.0;
|
|
1235
1084
|
}
|
|
1236
|
-
|
|
1237
1085
|
return publicAPI.create3DFromRaw(width, height, depth, numComps, dataType, data);
|
|
1238
1086
|
}
|
|
1239
|
-
|
|
1240
1087
|
if (dataType === VtkDataTypes.FLOAT || model.useHalfFloat && (dataType === VtkDataTypes.SHORT || dataType === VtkDataTypes.UNSIGNED_SHORT)) {
|
|
1241
1088
|
return publicAPI.create3DFromRaw(width, height, depth, numComps, dataType, data);
|
|
1242
1089
|
}
|
|
1243
|
-
|
|
1244
1090
|
if (dataType === VtkDataTypes.UNSIGNED_CHAR) {
|
|
1245
|
-
for (
|
|
1246
|
-
model.volumeInfo.scale[
|
|
1091
|
+
for (let c = 0; c < numComps; ++c) {
|
|
1092
|
+
model.volumeInfo.scale[c] = 255.0;
|
|
1247
1093
|
}
|
|
1248
|
-
|
|
1249
1094
|
return publicAPI.create3DFromRaw(width, height, depth, numComps, dataType, data);
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1095
|
+
}
|
|
1096
|
+
// otherwise convert to float
|
|
1097
|
+
const newArray = new Float32Array(numPixelsIn * numComps);
|
|
1098
|
+
// use computed scale and offset
|
|
1256
1099
|
model.volumeInfo.offset = scaleOffsetsCopy.offset;
|
|
1257
1100
|
model.volumeInfo.scale = scaleOffsetsCopy.scale;
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
for (var i = 0; i < numPixelsIn; i++) {
|
|
1264
|
-
for (var nc = 0; nc < numComps; nc++) {
|
|
1265
|
-
_newArray[count] = (data[count] - scaleOffsetsCopy.offset[nc]) * scaleInverse[nc];
|
|
1101
|
+
let count = 0;
|
|
1102
|
+
const scaleInverse = scaleOffsetsCopy.scale.map(s => 1 / s);
|
|
1103
|
+
for (let i = 0; i < numPixelsIn; i++) {
|
|
1104
|
+
for (let nc = 0; nc < numComps; nc++) {
|
|
1105
|
+
newArray[count] = (data[count] - scaleOffsetsCopy.offset[nc]) * scaleInverse[nc];
|
|
1266
1106
|
count++;
|
|
1267
1107
|
}
|
|
1268
1108
|
}
|
|
1109
|
+
return publicAPI.create3DFromRaw(width, height, depth, numComps, VtkDataTypes.FLOAT, newArray);
|
|
1110
|
+
}
|
|
1269
1111
|
|
|
1270
|
-
|
|
1271
|
-
} // not webgl2, deal with webgl1, no 3d textures
|
|
1112
|
+
// not webgl2, deal with webgl1, no 3d textures
|
|
1272
1113
|
// and maybe no float textures
|
|
1273
1114
|
|
|
1274
|
-
|
|
1275
|
-
var volCopyData = function volCopyData(outArray, outIdx, inValue, smin, smax) {
|
|
1115
|
+
let volCopyData = (outArray, outIdx, inValue, smin, smax) => {
|
|
1276
1116
|
outArray[outIdx] = inValue;
|
|
1277
1117
|
};
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1118
|
+
let dataTypeToUse = VtkDataTypes.UNSIGNED_CHAR;
|
|
1119
|
+
// unsigned char gets used as is
|
|
1281
1120
|
if (dataType === VtkDataTypes.UNSIGNED_CHAR) {
|
|
1282
|
-
for (
|
|
1283
|
-
scaleOffsetsCopy.offset[
|
|
1284
|
-
scaleOffsetsCopy.scale[
|
|
1121
|
+
for (let c = 0; c < numComps; ++c) {
|
|
1122
|
+
scaleOffsetsCopy.offset[c] = 0.0;
|
|
1123
|
+
scaleOffsetsCopy.scale[c] = 255.0;
|
|
1285
1124
|
}
|
|
1286
1125
|
} else if (model.context.getExtension('OES_texture_float') && model.context.getExtension('OES_texture_float_linear')) {
|
|
1287
1126
|
// use float textures scaled to 0.0 to 1.0
|
|
1288
1127
|
dataTypeToUse = VtkDataTypes.FLOAT;
|
|
1289
|
-
|
|
1290
|
-
volCopyData = function volCopyData(outArray, outIdx, inValue, soffset, sscale) {
|
|
1128
|
+
volCopyData = (outArray, outIdx, inValue, soffset, sscale) => {
|
|
1291
1129
|
outArray[outIdx] = (inValue - soffset) / sscale;
|
|
1292
1130
|
};
|
|
1293
1131
|
} else {
|
|
1294
1132
|
// worst case, scale data to uchar
|
|
1295
1133
|
dataTypeToUse = VtkDataTypes.UNSIGNED_CHAR;
|
|
1296
|
-
|
|
1297
|
-
volCopyData = function volCopyData(outArray, outIdx, inValue, soffset, sscale) {
|
|
1134
|
+
volCopyData = (outArray, outIdx, inValue, soffset, sscale) => {
|
|
1298
1135
|
outArray[outIdx] = 255.0 * (inValue - soffset) / sscale;
|
|
1299
1136
|
};
|
|
1300
|
-
}
|
|
1301
|
-
|
|
1137
|
+
}
|
|
1302
1138
|
|
|
1139
|
+
// Now determine the texture parameters using the arguments.
|
|
1303
1140
|
publicAPI.getOpenGLDataType(dataTypeToUse);
|
|
1304
1141
|
publicAPI.getInternalFormat(dataTypeToUse, numComps);
|
|
1305
1142
|
publicAPI.getFormat(dataTypeToUse, numComps);
|
|
1306
|
-
|
|
1307
1143
|
if (!model.internalFormat || !model.format || !model.openGLDataType) {
|
|
1308
1144
|
vtkErrorMacro('Failed to determine texture parameters.');
|
|
1309
1145
|
return false;
|
|
1310
|
-
}
|
|
1311
|
-
|
|
1146
|
+
}
|
|
1312
1147
|
|
|
1148
|
+
// have to pack this 3D texture into pot 2D texture
|
|
1313
1149
|
model.target = model.context.TEXTURE_2D;
|
|
1314
1150
|
model.components = numComps;
|
|
1315
1151
|
model.depth = 1;
|
|
1316
|
-
model.numberOfDimensions = 2;
|
|
1152
|
+
model.numberOfDimensions = 2;
|
|
1153
|
+
|
|
1154
|
+
// MAX_TEXTURE_SIZE gives the max dimensions that can be supported by the GPU,
|
|
1317
1155
|
// but it doesn't mean it will fit in memory. If we have to use a float data type
|
|
1318
1156
|
// or 4 components, there are good chances that the texture size will blow up
|
|
1319
1157
|
// and could not fit in the GPU memory. Use a smaller texture size in that case,
|
|
@@ -1322,126 +1160,112 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
1322
1160
|
// denser textures based on our data type.
|
|
1323
1161
|
// TODO: try to fit in the biggest supported texture, catch the gl error if it
|
|
1324
1162
|
// does not fix (OUT_OF_MEMORY), then attempt with smaller texture
|
|
1325
|
-
|
|
1326
|
-
var maxTexDim = model.context.getParameter(model.context.MAX_TEXTURE_SIZE);
|
|
1327
|
-
|
|
1163
|
+
let maxTexDim = model.context.getParameter(model.context.MAX_TEXTURE_SIZE);
|
|
1328
1164
|
if (maxTexDim > 4096 && (dataTypeToUse === VtkDataTypes.FLOAT || numComps >= 3)) {
|
|
1329
1165
|
maxTexDim = 4096;
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
var xstride = 1;
|
|
1334
|
-
var ystride = 1;
|
|
1166
|
+
}
|
|
1335
1167
|
|
|
1168
|
+
// compute estimate for XY subsample
|
|
1169
|
+
let xstride = 1;
|
|
1170
|
+
let ystride = 1;
|
|
1336
1171
|
if (numPixelsIn > maxTexDim * maxTexDim) {
|
|
1337
1172
|
xstride = Math.ceil(Math.sqrt(numPixelsIn / (maxTexDim * maxTexDim)));
|
|
1338
1173
|
ystride = xstride;
|
|
1339
1174
|
}
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
var targetHeight = nearestPowerOfTwo(height * yreps / ystride);
|
|
1175
|
+
let targetWidth = Math.sqrt(numPixelsIn) / xstride;
|
|
1176
|
+
targetWidth = nearestPowerOfTwo(targetWidth);
|
|
1177
|
+
// determine X reps
|
|
1178
|
+
const xreps = Math.floor(targetWidth * xstride / width);
|
|
1179
|
+
const yreps = Math.ceil(depth / xreps);
|
|
1180
|
+
const targetHeight = nearestPowerOfTwo(height * yreps / ystride);
|
|
1347
1181
|
model.width = targetWidth;
|
|
1348
1182
|
model.height = targetHeight;
|
|
1349
|
-
|
|
1350
1183
|
model._openGLRenderWindow.activateTexture(publicAPI);
|
|
1351
|
-
|
|
1352
1184
|
publicAPI.createTexture();
|
|
1353
|
-
publicAPI.bind();
|
|
1185
|
+
publicAPI.bind();
|
|
1354
1186
|
|
|
1187
|
+
// store the information, we will need it later
|
|
1355
1188
|
model.volumeInfo.xreps = xreps;
|
|
1356
1189
|
model.volumeInfo.yreps = yreps;
|
|
1357
1190
|
model.volumeInfo.xstride = xstride;
|
|
1358
1191
|
model.volumeInfo.ystride = ystride;
|
|
1359
1192
|
model.volumeInfo.offset = scaleOffsetsCopy.offset;
|
|
1360
|
-
model.volumeInfo.scale = scaleOffsetsCopy.scale;
|
|
1361
|
-
// first allocate the new texture
|
|
1193
|
+
model.volumeInfo.scale = scaleOffsetsCopy.scale;
|
|
1362
1194
|
|
|
1363
|
-
|
|
1364
|
-
var pixCount = targetWidth * targetHeight * numComps;
|
|
1195
|
+
// OK stuff the data into the 2d TEXTURE
|
|
1365
1196
|
|
|
1197
|
+
// first allocate the new texture
|
|
1198
|
+
let newArray;
|
|
1199
|
+
const pixCount = targetWidth * targetHeight * numComps;
|
|
1366
1200
|
if (dataTypeToUse === VtkDataTypes.FLOAT) {
|
|
1367
1201
|
newArray = new Float32Array(pixCount);
|
|
1368
1202
|
} else {
|
|
1369
1203
|
newArray = new Uint8Array(pixCount);
|
|
1370
|
-
}
|
|
1371
|
-
// for stride
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
var outIdx = 0;
|
|
1375
|
-
var tileWidth = Math.floor(width / xstride);
|
|
1376
|
-
var tileHeight = Math.floor(height / ystride);
|
|
1377
|
-
|
|
1378
|
-
for (var yRep = 0; yRep < yreps; yRep++) {
|
|
1379
|
-
var xrepsThisRow = Math.min(xreps, depth - yRep * xreps);
|
|
1380
|
-
var outXContIncr = numComps * (model.width - xrepsThisRow * Math.floor(width / xstride));
|
|
1381
|
-
|
|
1382
|
-
for (var tileY = 0; tileY < tileHeight; tileY++) {
|
|
1383
|
-
for (var xRep = 0; xRep < xrepsThisRow; xRep++) {
|
|
1384
|
-
var inOffset = numComps * ((yRep * xreps + xRep) * width * height + ystride * tileY * width);
|
|
1204
|
+
}
|
|
1385
1205
|
|
|
1386
|
-
|
|
1206
|
+
// then stuff the data into it, nothing fancy right now
|
|
1207
|
+
// for stride
|
|
1208
|
+
let outIdx = 0;
|
|
1209
|
+
const tileWidth = Math.floor(width / xstride);
|
|
1210
|
+
const tileHeight = Math.floor(height / ystride);
|
|
1211
|
+
for (let yRep = 0; yRep < yreps; yRep++) {
|
|
1212
|
+
const xrepsThisRow = Math.min(xreps, depth - yRep * xreps);
|
|
1213
|
+
const outXContIncr = numComps * (model.width - xrepsThisRow * Math.floor(width / xstride));
|
|
1214
|
+
for (let tileY = 0; tileY < tileHeight; tileY++) {
|
|
1215
|
+
for (let xRep = 0; xRep < xrepsThisRow; xRep++) {
|
|
1216
|
+
const inOffset = numComps * ((yRep * xreps + xRep) * width * height + ystride * tileY * width);
|
|
1217
|
+
for (let tileX = 0; tileX < tileWidth; tileX++) {
|
|
1387
1218
|
// copy value
|
|
1388
|
-
for (
|
|
1389
|
-
volCopyData(newArray, outIdx, data[inOffset + xstride * tileX * numComps +
|
|
1219
|
+
for (let nc = 0; nc < numComps; nc++) {
|
|
1220
|
+
volCopyData(newArray, outIdx, data[inOffset + xstride * tileX * numComps + nc], scaleOffsetsCopy.offset[nc], scaleOffsetsCopy.scale[nc]);
|
|
1390
1221
|
outIdx++;
|
|
1391
1222
|
}
|
|
1392
1223
|
}
|
|
1393
1224
|
}
|
|
1394
|
-
|
|
1395
1225
|
outIdx += outXContIncr;
|
|
1396
1226
|
}
|
|
1397
|
-
}
|
|
1398
|
-
// model.context.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
|
|
1399
|
-
|
|
1227
|
+
}
|
|
1400
1228
|
|
|
1229
|
+
// Source texture data from the PBO.
|
|
1230
|
+
// model.context.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
|
|
1401
1231
|
model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1);
|
|
1402
|
-
|
|
1403
1232
|
if (useTexStorage(dataTypeToUse)) {
|
|
1404
1233
|
model.context.texStorage2D(model.target, 1, model.internalFormat, model.width, model.height);
|
|
1405
|
-
|
|
1406
1234
|
if (newArray != null) {
|
|
1407
1235
|
model.context.texSubImage2D(model.target, 0, 0, 0, model.width, model.height, model.format, model.openGLDataType, newArray);
|
|
1408
1236
|
}
|
|
1409
1237
|
} else {
|
|
1410
1238
|
model.context.texImage2D(model.target, 0, model.internalFormat, model.width, model.height, 0, model.format, model.openGLDataType, newArray);
|
|
1411
1239
|
}
|
|
1412
|
-
|
|
1413
1240
|
publicAPI.deactivate();
|
|
1414
1241
|
return true;
|
|
1415
1242
|
};
|
|
1416
|
-
|
|
1417
|
-
publicAPI.setOpenGLRenderWindow = function (rw) {
|
|
1243
|
+
publicAPI.setOpenGLRenderWindow = rw => {
|
|
1418
1244
|
if (model._openGLRenderWindow === rw) {
|
|
1419
1245
|
return;
|
|
1420
1246
|
}
|
|
1421
|
-
|
|
1422
1247
|
publicAPI.releaseGraphicsResources();
|
|
1423
1248
|
model._openGLRenderWindow = rw;
|
|
1424
1249
|
model.context = null;
|
|
1425
|
-
|
|
1426
1250
|
if (rw) {
|
|
1427
1251
|
model.context = model._openGLRenderWindow.getContext();
|
|
1428
1252
|
}
|
|
1429
|
-
};
|
|
1430
|
-
|
|
1253
|
+
};
|
|
1431
1254
|
|
|
1432
|
-
|
|
1255
|
+
//----------------------------------------------------------------------------
|
|
1256
|
+
publicAPI.getMaximumTextureSize = ctx => {
|
|
1433
1257
|
if (ctx && ctx.isCurrent()) {
|
|
1434
1258
|
return ctx.getIntegerv(ctx.MAX_TEXTURE_SIZE);
|
|
1435
1259
|
}
|
|
1436
|
-
|
|
1437
1260
|
return -1;
|
|
1438
1261
|
};
|
|
1439
|
-
}
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
// ----------------------------------------------------------------------------
|
|
1440
1265
|
// Object factory
|
|
1441
1266
|
// ----------------------------------------------------------------------------
|
|
1442
1267
|
|
|
1443
|
-
|
|
1444
|
-
var DEFAULT_VALUES = {
|
|
1268
|
+
const DEFAULT_VALUES = {
|
|
1445
1269
|
_openGLRenderWindow: null,
|
|
1446
1270
|
_forceInternalFormat: false,
|
|
1447
1271
|
context: null,
|
|
@@ -1473,12 +1297,15 @@ var DEFAULT_VALUES = {
|
|
|
1473
1297
|
// range of half float
|
|
1474
1298
|
useHalfFloat: true,
|
|
1475
1299
|
oglNorm16Ext: null
|
|
1476
|
-
};
|
|
1300
|
+
};
|
|
1301
|
+
|
|
1302
|
+
// ----------------------------------------------------------------------------
|
|
1477
1303
|
|
|
1478
1304
|
function extend(publicAPI, model) {
|
|
1479
|
-
|
|
1480
|
-
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
1305
|
+
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1306
|
+
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
1481
1307
|
|
|
1308
|
+
// Inheritance
|
|
1482
1309
|
vtkViewNode.extend(publicAPI, model, initialValues);
|
|
1483
1310
|
model.sendParametersTime = {};
|
|
1484
1311
|
obj(model.sendParametersTime, {
|
|
@@ -1487,23 +1314,31 @@ function extend(publicAPI, model) {
|
|
|
1487
1314
|
model.textureBuildTime = {};
|
|
1488
1315
|
obj(model.textureBuildTime, {
|
|
1489
1316
|
mtime: 0
|
|
1490
|
-
});
|
|
1317
|
+
});
|
|
1491
1318
|
|
|
1319
|
+
// Build VTK API
|
|
1492
1320
|
set(publicAPI, model, ['format', 'openGLDataType']);
|
|
1493
1321
|
setGet(publicAPI, model, ['keyMatrixTime', 'minificationFilter', 'magnificationFilter', 'wrapS', 'wrapT', 'wrapR', 'generateMipmap', 'oglNorm16Ext']);
|
|
1494
1322
|
get(publicAPI, model, ['width', 'height', 'volumeInfo', 'components', 'handle', 'target']);
|
|
1495
|
-
moveToProtected(publicAPI, model, ['openGLRenderWindow']);
|
|
1323
|
+
moveToProtected(publicAPI, model, ['openGLRenderWindow']);
|
|
1496
1324
|
|
|
1325
|
+
// Object methods
|
|
1497
1326
|
vtkOpenGLTexture(publicAPI, model);
|
|
1498
|
-
}
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
// ----------------------------------------------------------------------------
|
|
1330
|
+
|
|
1331
|
+
const newInstance = newInstance$1(extend, 'vtkOpenGLTexture');
|
|
1499
1332
|
|
|
1500
|
-
|
|
1333
|
+
// ----------------------------------------------------------------------------
|
|
1501
1334
|
|
|
1502
|
-
var vtkOpenGLTexture$1 =
|
|
1503
|
-
newInstance
|
|
1504
|
-
extend
|
|
1505
|
-
|
|
1335
|
+
var vtkOpenGLTexture$1 = {
|
|
1336
|
+
newInstance,
|
|
1337
|
+
extend,
|
|
1338
|
+
...Constants
|
|
1339
|
+
};
|
|
1506
1340
|
|
|
1341
|
+
// Register ourself to OpenGL backend if imported
|
|
1507
1342
|
registerOverride('vtkTexture', newInstance);
|
|
1508
1343
|
|
|
1509
1344
|
export { vtkOpenGLTexture$1 as default, extend, newInstance };
|