super-three 0.171.0 → 0.173.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/build/three.cjs +594 -427
- package/build/three.core.js +515 -81
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +79 -350
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +20 -7
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +29362 -3427
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +29361 -3427
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/Addons.js +0 -5
- package/examples/jsm/animation/CCDIKSolver.js +9 -7
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +48 -37
- 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 +34 -29
- package/examples/jsm/exporters/KTX2Exporter.js +1 -1
- package/examples/jsm/exporters/PLYExporter.js +2 -2
- package/examples/jsm/geometries/TextGeometry.js +1 -12
- package/examples/jsm/helpers/TextureHelperGPU.js +15 -5
- package/examples/jsm/helpers/VertexNormalsHelper.js +2 -0
- package/examples/jsm/interactive/InteractiveGroup.js +108 -51
- package/examples/jsm/libs/demuxer_mp4.js +109 -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 +4 -2
- package/examples/jsm/loaders/GLTFLoader.js +22 -4
- 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 -2
- 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/materials/MeshGouraudMaterial.js +2 -0
- package/examples/jsm/math/ConvexHull.js +1 -1
- package/examples/jsm/math/OBB.js +17 -0
- package/examples/jsm/misc/GPUComputationRenderer.js +6 -7
- package/examples/jsm/misc/ProgressiveLightMap.js +4 -3
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +14 -13
- package/examples/jsm/misc/Volume.js +27 -17
- package/examples/jsm/misc/VolumeSlice.js +7 -5
- 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 +29 -24
- package/examples/jsm/physics/JoltPhysics.js +7 -7
- package/examples/jsm/physics/RapierPhysics.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/OutputPass.js +2 -0
- 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/OutputShader.js +5 -1
- package/examples/jsm/shaders/SobelOperatorShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
- package/examples/jsm/transpiler/TSLEncoder.js +2 -0
- 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 +4 -0
- package/src/Three.Legacy.js +0 -21
- package/src/Three.TSL.js +18 -5
- 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/ArrayCamera.js +1 -0
- package/src/cameras/PerspectiveCamera.js +18 -2
- package/src/constants.js +6 -1
- package/src/core/BufferAttribute.js +4 -0
- package/src/core/EventDispatcher.js +8 -6
- 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/ImageUtils.js +1 -11
- 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/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 +476 -23
- package/src/materials/nodes/NodeMaterials.js +0 -1
- package/src/materials/nodes/PointsNodeMaterial.js +121 -10
- package/src/materials/nodes/ShadowNodeMaterial.js +29 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +78 -20
- package/src/materials/nodes/VolumeNodeMaterial.js +80 -4
- package/src/materials/nodes/manager/NodeMaterialObserver.js +95 -0
- package/src/nodes/Nodes.js +5 -6
- package/src/nodes/TSL.js +6 -3
- package/src/nodes/accessors/AccessorsUtils.js +27 -0
- package/src/nodes/accessors/Arrays.js +47 -6
- package/src/nodes/accessors/BatchNode.js +42 -6
- 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 +113 -3
- 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/Lights.js +50 -1
- package/src/nodes/accessors/MaterialNode.js +306 -12
- 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 +65 -5
- package/src/nodes/accessors/Object3DNode.js +101 -1
- package/src/nodes/accessors/PointUVNode.js +26 -0
- package/src/nodes/accessors/Position.js +56 -7
- package/src/nodes/accessors/ReferenceBaseNode.js +186 -0
- package/src/nodes/accessors/ReferenceNode.js +201 -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 +209 -8
- package/src/nodes/accessors/StorageTextureNode.js +118 -0
- package/src/nodes/accessors/Tangent.js +38 -2
- package/src/nodes/accessors/Texture3DNode.js +91 -7
- package/src/nodes/accessors/TextureBicubic.js +12 -2
- package/src/nodes/accessors/TextureNode.js +316 -10
- package/src/nodes/accessors/TextureSizeNode.js +42 -0
- package/src/nodes/accessors/UV.js +10 -1
- package/src/nodes/accessors/UniformArrayNode.js +231 -25
- package/src/nodes/accessors/UserDataNode.js +46 -0
- package/src/nodes/accessors/VelocityNode.js +80 -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/ArrayNode.js +125 -0
- 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 +32 -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 +350 -12
- package/src/nodes/core/NodeAttribute.js +38 -0
- package/src/nodes/core/NodeBuilder.js +1166 -26
- 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 +152 -1
- package/src/nodes/core/NodeVar.js +47 -1
- package/src/nodes/core/NodeVarying.js +28 -0
- package/src/nodes/core/OutputStructNode.js +51 -10
- package/src/nodes/core/ParameterNode.js +28 -0
- package/src/nodes/core/PropertyNode.js +232 -0
- package/src/nodes/core/StackNode.js +98 -1
- package/src/nodes/core/StructNode.js +121 -0
- package/src/nodes/core/StructType.js +13 -0
- package/src/nodes/core/StructTypeNode.js +105 -6
- package/src/nodes/core/TempNode.js +31 -5
- package/src/nodes/core/UniformGroupNode.js +82 -7
- package/src/nodes/core/UniformNode.js +66 -0
- package/src/nodes/core/VarNode.js +146 -7
- package/src/nodes/core/VaryingNode.js +100 -3
- package/src/nodes/core/constants.js +36 -0
- package/src/nodes/display/BlendModes.js +88 -1
- 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 +300 -7
- package/src/nodes/display/PosterizeNode.js +33 -0
- package/src/nodes/display/RenderOutputNode.js +66 -1
- package/src/nodes/display/ScreenNode.js +96 -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 +110 -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 +174 -2
- package/src/nodes/gpgpu/BarrierNode.js +47 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +134 -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 +241 -35
- package/src/nodes/lighting/SpotLightNode.js +43 -0
- package/src/nodes/math/ConditionalNode.js +78 -4
- package/src/nodes/math/Hash.js +9 -0
- package/src/nodes/math/MathNode.js +627 -11
- package/src/nodes/math/MathUtils.js +45 -1
- package/src/nodes/math/OperatorNode.js +329 -18
- 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 +2 -2
- package/src/nodes/procedural/Checker.js +9 -0
- package/src/nodes/shapes/Shapes.js +33 -0
- package/src/nodes/tsl/TSLBase.js +3 -2
- package/src/nodes/tsl/TSLCore.js +22 -2
- package/src/nodes/utils/ArrayElementNode.js +39 -3
- 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 +82 -2
- package/src/nodes/utils/MatcapUVNode.js +17 -0
- package/src/nodes/utils/MaxMipLevelNode.js +49 -0
- package/src/nodes/utils/MemberNode.js +68 -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 +54 -0
- package/src/nodes/utils/Timer.js +40 -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 +2 -3
- package/src/objects/ClippingGroup.js +49 -0
- package/src/objects/Line.js +6 -6
- package/src/renderers/WebGLRenderer.js +30 -4
- package/src/renderers/common/Animation.js +85 -0
- package/src/renderers/common/Attributes.js +36 -0
- package/src/renderers/common/Backend.js +502 -44
- package/src/renderers/common/Background.js +48 -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 +45 -6
- package/src/renderers/common/ClippingContext.js +108 -15
- package/src/renderers/common/Color4.js +40 -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 +91 -14
- package/src/renderers/common/IndirectStorageBufferAttribute.js +25 -2
- package/src/renderers/common/Info.js +78 -35
- package/src/renderers/common/Lighting.js +34 -6
- package/src/renderers/common/Pipeline.js +22 -0
- package/src/renderers/common/Pipelines.js +148 -5
- package/src/renderers/common/PostProcessing.js +99 -11
- 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 +39 -10
- package/src/renderers/common/RenderContext.js +201 -2
- package/src/renderers/common/RenderContexts.js +59 -6
- package/src/renderers/common/RenderList.js +178 -0
- package/src/renderers/common/RenderLists.js +40 -3
- package/src/renderers/common/RenderObject.js +400 -17
- package/src/renderers/common/RenderObjects.js +103 -7
- package/src/renderers/common/RenderPipeline.js +24 -0
- package/src/renderers/common/Renderer.js +1170 -86
- package/src/renderers/common/RendererUtils.js +193 -0
- package/src/renderers/common/SampledTexture.js +120 -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 +97 -7
- package/src/renderers/common/TimestampQueryPool.js +39 -0
- package/src/renderers/common/Uniform.js +225 -3
- package/src/renderers/common/UniformBuffer.js +19 -0
- package/src/renderers/common/UniformsGroup.js +141 -2
- package/src/renderers/common/XRManager.js +1193 -0
- package/src/renderers/common/XRRenderTarget.js +74 -0
- package/src/renderers/common/extras/PMREMGenerator.js +76 -10
- package/src/renderers/common/nodes/NodeBuilderState.js +99 -5
- package/src/renderers/common/nodes/NodeLibrary.js +89 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +90 -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 +243 -2
- 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 +352 -78
- 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/WebGLBackground.js +4 -0
- package/src/renderers/webgl-fallback/WebGLBackend.js +819 -116
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +347 -18
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +58 -1
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +28 -0
- package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +45 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +323 -11
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +168 -22
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +359 -0
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +43 -0
- package/src/renderers/webgpu/WebGPUBackend.js +578 -164
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +36 -0
- package/src/renderers/webgpu/WebGPURenderer.js +36 -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 +674 -52
- 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 +95 -14
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +94 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +102 -3
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +98 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +262 -18
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +274 -0
- package/src/renderers/webgpu/utils/WebGPUUtils.js +116 -4
- package/src/renderers/webxr/WebXRDepthSensing.js +1 -1
- package/src/renderers/webxr/WebXRManager.js +19 -2
- package/src/textures/Data3DTexture.js +2 -2
- package/src/textures/Texture.js +4 -0
- package/src/textures/VideoFrameTexture.js +35 -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/geometries/InstancedPointsGeometry.js +0 -176
- package/examples/jsm/libs/mmdparser.module.js +0 -11530
- package/examples/jsm/loaders/MMDLoader.js +0 -2298
- package/examples/jsm/objects/InstancedPoints.js +0 -19
- package/examples/jsm/shaders/MMDToonShader.js +0 -134
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +0 -156
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +0 -24
- package/src/nodes/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,33 +46,105 @@ 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|Struct)?} [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
|
+
let nodeType, structTypeNode = null;
|
|
19
59
|
|
|
20
|
-
|
|
60
|
+
if ( bufferType && bufferType.isStruct ) {
|
|
61
|
+
|
|
62
|
+
nodeType = 'struct';
|
|
63
|
+
structTypeNode = bufferType.layout;
|
|
64
|
+
|
|
65
|
+
} else if ( bufferType === null && ( value.isStorageBufferAttribute || value.isStorageInstancedBufferAttribute ) ) {
|
|
66
|
+
|
|
67
|
+
nodeType = getTypeFromLength( value.itemSize );
|
|
21
68
|
bufferCount = value.count;
|
|
22
69
|
|
|
70
|
+
} else {
|
|
71
|
+
|
|
72
|
+
nodeType = bufferType;
|
|
73
|
+
|
|
23
74
|
}
|
|
24
75
|
|
|
25
|
-
super( value,
|
|
76
|
+
super( value, nodeType, bufferCount );
|
|
26
77
|
|
|
78
|
+
/**
|
|
79
|
+
* This flag can be used for type testing.
|
|
80
|
+
*
|
|
81
|
+
* @type {Boolean}
|
|
82
|
+
* @readonly
|
|
83
|
+
* @default true
|
|
84
|
+
*/
|
|
27
85
|
this.isStorageBufferNode = true;
|
|
28
86
|
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The buffer struct type.
|
|
90
|
+
*
|
|
91
|
+
* @type {structTypeNode?}
|
|
92
|
+
* @default null
|
|
93
|
+
*/
|
|
94
|
+
this.structTypeNode = structTypeNode;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The access type of the texture node.
|
|
98
|
+
*
|
|
99
|
+
* @type {String}
|
|
100
|
+
* @default 'readWrite'
|
|
101
|
+
*/
|
|
29
102
|
this.access = NodeAccess.READ_WRITE;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Whether the node is atomic or not.
|
|
106
|
+
*
|
|
107
|
+
* @type {Boolean}
|
|
108
|
+
* @default false
|
|
109
|
+
*/
|
|
30
110
|
this.isAtomic = false;
|
|
31
|
-
this.isPBO = false;
|
|
32
111
|
|
|
33
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Whether the node represents a PBO or not.
|
|
114
|
+
* Only relevant for WebGL.
|
|
115
|
+
*
|
|
116
|
+
* @type {Boolean}
|
|
117
|
+
* @default false
|
|
118
|
+
*/
|
|
119
|
+
this.isPBO = false;
|
|
34
120
|
|
|
121
|
+
/**
|
|
122
|
+
* A reference to the internal buffer attribute node.
|
|
123
|
+
*
|
|
124
|
+
* @type {BufferAttributeNode?}
|
|
125
|
+
* @default null
|
|
126
|
+
*/
|
|
35
127
|
this._attribute = null;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* A reference to the internal varying node.
|
|
131
|
+
*
|
|
132
|
+
* @type {VaryingNode?}
|
|
133
|
+
* @default null
|
|
134
|
+
*/
|
|
36
135
|
this._varying = null;
|
|
37
136
|
|
|
137
|
+
/**
|
|
138
|
+
* `StorageBufferNode` sets this property to `true` by default.
|
|
139
|
+
*
|
|
140
|
+
* @type {Boolean}
|
|
141
|
+
* @default true
|
|
142
|
+
*/
|
|
38
143
|
this.global = true;
|
|
39
144
|
|
|
40
145
|
if ( value.isStorageBufferAttribute !== true && value.isStorageInstancedBufferAttribute !== true ) {
|
|
41
146
|
|
|
42
|
-
//
|
|
147
|
+
// TODO: Improve it, possibly adding a new property to the BufferAttribute to identify it as a storage buffer read-only attribute in Renderer
|
|
43
148
|
|
|
44
149
|
if ( value.isInstancedBufferAttribute ) value.isStorageInstancedBufferAttribute = true;
|
|
45
150
|
else value.isStorageBufferAttribute = true;
|
|
@@ -48,6 +153,13 @@ class StorageBufferNode extends BufferNode {
|
|
|
48
153
|
|
|
49
154
|
}
|
|
50
155
|
|
|
156
|
+
/**
|
|
157
|
+
* This method is overwritten since the buffer data might be shared
|
|
158
|
+
* and thus the hash should be shared as well.
|
|
159
|
+
*
|
|
160
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
161
|
+
* @return {String} The hash.
|
|
162
|
+
*/
|
|
51
163
|
getHash( builder ) {
|
|
52
164
|
|
|
53
165
|
if ( this.bufferCount === 0 ) {
|
|
@@ -72,18 +184,36 @@ class StorageBufferNode extends BufferNode {
|
|
|
72
184
|
|
|
73
185
|
}
|
|
74
186
|
|
|
187
|
+
/**
|
|
188
|
+
* Overwrites the default implementation to return a fixed value `'indirectStorageBuffer'` or `'storageBuffer'`.
|
|
189
|
+
*
|
|
190
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
191
|
+
* @return {String} The input type.
|
|
192
|
+
*/
|
|
75
193
|
getInputType( /*builder*/ ) {
|
|
76
194
|
|
|
77
195
|
return this.value.isIndirectStorageBufferAttribute ? 'indirectStorageBuffer' : 'storageBuffer';
|
|
78
196
|
|
|
79
197
|
}
|
|
80
198
|
|
|
199
|
+
/**
|
|
200
|
+
* Enables element access with the given index node.
|
|
201
|
+
*
|
|
202
|
+
* @param {IndexNode} indexNode - The index node.
|
|
203
|
+
* @return {StorageArrayElementNode} A node representing the element access.
|
|
204
|
+
*/
|
|
81
205
|
element( indexNode ) {
|
|
82
206
|
|
|
83
207
|
return storageElement( this, indexNode );
|
|
84
208
|
|
|
85
209
|
}
|
|
86
210
|
|
|
211
|
+
/**
|
|
212
|
+
* Defines whether this node is a PBO or not. Only relevant for WebGL.
|
|
213
|
+
*
|
|
214
|
+
* @param {Boolean} value - The value so set.
|
|
215
|
+
* @return {StorageBufferNode} A reference to this node.
|
|
216
|
+
*/
|
|
87
217
|
setPBO( value ) {
|
|
88
218
|
|
|
89
219
|
this.isPBO = value;
|
|
@@ -92,12 +222,23 @@ class StorageBufferNode extends BufferNode {
|
|
|
92
222
|
|
|
93
223
|
}
|
|
94
224
|
|
|
225
|
+
/**
|
|
226
|
+
* Returns the `isPBO` value.
|
|
227
|
+
*
|
|
228
|
+
* @return {Boolean} Whether the node represents a PBO or not.
|
|
229
|
+
*/
|
|
95
230
|
getPBO() {
|
|
96
231
|
|
|
97
232
|
return this.isPBO;
|
|
98
233
|
|
|
99
234
|
}
|
|
100
235
|
|
|
236
|
+
/**
|
|
237
|
+
* Defines the node access.
|
|
238
|
+
*
|
|
239
|
+
* @param {String} value - The node access.
|
|
240
|
+
* @return {StorageBufferNode} A reference to this node.
|
|
241
|
+
*/
|
|
101
242
|
setAccess( value ) {
|
|
102
243
|
|
|
103
244
|
this.access = value;
|
|
@@ -106,12 +247,23 @@ class StorageBufferNode extends BufferNode {
|
|
|
106
247
|
|
|
107
248
|
}
|
|
108
249
|
|
|
250
|
+
/**
|
|
251
|
+
* Convenience method for configuring a read-only node access.
|
|
252
|
+
*
|
|
253
|
+
* @return {StorageBufferNode} A reference to this node.
|
|
254
|
+
*/
|
|
109
255
|
toReadOnly() {
|
|
110
256
|
|
|
111
257
|
return this.setAccess( NodeAccess.READ_ONLY );
|
|
112
258
|
|
|
113
259
|
}
|
|
114
260
|
|
|
261
|
+
/**
|
|
262
|
+
* Defines whether the node is atomic or not.
|
|
263
|
+
*
|
|
264
|
+
* @param {Boolean} value - The atomic flag.
|
|
265
|
+
* @return {StorageBufferNode} A reference to this node.
|
|
266
|
+
*/
|
|
115
267
|
setAtomic( value ) {
|
|
116
268
|
|
|
117
269
|
this.isAtomic = value;
|
|
@@ -120,12 +272,22 @@ class StorageBufferNode extends BufferNode {
|
|
|
120
272
|
|
|
121
273
|
}
|
|
122
274
|
|
|
275
|
+
/**
|
|
276
|
+
* Convenience method for making this node atomic.
|
|
277
|
+
*
|
|
278
|
+
* @return {StorageBufferNode} A reference to this node.
|
|
279
|
+
*/
|
|
123
280
|
toAtomic() {
|
|
124
281
|
|
|
125
282
|
return this.setAtomic( true );
|
|
126
283
|
|
|
127
284
|
}
|
|
128
285
|
|
|
286
|
+
/**
|
|
287
|
+
* Returns attribute data for this storage buffer node.
|
|
288
|
+
*
|
|
289
|
+
* @return {{attribute: BufferAttributeNode, varying: VaryingNode}} The attribute data.
|
|
290
|
+
*/
|
|
129
291
|
getAttributeData() {
|
|
130
292
|
|
|
131
293
|
if ( this._attribute === null ) {
|
|
@@ -142,8 +304,21 @@ class StorageBufferNode extends BufferNode {
|
|
|
142
304
|
|
|
143
305
|
}
|
|
144
306
|
|
|
307
|
+
/**
|
|
308
|
+
* This method is overwritten since the node type from the availability of storage buffers
|
|
309
|
+
* and the attribute data.
|
|
310
|
+
*
|
|
311
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
312
|
+
* @return {String} The node type.
|
|
313
|
+
*/
|
|
145
314
|
getNodeType( builder ) {
|
|
146
315
|
|
|
316
|
+
if ( this.structTypeNode !== null ) {
|
|
317
|
+
|
|
318
|
+
return this.structTypeNode.getNodeType( builder );
|
|
319
|
+
|
|
320
|
+
}
|
|
321
|
+
|
|
147
322
|
if ( builder.isAvailable( 'storageBuffer' ) || builder.isAvailable( 'indirectStorageBuffer' ) ) {
|
|
148
323
|
|
|
149
324
|
return super.getNodeType( builder );
|
|
@@ -156,8 +331,16 @@ class StorageBufferNode extends BufferNode {
|
|
|
156
331
|
|
|
157
332
|
}
|
|
158
333
|
|
|
334
|
+
/**
|
|
335
|
+
* Generates the code snippet of the storage buffer node.
|
|
336
|
+
*
|
|
337
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
338
|
+
* @return {String} The generated code snippet.
|
|
339
|
+
*/
|
|
159
340
|
generate( builder ) {
|
|
160
341
|
|
|
342
|
+
if ( this.structTypeNode !== null ) this.structTypeNode.build( builder );
|
|
343
|
+
|
|
161
344
|
if ( builder.isAvailable( 'storageBuffer' ) || builder.isAvailable( 'indirectStorageBuffer' ) ) {
|
|
162
345
|
|
|
163
346
|
return super.generate( builder );
|
|
@@ -178,8 +361,26 @@ class StorageBufferNode extends BufferNode {
|
|
|
178
361
|
|
|
179
362
|
export default StorageBufferNode;
|
|
180
363
|
|
|
181
|
-
|
|
182
|
-
|
|
364
|
+
/**
|
|
365
|
+
* TSL function for creating a storage buffer node.
|
|
366
|
+
*
|
|
367
|
+
* @function
|
|
368
|
+
* @param {StorageBufferAttribute|StorageInstancedBufferAttribute|BufferAttribute} value - The buffer data.
|
|
369
|
+
* @param {(String|Struct)?} [type=null] - The buffer type (e.g. `'vec3'`).
|
|
370
|
+
* @param {Number} [count=0] - The buffer count.
|
|
371
|
+
* @returns {StorageBufferNode}
|
|
372
|
+
*/
|
|
373
|
+
export const storage = ( value, type = null, count = 0 ) => nodeObject( new StorageBufferNode( value, type, count ) );
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* @function
|
|
377
|
+
* @deprecated since r171. Use `storage().setPBO( true )` instead.
|
|
378
|
+
*
|
|
379
|
+
* @param {StorageBufferAttribute|StorageInstancedBufferAttribute|BufferAttribute} value - The buffer data.
|
|
380
|
+
* @param {String?} type - The buffer type (e.g. `'vec3'`).
|
|
381
|
+
* @param {Number} count - The buffer count.
|
|
382
|
+
* @returns {StorageBufferNode}
|
|
383
|
+
*/
|
|
183
384
|
export const storageObject = ( value, type, count ) => { // @deprecated, r171
|
|
184
385
|
|
|
185
386
|
console.warn( 'THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.' );
|