@kitware/vtk.js 28.10.2 → 28.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Common/Core/Base64.js +53 -82
- package/Common/Core/CellArray.js +52 -60
- package/Common/Core/ClassHierarchy.js +8 -36
- package/Common/Core/DataArray/Constants.js +6 -6
- package/Common/Core/DataArray.js +185 -270
- package/Common/Core/Endian.js +14 -17
- package/Common/Core/HalfFloat.js +17 -34
- package/Common/Core/ImageHelper.js +17 -25
- package/Common/Core/LookupTable.js +131 -144
- package/Common/Core/Math/Constants.js +8 -8
- package/Common/Core/Math/index.js +754 -942
- package/Common/Core/Math.js +2 -4
- package/Common/Core/MatrixBuilder.js +99 -151
- package/Common/Core/Points.js +43 -43
- package/Common/Core/PriorityQueue.js +30 -28
- package/Common/Core/ProgressHandler.js +31 -32
- package/Common/Core/ScalarsToColors/Constants.js +4 -4
- package/Common/Core/ScalarsToColors.js +196 -253
- package/Common/Core/StringArray.js +48 -73
- package/Common/Core/URLExtract.js +10 -29
- package/Common/Core/VariantArray.js +48 -73
- package/Common/Core.js +11 -11
- package/Common/DataModel/AbstractPointLocator.js +19 -17
- package/Common/DataModel/BoundingBox.js +322 -490
- package/Common/DataModel/Box.js +46 -63
- package/Common/DataModel/CardinalSpline1D.js +92 -102
- package/Common/DataModel/Cell.js +41 -61
- package/Common/DataModel/CellLinks.js +91 -127
- package/Common/DataModel/CellTypes/Constants.js +7 -6
- package/Common/DataModel/CellTypes.js +55 -74
- package/Common/DataModel/Collection.js +45 -61
- package/Common/DataModel/Cone.js +28 -20
- package/Common/DataModel/Cylinder.js +41 -35
- package/Common/DataModel/DataSet/Constants.js +11 -5
- package/Common/DataModel/DataSet.js +37 -25
- package/Common/DataModel/DataSetAttributes/Constants.js +18 -18
- package/Common/DataModel/DataSetAttributes/FieldData.js +103 -194
- package/Common/DataModel/DataSetAttributes.js +96 -138
- package/Common/DataModel/EdgeLocator.js +45 -70
- package/Common/DataModel/ITKHelper.js +67 -137
- package/Common/DataModel/ImageData.js +115 -172
- package/Common/DataModel/ImplicitBoolean/Constants.js +2 -2
- package/Common/DataModel/ImplicitBoolean.js +66 -96
- package/Common/DataModel/IncrementalOctreeNode.js +201 -231
- package/Common/DataModel/IncrementalOctreePointLocator.js +160 -198
- package/Common/DataModel/KochanekSpline1D.js +78 -81
- package/Common/DataModel/Line/Constants.js +2 -2
- package/Common/DataModel/Line.js +82 -105
- package/Common/DataModel/Locator.js +17 -10
- package/Common/DataModel/Molecule.js +26 -17
- package/Common/DataModel/PiecewiseFunction.js +218 -239
- package/Common/DataModel/Plane.js +90 -113
- package/Common/DataModel/PointSet.js +30 -26
- package/Common/DataModel/PolyData/Constants.js +2 -2
- package/Common/DataModel/PolyData.js +95 -120
- package/Common/DataModel/PolyLine.js +44 -61
- package/Common/DataModel/Polygon/Constants.js +4 -4
- package/Common/DataModel/Polygon.js +128 -169
- package/Common/DataModel/Quad/Constants.js +2 -2
- package/Common/DataModel/Quad.js +61 -100
- package/Common/DataModel/SelectionNode/Constants.js +5 -4
- package/Common/DataModel/SelectionNode.js +25 -21
- package/Common/DataModel/Sphere.js +40 -35
- package/Common/DataModel/Spline1D/Constants.js +3 -2
- package/Common/DataModel/Spline1D.js +34 -18
- package/Common/DataModel/Spline3D/Constants.js +2 -2
- package/Common/DataModel/Spline3D.js +46 -41
- package/Common/DataModel/StructuredData/Constants.js +2 -2
- package/Common/DataModel/StructuredData.js +9 -20
- package/Common/DataModel/Triangle.js +207 -250
- package/Common/DataModel.js +19 -19
- package/Common/System/MobileVR.js +56 -61
- package/Common/System/TimerLog.js +1 -1
- package/Common/System.js +2 -2
- package/Common/Transform/LandmarkTransform/Constants.js +2 -2
- package/Common/Transform/LandmarkTransform.js +133 -117
- package/Common/Transform/Transform.js +42 -57
- package/Common/Transform.js +2 -2
- package/Common/index.js +4 -4
- package/Filters/Core/Cutter.js +134 -146
- package/Filters/Core/PolyDataNormals.js +44 -50
- package/Filters/Core.js +2 -2
- package/Filters/Cornerstone/ImageDataToCornerstoneImage.js +45 -33
- package/Filters/Cornerstone.js +1 -1
- package/Filters/General/AppendPolyData.js +84 -100
- package/Filters/General/Calculator.js +95 -163
- package/Filters/General/ClipClosedSurface/Constants.js +2 -2
- package/Filters/General/ClipClosedSurface.js +341 -416
- package/Filters/General/ClosedPolyLineToSurfaceFilter.js +141 -156
- package/Filters/General/ContourTriangulator/Constants.js +2 -2
- package/Filters/General/ContourTriangulator/helper.js +684 -812
- package/Filters/General/ContourTriangulator.js +92 -89
- package/Filters/General/ImageCropFilter.js +77 -78
- package/Filters/General/ImageDataOutlineFilter.js +42 -36
- package/Filters/General/ImageMarchingCubes/caseTable.js +9 -521
- package/Filters/General/ImageMarchingCubes.js +99 -112
- package/Filters/General/ImageMarchingSquares/caseTable.js +9 -41
- package/Filters/General/ImageMarchingSquares.js +93 -118
- package/Filters/General/ImageOutlineFilter.js +53 -54
- package/Filters/General/ImageSliceFilter.js +39 -30
- package/Filters/General/ImageStreamline.js +107 -124
- package/Filters/General/LineFilter.js +26 -15
- package/Filters/General/MoleculeToRepresentation.js +136 -149
- package/Filters/General/OBBTree/OBBNode.js +36 -34
- package/Filters/General/OBBTree/helper.js +19 -24
- package/Filters/General/OBBTree.js +396 -488
- package/Filters/General/OutlineFilter.js +52 -34
- package/Filters/General/PaintFilter/PaintFilter.worker.js +93 -130
- package/Filters/General/PaintFilter.js +150 -162
- package/Filters/General/ScalarToRGBA.js +38 -33
- package/Filters/General/TriangleFilter.js +65 -62
- package/Filters/General/TubeFilter/Constants.js +4 -4
- package/Filters/General/TubeFilter.js +376 -496
- package/Filters/General/WarpScalar.js +58 -60
- package/Filters/General/WindowedSincPolyDataFilter.js +258 -330
- package/Filters/General.js +21 -21
- package/Filters/Sources/Arrow2DSource/Constants.js +2 -2
- package/Filters/Sources/Arrow2DSource.js +56 -56
- package/Filters/Sources/ArrowSource.js +39 -29
- package/Filters/Sources/CircleSource.js +43 -43
- package/Filters/Sources/ConcentricCylinderSource.js +151 -174
- package/Filters/Sources/ConeSource.js +51 -42
- package/Filters/Sources/CubeSource.js +75 -96
- package/Filters/Sources/Cursor3D.js +94 -109
- package/Filters/Sources/CylinderSource.js +90 -90
- package/Filters/Sources/ImageGridSource.js +43 -43
- package/Filters/Sources/LineSource.js +49 -39
- package/Filters/Sources/PlaneSource.js +97 -104
- package/Filters/Sources/PointSource.js +46 -37
- package/Filters/Sources/RTAnalyticSource.js +50 -48
- package/Filters/Sources/SLICSource.js +63 -73
- package/Filters/Sources/SphereSource.js +88 -78
- package/Filters/Sources/ViewFinderSource.js +26 -23
- package/Filters/Sources.js +14 -14
- package/Filters/Texture/TextureMapToPlane.js +95 -97
- package/Filters/Texture/TextureMapToSphere.js +46 -54
- package/Filters/Texture.js +2 -2
- package/Filters/index.js +5 -5
- package/IO/Core/BinaryHelper.js +12 -18
- package/IO/Core/DataAccessHelper/HtmlDataAccessHelper.js +43 -59
- package/IO/Core/DataAccessHelper/HttpDataAccessHelper.js +76 -113
- package/IO/Core/DataAccessHelper/JSZipDataAccessHelper.js +62 -112
- package/IO/Core/DataAccessHelper/LiteHttpDataAccessHelper.js +76 -113
- package/IO/Core/DataAccessHelper.js +6 -6
- package/IO/Core/HttpDataSetReader.js +136 -139
- package/IO/Core/HttpDataSetSeriesReader.js +64 -75
- package/IO/Core/HttpSceneLoader.js +130 -179
- package/IO/Core/ImageStream/DefaultProtocol.js +29 -43
- package/IO/Core/ImageStream/ViewStream.js +100 -103
- package/IO/Core/ImageStream.js +62 -54
- package/IO/Core/ResourceLoader.js +10 -9
- package/IO/Core/Serializer/ArraySerializer.js +40 -40
- package/IO/Core/Serializer/FieldDataSerializer.js +18 -28
- package/IO/Core/Serializer/ImageDataSerializer.js +22 -23
- package/IO/Core/Serializer/PolyDataSerializer.js +17 -21
- package/IO/Core/Serializer.js +6 -13
- package/IO/Core/WSLinkClient.js +90 -76
- package/IO/Core/ZipMultiDataSetReader.js +46 -44
- package/IO/Core/ZipMultiDataSetWriter.js +43 -34
- package/IO/Core.js +7 -7
- package/IO/Geometry/DracoReader.js +118 -121
- package/IO/Geometry/PLYReader.js +163 -223
- package/IO/Geometry/PLYWriter/Constants.js +5 -5
- package/IO/Geometry/PLYWriter.js +139 -154
- package/IO/Geometry/STLReader.js +123 -146
- package/IO/Geometry/STLWriter/Constants.js +2 -2
- package/IO/Geometry/STLWriter.js +83 -82
- package/IO/Geometry.js +5 -5
- package/IO/Legacy/LegacyAsciiParser.js +78 -139
- package/IO/Legacy/PolyDataReader.js +48 -36
- package/IO/Legacy.js +2 -2
- package/IO/Misc/ElevationReader.js +67 -60
- package/IO/Misc/HttpDataSetLODsLoader.js +41 -38
- package/IO/Misc/ITKImageReader.js +58 -45
- package/IO/Misc/ITKPolyDataReader.js +50 -38
- package/IO/Misc/JSONNucleoReader.js +49 -42
- package/IO/Misc/JSONReader.js +38 -33
- package/IO/Misc/MTLReader.js +74 -119
- package/IO/Misc/OBJReader.js +153 -206
- package/IO/Misc/PDBReader.js +70 -68
- package/IO/Misc/SkyboxReader.js +77 -82
- package/IO/Misc.js +9 -9
- package/IO/XML/XMLImageDataReader.js +36 -38
- package/IO/XML/XMLImageDataWriter.js +28 -21
- package/IO/XML/XMLPolyDataReader.js +49 -46
- package/IO/XML/XMLPolyDataWriter.js +43 -42
- package/IO/XML/XMLReader.js +262 -304
- package/IO/XML/XMLWriter/Constants.js +3 -3
- package/IO/XML/XMLWriter.js +70 -84
- package/IO/XML.js +6 -6
- package/IO/index.js +5 -5
- package/Imaging/Core/AbstractImageInterpolator/Constants.js +4 -4
- package/Imaging/Core/AbstractImageInterpolator/InterpolationInfo.js +30 -27
- package/Imaging/Core/AbstractImageInterpolator.js +74 -87
- package/Imaging/Core/ImageInterpolator.js +201 -252
- package/Imaging/Core/ImagePointDataIterator.js +96 -122
- package/Imaging/Core/ImageReslice/Constants.js +2 -2
- package/Imaging/Core/ImageReslice.js +327 -464
- package/Imaging/Core.js +4 -4
- package/Imaging/Hybrid/SampleFunction.js +58 -51
- package/Imaging/Hybrid.js +1 -1
- package/Imaging/index.js +2 -2
- package/Interaction/Animations/TimeStepBasedAnimationHandler.js +39 -54
- package/Interaction/Manipulators/CompositeCameraManipulator.js +22 -13
- package/Interaction/Manipulators/CompositeGestureManipulator.js +31 -43
- package/Interaction/Manipulators/CompositeKeyboardManipulator.js +15 -11
- package/Interaction/Manipulators/CompositeMouseManipulator.js +27 -33
- package/Interaction/Manipulators/CompositeVRManipulator.js +22 -15
- package/Interaction/Manipulators/GestureCameraManipulator.js +54 -36
- package/Interaction/Manipulators/KeyboardCameraManipulator.js +95 -97
- package/Interaction/Manipulators/MouseBoxSelectorManipulator.js +70 -89
- package/Interaction/Manipulators/MouseCameraAxisRotateManipulator.js +67 -54
- package/Interaction/Manipulators/MouseCameraSliceManipulator.js +40 -38
- package/Interaction/Manipulators/MouseCameraTrackballFirstPersonManipulator.js +83 -68
- package/Interaction/Manipulators/MouseCameraTrackballMultiRotateManipulator.js +32 -28
- package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.js +47 -40
- package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +55 -43
- package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +56 -46
- package/Interaction/Manipulators/MouseCameraTrackballZoomManipulator.js +41 -46
- package/Interaction/Manipulators/MouseCameraTrackballZoomToMouseManipulator.js +29 -27
- package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +123 -146
- package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +144 -166
- package/Interaction/Manipulators/MouseRangeManipulator.js +127 -132
- package/Interaction/Manipulators/VRButtonPanManipulator.js +33 -23
- package/Interaction/Manipulators.js +21 -21
- package/Interaction/Misc/DeviceOrientationToCamera.js +25 -47
- package/Interaction/Misc.js +1 -1
- package/Interaction/Style/InteractorStyleImage.js +101 -121
- package/Interaction/Style/InteractorStyleMPRSlice.js +111 -128
- package/Interaction/Style/InteractorStyleManipulator/Presets.js +9 -17
- package/Interaction/Style/InteractorStyleManipulator.js +254 -329
- package/Interaction/Style/InteractorStyleRemoteMouse.js +195 -180
- package/Interaction/Style/InteractorStyleTrackballCamera.js +154 -157
- package/Interaction/Style/InteractorStyleUnicam.js +30 -38
- package/Interaction/Style.js +5 -5
- package/Interaction/UI/CornerAnnotation/CornerAnnotation.module.css.js +1 -1
- package/Interaction/UI/CornerAnnotation.js +65 -48
- package/Interaction/UI/FPSMonitor.js +104 -105
- package/Interaction/UI/Icons.js +1 -1
- package/Interaction/UI/Slider/Constants.js +2 -2
- package/Interaction/UI/Slider.js +78 -95
- package/Interaction/UI/VolumeController.js +104 -97
- package/Interaction/UI.js +5 -5
- package/Interaction/Widgets/OrientationMarkerWidget/Constants.js +2 -2
- package/Interaction/Widgets/OrientationMarkerWidget.js +90 -135
- package/Interaction/Widgets/PiecewiseGaussianWidget/ComputeHistogram.worker.js +0 -3
- package/Interaction/Widgets/PiecewiseGaussianWidget.js +381 -498
- package/Interaction/Widgets.js +2 -2
- package/Interaction/index.js +5 -5
- package/Proxy/Animation/AbstractAnimationProxy.js +22 -15
- package/Proxy/Animation/AnimationProxyManager.js +43 -51
- package/Proxy/Animation/TimeStepBasedAnimationHandlerProxy.js +26 -19
- package/Proxy/Core/AbstractRepresentationProxy.js +97 -151
- package/Proxy/Core/LookupTableProxy/Constants.js +4 -4
- package/Proxy/Core/LookupTableProxy.js +49 -52
- package/Proxy/Core/PiecewiseFunctionProxy/Constants.js +4 -4
- package/Proxy/Core/PiecewiseFunctionProxy.js +63 -72
- package/Proxy/Core/ProxyManager/core.js +83 -106
- package/Proxy/Core/ProxyManager/properties.js +53 -76
- package/Proxy/Core/ProxyManager/state.js +100 -110
- package/Proxy/Core/ProxyManager/view.js +45 -55
- package/Proxy/Core/ProxyManager.js +16 -8
- package/Proxy/Core/SourceProxy.js +41 -38
- package/Proxy/Core/View2DProxy.js +143 -199
- package/Proxy/Core/ViewProxy.js +223 -269
- package/Proxy/Core.js +7 -7
- package/Proxy/Representations/GeometryRepresentationProxy.js +34 -20
- package/Proxy/Representations/GlyphRepresentationProxy.js +42 -41
- package/Proxy/Representations/MoleculeRepresentationProxy.js +32 -22
- package/Proxy/Representations/ResliceRepresentationProxy.js +48 -32
- package/Proxy/Representations/SkyboxRepresentationProxy.js +30 -29
- package/Proxy/Representations/SliceRepresentationProxy.js +93 -112
- package/Proxy/Representations/SlicedGeometryRepresentationProxy.js +46 -42
- package/Proxy/Representations/VolumeRepresentationProxy.js +108 -133
- package/Proxy/Representations.js +7 -7
- package/Proxy/index.js +2 -2
- package/Rendering/Core/AbstractImageMapper/helper.js +44 -49
- package/Rendering/Core/AbstractImageMapper.js +18 -19
- package/Rendering/Core/AbstractMapper.js +39 -55
- package/Rendering/Core/AbstractMapper3D.js +26 -31
- package/Rendering/Core/AbstractPicker.js +25 -21
- package/Rendering/Core/Actor.js +71 -93
- package/Rendering/Core/Actor2D.js +64 -78
- package/Rendering/Core/AnnotatedCubeActor/Presets.js +5 -11
- package/Rendering/Core/AnnotatedCubeActor.js +94 -79
- package/Rendering/Core/AxesActor.js +65 -87
- package/Rendering/Core/Camera.js +246 -271
- package/Rendering/Core/CellPicker.js +125 -148
- package/Rendering/Core/ColorTransferFunction/ColorMaps.js +20 -21
- package/Rendering/Core/ColorTransferFunction/ColorMapsLite.js +20 -21
- package/Rendering/Core/ColorTransferFunction/Constants.js +4 -4
- package/Rendering/Core/ColorTransferFunction.js +460 -546
- package/Rendering/Core/Coordinate/Constants.js +2 -2
- package/Rendering/Core/Coordinate.js +119 -198
- package/Rendering/Core/CubeAxesActor.js +294 -320
- package/Rendering/Core/Follower.js +46 -45
- package/Rendering/Core/Glyph3DMapper/Constants.js +4 -4
- package/Rendering/Core/Glyph3DMapper.js +96 -148
- package/Rendering/Core/HardwareSelector.js +36 -69
- package/Rendering/Core/ImageArrayMapper.js +87 -126
- package/Rendering/Core/ImageCPRMapper.js +134 -209
- package/Rendering/Core/ImageMapper/Constants.js +2 -2
- package/Rendering/Core/ImageMapper.js +85 -144
- package/Rendering/Core/ImageProperty/Constants.js +2 -2
- package/Rendering/Core/ImageProperty.js +66 -81
- package/Rendering/Core/ImageResliceMapper/Constants.js +2 -2
- package/Rendering/Core/ImageResliceMapper.js +36 -29
- package/Rendering/Core/ImageSlice.js +85 -127
- package/Rendering/Core/InteractorObserver.js +82 -73
- package/Rendering/Core/InteractorStyle/Constants.js +2 -2
- package/Rendering/Core/InteractorStyle.js +56 -58
- package/Rendering/Core/Light.js +43 -49
- package/Rendering/Core/Mapper/CoincidentTopologyHelper.js +37 -48
- package/Rendering/Core/Mapper/Constants.js +6 -6
- package/Rendering/Core/Mapper/Static.js +15 -12
- package/Rendering/Core/Mapper.js +194 -259
- package/Rendering/Core/Mapper2D.js +61 -100
- package/Rendering/Core/Picker.js +124 -143
- package/Rendering/Core/PixelSpaceCallbackMapper.js +40 -37
- package/Rendering/Core/PointPicker.js +68 -79
- package/Rendering/Core/Prop/Constants.js +2 -2
- package/Rendering/Core/Prop.js +58 -106
- package/Rendering/Core/Prop3D.js +54 -83
- package/Rendering/Core/Property/Constants.js +6 -6
- package/Rendering/Core/Property.js +45 -74
- package/Rendering/Core/Property2D/Constants.js +2 -2
- package/Rendering/Core/Property2D.js +33 -42
- package/Rendering/Core/RenderWindow.js +70 -82
- package/Rendering/Core/RenderWindowInteractor/Constants.js +7 -7
- package/Rendering/Core/RenderWindowInteractor.js +324 -439
- package/Rendering/Core/Renderer.js +192 -256
- package/Rendering/Core/ScalarBarActor.js +267 -272
- package/Rendering/Core/Skybox.js +26 -24
- package/Rendering/Core/SphereMapper.js +22 -12
- package/Rendering/Core/StickMapper.js +22 -12
- package/Rendering/Core/SurfaceLICInterface/Constants.js +6 -6
- package/Rendering/Core/SurfaceLICInterface.js +13 -9
- package/Rendering/Core/SurfaceLICMapper.js +23 -15
- package/Rendering/Core/Texture.js +99 -141
- package/Rendering/Core/Viewport.js +60 -88
- package/Rendering/Core/Volume.js +55 -77
- package/Rendering/Core/VolumeMapper/Constants.js +4 -4
- package/Rendering/Core/VolumeMapper.js +59 -91
- package/Rendering/Core/VolumeProperty/Constants.js +4 -4
- package/Rendering/Core/VolumeProperty.js +78 -115
- package/Rendering/Core.js +47 -49
- package/Rendering/Misc/CanvasView.js +62 -61
- package/Rendering/Misc/FullScreenRenderWindow.js +60 -62
- package/Rendering/Misc/GenericRenderWindow.js +48 -37
- package/Rendering/Misc/RemoteView.js +86 -80
- package/Rendering/Misc/RenderWindowWithControlBar.js +54 -48
- package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager/CameraSynchronizer.js +43 -51
- package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager.js +52 -82
- package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.js +258 -308
- package/Rendering/Misc/SynchronizableRenderWindow.js +133 -163
- package/Rendering/Misc/TextureLODsDownloader.js +72 -74
- package/Rendering/Misc.js +7 -7
- package/Rendering/OpenGL/Actor.js +57 -68
- package/Rendering/OpenGL/Actor2D.js +56 -56
- package/Rendering/OpenGL/BufferObject/Constants.js +2 -2
- package/Rendering/OpenGL/BufferObject.js +50 -65
- package/Rendering/OpenGL/Camera.js +35 -29
- package/Rendering/OpenGL/CellArrayBufferObject.js +119 -149
- package/Rendering/OpenGL/Convolution2DPass.js +87 -81
- package/Rendering/OpenGL/CubeAxesActor.js +28 -21
- package/Rendering/OpenGL/ForwardPass.js +53 -64
- package/Rendering/OpenGL/Framebuffer.js +61 -101
- package/Rendering/OpenGL/Glyph3DMapper.js +165 -196
- package/Rendering/OpenGL/HardwareSelector/Constants.js +2 -2
- package/Rendering/OpenGL/HardwareSelector.js +272 -397
- package/Rendering/OpenGL/Helper.js +58 -73
- package/Rendering/OpenGL/ImageCPRMapper.js +339 -421
- package/Rendering/OpenGL/ImageMapper.js +268 -361
- package/Rendering/OpenGL/ImageResliceMapper.js +306 -438
- package/Rendering/OpenGL/ImageSlice.js +48 -54
- package/Rendering/OpenGL/OrderIndependentTranslucentPass.js +102 -84
- package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +43 -42
- package/Rendering/OpenGL/PolyDataMapper.js +358 -492
- package/Rendering/OpenGL/PolyDataMapper2D.js +153 -205
- package/Rendering/OpenGL/RadialDistortionPass.js +86 -89
- package/Rendering/OpenGL/RenderWindow/Constants.js +2 -2
- package/Rendering/OpenGL/RenderWindow/ContextProxy.js +20 -29
- package/Rendering/OpenGL/RenderWindow.js +356 -510
- package/Rendering/OpenGL/Renderer.js +77 -89
- package/Rendering/OpenGL/ReplacementShaderMapper.js +28 -46
- package/Rendering/OpenGL/ScalarBarActor.js +28 -21
- package/Rendering/OpenGL/Shader.js +37 -31
- package/Rendering/OpenGL/ShaderCache.js +67 -74
- package/Rendering/OpenGL/ShaderProgram.js +136 -248
- package/Rendering/OpenGL/Skybox.js +99 -60
- package/Rendering/OpenGL/SphereMapper.js +94 -108
- package/Rendering/OpenGL/StickMapper.js +110 -114
- package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D/pingpong.js +91 -157
- package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D.js +142 -151
- package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +142 -216
- package/Rendering/OpenGL/SurfaceLIC/SurfaceLICMapper.js +79 -100
- package/Rendering/OpenGL/SurfaceLIC.js +2 -2
- package/Rendering/OpenGL/Texture/Constants.js +4 -4
- package/Rendering/OpenGL/Texture.js +443 -608
- package/Rendering/OpenGL/TextureUnitManager.js +47 -43
- package/Rendering/OpenGL/VertexArrayObject.js +92 -131
- package/Rendering/OpenGL/ViewNodeFactory.js +25 -13
- package/Rendering/OpenGL/Volume.js +38 -34
- package/Rendering/OpenGL/VolumeMapper.js +437 -547
- package/Rendering/OpenGL.js +28 -28
- package/Rendering/SceneGraph/RenderPass.js +34 -31
- package/Rendering/SceneGraph/RenderWindowViewNode.js +68 -94
- package/Rendering/SceneGraph/ViewNode.js +82 -111
- package/Rendering/SceneGraph/ViewNodeFactory.js +31 -26
- package/Rendering/SceneGraph.js +4 -4
- package/Rendering/WebGPU/Actor.js +49 -49
- package/Rendering/WebGPU/Actor2D.js +45 -44
- package/Rendering/WebGPU/BindGroup.js +43 -50
- package/Rendering/WebGPU/Buffer.js +41 -50
- package/Rendering/WebGPU/BufferManager/Constants.js +4 -4
- package/Rendering/WebGPU/BufferManager.js +111 -141
- package/Rendering/WebGPU/Camera.js +65 -67
- package/Rendering/WebGPU/CellArrayMapper.js +621 -388
- package/Rendering/WebGPU/CubeAxesActor.js +28 -19
- package/Rendering/WebGPU/Device.js +78 -133
- package/Rendering/WebGPU/ForwardPass.js +75 -72
- package/Rendering/WebGPU/FullScreenQuad.js +25 -18
- package/Rendering/WebGPU/Glyph3DMapper.js +62 -74
- package/Rendering/WebGPU/HardwareSelectionPass.js +45 -38
- package/Rendering/WebGPU/HardwareSelector.js +200 -276
- package/Rendering/WebGPU/ImageMapper.js +180 -171
- package/Rendering/WebGPU/ImageSlice.js +45 -44
- package/Rendering/WebGPU/IndexBuffer.js +166 -200
- package/Rendering/WebGPU/OpaquePass.js +37 -36
- package/Rendering/WebGPU/OrderIndependentTranslucentPass.js +72 -45
- package/Rendering/WebGPU/Pipeline.js +37 -51
- package/Rendering/WebGPU/PixelSpaceCallbackMapper.js +27 -19
- package/Rendering/WebGPU/PolyDataMapper.js +50 -53
- package/Rendering/WebGPU/PolyDataMapper2D.js +39 -39
- package/Rendering/WebGPU/RenderEncoder.js +68 -88
- package/Rendering/WebGPU/RenderWindow.js +262 -376
- package/Rendering/WebGPU/Renderer.js +224 -208
- package/Rendering/WebGPU/Sampler.js +27 -21
- package/Rendering/WebGPU/ScalarBarActor.js +28 -19
- package/Rendering/WebGPU/ShaderCache.js +43 -41
- package/Rendering/WebGPU/ShaderDescription.js +52 -59
- package/Rendering/WebGPU/ShaderModule.js +26 -17
- package/Rendering/WebGPU/SimpleMapper.js +185 -121
- package/Rendering/WebGPU/SphereMapper.js +200 -130
- package/Rendering/WebGPU/StickMapper.js +289 -152
- package/Rendering/WebGPU/StorageBuffer.js +100 -115
- package/Rendering/WebGPU/Texture.js +79 -99
- package/Rendering/WebGPU/TextureManager.js +52 -54
- package/Rendering/WebGPU/TextureView.js +40 -43
- package/Rendering/WebGPU/Types.js +53 -70
- package/Rendering/WebGPU/UniformBuffer.js +158 -184
- package/Rendering/WebGPU/VertexInput.js +64 -90
- package/Rendering/WebGPU/ViewNodeFactory.js +25 -13
- package/Rendering/WebGPU/Volume.js +52 -51
- package/Rendering/WebGPU/VolumePass.js +218 -239
- package/Rendering/WebGPU/VolumePassFSQ.js +625 -306
- package/Rendering/WebGPU.js +1 -1
- package/Rendering/index.js +5 -5
- package/Widgets/Core/AbstractWidget/Constants.js +2 -2
- package/Widgets/Core/AbstractWidget.js +49 -58
- package/Widgets/Core/AbstractWidgetFactory.js +101 -122
- package/Widgets/Core/StateBuilder/boundsMixin.js +23 -28
- package/Widgets/Core/StateBuilder/color3Mixin.js +10 -7
- package/Widgets/Core/StateBuilder/colorMixin.js +10 -6
- package/Widgets/Core/StateBuilder/cornerMixin.js +16 -15
- package/Widgets/Core/StateBuilder/directionMixin.js +20 -18
- package/Widgets/Core/StateBuilder/manipulatorMixin.js +26 -18
- package/Widgets/Core/StateBuilder/nameMixin.js +10 -6
- package/Widgets/Core/StateBuilder/orientationMixin.js +19 -16
- package/Widgets/Core/StateBuilder/originMixin.js +25 -32
- package/Widgets/Core/StateBuilder/scale1Mixin.js +10 -6
- package/Widgets/Core/StateBuilder/scale3Mixin.js +10 -6
- package/Widgets/Core/StateBuilder/shapeMixin.js +12 -6
- package/Widgets/Core/StateBuilder/textMixin.js +10 -6
- package/Widgets/Core/StateBuilder/visibleMixin.js +10 -6
- package/Widgets/Core/StateBuilder.js +120 -149
- package/Widgets/Core/WidgetManager/Constants.js +7 -7
- package/Widgets/Core/WidgetManager.js +249 -421
- package/Widgets/Core/WidgetState.js +48 -57
- package/Widgets/Core.js +5 -5
- package/Widgets/Manipulators/AbstractManipulator.js +20 -14
- package/Widgets/Manipulators/CPRManipulator.js +55 -71
- package/Widgets/Manipulators/LineManipulator.js +31 -28
- package/Widgets/Manipulators/PickerManipulator.d.ts +48 -0
- package/Widgets/Manipulators/PickerManipulator.js +65 -0
- package/Widgets/Manipulators/PlaneManipulator.js +26 -23
- package/Widgets/Manipulators/TrackballManipulator.js +39 -35
- package/Widgets/Manipulators.js +4 -2
- package/Widgets/Representations/ArrowHandleRepresentation.js +148 -162
- package/Widgets/Representations/CircleContextRepresentation.js +44 -38
- package/Widgets/Representations/ContextRepresentation.js +17 -14
- package/Widgets/Representations/ConvexFaceContextRepresentation.js +50 -47
- package/Widgets/Representations/CroppingOutlineRepresentation.js +38 -27
- package/Widgets/Representations/CubeHandleRepresentation.js +21 -18
- package/Widgets/Representations/GlyphRepresentation.js +107 -152
- package/Widgets/Representations/HandleRepresentation.js +17 -14
- package/Widgets/Representations/ImplicitPlaneRepresentation.js +97 -91
- package/Widgets/Representations/LineHandleRepresentation.js +44 -41
- package/Widgets/Representations/OutlineContextRepresentation.js +42 -36
- package/Widgets/Representations/PolyLineRepresentation.js +60 -75
- package/Widgets/Representations/RectangleContextRepresentation.js +42 -37
- package/Widgets/Representations/SphereContextRepresentation.js +19 -27
- package/Widgets/Representations/SphereHandleRepresentation.js +31 -27
- package/Widgets/Representations/SplineContextRepresentation.js +46 -70
- package/Widgets/Representations/WidgetRepresentation/Constants.js +2 -2
- package/Widgets/Representations/WidgetRepresentation.js +99 -134
- package/Widgets/Representations.js +13 -13
- package/Widgets/Widgets3D/AngleWidget/behavior.js +41 -63
- package/Widgets/Widgets3D/AngleWidget.js +40 -38
- package/Widgets/Widgets3D/DistanceWidget/behavior.js +40 -61
- package/Widgets/Widgets3D/DistanceWidget.js +38 -36
- package/Widgets/Widgets3D/EllipseWidget/behavior.js +14 -19
- package/Widgets/Widgets3D/EllipseWidget/state.js +4 -2
- package/Widgets/Widgets3D/EllipseWidget.js +37 -26
- package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +26 -56
- package/Widgets/Widgets3D/ImageCroppingWidget/helpers.js +14 -17
- package/Widgets/Widgets3D/ImageCroppingWidget/state.js +20 -16
- package/Widgets/Widgets3D/ImageCroppingWidget.js +80 -98
- package/Widgets/Widgets3D/ImplicitPlaneWidget.js +55 -77
- package/Widgets/Widgets3D/InteractiveOrientationWidget/behavior.js +17 -18
- package/Widgets/Widgets3D/InteractiveOrientationWidget/state.js +15 -7
- package/Widgets/Widgets3D/InteractiveOrientationWidget.js +30 -29
- package/Widgets/Widgets3D/LabelWidget/behavior.js +37 -62
- package/Widgets/Widgets3D/LabelWidget.js +31 -25
- package/Widgets/Widgets3D/LineWidget/Constants.js +8 -8
- package/Widgets/Widgets3D/LineWidget/behavior.js +77 -114
- package/Widgets/Widgets3D/LineWidget/helpers.js +13 -20
- package/Widgets/Widgets3D/LineWidget/state.js +2 -1
- package/Widgets/Widgets3D/LineWidget.js +39 -35
- package/Widgets/Widgets3D/PaintWidget/behavior.js +24 -59
- package/Widgets/Widgets3D/PaintWidget.js +39 -37
- package/Widgets/Widgets3D/PolyLineWidget/behavior.js +44 -68
- package/Widgets/Widgets3D/PolyLineWidget.js +36 -31
- package/Widgets/Widgets3D/RectangleWidget/behavior.js +6 -11
- package/Widgets/Widgets3D/RectangleWidget/state.js +4 -2
- package/Widgets/Widgets3D/RectangleWidget.js +37 -25
- package/Widgets/Widgets3D/ResliceCursorWidget/Constants.js +35 -21
- package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +133 -209
- package/Widgets/Widgets3D/ResliceCursorWidget/cprBehavior.js +26 -41
- package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +89 -116
- package/Widgets/Widgets3D/ResliceCursorWidget/state.js +33 -40
- package/Widgets/Widgets3D/ResliceCursorWidget.js +186 -227
- package/Widgets/Widgets3D/SeedWidget/behavior.js +82 -0
- package/Widgets/Widgets3D/SeedWidget/state.js +18 -0
- package/Widgets/Widgets3D/SeedWidget.d.ts +44 -0
- package/Widgets/Widgets3D/SeedWidget.js +43 -0
- package/Widgets/Widgets3D/ShapeWidget/Constants.js +19 -19
- package/Widgets/Widgets3D/ShapeWidget/behavior.js +150 -252
- package/Widgets/Widgets3D/ShapeWidget.js +24 -27
- package/Widgets/Widgets3D/SphereWidget/behavior.js +35 -69
- package/Widgets/Widgets3D/SphereWidget/state.js +9 -5
- package/Widgets/Widgets3D/SphereWidget.js +34 -44
- package/Widgets/Widgets3D/SplineWidget/behavior.js +85 -120
- package/Widgets/Widgets3D/SplineWidget.js +43 -39
- package/Widgets/Widgets3D.js +15 -15
- package/Widgets/index.js +4 -4
- package/_virtual/rollup-plugin-worker-loader__module_Sources/Filters/General/PaintFilter/PaintFilter.worker.js +95 -207
- package/_virtual/rollup-plugin-worker-loader__module_Sources/Interaction/Widgets/PiecewiseGaussianWidget/ComputeHistogram.worker.js +0 -3
- package/favicon.js +5 -6
- package/index.d.ts +4 -2
- package/index.js +4 -3
- package/macros.js +4 -1931
- package/macros2.js +1684 -0
- package/package.json +6 -6
- package/vtk.js +18 -31
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
3
|
-
import macro from '../../macros.js';
|
|
1
|
+
import { m as macro } from '../../macros2.js';
|
|
4
2
|
import { registerViewConstructor } from '../Core/RenderWindow.js';
|
|
5
3
|
import vtkForwardPass from './ForwardPass.js';
|
|
6
4
|
import vtkWebGPUBuffer from './Buffer.js';
|
|
@@ -11,29 +9,29 @@ import vtkRenderPass from '../SceneGraph/RenderPass.js';
|
|
|
11
9
|
import vtkRenderWindowViewNode from '../SceneGraph/RenderWindowViewNode.js';
|
|
12
10
|
import HalfFloat from '../../Common/Core/HalfFloat.js';
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
const {
|
|
13
|
+
vtkErrorMacro
|
|
14
|
+
} = macro;
|
|
15
|
+
// const IS_CHROME = navigator.userAgent.indexOf('Chrome') !== -1;
|
|
16
|
+
const SCREENSHOT_PLACEHOLDER = {
|
|
17
17
|
position: 'absolute',
|
|
18
18
|
top: 0,
|
|
19
19
|
left: 0,
|
|
20
20
|
width: '100%',
|
|
21
21
|
height: '100%'
|
|
22
|
-
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// ----------------------------------------------------------------------------
|
|
23
25
|
// vtkWebGPURenderWindow methods
|
|
24
26
|
// ----------------------------------------------------------------------------
|
|
25
27
|
|
|
26
28
|
function vtkWebGPURenderWindow(publicAPI, model) {
|
|
27
29
|
// Set our className
|
|
28
30
|
model.classHierarchy.push('vtkWebGPURenderWindow');
|
|
31
|
+
publicAPI.getViewNodeFactory = () => model.myFactory;
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}; // Auto update style
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var previousSize = [0, 0];
|
|
36
|
-
|
|
33
|
+
// Auto update style
|
|
34
|
+
const previousSize = [0, 0];
|
|
37
35
|
function updateWindow() {
|
|
38
36
|
// Canvas size
|
|
39
37
|
if (model.renderable) {
|
|
@@ -44,35 +42,33 @@ function vtkWebGPURenderWindow(publicAPI, model) {
|
|
|
44
42
|
model.canvas.setAttribute('height', model.size[1]);
|
|
45
43
|
publicAPI.recreateSwapChain();
|
|
46
44
|
}
|
|
47
|
-
}
|
|
48
|
-
|
|
45
|
+
}
|
|
49
46
|
|
|
47
|
+
// ImageStream size
|
|
50
48
|
if (model.viewStream) {
|
|
51
49
|
// If same size that's a NoOp
|
|
52
50
|
model.viewStream.setSize(model.size[0], model.size[1]);
|
|
53
|
-
}
|
|
54
|
-
|
|
51
|
+
}
|
|
55
52
|
|
|
56
|
-
|
|
53
|
+
// Offscreen ?
|
|
54
|
+
model.canvas.style.display = model.useOffScreen ? 'none' : 'block';
|
|
57
55
|
|
|
56
|
+
// Cursor type
|
|
58
57
|
if (model.el) {
|
|
59
58
|
model.el.style.cursor = model.cursorVisibility ? model.cursor : 'none';
|
|
60
|
-
}
|
|
61
|
-
|
|
59
|
+
}
|
|
62
60
|
|
|
61
|
+
// Invalidate cached DOM container size
|
|
63
62
|
model.containerSize = null;
|
|
64
63
|
}
|
|
65
|
-
|
|
66
64
|
publicAPI.onModified(updateWindow);
|
|
67
|
-
|
|
68
|
-
publicAPI.recreateSwapChain = function () {
|
|
65
|
+
publicAPI.recreateSwapChain = () => {
|
|
69
66
|
if (model.context) {
|
|
70
67
|
model.context.unconfigure();
|
|
71
68
|
model.presentationFormat = navigator.gpu.getPreferredCanvasFormat(model.adapter);
|
|
72
|
-
/* eslint-disable no-undef */
|
|
73
69
|
|
|
70
|
+
/* eslint-disable no-undef */
|
|
74
71
|
/* eslint-disable no-bitwise */
|
|
75
|
-
|
|
76
72
|
model.context.configure({
|
|
77
73
|
device: model.device.getHandle(),
|
|
78
74
|
format: model.presentationFormat,
|
|
@@ -84,18 +80,14 @@ function vtkWebGPURenderWindow(publicAPI, model) {
|
|
|
84
80
|
model._configured = true;
|
|
85
81
|
}
|
|
86
82
|
};
|
|
83
|
+
publicAPI.getCurrentTexture = () => model.context.getCurrentTexture();
|
|
87
84
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}; // Builds myself.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
publicAPI.buildPass = function (prepass) {
|
|
85
|
+
// Builds myself.
|
|
86
|
+
publicAPI.buildPass = prepass => {
|
|
94
87
|
if (prepass) {
|
|
95
88
|
if (!model.renderable) {
|
|
96
89
|
return;
|
|
97
90
|
}
|
|
98
|
-
|
|
99
91
|
publicAPI.prepareNodes();
|
|
100
92
|
publicAPI.addMissingNodes(model.renderable.getRenderersByReference());
|
|
101
93
|
publicAPI.removeUnusedNodes();
|
|
@@ -104,10 +96,11 @@ function vtkWebGPURenderWindow(publicAPI, model) {
|
|
|
104
96
|
if (!model._configured) {
|
|
105
97
|
publicAPI.recreateSwapChain();
|
|
106
98
|
}
|
|
107
|
-
|
|
108
99
|
model.commandEncoder = model.device.createCommandEncoder();
|
|
109
100
|
}
|
|
110
|
-
};
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// publicAPI.traverseRenderers = (renPass) => {
|
|
111
104
|
// // iterate over renderers
|
|
112
105
|
// const numlayers = publicAPI.getRenderable().getNumberOfLayers();
|
|
113
106
|
// const renderers = publicAPI.getChildren();
|
|
@@ -122,137 +115,88 @@ function vtkWebGPURenderWindow(publicAPI, model) {
|
|
|
122
115
|
// }
|
|
123
116
|
// };
|
|
124
117
|
|
|
125
|
-
|
|
126
|
-
publicAPI.initialize = function () {
|
|
118
|
+
publicAPI.initialize = () => {
|
|
127
119
|
if (!model.initializing) {
|
|
128
120
|
model.initializing = true;
|
|
129
|
-
|
|
130
121
|
if (!navigator.gpu) {
|
|
131
122
|
vtkErrorMacro('WebGPU is not enabled.');
|
|
132
123
|
return;
|
|
133
124
|
}
|
|
134
|
-
|
|
135
|
-
publicAPI.create3DContextAsync().then(function () {
|
|
125
|
+
publicAPI.create3DContextAsync().then(() => {
|
|
136
126
|
model.initialized = true;
|
|
137
|
-
|
|
138
127
|
if (model.deleted) {
|
|
139
128
|
return;
|
|
140
129
|
}
|
|
141
|
-
|
|
142
130
|
publicAPI.invokeInitialized();
|
|
143
131
|
});
|
|
144
132
|
}
|
|
145
133
|
};
|
|
146
|
-
|
|
147
|
-
publicAPI.setContainer = function (el) {
|
|
134
|
+
publicAPI.setContainer = el => {
|
|
148
135
|
if (model.el && model.el !== el) {
|
|
149
136
|
if (model.canvas.parentNode !== model.el) {
|
|
150
137
|
vtkErrorMacro('Error: canvas parent node does not match container');
|
|
151
|
-
}
|
|
138
|
+
}
|
|
152
139
|
|
|
140
|
+
// Remove canvas from previous container
|
|
141
|
+
model.el.removeChild(model.canvas);
|
|
153
142
|
|
|
154
|
-
|
|
143
|
+
// If the renderer has previously added
|
|
155
144
|
// a background image, remove it from the DOM.
|
|
156
|
-
|
|
157
145
|
if (model.el.contains(model.bgImage)) {
|
|
158
146
|
model.el.removeChild(model.bgImage);
|
|
159
147
|
}
|
|
160
148
|
}
|
|
161
|
-
|
|
162
149
|
if (model.el !== el) {
|
|
163
150
|
model.el = el;
|
|
164
|
-
|
|
165
151
|
if (model.el) {
|
|
166
|
-
model.el.appendChild(model.canvas);
|
|
167
|
-
// image, attach it to the DOM.
|
|
152
|
+
model.el.appendChild(model.canvas);
|
|
168
153
|
|
|
154
|
+
// If the renderer is set to use a background
|
|
155
|
+
// image, attach it to the DOM.
|
|
169
156
|
if (model.useBackgroundImage) {
|
|
170
157
|
model.el.appendChild(model.bgImage);
|
|
171
158
|
}
|
|
172
|
-
}
|
|
173
|
-
|
|
159
|
+
}
|
|
174
160
|
|
|
161
|
+
// Trigger modified()
|
|
175
162
|
publicAPI.modified();
|
|
176
163
|
}
|
|
177
164
|
};
|
|
178
|
-
|
|
179
|
-
publicAPI.
|
|
180
|
-
return model.el;
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
publicAPI.getContainerSize = function () {
|
|
165
|
+
publicAPI.getContainer = () => model.el;
|
|
166
|
+
publicAPI.getContainerSize = () => {
|
|
184
167
|
if (!model.containerSize && model.el) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
168
|
+
const {
|
|
169
|
+
width,
|
|
170
|
+
height
|
|
171
|
+
} = model.el.getBoundingClientRect();
|
|
189
172
|
model.containerSize = [width, height];
|
|
190
173
|
}
|
|
191
|
-
|
|
192
174
|
return model.containerSize || model.size;
|
|
193
175
|
};
|
|
194
|
-
|
|
195
|
-
publicAPI.
|
|
196
|
-
|
|
176
|
+
publicAPI.getFramebufferSize = () => model.size;
|
|
177
|
+
publicAPI.create3DContextAsync = async () => {
|
|
178
|
+
// Get a GPU device to render with
|
|
179
|
+
model.adapter = await navigator.gpu.requestAdapter({
|
|
180
|
+
powerPreference: 'high-performance'
|
|
181
|
+
});
|
|
182
|
+
if (model.deleted) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
// console.log([...model.adapter.features]);
|
|
186
|
+
model.device = vtkWebGPUDevice.newInstance();
|
|
187
|
+
model.device.initialize(await model.adapter.requestDevice());
|
|
188
|
+
if (model.deleted) {
|
|
189
|
+
model.device = null;
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
// model.device.getHandle().lost.then((info) => {
|
|
193
|
+
// console.log(`${info.message}`);
|
|
194
|
+
// publicAPI.releaseGraphicsResources();
|
|
195
|
+
// });
|
|
196
|
+
model.context = model.canvas.getContext('webgpu');
|
|
197
197
|
};
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
201
|
-
while (1) {
|
|
202
|
-
switch (_context.prev = _context.next) {
|
|
203
|
-
case 0:
|
|
204
|
-
_context.next = 2;
|
|
205
|
-
return navigator.gpu.requestAdapter({
|
|
206
|
-
powerPreference: 'high-performance'
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
case 2:
|
|
210
|
-
model.adapter = _context.sent;
|
|
211
|
-
|
|
212
|
-
if (!model.deleted) {
|
|
213
|
-
_context.next = 5;
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
return _context.abrupt("return");
|
|
218
|
-
|
|
219
|
-
case 5:
|
|
220
|
-
// console.log([...model.adapter.features]);
|
|
221
|
-
model.device = vtkWebGPUDevice.newInstance();
|
|
222
|
-
_context.t0 = model.device;
|
|
223
|
-
_context.next = 9;
|
|
224
|
-
return model.adapter.requestDevice();
|
|
225
|
-
|
|
226
|
-
case 9:
|
|
227
|
-
_context.t1 = _context.sent;
|
|
228
|
-
|
|
229
|
-
_context.t0.initialize.call(_context.t0, _context.t1);
|
|
230
|
-
|
|
231
|
-
if (!model.deleted) {
|
|
232
|
-
_context.next = 14;
|
|
233
|
-
break;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
model.device = null;
|
|
237
|
-
return _context.abrupt("return");
|
|
238
|
-
|
|
239
|
-
case 14:
|
|
240
|
-
// model.device.getHandle().lost.then((info) => {
|
|
241
|
-
// console.log(`${info.message}`);
|
|
242
|
-
// publicAPI.releaseGraphicsResources();
|
|
243
|
-
// });
|
|
244
|
-
model.context = model.canvas.getContext('webgpu');
|
|
245
|
-
|
|
246
|
-
case 15:
|
|
247
|
-
case "end":
|
|
248
|
-
return _context.stop();
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}, _callee);
|
|
252
|
-
}));
|
|
253
|
-
|
|
254
|
-
publicAPI.releaseGraphicsResources = function () {
|
|
255
|
-
var rp = vtkRenderPass.newInstance();
|
|
198
|
+
publicAPI.releaseGraphicsResources = () => {
|
|
199
|
+
const rp = vtkRenderPass.newInstance();
|
|
256
200
|
rp.setCurrentOperation('Release');
|
|
257
201
|
rp.traverse(publicAPI, null);
|
|
258
202
|
model.adapter = null;
|
|
@@ -261,367 +205,299 @@ function vtkWebGPURenderWindow(publicAPI, model) {
|
|
|
261
205
|
model.initialized = false;
|
|
262
206
|
model.initializing = false;
|
|
263
207
|
};
|
|
264
|
-
|
|
265
|
-
publicAPI.setBackgroundImage = function (img) {
|
|
208
|
+
publicAPI.setBackgroundImage = img => {
|
|
266
209
|
model.bgImage.src = img.src;
|
|
267
210
|
};
|
|
211
|
+
publicAPI.setUseBackgroundImage = value => {
|
|
212
|
+
model.useBackgroundImage = value;
|
|
268
213
|
|
|
269
|
-
|
|
270
|
-
model.useBackgroundImage = value; // Add or remove the background image from the
|
|
214
|
+
// Add or remove the background image from the
|
|
271
215
|
// DOM as specified.
|
|
272
|
-
|
|
273
216
|
if (model.useBackgroundImage && !model.el.contains(model.bgImage)) {
|
|
274
217
|
model.el.appendChild(model.bgImage);
|
|
275
218
|
} else if (!model.useBackgroundImage && model.el.contains(model.bgImage)) {
|
|
276
219
|
model.el.removeChild(model.bgImage);
|
|
277
220
|
}
|
|
278
221
|
};
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
case 7:
|
|
310
|
-
result = _context3.sent;
|
|
311
|
-
imageData = new ImageData(result.colorValues, result.width, result.height); // temporaryCanvas.putImageData(imageData, 0, 0);
|
|
312
|
-
|
|
313
|
-
temporaryContext.putImageData(imageData, 0, 0); // Get current client rect to place canvas
|
|
314
|
-
|
|
315
|
-
mainBoundingClientRect = model.canvas.getBoundingClientRect();
|
|
316
|
-
renderWindow = model.renderable;
|
|
317
|
-
renderers = renderWindow.getRenderers();
|
|
318
|
-
renderers.forEach(function (renderer) {
|
|
319
|
-
var viewProps = renderer.getViewProps();
|
|
320
|
-
viewProps.forEach(function (viewProp) {
|
|
321
|
-
// Check if the prop has a container that should have canvas
|
|
322
|
-
if (viewProp.getContainer) {
|
|
323
|
-
var container = viewProp.getContainer();
|
|
324
|
-
var canvasList = container.getElementsByTagName('canvas'); // Go throughout all canvas and copy it into temporary main canvas
|
|
325
|
-
|
|
326
|
-
for (var i = 0; i < canvasList.length; i++) {
|
|
327
|
-
var currentCanvas = canvasList[i];
|
|
328
|
-
var boundingClientRect = currentCanvas.getBoundingClientRect();
|
|
329
|
-
var newXPosition = boundingClientRect.x - mainBoundingClientRect.x;
|
|
330
|
-
var newYPosition = boundingClientRect.y - mainBoundingClientRect.y;
|
|
331
|
-
temporaryContext.drawImage(currentCanvas, newXPosition, newYPosition);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
});
|
|
336
|
-
screenshot = temporaryCanvas.toDataURL(format);
|
|
337
|
-
temporaryCanvas.remove();
|
|
338
|
-
publicAPI.invokeImageReady(screenshot);
|
|
339
|
-
|
|
340
|
-
case 17:
|
|
341
|
-
case "end":
|
|
342
|
-
return _context3.stop();
|
|
222
|
+
async function getCanvasDataURL() {
|
|
223
|
+
let format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : model.imageFormat;
|
|
224
|
+
// Copy current canvas to not modify the original
|
|
225
|
+
const temporaryCanvas = document.createElement('canvas');
|
|
226
|
+
const temporaryContext = temporaryCanvas.getContext('2d');
|
|
227
|
+
temporaryCanvas.width = model.canvas.width;
|
|
228
|
+
temporaryCanvas.height = model.canvas.height;
|
|
229
|
+
const result = await publicAPI.getPixelsAsync();
|
|
230
|
+
const imageData = new ImageData(result.colorValues, result.width, result.height);
|
|
231
|
+
// temporaryCanvas.putImageData(imageData, 0, 0);
|
|
232
|
+
temporaryContext.putImageData(imageData, 0, 0);
|
|
233
|
+
|
|
234
|
+
// Get current client rect to place canvas
|
|
235
|
+
const mainBoundingClientRect = model.canvas.getBoundingClientRect();
|
|
236
|
+
const renderWindow = model.renderable;
|
|
237
|
+
const renderers = renderWindow.getRenderers();
|
|
238
|
+
renderers.forEach(renderer => {
|
|
239
|
+
const viewProps = renderer.getViewProps();
|
|
240
|
+
viewProps.forEach(viewProp => {
|
|
241
|
+
// Check if the prop has a container that should have canvas
|
|
242
|
+
if (viewProp.getContainer) {
|
|
243
|
+
const container = viewProp.getContainer();
|
|
244
|
+
const canvasList = container.getElementsByTagName('canvas');
|
|
245
|
+
// Go throughout all canvas and copy it into temporary main canvas
|
|
246
|
+
for (let i = 0; i < canvasList.length; i++) {
|
|
247
|
+
const currentCanvas = canvasList[i];
|
|
248
|
+
const boundingClientRect = currentCanvas.getBoundingClientRect();
|
|
249
|
+
const newXPosition = boundingClientRect.x - mainBoundingClientRect.x;
|
|
250
|
+
const newYPosition = boundingClientRect.y - mainBoundingClientRect.y;
|
|
251
|
+
temporaryContext.drawImage(currentCanvas, newXPosition, newYPosition);
|
|
343
252
|
}
|
|
344
253
|
}
|
|
345
|
-
}
|
|
346
|
-
})
|
|
347
|
-
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
const screenshot = temporaryCanvas.toDataURL(format);
|
|
257
|
+
temporaryCanvas.remove();
|
|
258
|
+
publicAPI.invokeImageReady(screenshot);
|
|
348
259
|
}
|
|
349
|
-
|
|
350
260
|
publicAPI.captureNextImage = function () {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
size = _ref2$size === void 0 ? null : _ref2$size,
|
|
358
|
-
_ref2$scale = _ref2.scale,
|
|
359
|
-
scale = _ref2$scale === void 0 ? 1 : _ref2$scale;
|
|
360
|
-
|
|
261
|
+
let format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'image/png';
|
|
262
|
+
let {
|
|
263
|
+
resetCamera = false,
|
|
264
|
+
size = null,
|
|
265
|
+
scale = 1
|
|
266
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
361
267
|
if (model.deleted) {
|
|
362
268
|
return null;
|
|
363
269
|
}
|
|
364
|
-
|
|
365
270
|
model.imageFormat = format;
|
|
366
|
-
|
|
271
|
+
const previous = model.notifyStartCaptureImage;
|
|
367
272
|
model.notifyStartCaptureImage = true;
|
|
368
273
|
model._screenshot = {
|
|
369
|
-
size: !!size || scale !== 1 ? size || model.size.map(
|
|
370
|
-
return val * scale;
|
|
371
|
-
}) : null
|
|
274
|
+
size: !!size || scale !== 1 ? size || model.size.map(val => val * scale) : null
|
|
372
275
|
};
|
|
373
|
-
return new Promise(
|
|
374
|
-
|
|
276
|
+
return new Promise((resolve, reject) => {
|
|
277
|
+
const subscription = publicAPI.onImageReady(imageURL => {
|
|
375
278
|
if (model._screenshot.size === null) {
|
|
376
279
|
model.notifyStartCaptureImage = previous;
|
|
377
280
|
subscription.unsubscribe();
|
|
378
|
-
|
|
379
281
|
if (model._screenshot.placeHolder) {
|
|
380
282
|
// resize the main canvas back to its original size and show it
|
|
381
|
-
model.size = model._screenshot.originalSize;
|
|
283
|
+
model.size = model._screenshot.originalSize;
|
|
382
284
|
|
|
383
|
-
|
|
285
|
+
// process the resize
|
|
286
|
+
publicAPI.modified();
|
|
384
287
|
|
|
288
|
+
// restore the saved camera parameters, if applicable
|
|
385
289
|
if (model._screenshot.cameras) {
|
|
386
|
-
model._screenshot.cameras.forEach(
|
|
387
|
-
|
|
388
|
-
|
|
290
|
+
model._screenshot.cameras.forEach(_ref => {
|
|
291
|
+
let {
|
|
292
|
+
restoreParamsFn,
|
|
293
|
+
arg
|
|
294
|
+
} = _ref;
|
|
389
295
|
return restoreParamsFn(arg);
|
|
390
296
|
});
|
|
391
|
-
}
|
|
392
|
-
|
|
297
|
+
}
|
|
393
298
|
|
|
394
|
-
|
|
299
|
+
// Trigger a render at the original size
|
|
300
|
+
publicAPI.traverseAllPasses();
|
|
395
301
|
|
|
302
|
+
// Remove and clean up the placeholder, revealing the original
|
|
396
303
|
model.el.removeChild(model._screenshot.placeHolder);
|
|
397
|
-
|
|
398
304
|
model._screenshot.placeHolder.remove();
|
|
399
|
-
|
|
400
305
|
model._screenshot = null;
|
|
401
306
|
}
|
|
402
|
-
|
|
403
307
|
resolve(imageURL);
|
|
404
308
|
} else {
|
|
405
309
|
// Create a placeholder image overlay while we resize and render
|
|
406
|
-
|
|
310
|
+
const tmpImg = document.createElement('img');
|
|
407
311
|
tmpImg.style = SCREENSHOT_PLACEHOLDER;
|
|
408
312
|
tmpImg.src = imageURL;
|
|
409
|
-
model._screenshot.placeHolder = model.el.appendChild(tmpImg);
|
|
313
|
+
model._screenshot.placeHolder = model.el.appendChild(tmpImg);
|
|
410
314
|
|
|
411
|
-
|
|
315
|
+
// hide the main canvas
|
|
316
|
+
model.canvas.style.display = 'none';
|
|
412
317
|
|
|
318
|
+
// remember the main canvas original size, then resize it
|
|
413
319
|
model._screenshot.originalSize = model.size;
|
|
414
320
|
model.size = model._screenshot.size;
|
|
415
|
-
model._screenshot.size = null;
|
|
321
|
+
model._screenshot.size = null;
|
|
416
322
|
|
|
323
|
+
// process the resize
|
|
417
324
|
publicAPI.modified();
|
|
418
|
-
|
|
419
325
|
if (resetCamera) {
|
|
420
|
-
|
|
421
|
-
// from all the renderers, so we can restore them later
|
|
326
|
+
const isUserResetCamera = resetCamera !== true;
|
|
422
327
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
328
|
+
// If resetCamera was requested, we first save camera parameters
|
|
329
|
+
// from all the renderers, so we can restore them later
|
|
330
|
+
model._screenshot.cameras = model.renderable.getRenderers().map(renderer => {
|
|
331
|
+
const camera = renderer.getActiveCamera();
|
|
332
|
+
const params = camera.get('focalPoint', 'position', 'parallelScale');
|
|
426
333
|
return {
|
|
427
334
|
resetCameraArgs: isUserResetCamera ? {
|
|
428
|
-
renderer
|
|
335
|
+
renderer
|
|
429
336
|
} : undefined,
|
|
430
337
|
resetCameraFn: isUserResetCamera ? resetCamera : renderer.resetCamera,
|
|
431
338
|
restoreParamsFn: camera.set,
|
|
432
339
|
// "clone" the params so we don't keep refs to properties
|
|
433
340
|
arg: JSON.parse(JSON.stringify(params))
|
|
434
341
|
};
|
|
435
|
-
});
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
// Perform the resetCamera() on each renderer only after capturing
|
|
436
345
|
// the params from all active cameras, in case there happen to be
|
|
437
346
|
// linked cameras among the renderers.
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
347
|
+
model._screenshot.cameras.forEach(_ref2 => {
|
|
348
|
+
let {
|
|
349
|
+
resetCameraFn,
|
|
350
|
+
resetCameraArgs
|
|
351
|
+
} = _ref2;
|
|
442
352
|
return resetCameraFn(resetCameraArgs);
|
|
443
353
|
});
|
|
444
|
-
}
|
|
445
|
-
|
|
354
|
+
}
|
|
446
355
|
|
|
356
|
+
// Trigger a render at the custom size
|
|
447
357
|
publicAPI.traverseAllPasses();
|
|
448
358
|
}
|
|
449
359
|
});
|
|
450
360
|
});
|
|
451
361
|
};
|
|
452
|
-
|
|
453
|
-
publicAPI.traverseAllPasses = function () {
|
|
362
|
+
publicAPI.traverseAllPasses = () => {
|
|
454
363
|
if (model.deleted) {
|
|
455
364
|
return;
|
|
456
|
-
}
|
|
365
|
+
}
|
|
366
|
+
// if we are not initialized then we call initialize
|
|
457
367
|
// which is async so we will not actually get a render
|
|
458
368
|
// so we queue up another traverse for when we are initialized
|
|
459
|
-
|
|
460
|
-
|
|
461
369
|
if (!model.initialized) {
|
|
462
370
|
publicAPI.initialize();
|
|
463
|
-
|
|
371
|
+
const subscription = publicAPI.onInitialized(() => {
|
|
464
372
|
subscription.unsubscribe();
|
|
465
373
|
publicAPI.traverseAllPasses();
|
|
466
374
|
});
|
|
467
375
|
} else {
|
|
468
376
|
if (model.renderPasses) {
|
|
469
|
-
for (
|
|
377
|
+
for (let index = 0; index < model.renderPasses.length; ++index) {
|
|
470
378
|
model.renderPasses[index].traverse(publicAPI, null);
|
|
471
379
|
}
|
|
472
380
|
}
|
|
473
|
-
|
|
474
381
|
if (model.commandEncoder) {
|
|
475
382
|
model.device.submitCommandEncoder(model.commandEncoder);
|
|
476
383
|
model.commandEncoder = null;
|
|
477
|
-
|
|
478
384
|
if (model.notifyStartCaptureImage) {
|
|
479
|
-
model.device.onSubmittedWorkDone().then(
|
|
385
|
+
model.device.onSubmittedWorkDone().then(() => {
|
|
480
386
|
getCanvasDataURL();
|
|
481
387
|
});
|
|
482
388
|
}
|
|
483
389
|
}
|
|
484
390
|
}
|
|
485
391
|
};
|
|
486
|
-
|
|
487
|
-
publicAPI.setViewStream = function (stream) {
|
|
392
|
+
publicAPI.setViewStream = stream => {
|
|
488
393
|
if (model.viewStream === stream) {
|
|
489
394
|
return false;
|
|
490
395
|
}
|
|
491
|
-
|
|
492
396
|
if (model.subscription) {
|
|
493
397
|
model.subscription.unsubscribe();
|
|
494
398
|
model.subscription = null;
|
|
495
399
|
}
|
|
496
|
-
|
|
497
400
|
model.viewStream = stream;
|
|
498
|
-
|
|
499
401
|
if (model.viewStream) {
|
|
500
402
|
// Force background to be transparent + render
|
|
501
|
-
|
|
502
|
-
mainRenderer.getBackgroundByReference()[3] = 0;
|
|
403
|
+
const mainRenderer = model.renderable.getRenderers()[0];
|
|
404
|
+
mainRenderer.getBackgroundByReference()[3] = 0;
|
|
503
405
|
|
|
504
|
-
|
|
406
|
+
// Enable display of the background image
|
|
407
|
+
publicAPI.setUseBackgroundImage(true);
|
|
505
408
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
});
|
|
409
|
+
// Bind to remote stream
|
|
410
|
+
model.subscription = model.viewStream.onImageReady(e => publicAPI.setBackgroundImage(e.image));
|
|
509
411
|
model.viewStream.setSize(model.size[0], model.size[1]);
|
|
510
412
|
model.viewStream.invalidateCache();
|
|
511
413
|
model.viewStream.render();
|
|
512
414
|
publicAPI.modified();
|
|
513
415
|
}
|
|
514
|
-
|
|
515
416
|
return true;
|
|
516
417
|
};
|
|
517
|
-
|
|
518
|
-
publicAPI.
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
publicAPI.getPropFromID = function (id) {
|
|
523
|
-
for (var i = 0; i < model.children.length; i++) {
|
|
524
|
-
var res = model.children[i].getPropFromID(id);
|
|
525
|
-
|
|
418
|
+
publicAPI.getUniquePropID = () => model.nextPropID++;
|
|
419
|
+
publicAPI.getPropFromID = id => {
|
|
420
|
+
for (let i = 0; i < model.children.length; i++) {
|
|
421
|
+
const res = model.children[i].getPropFromID(id);
|
|
526
422
|
if (res !== null) {
|
|
527
423
|
return res;
|
|
528
424
|
}
|
|
529
425
|
}
|
|
530
|
-
|
|
531
426
|
return null;
|
|
532
427
|
};
|
|
428
|
+
publicAPI.getPixelsAsync = async () => {
|
|
429
|
+
const device = model.device;
|
|
430
|
+
const texture = model.renderPasses[0].getOpaquePass().getColorTexture();
|
|
431
|
+
|
|
432
|
+
// as this is async we really don't want to store things in
|
|
433
|
+
// the class as multiple calls may start before resolving
|
|
434
|
+
// so anything specific to this request gets put into the
|
|
435
|
+
// result object (by value in most cases)
|
|
436
|
+
const result = {
|
|
437
|
+
width: texture.getWidth(),
|
|
438
|
+
height: texture.getHeight()
|
|
439
|
+
};
|
|
533
440
|
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
device.submitCommandEncoder(cmdEnc);
|
|
577
|
-
/* eslint-disable no-undef */
|
|
578
|
-
|
|
579
|
-
cLoad = colorBuffer.mapAsync(GPUMapMode.READ);
|
|
580
|
-
_context2.next = 14;
|
|
581
|
-
return cLoad;
|
|
582
|
-
|
|
583
|
-
case 14:
|
|
584
|
-
/* eslint-enable no-undef */
|
|
585
|
-
result.colorValues = new Uint16Array(colorBuffer.getMappedRange().slice());
|
|
586
|
-
colorBuffer.unmap(); // repack the array
|
|
587
|
-
|
|
588
|
-
tmparray = new Uint8ClampedArray(result.height * result.width * 4);
|
|
589
|
-
|
|
590
|
-
for (y = 0; y < result.height; y++) {
|
|
591
|
-
for (x = 0; x < result.width; x++) {
|
|
592
|
-
doffset = (y * result.width + x) * 4;
|
|
593
|
-
soffset = (y * result.colorBufferWidth + x) * 4;
|
|
594
|
-
tmparray[doffset] = 255.0 * HalfFloat.fromHalf(result.colorValues[soffset]);
|
|
595
|
-
tmparray[doffset + 1] = 255.0 * HalfFloat.fromHalf(result.colorValues[soffset + 1]);
|
|
596
|
-
tmparray[doffset + 2] = 255.0 * HalfFloat.fromHalf(result.colorValues[soffset + 2]);
|
|
597
|
-
tmparray[doffset + 3] = 255.0 * HalfFloat.fromHalf(result.colorValues[soffset + 3]);
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
result.colorValues = tmparray;
|
|
602
|
-
return _context2.abrupt("return", result);
|
|
603
|
-
|
|
604
|
-
case 20:
|
|
605
|
-
case "end":
|
|
606
|
-
return _context2.stop();
|
|
607
|
-
}
|
|
441
|
+
// must be a multiple of 256 bytes, so 32 texels with rgba16
|
|
442
|
+
result.colorBufferWidth = 32 * Math.floor((result.width + 31) / 32);
|
|
443
|
+
result.colorBufferSizeInBytes = result.colorBufferWidth * result.height * 8;
|
|
444
|
+
const colorBuffer = vtkWebGPUBuffer.newInstance();
|
|
445
|
+
colorBuffer.setDevice(device);
|
|
446
|
+
/* eslint-disable no-bitwise */
|
|
447
|
+
/* eslint-disable no-undef */
|
|
448
|
+
colorBuffer.create(result.colorBufferSizeInBytes, GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST);
|
|
449
|
+
/* eslint-enable no-bitwise */
|
|
450
|
+
/* eslint-enable no-undef */
|
|
451
|
+
|
|
452
|
+
const cmdEnc = model.device.createCommandEncoder();
|
|
453
|
+
cmdEnc.copyTextureToBuffer({
|
|
454
|
+
texture: texture.getHandle()
|
|
455
|
+
}, {
|
|
456
|
+
buffer: colorBuffer.getHandle(),
|
|
457
|
+
bytesPerRow: 8 * result.colorBufferWidth,
|
|
458
|
+
rowsPerImage: result.height
|
|
459
|
+
}, {
|
|
460
|
+
width: result.width,
|
|
461
|
+
height: result.height,
|
|
462
|
+
depthOrArrayLayers: 1
|
|
463
|
+
});
|
|
464
|
+
device.submitCommandEncoder(cmdEnc);
|
|
465
|
+
|
|
466
|
+
/* eslint-disable no-undef */
|
|
467
|
+
const cLoad = colorBuffer.mapAsync(GPUMapMode.READ);
|
|
468
|
+
await cLoad;
|
|
469
|
+
/* eslint-enable no-undef */
|
|
470
|
+
|
|
471
|
+
result.colorValues = new Uint16Array(colorBuffer.getMappedRange().slice());
|
|
472
|
+
colorBuffer.unmap();
|
|
473
|
+
// repack the array
|
|
474
|
+
const tmparray = new Uint8ClampedArray(result.height * result.width * 4);
|
|
475
|
+
for (let y = 0; y < result.height; y++) {
|
|
476
|
+
for (let x = 0; x < result.width; x++) {
|
|
477
|
+
const doffset = (y * result.width + x) * 4;
|
|
478
|
+
const soffset = (y * result.colorBufferWidth + x) * 4;
|
|
479
|
+
tmparray[doffset] = 255.0 * HalfFloat.fromHalf(result.colorValues[soffset]);
|
|
480
|
+
tmparray[doffset + 1] = 255.0 * HalfFloat.fromHalf(result.colorValues[soffset + 1]);
|
|
481
|
+
tmparray[doffset + 2] = 255.0 * HalfFloat.fromHalf(result.colorValues[soffset + 2]);
|
|
482
|
+
tmparray[doffset + 3] = 255.0 * HalfFloat.fromHalf(result.colorValues[soffset + 3]);
|
|
608
483
|
}
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
484
|
+
}
|
|
485
|
+
result.colorValues = tmparray;
|
|
486
|
+
return result;
|
|
487
|
+
};
|
|
488
|
+
publicAPI.createSelector = () => {
|
|
489
|
+
const ret = vtkWebGPUHardwareSelector.newInstance();
|
|
614
490
|
ret.setWebGPURenderWindow(publicAPI);
|
|
615
491
|
return ret;
|
|
616
492
|
};
|
|
617
|
-
|
|
618
493
|
publicAPI.delete = macro.chain(publicAPI.delete, publicAPI.setViewStream);
|
|
619
|
-
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// ----------------------------------------------------------------------------
|
|
620
497
|
// Object factory
|
|
621
498
|
// ----------------------------------------------------------------------------
|
|
622
499
|
|
|
623
|
-
|
|
624
|
-
var DEFAULT_VALUES = {
|
|
500
|
+
const DEFAULT_VALUES = {
|
|
625
501
|
initialized: false,
|
|
626
502
|
context: null,
|
|
627
503
|
adapter: null,
|
|
@@ -638,57 +514,67 @@ var DEFAULT_VALUES = {
|
|
|
638
514
|
nextPropID: 1,
|
|
639
515
|
xrSupported: false,
|
|
640
516
|
presentationFormat: null
|
|
641
|
-
};
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
// ----------------------------------------------------------------------------
|
|
642
520
|
|
|
643
521
|
function extend(publicAPI, model) {
|
|
644
|
-
|
|
645
|
-
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
522
|
+
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
523
|
+
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
646
524
|
|
|
525
|
+
// Create internal instances
|
|
647
526
|
model.canvas = document.createElement('canvas');
|
|
648
|
-
model.canvas.style.width = '100%';
|
|
527
|
+
model.canvas.style.width = '100%';
|
|
649
528
|
|
|
529
|
+
// Create internal bgImage
|
|
650
530
|
model.bgImage = new Image();
|
|
651
531
|
model.bgImage.style.position = 'absolute';
|
|
652
532
|
model.bgImage.style.left = '0';
|
|
653
533
|
model.bgImage.style.top = '0';
|
|
654
534
|
model.bgImage.style.width = '100%';
|
|
655
535
|
model.bgImage.style.height = '100%';
|
|
656
|
-
model.bgImage.style.zIndex = '-1';
|
|
536
|
+
model.bgImage.style.zIndex = '-1';
|
|
657
537
|
|
|
538
|
+
// Inheritance
|
|
658
539
|
vtkRenderWindowViewNode.extend(publicAPI, model, initialValues);
|
|
659
540
|
model.myFactory = vtkWebGPUViewNodeFactory.newInstance();
|
|
660
541
|
/* eslint-disable no-use-before-define */
|
|
661
|
-
|
|
662
542
|
model.myFactory.registerOverride('vtkRenderWindow', newInstance);
|
|
663
543
|
/* eslint-enable no-use-before-define */
|
|
664
|
-
// setup default forward pass rendering
|
|
665
544
|
|
|
545
|
+
// setup default forward pass rendering
|
|
666
546
|
model.renderPasses[0] = vtkForwardPass.newInstance();
|
|
667
|
-
|
|
668
547
|
if (!model.selector) {
|
|
669
548
|
model.selector = vtkWebGPUHardwareSelector.newInstance();
|
|
670
549
|
model.selector.setWebGPURenderWindow(publicAPI);
|
|
671
550
|
}
|
|
672
|
-
|
|
673
551
|
macro.event(publicAPI, model, 'imageReady');
|
|
674
|
-
macro.event(publicAPI, model, 'initialized');
|
|
552
|
+
macro.event(publicAPI, model, 'initialized');
|
|
675
553
|
|
|
554
|
+
// Build VTK API
|
|
676
555
|
macro.get(publicAPI, model, ['commandEncoder', 'device', 'presentationFormat', 'useBackgroundImage', 'xrSupported']);
|
|
677
556
|
macro.setGet(publicAPI, model, ['initialized', 'context', 'canvas', 'device', 'renderPasses', 'notifyStartCaptureImage', 'cursor', 'useOffScreen']);
|
|
678
|
-
macro.setGetArray(publicAPI, model, ['size'], 2);
|
|
557
|
+
macro.setGetArray(publicAPI, model, ['size'], 2);
|
|
679
558
|
|
|
559
|
+
// Object methods
|
|
680
560
|
vtkWebGPURenderWindow(publicAPI, model);
|
|
681
|
-
}
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// ----------------------------------------------------------------------------
|
|
682
564
|
|
|
683
|
-
|
|
565
|
+
const newInstance = macro.newInstance(extend, 'vtkWebGPURenderWindow');
|
|
566
|
+
|
|
567
|
+
// ----------------------------------------------------------------------------
|
|
684
568
|
// Register API specific RenderWindow implementation
|
|
685
569
|
// ----------------------------------------------------------------------------
|
|
686
570
|
|
|
687
|
-
registerViewConstructor('WebGPU', newInstance);
|
|
571
|
+
registerViewConstructor('WebGPU', newInstance);
|
|
572
|
+
|
|
573
|
+
// ----------------------------------------------------------------------------
|
|
688
574
|
|
|
689
575
|
var vtkRenderWindow = {
|
|
690
|
-
newInstance
|
|
691
|
-
extend
|
|
576
|
+
newInstance,
|
|
577
|
+
extend
|
|
692
578
|
};
|
|
693
579
|
|
|
694
580
|
export { vtkRenderWindow as default, extend, newInstance };
|