@gnsx/three 0.185.16 → 0.186.1

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 (417) hide show
  1. package/build/three.cjs +10 -82600
  2. package/build/three.core.js +1303 -728
  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/build/three.core.min.js +0 -6
  411. package/build/three.module.min.js +0 -6
  412. package/build/three.tsl.min.js +0 -6
  413. package/build/three.webgpu.min.js +0 -6
  414. package/build/three.webgpu.nodes.min.js +0 -6
  415. package/examples/jsm/libs/ecsy.module.js +0 -1792
  416. package/examples/jsm/loaders/LottieLoader.js +0 -130
  417. package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +0 -52
@@ -25,9 +25,9 @@ import {
25
25
  * sky.scale.setScalar( 10000 );
26
26
  * scene.add( sky );
27
27
  * ```
28
- *
28
+ *
29
29
  * It can be useful to hide the sun disc when generating an environment map to avoid artifacts
30
- *
30
+ *
31
31
  * ```js
32
32
  * // disable before rendering environment map
33
33
  * sky.material.uniforms.showSunDisc.value = false;
@@ -82,9 +82,8 @@ Sky.SkyShader = {
82
82
  'mieCoefficient': { value: 0.005 },
83
83
  'mieDirectionalG': { value: 0.8 },
84
84
  'sunPosition': { value: new Vector3() },
85
- 'up': { value: new Vector3( 0, 1, 0 ) },
86
85
  'cloudScale': { value: 0.0002 },
87
- 'cloudSpeed': { value: 0.0001 },
86
+ 'cloudSpeed': { value: 0.00002 },
88
87
  'cloudCoverage': { value: 0.4 },
89
88
  'cloudDensity': { value: 0.4 },
90
89
  'cloudElevation': { value: 0.5 },
@@ -97,7 +96,6 @@ Sky.SkyShader = {
97
96
  uniform float rayleigh;
98
97
  uniform float turbidity;
99
98
  uniform float mieCoefficient;
100
- uniform vec3 up;
101
99
 
102
100
  varying vec3 vWorldPosition;
103
101
  varying vec3 vSunDirection;
@@ -149,7 +147,7 @@ Sky.SkyShader = {
149
147
 
150
148
  vSunDirection = normalize( sunPosition );
151
149
 
152
- vSunE = sunIntensity( dot( vSunDirection, up ) );
150
+ vSunE = sunIntensity( vSunDirection.y );
153
151
 
154
152
  vSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );
155
153
 
@@ -172,7 +170,6 @@ Sky.SkyShader = {
172
170
  varying float vSunE;
173
171
 
174
172
  uniform float mieDirectionalG;
175
- uniform vec3 up;
176
173
  uniform float cloudScale;
177
174
  uniform float cloudSpeed;
178
175
  uniform float cloudCoverage;
@@ -181,31 +178,35 @@ Sky.SkyShader = {
181
178
  uniform float showSunDisc;
182
179
  uniform float time;
183
180
 
184
- // Cloud noise functions
185
- float hash( vec2 p ) {
186
- return fract( sin( dot( p, vec2( 127.1, 311.7 ) ) ) * 43758.5453123 );
181
+ // gradient at a lattice corner; sinless hash so every GPU produces the same clouds
182
+ vec2 gradient( vec2 i ) {
183
+ vec3 p = fract( i.xyx * vec3( 0.1031, 0.1030, 0.0973 ) );
184
+ p += dot( p, p.yzx + 33.33 );
185
+ return fract( ( p.xx + p.yz ) * p.zy ) * 2.0 - 1.0;
187
186
  }
188
187
 
188
+ // 2D gradient noise: isotropic lobes like Perlin at value-noise cost
189
189
  float noise( vec2 p ) {
190
190
  vec2 i = floor( p );
191
191
  vec2 f = fract( p );
192
- f = f * f * ( 3.0 - 2.0 * f );
193
- float a = hash( i );
194
- float b = hash( i + vec2( 1.0, 0.0 ) );
195
- float c = hash( i + vec2( 0.0, 1.0 ) );
196
- float d = hash( i + vec2( 1.0, 1.0 ) );
197
- return mix( mix( a, b, f.x ), mix( c, d, f.x ), f.y );
192
+ vec2 u = f * f * f * ( f * ( f * 6.0 - 15.0 ) + 10.0 ); // quintic fade
193
+ float a = dot( gradient( i ), f );
194
+ float b = dot( gradient( i + vec2( 1.0, 0.0 ) ), f - vec2( 1.0, 0.0 ) );
195
+ float c = dot( gradient( i + vec2( 0.0, 1.0 ) ), f - vec2( 0.0, 1.0 ) );
196
+ float d = dot( gradient( i + vec2( 1.0, 1.0 ) ), f - vec2( 1.0, 1.0 ) );
197
+ return mix( mix( a, b, u.x ), mix( c, d, u.x ), u.y ) * 1.6; // ~[-1,1]
198
198
  }
199
199
 
200
- float fbm( vec2 p ) {
201
- float value = 0.0;
202
- float amplitude = 0.5;
203
- for ( int i = 0; i < 5; i ++ ) {
204
- value += amplitude * noise( p );
205
- p *= 2.0;
200
+ // fbm; per-octave drift makes clouds billow instead of scrolling as a rigid stamp
201
+ float fbm( vec2 p, float drift ) {
202
+ float result = 0.0;
203
+ float amplitude = 1.0;
204
+ for ( int i = 0; i < 4; i ++ ) {
205
+ result += amplitude * noise( p );
206
206
  amplitude *= 0.5;
207
+ p = p * 2.0 + drift;
207
208
  }
208
- return value;
209
+ return result;
209
210
  }
210
211
 
211
212
  // constants for atmospheric scattering
@@ -241,7 +242,7 @@ Sky.SkyShader = {
241
242
 
242
243
  // optical length
243
244
  // cutoff angle at 90 to avoid singularity in next formula.
244
- float zenithAngle = acos( max( 0.0, dot( up, direction ) ) );
245
+ float zenithAngle = acos( max( 0.0, direction.y ) );
245
246
  float inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );
246
247
  float sR = rayleighZenithLength * inverse;
247
248
  float sM = mieZenithLength * inverse;
@@ -259,7 +260,7 @@ Sky.SkyShader = {
259
260
  vec3 betaMTheta = vBetaM * mPhase;
260
261
 
261
262
  vec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );
262
- Lin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );
263
+ Lin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - vSunDirection.y, 5.0 ), 0.0, 1.0 ) );
263
264
 
264
265
  // nightsky
265
266
  float theta = acos( direction.y ); // elevation --> y-axis, [-pi/2, pi/2]
@@ -268,10 +269,10 @@ Sky.SkyShader = {
268
269
  vec3 L0 = vec3( 0.1 ) * Fex;
269
270
 
270
271
  // composition + solar disc
271
- float sundisc = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta ) * showSunDisc;
272
- L0 += ( vSunE * 19000.0 * Fex ) * sundisc;
272
+ float sundisc = clamp( ( cosTheta - sunAngularDiameterCos ) * 50000.0, 0.0, 1.0 ) * showSunDisc;
273
+ vec3 sundiscColor = ( 760.0 * sundisc ) * min( vSunE * Fex, 80.0 );
273
274
 
274
- vec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );
275
+ vec3 texColor = ( Lin + L0 ) * 0.04 + sundiscColor + vec3( 0.0, 0.0003, 0.00075 );
275
276
 
276
277
  // Clouds
277
278
  if ( direction.y > 0.0 && cloudCoverage > 0.0 ) {
@@ -282,30 +283,50 @@ Sky.SkyShader = {
282
283
  cloudUV *= cloudScale;
283
284
  cloudUV += time * cloudSpeed;
284
285
 
285
- // Multi-octave noise for fluffy clouds
286
- float cloudNoise = fbm( cloudUV * 1000.0 );
287
- cloudNoise += 0.5 * fbm( cloudUV * 2000.0 + 3.7 );
288
- cloudNoise = cloudNoise * 0.5 + 0.5;
286
+ // Cloud density field
287
+ float evolve = time * cloudSpeed * 300.0;
288
+ float cloudNoise = clamp( fbm( cloudUV * 1000.0, evolve ) * 0.7 + 0.5, 0.0, 1.0 );
289
289
 
290
- // Apply coverage threshold
291
- float cloudMask = smoothstep( 1.0 - cloudCoverage, 1.0 - cloudCoverage + 0.3, cloudNoise );
290
+ // Large-scale coverage variation: clear gaps next to dense banks
291
+ float region = noise( cloudUV * 300.0 ) * 0.37 + 0.5;
292
+ float cov = clamp( cloudCoverage + ( region - 0.5 ) * 0.6, 0.0, 1.0 );
293
+
294
+ // Carve clouds where noise rises above the coverage level
295
+ float threshold = 1.0 - cov;
296
+ float cloudMask = smoothstep( threshold, threshold + 0.3, cloudNoise );
292
297
 
293
298
  // Fade clouds near horizon (adjusted by elevation)
294
- float horizonFade = smoothstep( 0.0, 0.1 + 0.2 * cloudElevation, direction.y );
299
+ float horizonFade = smoothstep( 0.0, 0.03 + 0.06 * cloudElevation, direction.y );
295
300
  cloudMask *= horizonFade;
296
301
 
297
- // Cloud lighting based on sun position
298
- float sunInfluence = dot( direction, vSunDirection ) * 0.5 + 0.5;
299
- float daylight = max( 0.0, vSunDirection.y * 2.0 );
302
+ // Cloud lighting from the sky's own radiance
303
+ float dayFactor = smoothstep( -0.08, 0.3, vSunDirection.y );
304
+ vec3 sunColor = vSunE * Fex * 0.22 * 0.04; // 0.22 ~ albedo/pi, 0.04 = exposure; the aerial composite adds the eye-leg extinction
305
+ vec3 skyAmbient = Lin * 0.04 + vec3( 0.0, 0.0003, 0.00075 );
306
+
307
+ // Beer-powder self-shadow from the sampled density
308
+ float depth = max( 0.0, cloudNoise - threshold );
309
+ float beer = exp( depth * -4.0 );
310
+ float powder = 1.0 - beer * beer; // beer*beer == exp(-8*depth)
311
+ float shade = mix( 0.45, 1.0, clamp( beer * powder * 2.6, 0.0, 1.0 ) ); // 2.6 = 1/0.385, normalizes beer*powder peak to 1
312
+
313
+ // Henyey-Greenstein forward lobe ( g = 0.7 ): silver lining on rims toward the sun
314
+ float silver = clamp( 0.51 / pow( 1.49 - cosTheta * 1.4, 1.5 ), 0.0, 3.0 ); // 0.51=1-g^2, 1.49=1+g^2, 1.4=2g
315
+ float edge = cloudMask * ( 1.0 - cloudMask ) * 4.0;
316
+
317
+ vec3 cloudColor = skyAmbient + sunColor * shade;
318
+ cloudColor += sunColor * silver * edge * 0.6;
319
+ cloudColor *= max( dayFactor, 0.03 );
320
+
321
+ // Cloud opacity via Beer's law: density sets how solid the clouds get
322
+ float alpha = ( 1.0 - exp( depth * cloudDensity * -12.0 ) ) * horizonFade;
300
323
 
301
- // Base cloud color affected by atmosphere
302
- vec3 atmosphereColor = Lin * 0.04;
303
- vec3 cloudColor = mix( vec3( 0.3 ), vec3( 1.0 ), daylight );
304
- cloudColor = mix( cloudColor, atmosphereColor + vec3( 1.0 ), sunInfluence * 0.5 );
305
- cloudColor *= vSunE * 0.00002;
324
+ // Occlude the sun disc/glow behind opaque cloud
325
+ texColor -= L0 * 0.04 * alpha;
306
326
 
307
- // Blend clouds with sky
308
- texColor = mix( texColor, cloudColor, cloudMask * cloudDensity );
327
+ // Composite through the atmosphere so distant clouds dissolve into haze
328
+ vec3 cloudAerial = mix( texColor, cloudColor, Fex );
329
+ texColor = mix( texColor, cloudAerial, alpha );
309
330
 
310
331
  }
311
332
 
@@ -6,7 +6,7 @@ import {
6
6
  NodeMaterial
7
7
  } from '@gnsx/three/webgpu';
8
8
 
9
- import { Fn, float, vec2, vec3, acos, add, mul, clamp, cos, dot, exp, max, mix, modelViewProjection, normalize, positionWorld, pow, smoothstep, sub, varyingProperty, vec4, uniform, cameraPosition, fract, floor, sin, time, Loop, If } from '@gnsx/three/tsl';
9
+ import { Fn, float, floor, fract, vec2, vec3, acos, add, mul, clamp, cos, dot, exp, max, min, mix, modelViewProjection, normalize, positionWorld, pow, smoothstep, sub, varyingProperty, vec4, uniform, cameraPosition, time, If, Loop } from '@gnsx/three/tsl';
10
10
 
11
11
  /**
12
12
  * Represents a skydome for scene backgrounds. Based on [A Practical Analytic Model for Daylight](https://www.researchgate.net/publication/220720443_A_Practical_Analytic_Model_for_Daylight)
@@ -27,7 +27,7 @@ import { Fn, float, vec2, vec3, acos, add, mul, clamp, cos, dot, exp, max, mix,
27
27
  * ```
28
28
  *
29
29
  * It can be useful to hide the sun disc when generating an environment map to avoid artifacts
30
- *
30
+ *
31
31
  * ```js
32
32
  * // disable before rendering environment map
33
33
  * sky.showSunDisc.value = false;
@@ -85,13 +85,6 @@ class SkyMesh extends Mesh {
85
85
  */
86
86
  this.sunPosition = uniform( new Vector3() );
87
87
 
88
- /**
89
- * The up position.
90
- *
91
- * @type {UniformNode<vec3>}
92
- */
93
- this.upUniform = uniform( new Vector3( 0, 1, 0 ) );
94
-
95
88
  /**
96
89
  * The cloud scale uniform.
97
90
  *
@@ -104,7 +97,7 @@ class SkyMesh extends Mesh {
104
97
  *
105
98
  * @type {UniformNode<float>}
106
99
  */
107
- this.cloudSpeed = uniform( 0.0001 );
100
+ this.cloudSpeed = uniform( 0.00002 );
108
101
 
109
102
  /**
110
103
  * The cloud coverage uniform.
@@ -192,7 +185,7 @@ class SkyMesh extends Mesh {
192
185
 
193
186
  // varying sun intensity
194
187
 
195
- const angle = dot( sunDirection, this.upUniform );
188
+ const angle = sunDirection.y;
196
189
  const zenithAngleCos = clamp( angle, - 1, 1 );
197
190
  const sunIntensity = EE.mul( max( 0.0, float( 1.0 ).sub( pow( e, cutoffAngle.sub( acos( zenithAngleCos ) ).div( steepness ).negate() ) ) ) );
198
191
  vSunE.assign( sunIntensity );
@@ -247,7 +240,7 @@ class SkyMesh extends Mesh {
247
240
 
248
241
  // optical length
249
242
  // cutoff angle at 90 to avoid singularity in next formula.
250
- const zenithAngle = acos( max( 0.0, dot( this.upUniform, direction ) ) );
243
+ const zenithAngle = acos( max( 0.0, direction.y ) );
251
244
  const inverse = float( 1.0 ).div( cos( zenithAngle ).add( float( 0.15 ).mul( pow( float( 93.885 ).sub( zenithAngle.mul( 180.0 ).div( pi ) ), - 1.253 ) ) ) );
252
245
  const sR = rayleighZenithLength.mul( inverse );
253
246
  const sM = mieZenithLength.mul( inverse );
@@ -272,56 +265,60 @@ class SkyMesh extends Mesh {
272
265
  const betaMTheta = vBetaM.mul( mPhase );
273
266
 
274
267
  const Lin = pow( vSunE.mul( add( betaRTheta, betaMTheta ).div( add( vBetaR, vBetaM ) ) ).mul( sub( 1.0, Fex ) ), vec3( 1.5 ) );
275
- Lin.mulAssign( mix( vec3( 1.0 ), pow( vSunE.mul( add( betaRTheta, betaMTheta ).div( add( vBetaR, vBetaM ) ) ).mul( Fex ), vec3( 1.0 / 2.0 ) ), clamp( pow( sub( 1.0, dot( this.upUniform, vSunDirection ) ), 5.0 ), 0.0, 1.0 ) ) );
268
+ Lin.mulAssign( mix( vec3( 1.0 ), pow( vSunE.mul( add( betaRTheta, betaMTheta ).div( add( vBetaR, vBetaM ) ) ).mul( Fex ), vec3( 1.0 / 2.0 ) ), clamp( pow( sub( 1.0, vSunDirection.y ), 5.0 ), 0.0, 1.0 ) ) );
276
269
 
277
270
  // nightsky
278
271
 
279
272
  const L0 = vec3( 0.1 ).mul( Fex );
280
273
 
281
274
  // composition + solar disc
282
- const sundisc = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos.add( 0.00002 ), cosTheta ).mul( this.showSunDisc );
283
- L0.addAssign( vSunE.mul( 19000.0 ).mul( Fex ).mul( sundisc ) );
275
+ const sundisc = clamp( cosTheta.sub( sunAngularDiameterCos ).mul( 50000.0 ), 0.0, 1.0 ).mul( this.showSunDisc );
276
+ const sundiscColor = min( vSunE.mul( Fex ), 80.0 ).mul( 760.0 ).mul( sundisc );
284
277
 
285
- const texColor = add( Lin, L0 ).mul( 0.04 ).add( vec3( 0.0, 0.0003, 0.00075 ) ).toVar();
278
+ const texColor = add( Lin, L0 ).mul( 0.04 ).add( sundiscColor ).add( vec3( 0.0, 0.0003, 0.00075 ) ).toVar();
286
279
 
287
- // Cloud noise functions
288
- const hash = Fn( ( [ p ] ) => {
280
+ // gradient at a lattice corner; sinless hash so every GPU produces the same clouds
281
+ const gradient = Fn( ( [ i ] ) => {
289
282
 
290
- return fract( sin( dot( p, vec2( 127.1, 311.7 ) ) ).mul( 43758.5453123 ) );
283
+ const p = fract( i.xyx.mul( vec3( 0.1031, 0.1030, 0.0973 ) ) ).toVar();
284
+ p.addAssign( dot( p, p.yzx.add( 33.33 ) ) );
285
+
286
+ return fract( p.xx.add( p.yz ).mul( p.zy ) ).mul( 2.0 ).sub( 1.0 );
291
287
 
292
288
  } );
293
289
 
294
- const noise = Fn( ( [ p_immutable ] ) => {
290
+ // 2D gradient noise: isotropic lobes like Perlin at value-noise cost
291
+ const noise = Fn( ( [ p ] ) => {
295
292
 
296
- const p = vec2( p_immutable ).toVar();
297
293
  const i = floor( p );
298
294
  const f = fract( p );
299
- const ff = f.mul( f ).mul( sub( 3.0, f.mul( 2.0 ) ) );
295
+ const u = f.mul( f ).mul( f ).mul( f.mul( f.mul( 6.0 ).sub( 15.0 ) ).add( 10.0 ) ); // quintic fade
300
296
 
301
- const a = hash( i );
302
- const b = hash( add( i, vec2( 1.0, 0.0 ) ) );
303
- const c = hash( add( i, vec2( 0.0, 1.0 ) ) );
304
- const d = hash( add( i, vec2( 1.0, 1.0 ) ) );
297
+ const a = dot( gradient( i ), f );
298
+ const b = dot( gradient( i.add( vec2( 1.0, 0.0 ) ) ), f.sub( vec2( 1.0, 0.0 ) ) );
299
+ const c = dot( gradient( i.add( vec2( 0.0, 1.0 ) ) ), f.sub( vec2( 0.0, 1.0 ) ) );
300
+ const d = dot( gradient( i.add( vec2( 1.0, 1.0 ) ) ), f.sub( vec2( 1.0, 1.0 ) ) );
305
301
 
306
- return mix( mix( a, b, ff.x ), mix( c, d, ff.x ), ff.y );
302
+ return mix( mix( a, b, u.x ), mix( c, d, u.x ), u.y ).mul( 1.6 ); // ~[-1,1]
307
303
 
308
304
  } );
309
305
 
310
- const fbm = Fn( ( [ p_immutable ] ) => {
306
+ // fbm; per-octave drift makes clouds billow instead of scrolling as a rigid stamp
307
+ const fbm = Fn( ( [ position, drift ] ) => {
311
308
 
312
- const p = vec2( p_immutable ).toVar();
313
- const value = float( 0.0 ).toVar();
314
- const amplitude = float( 0.5 ).toVar();
309
+ const p = vec2( position ).toVar();
310
+ const result = float( 0.0 ).toVar();
311
+ const amplitude = float( 1.0 ).toVar();
315
312
 
316
- Loop( 5, () => {
313
+ Loop( 4, () => {
317
314
 
318
- value.addAssign( amplitude.mul( noise( p ) ) );
319
- p.mulAssign( 2.0 );
315
+ result.addAssign( amplitude.mul( noise( p ) ) );
320
316
  amplitude.mulAssign( 0.5 );
317
+ p.mulAssign( 2.0 ).addAssign( drift );
321
318
 
322
319
  } );
323
320
 
324
- return value;
321
+ return result;
325
322
 
326
323
  } );
327
324
 
@@ -334,29 +331,50 @@ class SkyMesh extends Mesh {
334
331
  cloudUV.mulAssign( this.cloudScale );
335
332
  cloudUV.addAssign( time.mul( this.cloudSpeed ) );
336
333
 
337
- // Multi-octave noise for fluffy clouds
338
- const cloudNoise = fbm( cloudUV.mul( 1000.0 ) ).add( fbm( cloudUV.mul( 2000.0 ).add( 3.7 ) ).mul( 0.5 ) ).toVar();
339
- cloudNoise.assign( cloudNoise.mul( 0.5 ).add( 0.5 ) );
334
+ // Cloud density field
335
+ const evolve = time.mul( this.cloudSpeed ).mul( 300.0 );
336
+ const cloudNoise = fbm( cloudUV.mul( 1000.0 ), evolve ).mul( 0.7 ).add( 0.5 ).clamp( 0.0, 1.0 ).toVar();
337
+
338
+ // Large-scale coverage variation: clear gaps next to dense banks
339
+ const region = noise( cloudUV.mul( 300.0 ) ).mul( 0.37 ).add( 0.5 );
340
+ const cov = clamp( this.cloudCoverage.add( region.sub( 0.5 ).mul( 0.6 ) ), 0.0, 1.0 );
340
341
 
341
- // Apply coverage threshold
342
- const cloudMask = smoothstep( sub( 1.0, this.cloudCoverage ), sub( 1.0, this.cloudCoverage ).add( 0.3 ), cloudNoise ).toVar();
342
+ // Carve clouds where noise rises above the coverage level
343
+ const threshold = sub( 1.0, cov ).toVar();
344
+ const cloudMask = smoothstep( threshold, threshold.add( 0.3 ), cloudNoise ).toVar();
343
345
 
344
346
  // Fade clouds near horizon (adjusted by elevation)
345
- const horizonFade = smoothstep( 0.0, add( 0.1, mul( 0.2, this.cloudElevation ) ), direction.y );
347
+ const horizonFade = smoothstep( 0.0, add( 0.03, mul( 0.06, this.cloudElevation ) ), direction.y );
346
348
  cloudMask.mulAssign( horizonFade );
347
349
 
348
- // Cloud lighting based on sun position
349
- const sunInfluence = dot( direction, vSunDirection ).mul( 0.5 ).add( 0.5 );
350
- const daylight = max( 0.0, vSunDirection.y.mul( 2.0 ) );
350
+ // Cloud lighting from the sky's own radiance
351
+ const dayFactor = smoothstep( - 0.08, 0.3, vSunDirection.y );
352
+ const sunColor = vSunE.mul( Fex ).mul( 0.22 ).mul( 0.04 ).toVar(); // 0.22 ~ albedo/pi, 0.04 = exposure; the aerial composite adds the eye-leg extinction
353
+ const skyAmbient = Lin.mul( 0.04 ).add( vec3( 0.0, 0.0003, 0.00075 ) );
354
+
355
+ // Beer-powder self-shadow from the sampled density
356
+ const depth = max( 0.0, cloudNoise.sub( threshold ) ).toVar();
357
+ const beer = exp( depth.mul( - 4.0 ) ).toVar();
358
+ const powder = sub( 1.0, beer.mul( beer ) ); // beer*beer == exp(-8*depth)
359
+ const shade = mix( 0.45, 1.0, beer.mul( powder ).mul( 2.6 ).clamp( 0.0, 1.0 ) ); // 2.6 = 1/0.385, normalizes beer*powder peak to 1
360
+
361
+ // Henyey-Greenstein forward lobe ( g = 0.7 ): silver lining on rims toward the sun
362
+ const silver = float( 0.51 ).div( pow( sub( 1.49, cosTheta.mul( 1.4 ) ), 1.5 ) ).clamp( 0.0, 3.0 ); // 0.51=1-g^2, 1.49=1+g^2, 1.4=2g
363
+ const edge = cloudMask.mul( sub( 1.0, cloudMask ) ).mul( 4.0 );
364
+
365
+ const cloudColor = skyAmbient.add( sunColor.mul( shade ) ).toVar();
366
+ cloudColor.addAssign( sunColor.mul( silver ).mul( edge ).mul( 0.6 ) );
367
+ cloudColor.mulAssign( dayFactor.max( 0.03 ) );
368
+
369
+ // Cloud opacity via Beer's law: density sets how solid the clouds get
370
+ const alpha = sub( 1.0, exp( depth.mul( this.cloudDensity ).mul( - 12.0 ) ) ).mul( horizonFade ).toVar();
351
371
 
352
- // Base cloud color affected by atmosphere
353
- const atmosphereColor = Lin.mul( 0.04 );
354
- const cloudColor = mix( vec3( 0.3 ), vec3( 1.0 ), daylight ).toVar();
355
- cloudColor.assign( mix( cloudColor, atmosphereColor.add( vec3( 1.0 ) ), sunInfluence.mul( 0.5 ) ) );
356
- cloudColor.mulAssign( vSunE.mul( 0.00002 ) );
372
+ // Occlude the sun disc/glow behind opaque cloud
373
+ texColor.subAssign( L0.mul( 0.04 ).add( sundiscColor ).mul( alpha ) );
357
374
 
358
- // Blend clouds with sky
359
- texColor.assign( mix( texColor, cloudColor, cloudMask.mul( this.cloudDensity ) ) );
375
+ // Composite through the atmosphere so distant clouds dissolve into haze
376
+ const cloudAerial = mix( texColor, cloudColor, Fex );
377
+ texColor.assign( mix( texColor, cloudAerial, alpha ) );
360
378
 
361
379
  } );
362
380
 
@@ -366,6 +384,7 @@ class SkyMesh extends Mesh {
366
384
 
367
385
  material.side = BackSide;
368
386
  material.depthWrite = false;
387
+ material.fog = false;
369
388
 
370
389
  material.vertexNode = vertexNode;
371
390
  material.colorNode = colorNode;
@@ -204,7 +204,7 @@ async function JoltPhysics() {
204
204
 
205
205
  }
206
206
 
207
- function setMeshVelocity( mesh, velocity, index = 0 ) {
207
+ function setMeshVelocity( /*mesh, velocity, index = 0*/ ) {
208
208
 
209
209
  /*
210
210
  let body = meshMap.get( mesh );
@@ -76,12 +76,14 @@ class AfterimagePass extends Pass {
76
76
 
77
77
  this._textureComp = new WebGLRenderTarget( window.innerWidth, window.innerHeight, {
78
78
  magFilter: NearestFilter,
79
- type: HalfFloatType
79
+ type: HalfFloatType,
80
+ depthBuffer: false
80
81
  } );
81
82
 
82
83
  this._textureOld = new WebGLRenderTarget( window.innerWidth, window.innerHeight, {
83
84
  magFilter: NearestFilter,
84
- type: HalfFloatType
85
+ type: HalfFloatType,
86
+ depthBuffer: false
85
87
  } );
86
88
 
87
89
  this._compFsQuad = new FullScreenQuad( this.compFsMaterial );
@@ -104,9 +104,9 @@ class BloomPass extends Pass {
104
104
 
105
105
  // internals
106
106
 
107
- this._renderTargetX = new WebGLRenderTarget( 1, 1, { type: HalfFloatType } ); // will be resized later
107
+ this._renderTargetX = new WebGLRenderTarget( 1, 1, { type: HalfFloatType, depthBuffer: false } ); // will be resized later
108
108
  this._renderTargetX.texture.name = 'BloomPass.x';
109
- this._renderTargetY = new WebGLRenderTarget( 1, 1, { type: HalfFloatType } ); // will be resized later
109
+ this._renderTargetY = new WebGLRenderTarget( 1, 1, { type: HalfFloatType, depthBuffer: false } ); // will be resized later
110
110
  this._renderTargetY.texture.name = 'BloomPass.y';
111
111
 
112
112
  this._fsQuad = new FullScreenQuad( null );
@@ -140,7 +140,7 @@ class GTAOPass extends Pass {
140
140
  this.gtaoNoiseTexture = generateMagicSquareNoise();
141
141
  this.pdNoiseTexture = this._generateNoise();
142
142
 
143
- this.gtaoRenderTarget = new WebGLRenderTarget( this.width, this.height, { type: HalfFloatType } );
143
+ this.gtaoRenderTarget = new WebGLRenderTarget( this.width, this.height, { type: HalfFloatType, depthBuffer: false } );
144
144
  this.pdRenderTarget = this.gtaoRenderTarget.clone();
145
145
 
146
146
  this.gtaoMaterial = new ShaderMaterial( {
@@ -170,22 +170,22 @@ class OutlinePass extends Pass {
170
170
  this.renderTargetDepthBuffer.texture.name = 'OutlinePass.depth';
171
171
  this.renderTargetDepthBuffer.texture.generateMipmaps = false;
172
172
 
173
- this.renderTargetMaskDownSampleBuffer = new WebGLRenderTarget( resx, resy, { type: HalfFloatType } );
173
+ this.renderTargetMaskDownSampleBuffer = new WebGLRenderTarget( resx, resy, { type: HalfFloatType, depthBuffer: false } );
174
174
  this.renderTargetMaskDownSampleBuffer.texture.name = 'OutlinePass.depthDownSample';
175
175
  this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps = false;
176
176
 
177
- this.renderTargetBlurBuffer1 = new WebGLRenderTarget( resx, resy, { type: HalfFloatType } );
177
+ this.renderTargetBlurBuffer1 = new WebGLRenderTarget( resx, resy, { type: HalfFloatType, depthBuffer: false } );
178
178
  this.renderTargetBlurBuffer1.texture.name = 'OutlinePass.blur1';
179
179
  this.renderTargetBlurBuffer1.texture.generateMipmaps = false;
180
- this.renderTargetBlurBuffer2 = new WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ), { type: HalfFloatType } );
180
+ this.renderTargetBlurBuffer2 = new WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ), { type: HalfFloatType, depthBuffer: false } );
181
181
  this.renderTargetBlurBuffer2.texture.name = 'OutlinePass.blur2';
182
182
  this.renderTargetBlurBuffer2.texture.generateMipmaps = false;
183
183
 
184
184
  this.edgeDetectionMaterial = this._getEdgeDetectionMaterial();
185
- this.renderTargetEdgeBuffer1 = new WebGLRenderTarget( resx, resy, { type: HalfFloatType } );
185
+ this.renderTargetEdgeBuffer1 = new WebGLRenderTarget( resx, resy, { type: HalfFloatType, depthBuffer: false } );
186
186
  this.renderTargetEdgeBuffer1.texture.name = 'OutlinePass.edge1';
187
187
  this.renderTargetEdgeBuffer1.texture.generateMipmaps = false;
188
- this.renderTargetEdgeBuffer2 = new WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ), { type: HalfFloatType } );
188
+ this.renderTargetEdgeBuffer2 = new WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ), { type: HalfFloatType, depthBuffer: false } );
189
189
  this.renderTargetEdgeBuffer2.texture.name = 'OutlinePass.edge2';
190
190
  this.renderTargetEdgeBuffer2.texture.generateMipmaps = false;
191
191
 
@@ -108,7 +108,7 @@ class SAOPass extends Pass {
108
108
  */
109
109
  this.resolution = new Vector2( resolution.x, resolution.y );
110
110
 
111
- this.saoRenderTarget = new WebGLRenderTarget( this.resolution.x, this.resolution.y, { type: HalfFloatType } );
111
+ this.saoRenderTarget = new WebGLRenderTarget( this.resolution.x, this.resolution.y, { type: HalfFloatType, depthBuffer: false } );
112
112
  this.blurIntermediateRenderTarget = this.saoRenderTarget.clone();
113
113
 
114
114
  const depthTexture = new DepthTexture();
@@ -163,7 +163,7 @@ class SSAOPass extends Pass {
163
163
 
164
164
  // ssao render target
165
165
 
166
- this.ssaoRenderTarget = new WebGLRenderTarget( this.width, this.height, { type: HalfFloatType } );
166
+ this.ssaoRenderTarget = new WebGLRenderTarget( this.width, this.height, { type: HalfFloatType, depthBuffer: false } );
167
167
 
168
168
  this.blurRenderTarget = this.ssaoRenderTarget.clone();
169
169
 
@@ -315,7 +315,8 @@ class SSRPass extends Pass {
315
315
  //for bouncing
316
316
  this.prevRenderTarget = new WebGLRenderTarget( this.width, this.height, {
317
317
  minFilter: NearestFilter,
318
- magFilter: NearestFilter
318
+ magFilter: NearestFilter,
319
+ depthBuffer: false
319
320
  } );
320
321
 
321
322
  // normal render target
@@ -340,7 +341,8 @@ class SSRPass extends Pass {
340
341
 
341
342
  this.ssrRenderTarget = new WebGLRenderTarget( this.width, this.height, {
342
343
  minFilter: NearestFilter,
343
- magFilter: NearestFilter
344
+ magFilter: NearestFilter,
345
+ depthBuffer: false
344
346
  } );
345
347
 
346
348
  this.blurRenderTarget = this.ssrRenderTarget.clone();
@@ -61,7 +61,7 @@ class SavePass extends Pass {
61
61
 
62
62
  if ( this.renderTarget === undefined ) {
63
63
 
64
- this.renderTarget = new WebGLRenderTarget( 1, 1, { type: HalfFloatType } ); // will be resized later
64
+ this.renderTarget = new WebGLRenderTarget( 1, 1, { type: HalfFloatType, depthBuffer: false } ); // will be resized later
65
65
  this.renderTarget.texture.name = 'SavePass.rt';
66
66
 
67
67
  }
@@ -101,7 +101,7 @@ class TAARenderPass extends SSAARenderPass {
101
101
 
102
102
  if ( this._holdRenderTarget === null ) {
103
103
 
104
- this._holdRenderTarget = new WebGLRenderTarget( readBuffer.width, readBuffer.height, { type: HalfFloatType } );
104
+ this._holdRenderTarget = new WebGLRenderTarget( readBuffer.width, readBuffer.height, { type: HalfFloatType, depthBuffer: false } );
105
105
  this._holdRenderTarget.texture.name = 'TAARenderPass.hold';
106
106
 
107
107
  }
@@ -102,20 +102,20 @@ class UnrealBloomPass extends Pass {
102
102
  let resx = Math.round( this.resolution.x / 2 );
103
103
  let resy = Math.round( this.resolution.y / 2 );
104
104
 
105
- this.renderTargetBright = new WebGLRenderTarget( resx, resy, { type: HalfFloatType } );
105
+ this.renderTargetBright = new WebGLRenderTarget( resx, resy, { type: HalfFloatType, depthBuffer: false } );
106
106
  this.renderTargetBright.texture.name = 'UnrealBloomPass.bright';
107
107
  this.renderTargetBright.texture.generateMipmaps = false;
108
108
 
109
109
  for ( let i = 0; i < this.nMips; i ++ ) {
110
110
 
111
- const renderTargetHorizontal = new WebGLRenderTarget( resx, resy, { type: HalfFloatType } );
111
+ const renderTargetHorizontal = new WebGLRenderTarget( resx, resy, { type: HalfFloatType, depthBuffer: false } );
112
112
 
113
113
  renderTargetHorizontal.texture.name = 'UnrealBloomPass.h' + i;
114
114
  renderTargetHorizontal.texture.generateMipmaps = false;
115
115
 
116
116
  this.renderTargetsHorizontal.push( renderTargetHorizontal );
117
117
 
118
- const renderTargetVertical = new WebGLRenderTarget( resx, resy, { type: HalfFloatType } );
118
+ const renderTargetVertical = new WebGLRenderTarget( resx, resy, { type: HalfFloatType, depthBuffer: false } );
119
119
 
120
120
  renderTargetVertical.texture.name = 'UnrealBloomPass.v' + i;
121
121
  renderTargetVertical.texture.generateMipmaps = false;
@@ -387,17 +387,35 @@ class UnrealBloomPass extends Pass {
387
387
 
388
388
  }
389
389
 
390
+ // merge adjacent taps into single bilinear fetches (linear sampling)
391
+
392
+ const offsets = [];
393
+ const weights = [];
394
+
395
+ for ( let i = 1; i < kernelRadius; i += 2 ) {
396
+
397
+ const wa = coefficients[ i ];
398
+ const wb = ( i + 1 < kernelRadius ) ? coefficients[ i + 1 ] : 0;
399
+ const w = wa + wb;
400
+
401
+ offsets.push( ( i * wa + ( i + 1 ) * wb ) / w );
402
+ weights.push( w );
403
+
404
+ }
405
+
390
406
  return new ShaderMaterial( {
391
407
 
392
408
  defines: {
393
- 'KERNEL_RADIUS': kernelRadius
409
+ 'KERNEL_PAIRS': offsets.length
394
410
  },
395
411
 
396
412
  uniforms: {
397
413
  'colorTexture': { value: null },
398
414
  'invSize': { value: new Vector2( 0.5, 0.5 ) }, // inverse texture size
399
415
  'direction': { value: new Vector2( 0.5, 0.5 ) },
400
- 'gaussianCoefficients': { value: coefficients } // precomputed Gaussian coefficients
416
+ 'centerWeight': { value: coefficients[ 0 ] },
417
+ 'gaussianOffsets': { value: offsets },
418
+ 'gaussianWeights': { value: weights }
401
419
  },
402
420
 
403
421
  vertexShader: /* glsl */`
@@ -420,21 +438,20 @@ class UnrealBloomPass extends Pass {
420
438
  uniform sampler2D colorTexture;
421
439
  uniform vec2 invSize;
422
440
  uniform vec2 direction;
423
- uniform float gaussianCoefficients[KERNEL_RADIUS];
441
+ uniform float centerWeight;
442
+ uniform float gaussianOffsets[KERNEL_PAIRS];
443
+ uniform float gaussianWeights[KERNEL_PAIRS];
424
444
 
425
445
  void main() {
426
446
 
427
- float weightSum = gaussianCoefficients[0];
428
- vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum;
447
+ vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * centerWeight;
429
448
 
430
- for ( int i = 1; i < KERNEL_RADIUS; i ++ ) {
449
+ for ( int i = 0; i < KERNEL_PAIRS; i ++ ) {
431
450
 
432
- float x = float( i );
433
- float w = gaussianCoefficients[i];
434
- vec2 uvOffset = direction * invSize * x;
451
+ vec2 uvOffset = direction * invSize * gaussianOffsets[ i ];
435
452
  vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;
436
453
  vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;
437
- diffuseSum += ( sample1 + sample2 ) * w;
454
+ diffuseSum += ( sample1 + sample2 ) * gaussianWeights[ i ];
438
455
 
439
456
  }
440
457