@gnsx/three 0.185.16 → 0.186.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 (418) hide show
  1. package/build/three.cjs +10 -82600
  2. package/build/three.core.js +1309 -807
  3. package/build/three.module.js +439 -338
  4. package/build/three.tsl.js +74 -44
  5. package/build/three.webgpu.js +6036 -2184
  6. package/build/three.webgpu.nodes.js +6020 -2184
  7. package/examples/jsm/Addons.js +6 -6
  8. package/examples/jsm/controls/ArcballControls.js +1 -1
  9. package/examples/jsm/controls/FirstPersonControls.js +44 -20
  10. package/examples/jsm/controls/OrbitControls.js +9 -0
  11. package/examples/jsm/controls/TrackballControls.js +109 -4
  12. package/examples/jsm/csm/CSMShadowNode.js +13 -0
  13. package/examples/jsm/exporters/GLTFExporter.js +23 -7
  14. package/examples/jsm/exporters/USDZExporter.js +2 -2
  15. package/examples/jsm/generators/CityGenerator.js +377 -45
  16. package/examples/jsm/generators/ForestGenerator.js +12 -12
  17. package/examples/jsm/generators/TerrainGenerator.js +49 -37
  18. package/examples/jsm/generators/TreeGenerator.js +70 -76
  19. package/examples/jsm/generators/city/BenchGenerator.js +127 -0
  20. package/examples/jsm/generators/city/CarGenerator.js +479 -0
  21. package/examples/jsm/generators/city/CityGeneratorUtils.js +31 -0
  22. package/examples/jsm/generators/city/HydrantGenerator.js +106 -0
  23. package/examples/jsm/generators/city/InstancedMeshGenerator.js +86 -0
  24. package/examples/jsm/generators/city/PersonGenerator.js +447 -0
  25. package/examples/jsm/generators/city/SidewalkGenerator.js +33 -38
  26. package/examples/jsm/generators/city/SkyscraperGenerator.js +448 -48
  27. package/examples/jsm/generators/city/StreetTreeGenerator.js +231 -0
  28. package/examples/jsm/generators/city/StreetlightGenerator.js +100 -0
  29. package/examples/jsm/generators/city/TrafficlightGenerator.js +106 -0
  30. package/examples/jsm/generators/city/TrashcanGenerator.js +100 -0
  31. package/examples/jsm/geometries/BoxLineGeometry.js +1 -1
  32. package/examples/jsm/geometries/ParametricGeometry.js +1 -1
  33. package/examples/jsm/geometries/RoundedBoxGeometry.js +1 -1
  34. package/examples/jsm/gpgpu/CountingSort.js +271 -0
  35. package/examples/jsm/helpers/LightProbeGridHelper.js +60 -239
  36. package/examples/jsm/helpers/LightProbeGridHelperWebGL.js +221 -0
  37. package/examples/jsm/inspector/Extension.js +94 -0
  38. package/examples/jsm/inspector/Inspector.js +145 -41
  39. package/examples/jsm/inspector/RendererInspector.js +100 -52
  40. package/examples/jsm/inspector/extensions/color-grading/ColorGrading.js +2609 -0
  41. package/examples/jsm/inspector/extensions/color-grading/ColorWheel.js +352 -0
  42. package/examples/jsm/inspector/extensions/color-grading/CurveEditor.js +599 -0
  43. package/examples/jsm/inspector/extensions/color-grading/LUT3DStyle.js +1201 -0
  44. package/examples/jsm/inspector/extensions/color-grading/LUTMath.js +788 -0
  45. package/examples/jsm/inspector/extensions/color-grading/modules/BrightnessModule.js +72 -0
  46. package/examples/jsm/inspector/extensions/color-grading/modules/ColorWheelModule.js +112 -0
  47. package/examples/jsm/inspector/extensions/color-grading/modules/ContrastModule.js +82 -0
  48. package/examples/jsm/inspector/extensions/color-grading/modules/CurvesModule.js +109 -0
  49. package/examples/jsm/inspector/extensions/color-grading/modules/ExposureHueModule.js +110 -0
  50. package/examples/jsm/inspector/extensions/color-grading/modules/ExposureModule.js +73 -0
  51. package/examples/jsm/inspector/extensions/color-grading/modules/HueModule.js +78 -0
  52. package/examples/jsm/inspector/extensions/color-grading/modules/ImportedCubeModule.js +89 -0
  53. package/examples/jsm/inspector/extensions/color-grading/modules/Module.js +285 -0
  54. package/examples/jsm/inspector/extensions/color-grading/modules/OutputModule.js +101 -0
  55. package/examples/jsm/inspector/extensions/color-grading/modules/RendererModule.js +225 -0
  56. package/examples/jsm/inspector/extensions/color-grading/modules/SatVibranceModule.js +102 -0
  57. package/examples/jsm/inspector/extensions/color-grading/modules/SaturationModule.js +76 -0
  58. package/examples/jsm/inspector/extensions/color-grading/modules/VibranceModule.js +76 -0
  59. package/examples/jsm/inspector/extensions/color-grading/modules/WhiteBalanceModule.js +86 -0
  60. package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +26 -31
  61. package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +1 -0
  62. package/examples/jsm/inspector/tabs/Memory.js +0 -2
  63. package/examples/jsm/inspector/tabs/Settings.js +4 -0
  64. package/examples/jsm/inspector/tabs/Timeline.js +223 -171
  65. package/examples/jsm/inspector/tabs/Viewer.js +515 -21
  66. package/examples/jsm/inspector/ui/List.js +15 -9
  67. package/examples/jsm/inspector/ui/Profiler.js +170 -14
  68. package/examples/jsm/inspector/ui/Style.js +269 -23
  69. package/examples/jsm/inspector/ui/Tab.js +2 -0
  70. package/examples/jsm/inspector/ui/Values.js +14 -2
  71. package/examples/jsm/interactive/HTMLMesh.js +19 -3
  72. package/examples/jsm/lighting/LightProbeGrid.js +484 -889
  73. package/examples/jsm/lighting/LightProbeGridUtils.js +107 -0
  74. package/examples/jsm/lighting/LightProbeGridWebGL.js +841 -0
  75. package/examples/jsm/lighting/vxgi/VXGIConeTracer.js +194 -0
  76. package/examples/jsm/lighting/vxgi/VXGINode.js +660 -0
  77. package/examples/jsm/lighting/vxgi/VXGISceneCollector.js +478 -0
  78. package/examples/jsm/lighting/vxgi/VXGIVolume.js +1430 -0
  79. package/examples/jsm/lights/SunLight.js +95 -0
  80. package/examples/jsm/lights/SunLightNode.js +56 -0
  81. package/examples/jsm/lights/SunLightShadow.js +319 -0
  82. package/examples/jsm/lights/SunShadowNode.js +312 -0
  83. package/examples/jsm/loaders/3DMLoader.js +150 -49
  84. package/examples/jsm/loaders/3MFLoader.js +202 -1
  85. package/examples/jsm/loaders/FBXLoader.js +81 -5
  86. package/examples/jsm/loaders/GLTFGaussianSplatLoaderExtension.js +330 -0
  87. package/examples/jsm/loaders/GLTFLoader.js +79 -14
  88. package/examples/jsm/loaders/GaussianSplatPLYLoader.js +386 -0
  89. package/examples/jsm/loaders/KSPLATLoader.js +463 -0
  90. package/examples/jsm/loaders/MaterialXLoader.js +111 -1010
  91. package/examples/jsm/loaders/PCDLoader.js +1 -1
  92. package/examples/jsm/loaders/SPLATLoader.js +139 -0
  93. package/examples/jsm/loaders/SPZLoader.js +561 -0
  94. package/examples/jsm/loaders/materialx/MaterialXArchive.js +108 -0
  95. package/examples/jsm/loaders/materialx/MaterialXDocument.js +878 -0
  96. package/examples/jsm/loaders/materialx/MaterialXHextile.js +183 -0
  97. package/examples/jsm/loaders/materialx/MaterialXInterfaceValidation.js +376 -0
  98. package/examples/jsm/loaders/materialx/MaterialXLog.js +75 -0
  99. package/examples/jsm/loaders/materialx/MaterialXNodeInterfaceRegistry.js +4 -0
  100. package/examples/jsm/loaders/materialx/MaterialXNodeLibrary.js +1021 -0
  101. package/examples/jsm/loaders/materialx/MaterialXSurfaceMappings.js +661 -0
  102. package/examples/jsm/loaders/materialx/MaterialXUtils.js +57 -0
  103. package/examples/jsm/loaders/materialx/compile/MaterialXCompileRegistry.js +997 -0
  104. package/examples/jsm/loaders/materialx/parse/MaterialXParser.js +28 -0
  105. package/examples/jsm/loaders/usd/USDAParser.js +15 -2
  106. package/examples/jsm/loaders/usd/USDCParser.js +1 -4
  107. package/examples/jsm/loaders/usd/USDComposer.js +80 -42
  108. package/examples/jsm/materials/WoodNodeMaterial.js +6 -108
  109. package/examples/jsm/misc/RollerCoaster.js +2 -2
  110. package/examples/jsm/misc/SculptGL.LICENSE.txt +21 -0
  111. package/examples/jsm/misc/Sculptor.js +1679 -0
  112. package/examples/jsm/misc/SculptorMesh.js +1504 -0
  113. package/examples/jsm/misc/SculptorTools.js +1180 -0
  114. package/examples/jsm/misc/SculptorUtils.js +345 -0
  115. package/examples/jsm/misc/TubePainter.js +28 -16
  116. package/examples/jsm/misc/VolumeSlice.js +24 -24
  117. package/examples/jsm/modifiers/SimplifyModifier.js +63 -556
  118. package/examples/jsm/objects/GaussianSplat.js +1039 -0
  119. package/examples/jsm/objects/Sky.js +66 -45
  120. package/examples/jsm/objects/SkyMesh.js +70 -51
  121. package/examples/jsm/physics/JoltPhysics.js +1 -1
  122. package/examples/jsm/postprocessing/AfterimagePass.js +4 -2
  123. package/examples/jsm/postprocessing/BloomPass.js +2 -2
  124. package/examples/jsm/postprocessing/GTAOPass.js +1 -1
  125. package/examples/jsm/postprocessing/OutlinePass.js +5 -5
  126. package/examples/jsm/postprocessing/SAOPass.js +1 -1
  127. package/examples/jsm/postprocessing/SSAOPass.js +1 -1
  128. package/examples/jsm/postprocessing/SSRPass.js +4 -2
  129. package/examples/jsm/postprocessing/SavePass.js +1 -1
  130. package/examples/jsm/postprocessing/TAARenderPass.js +1 -1
  131. package/examples/jsm/postprocessing/UnrealBloomPass.js +30 -13
  132. package/examples/jsm/renderers/CSS2DRenderer.js +29 -5
  133. package/examples/jsm/shaders/DepthLimitedBlurShader.js +4 -1
  134. package/examples/jsm/shaders/ExposureShader.js +1 -1
  135. package/examples/jsm/shaders/FilmShader.js +2 -1
  136. package/examples/jsm/transpiler/AST.js +21 -2
  137. package/examples/jsm/transpiler/GLSLDecoder.js +498 -8
  138. package/examples/jsm/transpiler/TSLEncoder.js +82 -10
  139. package/examples/jsm/transpiler/WGSLEncoder.js +33 -4
  140. package/examples/jsm/tsl/WebGLNodesHandler.js +29 -39
  141. package/examples/jsm/tsl/display/AfterImageNode.js +2 -0
  142. package/examples/jsm/tsl/display/AnaglyphPassNode.js +3 -2
  143. package/examples/jsm/tsl/display/BilateralBlurNode.js +5 -2
  144. package/examples/jsm/tsl/display/BloomNode.js +55 -30
  145. package/examples/jsm/tsl/display/DenoiseNode.js +21 -1
  146. package/examples/jsm/tsl/display/DepthOfFieldNode.js +24 -6
  147. package/examples/jsm/tsl/display/DotScreenNode.js +11 -11
  148. package/examples/jsm/tsl/display/FSR1Node.js +8 -4
  149. package/examples/jsm/tsl/display/GTAONode.js +199 -86
  150. package/examples/jsm/tsl/display/GaussianBlurNode.js +65 -52
  151. package/examples/jsm/tsl/display/GodraysNode.js +5 -2
  152. package/examples/jsm/tsl/display/ImportanceSampledEnvironment.js +2 -2
  153. package/examples/jsm/tsl/display/LensflareNode.js +5 -2
  154. package/examples/jsm/tsl/display/OITPassNode.js +352 -0
  155. package/examples/jsm/tsl/display/OutlineNode.js +2 -0
  156. package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +3 -2
  157. package/examples/jsm/tsl/display/RGBShiftNode.js +9 -9
  158. package/examples/jsm/tsl/display/RecurrentDenoiseNode.js +7 -4
  159. package/examples/jsm/tsl/display/RetroPassNode.js +1 -1
  160. package/examples/jsm/tsl/display/SMAANode.js +22 -61
  161. package/examples/jsm/tsl/display/SSAAPassNode.js +2 -4
  162. package/examples/jsm/tsl/display/SSAONode.js +436 -0
  163. package/examples/jsm/tsl/display/SSGINode.js +5 -2
  164. package/examples/jsm/tsl/display/SSRNode.js +7 -2
  165. package/examples/jsm/tsl/display/SSSNode.js +5 -2
  166. package/examples/jsm/tsl/display/SharpenNode.js +5 -4
  167. package/examples/jsm/tsl/display/StereoCompositePassNode.js +1 -3
  168. package/examples/jsm/tsl/display/StereoPassNode.js +1 -3
  169. package/examples/jsm/tsl/display/TAAUNode.js +22 -125
  170. package/examples/jsm/tsl/display/TRAANode.js +16 -142
  171. package/examples/jsm/tsl/display/TemporalReprojectNode.js +21 -15
  172. package/examples/jsm/tsl/display/depthAwareBlur.js +63 -0
  173. package/examples/jsm/tsl/display/hashBlur.js +3 -2
  174. package/examples/jsm/tsl/lighting/ClusteredLightsNode.js +38 -27
  175. package/examples/jsm/tsl/lighting/LightProbeGridNode.js +136 -0
  176. package/examples/jsm/tsl/math/voronoiNoise.js +112 -0
  177. package/examples/jsm/tsl/shadows/TileShadowNode.js +4 -6
  178. package/examples/jsm/tsl/utils/Raymarching.js +5 -5
  179. package/examples/jsm/tsl/utils/SoftParticles.js +60 -0
  180. package/examples/jsm/tsl/utils/TAAUtils.js +195 -0
  181. package/examples/jsm/utils/BufferGeometryUtils.js +14 -14
  182. package/examples/jsm/utils/GaussianSplatUtils.js +229 -0
  183. package/examples/jsm/utils/WebGLTextureUtils.js +1 -1
  184. package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
  185. package/examples/jsm/webxr/WebGLXRFallback.js +2 -16
  186. package/examples/jsm/webxr/XRControllerModelFactory.js +16 -4
  187. package/package.json +9 -16
  188. package/src/Three.Core.js +2 -1
  189. package/src/Three.TSL.js +73 -43
  190. package/src/Three.WebGPU.Nodes.js +1 -0
  191. package/src/Three.WebGPU.js +1 -0
  192. package/src/animation/AnimationClip.js +15 -2
  193. package/src/animation/AnimationObjectGroup.js +18 -6
  194. package/src/animation/AnimationUtils.js +26 -0
  195. package/src/animation/KeyframeTrack.js +37 -0
  196. package/src/constants.js +23 -1
  197. package/src/core/BufferAttribute.js +3 -2
  198. package/src/core/BufferGeometry.js +1 -1
  199. package/src/core/InterleavedBuffer.js +5 -1
  200. package/src/core/Object3D.js +40 -12
  201. package/src/core/Raycaster.js +4 -0
  202. package/src/core/RenderTarget.js +99 -9
  203. package/src/core/RenderTarget3D.js +12 -8
  204. package/src/extras/Controls.js +0 -8
  205. package/src/extras/PMREMGenerator.js +99 -205
  206. package/src/geometries/TorusGeometry.js +1 -1
  207. package/src/helpers/ArrowHelper.js +2 -0
  208. package/src/helpers/AxesHelper.js +2 -0
  209. package/src/helpers/Box3Helper.js +2 -0
  210. package/src/helpers/BoxHelper.js +2 -0
  211. package/src/helpers/CameraHelper.js +2 -0
  212. package/src/helpers/DirectionalLightHelper.js +2 -0
  213. package/src/helpers/GridHelper.js +2 -0
  214. package/src/helpers/HemisphereLightHelper.js +2 -0
  215. package/src/helpers/PlaneHelper.js +2 -0
  216. package/src/helpers/PointLightHelper.js +2 -0
  217. package/src/helpers/PolarGridHelper.js +2 -0
  218. package/src/helpers/SkeletonHelper.js +2 -0
  219. package/src/helpers/SpotLightHelper.js +2 -0
  220. package/src/lights/Light.js +0 -10
  221. package/src/lights/LightShadow.js +43 -12
  222. package/src/lights/SpotLightShadow.js +18 -0
  223. package/src/loaders/BufferGeometryLoader.js +5 -0
  224. package/src/loaders/ImageBitmapLoader.js +3 -1
  225. package/src/loaders/ObjectLoader.js +8 -5
  226. package/src/materials/Material.js +80 -57
  227. package/src/materials/MeshPhysicalMaterial.js +32 -0
  228. package/src/materials/nodes/Line2NodeMaterial.js +17 -8
  229. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +42 -5
  230. package/src/materials/nodes/NodeMaterial.js +19 -13
  231. package/src/materials/nodes/PointsNodeMaterial.js +2 -1
  232. package/src/materials/nodes/manager/NodeMaterialObserver.js +282 -55
  233. package/src/math/Frustum.js +9 -0
  234. package/src/math/FrustumArray.js +1 -1
  235. package/src/math/MathUtils.js +5 -3
  236. package/src/math/Matrix4.js +2 -9
  237. package/src/math/Plane.js +30 -1
  238. package/src/math/Quaternion.js +0 -10
  239. package/src/math/Ray.js +95 -45
  240. package/src/math/Triangle.js +0 -2
  241. package/src/math/Vector3.js +2 -2
  242. package/src/math/Vector4.js +0 -4
  243. package/src/math/interpolants/BezierInterpolant.js +36 -23
  244. package/src/nodes/Nodes.js +2 -0
  245. package/src/nodes/TSL.js +11 -3
  246. package/src/nodes/accessors/Batch.js +85 -13
  247. package/src/nodes/accessors/BufferAttributeNode.js +1 -1
  248. package/src/nodes/accessors/BuiltinNode.js +1 -1
  249. package/src/nodes/accessors/Instance.js +19 -18
  250. package/src/nodes/accessors/MaterialNode.js +9 -0
  251. package/src/nodes/accessors/ModelNode.js +85 -9
  252. package/src/nodes/accessors/ReferenceBaseNode.js +1 -70
  253. package/src/nodes/accessors/ReferenceElementNode.js +72 -0
  254. package/src/nodes/accessors/ReferenceNode.js +1 -70
  255. package/src/nodes/accessors/Skinning.js +124 -12
  256. package/src/nodes/accessors/StorageTextureNode.js +7 -3
  257. package/src/nodes/accessors/Texture3DNode.js +1 -1
  258. package/src/nodes/accessors/TextureNode.js +51 -21
  259. package/src/nodes/accessors/TextureSizeNode.js +4 -2
  260. package/src/nodes/accessors/UniformArrayNode.js +30 -5
  261. package/src/nodes/code/CodeNode.js +1 -1
  262. package/src/nodes/code/FunctionNode.js +12 -2
  263. package/src/nodes/core/ArrayNode.js +2 -2
  264. package/src/nodes/core/ContextNode.js +57 -4
  265. package/src/nodes/core/IndexNode.js +69 -4
  266. package/src/nodes/core/InspectorNode.js +2 -2
  267. package/src/nodes/core/MRTNode.js +44 -2
  268. package/src/nodes/core/Node.js +6 -3
  269. package/src/nodes/core/NodeBuilder.js +65 -50
  270. package/src/nodes/core/NodeFrame.js +11 -3
  271. package/src/nodes/core/NodeUtils.js +88 -0
  272. package/src/nodes/core/PropertyNode.js +8 -0
  273. package/src/nodes/core/StackNode.js +0 -1
  274. package/src/nodes/core/StructNode.js +4 -3
  275. package/src/nodes/core/UniformGroupNode.js +3 -2
  276. package/src/nodes/core/UniformNode.js +26 -12
  277. package/src/nodes/core/VarNode.js +0 -1
  278. package/src/nodes/display/BumpMapNode.js +2 -2
  279. package/src/nodes/display/ColorAdjustment.js +1 -1
  280. package/src/nodes/display/PassNode.js +76 -15
  281. package/src/nodes/display/ScreenNode.js +22 -65
  282. package/src/nodes/fog/Fog.js +4 -4
  283. package/src/nodes/functions/BSDF/BRDF_GGX.js +6 -6
  284. package/src/nodes/functions/BSDF/BRDF_Sheen.js +1 -1
  285. package/src/nodes/functions/BSDF/DFGLUT.js +2 -1
  286. package/src/nodes/functions/BSDF/LTC.js +1 -1
  287. package/src/nodes/functions/PhongLightingModel.js +1 -1
  288. package/src/nodes/functions/PhysicalLightingModel.js +83 -25
  289. package/src/nodes/functions/ToonLightingModel.js +2 -2
  290. package/src/nodes/functions/material/getParallaxCorrectNormal.js +3 -3
  291. package/src/nodes/gpgpu/AtomicFunctionNode.js +64 -13
  292. package/src/nodes/gpgpu/BarrierNode.js +13 -4
  293. package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -1
  294. package/src/nodes/gpgpu/ComputeNode.js +20 -17
  295. package/src/nodes/gpgpu/SubgroupFunctionNode.js +165 -37
  296. package/src/nodes/gpgpu/WorkgroupInfoNode.js +44 -6
  297. package/src/nodes/lighting/EnvironmentNode.js +40 -4
  298. package/src/nodes/lighting/LightsNode.js +20 -4
  299. package/src/nodes/lighting/ShadowBaseNode.js +158 -1
  300. package/src/nodes/lighting/ShadowFilterNode.js +2 -106
  301. package/src/nodes/lighting/ShadowNode.js +22 -91
  302. package/src/nodes/materialx/{lib/mx_hsv.js → MaterialXColor.js} +3 -6
  303. package/src/nodes/materialx/{lib/mx_transform_color.js → MaterialXColorTransform.js} +3 -6
  304. package/src/nodes/materialx/MaterialXCore.js +37 -0
  305. package/src/nodes/materialx/MaterialXNodes.js +64 -72
  306. package/src/nodes/materialx/{lib/mx_noise.js → MaterialXNoise.js} +426 -197
  307. package/src/nodes/math/BitcountNode.js +24 -4
  308. package/src/nodes/math/MathNode.js +4 -4
  309. package/src/nodes/math/MathUtils.js +15 -4
  310. package/src/nodes/math/OperatorNode.js +2 -2
  311. package/src/nodes/math/PackFloatNode.js +29 -1
  312. package/src/nodes/math/Packed4x8IntegerNode.js +433 -0
  313. package/src/nodes/math/UnpackFloatNode.js +30 -2
  314. package/src/nodes/parsers/GLSLNodeFunction.js +1 -1
  315. package/src/nodes/pmrem/PMREMNode.js +1 -1
  316. package/src/nodes/pmrem/PMREMUtils.js +31 -74
  317. package/src/nodes/shapes/Shapes.js +1 -1
  318. package/src/nodes/tsl/TSLCore.js +1 -31
  319. package/src/nodes/utils/EventNode.js +75 -0
  320. package/src/nodes/utils/LoopNode.js +54 -13
  321. package/src/nodes/utils/PostProcessingUtils.js +23 -2
  322. package/src/nodes/utils/RTTNode.js +97 -32
  323. package/src/nodes/utils/ReflectorNode.js +8 -4
  324. package/src/nodes/utils/RotateNode.js +85 -8
  325. package/src/nodes/utils/SpriteUtils.js +58 -23
  326. package/src/objects/BatchedMesh.js +6 -0
  327. package/src/objects/InstancedMesh.js +1 -1
  328. package/src/objects/LOD.js +1 -1
  329. package/src/objects/Line.js +12 -0
  330. package/src/objects/Mesh.js +12 -0
  331. package/src/objects/Points.js +12 -0
  332. package/src/objects/Sprite.js +12 -0
  333. package/src/renderers/WebGLRenderer.js +93 -27
  334. package/src/renderers/common/Animation.js +12 -2
  335. package/src/renderers/common/Backend.js +38 -10
  336. package/src/renderers/common/BindGroup.js +0 -1
  337. package/src/renderers/common/Bindings.js +50 -4
  338. package/src/renderers/common/BundleGroup.js +4 -0
  339. package/src/renderers/common/ClippingContext.js +11 -1
  340. package/src/renderers/common/Color4.js +9 -0
  341. package/src/renderers/common/Constants.js +0 -5
  342. package/src/renderers/common/DirectRenderPipeline.js +233 -0
  343. package/src/renderers/common/Geometries.js +24 -3
  344. package/src/renderers/common/Info.js +3 -3
  345. package/src/renderers/common/InspectorBase.js +37 -8
  346. package/src/renderers/common/Lighting.js +11 -4
  347. package/src/renderers/common/Pipelines.js +6 -4
  348. package/src/renderers/common/QuadMesh.js +16 -2
  349. package/src/renderers/common/RenderContext.js +8 -0
  350. package/src/renderers/common/RenderList.js +53 -19
  351. package/src/renderers/common/RenderLists.js +58 -11
  352. package/src/renderers/common/RenderObject.js +14 -0
  353. package/src/renderers/common/RenderObjects.js +14 -9
  354. package/src/renderers/common/RenderPipeline.js +52 -44
  355. package/src/renderers/common/Renderer.js +226 -55
  356. package/src/renderers/common/Storage3DTexture.js +16 -0
  357. package/src/renderers/common/Textures.js +3 -3
  358. package/src/renderers/common/XRManager.js +79 -72
  359. package/src/renderers/common/extras/PMREMGenerator.js +76 -144
  360. package/src/renderers/common/nodes/NodeManager.js +144 -6
  361. package/src/renderers/common/nodes/NodeStorageBuffer.js +3 -1
  362. package/src/renderers/common/nodes/NodeUniformBuffer.js +3 -1
  363. package/src/renderers/shaders/DFGLUTData.js +2 -1
  364. package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +4 -2
  365. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +48 -0
  366. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +53 -4
  367. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +20 -2
  368. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +20 -0
  369. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
  370. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +61 -57
  371. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +82 -0
  372. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +9 -0
  373. package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +8 -1
  374. package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +15 -0
  375. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -0
  376. package/src/renderers/shaders/ShaderLib.js +1 -0
  377. package/src/renderers/shaders/UniformsLib.js +16 -0
  378. package/src/renderers/webgl/WebGLAnimation.js +2 -2
  379. package/src/renderers/webgl/WebGLCapabilities.js +2 -2
  380. package/src/renderers/webgl/WebGLLights.js +74 -4
  381. package/src/renderers/webgl/WebGLMaterials.js +6 -0
  382. package/src/renderers/webgl/WebGLOutput.js +36 -24
  383. package/src/renderers/webgl/WebGLProgram.js +3 -0
  384. package/src/renderers/webgl/WebGLPrograms.js +8 -0
  385. package/src/renderers/webgl/WebGLRenderLists.js +6 -10
  386. package/src/renderers/webgl/WebGLShadowMap.js +47 -44
  387. package/src/renderers/webgl/WebGLTextures.js +7 -7
  388. package/src/renderers/webgl-fallback/WebGLBackend.js +153 -45
  389. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +83 -29
  390. package/src/renderers/webgl-fallback/utils/WebGLState.js +163 -17
  391. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +32 -5
  392. package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +11 -4
  393. package/src/renderers/webgpu/WebGPUBackend.js +513 -145
  394. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +99 -20
  395. package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -1
  396. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +3 -12
  397. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +24 -14
  398. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +80 -14
  399. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +62 -7
  400. package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +9 -3
  401. package/src/renderers/webgpu/utils/WebGPUUtils.js +16 -4
  402. package/src/renderers/webxr/WebXRManager.js +25 -2
  403. package/src/scenes/Scene.js +3 -3
  404. package/src/textures/CompressedArrayTexture.js +16 -0
  405. package/src/textures/Data3DTexture.js +16 -0
  406. package/src/textures/DataArrayTexture.js +16 -0
  407. package/src/textures/DepthTexture.js +3 -3
  408. package/src/textures/Texture.js +3 -3
  409. package/src/textures/{Source.js → TextureSource.js} +39 -8
  410. package/src/utils.js +6 -79
  411. package/build/three.core.min.js +0 -6
  412. package/build/three.module.min.js +0 -6
  413. package/build/three.tsl.min.js +0 -6
  414. package/build/three.webgpu.min.js +0 -6
  415. package/build/three.webgpu.nodes.min.js +0 -6
  416. package/examples/jsm/libs/ecsy.module.js +0 -1792
  417. package/examples/jsm/loaders/LottieLoader.js +0 -130
  418. package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +0 -52
