super-three 0.167.0 → 0.168.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 +165 -44
- package/build/three.module.js +165 -45
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +23600 -21931
- package/build/three.webgpu.min.js +1 -1
- package/examples/jsm/Addons.js +3 -1
- 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 +453 -452
- 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/GLTFExporter.js +6 -1
- package/examples/jsm/exporters/USDZExporter.js +29 -8
- package/examples/jsm/helpers/LightProbeHelper.js +42 -43
- package/examples/jsm/loaders/KTX2Loader.js +19 -7
- package/examples/jsm/loaders/MaterialXLoader.js +11 -4
- package/examples/jsm/loaders/PCDLoader.js +9 -9
- package/examples/jsm/objects/SkyMesh.js +188 -0
- package/examples/jsm/objects/Water2Mesh.js +159 -0
- package/examples/jsm/objects/WaterMesh.js +102 -0
- package/examples/jsm/physics/RapierPhysics.js +20 -0
- 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/TSLEncoder.js +8 -8
- package/examples/jsm/utils/TextureUtils.js +1 -1
- package/package.json +2 -1
- package/src/Three.WebGPU.js +6 -0
- package/src/Three.js +1 -0
- package/src/constants.js +1 -1
- package/src/extras/Controls.js +32 -0
- package/src/loaders/ObjectLoader.js +3 -3
- package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +4 -4
- package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +1 -2
- package/src/materials/Material.js +4 -7
- package/src/{nodes/materials → materials/nodes}/InstancedPointsNodeMaterial.js +33 -24
- package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +34 -37
- package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +3 -4
- package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +7 -9
- package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +11 -11
- package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +5 -5
- package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +8 -8
- package/src/materials/nodes/MeshNormalNodeMaterial.js +40 -0
- package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +9 -8
- package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +18 -17
- package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +6 -6
- package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +17 -11
- package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +4 -4
- package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +67 -86
- package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +1 -1
- package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +3 -4
- package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +4 -4
- package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +11 -11
- package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +14 -16
- package/src/nodes/Nodes.js +103 -159
- package/src/nodes/TSL.js +176 -0
- package/src/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +48 -20
- package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
- package/src/nodes/accessors/BufferAttributeNode.js +5 -5
- package/src/nodes/accessors/BufferNode.js +4 -4
- package/src/nodes/accessors/{CameraNode.js → Camera.js} +10 -10
- package/src/nodes/accessors/ClippingNode.js +16 -14
- package/src/nodes/accessors/CubeTextureNode.js +5 -7
- package/src/nodes/accessors/InstanceNode.js +17 -13
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +4 -4
- package/src/nodes/accessors/MaterialNode.js +52 -55
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +6 -4
- package/src/nodes/accessors/ModelNode.js +11 -11
- package/src/nodes/accessors/ModelViewProjectionNode.js +6 -7
- package/src/nodes/accessors/MorphNode.js +12 -12
- package/src/nodes/accessors/Normal.js +62 -0
- package/src/nodes/accessors/Object3DNode.js +10 -10
- package/src/nodes/accessors/PointUVNode.js +4 -4
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +143 -0
- package/src/nodes/accessors/ReferenceNode.js +13 -7
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +6 -6
- package/src/nodes/accessors/SceneNode.js +5 -6
- package/src/nodes/accessors/SkinningNode.js +84 -21
- package/src/nodes/accessors/StorageBufferNode.js +4 -5
- package/src/nodes/accessors/StorageTextureNode.js +5 -5
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +11 -11
- package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
- package/src/nodes/accessors/TextureNode.js +16 -21
- package/src/nodes/accessors/TextureSizeNode.js +4 -6
- package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +17 -8
- package/src/nodes/accessors/UserDataNode.js +4 -4
- package/src/nodes/accessors/VelocityNode.js +83 -0
- package/src/nodes/accessors/VertexColorNode.js +4 -4
- package/src/nodes/code/CodeNode.js +5 -5
- package/src/nodes/code/ExpressionNode.js +4 -4
- package/src/nodes/code/FunctionCallNode.js +5 -5
- package/src/nodes/code/FunctionNode.js +5 -23
- package/src/nodes/code/ScriptableNode.js +4 -6
- package/src/nodes/code/ScriptableValueNode.js +4 -6
- package/src/nodes/core/AssignNode.js +5 -5
- package/src/nodes/core/AttributeNode.js +7 -20
- package/src/nodes/core/BypassNode.js +5 -5
- package/src/nodes/core/CacheNode.js +5 -5
- package/src/nodes/core/ConstNode.js +2 -2
- package/src/nodes/core/ContextNode.js +17 -11
- package/src/nodes/core/IndexNode.js +12 -7
- package/src/nodes/core/InputNode.js +2 -2
- package/src/nodes/core/MRTNode.js +12 -6
- package/src/nodes/core/Node.js +39 -19
- package/src/nodes/core/NodeBuilder.js +46 -33
- package/src/nodes/core/NodeUtils.js +1 -0
- package/src/nodes/core/OutputStructNode.js +4 -4
- package/src/nodes/core/ParameterNode.js +4 -4
- package/src/nodes/core/PropertyNode.js +32 -32
- package/src/nodes/core/StackNode.js +26 -10
- package/src/nodes/core/StructTypeNode.js +2 -2
- package/src/nodes/core/TempNode.js +2 -2
- package/src/nodes/core/UniformGroupNode.js +8 -9
- package/src/nodes/core/UniformNode.js +4 -4
- package/src/nodes/core/VarNode.js +6 -6
- package/src/nodes/core/VaryingNode.js +5 -5
- package/src/nodes/display/AfterImageNode.js +9 -9
- package/src/nodes/display/AnaglyphPassNode.js +61 -0
- package/src/nodes/display/AnamorphicNode.js +11 -11
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +21 -19
- package/src/nodes/display/BumpMapNode.js +7 -12
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +40 -63
- package/src/nodes/display/DenoiseNode.js +20 -17
- package/src/nodes/display/DepthOfFieldNode.js +8 -6
- package/src/nodes/display/DotScreenNode.js +10 -22
- package/src/nodes/display/FXAANode.js +17 -15
- package/src/nodes/display/FilmNode.js +7 -6
- package/src/nodes/display/FrontFacingNode.js +5 -5
- package/src/nodes/display/GTAONode.js +19 -15
- package/src/nodes/display/GaussianBlurNode.js +11 -8
- package/src/nodes/display/Lut3DNode.js +6 -5
- package/src/nodes/display/MotionBlur.js +25 -0
- package/src/nodes/display/NormalMapNode.js +8 -10
- package/src/nodes/display/ParallaxBarrierPassNode.js +55 -0
- package/src/nodes/display/PassNode.js +84 -8
- package/src/nodes/display/PixelationPassNode.js +12 -7
- package/src/nodes/display/PosterizeNode.js +4 -6
- package/src/nodes/display/RGBShiftNode.js +8 -7
- package/src/nodes/display/RenderOutputNode.js +9 -9
- package/src/nodes/display/SSAAPassNode.js +284 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +9 -7
- package/src/nodes/display/StereoCompositePassNode.js +107 -0
- package/src/nodes/display/StereoPassNode.js +80 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +12 -173
- package/src/nodes/display/TransitionNode.js +9 -8
- package/src/nodes/display/ViewportDepthNode.js +30 -29
- package/src/nodes/display/ViewportDepthTextureNode.js +6 -8
- package/src/nodes/display/ViewportNode.js +26 -25
- package/src/nodes/display/ViewportSharedTextureNode.js +6 -8
- package/src/nodes/display/ViewportTextureNode.js +7 -10
- package/src/nodes/fog/FogExp2Node.js +4 -6
- package/src/nodes/fog/FogNode.js +5 -7
- package/src/nodes/fog/FogRangeNode.js +4 -6
- 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 +32 -31
- 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/geometry/RangeNode.js +4 -4
- package/src/nodes/gpgpu/ComputeNode.js +5 -5
- package/src/nodes/lighting/AONode.js +2 -2
- package/src/nodes/lighting/AmbientLightNode.js +2 -7
- package/src/nodes/lighting/AnalyticLightNode.js +34 -13
- package/src/nodes/lighting/BasicEnvironmentNode.js +4 -3
- package/src/nodes/lighting/BasicLightMapNode.js +3 -3
- package/src/nodes/lighting/DirectionalLightNode.js +2 -7
- package/src/nodes/lighting/EnvironmentNode.js +20 -19
- package/src/nodes/lighting/HemisphereLightNode.js +3 -7
- package/src/nodes/lighting/IESSpotLightNode.js +3 -8
- package/src/nodes/lighting/IrradianceNode.js +2 -2
- package/src/nodes/lighting/LightNode.js +5 -5
- package/src/nodes/lighting/LightProbeNode.js +76 -0
- package/src/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +15 -17
- package/src/nodes/lighting/LightingNode.js +2 -2
- package/src/nodes/lighting/LightsNode.js +94 -76
- package/src/nodes/lighting/PointLightNode.js +3 -8
- package/src/nodes/lighting/RectAreaLightNode.js +2 -6
- package/src/nodes/lighting/SpotLightNode.js +3 -8
- 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} +18 -7
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +124 -124
- package/src/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +94 -52
- package/src/nodes/math/TriNoise3D.js +19 -29
- package/src/nodes/pmrem/PMREMNode.js +58 -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 +2 -2
- package/src/nodes/utils/ConvertNode.js +2 -2
- package/src/nodes/utils/CubeMapNode.js +157 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +5 -5
- package/src/nodes/utils/FlipNode.js +65 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +5 -5
- package/src/nodes/utils/JoinNode.js +2 -2
- package/src/nodes/utils/LoopNode.js +12 -6
- package/src/nodes/utils/MatcapUVNode.js +6 -6
- package/src/nodes/utils/MaxMipLevelNode.js +4 -4
- package/src/nodes/utils/OscNode.js +7 -7
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +8 -8
- package/src/nodes/utils/ReflectorNode.js +8 -3
- package/src/nodes/utils/RemapNode.js +7 -7
- package/src/nodes/utils/RotateNode.js +4 -12
- package/src/nodes/utils/SetNode.js +2 -2
- package/src/nodes/utils/SplitNode.js +2 -2
- package/src/nodes/utils/SpriteSheetUVNode.js +5 -5
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/src/nodes/utils/StorageArrayElementNode.js +4 -6
- package/src/nodes/utils/TimerNode.js +5 -5
- package/src/nodes/utils/TriplanarTexturesNode.js +7 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +2 -3
- package/src/renderers/WebGLRenderer.js +24 -0
- 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/ClippingContext.js +14 -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 +24 -0
- package/src/renderers/common/RenderList.js +1 -1
- package/src/renderers/common/RenderObject.js +2 -2
- package/src/renderers/common/Renderer.js +75 -49
- package/src/renderers/common/SampledTexture.js +12 -3
- package/src/renderers/common/StandardRenderer.js +18 -0
- package/src/renderers/common/Textures.js +8 -12
- package/src/renderers/common/extras/PMREMGenerator.js +12 -13
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- 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 +36 -9
- package/src/renderers/common/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
- package/src/renderers/webgl/WebGLProgram.js +1 -1
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLTextures.js +61 -4
- package/src/renderers/webgl-fallback/WebGLBackend.js +88 -68
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +57 -9
- package/src/renderers/webgl-fallback/utils/WebGLState.js +21 -0
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +28 -21
- package/src/renderers/webgpu/WebGPUBackend.js +86 -68
- package/src/renderers/webgpu/WebGPURenderer.js +8 -8
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +99 -63
- 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 +6 -15
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +36 -21
- package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -1
- package/src/renderers/webxr/WebXRManager.js +32 -25
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- 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/materials/MeshNormalNodeMaterial.js +0 -40
- 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/loaders → loaders/nodes}/NodeObjectLoader.js +0 -0
- /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,8 @@
|
|
|
1
|
-
import Node, {
|
|
1
|
+
import Node, { registerNode } 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
6
|
|
|
7
7
|
constructor( condNode, ifNode, elseNode = null ) {
|
|
8
8
|
|
|
@@ -119,10 +119,21 @@ class CondNode extends Node {
|
|
|
119
119
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
export default
|
|
122
|
+
export default ConditionalNode;
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
ConditionalNode.type = /*@__PURE__*/ registerNode( 'Conditional', ConditionalNode );
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
export const select = /*@__PURE__*/ nodeProxy( ConditionalNode );
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
addMethodChaining( 'select', select );
|
|
129
|
+
|
|
130
|
+
//
|
|
131
|
+
|
|
132
|
+
export const cond = ( ...params ) => { // @deprecated, r168
|
|
133
|
+
|
|
134
|
+
console.warn( 'TSL.ConditionalNode: cond() has been renamed to select().' );
|
|
135
|
+
return select( ...params );
|
|
136
|
+
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
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,7 +1,7 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
1
2
|
import TempNode from '../core/TempNode.js';
|
|
2
3
|
import { sub, mul, div } from './OperatorNode.js';
|
|
3
|
-
import {
|
|
4
|
-
import { addNodeElement, nodeObject, nodeProxy, float, vec2, vec3, vec4, tslFn } from '../shadernode/ShaderNode.js';
|
|
4
|
+
import { addMethodChaining, nodeObject, nodeProxy, float, vec2, vec3, vec4, Fn } from '../tsl/TSLCore.js';
|
|
5
5
|
|
|
6
6
|
class MathNode extends TempNode {
|
|
7
7
|
|
|
@@ -139,7 +139,7 @@ class MathNode extends TempNode {
|
|
|
139
139
|
b.build( builder, type )
|
|
140
140
|
);
|
|
141
141
|
|
|
142
|
-
} else if ( method === MathNode.STEP ) {
|
|
142
|
+
} else if ( isWebGL && method === MathNode.STEP ) {
|
|
143
143
|
|
|
144
144
|
params.push(
|
|
145
145
|
a.build( builder, builder.getTypeLength( a.getNodeType( builder ) ) === 1 ? 'float' : inputType ),
|
|
@@ -264,73 +264,75 @@ MathNode.FACEFORWARD = 'faceforward';
|
|
|
264
264
|
|
|
265
265
|
export default MathNode;
|
|
266
266
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
export const
|
|
270
|
-
export const
|
|
271
|
-
|
|
272
|
-
export const
|
|
273
|
-
|
|
274
|
-
export const
|
|
275
|
-
|
|
276
|
-
export const
|
|
277
|
-
|
|
278
|
-
export const
|
|
279
|
-
export const
|
|
280
|
-
export const
|
|
281
|
-
export const
|
|
282
|
-
export const
|
|
283
|
-
export const
|
|
284
|
-
export const
|
|
285
|
-
export const
|
|
286
|
-
export const
|
|
287
|
-
export const
|
|
288
|
-
export const
|
|
289
|
-
export const
|
|
290
|
-
export const
|
|
291
|
-
export const
|
|
292
|
-
export const
|
|
293
|
-
export const
|
|
294
|
-
export const
|
|
295
|
-
export const
|
|
296
|
-
export const
|
|
297
|
-
export const
|
|
298
|
-
export const
|
|
299
|
-
export const
|
|
300
|
-
export const
|
|
301
|
-
export const
|
|
302
|
-
export const
|
|
303
|
-
export const
|
|
304
|
-
export const
|
|
305
|
-
export const
|
|
306
|
-
export const
|
|
307
|
-
|
|
308
|
-
export const
|
|
309
|
-
|
|
310
|
-
export const
|
|
311
|
-
export const
|
|
312
|
-
export const
|
|
313
|
-
export const
|
|
314
|
-
export const
|
|
315
|
-
export const
|
|
316
|
-
export const
|
|
317
|
-
export const
|
|
318
|
-
export const
|
|
319
|
-
export const
|
|
320
|
-
export const
|
|
321
|
-
export const
|
|
322
|
-
export const
|
|
267
|
+
MathNode.type = /*@__PURE__*/ registerNode( 'Math', MathNode );
|
|
268
|
+
|
|
269
|
+
export const EPSILON = /*@__PURE__*/ float( 1e-6 );
|
|
270
|
+
export const INFINITY = /*@__PURE__*/ float( 1e6 );
|
|
271
|
+
export const PI = /*@__PURE__*/ float( Math.PI );
|
|
272
|
+
export const PI2 = /*@__PURE__*/ float( Math.PI * 2 );
|
|
273
|
+
|
|
274
|
+
export const all = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ALL );
|
|
275
|
+
export const any = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ANY );
|
|
276
|
+
export const equals = /*@__PURE__*/ nodeProxy( MathNode, MathNode.EQUALS );
|
|
277
|
+
|
|
278
|
+
export const radians = /*@__PURE__*/ nodeProxy( MathNode, MathNode.RADIANS );
|
|
279
|
+
export const degrees = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DEGREES );
|
|
280
|
+
export const exp = /*@__PURE__*/ nodeProxy( MathNode, MathNode.EXP );
|
|
281
|
+
export const exp2 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.EXP2 );
|
|
282
|
+
export const log = /*@__PURE__*/ nodeProxy( MathNode, MathNode.LOG );
|
|
283
|
+
export const log2 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.LOG2 );
|
|
284
|
+
export const sqrt = /*@__PURE__*/ nodeProxy( MathNode, MathNode.SQRT );
|
|
285
|
+
export const inverseSqrt = /*@__PURE__*/ nodeProxy( MathNode, MathNode.INVERSE_SQRT );
|
|
286
|
+
export const floor = /*@__PURE__*/ nodeProxy( MathNode, MathNode.FLOOR );
|
|
287
|
+
export const ceil = /*@__PURE__*/ nodeProxy( MathNode, MathNode.CEIL );
|
|
288
|
+
export const normalize = /*@__PURE__*/ nodeProxy( MathNode, MathNode.NORMALIZE );
|
|
289
|
+
export const fract = /*@__PURE__*/ nodeProxy( MathNode, MathNode.FRACT );
|
|
290
|
+
export const sin = /*@__PURE__*/ nodeProxy( MathNode, MathNode.SIN );
|
|
291
|
+
export const cos = /*@__PURE__*/ nodeProxy( MathNode, MathNode.COS );
|
|
292
|
+
export const tan = /*@__PURE__*/ nodeProxy( MathNode, MathNode.TAN );
|
|
293
|
+
export const asin = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ASIN );
|
|
294
|
+
export const acos = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ACOS );
|
|
295
|
+
export const atan = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ATAN );
|
|
296
|
+
export const abs = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ABS );
|
|
297
|
+
export const sign = /*@__PURE__*/ nodeProxy( MathNode, MathNode.SIGN );
|
|
298
|
+
export const length = /*@__PURE__*/ nodeProxy( MathNode, MathNode.LENGTH );
|
|
299
|
+
export const negate = /*@__PURE__*/ nodeProxy( MathNode, MathNode.NEGATE );
|
|
300
|
+
export const oneMinus = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ONE_MINUS );
|
|
301
|
+
export const dFdx = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DFDX );
|
|
302
|
+
export const dFdy = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DFDY );
|
|
303
|
+
export const round = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ROUND );
|
|
304
|
+
export const reciprocal = /*@__PURE__*/ nodeProxy( MathNode, MathNode.RECIPROCAL );
|
|
305
|
+
export const trunc = /*@__PURE__*/ nodeProxy( MathNode, MathNode.TRUNC );
|
|
306
|
+
export const fwidth = /*@__PURE__*/ nodeProxy( MathNode, MathNode.FWIDTH );
|
|
307
|
+
export const bitcast = /*@__PURE__*/ nodeProxy( MathNode, MathNode.BITCAST );
|
|
308
|
+
export const transpose = /*@__PURE__*/ nodeProxy( MathNode, MathNode.TRANSPOSE );
|
|
309
|
+
|
|
310
|
+
export const atan2 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ATAN2 );
|
|
311
|
+
export const min = /*@__PURE__*/ nodeProxy( MathNode, MathNode.MIN );
|
|
312
|
+
export const max = /*@__PURE__*/ nodeProxy( MathNode, MathNode.MAX );
|
|
313
|
+
export const mod = /*@__PURE__*/ nodeProxy( MathNode, MathNode.MOD );
|
|
314
|
+
export const step = /*@__PURE__*/ nodeProxy( MathNode, MathNode.STEP );
|
|
315
|
+
export const reflect = /*@__PURE__*/ nodeProxy( MathNode, MathNode.REFLECT );
|
|
316
|
+
export const distance = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DISTANCE );
|
|
317
|
+
export const difference = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DIFFERENCE );
|
|
318
|
+
export const dot = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DOT );
|
|
319
|
+
export const cross = /*@__PURE__*/ nodeProxy( MathNode, MathNode.CROSS );
|
|
320
|
+
export const pow = /*@__PURE__*/ nodeProxy( MathNode, MathNode.POW );
|
|
321
|
+
export const pow2 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.POW, 2 );
|
|
322
|
+
export const pow3 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.POW, 3 );
|
|
323
|
+
export const pow4 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.POW, 4 );
|
|
324
|
+
export const transformDirection = /*@__PURE__*/ nodeProxy( MathNode, MathNode.TRANSFORM_DIRECTION );
|
|
323
325
|
|
|
324
326
|
export const cbrt = ( a ) => mul( sign( a ), pow( abs( a ), 1.0 / 3.0 ) );
|
|
325
327
|
export const lengthSq = ( a ) => dot( a, a );
|
|
326
|
-
export const mix = nodeProxy( MathNode, MathNode.MIX );
|
|
328
|
+
export const mix = /*@__PURE__*/ nodeProxy( MathNode, MathNode.MIX );
|
|
327
329
|
export const clamp = ( value, low = 0, high = 1 ) => nodeObject( new MathNode( MathNode.CLAMP, nodeObject( value ), nodeObject( low ), nodeObject( high ) ) );
|
|
328
330
|
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 );
|
|
331
|
+
export const refract = /*@__PURE__*/ nodeProxy( MathNode, MathNode.REFRACT );
|
|
332
|
+
export const smoothstep = /*@__PURE__*/ nodeProxy( MathNode, MathNode.SMOOTHSTEP );
|
|
333
|
+
export const faceForward = /*@__PURE__*/ nodeProxy( MathNode, MathNode.FACEFORWARD );
|
|
332
334
|
|
|
333
|
-
export const rand =
|
|
335
|
+
export const rand = /*@__PURE__*/ Fn( ( [ uv ] ) => {
|
|
334
336
|
|
|
335
337
|
const a = 12.9898, b = 78.233, c = 43758.5453;
|
|
336
338
|
const dt = dot( uv.xy, vec2( a, b ) ), sn = mod( dt, PI );
|
|
@@ -342,63 +344,61 @@ export const rand = tslFn( ( [ uv ] ) => {
|
|
|
342
344
|
export const mixElement = ( t, e1, e2 ) => mix( e1, e2, t );
|
|
343
345
|
export const smoothstepElement = ( x, low, high ) => smoothstep( low, high, x );
|
|
344
346
|
|
|
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 );
|
|
347
|
+
addMethodChaining( 'all', all );
|
|
348
|
+
addMethodChaining( 'any', any );
|
|
349
|
+
addMethodChaining( 'equals', equals );
|
|
350
|
+
|
|
351
|
+
addMethodChaining( 'radians', radians );
|
|
352
|
+
addMethodChaining( 'degrees', degrees );
|
|
353
|
+
addMethodChaining( 'exp', exp );
|
|
354
|
+
addMethodChaining( 'exp2', exp2 );
|
|
355
|
+
addMethodChaining( 'log', log );
|
|
356
|
+
addMethodChaining( 'log2', log2 );
|
|
357
|
+
addMethodChaining( 'sqrt', sqrt );
|
|
358
|
+
addMethodChaining( 'inverseSqrt', inverseSqrt );
|
|
359
|
+
addMethodChaining( 'floor', floor );
|
|
360
|
+
addMethodChaining( 'ceil', ceil );
|
|
361
|
+
addMethodChaining( 'normalize', normalize );
|
|
362
|
+
addMethodChaining( 'fract', fract );
|
|
363
|
+
addMethodChaining( 'sin', sin );
|
|
364
|
+
addMethodChaining( 'cos', cos );
|
|
365
|
+
addMethodChaining( 'tan', tan );
|
|
366
|
+
addMethodChaining( 'asin', asin );
|
|
367
|
+
addMethodChaining( 'acos', acos );
|
|
368
|
+
addMethodChaining( 'atan', atan );
|
|
369
|
+
addMethodChaining( 'abs', abs );
|
|
370
|
+
addMethodChaining( 'sign', sign );
|
|
371
|
+
addMethodChaining( 'length', length );
|
|
372
|
+
addMethodChaining( 'lengthSq', lengthSq );
|
|
373
|
+
addMethodChaining( 'negate', negate );
|
|
374
|
+
addMethodChaining( 'oneMinus', oneMinus );
|
|
375
|
+
addMethodChaining( 'dFdx', dFdx );
|
|
376
|
+
addMethodChaining( 'dFdy', dFdy );
|
|
377
|
+
addMethodChaining( 'round', round );
|
|
378
|
+
addMethodChaining( 'reciprocal', reciprocal );
|
|
379
|
+
addMethodChaining( 'trunc', trunc );
|
|
380
|
+
addMethodChaining( 'fwidth', fwidth );
|
|
381
|
+
addMethodChaining( 'atan2', atan2 );
|
|
382
|
+
addMethodChaining( 'min', min );
|
|
383
|
+
addMethodChaining( 'max', max );
|
|
384
|
+
addMethodChaining( 'mod', mod );
|
|
385
|
+
addMethodChaining( 'step', step );
|
|
386
|
+
addMethodChaining( 'reflect', reflect );
|
|
387
|
+
addMethodChaining( 'distance', distance );
|
|
388
|
+
addMethodChaining( 'dot', dot );
|
|
389
|
+
addMethodChaining( 'cross', cross );
|
|
390
|
+
addMethodChaining( 'pow', pow );
|
|
391
|
+
addMethodChaining( 'pow2', pow2 );
|
|
392
|
+
addMethodChaining( 'pow3', pow3 );
|
|
393
|
+
addMethodChaining( 'pow4', pow4 );
|
|
394
|
+
addMethodChaining( 'transformDirection', transformDirection );
|
|
395
|
+
addMethodChaining( 'mix', mixElement );
|
|
396
|
+
addMethodChaining( 'clamp', clamp );
|
|
397
|
+
addMethodChaining( 'refract', refract );
|
|
398
|
+
addMethodChaining( 'smoothstep', smoothstepElement );
|
|
399
|
+
addMethodChaining( 'faceForward', faceForward );
|
|
400
|
+
addMethodChaining( 'difference', difference );
|
|
401
|
+
addMethodChaining( 'saturate', saturate );
|
|
402
|
+
addMethodChaining( 'cbrt', cbrt );
|
|
403
|
+
addMethodChaining( 'transpose', transpose );
|
|
404
|
+
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,6 +1,6 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
1
2
|
import TempNode from '../core/TempNode.js';
|
|
2
|
-
import {
|
|
3
|
-
import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js';
|
|
3
|
+
import { addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
|
|
4
4
|
|
|
5
5
|
class OperatorNode extends TempNode {
|
|
6
6
|
|
|
@@ -116,7 +116,7 @@ class OperatorNode extends TempNode {
|
|
|
116
116
|
|
|
117
117
|
typeB = typeA;
|
|
118
118
|
|
|
119
|
-
} else {
|
|
119
|
+
} else if ( typeA !== typeB ) {
|
|
120
120
|
|
|
121
121
|
typeA = typeB = 'float';
|
|
122
122
|
|
|
@@ -163,19 +163,51 @@ class OperatorNode extends TempNode {
|
|
|
163
163
|
|
|
164
164
|
if ( op === '<' && outputLength > 1 ) {
|
|
165
165
|
|
|
166
|
-
|
|
166
|
+
if ( builder.useComparisonMethod ) {
|
|
167
|
+
|
|
168
|
+
return builder.format( `${ builder.getMethod( 'lessThan', output ) }( ${ a }, ${ b } )`, type, output );
|
|
169
|
+
|
|
170
|
+
} else {
|
|
171
|
+
|
|
172
|
+
return builder.format( `( ${ a } < ${ b } )`, type, output );
|
|
173
|
+
|
|
174
|
+
}
|
|
167
175
|
|
|
168
176
|
} else if ( op === '<=' && outputLength > 1 ) {
|
|
169
177
|
|
|
170
|
-
|
|
178
|
+
if ( builder.useComparisonMethod ) {
|
|
179
|
+
|
|
180
|
+
return builder.format( `${ builder.getMethod( 'lessThanEqual', output ) }( ${ a }, ${ b } )`, type, output );
|
|
181
|
+
|
|
182
|
+
} else {
|
|
183
|
+
|
|
184
|
+
return builder.format( `( ${ a } <= ${ b } )`, type, output );
|
|
185
|
+
|
|
186
|
+
}
|
|
171
187
|
|
|
172
188
|
} else if ( op === '>' && outputLength > 1 ) {
|
|
173
189
|
|
|
174
|
-
|
|
190
|
+
if ( builder.useComparisonMethod ) {
|
|
191
|
+
|
|
192
|
+
return builder.format( `${ builder.getMethod( 'greaterThan', output ) }( ${ a }, ${ b } )`, type, output );
|
|
193
|
+
|
|
194
|
+
} else {
|
|
195
|
+
|
|
196
|
+
return builder.format( `( ${ a } > ${ b } )`, type, output );
|
|
197
|
+
|
|
198
|
+
}
|
|
175
199
|
|
|
176
200
|
} else if ( op === '>=' && outputLength > 1 ) {
|
|
177
201
|
|
|
178
|
-
|
|
202
|
+
if ( builder.useComparisonMethod ) {
|
|
203
|
+
|
|
204
|
+
return builder.format( `${ builder.getMethod( 'greaterThanEqual', output ) }( ${ a }, ${ b } )`, type, output );
|
|
205
|
+
|
|
206
|
+
} else {
|
|
207
|
+
|
|
208
|
+
return builder.format( `( ${ a } >= ${ b } )`, type, output );
|
|
209
|
+
|
|
210
|
+
}
|
|
179
211
|
|
|
180
212
|
} else if ( op === '!' || op === '~' ) {
|
|
181
213
|
|
|
@@ -227,48 +259,58 @@ class OperatorNode extends TempNode {
|
|
|
227
259
|
|
|
228
260
|
export default OperatorNode;
|
|
229
261
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
export const
|
|
233
|
-
export const
|
|
234
|
-
export const
|
|
235
|
-
export const
|
|
236
|
-
export const
|
|
237
|
-
export const
|
|
238
|
-
export const
|
|
239
|
-
export const
|
|
240
|
-
export const
|
|
241
|
-
export const
|
|
242
|
-
export const
|
|
243
|
-
export const
|
|
244
|
-
export const
|
|
245
|
-
export const
|
|
246
|
-
export const
|
|
247
|
-
export const
|
|
248
|
-
export const
|
|
249
|
-
export const
|
|
250
|
-
export const
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
262
|
+
OperatorNode.type = /*@__PURE__*/ registerNode( 'Operator', OperatorNode );
|
|
263
|
+
|
|
264
|
+
export const add = /*@__PURE__*/ nodeProxy( OperatorNode, '+' );
|
|
265
|
+
export const sub = /*@__PURE__*/ nodeProxy( OperatorNode, '-' );
|
|
266
|
+
export const mul = /*@__PURE__*/ nodeProxy( OperatorNode, '*' );
|
|
267
|
+
export const div = /*@__PURE__*/ nodeProxy( OperatorNode, '/' );
|
|
268
|
+
export const modInt = /*@__PURE__*/ nodeProxy( OperatorNode, '%' );
|
|
269
|
+
export const equal = /*@__PURE__*/ nodeProxy( OperatorNode, '==' );
|
|
270
|
+
export const notEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '!=' );
|
|
271
|
+
export const lessThan = /*@__PURE__*/ nodeProxy( OperatorNode, '<' );
|
|
272
|
+
export const greaterThan = /*@__PURE__*/ nodeProxy( OperatorNode, '>' );
|
|
273
|
+
export const lessThanEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '<=' );
|
|
274
|
+
export const greaterThanEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '>=' );
|
|
275
|
+
export const and = /*@__PURE__*/ nodeProxy( OperatorNode, '&&' );
|
|
276
|
+
export const or = /*@__PURE__*/ nodeProxy( OperatorNode, '||' );
|
|
277
|
+
export const not = /*@__PURE__*/ nodeProxy( OperatorNode, '!' );
|
|
278
|
+
export const xor = /*@__PURE__*/ nodeProxy( OperatorNode, '^^' );
|
|
279
|
+
export const bitAnd = /*@__PURE__*/ nodeProxy( OperatorNode, '&' );
|
|
280
|
+
export const bitNot = /*@__PURE__*/ nodeProxy( OperatorNode, '~' );
|
|
281
|
+
export const bitOr = /*@__PURE__*/ nodeProxy( OperatorNode, '|' );
|
|
282
|
+
export const bitXor = /*@__PURE__*/ nodeProxy( OperatorNode, '^' );
|
|
283
|
+
export const shiftLeft = /*@__PURE__*/ nodeProxy( OperatorNode, '<<' );
|
|
284
|
+
export const shiftRight = /*@__PURE__*/ nodeProxy( OperatorNode, '>>' );
|
|
285
|
+
|
|
286
|
+
addMethodChaining( 'add', add );
|
|
287
|
+
addMethodChaining( 'sub', sub );
|
|
288
|
+
addMethodChaining( 'mul', mul );
|
|
289
|
+
addMethodChaining( 'div', div );
|
|
290
|
+
addMethodChaining( 'modInt', modInt );
|
|
291
|
+
addMethodChaining( 'equal', equal );
|
|
292
|
+
addMethodChaining( 'notEqual', notEqual );
|
|
293
|
+
addMethodChaining( 'lessThan', lessThan );
|
|
294
|
+
addMethodChaining( 'greaterThan', greaterThan );
|
|
295
|
+
addMethodChaining( 'lessThanEqual', lessThanEqual );
|
|
296
|
+
addMethodChaining( 'greaterThanEqual', greaterThanEqual );
|
|
297
|
+
addMethodChaining( 'and', and );
|
|
298
|
+
addMethodChaining( 'or', or );
|
|
299
|
+
addMethodChaining( 'not', not );
|
|
300
|
+
addMethodChaining( 'xor', xor );
|
|
301
|
+
addMethodChaining( 'bitAnd', bitAnd );
|
|
302
|
+
addMethodChaining( 'bitNot', bitNot );
|
|
303
|
+
addMethodChaining( 'bitOr', bitOr );
|
|
304
|
+
addMethodChaining( 'bitXor', bitXor );
|
|
305
|
+
addMethodChaining( 'shiftLeft', shiftLeft );
|
|
306
|
+
addMethodChaining( 'shiftRight', shiftRight );
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
export const remainder = ( ...params ) => { // @deprecated, r168
|
|
310
|
+
|
|
311
|
+
console.warn( 'TSL.OperatorNode: .remainder() has been renamed to .modInt().' );
|
|
312
|
+
return modInt( ...params );
|
|
313
|
+
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
addMethodChaining( 'remainder', remainder );
|
|
@@ -1,28 +1,40 @@
|
|
|
1
1
|
// https://github.com/cabbibo/glsl-tri-noise-3d
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { float, vec3,
|
|
3
|
+
import { Loop } from '../utils/LoopNode.js';
|
|
4
|
+
import { float, vec3, Fn } from '../tsl/TSLBase.js';
|
|
5
5
|
|
|
6
|
-
const tri =
|
|
6
|
+
export const tri = /*@__PURE__*/ Fn( ( [ x ] ) => {
|
|
7
7
|
|
|
8
8
|
return x.fract().sub( .5 ).abs();
|
|
9
9
|
|
|
10
|
+
} ).setLayout( {
|
|
11
|
+
name: 'tri',
|
|
12
|
+
type: 'float',
|
|
13
|
+
inputs: [
|
|
14
|
+
{ name: 'x', type: 'float' }
|
|
15
|
+
]
|
|
10
16
|
} );
|
|
11
17
|
|
|
12
|
-
const tri3 =
|
|
18
|
+
export const tri3 = /*@__PURE__*/ Fn( ( [ p ] ) => {
|
|
13
19
|
|
|
14
20
|
return vec3( tri( p.z.add( tri( p.y.mul( 1. ) ) ) ), tri( p.z.add( tri( p.x.mul( 1. ) ) ) ), tri( p.y.add( tri( p.x.mul( 1. ) ) ) ) );
|
|
15
21
|
|
|
22
|
+
} ).setLayout( {
|
|
23
|
+
name: 'tri3',
|
|
24
|
+
type: 'vec3',
|
|
25
|
+
inputs: [
|
|
26
|
+
{ name: 'p', type: 'vec3' }
|
|
27
|
+
]
|
|
16
28
|
} );
|
|
17
29
|
|
|
18
|
-
const triNoise3D =
|
|
30
|
+
export const triNoise3D = /*@__PURE__*/ Fn( ( [ p_immutable, spd, time ] ) => {
|
|
19
31
|
|
|
20
32
|
const p = vec3( p_immutable ).toVar();
|
|
21
33
|
const z = float( 1.4 ).toVar();
|
|
22
34
|
const rz = float( 0.0 ).toVar();
|
|
23
35
|
const bp = vec3( p ).toVar();
|
|
24
36
|
|
|
25
|
-
|
|
37
|
+
Loop( { start: float( 0.0 ), end: float( 3.0 ), type: 'float', condition: '<=' }, () => {
|
|
26
38
|
|
|
27
39
|
const dg = vec3( tri3( bp.mul( 2.0 ) ) ).toVar();
|
|
28
40
|
p.addAssign( dg.add( time.mul( float( 0.1 ).mul( spd ) ) ) );
|
|
@@ -38,27 +50,7 @@ const triNoise3D = tslFn( ( [ p_immutable, spd, time ] ) => {
|
|
|
38
50
|
|
|
39
51
|
return rz;
|
|
40
52
|
|
|
41
|
-
} )
|
|
42
|
-
|
|
43
|
-
// layouts
|
|
44
|
-
|
|
45
|
-
tri.setLayout( {
|
|
46
|
-
name: 'tri',
|
|
47
|
-
type: 'float',
|
|
48
|
-
inputs: [
|
|
49
|
-
{ name: 'x', type: 'float' }
|
|
50
|
-
]
|
|
51
|
-
} );
|
|
52
|
-
|
|
53
|
-
tri3.setLayout( {
|
|
54
|
-
name: 'tri3',
|
|
55
|
-
type: 'vec3',
|
|
56
|
-
inputs: [
|
|
57
|
-
{ name: 'p', type: 'vec3' }
|
|
58
|
-
]
|
|
59
|
-
} );
|
|
60
|
-
|
|
61
|
-
triNoise3D.setLayout( {
|
|
53
|
+
} ).setLayout( {
|
|
62
54
|
name: 'triNoise3D',
|
|
63
55
|
type: 'float',
|
|
64
56
|
inputs: [
|
|
@@ -67,5 +59,3 @@ triNoise3D.setLayout( {
|
|
|
67
59
|
{ name: 'time', type: 'float' }
|
|
68
60
|
]
|
|
69
61
|
} );
|
|
70
|
-
|
|
71
|
-
export { tri, tri3, triNoise3D };
|