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
|
@@ -4,6 +4,13 @@ import { getValueType } from '../core/NodeUtils.js';
|
|
|
4
4
|
import ArrayElementNode from '../utils/ArrayElementNode.js';
|
|
5
5
|
import BufferNode from './BufferNode.js';
|
|
6
6
|
|
|
7
|
+
/** @module UniformArrayNode **/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Represents the element access on uniform array nodes.
|
|
11
|
+
*
|
|
12
|
+
* @augments ArrayElementNode
|
|
13
|
+
*/
|
|
7
14
|
class UniformArrayElementNode extends ArrayElementNode {
|
|
8
15
|
|
|
9
16
|
static get type() {
|
|
@@ -12,10 +19,23 @@ class UniformArrayElementNode extends ArrayElementNode {
|
|
|
12
19
|
|
|
13
20
|
}
|
|
14
21
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Constructs a new buffer node.
|
|
24
|
+
*
|
|
25
|
+
* @param {UniformArrayNode} uniformArrayNode - The uniform array node to access.
|
|
26
|
+
* @param {IndexNode} indexNode - The index data that define the position of the accessed element in the array.
|
|
27
|
+
*/
|
|
28
|
+
constructor( uniformArrayNode, indexNode ) {
|
|
29
|
+
|
|
30
|
+
super( uniformArrayNode, indexNode );
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* This flag can be used for type testing.
|
|
34
|
+
*
|
|
35
|
+
* @type {Boolean}
|
|
36
|
+
* @readonly
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
19
39
|
this.isArrayBufferElementNode = true;
|
|
20
40
|
|
|
21
41
|
}
|
|
@@ -24,13 +44,31 @@ class UniformArrayElementNode extends ArrayElementNode {
|
|
|
24
44
|
|
|
25
45
|
const snippet = super.generate( builder );
|
|
26
46
|
const type = this.getNodeType();
|
|
47
|
+
const paddedType = this.node.getPaddedType();
|
|
27
48
|
|
|
28
|
-
return builder.format( snippet,
|
|
49
|
+
return builder.format( snippet, paddedType, type );
|
|
29
50
|
|
|
30
51
|
}
|
|
31
52
|
|
|
32
53
|
}
|
|
33
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Similar to {@link module:BufferNode~BufferNode} this module represents array-like data as
|
|
57
|
+
* uniform buffers. Unlike {@link module:BufferNode~BufferNode}, it can handle more common
|
|
58
|
+
* data types in the array (e.g `three.js` primitives) and automatically
|
|
59
|
+
* manage buffer padding. It should be the first choice when working with
|
|
60
|
+
* uniforms buffers.
|
|
61
|
+
* ```js
|
|
62
|
+
* const tintColors = uniformArray( [
|
|
63
|
+
* new Color( 1, 0, 0 ),
|
|
64
|
+
* new Color( 0, 1, 0 ),
|
|
65
|
+
* new Color( 0, 0, 1 )
|
|
66
|
+
* ], 'color' );
|
|
67
|
+
*
|
|
68
|
+
* const redColor = tintColors.element( 0 );
|
|
69
|
+
*
|
|
70
|
+
* @augments module:BufferNode~BufferNode
|
|
71
|
+
*/
|
|
34
72
|
class UniformArrayNode extends BufferNode {
|
|
35
73
|
|
|
36
74
|
static get type() {
|
|
@@ -39,42 +77,130 @@ class UniformArrayNode extends BufferNode {
|
|
|
39
77
|
|
|
40
78
|
}
|
|
41
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Constructs a new uniform array node.
|
|
82
|
+
*
|
|
83
|
+
* @param {Array<Any>} value - Array holding the buffer data.
|
|
84
|
+
* @param {String?} [elementType=null] - The data type of a buffer element.
|
|
85
|
+
*/
|
|
42
86
|
constructor( value, elementType = null ) {
|
|
43
87
|
|
|
44
|
-
super( null
|
|
88
|
+
super( null );
|
|
45
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Array holding the buffer data. Unlike {@link module:BufferNode~BufferNode}, the array can
|
|
92
|
+
* hold number primitives as well as three.js objects like vectors, matrices
|
|
93
|
+
* or colors.
|
|
94
|
+
*
|
|
95
|
+
* @type {Array<Any>}
|
|
96
|
+
*/
|
|
46
97
|
this.array = value;
|
|
47
|
-
this.elementType = elementType;
|
|
48
|
-
|
|
49
|
-
this._elementType = null;
|
|
50
|
-
this._elementLength = 0;
|
|
51
98
|
|
|
99
|
+
/**
|
|
100
|
+
* The data type of an array element.
|
|
101
|
+
*
|
|
102
|
+
* @type {String}
|
|
103
|
+
*/
|
|
104
|
+
this.elementType = elementType === null ? getValueType( value[ 0 ] ) : elementType;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The padded type. Uniform buffers must conform to a certain buffer layout
|
|
108
|
+
* so a separate type is computed to ensure correct buffer size.
|
|
109
|
+
*
|
|
110
|
+
* @type {String}
|
|
111
|
+
*/
|
|
112
|
+
this.paddedType = this.getPaddedType();
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Overwritten since uniform array nodes are updated per render.
|
|
116
|
+
*
|
|
117
|
+
* @type {String}
|
|
118
|
+
* @default 'render'
|
|
119
|
+
*/
|
|
52
120
|
this.updateType = NodeUpdateType.RENDER;
|
|
53
121
|
|
|
122
|
+
/**
|
|
123
|
+
* This flag can be used for type testing.
|
|
124
|
+
*
|
|
125
|
+
* @type {Boolean}
|
|
126
|
+
* @readonly
|
|
127
|
+
* @default true
|
|
128
|
+
*/
|
|
54
129
|
this.isArrayBufferNode = true;
|
|
55
130
|
|
|
56
131
|
}
|
|
57
132
|
|
|
133
|
+
/**
|
|
134
|
+
* This method is overwritten since the node type is inferred from the
|
|
135
|
+
* {@link module:UniformArrayNode~UniformArrayNode#paddedType}.
|
|
136
|
+
*
|
|
137
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
138
|
+
* @return {String} The node type.
|
|
139
|
+
*/
|
|
140
|
+
getNodeType( /*builder*/ ) {
|
|
141
|
+
|
|
142
|
+
return this.paddedType;
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The data type of the array elements.
|
|
148
|
+
*
|
|
149
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
150
|
+
* @return {String} The element type.
|
|
151
|
+
*/
|
|
58
152
|
getElementType() {
|
|
59
153
|
|
|
60
|
-
return this.elementType
|
|
154
|
+
return this.elementType;
|
|
61
155
|
|
|
62
156
|
}
|
|
63
157
|
|
|
64
|
-
|
|
158
|
+
/**
|
|
159
|
+
* Returns the padded type based on the element type.
|
|
160
|
+
*
|
|
161
|
+
* @return {String} The padded type.
|
|
162
|
+
*/
|
|
163
|
+
getPaddedType() {
|
|
164
|
+
|
|
165
|
+
const elementType = this.elementType;
|
|
166
|
+
|
|
167
|
+
let paddedType = 'vec4';
|
|
168
|
+
|
|
169
|
+
if ( elementType === 'mat2' ) {
|
|
170
|
+
|
|
171
|
+
paddedType = 'mat2';
|
|
172
|
+
|
|
173
|
+
} else if ( /mat/.test( elementType ) === true ) {
|
|
65
174
|
|
|
66
|
-
|
|
175
|
+
paddedType = 'mat4';
|
|
176
|
+
|
|
177
|
+
} else if ( elementType.charAt( 0 ) === 'i' ) {
|
|
178
|
+
|
|
179
|
+
paddedType = 'ivec4';
|
|
180
|
+
|
|
181
|
+
} else if ( elementType.charAt( 0 ) === 'u' ) {
|
|
182
|
+
|
|
183
|
+
paddedType = 'uvec4';
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return paddedType;
|
|
67
188
|
|
|
68
189
|
}
|
|
69
190
|
|
|
191
|
+
/**
|
|
192
|
+
* The update makes sure to correctly transfer the data from the (complex) objects
|
|
193
|
+
* in the array to the internal, correctly padded value buffer.
|
|
194
|
+
*
|
|
195
|
+
* @param {NodeFrame} frame - A reference to the current node frame.
|
|
196
|
+
*/
|
|
70
197
|
update( /*frame*/ ) {
|
|
71
198
|
|
|
72
199
|
const { array, value } = this;
|
|
73
200
|
|
|
74
|
-
const
|
|
75
|
-
const elementType = this.getElementType();
|
|
201
|
+
const elementType = this.elementType;
|
|
76
202
|
|
|
77
|
-
if (
|
|
203
|
+
if ( elementType === 'float' || elementType === 'int' || elementType === 'uint' ) {
|
|
78
204
|
|
|
79
205
|
for ( let i = 0; i < array.length; i ++ ) {
|
|
80
206
|
|
|
@@ -98,6 +224,58 @@ class UniformArrayNode extends BufferNode {
|
|
|
98
224
|
|
|
99
225
|
}
|
|
100
226
|
|
|
227
|
+
} else if ( elementType === 'mat2' ) {
|
|
228
|
+
|
|
229
|
+
for ( let i = 0; i < array.length; i ++ ) {
|
|
230
|
+
|
|
231
|
+
const index = i * 4;
|
|
232
|
+
const matrix = array[ i ];
|
|
233
|
+
|
|
234
|
+
value[ index ] = matrix.elements[ 0 ];
|
|
235
|
+
value[ index + 1 ] = matrix.elements[ 1 ];
|
|
236
|
+
value[ index + 2 ] = matrix.elements[ 2 ];
|
|
237
|
+
value[ index + 3 ] = matrix.elements[ 3 ];
|
|
238
|
+
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
} else if ( elementType === 'mat3' ) {
|
|
242
|
+
|
|
243
|
+
for ( let i = 0; i < array.length; i ++ ) {
|
|
244
|
+
|
|
245
|
+
const index = i * 16;
|
|
246
|
+
const matrix = array[ i ];
|
|
247
|
+
|
|
248
|
+
value[ index ] = matrix.elements[ 0 ];
|
|
249
|
+
value[ index + 1 ] = matrix.elements[ 1 ];
|
|
250
|
+
value[ index + 2 ] = matrix.elements[ 2 ];
|
|
251
|
+
|
|
252
|
+
value[ index + 4 ] = matrix.elements[ 3 ];
|
|
253
|
+
value[ index + 5 ] = matrix.elements[ 4 ];
|
|
254
|
+
value[ index + 6 ] = matrix.elements[ 5 ];
|
|
255
|
+
|
|
256
|
+
value[ index + 8 ] = matrix.elements[ 6 ];
|
|
257
|
+
value[ index + 9 ] = matrix.elements[ 7 ];
|
|
258
|
+
value[ index + 10 ] = matrix.elements[ 8 ];
|
|
259
|
+
|
|
260
|
+
value[ index + 15 ] = 1;
|
|
261
|
+
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
} else if ( elementType === 'mat4' ) {
|
|
265
|
+
|
|
266
|
+
for ( let i = 0; i < array.length; i ++ ) {
|
|
267
|
+
|
|
268
|
+
const index = i * 16;
|
|
269
|
+
const matrix = array[ i ];
|
|
270
|
+
|
|
271
|
+
for ( let i = 0; i < matrix.elements.length; i ++ ) {
|
|
272
|
+
|
|
273
|
+
value[ index + i ] = matrix.elements[ i ];
|
|
274
|
+
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
}
|
|
278
|
+
|
|
101
279
|
} else {
|
|
102
280
|
|
|
103
281
|
for ( let i = 0; i < array.length; i ++ ) {
|
|
@@ -116,26 +294,40 @@ class UniformArrayNode extends BufferNode {
|
|
|
116
294
|
|
|
117
295
|
}
|
|
118
296
|
|
|
297
|
+
/**
|
|
298
|
+
* Implement the value buffer creation based on the array data.
|
|
299
|
+
*
|
|
300
|
+
* @param {NodeBuilder} builder - A reference to the current node builder.
|
|
301
|
+
* @return {null}
|
|
302
|
+
*/
|
|
119
303
|
setup( builder ) {
|
|
120
304
|
|
|
121
305
|
const length = this.array.length;
|
|
122
|
-
|
|
123
|
-
this._elementType = this.elementType === null ? getValueType( this.array[ 0 ] ) : this.elementType;
|
|
124
|
-
this._elementLength = builder.getTypeLength( this._elementType );
|
|
306
|
+
const elementType = this.elementType;
|
|
125
307
|
|
|
126
308
|
let arrayType = Float32Array;
|
|
127
309
|
|
|
128
|
-
|
|
129
|
-
|
|
310
|
+
const paddedType = this.paddedType;
|
|
311
|
+
const paddedElementLength = builder.getTypeLength( paddedType );
|
|
312
|
+
|
|
313
|
+
if ( elementType.charAt( 0 ) === 'i' ) arrayType = Int32Array;
|
|
314
|
+
if ( elementType.charAt( 0 ) === 'u' ) arrayType = Uint32Array;
|
|
130
315
|
|
|
131
|
-
this.value = new arrayType( length *
|
|
316
|
+
this.value = new arrayType( length * paddedElementLength );
|
|
132
317
|
this.bufferCount = length;
|
|
133
|
-
this.bufferType =
|
|
318
|
+
this.bufferType = paddedType;
|
|
134
319
|
|
|
135
320
|
return super.setup( builder );
|
|
136
321
|
|
|
137
322
|
}
|
|
138
323
|
|
|
324
|
+
/**
|
|
325
|
+
* Overwrites the default `element()` method to provide element access
|
|
326
|
+
* based on {@link module:UniformArrayNode~UniformArrayNode}.
|
|
327
|
+
*
|
|
328
|
+
* @param {IndexNode} indexNode - The index node.
|
|
329
|
+
* @return {UniformArrayElementNode}
|
|
330
|
+
*/
|
|
139
331
|
element( indexNode ) {
|
|
140
332
|
|
|
141
333
|
return nodeObject( new UniformArrayElementNode( this, nodeObject( indexNode ) ) );
|
|
@@ -146,6 +338,14 @@ class UniformArrayNode extends BufferNode {
|
|
|
146
338
|
|
|
147
339
|
export default UniformArrayNode;
|
|
148
340
|
|
|
341
|
+
/**
|
|
342
|
+
* TSL function for creating an uniform array node.
|
|
343
|
+
*
|
|
344
|
+
* @function
|
|
345
|
+
* @param {Array<Any>} values - Array-like data.
|
|
346
|
+
* @param {String} nodeType - The data type of the array elements.
|
|
347
|
+
* @returns {UniformArrayNode}
|
|
348
|
+
*/
|
|
149
349
|
export const uniformArray = ( values, nodeType ) => nodeObject( new UniformArrayNode( values, nodeType ) );
|
|
150
350
|
|
|
151
351
|
//
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import ReferenceNode from './ReferenceNode.js';
|
|
2
2
|
import { nodeObject } from '../tsl/TSLBase.js';
|
|
3
3
|
|
|
4
|
+
/** @module UserDataNode **/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A special type of reference node that allows to link values in
|
|
8
|
+
* `userData` fields to node objects.
|
|
9
|
+
* ```js
|
|
10
|
+
* sprite.userData.rotation = 1; // stores individual rotation per sprite
|
|
11
|
+
*
|
|
12
|
+
* const material = new THREE.SpriteNodeMaterial();
|
|
13
|
+
* material.rotationNode = userData( 'rotation', 'float' );
|
|
14
|
+
* ```
|
|
15
|
+
* Since `UserDataNode` is extended from {@link module:ReferenceNode~ReferenceNode}, the node value
|
|
16
|
+
* will automatically be updated when the `rotation` user data field changes.
|
|
17
|
+
*
|
|
18
|
+
* @augments module:ReferenceNode~ReferenceNode
|
|
19
|
+
*/
|
|
4
20
|
class UserDataNode extends ReferenceNode {
|
|
5
21
|
|
|
6
22
|
static get type() {
|
|
@@ -9,14 +25,35 @@ class UserDataNode extends ReferenceNode {
|
|
|
9
25
|
|
|
10
26
|
}
|
|
11
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Constructs a new user data node.
|
|
30
|
+
*
|
|
31
|
+
* @param {String} property - The property name that should be referenced by the node.
|
|
32
|
+
* @param {String} inputType - The node data type of the reference.
|
|
33
|
+
* @param {Object?} [userData=null] - A reference to the `userData` object. If not provided, the `userData` property of the 3D object that uses the node material is evaluated.
|
|
34
|
+
*/
|
|
12
35
|
constructor( property, inputType, userData = null ) {
|
|
13
36
|
|
|
14
37
|
super( property, inputType, userData );
|
|
15
38
|
|
|
39
|
+
/**
|
|
40
|
+
* A reference to the `userData` object. If not provided, the `userData`
|
|
41
|
+
* property of the 3D object that uses the node material is evaluated.
|
|
42
|
+
*
|
|
43
|
+
* @type {Object?}
|
|
44
|
+
* @default null
|
|
45
|
+
*/
|
|
16
46
|
this.userData = userData;
|
|
17
47
|
|
|
18
48
|
}
|
|
19
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Overwritten to make sure {@link module:ReferenceNode~ReferenceNode#reference} points to the correct
|
|
52
|
+
* `userData` field.
|
|
53
|
+
*
|
|
54
|
+
* @param {(NodeFrame|NodeBuilder)} state - The current state to evaluate.
|
|
55
|
+
* @return {Object} A reference to the `userData` field.
|
|
56
|
+
*/
|
|
20
57
|
updateReference( state ) {
|
|
21
58
|
|
|
22
59
|
this.reference = this.userData !== null ? this.userData : state.object.userData;
|
|
@@ -29,4 +66,13 @@ class UserDataNode extends ReferenceNode {
|
|
|
29
66
|
|
|
30
67
|
export default UserDataNode;
|
|
31
68
|
|
|
69
|
+
/**
|
|
70
|
+
* TSL function for creating a user data node.
|
|
71
|
+
*
|
|
72
|
+
* @function
|
|
73
|
+
* @param {String} name - The property name that should be referenced by the node.
|
|
74
|
+
* @param {String} inputType - The node data type of the reference.
|
|
75
|
+
* @param {Object?} userData - A reference to the `userData` object. If not provided, the `userData` property of the 3D object that uses the node material is evaluated.
|
|
76
|
+
* @returns {UserDataNode}
|
|
77
|
+
*/
|
|
32
78
|
export const userData = ( name, inputType, userData ) => nodeObject( new UserDataNode( name, inputType, userData ) );
|
|
@@ -11,6 +11,18 @@ import { renderGroup } from '../core/UniformGroupNode.js';
|
|
|
11
11
|
|
|
12
12
|
const _objectData = new WeakMap();
|
|
13
13
|
|
|
14
|
+
/** @module VelocityNode **/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A node for representing motion or velocity vectors. Foundation
|
|
18
|
+
* for advanced post processing effects like motion blur or TRAA.
|
|
19
|
+
*
|
|
20
|
+
* The node keeps track of the model, view and projection matrices
|
|
21
|
+
* of the previous frame and uses them to compute offsets in NDC space.
|
|
22
|
+
* These offsets represent the final velocity.
|
|
23
|
+
*
|
|
24
|
+
* @augments TempNode
|
|
25
|
+
*/
|
|
14
26
|
class VelocityNode extends TempNode {
|
|
15
27
|
|
|
16
28
|
static get type() {
|
|
@@ -19,27 +31,81 @@ class VelocityNode extends TempNode {
|
|
|
19
31
|
|
|
20
32
|
}
|
|
21
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Constructs a new vertex color node.
|
|
36
|
+
*
|
|
37
|
+
* @param {Number} [index=0] - The attribute index.
|
|
38
|
+
*/
|
|
22
39
|
constructor() {
|
|
23
40
|
|
|
24
41
|
super( 'vec2' );
|
|
25
42
|
|
|
43
|
+
/**
|
|
44
|
+
* The current projection matrix.
|
|
45
|
+
*
|
|
46
|
+
* @type {Matrix4?}
|
|
47
|
+
* @default null
|
|
48
|
+
*/
|
|
26
49
|
this.projectionMatrix = null;
|
|
27
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Overwritten since velocity nodes are updated per object.
|
|
53
|
+
*
|
|
54
|
+
* @type {String}
|
|
55
|
+
* @default 'object'
|
|
56
|
+
*/
|
|
28
57
|
this.updateType = NodeUpdateType.OBJECT;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Overwritten since velocity nodes save data after the update.
|
|
61
|
+
*
|
|
62
|
+
* @type {String}
|
|
63
|
+
* @default 'object'
|
|
64
|
+
*/
|
|
29
65
|
this.updateAfterType = NodeUpdateType.OBJECT;
|
|
30
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Uniform node representing the previous model matrix in world space.
|
|
69
|
+
*
|
|
70
|
+
* @type {UniformNode<mat4>}
|
|
71
|
+
* @default null
|
|
72
|
+
*/
|
|
31
73
|
this.previousModelWorldMatrix = uniform( new Matrix4() );
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Uniform node representing the previous projection matrix.
|
|
77
|
+
*
|
|
78
|
+
* @type {UniformNode<mat4>}
|
|
79
|
+
* @default null
|
|
80
|
+
*/
|
|
32
81
|
this.previousProjectionMatrix = uniform( new Matrix4() ).setGroup( renderGroup );
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Uniform node representing the previous view matrix.
|
|
85
|
+
*
|
|
86
|
+
* @type {UniformNode<mat4>}
|
|
87
|
+
* @default null
|
|
88
|
+
*/
|
|
33
89
|
this.previousCameraViewMatrix = uniform( new Matrix4() );
|
|
34
90
|
|
|
35
91
|
}
|
|
36
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Sets the given projection matrix.
|
|
95
|
+
*
|
|
96
|
+
* @param {Matrix4} projectionMatrix - The projection matrix to set.
|
|
97
|
+
*/
|
|
37
98
|
setProjectionMatrix( projectionMatrix ) {
|
|
38
99
|
|
|
39
100
|
this.projectionMatrix = projectionMatrix;
|
|
40
101
|
|
|
41
102
|
}
|
|
42
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Updates velocity specific uniforms.
|
|
106
|
+
*
|
|
107
|
+
* @param {NodeFrame} frame - A reference to the current node frame.
|
|
108
|
+
*/
|
|
43
109
|
update( { frameId, camera, object } ) {
|
|
44
110
|
|
|
45
111
|
const previousModelMatrix = getPreviousMatrix( object );
|
|
@@ -82,12 +148,23 @@ class VelocityNode extends TempNode {
|
|
|
82
148
|
|
|
83
149
|
}
|
|
84
150
|
|
|
151
|
+
/**
|
|
152
|
+
* Overwritten to updated velocity specific uniforms.
|
|
153
|
+
*
|
|
154
|
+
* @param {NodeFrame} frame - A reference to the current node frame.
|
|
155
|
+
*/
|
|
85
156
|
updateAfter( { object } ) {
|
|
86
157
|
|
|
87
158
|
getPreviousMatrix( object ).copy( object.matrixWorld );
|
|
88
159
|
|
|
89
160
|
}
|
|
90
161
|
|
|
162
|
+
/**
|
|
163
|
+
* Implements the velocity computation based on the previous and current vertex data.
|
|
164
|
+
*
|
|
165
|
+
* @param {NodeBuilder} builder - A reference to the current node builder.
|
|
166
|
+
* @return {Node<vec2>} The motion vector.
|
|
167
|
+
*/
|
|
91
168
|
setup( /*builder*/ ) {
|
|
92
169
|
|
|
93
170
|
const projectionMatrix = ( this.projectionMatrix === null ) ? cameraProjectionMatrix : uniform( this.projectionMatrix );
|
|
@@ -141,4 +218,9 @@ function getPreviousMatrix( object, index = 0 ) {
|
|
|
141
218
|
|
|
142
219
|
export default VelocityNode;
|
|
143
220
|
|
|
221
|
+
/**
|
|
222
|
+
* TSL object that represents the velocity of a render pass.
|
|
223
|
+
*
|
|
224
|
+
* @type {VelocityNode}
|
|
225
|
+
*/
|
|
144
226
|
export const velocity = /*@__PURE__*/ nodeImmutable( VelocityNode );
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import AttributeNode from '../core/AttributeNode.js';
|
|
2
2
|
import { nodeObject } from '../tsl/TSLBase.js';
|
|
3
|
-
|
|
4
3
|
import { Vector4 } from '../../math/Vector4.js';
|
|
5
4
|
|
|
5
|
+
/** @module VertexColorNode **/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* An attribute node for representing vertex colors.
|
|
9
|
+
*
|
|
10
|
+
* @augments module:AttributeNode~AttributeNode
|
|
11
|
+
*/
|
|
6
12
|
class VertexColorNode extends AttributeNode {
|
|
7
13
|
|
|
8
14
|
static get type() {
|
|
@@ -11,16 +17,40 @@ class VertexColorNode extends AttributeNode {
|
|
|
11
17
|
|
|
12
18
|
}
|
|
13
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Constructs a new vertex color node.
|
|
22
|
+
*
|
|
23
|
+
* @param {Number} [index=0] - The attribute index.
|
|
24
|
+
*/
|
|
14
25
|
constructor( index = 0 ) {
|
|
15
26
|
|
|
16
27
|
super( null, 'vec4' );
|
|
17
28
|
|
|
29
|
+
/**
|
|
30
|
+
* This flag can be used for type testing.
|
|
31
|
+
*
|
|
32
|
+
* @type {Boolean}
|
|
33
|
+
* @readonly
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
18
36
|
this.isVertexColorNode = true;
|
|
19
37
|
|
|
38
|
+
/**
|
|
39
|
+
* The attribute index to enable more than one sets of vertex colors.
|
|
40
|
+
*
|
|
41
|
+
* @type {Number}
|
|
42
|
+
* @default 0
|
|
43
|
+
*/
|
|
20
44
|
this.index = index;
|
|
21
45
|
|
|
22
46
|
}
|
|
23
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Overwrites the default implementation by honoring the attribute index.
|
|
50
|
+
*
|
|
51
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
52
|
+
* @return {String} The attribute name.
|
|
53
|
+
*/
|
|
24
54
|
getAttributeName( /*builder*/ ) {
|
|
25
55
|
|
|
26
56
|
const index = this.index;
|
|
@@ -71,4 +101,11 @@ class VertexColorNode extends AttributeNode {
|
|
|
71
101
|
|
|
72
102
|
export default VertexColorNode;
|
|
73
103
|
|
|
74
|
-
|
|
104
|
+
/**
|
|
105
|
+
* TSL function for creating a reference node.
|
|
106
|
+
*
|
|
107
|
+
* @function
|
|
108
|
+
* @param {Number} index - The attribute index.
|
|
109
|
+
* @returns {VertexColorNode}
|
|
110
|
+
*/
|
|
111
|
+
export const vertexColor = ( index ) => nodeObject( new VertexColorNode( index ) );
|