super-three 0.170.1 → 0.172.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/three.cjs +157 -49
- package/build/three.core.js +104 -42
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +53 -8
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +10 -5
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +21191 -1008
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +21189 -1008
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +0 -5
- package/examples/jsm/animation/CCDIKSolver.js +3 -2
- package/examples/jsm/controls/ArcballControls.js +28 -19
- package/examples/jsm/controls/OrbitControls.js +5 -4
- package/examples/jsm/csm/CSMShadowNode.js +16 -11
- package/examples/jsm/curves/NURBSCurve.js +1 -1
- package/examples/jsm/curves/NURBSUtils.js +3 -0
- package/examples/jsm/effects/OutlineEffect.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +11 -7
- package/examples/jsm/exporters/KTX2Exporter.js +1 -1
- package/examples/jsm/exporters/PLYExporter.js +2 -2
- package/examples/jsm/helpers/TextureHelperGPU.js +15 -5
- package/examples/jsm/helpers/VertexNormalsHelper.js +2 -0
- package/examples/jsm/lights/LightProbeGenerator.js +3 -3
- package/examples/jsm/lines/webgpu/LineSegments2.js +15 -6
- package/examples/jsm/loaders/3MFLoader.js +6 -3
- package/examples/jsm/loaders/BVHLoader.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +5 -5
- package/examples/jsm/loaders/DDSLoader.js +42 -0
- package/examples/jsm/loaders/GCodeLoader.js +1 -1
- package/examples/jsm/loaders/GLTFLoader.js +22 -2
- package/examples/jsm/loaders/KTX2Loader.js +6 -1
- package/examples/jsm/loaders/KTXLoader.js +4 -4
- package/examples/jsm/loaders/LDrawLoader.js +1 -1
- package/examples/jsm/loaders/LottieLoader.js +1 -1
- package/examples/jsm/loaders/MTLLoader.js +1 -0
- package/examples/jsm/loaders/NRRDLoader.js +1 -1
- package/examples/jsm/loaders/PLYLoader.js +7 -7
- package/examples/jsm/loaders/PVRLoader.js +1 -1
- package/examples/jsm/loaders/SVGLoader.js +2 -2
- package/examples/jsm/loaders/TDSLoader.js +1 -1
- package/examples/jsm/loaders/VRMLLoader.js +7 -7
- package/examples/jsm/loaders/lwo/IFFParser.js +4 -4
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +1 -1
- package/examples/jsm/math/ConvexHull.js +1 -1
- package/examples/jsm/math/OBB.js +17 -0
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +10 -10
- package/examples/jsm/misc/Volume.js +20 -12
- package/examples/jsm/misc/VolumeSlice.js +2 -2
- package/examples/jsm/modifiers/CurveModifier.js +10 -8
- package/examples/jsm/modifiers/CurveModifierGPU.js +9 -7
- package/examples/jsm/modifiers/SimplifyModifier.js +2 -2
- package/examples/jsm/objects/GroundedSkybox.js +4 -4
- package/examples/jsm/objects/Sky.js +2 -2
- package/examples/jsm/objects/SkyMesh.js +3 -3
- package/examples/jsm/objects/Water2.js +1 -1
- package/examples/jsm/objects/Water2Mesh.js +2 -2
- package/examples/jsm/objects/WaterMesh.js +4 -4
- package/examples/jsm/postprocessing/BloomPass.js +2 -2
- package/examples/jsm/postprocessing/EffectComposer.js +1 -2
- package/examples/jsm/postprocessing/OutlinePass.js +4 -4
- package/examples/jsm/postprocessing/SAOPass.js +1 -2
- package/examples/jsm/postprocessing/SMAAPass.js +1 -3
- package/examples/jsm/postprocessing/SSAOPass.js +2 -4
- package/examples/jsm/postprocessing/SSRPass.js +2 -4
- package/examples/jsm/postprocessing/UnrealBloomPass.js +2 -2
- package/examples/jsm/renderers/SVGRenderer.js +6 -4
- package/examples/jsm/shaders/BokehShader2.js +1 -1
- package/examples/jsm/shaders/GodRaysShader.js +3 -3
- package/examples/jsm/shaders/SobelOperatorShader.js +1 -1
- package/examples/jsm/tsl/display/AfterImageNode.js +93 -4
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +46 -2
- package/examples/jsm/tsl/display/AnamorphicNode.js +118 -5
- package/examples/jsm/tsl/display/BleachBypass.js +10 -0
- package/examples/jsm/tsl/display/BloomNode.js +233 -26
- package/examples/jsm/tsl/display/DenoiseNode.js +141 -25
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +80 -1
- package/examples/jsm/tsl/display/DotScreenNode.js +50 -5
- package/examples/jsm/tsl/display/FXAANode.js +52 -3
- package/examples/jsm/tsl/display/FilmNode.js +47 -1
- package/examples/jsm/tsl/display/GTAONode.js +210 -14
- package/examples/jsm/tsl/display/GaussianBlurNode.js +152 -8
- package/examples/jsm/tsl/display/LensflareNode.js +131 -13
- package/examples/jsm/tsl/display/Lut3DNode.js +55 -1
- package/examples/jsm/tsl/display/MotionBlur.js +12 -2
- package/examples/jsm/tsl/display/OutlineNode.js +343 -26
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +36 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +142 -9
- package/examples/jsm/tsl/display/RGBShiftNode.js +49 -2
- package/examples/jsm/tsl/display/SMAANode.js +187 -46
- package/examples/jsm/tsl/display/SSAAPassNode.js +110 -25
- package/examples/jsm/tsl/display/SSRNode.js +194 -21
- package/examples/jsm/tsl/display/Sepia.js +9 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +54 -4
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +79 -3
- package/examples/jsm/tsl/display/StereoPassNode.js +41 -3
- package/examples/jsm/tsl/display/TRAAPassNode.js +116 -21
- package/examples/jsm/tsl/display/TransitionNode.js +71 -6
- package/examples/jsm/tsl/display/hashBlur.js +14 -3
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +40 -34
- package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
- package/examples/jsm/utils/CameraUtils.js +4 -1
- package/examples/jsm/utils/GeometryUtils.js +22 -19
- package/examples/jsm/utils/SceneUtils.js +2 -2
- package/examples/jsm/webxr/XRControllerModelFactory.js +6 -1
- package/examples/jsm/webxr/XREstimatedLight.js +1 -1
- package/package.json +8 -3
- package/src/Three.Core.js +2 -0
- package/src/Three.Legacy.js +0 -21
- package/src/Three.TSL.js +9 -4
- package/src/Three.WebGPU.Nodes.js +2 -2
- package/src/Three.WebGPU.js +2 -2
- package/src/animation/PropertyBinding.js +2 -2
- package/src/cameras/PerspectiveCamera.js +18 -2
- package/src/constants.js +1 -1
- package/src/core/RenderTarget.js +18 -0
- package/src/core/RenderTarget3D.js +22 -0
- package/src/core/RenderTargetArray.js +22 -0
- package/src/extras/Earcut.js +1 -1
- package/src/extras/PMREMGenerator.js +20 -0
- package/src/extras/TextureUtils.js +6 -0
- package/src/helpers/CameraHelper.js +16 -13
- package/src/loaders/nodes/NodeLoader.js +59 -0
- package/src/loaders/nodes/NodeMaterialLoader.js +45 -0
- package/src/loaders/nodes/NodeObjectLoader.js +61 -0
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +72 -19
- package/src/materials/nodes/Line2NodeMaterial.js +128 -34
- package/src/materials/nodes/LineBasicNodeMaterial.js +17 -2
- package/src/materials/nodes/LineDashedNodeMaterial.js +78 -5
- package/src/materials/nodes/MeshBasicNodeMaterial.js +56 -0
- package/src/materials/nodes/MeshLambertNodeMaterial.js +35 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +22 -2
- package/src/materials/nodes/MeshNormalNodeMaterial.js +21 -2
- package/src/materials/nodes/MeshPhongNodeMaterial.js +64 -1
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +269 -0
- package/src/materials/nodes/MeshSSSNodeMaterial.js +97 -6
- package/src/materials/nodes/MeshStandardNodeMaterial.js +78 -0
- package/src/materials/nodes/MeshToonNodeMaterial.js +28 -0
- package/src/materials/nodes/NodeMaterial.js +474 -21
- package/src/materials/nodes/PointsNodeMaterial.js +22 -13
- package/src/materials/nodes/ShadowNodeMaterial.js +29 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +77 -19
- package/src/materials/nodes/VolumeNodeMaterial.js +80 -4
- package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -0
- package/src/nodes/Nodes.js +1 -6
- package/src/nodes/TSL.js +2 -3
- package/src/nodes/accessors/AccessorsUtils.js +27 -0
- package/src/nodes/accessors/Arrays.js +24 -5
- package/src/nodes/accessors/BatchNode.js +39 -3
- package/src/nodes/accessors/Bitangent.js +37 -0
- package/src/nodes/accessors/BufferAttributeNode.js +178 -5
- package/src/nodes/accessors/BufferNode.js +63 -0
- package/src/nodes/accessors/BuiltinNode.js +38 -0
- package/src/nodes/accessors/Camera.js +49 -0
- package/src/nodes/accessors/ClippingNode.js +71 -2
- package/src/nodes/accessors/CubeTextureNode.js +64 -0
- package/src/nodes/accessors/InstanceNode.js +85 -2
- package/src/nodes/accessors/InstancedMeshNode.js +28 -3
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +13 -0
- package/src/nodes/accessors/Lights.js +50 -1
- package/src/nodes/accessors/MaterialNode.js +302 -8
- package/src/nodes/accessors/MaterialProperties.js +7 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +53 -13
- package/src/nodes/accessors/ModelNode.js +100 -5
- package/src/nodes/accessors/ModelViewProjectionNode.js +10 -38
- package/src/nodes/accessors/MorphNode.js +48 -4
- package/src/nodes/accessors/Normal.js +59 -3
- package/src/nodes/accessors/Object3DNode.js +102 -1
- package/src/nodes/accessors/PointUVNode.js +26 -0
- package/src/nodes/accessors/Position.js +53 -4
- package/src/nodes/accessors/ReferenceBaseNode.js +188 -0
- package/src/nodes/accessors/ReferenceNode.js +202 -2
- package/src/nodes/accessors/ReflectVector.js +24 -0
- package/src/nodes/accessors/RendererReferenceNode.js +46 -1
- package/src/nodes/accessors/SceneNode.js +54 -0
- package/src/nodes/accessors/SkinningNode.js +127 -1
- package/src/nodes/accessors/StorageBufferNode.js +168 -4
- package/src/nodes/accessors/StorageTextureNode.js +118 -0
- package/src/nodes/accessors/Tangent.js +36 -0
- package/src/nodes/accessors/Texture3DNode.js +89 -5
- package/src/nodes/accessors/TextureBicubic.js +12 -2
- package/src/nodes/accessors/TextureNode.js +309 -10
- package/src/nodes/accessors/TextureSizeNode.js +42 -0
- package/src/nodes/accessors/UV.js +10 -1
- package/src/nodes/accessors/UniformArrayNode.js +223 -23
- package/src/nodes/accessors/UserDataNode.js +46 -0
- package/src/nodes/accessors/VelocityNode.js +82 -0
- package/src/nodes/accessors/VertexColorNode.js +39 -2
- package/src/nodes/code/CodeNode.js +95 -1
- package/src/nodes/code/ExpressionNode.js +28 -0
- package/src/nodes/code/FunctionCallNode.js +37 -0
- package/src/nodes/code/FunctionNode.js +45 -0
- package/src/nodes/code/ScriptableNode.js +223 -1
- package/src/nodes/code/ScriptableValueNode.js +85 -1
- package/src/nodes/core/AssignNode.js +48 -2
- package/src/nodes/core/AttributeNode.js +43 -0
- package/src/nodes/core/BypassNode.js +47 -2
- package/src/nodes/core/CacheNode.js +53 -2
- package/src/nodes/core/ConstNode.js +24 -0
- package/src/nodes/core/ContextNode.js +65 -0
- package/src/nodes/core/IndexNode.js +68 -7
- package/src/nodes/core/InputNode.js +48 -0
- package/src/nodes/core/LightingModel.js +60 -0
- package/src/nodes/core/MRTNode.js +66 -0
- package/src/nodes/core/Node.js +337 -12
- package/src/nodes/core/NodeAttribute.js +38 -0
- package/src/nodes/core/NodeBuilder.js +945 -15
- package/src/nodes/core/NodeCache.js +41 -2
- package/src/nodes/core/NodeCode.js +31 -0
- package/src/nodes/core/NodeFrame.js +123 -2
- package/src/nodes/core/NodeFunction.js +46 -0
- package/src/nodes/core/NodeFunctionInput.js +44 -0
- package/src/nodes/core/NodeParser.js +11 -0
- package/src/nodes/core/NodeUniform.js +52 -0
- package/src/nodes/core/NodeUtils.js +141 -0
- package/src/nodes/core/NodeVar.js +30 -0
- package/src/nodes/core/NodeVarying.js +28 -0
- package/src/nodes/core/OutputStructNode.js +33 -2
- package/src/nodes/core/ParameterNode.js +28 -0
- package/src/nodes/core/PropertyNode.js +232 -0
- package/src/nodes/core/StackNode.js +78 -0
- package/src/nodes/core/StructTypeNode.js +39 -1
- package/src/nodes/core/TempNode.js +30 -4
- package/src/nodes/core/UniformGroupNode.js +82 -7
- package/src/nodes/core/UniformNode.js +66 -0
- package/src/nodes/core/VarNode.js +52 -0
- package/src/nodes/core/VaryingNode.js +83 -2
- package/src/nodes/core/constants.js +36 -0
- package/src/nodes/display/BumpMapNode.js +37 -0
- package/src/nodes/display/ColorAdjustment.js +53 -11
- package/src/nodes/display/ColorSpaceFunctions.js +16 -0
- package/src/nodes/display/ColorSpaceNode.js +82 -0
- package/src/nodes/display/FrontFacingNode.js +29 -0
- package/src/nodes/display/NormalMapNode.js +43 -0
- package/src/nodes/display/PassNode.js +298 -7
- package/src/nodes/display/PosterizeNode.js +33 -0
- package/src/nodes/display/RenderOutputNode.js +66 -1
- package/src/nodes/display/ScreenNode.js +87 -0
- package/src/nodes/display/ToneMappingFunctions.js +58 -10
- package/src/nodes/display/ToneMappingNode.js +55 -2
- package/src/nodes/display/ToonOutlinePassNode.js +73 -0
- package/src/nodes/display/ViewportDepthNode.js +122 -8
- package/src/nodes/display/ViewportDepthTextureNode.js +23 -0
- package/src/nodes/display/ViewportSharedTextureNode.js +23 -0
- package/src/nodes/display/ViewportTextureNode.js +57 -0
- package/src/nodes/fog/Fog.js +93 -0
- package/src/nodes/functions/BasicLightingModel.js +24 -0
- package/src/nodes/functions/PhongLightingModel.js +34 -2
- package/src/nodes/functions/PhysicalLightingModel.js +167 -8
- package/src/nodes/functions/ShadowMaskModel.js +23 -0
- package/src/nodes/functions/ToonLightingModel.js +20 -0
- package/src/nodes/functions/material/getAlphaHashThreshold.js +1 -3
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +16 -1
- package/src/nodes/geometry/RangeNode.js +54 -2
- package/src/nodes/gpgpu/AtomicFunctionNode.js +157 -1
- package/src/nodes/gpgpu/BarrierNode.js +47 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +126 -0
- package/src/nodes/gpgpu/ComputeNode.js +106 -2
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +115 -6
- package/src/nodes/lighting/AONode.js +18 -0
- package/src/nodes/lighting/AmbientLightNode.js +10 -0
- package/src/nodes/lighting/AnalyticLightNode.js +97 -2
- package/src/nodes/lighting/BasicEnvironmentNode.js +19 -0
- package/src/nodes/lighting/BasicLightMapNode.js +17 -0
- package/src/nodes/lighting/DirectionalLightNode.js +10 -0
- package/src/nodes/lighting/EnvironmentNode.js +18 -0
- package/src/nodes/lighting/HemisphereLightNode.js +31 -0
- package/src/nodes/lighting/IESSpotLightNode.js +11 -0
- package/src/nodes/lighting/IrradianceNode.js +17 -0
- package/src/nodes/lighting/LightProbeNode.js +20 -0
- package/src/nodes/lighting/LightUtils.js +12 -0
- package/src/nodes/lighting/LightingContextNode.js +48 -0
- package/src/nodes/lighting/LightingNode.js +15 -6
- package/src/nodes/lighting/LightsNode.js +132 -1
- package/src/nodes/lighting/PointLightNode.js +32 -1
- package/src/nodes/lighting/PointShadowNode.js +54 -1
- package/src/nodes/lighting/RectAreaLightNode.js +44 -6
- package/src/nodes/lighting/ShadowBaseNode.js +93 -0
- package/src/nodes/lighting/ShadowNode.js +240 -34
- package/src/nodes/lighting/SpotLightNode.js +43 -0
- package/src/nodes/math/ConditionalNode.js +70 -3
- package/src/nodes/math/Hash.js +9 -0
- package/src/nodes/math/MathNode.js +614 -11
- package/src/nodes/math/MathUtils.js +45 -1
- package/src/nodes/math/OperatorNode.js +233 -0
- package/src/nodes/math/TriNoise3D.js +18 -7
- package/src/nodes/parsers/GLSLNodeFunction.js +16 -0
- package/src/nodes/parsers/GLSLNodeParser.js +11 -0
- package/src/nodes/pmrem/PMREMNode.js +133 -0
- package/src/nodes/pmrem/PMREMUtils.js +1 -1
- package/src/nodes/procedural/Checker.js +9 -0
- package/src/nodes/tsl/TSLBase.js +2 -2
- package/src/nodes/utils/ArrayElementNode.js +38 -2
- package/src/nodes/utils/ConvertNode.js +31 -0
- package/src/nodes/utils/CubeMapNode.js +78 -0
- package/src/nodes/utils/Discard.js +16 -0
- package/src/nodes/utils/EquirectUVNode.js +31 -1
- package/src/nodes/utils/FlipNode.js +38 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +53 -1
- package/src/nodes/utils/JoinNode.js +25 -0
- package/src/nodes/utils/LoopNode.js +74 -1
- package/src/nodes/utils/MatcapUVNode.js +17 -0
- package/src/nodes/utils/MaxMipLevelNode.js +49 -0
- package/src/nodes/utils/Oscillators.js +33 -0
- package/src/nodes/utils/Packing.js +17 -0
- package/src/nodes/utils/PostProcessingUtils.js +28 -23
- package/src/nodes/utils/RTTNode.js +123 -2
- package/src/nodes/utils/ReflectorNode.js +174 -4
- package/src/nodes/utils/RemapNode.js +79 -0
- package/src/nodes/utils/RotateNode.js +41 -0
- package/src/nodes/utils/SetNode.js +44 -1
- package/src/nodes/utils/SplitNode.js +55 -3
- package/src/nodes/utils/SpriteSheetUVNode.js +46 -0
- package/src/nodes/utils/SpriteUtils.js +17 -0
- package/src/nodes/utils/StorageArrayElementNode.js +40 -0
- package/src/nodes/utils/Timer.js +19 -0
- package/src/nodes/utils/TriplanarTexturesNode.js +84 -0
- package/src/nodes/utils/UVUtils.js +20 -0
- package/src/nodes/utils/ViewportUtils.js +13 -0
- package/src/objects/BatchedMesh.js +1 -2
- package/src/objects/ClippingGroup.js +49 -0
- package/src/renderers/WebGLRenderer.js +23 -4
- package/src/renderers/common/Animation.js +63 -0
- package/src/renderers/common/Attributes.js +36 -0
- package/src/renderers/common/Backend.js +467 -52
- package/src/renderers/common/Background.js +34 -1
- package/src/renderers/common/BindGroup.js +43 -0
- package/src/renderers/common/Binding.js +35 -0
- package/src/renderers/common/Bindings.js +93 -1
- package/src/renderers/common/Buffer.js +49 -0
- package/src/renderers/common/BufferUtils.js +27 -0
- package/src/renderers/common/BundleGroup.js +57 -0
- package/src/renderers/common/ChainMap.js +38 -1
- package/src/renderers/common/ClippingContext.js +107 -14
- package/src/renderers/common/Color4.js +36 -0
- package/src/renderers/common/ComputePipeline.js +24 -0
- package/src/renderers/common/CubeRenderTarget.js +13 -0
- package/src/renderers/common/DataMap.js +37 -1
- package/src/renderers/common/Geometries.js +98 -0
- package/src/renderers/common/IndirectStorageBufferAttribute.js +25 -2
- package/src/renderers/common/Info.js +87 -0
- package/src/renderers/common/Lighting.js +26 -0
- package/src/renderers/common/Pipeline.js +22 -0
- package/src/renderers/common/Pipelines.js +148 -5
- package/src/renderers/common/PostProcessing.js +75 -3
- package/src/renderers/common/ProgrammableStage.js +60 -2
- package/src/renderers/common/QuadMesh.js +54 -5
- package/src/renderers/common/RenderBundle.js +14 -8
- package/src/renderers/common/RenderBundles.js +33 -10
- package/src/renderers/common/RenderContext.js +169 -4
- package/src/renderers/common/RenderContexts.js +42 -2
- package/src/renderers/common/RenderList.js +178 -0
- package/src/renderers/common/RenderLists.js +31 -0
- package/src/renderers/common/RenderObject.js +328 -4
- package/src/renderers/common/RenderObjects.js +101 -7
- package/src/renderers/common/RenderPipeline.js +24 -0
- package/src/renderers/common/Renderer.js +1096 -31
- package/src/renderers/common/RendererUtils.js +193 -0
- package/src/renderers/common/SampledTexture.js +121 -0
- package/src/renderers/common/Sampler.js +30 -0
- package/src/renderers/common/StorageBuffer.js +24 -0
- package/src/renderers/common/StorageBufferAttribute.js +31 -2
- package/src/renderers/common/StorageInstancedBufferAttribute.js +31 -2
- package/src/renderers/common/StorageTexture.js +38 -0
- package/src/renderers/common/Textures.js +83 -0
- package/src/renderers/common/Uniform.js +188 -2
- package/src/renderers/common/UniformBuffer.js +19 -0
- package/src/renderers/common/UniformsGroup.js +139 -2
- package/src/renderers/common/extras/PMREMGenerator.js +24 -3
- package/src/renderers/common/nodes/NodeBuilderState.js +95 -1
- package/src/renderers/common/nodes/NodeLibrary.js +89 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +91 -2
- package/src/renderers/common/nodes/NodeSampler.js +28 -0
- package/src/renderers/common/nodes/NodeStorageBuffer.js +35 -0
- package/src/renderers/common/nodes/NodeUniform.js +189 -0
- package/src/renderers/common/nodes/NodeUniformBuffer.js +29 -0
- package/src/renderers/common/nodes/NodeUniformsGroup.js +31 -18
- package/src/renderers/common/nodes/Nodes.js +327 -60
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +7 -7
- package/src/renderers/webgl-fallback/WebGLBackend.js +547 -29
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +0 -1
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +1 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +1 -1
- package/src/renderers/webgpu/WebGPUBackend.js +480 -49
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +34 -0
- package/src/renderers/webgpu/WebGPURenderer.js +35 -0
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +20 -8
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +21 -8
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +59 -11
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +17 -0
- package/src/renderers/webgpu/nodes/WGSLNodeParser.js +11 -0
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +10 -8
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +9 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +5 -9
- package/src/renderers/webgpu/utils/WebGPUUtils.js +30 -0
- package/src/renderers/webxr/WebXRDepthSensing.js +1 -1
- package/src/renderers/webxr/WebXRManager.js +7 -1
- package/src/textures/Data3DTexture.js +2 -2
- package/src/textures/Texture.js +4 -0
- package/examples/jsm/animation/MMDAnimationHelper.js +0 -1209
- package/examples/jsm/animation/MMDPhysics.js +0 -1408
- package/examples/jsm/exporters/MMDExporter.js +0 -223
- package/examples/jsm/libs/mmdparser.module.js +0 -11530
- package/examples/jsm/loaders/MMDLoader.js +0 -2298
- package/examples/jsm/shaders/MMDToonShader.js +0 -134
- package/src/nodes/core/UniformGroup.js +0 -13
- package/src/nodes/fog/FogExp2Node.js +0 -35
- package/src/nodes/fog/FogNode.js +0 -50
- package/src/nodes/fog/FogRangeNode.js +0 -36
- package/src/renderers/common/PostProcessingUtils.js +0 -86
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
2
|
import { sub, mul, div } from './OperatorNode.js';
|
|
3
3
|
import { addMethodChaining, nodeObject, nodeProxy, float, vec2, vec3, vec4, Fn } from '../tsl/TSLCore.js';
|
|
4
|
-
|
|
4
|
+
import { WebGLCoordinateSystem, WebGPUCoordinateSystem } from '../../constants.js';
|
|
5
|
+
|
|
6
|
+
/** @module MathNode **/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This node represents a variety of mathematical methods available in shaders.
|
|
10
|
+
* They are divided into three categories:
|
|
11
|
+
*
|
|
12
|
+
* - Methods with one input like `sin`, `cos` or `normalize`.
|
|
13
|
+
* - Methods with two inputs like `dot`, `cross` or `pow`.
|
|
14
|
+
* - Methods with three inputs like `mix`, `clamp` or `smoothstep`.
|
|
15
|
+
*
|
|
16
|
+
* @augments TempNode
|
|
17
|
+
*/
|
|
5
18
|
class MathNode extends TempNode {
|
|
6
19
|
|
|
7
20
|
static get type() {
|
|
@@ -10,18 +23,56 @@ class MathNode extends TempNode {
|
|
|
10
23
|
|
|
11
24
|
}
|
|
12
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Constructs a new math node.
|
|
28
|
+
*
|
|
29
|
+
* @param {String} method - The method name.
|
|
30
|
+
* @param {Node} aNode - The first input.
|
|
31
|
+
* @param {Node?} [bNode=null] - The second input.
|
|
32
|
+
* @param {Node?} [cNode=null] - The third input.
|
|
33
|
+
*/
|
|
13
34
|
constructor( method, aNode, bNode = null, cNode = null ) {
|
|
14
35
|
|
|
15
36
|
super();
|
|
16
37
|
|
|
38
|
+
/**
|
|
39
|
+
* The method name.
|
|
40
|
+
*
|
|
41
|
+
* @type {String}
|
|
42
|
+
*/
|
|
17
43
|
this.method = method;
|
|
18
44
|
|
|
45
|
+
/**
|
|
46
|
+
* The first input.
|
|
47
|
+
*
|
|
48
|
+
* @type {Node}
|
|
49
|
+
*/
|
|
19
50
|
this.aNode = aNode;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The second input.
|
|
54
|
+
*
|
|
55
|
+
* @type {Node?}
|
|
56
|
+
* @default null
|
|
57
|
+
*/
|
|
20
58
|
this.bNode = bNode;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The third input.
|
|
62
|
+
*
|
|
63
|
+
* @type {Node?}
|
|
64
|
+
* @default null
|
|
65
|
+
*/
|
|
21
66
|
this.cNode = cNode;
|
|
22
67
|
|
|
23
68
|
}
|
|
24
69
|
|
|
70
|
+
/**
|
|
71
|
+
* The input type is inferred from the node types of the input nodes.
|
|
72
|
+
*
|
|
73
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
74
|
+
* @return {String} The input type.
|
|
75
|
+
*/
|
|
25
76
|
getInputType( builder ) {
|
|
26
77
|
|
|
27
78
|
const aType = this.aNode.getNodeType( builder );
|
|
@@ -50,6 +101,12 @@ class MathNode extends TempNode {
|
|
|
50
101
|
|
|
51
102
|
}
|
|
52
103
|
|
|
104
|
+
/**
|
|
105
|
+
* The selected method as well as the input type determine the node type of this node.
|
|
106
|
+
*
|
|
107
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
108
|
+
* @return {String} The node type.
|
|
109
|
+
*/
|
|
53
110
|
getNodeType( builder ) {
|
|
54
111
|
|
|
55
112
|
const method = this.method;
|
|
@@ -84,7 +141,7 @@ class MathNode extends TempNode {
|
|
|
84
141
|
|
|
85
142
|
generate( builder, output ) {
|
|
86
143
|
|
|
87
|
-
|
|
144
|
+
let method = this.method;
|
|
88
145
|
|
|
89
146
|
const type = this.getNodeType( builder );
|
|
90
147
|
const inputType = this.getInputType( builder );
|
|
@@ -93,7 +150,7 @@ class MathNode extends TempNode {
|
|
|
93
150
|
const b = this.bNode;
|
|
94
151
|
const c = this.cNode;
|
|
95
152
|
|
|
96
|
-
const
|
|
153
|
+
const coordinateSystem = builder.renderer.coordinateSystem;
|
|
97
154
|
|
|
98
155
|
if ( method === MathNode.TRANSFORM_DIRECTION ) {
|
|
99
156
|
|
|
@@ -144,14 +201,14 @@ class MathNode extends TempNode {
|
|
|
144
201
|
b.build( builder, type )
|
|
145
202
|
);
|
|
146
203
|
|
|
147
|
-
} else if (
|
|
204
|
+
} else if ( coordinateSystem === WebGLCoordinateSystem && method === MathNode.STEP ) {
|
|
148
205
|
|
|
149
206
|
params.push(
|
|
150
207
|
a.build( builder, builder.getTypeLength( a.getNodeType( builder ) ) === 1 ? 'float' : inputType ),
|
|
151
208
|
b.build( builder, inputType )
|
|
152
209
|
);
|
|
153
210
|
|
|
154
|
-
} else if ( (
|
|
211
|
+
} else if ( ( coordinateSystem === WebGLCoordinateSystem && ( method === MathNode.MIN || method === MathNode.MAX ) ) || method === MathNode.MOD ) {
|
|
155
212
|
|
|
156
213
|
params.push(
|
|
157
214
|
a.build( builder, inputType ),
|
|
@@ -176,6 +233,12 @@ class MathNode extends TempNode {
|
|
|
176
233
|
|
|
177
234
|
} else {
|
|
178
235
|
|
|
236
|
+
if ( coordinateSystem === WebGPUCoordinateSystem && method === MathNode.ATAN && b !== null ) {
|
|
237
|
+
|
|
238
|
+
method = 'atan2';
|
|
239
|
+
|
|
240
|
+
}
|
|
241
|
+
|
|
179
242
|
params.push( a.build( builder, inputType ) );
|
|
180
243
|
if ( b !== null ) params.push( b.build( builder, inputType ) );
|
|
181
244
|
if ( c !== null ) params.push( c.build( builder, inputType ) );
|
|
@@ -210,7 +273,6 @@ class MathNode extends TempNode {
|
|
|
210
273
|
|
|
211
274
|
MathNode.ALL = 'all';
|
|
212
275
|
MathNode.ANY = 'any';
|
|
213
|
-
MathNode.EQUALS = 'equals';
|
|
214
276
|
|
|
215
277
|
MathNode.RADIANS = 'radians';
|
|
216
278
|
MathNode.DEGREES = 'degrees';
|
|
@@ -241,12 +303,12 @@ MathNode.ROUND = 'round';
|
|
|
241
303
|
MathNode.RECIPROCAL = 'reciprocal';
|
|
242
304
|
MathNode.TRUNC = 'trunc';
|
|
243
305
|
MathNode.FWIDTH = 'fwidth';
|
|
244
|
-
MathNode.BITCAST = 'bitcast';
|
|
245
306
|
MathNode.TRANSPOSE = 'transpose';
|
|
246
307
|
|
|
247
308
|
// 2 inputs
|
|
248
309
|
|
|
249
|
-
MathNode.
|
|
310
|
+
MathNode.BITCAST = 'bitcast';
|
|
311
|
+
MathNode.EQUALS = 'equals';
|
|
250
312
|
MathNode.MIN = 'min';
|
|
251
313
|
MathNode.MAX = 'max';
|
|
252
314
|
MathNode.MOD = 'mod';
|
|
@@ -269,72 +331,572 @@ MathNode.FACEFORWARD = 'faceforward';
|
|
|
269
331
|
|
|
270
332
|
export default MathNode;
|
|
271
333
|
|
|
334
|
+
// 1 inputs
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* A small value used to handle floating-point precision errors.
|
|
338
|
+
*
|
|
339
|
+
* @type {Node<float>}
|
|
340
|
+
*/
|
|
272
341
|
export const EPSILON = /*@__PURE__*/ float( 1e-6 );
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Represents infinity.
|
|
345
|
+
*
|
|
346
|
+
* @type {Node<float>}
|
|
347
|
+
*/
|
|
273
348
|
export const INFINITY = /*@__PURE__*/ float( 1e6 );
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Represents PI.
|
|
352
|
+
*
|
|
353
|
+
* @type {Node<float>}
|
|
354
|
+
*/
|
|
274
355
|
export const PI = /*@__PURE__*/ float( Math.PI );
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Represents PI * 2.
|
|
359
|
+
*
|
|
360
|
+
* @type {Node<float>}
|
|
361
|
+
*/
|
|
275
362
|
export const PI2 = /*@__PURE__*/ float( Math.PI * 2 );
|
|
276
363
|
|
|
364
|
+
/**
|
|
365
|
+
* Returns `true` if all components of `x` are `true`.
|
|
366
|
+
*
|
|
367
|
+
* @function
|
|
368
|
+
* @param {Node | Number} x - The parameter.
|
|
369
|
+
* @returns {Node<bool>}
|
|
370
|
+
*/
|
|
277
371
|
export const all = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ALL );
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Returns `true` if any components of `x` are `true`.
|
|
375
|
+
*
|
|
376
|
+
* @function
|
|
377
|
+
* @param {Node | Number} x - The parameter.
|
|
378
|
+
* @returns {Node<bool>}
|
|
379
|
+
*/
|
|
278
380
|
export const any = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ANY );
|
|
279
|
-
export const equals = /*@__PURE__*/ nodeProxy( MathNode, MathNode.EQUALS );
|
|
280
381
|
|
|
382
|
+
/**
|
|
383
|
+
* Converts a quantity in degrees to radians.
|
|
384
|
+
*
|
|
385
|
+
* @function
|
|
386
|
+
* @param {Node | Number} x - The input in degrees.
|
|
387
|
+
* @returns {Node}
|
|
388
|
+
*/
|
|
281
389
|
export const radians = /*@__PURE__*/ nodeProxy( MathNode, MathNode.RADIANS );
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Convert a quantity in radians to degrees.
|
|
393
|
+
*
|
|
394
|
+
* @function
|
|
395
|
+
* @param {Node | Number} x - The input in radians.
|
|
396
|
+
* @returns {Node}
|
|
397
|
+
*/
|
|
282
398
|
export const degrees = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DEGREES );
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Returns the natural exponentiation of the parameter.
|
|
402
|
+
*
|
|
403
|
+
* @function
|
|
404
|
+
* @param {Node | Number} x - The parameter.
|
|
405
|
+
* @returns {Node}
|
|
406
|
+
*/
|
|
283
407
|
export const exp = /*@__PURE__*/ nodeProxy( MathNode, MathNode.EXP );
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Returns 2 raised to the power of the parameter.
|
|
411
|
+
*
|
|
412
|
+
* @function
|
|
413
|
+
* @param {Node | Number} x - The parameter.
|
|
414
|
+
* @returns {Node}
|
|
415
|
+
*/
|
|
284
416
|
export const exp2 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.EXP2 );
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Returns the natural logarithm of the parameter.
|
|
420
|
+
*
|
|
421
|
+
* @function
|
|
422
|
+
* @param {Node | Number} x - The parameter.
|
|
423
|
+
* @returns {Node}
|
|
424
|
+
*/
|
|
285
425
|
export const log = /*@__PURE__*/ nodeProxy( MathNode, MathNode.LOG );
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Returns the base 2 logarithm of the parameter.
|
|
429
|
+
*
|
|
430
|
+
* @function
|
|
431
|
+
* @param {Node | Number} x - The parameter.
|
|
432
|
+
* @returns {Node}
|
|
433
|
+
*/
|
|
286
434
|
export const log2 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.LOG2 );
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Returns the square root of the parameter.
|
|
438
|
+
*
|
|
439
|
+
* @function
|
|
440
|
+
* @param {Node | Number} x - The parameter.
|
|
441
|
+
* @returns {Node}
|
|
442
|
+
*/
|
|
287
443
|
export const sqrt = /*@__PURE__*/ nodeProxy( MathNode, MathNode.SQRT );
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Returns the inverse of the square root of the parameter.
|
|
447
|
+
*
|
|
448
|
+
* @function
|
|
449
|
+
* @param {Node | Number} x - The parameter.
|
|
450
|
+
* @returns {Node}
|
|
451
|
+
*/
|
|
288
452
|
export const inverseSqrt = /*@__PURE__*/ nodeProxy( MathNode, MathNode.INVERSE_SQRT );
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Finds the nearest integer less than or equal to the parameter.
|
|
456
|
+
*
|
|
457
|
+
* @function
|
|
458
|
+
* @param {Node | Number} x - The parameter.
|
|
459
|
+
* @returns {Node}
|
|
460
|
+
*/
|
|
289
461
|
export const floor = /*@__PURE__*/ nodeProxy( MathNode, MathNode.FLOOR );
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Finds the nearest integer that is greater than or equal to the parameter.
|
|
465
|
+
*
|
|
466
|
+
* @function
|
|
467
|
+
* @param {Node | Number} x - The parameter.
|
|
468
|
+
* @returns {Node}
|
|
469
|
+
*/
|
|
290
470
|
export const ceil = /*@__PURE__*/ nodeProxy( MathNode, MathNode.CEIL );
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Calculates the unit vector in the same direction as the original vector.
|
|
474
|
+
*
|
|
475
|
+
* @function
|
|
476
|
+
* @param {Node} x - The input vector.
|
|
477
|
+
* @returns {Node}
|
|
478
|
+
*/
|
|
291
479
|
export const normalize = /*@__PURE__*/ nodeProxy( MathNode, MathNode.NORMALIZE );
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Computes the fractional part of the parameter.
|
|
483
|
+
*
|
|
484
|
+
* @function
|
|
485
|
+
* @param {Node | Number} x - The parameter.
|
|
486
|
+
* @returns {Node}
|
|
487
|
+
*/
|
|
292
488
|
export const fract = /*@__PURE__*/ nodeProxy( MathNode, MathNode.FRACT );
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Returns the sine of the parameter.
|
|
492
|
+
*
|
|
493
|
+
* @function
|
|
494
|
+
* @param {Node | Number} x - The parameter.
|
|
495
|
+
* @returns {Node}
|
|
496
|
+
*/
|
|
293
497
|
export const sin = /*@__PURE__*/ nodeProxy( MathNode, MathNode.SIN );
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Returns the cosine of the parameter.
|
|
501
|
+
*
|
|
502
|
+
* @function
|
|
503
|
+
* @param {Node | Number} x - The parameter.
|
|
504
|
+
* @returns {Node}
|
|
505
|
+
*/
|
|
294
506
|
export const cos = /*@__PURE__*/ nodeProxy( MathNode, MathNode.COS );
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Returns the tangent of the parameter.
|
|
510
|
+
*
|
|
511
|
+
* @function
|
|
512
|
+
* @param {Node | Number} x - The parameter.
|
|
513
|
+
* @returns {Node}
|
|
514
|
+
*/
|
|
295
515
|
export const tan = /*@__PURE__*/ nodeProxy( MathNode, MathNode.TAN );
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Returns the arcsine of the parameter.
|
|
519
|
+
*
|
|
520
|
+
* @function
|
|
521
|
+
* @param {Node | Number} x - The parameter.
|
|
522
|
+
* @returns {Node}
|
|
523
|
+
*/
|
|
296
524
|
export const asin = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ASIN );
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Returns the arccosine of the parameter.
|
|
528
|
+
*
|
|
529
|
+
* @function
|
|
530
|
+
* @param {Node | Number} x - The parameter.
|
|
531
|
+
* @returns {Node}
|
|
532
|
+
*/
|
|
297
533
|
export const acos = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ACOS );
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Returns the arc-tangent of the parameter.
|
|
537
|
+
*
|
|
538
|
+
* @function
|
|
539
|
+
* @param {Node | Number} x - The parameter.
|
|
540
|
+
* @returns {Node}
|
|
541
|
+
*/
|
|
298
542
|
export const atan = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ATAN );
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Returns the absolute value of the parameter.
|
|
546
|
+
*
|
|
547
|
+
* @function
|
|
548
|
+
* @param {Node | Number} x - The parameter.
|
|
549
|
+
* @returns {Node}
|
|
550
|
+
*/
|
|
299
551
|
export const abs = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ABS );
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Extracts the sign of the parameter.
|
|
555
|
+
*
|
|
556
|
+
* @function
|
|
557
|
+
* @param {Node | Number} x - The parameter.
|
|
558
|
+
* @returns {Node}
|
|
559
|
+
*/
|
|
300
560
|
export const sign = /*@__PURE__*/ nodeProxy( MathNode, MathNode.SIGN );
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Calculates the length of a vector.
|
|
564
|
+
*
|
|
565
|
+
* @function
|
|
566
|
+
* @param {Node} x - The parameter.
|
|
567
|
+
* @returns {Node<float>}
|
|
568
|
+
*/
|
|
301
569
|
export const length = /*@__PURE__*/ nodeProxy( MathNode, MathNode.LENGTH );
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Negates the value of the parameter (-x).
|
|
573
|
+
*
|
|
574
|
+
* @function
|
|
575
|
+
* @param {Node | Number} x - The parameter.
|
|
576
|
+
* @returns {Node}
|
|
577
|
+
*/
|
|
302
578
|
export const negate = /*@__PURE__*/ nodeProxy( MathNode, MathNode.NEGATE );
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Return `1` minus the parameter.
|
|
582
|
+
*
|
|
583
|
+
* @function
|
|
584
|
+
* @param {Node | Number} x - The parameter.
|
|
585
|
+
* @returns {Node}
|
|
586
|
+
*/
|
|
303
587
|
export const oneMinus = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ONE_MINUS );
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Returns the partial derivative of the parameter with respect to x.
|
|
591
|
+
*
|
|
592
|
+
* @function
|
|
593
|
+
* @param {Node | Number} x - The parameter.
|
|
594
|
+
* @returns {Node}
|
|
595
|
+
*/
|
|
304
596
|
export const dFdx = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DFDX );
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Returns the partial derivative of the parameter with respect to y.
|
|
600
|
+
*
|
|
601
|
+
* @function
|
|
602
|
+
* @param {Node | Number} x - The parameter.
|
|
603
|
+
* @returns {Node}
|
|
604
|
+
*/
|
|
305
605
|
export const dFdy = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DFDY );
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* Rounds the parameter to the nearest integer.
|
|
609
|
+
*
|
|
610
|
+
* @function
|
|
611
|
+
* @param {Node | Number} x - The parameter.
|
|
612
|
+
* @returns {Node}
|
|
613
|
+
*/
|
|
306
614
|
export const round = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ROUND );
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Returns the reciprocal of the parameter `(1/x)`.
|
|
618
|
+
*
|
|
619
|
+
* @function
|
|
620
|
+
* @param {Node | Number} x - The parameter.
|
|
621
|
+
* @returns {Node}
|
|
622
|
+
*/
|
|
307
623
|
export const reciprocal = /*@__PURE__*/ nodeProxy( MathNode, MathNode.RECIPROCAL );
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Truncates the parameter, removing the fractional part.
|
|
627
|
+
*
|
|
628
|
+
* @function
|
|
629
|
+
* @param {Node | Number} x - The parameter.
|
|
630
|
+
* @returns {Node}
|
|
631
|
+
*/
|
|
308
632
|
export const trunc = /*@__PURE__*/ nodeProxy( MathNode, MathNode.TRUNC );
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Returns the sum of the absolute derivatives in x and y.
|
|
636
|
+
*
|
|
637
|
+
* @function
|
|
638
|
+
* @param {Node | Number} x - The parameter.
|
|
639
|
+
* @returns {Node}
|
|
640
|
+
*/
|
|
309
641
|
export const fwidth = /*@__PURE__*/ nodeProxy( MathNode, MathNode.FWIDTH );
|
|
310
|
-
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Returns the transpose of a matrix.
|
|
645
|
+
*
|
|
646
|
+
* @function
|
|
647
|
+
* @param {Node<mat2|mat3|mat4>} x - The parameter.
|
|
648
|
+
* @returns {Node}
|
|
649
|
+
*/
|
|
311
650
|
export const transpose = /*@__PURE__*/ nodeProxy( MathNode, MathNode.TRANSPOSE );
|
|
312
651
|
|
|
313
|
-
|
|
652
|
+
// 2 inputs
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* Reinterpret the bit representation of a value in one type as a value in another type.
|
|
656
|
+
*
|
|
657
|
+
* @function
|
|
658
|
+
* @param {Node | Number} x - The parameter.
|
|
659
|
+
* @param {String} y - The new type.
|
|
660
|
+
* @returns {Node}
|
|
661
|
+
*/
|
|
662
|
+
export const bitcast = /*@__PURE__*/ nodeProxy( MathNode, MathNode.BITCAST );
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* Returns `true` if `x` equals `y`.
|
|
666
|
+
*
|
|
667
|
+
* @function
|
|
668
|
+
* @param {Node | Number} x - The first parameter.
|
|
669
|
+
* @param {Node | Number} y - The second parameter.
|
|
670
|
+
* @returns {Node<bool>}
|
|
671
|
+
*/
|
|
672
|
+
export const equals = /*@__PURE__*/ nodeProxy( MathNode, MathNode.EQUALS );
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* Returns the lesser of two values.
|
|
676
|
+
*
|
|
677
|
+
* @function
|
|
678
|
+
* @param {Node | Number} x - The y parameter.
|
|
679
|
+
* @param {Node | Number} y - The x parameter.
|
|
680
|
+
* @returns {Node}
|
|
681
|
+
*/
|
|
314
682
|
export const min = /*@__PURE__*/ nodeProxy( MathNode, MathNode.MIN );
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Returns the greater of two values.
|
|
686
|
+
*
|
|
687
|
+
* @function
|
|
688
|
+
* @param {Node | Number} x - The y parameter.
|
|
689
|
+
* @param {Node | Number} y - The x parameter.
|
|
690
|
+
* @returns {Node}
|
|
691
|
+
*/
|
|
315
692
|
export const max = /*@__PURE__*/ nodeProxy( MathNode, MathNode.MAX );
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Computes the remainder of dividing the first node by the second one.
|
|
696
|
+
*
|
|
697
|
+
* @function
|
|
698
|
+
* @param {Node | Number} x - The y parameter.
|
|
699
|
+
* @param {Node | Number} y - The x parameter.
|
|
700
|
+
* @returns {Node}
|
|
701
|
+
*/
|
|
316
702
|
export const mod = /*@__PURE__*/ nodeProxy( MathNode, MathNode.MOD );
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Generate a step function by comparing two values.
|
|
706
|
+
*
|
|
707
|
+
* @function
|
|
708
|
+
* @param {Node | Number} x - The y parameter.
|
|
709
|
+
* @param {Node | Number} y - The x parameter.
|
|
710
|
+
* @returns {Node}
|
|
711
|
+
*/
|
|
317
712
|
export const step = /*@__PURE__*/ nodeProxy( MathNode, MathNode.STEP );
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* Calculates the reflection direction for an incident vector.
|
|
716
|
+
*
|
|
717
|
+
* @function
|
|
718
|
+
* @param {Node<vec2|vec3|vec4>} I - The incident vector.
|
|
719
|
+
* @param {Node<vec2|vec3|vec4>} N - The normal vector.
|
|
720
|
+
* @returns {Node<vec2|vec3|vec4>}
|
|
721
|
+
*/
|
|
318
722
|
export const reflect = /*@__PURE__*/ nodeProxy( MathNode, MathNode.REFLECT );
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* Calculates the distance between two points.
|
|
726
|
+
*
|
|
727
|
+
* @function
|
|
728
|
+
* @param {Node<vec2|vec3|vec4>} x - The first point.
|
|
729
|
+
* @param {Node<vec2|vec3|vec4>} y - The second point.
|
|
730
|
+
* @returns {Node<float>}
|
|
731
|
+
*/
|
|
319
732
|
export const distance = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DISTANCE );
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Calculates the absolute difference between two values.
|
|
736
|
+
*
|
|
737
|
+
* @function
|
|
738
|
+
* @param {Node | Number} x - The first parameter.
|
|
739
|
+
* @param {Node | Number} y - The second parameter.
|
|
740
|
+
* @returns {Node}
|
|
741
|
+
*/
|
|
320
742
|
export const difference = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DIFFERENCE );
|
|
743
|
+
|
|
744
|
+
/**
|
|
745
|
+
* Calculates the dot product of two vectors.
|
|
746
|
+
*
|
|
747
|
+
* @function
|
|
748
|
+
* @param {Node<vec2|vec3|vec4>} x - The first vector.
|
|
749
|
+
* @param {Node<vec2|vec3|vec4>} y - The second vector.
|
|
750
|
+
* @returns {Node<float>}
|
|
751
|
+
*/
|
|
321
752
|
export const dot = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DOT );
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* Calculates the cross product of two vectors.
|
|
756
|
+
*
|
|
757
|
+
* @function
|
|
758
|
+
* @param {Node<vec2|vec3|vec4>} x - The first vector.
|
|
759
|
+
* @param {Node<vec2|vec3|vec4>} y - The second vector.
|
|
760
|
+
* @returns {Node<vec2|vec3|vec4>}
|
|
761
|
+
*/
|
|
322
762
|
export const cross = /*@__PURE__*/ nodeProxy( MathNode, MathNode.CROSS );
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* Return the value of the first parameter raised to the power of the second one.
|
|
766
|
+
*
|
|
767
|
+
* @function
|
|
768
|
+
* @param {Node | Number} x - The first parameter.
|
|
769
|
+
* @param {Node | Number} y - The second parameter.
|
|
770
|
+
* @returns {Node}
|
|
771
|
+
*/
|
|
323
772
|
export const pow = /*@__PURE__*/ nodeProxy( MathNode, MathNode.POW );
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* Returns the square of the parameter.
|
|
776
|
+
*
|
|
777
|
+
* @function
|
|
778
|
+
* @param {Node | Number} x - The first parameter.
|
|
779
|
+
* @returns {Node}
|
|
780
|
+
*/
|
|
324
781
|
export const pow2 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.POW, 2 );
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* Returns the cube of the parameter.
|
|
785
|
+
*
|
|
786
|
+
* @function
|
|
787
|
+
* @param {Node | Number} x - The first parameter.
|
|
788
|
+
* @returns {Node}
|
|
789
|
+
*/
|
|
325
790
|
export const pow3 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.POW, 3 );
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* Returns the fourth power of the parameter.
|
|
794
|
+
*
|
|
795
|
+
* @function
|
|
796
|
+
* @param {Node | Number} x - The first parameter.
|
|
797
|
+
* @returns {Node}
|
|
798
|
+
*/
|
|
326
799
|
export const pow4 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.POW, 4 );
|
|
800
|
+
|
|
801
|
+
/**
|
|
802
|
+
* Transforms the direction of a vector by a matrix and then normalizes the result.
|
|
803
|
+
*
|
|
804
|
+
* @function
|
|
805
|
+
* @param {Node<vec2|vec3|vec4>} direction - The direction vector.
|
|
806
|
+
* @param {Node<mat2|mat3|mat4>} matrix - The transformation matrix.
|
|
807
|
+
* @returns {Node}
|
|
808
|
+
*/
|
|
327
809
|
export const transformDirection = /*@__PURE__*/ nodeProxy( MathNode, MathNode.TRANSFORM_DIRECTION );
|
|
328
810
|
|
|
811
|
+
/**
|
|
812
|
+
* Returns the cube root of a number.
|
|
813
|
+
*
|
|
814
|
+
* @function
|
|
815
|
+
* @param {Node | Number} a - The first parameter.
|
|
816
|
+
* @returns {Node}
|
|
817
|
+
*/
|
|
329
818
|
export const cbrt = ( a ) => mul( sign( a ), pow( abs( a ), 1.0 / 3.0 ) );
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* Calculate the squared length of a vector.
|
|
822
|
+
*
|
|
823
|
+
* @function
|
|
824
|
+
* @param {Node<vec2|vec3|vec4>} a - The vector.
|
|
825
|
+
* @returns {Node<float>}
|
|
826
|
+
*/
|
|
330
827
|
export const lengthSq = ( a ) => dot( a, a );
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Linearly interpolates between two values.
|
|
831
|
+
*
|
|
832
|
+
* @function
|
|
833
|
+
* @param {Node | Number} a - The first parameter.
|
|
834
|
+
* @param {Node | Number} b - The second parameter.
|
|
835
|
+
* @param {Node | Number} t - The interpolation value.
|
|
836
|
+
* @returns {Node}
|
|
837
|
+
*/
|
|
331
838
|
export const mix = /*@__PURE__*/ nodeProxy( MathNode, MathNode.MIX );
|
|
839
|
+
|
|
840
|
+
/**
|
|
841
|
+
* Constrains a value to lie between two further values.
|
|
842
|
+
*
|
|
843
|
+
* @function
|
|
844
|
+
* @param {Node | Number} value - The value to constrain.
|
|
845
|
+
* @param {Node | Number} [low=0] - The lower bound.
|
|
846
|
+
* @param {Node | Number} [high=1] - The upper bound.
|
|
847
|
+
* @returns {Node}
|
|
848
|
+
*/
|
|
332
849
|
export const clamp = ( value, low = 0, high = 1 ) => nodeObject( new MathNode( MathNode.CLAMP, nodeObject( value ), nodeObject( low ), nodeObject( high ) ) );
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* Constrains a value between `0` and `1`.
|
|
853
|
+
*
|
|
854
|
+
* @function
|
|
855
|
+
* @param {Node | Number} value - The value to constrain.
|
|
856
|
+
* @returns {Node}
|
|
857
|
+
*/
|
|
333
858
|
export const saturate = ( value ) => clamp( value );
|
|
859
|
+
|
|
860
|
+
/**
|
|
861
|
+
* Calculates the refraction direction for an incident vector.
|
|
862
|
+
*
|
|
863
|
+
* @function
|
|
864
|
+
* @param {Node<vec2|vec3|vec4>} I - The incident vector.
|
|
865
|
+
* @param {Node<vec2|vec3|vec4>} N - The normal vector.
|
|
866
|
+
* @param {Node<float>} eta - The the ratio of indices of refraction.
|
|
867
|
+
* @returns {Node<vec2|vec3|vec4>}
|
|
868
|
+
*/
|
|
334
869
|
export const refract = /*@__PURE__*/ nodeProxy( MathNode, MathNode.REFRACT );
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* Performs a Hermite interpolation between two values.
|
|
873
|
+
*
|
|
874
|
+
* @function
|
|
875
|
+
* @param {Node | Number} low - The value of the lower edge of the Hermite function.
|
|
876
|
+
* @param {Node | Number} high - The value of the upper edge of the Hermite function.
|
|
877
|
+
* @param {Node | Number} x - The source value for interpolation.
|
|
878
|
+
* @returns {Node}
|
|
879
|
+
*/
|
|
335
880
|
export const smoothstep = /*@__PURE__*/ nodeProxy( MathNode, MathNode.SMOOTHSTEP );
|
|
881
|
+
|
|
882
|
+
/**
|
|
883
|
+
* Returns a vector pointing in the same direction as another.
|
|
884
|
+
*
|
|
885
|
+
* @function
|
|
886
|
+
* @param {Node<vec2|vec3|vec4>} N - The vector to orient.
|
|
887
|
+
* @param {Node<vec2|vec3|vec4>} I - The incident vector.
|
|
888
|
+
* @param {Node<vec2|vec3|vec4>} Nref - The reference vector.
|
|
889
|
+
* @returns {Node<vec2|vec3|vec4>}
|
|
890
|
+
*/
|
|
336
891
|
export const faceForward = /*@__PURE__*/ nodeProxy( MathNode, MathNode.FACEFORWARD );
|
|
337
892
|
|
|
893
|
+
/**
|
|
894
|
+
* Returns a random value for the given uv.
|
|
895
|
+
*
|
|
896
|
+
* @function
|
|
897
|
+
* @param {Node<vec2>} uv - The uv node.
|
|
898
|
+
* @returns {Node<float>}
|
|
899
|
+
*/
|
|
338
900
|
export const rand = /*@__PURE__*/ Fn( ( [ uv ] ) => {
|
|
339
901
|
|
|
340
902
|
const a = 12.9898, b = 78.233, c = 43758.5453;
|
|
@@ -344,9 +906,50 @@ export const rand = /*@__PURE__*/ Fn( ( [ uv ] ) => {
|
|
|
344
906
|
|
|
345
907
|
} );
|
|
346
908
|
|
|
909
|
+
/**
|
|
910
|
+
* Alias for `mix()` with a different parameter order.
|
|
911
|
+
*
|
|
912
|
+
* @function
|
|
913
|
+
* @param {Node | Number} t - The interpolation value.
|
|
914
|
+
* @param {Node | Number} e1 - The first parameter.
|
|
915
|
+
* @param {Node | Number} e2 - The second parameter.
|
|
916
|
+
* @returns {Node}
|
|
917
|
+
*/
|
|
347
918
|
export const mixElement = ( t, e1, e2 ) => mix( e1, e2, t );
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* Alias for `smoothstep()` with a different parameter order.
|
|
922
|
+
*
|
|
923
|
+
* @function
|
|
924
|
+
* @param {Node | Number} x - The source value for interpolation.
|
|
925
|
+
* @param {Node | Number} low - The value of the lower edge of the Hermite function.
|
|
926
|
+
* @param {Node | Number} high - The value of the upper edge of the Hermite function.
|
|
927
|
+
* @returns {Node}
|
|
928
|
+
*/
|
|
348
929
|
export const smoothstepElement = ( x, low, high ) => smoothstep( low, high, x );
|
|
349
930
|
|
|
931
|
+
/**
|
|
932
|
+
* Returns the arc-tangent of the quotient of its parameters.
|
|
933
|
+
*
|
|
934
|
+
* @function
|
|
935
|
+
* @param {Node | Number} y - The y parameter.
|
|
936
|
+
* @param {Node | Number} x - The x parameter.
|
|
937
|
+
* @returns {Node}
|
|
938
|
+
*/
|
|
939
|
+
export const atan2 = ( y, x ) => { // @deprecated, r172
|
|
940
|
+
|
|
941
|
+
console.warn( 'THREE.TSL: "atan2" is overloaded. Use "atan" instead.' );
|
|
942
|
+
return atan( y, x );
|
|
943
|
+
|
|
944
|
+
};
|
|
945
|
+
|
|
946
|
+
// GLSL alias function
|
|
947
|
+
|
|
948
|
+
export const faceforward = faceForward;
|
|
949
|
+
export const inversesqrt = inverseSqrt;
|
|
950
|
+
|
|
951
|
+
// Method chaining
|
|
952
|
+
|
|
350
953
|
addMethodChaining( 'all', all );
|
|
351
954
|
addMethodChaining( 'any', any );
|
|
352
955
|
addMethodChaining( 'equals', equals );
|