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
|
@@ -2,6 +2,19 @@ import ReferenceBaseNode from './ReferenceBaseNode.js';
|
|
|
2
2
|
import { nodeObject } from '../tsl/TSLCore.js';
|
|
3
3
|
import { renderGroup } from '../core/UniformGroupNode.js';
|
|
4
4
|
|
|
5
|
+
/** @module RendererReferenceNode **/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* This node is a special type of reference node which is intended
|
|
9
|
+
* for linking renderer properties with node values.
|
|
10
|
+
* ```js
|
|
11
|
+
* const exposureNode = rendererReference( 'toneMappingExposure', 'float', renderer );
|
|
12
|
+
* ```
|
|
13
|
+
* When changing `renderer.toneMappingExposure`, the node value of `exposureNode` will
|
|
14
|
+
* automatically be updated.
|
|
15
|
+
*
|
|
16
|
+
* @augments ReferenceBaseNode
|
|
17
|
+
*/
|
|
5
18
|
class RendererReferenceNode extends ReferenceBaseNode {
|
|
6
19
|
|
|
7
20
|
static get type() {
|
|
@@ -10,16 +23,38 @@ class RendererReferenceNode extends ReferenceBaseNode {
|
|
|
10
23
|
|
|
11
24
|
}
|
|
12
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Constructs a new renderer reference node.
|
|
28
|
+
*
|
|
29
|
+
* @param {String} property - The name of the property the node refers to.
|
|
30
|
+
* @param {String} inputType - The uniform type that should be used to represent the property value.
|
|
31
|
+
* @param {Renderer?} [renderer=null] - The renderer the property belongs to. When no renderer is set,
|
|
32
|
+
* the node refers to the renderer of the current state.
|
|
33
|
+
*/
|
|
13
34
|
constructor( property, inputType, renderer = null ) {
|
|
14
35
|
|
|
15
36
|
super( property, inputType, renderer );
|
|
16
37
|
|
|
38
|
+
/**
|
|
39
|
+
* The renderer the property belongs to. When no renderer is set,
|
|
40
|
+
* the node refers to the renderer of the current state.
|
|
41
|
+
*
|
|
42
|
+
* @type {Renderer?}
|
|
43
|
+
* @default null
|
|
44
|
+
*/
|
|
17
45
|
this.renderer = renderer;
|
|
18
46
|
|
|
19
47
|
this.setGroup( renderGroup );
|
|
20
48
|
|
|
21
49
|
}
|
|
22
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Updates the reference based on the given state. The state is only evaluated
|
|
53
|
+
* {@link module:RendererReferenceNode~RendererReferenceNode#renderer} is not set.
|
|
54
|
+
*
|
|
55
|
+
* @param {(NodeFrame|NodeBuilder)} state - The current state.
|
|
56
|
+
* @return {Object} The updated reference.
|
|
57
|
+
*/
|
|
23
58
|
updateReference( state ) {
|
|
24
59
|
|
|
25
60
|
this.reference = this.renderer !== null ? this.renderer : state.renderer;
|
|
@@ -32,4 +67,14 @@ class RendererReferenceNode extends ReferenceBaseNode {
|
|
|
32
67
|
|
|
33
68
|
export default RendererReferenceNode;
|
|
34
69
|
|
|
35
|
-
|
|
70
|
+
/**
|
|
71
|
+
* TSL function for creating a renderer reference node.
|
|
72
|
+
*
|
|
73
|
+
* @function
|
|
74
|
+
* @param {String} name - The name of the property the node refers to.
|
|
75
|
+
* @param {String} type - The uniform type that should be used to represent the property value.
|
|
76
|
+
* @param {Renderer?} [renderer=null] - The renderer the property belongs to. When no renderer is set,
|
|
77
|
+
* the node refers to the renderer of the current state.
|
|
78
|
+
* @returns {RendererReferenceNode}
|
|
79
|
+
*/
|
|
80
|
+
export const rendererReference = ( name, type, renderer = null ) => nodeObject( new RendererReferenceNode( name, type, renderer ) );
|
|
@@ -9,6 +9,18 @@ import { reference } from './ReferenceNode.js';
|
|
|
9
9
|
const _e1 = /*@__PURE__*/ new Euler();
|
|
10
10
|
const _m1 = /*@__PURE__*/ new Matrix4();
|
|
11
11
|
|
|
12
|
+
/** @module SceneNode **/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* This module allows access to a collection of scene properties. The following predefined TSL objects
|
|
16
|
+
* are available for easier use:
|
|
17
|
+
*
|
|
18
|
+
* - `backgroundBlurriness`: A node that represents the scene's background blurriness.
|
|
19
|
+
* - `backgroundIntensity`: A node that represents the scene's background intensity.
|
|
20
|
+
* - `backgroundRotation`: A node that represents the scene's background rotation.
|
|
21
|
+
*
|
|
22
|
+
* @augments Node
|
|
23
|
+
*/
|
|
12
24
|
class SceneNode extends Node {
|
|
13
25
|
|
|
14
26
|
static get type() {
|
|
@@ -17,15 +29,40 @@ class SceneNode extends Node {
|
|
|
17
29
|
|
|
18
30
|
}
|
|
19
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Constructs a new scene node.
|
|
34
|
+
*
|
|
35
|
+
* @param {('backgroundBlurriness'|'backgroundIntensity'|'backgroundRotation')} scope - The scope defines the type of scene property that is accessed.
|
|
36
|
+
* @param {Scene?} [scene=null] - A reference to the scene.
|
|
37
|
+
*/
|
|
20
38
|
constructor( scope = SceneNode.BACKGROUND_BLURRINESS, scene = null ) {
|
|
21
39
|
|
|
22
40
|
super();
|
|
23
41
|
|
|
42
|
+
/**
|
|
43
|
+
* The scope defines the type of scene property that is accessed.
|
|
44
|
+
*
|
|
45
|
+
* @type {('backgroundBlurriness'|'backgroundIntensity'|'backgroundRotation')}
|
|
46
|
+
*/
|
|
24
47
|
this.scope = scope;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A reference to the scene that is going to be accessed.
|
|
51
|
+
*
|
|
52
|
+
* @type {Scene?}
|
|
53
|
+
* @default null
|
|
54
|
+
*/
|
|
25
55
|
this.scene = scene;
|
|
26
56
|
|
|
27
57
|
}
|
|
28
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Depending on the scope, the method returns a different type of node that represents
|
|
61
|
+
* the respective scene property.
|
|
62
|
+
*
|
|
63
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
64
|
+
* @return {Node} The output node.
|
|
65
|
+
*/
|
|
29
66
|
setup( builder ) {
|
|
30
67
|
|
|
31
68
|
const scope = this.scope;
|
|
@@ -84,6 +121,23 @@ SceneNode.BACKGROUND_ROTATION = 'backgroundRotation';
|
|
|
84
121
|
|
|
85
122
|
export default SceneNode;
|
|
86
123
|
|
|
124
|
+
/**
|
|
125
|
+
* TSL object that represents the scene's background blurriness.
|
|
126
|
+
*
|
|
127
|
+
* @type {SceneNode}
|
|
128
|
+
*/
|
|
87
129
|
export const backgroundBlurriness = /*@__PURE__*/ nodeImmutable( SceneNode, SceneNode.BACKGROUND_BLURRINESS );
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* TSL object that represents the scene's background intensity.
|
|
133
|
+
*
|
|
134
|
+
* @type {SceneNode}
|
|
135
|
+
*/
|
|
88
136
|
export const backgroundIntensity = /*@__PURE__*/ nodeImmutable( SceneNode, SceneNode.BACKGROUND_INTENSITY );
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* TSL object that represents the scene's background rotation.
|
|
140
|
+
*
|
|
141
|
+
* @type {SceneNode}
|
|
142
|
+
*/
|
|
89
143
|
export const backgroundRotation = /*@__PURE__*/ nodeImmutable( SceneNode, SceneNode.BACKGROUND_ROTATION );
|
|
@@ -9,9 +9,18 @@ import { positionLocal, positionPrevious } from './Position.js';
|
|
|
9
9
|
import { tangentLocal } from './Tangent.js';
|
|
10
10
|
import { uniform } from '../core/UniformNode.js';
|
|
11
11
|
import { buffer } from './BufferNode.js';
|
|
12
|
+
import { getDataFromObject } from '../core/NodeUtils.js';
|
|
13
|
+
|
|
14
|
+
/** @module SkinningNode **/
|
|
12
15
|
|
|
13
16
|
const _frameId = new WeakMap();
|
|
14
17
|
|
|
18
|
+
/**
|
|
19
|
+
* This node implements the vertex transformation shader logic which is required
|
|
20
|
+
* for skinning/skeletal animation.
|
|
21
|
+
*
|
|
22
|
+
* @augments Node
|
|
23
|
+
*/
|
|
15
24
|
class SkinningNode extends Node {
|
|
16
25
|
|
|
17
26
|
static get type() {
|
|
@@ -20,18 +29,52 @@ class SkinningNode extends Node {
|
|
|
20
29
|
|
|
21
30
|
}
|
|
22
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Constructs a new skinning node.
|
|
34
|
+
*
|
|
35
|
+
* @param {SkinnedMesh} skinnedMesh - The skinned mesh.
|
|
36
|
+
* @param {Boolean} [useReference=false] - Whether to use reference nodes for internal skinned mesh related data or not.
|
|
37
|
+
*/
|
|
23
38
|
constructor( skinnedMesh, useReference = false ) {
|
|
24
39
|
|
|
25
40
|
super( 'void' );
|
|
26
41
|
|
|
42
|
+
/**
|
|
43
|
+
* The skinned mesh.
|
|
44
|
+
*
|
|
45
|
+
* @type {SkinnedMesh}
|
|
46
|
+
*/
|
|
27
47
|
this.skinnedMesh = skinnedMesh;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Whether to use reference nodes for internal skinned mesh related data or not.
|
|
51
|
+
* TODO: Explain the purpose of the property.
|
|
52
|
+
*
|
|
53
|
+
* @type {Boolean}
|
|
54
|
+
*/
|
|
28
55
|
this.useReference = useReference;
|
|
29
56
|
|
|
57
|
+
/**
|
|
58
|
+
* The update type overwritten since skinning nodes are updated per object.
|
|
59
|
+
*
|
|
60
|
+
* @type {String}
|
|
61
|
+
*/
|
|
30
62
|
this.updateType = NodeUpdateType.OBJECT;
|
|
31
63
|
|
|
32
64
|
//
|
|
33
65
|
|
|
66
|
+
/**
|
|
67
|
+
* The skin index attribute.
|
|
68
|
+
*
|
|
69
|
+
* @type {AttributeNode}
|
|
70
|
+
*/
|
|
34
71
|
this.skinIndexNode = attribute( 'skinIndex', 'uvec4' );
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The skin weight attribute.
|
|
75
|
+
*
|
|
76
|
+
* @type {AttributeNode}
|
|
77
|
+
*/
|
|
35
78
|
this.skinWeightNode = attribute( 'skinWeight', 'vec4' );
|
|
36
79
|
|
|
37
80
|
let bindMatrixNode, bindMatrixInverseNode, boneMatricesNode;
|
|
@@ -50,13 +93,45 @@ class SkinningNode extends Node {
|
|
|
50
93
|
|
|
51
94
|
}
|
|
52
95
|
|
|
96
|
+
/**
|
|
97
|
+
* The bind matrix node.
|
|
98
|
+
*
|
|
99
|
+
* @type {Node<mat4>}
|
|
100
|
+
*/
|
|
53
101
|
this.bindMatrixNode = bindMatrixNode;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The bind matrix inverse node.
|
|
105
|
+
*
|
|
106
|
+
* @type {Node<mat4>}
|
|
107
|
+
*/
|
|
54
108
|
this.bindMatrixInverseNode = bindMatrixInverseNode;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The bind matrices as a uniform buffer node.
|
|
112
|
+
*
|
|
113
|
+
* @type {Node}
|
|
114
|
+
*/
|
|
55
115
|
this.boneMatricesNode = boneMatricesNode;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The previous bind matrices as a uniform buffer node.
|
|
119
|
+
* Required for computing motion vectors.
|
|
120
|
+
*
|
|
121
|
+
* @type {Node?}
|
|
122
|
+
* @default null
|
|
123
|
+
*/
|
|
56
124
|
this.previousBoneMatricesNode = null;
|
|
57
125
|
|
|
58
126
|
}
|
|
59
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Transforms the given vertex position via skinning.
|
|
130
|
+
*
|
|
131
|
+
* @param {Node} [boneMatrices=this.boneMatricesNode] - The bone matrices
|
|
132
|
+
* @param {Node<vec3>} [position=positionLocal] - The vertex position in local space.
|
|
133
|
+
* @return {Node<vec3>} The transformed vertex position.
|
|
134
|
+
*/
|
|
60
135
|
getSkinnedPosition( boneMatrices = this.boneMatricesNode, position = positionLocal ) {
|
|
61
136
|
|
|
62
137
|
const { skinIndexNode, skinWeightNode, bindMatrixNode, bindMatrixInverseNode } = this;
|
|
@@ -81,6 +156,13 @@ class SkinningNode extends Node {
|
|
|
81
156
|
|
|
82
157
|
}
|
|
83
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Transforms the given vertex normal via skinning.
|
|
161
|
+
*
|
|
162
|
+
* @param {Node} [boneMatrices=this.boneMatricesNode] - The bone matrices
|
|
163
|
+
* @param {Node<vec3>} [normal=normalLocal] - The vertex normal in local space.
|
|
164
|
+
* @return {Node<vec3>} The transformed vertex normal.
|
|
165
|
+
*/
|
|
84
166
|
getSkinnedNormal( boneMatrices = this.boneMatricesNode, normal = normalLocal ) {
|
|
85
167
|
|
|
86
168
|
const { skinIndexNode, skinWeightNode, bindMatrixNode, bindMatrixInverseNode } = this;
|
|
@@ -105,6 +187,12 @@ class SkinningNode extends Node {
|
|
|
105
187
|
|
|
106
188
|
}
|
|
107
189
|
|
|
190
|
+
/**
|
|
191
|
+
* Transforms the given vertex normal via skinning.
|
|
192
|
+
*
|
|
193
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
194
|
+
* @return {Node<vec3>} The skinned position from the previous frame.
|
|
195
|
+
*/
|
|
108
196
|
getPreviousSkinnedPosition( builder ) {
|
|
109
197
|
|
|
110
198
|
const skinnedMesh = builder.object;
|
|
@@ -121,14 +209,25 @@ class SkinningNode extends Node {
|
|
|
121
209
|
|
|
122
210
|
}
|
|
123
211
|
|
|
212
|
+
/**
|
|
213
|
+
* Returns `true` if bone matrices from the previous frame are required.
|
|
214
|
+
*
|
|
215
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
216
|
+
* @return {Boolean} Whether bone matrices from the previous frame are required or not.
|
|
217
|
+
*/
|
|
124
218
|
needsPreviousBoneMatrices( builder ) {
|
|
125
219
|
|
|
126
220
|
const mrt = builder.renderer.getMRT();
|
|
127
221
|
|
|
128
|
-
return mrt && mrt.has( 'velocity' );
|
|
222
|
+
return ( mrt && mrt.has( 'velocity' ) ) || getDataFromObject( builder.object ).useVelocity === true;
|
|
129
223
|
|
|
130
224
|
}
|
|
131
225
|
|
|
226
|
+
/**
|
|
227
|
+
* Setups the skinning node by assigning the transformed vertex data to predefined node variables.
|
|
228
|
+
*
|
|
229
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
230
|
+
*/
|
|
132
231
|
setup( builder ) {
|
|
133
232
|
|
|
134
233
|
if ( this.needsPreviousBoneMatrices( builder ) ) {
|
|
@@ -158,6 +257,13 @@ class SkinningNode extends Node {
|
|
|
158
257
|
|
|
159
258
|
}
|
|
160
259
|
|
|
260
|
+
/**
|
|
261
|
+
* Generates the code snippet of the skinning node.
|
|
262
|
+
*
|
|
263
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
264
|
+
* @param {String} output - The current output.
|
|
265
|
+
* @return {String} The generated code snippet.
|
|
266
|
+
*/
|
|
161
267
|
generate( builder, output ) {
|
|
162
268
|
|
|
163
269
|
if ( output !== 'void' ) {
|
|
@@ -168,6 +274,11 @@ class SkinningNode extends Node {
|
|
|
168
274
|
|
|
169
275
|
}
|
|
170
276
|
|
|
277
|
+
/**
|
|
278
|
+
* Updates the state of the skinned mesh by updating the skeleton once per frame.
|
|
279
|
+
*
|
|
280
|
+
* @param {NodeFrame} frame - The current node frame.
|
|
281
|
+
*/
|
|
171
282
|
update( frame ) {
|
|
172
283
|
|
|
173
284
|
const object = this.useReference ? frame.object : this.skinnedMesh;
|
|
@@ -187,5 +298,20 @@ class SkinningNode extends Node {
|
|
|
187
298
|
|
|
188
299
|
export default SkinningNode;
|
|
189
300
|
|
|
301
|
+
/**
|
|
302
|
+
* TSL function for creating a skinning node.
|
|
303
|
+
*
|
|
304
|
+
* @function
|
|
305
|
+
* @param {SkinnedMesh} skinnedMesh - The skinned mesh.
|
|
306
|
+
* @returns {SkinningNode}
|
|
307
|
+
*/
|
|
190
308
|
export const skinning = ( skinnedMesh ) => nodeObject( new SkinningNode( skinnedMesh ) );
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* TSL function for creating a skinning node with reference usage.
|
|
312
|
+
*
|
|
313
|
+
* @function
|
|
314
|
+
* @param {SkinnedMesh} skinnedMesh - The skinned mesh.
|
|
315
|
+
* @returns {SkinningNode}
|
|
316
|
+
*/
|
|
191
317
|
export const skinningReference = ( skinnedMesh ) => nodeObject( new SkinningNode( skinnedMesh, true ) );
|
|
@@ -5,6 +5,39 @@ import { storageElement } from '../utils/StorageArrayElementNode.js';
|
|
|
5
5
|
import { NodeAccess } from '../core/constants.js';
|
|
6
6
|
import { getTypeFromLength } from '../core/NodeUtils.js';
|
|
7
7
|
|
|
8
|
+
/** @module StorageBufferNode **/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* This node is used in context of compute shaders and allows to define a
|
|
12
|
+
* storage buffer for data. A typical workflow is to create instances of
|
|
13
|
+
* this node with the convenience functions `attributeArray()` or `instancedArray()`,
|
|
14
|
+
* setup up a compute shader that writes into the buffers and then convert
|
|
15
|
+
* the storage buffers to attribute nodes for rendering.
|
|
16
|
+
*
|
|
17
|
+
* ```js
|
|
18
|
+
* const positionBuffer = instancedArray( particleCount, 'vec3' ); // the storage buffer node
|
|
19
|
+
*
|
|
20
|
+
* const computeInit = Fn( () => { // the compute shader
|
|
21
|
+
*
|
|
22
|
+
* const position = positionBuffer.element( instanceIndex );
|
|
23
|
+
*
|
|
24
|
+
* // compute position data
|
|
25
|
+
*
|
|
26
|
+
* position.x = 1;
|
|
27
|
+
* position.y = 1;
|
|
28
|
+
* position.z = 1;
|
|
29
|
+
*
|
|
30
|
+
* } )().compute( particleCount );
|
|
31
|
+
*
|
|
32
|
+
* const particleMaterial = new THREE.SpriteNodeMaterial();
|
|
33
|
+
* particleMaterial.positionNode = positionBuffer.toAttribute();
|
|
34
|
+
*
|
|
35
|
+
* renderer.computeAsync( computeInit );
|
|
36
|
+
*
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @augments BufferNode
|
|
40
|
+
*/
|
|
8
41
|
class StorageBufferNode extends BufferNode {
|
|
9
42
|
|
|
10
43
|
static get type() {
|
|
@@ -13,6 +46,13 @@ class StorageBufferNode extends BufferNode {
|
|
|
13
46
|
|
|
14
47
|
}
|
|
15
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Constructs a new storage buffer node.
|
|
51
|
+
*
|
|
52
|
+
* @param {StorageBufferAttribute|StorageInstancedBufferAttribute|BufferAttribute} value - The buffer data.
|
|
53
|
+
* @param {String?} [bufferType=null] - The buffer type (e.g. `'vec3'`).
|
|
54
|
+
* @param {Number} [bufferCount=0] - The buffer count.
|
|
55
|
+
*/
|
|
16
56
|
constructor( value, bufferType = null, bufferCount = 0 ) {
|
|
17
57
|
|
|
18
58
|
if ( bufferType === null && ( value.isStorageBufferAttribute || value.isStorageInstancedBufferAttribute ) ) {
|
|
@@ -24,22 +64,67 @@ class StorageBufferNode extends BufferNode {
|
|
|
24
64
|
|
|
25
65
|
super( value, bufferType, bufferCount );
|
|
26
66
|
|
|
67
|
+
/**
|
|
68
|
+
* This flag can be used for type testing.
|
|
69
|
+
*
|
|
70
|
+
* @type {Boolean}
|
|
71
|
+
* @readonly
|
|
72
|
+
* @default true
|
|
73
|
+
*/
|
|
27
74
|
this.isStorageBufferNode = true;
|
|
28
75
|
|
|
76
|
+
/**
|
|
77
|
+
* The access type of the texture node.
|
|
78
|
+
*
|
|
79
|
+
* @type {String}
|
|
80
|
+
* @default 'readWrite'
|
|
81
|
+
*/
|
|
29
82
|
this.access = NodeAccess.READ_WRITE;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Whether the node is atomic or not.
|
|
86
|
+
*
|
|
87
|
+
* @type {Boolean}
|
|
88
|
+
* @default false
|
|
89
|
+
*/
|
|
30
90
|
this.isAtomic = false;
|
|
31
|
-
this.isPBO = false;
|
|
32
91
|
|
|
33
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Whether the node represents a PBO or not.
|
|
94
|
+
* Only relevant for WebGL.
|
|
95
|
+
*
|
|
96
|
+
* @type {Boolean}
|
|
97
|
+
* @default false
|
|
98
|
+
*/
|
|
99
|
+
this.isPBO = false;
|
|
34
100
|
|
|
101
|
+
/**
|
|
102
|
+
* A reference to the internal buffer attribute node.
|
|
103
|
+
*
|
|
104
|
+
* @type {BufferAttributeNode?}
|
|
105
|
+
* @default null
|
|
106
|
+
*/
|
|
35
107
|
this._attribute = null;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* A reference to the internal varying node.
|
|
111
|
+
*
|
|
112
|
+
* @type {VaryingNode?}
|
|
113
|
+
* @default null
|
|
114
|
+
*/
|
|
36
115
|
this._varying = null;
|
|
37
116
|
|
|
117
|
+
/**
|
|
118
|
+
* `StorageBufferNode` sets this property to `true` by default.
|
|
119
|
+
*
|
|
120
|
+
* @type {Boolean}
|
|
121
|
+
* @default true
|
|
122
|
+
*/
|
|
38
123
|
this.global = true;
|
|
39
124
|
|
|
40
125
|
if ( value.isStorageBufferAttribute !== true && value.isStorageInstancedBufferAttribute !== true ) {
|
|
41
126
|
|
|
42
|
-
//
|
|
127
|
+
// TODO: Improve it, possibly adding a new property to the BufferAttribute to identify it as a storage buffer read-only attribute in Renderer
|
|
43
128
|
|
|
44
129
|
if ( value.isInstancedBufferAttribute ) value.isStorageInstancedBufferAttribute = true;
|
|
45
130
|
else value.isStorageBufferAttribute = true;
|
|
@@ -48,6 +133,13 @@ class StorageBufferNode extends BufferNode {
|
|
|
48
133
|
|
|
49
134
|
}
|
|
50
135
|
|
|
136
|
+
/**
|
|
137
|
+
* This method is overwritten since the buffer data might be shared
|
|
138
|
+
* and thus the hash should be shared as well.
|
|
139
|
+
*
|
|
140
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
141
|
+
* @return {String} The hash.
|
|
142
|
+
*/
|
|
51
143
|
getHash( builder ) {
|
|
52
144
|
|
|
53
145
|
if ( this.bufferCount === 0 ) {
|
|
@@ -72,18 +164,36 @@ class StorageBufferNode extends BufferNode {
|
|
|
72
164
|
|
|
73
165
|
}
|
|
74
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Overwrites the default implementation to return a fixed value `'indirectStorageBuffer'` or `'storageBuffer'`.
|
|
169
|
+
*
|
|
170
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
171
|
+
* @return {String} The input type.
|
|
172
|
+
*/
|
|
75
173
|
getInputType( /*builder*/ ) {
|
|
76
174
|
|
|
77
175
|
return this.value.isIndirectStorageBufferAttribute ? 'indirectStorageBuffer' : 'storageBuffer';
|
|
78
176
|
|
|
79
177
|
}
|
|
80
178
|
|
|
179
|
+
/**
|
|
180
|
+
* Enables element access with the given index node.
|
|
181
|
+
*
|
|
182
|
+
* @param {IndexNode} indexNode - The index node.
|
|
183
|
+
* @return {StorageArrayElementNode} A node representing the element access.
|
|
184
|
+
*/
|
|
81
185
|
element( indexNode ) {
|
|
82
186
|
|
|
83
187
|
return storageElement( this, indexNode );
|
|
84
188
|
|
|
85
189
|
}
|
|
86
190
|
|
|
191
|
+
/**
|
|
192
|
+
* Defines whether this node is a PBO or not. Only relevant for WebGL.
|
|
193
|
+
*
|
|
194
|
+
* @param {Boolean} value - The value so set.
|
|
195
|
+
* @return {StorageBufferNode} A reference to this node.
|
|
196
|
+
*/
|
|
87
197
|
setPBO( value ) {
|
|
88
198
|
|
|
89
199
|
this.isPBO = value;
|
|
@@ -92,12 +202,23 @@ class StorageBufferNode extends BufferNode {
|
|
|
92
202
|
|
|
93
203
|
}
|
|
94
204
|
|
|
205
|
+
/**
|
|
206
|
+
* Returns the `isPBO` value.
|
|
207
|
+
*
|
|
208
|
+
* @return {Boolean} Whether the node represents a PBO or not.
|
|
209
|
+
*/
|
|
95
210
|
getPBO() {
|
|
96
211
|
|
|
97
212
|
return this.isPBO;
|
|
98
213
|
|
|
99
214
|
}
|
|
100
215
|
|
|
216
|
+
/**
|
|
217
|
+
* Defines the node access.
|
|
218
|
+
*
|
|
219
|
+
* @param {String} value - The node access.
|
|
220
|
+
* @return {StorageBufferNode} A reference to this node.
|
|
221
|
+
*/
|
|
101
222
|
setAccess( value ) {
|
|
102
223
|
|
|
103
224
|
this.access = value;
|
|
@@ -106,12 +227,23 @@ class StorageBufferNode extends BufferNode {
|
|
|
106
227
|
|
|
107
228
|
}
|
|
108
229
|
|
|
230
|
+
/**
|
|
231
|
+
* Convenience method for configuring a read-only node access.
|
|
232
|
+
*
|
|
233
|
+
* @return {StorageBufferNode} A reference to this node.
|
|
234
|
+
*/
|
|
109
235
|
toReadOnly() {
|
|
110
236
|
|
|
111
237
|
return this.setAccess( NodeAccess.READ_ONLY );
|
|
112
238
|
|
|
113
239
|
}
|
|
114
240
|
|
|
241
|
+
/**
|
|
242
|
+
* Defines whether the node is atomic or not.
|
|
243
|
+
*
|
|
244
|
+
* @param {Boolean} value - The atomic flag.
|
|
245
|
+
* @return {StorageBufferNode} A reference to this node.
|
|
246
|
+
*/
|
|
115
247
|
setAtomic( value ) {
|
|
116
248
|
|
|
117
249
|
this.isAtomic = value;
|
|
@@ -120,12 +252,22 @@ class StorageBufferNode extends BufferNode {
|
|
|
120
252
|
|
|
121
253
|
}
|
|
122
254
|
|
|
255
|
+
/**
|
|
256
|
+
* Convenience method for making this node atomic.
|
|
257
|
+
*
|
|
258
|
+
* @return {StorageBufferNode} A reference to this node.
|
|
259
|
+
*/
|
|
123
260
|
toAtomic() {
|
|
124
261
|
|
|
125
262
|
return this.setAtomic( true );
|
|
126
263
|
|
|
127
264
|
}
|
|
128
265
|
|
|
266
|
+
/**
|
|
267
|
+
* Returns attribute data for this storage buffer node.
|
|
268
|
+
*
|
|
269
|
+
* @return {{attribute: BufferAttributeNode, varying: VaryingNode}} The attribute data.
|
|
270
|
+
*/
|
|
129
271
|
getAttributeData() {
|
|
130
272
|
|
|
131
273
|
if ( this._attribute === null ) {
|
|
@@ -142,6 +284,13 @@ class StorageBufferNode extends BufferNode {
|
|
|
142
284
|
|
|
143
285
|
}
|
|
144
286
|
|
|
287
|
+
/**
|
|
288
|
+
* This method is overwritten since the node type from the availability of storage buffers
|
|
289
|
+
* and the attribute data.
|
|
290
|
+
*
|
|
291
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
292
|
+
* @return {String} The node type.
|
|
293
|
+
*/
|
|
145
294
|
getNodeType( builder ) {
|
|
146
295
|
|
|
147
296
|
if ( builder.isAvailable( 'storageBuffer' ) || builder.isAvailable( 'indirectStorageBuffer' ) ) {
|
|
@@ -156,6 +305,12 @@ class StorageBufferNode extends BufferNode {
|
|
|
156
305
|
|
|
157
306
|
}
|
|
158
307
|
|
|
308
|
+
/**
|
|
309
|
+
* Generates the code snippet of the storage buffer node.
|
|
310
|
+
*
|
|
311
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
312
|
+
* @return {String} The generated code snippet.
|
|
313
|
+
*/
|
|
159
314
|
generate( builder ) {
|
|
160
315
|
|
|
161
316
|
if ( builder.isAvailable( 'storageBuffer' ) || builder.isAvailable( 'indirectStorageBuffer' ) ) {
|
|
@@ -178,7 +333,16 @@ class StorageBufferNode extends BufferNode {
|
|
|
178
333
|
|
|
179
334
|
export default StorageBufferNode;
|
|
180
335
|
|
|
181
|
-
|
|
336
|
+
/**
|
|
337
|
+
* TSL function for creating a storage buffer node.
|
|
338
|
+
*
|
|
339
|
+
* @function
|
|
340
|
+
* @param {StorageBufferAttribute|StorageInstancedBufferAttribute|BufferAttribute} value - The buffer data.
|
|
341
|
+
* @param {String?} [type=null] - The buffer type (e.g. `'vec3'`).
|
|
342
|
+
* @param {Number} [count=0] - The buffer count.
|
|
343
|
+
* @returns {StorageBufferNode}
|
|
344
|
+
*/
|
|
345
|
+
export const storage = ( value, type = null, count = 0 ) => nodeObject( new StorageBufferNode( value, type, count ) );
|
|
182
346
|
|
|
183
347
|
export const storageObject = ( value, type, count ) => { // @deprecated, r171
|
|
184
348
|
|