super-three 0.171.0 → 0.172.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/README.md +1 -1
- package/build/three.cjs +157 -49
- package/build/three.core.js +104 -42
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +53 -8
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +10 -5
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +21191 -1008
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +21189 -1008
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +0 -5
- package/examples/jsm/animation/CCDIKSolver.js +3 -2
- package/examples/jsm/controls/ArcballControls.js +28 -19
- package/examples/jsm/controls/OrbitControls.js +5 -4
- package/examples/jsm/csm/CSMShadowNode.js +16 -11
- package/examples/jsm/curves/NURBSCurve.js +1 -1
- package/examples/jsm/curves/NURBSUtils.js +3 -0
- package/examples/jsm/effects/OutlineEffect.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +11 -7
- package/examples/jsm/exporters/KTX2Exporter.js +1 -1
- package/examples/jsm/exporters/PLYExporter.js +2 -2
- package/examples/jsm/helpers/TextureHelperGPU.js +15 -5
- package/examples/jsm/helpers/VertexNormalsHelper.js +2 -0
- package/examples/jsm/lights/LightProbeGenerator.js +3 -3
- package/examples/jsm/lines/webgpu/LineSegments2.js +15 -6
- package/examples/jsm/loaders/3MFLoader.js +6 -3
- package/examples/jsm/loaders/BVHLoader.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +5 -5
- package/examples/jsm/loaders/DDSLoader.js +42 -0
- package/examples/jsm/loaders/GCodeLoader.js +1 -1
- package/examples/jsm/loaders/GLTFLoader.js +22 -2
- package/examples/jsm/loaders/KTX2Loader.js +6 -1
- package/examples/jsm/loaders/KTXLoader.js +4 -4
- package/examples/jsm/loaders/LDrawLoader.js +1 -1
- package/examples/jsm/loaders/LottieLoader.js +1 -1
- package/examples/jsm/loaders/MTLLoader.js +1 -0
- package/examples/jsm/loaders/NRRDLoader.js +1 -1
- package/examples/jsm/loaders/PLYLoader.js +7 -7
- package/examples/jsm/loaders/PVRLoader.js +1 -1
- package/examples/jsm/loaders/SVGLoader.js +2 -2
- package/examples/jsm/loaders/TDSLoader.js +1 -1
- package/examples/jsm/loaders/VRMLLoader.js +7 -7
- package/examples/jsm/loaders/lwo/IFFParser.js +4 -4
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +1 -1
- package/examples/jsm/math/ConvexHull.js +1 -1
- package/examples/jsm/math/OBB.js +17 -0
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +10 -10
- package/examples/jsm/misc/Volume.js +20 -12
- package/examples/jsm/misc/VolumeSlice.js +2 -2
- package/examples/jsm/modifiers/CurveModifier.js +10 -8
- package/examples/jsm/modifiers/CurveModifierGPU.js +9 -7
- package/examples/jsm/modifiers/SimplifyModifier.js +2 -2
- package/examples/jsm/objects/GroundedSkybox.js +4 -4
- package/examples/jsm/objects/Sky.js +2 -2
- package/examples/jsm/objects/SkyMesh.js +3 -3
- package/examples/jsm/objects/Water2.js +1 -1
- package/examples/jsm/objects/Water2Mesh.js +2 -2
- package/examples/jsm/objects/WaterMesh.js +4 -4
- package/examples/jsm/postprocessing/BloomPass.js +2 -2
- package/examples/jsm/postprocessing/EffectComposer.js +1 -2
- package/examples/jsm/postprocessing/OutlinePass.js +4 -4
- package/examples/jsm/postprocessing/SAOPass.js +1 -2
- package/examples/jsm/postprocessing/SMAAPass.js +1 -3
- package/examples/jsm/postprocessing/SSAOPass.js +2 -4
- package/examples/jsm/postprocessing/SSRPass.js +2 -4
- package/examples/jsm/postprocessing/UnrealBloomPass.js +2 -2
- package/examples/jsm/renderers/SVGRenderer.js +6 -4
- package/examples/jsm/shaders/BokehShader2.js +1 -1
- package/examples/jsm/shaders/GodRaysShader.js +3 -3
- package/examples/jsm/shaders/SobelOperatorShader.js +1 -1
- package/examples/jsm/tsl/display/AfterImageNode.js +93 -4
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +46 -2
- package/examples/jsm/tsl/display/AnamorphicNode.js +118 -5
- package/examples/jsm/tsl/display/BleachBypass.js +10 -0
- package/examples/jsm/tsl/display/BloomNode.js +233 -26
- package/examples/jsm/tsl/display/DenoiseNode.js +141 -25
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +80 -1
- package/examples/jsm/tsl/display/DotScreenNode.js +50 -5
- package/examples/jsm/tsl/display/FXAANode.js +52 -3
- package/examples/jsm/tsl/display/FilmNode.js +47 -1
- package/examples/jsm/tsl/display/GTAONode.js +210 -14
- package/examples/jsm/tsl/display/GaussianBlurNode.js +152 -8
- package/examples/jsm/tsl/display/LensflareNode.js +131 -13
- package/examples/jsm/tsl/display/Lut3DNode.js +55 -1
- package/examples/jsm/tsl/display/MotionBlur.js +12 -2
- package/examples/jsm/tsl/display/OutlineNode.js +343 -26
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +36 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +142 -9
- package/examples/jsm/tsl/display/RGBShiftNode.js +49 -2
- package/examples/jsm/tsl/display/SMAANode.js +187 -46
- package/examples/jsm/tsl/display/SSAAPassNode.js +110 -25
- package/examples/jsm/tsl/display/SSRNode.js +194 -21
- package/examples/jsm/tsl/display/Sepia.js +9 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +54 -4
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +79 -3
- package/examples/jsm/tsl/display/StereoPassNode.js +41 -3
- package/examples/jsm/tsl/display/TRAAPassNode.js +116 -21
- package/examples/jsm/tsl/display/TransitionNode.js +71 -6
- package/examples/jsm/tsl/display/hashBlur.js +14 -3
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +40 -34
- package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
- package/examples/jsm/utils/CameraUtils.js +4 -1
- package/examples/jsm/utils/GeometryUtils.js +22 -19
- package/examples/jsm/utils/SceneUtils.js +2 -2
- package/examples/jsm/webxr/XRControllerModelFactory.js +6 -1
- package/examples/jsm/webxr/XREstimatedLight.js +1 -1
- package/package.json +8 -3
- package/src/Three.Core.js +2 -0
- package/src/Three.Legacy.js +0 -21
- package/src/Three.TSL.js +9 -4
- package/src/Three.WebGPU.Nodes.js +2 -2
- package/src/Three.WebGPU.js +2 -2
- package/src/animation/PropertyBinding.js +2 -2
- package/src/cameras/PerspectiveCamera.js +18 -2
- package/src/constants.js +1 -1
- package/src/core/RenderTarget.js +18 -0
- package/src/core/RenderTarget3D.js +22 -0
- package/src/core/RenderTargetArray.js +22 -0
- package/src/extras/Earcut.js +1 -1
- package/src/extras/PMREMGenerator.js +20 -0
- package/src/extras/TextureUtils.js +6 -0
- package/src/helpers/CameraHelper.js +16 -13
- package/src/loaders/nodes/NodeLoader.js +59 -0
- package/src/loaders/nodes/NodeMaterialLoader.js +45 -0
- package/src/loaders/nodes/NodeObjectLoader.js +61 -0
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +72 -19
- package/src/materials/nodes/Line2NodeMaterial.js +128 -34
- package/src/materials/nodes/LineBasicNodeMaterial.js +17 -2
- package/src/materials/nodes/LineDashedNodeMaterial.js +78 -5
- package/src/materials/nodes/MeshBasicNodeMaterial.js +56 -0
- package/src/materials/nodes/MeshLambertNodeMaterial.js +35 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +22 -2
- package/src/materials/nodes/MeshNormalNodeMaterial.js +21 -2
- package/src/materials/nodes/MeshPhongNodeMaterial.js +64 -1
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +269 -0
- package/src/materials/nodes/MeshSSSNodeMaterial.js +97 -6
- package/src/materials/nodes/MeshStandardNodeMaterial.js +78 -0
- package/src/materials/nodes/MeshToonNodeMaterial.js +28 -0
- package/src/materials/nodes/NodeMaterial.js +474 -21
- package/src/materials/nodes/PointsNodeMaterial.js +22 -13
- package/src/materials/nodes/ShadowNodeMaterial.js +29 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +77 -19
- package/src/materials/nodes/VolumeNodeMaterial.js +80 -4
- package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -0
- package/src/nodes/Nodes.js +1 -6
- package/src/nodes/TSL.js +2 -3
- package/src/nodes/accessors/AccessorsUtils.js +27 -0
- package/src/nodes/accessors/Arrays.js +24 -5
- package/src/nodes/accessors/BatchNode.js +39 -3
- package/src/nodes/accessors/Bitangent.js +37 -0
- package/src/nodes/accessors/BufferAttributeNode.js +178 -5
- package/src/nodes/accessors/BufferNode.js +63 -0
- package/src/nodes/accessors/BuiltinNode.js +38 -0
- package/src/nodes/accessors/Camera.js +49 -0
- package/src/nodes/accessors/ClippingNode.js +71 -2
- package/src/nodes/accessors/CubeTextureNode.js +64 -0
- package/src/nodes/accessors/InstanceNode.js +85 -2
- package/src/nodes/accessors/InstancedMeshNode.js +28 -3
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +13 -0
- package/src/nodes/accessors/Lights.js +50 -1
- package/src/nodes/accessors/MaterialNode.js +302 -8
- package/src/nodes/accessors/MaterialProperties.js +7 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +53 -13
- package/src/nodes/accessors/ModelNode.js +100 -5
- package/src/nodes/accessors/ModelViewProjectionNode.js +10 -38
- package/src/nodes/accessors/MorphNode.js +48 -4
- package/src/nodes/accessors/Normal.js +59 -3
- package/src/nodes/accessors/Object3DNode.js +102 -1
- package/src/nodes/accessors/PointUVNode.js +26 -0
- package/src/nodes/accessors/Position.js +53 -4
- package/src/nodes/accessors/ReferenceBaseNode.js +188 -0
- package/src/nodes/accessors/ReferenceNode.js +202 -2
- package/src/nodes/accessors/ReflectVector.js +24 -0
- package/src/nodes/accessors/RendererReferenceNode.js +46 -1
- package/src/nodes/accessors/SceneNode.js +54 -0
- package/src/nodes/accessors/SkinningNode.js +127 -1
- package/src/nodes/accessors/StorageBufferNode.js +168 -4
- package/src/nodes/accessors/StorageTextureNode.js +118 -0
- package/src/nodes/accessors/Tangent.js +36 -0
- package/src/nodes/accessors/Texture3DNode.js +89 -5
- package/src/nodes/accessors/TextureBicubic.js +12 -2
- package/src/nodes/accessors/TextureNode.js +309 -10
- package/src/nodes/accessors/TextureSizeNode.js +42 -0
- package/src/nodes/accessors/UV.js +10 -1
- package/src/nodes/accessors/UniformArrayNode.js +223 -23
- package/src/nodes/accessors/UserDataNode.js +46 -0
- package/src/nodes/accessors/VelocityNode.js +82 -0
- package/src/nodes/accessors/VertexColorNode.js +39 -2
- package/src/nodes/code/CodeNode.js +95 -1
- package/src/nodes/code/ExpressionNode.js +28 -0
- package/src/nodes/code/FunctionCallNode.js +37 -0
- package/src/nodes/code/FunctionNode.js +45 -0
- package/src/nodes/code/ScriptableNode.js +223 -1
- package/src/nodes/code/ScriptableValueNode.js +85 -1
- package/src/nodes/core/AssignNode.js +48 -2
- package/src/nodes/core/AttributeNode.js +43 -0
- package/src/nodes/core/BypassNode.js +47 -2
- package/src/nodes/core/CacheNode.js +53 -2
- package/src/nodes/core/ConstNode.js +24 -0
- package/src/nodes/core/ContextNode.js +65 -0
- package/src/nodes/core/IndexNode.js +68 -7
- package/src/nodes/core/InputNode.js +48 -0
- package/src/nodes/core/LightingModel.js +60 -0
- package/src/nodes/core/MRTNode.js +66 -0
- package/src/nodes/core/Node.js +337 -12
- package/src/nodes/core/NodeAttribute.js +38 -0
- package/src/nodes/core/NodeBuilder.js +945 -15
- package/src/nodes/core/NodeCache.js +41 -2
- package/src/nodes/core/NodeCode.js +31 -0
- package/src/nodes/core/NodeFrame.js +123 -2
- package/src/nodes/core/NodeFunction.js +46 -0
- package/src/nodes/core/NodeFunctionInput.js +44 -0
- package/src/nodes/core/NodeParser.js +11 -0
- package/src/nodes/core/NodeUniform.js +52 -0
- package/src/nodes/core/NodeUtils.js +141 -0
- package/src/nodes/core/NodeVar.js +30 -0
- package/src/nodes/core/NodeVarying.js +28 -0
- package/src/nodes/core/OutputStructNode.js +33 -2
- package/src/nodes/core/ParameterNode.js +28 -0
- package/src/nodes/core/PropertyNode.js +232 -0
- package/src/nodes/core/StackNode.js +78 -0
- package/src/nodes/core/StructTypeNode.js +39 -1
- package/src/nodes/core/TempNode.js +30 -4
- package/src/nodes/core/UniformGroupNode.js +82 -7
- package/src/nodes/core/UniformNode.js +66 -0
- package/src/nodes/core/VarNode.js +52 -0
- package/src/nodes/core/VaryingNode.js +83 -2
- package/src/nodes/core/constants.js +36 -0
- package/src/nodes/display/BumpMapNode.js +37 -0
- package/src/nodes/display/ColorAdjustment.js +53 -11
- package/src/nodes/display/ColorSpaceFunctions.js +16 -0
- package/src/nodes/display/ColorSpaceNode.js +82 -0
- package/src/nodes/display/FrontFacingNode.js +29 -0
- package/src/nodes/display/NormalMapNode.js +43 -0
- package/src/nodes/display/PassNode.js +298 -7
- package/src/nodes/display/PosterizeNode.js +33 -0
- package/src/nodes/display/RenderOutputNode.js +66 -1
- package/src/nodes/display/ScreenNode.js +87 -0
- package/src/nodes/display/ToneMappingFunctions.js +58 -10
- package/src/nodes/display/ToneMappingNode.js +55 -2
- package/src/nodes/display/ToonOutlinePassNode.js +73 -0
- package/src/nodes/display/ViewportDepthNode.js +122 -8
- package/src/nodes/display/ViewportDepthTextureNode.js +23 -0
- package/src/nodes/display/ViewportSharedTextureNode.js +23 -0
- package/src/nodes/display/ViewportTextureNode.js +57 -0
- package/src/nodes/fog/Fog.js +93 -0
- package/src/nodes/functions/BasicLightingModel.js +24 -0
- package/src/nodes/functions/PhongLightingModel.js +34 -2
- package/src/nodes/functions/PhysicalLightingModel.js +167 -8
- package/src/nodes/functions/ShadowMaskModel.js +23 -0
- package/src/nodes/functions/ToonLightingModel.js +20 -0
- package/src/nodes/functions/material/getAlphaHashThreshold.js +1 -3
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +16 -1
- package/src/nodes/geometry/RangeNode.js +54 -2
- package/src/nodes/gpgpu/AtomicFunctionNode.js +157 -1
- package/src/nodes/gpgpu/BarrierNode.js +47 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +126 -0
- package/src/nodes/gpgpu/ComputeNode.js +106 -2
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +115 -6
- package/src/nodes/lighting/AONode.js +18 -0
- package/src/nodes/lighting/AmbientLightNode.js +10 -0
- package/src/nodes/lighting/AnalyticLightNode.js +97 -2
- package/src/nodes/lighting/BasicEnvironmentNode.js +19 -0
- package/src/nodes/lighting/BasicLightMapNode.js +17 -0
- package/src/nodes/lighting/DirectionalLightNode.js +10 -0
- package/src/nodes/lighting/EnvironmentNode.js +18 -0
- package/src/nodes/lighting/HemisphereLightNode.js +31 -0
- package/src/nodes/lighting/IESSpotLightNode.js +11 -0
- package/src/nodes/lighting/IrradianceNode.js +17 -0
- package/src/nodes/lighting/LightProbeNode.js +20 -0
- package/src/nodes/lighting/LightUtils.js +12 -0
- package/src/nodes/lighting/LightingContextNode.js +48 -0
- package/src/nodes/lighting/LightingNode.js +15 -6
- package/src/nodes/lighting/LightsNode.js +132 -1
- package/src/nodes/lighting/PointLightNode.js +32 -1
- package/src/nodes/lighting/PointShadowNode.js +54 -1
- package/src/nodes/lighting/RectAreaLightNode.js +44 -6
- package/src/nodes/lighting/ShadowBaseNode.js +93 -0
- package/src/nodes/lighting/ShadowNode.js +240 -34
- package/src/nodes/lighting/SpotLightNode.js +43 -0
- package/src/nodes/math/ConditionalNode.js +70 -3
- package/src/nodes/math/Hash.js +9 -0
- package/src/nodes/math/MathNode.js +614 -11
- package/src/nodes/math/MathUtils.js +45 -1
- package/src/nodes/math/OperatorNode.js +233 -0
- package/src/nodes/math/TriNoise3D.js +18 -7
- package/src/nodes/parsers/GLSLNodeFunction.js +16 -0
- package/src/nodes/parsers/GLSLNodeParser.js +11 -0
- package/src/nodes/pmrem/PMREMNode.js +133 -0
- package/src/nodes/pmrem/PMREMUtils.js +1 -1
- package/src/nodes/procedural/Checker.js +9 -0
- package/src/nodes/tsl/TSLBase.js +2 -2
- package/src/nodes/utils/ArrayElementNode.js +38 -2
- package/src/nodes/utils/ConvertNode.js +31 -0
- package/src/nodes/utils/CubeMapNode.js +78 -0
- package/src/nodes/utils/Discard.js +16 -0
- package/src/nodes/utils/EquirectUVNode.js +31 -1
- package/src/nodes/utils/FlipNode.js +38 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +53 -1
- package/src/nodes/utils/JoinNode.js +25 -0
- package/src/nodes/utils/LoopNode.js +74 -1
- package/src/nodes/utils/MatcapUVNode.js +17 -0
- package/src/nodes/utils/MaxMipLevelNode.js +49 -0
- package/src/nodes/utils/Oscillators.js +33 -0
- package/src/nodes/utils/Packing.js +17 -0
- package/src/nodes/utils/PostProcessingUtils.js +28 -23
- package/src/nodes/utils/RTTNode.js +123 -2
- package/src/nodes/utils/ReflectorNode.js +174 -4
- package/src/nodes/utils/RemapNode.js +79 -0
- package/src/nodes/utils/RotateNode.js +41 -0
- package/src/nodes/utils/SetNode.js +44 -1
- package/src/nodes/utils/SplitNode.js +55 -3
- package/src/nodes/utils/SpriteSheetUVNode.js +46 -0
- package/src/nodes/utils/SpriteUtils.js +17 -0
- package/src/nodes/utils/StorageArrayElementNode.js +40 -0
- package/src/nodes/utils/Timer.js +19 -0
- package/src/nodes/utils/TriplanarTexturesNode.js +84 -0
- package/src/nodes/utils/UVUtils.js +20 -0
- package/src/nodes/utils/ViewportUtils.js +13 -0
- package/src/objects/BatchedMesh.js +1 -2
- package/src/objects/ClippingGroup.js +49 -0
- package/src/renderers/WebGLRenderer.js +23 -4
- package/src/renderers/common/Animation.js +63 -0
- package/src/renderers/common/Attributes.js +36 -0
- package/src/renderers/common/Backend.js +467 -52
- package/src/renderers/common/Background.js +34 -1
- package/src/renderers/common/BindGroup.js +43 -0
- package/src/renderers/common/Binding.js +35 -0
- package/src/renderers/common/Bindings.js +93 -1
- package/src/renderers/common/Buffer.js +49 -0
- package/src/renderers/common/BufferUtils.js +27 -0
- package/src/renderers/common/BundleGroup.js +57 -0
- package/src/renderers/common/ChainMap.js +38 -1
- package/src/renderers/common/ClippingContext.js +107 -14
- package/src/renderers/common/Color4.js +36 -0
- package/src/renderers/common/ComputePipeline.js +24 -0
- package/src/renderers/common/CubeRenderTarget.js +13 -0
- package/src/renderers/common/DataMap.js +37 -1
- package/src/renderers/common/Geometries.js +98 -0
- package/src/renderers/common/IndirectStorageBufferAttribute.js +25 -2
- package/src/renderers/common/Info.js +87 -0
- package/src/renderers/common/Lighting.js +26 -0
- package/src/renderers/common/Pipeline.js +22 -0
- package/src/renderers/common/Pipelines.js +148 -5
- package/src/renderers/common/PostProcessing.js +75 -3
- package/src/renderers/common/ProgrammableStage.js +60 -2
- package/src/renderers/common/QuadMesh.js +54 -5
- package/src/renderers/common/RenderBundle.js +14 -8
- package/src/renderers/common/RenderBundles.js +33 -10
- package/src/renderers/common/RenderContext.js +169 -4
- package/src/renderers/common/RenderContexts.js +42 -2
- package/src/renderers/common/RenderList.js +178 -0
- package/src/renderers/common/RenderLists.js +31 -0
- package/src/renderers/common/RenderObject.js +328 -4
- package/src/renderers/common/RenderObjects.js +101 -7
- package/src/renderers/common/RenderPipeline.js +24 -0
- package/src/renderers/common/Renderer.js +1096 -31
- package/src/renderers/common/RendererUtils.js +193 -0
- package/src/renderers/common/SampledTexture.js +121 -0
- package/src/renderers/common/Sampler.js +30 -0
- package/src/renderers/common/StorageBuffer.js +24 -0
- package/src/renderers/common/StorageBufferAttribute.js +31 -2
- package/src/renderers/common/StorageInstancedBufferAttribute.js +31 -2
- package/src/renderers/common/StorageTexture.js +38 -0
- package/src/renderers/common/Textures.js +83 -0
- package/src/renderers/common/Uniform.js +188 -2
- package/src/renderers/common/UniformBuffer.js +19 -0
- package/src/renderers/common/UniformsGroup.js +139 -2
- package/src/renderers/common/extras/PMREMGenerator.js +24 -3
- package/src/renderers/common/nodes/NodeBuilderState.js +95 -1
- package/src/renderers/common/nodes/NodeLibrary.js +89 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +91 -2
- package/src/renderers/common/nodes/NodeSampler.js +28 -0
- package/src/renderers/common/nodes/NodeStorageBuffer.js +35 -0
- package/src/renderers/common/nodes/NodeUniform.js +189 -0
- package/src/renderers/common/nodes/NodeUniformBuffer.js +29 -0
- package/src/renderers/common/nodes/NodeUniformsGroup.js +31 -18
- package/src/renderers/common/nodes/Nodes.js +327 -60
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +7 -7
- package/src/renderers/webgl-fallback/WebGLBackend.js +547 -29
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +0 -1
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +1 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +1 -1
- package/src/renderers/webgpu/WebGPUBackend.js +480 -49
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +34 -0
- package/src/renderers/webgpu/WebGPURenderer.js +35 -0
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +20 -8
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +21 -8
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +59 -11
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +17 -0
- package/src/renderers/webgpu/nodes/WGSLNodeParser.js +11 -0
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +10 -8
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +9 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +5 -9
- package/src/renderers/webgpu/utils/WebGPUUtils.js +30 -0
- package/src/renderers/webxr/WebXRDepthSensing.js +1 -1
- package/src/renderers/webxr/WebXRManager.js +7 -1
- package/src/textures/Data3DTexture.js +2 -2
- package/src/textures/Texture.js +4 -0
- package/examples/jsm/animation/MMDAnimationHelper.js +0 -1209
- package/examples/jsm/animation/MMDPhysics.js +0 -1408
- package/examples/jsm/exporters/MMDExporter.js +0 -223
- package/examples/jsm/libs/mmdparser.module.js +0 -11530
- package/examples/jsm/loaders/MMDLoader.js +0 -2298
- package/examples/jsm/shaders/MMDToonShader.js +0 -134
- package/src/nodes/core/UniformGroup.js +0 -13
- 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/renderers/common/PostProcessingUtils.js +0 -86
|
@@ -15,14 +15,42 @@ import WebGPUTextureUtils from './utils/WebGPUTextureUtils.js';
|
|
|
15
15
|
|
|
16
16
|
import { WebGPUCoordinateSystem } from '../../constants.js';
|
|
17
17
|
|
|
18
|
-
//
|
|
19
18
|
|
|
19
|
+
/**
|
|
20
|
+
* A backend implementation targeting WebGPU.
|
|
21
|
+
*
|
|
22
|
+
* @private
|
|
23
|
+
* @augments Backend
|
|
24
|
+
*/
|
|
20
25
|
class WebGPUBackend extends Backend {
|
|
21
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Constructs a new WebGPU backend.
|
|
29
|
+
*
|
|
30
|
+
* @param {Object} parameters - The configuration parameter.
|
|
31
|
+
* @param {Boolean} [parameters.logarithmicDepthBuffer=false] - Whether logarithmic depth buffer is enabled or not.
|
|
32
|
+
* @param {Boolean} [parameters.alpha=true] - Whether the default framebuffer (which represents the final contents of the canvas) should be transparent or opaque.
|
|
33
|
+
* @param {Boolean} [parameters.depth=true] - Whether the default framebuffer should have a depth buffer or not.
|
|
34
|
+
* @param {Boolean} [parameters.stencil=false] - Whether the default framebuffer should have a stencil buffer or not.
|
|
35
|
+
* @param {Boolean} [parameters.antialias=false] - Whether MSAA as the default anti-aliasing should be enabled or not.
|
|
36
|
+
* @param {Number} [parameters.samples=0] - When `antialias` is `true`, `4` samples are used by default. Set this parameter to any other integer value than 0 to overwrite the default.
|
|
37
|
+
* @param {Boolean} [parameters.forceWebGL=false] - If set to `true`, the renderer uses it WebGL 2 backend no matter if WebGPU is supported or not.
|
|
38
|
+
* @param {Boolean} [parameters.trackTimestamp=false] - Whether to track timestamps with a Timestamp Query API or not.
|
|
39
|
+
* @param {String?} [parameters.powerPreference=null] - The power preference.
|
|
40
|
+
* @param {String?} [parameters.requiredLimits={}] - Specifies the limits that are required by the device request.
|
|
41
|
+
* The request will fail if the adapter cannot provide these limits.
|
|
42
|
+
*/
|
|
22
43
|
constructor( parameters = {} ) {
|
|
23
44
|
|
|
24
45
|
super( parameters );
|
|
25
46
|
|
|
47
|
+
/**
|
|
48
|
+
* This flag can be used for type testing.
|
|
49
|
+
*
|
|
50
|
+
* @type {Boolean}
|
|
51
|
+
* @readonly
|
|
52
|
+
* @default true
|
|
53
|
+
*/
|
|
26
54
|
this.isWebGPUBackend = true;
|
|
27
55
|
|
|
28
56
|
// some parameters require default values other than "undefined"
|
|
@@ -30,22 +58,101 @@ class WebGPUBackend extends Backend {
|
|
|
30
58
|
|
|
31
59
|
this.parameters.requiredLimits = ( parameters.requiredLimits === undefined ) ? {} : parameters.requiredLimits;
|
|
32
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Whether to track timestamps with a Timestamp Query API or not.
|
|
63
|
+
*
|
|
64
|
+
* @type {Boolean}
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
33
67
|
this.trackTimestamp = ( parameters.trackTimestamp === true );
|
|
34
68
|
|
|
69
|
+
/**
|
|
70
|
+
* A reference to the device.
|
|
71
|
+
*
|
|
72
|
+
* @type {GPUDevice?}
|
|
73
|
+
* @default null
|
|
74
|
+
*/
|
|
35
75
|
this.device = null;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* A reference to the context.
|
|
79
|
+
*
|
|
80
|
+
* @type {GPUCanvasContext?}
|
|
81
|
+
* @default null
|
|
82
|
+
*/
|
|
36
83
|
this.context = null;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* A reference to the color attachment of the default framebuffer.
|
|
87
|
+
*
|
|
88
|
+
* @type {GPUTexture?}
|
|
89
|
+
* @default null
|
|
90
|
+
*/
|
|
37
91
|
this.colorBuffer = null;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* A reference to the default render pass descriptor.
|
|
95
|
+
*
|
|
96
|
+
* @type {Object?}
|
|
97
|
+
* @default null
|
|
98
|
+
*/
|
|
38
99
|
this.defaultRenderPassdescriptor = null;
|
|
39
100
|
|
|
101
|
+
/**
|
|
102
|
+
* A reference to a backend module holding common utility functions.
|
|
103
|
+
*
|
|
104
|
+
* @type {WebGPUUtils}
|
|
105
|
+
*/
|
|
40
106
|
this.utils = new WebGPUUtils( this );
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A reference to a backend module holding shader attribute-related
|
|
110
|
+
* utility functions.
|
|
111
|
+
*
|
|
112
|
+
* @type {WebGPUAttributeUtils}
|
|
113
|
+
*/
|
|
41
114
|
this.attributeUtils = new WebGPUAttributeUtils( this );
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* A reference to a backend module holding shader binding-related
|
|
118
|
+
* utility functions.
|
|
119
|
+
*
|
|
120
|
+
* @type {WebGPUBindingUtils}
|
|
121
|
+
*/
|
|
42
122
|
this.bindingUtils = new WebGPUBindingUtils( this );
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* A reference to a backend module holding shader pipeline-related
|
|
126
|
+
* utility functions.
|
|
127
|
+
*
|
|
128
|
+
* @type {WebGPUPipelineUtils}
|
|
129
|
+
*/
|
|
43
130
|
this.pipelineUtils = new WebGPUPipelineUtils( this );
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* A reference to a backend module holding shader texture-related
|
|
134
|
+
* utility functions.
|
|
135
|
+
*
|
|
136
|
+
* @type {WebGPUTextureUtils}
|
|
137
|
+
*/
|
|
44
138
|
this.textureUtils = new WebGPUTextureUtils( this );
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* A map that manages the resolve buffers for occlusion queries.
|
|
142
|
+
*
|
|
143
|
+
* @type {Map<Number,GPUBuffer>}
|
|
144
|
+
*/
|
|
45
145
|
this.occludedResolveCache = new Map();
|
|
46
146
|
|
|
47
147
|
}
|
|
48
148
|
|
|
149
|
+
/**
|
|
150
|
+
* Initializes the backend so it is ready for usage.
|
|
151
|
+
*
|
|
152
|
+
* @async
|
|
153
|
+
* @param {Renderer} renderer - The renderer.
|
|
154
|
+
* @return {Promise} A Promise that resolves when the backend has been initialized.
|
|
155
|
+
*/
|
|
49
156
|
async init( renderer ) {
|
|
50
157
|
|
|
51
158
|
await super.init( renderer );
|
|
@@ -134,24 +241,53 @@ class WebGPUBackend extends Backend {
|
|
|
134
241
|
|
|
135
242
|
}
|
|
136
243
|
|
|
244
|
+
/**
|
|
245
|
+
* The coordinate system of the backend.
|
|
246
|
+
*
|
|
247
|
+
* @type {Number}
|
|
248
|
+
* @readonly
|
|
249
|
+
*/
|
|
137
250
|
get coordinateSystem() {
|
|
138
251
|
|
|
139
252
|
return WebGPUCoordinateSystem;
|
|
140
253
|
|
|
141
254
|
}
|
|
142
255
|
|
|
256
|
+
/**
|
|
257
|
+
* Transfers buffer data from a storage buffer attribute
|
|
258
|
+
* from the GPU to the CPU in context of compute shaders.
|
|
259
|
+
*
|
|
260
|
+
* @async
|
|
261
|
+
* @param {StorageBufferAttribute} attribute - The storage buffer attribute.
|
|
262
|
+
* @return {Promise<ArrayBuffer>} A promise that resolves with the buffer data when the data are ready.
|
|
263
|
+
*/
|
|
143
264
|
async getArrayBufferAsync( attribute ) {
|
|
144
265
|
|
|
145
266
|
return await this.attributeUtils.getArrayBufferAsync( attribute );
|
|
146
267
|
|
|
147
268
|
}
|
|
148
269
|
|
|
270
|
+
/**
|
|
271
|
+
* Returns the backend's rendering context.
|
|
272
|
+
*
|
|
273
|
+
* @return {GPUCanvasContext} The rendering context.
|
|
274
|
+
*/
|
|
149
275
|
getContext() {
|
|
150
276
|
|
|
151
277
|
return this.context;
|
|
152
278
|
|
|
153
279
|
}
|
|
154
280
|
|
|
281
|
+
/**
|
|
282
|
+
* Returns the default render pass descriptor.
|
|
283
|
+
*
|
|
284
|
+
* In WebGPU, the default framebuffer must be configured
|
|
285
|
+
* like custom fraemebuffers so the backend needs a render
|
|
286
|
+
* pass descriptor even when rendering directly to screen.
|
|
287
|
+
*
|
|
288
|
+
* @private
|
|
289
|
+
* @return {Object} The render pass descriptor.
|
|
290
|
+
*/
|
|
155
291
|
_getDefaultRenderPassDescriptor() {
|
|
156
292
|
|
|
157
293
|
let descriptor = this.defaultRenderPassdescriptor;
|
|
@@ -206,7 +342,15 @@ class WebGPUBackend extends Backend {
|
|
|
206
342
|
|
|
207
343
|
}
|
|
208
344
|
|
|
209
|
-
|
|
345
|
+
/**
|
|
346
|
+
* Returns the render pass descriptor for the given render context.
|
|
347
|
+
*
|
|
348
|
+
* @private
|
|
349
|
+
* @param {RenderContext} renderContext - The render context.
|
|
350
|
+
* @param {Object} colorAttachmentsConfig - Configuration object for the color attachments.
|
|
351
|
+
* @return {Object} The render pass descriptor.
|
|
352
|
+
*/
|
|
353
|
+
_getRenderPassDescriptor( renderContext, colorAttachmentsConfig = {} ) {
|
|
210
354
|
|
|
211
355
|
const renderTarget = renderContext.renderTarget;
|
|
212
356
|
const renderTargetData = this.get( renderTarget );
|
|
@@ -216,8 +360,11 @@ class WebGPUBackend extends Backend {
|
|
|
216
360
|
if ( descriptors === undefined ||
|
|
217
361
|
renderTargetData.width !== renderTarget.width ||
|
|
218
362
|
renderTargetData.height !== renderTarget.height ||
|
|
363
|
+
renderTargetData.dimensions !== renderTarget.dimensions ||
|
|
219
364
|
renderTargetData.activeMipmapLevel !== renderTarget.activeMipmapLevel ||
|
|
220
|
-
renderTargetData.
|
|
365
|
+
renderTargetData.activeCubeFace !== renderContext.activeCubeFace ||
|
|
366
|
+
renderTargetData.samples !== renderTarget.samples ||
|
|
367
|
+
renderTargetData.loadOp !== colorAttachmentsConfig.loadOp
|
|
221
368
|
) {
|
|
222
369
|
|
|
223
370
|
descriptors = {};
|
|
@@ -247,16 +394,37 @@ class WebGPUBackend extends Backend {
|
|
|
247
394
|
const textures = renderContext.textures;
|
|
248
395
|
const colorAttachments = [];
|
|
249
396
|
|
|
397
|
+
let sliceIndex;
|
|
398
|
+
|
|
250
399
|
for ( let i = 0; i < textures.length; i ++ ) {
|
|
251
400
|
|
|
252
401
|
const textureData = this.get( textures[ i ] );
|
|
253
402
|
|
|
254
|
-
const
|
|
403
|
+
const viewDescriptor = {
|
|
404
|
+
label: `colorAttachment_${ i }`,
|
|
255
405
|
baseMipLevel: renderContext.activeMipmapLevel,
|
|
256
406
|
mipLevelCount: 1,
|
|
257
407
|
baseArrayLayer: renderContext.activeCubeFace,
|
|
408
|
+
arrayLayerCount: 1,
|
|
258
409
|
dimension: GPUTextureViewDimension.TwoD
|
|
259
|
-
}
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
if ( renderTarget.isRenderTarget3D ) {
|
|
413
|
+
|
|
414
|
+
sliceIndex = renderContext.activeCubeFace;
|
|
415
|
+
|
|
416
|
+
viewDescriptor.baseArrayLayer = 0;
|
|
417
|
+
viewDescriptor.dimension = GPUTextureViewDimension.ThreeD;
|
|
418
|
+
viewDescriptor.depthOrArrayLayers = textures[ i ].image.depth;
|
|
419
|
+
|
|
420
|
+
} else if ( renderTarget.isRenderTargetArray ) {
|
|
421
|
+
|
|
422
|
+
viewDescriptor.dimension = GPUTextureViewDimension.TwoDArray;
|
|
423
|
+
viewDescriptor.depthOrArrayLayers = textures[ i ].image.depth;
|
|
424
|
+
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
const textureView = textureData.texture.createView( viewDescriptor );
|
|
260
428
|
|
|
261
429
|
let view, resolveTarget;
|
|
262
430
|
|
|
@@ -274,9 +442,11 @@ class WebGPUBackend extends Backend {
|
|
|
274
442
|
|
|
275
443
|
colorAttachments.push( {
|
|
276
444
|
view,
|
|
445
|
+
depthSlice: sliceIndex,
|
|
277
446
|
resolveTarget,
|
|
278
447
|
loadOp: GPULoadOp.Load,
|
|
279
|
-
storeOp: GPUStoreOp.Store
|
|
448
|
+
storeOp: GPUStoreOp.Store,
|
|
449
|
+
...colorAttachmentsConfig
|
|
280
450
|
} );
|
|
281
451
|
|
|
282
452
|
}
|
|
@@ -302,7 +472,11 @@ class WebGPUBackend extends Backend {
|
|
|
302
472
|
renderTargetData.width = renderTarget.width;
|
|
303
473
|
renderTargetData.height = renderTarget.height;
|
|
304
474
|
renderTargetData.samples = renderTarget.samples;
|
|
305
|
-
renderTargetData.activeMipmapLevel =
|
|
475
|
+
renderTargetData.activeMipmapLevel = renderContext.activeMipmapLevel;
|
|
476
|
+
renderTargetData.activeCubeFace = renderContext.activeCubeFace;
|
|
477
|
+
renderTargetData.dimensions = renderTarget.dimensions;
|
|
478
|
+
renderTargetData.depthSlice = sliceIndex;
|
|
479
|
+
renderTargetData.loadOp = colorAttachments[ 0 ].loadOp;
|
|
306
480
|
|
|
307
481
|
}
|
|
308
482
|
|
|
@@ -310,6 +484,12 @@ class WebGPUBackend extends Backend {
|
|
|
310
484
|
|
|
311
485
|
}
|
|
312
486
|
|
|
487
|
+
/**
|
|
488
|
+
* This method is executed at the beginning of a render call and prepares
|
|
489
|
+
* the WebGPU state for upcoming render calls
|
|
490
|
+
*
|
|
491
|
+
* @param {RenderContext} renderContext - The render context.
|
|
492
|
+
*/
|
|
313
493
|
beginRender( renderContext ) {
|
|
314
494
|
|
|
315
495
|
const renderContextData = this.get( renderContext );
|
|
@@ -350,7 +530,7 @@ class WebGPUBackend extends Backend {
|
|
|
350
530
|
|
|
351
531
|
} else {
|
|
352
532
|
|
|
353
|
-
descriptor = this._getRenderPassDescriptor( renderContext );
|
|
533
|
+
descriptor = this._getRenderPassDescriptor( renderContext, { loadOp: GPULoadOp.Load } );
|
|
354
534
|
|
|
355
535
|
}
|
|
356
536
|
|
|
@@ -469,6 +649,12 @@ class WebGPUBackend extends Backend {
|
|
|
469
649
|
|
|
470
650
|
}
|
|
471
651
|
|
|
652
|
+
/**
|
|
653
|
+
* This method is executed at the end of a render call and finalizes work
|
|
654
|
+
* after draw calls.
|
|
655
|
+
*
|
|
656
|
+
* @param {RenderContext} renderContext - The render context.
|
|
657
|
+
*/
|
|
472
658
|
finishRender( renderContext ) {
|
|
473
659
|
|
|
474
660
|
const renderContextData = this.get( renderContext );
|
|
@@ -557,6 +743,14 @@ class WebGPUBackend extends Backend {
|
|
|
557
743
|
|
|
558
744
|
}
|
|
559
745
|
|
|
746
|
+
/**
|
|
747
|
+
* Returns `true` if the given 3D object is fully occluded by other
|
|
748
|
+
* 3D objects in the scene.
|
|
749
|
+
*
|
|
750
|
+
* @param {RenderContext} renderContext - The render context.
|
|
751
|
+
* @param {Object3D} object - The 3D object to test.
|
|
752
|
+
* @return {Boolean} Whether the 3D object is fully occluded or not.
|
|
753
|
+
*/
|
|
560
754
|
isOccluded( renderContext, object ) {
|
|
561
755
|
|
|
562
756
|
const renderContextData = this.get( renderContext );
|
|
@@ -565,6 +759,13 @@ class WebGPUBackend extends Backend {
|
|
|
565
759
|
|
|
566
760
|
}
|
|
567
761
|
|
|
762
|
+
/**
|
|
763
|
+
* This method processes the result of occlusion queries and writes it
|
|
764
|
+
* into render context data.
|
|
765
|
+
*
|
|
766
|
+
* @async
|
|
767
|
+
* @param {RenderContext} renderContext - The render context.
|
|
768
|
+
*/
|
|
568
769
|
async resolveOccludedAsync( renderContext ) {
|
|
569
770
|
|
|
570
771
|
const renderContextData = this.get( renderContext );
|
|
@@ -603,6 +804,11 @@ class WebGPUBackend extends Backend {
|
|
|
603
804
|
|
|
604
805
|
}
|
|
605
806
|
|
|
807
|
+
/**
|
|
808
|
+
* Updates the viewport with the values from the given render context.
|
|
809
|
+
*
|
|
810
|
+
* @param {RenderContext} renderContext - The render context.
|
|
811
|
+
*/
|
|
606
812
|
updateViewport( renderContext ) {
|
|
607
813
|
|
|
608
814
|
const { currentPass } = this.get( renderContext );
|
|
@@ -612,7 +818,15 @@ class WebGPUBackend extends Backend {
|
|
|
612
818
|
|
|
613
819
|
}
|
|
614
820
|
|
|
615
|
-
|
|
821
|
+
/**
|
|
822
|
+
* Performs a clear operation.
|
|
823
|
+
*
|
|
824
|
+
* @param {Boolean} color - Whether the color buffer should be cleared or not.
|
|
825
|
+
* @param {Boolean} depth - Whether the depth buffer should be cleared or not.
|
|
826
|
+
* @param {Boolean} stencil - Whether the stencil buffer should be cleared or not.
|
|
827
|
+
* @param {RenderContext?} [renderTargetContext=null] - The render context of the current set render target.
|
|
828
|
+
*/
|
|
829
|
+
clear( color, depth, stencil, renderTargetContext = null ) {
|
|
616
830
|
|
|
617
831
|
const device = this.device;
|
|
618
832
|
const renderer = this.renderer;
|
|
@@ -645,7 +859,7 @@ class WebGPUBackend extends Backend {
|
|
|
645
859
|
|
|
646
860
|
}
|
|
647
861
|
|
|
648
|
-
if (
|
|
862
|
+
if ( renderTargetContext === null ) {
|
|
649
863
|
|
|
650
864
|
supportsDepth = renderer.depth;
|
|
651
865
|
supportsStencil = renderer.stencil;
|
|
@@ -672,45 +886,20 @@ class WebGPUBackend extends Backend {
|
|
|
672
886
|
|
|
673
887
|
} else {
|
|
674
888
|
|
|
675
|
-
supportsDepth =
|
|
676
|
-
supportsStencil =
|
|
889
|
+
supportsDepth = renderTargetContext.depth;
|
|
890
|
+
supportsStencil = renderTargetContext.stencil;
|
|
677
891
|
|
|
678
892
|
if ( color ) {
|
|
679
893
|
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
const textureData = this.get( texture );
|
|
683
|
-
const textureView = textureData.texture.createView();
|
|
684
|
-
|
|
685
|
-
let view, resolveTarget;
|
|
894
|
+
const descriptor = this._getRenderPassDescriptor( renderTargetContext, { loadOp: GPULoadOp.Clear } );
|
|
686
895
|
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
view = textureData.msaaTexture.createView();
|
|
690
|
-
resolveTarget = textureView;
|
|
691
|
-
|
|
692
|
-
} else {
|
|
693
|
-
|
|
694
|
-
view = textureView;
|
|
695
|
-
resolveTarget = undefined;
|
|
696
|
-
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
colorAttachments.push( {
|
|
700
|
-
view,
|
|
701
|
-
resolveTarget,
|
|
702
|
-
clearValue,
|
|
703
|
-
loadOp: GPULoadOp.Clear,
|
|
704
|
-
storeOp: GPUStoreOp.Store
|
|
705
|
-
} );
|
|
706
|
-
|
|
707
|
-
}
|
|
896
|
+
colorAttachments = descriptor.colorAttachments;
|
|
708
897
|
|
|
709
898
|
}
|
|
710
899
|
|
|
711
900
|
if ( supportsDepth || supportsStencil ) {
|
|
712
901
|
|
|
713
|
-
const depthTextureData = this.get(
|
|
902
|
+
const depthTextureData = this.get( renderTargetContext.depthTexture );
|
|
714
903
|
|
|
715
904
|
depthStencilAttachment = {
|
|
716
905
|
view: depthTextureData.texture.createView()
|
|
@@ -774,6 +963,12 @@ class WebGPUBackend extends Backend {
|
|
|
774
963
|
|
|
775
964
|
// compute
|
|
776
965
|
|
|
966
|
+
/**
|
|
967
|
+
* This method is executed at the beginning of a compute call and
|
|
968
|
+
* prepares the state for upcoming compute tasks.
|
|
969
|
+
*
|
|
970
|
+
* @param {Node|Array<Node>} computeGroup - The compute node(s).
|
|
971
|
+
*/
|
|
777
972
|
beginCompute( computeGroup ) {
|
|
778
973
|
|
|
779
974
|
const groupGPU = this.get( computeGroup );
|
|
@@ -789,6 +984,14 @@ class WebGPUBackend extends Backend {
|
|
|
789
984
|
|
|
790
985
|
}
|
|
791
986
|
|
|
987
|
+
/**
|
|
988
|
+
* Executes a compute command for the given compute node.
|
|
989
|
+
*
|
|
990
|
+
* @param {Node|Array<Node>} computeGroup - The group of compute nodes of a compute call. Can be a single compute node.
|
|
991
|
+
* @param {Node} computeNode - The compute node.
|
|
992
|
+
* @param {Array<BindGroup>} bindings - The bindings.
|
|
993
|
+
* @param {ComputePipeline} pipeline - The compute pipeline.
|
|
994
|
+
*/
|
|
792
995
|
compute( computeGroup, computeNode, bindings, pipeline ) {
|
|
793
996
|
|
|
794
997
|
const { passEncoderGPU } = this.get( computeGroup );
|
|
@@ -836,6 +1039,12 @@ class WebGPUBackend extends Backend {
|
|
|
836
1039
|
|
|
837
1040
|
}
|
|
838
1041
|
|
|
1042
|
+
/**
|
|
1043
|
+
* This method is executed at the end of a compute call and
|
|
1044
|
+
* finalizes work after compute tasks.
|
|
1045
|
+
*
|
|
1046
|
+
* @param {Node|Array<Node>} computeGroup - The compute node(s).
|
|
1047
|
+
*/
|
|
839
1048
|
finishCompute( computeGroup ) {
|
|
840
1049
|
|
|
841
1050
|
const groupData = this.get( computeGroup );
|
|
@@ -848,6 +1057,13 @@ class WebGPUBackend extends Backend {
|
|
|
848
1057
|
|
|
849
1058
|
}
|
|
850
1059
|
|
|
1060
|
+
/**
|
|
1061
|
+
* Can be used to synchronize CPU operations with GPU tasks. So when this method is called,
|
|
1062
|
+
* the CPU waits for the GPU to complete its operation (e.g. a compute task).
|
|
1063
|
+
*
|
|
1064
|
+
* @async
|
|
1065
|
+
* @return {Promise} A Promise that resolves when synchronization has been finished.
|
|
1066
|
+
*/
|
|
851
1067
|
async waitForGPU() {
|
|
852
1068
|
|
|
853
1069
|
await this.device.queue.onSubmittedWorkDone();
|
|
@@ -856,6 +1072,12 @@ class WebGPUBackend extends Backend {
|
|
|
856
1072
|
|
|
857
1073
|
// render object
|
|
858
1074
|
|
|
1075
|
+
/**
|
|
1076
|
+
* Executes a draw command for the given render object.
|
|
1077
|
+
*
|
|
1078
|
+
* @param {RenderObject} renderObject - The render object to draw.
|
|
1079
|
+
* @param {Info} info - Holds a series of statistical information about the GPU memory and the rendering process.
|
|
1080
|
+
*/
|
|
859
1081
|
draw( renderObject, info ) {
|
|
860
1082
|
|
|
861
1083
|
const { object, context, pipeline } = renderObject;
|
|
@@ -976,14 +1198,20 @@ class WebGPUBackend extends Backend {
|
|
|
976
1198
|
const drawCount = object._multiDrawCount;
|
|
977
1199
|
const drawInstances = object._multiDrawInstances;
|
|
978
1200
|
|
|
979
|
-
const bytesPerElement = hasIndex ? index.array.BYTES_PER_ELEMENT : 1;
|
|
980
|
-
|
|
981
1201
|
for ( let i = 0; i < drawCount; i ++ ) {
|
|
982
1202
|
|
|
983
1203
|
const count = drawInstances ? drawInstances[ i ] : 1;
|
|
984
1204
|
const firstInstance = count > 1 ? 0 : i;
|
|
985
1205
|
|
|
986
|
-
|
|
1206
|
+
if ( hasIndex === true ) {
|
|
1207
|
+
|
|
1208
|
+
passEncoderGPU.drawIndexed( counts[ i ], count, starts[ i ] / index.array.BYTES_PER_ELEMENT, 0, firstInstance );
|
|
1209
|
+
|
|
1210
|
+
} else {
|
|
1211
|
+
|
|
1212
|
+
passEncoderGPU.draw( counts[ i ], count, starts[ i ], firstInstance );
|
|
1213
|
+
|
|
1214
|
+
}
|
|
987
1215
|
|
|
988
1216
|
}
|
|
989
1217
|
|
|
@@ -1033,6 +1261,12 @@ class WebGPUBackend extends Backend {
|
|
|
1033
1261
|
|
|
1034
1262
|
// cache key
|
|
1035
1263
|
|
|
1264
|
+
/**
|
|
1265
|
+
* Returns `true` if the render pipeline requires an update.
|
|
1266
|
+
*
|
|
1267
|
+
* @param {RenderObject} renderObject - The render object.
|
|
1268
|
+
* @return {Boolean} Whether the render pipeline requires an update or not.
|
|
1269
|
+
*/
|
|
1036
1270
|
needsRenderUpdate( renderObject ) {
|
|
1037
1271
|
|
|
1038
1272
|
const data = this.get( renderObject );
|
|
@@ -1089,6 +1323,12 @@ class WebGPUBackend extends Backend {
|
|
|
1089
1323
|
|
|
1090
1324
|
}
|
|
1091
1325
|
|
|
1326
|
+
/**
|
|
1327
|
+
* Returns a cache key that is used to identify render pipelines.
|
|
1328
|
+
*
|
|
1329
|
+
* @param {RenderObject} renderObject - The render object.
|
|
1330
|
+
* @return {String} The cache key.
|
|
1331
|
+
*/
|
|
1092
1332
|
getRenderCacheKey( renderObject ) {
|
|
1093
1333
|
|
|
1094
1334
|
const { object, material } = renderObject;
|
|
@@ -1117,55 +1357,109 @@ class WebGPUBackend extends Backend {
|
|
|
1117
1357
|
|
|
1118
1358
|
// textures
|
|
1119
1359
|
|
|
1360
|
+
/**
|
|
1361
|
+
* Creates a sampler for the given texture.
|
|
1362
|
+
*
|
|
1363
|
+
* @param {Texture} texture - The texture to create the sampler for.
|
|
1364
|
+
*/
|
|
1120
1365
|
createSampler( texture ) {
|
|
1121
1366
|
|
|
1122
1367
|
this.textureUtils.createSampler( texture );
|
|
1123
1368
|
|
|
1124
1369
|
}
|
|
1125
1370
|
|
|
1371
|
+
/**
|
|
1372
|
+
* Destroys the sampler for the given texture.
|
|
1373
|
+
*
|
|
1374
|
+
* @param {Texture} texture - The texture to destroy the sampler for.
|
|
1375
|
+
*/
|
|
1126
1376
|
destroySampler( texture ) {
|
|
1127
1377
|
|
|
1128
1378
|
this.textureUtils.destroySampler( texture );
|
|
1129
1379
|
|
|
1130
1380
|
}
|
|
1131
1381
|
|
|
1382
|
+
/**
|
|
1383
|
+
* Creates a default texture for the given texture that can be used
|
|
1384
|
+
* as a placeholder until the actual texture is ready for usage.
|
|
1385
|
+
*
|
|
1386
|
+
* @param {Texture} texture - The texture to create a default texture for.
|
|
1387
|
+
*/
|
|
1132
1388
|
createDefaultTexture( texture ) {
|
|
1133
1389
|
|
|
1134
1390
|
this.textureUtils.createDefaultTexture( texture );
|
|
1135
1391
|
|
|
1136
1392
|
}
|
|
1137
1393
|
|
|
1394
|
+
/**
|
|
1395
|
+
* Defines a texture on the GPU for the given texture object.
|
|
1396
|
+
*
|
|
1397
|
+
* @param {Texture} texture - The texture.
|
|
1398
|
+
* @param {Object} [options={}] - Optional configuration parameter.
|
|
1399
|
+
*/
|
|
1138
1400
|
createTexture( texture, options ) {
|
|
1139
1401
|
|
|
1140
1402
|
this.textureUtils.createTexture( texture, options );
|
|
1141
1403
|
|
|
1142
1404
|
}
|
|
1143
1405
|
|
|
1406
|
+
/**
|
|
1407
|
+
* Uploads the updated texture data to the GPU.
|
|
1408
|
+
*
|
|
1409
|
+
* @param {Texture} texture - The texture.
|
|
1410
|
+
* @param {Object} [options={}] - Optional configuration parameter.
|
|
1411
|
+
*/
|
|
1144
1412
|
updateTexture( texture, options ) {
|
|
1145
1413
|
|
|
1146
1414
|
this.textureUtils.updateTexture( texture, options );
|
|
1147
1415
|
|
|
1148
1416
|
}
|
|
1149
1417
|
|
|
1418
|
+
/**
|
|
1419
|
+
* Generates mipmaps for the given texture
|
|
1420
|
+
*
|
|
1421
|
+
* @param {Texture} texture - The texture.
|
|
1422
|
+
*/
|
|
1150
1423
|
generateMipmaps( texture ) {
|
|
1151
1424
|
|
|
1152
1425
|
this.textureUtils.generateMipmaps( texture );
|
|
1153
1426
|
|
|
1154
1427
|
}
|
|
1155
1428
|
|
|
1429
|
+
/**
|
|
1430
|
+
* Destroys the GPU data for the given texture object.
|
|
1431
|
+
*
|
|
1432
|
+
* @param {Texture} texture - The texture.
|
|
1433
|
+
*/
|
|
1156
1434
|
destroyTexture( texture ) {
|
|
1157
1435
|
|
|
1158
1436
|
this.textureUtils.destroyTexture( texture );
|
|
1159
1437
|
|
|
1160
1438
|
}
|
|
1161
1439
|
|
|
1440
|
+
/**
|
|
1441
|
+
* Returns texture data as a typed array.
|
|
1442
|
+
*
|
|
1443
|
+
* @param {Texture} texture - The texture to copy.
|
|
1444
|
+
* @param {Number} x - The x coordinate of the copy origin.
|
|
1445
|
+
* @param {Number} y - The y coordinate of the copy origin.
|
|
1446
|
+
* @param {Number} width - The width of the copy.
|
|
1447
|
+
* @param {Number} height - The height of the copy.
|
|
1448
|
+
* @param {Number} faceIndex - The face index.
|
|
1449
|
+
* @return {TypedArray} The texture data as a typed array.
|
|
1450
|
+
*/
|
|
1162
1451
|
copyTextureToBuffer( texture, x, y, width, height, faceIndex ) {
|
|
1163
1452
|
|
|
1164
1453
|
return this.textureUtils.copyTextureToBuffer( texture, x, y, width, height, faceIndex );
|
|
1165
1454
|
|
|
1166
1455
|
}
|
|
1167
1456
|
|
|
1168
|
-
|
|
1457
|
+
/**
|
|
1458
|
+
* Inits a time stamp query for the given render context.
|
|
1459
|
+
*
|
|
1460
|
+
* @param {RenderContext} renderContext - The render context.
|
|
1461
|
+
* @param {Object} descriptor - The query descriptor.
|
|
1462
|
+
*/
|
|
1169
1463
|
initTimestampQuery( renderContext, descriptor ) {
|
|
1170
1464
|
|
|
1171
1465
|
if ( ! this.trackTimestamp ) return;
|
|
@@ -1192,8 +1486,12 @@ class WebGPUBackend extends Backend {
|
|
|
1192
1486
|
|
|
1193
1487
|
}
|
|
1194
1488
|
|
|
1195
|
-
|
|
1196
|
-
|
|
1489
|
+
/**
|
|
1490
|
+
* Prepares the timestamp buffer.
|
|
1491
|
+
*
|
|
1492
|
+
* @param {RenderContext} renderContext - The render context.
|
|
1493
|
+
* @param {GPUCommandEncoder} encoder - The command encoder.
|
|
1494
|
+
*/
|
|
1197
1495
|
prepareTimestampBuffer( renderContext, encoder ) {
|
|
1198
1496
|
|
|
1199
1497
|
if ( ! this.trackTimestamp ) return;
|
|
@@ -1233,6 +1531,14 @@ class WebGPUBackend extends Backend {
|
|
|
1233
1531
|
|
|
1234
1532
|
}
|
|
1235
1533
|
|
|
1534
|
+
/**
|
|
1535
|
+
* Resolves the time stamp for the given render context and type.
|
|
1536
|
+
*
|
|
1537
|
+
* @async
|
|
1538
|
+
* @param {RenderContext} renderContext - The render context.
|
|
1539
|
+
* @param {String} type - The render context.
|
|
1540
|
+
* @return {Promise} A Promise that resolves when the time stamp has been computed.
|
|
1541
|
+
*/
|
|
1236
1542
|
async resolveTimestampAsync( renderContext, type = 'render' ) {
|
|
1237
1543
|
|
|
1238
1544
|
if ( ! this.trackTimestamp ) return;
|
|
@@ -1243,8 +1549,6 @@ class WebGPUBackend extends Backend {
|
|
|
1243
1549
|
|
|
1244
1550
|
const { resultBuffer } = renderContextData.currentTimestampQueryBuffers;
|
|
1245
1551
|
|
|
1246
|
-
await this.device.queue.onSubmittedWorkDone();
|
|
1247
|
-
|
|
1248
1552
|
if ( resultBuffer.mapState === 'unmapped' ) {
|
|
1249
1553
|
|
|
1250
1554
|
resultBuffer.mapAsync( GPUMapMode.READ ).then( () => {
|
|
@@ -1266,6 +1570,13 @@ class WebGPUBackend extends Backend {
|
|
|
1266
1570
|
|
|
1267
1571
|
// node builder
|
|
1268
1572
|
|
|
1573
|
+
/**
|
|
1574
|
+
* Returns a node builder for the given render object.
|
|
1575
|
+
*
|
|
1576
|
+
* @param {RenderObject} object - The render object.
|
|
1577
|
+
* @param {Renderer} renderer - The renderer.
|
|
1578
|
+
* @return {WGSLNodeBuilder} The node builder.
|
|
1579
|
+
*/
|
|
1269
1580
|
createNodeBuilder( object, renderer ) {
|
|
1270
1581
|
|
|
1271
1582
|
return new WGSLNodeBuilder( object, renderer );
|
|
@@ -1274,17 +1585,27 @@ class WebGPUBackend extends Backend {
|
|
|
1274
1585
|
|
|
1275
1586
|
// program
|
|
1276
1587
|
|
|
1588
|
+
/**
|
|
1589
|
+
* Creates a shader program from the given programmable stage.
|
|
1590
|
+
*
|
|
1591
|
+
* @param {ProgrammableStage} program - The programmable stage.
|
|
1592
|
+
*/
|
|
1277
1593
|
createProgram( program ) {
|
|
1278
1594
|
|
|
1279
1595
|
const programGPU = this.get( program );
|
|
1280
1596
|
|
|
1281
1597
|
programGPU.module = {
|
|
1282
|
-
module: this.device.createShaderModule( { code: program.code, label: program.stage } ),
|
|
1598
|
+
module: this.device.createShaderModule( { code: program.code, label: program.stage + ( program.name !== '' ? `_${ program.name }` : '' ) } ),
|
|
1283
1599
|
entryPoint: 'main'
|
|
1284
1600
|
};
|
|
1285
1601
|
|
|
1286
1602
|
}
|
|
1287
1603
|
|
|
1604
|
+
/**
|
|
1605
|
+
* Destroys the shader program of the given programmable stage.
|
|
1606
|
+
*
|
|
1607
|
+
* @param {ProgrammableStage} program - The programmable stage.
|
|
1608
|
+
*/
|
|
1288
1609
|
destroyProgram( program ) {
|
|
1289
1610
|
|
|
1290
1611
|
this.delete( program );
|
|
@@ -1293,18 +1614,35 @@ class WebGPUBackend extends Backend {
|
|
|
1293
1614
|
|
|
1294
1615
|
// pipelines
|
|
1295
1616
|
|
|
1617
|
+
/**
|
|
1618
|
+
* Creates a render pipeline for the given render object.
|
|
1619
|
+
*
|
|
1620
|
+
* @param {RenderObject} renderObject - The render object.
|
|
1621
|
+
* @param {Array<Promise>} promises - An array of compilation promises which are used in `compileAsync()`.
|
|
1622
|
+
*/
|
|
1296
1623
|
createRenderPipeline( renderObject, promises ) {
|
|
1297
1624
|
|
|
1298
1625
|
this.pipelineUtils.createRenderPipeline( renderObject, promises );
|
|
1299
1626
|
|
|
1300
1627
|
}
|
|
1301
1628
|
|
|
1629
|
+
/**
|
|
1630
|
+
* Creates a compute pipeline for the given compute node.
|
|
1631
|
+
*
|
|
1632
|
+
* @param {ComputePipeline} computePipeline - The compute pipeline.
|
|
1633
|
+
* @param {Array<BindGroup>} bindings - The bindings.
|
|
1634
|
+
*/
|
|
1302
1635
|
createComputePipeline( computePipeline, bindings ) {
|
|
1303
1636
|
|
|
1304
1637
|
this.pipelineUtils.createComputePipeline( computePipeline, bindings );
|
|
1305
1638
|
|
|
1306
1639
|
}
|
|
1307
1640
|
|
|
1641
|
+
/**
|
|
1642
|
+
* Prepares the state for encoding render bundles.
|
|
1643
|
+
*
|
|
1644
|
+
* @param {RenderContext} renderContext - The render context.
|
|
1645
|
+
*/
|
|
1308
1646
|
beginBundle( renderContext ) {
|
|
1309
1647
|
|
|
1310
1648
|
const renderContextData = this.get( renderContext );
|
|
@@ -1317,6 +1655,12 @@ class WebGPUBackend extends Backend {
|
|
|
1317
1655
|
|
|
1318
1656
|
}
|
|
1319
1657
|
|
|
1658
|
+
/**
|
|
1659
|
+
* After processing render bundles this method finalizes related work.
|
|
1660
|
+
*
|
|
1661
|
+
* @param {RenderContext} renderContext - The render context.
|
|
1662
|
+
* @param {RenderBundle} bundle - The render bundle.
|
|
1663
|
+
*/
|
|
1320
1664
|
finishBundle( renderContext, bundle ) {
|
|
1321
1665
|
|
|
1322
1666
|
const renderContextData = this.get( renderContext );
|
|
@@ -1333,6 +1677,12 @@ class WebGPUBackend extends Backend {
|
|
|
1333
1677
|
|
|
1334
1678
|
}
|
|
1335
1679
|
|
|
1680
|
+
/**
|
|
1681
|
+
* Adds a render bundle to the render context data.
|
|
1682
|
+
*
|
|
1683
|
+
* @param {RenderContext} renderContext - The render context.
|
|
1684
|
+
* @param {RenderBundle} bundle - The render bundle to add.
|
|
1685
|
+
*/
|
|
1336
1686
|
addBundle( renderContext, bundle ) {
|
|
1337
1687
|
|
|
1338
1688
|
const renderContextData = this.get( renderContext );
|
|
@@ -1343,18 +1693,39 @@ class WebGPUBackend extends Backend {
|
|
|
1343
1693
|
|
|
1344
1694
|
// bindings
|
|
1345
1695
|
|
|
1696
|
+
/**
|
|
1697
|
+
* Creates bindings from the given bind group definition.
|
|
1698
|
+
*
|
|
1699
|
+
* @param {BindGroup} bindGroup - The bind group.
|
|
1700
|
+
* @param {Array<BindGroup>} bindings - Array of bind groups.
|
|
1701
|
+
* @param {Number} cacheIndex - The cache index.
|
|
1702
|
+
* @param {Number} version - The version.
|
|
1703
|
+
*/
|
|
1346
1704
|
createBindings( bindGroup, bindings, cacheIndex, version ) {
|
|
1347
1705
|
|
|
1348
1706
|
this.bindingUtils.createBindings( bindGroup, bindings, cacheIndex, version );
|
|
1349
1707
|
|
|
1350
1708
|
}
|
|
1351
1709
|
|
|
1710
|
+
/**
|
|
1711
|
+
* Updates the given bind group definition.
|
|
1712
|
+
*
|
|
1713
|
+
* @param {BindGroup} bindGroup - The bind group.
|
|
1714
|
+
* @param {Array<BindGroup>} bindings - Array of bind groups.
|
|
1715
|
+
* @param {Number} cacheIndex - The cache index.
|
|
1716
|
+
* @param {Number} version - The version.
|
|
1717
|
+
*/
|
|
1352
1718
|
updateBindings( bindGroup, bindings, cacheIndex, version ) {
|
|
1353
1719
|
|
|
1354
1720
|
this.bindingUtils.createBindings( bindGroup, bindings, cacheIndex, version );
|
|
1355
1721
|
|
|
1356
1722
|
}
|
|
1357
1723
|
|
|
1724
|
+
/**
|
|
1725
|
+
* Updates a buffer binding.
|
|
1726
|
+
*
|
|
1727
|
+
* @param {Buffer} binding - The buffer binding to update.
|
|
1728
|
+
*/
|
|
1358
1729
|
updateBinding( binding ) {
|
|
1359
1730
|
|
|
1360
1731
|
this.bindingUtils.updateBinding( binding );
|
|
@@ -1363,36 +1734,66 @@ class WebGPUBackend extends Backend {
|
|
|
1363
1734
|
|
|
1364
1735
|
// attributes
|
|
1365
1736
|
|
|
1737
|
+
/**
|
|
1738
|
+
* Creates the buffer of an indexed shader attribute.
|
|
1739
|
+
*
|
|
1740
|
+
* @param {BufferAttribute} attribute - The indexed buffer attribute.
|
|
1741
|
+
*/
|
|
1366
1742
|
createIndexAttribute( attribute ) {
|
|
1367
1743
|
|
|
1368
1744
|
this.attributeUtils.createAttribute( attribute, GPUBufferUsage.INDEX | GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST );
|
|
1369
1745
|
|
|
1370
1746
|
}
|
|
1371
1747
|
|
|
1748
|
+
/**
|
|
1749
|
+
* Creates the buffer of a shader attribute.
|
|
1750
|
+
*
|
|
1751
|
+
* @param {BufferAttribute} attribute - The buffer attribute.
|
|
1752
|
+
*/
|
|
1372
1753
|
createAttribute( attribute ) {
|
|
1373
1754
|
|
|
1374
1755
|
this.attributeUtils.createAttribute( attribute, GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST );
|
|
1375
1756
|
|
|
1376
1757
|
}
|
|
1377
1758
|
|
|
1759
|
+
/**
|
|
1760
|
+
* Creates the buffer of a storage attribute.
|
|
1761
|
+
*
|
|
1762
|
+
* @param {BufferAttribute} attribute - The buffer attribute.
|
|
1763
|
+
*/
|
|
1378
1764
|
createStorageAttribute( attribute ) {
|
|
1379
1765
|
|
|
1380
1766
|
this.attributeUtils.createAttribute( attribute, GPUBufferUsage.STORAGE | GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST );
|
|
1381
1767
|
|
|
1382
1768
|
}
|
|
1383
1769
|
|
|
1770
|
+
/**
|
|
1771
|
+
* Creates the buffer of an indirect storage attribute.
|
|
1772
|
+
*
|
|
1773
|
+
* @param {BufferAttribute} attribute - The buffer attribute.
|
|
1774
|
+
*/
|
|
1384
1775
|
createIndirectStorageAttribute( attribute ) {
|
|
1385
1776
|
|
|
1386
1777
|
this.attributeUtils.createAttribute( attribute, GPUBufferUsage.STORAGE | GPUBufferUsage.INDIRECT | GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST );
|
|
1387
1778
|
|
|
1388
1779
|
}
|
|
1389
1780
|
|
|
1781
|
+
/**
|
|
1782
|
+
* Updates the buffer of a shader attribute.
|
|
1783
|
+
*
|
|
1784
|
+
* @param {BufferAttribute} attribute - The buffer attribute to update.
|
|
1785
|
+
*/
|
|
1390
1786
|
updateAttribute( attribute ) {
|
|
1391
1787
|
|
|
1392
1788
|
this.attributeUtils.updateAttribute( attribute );
|
|
1393
1789
|
|
|
1394
1790
|
}
|
|
1395
1791
|
|
|
1792
|
+
/**
|
|
1793
|
+
* Destroys the buffer of a shader attribute.
|
|
1794
|
+
*
|
|
1795
|
+
* @param {BufferAttribute} attribute - The buffer attribute to destroy.
|
|
1796
|
+
*/
|
|
1396
1797
|
destroyAttribute( attribute ) {
|
|
1397
1798
|
|
|
1398
1799
|
this.attributeUtils.destroyAttribute( attribute );
|
|
@@ -1401,6 +1802,9 @@ class WebGPUBackend extends Backend {
|
|
|
1401
1802
|
|
|
1402
1803
|
// canvas
|
|
1403
1804
|
|
|
1805
|
+
/**
|
|
1806
|
+
* Triggers an update of the default render pass descriptor.
|
|
1807
|
+
*/
|
|
1404
1808
|
updateSize() {
|
|
1405
1809
|
|
|
1406
1810
|
this.colorBuffer = this.textureUtils.getColorBuffer();
|
|
@@ -1410,18 +1814,38 @@ class WebGPUBackend extends Backend {
|
|
|
1410
1814
|
|
|
1411
1815
|
// utils public
|
|
1412
1816
|
|
|
1817
|
+
/**
|
|
1818
|
+
* Returns the maximum anisotropy texture filtering value.
|
|
1819
|
+
*
|
|
1820
|
+
* @return {Number} The maximum anisotropy texture filtering value.
|
|
1821
|
+
*/
|
|
1413
1822
|
getMaxAnisotropy() {
|
|
1414
1823
|
|
|
1415
1824
|
return 16;
|
|
1416
1825
|
|
|
1417
1826
|
}
|
|
1418
1827
|
|
|
1828
|
+
/**
|
|
1829
|
+
* Checks if the given feature is supported by the backend.
|
|
1830
|
+
*
|
|
1831
|
+
* @param {String} name - The feature's name.
|
|
1832
|
+
* @return {Boolean} Whether the feature is supported or not.
|
|
1833
|
+
*/
|
|
1419
1834
|
hasFeature( name ) {
|
|
1420
1835
|
|
|
1421
1836
|
return this.device.features.has( name );
|
|
1422
1837
|
|
|
1423
1838
|
}
|
|
1424
1839
|
|
|
1840
|
+
/**
|
|
1841
|
+
* Copies data of the given source texture to the given destination texture.
|
|
1842
|
+
*
|
|
1843
|
+
* @param {Texture} srcTexture - The source texture.
|
|
1844
|
+
* @param {Texture} dstTexture - The destination texture.
|
|
1845
|
+
* @param {Vector4?} [srcRegion=null] - The region of the source texture to copy.
|
|
1846
|
+
* @param {(Vector2|Vector3)?} [dstPosition=null] - The destination position of the copy.
|
|
1847
|
+
* @param {Number} [level=0] - The mip level to copy.
|
|
1848
|
+
*/
|
|
1425
1849
|
copyTextureToTexture( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
|
|
1426
1850
|
|
|
1427
1851
|
let dstX = 0;
|
|
@@ -1480,6 +1904,13 @@ class WebGPUBackend extends Backend {
|
|
|
1480
1904
|
|
|
1481
1905
|
}
|
|
1482
1906
|
|
|
1907
|
+
/**
|
|
1908
|
+
* Copies the current bound framebuffer to the given texture.
|
|
1909
|
+
*
|
|
1910
|
+
* @param {Texture} texture - The destination texture.
|
|
1911
|
+
* @param {RenderContext} renderContext - The render context.
|
|
1912
|
+
* @param {Vector4} rectangle - A four dimensional vector defining the origin and dimension of the copy.
|
|
1913
|
+
*/
|
|
1483
1914
|
copyFramebufferToTexture( texture, renderContext, rectangle ) {
|
|
1484
1915
|
|
|
1485
1916
|
const renderContextData = this.get( renderContext );
|