@@ -1,12 +1,10 @@
1
- // Three.js Transpiler
2
- // https://raw.githubusercontent.com/AcademySoftwareFoundation/MaterialX/main/libraries/stdlib/genglsl/lib/mx_noise.glsl
3
-
4
- import { int, uint, float, vec3, bool, uvec3, vec2, vec4, If, Fn } from '../../tsl/TSLBase.js';
5
- import { select } from '../../math/ConditionalNode.js';
6
- import { sub, mul } from '../../math/OperatorNode.js';
7
- import { floor, abs, max, dot, min, sqrt, clamp } from '../../math/MathNode.js';
8
- import { overloadingFn } from '../../utils/FunctionOverloadingNode.js';
9
- import { Loop } from '../../utils/LoopNode.js';
1
+ import { int, uint, float, vec3, bool, uvec3, vec2, vec4, If, Fn } from '../tsl/TSLBase.js';
2
+ import { select } from '../math/ConditionalNode.js';
3
+ import { add, sub, mul } from '../math/OperatorNode.js';
4
+ import { floor, abs, max, dot, sqrt, clamp, fract } from '../math/MathNode.js';
5
+ import { overloadingFn } from '../utils/FunctionOverloadingNode.js';
6
+ import { Loop } from '../utils/LoopNode.js';
7
+ import { mx_rotate2d, mx_rotate3d } from './MaterialXCore.js';
10
8
 
