three-stdlib 2.35.4 → 2.35.5

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 +17 -20
  2. package/_polyfill/CapsuleGeometry.cjs.map +1 -1
  3. package/_polyfill/CapsuleGeometry.js +17 -20
  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 +715 -722
  50. package/deprecated/Geometry.cjs.map +1 -1
  51. package/deprecated/Geometry.js +716 -723
  52. package/deprecated/Geometry.js.map +1 -1
  53. package/effects/AnaglyphEffect.cjs +1 -2
  54. package/effects/AnaglyphEffect.cjs.map +1 -1
  55. package/effects/AnaglyphEffect.js +2 -3
  56. package/effects/AnaglyphEffect.js.map +1 -1
  57. package/effects/OutlineEffect.cjs +1 -2
  58. package/effects/OutlineEffect.cjs.map +1 -1
  59. package/effects/OutlineEffect.js +2 -3
  60. package/effects/OutlineEffect.js.map +1 -1
  61. package/effects/ParallaxBarrierEffect.cjs +1 -2
  62. package/effects/ParallaxBarrierEffect.cjs.map +1 -1
  63. package/effects/ParallaxBarrierEffect.js +2 -3
  64. package/effects/ParallaxBarrierEffect.js.map +1 -1
  65. package/exporters/DRACOExporter.cjs +122 -133
  66. package/exporters/DRACOExporter.cjs.map +1 -1
  67. package/exporters/DRACOExporter.d.ts +21 -23
  68. package/exporters/DRACOExporter.js +122 -133
  69. package/exporters/DRACOExporter.js.map +1 -1
  70. package/exporters/GLTFExporter.cjs +167 -170
  71. package/exporters/GLTFExporter.cjs.map +1 -1
  72. package/exporters/GLTFExporter.js +167 -170
  73. package/exporters/GLTFExporter.js.map +1 -1
  74. package/geometries/LightningStrike.cjs +515 -524
  75. package/geometries/LightningStrike.cjs.map +1 -1
  76. package/geometries/LightningStrike.js +515 -524
  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 +1 -2
  123. package/lines/LineMaterial.cjs.map +1 -1
  124. package/lines/LineMaterial.js +2 -3
  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 +435 -441
  139. package/loaders/BasisTextureLoader.cjs.map +1 -1
  140. package/loaders/BasisTextureLoader.js +435 -441
  141. package/loaders/BasisTextureLoader.js.map +1 -1
  142. package/loaders/EXRLoader.cjs +1 -2
  143. package/loaders/EXRLoader.cjs.map +1 -1
  144. package/loaders/EXRLoader.js +2 -3
  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 +374 -377
  160. package/loaders/KTX2Loader.cjs.map +1 -1
  161. package/loaders/KTX2Loader.js +374 -377
  162. package/loaders/KTX2Loader.js.map +1 -1
  163. package/loaders/LDrawLoader.cjs +4 -5
  164. package/loaders/LDrawLoader.cjs.map +1 -1
  165. package/loaders/LDrawLoader.js +5 -6
  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 +43 -46
  172. package/loaders/PRWMLoader.cjs.map +1 -1
  173. package/loaders/PRWMLoader.js +43 -46
  174. package/loaders/PRWMLoader.js.map +1 -1
  175. package/loaders/SVGLoader.cjs +1688 -1694
  176. package/loaders/SVGLoader.cjs.map +1 -1
  177. package/loaders/SVGLoader.js +1688 -1694
  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 +50 -53
  192. package/math/ConvexHull.cjs.map +1 -1
  193. package/math/ConvexHull.js +50 -53
  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 +268 -271
  212. package/misc/ConvexObjectBreaker.cjs.map +1 -1
  213. package/misc/ConvexObjectBreaker.js +269 -272
  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 +1 -2
  232. package/objects/GroundProjectedEnv.cjs.map +1 -1
  233. package/objects/GroundProjectedEnv.js +2 -3
  234. package/objects/GroundProjectedEnv.js.map +1 -1
  235. package/objects/Lensflare.cjs +206 -209
  236. package/objects/Lensflare.cjs.map +1 -1
  237. package/objects/Lensflare.js +206 -209
  238. package/objects/Lensflare.js.map +1 -1
  239. package/objects/Reflector.cjs +146 -154
  240. package/objects/Reflector.cjs.map +1 -1
  241. package/objects/Reflector.js +146 -154
  242. package/objects/Reflector.js.map +1 -1
  243. package/objects/ReflectorForSSRPass.cjs +180 -183
  244. package/objects/ReflectorForSSRPass.cjs.map +1 -1
  245. package/objects/ReflectorForSSRPass.js +180 -183
  246. package/objects/ReflectorForSSRPass.js.map +1 -1
  247. package/objects/Refractor.cjs +161 -164
  248. package/objects/Refractor.cjs.map +1 -1
  249. package/objects/Refractor.js +161 -164
  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 +32 -35
  256. package/objects/Sky.cjs.map +1 -1
  257. package/objects/Sky.d.ts +6 -100
  258. package/objects/Sky.js +32 -35
  259. package/objects/Sky.js.map +1 -1
  260. package/objects/Water.cjs +1 -2
  261. package/objects/Water.cjs.map +1 -1
  262. package/objects/Water.js +2 -3
  263. package/objects/Water.js.map +1 -1
  264. package/objects/Water2.cjs +140 -143
  265. package/objects/Water2.cjs.map +1 -1
  266. package/objects/Water2.js +140 -143
  267. package/objects/Water2.js.map +1 -1
  268. package/package.json +1 -1
  269. package/postprocessing/SAOPass.cjs +264 -267
  270. package/postprocessing/SAOPass.cjs.map +1 -1
  271. package/postprocessing/SAOPass.js +264 -267
  272. package/postprocessing/SAOPass.js.map +1 -1
  273. package/postprocessing/SSAOPass.cjs +250 -253
  274. package/postprocessing/SSAOPass.cjs.map +1 -1
  275. package/postprocessing/SSAOPass.js +250 -253
  276. package/postprocessing/SSAOPass.js.map +1 -1
  277. package/postprocessing/SSRPass.cjs +376 -379
  278. package/postprocessing/SSRPass.cjs.map +1 -1
  279. package/postprocessing/SSRPass.js +376 -379
  280. package/postprocessing/SSRPass.js.map +1 -1
  281. package/postprocessing/UnrealBloomPass.cjs +202 -205
  282. package/postprocessing/UnrealBloomPass.cjs.map +1 -1
  283. package/postprocessing/UnrealBloomPass.js +202 -205
  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 +46 -71
  294. package/shaders/ACESFilmicToneMappingShader.cjs.map +1 -1
  295. package/shaders/ACESFilmicToneMappingShader.js +46 -71
  296. package/shaders/ACESFilmicToneMappingShader.js.map +1 -1
  297. package/shaders/AfterimageShader.cjs +22 -41
  298. package/shaders/AfterimageShader.cjs.map +1 -1
  299. package/shaders/AfterimageShader.js +22 -41
  300. package/shaders/AfterimageShader.js.map +1 -1
  301. package/shaders/BasicShader.cjs +6 -20
  302. package/shaders/BasicShader.cjs.map +1 -1
  303. package/shaders/BasicShader.js +6 -20
  304. package/shaders/BasicShader.js.map +1 -1
  305. package/shaders/BleachBypassShader.cjs +26 -46
  306. package/shaders/BleachBypassShader.cjs.map +1 -1
  307. package/shaders/BleachBypassShader.js +26 -46
  308. package/shaders/BleachBypassShader.js.map +1 -1
  309. package/shaders/BlendShader.cjs +19 -33
  310. package/shaders/BlendShader.cjs.map +1 -1
  311. package/shaders/BlendShader.js +19 -33
  312. package/shaders/BlendShader.js.map +1 -1
  313. package/shaders/BokehShader.cjs +90 -117
  314. package/shaders/BokehShader.cjs.map +1 -1
  315. package/shaders/BokehShader.js +90 -117
  316. package/shaders/BokehShader.js.map +1 -1
  317. package/shaders/BokehShader2.cjs +232 -333
  318. package/shaders/BokehShader2.cjs.map +1 -1
  319. package/shaders/BokehShader2.js +232 -333
  320. package/shaders/BokehShader2.js.map +1 -1
  321. package/shaders/BrightnessContrastShader.cjs +22 -38
  322. package/shaders/BrightnessContrastShader.cjs.map +1 -1
  323. package/shaders/BrightnessContrastShader.js +22 -38
  324. package/shaders/BrightnessContrastShader.js.map +1 -1
  325. package/shaders/ColorCorrectionShader.cjs +21 -35
  326. package/shaders/ColorCorrectionShader.cjs.map +1 -1
  327. package/shaders/ColorCorrectionShader.js +21 -35
  328. package/shaders/ColorCorrectionShader.js.map +1 -1
  329. package/shaders/ColorifyShader.cjs +19 -34
  330. package/shaders/ColorifyShader.cjs.map +1 -1
  331. package/shaders/ColorifyShader.js +19 -34
  332. package/shaders/ColorifyShader.js.map +1 -1
  333. package/shaders/ConvolutionShader.cjs +24 -43
  334. package/shaders/ConvolutionShader.cjs.map +1 -1
  335. package/shaders/ConvolutionShader.js +24 -43
  336. package/shaders/ConvolutionShader.js.map +1 -1
  337. package/shaders/CopyShader.cjs +16 -30
  338. package/shaders/CopyShader.cjs.map +1 -1
  339. package/shaders/CopyShader.js +16 -30
  340. package/shaders/CopyShader.js.map +1 -1
  341. package/shaders/DOFMipMapShader.cjs +21 -38
  342. package/shaders/DOFMipMapShader.cjs.map +1 -1
  343. package/shaders/DOFMipMapShader.js +21 -38
  344. package/shaders/DOFMipMapShader.js.map +1 -1
  345. package/shaders/DepthLimitedBlurShader.cjs +69 -98
  346. package/shaders/DepthLimitedBlurShader.cjs.map +1 -1
  347. package/shaders/DepthLimitedBlurShader.js +69 -98
  348. package/shaders/DepthLimitedBlurShader.js.map +1 -1
  349. package/shaders/DigitalGlitch.cjs +59 -70
  350. package/shaders/DigitalGlitch.cjs.map +1 -1
  351. package/shaders/DigitalGlitch.js +59 -70
  352. package/shaders/DigitalGlitch.js.map +1 -1
  353. package/shaders/DotScreenShader.cjs +28 -49
  354. package/shaders/DotScreenShader.cjs.map +1 -1
  355. package/shaders/DotScreenShader.js +28 -49
  356. package/shaders/DotScreenShader.js.map +1 -1
  357. package/shaders/FXAAShader.cjs +1089 -1098
  358. package/shaders/FXAAShader.cjs.map +1 -1
  359. package/shaders/FXAAShader.js +1089 -1098
  360. package/shaders/FXAAShader.js.map +1 -1
  361. package/shaders/FilmShader.cjs +29 -57
  362. package/shaders/FilmShader.cjs.map +1 -1
  363. package/shaders/FilmShader.js +29 -57
  364. package/shaders/FilmShader.js.map +1 -1
  365. package/shaders/FocusShader.cjs +43 -70
  366. package/shaders/FocusShader.cjs.map +1 -1
  367. package/shaders/FocusShader.js +43 -70
  368. package/shaders/FocusShader.js.map +1 -1
  369. package/shaders/FreiChenShader.cjs +53 -74
  370. package/shaders/FreiChenShader.cjs.map +1 -1
  371. package/shaders/FreiChenShader.js +53 -74
  372. package/shaders/FreiChenShader.js.map +1 -1
  373. package/shaders/FresnelShader.cjs +35 -55
  374. package/shaders/FresnelShader.cjs.map +1 -1
  375. package/shaders/FresnelShader.js +35 -55
  376. package/shaders/FresnelShader.js.map +1 -1
  377. package/shaders/GammaCorrectionShader.cjs +19 -33
  378. package/shaders/GammaCorrectionShader.cjs.map +1 -1
  379. package/shaders/GammaCorrectionShader.js +19 -33
  380. package/shaders/GammaCorrectionShader.js.map +1 -1
  381. package/shaders/GodRaysShader.cjs +116 -193
  382. package/shaders/GodRaysShader.cjs.map +1 -1
  383. package/shaders/GodRaysShader.js +116 -193
  384. package/shaders/GodRaysShader.js.map +1 -1
  385. package/shaders/HalftoneShader.cjs +192 -270
  386. package/shaders/HalftoneShader.cjs.map +1 -1
  387. package/shaders/HalftoneShader.js +192 -270
  388. package/shaders/HalftoneShader.js.map +1 -1
  389. package/shaders/HorizontalTiltShiftShader.cjs +27 -43
  390. package/shaders/HorizontalTiltShiftShader.cjs.map +1 -1
  391. package/shaders/HorizontalTiltShiftShader.js +27 -43
  392. package/shaders/HorizontalTiltShiftShader.js.map +1 -1
  393. package/shaders/HueSaturationShader.cjs +31 -47
  394. package/shaders/HueSaturationShader.cjs.map +1 -1
  395. package/shaders/HueSaturationShader.js +31 -47
  396. package/shaders/HueSaturationShader.js.map +1 -1
  397. package/shaders/KaleidoShader.cjs +24 -37
  398. package/shaders/KaleidoShader.cjs.map +1 -1
  399. package/shaders/KaleidoShader.js +24 -37
  400. package/shaders/KaleidoShader.js.map +1 -1
  401. package/shaders/LuminosityHighPassShader.cjs +24 -43
  402. package/shaders/LuminosityHighPassShader.cjs.map +1 -1
  403. package/shaders/LuminosityHighPassShader.js +24 -43
  404. package/shaders/LuminosityHighPassShader.js.map +1 -1
  405. package/shaders/LuminosityShader.cjs +17 -34
  406. package/shaders/LuminosityShader.cjs.map +1 -1
  407. package/shaders/LuminosityShader.js +17 -34
  408. package/shaders/LuminosityShader.js.map +1 -1
  409. package/shaders/MirrorShader.cjs +26 -39
  410. package/shaders/MirrorShader.cjs.map +1 -1
  411. package/shaders/MirrorShader.js +26 -39
  412. package/shaders/MirrorShader.js.map +1 -1
  413. package/shaders/NormalMapShader.cjs +21 -36
  414. package/shaders/NormalMapShader.cjs.map +1 -1
  415. package/shaders/NormalMapShader.js +21 -36
  416. package/shaders/NormalMapShader.js.map +1 -1
  417. package/shaders/ParallaxShader.cjs +97 -147
  418. package/shaders/ParallaxShader.cjs.map +1 -1
  419. package/shaders/ParallaxShader.js +97 -147
  420. package/shaders/ParallaxShader.js.map +1 -1
  421. package/shaders/PixelShader.cjs +18 -31
  422. package/shaders/PixelShader.cjs.map +1 -1
  423. package/shaders/PixelShader.js +18 -31
  424. package/shaders/PixelShader.js.map +1 -1
  425. package/shaders/RGBShiftShader.cjs +20 -33
  426. package/shaders/RGBShiftShader.cjs.map +1 -1
  427. package/shaders/RGBShiftShader.js +20 -33
  428. package/shaders/RGBShiftShader.js.map +1 -1
  429. package/shaders/SAOShader.cjs +117 -154
  430. package/shaders/SAOShader.cjs.map +1 -1
  431. package/shaders/SAOShader.js +117 -154
  432. package/shaders/SAOShader.js.map +1 -1
  433. package/shaders/SMAAShader.cjs +270 -358
  434. package/shaders/SMAAShader.cjs.map +1 -1
  435. package/shaders/SMAAShader.js +270 -358
  436. package/shaders/SMAAShader.js.map +1 -1
  437. package/shaders/SSAOShader.cjs +142 -236
  438. package/shaders/SSAOShader.cjs.map +1 -1
  439. package/shaders/SSAOShader.js +142 -236
  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 +20 -36
  446. package/shaders/SepiaShader.cjs.map +1 -1
  447. package/shaders/SepiaShader.js +20 -36
  448. package/shaders/SepiaShader.js.map +1 -1
  449. package/shaders/SobelOperatorShader.cjs +37 -64
  450. package/shaders/SobelOperatorShader.cjs.map +1 -1
  451. package/shaders/SobelOperatorShader.js +37 -64
  452. package/shaders/SobelOperatorShader.js.map +1 -1
  453. package/shaders/TechnicolorShader.cjs +16 -29
  454. package/shaders/TechnicolorShader.cjs.map +1 -1
  455. package/shaders/TechnicolorShader.js +16 -29
  456. package/shaders/TechnicolorShader.js.map +1 -1
  457. package/shaders/ToneMapShader.cjs +35 -55
  458. package/shaders/ToneMapShader.cjs.map +1 -1
  459. package/shaders/ToneMapShader.js +35 -55
  460. package/shaders/ToneMapShader.js.map +1 -1
  461. package/shaders/ToonShader.cjs +165 -275
  462. package/shaders/ToonShader.cjs.map +1 -1
  463. package/shaders/ToonShader.js +165 -275
  464. package/shaders/ToonShader.js.map +1 -1
  465. package/shaders/TriangleBlurShader.cjs +27 -50
  466. package/shaders/TriangleBlurShader.cjs.map +1 -1
  467. package/shaders/TriangleBlurShader.js +27 -50
  468. package/shaders/TriangleBlurShader.js.map +1 -1
  469. package/shaders/UnpackDepthRGBAShader.cjs +17 -32
  470. package/shaders/UnpackDepthRGBAShader.cjs.map +1 -1
  471. package/shaders/UnpackDepthRGBAShader.js +17 -32
  472. package/shaders/UnpackDepthRGBAShader.js.map +1 -1
  473. package/shaders/VerticalTiltShiftShader.cjs +27 -43
  474. package/shaders/VerticalTiltShiftShader.cjs.map +1 -1
  475. package/shaders/VerticalTiltShiftShader.js +27 -43
  476. package/shaders/VerticalTiltShiftShader.js.map +1 -1
  477. package/shaders/VignetteShader.cjs +27 -43
  478. package/shaders/VignetteShader.cjs.map +1 -1
  479. package/shaders/VignetteShader.js +27 -43
  480. package/shaders/VignetteShader.js.map +1 -1
  481. package/shaders/VolumeShader.cjs +213 -264
  482. package/shaders/VolumeShader.cjs.map +1 -1
  483. package/shaders/VolumeShader.js +213 -264
  484. package/shaders/VolumeShader.js.map +1 -1
  485. package/shaders/WaterRefractionShader.cjs +35 -63
  486. package/shaders/WaterRefractionShader.cjs.map +1 -1
  487. package/shaders/WaterRefractionShader.js +35 -63
  488. package/shaders/WaterRefractionShader.js.map +1 -1
  489. package/utils/GeometryCompressionUtils.cjs +1 -2
  490. package/utils/GeometryCompressionUtils.cjs.map +1 -1
  491. package/utils/GeometryCompressionUtils.js +2 -3
  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 +106 -109
  498. package/webxr/ARButton.cjs.map +1 -1
  499. package/webxr/ARButton.d.ts +3 -4
  500. package/webxr/ARButton.js +106 -109
  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 +95 -98
  507. package/webxr/VRButton.cjs.map +1 -1
  508. package/webxr/VRButton.d.ts +5 -6
  509. package/webxr/VRButton.js +95 -98
  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
