three-stdlib 2.35.5 → 2.35.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (514) hide show
  1. package/_polyfill/CapsuleGeometry.cjs +20 -17
  2. package/_polyfill/CapsuleGeometry.cjs.map +1 -1
  3. package/_polyfill/CapsuleGeometry.js +20 -17
  4. package/_polyfill/CapsuleGeometry.js.map +1 -1
  5. package/_polyfill/constants.cjs +1 -1
  6. package/_polyfill/constants.cjs.map +1 -1
  7. package/_polyfill/constants.js +1 -1
  8. package/_polyfill/constants.js.map +1 -1
  9. package/animation/AnimationClipCreator.cjs +13 -13
  10. package/animation/AnimationClipCreator.cjs.map +1 -1
  11. package/animation/AnimationClipCreator.js +13 -13
  12. package/animation/AnimationClipCreator.js.map +1 -1
  13. package/animation/CCDIKSolver.cjs +11 -11
  14. package/animation/CCDIKSolver.cjs.map +1 -1
  15. package/animation/CCDIKSolver.js +12 -12
  16. package/animation/CCDIKSolver.js.map +1 -1
  17. package/animation/MMDAnimationHelper.cjs +1 -1
  18. package/animation/MMDAnimationHelper.cjs.map +1 -1
  19. package/animation/MMDAnimationHelper.js +1 -1
  20. package/animation/MMDAnimationHelper.js.map +1 -1
  21. package/animation/MMDPhysics.cjs +4 -4
  22. package/animation/MMDPhysics.cjs.map +1 -1
  23. package/animation/MMDPhysics.js +4 -4
  24. package/animation/MMDPhysics.js.map +1 -1
  25. package/controls/ArcballControls.cjs +2 -2
  26. package/controls/ArcballControls.cjs.map +1 -1
  27. package/controls/ArcballControls.js +3 -3
  28. package/controls/ArcballControls.js.map +1 -1
  29. package/controls/FirstPersonControls.cjs +1 -1
  30. package/controls/FirstPersonControls.cjs.map +1 -1
  31. package/controls/FirstPersonControls.js +1 -1
  32. package/controls/FirstPersonControls.js.map +1 -1
  33. package/controls/OrbitControls.cjs +2 -2
  34. package/controls/OrbitControls.cjs.map +1 -1
  35. package/controls/OrbitControls.js +3 -3
  36. package/controls/OrbitControls.js.map +1 -1
  37. package/controls/PointerLockControls.cjs +2 -2
  38. package/controls/PointerLockControls.cjs.map +1 -1
  39. package/controls/PointerLockControls.js +3 -3
  40. package/controls/PointerLockControls.js.map +1 -1
  41. package/csm/CSM.cjs +4 -4
  42. package/csm/CSM.cjs.map +1 -1
  43. package/csm/CSM.js +5 -5
  44. package/csm/CSM.js.map +1 -1
  45. package/csm/CSMFrustum.cjs +1 -1
  46. package/csm/CSMFrustum.cjs.map +1 -1
  47. package/csm/CSMFrustum.js +2 -2
  48. package/csm/CSMFrustum.js.map +1 -1
  49. package/deprecated/Geometry.cjs +722 -715
  50. package/deprecated/Geometry.cjs.map +1 -1
  51. package/deprecated/Geometry.js +723 -716
  52. package/deprecated/Geometry.js.map +1 -1
  53. package/effects/AnaglyphEffect.cjs +2 -1
  54. package/effects/AnaglyphEffect.cjs.map +1 -1
  55. package/effects/AnaglyphEffect.js +3 -2
  56. package/effects/AnaglyphEffect.js.map +1 -1
  57. package/effects/OutlineEffect.cjs +2 -1
  58. package/effects/OutlineEffect.cjs.map +1 -1
  59. package/effects/OutlineEffect.js +3 -2
  60. package/effects/OutlineEffect.js.map +1 -1
  61. package/effects/ParallaxBarrierEffect.cjs +2 -1
  62. package/effects/ParallaxBarrierEffect.cjs.map +1 -1
  63. package/effects/ParallaxBarrierEffect.js +3 -2
  64. package/effects/ParallaxBarrierEffect.js.map +1 -1
  65. package/exporters/DRACOExporter.cjs +133 -122
  66. package/exporters/DRACOExporter.cjs.map +1 -1
  67. package/exporters/DRACOExporter.d.ts +34 -21
  68. package/exporters/DRACOExporter.js +133 -122
  69. package/exporters/DRACOExporter.js.map +1 -1
  70. package/exporters/GLTFExporter.cjs +170 -167
  71. package/exporters/GLTFExporter.cjs.map +1 -1
  72. package/exporters/GLTFExporter.js +170 -167
  73. package/exporters/GLTFExporter.js.map +1 -1
  74. package/geometries/LightningStrike.cjs +524 -515
  75. package/geometries/LightningStrike.cjs.map +1 -1
  76. package/geometries/LightningStrike.js +524 -515
  77. package/geometries/LightningStrike.js.map +1 -1
  78. package/geometries/RoundedBoxGeometry.cjs +1 -1
  79. package/geometries/RoundedBoxGeometry.cjs.map +1 -1
  80. package/geometries/RoundedBoxGeometry.js +2 -2
  81. package/geometries/RoundedBoxGeometry.js.map +1 -1
  82. package/helpers/RaycasterHelper.cjs +2 -2
  83. package/helpers/RaycasterHelper.cjs.map +1 -1
  84. package/helpers/RaycasterHelper.js +3 -3
  85. package/helpers/RaycasterHelper.js.map +1 -1
  86. package/helpers/VertexNormalsHelper.cjs +3 -3
  87. package/helpers/VertexNormalsHelper.cjs.map +1 -1
  88. package/helpers/VertexNormalsHelper.js +4 -4
  89. package/helpers/VertexNormalsHelper.js.map +1 -1
  90. package/helpers/VertexTangentsHelper.cjs +2 -2
  91. package/helpers/VertexTangentsHelper.cjs.map +1 -1
  92. package/helpers/VertexTangentsHelper.js +3 -3
  93. package/helpers/VertexTangentsHelper.js.map +1 -1
  94. package/interactive/InteractiveGroup.cjs +1 -1
  95. package/interactive/InteractiveGroup.cjs.map +1 -1
  96. package/interactive/InteractiveGroup.js +2 -2
  97. package/interactive/InteractiveGroup.js.map +1 -1
  98. package/interactive/SelectionBox.cjs +15 -15
  99. package/interactive/SelectionBox.cjs.map +1 -1
  100. package/interactive/SelectionBox.js +16 -16
  101. package/interactive/SelectionBox.js.map +1 -1
  102. package/libs/chevrotain.cjs +1 -1
  103. package/libs/chevrotain.cjs.map +1 -1
  104. package/libs/chevrotain.js +1 -1
  105. package/libs/chevrotain.js.map +1 -1
  106. package/libs/lottie.cjs +1 -1
  107. package/libs/lottie.cjs.map +1 -1
  108. package/libs/lottie.js +1 -1
  109. package/libs/lottie.js.map +1 -1
  110. package/libs/opentype.cjs +1 -1
  111. package/libs/opentype.cjs.map +1 -1
  112. package/libs/opentype.js +1 -1
  113. package/libs/opentype.js.map +1 -1
  114. package/lights/LightProbeGenerator.cjs +5 -5
  115. package/lights/LightProbeGenerator.cjs.map +1 -1
  116. package/lights/LightProbeGenerator.js +5 -5
  117. package/lights/LightProbeGenerator.js.map +1 -1
  118. package/lights/RectAreaLightUniformsLib.cjs +3 -3
  119. package/lights/RectAreaLightUniformsLib.cjs.map +1 -1
  120. package/lights/RectAreaLightUniformsLib.js +3 -3
  121. package/lights/RectAreaLightUniformsLib.js.map +1 -1
  122. package/lines/LineMaterial.cjs +2 -1
  123. package/lines/LineMaterial.cjs.map +1 -1
  124. package/lines/LineMaterial.js +3 -2
  125. package/lines/LineMaterial.js.map +1 -1
  126. package/lines/LineSegments2.cjs +13 -13
  127. package/lines/LineSegments2.cjs.map +1 -1
  128. package/lines/LineSegments2.js +14 -14
  129. package/lines/LineSegments2.js.map +1 -1
  130. package/lines/LineSegmentsGeometry.cjs +2 -2
  131. package/lines/LineSegmentsGeometry.cjs.map +1 -1
  132. package/lines/LineSegmentsGeometry.js +3 -3
  133. package/lines/LineSegmentsGeometry.js.map +1 -1
  134. package/lines/Wireframe.cjs +3 -3
  135. package/lines/Wireframe.cjs.map +1 -1
  136. package/lines/Wireframe.js +4 -4
  137. package/lines/Wireframe.js.map +1 -1
  138. package/loaders/BasisTextureLoader.cjs +441 -435
  139. package/loaders/BasisTextureLoader.cjs.map +1 -1
  140. package/loaders/BasisTextureLoader.js +441 -435
  141. package/loaders/BasisTextureLoader.js.map +1 -1
  142. package/loaders/EXRLoader.cjs +2 -1
  143. package/loaders/EXRLoader.cjs.map +1 -1
  144. package/loaders/EXRLoader.js +3 -2
  145. package/loaders/EXRLoader.js.map +1 -1
  146. package/loaders/FBXLoader.cjs +2 -2
  147. package/loaders/FBXLoader.cjs.map +1 -1
  148. package/loaders/FBXLoader.js +2 -2
  149. package/loaders/FBXLoader.js.map +1 -1
  150. package/loaders/FontLoader.cjs +2 -2
  151. package/loaders/FontLoader.cjs.map +1 -1
  152. package/loaders/FontLoader.d.ts +2 -2
  153. package/loaders/FontLoader.js +2 -2
  154. package/loaders/FontLoader.js.map +1 -1
  155. package/loaders/GLTFLoader.cjs +2 -2
  156. package/loaders/GLTFLoader.cjs.map +1 -1
  157. package/loaders/GLTFLoader.js +2 -2
  158. package/loaders/GLTFLoader.js.map +1 -1
  159. package/loaders/KTX2Loader.cjs +377 -374
  160. package/loaders/KTX2Loader.cjs.map +1 -1
  161. package/loaders/KTX2Loader.js +377 -374
  162. package/loaders/KTX2Loader.js.map +1 -1
  163. package/loaders/LDrawLoader.cjs +5 -4
  164. package/loaders/LDrawLoader.cjs.map +1 -1
  165. package/loaders/LDrawLoader.js +6 -5
  166. package/loaders/LDrawLoader.js.map +1 -1
  167. package/loaders/OBJLoader.cjs +5 -5
  168. package/loaders/OBJLoader.cjs.map +1 -1
  169. package/loaders/OBJLoader.js +6 -6
  170. package/loaders/OBJLoader.js.map +1 -1
  171. package/loaders/PRWMLoader.cjs +46 -43
  172. package/loaders/PRWMLoader.cjs.map +1 -1
  173. package/loaders/PRWMLoader.js +46 -43
  174. package/loaders/PRWMLoader.js.map +1 -1
  175. package/loaders/SVGLoader.cjs +1694 -1688
  176. package/loaders/SVGLoader.cjs.map +1 -1
  177. package/loaders/SVGLoader.js +1694 -1688
  178. package/loaders/SVGLoader.js.map +1 -1
  179. package/loaders/XLoader.cjs +1 -1
  180. package/loaders/XLoader.cjs.map +1 -1
  181. package/loaders/XLoader.js +1 -1
  182. package/loaders/XLoader.js.map +1 -1
  183. package/math/Capsule.cjs +3 -3
  184. package/math/Capsule.cjs.map +1 -1
  185. package/math/Capsule.js +3 -3
  186. package/math/Capsule.js.map +1 -1
  187. package/math/ColorConverter.cjs +9 -9
  188. package/math/ColorConverter.cjs.map +1 -1
  189. package/math/ColorConverter.js +9 -9
  190. package/math/ColorConverter.js.map +1 -1
  191. package/math/ConvexHull.cjs +53 -50
  192. package/math/ConvexHull.cjs.map +1 -1
  193. package/math/ConvexHull.js +53 -50
  194. package/math/ConvexHull.js.map +1 -1
  195. package/math/ImprovedNoise.cjs +1 -1
  196. package/math/ImprovedNoise.cjs.map +1 -1
  197. package/math/ImprovedNoise.js +1 -1
  198. package/math/ImprovedNoise.js.map +1 -1
  199. package/math/MeshSurfaceSampler.cjs +2 -2
  200. package/math/MeshSurfaceSampler.cjs.map +1 -1
  201. package/math/MeshSurfaceSampler.js +2 -2
  202. package/math/MeshSurfaceSampler.js.map +1 -1
  203. package/math/OBB.cjs +14 -14
  204. package/math/OBB.cjs.map +1 -1
  205. package/math/OBB.js +15 -15
  206. package/math/OBB.js.map +1 -1
  207. package/math/Octree.cjs +7 -7
  208. package/math/Octree.cjs.map +1 -1
  209. package/math/Octree.js +8 -8
  210. package/math/Octree.js.map +1 -1
  211. package/misc/ConvexObjectBreaker.cjs +271 -268
  212. package/misc/ConvexObjectBreaker.cjs.map +1 -1
  213. package/misc/ConvexObjectBreaker.js +272 -269
  214. package/misc/ConvexObjectBreaker.js.map +1 -1
  215. package/misc/Gyroscope.cjs +6 -6
  216. package/misc/Gyroscope.cjs.map +1 -1
  217. package/misc/Gyroscope.js +7 -7
  218. package/misc/Gyroscope.js.map +1 -1
  219. package/modifiers/CurveModifier.cjs +1 -1
  220. package/modifiers/CurveModifier.cjs.map +1 -1
  221. package/modifiers/CurveModifier.js +2 -2
  222. package/modifiers/CurveModifier.js.map +1 -1
  223. package/modifiers/SimplifyModifier.cjs +2 -2
  224. package/modifiers/SimplifyModifier.cjs.map +1 -1
  225. package/modifiers/SimplifyModifier.js +2 -2
  226. package/modifiers/SimplifyModifier.js.map +1 -1
  227. package/objects/BatchedMesh.cjs +2 -2
  228. package/objects/BatchedMesh.cjs.map +1 -1
  229. package/objects/BatchedMesh.js +3 -3
  230. package/objects/BatchedMesh.js.map +1 -1
  231. package/objects/GroundProjectedEnv.cjs +2 -1
  232. package/objects/GroundProjectedEnv.cjs.map +1 -1
  233. package/objects/GroundProjectedEnv.js +3 -2
  234. package/objects/GroundProjectedEnv.js.map +1 -1
  235. package/objects/Lensflare.cjs +211 -206
  236. package/objects/Lensflare.cjs.map +1 -1
  237. package/objects/Lensflare.js +212 -207
  238. package/objects/Lensflare.js.map +1 -1
  239. package/objects/Reflector.cjs +154 -146
  240. package/objects/Reflector.cjs.map +1 -1
  241. package/objects/Reflector.js +154 -146
  242. package/objects/Reflector.js.map +1 -1
  243. package/objects/ReflectorForSSRPass.cjs +183 -180
  244. package/objects/ReflectorForSSRPass.cjs.map +1 -1
  245. package/objects/ReflectorForSSRPass.js +183 -180
  246. package/objects/ReflectorForSSRPass.js.map +1 -1
  247. package/objects/Refractor.cjs +164 -161
  248. package/objects/Refractor.cjs.map +1 -1
  249. package/objects/Refractor.js +164 -161
  250. package/objects/Refractor.js.map +1 -1
  251. package/objects/ShadowMesh.cjs +1 -1
  252. package/objects/ShadowMesh.cjs.map +1 -1
  253. package/objects/ShadowMesh.js +2 -2
  254. package/objects/ShadowMesh.js.map +1 -1
  255. package/objects/Sky.cjs +35 -32
  256. package/objects/Sky.cjs.map +1 -1
  257. package/objects/Sky.d.ts +17 -42
  258. package/objects/Sky.js +35 -32
  259. package/objects/Sky.js.map +1 -1
  260. package/objects/Water.cjs +2 -1
  261. package/objects/Water.cjs.map +1 -1
  262. package/objects/Water.js +3 -2
  263. package/objects/Water.js.map +1 -1
  264. package/objects/Water2.cjs +143 -140
  265. package/objects/Water2.cjs.map +1 -1
  266. package/objects/Water2.js +143 -140
  267. package/objects/Water2.js.map +1 -1
  268. package/package.json +1 -1
  269. package/postprocessing/SAOPass.cjs +267 -264
  270. package/postprocessing/SAOPass.cjs.map +1 -1
  271. package/postprocessing/SAOPass.js +267 -264
  272. package/postprocessing/SAOPass.js.map +1 -1
  273. package/postprocessing/SSAOPass.cjs +253 -250
  274. package/postprocessing/SSAOPass.cjs.map +1 -1
  275. package/postprocessing/SSAOPass.js +253 -250
  276. package/postprocessing/SSAOPass.js.map +1 -1
  277. package/postprocessing/SSRPass.cjs +379 -376
  278. package/postprocessing/SSRPass.cjs.map +1 -1
  279. package/postprocessing/SSRPass.js +379 -376
  280. package/postprocessing/SSRPass.js.map +1 -1
  281. package/postprocessing/UnrealBloomPass.cjs +205 -202
  282. package/postprocessing/UnrealBloomPass.cjs.map +1 -1
  283. package/postprocessing/UnrealBloomPass.js +205 -202
  284. package/postprocessing/UnrealBloomPass.js.map +1 -1
  285. package/renderers/CSS2DRenderer.cjs +5 -5
  286. package/renderers/CSS2DRenderer.cjs.map +1 -1
  287. package/renderers/CSS2DRenderer.js +5 -5
  288. package/renderers/CSS2DRenderer.js.map +1 -1
  289. package/renderers/CSS3DRenderer.cjs +5 -5
  290. package/renderers/CSS3DRenderer.cjs.map +1 -1
  291. package/renderers/CSS3DRenderer.js +6 -6
  292. package/renderers/CSS3DRenderer.js.map +1 -1
  293. package/shaders/ACESFilmicToneMappingShader.cjs +71 -46
  294. package/shaders/ACESFilmicToneMappingShader.cjs.map +1 -1
  295. package/shaders/ACESFilmicToneMappingShader.js +71 -46
  296. package/shaders/ACESFilmicToneMappingShader.js.map +1 -1
  297. package/shaders/AfterimageShader.cjs +41 -22
  298. package/shaders/AfterimageShader.cjs.map +1 -1
  299. package/shaders/AfterimageShader.js +41 -22
  300. package/shaders/AfterimageShader.js.map +1 -1
  301. package/shaders/BasicShader.cjs +20 -6
  302. package/shaders/BasicShader.cjs.map +1 -1
  303. package/shaders/BasicShader.js +20 -6
  304. package/shaders/BasicShader.js.map +1 -1
  305. package/shaders/BleachBypassShader.cjs +46 -26
  306. package/shaders/BleachBypassShader.cjs.map +1 -1
  307. package/shaders/BleachBypassShader.js +46 -26
  308. package/shaders/BleachBypassShader.js.map +1 -1
  309. package/shaders/BlendShader.cjs +33 -19
  310. package/shaders/BlendShader.cjs.map +1 -1
  311. package/shaders/BlendShader.js +33 -19
  312. package/shaders/BlendShader.js.map +1 -1
  313. package/shaders/BokehShader.cjs +117 -90
  314. package/shaders/BokehShader.cjs.map +1 -1
  315. package/shaders/BokehShader.js +117 -90
  316. package/shaders/BokehShader.js.map +1 -1
  317. package/shaders/BokehShader2.cjs +333 -232
  318. package/shaders/BokehShader2.cjs.map +1 -1
  319. package/shaders/BokehShader2.js +333 -232
  320. package/shaders/BokehShader2.js.map +1 -1
  321. package/shaders/BrightnessContrastShader.cjs +38 -22
  322. package/shaders/BrightnessContrastShader.cjs.map +1 -1
  323. package/shaders/BrightnessContrastShader.js +38 -22
  324. package/shaders/BrightnessContrastShader.js.map +1 -1
  325. package/shaders/ColorCorrectionShader.cjs +35 -21
  326. package/shaders/ColorCorrectionShader.cjs.map +1 -1
  327. package/shaders/ColorCorrectionShader.js +35 -21
  328. package/shaders/ColorCorrectionShader.js.map +1 -1
  329. package/shaders/ColorifyShader.cjs +34 -19
  330. package/shaders/ColorifyShader.cjs.map +1 -1
  331. package/shaders/ColorifyShader.js +34 -19
  332. package/shaders/ColorifyShader.js.map +1 -1
  333. package/shaders/ConvolutionShader.cjs +43 -24
  334. package/shaders/ConvolutionShader.cjs.map +1 -1
  335. package/shaders/ConvolutionShader.js +43 -24
  336. package/shaders/ConvolutionShader.js.map +1 -1
  337. package/shaders/CopyShader.cjs +30 -16
  338. package/shaders/CopyShader.cjs.map +1 -1
  339. package/shaders/CopyShader.js +30 -16
  340. package/shaders/CopyShader.js.map +1 -1
  341. package/shaders/DOFMipMapShader.cjs +38 -21
  342. package/shaders/DOFMipMapShader.cjs.map +1 -1
  343. package/shaders/DOFMipMapShader.js +38 -21
  344. package/shaders/DOFMipMapShader.js.map +1 -1
  345. package/shaders/DepthLimitedBlurShader.cjs +98 -69
  346. package/shaders/DepthLimitedBlurShader.cjs.map +1 -1
  347. package/shaders/DepthLimitedBlurShader.js +98 -69
  348. package/shaders/DepthLimitedBlurShader.js.map +1 -1
  349. package/shaders/DigitalGlitch.cjs +70 -59
  350. package/shaders/DigitalGlitch.cjs.map +1 -1
  351. package/shaders/DigitalGlitch.js +70 -59
  352. package/shaders/DigitalGlitch.js.map +1 -1
  353. package/shaders/DotScreenShader.cjs +49 -28
  354. package/shaders/DotScreenShader.cjs.map +1 -1
  355. package/shaders/DotScreenShader.js +49 -28
  356. package/shaders/DotScreenShader.js.map +1 -1
  357. package/shaders/FXAAShader.cjs +1098 -1089
  358. package/shaders/FXAAShader.cjs.map +1 -1
  359. package/shaders/FXAAShader.js +1098 -1089
  360. package/shaders/FXAAShader.js.map +1 -1
  361. package/shaders/FilmShader.cjs +57 -29
  362. package/shaders/FilmShader.cjs.map +1 -1
  363. package/shaders/FilmShader.js +57 -29
  364. package/shaders/FilmShader.js.map +1 -1
  365. package/shaders/FocusShader.cjs +70 -43
  366. package/shaders/FocusShader.cjs.map +1 -1
  367. package/shaders/FocusShader.js +70 -43
  368. package/shaders/FocusShader.js.map +1 -1
  369. package/shaders/FreiChenShader.cjs +74 -53
  370. package/shaders/FreiChenShader.cjs.map +1 -1
  371. package/shaders/FreiChenShader.js +74 -53
  372. package/shaders/FreiChenShader.js.map +1 -1
  373. package/shaders/FresnelShader.cjs +55 -35
  374. package/shaders/FresnelShader.cjs.map +1 -1
  375. package/shaders/FresnelShader.js +55 -35
  376. package/shaders/FresnelShader.js.map +1 -1
  377. package/shaders/GammaCorrectionShader.cjs +33 -19
  378. package/shaders/GammaCorrectionShader.cjs.map +1 -1
  379. package/shaders/GammaCorrectionShader.js +33 -19
  380. package/shaders/GammaCorrectionShader.js.map +1 -1
  381. package/shaders/GodRaysShader.cjs +193 -116
  382. package/shaders/GodRaysShader.cjs.map +1 -1
  383. package/shaders/GodRaysShader.js +193 -116
  384. package/shaders/GodRaysShader.js.map +1 -1
  385. package/shaders/HalftoneShader.cjs +270 -192
  386. package/shaders/HalftoneShader.cjs.map +1 -1
  387. package/shaders/HalftoneShader.js +270 -192
  388. package/shaders/HalftoneShader.js.map +1 -1
  389. package/shaders/HorizontalTiltShiftShader.cjs +43 -27
  390. package/shaders/HorizontalTiltShiftShader.cjs.map +1 -1
  391. package/shaders/HorizontalTiltShiftShader.js +43 -27
  392. package/shaders/HorizontalTiltShiftShader.js.map +1 -1
  393. package/shaders/HueSaturationShader.cjs +47 -31
  394. package/shaders/HueSaturationShader.cjs.map +1 -1
  395. package/shaders/HueSaturationShader.js +47 -31
  396. package/shaders/HueSaturationShader.js.map +1 -1
  397. package/shaders/KaleidoShader.cjs +37 -24
  398. package/shaders/KaleidoShader.cjs.map +1 -1
  399. package/shaders/KaleidoShader.js +37 -24
  400. package/shaders/KaleidoShader.js.map +1 -1
  401. package/shaders/LuminosityHighPassShader.cjs +43 -24
  402. package/shaders/LuminosityHighPassShader.cjs.map +1 -1
  403. package/shaders/LuminosityHighPassShader.js +43 -24
  404. package/shaders/LuminosityHighPassShader.js.map +1 -1
  405. package/shaders/LuminosityShader.cjs +34 -17
  406. package/shaders/LuminosityShader.cjs.map +1 -1
  407. package/shaders/LuminosityShader.js +34 -17
  408. package/shaders/LuminosityShader.js.map +1 -1
  409. package/shaders/MirrorShader.cjs +39 -26
  410. package/shaders/MirrorShader.cjs.map +1 -1
  411. package/shaders/MirrorShader.js +39 -26
  412. package/shaders/MirrorShader.js.map +1 -1
  413. package/shaders/NormalMapShader.cjs +36 -21
  414. package/shaders/NormalMapShader.cjs.map +1 -1
  415. package/shaders/NormalMapShader.js +36 -21
  416. package/shaders/NormalMapShader.js.map +1 -1
  417. package/shaders/ParallaxShader.cjs +147 -97
  418. package/shaders/ParallaxShader.cjs.map +1 -1
  419. package/shaders/ParallaxShader.js +147 -97
  420. package/shaders/ParallaxShader.js.map +1 -1
  421. package/shaders/PixelShader.cjs +31 -18
  422. package/shaders/PixelShader.cjs.map +1 -1
  423. package/shaders/PixelShader.js +31 -18
  424. package/shaders/PixelShader.js.map +1 -1
  425. package/shaders/RGBShiftShader.cjs +33 -20
  426. package/shaders/RGBShiftShader.cjs.map +1 -1
  427. package/shaders/RGBShiftShader.js +33 -20
  428. package/shaders/RGBShiftShader.js.map +1 -1
  429. package/shaders/SAOShader.cjs +154 -117
  430. package/shaders/SAOShader.cjs.map +1 -1
  431. package/shaders/SAOShader.js +154 -117
  432. package/shaders/SAOShader.js.map +1 -1
  433. package/shaders/SMAAShader.cjs +358 -270
  434. package/shaders/SMAAShader.cjs.map +1 -1
  435. package/shaders/SMAAShader.js +358 -270
  436. package/shaders/SMAAShader.js.map +1 -1
  437. package/shaders/SSAOShader.cjs +236 -142
  438. package/shaders/SSAOShader.cjs.map +1 -1
  439. package/shaders/SSAOShader.js +236 -142
  440. package/shaders/SSAOShader.js.map +1 -1
  441. package/shaders/SSRShader.cjs +4 -4
  442. package/shaders/SSRShader.cjs.map +1 -1
  443. package/shaders/SSRShader.js +4 -4
  444. package/shaders/SSRShader.js.map +1 -1
  445. package/shaders/SepiaShader.cjs +36 -20
  446. package/shaders/SepiaShader.cjs.map +1 -1
  447. package/shaders/SepiaShader.js +36 -20
  448. package/shaders/SepiaShader.js.map +1 -1
  449. package/shaders/SobelOperatorShader.cjs +64 -37
  450. package/shaders/SobelOperatorShader.cjs.map +1 -1
  451. package/shaders/SobelOperatorShader.js +64 -37
  452. package/shaders/SobelOperatorShader.js.map +1 -1
  453. package/shaders/TechnicolorShader.cjs +29 -16
  454. package/shaders/TechnicolorShader.cjs.map +1 -1
  455. package/shaders/TechnicolorShader.js +29 -16
  456. package/shaders/TechnicolorShader.js.map +1 -1
  457. package/shaders/ToneMapShader.cjs +55 -35
  458. package/shaders/ToneMapShader.cjs.map +1 -1
  459. package/shaders/ToneMapShader.js +55 -35
  460. package/shaders/ToneMapShader.js.map +1 -1
  461. package/shaders/ToonShader.cjs +275 -165
  462. package/shaders/ToonShader.cjs.map +1 -1
  463. package/shaders/ToonShader.js +275 -165
  464. package/shaders/ToonShader.js.map +1 -1
  465. package/shaders/TriangleBlurShader.cjs +50 -27
  466. package/shaders/TriangleBlurShader.cjs.map +1 -1
  467. package/shaders/TriangleBlurShader.js +50 -27
  468. package/shaders/TriangleBlurShader.js.map +1 -1
  469. package/shaders/UnpackDepthRGBAShader.cjs +32 -17
  470. package/shaders/UnpackDepthRGBAShader.cjs.map +1 -1
  471. package/shaders/UnpackDepthRGBAShader.js +32 -17
  472. package/shaders/UnpackDepthRGBAShader.js.map +1 -1
  473. package/shaders/VerticalTiltShiftShader.cjs +43 -27
  474. package/shaders/VerticalTiltShiftShader.cjs.map +1 -1
  475. package/shaders/VerticalTiltShiftShader.js +43 -27
  476. package/shaders/VerticalTiltShiftShader.js.map +1 -1
  477. package/shaders/VignetteShader.cjs +43 -27
  478. package/shaders/VignetteShader.cjs.map +1 -1
  479. package/shaders/VignetteShader.js +43 -27
  480. package/shaders/VignetteShader.js.map +1 -1
  481. package/shaders/VolumeShader.cjs +264 -213
  482. package/shaders/VolumeShader.cjs.map +1 -1
  483. package/shaders/VolumeShader.js +264 -213
  484. package/shaders/VolumeShader.js.map +1 -1
  485. package/shaders/WaterRefractionShader.cjs +63 -35
  486. package/shaders/WaterRefractionShader.cjs.map +1 -1
  487. package/shaders/WaterRefractionShader.js +63 -35
  488. package/shaders/WaterRefractionShader.js.map +1 -1
  489. package/utils/GeometryCompressionUtils.cjs +2 -1
  490. package/utils/GeometryCompressionUtils.cjs.map +1 -1
  491. package/utils/GeometryCompressionUtils.js +3 -2
  492. package/utils/GeometryCompressionUtils.js.map +1 -1
  493. package/utils/RoughnessMipmapper.cjs +3 -3
  494. package/utils/RoughnessMipmapper.cjs.map +1 -1
  495. package/utils/RoughnessMipmapper.js +4 -4
  496. package/utils/RoughnessMipmapper.js.map +1 -1
  497. package/webxr/ARButton.cjs +3 -3
  498. package/webxr/ARButton.cjs.map +1 -1
  499. package/webxr/ARButton.d.ts +3 -3
  500. package/webxr/ARButton.js +3 -3
  501. package/webxr/ARButton.js.map +1 -1
  502. package/webxr/OculusHandPointerModel.cjs +2 -2
  503. package/webxr/OculusHandPointerModel.cjs.map +1 -1
  504. package/webxr/OculusHandPointerModel.js +2 -2
  505. package/webxr/OculusHandPointerModel.js.map +1 -1
  506. package/webxr/VRButton.cjs +98 -95
  507. package/webxr/VRButton.cjs.map +1 -1
  508. package/webxr/VRButton.d.ts +9 -6
  509. package/webxr/VRButton.js +98 -95
  510. package/webxr/VRButton.js.map +1 -1
  511. package/webxr/XRHandPrimitiveModel.cjs +2 -2
  512. package/webxr/XRHandPrimitiveModel.cjs.map +1 -1
  513. package/webxr/XRHandPrimitiveModel.js +3 -3
  514. package/webxr/XRHandPrimitiveModel.js.map +1 -1