11
9
 
12
10
  export const mx_select = /*@__PURE__*/ Fn( ( [ b_immutable, t_immutable, f_immutable ] ) => {
@@ -66,6 +64,22 @@ export const mx_floorfrac = /*@__PURE__*/ Fn( ( [ x_immutable, i ] ) => {
66
64
 
67
65
  } );
68
66
 
67
+ const mxBilerpValue = ( v0, v1, v2, v3, s, t ) => {
68
+
69
+ const s1 = float( sub( 1.0, s ) ).toVar();
70
+ return sub( 1.0, t ).mul( v0.mul( s1 ).add( v1.mul( s ) ) ).add( t.mul( v2.mul( s1 ).add( v3.mul( s ) ) ) );
71
+
72
+ };
73
+
74
+ const mxTrilerpValue = ( v0, v1, v2, v3, v4, v5, v6, v7, s, t, r ) => {
75
+
76
+ const s1 = float( sub( 1.0, s ) ).toVar();
77
+ const t1 = float( sub( 1.0, t ) ).toVar();
78
+ const r1 = float( sub( 1.0, r ) ).toVar();
79
+ return r1.mul( t1.mul( v0.mul( s1 ).add( v1.mul( s ) ) ).add( t.mul( v2.mul( s1 ).add( v3.mul( s ) ) ) ) ).add( r.mul( t1.mul( v4.mul( s1 ).add( v5.mul( s ) ) ).add( t.mul( v6.mul( s1 ).add( v7.mul( s ) ) ) ) ) );
80
+
81
+ };
82
+
69
83
  export const mx_bilerp_0 = /*@__PURE__*/ Fn( ( [ v0_immutable, v1_immutable, v2_immutable, v3_immutable, s_immutable, t_immutable ] ) => {
70
84
 
71
85
  const t = float( t_immutable ).toVar();
@@ -74,9 +88,8 @@ export const mx_bilerp_0 = /*@__PURE__*/ Fn( ( [ v0_immutable, v1_immutable, v2_
74
88
  const v2 = float( v2_immutable ).toVar();
75
89
  const v1 = float( v1_immutable ).toVar();
76
90
  const v0 = float( v0_immutable ).toVar();
77
- const s1 = float( sub( 1.0, s ) ).toVar();
78
91
 
79
- return sub( 1.0, t ).mul( v0.mul( s1 ).add( v1.mul( s ) ) ).add( t.mul( v2.mul( s1 ).add( v3.mul( s ) ) ) );
92
+ return mxBilerpValue( v0, v1, v2, v3, s, t );
80
93
 
81
94
  } ).setLayout( {
82
95
  name: 'mx_bilerp_0',
@@ -99,9 +112,8 @@ export const mx_bilerp_1 = /*@__PURE__*/ Fn( ( [ v0_immutable, v1_immutable, v2_
99
112
  const v2 = vec3( v2_immutable ).toVar();
100
113
  const v1 = vec3( v1_immutable ).toVar();
101
114
  const v0 = vec3( v0_immutable ).toVar();
102
- const s1 = float( sub( 1.0, s ) ).toVar();
103
115
 
104
- return sub( 1.0, t ).mul( v0.mul( s1 ).add( v1.mul( s ) ) ).add( t.mul( v2.mul( s1 ).add( v3.mul( s ) ) ) );
116
+ return mxBilerpValue( v0, v1, v2, v3, s, t );
105
117
 
106
118
  } ).setLayout( {
107
119
  name: 'mx_bilerp_1',
@@ -131,11 +143,8 @@ export const mx_trilerp_0 = /*@__PURE__*/ Fn( ( [ v0_immutable, v1_immutable, v2
131
143
  const v2 = float( v2_immutable ).toVar();
132
144
  const v1 = float( v1_immutable ).toVar();
133
145
  const v0 = float( v0_immutable ).toVar();
134
- const s1 = float( sub( 1.0, s ) ).toVar();
135
- const t1 = float( sub( 1.0, t ) ).toVar();
136
- const r1 = float( sub( 1.0, r ) ).toVar();
137
146
 
138
- return r1.mul( t1.mul( v0.mul( s1 ).add( v1.mul( s ) ) ).add( t.mul( v2.mul( s1 ).add( v3.mul( s ) ) ) ) ).add( r.mul( t1.mul( v4.mul( s1 ).add( v5.mul( s ) ) ).add( t.mul( v6.mul( s1 ).add( v7.mul( s ) ) ) ) ) );
147
+ return mxTrilerpValue( v0, v1, v2, v3, v4, v5, v6, v7, s, t, r );
139
148
 
140
149
  } ).setLayout( {
141
150
  name: 'mx_trilerp_0',
@@ -168,11 +177,8 @@ export const mx_trilerp_1 = /*@__PURE__*/ Fn( ( [ v0_immutable, v1_immutable, v2
168
177
  const v2 = vec3( v2_immutable ).toVar();
169
178
  const v1 = vec3( v1_immutable ).toVar();
170
179
  const v0 = vec3( v0_immutable ).toVar();
171
- const s1 = float( sub( 1.0, s ) ).toVar();
172
- const t1 = float( sub( 1.0, t ) ).toVar();
173
- const r1 = float( sub( 1.0, r ) ).toVar();
174
180
 
175
- return r1.mul( t1.mul( v0.mul( s1 ).add( v1.mul( s ) ) ).add( t.mul( v2.mul( s1 ).add( v3.mul( s ) ) ) ) ).add( r.mul( t1.mul( v4.mul( s1 ).add( v5.mul( s ) ) ).add( t.mul( v6.mul( s1 ).add( v7.mul( s ) ) ) ) ) );
181
+ return mxTrilerpValue( v0, v1, v2, v3, v4, v5, v6, v7, s, t, r );
176
182
 
177
183
  } ).setLayout( {
178
184
  name: 'mx_trilerp_1',
@@ -358,6 +364,9 @@ export const mx_rotl32 = /*@__PURE__*/ Fn( ( [ x_immutable, k_immutable ] ) => {
358
364
 
359
365
  export const mx_bjmix = /*@__PURE__*/ Fn( ( [ a, b, c ] ) => {
360
366
 
367
+ a = uint( a ).toVar();
368
+ b = uint( b ).toVar();
369
+ c = uint( c ).toVar();
361
370
  a.subAssign( c );
362
371
  a.bitXorAssign( mx_rotl32( c, int( 4 ) ) );
363
372
  c.addAssign( b );
@@ -377,6 +386,16 @@ export const mx_bjmix = /*@__PURE__*/ Fn( ( [ a, b, c ] ) => {
377
386
  c.bitXorAssign( mx_rotl32( b, int( 4 ) ) );
378
387
  b.addAssign( a );
379
388
 
389
+ return uvec3( a, b, c );
390
+
391
+ } ).setLayout( {
392
+ name: 'mx_bjmix',
393
+ type: 'uvec3',
394
+ inputs: [
395
+ { name: 'a', type: 'uint' },
396
+ { name: 'b', type: 'uint' },
397
+ { name: 'c', type: 'uint' }
398
+ ]
380
399
  } );
381
400
 
382
401
  export const mx_bjfinal = /*@__PURE__*/ Fn( ( [ a_immutable, b_immutable, c_immutable ] ) => {
@@ -415,7 +434,7 @@ export const mx_bits_to_01 = /*@__PURE__*/ Fn( ( [ bits_immutable ] ) => {
415
434
 
416
435
  const bits = uint( bits_immutable ).toVar();
417
436
 
418
- return float( bits ).div( float( uint( int( 0xffffffff ) ) ) );
437
+ return float( bits ).div( float( uint( 0xffffffff ) ) );
419
438
 
420
439
  } ).setLayout( {
421
440
  name: 'mx_bits_to_01',
@@ -443,7 +462,7 @@ export const mx_hash_int_0 = /*@__PURE__*/ Fn( ( [ x_immutable ] ) => {
443
462
 
444
463
  const x = int( x_immutable ).toVar();
445
464
  const len = uint( uint( 1 ) ).toVar();
446
- const seed = uint( uint( int( 0xdeadbeef ) ).add( len.shiftLeft( uint( 2 ) ) ).add( uint( 13 ) ) ).toVar();
465
+ const seed = uint( uint( 0xdeadbeef ).add( len.shiftLeft( uint( 2 ) ) ).add( uint( 13 ) ) ).toVar();
447
466
 
448
467
  return mx_bjfinal( seed.add( uint( x ) ), seed, seed );
449
468
 
@@ -461,7 +480,7 @@ export const mx_hash_int_1 = /*@__PURE__*/ Fn( ( [ x_immutable, y_immutable ] )
461
480
  const x = int( x_immutable ).toVar();
462
481
  const len = uint( uint( 2 ) ).toVar();
463
482
  const a = uint().toVar(), b = uint().toVar(), c = uint().toVar();
464
- a.assign( b.assign( c.assign( uint( int( 0xdeadbeef ) ).add( len.shiftLeft( uint( 2 ) ) ).add( uint( 13 ) ) ) ) );
483
+ a.assign( b.assign( c.assign( uint( 0xdeadbeef ).add( len.shiftLeft( uint( 2 ) ) ).add( uint( 13 ) ) ) ) );
465
484
  a.addAssign( uint( x ) );
466
485
  b.addAssign( uint( y ) );
467
486
 
@@ -483,7 +502,7 @@ export const mx_hash_int_2 = /*@__PURE__*/ Fn( ( [ x_immutable, y_immutable, z_i
483
502
  const x = int( x_immutable ).toVar();
484
503
  const len = uint( uint( 3 ) ).toVar();
485
504
  const a = uint().toVar(), b = uint().toVar(), c = uint().toVar();
486
- a.assign( b.assign( c.assign( uint( int( 0xdeadbeef ) ).add( len.shiftLeft( uint( 2 ) ) ).add( uint( 13 ) ) ) ) );
505
+ a.assign( b.assign( c.assign( uint( 0xdeadbeef ).add( len.shiftLeft( uint( 2 ) ) ).add( uint( 13 ) ) ) ) );
487
506
  a.addAssign( uint( x ) );
488
507
  b.addAssign( uint( y ) );
489
508
  c.addAssign( uint( z ) );
@@ -508,11 +527,14 @@ export const mx_hash_int_3 = /*@__PURE__*/ Fn( ( [ x_immutable, y_immutable, z_i
508
527
  const x = int( x_immutable ).toVar();
509
528
  const len = uint( uint( 4 ) ).toVar();
510
529
  const a = uint().toVar(), b = uint().toVar(), c = uint().toVar();
511
- a.assign( b.assign( c.assign( uint( int( 0xdeadbeef ) ).add( len.shiftLeft( uint( 2 ) ) ).add( uint( 13 ) ) ) ) );
530
+ a.assign( b.assign( c.assign( uint( 0xdeadbeef ).add( len.shiftLeft( uint( 2 ) ) ).add( uint( 13 ) ) ) ) );
512
531
  a.addAssign( uint( x ) );
513
532
  b.addAssign( uint( y ) );
514
533
  c.addAssign( uint( z ) );
515
- mx_bjmix( a, b, c );
534
+ const mixed = uvec3( mx_bjmix( a, b, c ) ).toVar();
535
+ a.assign( mixed.x );
536
+ b.assign( mixed.y );
537
+ c.assign( mixed.z );
516
538
  a.addAssign( uint( xx ) );
517
539
 
518
540
  return mx_bjfinal( a, b, c );
@@ -537,11 +559,14 @@ export const mx_hash_int_4 = /*@__PURE__*/ Fn( ( [ x_immutable, y_immutable, z_i
537
559
  const x = int( x_immutable ).toVar();
538
560
  const len = uint( uint( 5 ) ).toVar();
539
561
  const a = uint().toVar(), b = uint().toVar(), c = uint().toVar();
540
- a.assign( b.assign( c.assign( uint( int( 0xdeadbeef ) ).add( len.shiftLeft( uint( 2 ) ) ).add( uint( 13 ) ) ) ) );
562
+ a.assign( b.assign( c.assign( uint( 0xdeadbeef ).add( len.shiftLeft( uint( 2 ) ) ).add( uint( 13 ) ) ) ) );
541
563
  a.addAssign( uint( x ) );
542
564
  b.addAssign( uint( y ) );
543
565
  c.addAssign( uint( z ) );
544
- mx_bjmix( a, b, c );
566
+ const mixed = uvec3( mx_bjmix( a, b, c ) ).toVar();
567
+ a.assign( mixed.x );
568
+ b.assign( mixed.y );
569
+ c.assign( mixed.z );
545
570
  a.addAssign( uint( xx ) );
546
571
  b.addAssign( uint( yy ) );
547
572
 
@@ -768,7 +793,11 @@ export const mx_cell_noise_vec3_0 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => {
768
793
  const p = float( p_immutable ).toVar();
769
794
  const ix = int( mx_floor( p ) ).toVar();
770
795
 
771
- return vec3( mx_bits_to_01( mx_hash_int( ix, int( 0 ) ) ), mx_bits_to_01( mx_hash_int( ix, int( 1 ) ) ), mx_bits_to_01( mx_hash_int( ix, int( 2 ) ) ) );
796
+ return vec3(
797
+ mx_bits_to_01( mx_hash_int( ix, int( 0 ) ) ),
798
+ mx_bits_to_01( mx_hash_int( ix, int( 1 ) ) ),
799
+ mx_bits_to_01( mx_hash_int( ix, int( 2 ) ) )
800
+ );
772
801
 
773
802
  } ).setLayout( {
774
803
  name: 'mx_cell_noise_vec3_0',
@@ -784,7 +813,11 @@ export const mx_cell_noise_vec3_1 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => {
784
813
  const ix = int( mx_floor( p.x ) ).toVar();
785
814
  const iy = int( mx_floor( p.y ) ).toVar();
786
815
 
787
- return vec3( mx_bits_to_01( mx_hash_int( ix, iy, int( 0 ) ) ), mx_bits_to_01( mx_hash_int( ix, iy, int( 1 ) ) ), mx_bits_to_01( mx_hash_int( ix, iy, int( 2 ) ) ) );
816
+ return vec3(
817
+ mx_bits_to_01( mx_hash_int( ix, iy, int( 0 ) ) ),
818
+ mx_bits_to_01( mx_hash_int( ix, iy, int( 1 ) ) ),
819
+ mx_bits_to_01( mx_hash_int( ix, iy, int( 2 ) ) )
820
+ );
788
821
 
789
822
  } ).setLayout( {
790
823
  name: 'mx_cell_noise_vec3_1',
@@ -794,14 +827,29 @@ export const mx_cell_noise_vec3_1 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => {
794
827
  ]
795
828
  } );
796
829
 
797
- export const mx_cell_noise_vec3_2 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => {
830
+ export const mx_cell_noise_vec3_2 = /*@__PURE__*/ Fn( ( [ positionInput ] ) => {
798
831
 
799
- const p = vec3( p_immutable ).toVar();
800
- const ix = int( mx_floor( p.x ) ).toVar();
801
- const iy = int( mx_floor( p.y ) ).toVar();
802
- const iz = int( mx_floor( p.z ) ).toVar();
803
-
804
- return vec3( mx_bits_to_01( mx_hash_int( ix, iy, iz, int( 0 ) ) ), mx_bits_to_01( mx_hash_int( ix, iy, iz, int( 1 ) ) ), mx_bits_to_01( mx_hash_int( ix, iy, iz, int( 2 ) ) ) );
832
+ const position = vec3( positionInput ).toVar();
833
+ const ix = int( floor( position.x ) ).toVar();
834
+ const iy = int( floor( position.y ) ).toVar();
835
+ const iz = int( floor( position.z ) ).toVar();
836
+ const seed = uint( 0xdeadbeef + ( 4 << 2 ) + 13 ).toVar();
837
+ const a = uint().toVar(), b = uint().toVar(), c = uint().toVar();
838
+ a.assign( b.assign( c.assign( seed ) ) );
839
+ a.addAssign( uint( ix ) );
840
+ b.addAssign( uint( iy ) );
841
+ c.addAssign( uint( iz ) );
842
+
843
+ const mixed = uvec3( mx_bjmix( a, b, c ) ).toVar();
844
+ const hash0 = mx_bjfinal( mixed.x, mixed.y, mixed.z );
845
+ const hash1 = mx_bjfinal( add( mixed.x, uint( 1 ) ), mixed.y, mixed.z );
846
+ const hash2 = mx_bjfinal( add( mixed.x, uint( 2 ) ), mixed.y, mixed.z );
847
+
848
+ return vec3(
849
+ mx_bits_to_01( hash0 ),
850
+ mx_bits_to_01( hash1 ),
851
+ mx_bits_to_01( hash2 )
852
+ );
805
853
 
806
854
  } ).setLayout( {
807
855
  name: 'mx_cell_noise_vec3_2',
@@ -818,8 +866,24 @@ export const mx_cell_noise_vec3_3 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => {
818
866
  const iy = int( mx_floor( p.y ) ).toVar();
819
867
  const iz = int( mx_floor( p.z ) ).toVar();
820
868
  const iw = int( mx_floor( p.w ) ).toVar();
821
-
822
- return vec3( mx_bits_to_01( mx_hash_int( ix, iy, iz, iw, int( 0 ) ) ), mx_bits_to_01( mx_hash_int( ix, iy, iz, iw, int( 1 ) ) ), mx_bits_to_01( mx_hash_int( ix, iy, iz, iw, int( 2 ) ) ) );
869
+ const seed = uint( 0xdeadbeef + ( 5 << 2 ) + 13 ).toVar();
870
+ const a = uint().toVar(), b = uint().toVar(), c = uint().toVar();
871
+ a.assign( b.assign( c.assign( seed ) ) );
872
+ a.addAssign( uint( ix ) );
873
+ b.addAssign( uint( iy ) );
874
+ c.addAssign( uint( iz ) );
875
+
876
+ const mixed = uvec3( mx_bjmix( a, b, c ) ).toVar();
877
+ a.assign( mixed.x );
878
+ b.assign( mixed.y );
879
+ c.assign( mixed.z );
880
+ a.addAssign( uint( iw ) );
881
+
882
+ return vec3(
883
+ mx_bits_to_01( mx_bjfinal( a, b, c ) ),
884
+ mx_bits_to_01( mx_bjfinal( a, add( b, uint( 1 ) ), c ) ),
885
+ mx_bits_to_01( mx_bjfinal( a, add( b, uint( 2 ) ), c ) )
886
+ );
823
887
 
824
888
  } ).setLayout( {
825
889
  name: 'mx_cell_noise_vec3_3',
@@ -831,6 +895,62 @@ export const mx_cell_noise_vec3_3 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => {
831
895
 
832
896
  export const mx_cell_noise_vec3 = /*@__PURE__*/ overloadingFn( [ mx_cell_noise_vec3_0, mx_cell_noise_vec3_1, mx_cell_noise_vec3_2, mx_cell_noise_vec3_3 ] );
833
897
 
898
+ const mx_cell_noise_vec3_3d = /*@__PURE__*/ Fn( ( [ positionInput ] ) => {
899
+
900
+ const position = vec3( positionInput ).toVar();
901
+ const ix = int( floor( position.x ) ).toVar();
902
+ const iy = int( floor( position.y ) ).toVar();
903
+ const iz = int( floor( position.z ) ).toVar();
904
+ const seed = uint( 0xdeadbeef + ( 4 << 2 ) + 13 ).toVar();
905
+ const a = uint().toVar(), b = uint().toVar(), c = uint().toVar();
906
+ a.assign( b.assign( c.assign( seed ) ) );
907
+ a.addAssign( uint( ix ) );
908
+ b.addAssign( uint( iy ) );
909
+ c.addAssign( uint( iz ) );
910
+
911
+ const mixed = uvec3( mx_bjmix( a, b, c ) ).toVar();
912
+ const hash0 = mx_bjfinal( mixed.x, mixed.y, mixed.z );
913
+ const hash1 = mx_bjfinal( add( mixed.x, uint( 1 ) ), mixed.y, mixed.z );
914
+ const hash2 = mx_bjfinal( add( mixed.x, uint( 2 ) ), mixed.y, mixed.z );
915
+
916
+ return vec3(
917
+ mx_bits_to_01( hash0 ),
918
+ mx_bits_to_01( hash1 ),
919
+ mx_bits_to_01( hash2 )
920
+ );
921
+
922
+ } );
923
+
924
+ export const mx_fractal_noise_float_2d = /*@__PURE__*/ Fn( ( [ p_immutable, octaves_immutable, lacunarity_immutable, diminish_immutable ] ) => {
925
+
926
+ const diminish = float( diminish_immutable ).toVar();
927
+ const lacunarity = float( lacunarity_immutable ).toVar();
928
+ const octaves = int( octaves_immutable ).toVar();
929
+ const p = vec2( p_immutable ).toVar();
930
+ const result = float( 0.0 ).toVar();
931
+ const amplitude = float( 1.0 ).toVar();
932
+
933
+ Loop( octaves, () => {
934
+
935
+ result.addAssign( amplitude.mul( mx_perlin_noise_float( p ) ) );
936
+ amplitude.mulAssign( diminish );
937
+ p.mulAssign( lacunarity );
938
+
939
+ } );
940
+
941
+ return result;
942
+
943
+ } ).setLayout( {
944
+ name: 'mx_fractal_noise_float_2d',
945
+ type: 'float',
946
+ inputs: [
947
+ { name: 'p', type: 'vec2' },
948
+ { name: 'octaves', type: 'int' },
949
+ { name: 'lacunarity', type: 'float' },
950
+ { name: 'diminish', type: 'float' }
951
+ ]
952
+ } );
953
+
834
954
  export const mx_fractal_noise_float = /*@__PURE__*/ Fn( ( [ p_immutable, octaves_immutable, lacunarity_immutable, diminish_immutable ] ) => {
835
955
 
836
956
  const diminish = float( diminish_immutable ).toVar();
@@ -989,7 +1109,7 @@ export const mx_worley_distance_1 = /*@__PURE__*/ Fn( ( [ p_immutable, x_immutab
989
1109
  const y = int( y_immutable ).toVar();
990
1110
  const x = int( x_immutable ).toVar();
991
1111
  const p = vec3( p_immutable ).toVar();
992
- const off = vec3( mx_cell_noise_vec3( vec3( x.add( xoff ), y.add( yoff ), z.add( zoff ) ) ) ).toVar();
1112
+ const off = vec3( mx_cell_noise_vec3_3d( vec3( x.add( xoff ), y.add( yoff ), z.add( zoff ) ) ) ).toVar();
993
1113
  off.subAssign( 0.5 );
994
1114
  off.mulAssign( jitter );
995
1115
  off.addAssign( 0.5 );
@@ -1028,27 +1148,49 @@ export const mx_worley_distance_1 = /*@__PURE__*/ Fn( ( [ p_immutable, x_immutab
1028
1148
 
1029
1149
  export const mx_worley_distance = /*@__PURE__*/ overloadingFn( [ mx_worley_distance_0, mx_worley_distance_1 ] );
1030
1150
 
1031
- export const mx_worley_noise_float_0 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => {
1151
+ const mx_perlin_noise_float_scaled = ( texcoord, amplitude = 1, pivot = 0 ) => mx_perlin_noise_float( texcoord ).mul( amplitude ).add( pivot );
1032
1152
 
1033
- const metric = int( metric_immutable ).toVar();
1034
- const jitter = float( jitter_immutable ).toVar();
1035
- const p = vec2( p_immutable ).toVar();
1036
- const X = int().toVar(), Y = int().toVar();
1037
- const localpos = vec2( mx_floorfrac( p.x, X ), mx_floorfrac( p.y, Y ) ).toVar();
1153
+ export const mx_worley_noise_float_3d = /*@__PURE__*/ Fn( ( [ positionInput, jitterInput, styleInput ] ) => {
1154
+
1155
+ const position = vec3( positionInput ).toVar();
1156
+ const jitter = float( jitterInput ).toVar();
1157
+ const style = int( styleInput ).toVar();
1158
+ const X = int().toVar(), Y = int().toVar(), Z = int().toVar();
1159
+ const localpos = vec3( mx_floorfrac( position.x, X ), mx_floorfrac( position.y, Y ), mx_floorfrac( position.z, Z ) ).toVar();
1038
1160
  const sqdist = float( 1e6 ).toVar();
1161
+ const minpos = vec3( 0, 0, 0 ).toVar();
1039
1162
 
1040
1163
  Loop( { start: - 1, end: int( 1 ), name: 'x', condition: '<=' }, ( { x } ) => {
1041
1164
 
1042
1165
  Loop( { start: - 1, end: int( 1 ), name: 'y', condition: '<=' }, ( { y } ) => {
1043
1166
 
1044
- const dist = float( mx_worley_distance( localpos, x, y, X, Y, jitter, metric ) ).toVar();
1045
- sqdist.assign( min( sqdist, dist ) );
1167
+ Loop( { start: - 1, end: int( 1 ), name: 'z', condition: '<=' }, ( { z } ) => {
1168
+
1169
+ const dist = float( mx_worley_distance( localpos, x, y, z, X, Y, Z, jitter, int( 0 ) ) ).toVar();
1170
+ const off = vec3( mx_cell_noise_vec3_3d( vec3( X.add( x ), Y.add( y ), Z.add( z ) ) ) ).toVar();
1171
+ off.subAssign( 0.5 );
1172
+ off.mulAssign( jitter );
1173
+ off.addAssign( 0.5 );
1174
+ const cellpos = vec3( vec3( float( x ), float( y ), float( z ) ).add( off ).sub( localpos ) ).toVar();
1175
+
1176
+ If( dist.lessThan( sqdist ), () => {
1177
+
1178
+ sqdist.assign( dist );
1179
+ minpos.assign( cellpos );
1180
+
1181
+ } );
1182
+
1183
+ } );
1046
1184
 
1047
1185
  } );
1048
1186
 
1049
1187
  } );
1050
1188
 
1051
- If( metric.equal( int( 0 ) ), () => {
1189
+ If( style.equal( int( 1 ) ), () => {
1190
+
1191
+ sqdist.assign( mx_cell_noise_float( minpos.add( position ) ) );
1192
+
1193
+ } ).Else( () => {
1052
1194
 
1053
1195
  sqdist.assign( sqrt( sqdist ) );
1054
1196
 
@@ -1056,16 +1198,58 @@ export const mx_worley_noise_float_0 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter
1056
1198
 
1057
1199
  return sqdist;
1058
1200
 
1059
- } ).setLayout( {
1060
- name: 'mx_worley_noise_float_0',
1061
- type: 'float',
1062
- inputs: [
1063
- { name: 'p', type: 'vec2' },
1064
- { name: 'jitter', type: 'float' },
1065
- { name: 'metric', type: 'int' }
1066
- ]
1067
1201
  } );
1068
1202
 
1203
+ export const mx_worley_noise_float_2d = /*@__PURE__*/ Fn( ( [ texcoordInput, jitterInput, styleInput ] ) => {
1204
+
1205
+ const texcoord = vec2( texcoordInput ).toVar();
1206
+ const jitter = float( jitterInput ).toVar();
1207
+ const style = int( styleInput ).toVar();
1208
+ const floorPos = floor( texcoord ).toVar();
1209
+ const localpos = vec2( fract( texcoord.x ), fract( texcoord.y ) ).toVar();
1210
+ const sqdist = float( 1e6 ).toVar();
1211
+ const minpos = vec2( 0, 0 ).toVar();
1212
+
1213
+ Loop( { start: - 1, end: int( 1 ), name: 'x', condition: '<=' }, ( { x } ) => {
1214
+
1215
+ Loop( { start: - 1, end: int( 1 ), name: 'y', condition: '<=' }, ( { y } ) => {
1216
+
1217
+ const cell = vec2( float( x ), float( y ) ).toVar();
1218
+ const seed = vec2( cell.x.add( floorPos.x ), cell.y.add( floorPos.y ) ).toVar();
1219
+ const off = vec2( mx_cell_noise_float( vec3( seed.x, seed.y, 0 ) ), mx_cell_noise_float( vec3( seed.x, seed.y, 1 ) ) ).toVar();
1220
+ off.subAssign( 0.5 );
1221
+ off.mulAssign( jitter );
1222
+ off.addAssign( 0.5 );
1223
+ const cellpos = vec2( cell.add( off ).sub( localpos ) ).toVar();
1224
+ const dist = dot( cellpos, cellpos ).toVar();
1225
+
1226
+ If( dist.lessThan( sqdist ), () => {
1227
+
1228
+ sqdist.assign( dist );
1229
+ minpos.assign( cellpos );
1230
+
1231
+ } );
1232
+
1233
+ } );
1234
+
1235
+ } );
1236
+
1237
+ If( style.equal( int( 1 ) ), () => {
1238
+
1239
+ sqdist.assign( mx_cell_noise_float( minpos.add( texcoord ) ) );
1240
+
1241
+ } ).Else( () => {
1242
+
1243
+ sqdist.assign( sqrt( sqdist ) );
1244
+
1245
+ } );
1246
+
1247
+ return sqdist;
1248
+
1249
+ } );
1250
+
1251
+ export const mx_worley_noise_float = /*@__PURE__*/ overloadingFn( [ mx_worley_noise_float_2d, mx_worley_noise_float_3d ] );
1252
+
1069
1253
  export const mx_worley_noise_vec2_0 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => {
1070
1254
 
1071
1255
  const metric = int( metric_immutable ).toVar();
@@ -1168,14 +1352,14 @@ export const mx_worley_noise_vec3_0 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_
1168
1352
  ]
1169
1353
  } );
1170
1354
 
1171
- export const mx_worley_noise_float_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => {
1355
+ export const mx_worley_noise_vec2_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => {
1172
1356
 
1173
1357
  const metric = int( metric_immutable ).toVar();
1174
1358
  const jitter = float( jitter_immutable ).toVar();
1175
1359
  const p = vec3( p_immutable ).toVar();
1176
1360
  const X = int().toVar(), Y = int().toVar(), Z = int().toVar();
1177
1361
  const localpos = vec3( mx_floorfrac( p.x, X ), mx_floorfrac( p.y, Y ), mx_floorfrac( p.z, Z ) ).toVar();
1178
- const sqdist = float( 1e6 ).toVar();
1362
+ const sqdist = vec2( 1e6, 1e6 ).toVar();
1179
1363
 
1180
1364
  Loop( { start: - 1, end: int( 1 ), name: 'x', condition: '<=' }, ( { x } ) => {
1181
1365
 
@@ -1184,7 +1368,17 @@ export const mx_worley_noise_float_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter
1184
1368
  Loop( { start: - 1, end: int( 1 ), name: 'z', condition: '<=' }, ( { z } ) => {
1185
1369
 
1186
1370
  const dist = float( mx_worley_distance( localpos, x, y, z, X, Y, Z, jitter, metric ) ).toVar();
1187
- sqdist.assign( min( sqdist, dist ) );
1371
+
1372
+ If( dist.lessThan( sqdist.x ), () => {
1373
+
1374
+ sqdist.y.assign( sqdist.x );
1375
+ sqdist.x.assign( dist );
1376
+
1377
+ } ).ElseIf( dist.lessThan( sqdist.y ), () => {
1378
+
1379
+ sqdist.y.assign( dist );
1380
+
1381
+ } );
1188
1382
 
1189
1383
  } );
1190
1384
 
@@ -1201,8 +1395,8 @@ export const mx_worley_noise_float_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter
1201
1395
  return sqdist;
1202
1396
 
1203
1397
  } ).setLayout( {
1204
- name: 'mx_worley_noise_float_1',
1205
- type: 'float',
1398
+ name: 'mx_worley_noise_vec2_1',
1399
+ type: 'vec2',
1206
1400
  inputs: [
1207
1401
  { name: 'p', type: 'vec3' },
1208
1402
  { name: 'jitter', type: 'float' },
@@ -1210,16 +1404,16 @@ export const mx_worley_noise_float_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter
1210
1404
  ]
1211
1405
  } );
1212
1406
 
1213
- export const mx_worley_noise_float = /*@__PURE__*/ overloadingFn( [ mx_worley_noise_float_0, mx_worley_noise_float_1 ] );
1407
+ export const mx_worley_noise_vec2 = /*@__PURE__*/ overloadingFn( [ mx_worley_noise_vec2_0, mx_worley_noise_vec2_1 ] );
1214
1408
 
1215
- export const mx_worley_noise_vec2_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => {
1409
+ export const mx_worley_noise_vec3_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => {
1216
1410
 
1217
1411
  const metric = int( metric_immutable ).toVar();
1218
1412
  const jitter = float( jitter_immutable ).toVar();
1219
1413
  const p = vec3( p_immutable ).toVar();
1220
1414
  const X = int().toVar(), Y = int().toVar(), Z = int().toVar();
1221
1415
  const localpos = vec3( mx_floorfrac( p.x, X ), mx_floorfrac( p.y, Y ), mx_floorfrac( p.z, Z ) ).toVar();
1222
- const sqdist = vec2( 1e6, 1e6 ).toVar();
1416
+ const sqdist = vec3( 1e6, 1e6, 1e6 ).toVar();
1223
1417
 
1224
1418
  Loop( { start: - 1, end: int( 1 ), name: 'x', condition: '<=' }, ( { x } ) => {
1225
1419
 
@@ -1231,13 +1425,19 @@ export const mx_worley_noise_vec2_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_
1231
1425
 
1232
1426
  If( dist.lessThan( sqdist.x ), () => {
1233
1427
 
1428
+ sqdist.z.assign( sqdist.y );
1234
1429
  sqdist.y.assign( sqdist.x );
1235
1430
  sqdist.x.assign( dist );
1236
1431
 
1237
1432
  } ).ElseIf( dist.lessThan( sqdist.y ), () => {
1238
1433
 
1434
+ sqdist.z.assign( sqdist.y );
1239
1435
  sqdist.y.assign( dist );
1240
1436
 
1437
+ } ).ElseIf( dist.lessThan( sqdist.z ), () => {
1438
+
1439
+ sqdist.z.assign( dist );
1440
+
1241
1441
  } );
1242
1442
 
1243
1443
  } );
@@ -1255,8 +1455,8 @@ export const mx_worley_noise_vec2_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_
1255
1455
  return sqdist;
1256
1456
 
1257
1457
  } ).setLayout( {
1258
- name: 'mx_worley_noise_vec2_1',
1259
- type: 'vec2',
1458
+ name: 'mx_worley_noise_vec3_1',
1459
+ type: 'vec3',
1260
1460
  inputs: [
1261
1461
  { name: 'p', type: 'vec3' },
1262
1462
  { name: 'jitter', type: 'float' },
@@ -1264,16 +1464,72 @@ export const mx_worley_noise_vec2_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_
1264
1464
  ]
1265
1465
  } );
1266
1466
 
1267
- export const mx_worley_noise_vec2 = /*@__PURE__*/ overloadingFn( [ mx_worley_noise_vec2_0, mx_worley_noise_vec2_1 ] );
1467
+ export const mx_worley_noise_vec3 = /*@__PURE__*/ overloadingFn( [ mx_worley_noise_vec3_0, mx_worley_noise_vec3_1 ] );
1268
1468
 
1269
- export const mx_worley_noise_vec3_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => {
1469
+ export const mx_worley_noise_vec3_style_0 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, style_immutable, metric_immutable ] ) => {
1270
1470
 
1271
1471
  const metric = int( metric_immutable ).toVar();
1472
+ const style = int( style_immutable ).toVar();
1473
+ const jitter = float( jitter_immutable ).toVar();
1474
+ const p = vec2( p_immutable ).toVar();
1475
+ const X = int().toVar(), Y = int().toVar();
1476
+ const localpos = vec2( mx_floorfrac( p.x, X ), mx_floorfrac( p.y, Y ) ).toVar();
1477
+ const sqdist = float( 1e6 ).toVar();
1478
+ const minpos = vec2( 0, 0 ).toVar();
1479
+
1480
+ Loop( { start: - 1, end: int( 1 ), name: 'x', condition: '<=' }, ( { x } ) => {
1481
+
1482
+ Loop( { start: - 1, end: int( 1 ), name: 'y', condition: '<=' }, ( { y } ) => {
1483
+
1484
+ const dist = float( mx_worley_distance( localpos, x, y, X, Y, jitter, metric ) ).toVar();
1485
+ const tmp = vec3( mx_cell_noise_vec3( vec2( X.add( x ), Y.add( y ) ) ) ).toVar();
1486
+ const off = vec2( tmp.x, tmp.y ).toVar();
1487
+ off.subAssign( 0.5 );
1488
+ off.mulAssign( jitter );
1489
+ off.addAssign( 0.5 );
1490
+ const cellpos = vec2( vec2( float( x ), float( y ) ).add( off ).sub( localpos ) ).toVar();
1491
+
1492
+ If( dist.lessThan( sqdist ), () => {
1493
+
1494
+ sqdist.assign( dist );
1495
+ minpos.assign( cellpos );
1496
+
1497
+ } );
1498
+
1499
+ } );
1500
+
1501
+ } );
1502
+
1503
+ const result = vec3( mx_worley_noise_vec3( p, jitter, metric ) ).toVar();
1504
+ If( style.equal( int( 1 ) ), () => {
1505
+
1506
+ result.assign( mx_cell_noise_vec3( minpos.add( p ) ) );
1507
+
1508
+ } );
1509
+
1510
+ return result;
1511
+
1512
+ } ).setLayout( {
1513
+ name: 'mx_worley_noise_vec3_style_0',
1514
+ type: 'vec3',
1515
+ inputs: [
1516
+ { name: 'p', type: 'vec2' },
1517
+ { name: 'jitter', type: 'float' },
1518
+ { name: 'style', type: 'int' },
1519
+ { name: 'metric', type: 'int' }
1520
+ ]
1521
+ } );
1522
+
1523
+ export const mx_worley_noise_vec3_style_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, style_immutable, metric_immutable ] ) => {
1524
+
1525
+ const metric = int( metric_immutable ).toVar();
1526
+ const style = int( style_immutable ).toVar();
1272
1527
  const jitter = float( jitter_immutable ).toVar();
1273
1528
  const p = vec3( p_immutable ).toVar();
1274
1529
  const X = int().toVar(), Y = int().toVar(), Z = int().toVar();
1275
1530
  const localpos = vec3( mx_floorfrac( p.x, X ), mx_floorfrac( p.y, Y ), mx_floorfrac( p.z, Z ) ).toVar();
1276
- const sqdist = vec3( 1e6, 1e6, 1e6 ).toVar();
1531
+ const sqdist = float( 1e6 ).toVar();
1532
+ const minpos = vec3( 0, 0, 0 ).toVar();
1277
1533
 
1278
1534
  Loop( { start: - 1, end: int( 1 ), name: 'x', condition: '<=' }, ( { x } ) => {
1279
1535
 
@@ -1282,21 +1538,16 @@ export const mx_worley_noise_vec3_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_
1282
1538
  Loop( { start: - 1, end: int( 1 ), name: 'z', condition: '<=' }, ( { z } ) => {
1283
1539
 
1284
1540
  const dist = float( mx_worley_distance( localpos, x, y, z, X, Y, Z, jitter, metric ) ).toVar();
1541
+ const off = vec3( mx_cell_noise_vec3_3d( vec3( X.add( x ), Y.add( y ), Z.add( z ) ) ) ).toVar();
1542
+ off.subAssign( 0.5 );
1543
+ off.mulAssign( jitter );
1544
+ off.addAssign( 0.5 );
1545
+ const cellpos = vec3( vec3( float( x ), float( y ), float( z ) ).add( off ).sub( localpos ) ).toVar();
1285
1546
 
1286
- If( dist.lessThan( sqdist.x ), () => {
1287
-
1288
- sqdist.z.assign( sqdist.y );
1289
- sqdist.y.assign( sqdist.x );
1290
- sqdist.x.assign( dist );
1547
+ If( dist.lessThan( sqdist ), () => {
1291
1548
 
1292
- } ).ElseIf( dist.lessThan( sqdist.y ), () => {
1293
-
1294
- sqdist.z.assign( sqdist.y );
1295
- sqdist.y.assign( dist );
1296
-
1297
- } ).ElseIf( dist.lessThan( sqdist.z ), () => {
1298
-
1299
- sqdist.z.assign( dist );
1549
+ sqdist.assign( dist );
1550
+ minpos.assign( cellpos );
1300
1551
 
1301
1552
  } );
1302
1553
 
@@ -1306,186 +1557,164 @@ export const mx_worley_noise_vec3_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_
1306
1557
 
1307
1558
  } );
1308
1559
 
1309
- If( metric.equal( int( 0 ) ), () => {
1560
+ const result = vec3( mx_worley_noise_vec3( p, jitter, metric ) ).toVar();
1561
+ If( style.equal( int( 1 ) ), () => {
1310
1562
 
1311
- sqdist.assign( sqrt( sqdist ) );
1563
+ result.assign( mx_cell_noise_vec3_3d( minpos.add( p ) ) );
1312
1564
 
1313
1565
  } );
1314
1566
 
1315
- return sqdist;
1567
+ return result;
1316
1568
 
1317
1569
  } ).setLayout( {
1318
- name: 'mx_worley_noise_vec3_1',
1570
+ name: 'mx_worley_noise_vec3_style_1',
1319
1571
  type: 'vec3',
1320
1572
  inputs: [
1321
1573
  { name: 'p', type: 'vec3' },
1322
1574
  { name: 'jitter', type: 'float' },
1575
+ { name: 'style', type: 'int' },
1323
1576
  { name: 'metric', type: 'int' }
1324
1577
  ]
1325
1578
  } );
1326
1579
 
1327
- export const mx_worley_noise_vec3 = /*@__PURE__*/ overloadingFn( [ mx_worley_noise_vec3_0, mx_worley_noise_vec3_1 ] );
1580
+ export const mx_worley_noise_vec3_style = /*@__PURE__*/ overloadingFn( [ mx_worley_noise_vec3_style_0, mx_worley_noise_vec3_style_1 ] );
1328
1581
 
1329
1582
  // Unified Noise 2D
1330
1583
  export const mx_unifiednoise2d = /*@__PURE__*/ Fn( ( [
1331
- noiseType_immutable, texcoord_immutable, freq_immutable, offset_immutable,
1332
- jitter_immutable, outmin_immutable, outmax_immutable, clampoutput_immutable,
1333
- octaves_immutable, lacunarity_immutable, diminish_immutable
1584
+ noiseTypeInput,
1585
+ texcoordInput,
1586
+ freqInput,
1587
+ offsetInput,
1588
+ jitterInput,
1589
+ outminInput,
1590
+ outmaxInput,
1591
+ clampoutputInput,
1592
+ octavesInput,
1593
+ lacunarityInput,
1594
+ diminishInput,
1595
+ styleInput
1334
1596
  ] ) => {
1335
1597
 
1336
- const noiseType = int( noiseType_immutable ).toVar();
1337
- const texcoord = vec2( texcoord_immutable ).toVar();
1338
- const freq = vec2( freq_immutable ).toVar();
1339
- const offset = vec2( offset_immutable ).toVar();
1340
- const jitter = float( jitter_immutable ).toVar();
1341
- const outmin = float( outmin_immutable ).toVar();
1342
- const outmax = float( outmax_immutable ).toVar();
1343
- const clampoutput = bool( clampoutput_immutable ).toVar();
1344
- const octaves = int( octaves_immutable ).toVar();
1345
- const lacunarity = float( lacunarity_immutable ).toVar();
1346
- const diminish = float( diminish_immutable ).toVar();
1347
-
1348
- // Compute input position
1349
- const p = texcoord.mul( freq ).add( offset );
1350
-
1351
- const result = float( 0.0 ).toVar();
1598
+ const noiseType = int( noiseTypeInput ).toVar();
1599
+ const texcoord = vec2( texcoordInput ).toVar();
1600
+ const freq = vec2( freqInput ).toVar();
1601
+ const offset = vec2( offsetInput ).toVar();
1602
+ const jitter = float( jitterInput ).toVar();
1603
+ const outmin = float( outminInput ).toVar();
1604
+ const outmax = float( outmaxInput ).toVar();
1605
+ const clampoutput = float( clampoutputInput ).toVar();
1606
+ const octaves = int( octavesInput ).toVar();
1607
+ const lacunarity = float( lacunarityInput ).toVar();
1608
+ const diminish = float( diminishInput ).toVar();
1609
+ const style = int( styleInput ).toVar();
1610
+
1611
+ const applyFreq = mul( texcoord, freq ).toVar();
1612
+ const applyOffset = add( applyFreq, offset ).toVar();
1613
+ const cellJitterMult = mul( sub( jitter, 1 ), 90000 ).toVar();
1614
+ const applyCellJitter = mx_rotate2d( applyOffset, cellJitterMult ).toVar();
1615
+ const fractalInput = vec3( applyOffset.x, applyOffset.y, cellJitterMult ).toVar();
1616
+ const result = float( 0 ).toVar();
1352
1617
 
1353
- // Perlin
1354
1618
  If( noiseType.equal( int( 0 ) ), () => {
1355
1619
 
1356
- result.assign( mx_perlin_noise_vec3( p ) );
1620
+ result.assign( mx_perlin_noise_float_scaled( applyCellJitter, 0.5, 0.5 ) );
1357
1621
 
1358
1622
  } );
1359
-
1360
- // Cell
1361
1623
  If( noiseType.equal( int( 1 ) ), () => {
1362
1624
 
1363
- result.assign( mx_cell_noise_vec3( p ) );
1625
+ result.assign( mx_cell_noise_float( applyCellJitter ) );
1364
1626
 
1365
1627
  } );
1366
-
1367
- // Worley (metric=0 = euclidean)
1368
1628
  If( noiseType.equal( int( 2 ) ), () => {
1369
1629
 
1370
- result.assign( mx_worley_noise_vec3( p, jitter, int( 0 ) ) );
1630
+ result.assign( mx_worley_noise_float_2d( applyOffset, jitter, style ) );
1371
1631
 
1372
1632
  } );
1373
-
1374
- // Fractal (use vec3(p, 0.0) for 2D input)
1375
1633
  If( noiseType.equal( int( 3 ) ), () => {
1376
1634
 
1377
- result.assign( mx_fractal_noise_vec3( vec3( p, 0.0 ), octaves, lacunarity, diminish ) );
1635
+ result.assign( mx_fractal_noise_float( fractalInput, octaves, lacunarity, diminish ) );
1378
1636
 
1379
1637
  } );
1380
1638
 
1381
- // Remap output to [outmin, outmax]
1382
- result.assign( result.mul( outmax.sub( outmin ) ).add( outmin ) );
1639
+ const ranged = add( outmin, mul( result, sub( outmax, outmin ) ) ).toVar();
1640
+ const clamped = clamp( ranged, outmin, outmax ).toVar();
1641
+ const output = ranged.toVar();
1383
1642
 
1384
- // Clamp if requested
1385
- If( clampoutput, () => {
1643
+ If( clampoutput.equal( float( 1 ) ), () => {
1386
1644
 
1387
- result.assign( clamp( result, outmin, outmax ) );
1645
+ output.assign( clamped );
1388
1646
 
1389
1647
  } );
1390
1648
 
1391
- return result;
1649
+ return output;
1392
1650
 
1393
- } ).setLayout( {
1394
- name: 'mx_unifiednoise2d',
1395
- type: 'float',
1396
- inputs: [
1397
- { name: 'noiseType', type: 'int' },
1398
- { name: 'texcoord', type: 'vec2' },
1399
- { name: 'freq', type: 'vec2' },
1400
- { name: 'offset', type: 'vec2' },
1401
- { name: 'jitter', type: 'float' },
1402
- { name: 'outmin', type: 'float' },
1403
- { name: 'outmax', type: 'float' },
1404
- { name: 'clampoutput', type: 'bool' },
1405
- { name: 'octaves', type: 'int' },
1406
- { name: 'lacunarity', type: 'float' },
1407
- { name: 'diminish', type: 'float' }
1408
- ]
1409
1651
  } );
1410
1652
 
1411
1653
  // Unified Noise 3D
1412
1654
  export const mx_unifiednoise3d = /*@__PURE__*/ Fn( ( [
1413
- noiseType_immutable, position_immutable, freq_immutable, offset_immutable,
1414
- jitter_immutable, outmin_immutable, outmax_immutable, clampoutput_immutable,
1415
- octaves_immutable, lacunarity_immutable, diminish_immutable
1655
+ noiseTypeInput,
1656
+ positionInput,
1657
+ freqInput,
1658
+ offsetInput,
1659
+ jitterInput,
1660
+ outminInput,
1661
+ outmaxInput,
1662
+ clampoutputInput,
1663
+ octavesInput,
1664
+ lacunarityInput,
1665
+ diminishInput,
1666
+ styleInput
1416
1667
  ] ) => {
1417
1668
 
1418
- const noiseType = int( noiseType_immutable ).toVar();
1419
- const position = vec3( position_immutable ).toVar();
1420
- const freq = vec3( freq_immutable ).toVar();
1421
- const offset = vec3( offset_immutable ).toVar();
1422
- const jitter = float( jitter_immutable ).toVar();
1423
- const outmin = float( outmin_immutable ).toVar();
1424
- const outmax = float( outmax_immutable ).toVar();
1425
- const clampoutput = bool( clampoutput_immutable ).toVar();
1426
- const octaves = int( octaves_immutable ).toVar();
1427
- const lacunarity = float( lacunarity_immutable ).toVar();
1428
- const diminish = float( diminish_immutable ).toVar();
1429
-
1430
- // Compute input position
1431
- const p = position.mul( freq ).add( offset );
1432
-
1433
- const result = float( 0.0 ).toVar();
1434
-
1435
- // Perlin
1436
- If( noiseType.equal( int( 0 ) ), () => {
1437
-
1438
- result.assign( mx_perlin_noise_vec3( p ) );
1439
-
1440
- } );
1669
+ const noiseType = int( noiseTypeInput ).toVar();
1670
+ const position = vec3( positionInput ).toVar();
1671
+ const freq = vec3( freqInput ).toVar();
1672
+ const offset = vec3( offsetInput ).toVar();
1673
+ const jitter = float( jitterInput ).toVar();
1674
+ const outmin = float( outminInput ).toVar();
1675
+ const outmax = float( outmaxInput ).toVar();
1676
+ const clampoutput = float( clampoutputInput ).toVar();
1677
+ const octaves = int( octavesInput ).toVar();
1678
+ const lacunarity = float( lacunarityInput ).toVar();
1679
+ const diminish = float( diminishInput ).toVar();
1680
+ const style = int( styleInput ).toVar();
1681
+
1682
+ const applyFreq = mul( position, freq ).toVar();
1683
+ const applyOffset = add( applyFreq, offset ).toVar();
1684
+ const cellJitterMult = mul( sub( jitter, 1 ), 90000 ).toVar();
1685
+ const applyCellJitter = mx_rotate3d( applyOffset, cellJitterMult, vec3( 0.1, 1, 0 ) ).toVar();
1686
+ const perlin = mx_perlin_noise_float_scaled( applyCellJitter, 0.5, 0.5 );
1687
+ const cell = mx_cell_noise_float( applyCellJitter );
1688
+ const worley = mx_worley_noise_float_3d( applyOffset, jitter, style );
1689
+ const fractal = mx_fractal_noise_float( applyCellJitter, octaves, lacunarity, diminish );
1690
+ const result = perlin.toVar();
1441
1691
 
1442
- // Cell
1443
1692
  If( noiseType.equal( int( 1 ) ), () => {
1444
1693
 
1445
- result.assign( mx_cell_noise_vec3( p ) );
1694
+ result.assign( cell );
1446
1695
 
1447
1696
  } );
1448
-
1449
- // Worley (metric=0 = euclidean)
1450
1697
  If( noiseType.equal( int( 2 ) ), () => {
1451
1698
 
1452
- result.assign( mx_worley_noise_vec3( p, jitter, int( 0 ) ) );
1699
+ result.assign( worley );
1453
1700
 
1454
1701
  } );
1455
-
1456
- // Fractal
1457
1702
  If( noiseType.equal( int( 3 ) ), () => {
1458
1703
 
1459
- result.assign( mx_fractal_noise_vec3( p, octaves, lacunarity, diminish ) );
1704
+ result.assign( fractal );
1460
1705
 
1461
1706
  } );
1462
1707
 
1463
- // Remap output to [outmin, outmax]
1464
- result.assign( result.mul( outmax.sub( outmin ) ).add( outmin ) );
1708
+ const ranged = add( outmin, mul( result, sub( outmax, outmin ) ) ).toVar();
1709
+ const clamped = clamp( ranged, outmin, outmax ).toVar();
1710
+ const output = ranged.toVar();
1465
1711
 
1466
- // Clamp if requested
1467
- If( clampoutput, () => {
1712
+ If( clampoutput.equal( float( 1 ) ), () => {
1468
1713
 
1469
- result.assign( clamp( result, outmin, outmax ) );
1714
+ output.assign( clamped );
1470
1715
 
1471
1716
  } );
1472
1717
 
1473
- return result;
1718
+ return output;
1474
1719
 
1475
- } ).setLayout( {
1476
- name: 'mx_unifiednoise3d',
1477
- type: 'float',
1478
- inputs: [
1479
- { name: 'noiseType', type: 'int' },
1480
- { name: 'position', type: 'vec3' },
1481
- { name: 'freq', type: 'vec3' },
1482
- { name: 'offset', type: 'vec3' },
1483
- { name: 'jitter', type: 'float' },
1484
- { name: 'outmin', type: 'float' },
1485
- { name: 'outmax', type: 'float' },
1486
- { name: 'clampoutput', type: 'bool' },
1487
- { name: 'octaves', type: 'int' },
1488
- { name: 'lacunarity', type: 'float' },
1489
- { name: 'diminish', type: 'float' }
1490
- ]
1491
1720
  } );