super-three 0.167.0 → 0.169.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/build/three.cjs +532 -173
- package/build/three.module.js +532 -174
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +18173 -14266
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +79941 -0
- package/build/three.webgpu.nodes.min.js +6 -0
- package/examples/jsm/Addons.js +0 -4
- package/examples/jsm/animation/AnimationClipCreator.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +27 -21
- package/examples/jsm/controls/ArcballControls.js +174 -158
- package/examples/jsm/controls/DragControls.js +260 -132
- package/examples/jsm/controls/FirstPersonControls.js +175 -163
- package/examples/jsm/controls/FlyControls.js +194 -188
- package/examples/jsm/controls/OrbitControls.js +777 -786
- package/examples/jsm/controls/PointerLockControls.js +24 -15
- package/examples/jsm/controls/TrackballControls.js +469 -448
- package/examples/jsm/controls/TransformControls.js +97 -62
- package/examples/jsm/effects/AnaglyphEffect.js +6 -13
- package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
- package/examples/jsm/effects/StereoEffect.js +6 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -1
- package/examples/jsm/exporters/DRACOExporter.js +4 -2
- package/examples/jsm/exporters/EXRExporter.js +19 -11
- package/examples/jsm/exporters/GLTFExporter.js +6 -1
- package/examples/jsm/exporters/KTX2Exporter.js +21 -13
- package/examples/jsm/exporters/OBJExporter.js +5 -1
- package/examples/jsm/exporters/PLYExporter.js +9 -7
- package/examples/jsm/exporters/USDZExporter.js +29 -8
- package/examples/jsm/geometries/DecalGeometry.js +4 -1
- package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +43 -44
- package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
- package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/LightProbeGenerator.js +24 -10
- package/examples/jsm/loaders/ColladaLoader.js +9 -6
- package/examples/jsm/loaders/DRACOLoader.js +3 -1
- package/examples/jsm/loaders/FBXLoader.js +30 -20
- package/examples/jsm/loaders/GLTFLoader.js +5 -10
- package/examples/jsm/loaders/KTX2Loader.js +27 -12
- package/examples/jsm/loaders/MTLLoader.js +4 -3
- package/examples/jsm/loaders/MaterialXLoader.js +40 -14
- package/examples/jsm/loaders/OBJLoader.js +5 -3
- package/examples/jsm/loaders/PCDLoader.js +14 -13
- package/examples/jsm/loaders/PDBLoader.js +3 -2
- package/examples/jsm/loaders/PLYLoader.js +8 -5
- package/examples/jsm/loaders/STLLoader.js +3 -2
- package/examples/jsm/loaders/VRMLLoader.js +10 -10
- package/examples/jsm/loaders/VTKLoader.js +4 -3
- package/examples/jsm/loaders/XYZLoader.js +3 -2
- package/examples/jsm/misc/Timer.js +1 -1
- package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
- package/examples/jsm/objects/LensflareMesh.js +322 -0
- package/examples/jsm/objects/SkyMesh.js +187 -0
- package/examples/jsm/objects/Water2Mesh.js +158 -0
- package/examples/jsm/objects/WaterMesh.js +101 -0
- package/examples/jsm/physics/JoltPhysics.js +1 -1
- package/examples/jsm/physics/RapierPhysics.js +21 -1
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -2
- package/examples/jsm/shaders/OutputShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
- package/examples/jsm/transpiler/TSLEncoder.js +8 -8
- package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
- package/examples/jsm/utils/ShadowMapViewer.js +3 -8
- package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
- package/examples/jsm/utils/SkeletonUtils.js +84 -66
- package/examples/jsm/utils/TextureUtils.js +2 -1
- package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/package.json +3 -2
- package/src/Three.WebGPU.Nodes.js +200 -0
- package/src/Three.WebGPU.js +7 -0
- package/src/Three.js +1 -0
- package/src/audio/Audio.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +0 -9
- package/src/core/Clock.js +1 -1
- package/src/core/InterleavedBuffer.js +0 -9
- package/src/extras/Controls.js +32 -0
- package/src/geometries/CylinderGeometry.js +11 -4
- package/src/loaders/MaterialLoader.js +7 -1
- package/src/loaders/ObjectLoader.js +3 -3
- package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +25 -5
- package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +21 -18
- package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +19 -0
- package/src/materials/Material.js +4 -7
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +156 -0
- package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +56 -59
- package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +8 -5
- package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +12 -10
- package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +16 -12
- package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +10 -6
- package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +13 -9
- package/src/{nodes/materials → materials/nodes}/MeshNormalNodeMaterial.js +13 -9
- package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +14 -9
- package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +22 -18
- package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +10 -7
- package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +22 -12
- package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +9 -5
- package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +71 -115
- package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +3 -1
- package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +8 -5
- package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +9 -5
- package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +47 -14
- package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +24 -22
- package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
- package/src/math/Triangle.js +24 -0
- package/src/nodes/Nodes.js +103 -159
- package/src/nodes/TSL.js +179 -0
- package/src/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +53 -21
- package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
- package/src/nodes/accessors/BufferAttributeNode.js +8 -5
- package/src/nodes/accessors/BufferNode.js +7 -4
- package/src/nodes/accessors/Camera.js +13 -0
- package/src/nodes/accessors/ClippingNode.js +19 -13
- package/src/nodes/accessors/CubeTextureNode.js +9 -8
- package/src/nodes/accessors/InstanceNode.js +19 -15
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +8 -5
- package/src/nodes/accessors/Lights.js +51 -0
- package/src/nodes/accessors/MaterialNode.js +56 -55
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +9 -4
- package/src/nodes/accessors/ModelNode.js +47 -12
- package/src/nodes/accessors/ModelViewProjectionNode.js +12 -9
- package/src/nodes/accessors/MorphNode.js +17 -13
- package/src/nodes/accessors/Normal.js +88 -0
- package/src/nodes/accessors/Object3DNode.js +17 -33
- package/src/nodes/accessors/PointUVNode.js +9 -5
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +171 -0
- package/src/nodes/accessors/ReferenceNode.js +50 -7
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +12 -6
- package/src/nodes/accessors/SceneNode.js +9 -6
- package/src/nodes/accessors/SkinningNode.js +88 -21
- package/src/nodes/accessors/StorageBufferNode.js +22 -5
- package/src/nodes/accessors/StorageTextureNode.js +9 -6
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +16 -13
- package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
- package/src/nodes/accessors/TextureNode.js +29 -23
- package/src/nodes/accessors/TextureSizeNode.js +10 -9
- package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +26 -14
- package/src/nodes/accessors/UserDataNode.js +10 -7
- package/src/nodes/accessors/VelocityNode.js +134 -0
- package/src/nodes/accessors/VertexColorNode.js +7 -4
- package/src/nodes/code/CodeNode.js +9 -5
- package/src/nodes/code/ExpressionNode.js +10 -6
- package/src/nodes/code/FunctionCallNode.js +8 -5
- package/src/nodes/code/FunctionNode.js +8 -23
- package/src/nodes/code/ScriptableNode.js +13 -10
- package/src/nodes/code/ScriptableValueNode.js +9 -7
- package/src/nodes/core/AssignNode.js +12 -9
- package/src/nodes/core/AttributeNode.js +12 -21
- package/src/nodes/core/BypassNode.js +11 -7
- package/src/nodes/core/CacheNode.js +10 -6
- package/src/nodes/core/ConstNode.js +6 -3
- package/src/nodes/core/ContextNode.js +21 -11
- package/src/nodes/core/IndexNode.js +35 -8
- package/src/nodes/core/InputNode.js +7 -3
- package/src/nodes/core/MRTNode.js +16 -7
- package/src/nodes/core/Node.js +19 -40
- package/src/nodes/core/NodeBuilder.js +117 -38
- package/src/nodes/core/NodeUtils.js +49 -6
- package/src/nodes/core/OutputStructNode.js +10 -6
- package/src/nodes/core/ParameterNode.js +7 -4
- package/src/nodes/core/PropertyNode.js +36 -32
- package/src/nodes/core/StackNode.js +31 -11
- package/src/nodes/core/StructTypeNode.js +7 -3
- package/src/nodes/core/TempNode.js +8 -4
- package/src/nodes/core/UniformGroupNode.js +14 -11
- package/src/nodes/core/UniformNode.js +7 -4
- package/src/nodes/core/VarNode.js +12 -8
- package/src/nodes/core/VaryingNode.js +10 -6
- package/src/nodes/display/AfterImageNode.js +15 -9
- package/src/nodes/display/AnaglyphPassNode.js +67 -0
- package/src/nodes/display/AnamorphicNode.js +17 -11
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +27 -19
- package/src/nodes/display/BumpMapNode.js +13 -12
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +67 -61
- package/src/nodes/display/DenoiseNode.js +23 -17
- package/src/nodes/display/DepthOfFieldNode.js +12 -7
- package/src/nodes/display/DotScreenNode.js +13 -22
- package/src/nodes/display/FXAANode.js +21 -16
- package/src/nodes/display/FilmNode.js +11 -7
- package/src/nodes/display/FrontFacingNode.js +10 -6
- package/src/nodes/display/GTAONode.js +22 -15
- package/src/nodes/display/GaussianBlurNode.js +14 -8
- package/src/nodes/display/Lut3DNode.js +10 -6
- package/src/nodes/display/MotionBlur.js +25 -0
- package/src/nodes/display/NormalMapNode.js +13 -13
- package/src/nodes/display/ParallaxBarrierPassNode.js +58 -0
- package/src/nodes/display/PassNode.js +95 -8
- package/src/nodes/display/PixelationPassNode.js +20 -8
- package/src/nodes/display/PosterizeNode.js +8 -7
- package/src/nodes/display/RGBShiftNode.js +11 -7
- package/src/nodes/display/RenderOutputNode.js +15 -11
- package/src/nodes/display/SSAAPassNode.js +287 -0
- package/src/nodes/display/ScreenNode.js +181 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +13 -8
- package/src/nodes/display/StereoCompositePassNode.js +110 -0
- package/src/nodes/display/StereoPassNode.js +83 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +15 -175
- package/src/nodes/display/ToonOutlinePassNode.js +111 -0
- package/src/nodes/display/TransitionNode.js +12 -8
- package/src/nodes/display/ViewportDepthNode.js +34 -29
- package/src/nodes/display/ViewportDepthTextureNode.js +10 -9
- package/src/nodes/display/ViewportSharedTextureNode.js +10 -9
- package/src/nodes/display/ViewportTextureNode.js +11 -11
- package/src/nodes/fog/FogExp2Node.js +8 -7
- package/src/nodes/fog/FogNode.js +10 -8
- package/src/nodes/fog/FogRangeNode.js +8 -7
- package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
- package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
- package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +6 -6
- package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/BasicLightingModel.js +1 -1
- package/src/nodes/functions/PhongLightingModel.js +5 -5
- package/src/nodes/functions/PhysicalLightingModel.js +34 -33
- package/src/nodes/functions/ShadowMaskModel.js +1 -1
- package/src/nodes/functions/ToonLightingModel.js +3 -3
- package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
- package/src/nodes/functions/material/getRoughness.js +2 -2
- package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
- package/src/nodes/geometry/RangeNode.js +9 -5
- package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
- package/src/nodes/gpgpu/BarrierNode.js +40 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
- package/src/nodes/gpgpu/ComputeNode.js +10 -6
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
- package/src/nodes/lighting/AONode.js +6 -3
- package/src/nodes/lighting/AmbientLightNode.js +6 -8
- package/src/nodes/lighting/AnalyticLightNode.js +225 -36
- package/src/nodes/lighting/BasicEnvironmentNode.js +8 -4
- package/src/nodes/lighting/BasicLightMapNode.js +7 -4
- package/src/nodes/lighting/DirectionalLightNode.js +7 -9
- package/src/nodes/lighting/EnvironmentNode.js +23 -19
- package/src/nodes/lighting/HemisphereLightNode.js +11 -11
- package/src/nodes/lighting/IESSpotLightNode.js +7 -9
- package/src/nodes/lighting/IrradianceNode.js +6 -3
- package/src/nodes/lighting/LightProbeNode.js +53 -0
- package/src/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +19 -18
- package/src/nodes/lighting/LightingNode.js +7 -3
- package/src/nodes/lighting/LightsNode.js +112 -75
- package/src/nodes/lighting/PointLightNode.js +12 -13
- package/src/nodes/lighting/RectAreaLightNode.js +11 -11
- package/src/nodes/lighting/SpotLightNode.js +14 -16
- package/src/nodes/materialx/MaterialXNodes.js +2 -2
- package/src/nodes/materialx/lib/mx_hsv.js +36 -31
- package/src/nodes/materialx/lib/mx_noise.js +96 -96
- package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
- package/src/nodes/math/{CondNode.js → ConditionalNode.js} +38 -10
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +127 -124
- package/src/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +97 -52
- package/src/nodes/math/TriNoise3D.js +19 -29
- package/src/nodes/pmrem/PMREMNode.js +61 -15
- package/src/nodes/pmrem/PMREMUtils.js +46 -46
- package/src/nodes/procedural/Checker.js +14 -0
- package/src/nodes/tsl/TSLBase.js +30 -0
- package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
- package/src/nodes/utils/ArrayElementNode.js +8 -4
- package/src/nodes/utils/ConvertNode.js +7 -3
- package/src/nodes/utils/CubeMapNode.js +160 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +9 -6
- package/src/nodes/utils/FlipNode.js +68 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +9 -5
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +16 -6
- package/src/nodes/utils/MatcapUVNode.js +10 -7
- package/src/nodes/utils/MaxMipLevelNode.js +8 -5
- package/src/nodes/utils/OscNode.js +12 -8
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +11 -8
- package/src/nodes/utils/ReflectorNode.js +12 -4
- package/src/nodes/utils/RemapNode.js +12 -8
- package/src/nodes/utils/RotateNode.js +8 -13
- package/src/nodes/utils/SetNode.js +7 -4
- package/src/nodes/utils/SplitNode.js +7 -3
- package/src/nodes/utils/SpriteSheetUVNode.js +10 -6
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/src/nodes/utils/StorageArrayElementNode.js +11 -12
- package/src/nodes/utils/TimerNode.js +8 -5
- package/src/nodes/utils/TriplanarTexturesNode.js +11 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +78 -13
- package/src/objects/LOD.js +21 -0
- package/src/objects/Line.js +1 -0
- package/src/objects/Mesh.js +7 -23
- package/src/objects/Points.js +2 -0
- package/src/renderers/WebGLRenderer.js +88 -41
- package/src/renderers/common/Backend.js +2 -2
- package/src/renderers/common/Background.js +3 -1
- package/src/renderers/common/BindGroup.js +3 -1
- package/src/renderers/common/Bindings.js +13 -15
- package/src/renderers/common/BundleGroup.js +26 -0
- package/src/renderers/common/ClippingContext.js +15 -5
- package/src/renderers/common/CubeRenderTarget.js +9 -3
- package/src/renderers/common/PostProcessing.js +4 -1
- package/src/renderers/common/QuadMesh.js +2 -0
- package/src/renderers/common/RenderContext.js +23 -0
- package/src/renderers/common/RenderList.js +1 -1
- package/src/renderers/common/RenderObject.js +117 -6
- package/src/renderers/common/RenderObjects.js +8 -1
- package/src/renderers/common/Renderer.js +128 -94
- package/src/renderers/common/SampledTexture.js +12 -3
- package/src/renderers/common/Textures.js +8 -12
- package/src/renderers/common/extras/PMREMGenerator.js +19 -22
- package/src/renderers/common/nodes/NodeBuilderState.js +4 -4
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
- package/src/renderers/common/nodes/Nodes.js +65 -19
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
- package/src/renderers/webgl/WebGLAttributes.js +45 -14
- package/src/renderers/webgl/WebGLCapabilities.js +9 -0
- package/src/renderers/webgl/WebGLProgram.js +3 -1
- package/src/renderers/webgl/WebGLPrograms.js +21 -17
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLState.js +21 -0
- package/src/renderers/webgl/WebGLTextures.js +83 -4
- package/src/renderers/webgl-fallback/WebGLBackend.js +135 -110
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +60 -12
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +6 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +20 -2
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +89 -37
- package/src/renderers/webgpu/WebGPUBackend.js +112 -86
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
- package/src/renderers/webgpu/WebGPURenderer.js +9 -6
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +189 -73
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -16
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +7 -16
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +43 -26
- package/src/renderers/webgpu/utils/WebGPUUtils.js +19 -2
- package/src/renderers/webxr/WebXRManager.js +32 -25
- package/src/utils.js +33 -1
- package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/examples/jsm/loaders/TiltLoader.js +0 -520
- package/examples/jsm/utils/GPUStatsPanel.js +0 -95
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
- package/src/nodes/accessors/CameraNode.js +0 -19
- package/src/nodes/accessors/NormalNode.js +0 -14
- package/src/nodes/accessors/PositionNode.js +0 -10
- package/src/nodes/accessors/ReflectVectorNode.js +0 -10
- package/src/nodes/accessors/TangentNode.js +0 -23
- package/src/nodes/core/NodeKeywords.js +0 -80
- package/src/nodes/display/BlendModeNode.js +0 -128
- package/src/nodes/display/ColorAdjustmentNode.js +0 -104
- package/src/nodes/display/ViewportNode.js +0 -137
- package/src/nodes/lighting/LightNode.js +0 -57
- package/src/nodes/materials/InstancedPointsNodeMaterial.js +0 -162
- package/src/nodes/math/HashNode.js +0 -34
- package/src/nodes/procedural/CheckerNode.js +0 -42
- package/src/nodes/utils/DiscardNode.js +0 -28
- package/src/nodes/utils/PackingNode.js +0 -55
- package/src/nodes/utils/RotateUVNode.js +0 -35
- /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Three.js Transpiler
|
|
2
2
|
// https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/libraries/stdlib/genglsl/lib/mx_transform_color.glsl
|
|
3
3
|
|
|
4
|
-
import { bvec3, vec3,
|
|
4
|
+
import { bvec3, vec3, Fn } from '../../tsl/TSLBase.js';
|
|
5
5
|
import { greaterThan } from '../../math/OperatorNode.js';
|
|
6
6
|
import { max, pow, mix } from '../../math/MathNode.js';
|
|
7
7
|
|
|
8
|
-
export const mx_srgb_texture_to_lin_rec709 =
|
|
8
|
+
export const mx_srgb_texture_to_lin_rec709 = /*@__PURE__*/ Fn( ( [ color_immutable ] ) => {
|
|
9
9
|
|
|
10
10
|
const color = vec3( color_immutable ).toVar();
|
|
11
11
|
const isAbove = bvec3( greaterThan( color, vec3( 0.04045 ) ) ).toVar();
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import Node
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
2
|
import { property } from '../core/PropertyNode.js';
|
|
3
|
-
import {
|
|
3
|
+
import { addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
|
|
4
4
|
|
|
5
|
-
class
|
|
5
|
+
class ConditionalNode extends Node {
|
|
6
|
+
|
|
7
|
+
static get type() {
|
|
8
|
+
|
|
9
|
+
return 'ConditionalNode';
|
|
10
|
+
|
|
11
|
+
}
|
|
6
12
|
|
|
7
13
|
constructor( condNode, ifNode, elseNode = null ) {
|
|
8
14
|
|
|
@@ -37,10 +43,23 @@ class CondNode extends Node {
|
|
|
37
43
|
|
|
38
44
|
setup( builder ) {
|
|
39
45
|
|
|
46
|
+
const condNode = this.condNode.cache();
|
|
47
|
+
const ifNode = this.ifNode.cache();
|
|
48
|
+
const elseNode = this.elseNode ? this.elseNode.cache() : null;
|
|
49
|
+
|
|
50
|
+
//
|
|
51
|
+
|
|
52
|
+
const currentNodeBlock = builder.context.nodeBlock;
|
|
53
|
+
|
|
54
|
+
builder.getDataFromNode( ifNode ).parentNodeBlock = currentNodeBlock;
|
|
55
|
+
if ( elseNode !== null ) builder.getDataFromNode( elseNode ).parentNodeBlock = currentNodeBlock;
|
|
56
|
+
|
|
57
|
+
//
|
|
58
|
+
|
|
40
59
|
const properties = builder.getNodeProperties( this );
|
|
41
|
-
properties.condNode =
|
|
42
|
-
properties.ifNode =
|
|
43
|
-
properties.elseNode =
|
|
60
|
+
properties.condNode = condNode;
|
|
61
|
+
properties.ifNode = ifNode.context( { nodeBlock: ifNode } );
|
|
62
|
+
properties.elseNode = elseNode ? elseNode.context( { nodeBlock: elseNode } ) : null;
|
|
44
63
|
|
|
45
64
|
}
|
|
46
65
|
|
|
@@ -119,10 +138,19 @@ class CondNode extends Node {
|
|
|
119
138
|
|
|
120
139
|
}
|
|
121
140
|
|
|
122
|
-
export default
|
|
141
|
+
export default ConditionalNode;
|
|
142
|
+
|
|
143
|
+
export const select = /*@__PURE__*/ nodeProxy( ConditionalNode );
|
|
144
|
+
|
|
145
|
+
addMethodChaining( 'select', select );
|
|
146
|
+
|
|
147
|
+
//
|
|
148
|
+
|
|
149
|
+
export const cond = ( ...params ) => { // @deprecated, r168
|
|
123
150
|
|
|
124
|
-
|
|
151
|
+
console.warn( 'TSL.ConditionalNode: cond() has been renamed to select().' );
|
|
152
|
+
return select( ...params );
|
|
125
153
|
|
|
126
|
-
|
|
154
|
+
};
|
|
127
155
|
|
|
128
|
-
|
|
156
|
+
addMethodChaining( 'cond', cond );
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Fn } from '../tsl/TSLBase.js';
|
|
2
|
+
|
|
3
|
+
export const hash = /*@__PURE__*/ Fn( ( [ seed ] ) => {
|
|
4
|
+
|
|
5
|
+
// Taken from https://www.shadertoy.com/view/XlGcRh, originally from pcg-random.org
|
|
6
|
+
|
|
7
|
+
const state = seed.toUint().mul( 747796405 ).add( 2891336453 );
|
|
8
|
+
const word = state.shiftRight( state.shiftRight( 28 ).add( 4 ) ).bitXor( state ).mul( 277803737 );
|
|
9
|
+
const result = word.shiftRight( 22 ).bitXor( word );
|
|
10
|
+
|
|
11
|
+
return result.toFloat().mul( 1 / 2 ** 32 ); // Convert to range [0, 1)
|
|
12
|
+
|
|
13
|
+
} );
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
2
|
import { sub, mul, div } from './OperatorNode.js';
|
|
3
|
-
import {
|
|
4
|
-
import { addNodeElement, nodeObject, nodeProxy, float, vec2, vec3, vec4, tslFn } from '../shadernode/ShaderNode.js';
|
|
3
|
+
import { addMethodChaining, nodeObject, nodeProxy, float, vec2, vec3, vec4, Fn } from '../tsl/TSLCore.js';
|
|
5
4
|
|
|
6
5
|
class MathNode extends TempNode {
|
|
7
6
|
|
|
7
|
+
static get type() {
|
|
8
|
+
|
|
9
|
+
return 'MathNode';
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
constructor( method, aNode, bNode = null, cNode = null ) {
|
|
9
14
|
|
|
10
15
|
super();
|
|
@@ -139,7 +144,7 @@ class MathNode extends TempNode {
|
|
|
139
144
|
b.build( builder, type )
|
|
140
145
|
);
|
|
141
146
|
|
|
142
|
-
} else if ( method === MathNode.STEP ) {
|
|
147
|
+
} else if ( isWebGL && method === MathNode.STEP ) {
|
|
143
148
|
|
|
144
149
|
params.push(
|
|
145
150
|
a.build( builder, builder.getTypeLength( a.getNodeType( builder ) ) === 1 ? 'float' : inputType ),
|
|
@@ -264,73 +269,73 @@ MathNode.FACEFORWARD = 'faceforward';
|
|
|
264
269
|
|
|
265
270
|
export default MathNode;
|
|
266
271
|
|
|
267
|
-
export const EPSILON = float( 1e-6 );
|
|
268
|
-
export const INFINITY = float( 1e6 );
|
|
269
|
-
export const PI = float( Math.PI );
|
|
270
|
-
export const PI2 = float( Math.PI * 2 );
|
|
271
|
-
|
|
272
|
-
export const all = nodeProxy( MathNode, MathNode.ALL );
|
|
273
|
-
export const any = nodeProxy( MathNode, MathNode.ANY );
|
|
274
|
-
export const equals = nodeProxy( MathNode, MathNode.EQUALS );
|
|
275
|
-
|
|
276
|
-
export const radians = nodeProxy( MathNode, MathNode.RADIANS );
|
|
277
|
-
export const degrees = nodeProxy( MathNode, MathNode.DEGREES );
|
|
278
|
-
export const exp = nodeProxy( MathNode, MathNode.EXP );
|
|
279
|
-
export const exp2 = nodeProxy( MathNode, MathNode.EXP2 );
|
|
280
|
-
export const log = nodeProxy( MathNode, MathNode.LOG );
|
|
281
|
-
export const log2 = nodeProxy( MathNode, MathNode.LOG2 );
|
|
282
|
-
export const sqrt = nodeProxy( MathNode, MathNode.SQRT );
|
|
283
|
-
export const inverseSqrt = nodeProxy( MathNode, MathNode.INVERSE_SQRT );
|
|
284
|
-
export const floor = nodeProxy( MathNode, MathNode.FLOOR );
|
|
285
|
-
export const ceil = nodeProxy( MathNode, MathNode.CEIL );
|
|
286
|
-
export const normalize = nodeProxy( MathNode, MathNode.NORMALIZE );
|
|
287
|
-
export const fract = nodeProxy( MathNode, MathNode.FRACT );
|
|
288
|
-
export const sin = nodeProxy( MathNode, MathNode.SIN );
|
|
289
|
-
export const cos = nodeProxy( MathNode, MathNode.COS );
|
|
290
|
-
export const tan = nodeProxy( MathNode, MathNode.TAN );
|
|
291
|
-
export const asin = nodeProxy( MathNode, MathNode.ASIN );
|
|
292
|
-
export const acos = nodeProxy( MathNode, MathNode.ACOS );
|
|
293
|
-
export const atan = nodeProxy( MathNode, MathNode.ATAN );
|
|
294
|
-
export const abs = nodeProxy( MathNode, MathNode.ABS );
|
|
295
|
-
export const sign = nodeProxy( MathNode, MathNode.SIGN );
|
|
296
|
-
export const length = nodeProxy( MathNode, MathNode.LENGTH );
|
|
297
|
-
export const negate = nodeProxy( MathNode, MathNode.NEGATE );
|
|
298
|
-
export const oneMinus = nodeProxy( MathNode, MathNode.ONE_MINUS );
|
|
299
|
-
export const dFdx = nodeProxy( MathNode, MathNode.DFDX );
|
|
300
|
-
export const dFdy = nodeProxy( MathNode, MathNode.DFDY );
|
|
301
|
-
export const round = nodeProxy( MathNode, MathNode.ROUND );
|
|
302
|
-
export const reciprocal = nodeProxy( MathNode, MathNode.RECIPROCAL );
|
|
303
|
-
export const trunc = nodeProxy( MathNode, MathNode.TRUNC );
|
|
304
|
-
export const fwidth = nodeProxy( MathNode, MathNode.FWIDTH );
|
|
305
|
-
export const bitcast = nodeProxy( MathNode, MathNode.BITCAST );
|
|
306
|
-
export const transpose = nodeProxy( MathNode, MathNode.TRANSPOSE );
|
|
307
|
-
|
|
308
|
-
export const atan2 = nodeProxy( MathNode, MathNode.ATAN2 );
|
|
309
|
-
export const min = nodeProxy( MathNode, MathNode.MIN );
|
|
310
|
-
export const max = nodeProxy( MathNode, MathNode.MAX );
|
|
311
|
-
export const mod = nodeProxy( MathNode, MathNode.MOD );
|
|
312
|
-
export const step = nodeProxy( MathNode, MathNode.STEP );
|
|
313
|
-
export const reflect = nodeProxy( MathNode, MathNode.REFLECT );
|
|
314
|
-
export const distance = nodeProxy( MathNode, MathNode.DISTANCE );
|
|
315
|
-
export const difference = nodeProxy( MathNode, MathNode.DIFFERENCE );
|
|
316
|
-
export const dot = nodeProxy( MathNode, MathNode.DOT );
|
|
317
|
-
export const cross = nodeProxy( MathNode, MathNode.CROSS );
|
|
318
|
-
export const pow = nodeProxy( MathNode, MathNode.POW );
|
|
319
|
-
export const pow2 = nodeProxy( MathNode, MathNode.POW, 2 );
|
|
320
|
-
export const pow3 = nodeProxy( MathNode, MathNode.POW, 3 );
|
|
321
|
-
export const pow4 = nodeProxy( MathNode, MathNode.POW, 4 );
|
|
322
|
-
export const transformDirection = nodeProxy( MathNode, MathNode.TRANSFORM_DIRECTION );
|
|
272
|
+
export const EPSILON = /*@__PURE__*/ float( 1e-6 );
|
|
273
|
+
export const INFINITY = /*@__PURE__*/ float( 1e6 );
|
|
274
|
+
export const PI = /*@__PURE__*/ float( Math.PI );
|
|
275
|
+
export const PI2 = /*@__PURE__*/ float( Math.PI * 2 );
|
|
276
|
+
|
|
277
|
+
export const all = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ALL );
|
|
278
|
+
export const any = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ANY );
|
|
279
|
+
export const equals = /*@__PURE__*/ nodeProxy( MathNode, MathNode.EQUALS );
|
|
280
|
+
|
|
281
|
+
export const radians = /*@__PURE__*/ nodeProxy( MathNode, MathNode.RADIANS );
|
|
282
|
+
export const degrees = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DEGREES );
|
|
283
|
+
export const exp = /*@__PURE__*/ nodeProxy( MathNode, MathNode.EXP );
|
|
284
|
+
export const exp2 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.EXP2 );
|
|
285
|
+
export const log = /*@__PURE__*/ nodeProxy( MathNode, MathNode.LOG );
|
|
286
|
+
export const log2 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.LOG2 );
|
|
287
|
+
export const sqrt = /*@__PURE__*/ nodeProxy( MathNode, MathNode.SQRT );
|
|
288
|
+
export const inverseSqrt = /*@__PURE__*/ nodeProxy( MathNode, MathNode.INVERSE_SQRT );
|
|
289
|
+
export const floor = /*@__PURE__*/ nodeProxy( MathNode, MathNode.FLOOR );
|
|
290
|
+
export const ceil = /*@__PURE__*/ nodeProxy( MathNode, MathNode.CEIL );
|
|
291
|
+
export const normalize = /*@__PURE__*/ nodeProxy( MathNode, MathNode.NORMALIZE );
|
|
292
|
+
export const fract = /*@__PURE__*/ nodeProxy( MathNode, MathNode.FRACT );
|
|
293
|
+
export const sin = /*@__PURE__*/ nodeProxy( MathNode, MathNode.SIN );
|
|
294
|
+
export const cos = /*@__PURE__*/ nodeProxy( MathNode, MathNode.COS );
|
|
295
|
+
export const tan = /*@__PURE__*/ nodeProxy( MathNode, MathNode.TAN );
|
|
296
|
+
export const asin = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ASIN );
|
|
297
|
+
export const acos = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ACOS );
|
|
298
|
+
export const atan = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ATAN );
|
|
299
|
+
export const abs = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ABS );
|
|
300
|
+
export const sign = /*@__PURE__*/ nodeProxy( MathNode, MathNode.SIGN );
|
|
301
|
+
export const length = /*@__PURE__*/ nodeProxy( MathNode, MathNode.LENGTH );
|
|
302
|
+
export const negate = /*@__PURE__*/ nodeProxy( MathNode, MathNode.NEGATE );
|
|
303
|
+
export const oneMinus = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ONE_MINUS );
|
|
304
|
+
export const dFdx = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DFDX );
|
|
305
|
+
export const dFdy = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DFDY );
|
|
306
|
+
export const round = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ROUND );
|
|
307
|
+
export const reciprocal = /*@__PURE__*/ nodeProxy( MathNode, MathNode.RECIPROCAL );
|
|
308
|
+
export const trunc = /*@__PURE__*/ nodeProxy( MathNode, MathNode.TRUNC );
|
|
309
|
+
export const fwidth = /*@__PURE__*/ nodeProxy( MathNode, MathNode.FWIDTH );
|
|
310
|
+
export const bitcast = /*@__PURE__*/ nodeProxy( MathNode, MathNode.BITCAST );
|
|
311
|
+
export const transpose = /*@__PURE__*/ nodeProxy( MathNode, MathNode.TRANSPOSE );
|
|
312
|
+
|
|
313
|
+
export const atan2 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ATAN2 );
|
|
314
|
+
export const min = /*@__PURE__*/ nodeProxy( MathNode, MathNode.MIN );
|
|
315
|
+
export const max = /*@__PURE__*/ nodeProxy( MathNode, MathNode.MAX );
|
|
316
|
+
export const mod = /*@__PURE__*/ nodeProxy( MathNode, MathNode.MOD );
|
|
317
|
+
export const step = /*@__PURE__*/ nodeProxy( MathNode, MathNode.STEP );
|
|
318
|
+
export const reflect = /*@__PURE__*/ nodeProxy( MathNode, MathNode.REFLECT );
|
|
319
|
+
export const distance = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DISTANCE );
|
|
320
|
+
export const difference = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DIFFERENCE );
|
|
321
|
+
export const dot = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DOT );
|
|
322
|
+
export const cross = /*@__PURE__*/ nodeProxy( MathNode, MathNode.CROSS );
|
|
323
|
+
export const pow = /*@__PURE__*/ nodeProxy( MathNode, MathNode.POW );
|
|
324
|
+
export const pow2 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.POW, 2 );
|
|
325
|
+
export const pow3 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.POW, 3 );
|
|
326
|
+
export const pow4 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.POW, 4 );
|
|
327
|
+
export const transformDirection = /*@__PURE__*/ nodeProxy( MathNode, MathNode.TRANSFORM_DIRECTION );
|
|
323
328
|
|
|
324
329
|
export const cbrt = ( a ) => mul( sign( a ), pow( abs( a ), 1.0 / 3.0 ) );
|
|
325
330
|
export const lengthSq = ( a ) => dot( a, a );
|
|
326
|
-
export const mix = nodeProxy( MathNode, MathNode.MIX );
|
|
331
|
+
export const mix = /*@__PURE__*/ nodeProxy( MathNode, MathNode.MIX );
|
|
327
332
|
export const clamp = ( value, low = 0, high = 1 ) => nodeObject( new MathNode( MathNode.CLAMP, nodeObject( value ), nodeObject( low ), nodeObject( high ) ) );
|
|
328
333
|
export const saturate = ( value ) => clamp( value );
|
|
329
|
-
export const refract = nodeProxy( MathNode, MathNode.REFRACT );
|
|
330
|
-
export const smoothstep = nodeProxy( MathNode, MathNode.SMOOTHSTEP );
|
|
331
|
-
export const faceForward = nodeProxy( MathNode, MathNode.FACEFORWARD );
|
|
334
|
+
export const refract = /*@__PURE__*/ nodeProxy( MathNode, MathNode.REFRACT );
|
|
335
|
+
export const smoothstep = /*@__PURE__*/ nodeProxy( MathNode, MathNode.SMOOTHSTEP );
|
|
336
|
+
export const faceForward = /*@__PURE__*/ nodeProxy( MathNode, MathNode.FACEFORWARD );
|
|
332
337
|
|
|
333
|
-
export const rand =
|
|
338
|
+
export const rand = /*@__PURE__*/ Fn( ( [ uv ] ) => {
|
|
334
339
|
|
|
335
340
|
const a = 12.9898, b = 78.233, c = 43758.5453;
|
|
336
341
|
const dt = dot( uv.xy, vec2( a, b ) ), sn = mod( dt, PI );
|
|
@@ -342,63 +347,61 @@ export const rand = tslFn( ( [ uv ] ) => {
|
|
|
342
347
|
export const mixElement = ( t, e1, e2 ) => mix( e1, e2, t );
|
|
343
348
|
export const smoothstepElement = ( x, low, high ) => smoothstep( low, high, x );
|
|
344
349
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
addNodeClass( 'MathNode', MathNode );
|
|
350
|
+
addMethodChaining( 'all', all );
|
|
351
|
+
addMethodChaining( 'any', any );
|
|
352
|
+
addMethodChaining( 'equals', equals );
|
|
353
|
+
|
|
354
|
+
addMethodChaining( 'radians', radians );
|
|
355
|
+
addMethodChaining( 'degrees', degrees );
|
|
356
|
+
addMethodChaining( 'exp', exp );
|
|
357
|
+
addMethodChaining( 'exp2', exp2 );
|
|
358
|
+
addMethodChaining( 'log', log );
|
|
359
|
+
addMethodChaining( 'log2', log2 );
|
|
360
|
+
addMethodChaining( 'sqrt', sqrt );
|
|
361
|
+
addMethodChaining( 'inverseSqrt', inverseSqrt );
|
|
362
|
+
addMethodChaining( 'floor', floor );
|
|
363
|
+
addMethodChaining( 'ceil', ceil );
|
|
364
|
+
addMethodChaining( 'normalize', normalize );
|
|
365
|
+
addMethodChaining( 'fract', fract );
|
|
366
|
+
addMethodChaining( 'sin', sin );
|
|
367
|
+
addMethodChaining( 'cos', cos );
|
|
368
|
+
addMethodChaining( 'tan', tan );
|
|
369
|
+
addMethodChaining( 'asin', asin );
|
|
370
|
+
addMethodChaining( 'acos', acos );
|
|
371
|
+
addMethodChaining( 'atan', atan );
|
|
372
|
+
addMethodChaining( 'abs', abs );
|
|
373
|
+
addMethodChaining( 'sign', sign );
|
|
374
|
+
addMethodChaining( 'length', length );
|
|
375
|
+
addMethodChaining( 'lengthSq', lengthSq );
|
|
376
|
+
addMethodChaining( 'negate', negate );
|
|
377
|
+
addMethodChaining( 'oneMinus', oneMinus );
|
|
378
|
+
addMethodChaining( 'dFdx', dFdx );
|
|
379
|
+
addMethodChaining( 'dFdy', dFdy );
|
|
380
|
+
addMethodChaining( 'round', round );
|
|
381
|
+
addMethodChaining( 'reciprocal', reciprocal );
|
|
382
|
+
addMethodChaining( 'trunc', trunc );
|
|
383
|
+
addMethodChaining( 'fwidth', fwidth );
|
|
384
|
+
addMethodChaining( 'atan2', atan2 );
|
|
385
|
+
addMethodChaining( 'min', min );
|
|
386
|
+
addMethodChaining( 'max', max );
|
|
387
|
+
addMethodChaining( 'mod', mod );
|
|
388
|
+
addMethodChaining( 'step', step );
|
|
389
|
+
addMethodChaining( 'reflect', reflect );
|
|
390
|
+
addMethodChaining( 'distance', distance );
|
|
391
|
+
addMethodChaining( 'dot', dot );
|
|
392
|
+
addMethodChaining( 'cross', cross );
|
|
393
|
+
addMethodChaining( 'pow', pow );
|
|
394
|
+
addMethodChaining( 'pow2', pow2 );
|
|
395
|
+
addMethodChaining( 'pow3', pow3 );
|
|
396
|
+
addMethodChaining( 'pow4', pow4 );
|
|
397
|
+
addMethodChaining( 'transformDirection', transformDirection );
|
|
398
|
+
addMethodChaining( 'mix', mixElement );
|
|
399
|
+
addMethodChaining( 'clamp', clamp );
|
|
400
|
+
addMethodChaining( 'refract', refract );
|
|
401
|
+
addMethodChaining( 'smoothstep', smoothstepElement );
|
|
402
|
+
addMethodChaining( 'faceForward', faceForward );
|
|
403
|
+
addMethodChaining( 'difference', difference );
|
|
404
|
+
addMethodChaining( 'saturate', saturate );
|
|
405
|
+
addMethodChaining( 'cbrt', cbrt );
|
|
406
|
+
addMethodChaining( 'transpose', transpose );
|
|
407
|
+
addMethodChaining( 'rand', rand );
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { sub, mul, div, add } from './OperatorNode.js';
|
|
2
|
-
import { addNodeElement } from '../shadernode/ShaderNode.js';
|
|
3
2
|
import { PI, pow, sin } from './MathNode.js';
|
|
4
3
|
|
|
5
4
|
// remapping functions https://iquilezles.org/articles/functions/
|
|
@@ -7,9 +6,3 @@ export const parabola = ( x, k ) => pow( mul( 4.0, x.mul( sub( 1.0, x ) ) ), k )
|
|
|
7
6
|
export const gain = ( x, k ) => x.lessThan( 0.5 ) ? parabola( x.mul( 2.0 ), k ).div( 2.0 ) : sub( 1.0, parabola( mul( sub( 1.0, x ), 2.0 ), k ).div( 2.0 ) );
|
|
8
7
|
export const pcurve = ( x, a, b ) => pow( div( pow( x, a ), add( pow( x, a ), pow( sub( 1.0, x ), b ) ) ), 1.0 / a );
|
|
9
8
|
export const sinc = ( x, k ) => sin( PI.mul( k.mul( x ).sub( 1.0 ) ) ).div( PI.mul( k.mul( x ).sub( 1.0 ) ) );
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
addNodeElement( 'parabola', parabola );
|
|
13
|
-
addNodeElement( 'gain', gain );
|
|
14
|
-
addNodeElement( 'pcurve', pcurve );
|
|
15
|
-
addNodeElement( 'sinc', sinc );
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
|
-
import {
|
|
3
|
-
import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js';
|
|
2
|
+
import { addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
|
|
4
3
|
|
|
5
4
|
class OperatorNode extends TempNode {
|
|
6
5
|
|
|
6
|
+
static get type() {
|
|
7
|
+
|
|
8
|
+
return 'OperatorNode';
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
constructor( op, aNode, bNode, ...params ) {
|
|
8
13
|
|
|
9
14
|
super();
|
|
@@ -116,7 +121,7 @@ class OperatorNode extends TempNode {
|
|
|
116
121
|
|
|
117
122
|
typeB = typeA;
|
|
118
123
|
|
|
119
|
-
} else {
|
|
124
|
+
} else if ( typeA !== typeB ) {
|
|
120
125
|
|
|
121
126
|
typeA = typeB = 'float';
|
|
122
127
|
|
|
@@ -163,19 +168,51 @@ class OperatorNode extends TempNode {
|
|
|
163
168
|
|
|
164
169
|
if ( op === '<' && outputLength > 1 ) {
|
|
165
170
|
|
|
166
|
-
|
|
171
|
+
if ( builder.useComparisonMethod ) {
|
|
172
|
+
|
|
173
|
+
return builder.format( `${ builder.getMethod( 'lessThan', output ) }( ${ a }, ${ b } )`, type, output );
|
|
174
|
+
|
|
175
|
+
} else {
|
|
176
|
+
|
|
177
|
+
return builder.format( `( ${ a } < ${ b } )`, type, output );
|
|
178
|
+
|
|
179
|
+
}
|
|
167
180
|
|
|
168
181
|
} else if ( op === '<=' && outputLength > 1 ) {
|
|
169
182
|
|
|
170
|
-
|
|
183
|
+
if ( builder.useComparisonMethod ) {
|
|
184
|
+
|
|
185
|
+
return builder.format( `${ builder.getMethod( 'lessThanEqual', output ) }( ${ a }, ${ b } )`, type, output );
|
|
186
|
+
|
|
187
|
+
} else {
|
|
188
|
+
|
|
189
|
+
return builder.format( `( ${ a } <= ${ b } )`, type, output );
|
|
190
|
+
|
|
191
|
+
}
|
|
171
192
|
|
|
172
193
|
} else if ( op === '>' && outputLength > 1 ) {
|
|
173
194
|
|
|
174
|
-
|
|
195
|
+
if ( builder.useComparisonMethod ) {
|
|
196
|
+
|
|
197
|
+
return builder.format( `${ builder.getMethod( 'greaterThan', output ) }( ${ a }, ${ b } )`, type, output );
|
|
198
|
+
|
|
199
|
+
} else {
|
|
200
|
+
|
|
201
|
+
return builder.format( `( ${ a } > ${ b } )`, type, output );
|
|
202
|
+
|
|
203
|
+
}
|
|
175
204
|
|
|
176
205
|
} else if ( op === '>=' && outputLength > 1 ) {
|
|
177
206
|
|
|
178
|
-
|
|
207
|
+
if ( builder.useComparisonMethod ) {
|
|
208
|
+
|
|
209
|
+
return builder.format( `${ builder.getMethod( 'greaterThanEqual', output ) }( ${ a }, ${ b } )`, type, output );
|
|
210
|
+
|
|
211
|
+
} else {
|
|
212
|
+
|
|
213
|
+
return builder.format( `( ${ a } >= ${ b } )`, type, output );
|
|
214
|
+
|
|
215
|
+
}
|
|
179
216
|
|
|
180
217
|
} else if ( op === '!' || op === '~' ) {
|
|
181
218
|
|
|
@@ -227,48 +264,56 @@ class OperatorNode extends TempNode {
|
|
|
227
264
|
|
|
228
265
|
export default OperatorNode;
|
|
229
266
|
|
|
230
|
-
export const add = nodeProxy( OperatorNode, '+' );
|
|
231
|
-
export const sub = nodeProxy( OperatorNode, '-' );
|
|
232
|
-
export const mul = nodeProxy( OperatorNode, '*' );
|
|
233
|
-
export const div = nodeProxy( OperatorNode, '/' );
|
|
234
|
-
export const
|
|
235
|
-
export const equal = nodeProxy( OperatorNode, '==' );
|
|
236
|
-
export const notEqual = nodeProxy( OperatorNode, '!=' );
|
|
237
|
-
export const lessThan = nodeProxy( OperatorNode, '<' );
|
|
238
|
-
export const greaterThan = nodeProxy( OperatorNode, '>' );
|
|
239
|
-
export const lessThanEqual = nodeProxy( OperatorNode, '<=' );
|
|
240
|
-
export const greaterThanEqual = nodeProxy( OperatorNode, '>=' );
|
|
241
|
-
export const and = nodeProxy( OperatorNode, '&&' );
|
|
242
|
-
export const or = nodeProxy( OperatorNode, '||' );
|
|
243
|
-
export const not = nodeProxy( OperatorNode, '!' );
|
|
244
|
-
export const xor = nodeProxy( OperatorNode, '^^' );
|
|
245
|
-
export const bitAnd = nodeProxy( OperatorNode, '&' );
|
|
246
|
-
export const bitNot = nodeProxy( OperatorNode, '~' );
|
|
247
|
-
export const bitOr = nodeProxy( OperatorNode, '|' );
|
|
248
|
-
export const bitXor = nodeProxy( OperatorNode, '^' );
|
|
249
|
-
export const shiftLeft = nodeProxy( OperatorNode, '<<' );
|
|
250
|
-
export const shiftRight = nodeProxy( OperatorNode, '>>' );
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
267
|
+
export const add = /*@__PURE__*/ nodeProxy( OperatorNode, '+' );
|
|
268
|
+
export const sub = /*@__PURE__*/ nodeProxy( OperatorNode, '-' );
|
|
269
|
+
export const mul = /*@__PURE__*/ nodeProxy( OperatorNode, '*' );
|
|
270
|
+
export const div = /*@__PURE__*/ nodeProxy( OperatorNode, '/' );
|
|
271
|
+
export const modInt = /*@__PURE__*/ nodeProxy( OperatorNode, '%' );
|
|
272
|
+
export const equal = /*@__PURE__*/ nodeProxy( OperatorNode, '==' );
|
|
273
|
+
export const notEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '!=' );
|
|
274
|
+
export const lessThan = /*@__PURE__*/ nodeProxy( OperatorNode, '<' );
|
|
275
|
+
export const greaterThan = /*@__PURE__*/ nodeProxy( OperatorNode, '>' );
|
|
276
|
+
export const lessThanEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '<=' );
|
|
277
|
+
export const greaterThanEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '>=' );
|
|
278
|
+
export const and = /*@__PURE__*/ nodeProxy( OperatorNode, '&&' );
|
|
279
|
+
export const or = /*@__PURE__*/ nodeProxy( OperatorNode, '||' );
|
|
280
|
+
export const not = /*@__PURE__*/ nodeProxy( OperatorNode, '!' );
|
|
281
|
+
export const xor = /*@__PURE__*/ nodeProxy( OperatorNode, '^^' );
|
|
282
|
+
export const bitAnd = /*@__PURE__*/ nodeProxy( OperatorNode, '&' );
|
|
283
|
+
export const bitNot = /*@__PURE__*/ nodeProxy( OperatorNode, '~' );
|
|
284
|
+
export const bitOr = /*@__PURE__*/ nodeProxy( OperatorNode, '|' );
|
|
285
|
+
export const bitXor = /*@__PURE__*/ nodeProxy( OperatorNode, '^' );
|
|
286
|
+
export const shiftLeft = /*@__PURE__*/ nodeProxy( OperatorNode, '<<' );
|
|
287
|
+
export const shiftRight = /*@__PURE__*/ nodeProxy( OperatorNode, '>>' );
|
|
288
|
+
|
|
289
|
+
addMethodChaining( 'add', add );
|
|
290
|
+
addMethodChaining( 'sub', sub );
|
|
291
|
+
addMethodChaining( 'mul', mul );
|
|
292
|
+
addMethodChaining( 'div', div );
|
|
293
|
+
addMethodChaining( 'modInt', modInt );
|
|
294
|
+
addMethodChaining( 'equal', equal );
|
|
295
|
+
addMethodChaining( 'notEqual', notEqual );
|
|
296
|
+
addMethodChaining( 'lessThan', lessThan );
|
|
297
|
+
addMethodChaining( 'greaterThan', greaterThan );
|
|
298
|
+
addMethodChaining( 'lessThanEqual', lessThanEqual );
|
|
299
|
+
addMethodChaining( 'greaterThanEqual', greaterThanEqual );
|
|
300
|
+
addMethodChaining( 'and', and );
|
|
301
|
+
addMethodChaining( 'or', or );
|
|
302
|
+
addMethodChaining( 'not', not );
|
|
303
|
+
addMethodChaining( 'xor', xor );
|
|
304
|
+
addMethodChaining( 'bitAnd', bitAnd );
|
|
305
|
+
addMethodChaining( 'bitNot', bitNot );
|
|
306
|
+
addMethodChaining( 'bitOr', bitOr );
|
|
307
|
+
addMethodChaining( 'bitXor', bitXor );
|
|
308
|
+
addMethodChaining( 'shiftLeft', shiftLeft );
|
|
309
|
+
addMethodChaining( 'shiftRight', shiftRight );
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
export const remainder = ( ...params ) => { // @deprecated, r168
|
|
313
|
+
|
|
314
|
+
console.warn( 'TSL.OperatorNode: .remainder() has been renamed to .modInt().' );
|
|
315
|
+
return modInt( ...params );
|
|
316
|
+
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
addMethodChaining( 'remainder', remainder );
|