@@ -8,556 +8,547 @@ 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 = /* @__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();
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());
19
24
  }
20
- static createRandomGenerator() {
21
- const numSeeds = 2053;
22
- const seeds = [];
23
- for (let i = 0; i < numSeeds; i++) {
24
- seeds.push(Math.random());
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;
25
37
  }
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;
38
+ };
39
+ return generator;
40
+ }
41
+ static copyParameters(dest = {}, source = {}) {
42
+ const vecCopy = function(v) {
43
+ if (source === dest) {
44
+ return v;
75
45
  } else {
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
- }
46
+ return v.clone();
82
47
  }
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
- }
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;
104
70
  } else {
105
- this.randomGenerator = _LightningStrike.createRandomGenerator();
106
- this.seedGenerator = Math;
71
+ this.state = _LightningStrike.RAY_STEADY;
107
72
  }
108
- if (rayParameters.onDecideSubrayCreation !== void 0) {
109
- this.onDecideSubrayCreation = rayParameters.onDecideSubrayCreation;
73
+ this.visible = true;
74
+ } else {
75
+ this.visible = false;
76
+ if (time < this.rayParameters.birthTime) {
77
+ this.state = _LightningStrike.RAY_UNBORN;
110
78
  } else {
111
- this.createDefaultSubrayCreationCallbacks();
112
- if (rayParameters.onSubrayCreation !== void 0) {
113
- this.onSubrayCreation = rayParameters.onSubrayCreation;
114
- }
79
+ this.state = _LightningStrike.RAY_EXTINGUISHED;
115
80
  }
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();
158
81
  }
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;
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);
187
102
  }
103
+ } else {
104
+ this.randomGenerator = _LightningStrike.createRandomGenerator();
105
+ this.seedGenerator = Math;
188
106
  }
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;
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;
196
113
  }
197
114
  }
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
- });
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());
226
122
  }
227
- addNewSubray() {
228
- return this.subrays[this.numSubrays++];
123
+ this.raySegments = [];
124
+ for (let i = 0; i < this.maxRaySegments; i++) {
125
+ this.raySegments.push(this.createSegment());
229
126
  }
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;
247
- }
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;
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);
283
166
  }
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();
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);
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);
337
174
  }
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;
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;
343
180
  }
344
- this.currentCreateTriangleVertices(
345
- segment.pos1,
346
- segment.up0,
347
- this.forwardsFill,
348
- segment.radius1,
349
- segment.fraction1
350
- );
351
- this.createPrismFaces();
352
- }
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;
371
181
  }
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;
182
+ this.vertices = this.positionAttribute.array;
183
+ this.indices = this.index.array;
184
+ if (this.generateUVs) {
185
+ this.uvs = this.uvsAttribute.array;
397
186
  }
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;
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;
419
195
  }
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;
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);
434
214
  }
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);
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);
464
221
  }
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
- };
497
- }
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
- };
521
- }
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
- };
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);
537
279
  }
538
- getNewSegment() {
539
- return this.raySegments[this.currentSegmentIndex++];
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;
540
287
  }
541
- copy(source) {
542
- super.copy(source);
543
- this.init(_LightningStrike.copyParameters({}, source.rayParameters));
544
- return this;
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();
545
293
  }
546
- clone() {
547
- return new this.constructor(_LightningStrike.copyParameters({}, this.rayParameters));
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;
548
342
  }
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
- })();
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));
562
553
  exports.LightningStrike = LightningStrike;
563
554
  //# sourceMappingURL=LightningStrike.cjs.map