@needle-tools/three 0.169.20-experimental.0 → 0.183.2-canary.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/LICENSE +1 -1
- package/README.md +5 -6
- package/build/three.cjs +54184 -56703
- package/build/three.core.js +59506 -0
- package/build/three.core.min.js +6 -0
- package/build/three.module.js +11645 -73000
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +648 -0
- package/build/three.tsl.min.js +6 -0
- package/build/three.webgpu.js +53912 -51652
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +53888 -51806
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
- package/examples/jsm/Addons.js +5 -15
- package/examples/jsm/animation/AnimationClipCreator.js +58 -6
- package/examples/jsm/animation/CCDIKSolver.js +152 -45
- package/examples/jsm/capabilities/WebGL.js +28 -29
- package/examples/jsm/capabilities/WebGPU.js +19 -17
- package/examples/jsm/controls/ArcballControls.js +474 -178
- package/examples/jsm/controls/DragControls.js +100 -58
- package/examples/jsm/controls/FirstPersonControls.js +116 -6
- package/examples/jsm/controls/FlyControls.js +50 -2
- package/examples/jsm/controls/MapControls.js +96 -8
- package/examples/jsm/controls/OrbitControls.js +496 -57
- package/examples/jsm/controls/PointerLockControls.js +115 -22
- package/examples/jsm/controls/TrackballControls.js +166 -14
- package/examples/jsm/controls/TransformControls.js +336 -26
- package/examples/jsm/csm/CSM.js +232 -18
- package/examples/jsm/csm/CSMFrustum.js +61 -4
- package/examples/jsm/csm/CSMHelper.js +50 -0
- package/examples/jsm/csm/CSMShader.js +13 -1
- package/examples/jsm/csm/CSMShadowNode.js +599 -0
- package/examples/jsm/curves/CurveExtras.js +303 -31
- package/examples/jsm/curves/NURBSCurve.js +91 -16
- package/examples/jsm/curves/NURBSSurface.js +52 -6
- package/examples/jsm/curves/NURBSUtils.js +102 -112
- package/examples/jsm/curves/NURBSVolume.js +24 -4
- package/examples/jsm/effects/AnaglyphEffect.js +134 -7
- package/examples/jsm/effects/AsciiEffect.js +69 -22
- package/examples/jsm/effects/OutlineEffect.js +61 -111
- package/examples/jsm/effects/ParallaxBarrierEffect.js +30 -0
- package/examples/jsm/effects/StereoEffect.js +31 -0
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/DebugEnvironment.js +50 -0
- package/examples/jsm/environments/RoomEnvironment.js +83 -42
- package/examples/jsm/exporters/DRACOExporter.js +56 -14
- package/examples/jsm/exporters/EXRExporter.js +40 -9
- package/examples/jsm/exporters/GLTFExporter.js +502 -169
- package/examples/jsm/exporters/OBJExporter.js +21 -1
- package/examples/jsm/exporters/PLYExporter.js +44 -12
- package/examples/jsm/exporters/STLExporter.js +27 -5
- package/examples/jsm/exporters/USDZExporter.js +781 -291
- package/examples/jsm/geometries/BoxLineGeometry.js +23 -0
- package/examples/jsm/geometries/ConvexGeometry.js +19 -0
- package/examples/jsm/geometries/DecalGeometry.js +91 -30
- package/examples/jsm/geometries/ParametricFunctions.js +100 -0
- package/examples/jsm/geometries/ParametricGeometry.js +38 -5
- package/examples/jsm/geometries/RoundedBoxGeometry.js +68 -7
- package/examples/jsm/geometries/TeapotGeometry.js +23 -38
- package/examples/jsm/geometries/TextGeometry.js +48 -29
- package/examples/jsm/gpgpu/BitonicSort.js +715 -0
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/LightProbeHelper.js +36 -0
- package/examples/jsm/helpers/LightProbeHelperGPU.js +38 -1
- package/examples/jsm/helpers/OctreeHelper.js +36 -0
- package/examples/jsm/helpers/PositionalAudioHelper.js +60 -0
- package/examples/jsm/helpers/RapierHelper.js +59 -0
- package/examples/jsm/helpers/RectAreaLightHelper.js +36 -3
- package/examples/jsm/helpers/TextureHelper.js +28 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +214 -0
- package/examples/jsm/helpers/VertexNormalsHelper.js +61 -2
- package/examples/jsm/helpers/VertexTangentsHelper.js +47 -2
- package/examples/jsm/helpers/ViewHelper.js +181 -9
- package/examples/jsm/inspector/Inspector.js +487 -0
- package/examples/jsm/inspector/RendererInspector.js +425 -0
- package/examples/jsm/inspector/tabs/Console.js +238 -0
- package/examples/jsm/inspector/tabs/Parameters.js +348 -0
- package/examples/jsm/inspector/tabs/Performance.js +268 -0
- package/examples/jsm/inspector/tabs/Viewer.js +166 -0
- package/examples/jsm/inspector/ui/Graph.js +95 -0
- package/examples/jsm/inspector/ui/Item.js +170 -0
- package/examples/jsm/inspector/ui/List.js +75 -0
- package/examples/jsm/inspector/ui/Profiler.js +1975 -0
- package/examples/jsm/inspector/ui/Style.js +1613 -0
- package/examples/jsm/inspector/ui/Tab.js +233 -0
- package/examples/jsm/inspector/ui/Values.js +439 -0
- package/examples/jsm/inspector/ui/utils.js +56 -0
- package/examples/jsm/interactive/HTMLMesh.js +43 -12
- package/examples/jsm/interactive/InteractiveGroup.js +170 -52
- package/examples/jsm/interactive/SelectionBox.js +106 -9
- package/examples/jsm/interactive/SelectionHelper.js +76 -30
- package/examples/jsm/libs/demuxer_mp4.js +109 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +76 -58
- package/examples/jsm/libs/motion-controllers.module.js +1 -1
- package/examples/jsm/lighting/TiledLighting.js +42 -0
- package/examples/jsm/lights/LightProbeGenerator.js +44 -7
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +50 -14
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +16 -0
- package/examples/jsm/lines/Line2.js +41 -4
- package/examples/jsm/lines/LineGeometry.js +80 -2
- package/examples/jsm/lines/LineMaterial.js +105 -5
- package/examples/jsm/lines/LineSegments2.js +54 -4
- package/examples/jsm/lines/LineSegmentsGeometry.js +65 -8
- package/examples/jsm/lines/Wireframe.js +41 -4
- package/examples/jsm/lines/WireframeGeometry2.js +27 -2
- package/examples/jsm/lines/webgpu/Line2.js +28 -2
- package/examples/jsm/lines/webgpu/LineSegments2.js +59 -24
- package/examples/jsm/lines/webgpu/Wireframe.js +86 -0
- package/examples/jsm/loaders/3DMLoader.js +78 -6
- package/examples/jsm/loaders/3MFLoader.js +148 -7
- package/examples/jsm/loaders/AMFLoader.js +34 -14
- package/examples/jsm/loaders/BVHLoader.js +59 -12
- package/examples/jsm/loaders/ColladaLoader.js +61 -4027
- package/examples/jsm/loaders/DDSLoader.js +68 -1
- package/examples/jsm/loaders/DRACOLoader.js +146 -22
- package/examples/jsm/loaders/EXRLoader.js +255 -34
- package/examples/jsm/loaders/FBXLoader.js +80 -42
- package/examples/jsm/loaders/FontLoader.js +83 -6
- package/examples/jsm/loaders/GCodeLoader.js +71 -14
- package/examples/jsm/loaders/GLTFLoader.js +381 -263
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +52 -3
- package/examples/jsm/loaders/HDRLoader.js +485 -0
- package/examples/jsm/loaders/IESLoader.js +42 -0
- package/examples/jsm/loaders/KMZLoader.js +39 -6
- package/examples/jsm/loaders/KTX2Loader.js +124 -48
- package/examples/jsm/loaders/KTXLoader.js +31 -10
- package/examples/jsm/loaders/LDrawLoader.js +192 -145
- package/examples/jsm/loaders/LUT3dlLoader.js +47 -10
- package/examples/jsm/loaders/LUTCubeLoader.js +46 -9
- package/examples/jsm/loaders/LUTImageLoader.js +79 -38
- package/examples/jsm/loaders/LWOLoader.js +54 -59
- package/examples/jsm/loaders/LottieLoader.js +54 -1
- package/examples/jsm/loaders/MD2Loader.js +37 -1
- package/examples/jsm/loaders/MDDLoader.js +57 -12
- package/examples/jsm/loaders/MTLLoader.js +60 -35
- package/examples/jsm/loaders/MaterialXLoader.js +268 -34
- package/examples/jsm/loaders/NRRDLoader.js +40 -8
- package/examples/jsm/loaders/OBJLoader.js +51 -2
- package/examples/jsm/loaders/PCDLoader.js +173 -21
- package/examples/jsm/loaders/PDBLoader.js +41 -2
- package/examples/jsm/loaders/PLYLoader.js +70 -39
- package/examples/jsm/loaders/PVRLoader.js +25 -6
- package/examples/jsm/loaders/RGBELoader.js +6 -438
- package/examples/jsm/loaders/STLLoader.js +48 -38
- package/examples/jsm/loaders/SVGLoader.js +119 -25
- package/examples/jsm/loaders/TDSLoader.js +92 -74
- package/examples/jsm/loaders/TGALoader.js +23 -2
- package/examples/jsm/loaders/TIFFLoader.js +23 -0
- package/examples/jsm/loaders/TTFLoader.js +50 -3
- package/examples/jsm/loaders/USDLoader.js +279 -0
- package/examples/jsm/loaders/USDZLoader.js +4 -858
- package/examples/jsm/loaders/UltraHDRLoader.js +338 -166
- package/examples/jsm/loaders/VOXLoader.js +688 -87
- package/examples/jsm/loaders/VRMLLoader.js +121 -12
- package/examples/jsm/loaders/VTKLoader.js +77 -25
- package/examples/jsm/loaders/XYZLoader.js +36 -0
- package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
- package/examples/jsm/loaders/lwo/IFFParser.js +77 -77
- package/examples/jsm/loaders/usd/USDAParser.js +822 -0
- package/examples/jsm/loaders/usd/USDCParser.js +1852 -0
- package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +183 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +154 -0
- package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
- package/examples/jsm/math/Capsule.js +91 -14
- package/examples/jsm/math/ColorConverter.js +22 -0
- package/examples/jsm/math/ColorSpaces.js +74 -2
- package/examples/jsm/math/ConvexHull.js +517 -93
- package/examples/jsm/math/ImprovedNoise.js +32 -15
- package/examples/jsm/math/Lut.js +113 -0
- package/examples/jsm/math/MeshSurfaceSampler.js +78 -13
- package/examples/jsm/math/OBB.js +141 -29
- package/examples/jsm/math/Octree.js +283 -7
- package/examples/jsm/math/SimplexNoise.js +68 -42
- package/examples/jsm/misc/ConvexObjectBreaker.js +45 -25
- package/examples/jsm/misc/GPUComputationRenderer.js +96 -20
- package/examples/jsm/misc/Gyroscope.js +12 -0
- package/examples/jsm/misc/MD2Character.js +117 -2
- package/examples/jsm/misc/MD2CharacterComplex.js +175 -11
- package/examples/jsm/misc/MorphAnimMesh.js +44 -0
- package/examples/jsm/misc/MorphBlendMesh.js +103 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +100 -54
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +322 -0
- package/examples/jsm/misc/RollerCoaster.js +57 -0
- package/examples/jsm/misc/TubePainter.js +437 -40
- package/examples/jsm/misc/Volume.js +123 -76
- package/examples/jsm/misc/VolumeSlice.js +95 -49
- package/examples/jsm/modifiers/CurveModifier.js +66 -38
- package/examples/jsm/modifiers/CurveModifierGPU.js +42 -19
- package/examples/jsm/modifiers/EdgeSplitModifier.js +20 -0
- package/examples/jsm/modifiers/SimplifyModifier.js +24 -10
- package/examples/jsm/modifiers/TessellateModifier.js +35 -2
- package/examples/jsm/objects/GroundedSkybox.js +25 -6
- package/examples/jsm/objects/Lensflare.js +94 -2
- package/examples/jsm/objects/LensflareMesh.js +64 -10
- package/examples/jsm/objects/MarchingCubes.js +90 -5
- package/examples/jsm/objects/Reflector.js +76 -2
- package/examples/jsm/objects/ReflectorForSSRPass.js +41 -0
- package/examples/jsm/objects/Refractor.js +62 -0
- package/examples/jsm/objects/ShadowMesh.js +54 -4
- package/examples/jsm/objects/Sky.js +106 -16
- package/examples/jsm/objects/SkyMesh.js +211 -38
- package/examples/jsm/objects/Water.js +49 -8
- package/examples/jsm/objects/Water2.js +49 -7
- package/examples/jsm/objects/Water2Mesh.js +50 -9
- package/examples/jsm/objects/WaterMesh.js +136 -43
- package/examples/jsm/physics/AmmoPhysics.js +60 -7
- package/examples/jsm/physics/JoltPhysics.js +65 -12
- package/examples/jsm/physics/RapierPhysics.js +217 -21
- package/examples/jsm/postprocessing/AfterimagePass.js +110 -29
- package/examples/jsm/postprocessing/BloomPass.js +128 -26
- package/examples/jsm/postprocessing/BokehPass.js +99 -22
- package/examples/jsm/postprocessing/ClearPass.js +54 -3
- package/examples/jsm/postprocessing/CubeTexturePass.js +82 -21
- package/examples/jsm/postprocessing/DotScreenPass.js +59 -10
- package/examples/jsm/postprocessing/EffectComposer.js +140 -6
- package/examples/jsm/postprocessing/FXAAPass.js +40 -0
- package/examples/jsm/postprocessing/FilmPass.js +54 -5
- package/examples/jsm/postprocessing/GTAOPass.js +202 -57
- package/examples/jsm/postprocessing/GlitchPass.js +86 -34
- package/examples/jsm/postprocessing/HalftonePass.js +65 -10
- package/examples/jsm/postprocessing/LUTPass.js +38 -8
- package/examples/jsm/postprocessing/MaskPass.js +91 -0
- package/examples/jsm/postprocessing/OutlinePass.js +272 -135
- package/examples/jsm/postprocessing/OutputPass.js +65 -14
- package/examples/jsm/postprocessing/Pass.js +100 -4
- package/examples/jsm/postprocessing/RenderPass.js +94 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +124 -45
- package/examples/jsm/postprocessing/RenderTransitionPass.js +120 -21
- package/examples/jsm/postprocessing/SAOPass.js +128 -55
- package/examples/jsm/postprocessing/SMAAPass.js +106 -75
- package/examples/jsm/postprocessing/SSAARenderPass.js +118 -35
- package/examples/jsm/postprocessing/SSAOPass.js +173 -60
- package/examples/jsm/postprocessing/SSRPass.js +268 -53
- package/examples/jsm/postprocessing/SavePass.js +69 -16
- package/examples/jsm/postprocessing/ShaderPass.js +65 -7
- package/examples/jsm/postprocessing/TAARenderPass.js +79 -24
- package/examples/jsm/postprocessing/TexturePass.js +72 -8
- package/examples/jsm/postprocessing/UnrealBloomPass.js +168 -59
- package/examples/jsm/renderers/CSS2DRenderer.js +98 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +111 -7
- package/examples/jsm/renderers/Projector.js +288 -32
- package/examples/jsm/renderers/SVGRenderer.js +323 -61
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +3 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +1 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +5 -1
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +12 -5
- package/examples/jsm/shaders/AfterimageShader.js +8 -3
- package/examples/jsm/shaders/BasicShader.js +8 -1
- package/examples/jsm/shaders/BleachBypassShader.js +10 -3
- package/examples/jsm/shaders/BlendShader.js +8 -1
- package/examples/jsm/shaders/BokehShader.js +9 -3
- package/examples/jsm/shaders/BokehShader2.js +11 -4
- package/examples/jsm/shaders/BrightnessContrastShader.js +10 -4
- package/examples/jsm/shaders/ColorCorrectionShader.js +8 -1
- package/examples/jsm/shaders/ColorifyShader.js +8 -1
- package/examples/jsm/shaders/ConvolutionShader.js +9 -38
- package/examples/jsm/shaders/CopyShader.js +8 -1
- package/examples/jsm/shaders/DOFMipMapShader.js +10 -3
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +10 -1
- package/examples/jsm/shaders/DigitalGlitch.js +10 -7
- package/examples/jsm/shaders/DotScreenShader.js +8 -3
- package/examples/jsm/shaders/ExposureShader.js +8 -1
- package/examples/jsm/shaders/FXAAShader.js +233 -221
- package/examples/jsm/shaders/FilmShader.js +13 -0
- package/examples/jsm/shaders/FocusShader.js +8 -3
- package/examples/jsm/shaders/FreiChenShader.js +10 -3
- package/examples/jsm/shaders/GTAOShader.js +55 -45
- package/examples/jsm/shaders/GammaCorrectionShader.js +11 -2
- package/examples/jsm/shaders/HalftoneShader.js +24 -4
- package/examples/jsm/shaders/HorizontalBlurShader.js +12 -3
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +9 -2
- package/examples/jsm/shaders/HueSaturationShader.js +10 -3
- package/examples/jsm/shaders/KaleidoShader.js +11 -4
- package/examples/jsm/shaders/LuminosityHighPassShader.js +8 -4
- package/examples/jsm/shaders/LuminosityShader.js +8 -2
- package/examples/jsm/shaders/MirrorShader.js +10 -4
- package/examples/jsm/shaders/NormalMapShader.js +7 -2
- package/examples/jsm/shaders/OutputShader.js +19 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +30 -17
- package/examples/jsm/shaders/RGBShiftShader.js +8 -1
- package/examples/jsm/shaders/SAOShader.js +27 -5
- package/examples/jsm/shaders/SMAAShader.js +24 -1
- package/examples/jsm/shaders/SSAOShader.js +37 -6
- package/examples/jsm/shaders/SSRShader.js +32 -6
- package/examples/jsm/shaders/SepiaShader.js +8 -3
- package/examples/jsm/shaders/SobelOperatorShader.js +9 -3
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +13 -8
- package/examples/jsm/shaders/TechnicolorShader.js +10 -4
- package/examples/jsm/shaders/ToonShader.js +29 -6
- package/examples/jsm/shaders/TriangleBlurShader.js +9 -4
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +19 -6
- package/examples/jsm/shaders/VelocityShader.js +8 -1
- package/examples/jsm/shaders/VerticalBlurShader.js +9 -2
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +8 -1
- package/examples/jsm/shaders/VignetteShader.js +8 -3
- package/examples/jsm/shaders/VolumeShader.js +11 -2
- package/examples/jsm/shaders/WaterRefractionShader.js +11 -0
- package/examples/jsm/textures/FlakesTexture.js +14 -0
- package/examples/jsm/transpiler/AST.js +436 -31
- package/examples/jsm/transpiler/GLSLDecoder.js +380 -135
- package/examples/jsm/transpiler/Linker.js +327 -0
- package/examples/jsm/transpiler/ShaderToyDecoder.js +3 -1
- package/examples/jsm/transpiler/TSLEncoder.js +363 -97
- package/examples/jsm/transpiler/Transpiler.js +50 -1
- package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
- package/examples/jsm/transpiler/WGSLEncoder.js +839 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +244 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +549 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +282 -0
- package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
- package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +11 -4
- package/examples/jsm/tsl/display/BloomNode.js +534 -0
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +207 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +334 -0
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +554 -0
- package/examples/jsm/tsl/display/DotScreenNode.js +104 -0
- package/examples/jsm/tsl/display/FXAANode.js +365 -0
- package/examples/jsm/tsl/display/FilmNode.js +101 -0
- package/examples/jsm/tsl/display/GTAONode.js +571 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.js +389 -0
- package/examples/jsm/tsl/display/GodraysNode.js +624 -0
- package/examples/jsm/tsl/display/LensflareNode.js +279 -0
- package/examples/jsm/tsl/display/Lut3DNode.js +109 -0
- package/examples/jsm/tsl/display/MotionBlur.js +33 -0
- package/examples/jsm/tsl/display/OutlineNode.js +762 -0
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +89 -0
- package/examples/jsm/tsl/display/PixelationPassNode.js +335 -0
- package/examples/jsm/tsl/display/RGBShiftNode.js +96 -0
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.js +768 -0
- package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +120 -49
- package/examples/jsm/tsl/display/SSGINode.js +642 -0
- package/examples/jsm/tsl/display/SSRNode.js +656 -0
- package/examples/jsm/tsl/display/SSSNode.js +490 -0
- package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +9 -2
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +61 -19
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +192 -0
- package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +48 -12
- package/examples/jsm/tsl/display/TRAANode.js +726 -0
- package/examples/jsm/tsl/display/TransitionNode.js +141 -0
- package/examples/jsm/tsl/display/boxBlur.js +65 -0
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/display/hashBlur.js +54 -0
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +442 -0
- package/examples/jsm/tsl/math/Bayer.js +73 -0
- package/examples/jsm/tsl/shadows/TileShadowNode.js +456 -0
- package/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +212 -0
- package/examples/jsm/tsl/utils/Raymarching.js +70 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +91 -29
- package/examples/jsm/utils/CameraUtils.js +15 -6
- package/examples/jsm/utils/GeometryCompressionUtils.js +23 -30
- package/examples/jsm/utils/GeometryUtils.js +32 -27
- package/examples/jsm/utils/LDrawUtils.js +14 -5
- package/examples/jsm/utils/SceneOptimizer.js +458 -0
- package/examples/jsm/utils/SceneUtils.js +53 -3
- package/examples/jsm/utils/ShadowMapViewer.js +72 -33
- package/examples/jsm/utils/ShadowMapViewerGPU.js +61 -29
- package/examples/jsm/utils/SkeletonUtils.js +48 -0
- package/examples/jsm/utils/SortUtils.js +17 -5
- package/examples/jsm/utils/UVsDebug.js +12 -4
- package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +16 -0
- package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +20 -2
- package/examples/jsm/utils/WorkerPool.js +67 -2
- package/examples/jsm/webxr/ARButton.js +19 -0
- package/examples/jsm/webxr/OculusHandModel.js +84 -0
- package/examples/jsm/webxr/OculusHandPointerModel.js +148 -22
- package/examples/jsm/webxr/Text2D.js +20 -6
- package/examples/jsm/webxr/VRButton.js +31 -0
- package/examples/jsm/webxr/XRButton.js +23 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +94 -3
- package/examples/jsm/webxr/XREstimatedLight.js +35 -4
- package/examples/jsm/webxr/XRHandMeshModel.js +37 -0
- package/examples/jsm/webxr/XRHandModelFactory.js +96 -6
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +44 -0
- package/examples/jsm/webxr/XRPlanes.js +18 -0
- package/package.json +29 -37
- package/src/Three.Core.js +198 -0
- package/src/Three.Legacy.js +0 -21
- package/src/Three.TSL.js +641 -0
- package/src/Three.WebGPU.Nodes.js +14 -186
- package/src/Three.WebGPU.js +16 -186
- package/src/Three.js +2 -197
- package/src/animation/AnimationAction.js +263 -31
- package/src/animation/AnimationClip.js +162 -7
- package/src/animation/AnimationMixer.js +105 -15
- package/src/animation/AnimationObjectGroup.js +45 -21
- package/src/animation/AnimationUtils.js +163 -24
- package/src/animation/KeyframeTrack.js +191 -17
- package/src/animation/PropertyBinding.js +91 -16
- package/src/animation/PropertyMixer.js +72 -5
- package/src/animation/tracks/BooleanKeyframeTrack.js +33 -6
- package/src/animation/tracks/ColorKeyframeTrack.js +26 -5
- package/src/animation/tracks/NumberKeyframeTrack.js +26 -2
- package/src/animation/tracks/QuaternionKeyframeTrack.js +30 -1
- package/src/animation/tracks/StringKeyframeTrack.js +33 -2
- package/src/animation/tracks/VectorKeyframeTrack.js +26 -2
- package/src/audio/Audio.js +386 -8
- package/src/audio/AudioAnalyser.js +58 -1
- package/src/audio/AudioContext.js +15 -0
- package/src/audio/AudioListener.js +94 -13
- package/src/audio/PositionalAudio.js +107 -0
- package/src/cameras/ArrayCamera.js +37 -0
- package/src/cameras/Camera.js +61 -0
- package/src/cameras/CubeCamera.js +86 -0
- package/src/cameras/OrthographicCamera.js +110 -1
- package/src/cameras/PerspectiveCamera.js +174 -35
- package/src/cameras/StereoCamera.js +48 -2
- package/src/constants.js +1546 -11
- package/src/core/BufferAttribute.js +417 -3
- package/src/core/BufferGeometry.js +407 -22
- package/src/core/Clock.js +69 -8
- package/src/core/EventDispatcher.js +52 -8
- package/src/core/GLBufferAttribute.js +113 -2
- package/src/core/InstancedBufferAttribute.js +29 -0
- package/src/core/InstancedBufferGeometry.js +20 -0
- package/src/core/InstancedInterleavedBuffer.js +26 -0
- package/src/core/InterleavedBuffer.js +141 -7
- package/src/core/InterleavedBufferAttribute.js +200 -2
- package/src/core/Layers.js +71 -10
- package/src/core/Object3D.js +673 -26
- package/src/core/Raycaster.js +136 -2
- package/src/core/RenderTarget.js +256 -27
- package/src/core/RenderTarget3D.js +48 -0
- package/src/core/Timer.js +184 -0
- package/src/core/Uniform.js +29 -0
- package/src/core/UniformsGroup.js +84 -2
- package/src/extras/Controls.js +89 -1
- package/src/extras/DataUtils.js +50 -9
- package/src/extras/Earcut.js +18 -779
- package/src/extras/ImageUtils.js +22 -14
- package/src/extras/PMREMGenerator.js +316 -67
- package/src/extras/ShapeUtils.js +24 -2
- package/src/extras/TextureUtils.js +101 -15
- package/src/extras/core/Curve.js +156 -55
- package/src/extras/core/CurvePath.js +63 -22
- package/src/extras/core/Interpolations.js +34 -2
- package/src/extras/core/Path.js +134 -1
- package/src/extras/core/Shape.js +66 -3
- package/src/extras/core/ShapePath.js +80 -4
- package/src/extras/curves/ArcCurve.js +22 -0
- package/src/extras/curves/CatmullRomCurve3.js +89 -18
- package/src/extras/curves/CubicBezierCurve.js +67 -0
- package/src/extras/curves/CubicBezierCurve3.js +50 -0
- package/src/extras/curves/EllipseCurve.js +102 -0
- package/src/extras/curves/LineCurve.js +36 -0
- package/src/extras/curves/LineCurve3.js +36 -0
- package/src/extras/curves/QuadraticBezierCurve.js +59 -0
- package/src/extras/curves/QuadraticBezierCurve3.js +43 -0
- package/src/extras/curves/SplineCurve.js +48 -0
- package/src/extras/lib/earcut.js +685 -0
- package/src/geometries/BoxGeometry.js +39 -0
- package/src/geometries/CapsuleGeometry.js +196 -11
- package/src/geometries/CircleGeometry.js +41 -0
- package/src/geometries/ConeGeometry.js +39 -0
- package/src/geometries/CylinderGeometry.js +42 -2
- package/src/geometries/DodecahedronGeometry.js +33 -0
- package/src/geometries/EdgesGeometry.js +30 -2
- package/src/geometries/ExtrudeGeometry.js +148 -52
- package/src/geometries/IcosahedronGeometry.js +33 -0
- package/src/geometries/LatheGeometry.js +44 -3
- package/src/geometries/OctahedronGeometry.js +33 -0
- package/src/geometries/PlaneGeometry.js +35 -0
- package/src/geometries/PolyhedronGeometry.js +30 -1
- package/src/geometries/RingGeometry.js +37 -0
- package/src/geometries/ShapeGeometry.js +38 -0
- package/src/geometries/SphereGeometry.js +38 -0
- package/src/geometries/TetrahedronGeometry.js +33 -0
- package/src/geometries/TorusGeometry.js +44 -3
- package/src/geometries/TorusKnotGeometry.js +39 -0
- package/src/geometries/TubeGeometry.js +50 -0
- package/src/geometries/WireframeGeometry.js +32 -0
- package/src/helpers/ArrowHelper.js +62 -5
- package/src/helpers/AxesHelper.js +28 -0
- package/src/helpers/Box3Helper.js +28 -0
- package/src/helpers/BoxHelper.js +43 -7
- package/src/helpers/CameraHelper.js +103 -27
- package/src/helpers/DirectionalLightHelper.js +55 -0
- package/src/helpers/GridHelper.js +26 -0
- package/src/helpers/HemisphereLightHelper.js +42 -0
- package/src/helpers/PlaneHelper.js +33 -0
- package/src/helpers/PointLightHelper.js +43 -24
- package/src/helpers/PolarGridHelper.js +30 -0
- package/src/helpers/SkeletonHelper.js +73 -7
- package/src/helpers/SpotLightHelper.js +43 -0
- package/src/lights/AmbientLight.js +25 -0
- package/src/lights/DirectionalLight.js +70 -0
- package/src/lights/DirectionalLightShadow.js +15 -0
- package/src/lights/HemisphereLight.js +42 -0
- package/src/lights/Light.js +37 -11
- package/src/lights/LightProbe.js +37 -9
- package/src/lights/LightShadow.js +202 -7
- package/src/lights/PointLight.js +74 -0
- package/src/lights/PointLightShadow.js +15 -80
- package/src/lights/RectAreaLight.js +59 -0
- package/src/lights/SpotLight.js +124 -1
- package/src/lights/SpotLightShadow.js +33 -3
- package/src/lights/webgpu/IESSpotLight.js +22 -0
- package/src/lights/webgpu/ProjectorLight.js +46 -0
- package/src/loaders/AnimationLoader.js +34 -2
- package/src/loaders/AudioLoader.js +34 -2
- package/src/loaders/BufferGeometryLoader.js +38 -13
- package/src/loaders/Cache.js +75 -2
- package/src/loaders/CompressedTextureLoader.js +36 -3
- package/src/loaders/CubeTextureLoader.js +45 -0
- package/src/loaders/DataTextureLoader.js +45 -4
- package/src/loaders/FileLoader.js +85 -5
- package/src/loaders/ImageBitmapLoader.js +113 -11
- package/src/loaders/ImageLoader.js +85 -8
- package/src/loaders/Loader.js +150 -0
- package/src/loaders/LoaderUtils.js +18 -36
- package/src/loaders/LoadingManager.js +187 -0
- package/src/loaders/MaterialLoader.js +62 -3
- package/src/loaders/ObjectLoader.js +131 -31
- package/src/loaders/TextureLoader.js +33 -0
- package/src/loaders/nodes/NodeLoader.js +68 -4
- package/src/loaders/nodes/NodeMaterialLoader.js +45 -0
- package/src/loaders/nodes/NodeObjectLoader.js +61 -0
- package/src/materials/LineBasicMaterial.js +74 -1
- package/src/materials/LineDashedMaterial.js +52 -1
- package/src/materials/Material.js +502 -8
- package/src/materials/MeshBasicMaterial.js +168 -2
- package/src/materials/MeshDepthMaterial.js +94 -0
- package/src/materials/MeshDistanceMaterial.js +76 -0
- package/src/materials/MeshLambertMaterial.js +283 -0
- package/src/materials/MeshMatcapMaterial.js +164 -0
- package/src/materials/MeshNormalMaterial.js +114 -0
- package/src/materials/MeshPhongMaterial.js +298 -0
- package/src/materials/MeshPhysicalMaterial.js +296 -4
- package/src/materials/MeshStandardMaterial.js +300 -2
- package/src/materials/MeshToonMaterial.js +219 -0
- package/src/materials/PointsMaterial.js +89 -0
- package/src/materials/RawShaderMaterial.js +25 -0
- package/src/materials/ShaderMaterial.js +234 -6
- package/src/materials/ShadowMaterial.js +54 -0
- package/src/materials/SpriteMaterial.js +82 -0
- package/src/materials/nodes/Line2NodeMaterial.js +158 -53
- package/src/materials/nodes/LineBasicNodeMaterial.js +17 -2
- package/src/materials/nodes/LineDashedNodeMaterial.js +81 -6
- package/src/materials/nodes/MeshBasicNodeMaterial.js +59 -2
- package/src/materials/nodes/MeshLambertNodeMaterial.js +35 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +23 -3
- package/src/materials/nodes/MeshNormalNodeMaterial.js +27 -4
- package/src/materials/nodes/MeshPhongNodeMaterial.js +64 -1
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +276 -3
- package/src/materials/nodes/MeshSSSNodeMaterial.js +98 -10
- package/src/materials/nodes/MeshStandardNodeMaterial.js +83 -4
- package/src/materials/nodes/MeshToonNodeMaterial.js +28 -0
- package/src/materials/nodes/NodeMaterial.js +789 -74
- package/src/materials/nodes/NodeMaterials.js +0 -1
- package/src/materials/nodes/PointsNodeMaterial.js +180 -11
- package/src/materials/nodes/ShadowNodeMaterial.js +38 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +86 -23
- package/src/materials/nodes/VolumeNodeMaterial.js +57 -84
- package/src/materials/nodes/manager/NodeMaterialObserver.js +329 -12
- package/src/math/Box2.js +177 -0
- package/src/math/Box3.js +271 -0
- package/src/math/Color.js +355 -11
- package/src/math/ColorManagement.js +158 -92
- package/src/math/Cylindrical.js +65 -6
- package/src/math/Euler.js +139 -5
- package/src/math/Frustum.js +108 -9
- package/src/math/FrustumArray.js +258 -0
- package/src/math/Interpolant.js +87 -8
- package/src/math/Line3.js +221 -2
- package/src/math/MathUtils.js +408 -20
- package/src/math/Matrix2.js +70 -0
- package/src/math/Matrix3.js +229 -4
- package/src/math/Matrix4.js +489 -94
- package/src/math/Plane.js +164 -2
- package/src/math/Quaternion.js +322 -90
- package/src/math/Ray.js +162 -0
- package/src/math/Sphere.js +175 -0
- package/src/math/Spherical.js +73 -11
- package/src/math/SphericalHarmonics3.js +112 -14
- package/src/math/Triangle.js +206 -2
- package/src/math/Vector2.js +396 -10
- package/src/math/Vector3.js +550 -15
- package/src/math/Vector4.js +415 -9
- package/src/math/interpolants/BezierInterpolant.js +108 -0
- package/src/math/interpolants/CubicInterpolant.js +10 -1
- package/src/math/interpolants/DiscreteInterpolant.js +10 -2
- package/src/math/interpolants/LinearInterpolant.js +13 -0
- package/src/math/interpolants/QuaternionLinearInterpolant.js +10 -1
- package/src/nodes/Nodes.js +91 -88
- package/src/nodes/TSL.js +32 -38
- package/src/nodes/accessors/AccessorsUtils.js +37 -9
- package/src/nodes/accessors/Arrays.js +68 -0
- package/src/nodes/accessors/BatchNode.js +49 -14
- package/src/nodes/accessors/Bitangent.js +82 -13
- package/src/nodes/accessors/BufferAttributeNode.js +269 -8
- package/src/nodes/accessors/BufferNode.js +91 -2
- package/src/nodes/accessors/BuiltinNode.js +63 -0
- package/src/nodes/accessors/Camera.js +400 -10
- package/src/nodes/accessors/ClippingNode.js +149 -45
- package/src/nodes/accessors/CubeTextureNode.js +137 -7
- package/src/nodes/accessors/InstanceNode.js +245 -40
- package/src/nodes/accessors/InstancedMeshNode.js +50 -0
- package/src/nodes/accessors/Lights.js +88 -0
- package/src/nodes/accessors/MaterialNode.js +355 -13
- package/src/nodes/accessors/MaterialProperties.js +57 -1
- package/src/nodes/accessors/MaterialReferenceNode.js +52 -14
- package/src/nodes/accessors/ModelNode.js +117 -5
- package/src/nodes/accessors/ModelViewProjectionNode.js +10 -39
- package/src/nodes/accessors/MorphNode.js +73 -26
- package/src/nodes/accessors/Normal.js +174 -19
- package/src/nodes/accessors/Object3DNode.js +146 -12
- package/src/nodes/accessors/PointUVNode.js +25 -0
- package/src/nodes/accessors/Position.js +119 -7
- package/src/nodes/accessors/ReferenceBaseNode.js +190 -4
- package/src/nodes/accessors/ReferenceNode.js +223 -8
- package/src/nodes/accessors/ReflectVector.js +29 -3
- package/src/nodes/accessors/RendererReferenceNode.js +45 -2
- package/src/nodes/accessors/SceneProperties.js +53 -0
- package/src/nodes/accessors/SkinningNode.js +180 -43
- package/src/nodes/accessors/StorageBufferNode.js +278 -26
- package/src/nodes/accessors/StorageTextureNode.js +205 -12
- package/src/nodes/accessors/Tangent.js +48 -10
- package/src/nodes/accessors/TangentUtils.js +46 -0
- package/src/nodes/accessors/Texture3DNode.js +104 -11
- package/src/nodes/accessors/TextureBicubic.js +31 -4
- package/src/nodes/accessors/TextureNode.js +564 -52
- package/src/nodes/accessors/TextureSizeNode.js +42 -1
- package/src/nodes/accessors/UV.js +9 -1
- package/src/nodes/accessors/UniformArrayNode.js +226 -34
- package/src/nodes/accessors/UserDataNode.js +46 -2
- package/src/nodes/accessors/VelocityNode.js +93 -3
- package/src/nodes/accessors/VertexColorNode.js +39 -4
- package/src/nodes/code/CodeNode.js +101 -8
- package/src/nodes/code/ExpressionNode.js +29 -2
- package/src/nodes/code/FunctionCallNode.js +98 -10
- package/src/nodes/code/FunctionNode.js +69 -2
- package/src/nodes/core/ArrayNode.js +174 -0
- package/src/nodes/core/AssignNode.js +80 -9
- package/src/nodes/core/AttributeNode.js +47 -4
- package/src/nodes/core/BypassNode.js +47 -3
- package/src/nodes/core/ConstNode.js +32 -0
- package/src/nodes/core/ContextNode.js +220 -14
- package/src/nodes/core/IndexNode.js +72 -7
- package/src/nodes/core/InputNode.js +50 -1
- package/src/nodes/core/InspectorNode.js +128 -0
- package/src/nodes/core/IsolateNode.js +133 -0
- package/src/nodes/core/LightingModel.js +65 -5
- package/src/nodes/core/MRTNode.js +113 -2
- package/src/nodes/core/Node.js +595 -36
- package/src/nodes/core/NodeAttribute.js +38 -0
- package/src/nodes/core/NodeBuilder.js +1840 -121
- package/src/nodes/core/NodeCache.js +41 -2
- package/src/nodes/core/NodeCode.js +31 -0
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeFrame.js +153 -24
- package/src/nodes/core/NodeFunction.js +48 -1
- package/src/nodes/core/NodeFunctionInput.js +44 -0
- package/src/nodes/core/NodeParser.js +13 -1
- package/src/nodes/core/NodeUniform.js +53 -1
- package/src/nodes/core/NodeUtils.js +201 -51
- package/src/nodes/core/NodeVar.js +47 -1
- package/src/nodes/core/NodeVarying.js +47 -1
- package/src/nodes/core/OutputStructNode.js +54 -12
- package/src/nodes/core/ParameterNode.js +60 -2
- package/src/nodes/core/PropertyNode.js +286 -7
- package/src/nodes/core/StackNode.js +337 -20
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +134 -0
- package/src/nodes/core/StructType.js +13 -0
- package/src/nodes/core/StructTypeNode.js +126 -6
- package/src/nodes/core/SubBuildNode.js +89 -0
- package/src/nodes/core/TempNode.js +31 -5
- package/src/nodes/core/UniformGroupNode.js +85 -7
- package/src/nodes/core/UniformNode.js +163 -16
- package/src/nodes/core/VarNode.js +317 -10
- package/src/nodes/core/VaryingNode.js +115 -13
- package/src/nodes/core/constants.js +40 -0
- package/src/nodes/display/BlendModes.js +171 -0
- package/src/nodes/display/BumpMapNode.js +38 -2
- package/src/nodes/display/ColorAdjustment.js +118 -6
- package/src/nodes/display/ColorSpaceFunctions.js +22 -6
- package/src/nodes/display/ColorSpaceNode.js +97 -47
- package/src/nodes/display/FrontFacingNode.js +64 -7
- package/src/nodes/display/NormalMapNode.js +101 -54
- package/src/nodes/display/PassNode.js +690 -33
- package/src/nodes/display/RenderOutputNode.js +94 -4
- package/src/nodes/display/ScreenNode.js +138 -27
- package/src/nodes/display/ToneMappingFunctions.js +62 -10
- package/src/nodes/display/ToneMappingNode.js +88 -8
- package/src/nodes/display/ToonOutlinePassNode.js +84 -4
- package/src/nodes/display/ViewportDepthNode.js +227 -10
- package/src/nodes/display/ViewportDepthTextureNode.js +39 -5
- package/src/nodes/display/ViewportSharedTextureNode.js +35 -1
- package/src/nodes/display/ViewportTextureNode.js +171 -7
- package/src/nodes/fog/Fog.js +97 -0
- package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +45 -1
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +1 -1
- package/src/nodes/functions/BasicLightingModel.js +28 -6
- package/src/nodes/functions/PhongLightingModel.js +36 -6
- package/src/nodes/functions/PhysicalLightingModel.js +336 -91
- package/src/nodes/functions/ShadowMaskModel.js +30 -3
- package/src/nodes/functions/ToonLightingModel.js +21 -2
- package/src/nodes/functions/VolumetricLightingModel.js +183 -0
- package/src/nodes/functions/material/getAlphaHashThreshold.js +68 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +10 -4
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +37 -0
- package/src/nodes/geometry/RangeNode.js +97 -8
- package/src/nodes/gpgpu/AtomicFunctionNode.js +198 -23
- package/src/nodes/gpgpu/BarrierNode.js +52 -3
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +135 -6
- package/src/nodes/gpgpu/ComputeNode.js +212 -16
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +455 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +143 -9
- package/src/nodes/lighting/AONode.js +18 -0
- package/src/nodes/lighting/AmbientLightNode.js +10 -0
- package/src/nodes/lighting/AnalyticLightNode.js +186 -399
- package/src/nodes/lighting/BasicEnvironmentNode.js +19 -0
- package/src/nodes/lighting/BasicLightMapNode.js +17 -0
- package/src/nodes/lighting/DirectionalLightNode.js +12 -11
- package/src/nodes/lighting/EnvironmentNode.js +59 -19
- package/src/nodes/lighting/HemisphereLightNode.js +33 -2
- package/src/nodes/lighting/IESSpotLightNode.js +13 -1
- package/src/nodes/lighting/IrradianceNode.js +17 -0
- package/src/nodes/lighting/LightProbeNode.js +20 -0
- package/src/nodes/lighting/LightUtils.js +11 -3
- package/src/nodes/lighting/LightingContextNode.js +52 -4
- package/src/nodes/lighting/LightingNode.js +15 -6
- package/src/nodes/lighting/LightsNode.js +238 -35
- package/src/nodes/lighting/PointLightNode.js +60 -25
- package/src/nodes/lighting/PointShadowNode.js +325 -0
- package/src/nodes/lighting/ProjectorLightNode.js +91 -0
- package/src/nodes/lighting/RectAreaLightNode.js +50 -14
- package/src/nodes/lighting/ShadowBaseNode.js +81 -0
- package/src/nodes/lighting/ShadowFilterNode.js +264 -0
- package/src/nodes/lighting/ShadowNode.js +867 -0
- package/src/nodes/lighting/SpotLightNode.js +99 -18
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +166 -2
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/ConditionalNode.js +110 -21
- package/src/nodes/math/Hash.js +8 -0
- package/src/nodes/math/MathNode.js +820 -97
- package/src/nodes/math/MathUtils.js +47 -1
- package/src/nodes/math/OperatorNode.js +517 -84
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/TriNoise3D.js +17 -7
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/parsers/GLSLNodeFunction.js +16 -0
- package/src/nodes/parsers/GLSLNodeParser.js +11 -0
- package/src/nodes/pmrem/PMREMNode.js +180 -23
- package/src/nodes/pmrem/PMREMUtils.js +114 -5
- package/src/nodes/procedural/Checker.js +8 -0
- package/src/nodes/shapes/Shapes.js +33 -0
- package/src/nodes/tsl/TSLBase.js +10 -4
- package/src/nodes/tsl/TSLCore.js +732 -160
- package/src/nodes/utils/ArrayElementNode.js +55 -4
- package/src/nodes/utils/ConvertNode.js +31 -0
- package/src/nodes/utils/CubeMapNode.js +79 -2
- package/src/nodes/utils/DebugNode.js +83 -0
- package/src/nodes/utils/Discard.js +18 -2
- package/src/nodes/utils/EquirectUV.js +27 -0
- package/src/nodes/utils/EventNode.js +118 -0
- package/src/nodes/utils/FlipNode.js +38 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +91 -22
- package/src/nodes/utils/JoinNode.js +57 -4
- package/src/nodes/utils/LoopNode.js +193 -55
- package/src/nodes/utils/MatcapUV.js +22 -0
- package/src/nodes/utils/MaxMipLevelNode.js +49 -1
- package/src/nodes/utils/MemberNode.js +120 -0
- package/src/nodes/utils/Oscillators.js +41 -0
- package/src/nodes/utils/Packing.js +30 -1
- package/src/nodes/utils/PostProcessingUtils.js +154 -0
- package/src/nodes/utils/RTTNode.js +165 -9
- package/src/nodes/utils/ReflectorNode.js +407 -21
- package/src/nodes/utils/RemapNode.js +81 -2
- package/src/nodes/utils/RotateNode.js +41 -1
- package/src/nodes/utils/SampleNode.js +91 -0
- package/src/nodes/utils/SetNode.js +44 -1
- package/src/nodes/utils/SplitNode.js +66 -3
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/SpriteUtils.js +16 -0
- package/src/nodes/utils/StorageArrayElementNode.js +56 -3
- package/src/nodes/utils/Timer.js +26 -0
- package/src/nodes/utils/TriplanarTextures.js +65 -0
- package/src/nodes/utils/UVUtils.js +48 -0
- package/src/nodes/utils/ViewportUtils.js +12 -0
- package/src/objects/BatchedMesh.js +798 -309
- package/src/objects/Bone.js +24 -0
- package/src/objects/ClippingGroup.js +68 -0
- package/src/objects/Group.js +24 -0
- package/src/objects/InstancedMesh.js +131 -2
- package/src/objects/LOD.js +99 -5
- package/src/objects/Line.js +90 -7
- package/src/objects/LineLoop.js +20 -0
- package/src/objects/LineSegments.js +20 -1
- package/src/objects/Mesh.js +84 -0
- package/src/objects/Points.js +60 -0
- package/src/objects/Skeleton.js +120 -5
- package/src/objects/SkinnedMesh.js +102 -6
- package/src/objects/Sprite.js +65 -1
- package/src/renderers/WebGL3DRenderTarget.js +26 -0
- package/src/renderers/WebGLArrayRenderTarget.js +26 -0
- package/src/renderers/WebGLCubeRenderTarget.js +41 -5
- package/src/renderers/WebGLRenderTarget.js +19 -0
- package/src/renderers/WebGLRenderer.js +1016 -278
- package/src/renderers/common/Animation.js +123 -14
- package/src/renderers/common/Attributes.js +41 -1
- package/src/renderers/common/Backend.js +623 -44
- package/src/renderers/common/Background.js +99 -16
- package/src/renderers/common/BindGroup.js +37 -2
- package/src/renderers/common/Binding.js +46 -0
- package/src/renderers/common/Bindings.js +211 -20
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/Buffer.js +89 -0
- package/src/renderers/common/BufferUtils.js +25 -0
- package/src/renderers/common/BundleGroup.js +57 -0
- package/src/renderers/common/CanvasTarget.js +341 -0
- package/src/renderers/common/ChainMap.js +73 -10
- package/src/renderers/common/ClippingContext.js +172 -87
- package/src/renderers/common/Color4.js +40 -0
- package/src/renderers/common/ComputePipeline.js +24 -0
- package/src/renderers/common/Constants.js +2 -1
- package/src/renderers/common/CubeRenderTarget.js +77 -7
- package/src/renderers/common/DataMap.js +37 -1
- package/src/renderers/common/Geometries.js +163 -14
- package/src/renderers/common/IndirectStorageBufferAttribute.js +38 -0
- package/src/renderers/common/Info.js +81 -36
- package/src/renderers/common/InspectorBase.js +146 -0
- package/src/renderers/common/Lighting.js +57 -0
- package/src/renderers/common/Pipeline.js +22 -0
- package/src/renderers/common/Pipelines.js +150 -7
- package/src/renderers/common/PostProcessing.js +22 -84
- package/src/renderers/common/ProgrammableStage.js +60 -2
- package/src/renderers/common/QuadMesh.js +63 -6
- package/src/renderers/common/RenderBundle.js +14 -8
- package/src/renderers/common/RenderBundles.js +40 -10
- package/src/renderers/common/RenderContext.js +219 -4
- package/src/renderers/common/RenderContexts.js +54 -17
- package/src/renderers/common/RenderList.js +233 -24
- package/src/renderers/common/RenderLists.js +46 -6
- package/src/renderers/common/RenderObject.js +548 -46
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +133 -15
- package/src/renderers/common/RenderPipeline.js +216 -6
- package/src/renderers/common/Renderer.js +2155 -332
- package/src/renderers/common/RendererUtils.js +200 -0
- package/src/renderers/common/SampledTexture.js +99 -39
- package/src/renderers/common/Sampler.js +148 -1
- package/src/renderers/common/Storage3DTexture.js +100 -0
- package/src/renderers/common/StorageArrayTexture.js +84 -0
- package/src/renderers/common/StorageBuffer.js +38 -2
- package/src/renderers/common/StorageBufferAttribute.js +31 -2
- package/src/renderers/common/StorageInstancedBufferAttribute.js +31 -2
- package/src/renderers/common/StorageTexture.js +65 -0
- package/src/renderers/common/Textures.js +273 -57
- package/src/renderers/common/TimestampQueryPool.js +163 -0
- package/src/renderers/common/Uniform.js +233 -3
- package/src/renderers/common/UniformBuffer.js +19 -0
- package/src/renderers/common/UniformsGroup.js +235 -26
- package/src/renderers/common/XRManager.js +1677 -0
- package/src/renderers/common/XRRenderTarget.js +91 -0
- package/src/renderers/common/extras/PMREMGenerator.js +371 -108
- package/src/renderers/common/nodes/NodeBuilderState.js +100 -6
- package/src/renderers/common/nodes/NodeLibrary.js +95 -17
- package/src/renderers/common/nodes/NodeManager.js +852 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +84 -8
- package/src/renderers/common/nodes/NodeSampler.js +41 -1
- package/src/renderers/common/nodes/NodeStorageBuffer.js +48 -3
- package/src/renderers/common/nodes/NodeUniform.js +285 -2
- package/src/renderers/common/nodes/NodeUniformBuffer.js +81 -0
- package/src/renderers/common/nodes/NodeUniformsGroup.js +31 -18
- package/src/renderers/shaders/DFGLUTData.js +49 -0
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -12
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +5 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +154 -59
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +230 -181
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk.js +3 -3
- package/src/renderers/shaders/ShaderLib/background.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +14 -2
- package/src/renderers/shaders/ShaderLib/{distanceRGBA.glsl.js → distance.glsl.js} +1 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -9
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +7 -5
- package/src/renderers/shaders/UniformsLib.js +2 -7
- package/src/renderers/shaders/UniformsUtils.js +21 -2
- package/src/renderers/webgl/WebGLAttributes.js +4 -0
- package/src/renderers/webgl/WebGLBackground.js +30 -5
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLCapabilities.js +7 -14
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLExtensions.js +2 -25
- package/src/renderers/webgl/WebGLGeometries.js +10 -35
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLInfo.js +3 -1
- package/src/renderers/webgl/WebGLLights.js +18 -1
- package/src/renderers/webgl/WebGLMaterials.js +12 -0
- package/src/renderers/webgl/WebGLObjects.js +3 -1
- package/src/renderers/webgl/WebGLOutput.js +267 -0
- package/src/renderers/webgl/WebGLProgram.js +87 -148
- package/src/renderers/webgl/WebGLPrograms.js +53 -51
- package/src/renderers/webgl/WebGLRenderLists.js +15 -0
- package/src/renderers/webgl/WebGLShadowMap.js +204 -28
- package/src/renderers/webgl/WebGLState.js +88 -56
- package/src/renderers/webgl/WebGLTextures.js +293 -59
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUniformsGroups.js +5 -3
- package/src/renderers/webgl/WebGLUtils.js +7 -5
- package/src/renderers/webgl-fallback/WebGLBackend.js +1416 -293
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +5 -10
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +785 -92
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +62 -1
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +28 -0
- package/src/renderers/webgl-fallback/utils/WebGLConstants.js +3 -3
- package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +45 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +584 -20
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +468 -80
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +396 -0
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +72 -24
- package/src/renderers/webgpu/WebGPUBackend.js +1517 -428
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +31 -4
- package/src/renderers/webgpu/WebGPURenderer.js +55 -4
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +23 -16
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +37 -42
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +1335 -241
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +32 -4
- package/src/renderers/webgpu/nodes/WGSLNodeParser.js +11 -0
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +144 -20
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +460 -116
- package/src/renderers/webgpu/utils/WebGPUConstants.js +17 -4
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +283 -69
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +225 -178
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +583 -191
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +310 -0
- package/src/renderers/webgpu/utils/WebGPUUtils.js +150 -28
- package/src/renderers/webxr/WebXRController.js +87 -2
- package/src/renderers/webxr/WebXRDepthSensing.js +52 -7
- package/src/renderers/webxr/WebXRManager.js +275 -15
- package/src/scenes/Fog.js +60 -0
- package/src/scenes/FogExp2.js +51 -0
- package/src/scenes/Scene.js +88 -0
- package/src/textures/CanvasTexture.js +28 -0
- package/src/textures/CompressedArrayTexture.js +57 -0
- package/src/textures/CompressedCubeTexture.js +29 -0
- package/src/textures/CompressedTexture.js +64 -6
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/CubeTexture.js +52 -4
- package/src/textures/Data3DTexture.js +79 -2
- package/src/textures/DataArrayTexture.js +93 -0
- package/src/textures/DataTexture.js +65 -0
- package/src/textures/DepthTexture.js +59 -11
- package/src/textures/ExternalTexture.js +56 -0
- package/src/textures/FramebufferTexture.js +62 -0
- package/src/textures/Source.js +106 -4
- package/src/textures/Texture.js +488 -6
- package/src/textures/VideoFrameTexture.js +72 -0
- package/src/textures/VideoTexture.js +78 -6
- package/src/utils.js +322 -3
- package/examples/jsm/animation/MMDAnimationHelper.js +0 -1207
- package/examples/jsm/animation/MMDPhysics.js +0 -1406
- package/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/examples/jsm/effects/PeppersGhostEffect.js +0 -153
- package/examples/jsm/exporters/MMDExporter.js +0 -217
- package/examples/jsm/geometries/InstancedPointsGeometry.js +0 -174
- package/examples/jsm/geometries/ParametricGeometries.js +0 -254
- package/examples/jsm/libs/mmdparser.module.js +0 -11530
- package/examples/jsm/loaders/GLTFLoaderAnimationPointer.js +0 -729
- package/examples/jsm/loaders/MMDLoader.js +0 -2295
- package/examples/jsm/loaders/RGBMLoader.js +0 -1081
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -432
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -144
- package/examples/jsm/misc/Timer.js +0 -128
- package/examples/jsm/objects/InstancedPoints.js +0 -21
- package/examples/jsm/shaders/GodRaysShader.js +0 -321
- package/examples/jsm/shaders/MMDToonShader.js +0 -134
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +0 -156
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +0 -24
- package/src/nodes/accessors/SceneNode.js +0 -55
- package/src/nodes/code/ScriptableNode.js +0 -505
- package/src/nodes/code/ScriptableValueNode.js +0 -170
- package/src/nodes/core/CacheNode.js +0 -50
- package/src/nodes/core/UniformGroup.js +0 -13
- package/src/nodes/display/AfterImageNode.js +0 -158
- package/src/nodes/display/AnaglyphPassNode.js +0 -67
- package/src/nodes/display/AnamorphicNode.js +0 -151
- package/src/nodes/display/BlendMode.js +0 -54
- package/src/nodes/display/BloomNode.js +0 -341
- package/src/nodes/display/DenoiseNode.js +0 -204
- package/src/nodes/display/DepthOfFieldNode.js +0 -124
- package/src/nodes/display/DotScreenNode.js +0 -66
- package/src/nodes/display/FXAANode.js +0 -332
- package/src/nodes/display/FilmNode.js +0 -56
- package/src/nodes/display/GTAONode.js +0 -331
- package/src/nodes/display/GaussianBlurNode.js +0 -213
- package/src/nodes/display/Lut3DNode.js +0 -57
- package/src/nodes/display/MotionBlur.js +0 -25
- package/src/nodes/display/ParallaxBarrierPassNode.js +0 -58
- package/src/nodes/display/PixelationPassNode.js +0 -213
- package/src/nodes/display/PosterizeNode.js +0 -33
- package/src/nodes/display/RGBShiftNode.js +0 -53
- package/src/nodes/display/StereoCompositePassNode.js +0 -110
- package/src/nodes/display/TransitionNode.js +0 -80
- package/src/nodes/fog/FogExp2Node.js +0 -35
- package/src/nodes/fog/FogNode.js +0 -50
- package/src/nodes/fog/FogRangeNode.js +0 -36
- package/src/nodes/functions/BSDF/DFGApprox.js +0 -30
- package/src/nodes/utils/EquirectUVNode.js +0 -36
- package/src/nodes/utils/MatcapUVNode.js +0 -33
- package/src/nodes/utils/OscNode.js +0 -85
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -45
- package/src/nodes/utils/TimerNode.js +0 -97
- package/src/nodes/utils/TriplanarTexturesNode.js +0 -64
- package/src/renderers/common/nodes/Nodes.js +0 -534
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -136
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
GPUTextureFormat, GPUAddressMode, GPUFilterMode, GPUTextureDimension, GPUFeatureName
|
|
2
|
+
GPUTextureFormat, GPUAddressMode, GPUFilterMode, GPUTextureDimension, GPUFeatureName, GPUTextureViewDimension
|
|
3
3
|
} from './WebGPUConstants.js';
|
|
4
|
+
import { ColorManagement } from '../../../math/ColorManagement.js';
|
|
4
5
|
|
|
5
6
|
import WebGPUTexturePassUtils from './WebGPUTexturePassUtils.js';
|
|
6
7
|
|
|
@@ -9,15 +10,17 @@ import {
|
|
|
9
10
|
NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter,
|
|
10
11
|
RepeatWrapping, MirroredRepeatWrapping,
|
|
11
12
|
RGB_ETC2_Format, RGBA_ETC2_EAC_Format,
|
|
12
|
-
RGBAFormat, RGBFormat, RedFormat, RGFormat, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, UnsignedByteType, FloatType, HalfFloatType,
|
|
13
|
+
RGBAFormat, RGBFormat, RedFormat, RGFormat, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, UnsignedByteType, FloatType, HalfFloatType, SRGBTransfer, DepthFormat, DepthStencilFormat,
|
|
13
14
|
RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format,
|
|
14
15
|
RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, UnsignedIntType, UnsignedShortType, UnsignedInt248Type, UnsignedInt5999Type,
|
|
15
16
|
NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, IntType, RedIntegerFormat, RGIntegerFormat, RGBAIntegerFormat,
|
|
16
|
-
|
|
17
|
+
UnsignedInt101111Type, RGBA_BPTC_Format, RGB_ETC1_Format, RGB_S3TC_DXT1_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format,
|
|
18
|
+
R11_EAC_Format, SIGNED_R11_EAC_Format, RG11_EAC_Format, SIGNED_RG11_EAC_Format,
|
|
19
|
+
Compatibility
|
|
17
20
|
} from '../../../constants.js';
|
|
18
21
|
import { CubeTexture } from '../../../textures/CubeTexture.js';
|
|
19
|
-
import { DepthTexture } from '../../../textures/DepthTexture.js';
|
|
20
22
|
import { Texture } from '../../../textures/Texture.js';
|
|
23
|
+
import { warn, error } from '../../../utils.js';
|
|
21
24
|
|
|
22
25
|
const _compareToWebGPU = {
|
|
23
26
|
[ NeverCompare ]: 'never',
|
|
@@ -32,52 +35,165 @@ const _compareToWebGPU = {
|
|
|
32
35
|
|
|
33
36
|
const _flipMap = [ 0, 1, 3, 2, 4, 5 ];
|
|
34
37
|
|
|
38
|
+
/**
|
|
39
|
+
* A WebGPU backend utility module for managing textures.
|
|
40
|
+
*
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
35
43
|
class WebGPUTextureUtils {
|
|
36
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Constructs a new utility object.
|
|
47
|
+
*
|
|
48
|
+
* @param {WebGPUBackend} backend - The WebGPU backend.
|
|
49
|
+
*/
|
|
37
50
|
constructor( backend ) {
|
|
38
51
|
|
|
52
|
+
/**
|
|
53
|
+
* A reference to the WebGPU backend.
|
|
54
|
+
*
|
|
55
|
+
* @type {WebGPUBackend}
|
|
56
|
+
*/
|
|
39
57
|
this.backend = backend;
|
|
40
58
|
|
|
59
|
+
/**
|
|
60
|
+
* A reference to the pass utils.
|
|
61
|
+
*
|
|
62
|
+
* @type {?WebGPUTexturePassUtils}
|
|
63
|
+
* @default null
|
|
64
|
+
*/
|
|
41
65
|
this._passUtils = null;
|
|
42
66
|
|
|
67
|
+
/**
|
|
68
|
+
* A dictionary for managing default textures. The key
|
|
69
|
+
* is the texture format, the value the texture object.
|
|
70
|
+
*
|
|
71
|
+
* @type {Object<string,Texture>}
|
|
72
|
+
*/
|
|
43
73
|
this.defaultTexture = {};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A dictionary for managing default cube textures. The key
|
|
77
|
+
* is the texture format, the value the texture object.
|
|
78
|
+
*
|
|
79
|
+
* @type {Object<string,CubeTexture>}
|
|
80
|
+
*/
|
|
44
81
|
this.defaultCubeTexture = {};
|
|
45
|
-
this.defaultVideoFrame = null;
|
|
46
82
|
|
|
47
|
-
|
|
83
|
+
/**
|
|
84
|
+
* A default video frame.
|
|
85
|
+
*
|
|
86
|
+
* @type {?VideoFrame}
|
|
87
|
+
* @default null
|
|
88
|
+
*/
|
|
89
|
+
this.defaultVideoFrame = null;
|
|
48
90
|
|
|
49
|
-
|
|
50
|
-
|
|
91
|
+
/**
|
|
92
|
+
* A cache of shared texture samplers.
|
|
93
|
+
*
|
|
94
|
+
* @type {Map<string, Object>}
|
|
95
|
+
*/
|
|
96
|
+
this._samplerCache = new Map();
|
|
51
97
|
|
|
52
98
|
}
|
|
53
99
|
|
|
54
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Creates a GPU sampler for the given texture.
|
|
102
|
+
*
|
|
103
|
+
* @param {Texture} texture - The texture to create the sampler for.
|
|
104
|
+
* @return {string} The current sampler key.
|
|
105
|
+
*/
|
|
106
|
+
updateSampler( texture ) {
|
|
55
107
|
|
|
56
108
|
const backend = this.backend;
|
|
57
|
-
const device = backend.device;
|
|
58
|
-
|
|
59
|
-
const textureGPU = backend.get( texture );
|
|
60
|
-
|
|
61
|
-
const samplerDescriptorGPU = {
|
|
62
|
-
addressModeU: this._convertAddressMode( texture.wrapS ),
|
|
63
|
-
addressModeV: this._convertAddressMode( texture.wrapT ),
|
|
64
|
-
addressModeW: this._convertAddressMode( texture.wrapR ),
|
|
65
|
-
magFilter: this._convertFilterMode( texture.magFilter ),
|
|
66
|
-
minFilter: this._convertFilterMode( texture.minFilter ),
|
|
67
|
-
mipmapFilter: this._convertFilterMode( texture.minFilter ),
|
|
68
|
-
maxAnisotropy: texture.anisotropy
|
|
69
|
-
};
|
|
70
109
|
|
|
71
|
-
|
|
110
|
+
const samplerKey = texture.minFilter + '-' + texture.magFilter + '-' +
|
|
111
|
+
texture.wrapS + '-' + texture.wrapT + '-' + ( texture.wrapR || '0' ) + '-' +
|
|
112
|
+
texture.anisotropy + '-' + ( texture.compareFunction || 0 );
|
|
113
|
+
|
|
114
|
+
let samplerData = this._samplerCache.get( samplerKey );
|
|
115
|
+
|
|
116
|
+
if ( samplerData === undefined ) {
|
|
117
|
+
|
|
118
|
+
const samplerDescriptorGPU = {
|
|
119
|
+
addressModeU: this._convertAddressMode( texture.wrapS ),
|
|
120
|
+
addressModeV: this._convertAddressMode( texture.wrapT ),
|
|
121
|
+
addressModeW: this._convertAddressMode( texture.wrapR ),
|
|
122
|
+
magFilter: this._convertFilterMode( texture.magFilter ),
|
|
123
|
+
minFilter: this._convertFilterMode( texture.minFilter ),
|
|
124
|
+
mipmapFilter: this._convertFilterMode( texture.minFilter ),
|
|
125
|
+
maxAnisotropy: 1
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// Depth textures without compare function must use non-filtering (nearest) sampling
|
|
129
|
+
if ( texture.isDepthTexture && texture.compareFunction === null ) {
|
|
130
|
+
|
|
131
|
+
samplerDescriptorGPU.magFilter = GPUFilterMode.Nearest;
|
|
132
|
+
samplerDescriptorGPU.minFilter = GPUFilterMode.Nearest;
|
|
133
|
+
samplerDescriptorGPU.mipmapFilter = GPUFilterMode.Nearest;
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// anisotropy can only be used when all filter modes are set to linear.
|
|
138
|
+
|
|
139
|
+
if ( samplerDescriptorGPU.magFilter === GPUFilterMode.Linear && samplerDescriptorGPU.minFilter === GPUFilterMode.Linear && samplerDescriptorGPU.mipmapFilter === GPUFilterMode.Linear ) {
|
|
140
|
+
|
|
141
|
+
samplerDescriptorGPU.maxAnisotropy = texture.anisotropy;
|
|
142
|
+
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if ( texture.isDepthTexture && texture.compareFunction !== null && backend.hasCompatibility( Compatibility.TEXTURE_COMPARE ) ) {
|
|
146
|
+
|
|
147
|
+
samplerDescriptorGPU.compare = _compareToWebGPU[ texture.compareFunction ];
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const sampler = backend.device.createSampler( samplerDescriptorGPU );
|
|
152
|
+
|
|
153
|
+
samplerData = { sampler, usedTimes: 0 };
|
|
72
154
|
|
|
73
|
-
|
|
155
|
+
this._samplerCache.set( samplerKey, samplerData );
|
|
74
156
|
|
|
75
157
|
}
|
|
76
158
|
|
|
77
|
-
|
|
159
|
+
const textureData = backend.get( texture );
|
|
160
|
+
|
|
161
|
+
if ( textureData.sampler !== samplerData.sampler ) {
|
|
162
|
+
|
|
163
|
+
// check if previous sampler is unused so it can be deleted
|
|
164
|
+
|
|
165
|
+
if ( textureData.sampler !== undefined ) {
|
|
166
|
+
|
|
167
|
+
const oldSamplerData = this._samplerCache.get( textureData.samplerKey );
|
|
168
|
+
oldSamplerData.usedTimes --;
|
|
169
|
+
|
|
170
|
+
if ( oldSamplerData.usedTimes === 0 ) {
|
|
171
|
+
|
|
172
|
+
this._samplerCache.delete( textureData.samplerKey );
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// update to new sampler data
|
|
179
|
+
|
|
180
|
+
textureData.samplerKey = samplerKey;
|
|
181
|
+
textureData.sampler = samplerData.sampler;
|
|
182
|
+
|
|
183
|
+
samplerData.usedTimes ++;
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return samplerKey;
|
|
78
188
|
|
|
79
189
|
}
|
|
80
190
|
|
|
191
|
+
/**
|
|
192
|
+
* Creates a default texture for the given texture that can be used
|
|
193
|
+
* as a placeholder until the actual texture is ready for usage.
|
|
194
|
+
*
|
|
195
|
+
* @param {Texture} texture - The texture to create a default texture for.
|
|
196
|
+
*/
|
|
81
197
|
createDefaultTexture( texture ) {
|
|
82
198
|
|
|
83
199
|
let textureGPU;
|
|
@@ -88,10 +204,6 @@ class WebGPUTextureUtils {
|
|
|
88
204
|
|
|
89
205
|
textureGPU = this._getDefaultCubeTextureGPU( format );
|
|
90
206
|
|
|
91
|
-
} else if ( texture.isVideoTexture ) {
|
|
92
|
-
|
|
93
|
-
this.backend.get( texture ).externalTexture = this._getDefaultVideoFrame();
|
|
94
|
-
|
|
95
207
|
} else {
|
|
96
208
|
|
|
97
209
|
textureGPU = this._getDefaultTextureGPU( format );
|
|
@@ -102,6 +214,12 @@ class WebGPUTextureUtils {
|
|
|
102
214
|
|
|
103
215
|
}
|
|
104
216
|
|
|
217
|
+
/**
|
|
218
|
+
* Defines a texture on the GPU for the given texture object.
|
|
219
|
+
*
|
|
220
|
+
* @param {Texture} texture - The texture.
|
|
221
|
+
* @param {Object} [options={}] - Optional configuration parameter.
|
|
222
|
+
*/
|
|
105
223
|
createTexture( texture, options = {} ) {
|
|
106
224
|
|
|
107
225
|
const backend = this.backend;
|
|
@@ -113,22 +231,41 @@ class WebGPUTextureUtils {
|
|
|
113
231
|
|
|
114
232
|
}
|
|
115
233
|
|
|
234
|
+
if ( texture.isExternalTexture ) {
|
|
235
|
+
|
|
236
|
+
textureData.texture = texture.sourceTexture;
|
|
237
|
+
textureData.initialized = true;
|
|
238
|
+
|
|
239
|
+
return;
|
|
240
|
+
|
|
241
|
+
}
|
|
242
|
+
|
|
116
243
|
if ( options.needsMipmaps === undefined ) options.needsMipmaps = false;
|
|
117
244
|
if ( options.levels === undefined ) options.levels = 1;
|
|
118
245
|
if ( options.depth === undefined ) options.depth = 1;
|
|
119
246
|
|
|
120
247
|
const { width, height, depth, levels } = options;
|
|
121
248
|
|
|
249
|
+
if ( texture.isFramebufferTexture ) {
|
|
250
|
+
|
|
251
|
+
if ( options.renderTarget ) {
|
|
252
|
+
|
|
253
|
+
options.format = this.backend.utils.getCurrentColorFormat( options.renderTarget );
|
|
254
|
+
|
|
255
|
+
} else {
|
|
256
|
+
|
|
257
|
+
options.format = this.backend.utils.getPreferredCanvasFormat();
|
|
258
|
+
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
}
|
|
262
|
+
|
|
122
263
|
const dimension = this._getDimension( texture );
|
|
123
264
|
const format = texture.internalFormat || options.format || getFormat( texture, backend.device );
|
|
124
265
|
|
|
125
266
|
textureData.format = format;
|
|
126
267
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
sampleCount = backend.utils.getSampleCount( sampleCount );
|
|
130
|
-
|
|
131
|
-
const primarySampleCount = texture.isRenderTargetTexture && ! texture.isMultisampleRenderTargetTexture ? 1 : sampleCount;
|
|
268
|
+
const { samples, primarySamples, isMSAA } = backend.utils.getTextureSampleData( texture );
|
|
132
269
|
|
|
133
270
|
let usage = GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC;
|
|
134
271
|
|
|
@@ -138,7 +275,7 @@ class WebGPUTextureUtils {
|
|
|
138
275
|
|
|
139
276
|
}
|
|
140
277
|
|
|
141
|
-
if ( texture.isCompressedTexture !== true && texture.isCompressedArrayTexture !== true ) {
|
|
278
|
+
if ( texture.isCompressedTexture !== true && texture.isCompressedArrayTexture !== true && format !== GPUTextureFormat.RGB9E5UFloat ) {
|
|
142
279
|
|
|
143
280
|
usage |= GPUTextureUsage.RENDER_ATTACHMENT;
|
|
144
281
|
|
|
@@ -152,7 +289,7 @@ class WebGPUTextureUtils {
|
|
|
152
289
|
depthOrArrayLayers: depth,
|
|
153
290
|
},
|
|
154
291
|
mipLevelCount: levels,
|
|
155
|
-
sampleCount:
|
|
292
|
+
sampleCount: primarySamples,
|
|
156
293
|
dimension: dimension,
|
|
157
294
|
format: format,
|
|
158
295
|
usage: usage
|
|
@@ -160,38 +297,40 @@ class WebGPUTextureUtils {
|
|
|
160
297
|
|
|
161
298
|
// texture creation
|
|
162
299
|
|
|
163
|
-
if (
|
|
300
|
+
if ( format === undefined ) {
|
|
164
301
|
|
|
165
|
-
|
|
166
|
-
const videoFrame = new VideoFrame( video );
|
|
302
|
+
warn( 'WebGPURenderer: Texture format not supported.' );
|
|
167
303
|
|
|
168
|
-
|
|
169
|
-
|
|
304
|
+
this.createDefaultTexture( texture );
|
|
305
|
+
return;
|
|
170
306
|
|
|
171
|
-
|
|
307
|
+
}
|
|
172
308
|
|
|
173
|
-
|
|
309
|
+
if ( texture.isCubeTexture ) {
|
|
174
310
|
|
|
175
|
-
|
|
311
|
+
textureDescriptorGPU.textureBindingViewDimension = GPUTextureViewDimension.Cube;
|
|
176
312
|
|
|
177
|
-
|
|
313
|
+
}
|
|
178
314
|
|
|
179
|
-
|
|
315
|
+
try {
|
|
180
316
|
|
|
181
|
-
|
|
317
|
+
textureData.texture = backend.device.createTexture( textureDescriptorGPU );
|
|
182
318
|
|
|
183
|
-
|
|
319
|
+
} catch ( e ) {
|
|
184
320
|
|
|
185
|
-
|
|
321
|
+
warn( 'WebGPURenderer: Failed to create texture with descriptor:', textureDescriptorGPU );
|
|
322
|
+
this.createDefaultTexture( texture );
|
|
323
|
+
return;
|
|
186
324
|
|
|
187
325
|
}
|
|
188
326
|
|
|
189
|
-
if (
|
|
327
|
+
if ( isMSAA ) {
|
|
190
328
|
|
|
191
329
|
const msaaTextureDescriptorGPU = Object.assign( {}, textureDescriptorGPU );
|
|
192
330
|
|
|
193
331
|
msaaTextureDescriptorGPU.label = msaaTextureDescriptorGPU.label + '-msaa';
|
|
194
|
-
msaaTextureDescriptorGPU.sampleCount =
|
|
332
|
+
msaaTextureDescriptorGPU.sampleCount = samples;
|
|
333
|
+
msaaTextureDescriptorGPU.mipLevelCount = 1; // See https://www.w3.org/TR/webgpu/#texture-creation
|
|
195
334
|
|
|
196
335
|
textureData.msaaTexture = backend.device.createTexture( msaaTextureDescriptorGPU );
|
|
197
336
|
|
|
@@ -203,12 +342,18 @@ class WebGPUTextureUtils {
|
|
|
203
342
|
|
|
204
343
|
}
|
|
205
344
|
|
|
206
|
-
|
|
345
|
+
/**
|
|
346
|
+
* Destroys the GPU data for the given texture object.
|
|
347
|
+
*
|
|
348
|
+
* @param {Texture} texture - The texture.
|
|
349
|
+
* @param {boolean} [isDefaultTexture=false] - Whether the texture uses a default GPU texture or not.
|
|
350
|
+
*/
|
|
351
|
+
destroyTexture( texture, isDefaultTexture = false ) {
|
|
207
352
|
|
|
208
353
|
const backend = this.backend;
|
|
209
354
|
const textureData = backend.get( texture );
|
|
210
355
|
|
|
211
|
-
textureData.texture.destroy();
|
|
356
|
+
if ( textureData.texture !== undefined && isDefaultTexture === false ) textureData.texture.destroy();
|
|
212
357
|
|
|
213
358
|
if ( textureData.msaaTexture !== undefined ) textureData.msaaTexture.destroy();
|
|
214
359
|
|
|
@@ -216,70 +361,101 @@ class WebGPUTextureUtils {
|
|
|
216
361
|
|
|
217
362
|
}
|
|
218
363
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
generateMipmaps( texture ) {
|
|
364
|
+
/**
|
|
365
|
+
* Generates mipmaps for the given texture.
|
|
366
|
+
*
|
|
367
|
+
* @param {Texture} texture - The texture.
|
|
368
|
+
* @param {?GPUCommandEncoder} [encoder=null] - An optional command encoder used to generate mipmaps.
|
|
369
|
+
*/
|
|
370
|
+
generateMipmaps( texture, encoder = null ) {
|
|
229
371
|
|
|
230
372
|
const textureData = this.backend.get( texture );
|
|
231
373
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
for ( let i = 0; i < 6; i ++ ) {
|
|
235
|
-
|
|
236
|
-
this._generateMipmaps( textureData.texture, textureData.textureDescriptorGPU, i );
|
|
374
|
+
this._generateMipmaps( textureData.texture, encoder );
|
|
237
375
|
|
|
238
|
-
|
|
376
|
+
}
|
|
239
377
|
|
|
240
|
-
|
|
378
|
+
/**
|
|
379
|
+
* Returns the color buffer representing the color
|
|
380
|
+
* attachment of the default framebuffer.
|
|
381
|
+
*
|
|
382
|
+
* @return {GPUTexture} The color buffer.
|
|
383
|
+
*/
|
|
384
|
+
getColorBuffer() {
|
|
241
385
|
|
|
242
|
-
|
|
386
|
+
const backend = this.backend;
|
|
387
|
+
const canvasTarget = backend.renderer.getCanvasTarget();
|
|
388
|
+
const { width, height } = backend.getDrawingBufferSize();
|
|
389
|
+
const samples = backend.renderer.currentSamples;
|
|
243
390
|
|
|
244
|
-
|
|
391
|
+
const colorTexture = canvasTarget.colorTexture;
|
|
392
|
+
const colorTextureData = backend.get( colorTexture );
|
|
245
393
|
|
|
246
|
-
|
|
394
|
+
if ( colorTexture.width === width && colorTexture.height === height && colorTexture.samples === samples ) {
|
|
247
395
|
|
|
248
|
-
|
|
396
|
+
return colorTextureData.texture;
|
|
249
397
|
|
|
250
398
|
}
|
|
251
399
|
|
|
252
|
-
|
|
400
|
+
// recreate
|
|
253
401
|
|
|
254
|
-
|
|
402
|
+
let colorBuffer = colorTextureData.texture;
|
|
255
403
|
|
|
256
|
-
if (
|
|
257
|
-
|
|
258
|
-
const backend = this.backend;
|
|
259
|
-
const { width, height } = backend.getDrawingBufferSize();
|
|
404
|
+
if ( colorBuffer ) colorBuffer.destroy();
|
|
260
405
|
|
|
261
|
-
|
|
406
|
+
colorBuffer = backend.device.createTexture( {
|
|
262
407
|
label: 'colorBuffer',
|
|
263
408
|
size: {
|
|
264
409
|
width: width,
|
|
265
410
|
height: height,
|
|
266
411
|
depthOrArrayLayers: 1
|
|
267
412
|
},
|
|
268
|
-
sampleCount: backend.utils.getSampleCount( backend.renderer.
|
|
413
|
+
sampleCount: backend.utils.getSampleCount( backend.renderer.currentSamples ),
|
|
269
414
|
format: backend.utils.getPreferredCanvasFormat(),
|
|
270
415
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC
|
|
271
416
|
} );
|
|
272
417
|
|
|
273
|
-
|
|
418
|
+
//
|
|
419
|
+
|
|
420
|
+
colorTexture.source.width = width;
|
|
421
|
+
colorTexture.source.height = height;
|
|
422
|
+
colorTexture.samples = samples;
|
|
423
|
+
|
|
424
|
+
colorTextureData.texture = colorBuffer;
|
|
425
|
+
|
|
426
|
+
return colorBuffer;
|
|
274
427
|
|
|
275
428
|
}
|
|
276
429
|
|
|
430
|
+
/**
|
|
431
|
+
* Returns the depth buffer representing the depth
|
|
432
|
+
* attachment of the default framebuffer.
|
|
433
|
+
*
|
|
434
|
+
* @param {boolean} [depth=true] - Whether depth is enabled or not.
|
|
435
|
+
* @param {boolean} [stencil=false] - Whether stencil is enabled or not.
|
|
436
|
+
* @return {GPUTexture} The depth buffer.
|
|
437
|
+
*/
|
|
277
438
|
getDepthBuffer( depth = true, stencil = false ) {
|
|
278
439
|
|
|
279
440
|
const backend = this.backend;
|
|
441
|
+
const canvasTarget = backend.renderer.getCanvasTarget();
|
|
280
442
|
const { width, height } = backend.getDrawingBufferSize();
|
|
443
|
+
const samples = backend.renderer.currentSamples;
|
|
444
|
+
|
|
445
|
+
const depthTexture = canvasTarget.depthTexture;
|
|
446
|
+
|
|
447
|
+
if ( depthTexture.width === width &&
|
|
448
|
+
depthTexture.height === height &&
|
|
449
|
+
depthTexture.samples === samples &&
|
|
450
|
+
depthTexture.depth === depth &&
|
|
451
|
+
depthTexture.stencil === stencil ) {
|
|
452
|
+
|
|
453
|
+
return backend.get( depthTexture ).texture;
|
|
454
|
+
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
//
|
|
281
458
|
|
|
282
|
-
const depthTexture = this.depthTexture;
|
|
283
459
|
const depthTextureGPU = backend.get( depthTexture ).texture;
|
|
284
460
|
|
|
285
461
|
let format, type;
|
|
@@ -298,7 +474,7 @@ class WebGPUTextureUtils {
|
|
|
298
474
|
|
|
299
475
|
if ( depthTextureGPU !== undefined ) {
|
|
300
476
|
|
|
301
|
-
if ( depthTexture.image.width === width && depthTexture.image.height === height && depthTexture.format === format && depthTexture.type === type ) {
|
|
477
|
+
if ( depthTexture.image.width === width && depthTexture.image.height === height && depthTexture.format === format && depthTexture.type === type && depthTexture.samples === samples ) {
|
|
302
478
|
|
|
303
479
|
return depthTextureGPU;
|
|
304
480
|
|
|
@@ -308,21 +484,31 @@ class WebGPUTextureUtils {
|
|
|
308
484
|
|
|
309
485
|
}
|
|
310
486
|
|
|
487
|
+
// recreate
|
|
488
|
+
|
|
311
489
|
depthTexture.name = 'depthBuffer';
|
|
312
490
|
depthTexture.format = format;
|
|
313
491
|
depthTexture.type = type;
|
|
314
492
|
depthTexture.image.width = width;
|
|
315
493
|
depthTexture.image.height = height;
|
|
494
|
+
depthTexture.samples = samples;
|
|
316
495
|
|
|
317
|
-
this.createTexture( depthTexture, {
|
|
496
|
+
this.createTexture( depthTexture, { width, height } );
|
|
318
497
|
|
|
319
498
|
return backend.get( depthTexture ).texture;
|
|
320
499
|
|
|
321
500
|
}
|
|
322
501
|
|
|
502
|
+
/**
|
|
503
|
+
* Uploads the updated texture data to the GPU.
|
|
504
|
+
*
|
|
505
|
+
* @param {Texture} texture - The texture.
|
|
506
|
+
* @param {Object} [options={}] - Optional configuration parameter.
|
|
507
|
+
*/
|
|
323
508
|
updateTexture( texture, options ) {
|
|
324
509
|
|
|
325
510
|
const textureData = this.backend.get( texture );
|
|
511
|
+
const mipmaps = texture.mipmaps;
|
|
326
512
|
|
|
327
513
|
const { textureDescriptorGPU } = textureData;
|
|
328
514
|
|
|
@@ -333,9 +519,24 @@ class WebGPUTextureUtils {
|
|
|
333
519
|
|
|
334
520
|
if ( texture.isDataTexture ) {
|
|
335
521
|
|
|
336
|
-
|
|
522
|
+
if ( mipmaps.length > 0 ) {
|
|
523
|
+
|
|
524
|
+
for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
|
|
525
|
+
|
|
526
|
+
const mipmap = mipmaps[ i ];
|
|
527
|
+
|
|
528
|
+
this._copyBufferToTexture( mipmap, textureData.texture, textureDescriptorGPU, 0, texture.flipY, 0, i );
|
|
529
|
+
|
|
530
|
+
}
|
|
337
531
|
|
|
338
|
-
|
|
532
|
+
|
|
533
|
+
} else {
|
|
534
|
+
|
|
535
|
+
this._copyBufferToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, texture.flipY );
|
|
536
|
+
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
} else if ( texture.isArrayTexture || texture.isDataArrayTexture || texture.isData3DTexture ) {
|
|
339
540
|
|
|
340
541
|
for ( let i = 0; i < options.image.depth; i ++ ) {
|
|
341
542
|
|
|
@@ -349,17 +550,26 @@ class WebGPUTextureUtils {
|
|
|
349
550
|
|
|
350
551
|
} else if ( texture.isCubeTexture ) {
|
|
351
552
|
|
|
352
|
-
this._copyCubeMapToTexture(
|
|
553
|
+
this._copyCubeMapToTexture( texture, textureData.texture, textureDescriptorGPU );
|
|
353
554
|
|
|
354
|
-
} else
|
|
555
|
+
} else {
|
|
355
556
|
|
|
356
|
-
|
|
557
|
+
if ( mipmaps.length > 0 ) {
|
|
357
558
|
|
|
358
|
-
|
|
559
|
+
for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
|
|
359
560
|
|
|
360
|
-
|
|
561
|
+
const mipmap = mipmaps[ i ];
|
|
562
|
+
|
|
563
|
+
this._copyImageToTexture( mipmap, textureData.texture, textureDescriptorGPU, 0, texture.flipY, texture.premultiplyAlpha, i );
|
|
564
|
+
|
|
565
|
+
}
|
|
361
566
|
|
|
362
|
-
|
|
567
|
+
|
|
568
|
+
} else {
|
|
569
|
+
|
|
570
|
+
this._copyImageToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, texture.flipY, texture.premultiplyAlpha );
|
|
571
|
+
|
|
572
|
+
}
|
|
363
573
|
|
|
364
574
|
}
|
|
365
575
|
|
|
@@ -367,10 +577,20 @@ class WebGPUTextureUtils {
|
|
|
367
577
|
|
|
368
578
|
textureData.version = texture.version;
|
|
369
579
|
|
|
370
|
-
if ( texture.onUpdate ) texture.onUpdate( texture );
|
|
371
|
-
|
|
372
580
|
}
|
|
373
581
|
|
|
582
|
+
/**
|
|
583
|
+
* Returns texture data as a typed array.
|
|
584
|
+
*
|
|
585
|
+
* @async
|
|
586
|
+
* @param {Texture} texture - The texture to copy.
|
|
587
|
+
* @param {number} x - The x coordinate of the copy origin.
|
|
588
|
+
* @param {number} y - The y coordinate of the copy origin.
|
|
589
|
+
* @param {number} width - The width of the copy.
|
|
590
|
+
* @param {number} height - The height of the copy.
|
|
591
|
+
* @param {number} faceIndex - The face index.
|
|
592
|
+
* @return {Promise<TypedArray>} A Promise that resolves with a typed array when the copy operation has finished.
|
|
593
|
+
*/
|
|
374
594
|
async copyTextureToBuffer( texture, x, y, width, height, faceIndex ) {
|
|
375
595
|
|
|
376
596
|
const device = this.backend.device;
|
|
@@ -385,7 +605,7 @@ class WebGPUTextureUtils {
|
|
|
385
605
|
|
|
386
606
|
const readBuffer = device.createBuffer(
|
|
387
607
|
{
|
|
388
|
-
size:
|
|
608
|
+
size: ( ( height - 1 ) * bytesPerRow ) + ( width * bytesPerTexel ), // see https://github.com/mrdoob/three.js/issues/31658#issuecomment-3229442010
|
|
389
609
|
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ
|
|
390
610
|
}
|
|
391
611
|
);
|
|
@@ -420,14 +640,22 @@ class WebGPUTextureUtils {
|
|
|
420
640
|
|
|
421
641
|
}
|
|
422
642
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
643
|
+
/**
|
|
644
|
+
* Frees all internal resources.
|
|
645
|
+
*/
|
|
646
|
+
dispose() {
|
|
426
647
|
|
|
427
|
-
|
|
648
|
+
this._samplerCache.clear();
|
|
428
649
|
|
|
429
650
|
}
|
|
430
651
|
|
|
652
|
+
/**
|
|
653
|
+
* Returns the default GPU texture for the given format.
|
|
654
|
+
*
|
|
655
|
+
* @private
|
|
656
|
+
* @param {string} format - The GPU format.
|
|
657
|
+
* @return {GPUTexture} The GPU texture.
|
|
658
|
+
*/
|
|
431
659
|
_getDefaultTextureGPU( format ) {
|
|
432
660
|
|
|
433
661
|
let defaultTexture = this.defaultTexture[ format ];
|
|
@@ -448,9 +676,16 @@ class WebGPUTextureUtils {
|
|
|
448
676
|
|
|
449
677
|
}
|
|
450
678
|
|
|
679
|
+
/**
|
|
680
|
+
* Returns the default GPU cube texture for the given format.
|
|
681
|
+
*
|
|
682
|
+
* @private
|
|
683
|
+
* @param {string} format - The GPU format.
|
|
684
|
+
* @return {GPUTexture} The GPU texture.
|
|
685
|
+
*/
|
|
451
686
|
_getDefaultCubeTextureGPU( format ) {
|
|
452
687
|
|
|
453
|
-
let defaultCubeTexture = this.
|
|
688
|
+
let defaultCubeTexture = this.defaultCubeTexture[ format ];
|
|
454
689
|
|
|
455
690
|
if ( defaultCubeTexture === undefined ) {
|
|
456
691
|
|
|
@@ -468,42 +703,50 @@ class WebGPUTextureUtils {
|
|
|
468
703
|
|
|
469
704
|
}
|
|
470
705
|
|
|
471
|
-
|
|
706
|
+
/**
|
|
707
|
+
* Uploads cube texture image data to the GPU memory.
|
|
708
|
+
*
|
|
709
|
+
* @private
|
|
710
|
+
* @param {CubeTexture} texture - The cube texture.
|
|
711
|
+
* @param {GPUTexture} textureGPU - The GPU texture.
|
|
712
|
+
* @param {Object} textureDescriptorGPU - The GPU texture descriptor.
|
|
713
|
+
*/
|
|
714
|
+
_copyCubeMapToTexture( texture, textureGPU, textureDescriptorGPU ) {
|
|
472
715
|
|
|
473
|
-
|
|
716
|
+
const images = texture.images;
|
|
717
|
+
const mipmaps = texture.mipmaps;
|
|
474
718
|
|
|
475
|
-
|
|
719
|
+
for ( let i = 0; i < 6; i ++ ) {
|
|
476
720
|
|
|
477
|
-
const
|
|
478
|
-
timestamp: 0,
|
|
479
|
-
codedWidth: 1,
|
|
480
|
-
codedHeight: 1,
|
|
481
|
-
format: 'RGBA',
|
|
482
|
-
};
|
|
721
|
+
const image = images[ i ];
|
|
483
722
|
|
|
484
|
-
|
|
723
|
+
const flipIndex = texture.flipY === true ? _flipMap[ i ] : i;
|
|
485
724
|
|
|
486
|
-
|
|
725
|
+
if ( image.isDataTexture ) {
|
|
487
726
|
|
|
488
|
-
|
|
727
|
+
this._copyBufferToTexture( image.image, textureGPU, textureDescriptorGPU, flipIndex, texture.flipY );
|
|
489
728
|
|
|
490
|
-
|
|
729
|
+
} else {
|
|
491
730
|
|
|
492
|
-
|
|
731
|
+
this._copyImageToTexture( image, textureGPU, textureDescriptorGPU, flipIndex, texture.flipY, texture.premultiplyAlpha );
|
|
493
732
|
|
|
494
|
-
|
|
733
|
+
}
|
|
495
734
|
|
|
496
|
-
|
|
735
|
+
for ( let j = 0; j < mipmaps.length; j ++ ) {
|
|
497
736
|
|
|
498
|
-
|
|
737
|
+
const mipmap = mipmaps[ j ];
|
|
738
|
+
const image = mipmap.images[ i ];
|
|
499
739
|
|
|
500
|
-
|
|
740
|
+
if ( image.isDataTexture ) {
|
|
501
741
|
|
|
502
|
-
|
|
742
|
+
this._copyBufferToTexture( image.image, textureGPU, textureDescriptorGPU, flipIndex, texture.flipY, 0, j + 1 );
|
|
503
743
|
|
|
504
|
-
|
|
744
|
+
} else {
|
|
745
|
+
|
|
746
|
+
this._copyImageToTexture( image, textureGPU, textureDescriptorGPU, flipIndex, texture.flipY, texture.premultiplyAlpha, j + 1 );
|
|
747
|
+
|
|
748
|
+
}
|
|
505
749
|
|
|
506
|
-
this._copyImageToTexture( image, textureGPU, textureDescriptorGPU, flipIndex, flipY );
|
|
507
750
|
|
|
508
751
|
}
|
|
509
752
|
|
|
@@ -511,32 +754,55 @@ class WebGPUTextureUtils {
|
|
|
511
754
|
|
|
512
755
|
}
|
|
513
756
|
|
|
514
|
-
|
|
757
|
+
/**
|
|
758
|
+
* Uploads texture image data to the GPU memory.
|
|
759
|
+
*
|
|
760
|
+
* @private
|
|
761
|
+
* @param {HTMLImageElement|ImageBitmap|HTMLCanvasElement} image - The image data.
|
|
762
|
+
* @param {GPUTexture} textureGPU - The GPU texture.
|
|
763
|
+
* @param {Object} textureDescriptorGPU - The GPU texture descriptor.
|
|
764
|
+
* @param {number} originDepth - The origin depth.
|
|
765
|
+
* @param {boolean} flipY - Whether to flip texture data along their vertical axis or not.
|
|
766
|
+
* @param {boolean} premultiplyAlpha - Whether the texture should have its RGB channels premultiplied by the alpha channel or not.
|
|
767
|
+
* @param {number} [mipLevel=0] - The mip level where the data should be copied to.
|
|
768
|
+
*/
|
|
769
|
+
_copyImageToTexture( image, textureGPU, textureDescriptorGPU, originDepth, flipY, premultiplyAlpha, mipLevel = 0 ) {
|
|
515
770
|
|
|
516
771
|
const device = this.backend.device;
|
|
517
772
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
773
|
+
const width = ( mipLevel > 0 ) ? image.width : textureDescriptorGPU.size.width;
|
|
774
|
+
const height = ( mipLevel > 0 ) ? image.height : textureDescriptorGPU.size.height;
|
|
775
|
+
|
|
776
|
+
try {
|
|
777
|
+
|
|
778
|
+
device.queue.copyExternalImageToTexture(
|
|
779
|
+
{
|
|
780
|
+
source: image,
|
|
781
|
+
flipY: flipY
|
|
782
|
+
}, {
|
|
783
|
+
texture: textureGPU,
|
|
784
|
+
mipLevel: mipLevel,
|
|
785
|
+
origin: { x: 0, y: 0, z: originDepth },
|
|
786
|
+
premultipliedAlpha: premultiplyAlpha
|
|
787
|
+
}, {
|
|
788
|
+
width: width,
|
|
789
|
+
height: height,
|
|
790
|
+
depthOrArrayLayers: 1
|
|
791
|
+
}
|
|
792
|
+
);
|
|
531
793
|
|
|
532
|
-
|
|
794
|
+
// try/catch has been added to fix bad video frame data on certain devices, see #32391
|
|
533
795
|
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
}
|
|
796
|
+
} catch ( _ ) {}
|
|
537
797
|
|
|
538
798
|
}
|
|
539
799
|
|
|
800
|
+
/**
|
|
801
|
+
* Returns the pass utils singleton.
|
|
802
|
+
*
|
|
803
|
+
* @private
|
|
804
|
+
* @return {WebGPUTexturePassUtils} The utils instance.
|
|
805
|
+
*/
|
|
540
806
|
_getPassUtils() {
|
|
541
807
|
|
|
542
808
|
let passUtils = this._passUtils;
|
|
@@ -551,19 +817,46 @@ class WebGPUTextureUtils {
|
|
|
551
817
|
|
|
552
818
|
}
|
|
553
819
|
|
|
554
|
-
|
|
820
|
+
/**
|
|
821
|
+
* Generates mipmaps for the given GPU texture.
|
|
822
|
+
*
|
|
823
|
+
* @private
|
|
824
|
+
* @param {GPUTexture} textureGPU - The GPU texture object.
|
|
825
|
+
* @param {?GPUCommandEncoder} [encoder=null] - An optional command encoder used to generate mipmaps.
|
|
826
|
+
*/
|
|
827
|
+
_generateMipmaps( textureGPU, encoder = null ) {
|
|
555
828
|
|
|
556
|
-
this._getPassUtils().generateMipmaps( textureGPU,
|
|
829
|
+
this._getPassUtils().generateMipmaps( textureGPU, encoder );
|
|
557
830
|
|
|
558
831
|
}
|
|
559
832
|
|
|
833
|
+
/**
|
|
834
|
+
* Flip the contents of the given GPU texture along its vertical axis.
|
|
835
|
+
*
|
|
836
|
+
* @private
|
|
837
|
+
* @param {GPUTexture} textureGPU - The GPU texture object.
|
|
838
|
+
* @param {Object} textureDescriptorGPU - The texture descriptor.
|
|
839
|
+
* @param {number} [originDepth=0] - The origin depth.
|
|
840
|
+
*/
|
|
560
841
|
_flipY( textureGPU, textureDescriptorGPU, originDepth = 0 ) {
|
|
561
842
|
|
|
562
843
|
this._getPassUtils().flipY( textureGPU, textureDescriptorGPU, originDepth );
|
|
563
844
|
|
|
564
845
|
}
|
|
565
846
|
|
|
566
|
-
|
|
847
|
+
/**
|
|
848
|
+
* Uploads texture buffer data to the GPU memory.
|
|
849
|
+
*
|
|
850
|
+
* @private
|
|
851
|
+
* @param {Object} image - An object defining the image buffer data.
|
|
852
|
+
* @param {GPUTexture} textureGPU - The GPU texture.
|
|
853
|
+
* @param {Object} textureDescriptorGPU - The GPU texture descriptor.
|
|
854
|
+
* @param {number} originDepth - The origin depth.
|
|
855
|
+
* @param {boolean} flipY - Whether to flip texture data along their vertical axis or not.
|
|
856
|
+
* @param {number} [depth=0] - The depth offset when copying array or 3D texture data.
|
|
857
|
+
* @param {number} [mipLevel=0] - The mip level where the data should be copied to.
|
|
858
|
+
*/
|
|
859
|
+
_copyBufferToTexture( image, textureGPU, textureDescriptorGPU, originDepth, flipY, depth = 0, mipLevel = 0 ) {
|
|
567
860
|
|
|
568
861
|
// @TODO: Consider to use GPUCommandEncoder.copyBufferToTexture()
|
|
569
862
|
// @TODO: Consider to support valid buffer layouts with other formats like RGB
|
|
@@ -578,7 +871,7 @@ class WebGPUTextureUtils {
|
|
|
578
871
|
device.queue.writeTexture(
|
|
579
872
|
{
|
|
580
873
|
texture: textureGPU,
|
|
581
|
-
mipLevel:
|
|
874
|
+
mipLevel: mipLevel,
|
|
582
875
|
origin: { x: 0, y: 0, z: originDepth }
|
|
583
876
|
},
|
|
584
877
|
data,
|
|
@@ -600,6 +893,14 @@ class WebGPUTextureUtils {
|
|
|
600
893
|
|
|
601
894
|
}
|
|
602
895
|
|
|
896
|
+
/**
|
|
897
|
+
* Uploads compressed texture data to the GPU memory.
|
|
898
|
+
*
|
|
899
|
+
* @private
|
|
900
|
+
* @param {Array<Object>} mipmaps - An array with mipmap data.
|
|
901
|
+
* @param {GPUTexture} textureGPU - The GPU texture.
|
|
902
|
+
* @param {Object} textureDescriptorGPU - The GPU texture descriptor.
|
|
903
|
+
*/
|
|
603
904
|
_copyCompressedBufferToTexture( mipmaps, textureGPU, textureDescriptorGPU ) {
|
|
604
905
|
|
|
605
906
|
// @TODO: Consider to use GPUCommandEncoder.copyBufferToTexture()
|
|
@@ -607,7 +908,7 @@ class WebGPUTextureUtils {
|
|
|
607
908
|
const device = this.backend.device;
|
|
608
909
|
|
|
609
910
|
const blockData = this._getBlockData( textureDescriptorGPU.format );
|
|
610
|
-
const
|
|
911
|
+
const isArrayTexture = textureDescriptorGPU.size.depthOrArrayLayers > 1;
|
|
611
912
|
|
|
612
913
|
for ( let i = 0; i < mipmaps.length; i ++ ) {
|
|
613
914
|
|
|
@@ -615,7 +916,7 @@ class WebGPUTextureUtils {
|
|
|
615
916
|
|
|
616
917
|
const width = mipmap.width;
|
|
617
918
|
const height = mipmap.height;
|
|
618
|
-
const depth =
|
|
919
|
+
const depth = isArrayTexture ? textureDescriptorGPU.size.depthOrArrayLayers : 1;
|
|
619
920
|
|
|
620
921
|
const bytesPerRow = Math.ceil( width / blockData.width ) * blockData.byteLength;
|
|
621
922
|
const bytesPerImage = bytesPerRow * Math.ceil( height / blockData.height );
|
|
@@ -647,14 +948,20 @@ class WebGPUTextureUtils {
|
|
|
647
948
|
|
|
648
949
|
}
|
|
649
950
|
|
|
951
|
+
/**
|
|
952
|
+
* This method is only relevant for compressed texture formats. It returns a block
|
|
953
|
+
* data descriptor for the given GPU compressed texture format.
|
|
954
|
+
*
|
|
955
|
+
* @private
|
|
956
|
+
* @param {string} format - The GPU compressed texture format.
|
|
957
|
+
* @return {Object} The block data descriptor.
|
|
958
|
+
*/
|
|
650
959
|
_getBlockData( format ) {
|
|
651
960
|
|
|
652
|
-
// this method is only relevant for compressed texture formats
|
|
653
|
-
|
|
654
961
|
if ( format === GPUTextureFormat.BC1RGBAUnorm || format === GPUTextureFormat.BC1RGBAUnormSRGB ) return { byteLength: 8, width: 4, height: 4 }; // DXT1
|
|
655
962
|
if ( format === GPUTextureFormat.BC2RGBAUnorm || format === GPUTextureFormat.BC2RGBAUnormSRGB ) return { byteLength: 16, width: 4, height: 4 }; // DXT3
|
|
656
963
|
if ( format === GPUTextureFormat.BC3RGBAUnorm || format === GPUTextureFormat.BC3RGBAUnormSRGB ) return { byteLength: 16, width: 4, height: 4 }; // DXT5
|
|
657
|
-
if ( format === GPUTextureFormat.BC4RUnorm || format === GPUTextureFormat.
|
|
964
|
+
if ( format === GPUTextureFormat.BC4RUnorm || format === GPUTextureFormat.BC4RSnorm ) return { byteLength: 8, width: 4, height: 4 }; // RGTC1
|
|
658
965
|
if ( format === GPUTextureFormat.BC5RGUnorm || format === GPUTextureFormat.BC5RGSnorm ) return { byteLength: 16, width: 4, height: 4 }; // RGTC2
|
|
659
966
|
if ( format === GPUTextureFormat.BC6HRGBUFloat || format === GPUTextureFormat.BC6HRGBFloat ) return { byteLength: 16, width: 4, height: 4 }; // BPTC (float)
|
|
660
967
|
if ( format === GPUTextureFormat.BC7RGBAUnorm || format === GPUTextureFormat.BC7RGBAUnormSRGB ) return { byteLength: 16, width: 4, height: 4 }; // BPTC (unorm)
|
|
@@ -684,6 +991,13 @@ class WebGPUTextureUtils {
|
|
|
684
991
|
|
|
685
992
|
}
|
|
686
993
|
|
|
994
|
+
/**
|
|
995
|
+
* Converts the three.js uv wrapping constants to GPU address mode constants.
|
|
996
|
+
*
|
|
997
|
+
* @private
|
|
998
|
+
* @param {number} value - The three.js constant defining a uv wrapping mode.
|
|
999
|
+
* @return {string} The GPU address mode.
|
|
1000
|
+
*/
|
|
687
1001
|
_convertAddressMode( value ) {
|
|
688
1002
|
|
|
689
1003
|
let addressMode = GPUAddressMode.ClampToEdge;
|
|
@@ -702,6 +1016,13 @@ class WebGPUTextureUtils {
|
|
|
702
1016
|
|
|
703
1017
|
}
|
|
704
1018
|
|
|
1019
|
+
/**
|
|
1020
|
+
* Converts the three.js filter constants to GPU filter constants.
|
|
1021
|
+
*
|
|
1022
|
+
* @private
|
|
1023
|
+
* @param {number} value - The three.js constant defining a filter mode.
|
|
1024
|
+
* @return {string} The GPU filter mode.
|
|
1025
|
+
*/
|
|
705
1026
|
_convertFilterMode( value ) {
|
|
706
1027
|
|
|
707
1028
|
let filterMode = GPUFilterMode.Linear;
|
|
@@ -716,6 +1037,13 @@ class WebGPUTextureUtils {
|
|
|
716
1037
|
|
|
717
1038
|
}
|
|
718
1039
|
|
|
1040
|
+
/**
|
|
1041
|
+
* Returns the bytes-per-texel value for the given GPU texture format.
|
|
1042
|
+
*
|
|
1043
|
+
* @private
|
|
1044
|
+
* @param {string} format - The GPU texture format.
|
|
1045
|
+
* @return {number} The bytes-per-texel.
|
|
1046
|
+
*/
|
|
719
1047
|
_getBytesPerTexel( format ) {
|
|
720
1048
|
|
|
721
1049
|
// 8-bit formats
|
|
@@ -772,6 +1100,13 @@ class WebGPUTextureUtils {
|
|
|
772
1100
|
|
|
773
1101
|
}
|
|
774
1102
|
|
|
1103
|
+
/**
|
|
1104
|
+
* Returns the corresponding typed array type for the given GPU texture format.
|
|
1105
|
+
*
|
|
1106
|
+
* @private
|
|
1107
|
+
* @param {string} format - The GPU texture format.
|
|
1108
|
+
* @return {TypedArray.constructor} The typed array type.
|
|
1109
|
+
*/
|
|
775
1110
|
_getTypedArrayType( format ) {
|
|
776
1111
|
|
|
777
1112
|
if ( format === GPUTextureFormat.R8Uint ) return Uint8Array;
|
|
@@ -784,7 +1119,7 @@ class WebGPUTextureUtils {
|
|
|
784
1119
|
if ( format === GPUTextureFormat.RG8Snorm ) return Int8Array;
|
|
785
1120
|
if ( format === GPUTextureFormat.RGBA8Uint ) return Uint8Array;
|
|
786
1121
|
if ( format === GPUTextureFormat.RGBA8Sint ) return Int8Array;
|
|
787
|
-
if ( format === GPUTextureFormat.RGBA8Unorm ) return Uint8Array;
|
|
1122
|
+
if ( format === GPUTextureFormat.RGBA8Unorm || format === GPUTextureFormat.RGBA8UnormSRGB ) return Uint8Array;
|
|
788
1123
|
if ( format === GPUTextureFormat.RGBA8Snorm ) return Int8Array;
|
|
789
1124
|
|
|
790
1125
|
|
|
@@ -809,8 +1144,7 @@ class WebGPUTextureUtils {
|
|
|
809
1144
|
if ( format === GPUTextureFormat.RGBA32Sint ) return Int32Array;
|
|
810
1145
|
if ( format === GPUTextureFormat.RGBA32Float ) return Float32Array;
|
|
811
1146
|
|
|
812
|
-
if ( format === GPUTextureFormat.BGRA8Unorm ) return Uint8Array;
|
|
813
|
-
if ( format === GPUTextureFormat.BGRA8UnormSRGB ) return Uint8Array;
|
|
1147
|
+
if ( format === GPUTextureFormat.BGRA8Unorm || format === GPUTextureFormat.BGRA8UnormSRGB ) return Uint8Array;
|
|
814
1148
|
if ( format === GPUTextureFormat.RGB10A2Unorm ) return Uint32Array;
|
|
815
1149
|
if ( format === GPUTextureFormat.RGB9E5UFloat ) return Uint32Array;
|
|
816
1150
|
if ( format === GPUTextureFormat.RG11B10UFloat ) return Uint32Array;
|
|
@@ -822,11 +1156,18 @@ class WebGPUTextureUtils {
|
|
|
822
1156
|
|
|
823
1157
|
}
|
|
824
1158
|
|
|
1159
|
+
/**
|
|
1160
|
+
* Returns the GPU dimensions for the given texture.
|
|
1161
|
+
*
|
|
1162
|
+
* @private
|
|
1163
|
+
* @param {Texture} texture - The texture.
|
|
1164
|
+
* @return {string} The GPU dimension.
|
|
1165
|
+
*/
|
|
825
1166
|
_getDimension( texture ) {
|
|
826
1167
|
|
|
827
1168
|
let dimension;
|
|
828
1169
|
|
|
829
|
-
if ( texture.isData3DTexture ) {
|
|
1170
|
+
if ( texture.is3DTexture || texture.isData3DTexture ) {
|
|
830
1171
|
|
|
831
1172
|
dimension = GPUTextureDimension.ThreeD;
|
|
832
1173
|
|
|
@@ -842,100 +1183,147 @@ class WebGPUTextureUtils {
|
|
|
842
1183
|
|
|
843
1184
|
}
|
|
844
1185
|
|
|
1186
|
+
/**
|
|
1187
|
+
* Returns the GPU format for the given texture.
|
|
1188
|
+
*
|
|
1189
|
+
* @param {Texture} texture - The texture.
|
|
1190
|
+
* @param {?GPUDevice} [device=null] - The GPU device which is used for feature detection.
|
|
1191
|
+
* It is not necessary to apply the device for most formats.
|
|
1192
|
+
* @return {string} The GPU format.
|
|
1193
|
+
*/
|
|
845
1194
|
export function getFormat( texture, device = null ) {
|
|
846
1195
|
|
|
847
1196
|
const format = texture.format;
|
|
848
1197
|
const type = texture.type;
|
|
849
1198
|
const colorSpace = texture.colorSpace;
|
|
1199
|
+
const transfer = ColorManagement.getTransfer( colorSpace );
|
|
850
1200
|
|
|
851
1201
|
let formatGPU;
|
|
852
1202
|
|
|
853
|
-
if ( texture.
|
|
854
|
-
|
|
855
|
-
formatGPU = GPUTextureFormat.BGRA8Unorm;
|
|
856
|
-
|
|
857
|
-
} else if ( texture.isCompressedTexture === true || texture.isCompressedArrayTexture === true ) {
|
|
1203
|
+
if ( texture.isCompressedTexture === true || texture.isCompressedArrayTexture === true ) {
|
|
858
1204
|
|
|
859
1205
|
switch ( format ) {
|
|
860
1206
|
|
|
1207
|
+
case RGB_S3TC_DXT1_Format:
|
|
861
1208
|
case RGBA_S3TC_DXT1_Format:
|
|
862
|
-
formatGPU = (
|
|
1209
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.BC1RGBAUnormSRGB : GPUTextureFormat.BC1RGBAUnorm;
|
|
863
1210
|
break;
|
|
864
1211
|
|
|
865
1212
|
case RGBA_S3TC_DXT3_Format:
|
|
866
|
-
formatGPU = (
|
|
1213
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.BC2RGBAUnormSRGB : GPUTextureFormat.BC2RGBAUnorm;
|
|
867
1214
|
break;
|
|
868
1215
|
|
|
869
1216
|
case RGBA_S3TC_DXT5_Format:
|
|
870
|
-
formatGPU = (
|
|
1217
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.BC3RGBAUnormSRGB : GPUTextureFormat.BC3RGBAUnorm;
|
|
1218
|
+
break;
|
|
1219
|
+
|
|
1220
|
+
case RED_RGTC1_Format:
|
|
1221
|
+
formatGPU = GPUTextureFormat.BC4RUnorm;
|
|
1222
|
+
break;
|
|
1223
|
+
|
|
1224
|
+
case SIGNED_RED_RGTC1_Format:
|
|
1225
|
+
formatGPU = GPUTextureFormat.BC4RSnorm;
|
|
1226
|
+
break;
|
|
1227
|
+
|
|
1228
|
+
case RED_GREEN_RGTC2_Format:
|
|
1229
|
+
formatGPU = GPUTextureFormat.BC5RGUnorm;
|
|
1230
|
+
break;
|
|
1231
|
+
|
|
1232
|
+
case SIGNED_RED_GREEN_RGTC2_Format:
|
|
1233
|
+
formatGPU = GPUTextureFormat.BC5RGSnorm;
|
|
1234
|
+
break;
|
|
1235
|
+
|
|
1236
|
+
case RGBA_BPTC_Format:
|
|
1237
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.BC7RGBAUnormSRGB : GPUTextureFormat.BC7RGBAUnorm;
|
|
871
1238
|
break;
|
|
872
1239
|
|
|
873
1240
|
case RGB_ETC2_Format:
|
|
874
|
-
|
|
1241
|
+
case RGB_ETC1_Format:
|
|
1242
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ETC2RGB8UnormSRGB : GPUTextureFormat.ETC2RGB8Unorm;
|
|
875
1243
|
break;
|
|
876
1244
|
|
|
877
1245
|
case RGBA_ETC2_EAC_Format:
|
|
878
|
-
formatGPU = (
|
|
1246
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ETC2RGBA8UnormSRGB : GPUTextureFormat.ETC2RGBA8Unorm;
|
|
1247
|
+
break;
|
|
1248
|
+
|
|
1249
|
+
case R11_EAC_Format:
|
|
1250
|
+
formatGPU = GPUTextureFormat.EACR11Unorm;
|
|
1251
|
+
break;
|
|
1252
|
+
|
|
1253
|
+
case SIGNED_R11_EAC_Format:
|
|
1254
|
+
formatGPU = GPUTextureFormat.EACR11Snorm;
|
|
1255
|
+
break;
|
|
1256
|
+
|
|
1257
|
+
case RG11_EAC_Format:
|
|
1258
|
+
formatGPU = GPUTextureFormat.EACRG11Unorm;
|
|
1259
|
+
break;
|
|
1260
|
+
|
|
1261
|
+
case SIGNED_RG11_EAC_Format:
|
|
1262
|
+
formatGPU = GPUTextureFormat.EACRG11Snorm;
|
|
879
1263
|
break;
|
|
880
1264
|
|
|
881
1265
|
case RGBA_ASTC_4x4_Format:
|
|
882
|
-
formatGPU = (
|
|
1266
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC4x4UnormSRGB : GPUTextureFormat.ASTC4x4Unorm;
|
|
883
1267
|
break;
|
|
884
1268
|
|
|
885
1269
|
case RGBA_ASTC_5x4_Format:
|
|
886
|
-
formatGPU = (
|
|
1270
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC5x4UnormSRGB : GPUTextureFormat.ASTC5x4Unorm;
|
|
887
1271
|
break;
|
|
888
1272
|
|
|
889
1273
|
case RGBA_ASTC_5x5_Format:
|
|
890
|
-
formatGPU = (
|
|
1274
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC5x5UnormSRGB : GPUTextureFormat.ASTC5x5Unorm;
|
|
891
1275
|
break;
|
|
892
1276
|
|
|
893
1277
|
case RGBA_ASTC_6x5_Format:
|
|
894
|
-
formatGPU = (
|
|
1278
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC6x5UnormSRGB : GPUTextureFormat.ASTC6x5Unorm;
|
|
895
1279
|
break;
|
|
896
1280
|
|
|
897
1281
|
case RGBA_ASTC_6x6_Format:
|
|
898
|
-
formatGPU = (
|
|
1282
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC6x6UnormSRGB : GPUTextureFormat.ASTC6x6Unorm;
|
|
899
1283
|
break;
|
|
900
1284
|
|
|
901
1285
|
case RGBA_ASTC_8x5_Format:
|
|
902
|
-
formatGPU = (
|
|
1286
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC8x5UnormSRGB : GPUTextureFormat.ASTC8x5Unorm;
|
|
903
1287
|
break;
|
|
904
1288
|
|
|
905
1289
|
case RGBA_ASTC_8x6_Format:
|
|
906
|
-
formatGPU = (
|
|
1290
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC8x6UnormSRGB : GPUTextureFormat.ASTC8x6Unorm;
|
|
907
1291
|
break;
|
|
908
1292
|
|
|
909
1293
|
case RGBA_ASTC_8x8_Format:
|
|
910
|
-
formatGPU = (
|
|
1294
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC8x8UnormSRGB : GPUTextureFormat.ASTC8x8Unorm;
|
|
911
1295
|
break;
|
|
912
1296
|
|
|
913
1297
|
case RGBA_ASTC_10x5_Format:
|
|
914
|
-
formatGPU = (
|
|
1298
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC10x5UnormSRGB : GPUTextureFormat.ASTC10x5Unorm;
|
|
915
1299
|
break;
|
|
916
1300
|
|
|
917
1301
|
case RGBA_ASTC_10x6_Format:
|
|
918
|
-
formatGPU = (
|
|
1302
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC10x6UnormSRGB : GPUTextureFormat.ASTC10x6Unorm;
|
|
919
1303
|
break;
|
|
920
1304
|
|
|
921
1305
|
case RGBA_ASTC_10x8_Format:
|
|
922
|
-
formatGPU = (
|
|
1306
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC10x8UnormSRGB : GPUTextureFormat.ASTC10x8Unorm;
|
|
923
1307
|
break;
|
|
924
1308
|
|
|
925
1309
|
case RGBA_ASTC_10x10_Format:
|
|
926
|
-
formatGPU = (
|
|
1310
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC10x10UnormSRGB : GPUTextureFormat.ASTC10x10Unorm;
|
|
927
1311
|
break;
|
|
928
1312
|
|
|
929
1313
|
case RGBA_ASTC_12x10_Format:
|
|
930
|
-
formatGPU = (
|
|
1314
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC12x10UnormSRGB : GPUTextureFormat.ASTC12x10Unorm;
|
|
931
1315
|
break;
|
|
932
1316
|
|
|
933
1317
|
case RGBA_ASTC_12x12_Format:
|
|
934
|
-
formatGPU = (
|
|
1318
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC12x12UnormSRGB : GPUTextureFormat.ASTC12x12Unorm;
|
|
1319
|
+
break;
|
|
1320
|
+
|
|
1321
|
+
case RGBAFormat:
|
|
1322
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.RGBA8UnormSRGB : GPUTextureFormat.RGBA8Unorm;
|
|
935
1323
|
break;
|
|
936
1324
|
|
|
937
1325
|
default:
|
|
938
|
-
|
|
1326
|
+
error( 'WebGPURenderer: Unsupported texture format.', format );
|
|
939
1327
|
|
|
940
1328
|
}
|
|
941
1329
|
|
|
@@ -967,7 +1355,7 @@ export function getFormat( texture, device = null ) {
|
|
|
967
1355
|
break;
|
|
968
1356
|
|
|
969
1357
|
case UnsignedByteType:
|
|
970
|
-
formatGPU = (
|
|
1358
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.RGBA8UnormSRGB : GPUTextureFormat.RGBA8Unorm;
|
|
971
1359
|
break;
|
|
972
1360
|
|
|
973
1361
|
case HalfFloatType:
|
|
@@ -979,7 +1367,7 @@ export function getFormat( texture, device = null ) {
|
|
|
979
1367
|
break;
|
|
980
1368
|
|
|
981
1369
|
default:
|
|
982
|
-
|
|
1370
|
+
error( 'WebGPURenderer: Unsupported texture type with RGBAFormat.', type );
|
|
983
1371
|
|
|
984
1372
|
}
|
|
985
1373
|
|
|
@@ -993,8 +1381,12 @@ export function getFormat( texture, device = null ) {
|
|
|
993
1381
|
formatGPU = GPUTextureFormat.RGB9E5UFloat;
|
|
994
1382
|
break;
|
|
995
1383
|
|
|
1384
|
+
case UnsignedInt101111Type:
|
|
1385
|
+
formatGPU = GPUTextureFormat.RG11B10UFloat;
|
|
1386
|
+
break;
|
|
1387
|
+
|
|
996
1388
|
default:
|
|
997
|
-
|
|
1389
|
+
error( 'WebGPURenderer: Unsupported texture type with RGBFormat.', type );
|
|
998
1390
|
|
|
999
1391
|
}
|
|
1000
1392
|
|
|
@@ -1037,7 +1429,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1037
1429
|
break;
|
|
1038
1430
|
|
|
1039
1431
|
default:
|
|
1040
|
-
|
|
1432
|
+
error( 'WebGPURenderer: Unsupported texture type with RedFormat.', type );
|
|
1041
1433
|
|
|
1042
1434
|
}
|
|
1043
1435
|
|
|
@@ -1080,7 +1472,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1080
1472
|
break;
|
|
1081
1473
|
|
|
1082
1474
|
default:
|
|
1083
|
-
|
|
1475
|
+
error( 'WebGPURenderer: Unsupported texture type with RGFormat.', type );
|
|
1084
1476
|
|
|
1085
1477
|
}
|
|
1086
1478
|
|
|
@@ -1103,7 +1495,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1103
1495
|
break;
|
|
1104
1496
|
|
|
1105
1497
|
default:
|
|
1106
|
-
|
|
1498
|
+
error( 'WebGPURenderer: Unsupported texture type with DepthFormat.', type );
|
|
1107
1499
|
|
|
1108
1500
|
}
|
|
1109
1501
|
|
|
@@ -1121,7 +1513,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1121
1513
|
|
|
1122
1514
|
if ( device && device.features.has( GPUFeatureName.Depth32FloatStencil8 ) === false ) {
|
|
1123
1515
|
|
|
1124
|
-
|
|
1516
|
+
error( 'WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.' );
|
|
1125
1517
|
|
|
1126
1518
|
}
|
|
1127
1519
|
|
|
@@ -1130,7 +1522,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1130
1522
|
break;
|
|
1131
1523
|
|
|
1132
1524
|
default:
|
|
1133
|
-
|
|
1525
|
+
error( 'WebGPURenderer: Unsupported texture type with DepthStencilFormat.', type );
|
|
1134
1526
|
|
|
1135
1527
|
}
|
|
1136
1528
|
|
|
@@ -1149,7 +1541,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1149
1541
|
break;
|
|
1150
1542
|
|
|
1151
1543
|
default:
|
|
1152
|
-
|
|
1544
|
+
error( 'WebGPURenderer: Unsupported texture type with RedIntegerFormat.', type );
|
|
1153
1545
|
|
|
1154
1546
|
}
|
|
1155
1547
|
|
|
@@ -1168,7 +1560,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1168
1560
|
break;
|
|
1169
1561
|
|
|
1170
1562
|
default:
|
|
1171
|
-
|
|
1563
|
+
error( 'WebGPURenderer: Unsupported texture type with RGIntegerFormat.', type );
|
|
1172
1564
|
|
|
1173
1565
|
}
|
|
1174
1566
|
|
|
@@ -1187,14 +1579,14 @@ export function getFormat( texture, device = null ) {
|
|
|
1187
1579
|
break;
|
|
1188
1580
|
|
|
1189
1581
|
default:
|
|
1190
|
-
|
|
1582
|
+
error( 'WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.', type );
|
|
1191
1583
|
|
|
1192
1584
|
}
|
|
1193
1585
|
|
|
1194
1586
|
break;
|
|
1195
1587
|
|
|
1196
1588
|
default:
|
|
1197
|
-
|
|
1589
|
+
error( 'WebGPURenderer: Unsupported texture format.', format );
|
|
1198
1590
|
|
|
1199
1591
|
}
|
|
1200
1592
|
|