@@ -6,548 +6,557 @@ var __publicField = (obj, key, value) => {
6
6
  };
7
7
  import { BufferGeometry, Vector3, Uint32BufferAttribute, Float32BufferAttribute, DynamicDrawUsage, MathUtils } from "three";
8
8
  import { SimplexNoise } from "../math/SimplexNoise.js";
9
- const _LightningStrike = class extends BufferGeometry {
10
- constructor(rayParameters = {}) {
11
- super();
12
- this.isLightningStrike = true;
13
- this.type = "LightningStrike";
14
- this.init(_LightningStrike.copyParameters(rayParameters, rayParameters));
15
- this.createMesh();
16
- }
17
- static createRandomGenerator() {
18
- const numSeeds = 2053;
19
- const seeds = [];
20
- for (let i = 0; i < numSeeds; i++) {
21
- seeds.push(Math.random());
9
+ const LightningStrike = /* @__PURE__ */ (() => {
10
+ const _LightningStrike = class extends BufferGeometry {
11
+ constructor(rayParameters = {}) {
12
+ super();
13
+ this.isLightningStrike = true;
14
+ this.type = "LightningStrike";
15
+ this.init(_LightningStrike.copyParameters(rayParameters, rayParameters));
16
+ this.createMesh();
22
17
  }
23
- const generator = {
24
- currentSeed: 0,
25
- random: function() {
26
- const value = seeds[generator.currentSeed];
27
- generator.currentSeed = (generator.currentSeed + 1) % numSeeds;
28
- return value;
29
- },
30
- getSeed: function() {
31
- return generator.currentSeed / numSeeds;
32
- },
33
- setSeed: function(seed) {
34
- generator.currentSeed = Math.floor(seed * numSeeds) % numSeeds;
18
+ static createRandomGenerator() {
19
+ const numSeeds = 2053;
20
+ const seeds = [];
21
+ for (let i = 0; i < numSeeds; i++) {
22
+ seeds.push(Math.random());
35
23
  }
36
- };
37
- return generator;
38
- }
39
- static copyParameters(dest = {}, source = {}) {
40
- const vecCopy = function(v) {
41
- if (source === dest) {
42
- return v;
24
+ const generator = {
25
+ currentSeed: 0,
26
+ random: function() {
27
+ const value = seeds[generator.currentSeed];
28
+ generator.currentSeed = (generator.currentSeed + 1) % numSeeds;
29
+ return value;
30
+ },
31
+ getSeed: function() {
32
+ return generator.currentSeed / numSeeds;
33
+ },
34
+ setSeed: function(seed) {
35
+ generator.currentSeed = Math.floor(seed * numSeeds) % numSeeds;
36
+ }
37
+ };
38
+ return generator;
39
+ }
40
+ static copyParameters(dest = {}, source = {}) {
41
+ const vecCopy = function(v) {
42
+ if (source === dest) {
43
+ return v;
44
+ } else {
45
+ return v.clone();
46
+ }
47
+ };
48
+ dest.sourceOffset = source.sourceOffset !== void 0 ? vecCopy(source.sourceOffset) : new Vector3(0, 100, 0), dest.destOffset = source.destOffset !== void 0 ? vecCopy(source.destOffset) : new Vector3(0, 0, 0), dest.timeScale = source.timeScale !== void 0 ? source.timeScale : 1, dest.roughness = source.roughness !== void 0 ? source.roughness : 0.9, dest.straightness = source.straightness !== void 0 ? source.straightness : 0.7, dest.up0 = source.up0 !== void 0 ? vecCopy(source.up0) : new Vector3(0, 0, 1);
49
+ dest.up1 = source.up1 !== void 0 ? vecCopy(source.up1) : new Vector3(0, 0, 1), dest.radius0 = source.radius0 !== void 0 ? source.radius0 : 1, dest.radius1 = source.radius1 !== void 0 ? source.radius1 : 1, dest.radius0Factor = source.radius0Factor !== void 0 ? source.radius0Factor : 0.5, dest.radius1Factor = source.radius1Factor !== void 0 ? source.radius1Factor : 0.2, dest.minRadius = source.minRadius !== void 0 ? source.minRadius : 0.2, // These parameters should not be changed after lightning creation. They can be changed but the ray will change its form abruptly:
50
+ dest.isEternal = source.isEternal !== void 0 ? source.isEternal : source.birthTime === void 0 || source.deathTime === void 0, dest.birthTime = source.birthTime, dest.deathTime = source.deathTime, dest.propagationTimeFactor = source.propagationTimeFactor !== void 0 ? source.propagationTimeFactor : 0.1, dest.vanishingTimeFactor = source.vanishingTimeFactor !== void 0 ? source.vanishingTimeFactor : 0.9, dest.subrayPeriod = source.subrayPeriod !== void 0 ? source.subrayPeriod : 4, dest.subrayDutyCycle = source.subrayDutyCycle !== void 0 ? source.subrayDutyCycle : 0.6;
51
+ dest.maxIterations = source.maxIterations !== void 0 ? source.maxIterations : 9;
52
+ dest.isStatic = source.isStatic !== void 0 ? source.isStatic : false;
53
+ dest.ramification = source.ramification !== void 0 ? source.ramification : 5;
54
+ dest.maxSubrayRecursion = source.maxSubrayRecursion !== void 0 ? source.maxSubrayRecursion : 3;
55
+ dest.recursionProbability = source.recursionProbability !== void 0 ? source.recursionProbability : 0.6;
56
+ dest.generateUVs = source.generateUVs !== void 0 ? source.generateUVs : false;
57
+ dest.randomGenerator = source.randomGenerator, dest.noiseSeed = source.noiseSeed, dest.onDecideSubrayCreation = source.onDecideSubrayCreation, dest.onSubrayCreation = source.onSubrayCreation;
58
+ return dest;
59
+ }
60
+ update(time) {
61
+ if (this.isStatic)
62
+ return;
63
+ if (this.rayParameters.isEternal || this.rayParameters.birthTime <= time && time <= this.rayParameters.deathTime) {
64
+ this.updateMesh(time);
65
+ if (time < this.subrays[0].endPropagationTime) {
66
+ this.state = _LightningStrike.RAY_PROPAGATING;
67
+ } else if (time > this.subrays[0].beginVanishingTime) {
68
+ this.state = _LightningStrike.RAY_VANISHING;
69
+ } else {
70
+ this.state = _LightningStrike.RAY_STEADY;
71
+ }
72
+ this.visible = true;
43
73
  } else {
44
- return v.clone();
74
+ this.visible = false;
75
+ if (time < this.rayParameters.birthTime) {
76
+ this.state = _LightningStrike.RAY_UNBORN;
77
+ } else {
78
+ this.state = _LightningStrike.RAY_EXTINGUISHED;
79
+ }
45
80
  }
46
- };
47
- dest.sourceOffset = source.sourceOffset !== void 0 ? vecCopy(source.sourceOffset) : new Vector3(0, 100, 0), dest.destOffset = source.destOffset !== void 0 ? vecCopy(source.destOffset) : new Vector3(0, 0, 0), dest.timeScale = source.timeScale !== void 0 ? source.timeScale : 1, dest.roughness = source.roughness !== void 0 ? source.roughness : 0.9, dest.straightness = source.straightness !== void 0 ? source.straightness : 0.7, dest.up0 = source.up0 !== void 0 ? vecCopy(source.up0) : new Vector3(0, 0, 1);
48
- dest.up1 = source.up1 !== void 0 ? vecCopy(source.up1) : new Vector3(0, 0, 1), dest.radius0 = source.radius0 !== void 0 ? source.radius0 : 1, dest.radius1 = source.radius1 !== void 0 ? source.radius1 : 1, dest.radius0Factor = source.radius0Factor !== void 0 ? source.radius0Factor : 0.5, dest.radius1Factor = source.radius1Factor !== void 0 ? source.radius1Factor : 0.2, dest.minRadius = source.minRadius !== void 0 ? source.minRadius : 0.2, // These parameters should not be changed after lightning creation. They can be changed but the ray will change its form abruptly:
49
- dest.isEternal = source.isEternal !== void 0 ? source.isEternal : source.birthTime === void 0 || source.deathTime === void 0, dest.birthTime = source.birthTime, dest.deathTime = source.deathTime, dest.propagationTimeFactor = source.propagationTimeFactor !== void 0 ? source.propagationTimeFactor : 0.1, dest.vanishingTimeFactor = source.vanishingTimeFactor !== void 0 ? source.vanishingTimeFactor : 0.9, dest.subrayPeriod = source.subrayPeriod !== void 0 ? source.subrayPeriod : 4, dest.subrayDutyCycle = source.subrayDutyCycle !== void 0 ? source.subrayDutyCycle : 0.6;
50
- dest.maxIterations = source.maxIterations !== void 0 ? source.maxIterations : 9;
51
- dest.isStatic = source.isStatic !== void 0 ? source.isStatic : false;
52
- dest.ramification = source.ramification !== void 0 ? source.ramification : 5;
53
- dest.maxSubrayRecursion = source.maxSubrayRecursion !== void 0 ? source.maxSubrayRecursion : 3;
54
- dest.recursionProbability = source.recursionProbability !== void 0 ? source.recursionProbability : 0.6;
55
- dest.generateUVs = source.generateUVs !== void 0 ? source.generateUVs : false;
56
- dest.randomGenerator = source.randomGenerator, dest.noiseSeed = source.noiseSeed, dest.onDecideSubrayCreation = source.onDecideSubrayCreation, dest.onSubrayCreation = source.onSubrayCreation;
57
- return dest;
58
- }
59
- update(time) {
60
- if (this.isStatic)
61
- return;
62
- if (this.rayParameters.isEternal || this.rayParameters.birthTime <= time && time <= this.rayParameters.deathTime) {
63
- this.updateMesh(time);
64
- if (time < this.subrays[0].endPropagationTime) {
65
- this.state = _LightningStrike.RAY_PROPAGATING;
66
- } else if (time > this.subrays[0].beginVanishingTime) {
67
- this.state = _LightningStrike.RAY_VANISHING;
81
+ }
82
+ init(rayParameters) {
83
+ this.rayParameters = rayParameters;
84
+ this.maxIterations = rayParameters.maxIterations !== void 0 ? Math.floor(rayParameters.maxIterations) : 9;
85
+ rayParameters.maxIterations = this.maxIterations;
86
+ this.isStatic = rayParameters.isStatic !== void 0 ? rayParameters.isStatic : false;
87
+ rayParameters.isStatic = this.isStatic;
88
+ this.ramification = rayParameters.ramification !== void 0 ? Math.floor(rayParameters.ramification) : 5;
89
+ rayParameters.ramification = this.ramification;
90
+ this.maxSubrayRecursion = rayParameters.maxSubrayRecursion !== void 0 ? Math.floor(rayParameters.maxSubrayRecursion) : 3;
91
+ rayParameters.maxSubrayRecursion = this.maxSubrayRecursion;
92
+ this.recursionProbability = rayParameters.recursionProbability !== void 0 ? rayParameters.recursionProbability : 0.6;
93
+ rayParameters.recursionProbability = this.recursionProbability;
94
+ this.generateUVs = rayParameters.generateUVs !== void 0 ? rayParameters.generateUVs : false;
95
+ rayParameters.generateUVs = this.generateUVs;
96
+ if (rayParameters.randomGenerator !== void 0) {
97
+ this.randomGenerator = rayParameters.randomGenerator;
98
+ this.seedGenerator = rayParameters.randomGenerator;
99
+ if (rayParameters.noiseSeed !== void 0) {
100
+ this.seedGenerator.setSeed(rayParameters.noiseSeed);
101
+ }
68
102
  } else {
69
- this.state = _LightningStrike.RAY_STEADY;
103
+ this.randomGenerator = _LightningStrike.createRandomGenerator();
104
+ this.seedGenerator = Math;
70
105
  }
71
- this.visible = true;
72
- } else {
73
- this.visible = false;
74
- if (time < this.rayParameters.birthTime) {
75
- this.state = _LightningStrike.RAY_UNBORN;
106
+ if (rayParameters.onDecideSubrayCreation !== void 0) {
107
+ this.onDecideSubrayCreation = rayParameters.onDecideSubrayCreation;
76
108
  } else {
77
- this.state = _LightningStrike.RAY_EXTINGUISHED;
109
+ this.createDefaultSubrayCreationCallbacks();
110
+ if (rayParameters.onSubrayCreation !== void 0) {
111
+ this.onSubrayCreation = rayParameters.onSubrayCreation;
112
+ }
78
113
  }
114
+ this.state = _LightningStrike.RAY_INITIALIZED;
115
+ this.maxSubrays = Math.ceil(1 + Math.pow(this.ramification, Math.max(0, this.maxSubrayRecursion - 1)));
116
+ rayParameters.maxSubrays = this.maxSubrays;
117
+ this.maxRaySegments = 2 * (1 << this.maxIterations);
118
+ this.subrays = [];
119
+ for (let i = 0; i < this.maxSubrays; i++) {
120
+ this.subrays.push(this.createSubray());
121
+ }
122
+ this.raySegments = [];
123
+ for (let i = 0; i < this.maxRaySegments; i++) {
124
+ this.raySegments.push(this.createSegment());
125
+ }
126
+ this.time = 0;
127
+ this.timeFraction = 0;
128
+ this.currentSegmentCallback = null;
129
+ this.currentCreateTriangleVertices = this.generateUVs ? this.createTriangleVerticesWithUVs : this.createTriangleVerticesWithoutUVs;
130
+ this.numSubrays = 0;
131
+ this.currentSubray = null;
132
+ this.currentSegmentIndex = 0;
133
+ this.isInitialSegment = false;
134
+ this.subrayProbability = 0;
135
+ this.currentVertex = 0;
136
+ this.currentIndex = 0;
137
+ this.currentCoordinate = 0;
138
+ this.currentUVCoordinate = 0;
139
+ this.vertices = null;
140
+ this.uvs = null;
141
+ this.indices = null;
142
+ this.positionAttribute = null;
143
+ this.uvsAttribute = null;
144
+ this.simplexX = new SimplexNoise(this.seedGenerator);
145
+ this.simplexY = new SimplexNoise(this.seedGenerator);
146
+ this.simplexZ = new SimplexNoise(this.seedGenerator);
147
+ this.forwards = new Vector3();
148
+ this.forwardsFill = new Vector3();
149
+ this.side = new Vector3();
150
+ this.down = new Vector3();
151
+ this.middlePos = new Vector3();
152
+ this.middleLinPos = new Vector3();
153
+ this.newPos = new Vector3();
154
+ this.vPos = new Vector3();
155
+ this.cross1 = new Vector3();
79
156
  }
80
- }
81
- init(rayParameters) {
82
- this.rayParameters = rayParameters;
83
- this.maxIterations = rayParameters.maxIterations !== void 0 ? Math.floor(rayParameters.maxIterations) : 9;
84
- rayParameters.maxIterations = this.maxIterations;
85
- this.isStatic = rayParameters.isStatic !== void 0 ? rayParameters.isStatic : false;
86
- rayParameters.isStatic = this.isStatic;
87
- this.ramification = rayParameters.ramification !== void 0 ? Math.floor(rayParameters.ramification) : 5;
88
- rayParameters.ramification = this.ramification;
89
- this.maxSubrayRecursion = rayParameters.maxSubrayRecursion !== void 0 ? Math.floor(rayParameters.maxSubrayRecursion) : 3;
90
- rayParameters.maxSubrayRecursion = this.maxSubrayRecursion;
91
- this.recursionProbability = rayParameters.recursionProbability !== void 0 ? rayParameters.recursionProbability : 0.6;
92
- rayParameters.recursionProbability = this.recursionProbability;
93
- this.generateUVs = rayParameters.generateUVs !== void 0 ? rayParameters.generateUVs : false;
94
- rayParameters.generateUVs = this.generateUVs;
95
- if (rayParameters.randomGenerator !== void 0) {
96
- this.randomGenerator = rayParameters.randomGenerator;
97
- this.seedGenerator = rayParameters.randomGenerator;
98
- if (rayParameters.noiseSeed !== void 0) {
99
- this.seedGenerator.setSeed(rayParameters.noiseSeed);
157
+ createMesh() {
158
+ const maxDrawableSegmentsPerSubRay = 1 << this.maxIterations;
159
+ const maxVerts = 3 * (maxDrawableSegmentsPerSubRay + 1) * this.maxSubrays;
160
+ const maxIndices = 18 * maxDrawableSegmentsPerSubRay * this.maxSubrays;
161
+ this.vertices = new Float32Array(maxVerts * 3);
162
+ this.indices = new Uint32Array(maxIndices);
163
+ if (this.generateUVs) {
164
+ this.uvs = new Float32Array(maxVerts * 2);
165
+ }
166
+ this.fillMesh(0);
167
+ this.setIndex(new Uint32BufferAttribute(this.indices, 1));
168
+ this.positionAttribute = new Float32BufferAttribute(this.vertices, 3);
169
+ this.setAttribute("position", this.positionAttribute);
170
+ if (this.generateUVs) {
171
+ this.uvsAttribute = new Float32BufferAttribute(new Float32Array(this.uvs), 2);
172
+ this.setAttribute("uv", this.uvsAttribute);
173
+ }
174
+ if (!this.isStatic) {
175
+ this.index.usage = DynamicDrawUsage;
176
+ this.positionAttribute.usage = DynamicDrawUsage;
177
+ if (this.generateUVs) {
178
+ this.uvsAttribute.usage = DynamicDrawUsage;
179
+ }
180
+ }
181
+ this.vertices = this.positionAttribute.array;
182
+ this.indices = this.index.array;
183
+ if (this.generateUVs) {
184
+ this.uvs = this.uvsAttribute.array;
100
185
  }
101
- } else {
102
- this.randomGenerator = _LightningStrike.createRandomGenerator();
103
- this.seedGenerator = Math;
104
186
  }
105
- if (rayParameters.onDecideSubrayCreation !== void 0) {
106
- this.onDecideSubrayCreation = rayParameters.onDecideSubrayCreation;
107
- } else {
108
- this.createDefaultSubrayCreationCallbacks();
109
- if (rayParameters.onSubrayCreation !== void 0) {
110
- this.onSubrayCreation = rayParameters.onSubrayCreation;
187
+ updateMesh(time) {
188
+ this.fillMesh(time);
189
+ this.drawRange.count = this.currentIndex;
190
+ this.index.needsUpdate = true;
191
+ this.positionAttribute.needsUpdate = true;
192
+ if (this.generateUVs) {
193
+ this.uvsAttribute.needsUpdate = true;
111
194
  }
112
195
  }
113
- this.state = _LightningStrike.RAY_INITIALIZED;
114
- this.maxSubrays = Math.ceil(1 + Math.pow(this.ramification, Math.max(0, this.maxSubrayRecursion - 1)));
115
- rayParameters.maxSubrays = this.maxSubrays;
116
- this.maxRaySegments = 2 * (1 << this.maxIterations);
117
- this.subrays = [];
118
- for (let i = 0; i < this.maxSubrays; i++) {
119
- this.subrays.push(this.createSubray());
196
+ fillMesh(time) {
197
+ const scope = this;
198
+ this.currentVertex = 0;
199
+ this.currentIndex = 0;
200
+ this.currentCoordinate = 0;
201
+ this.currentUVCoordinate = 0;
202
+ this.fractalRay(time, function fillVertices(segment) {
203
+ const subray = scope.currentSubray;
204
+ if (time < subray.birthTime) {
205
+ return;
206
+ } else if (this.rayParameters.isEternal && scope.currentSubray.recursion == 0) {
207
+ scope.createPrism(segment);
208
+ scope.onDecideSubrayCreation(segment, scope);
209
+ } else if (time < subray.endPropagationTime) {
210
+ if (scope.timeFraction >= segment.fraction0 * subray.propagationTimeFactor) {
211
+ scope.createPrism(segment);
212
+ scope.onDecideSubrayCreation(segment, scope);
213
+ }
214
+ } else if (time < subray.beginVanishingTime) {
215
+ scope.createPrism(segment);
216
+ scope.onDecideSubrayCreation(segment, scope);
217
+ } else {
218
+ if (scope.timeFraction <= subray.vanishingTimeFactor + segment.fraction1 * (1 - subray.vanishingTimeFactor)) {
219
+ scope.createPrism(segment);
220
+ }
221
+ scope.onDecideSubrayCreation(segment, scope);
222
+ }
223
+ });
120
224
  }
121
- this.raySegments = [];
122
- for (let i = 0; i < this.maxRaySegments; i++) {
123
- this.raySegments.push(this.createSegment());
225
+ addNewSubray() {
226
+ return this.subrays[this.numSubrays++];
124
227
  }
125
- this.time = 0;
126
- this.timeFraction = 0;
127
- this.currentSegmentCallback = null;
128
- this.currentCreateTriangleVertices = this.generateUVs ? this.createTriangleVerticesWithUVs : this.createTriangleVerticesWithoutUVs;
129
- this.numSubrays = 0;
130
- this.currentSubray = null;
131
- this.currentSegmentIndex = 0;
132
- this.isInitialSegment = false;
133
- this.subrayProbability = 0;
134
- this.currentVertex = 0;
135
- this.currentIndex = 0;
136
- this.currentCoordinate = 0;
137
- this.currentUVCoordinate = 0;
138
- this.vertices = null;
139
- this.uvs = null;
140
- this.indices = null;
141
- this.positionAttribute = null;
142
- this.uvsAttribute = null;
143
- this.simplexX = new SimplexNoise(this.seedGenerator);
144
- this.simplexY = new SimplexNoise(this.seedGenerator);
145
- this.simplexZ = new SimplexNoise(this.seedGenerator);
146
- this.forwards = new Vector3();
147
- this.forwardsFill = new Vector3();
148
- this.side = new Vector3();
149
- this.down = new Vector3();
150
- this.middlePos = new Vector3();
151
- this.middleLinPos = new Vector3();
152
- this.newPos = new Vector3();
153
- this.vPos = new Vector3();
154
- this.cross1 = new Vector3();
155
- }
156
- createMesh() {
157
- const maxDrawableSegmentsPerSubRay = 1 << this.maxIterations;
158
- const maxVerts = 3 * (maxDrawableSegmentsPerSubRay + 1) * this.maxSubrays;
159
- const maxIndices = 18 * maxDrawableSegmentsPerSubRay * this.maxSubrays;
160
- this.vertices = new Float32Array(maxVerts * 3);
161
- this.indices = new Uint32Array(maxIndices);
162
- if (this.generateUVs) {
163
- this.uvs = new Float32Array(maxVerts * 2);
228
+ initSubray(subray, rayParameters) {
229
+ subray.pos0.copy(rayParameters.sourceOffset);
230
+ subray.pos1.copy(rayParameters.destOffset);
231
+ subray.up0.copy(rayParameters.up0);
232
+ subray.up1.copy(rayParameters.up1);
233
+ subray.radius0 = rayParameters.radius0;
234
+ subray.radius1 = rayParameters.radius1;
235
+ subray.birthTime = rayParameters.birthTime;
236
+ subray.deathTime = rayParameters.deathTime;
237
+ subray.timeScale = rayParameters.timeScale;
238
+ subray.roughness = rayParameters.roughness;
239
+ subray.straightness = rayParameters.straightness;
240
+ subray.propagationTimeFactor = rayParameters.propagationTimeFactor;
241
+ subray.vanishingTimeFactor = rayParameters.vanishingTimeFactor;
242
+ subray.maxIterations = this.maxIterations;
243
+ subray.seed = rayParameters.noiseSeed !== void 0 ? rayParameters.noiseSeed : 0;
244
+ subray.recursion = 0;
164
245
  }
165
- this.fillMesh(0);
166
- this.setIndex(new Uint32BufferAttribute(this.indices, 1));
167
- this.positionAttribute = new Float32BufferAttribute(this.vertices, 3);
168
- this.setAttribute("position", this.positionAttribute);
169
- if (this.generateUVs) {
170
- this.uvsAttribute = new Float32BufferAttribute(new Float32Array(this.uvs), 2);
171
- this.setAttribute("uv", this.uvsAttribute);
246
+ fractalRay(time, segmentCallback) {
247
+ this.time = time;
248
+ this.currentSegmentCallback = segmentCallback;
249
+ this.numSubrays = 0;
250
+ this.initSubray(this.addNewSubray(), this.rayParameters);
251
+ for (let subrayIndex = 0; subrayIndex < this.numSubrays; subrayIndex++) {
252
+ const subray = this.subrays[subrayIndex];
253
+ this.currentSubray = subray;
254
+ this.randomGenerator.setSeed(subray.seed);
255
+ subray.endPropagationTime = MathUtils.lerp(subray.birthTime, subray.deathTime, subray.propagationTimeFactor);
256
+ subray.beginVanishingTime = MathUtils.lerp(subray.deathTime, subray.birthTime, 1 - subray.vanishingTimeFactor);
257
+ const random1 = this.randomGenerator.random;
258
+ subray.linPos0.set(random1(), random1(), random1()).multiplyScalar(1e3);
259
+ subray.linPos1.set(random1(), random1(), random1()).multiplyScalar(1e3);
260
+ this.timeFraction = (time - subray.birthTime) / (subray.deathTime - subray.birthTime);
261
+ this.currentSegmentIndex = 0;
262
+ this.isInitialSegment = true;
263
+ const segment = this.getNewSegment();
264
+ segment.iteration = 0;
265
+ segment.pos0.copy(subray.pos0);
266
+ segment.pos1.copy(subray.pos1);
267
+ segment.linPos0.copy(subray.linPos0);
268
+ segment.linPos1.copy(subray.linPos1);
269
+ segment.up0.copy(subray.up0);
270
+ segment.up1.copy(subray.up1);
271
+ segment.radius0 = subray.radius0;
272
+ segment.radius1 = subray.radius1;
273
+ segment.fraction0 = 0;
274
+ segment.fraction1 = 1;
275
+ segment.positionVariationFactor = 1 - subray.straightness;
276
+ this.subrayProbability = this.ramification * Math.pow(this.recursionProbability, subray.recursion) / (1 << subray.maxIterations);
277
+ this.fractalRayRecursive(segment);
278
+ }
279
+ this.currentSegmentCallback = null;
280
+ this.currentSubray = null;
172
281
  }
173
- if (!this.isStatic) {
174
- this.index.usage = DynamicDrawUsage;
175
- this.positionAttribute.usage = DynamicDrawUsage;
176
- if (this.generateUVs) {
177
- this.uvsAttribute.usage = DynamicDrawUsage;
282
+ fractalRayRecursive(segment) {
283
+ if (segment.iteration >= this.currentSubray.maxIterations) {
284
+ this.currentSegmentCallback(segment);
285
+ return;
286
+ }
287
+ this.forwards.subVectors(segment.pos1, segment.pos0);
288
+ let lForwards = this.forwards.length();
289
+ if (lForwards < 1e-6) {
290
+ this.forwards.set(0, 0, 0.01);
291
+ lForwards = this.forwards.length();
178
292
  }
293
+ const middleRadius = (segment.radius0 + segment.radius1) * 0.5;
294
+ const middleFraction = (segment.fraction0 + segment.fraction1) * 0.5;
295
+ const timeDimension = this.time * this.currentSubray.timeScale * Math.pow(2, segment.iteration);
296
+ this.middlePos.lerpVectors(segment.pos0, segment.pos1, 0.5);
297
+ this.middleLinPos.lerpVectors(segment.linPos0, segment.linPos1, 0.5);
298
+ const p = this.middleLinPos;
299
+ this.newPos.set(
300
+ this.simplexX.noise4d(p.x, p.y, p.z, timeDimension),
301
+ this.simplexY.noise4d(p.x, p.y, p.z, timeDimension),
302
+ this.simplexZ.noise4d(p.x, p.y, p.z, timeDimension)
303
+ );
304
+ this.newPos.multiplyScalar(segment.positionVariationFactor * lForwards);
305
+ this.newPos.add(this.middlePos);
306
+ const newSegment1 = this.getNewSegment();
307
+ newSegment1.pos0.copy(segment.pos0);
308
+ newSegment1.pos1.copy(this.newPos);
309
+ newSegment1.linPos0.copy(segment.linPos0);
310
+ newSegment1.linPos1.copy(this.middleLinPos);
311
+ newSegment1.up0.copy(segment.up0);
312
+ newSegment1.up1.copy(segment.up1);
313
+ newSegment1.radius0 = segment.radius0;
314
+ newSegment1.radius1 = middleRadius;
315
+ newSegment1.fraction0 = segment.fraction0;
316
+ newSegment1.fraction1 = middleFraction;
317
+ newSegment1.positionVariationFactor = segment.positionVariationFactor * this.currentSubray.roughness;
318
+ newSegment1.iteration = segment.iteration + 1;
319
+ const newSegment2 = this.getNewSegment();
320
+ newSegment2.pos0.copy(this.newPos);
321
+ newSegment2.pos1.copy(segment.pos1);
322
+ newSegment2.linPos0.copy(this.middleLinPos);
323
+ newSegment2.linPos1.copy(segment.linPos1);
324
+ this.cross1.crossVectors(segment.up0, this.forwards.normalize());
325
+ newSegment2.up0.crossVectors(this.forwards, this.cross1).normalize();
326
+ newSegment2.up1.copy(segment.up1);
327
+ newSegment2.radius0 = middleRadius;
328
+ newSegment2.radius1 = segment.radius1;
329
+ newSegment2.fraction0 = middleFraction;
330
+ newSegment2.fraction1 = segment.fraction1;
331
+ newSegment2.positionVariationFactor = segment.positionVariationFactor * this.currentSubray.roughness;
332
+ newSegment2.iteration = segment.iteration + 1;
333
+ this.fractalRayRecursive(newSegment1);
334
+ this.fractalRayRecursive(newSegment2);
179
335
  }
180
- this.vertices = this.positionAttribute.array;
181
- this.indices = this.index.array;
182
- if (this.generateUVs) {
183
- this.uvs = this.uvsAttribute.array;
336
+ createPrism(segment) {
337
+ this.forwardsFill.subVectors(segment.pos1, segment.pos0).normalize();
338
+ if (this.isInitialSegment) {
339
+ this.currentCreateTriangleVertices(segment.pos0, segment.up0, this.forwardsFill, segment.radius0, 0);
340
+ this.isInitialSegment = false;
341
+ }
342
+ this.currentCreateTriangleVertices(
343
+ segment.pos1,
344
+ segment.up0,
345
+ this.forwardsFill,
346
+ segment.radius1,
347
+ segment.fraction1
348
+ );
349
+ this.createPrismFaces();
184
350
  }
185
- }
186
- updateMesh(time) {
187
- this.fillMesh(time);
188
- this.drawRange.count = this.currentIndex;
189
- this.index.needsUpdate = true;
190
- this.positionAttribute.needsUpdate = true;
191
- if (this.generateUVs) {
192
- this.uvsAttribute.needsUpdate = true;
351
+ createTriangleVerticesWithoutUVs(pos, up, forwards, radius) {
352
+ this.side.crossVectors(up, forwards).multiplyScalar(radius * _LightningStrike.COS30DEG);
353
+ this.down.copy(up).multiplyScalar(-radius * _LightningStrike.SIN30DEG);
354
+ const p = this.vPos;
355
+ const v = this.vertices;
356
+ p.copy(pos).sub(this.side).add(this.down);
357
+ v[this.currentCoordinate++] = p.x;
358
+ v[this.currentCoordinate++] = p.y;
359
+ v[this.currentCoordinate++] = p.z;
360
+ p.copy(pos).add(this.side).add(this.down);
361
+ v[this.currentCoordinate++] = p.x;
362
+ v[this.currentCoordinate++] = p.y;
363
+ v[this.currentCoordinate++] = p.z;
364
+ p.copy(up).multiplyScalar(radius).add(pos);
365
+ v[this.currentCoordinate++] = p.x;
366
+ v[this.currentCoordinate++] = p.y;
367
+ v[this.currentCoordinate++] = p.z;
368
+ this.currentVertex += 3;
193
369
  }
194
- }
195
- fillMesh(time) {
196
- const scope = this;
197
- this.currentVertex = 0;
198
- this.currentIndex = 0;
199
- this.currentCoordinate = 0;
200
- this.currentUVCoordinate = 0;
201
- this.fractalRay(time, function fillVertices(segment) {
202
- const subray = scope.currentSubray;
203
- if (time < subray.birthTime) {
204
- return;
205
- } else if (this.rayParameters.isEternal && scope.currentSubray.recursion == 0) {
206
- scope.createPrism(segment);
207
- scope.onDecideSubrayCreation(segment, scope);
208
- } else if (time < subray.endPropagationTime) {
209
- if (scope.timeFraction >= segment.fraction0 * subray.propagationTimeFactor) {
210
- scope.createPrism(segment);
211
- scope.onDecideSubrayCreation(segment, scope);
370
+ createTriangleVerticesWithUVs(pos, up, forwards, radius, u) {
371
+ this.side.crossVectors(up, forwards).multiplyScalar(radius * _LightningStrike.COS30DEG);
372
+ this.down.copy(up).multiplyScalar(-radius * _LightningStrike.SIN30DEG);
373
+ const p = this.vPos;
374
+ const v = this.vertices;
375
+ const uv = this.uvs;
376
+ p.copy(pos).sub(this.side).add(this.down);
377
+ v[this.currentCoordinate++] = p.x;
378
+ v[this.currentCoordinate++] = p.y;
379
+ v[this.currentCoordinate++] = p.z;
380
+ uv[this.currentUVCoordinate++] = u;
381
+ uv[this.currentUVCoordinate++] = 0;
382
+ p.copy(pos).add(this.side).add(this.down);
383
+ v[this.currentCoordinate++] = p.x;
384
+ v[this.currentCoordinate++] = p.y;
385
+ v[this.currentCoordinate++] = p.z;
386
+ uv[this.currentUVCoordinate++] = u;
387
+ uv[this.currentUVCoordinate++] = 0.5;
388
+ p.copy(up).multiplyScalar(radius).add(pos);
389
+ v[this.currentCoordinate++] = p.x;
390
+ v[this.currentCoordinate++] = p.y;
391
+ v[this.currentCoordinate++] = p.z;
392
+ uv[this.currentUVCoordinate++] = u;
393
+ uv[this.currentUVCoordinate++] = 1;
394
+ this.currentVertex += 3;
395
+ }
396
+ createPrismFaces(vertex) {
397
+ const indices = this.indices;
398
+ vertex = this.currentVertex - 6;
399
+ indices[this.currentIndex++] = vertex + 1;
400
+ indices[this.currentIndex++] = vertex + 2;
401
+ indices[this.currentIndex++] = vertex + 5;
402
+ indices[this.currentIndex++] = vertex + 1;
403
+ indices[this.currentIndex++] = vertex + 5;
404
+ indices[this.currentIndex++] = vertex + 4;
405
+ indices[this.currentIndex++] = vertex + 0;
406
+ indices[this.currentIndex++] = vertex + 1;
407
+ indices[this.currentIndex++] = vertex + 4;
408
+ indices[this.currentIndex++] = vertex + 0;
409
+ indices[this.currentIndex++] = vertex + 4;
410
+ indices[this.currentIndex++] = vertex + 3;
411
+ indices[this.currentIndex++] = vertex + 2;
412
+ indices[this.currentIndex++] = vertex + 0;
413
+ indices[this.currentIndex++] = vertex + 3;
414
+ indices[this.currentIndex++] = vertex + 2;
415
+ indices[this.currentIndex++] = vertex + 3;
416
+ indices[this.currentIndex++] = vertex + 5;
417
+ }
418
+ createDefaultSubrayCreationCallbacks() {
419
+ const random1 = this.randomGenerator.random;
420
+ this.onDecideSubrayCreation = function(segment, lightningStrike) {
421
+ const subray = lightningStrike.currentSubray;
422
+ const period = lightningStrike.rayParameters.subrayPeriod;
423
+ const dutyCycle = lightningStrike.rayParameters.subrayDutyCycle;
424
+ const phase0 = lightningStrike.rayParameters.isEternal && subray.recursion == 0 ? -random1() * period : MathUtils.lerp(subray.birthTime, subray.endPropagationTime, segment.fraction0) - random1() * period;
425
+ const phase = lightningStrike.time - phase0;
426
+ const currentCycle = Math.floor(phase / period);
427
+ const childSubraySeed = random1() * (currentCycle + 1);
428
+ const isActive = phase % period <= dutyCycle * period;
429
+ let probability = 0;
430
+ if (isActive) {
431
+ probability = lightningStrike.subrayProbability;
212
432
  }
213
- } else if (time < subray.beginVanishingTime) {
214
- scope.createPrism(segment);
215
- scope.onDecideSubrayCreation(segment, scope);
216
- } else {
217
- if (scope.timeFraction <= subray.vanishingTimeFactor + segment.fraction1 * (1 - subray.vanishingTimeFactor)) {
218
- scope.createPrism(segment);
433
+ if (subray.recursion < lightningStrike.maxSubrayRecursion && lightningStrike.numSubrays < lightningStrike.maxSubrays && random1() < probability) {
434
+ const childSubray = lightningStrike.addNewSubray();
435
+ const parentSeed = lightningStrike.randomGenerator.getSeed();
436
+ childSubray.seed = childSubraySeed;
437
+ lightningStrike.randomGenerator.setSeed(childSubraySeed);
438
+ childSubray.recursion = subray.recursion + 1;
439
+ childSubray.maxIterations = Math.max(1, subray.maxIterations - 1);
440
+ childSubray.linPos0.set(random1(), random1(), random1()).multiplyScalar(1e3);
441
+ childSubray.linPos1.set(random1(), random1(), random1()).multiplyScalar(1e3);
442
+ childSubray.up0.copy(subray.up0);
443
+ childSubray.up1.copy(subray.up1);
444
+ childSubray.radius0 = segment.radius0 * lightningStrike.rayParameters.radius0Factor;
445
+ childSubray.radius1 = Math.min(
446
+ lightningStrike.rayParameters.minRadius,
447
+ segment.radius1 * lightningStrike.rayParameters.radius1Factor
448
+ );
449
+ childSubray.birthTime = phase0 + currentCycle * period;
450
+ childSubray.deathTime = childSubray.birthTime + period * dutyCycle;
451
+ if (!lightningStrike.rayParameters.isEternal && subray.recursion == 0) {
452
+ childSubray.birthTime = Math.max(childSubray.birthTime, subray.birthTime);
453
+ childSubray.deathTime = Math.min(childSubray.deathTime, subray.deathTime);
454
+ }
455
+ childSubray.timeScale = subray.timeScale * 2;
456
+ childSubray.roughness = subray.roughness;
457
+ childSubray.straightness = subray.straightness;
458
+ childSubray.propagationTimeFactor = subray.propagationTimeFactor;
459
+ childSubray.vanishingTimeFactor = subray.vanishingTimeFactor;
460
+ lightningStrike.onSubrayCreation(segment, subray, childSubray, lightningStrike);
461
+ lightningStrike.randomGenerator.setSeed(parentSeed);
219
462
  }
220
- scope.onDecideSubrayCreation(segment, scope);
221
- }
222
- });
223
- }
224
- addNewSubray() {
225
- return this.subrays[this.numSubrays++];
226
- }
227
- initSubray(subray, rayParameters) {
228
- subray.pos0.copy(rayParameters.sourceOffset);
229
- subray.pos1.copy(rayParameters.destOffset);
230
- subray.up0.copy(rayParameters.up0);
231
- subray.up1.copy(rayParameters.up1);
232
- subray.radius0 = rayParameters.radius0;
233
- subray.radius1 = rayParameters.radius1;
234
- subray.birthTime = rayParameters.birthTime;
235
- subray.deathTime = rayParameters.deathTime;
236
- subray.timeScale = rayParameters.timeScale;
237
- subray.roughness = rayParameters.roughness;
238
- subray.straightness = rayParameters.straightness;
239
- subray.propagationTimeFactor = rayParameters.propagationTimeFactor;
240
- subray.vanishingTimeFactor = rayParameters.vanishingTimeFactor;
241
- subray.maxIterations = this.maxIterations;
242
- subray.seed = rayParameters.noiseSeed !== void 0 ? rayParameters.noiseSeed : 0;
243
- subray.recursion = 0;
244
- }
245
- fractalRay(time, segmentCallback) {
246
- this.time = time;
247
- this.currentSegmentCallback = segmentCallback;
248
- this.numSubrays = 0;
249
- this.initSubray(this.addNewSubray(), this.rayParameters);
250
- for (let subrayIndex = 0; subrayIndex < this.numSubrays; subrayIndex++) {
251
- const subray = this.subrays[subrayIndex];
252
- this.currentSubray = subray;
253
- this.randomGenerator.setSeed(subray.seed);
254
- subray.endPropagationTime = MathUtils.lerp(subray.birthTime, subray.deathTime, subray.propagationTimeFactor);
255
- subray.beginVanishingTime = MathUtils.lerp(subray.deathTime, subray.birthTime, 1 - subray.vanishingTimeFactor);
256
- const random1 = this.randomGenerator.random;
257
- subray.linPos0.set(random1(), random1(), random1()).multiplyScalar(1e3);
258
- subray.linPos1.set(random1(), random1(), random1()).multiplyScalar(1e3);
259
- this.timeFraction = (time - subray.birthTime) / (subray.deathTime - subray.birthTime);
260
- this.currentSegmentIndex = 0;
261
- this.isInitialSegment = true;
262
- const segment = this.getNewSegment();
263
- segment.iteration = 0;
264
- segment.pos0.copy(subray.pos0);
265
- segment.pos1.copy(subray.pos1);
266
- segment.linPos0.copy(subray.linPos0);
267
- segment.linPos1.copy(subray.linPos1);
268
- segment.up0.copy(subray.up0);
269
- segment.up1.copy(subray.up1);
270
- segment.radius0 = subray.radius0;
271
- segment.radius1 = subray.radius1;
272
- segment.fraction0 = 0;
273
- segment.fraction1 = 1;
274
- segment.positionVariationFactor = 1 - subray.straightness;
275
- this.subrayProbability = this.ramification * Math.pow(this.recursionProbability, subray.recursion) / (1 << subray.maxIterations);
276
- this.fractalRayRecursive(segment);
463
+ };
464
+ const vec1Pos = new Vector3();
465
+ const vec2Forward = new Vector3();
466
+ const vec3Side = new Vector3();
467
+ const vec4Up = new Vector3();
468
+ this.onSubrayCreation = function(segment, parentSubray, childSubray, lightningStrike) {
469
+ lightningStrike.subrayCylinderPosition(segment, parentSubray, childSubray, 0.5, 0.6, 0.2);
470
+ };
471
+ this.subrayConePosition = function(segment, parentSubray, childSubray, heightFactor, sideWidthFactor, minSideWidthFactor) {
472
+ childSubray.pos0.copy(segment.pos0);
473
+ vec1Pos.subVectors(parentSubray.pos1, parentSubray.pos0);
474
+ vec2Forward.copy(vec1Pos).normalize();
475
+ vec1Pos.multiplyScalar(segment.fraction0 + (1 - segment.fraction0) * (random1() * heightFactor));
476
+ const length = vec1Pos.length();
477
+ vec3Side.crossVectors(parentSubray.up0, vec2Forward);
478
+ const angle = 2 * Math.PI * random1();
479
+ vec3Side.multiplyScalar(Math.cos(angle));
480
+ vec4Up.copy(parentSubray.up0).multiplyScalar(Math.sin(angle));
481
+ childSubray.pos1.copy(vec3Side).add(vec4Up).multiplyScalar(length * sideWidthFactor * (minSideWidthFactor + random1() * (1 - minSideWidthFactor))).add(vec1Pos).add(parentSubray.pos0);
482
+ };
483
+ this.subrayCylinderPosition = function(segment, parentSubray, childSubray, heightFactor, sideWidthFactor, minSideWidthFactor) {
484
+ childSubray.pos0.copy(segment.pos0);
485
+ vec1Pos.subVectors(parentSubray.pos1, parentSubray.pos0);
486
+ vec2Forward.copy(vec1Pos).normalize();
487
+ vec1Pos.multiplyScalar(segment.fraction0 + (1 - segment.fraction0) * ((2 * random1() - 1) * heightFactor));
488
+ const length = vec1Pos.length();
489
+ vec3Side.crossVectors(parentSubray.up0, vec2Forward);
490
+ const angle = 2 * Math.PI * random1();
491
+ vec3Side.multiplyScalar(Math.cos(angle));
492
+ vec4Up.copy(parentSubray.up0).multiplyScalar(Math.sin(angle));
493
+ childSubray.pos1.copy(vec3Side).add(vec4Up).multiplyScalar(length * sideWidthFactor * (minSideWidthFactor + random1() * (1 - minSideWidthFactor))).add(vec1Pos).add(parentSubray.pos0);
494
+ };
277
495
  }
278
- this.currentSegmentCallback = null;
279
- this.currentSubray = null;
280
- }
281
- fractalRayRecursive(segment) {
282
- if (segment.iteration >= this.currentSubray.maxIterations) {
283
- this.currentSegmentCallback(segment);
284
- return;
496
+ createSubray() {
497
+ return {
498
+ seed: 0,
499
+ maxIterations: 0,
500
+ recursion: 0,
501
+ pos0: new Vector3(),
502
+ pos1: new Vector3(),
503
+ linPos0: new Vector3(),
504
+ linPos1: new Vector3(),
505
+ up0: new Vector3(),
506
+ up1: new Vector3(),
507
+ radius0: 0,
508
+ radius1: 0,
509
+ birthTime: 0,
510
+ deathTime: 0,
511
+ timeScale: 0,
512
+ roughness: 0,
513
+ straightness: 0,
514
+ propagationTimeFactor: 0,
515
+ vanishingTimeFactor: 0,
516
+ endPropagationTime: 0,
517
+ beginVanishingTime: 0
518
+ };
285
519
  }
286
- this.forwards.subVectors(segment.pos1, segment.pos0);
287
- let lForwards = this.forwards.length();
288
- if (lForwards < 1e-6) {
289
- this.forwards.set(0, 0, 0.01);
290
- lForwards = this.forwards.length();
520
+ createSegment() {
521
+ return {
522
+ iteration: 0,
523
+ pos0: new Vector3(),
524
+ pos1: new Vector3(),
525
+ linPos0: new Vector3(),
526
+ linPos1: new Vector3(),
527
+ up0: new Vector3(),
528
+ up1: new Vector3(),
529
+ radius0: 0,
530
+ radius1: 0,
531
+ fraction0: 0,
532
+ fraction1: 0,
533
+ positionVariationFactor: 0
534
+ };
291
535
  }
292
- const middleRadius = (segment.radius0 + segment.radius1) * 0.5;
293
- const middleFraction = (segment.fraction0 + segment.fraction1) * 0.5;
294
- const timeDimension = this.time * this.currentSubray.timeScale * Math.pow(2, segment.iteration);
295
- this.middlePos.lerpVectors(segment.pos0, segment.pos1, 0.5);
296
- this.middleLinPos.lerpVectors(segment.linPos0, segment.linPos1, 0.5);
297
- const p = this.middleLinPos;
298
- this.newPos.set(
299
- this.simplexX.noise4d(p.x, p.y, p.z, timeDimension),
300
- this.simplexY.noise4d(p.x, p.y, p.z, timeDimension),
301
- this.simplexZ.noise4d(p.x, p.y, p.z, timeDimension)
302
- );
303
- this.newPos.multiplyScalar(segment.positionVariationFactor * lForwards);
304
- this.newPos.add(this.middlePos);
305
- const newSegment1 = this.getNewSegment();
306
- newSegment1.pos0.copy(segment.pos0);
307
- newSegment1.pos1.copy(this.newPos);
308
- newSegment1.linPos0.copy(segment.linPos0);
309
- newSegment1.linPos1.copy(this.middleLinPos);
310
- newSegment1.up0.copy(segment.up0);
311
- newSegment1.up1.copy(segment.up1);
312
- newSegment1.radius0 = segment.radius0;
313
- newSegment1.radius1 = middleRadius;
314
- newSegment1.fraction0 = segment.fraction0;
315
- newSegment1.fraction1 = middleFraction;
316
- newSegment1.positionVariationFactor = segment.positionVariationFactor * this.currentSubray.roughness;
317
- newSegment1.iteration = segment.iteration + 1;
318
- const newSegment2 = this.getNewSegment();
319
- newSegment2.pos0.copy(this.newPos);
320
- newSegment2.pos1.copy(segment.pos1);
321
- newSegment2.linPos0.copy(this.middleLinPos);
322
- newSegment2.linPos1.copy(segment.linPos1);
323
- this.cross1.crossVectors(segment.up0, this.forwards.normalize());
324
- newSegment2.up0.crossVectors(this.forwards, this.cross1).normalize();
325
- newSegment2.up1.copy(segment.up1);
326
- newSegment2.radius0 = middleRadius;
327
- newSegment2.radius1 = segment.radius1;
328
- newSegment2.fraction0 = middleFraction;
329
- newSegment2.fraction1 = segment.fraction1;
330
- newSegment2.positionVariationFactor = segment.positionVariationFactor * this.currentSubray.roughness;
331
- newSegment2.iteration = segment.iteration + 1;
332
- this.fractalRayRecursive(newSegment1);
333
- this.fractalRayRecursive(newSegment2);
334
- }
335
- createPrism(segment) {
336
- this.forwardsFill.subVectors(segment.pos1, segment.pos0).normalize();
337
- if (this.isInitialSegment) {
338
- this.currentCreateTriangleVertices(segment.pos0, segment.up0, this.forwardsFill, segment.radius0, 0);
339
- this.isInitialSegment = false;
536
+ getNewSegment() {
537
+ return this.raySegments[this.currentSegmentIndex++];
340
538
  }
341
- this.currentCreateTriangleVertices(segment.pos1, segment.up0, this.forwardsFill, segment.radius1, segment.fraction1);
342
- this.createPrismFaces();
343
- }
344
- createTriangleVerticesWithoutUVs(pos, up, forwards, radius) {
345
- this.side.crossVectors(up, forwards).multiplyScalar(radius * _LightningStrike.COS30DEG);
346
- this.down.copy(up).multiplyScalar(-radius * _LightningStrike.SIN30DEG);
347
- const p = this.vPos;
348
- const v = this.vertices;
349
- p.copy(pos).sub(this.side).add(this.down);
350
- v[this.currentCoordinate++] = p.x;
351
- v[this.currentCoordinate++] = p.y;
352
- v[this.currentCoordinate++] = p.z;
353
- p.copy(pos).add(this.side).add(this.down);
354
- v[this.currentCoordinate++] = p.x;
355
- v[this.currentCoordinate++] = p.y;
356
- v[this.currentCoordinate++] = p.z;
357
- p.copy(up).multiplyScalar(radius).add(pos);
358
- v[this.currentCoordinate++] = p.x;
359
- v[this.currentCoordinate++] = p.y;
360
- v[this.currentCoordinate++] = p.z;
361
- this.currentVertex += 3;
362
- }
363
- createTriangleVerticesWithUVs(pos, up, forwards, radius, u) {
364
- this.side.crossVectors(up, forwards).multiplyScalar(radius * _LightningStrike.COS30DEG);
365
- this.down.copy(up).multiplyScalar(-radius * _LightningStrike.SIN30DEG);
366
- const p = this.vPos;
367
- const v = this.vertices;
368
- const uv = this.uvs;
369
- p.copy(pos).sub(this.side).add(this.down);
370
- v[this.currentCoordinate++] = p.x;
371
- v[this.currentCoordinate++] = p.y;
372
- v[this.currentCoordinate++] = p.z;
373
- uv[this.currentUVCoordinate++] = u;
374
- uv[this.currentUVCoordinate++] = 0;
375
- p.copy(pos).add(this.side).add(this.down);
376
- v[this.currentCoordinate++] = p.x;
377
- v[this.currentCoordinate++] = p.y;
378
- v[this.currentCoordinate++] = p.z;
379
- uv[this.currentUVCoordinate++] = u;
380
- uv[this.currentUVCoordinate++] = 0.5;
381
- p.copy(up).multiplyScalar(radius).add(pos);
382
- v[this.currentCoordinate++] = p.x;
383
- v[this.currentCoordinate++] = p.y;
384
- v[this.currentCoordinate++] = p.z;
385
- uv[this.currentUVCoordinate++] = u;
386
- uv[this.currentUVCoordinate++] = 1;
387
- this.currentVertex += 3;
388
- }
389
- createPrismFaces(vertex) {
390
- const indices = this.indices;
391
- vertex = this.currentVertex - 6;
392
- indices[this.currentIndex++] = vertex + 1;
393
- indices[this.currentIndex++] = vertex + 2;
394
- indices[this.currentIndex++] = vertex + 5;
395
- indices[this.currentIndex++] = vertex + 1;
396
- indices[this.currentIndex++] = vertex + 5;
397
- indices[this.currentIndex++] = vertex + 4;
398
- indices[this.currentIndex++] = vertex + 0;
399
- indices[this.currentIndex++] = vertex + 1;
400
- indices[this.currentIndex++] = vertex + 4;
401
- indices[this.currentIndex++] = vertex + 0;
402
- indices[this.currentIndex++] = vertex + 4;
403
- indices[this.currentIndex++] = vertex + 3;
404
- indices[this.currentIndex++] = vertex + 2;
405
- indices[this.currentIndex++] = vertex + 0;
406
- indices[this.currentIndex++] = vertex + 3;
407
- indices[this.currentIndex++] = vertex + 2;
408
- indices[this.currentIndex++] = vertex + 3;
409
- indices[this.currentIndex++] = vertex + 5;
410
- }
411
- createDefaultSubrayCreationCallbacks() {
412
- const random1 = this.randomGenerator.random;
413
- this.onDecideSubrayCreation = function(segment, lightningStrike) {
414
- const subray = lightningStrike.currentSubray;
415
- const period = lightningStrike.rayParameters.subrayPeriod;
416
- const dutyCycle = lightningStrike.rayParameters.subrayDutyCycle;
417
- const phase0 = lightningStrike.rayParameters.isEternal && subray.recursion == 0 ? -random1() * period : MathUtils.lerp(subray.birthTime, subray.endPropagationTime, segment.fraction0) - random1() * period;
418
- const phase = lightningStrike.time - phase0;
419
- const currentCycle = Math.floor(phase / period);
420
- const childSubraySeed = random1() * (currentCycle + 1);
421
- const isActive = phase % period <= dutyCycle * period;
422
- let probability = 0;
423
- if (isActive) {
424
- probability = lightningStrike.subrayProbability;
425
- }
426
- if (subray.recursion < lightningStrike.maxSubrayRecursion && lightningStrike.numSubrays < lightningStrike.maxSubrays && random1() < probability) {
427
- const childSubray = lightningStrike.addNewSubray();
428
- const parentSeed = lightningStrike.randomGenerator.getSeed();
429
- childSubray.seed = childSubraySeed;
430
- lightningStrike.randomGenerator.setSeed(childSubraySeed);
431
- childSubray.recursion = subray.recursion + 1;
432
- childSubray.maxIterations = Math.max(1, subray.maxIterations - 1);
433
- childSubray.linPos0.set(random1(), random1(), random1()).multiplyScalar(1e3);
434
- childSubray.linPos1.set(random1(), random1(), random1()).multiplyScalar(1e3);
435
- childSubray.up0.copy(subray.up0);
436
- childSubray.up1.copy(subray.up1);
437
- childSubray.radius0 = segment.radius0 * lightningStrike.rayParameters.radius0Factor;
438
- childSubray.radius1 = Math.min(
439
- lightningStrike.rayParameters.minRadius,
440
- segment.radius1 * lightningStrike.rayParameters.radius1Factor
441
- );
442
- childSubray.birthTime = phase0 + currentCycle * period;
443
- childSubray.deathTime = childSubray.birthTime + period * dutyCycle;
444
- if (!lightningStrike.rayParameters.isEternal && subray.recursion == 0) {
445
- childSubray.birthTime = Math.max(childSubray.birthTime, subray.birthTime);
446
- childSubray.deathTime = Math.min(childSubray.deathTime, subray.deathTime);
447
- }
448
- childSubray.timeScale = subray.timeScale * 2;
449
- childSubray.roughness = subray.roughness;
450
- childSubray.straightness = subray.straightness;
451
- childSubray.propagationTimeFactor = subray.propagationTimeFactor;
452
- childSubray.vanishingTimeFactor = subray.vanishingTimeFactor;
453
- lightningStrike.onSubrayCreation(segment, subray, childSubray, lightningStrike);
454
- lightningStrike.randomGenerator.setSeed(parentSeed);
455
- }
456
- };
457
- const vec1Pos = new Vector3();
458
- const vec2Forward = new Vector3();
459
- const vec3Side = new Vector3();
460
- const vec4Up = new Vector3();
461
- this.onSubrayCreation = function(segment, parentSubray, childSubray, lightningStrike) {
462
- lightningStrike.subrayCylinderPosition(segment, parentSubray, childSubray, 0.5, 0.6, 0.2);
463
- };
464
- this.subrayConePosition = function(segment, parentSubray, childSubray, heightFactor, sideWidthFactor, minSideWidthFactor) {
465
- childSubray.pos0.copy(segment.pos0);
466
- vec1Pos.subVectors(parentSubray.pos1, parentSubray.pos0);
467
- vec2Forward.copy(vec1Pos).normalize();
468
- vec1Pos.multiplyScalar(segment.fraction0 + (1 - segment.fraction0) * (random1() * heightFactor));
469
- const length = vec1Pos.length();
470
- vec3Side.crossVectors(parentSubray.up0, vec2Forward);
471
- const angle = 2 * Math.PI * random1();
472
- vec3Side.multiplyScalar(Math.cos(angle));
473
- vec4Up.copy(parentSubray.up0).multiplyScalar(Math.sin(angle));
474
- childSubray.pos1.copy(vec3Side).add(vec4Up).multiplyScalar(length * sideWidthFactor * (minSideWidthFactor + random1() * (1 - minSideWidthFactor))).add(vec1Pos).add(parentSubray.pos0);
475
- };
476
- this.subrayCylinderPosition = function(segment, parentSubray, childSubray, heightFactor, sideWidthFactor, minSideWidthFactor) {
477
- childSubray.pos0.copy(segment.pos0);
478
- vec1Pos.subVectors(parentSubray.pos1, parentSubray.pos0);
479
- vec2Forward.copy(vec1Pos).normalize();
480
- vec1Pos.multiplyScalar(segment.fraction0 + (1 - segment.fraction0) * ((2 * random1() - 1) * heightFactor));
481
- const length = vec1Pos.length();
482
- vec3Side.crossVectors(parentSubray.up0, vec2Forward);
483
- const angle = 2 * Math.PI * random1();
484
- vec3Side.multiplyScalar(Math.cos(angle));
485
- vec4Up.copy(parentSubray.up0).multiplyScalar(Math.sin(angle));
486
- childSubray.pos1.copy(vec3Side).add(vec4Up).multiplyScalar(length * sideWidthFactor * (minSideWidthFactor + random1() * (1 - minSideWidthFactor))).add(vec1Pos).add(parentSubray.pos0);
487
- };
488
- }
489
- createSubray() {
490
- return {
491
- seed: 0,
492
- maxIterations: 0,
493
- recursion: 0,
494
- pos0: new Vector3(),
495
- pos1: new Vector3(),
496
- linPos0: new Vector3(),
497
- linPos1: new Vector3(),
498
- up0: new Vector3(),
499
- up1: new Vector3(),
500
- radius0: 0,
501
- radius1: 0,
502
- birthTime: 0,
503
- deathTime: 0,
504
- timeScale: 0,
505
- roughness: 0,
506
- straightness: 0,
507
- propagationTimeFactor: 0,
508
- vanishingTimeFactor: 0,
509
- endPropagationTime: 0,
510
- beginVanishingTime: 0
511
- };
512
- }
513
- createSegment() {
514
- return {
515
- iteration: 0,
516
- pos0: new Vector3(),
517
- pos1: new Vector3(),
518
- linPos0: new Vector3(),
519
- linPos1: new Vector3(),
520
- up0: new Vector3(),
521
- up1: new Vector3(),
522
- radius0: 0,
523
- radius1: 0,
524
- fraction0: 0,
525
- fraction1: 0,
526
- positionVariationFactor: 0
527
- };
528
- }
529
- getNewSegment() {
530
- return this.raySegments[this.currentSegmentIndex++];
531
- }
532
- copy(source) {
533
- super.copy(source);
534
- this.init(_LightningStrike.copyParameters({}, source.rayParameters));
535
- return this;
536
- }
537
- clone() {
538
- return new this.constructor(_LightningStrike.copyParameters({}, this.rayParameters));
539
- }
540
- };
541
- let LightningStrike = _LightningStrike;
542
- // Ray states
543
- __publicField(LightningStrike, "RAY_INITIALIZED", 0);
544
- __publicField(LightningStrike, "RAY_UNBORN", 1);
545
- __publicField(LightningStrike, "RAY_PROPAGATING", 2);
546
- __publicField(LightningStrike, "RAY_STEADY", 3);
547
- __publicField(LightningStrike, "RAY_VANISHING", 4);
548
- __publicField(LightningStrike, "RAY_EXTINGUISHED", 5);
549
- __publicField(LightningStrike, "COS30DEG", Math.cos(30 * Math.PI / 180));
550
- __publicField(LightningStrike, "SIN30DEG", Math.sin(30 * Math.PI / 180));
539
+ copy(source) {
540
+ super.copy(source);
541
+ this.init(_LightningStrike.copyParameters({}, source.rayParameters));
542
+ return this;
543
+ }
544
+ clone() {
545
+ return new this.constructor(_LightningStrike.copyParameters({}, this.rayParameters));
546
+ }
547
+ };
548
+ let LightningStrike2 = _LightningStrike;
549
+ // Ray states
550
+ __publicField(LightningStrike2, "RAY_INITIALIZED", 0);
551
+ __publicField(LightningStrike2, "RAY_UNBORN", 1);
552
+ __publicField(LightningStrike2, "RAY_PROPAGATING", 2);
553
+ __publicField(LightningStrike2, "RAY_STEADY", 3);
554
+ __publicField(LightningStrike2, "RAY_VANISHING", 4);
555
+ __publicField(LightningStrike2, "RAY_EXTINGUISHED", 5);
556
+ __publicField(LightningStrike2, "COS30DEG", Math.cos(30 * Math.PI / 180));
557
+ __publicField(LightningStrike2, "SIN30DEG", Math.sin(30 * Math.PI / 180));
558
+ return LightningStrike2;
559
+ })();
551
560
  export {
552
561
  LightningStrike
553
562
  };