three-stdlib 2.35.2 → 2.35.4

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