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.
Files changed (311) hide show
  1. package/build/three.cjs +165 -44
  2. package/build/three.module.js +165 -45
  3. package/build/three.module.min.js +1 -1
  4. package/build/three.webgpu.js +23600 -21931
  5. package/build/three.webgpu.min.js +1 -1
  6. package/examples/jsm/Addons.js +3 -1
  7. package/examples/jsm/animation/AnimationClipCreator.js +1 -1
  8. package/examples/jsm/capabilities/WebGL.js +27 -21
  9. package/examples/jsm/controls/ArcballControls.js +174 -158
  10. package/examples/jsm/controls/DragControls.js +260 -132
  11. package/examples/jsm/controls/FirstPersonControls.js +175 -163
  12. package/examples/jsm/controls/FlyControls.js +194 -188
  13. package/examples/jsm/controls/OrbitControls.js +777 -786
  14. package/examples/jsm/controls/PointerLockControls.js +24 -15
  15. package/examples/jsm/controls/TrackballControls.js +453 -452
  16. package/examples/jsm/effects/AnaglyphEffect.js +6 -13
  17. package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
  18. package/examples/jsm/effects/StereoEffect.js +6 -1
  19. package/examples/jsm/environments/RoomEnvironment.js +1 -1
  20. package/examples/jsm/exporters/GLTFExporter.js +6 -1
  21. package/examples/jsm/exporters/USDZExporter.js +29 -8
  22. package/examples/jsm/helpers/LightProbeHelper.js +42 -43
  23. package/examples/jsm/loaders/KTX2Loader.js +19 -7
  24. package/examples/jsm/loaders/MaterialXLoader.js +11 -4
  25. package/examples/jsm/loaders/PCDLoader.js +9 -9
  26. package/examples/jsm/objects/SkyMesh.js +188 -0
  27. package/examples/jsm/objects/Water2Mesh.js +159 -0
  28. package/examples/jsm/objects/WaterMesh.js +102 -0
  29. package/examples/jsm/physics/RapierPhysics.js +20 -0
  30. package/examples/jsm/postprocessing/OutlinePass.js +31 -46
  31. package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
  32. package/examples/jsm/shaders/BleachBypassShader.js +1 -2
  33. package/examples/jsm/shaders/OutputShader.js +1 -1
  34. package/examples/jsm/transpiler/TSLEncoder.js +8 -8
  35. package/examples/jsm/utils/TextureUtils.js +1 -1
  36. package/package.json +2 -1
  37. package/src/Three.WebGPU.js +6 -0
  38. package/src/Three.js +1 -0
  39. package/src/constants.js +1 -1
  40. package/src/extras/Controls.js +32 -0
  41. package/src/loaders/ObjectLoader.js +3 -3
  42. package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +4 -4
  43. package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +1 -2
  44. package/src/materials/Material.js +4 -7
  45. package/src/{nodes/materials → materials/nodes}/InstancedPointsNodeMaterial.js +33 -24
  46. package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +34 -37
  47. package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +3 -4
  48. package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +7 -9
  49. package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +11 -11
  50. package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +5 -5
  51. package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +8 -8
  52. package/src/materials/nodes/MeshNormalNodeMaterial.js +40 -0
  53. package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +9 -8
  54. package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +18 -17
  55. package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +6 -6
  56. package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +17 -11
  57. package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +4 -4
  58. package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +67 -86
  59. package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +1 -1
  60. package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +3 -4
  61. package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +4 -4
  62. package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +11 -11
  63. package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +14 -16
  64. package/src/nodes/Nodes.js +103 -159
  65. package/src/nodes/TSL.js +176 -0
  66. package/src/nodes/accessors/AccessorsUtils.js +8 -8
  67. package/src/nodes/accessors/BatchNode.js +48 -20
  68. package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
  69. package/src/nodes/accessors/BufferAttributeNode.js +5 -5
  70. package/src/nodes/accessors/BufferNode.js +4 -4
  71. package/src/nodes/accessors/{CameraNode.js → Camera.js} +10 -10
  72. package/src/nodes/accessors/ClippingNode.js +16 -14
  73. package/src/nodes/accessors/CubeTextureNode.js +5 -7
  74. package/src/nodes/accessors/InstanceNode.js +17 -13
  75. package/src/nodes/accessors/InstancedPointsMaterialNode.js +4 -4
  76. package/src/nodes/accessors/MaterialNode.js +52 -55
  77. package/src/nodes/accessors/MaterialProperties.js +3 -0
  78. package/src/nodes/accessors/MaterialReferenceNode.js +6 -4
  79. package/src/nodes/accessors/ModelNode.js +11 -11
  80. package/src/nodes/accessors/ModelViewProjectionNode.js +6 -7
  81. package/src/nodes/accessors/MorphNode.js +12 -12
  82. package/src/nodes/accessors/Normal.js +62 -0
  83. package/src/nodes/accessors/Object3DNode.js +10 -10
  84. package/src/nodes/accessors/PointUVNode.js +4 -4
  85. package/src/nodes/accessors/Position.js +10 -0
  86. package/src/nodes/accessors/ReferenceBaseNode.js +143 -0
  87. package/src/nodes/accessors/ReferenceNode.js +13 -7
  88. package/src/nodes/accessors/ReflectVector.js +10 -0
  89. package/src/nodes/accessors/RendererReferenceNode.js +6 -6
  90. package/src/nodes/accessors/SceneNode.js +5 -6
  91. package/src/nodes/accessors/SkinningNode.js +84 -21
  92. package/src/nodes/accessors/StorageBufferNode.js +4 -5
  93. package/src/nodes/accessors/StorageTextureNode.js +5 -5
  94. package/src/nodes/accessors/Tangent.js +22 -0
  95. package/src/nodes/accessors/Texture3DNode.js +11 -11
  96. package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
  97. package/src/nodes/accessors/TextureNode.js +16 -21
  98. package/src/nodes/accessors/TextureSizeNode.js +4 -6
  99. package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +17 -8
  100. package/src/nodes/accessors/UserDataNode.js +4 -4
  101. package/src/nodes/accessors/VelocityNode.js +83 -0
  102. package/src/nodes/accessors/VertexColorNode.js +4 -4
  103. package/src/nodes/code/CodeNode.js +5 -5
  104. package/src/nodes/code/ExpressionNode.js +4 -4
  105. package/src/nodes/code/FunctionCallNode.js +5 -5
  106. package/src/nodes/code/FunctionNode.js +5 -23
  107. package/src/nodes/code/ScriptableNode.js +4 -6
  108. package/src/nodes/code/ScriptableValueNode.js +4 -6
  109. package/src/nodes/core/AssignNode.js +5 -5
  110. package/src/nodes/core/AttributeNode.js +7 -20
  111. package/src/nodes/core/BypassNode.js +5 -5
  112. package/src/nodes/core/CacheNode.js +5 -5
  113. package/src/nodes/core/ConstNode.js +2 -2
  114. package/src/nodes/core/ContextNode.js +17 -11
  115. package/src/nodes/core/IndexNode.js +12 -7
  116. package/src/nodes/core/InputNode.js +2 -2
  117. package/src/nodes/core/MRTNode.js +12 -6
  118. package/src/nodes/core/Node.js +39 -19
  119. package/src/nodes/core/NodeBuilder.js +46 -33
  120. package/src/nodes/core/NodeUtils.js +1 -0
  121. package/src/nodes/core/OutputStructNode.js +4 -4
  122. package/src/nodes/core/ParameterNode.js +4 -4
  123. package/src/nodes/core/PropertyNode.js +32 -32
  124. package/src/nodes/core/StackNode.js +26 -10
  125. package/src/nodes/core/StructTypeNode.js +2 -2
  126. package/src/nodes/core/TempNode.js +2 -2
  127. package/src/nodes/core/UniformGroupNode.js +8 -9
  128. package/src/nodes/core/UniformNode.js +4 -4
  129. package/src/nodes/core/VarNode.js +6 -6
  130. package/src/nodes/core/VaryingNode.js +5 -5
  131. package/src/nodes/display/AfterImageNode.js +9 -9
  132. package/src/nodes/display/AnaglyphPassNode.js +61 -0
  133. package/src/nodes/display/AnamorphicNode.js +11 -11
  134. package/src/nodes/display/BleachBypass.js +26 -0
  135. package/src/nodes/display/BlendMode.js +54 -0
  136. package/src/nodes/display/BloomNode.js +21 -19
  137. package/src/nodes/display/BumpMapNode.js +7 -12
  138. package/src/nodes/display/ColorAdjustment.js +46 -0
  139. package/src/nodes/display/ColorSpaceFunctions.js +38 -0
  140. package/src/nodes/display/ColorSpaceNode.js +40 -63
  141. package/src/nodes/display/DenoiseNode.js +20 -17
  142. package/src/nodes/display/DepthOfFieldNode.js +8 -6
  143. package/src/nodes/display/DotScreenNode.js +10 -22
  144. package/src/nodes/display/FXAANode.js +17 -15
  145. package/src/nodes/display/FilmNode.js +7 -6
  146. package/src/nodes/display/FrontFacingNode.js +5 -5
  147. package/src/nodes/display/GTAONode.js +19 -15
  148. package/src/nodes/display/GaussianBlurNode.js +11 -8
  149. package/src/nodes/display/Lut3DNode.js +6 -5
  150. package/src/nodes/display/MotionBlur.js +25 -0
  151. package/src/nodes/display/NormalMapNode.js +8 -10
  152. package/src/nodes/display/ParallaxBarrierPassNode.js +55 -0
  153. package/src/nodes/display/PassNode.js +84 -8
  154. package/src/nodes/display/PixelationPassNode.js +12 -7
  155. package/src/nodes/display/PosterizeNode.js +4 -6
  156. package/src/nodes/display/RGBShiftNode.js +8 -7
  157. package/src/nodes/display/RenderOutputNode.js +9 -9
  158. package/src/nodes/display/SSAAPassNode.js +284 -0
  159. package/src/nodes/display/Sepia.js +17 -0
  160. package/src/nodes/display/SobelOperatorNode.js +9 -7
  161. package/src/nodes/display/StereoCompositePassNode.js +107 -0
  162. package/src/nodes/display/StereoPassNode.js +80 -0
  163. package/src/nodes/display/ToneMappingFunctions.js +190 -0
  164. package/src/nodes/display/ToneMappingNode.js +12 -173
  165. package/src/nodes/display/TransitionNode.js +9 -8
  166. package/src/nodes/display/ViewportDepthNode.js +30 -29
  167. package/src/nodes/display/ViewportDepthTextureNode.js +6 -8
  168. package/src/nodes/display/ViewportNode.js +26 -25
  169. package/src/nodes/display/ViewportSharedTextureNode.js +6 -8
  170. package/src/nodes/display/ViewportTextureNode.js +7 -10
  171. package/src/nodes/fog/FogExp2Node.js +4 -6
  172. package/src/nodes/fog/FogNode.js +5 -7
  173. package/src/nodes/fog/FogRangeNode.js +4 -6
  174. package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
  175. package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
  176. package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
  177. package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
  178. package/src/nodes/functions/BSDF/D_GGX.js +2 -2
  179. package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
  180. package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
  181. package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
  182. package/src/nodes/functions/BSDF/LTC.js +6 -6
  183. package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
  184. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
  185. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
  186. package/src/nodes/functions/BasicLightingModel.js +1 -1
  187. package/src/nodes/functions/PhongLightingModel.js +5 -5
  188. package/src/nodes/functions/PhysicalLightingModel.js +32 -31
  189. package/src/nodes/functions/ShadowMaskModel.js +1 -1
  190. package/src/nodes/functions/ToonLightingModel.js +3 -3
  191. package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
  192. package/src/nodes/functions/material/getRoughness.js +2 -2
  193. package/src/nodes/geometry/RangeNode.js +4 -4
  194. package/src/nodes/gpgpu/ComputeNode.js +5 -5
  195. package/src/nodes/lighting/AONode.js +2 -2
  196. package/src/nodes/lighting/AmbientLightNode.js +2 -7
  197. package/src/nodes/lighting/AnalyticLightNode.js +34 -13
  198. package/src/nodes/lighting/BasicEnvironmentNode.js +4 -3
  199. package/src/nodes/lighting/BasicLightMapNode.js +3 -3
  200. package/src/nodes/lighting/DirectionalLightNode.js +2 -7
  201. package/src/nodes/lighting/EnvironmentNode.js +20 -19
  202. package/src/nodes/lighting/HemisphereLightNode.js +3 -7
  203. package/src/nodes/lighting/IESSpotLightNode.js +3 -8
  204. package/src/nodes/lighting/IrradianceNode.js +2 -2
  205. package/src/nodes/lighting/LightNode.js +5 -5
  206. package/src/nodes/lighting/LightProbeNode.js +76 -0
  207. package/src/nodes/lighting/LightUtils.js +3 -3
  208. package/src/nodes/lighting/LightingContextNode.js +15 -17
  209. package/src/nodes/lighting/LightingNode.js +2 -2
  210. package/src/nodes/lighting/LightsNode.js +94 -76
  211. package/src/nodes/lighting/PointLightNode.js +3 -8
  212. package/src/nodes/lighting/RectAreaLightNode.js +2 -6
  213. package/src/nodes/lighting/SpotLightNode.js +3 -8
  214. package/src/nodes/materialx/MaterialXNodes.js +2 -2
  215. package/src/nodes/materialx/lib/mx_hsv.js +36 -31
  216. package/src/nodes/materialx/lib/mx_noise.js +96 -96
  217. package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
  218. package/src/nodes/math/{CondNode.js → ConditionalNode.js} +18 -7
  219. package/src/nodes/math/Hash.js +13 -0
  220. package/src/nodes/math/MathNode.js +124 -124
  221. package/src/nodes/math/MathUtils.js +0 -7
  222. package/src/nodes/math/OperatorNode.js +94 -52
  223. package/src/nodes/math/TriNoise3D.js +19 -29
  224. package/src/nodes/pmrem/PMREMNode.js +58 -15
  225. package/src/nodes/pmrem/PMREMUtils.js +46 -46
  226. package/src/nodes/procedural/Checker.js +14 -0
  227. package/src/nodes/tsl/TSLBase.js +30 -0
  228. package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
  229. package/src/nodes/utils/ArrayElementNode.js +2 -2
  230. package/src/nodes/utils/ConvertNode.js +2 -2
  231. package/src/nodes/utils/CubeMapNode.js +157 -0
  232. package/src/nodes/utils/Discard.js +8 -0
  233. package/src/nodes/utils/EquirectUVNode.js +5 -5
  234. package/src/nodes/utils/FlipNode.js +65 -0
  235. package/src/nodes/utils/FunctionOverloadingNode.js +5 -5
  236. package/src/nodes/utils/JoinNode.js +2 -2
  237. package/src/nodes/utils/LoopNode.js +12 -6
  238. package/src/nodes/utils/MatcapUVNode.js +6 -6
  239. package/src/nodes/utils/MaxMipLevelNode.js +4 -4
  240. package/src/nodes/utils/OscNode.js +7 -7
  241. package/src/nodes/utils/Packing.js +4 -0
  242. package/src/nodes/utils/RTTNode.js +8 -8
  243. package/src/nodes/utils/ReflectorNode.js +8 -3
  244. package/src/nodes/utils/RemapNode.js +7 -7
  245. package/src/nodes/utils/RotateNode.js +4 -12
  246. package/src/nodes/utils/SetNode.js +2 -2
  247. package/src/nodes/utils/SplitNode.js +2 -2
  248. package/src/nodes/utils/SpriteSheetUVNode.js +5 -5
  249. package/src/nodes/utils/SpriteUtils.js +47 -0
  250. package/src/nodes/utils/StorageArrayElementNode.js +4 -6
  251. package/src/nodes/utils/TimerNode.js +5 -5
  252. package/src/nodes/utils/TriplanarTexturesNode.js +7 -9
  253. package/src/nodes/utils/UVUtils.js +19 -0
  254. package/src/nodes/utils/ViewportUtils.js +14 -0
  255. package/src/objects/BatchedMesh.js +2 -3
  256. package/src/renderers/WebGLRenderer.js +24 -0
  257. package/src/renderers/common/Backend.js +2 -2
  258. package/src/renderers/common/Background.js +3 -1
  259. package/src/renderers/common/BindGroup.js +3 -1
  260. package/src/renderers/common/Bindings.js +13 -15
  261. package/src/renderers/common/ClippingContext.js +14 -5
  262. package/src/renderers/common/CubeRenderTarget.js +9 -3
  263. package/src/renderers/common/PostProcessing.js +4 -1
  264. package/src/renderers/common/QuadMesh.js +2 -0
  265. package/src/renderers/common/RenderContext.js +24 -0
  266. package/src/renderers/common/RenderList.js +1 -1
  267. package/src/renderers/common/RenderObject.js +2 -2
  268. package/src/renderers/common/Renderer.js +75 -49
  269. package/src/renderers/common/SampledTexture.js +12 -3
  270. package/src/renderers/common/StandardRenderer.js +18 -0
  271. package/src/renderers/common/Textures.js +8 -12
  272. package/src/renderers/common/extras/PMREMGenerator.js +12 -13
  273. package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
  274. package/src/renderers/common/nodes/NodeLibrary.js +118 -0
  275. package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
  276. package/src/renderers/common/nodes/Nodes.js +36 -9
  277. package/src/renderers/common/nodes/StandardNodeLibrary.js +105 -0
  278. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
  279. package/src/renderers/webgl/WebGLProgram.js +1 -1
  280. package/src/renderers/webgl/WebGLProperties.js +7 -0
  281. package/src/renderers/webgl/WebGLTextures.js +61 -4
  282. package/src/renderers/webgl-fallback/WebGLBackend.js +88 -68
  283. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +57 -9
  284. package/src/renderers/webgl-fallback/utils/WebGLState.js +21 -0
  285. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +28 -21
  286. package/src/renderers/webgpu/WebGPUBackend.js +86 -68
  287. package/src/renderers/webgpu/WebGPURenderer.js +8 -8
  288. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +99 -63
  289. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
  290. package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
  291. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +6 -15
  292. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
  293. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +36 -21
  294. package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -1
  295. package/src/renderers/webxr/WebXRManager.js +32 -25
  296. package/examples/jsm/loaders/LogLuvLoader.js +0 -606
  297. package/src/nodes/accessors/NormalNode.js +0 -14
  298. package/src/nodes/accessors/PositionNode.js +0 -10
  299. package/src/nodes/accessors/ReflectVectorNode.js +0 -10
  300. package/src/nodes/accessors/TangentNode.js +0 -23
  301. package/src/nodes/core/NodeKeywords.js +0 -80
  302. package/src/nodes/display/BlendModeNode.js +0 -128
  303. package/src/nodes/display/ColorAdjustmentNode.js +0 -104
  304. package/src/nodes/materials/MeshNormalNodeMaterial.js +0 -40
  305. package/src/nodes/math/HashNode.js +0 -34
  306. package/src/nodes/procedural/CheckerNode.js +0 -42
  307. package/src/nodes/utils/DiscardNode.js +0 -28
  308. package/src/nodes/utils/PackingNode.js +0 -55
  309. package/src/nodes/utils/RotateUVNode.js +0 -35
  310. /package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +0 -0
  311. /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, tslFn } from '../../shadernode/ShaderNode.js';
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 = /*#__PURE__*/ tslFn( ( [ color_immutable ] ) => {
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, { addNodeClass } from '../core/Node.js';
1
+ import Node, { registerNode } from '../core/Node.js';
2
2
  import { property } from '../core/PropertyNode.js';
3
- import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js';
3
+ import { addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
4
4
 
5
- class CondNode extends Node {
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 CondNode;
122
+ export default ConditionalNode;
123
123
 
124
- export const cond = nodeProxy( CondNode );
124
+ ConditionalNode.type = /*@__PURE__*/ registerNode( 'Conditional', ConditionalNode );
125
125
 
126
- addNodeElement( 'cond', cond );
126
+ export const select = /*@__PURE__*/ nodeProxy( ConditionalNode );
127
127
 
128
- addNodeClass( 'CondNode', CondNode );
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 { addNodeClass } from '../core/Node.js';
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
- 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 );
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 = tslFn( ( [ uv ] ) => {
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
- addNodeElement( 'all', all );
346
- addNodeElement( 'any', any );
347
- addNodeElement( 'equals', equals );
348
-
349
- addNodeElement( 'radians', radians );
350
- addNodeElement( 'degrees', degrees );
351
- addNodeElement( 'exp', exp );
352
- addNodeElement( 'exp2', exp2 );
353
- addNodeElement( 'log', log );
354
- addNodeElement( 'log2', log2 );
355
- addNodeElement( 'sqrt', sqrt );
356
- addNodeElement( 'inverseSqrt', inverseSqrt );
357
- addNodeElement( 'floor', floor );
358
- addNodeElement( 'ceil', ceil );
359
- addNodeElement( 'normalize', normalize );
360
- addNodeElement( 'fract', fract );
361
- addNodeElement( 'sin', sin );
362
- addNodeElement( 'cos', cos );
363
- addNodeElement( 'tan', tan );
364
- addNodeElement( 'asin', asin );
365
- addNodeElement( 'acos', acos );
366
- addNodeElement( 'atan', atan );
367
- addNodeElement( 'abs', abs );
368
- addNodeElement( 'sign', sign );
369
- addNodeElement( 'length', length );
370
- addNodeElement( 'lengthSq', lengthSq );
371
- addNodeElement( 'negate', negate );
372
- addNodeElement( 'oneMinus', oneMinus );
373
- addNodeElement( 'dFdx', dFdx );
374
- addNodeElement( 'dFdy', dFdy );
375
- addNodeElement( 'round', round );
376
- addNodeElement( 'reciprocal', reciprocal );
377
- addNodeElement( 'trunc', trunc );
378
- addNodeElement( 'fwidth', fwidth );
379
- addNodeElement( 'atan2', atan2 );
380
- addNodeElement( 'min', min );
381
- addNodeElement( 'max', max );
382
- addNodeElement( 'mod', mod );
383
- addNodeElement( 'step', step );
384
- addNodeElement( 'reflect', reflect );
385
- addNodeElement( 'distance', distance );
386
- addNodeElement( 'dot', dot );
387
- addNodeElement( 'cross', cross );
388
- addNodeElement( 'pow', pow );
389
- addNodeElement( 'pow2', pow2 );
390
- addNodeElement( 'pow3', pow3 );
391
- addNodeElement( 'pow4', pow4 );
392
- addNodeElement( 'transformDirection', transformDirection );
393
- addNodeElement( 'mix', mixElement );
394
- addNodeElement( 'clamp', clamp );
395
- addNodeElement( 'refract', refract );
396
- addNodeElement( 'smoothstep', smoothstepElement );
397
- addNodeElement( 'faceForward', faceForward );
398
- addNodeElement( 'difference', difference );
399
- addNodeElement( 'saturate', saturate );
400
- addNodeElement( 'cbrt', cbrt );
401
- addNodeElement( 'transpose', transpose );
402
- addNodeElement( 'rand', rand );
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 { addNodeClass } from '../core/Node.js';
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
- return builder.format( `${ builder.getMethod( 'lessThan' ) }( ${ a }, ${ b } )`, type, output );
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
- return builder.format( `${ builder.getMethod( 'lessThanEqual' ) }( ${ a }, ${ b } )`, type, output );
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
- return builder.format( `${ builder.getMethod( 'greaterThan' ) }( ${ a }, ${ b } )`, type, output );
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
- return builder.format( `${ builder.getMethod( 'greaterThanEqual' ) }( ${ a }, ${ b } )`, type, output );
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
- 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 remainder = nodeProxy( OperatorNode, '%' );
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
- addNodeElement( 'add', add );
253
- addNodeElement( 'sub', sub );
254
- addNodeElement( 'mul', mul );
255
- addNodeElement( 'div', div );
256
- addNodeElement( 'remainder', remainder );
257
- addNodeElement( 'equal', equal );
258
- addNodeElement( 'notEqual', notEqual );
259
- addNodeElement( 'lessThan', lessThan );
260
- addNodeElement( 'greaterThan', greaterThan );
261
- addNodeElement( 'lessThanEqual', lessThanEqual );
262
- addNodeElement( 'greaterThanEqual', greaterThanEqual );
263
- addNodeElement( 'and', and );
264
- addNodeElement( 'or', or );
265
- addNodeElement( 'not', not );
266
- addNodeElement( 'xor', xor );
267
- addNodeElement( 'bitAnd', bitAnd );
268
- addNodeElement( 'bitNot', bitNot );
269
- addNodeElement( 'bitOr', bitOr );
270
- addNodeElement( 'bitXor', bitXor );
271
- addNodeElement( 'shiftLeft', shiftLeft );
272
- addNodeElement( 'shiftRight', shiftRight );
273
-
274
- addNodeClass( 'OperatorNode', OperatorNode );
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 { loop } from '../utils/LoopNode.js';
4
- import { float, vec3, tslFn } from '../shadernode/ShaderNode.js';
3
+ import { Loop } from '../utils/LoopNode.js';
4
+ import { float, vec3, Fn } from '../tsl/TSLBase.js';
5
5
 
6
- const tri = tslFn( ( [ x ] ) => {
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 = tslFn( ( [ p ] ) => {
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 = tslFn( ( [ p_immutable, spd, time ] ) => {
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
- loop( { start: float( 0.0 ), end: float( 3.0 ), type: 'float', condition: '<=' }, () => {
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 };