super-three 0.170.1 → 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
|
@@ -1,12 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This renderer module provides a series of statistical information
|
|
3
|
+
* about the GPU memory and the rendering process. Useful for debugging
|
|
4
|
+
* and monitoring.
|
|
5
|
+
*/
|
|
1
6
|
class Info {
|
|
2
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Constructs a new info component.
|
|
10
|
+
*/
|
|
3
11
|
constructor() {
|
|
4
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Whether frame related metrics should automatically
|
|
15
|
+
* be resetted or not. This property should be set to `false`
|
|
16
|
+
* by apps which manage their own animation loop. They must
|
|
17
|
+
* then call `renderer.info.reset()` once per frame manually.
|
|
18
|
+
*
|
|
19
|
+
* @type {Boolean}
|
|
20
|
+
* @default true
|
|
21
|
+
*/
|
|
5
22
|
this.autoReset = true;
|
|
6
23
|
|
|
24
|
+
/**
|
|
25
|
+
* The current frame ID. This ID is managed
|
|
26
|
+
* by `NodeFrame`.
|
|
27
|
+
*
|
|
28
|
+
* @type {Number}
|
|
29
|
+
* @readonly
|
|
30
|
+
* @default 0
|
|
31
|
+
*/
|
|
7
32
|
this.frame = 0;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The number of render calls since the
|
|
36
|
+
* app has been started.
|
|
37
|
+
*
|
|
38
|
+
* @type {Number}
|
|
39
|
+
* @readonly
|
|
40
|
+
* @default 0
|
|
41
|
+
*/
|
|
8
42
|
this.calls = 0;
|
|
9
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Render related metrics.
|
|
46
|
+
*
|
|
47
|
+
* @type {Object}
|
|
48
|
+
* @readonly
|
|
49
|
+
* @property {Number} calls - The number of render calls since the app has been started.
|
|
50
|
+
* @property {Number} frameCalls - The number of render calls of the current frame.
|
|
51
|
+
* @property {Number} drawCalls - The number of draw calls of the current frame.
|
|
52
|
+
* @property {Number} triangles - The number of rendered triangle primitives of the current frame.
|
|
53
|
+
* @property {Number} points - The number of rendered point primitives of the current frame.
|
|
54
|
+
* @property {Number} lines - The number of rendered line primitives of the current frame.
|
|
55
|
+
* @property {Number} previousFrameCalls - The number of render calls of the previous frame.
|
|
56
|
+
* @property {Number} timestamp - The timestamp of the frame when using `renderer.renderAsync()`.
|
|
57
|
+
* @property {Number} timestampCalls - The number of render calls using `renderer.renderAsync()`.
|
|
58
|
+
*/
|
|
10
59
|
this.render = {
|
|
11
60
|
calls: 0,
|
|
12
61
|
frameCalls: 0,
|
|
@@ -19,6 +68,17 @@ class Info {
|
|
|
19
68
|
timestampCalls: 0
|
|
20
69
|
};
|
|
21
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Compute related metrics.
|
|
73
|
+
*
|
|
74
|
+
* @type {Object}
|
|
75
|
+
* @readonly
|
|
76
|
+
* @property {Number} calls - The number of compute calls since the app has been started.
|
|
77
|
+
* @property {Number} frameCalls - The number of compute calls of the current frame.
|
|
78
|
+
* @property {Number} previousFrameCalls - The number of compute calls of the previous frame.
|
|
79
|
+
* @property {Number} timestamp - The timestamp of the frame when using `renderer.computeAsync()`.
|
|
80
|
+
* @property {Number} timestampCalls - The number of render calls using `renderer.computeAsync()`.
|
|
81
|
+
*/
|
|
22
82
|
this.compute = {
|
|
23
83
|
calls: 0,
|
|
24
84
|
frameCalls: 0,
|
|
@@ -27,6 +87,14 @@ class Info {
|
|
|
27
87
|
timestampCalls: 0
|
|
28
88
|
};
|
|
29
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Memory related metrics.
|
|
92
|
+
*
|
|
93
|
+
* @type {Object}
|
|
94
|
+
* @readonly
|
|
95
|
+
* @property {Number} geometries - The number of active geometries.
|
|
96
|
+
* @property {Number} frameCalls - The number of active textures.
|
|
97
|
+
*/
|
|
30
98
|
this.memory = {
|
|
31
99
|
geometries: 0,
|
|
32
100
|
textures: 0
|
|
@@ -34,6 +102,13 @@ class Info {
|
|
|
34
102
|
|
|
35
103
|
}
|
|
36
104
|
|
|
105
|
+
/**
|
|
106
|
+
* This method should be executed per draw call and updates the corresponding metrics.
|
|
107
|
+
*
|
|
108
|
+
* @param {Object3D} object - The 3D object that is going to be rendered.
|
|
109
|
+
* @param {Number} count - The vertex or index count.
|
|
110
|
+
* @param {Number} instanceCount - The instance count.
|
|
111
|
+
*/
|
|
37
112
|
update( object, count, instanceCount ) {
|
|
38
113
|
|
|
39
114
|
this.render.drawCalls ++;
|
|
@@ -62,6 +137,12 @@ class Info {
|
|
|
62
137
|
|
|
63
138
|
}
|
|
64
139
|
|
|
140
|
+
/**
|
|
141
|
+
* Used by async render methods to updated timestamp metrics.
|
|
142
|
+
*
|
|
143
|
+
* @param {('render'|'compute')} type - The type of render call.
|
|
144
|
+
* @param {Number} time - The duration of the compute/render call in milliseconds.
|
|
145
|
+
*/
|
|
65
146
|
updateTimestamp( type, time ) {
|
|
66
147
|
|
|
67
148
|
if ( this[ type ].timestampCalls === 0 ) {
|
|
@@ -85,6 +166,9 @@ class Info {
|
|
|
85
166
|
|
|
86
167
|
}
|
|
87
168
|
|
|
169
|
+
/**
|
|
170
|
+
* Resets frame related metrics.
|
|
171
|
+
*/
|
|
88
172
|
reset() {
|
|
89
173
|
|
|
90
174
|
const previousRenderFrameCalls = this.render.frameCalls;
|
|
@@ -105,6 +189,9 @@ class Info {
|
|
|
105
189
|
|
|
106
190
|
}
|
|
107
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Performs a complete reset of the object.
|
|
194
|
+
*/
|
|
108
195
|
dispose() {
|
|
109
196
|
|
|
110
197
|
this.reset();
|
|
@@ -3,20 +3,46 @@ import ChainMap from './ChainMap.js';
|
|
|
3
3
|
|
|
4
4
|
const _defaultLights = /*@__PURE__*/ new LightsNode();
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* This renderer module manages the lights nodes which are unique
|
|
8
|
+
* per scene and camera combination.
|
|
9
|
+
*
|
|
10
|
+
* The lights node itself is later configured in the render list
|
|
11
|
+
* with the actual lights from the scene.
|
|
12
|
+
*
|
|
13
|
+
* @private
|
|
14
|
+
* @augments ChainMap
|
|
15
|
+
*/
|
|
6
16
|
class Lighting extends ChainMap {
|
|
7
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Constructs a lighting management component.
|
|
20
|
+
*/
|
|
8
21
|
constructor() {
|
|
9
22
|
|
|
10
23
|
super();
|
|
11
24
|
|
|
12
25
|
}
|
|
13
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new lights node for the given array of lights.
|
|
29
|
+
*
|
|
30
|
+
* @param {Array<Light>} lights - The render object.
|
|
31
|
+
* @return {Boolean} Whether if the given render object has an initialized geometry or not.
|
|
32
|
+
*/
|
|
14
33
|
createNode( lights = [] ) {
|
|
15
34
|
|
|
16
35
|
return new LightsNode().setLights( lights );
|
|
17
36
|
|
|
18
37
|
}
|
|
19
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Returns a lights node for the given scene and camera.
|
|
41
|
+
*
|
|
42
|
+
* @param {Scene} scene - The scene.
|
|
43
|
+
* @param {Camera} camera - The camera.
|
|
44
|
+
* @return {LightsNode} The lights node.
|
|
45
|
+
*/
|
|
20
46
|
getNode( scene, camera ) {
|
|
21
47
|
|
|
22
48
|
// ignore post-processing
|
|
@@ -1,9 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abstract class for representing pipelines.
|
|
3
|
+
*
|
|
4
|
+
* @private
|
|
5
|
+
* @abstract
|
|
6
|
+
*/
|
|
1
7
|
class Pipeline {
|
|
2
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Constructs a new pipeline.
|
|
11
|
+
*
|
|
12
|
+
* @param {String} cacheKey - The pipeline's cache key.
|
|
13
|
+
*/
|
|
3
14
|
constructor( cacheKey ) {
|
|
4
15
|
|
|
16
|
+
/**
|
|
17
|
+
* The pipeline's cache key.
|
|
18
|
+
*
|
|
19
|
+
* @type {String}
|
|
20
|
+
*/
|
|
5
21
|
this.cacheKey = cacheKey;
|
|
6
22
|
|
|
23
|
+
/**
|
|
24
|
+
* How often the pipeline is currently in use.
|
|
25
|
+
*
|
|
26
|
+
* @type {Number}
|
|
27
|
+
* @default 0
|
|
28
|
+
*/
|
|
7
29
|
this.usedTimes = 0;
|
|
8
30
|
|
|
9
31
|
}
|
|
@@ -3,18 +3,63 @@ import RenderPipeline from './RenderPipeline.js';
|
|
|
3
3
|
import ComputePipeline from './ComputePipeline.js';
|
|
4
4
|
import ProgrammableStage from './ProgrammableStage.js';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* This renderer module manages the pipelines of the renderer.
|
|
8
|
+
*
|
|
9
|
+
* @private
|
|
10
|
+
* @augments DataMap
|
|
11
|
+
*/
|
|
6
12
|
class Pipelines extends DataMap {
|
|
7
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Constructs a new pipeline management component.
|
|
16
|
+
*
|
|
17
|
+
* @param {Backend} backend - The renderer's backend.
|
|
18
|
+
* @param {Nodes} nodes - Renderer component for managing nodes related logic.
|
|
19
|
+
*/
|
|
8
20
|
constructor( backend, nodes ) {
|
|
9
21
|
|
|
10
22
|
super();
|
|
11
23
|
|
|
24
|
+
/**
|
|
25
|
+
* The renderer's backend.
|
|
26
|
+
*
|
|
27
|
+
* @type {Backend}
|
|
28
|
+
*/
|
|
12
29
|
this.backend = backend;
|
|
13
|
-
this.nodes = nodes;
|
|
14
30
|
|
|
15
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Renderer component for managing nodes related logic.
|
|
33
|
+
*
|
|
34
|
+
* @type {Nodes}
|
|
35
|
+
*/
|
|
36
|
+
this.nodes = nodes;
|
|
16
37
|
|
|
38
|
+
/**
|
|
39
|
+
* A references to the bindings management component.
|
|
40
|
+
* This reference will be set inside the `Bindings`
|
|
41
|
+
* constructor.
|
|
42
|
+
*
|
|
43
|
+
* @type {Bindings?}
|
|
44
|
+
* @default null
|
|
45
|
+
*/
|
|
46
|
+
this.bindings = null;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Internal cache for maintaining pipelines.
|
|
50
|
+
* The key of the map is a cache key, the value the pipeline.
|
|
51
|
+
*
|
|
52
|
+
* @type {Map<String,Pipeline>}
|
|
53
|
+
*/
|
|
17
54
|
this.caches = new Map();
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* This dictionary maintains for each shader stage type (vertex,
|
|
58
|
+
* fragment and compute) the progammable stage objects which
|
|
59
|
+
* represent the actual shader code.
|
|
60
|
+
*
|
|
61
|
+
* @type {Object<String,Map>}
|
|
62
|
+
*/
|
|
18
63
|
this.programs = {
|
|
19
64
|
vertex: new Map(),
|
|
20
65
|
fragment: new Map(),
|
|
@@ -23,6 +68,13 @@ class Pipelines extends DataMap {
|
|
|
23
68
|
|
|
24
69
|
}
|
|
25
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Returns a compute pipeline for the given compute node.
|
|
73
|
+
*
|
|
74
|
+
* @param {Node} computeNode - The compute node.
|
|
75
|
+
* @param {Array<BindGroup>} bindings - The bindings.
|
|
76
|
+
* @return {ComputePipeline} The compute pipeline.
|
|
77
|
+
*/
|
|
26
78
|
getForCompute( computeNode, bindings ) {
|
|
27
79
|
|
|
28
80
|
const { backend } = this;
|
|
@@ -52,7 +104,7 @@ class Pipelines extends DataMap {
|
|
|
52
104
|
|
|
53
105
|
if ( previousPipeline && previousPipeline.computeProgram.usedTimes === 0 ) this._releaseProgram( previousPipeline.computeProgram );
|
|
54
106
|
|
|
55
|
-
stageCompute = new ProgrammableStage( nodeBuilderState.computeShader, 'compute', nodeBuilderState.transforms, nodeBuilderState.nodeAttributes );
|
|
107
|
+
stageCompute = new ProgrammableStage( nodeBuilderState.computeShader, 'compute', computeNode.name, nodeBuilderState.transforms, nodeBuilderState.nodeAttributes );
|
|
56
108
|
this.programs.compute.set( nodeBuilderState.computeShader, stageCompute );
|
|
57
109
|
|
|
58
110
|
backend.createProgram( stageCompute );
|
|
@@ -89,6 +141,13 @@ class Pipelines extends DataMap {
|
|
|
89
141
|
|
|
90
142
|
}
|
|
91
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Returns a render pipeline for the given render object.
|
|
146
|
+
*
|
|
147
|
+
* @param {RenderObject} renderObject - The render object.
|
|
148
|
+
* @param {Array<Promise>?} [promises=null] - An array of compilation promises which is only relevant in context of `Renderer.compileAsync()`.
|
|
149
|
+
* @return {RenderPipeline} The render pipeline.
|
|
150
|
+
*/
|
|
92
151
|
getForRender( renderObject, promises = null ) {
|
|
93
152
|
|
|
94
153
|
const { backend } = this;
|
|
@@ -111,6 +170,8 @@ class Pipelines extends DataMap {
|
|
|
111
170
|
|
|
112
171
|
const nodeBuilderState = renderObject.getNodeBuilderState();
|
|
113
172
|
|
|
173
|
+
const name = renderObject.material ? renderObject.material.name : '';
|
|
174
|
+
|
|
114
175
|
// programmable stages
|
|
115
176
|
|
|
116
177
|
let stageVertex = this.programs.vertex.get( nodeBuilderState.vertexShader );
|
|
@@ -119,7 +180,7 @@ class Pipelines extends DataMap {
|
|
|
119
180
|
|
|
120
181
|
if ( previousPipeline && previousPipeline.vertexProgram.usedTimes === 0 ) this._releaseProgram( previousPipeline.vertexProgram );
|
|
121
182
|
|
|
122
|
-
stageVertex = new ProgrammableStage( nodeBuilderState.vertexShader, 'vertex' );
|
|
183
|
+
stageVertex = new ProgrammableStage( nodeBuilderState.vertexShader, 'vertex', name );
|
|
123
184
|
this.programs.vertex.set( nodeBuilderState.vertexShader, stageVertex );
|
|
124
185
|
|
|
125
186
|
backend.createProgram( stageVertex );
|
|
@@ -132,7 +193,7 @@ class Pipelines extends DataMap {
|
|
|
132
193
|
|
|
133
194
|
if ( previousPipeline && previousPipeline.fragmentProgram.usedTimes === 0 ) this._releaseProgram( previousPipeline.fragmentProgram );
|
|
134
195
|
|
|
135
|
-
stageFragment = new ProgrammableStage( nodeBuilderState.fragmentShader, 'fragment' );
|
|
196
|
+
stageFragment = new ProgrammableStage( nodeBuilderState.fragmentShader, 'fragment', name );
|
|
136
197
|
this.programs.fragment.set( nodeBuilderState.fragmentShader, stageFragment );
|
|
137
198
|
|
|
138
199
|
backend.createProgram( stageFragment );
|
|
@@ -173,6 +234,12 @@ class Pipelines extends DataMap {
|
|
|
173
234
|
|
|
174
235
|
}
|
|
175
236
|
|
|
237
|
+
/**
|
|
238
|
+
* Deletes the pipeline for the given render object.
|
|
239
|
+
*
|
|
240
|
+
* @param {RenderObject} object - The render object.
|
|
241
|
+
* @return {Object?} The deleted dictionary.
|
|
242
|
+
*/
|
|
176
243
|
delete( object ) {
|
|
177
244
|
|
|
178
245
|
const pipeline = this.get( object ).pipeline;
|
|
@@ -209,6 +276,9 @@ class Pipelines extends DataMap {
|
|
|
209
276
|
|
|
210
277
|
}
|
|
211
278
|
|
|
279
|
+
/**
|
|
280
|
+
* Frees internal resources.
|
|
281
|
+
*/
|
|
212
282
|
dispose() {
|
|
213
283
|
|
|
214
284
|
super.dispose();
|
|
@@ -222,12 +292,27 @@ class Pipelines extends DataMap {
|
|
|
222
292
|
|
|
223
293
|
}
|
|
224
294
|
|
|
295
|
+
/**
|
|
296
|
+
* Updates the pipeline for the given render object.
|
|
297
|
+
*
|
|
298
|
+
* @param {RenderObject} renderObject - The render object.
|
|
299
|
+
*/
|
|
225
300
|
updateForRender( renderObject ) {
|
|
226
301
|
|
|
227
302
|
this.getForRender( renderObject );
|
|
228
303
|
|
|
229
304
|
}
|
|
230
305
|
|
|
306
|
+
/**
|
|
307
|
+
* Returns a compute pipeline for the given parameters.
|
|
308
|
+
*
|
|
309
|
+
* @private
|
|
310
|
+
* @param {Node} computeNode - The compute node.
|
|
311
|
+
* @param {ProgrammableStage} stageCompute - The programmable stage representing the compute shader.
|
|
312
|
+
* @param {String} cacheKey - The cache key.
|
|
313
|
+
* @param {Array<BindGroup>} bindings - The bindings.
|
|
314
|
+
* @return {ComputePipeline} The compute pipeline.
|
|
315
|
+
*/
|
|
231
316
|
_getComputePipeline( computeNode, stageCompute, cacheKey, bindings ) {
|
|
232
317
|
|
|
233
318
|
// check for existing pipeline
|
|
@@ -250,6 +335,17 @@ class Pipelines extends DataMap {
|
|
|
250
335
|
|
|
251
336
|
}
|
|
252
337
|
|
|
338
|
+
/**
|
|
339
|
+
* Returns a render pipeline for the given parameters.
|
|
340
|
+
*
|
|
341
|
+
* @private
|
|
342
|
+
* @param {RenderObject} renderObject - The render object.
|
|
343
|
+
* @param {ProgrammableStage} stageVertex - The programmable stage representing the vertex shader.
|
|
344
|
+
* @param {ProgrammableStage} stageFragment - The programmable stage representing the fragment shader.
|
|
345
|
+
* @param {String} cacheKey - The cache key.
|
|
346
|
+
* @param {Array} promises - An array of compilation promises which is only relevant in context of `Renderer.compileAsync()`.
|
|
347
|
+
* @return {ComputePipeline} The compute pipeline.
|
|
348
|
+
*/
|
|
253
349
|
_getRenderPipeline( renderObject, stageVertex, stageFragment, cacheKey, promises ) {
|
|
254
350
|
|
|
255
351
|
// check for existing pipeline
|
|
@@ -266,6 +362,10 @@ class Pipelines extends DataMap {
|
|
|
266
362
|
|
|
267
363
|
renderObject.pipeline = pipeline;
|
|
268
364
|
|
|
365
|
+
// The `promises` array is `null` by default and only set to an empty array when
|
|
366
|
+
// `Renderer.compileAsync()` is used. The next call actually fills the array with
|
|
367
|
+
// pending promises that resolve when the render pipelines are ready for rendering.
|
|
368
|
+
|
|
269
369
|
this.backend.createRenderPipeline( renderObject, promises );
|
|
270
370
|
|
|
271
371
|
}
|
|
@@ -274,24 +374,53 @@ class Pipelines extends DataMap {
|
|
|
274
374
|
|
|
275
375
|
}
|
|
276
376
|
|
|
377
|
+
/**
|
|
378
|
+
* Computes a cache key representing a compute pipeline.
|
|
379
|
+
*
|
|
380
|
+
* @private
|
|
381
|
+
* @param {Node} computeNode - The compute node.
|
|
382
|
+
* @param {ProgrammableStage} stageCompute - The programmable stage representing the compute shader.
|
|
383
|
+
* @return {String} The cache key.
|
|
384
|
+
*/
|
|
277
385
|
_getComputeCacheKey( computeNode, stageCompute ) {
|
|
278
386
|
|
|
279
387
|
return computeNode.id + ',' + stageCompute.id;
|
|
280
388
|
|
|
281
389
|
}
|
|
282
390
|
|
|
391
|
+
/**
|
|
392
|
+
* Computes a cache key representing a render pipeline.
|
|
393
|
+
*
|
|
394
|
+
* @private
|
|
395
|
+
* @param {RenderObject} renderObject - The render object.
|
|
396
|
+
* @param {ProgrammableStage} stageVertex - The programmable stage representing the vertex shader.
|
|
397
|
+
* @param {ProgrammableStage} stageFragment - The programmable stage representing the fragment shader.
|
|
398
|
+
* @return {String} The cache key.
|
|
399
|
+
*/
|
|
283
400
|
_getRenderCacheKey( renderObject, stageVertex, stageFragment ) {
|
|
284
401
|
|
|
285
402
|
return stageVertex.id + ',' + stageFragment.id + ',' + this.backend.getRenderCacheKey( renderObject );
|
|
286
403
|
|
|
287
404
|
}
|
|
288
405
|
|
|
406
|
+
/**
|
|
407
|
+
* Releases the given pipeline.
|
|
408
|
+
*
|
|
409
|
+
* @private
|
|
410
|
+
* @param {Pipeline} pipeline - The pipeline to release.
|
|
411
|
+
*/
|
|
289
412
|
_releasePipeline( pipeline ) {
|
|
290
413
|
|
|
291
414
|
this.caches.delete( pipeline.cacheKey );
|
|
292
415
|
|
|
293
416
|
}
|
|
294
417
|
|
|
418
|
+
/**
|
|
419
|
+
* Releases the shader program.
|
|
420
|
+
*
|
|
421
|
+
* @private
|
|
422
|
+
* @param {Object} program - The shdaer program to release.
|
|
423
|
+
*/
|
|
295
424
|
_releaseProgram( program ) {
|
|
296
425
|
|
|
297
426
|
const code = program.code;
|
|
@@ -301,6 +430,13 @@ class Pipelines extends DataMap {
|
|
|
301
430
|
|
|
302
431
|
}
|
|
303
432
|
|
|
433
|
+
/**
|
|
434
|
+
* Returns `true` if the compute pipeline for the given compute node requires an update.
|
|
435
|
+
*
|
|
436
|
+
* @private
|
|
437
|
+
* @param {Node} computeNode - The compute node.
|
|
438
|
+
* @return {Boolean} Whether the compute pipeline for the given compute node requires an update or not.
|
|
439
|
+
*/
|
|
304
440
|
_needsComputeUpdate( computeNode ) {
|
|
305
441
|
|
|
306
442
|
const data = this.get( computeNode );
|
|
@@ -309,6 +445,13 @@ class Pipelines extends DataMap {
|
|
|
309
445
|
|
|
310
446
|
}
|
|
311
447
|
|
|
448
|
+
/**
|
|
449
|
+
* Returns `true` if the render pipeline for the given render object requires an update.
|
|
450
|
+
*
|
|
451
|
+
* @private
|
|
452
|
+
* @param {RenderObject} renderObject - The render object.
|
|
453
|
+
* @return {Boolean} Whether the render object for the given render object requires an update or not.
|
|
454
|
+
*/
|
|
312
455
|
_needsRenderUpdate( renderObject ) {
|
|
313
456
|
|
|
314
457
|
const data = this.get( renderObject );
|
|
@@ -6,24 +6,83 @@ import QuadMesh from '../../renderers/common/QuadMesh.js';
|
|
|
6
6
|
const _material = /*@__PURE__*/ new NodeMaterial();
|
|
7
7
|
const _quadMesh = /*@__PURE__*/ new QuadMesh( _material );
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* This module is responsible to manage the post processing setups in apps.
|
|
11
|
+
* You usually create a single instance of this class and use it to define
|
|
12
|
+
* the output of your post processing effect chain.
|
|
13
|
+
* ```js
|
|
14
|
+
* const postProcessing = new PostProcessing( renderer );
|
|
15
|
+
*
|
|
16
|
+
* const scenePass = pass( scene, camera );
|
|
17
|
+
*
|
|
18
|
+
* postProcessing.outputNode = scenePass;
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
9
21
|
class PostProcessing {
|
|
10
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Constructs a new post processing management module.
|
|
25
|
+
*
|
|
26
|
+
* @param {Renderer} renderer - A reference to the renderer.
|
|
27
|
+
* @param {Node<vec4>} outputNode - An optional output node.
|
|
28
|
+
*/
|
|
11
29
|
constructor( renderer, outputNode = vec4( 0, 0, 1, 1 ) ) {
|
|
12
30
|
|
|
31
|
+
/**
|
|
32
|
+
* A reference to the renderer.
|
|
33
|
+
*
|
|
34
|
+
* @type {Renderer}
|
|
35
|
+
*/
|
|
13
36
|
this.renderer = renderer;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A node which defines the final output of the post
|
|
40
|
+
* processing. This is usually the last node in a chain
|
|
41
|
+
* of effect nodes.
|
|
42
|
+
*
|
|
43
|
+
* @type {Node<vec4>}
|
|
44
|
+
*/
|
|
14
45
|
this.outputNode = outputNode;
|
|
15
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Whether the default output tone mapping and color
|
|
49
|
+
* space transformation should be enabled or not.
|
|
50
|
+
*
|
|
51
|
+
* It is enabled by default by it must be disabled when
|
|
52
|
+
* effects must be executed after tone mapping and color
|
|
53
|
+
* space conversion. A typical example is FXAA which
|
|
54
|
+
* requires sRGB input.
|
|
55
|
+
*
|
|
56
|
+
* When set to `false`, the app must control the output
|
|
57
|
+
* transformation with `RenderOutputNode`.
|
|
58
|
+
*
|
|
59
|
+
* ```js
|
|
60
|
+
* const outputPass = renderOutput( scenePass );
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @type {Boolean}
|
|
64
|
+
*/
|
|
16
65
|
this.outputColorTransform = true;
|
|
17
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Must be set to `true` when the output node changes.
|
|
69
|
+
*
|
|
70
|
+
* @type {Node<vec4>}
|
|
71
|
+
*/
|
|
18
72
|
this.needsUpdate = true;
|
|
19
73
|
|
|
20
74
|
_material.name = 'PostProcessing';
|
|
21
75
|
|
|
22
76
|
}
|
|
23
77
|
|
|
78
|
+
/**
|
|
79
|
+
* When `PostProcessing` is used to apply post processing effects,
|
|
80
|
+
* the application must use this version of `render()` inside
|
|
81
|
+
* its animation loop (not the one from the renderer).
|
|
82
|
+
*/
|
|
24
83
|
render() {
|
|
25
84
|
|
|
26
|
-
this.
|
|
85
|
+
this._update();
|
|
27
86
|
|
|
28
87
|
const renderer = this.renderer;
|
|
29
88
|
|
|
@@ -44,7 +103,12 @@ class PostProcessing {
|
|
|
44
103
|
|
|
45
104
|
}
|
|
46
105
|
|
|
47
|
-
|
|
106
|
+
/**
|
|
107
|
+
* Updates the state of the module.
|
|
108
|
+
*
|
|
109
|
+
* @private
|
|
110
|
+
*/
|
|
111
|
+
_update() {
|
|
48
112
|
|
|
49
113
|
if ( this.needsUpdate === true ) {
|
|
50
114
|
|
|
@@ -62,9 +126,17 @@ class PostProcessing {
|
|
|
62
126
|
|
|
63
127
|
}
|
|
64
128
|
|
|
129
|
+
/**
|
|
130
|
+
* When `PostProcessing` is used to apply post processing effects,
|
|
131
|
+
* the application must use this version of `renderAsync()` inside
|
|
132
|
+
* its animation loop (not the one from the renderer).
|
|
133
|
+
*
|
|
134
|
+
* @async
|
|
135
|
+
* @return {Promise} A Promise that resolves when the render has been finished.
|
|
136
|
+
*/
|
|
65
137
|
async renderAsync() {
|
|
66
138
|
|
|
67
|
-
this.
|
|
139
|
+
this._update();
|
|
68
140
|
|
|
69
141
|
const renderer = this.renderer;
|
|
70
142
|
|
|
@@ -1,16 +1,74 @@
|
|
|
1
1
|
let _id = 0;
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Class for representing programmable stages which are vertex,
|
|
5
|
+
* fragment or compute shaders. Unlike fixed-function states (like blending),
|
|
6
|
+
* they represent the programmable part of a pipeline.
|
|
7
|
+
*
|
|
8
|
+
* @private
|
|
9
|
+
*/
|
|
3
10
|
class ProgrammableStage {
|
|
4
11
|
|
|
5
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Constructs a new programmable stage.
|
|
14
|
+
*
|
|
15
|
+
* @param {String} code - The shader code.
|
|
16
|
+
* @param {('vertex'|'fragment'|'compute')} stage - The type of stage.
|
|
17
|
+
* @param {String} name - The name of the shader.
|
|
18
|
+
* @param {Array<Object>?} [transforms=null] - The transforms (only relevant for compute stages with WebGL 2 which uses Transform Feedback).
|
|
19
|
+
* @param {Array<Object>?} [attributes=null] - The attributes (only relevant for compute stages with WebGL 2 which uses Transform Feedback).
|
|
20
|
+
*/
|
|
21
|
+
constructor( code, stage, name, transforms = null, attributes = null ) {
|
|
6
22
|
|
|
23
|
+
/**
|
|
24
|
+
* The id of the programmable stage.
|
|
25
|
+
*
|
|
26
|
+
* @type {Number}
|
|
27
|
+
*/
|
|
7
28
|
this.id = _id ++;
|
|
8
29
|
|
|
30
|
+
/**
|
|
31
|
+
* The shader code.
|
|
32
|
+
*
|
|
33
|
+
* @type {String}
|
|
34
|
+
*/
|
|
9
35
|
this.code = code;
|
|
10
|
-
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The type of stage.
|
|
39
|
+
*
|
|
40
|
+
* @type {String}
|
|
41
|
+
*/
|
|
42
|
+
this.stage = stage;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The name of the stage.
|
|
46
|
+
* This is used for debugging purposes.
|
|
47
|
+
*
|
|
48
|
+
* @type {String}
|
|
49
|
+
*/
|
|
50
|
+
this.name = name;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The transforms (only relevant for compute stages with WebGL 2 which uses Transform Feedback).
|
|
54
|
+
*
|
|
55
|
+
* @type {Array<Object>?}
|
|
56
|
+
*/
|
|
11
57
|
this.transforms = transforms;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The attributes (only relevant for compute stages with WebGL 2 which uses Transform Feedback).
|
|
61
|
+
*
|
|
62
|
+
* @type {Array<Object>?}
|
|
63
|
+
*/
|
|
12
64
|
this.attributes = attributes;
|
|
13
65
|
|
|
66
|
+
/**
|
|
67
|
+
* How often the programmable stage is currently in use.
|
|
68
|
+
*
|
|
69
|
+
* @type {Number}
|
|
70
|
+
* @default 0
|
|
71
|
+
*/
|
|
14
72
|
this.usedTimes = 0;
|
|
15
73
|
|
|
16
74
|
}
|