@geoblocks/cesium-post-process 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (505) hide show
  1. package/README.md +6 -1
  2. package/dist/analog-video.d.ts +71 -0
  3. package/dist/analog-video.d.ts.map +1 -0
  4. package/dist/analog-video.js +128 -0
  5. package/dist/analog-video.js.map +1 -0
  6. package/dist/blur.d.ts +13 -0
  7. package/dist/blur.d.ts.map +1 -0
  8. package/dist/blur.js +36 -0
  9. package/dist/blur.js.map +1 -0
  10. package/dist/cesium-post-process.d.ts +30 -0
  11. package/dist/cesium-post-process.d.ts.map +1 -0
  12. package/dist/cesium-post-process.js +31 -0
  13. package/dist/cesium-post-process.js.map +1 -0
  14. package/dist/cloud-cover.d.ts +28 -0
  15. package/dist/cloud-cover.d.ts.map +1 -0
  16. package/dist/cloud-cover.js +45 -0
  17. package/dist/cloud-cover.js.map +1 -0
  18. package/dist/cloud-map.d.ts +7 -0
  19. package/dist/cloud-map.d.ts.map +1 -0
  20. package/dist/cloud-map.js +118 -0
  21. package/dist/cloud-map.js.map +1 -0
  22. package/dist/cloud-noise.d.ts +13 -0
  23. package/dist/cloud-noise.d.ts.map +1 -0
  24. package/dist/cloud-noise.js +222 -0
  25. package/dist/cloud-noise.js.map +1 -0
  26. package/dist/clouds.d.ts +275 -0
  27. package/dist/clouds.d.ts.map +1 -0
  28. package/dist/clouds.js +642 -0
  29. package/dist/clouds.js.map +1 -0
  30. package/dist/color-isolation.d.ts +38 -0
  31. package/dist/color-isolation.d.ts.map +1 -0
  32. package/dist/color-isolation.js +61 -0
  33. package/dist/color-isolation.js.map +1 -0
  34. package/dist/depth-test.d.ts +9 -0
  35. package/dist/depth-test.d.ts.map +1 -0
  36. package/dist/depth-test.js +35 -0
  37. package/dist/depth-test.js.map +1 -0
  38. package/dist/digital-video.d.ts +47 -0
  39. package/dist/digital-video.d.ts.map +1 -0
  40. package/dist/digital-video.js +102 -0
  41. package/dist/digital-video.js.map +1 -0
  42. package/dist/drone-display.d.ts +70 -0
  43. package/dist/drone-display.d.ts.map +1 -0
  44. package/dist/drone-display.js +158 -0
  45. package/dist/drone-display.js.map +1 -0
  46. package/dist/dufour.d.ts +108 -0
  47. package/dist/dufour.d.ts.map +1 -0
  48. package/dist/dufour.js +201 -0
  49. package/dist/dufour.js.map +1 -0
  50. package/dist/effect.d.ts +33 -0
  51. package/dist/effect.d.ts.map +1 -0
  52. package/dist/effect.js +60 -0
  53. package/dist/effect.js.map +1 -0
  54. package/dist/focus.d.ts +11 -0
  55. package/dist/focus.d.ts.map +1 -0
  56. package/dist/focus.js +23 -0
  57. package/dist/focus.js.map +1 -0
  58. package/dist/frame-clock.d.ts +11 -0
  59. package/dist/frame-clock.d.ts.map +1 -0
  60. package/dist/frame-clock.js +57 -0
  61. package/dist/frame-clock.js.map +1 -0
  62. package/dist/height.d.ts +12 -0
  63. package/dist/height.d.ts.map +1 -0
  64. package/dist/height.js +22 -0
  65. package/dist/height.js.map +1 -0
  66. package/dist/infrared.d.ts +23 -0
  67. package/dist/infrared.d.ts.map +1 -0
  68. package/dist/infrared.js +36 -0
  69. package/dist/infrared.js.map +1 -0
  70. package/dist/jello.d.ts +52 -0
  71. package/dist/jello.d.ts.map +1 -0
  72. package/dist/jello.js +136 -0
  73. package/dist/jello.js.map +1 -0
  74. package/dist/lens-distortion.d.ts +33 -0
  75. package/dist/lens-distortion.d.ts.map +1 -0
  76. package/dist/lens-distortion.js +61 -0
  77. package/dist/lens-distortion.js.map +1 -0
  78. package/dist/lightning.d.ts +124 -0
  79. package/dist/lightning.d.ts.map +1 -0
  80. package/dist/lightning.js +301 -0
  81. package/dist/lightning.js.map +1 -0
  82. package/dist/local-frame.d.ts +38 -0
  83. package/dist/local-frame.d.ts.map +1 -0
  84. package/dist/local-frame.js +52 -0
  85. package/dist/local-frame.js.map +1 -0
  86. package/dist/motion-blur.d.ts +50 -0
  87. package/dist/motion-blur.d.ts.map +1 -0
  88. package/dist/motion-blur.js +108 -0
  89. package/dist/motion-blur.js.map +1 -0
  90. package/dist/precipitation.d.ts +146 -0
  91. package/dist/precipitation.d.ts.map +1 -0
  92. package/dist/precipitation.js +454 -0
  93. package/dist/precipitation.js.map +1 -0
  94. package/dist/rain-rings.d.ts +100 -0
  95. package/dist/rain-rings.d.ts.map +1 -0
  96. package/dist/rain-rings.js +181 -0
  97. package/dist/rain-rings.js.map +1 -0
  98. package/dist/shaders/Alpenglow.d.ts +3 -0
  99. package/dist/shaders/Alpenglow.d.ts.map +1 -0
  100. package/dist/shaders/Alpenglow.js +3 -0
  101. package/dist/shaders/Alpenglow.js.map +1 -0
  102. package/dist/shaders/AnalogVideo.d.ts +3 -0
  103. package/dist/shaders/AnalogVideo.d.ts.map +1 -0
  104. package/dist/shaders/AnalogVideo.js +3 -0
  105. package/dist/shaders/AnalogVideo.js.map +1 -0
  106. package/dist/shaders/Beam.d.ts +3 -0
  107. package/dist/shaders/Beam.d.ts.map +1 -0
  108. package/dist/shaders/Beam.js +3 -0
  109. package/dist/shaders/Beam.js.map +1 -0
  110. package/dist/shaders/CloudsBlur.d.ts +3 -0
  111. package/dist/shaders/CloudsBlur.d.ts.map +1 -0
  112. package/dist/shaders/CloudsBlur.js +3 -0
  113. package/dist/shaders/CloudsBlur.js.map +1 -0
  114. package/dist/shaders/CloudsComposite.d.ts +3 -0
  115. package/dist/shaders/CloudsComposite.d.ts.map +1 -0
  116. package/dist/shaders/CloudsComposite.js +3 -0
  117. package/dist/shaders/CloudsComposite.js.map +1 -0
  118. package/dist/shaders/CloudsDensity.d.ts +3 -0
  119. package/dist/shaders/CloudsDensity.d.ts.map +1 -0
  120. package/dist/shaders/CloudsDensity.js +3 -0
  121. package/dist/shaders/CloudsDensity.js.map +1 -0
  122. package/dist/shaders/CloudsDepth.d.ts +3 -0
  123. package/dist/shaders/CloudsDepth.d.ts.map +1 -0
  124. package/dist/shaders/CloudsDepth.js +3 -0
  125. package/dist/shaders/CloudsDepth.js.map +1 -0
  126. package/dist/shaders/CloudsMarch.d.ts +3 -0
  127. package/dist/shaders/CloudsMarch.d.ts.map +1 -0
  128. package/dist/shaders/CloudsMarch.js +3 -0
  129. package/dist/shaders/CloudsMarch.js.map +1 -0
  130. package/dist/shaders/CloudsResolve.d.ts +3 -0
  131. package/dist/shaders/CloudsResolve.d.ts.map +1 -0
  132. package/dist/shaders/CloudsResolve.js +3 -0
  133. package/dist/shaders/CloudsResolve.js.map +1 -0
  134. package/dist/shaders/CloudsShadow.d.ts +3 -0
  135. package/dist/shaders/CloudsShadow.d.ts.map +1 -0
  136. package/dist/shaders/CloudsShadow.js +3 -0
  137. package/dist/shaders/CloudsShadow.js.map +1 -0
  138. package/dist/shaders/CloudsShadowMap.d.ts +3 -0
  139. package/dist/shaders/CloudsShadowMap.d.ts.map +1 -0
  140. package/dist/shaders/CloudsShadowMap.js +3 -0
  141. package/dist/shaders/CloudsShadowMap.js.map +1 -0
  142. package/dist/shaders/CloudsSlab.d.ts +3 -0
  143. package/dist/shaders/CloudsSlab.d.ts.map +1 -0
  144. package/dist/shaders/CloudsSlab.js +3 -0
  145. package/dist/shaders/CloudsSlab.js.map +1 -0
  146. package/dist/shaders/ColorIsolation.d.ts +3 -0
  147. package/dist/shaders/ColorIsolation.d.ts.map +1 -0
  148. package/dist/shaders/ColorIsolation.js +3 -0
  149. package/dist/shaders/ColorIsolation.js.map +1 -0
  150. package/dist/shaders/DepthEdges.d.ts +3 -0
  151. package/dist/shaders/DepthEdges.d.ts.map +1 -0
  152. package/dist/shaders/DepthEdges.js +3 -0
  153. package/dist/shaders/DepthEdges.js.map +1 -0
  154. package/dist/shaders/DigitalVideo.d.ts +3 -0
  155. package/dist/shaders/DigitalVideo.d.ts.map +1 -0
  156. package/dist/shaders/DigitalVideo.js +3 -0
  157. package/dist/shaders/DigitalVideo.js.map +1 -0
  158. package/dist/shaders/DroneDisplay.d.ts +3 -0
  159. package/dist/shaders/DroneDisplay.d.ts.map +1 -0
  160. package/dist/shaders/DroneDisplay.js +3 -0
  161. package/dist/shaders/DroneDisplay.js.map +1 -0
  162. package/dist/shaders/Dufour.d.ts +3 -0
  163. package/dist/shaders/Dufour.d.ts.map +1 -0
  164. package/dist/shaders/Dufour.js +3 -0
  165. package/dist/shaders/Dufour.js.map +1 -0
  166. package/dist/shaders/EyeFromDepth.d.ts +3 -0
  167. package/dist/shaders/EyeFromDepth.d.ts.map +1 -0
  168. package/dist/shaders/EyeFromDepth.js +3 -0
  169. package/dist/shaders/EyeFromDepth.js.map +1 -0
  170. package/dist/shaders/Filmic.d.ts +3 -0
  171. package/dist/shaders/Filmic.d.ts.map +1 -0
  172. package/dist/shaders/Filmic.js +3 -0
  173. package/dist/shaders/Filmic.js.map +1 -0
  174. package/dist/shaders/Flashlight.d.ts +3 -0
  175. package/dist/shaders/Flashlight.d.ts.map +1 -0
  176. package/dist/shaders/Flashlight.js +3 -0
  177. package/dist/shaders/Flashlight.js.map +1 -0
  178. package/dist/shaders/Fog.d.ts +3 -0
  179. package/dist/shaders/Fog.d.ts.map +1 -0
  180. package/dist/shaders/Fog.js +3 -0
  181. package/dist/shaders/Fog.js.map +1 -0
  182. package/dist/shaders/Frame.d.ts +3 -0
  183. package/dist/shaders/Frame.d.ts.map +1 -0
  184. package/dist/shaders/Frame.js +3 -0
  185. package/dist/shaders/Frame.js.map +1 -0
  186. package/dist/shaders/Hash.d.ts +3 -0
  187. package/dist/shaders/Hash.d.ts.map +1 -0
  188. package/dist/shaders/Hash.js +3 -0
  189. package/dist/shaders/Hash.js.map +1 -0
  190. package/dist/shaders/Height.d.ts +3 -0
  191. package/dist/shaders/Height.d.ts.map +1 -0
  192. package/dist/shaders/Height.js +3 -0
  193. package/dist/shaders/Height.js.map +1 -0
  194. package/dist/shaders/Infrared.d.ts +3 -0
  195. package/dist/shaders/Infrared.d.ts.map +1 -0
  196. package/dist/shaders/Infrared.js +3 -0
  197. package/dist/shaders/Infrared.js.map +1 -0
  198. package/dist/shaders/Jello.d.ts +3 -0
  199. package/dist/shaders/Jello.d.ts.map +1 -0
  200. package/dist/shaders/Jello.js +3 -0
  201. package/dist/shaders/Jello.js.map +1 -0
  202. package/dist/shaders/LensDistortion.d.ts +3 -0
  203. package/dist/shaders/LensDistortion.d.ts.map +1 -0
  204. package/dist/shaders/LensDistortion.js +3 -0
  205. package/dist/shaders/LensDistortion.js.map +1 -0
  206. package/dist/shaders/Lightning.d.ts +3 -0
  207. package/dist/shaders/Lightning.d.ts.map +1 -0
  208. package/dist/shaders/Lightning.js +3 -0
  209. package/dist/shaders/Lightning.js.map +1 -0
  210. package/dist/shaders/MotionBlur.d.ts +3 -0
  211. package/dist/shaders/MotionBlur.d.ts.map +1 -0
  212. package/dist/shaders/MotionBlur.js +3 -0
  213. package/dist/shaders/MotionBlur.js.map +1 -0
  214. package/dist/shaders/MotionBlurVelocity.d.ts +3 -0
  215. package/dist/shaders/MotionBlurVelocity.d.ts.map +1 -0
  216. package/dist/shaders/MotionBlurVelocity.js +3 -0
  217. package/dist/shaders/MotionBlurVelocity.js.map +1 -0
  218. package/dist/shaders/Noise.d.ts +3 -0
  219. package/dist/shaders/Noise.d.ts.map +1 -0
  220. package/dist/shaders/Noise.js +3 -0
  221. package/dist/shaders/Noise.js.map +1 -0
  222. package/dist/shaders/Normal.d.ts +3 -0
  223. package/dist/shaders/Normal.d.ts.map +1 -0
  224. package/dist/shaders/Normal.js +3 -0
  225. package/dist/shaders/Normal.js.map +1 -0
  226. package/dist/shaders/Phase.d.ts +3 -0
  227. package/dist/shaders/Phase.d.ts.map +1 -0
  228. package/dist/shaders/Phase.js +3 -0
  229. package/dist/shaders/Phase.js.map +1 -0
  230. package/dist/shaders/Precipitation.d.ts +3 -0
  231. package/dist/shaders/Precipitation.d.ts.map +1 -0
  232. package/dist/shaders/Precipitation.js +3 -0
  233. package/dist/shaders/Precipitation.js.map +1 -0
  234. package/dist/shaders/PrecipitationShaftBlur.d.ts +3 -0
  235. package/dist/shaders/PrecipitationShaftBlur.d.ts.map +1 -0
  236. package/dist/shaders/PrecipitationShaftBlur.js +3 -0
  237. package/dist/shaders/PrecipitationShaftBlur.js.map +1 -0
  238. package/dist/shaders/PrecipitationShafts.d.ts +3 -0
  239. package/dist/shaders/PrecipitationShafts.d.ts.map +1 -0
  240. package/dist/shaders/PrecipitationShafts.js +3 -0
  241. package/dist/shaders/PrecipitationShafts.js.map +1 -0
  242. package/dist/shaders/PrecipitationWind.d.ts +3 -0
  243. package/dist/shaders/PrecipitationWind.d.ts.map +1 -0
  244. package/dist/shaders/PrecipitationWind.js +3 -0
  245. package/dist/shaders/PrecipitationWind.js.map +1 -0
  246. package/dist/shaders/RainHaze.d.ts +3 -0
  247. package/dist/shaders/RainHaze.d.ts.map +1 -0
  248. package/dist/shaders/RainHaze.js +3 -0
  249. package/dist/shaders/RainHaze.js.map +1 -0
  250. package/dist/shaders/RainRings.d.ts +3 -0
  251. package/dist/shaders/RainRings.d.ts.map +1 -0
  252. package/dist/shaders/RainRings.js +3 -0
  253. package/dist/shaders/RainRings.js.map +1 -0
  254. package/dist/shaders/Shockwave.d.ts +3 -0
  255. package/dist/shaders/Shockwave.d.ts.map +1 -0
  256. package/dist/shaders/Shockwave.js +3 -0
  257. package/dist/shaders/Shockwave.js.map +1 -0
  258. package/dist/shaders/SkyTable.d.ts +3 -0
  259. package/dist/shaders/SkyTable.d.ts.map +1 -0
  260. package/dist/shaders/SkyTable.js +3 -0
  261. package/dist/shaders/SkyTable.js.map +1 -0
  262. package/dist/shaders/SnowLine.d.ts +3 -0
  263. package/dist/shaders/SnowLine.d.ts.map +1 -0
  264. package/dist/shaders/SnowLine.js +3 -0
  265. package/dist/shaders/SnowLine.js.map +1 -0
  266. package/dist/shaders/SpeedLines.d.ts +3 -0
  267. package/dist/shaders/SpeedLines.d.ts.map +1 -0
  268. package/dist/shaders/SpeedLines.js +3 -0
  269. package/dist/shaders/SpeedLines.js.map +1 -0
  270. package/dist/shaders/Spotlight.d.ts +3 -0
  271. package/dist/shaders/Spotlight.d.ts.map +1 -0
  272. package/dist/shaders/Spotlight.js +3 -0
  273. package/dist/shaders/Spotlight.js.map +1 -0
  274. package/dist/shaders/SpotlightBeam.d.ts +3 -0
  275. package/dist/shaders/SpotlightBeam.d.ts.map +1 -0
  276. package/dist/shaders/SpotlightBeam.js +3 -0
  277. package/dist/shaders/SpotlightBeam.js.map +1 -0
  278. package/dist/shaders/SpotlightBeamBlur.d.ts +3 -0
  279. package/dist/shaders/SpotlightBeamBlur.d.ts.map +1 -0
  280. package/dist/shaders/SpotlightBeamBlur.js +3 -0
  281. package/dist/shaders/SpotlightBeamBlur.js.map +1 -0
  282. package/dist/shaders/SpotlightCone.d.ts +3 -0
  283. package/dist/shaders/SpotlightCone.d.ts.map +1 -0
  284. package/dist/shaders/SpotlightCone.js +3 -0
  285. package/dist/shaders/SpotlightCone.js.map +1 -0
  286. package/dist/shaders/Super8.d.ts +3 -0
  287. package/dist/shaders/Super8.d.ts.map +1 -0
  288. package/dist/shaders/Super8.js +3 -0
  289. package/dist/shaders/Super8.js.map +1 -0
  290. package/dist/shaders/Technicolor.d.ts +3 -0
  291. package/dist/shaders/Technicolor.d.ts.map +1 -0
  292. package/dist/shaders/Technicolor.js +3 -0
  293. package/dist/shaders/Technicolor.js.map +1 -0
  294. package/dist/shaders/TiltShift.d.ts +3 -0
  295. package/dist/shaders/TiltShift.d.ts.map +1 -0
  296. package/dist/shaders/TiltShift.js +3 -0
  297. package/dist/shaders/TiltShift.js.map +1 -0
  298. package/dist/shaders/Toy.d.ts +3 -0
  299. package/dist/shaders/Toy.d.ts.map +1 -0
  300. package/dist/shaders/Toy.js +3 -0
  301. package/dist/shaders/Toy.js.map +1 -0
  302. package/dist/shaders/Trails.d.ts +3 -0
  303. package/dist/shaders/Trails.d.ts.map +1 -0
  304. package/dist/shaders/Trails.js +3 -0
  305. package/dist/shaders/Trails.js.map +1 -0
  306. package/dist/shaders/ValleyFog.d.ts +3 -0
  307. package/dist/shaders/ValleyFog.d.ts.map +1 -0
  308. package/dist/shaders/ValleyFog.js +3 -0
  309. package/dist/shaders/ValleyFog.js.map +1 -0
  310. package/dist/shaders/WeatherMap.d.ts +3 -0
  311. package/dist/shaders/WeatherMap.d.ts.map +1 -0
  312. package/dist/shaders/WeatherMap.js +3 -0
  313. package/dist/shaders/WeatherMap.js.map +1 -0
  314. package/dist/shaders/WhiteModel.d.ts +3 -0
  315. package/dist/shaders/WhiteModel.d.ts.map +1 -0
  316. package/dist/shaders/WhiteModel.js +3 -0
  317. package/dist/shaders/WhiteModel.js.map +1 -0
  318. package/dist/snow-line.d.ts +117 -0
  319. package/dist/snow-line.d.ts.map +1 -0
  320. package/dist/snow-line.js +201 -0
  321. package/dist/snow-line.js.map +1 -0
  322. package/dist/speed-lines.d.ts +36 -0
  323. package/dist/speed-lines.d.ts.map +1 -0
  324. package/dist/speed-lines.js +65 -0
  325. package/dist/speed-lines.js.map +1 -0
  326. package/dist/spotlight.d.ts +84 -0
  327. package/dist/spotlight.d.ts.map +1 -0
  328. package/dist/spotlight.js +175 -0
  329. package/dist/spotlight.js.map +1 -0
  330. package/dist/strikes.d.ts +17 -0
  331. package/dist/strikes.d.ts.map +1 -0
  332. package/dist/strikes.js +30 -0
  333. package/dist/strikes.js.map +1 -0
  334. package/dist/super8.d.ts +78 -0
  335. package/dist/super8.d.ts.map +1 -0
  336. package/dist/super8.js +146 -0
  337. package/dist/super8.js.map +1 -0
  338. package/dist/technicolor.d.ts +32 -0
  339. package/dist/technicolor.d.ts.map +1 -0
  340. package/dist/technicolor.js +51 -0
  341. package/dist/technicolor.js.map +1 -0
  342. package/dist/tilt-shift.d.ts +60 -0
  343. package/dist/tilt-shift.d.ts.map +1 -0
  344. package/dist/tilt-shift.js +112 -0
  345. package/dist/tilt-shift.js.map +1 -0
  346. package/dist/toy.d.ts +110 -0
  347. package/dist/toy.d.ts.map +1 -0
  348. package/dist/toy.js +173 -0
  349. package/dist/toy.js.map +1 -0
  350. package/dist/valley-fog.d.ts +56 -0
  351. package/dist/valley-fog.d.ts.map +1 -0
  352. package/dist/valley-fog.js +94 -0
  353. package/dist/valley-fog.js.map +1 -0
  354. package/dist/weather-map.d.ts +132 -0
  355. package/dist/weather-map.d.ts.map +1 -0
  356. package/dist/weather-map.js +266 -0
  357. package/dist/weather-map.js.map +1 -0
  358. package/dist/white-model.d.ts +70 -0
  359. package/dist/white-model.d.ts.map +1 -0
  360. package/dist/white-model.js +94 -0
  361. package/dist/white-model.js.map +1 -0
  362. package/package.json +19 -40
  363. package/{cesium-post-process.js → src/cesium-post-process.js} +2 -0
  364. package/src/local-frame.js +57 -0
  365. package/{rain-rings.js → src/rain-rings.js} +14 -28
  366. package/src/shaders/AnalogVideo.glsl +132 -0
  367. package/src/shaders/Beam.glsl +108 -0
  368. package/src/shaders/CloudsBlur.glsl +30 -0
  369. package/src/shaders/CloudsComposite.glsl +59 -0
  370. package/src/shaders/CloudsDensity.glsl +129 -0
  371. package/src/shaders/CloudsDepth.glsl +26 -0
  372. package/src/shaders/CloudsMarch.glsl +174 -0
  373. package/src/shaders/CloudsResolve.glsl +46 -0
  374. package/src/shaders/CloudsShadow.glsl +50 -0
  375. package/src/shaders/CloudsShadowMap.glsl +68 -0
  376. package/src/shaders/CloudsSlab.glsl +58 -0
  377. package/src/shaders/ColorIsolation.glsl +26 -0
  378. package/src/shaders/DepthEdges.glsl +81 -0
  379. package/src/shaders/DigitalVideo.glsl +65 -0
  380. package/src/shaders/DroneDisplay.glsl +337 -0
  381. package/src/shaders/Dufour.glsl +109 -0
  382. package/src/shaders/EyeFromDepth.glsl +36 -0
  383. package/src/shaders/Filmic.glsl +5 -0
  384. package/src/shaders/Fog.glsl +18 -0
  385. package/src/shaders/Frame.glsl +10 -0
  386. package/src/shaders/Hash.glsl +12 -0
  387. package/src/shaders/Height.glsl +25 -0
  388. package/src/shaders/Infrared.glsl +44 -0
  389. package/src/shaders/Jello.glsl +41 -0
  390. package/src/shaders/LensDistortion.glsl +24 -0
  391. package/src/shaders/Lightning.glsl +257 -0
  392. package/src/shaders/MotionBlur.glsl +71 -0
  393. package/src/shaders/MotionBlurVelocity.glsl +31 -0
  394. package/src/shaders/Noise.glsl +43 -0
  395. package/src/shaders/Normal.glsl +21 -0
  396. package/src/shaders/Phase.glsl +6 -0
  397. package/src/shaders/Precipitation.glsl +199 -0
  398. package/src/shaders/PrecipitationShaftBlur.glsl +21 -0
  399. package/src/shaders/PrecipitationShafts.glsl +84 -0
  400. package/src/shaders/PrecipitationWind.glsl +33 -0
  401. package/src/shaders/RainHaze.glsl +145 -0
  402. package/src/shaders/RainRings.glsl +64 -0
  403. package/src/shaders/SkyTable.glsl +23 -0
  404. package/src/shaders/SnowLine.glsl +97 -0
  405. package/src/shaders/SnowLine.js +2 -0
  406. package/src/shaders/SpeedLines.glsl +61 -0
  407. package/src/shaders/Spotlight.glsl +89 -0
  408. package/src/shaders/SpotlightBeam.glsl +49 -0
  409. package/src/shaders/SpotlightBeamBlur.glsl +27 -0
  410. package/src/shaders/SpotlightCone.glsl +37 -0
  411. package/src/shaders/Super8.glsl +90 -0
  412. package/src/shaders/Technicolor.glsl +30 -0
  413. package/src/shaders/TiltShift.glsl +34 -0
  414. package/src/shaders/Toy.glsl +46 -0
  415. package/src/shaders/ValleyFog.glsl +40 -0
  416. package/src/shaders/WeatherMap.glsl +33 -0
  417. package/src/shaders/WhiteModel.glsl +108 -0
  418. package/{snow-line.js → src/snow-line.js} +71 -3
  419. package/local-frame.js +0 -15
  420. package/shaders/SnowLine.js +0 -2
  421. /package/{analog-video.js → src/analog-video.js} +0 -0
  422. /package/{blur.js → src/blur.js} +0 -0
  423. /package/{cloud-cover.js → src/cloud-cover.js} +0 -0
  424. /package/{cloud-map.js → src/cloud-map.js} +0 -0
  425. /package/{cloud-noise.js → src/cloud-noise.js} +0 -0
  426. /package/{clouds.js → src/clouds.js} +0 -0
  427. /package/{color-isolation.js → src/color-isolation.js} +0 -0
  428. /package/{depth-test.js → src/depth-test.js} +0 -0
  429. /package/{digital-video.js → src/digital-video.js} +0 -0
  430. /package/{drone-display.js → src/drone-display.js} +0 -0
  431. /package/{dufour.js → src/dufour.js} +0 -0
  432. /package/{effect.js → src/effect.js} +0 -0
  433. /package/{focus.js → src/focus.js} +0 -0
  434. /package/{frame-clock.js → src/frame-clock.js} +0 -0
  435. /package/{height.js → src/height.js} +0 -0
  436. /package/{infrared.js → src/infrared.js} +0 -0
  437. /package/{jello.js → src/jello.js} +0 -0
  438. /package/{lens-distortion.js → src/lens-distortion.js} +0 -0
  439. /package/{lightning.js → src/lightning.js} +0 -0
  440. /package/{motion-blur.js → src/motion-blur.js} +0 -0
  441. /package/{precipitation.js → src/precipitation.js} +0 -0
  442. /package/{shaders → src/shaders}/Alpenglow.js +0 -0
  443. /package/{shaders → src/shaders}/AnalogVideo.js +0 -0
  444. /package/{shaders → src/shaders}/Beam.js +0 -0
  445. /package/{shaders → src/shaders}/CloudsBlur.js +0 -0
  446. /package/{shaders → src/shaders}/CloudsComposite.js +0 -0
  447. /package/{shaders → src/shaders}/CloudsDensity.js +0 -0
  448. /package/{shaders → src/shaders}/CloudsDepth.js +0 -0
  449. /package/{shaders → src/shaders}/CloudsMarch.js +0 -0
  450. /package/{shaders → src/shaders}/CloudsResolve.js +0 -0
  451. /package/{shaders → src/shaders}/CloudsShadow.js +0 -0
  452. /package/{shaders → src/shaders}/CloudsShadowMap.js +0 -0
  453. /package/{shaders → src/shaders}/CloudsSlab.js +0 -0
  454. /package/{shaders → src/shaders}/ColorIsolation.js +0 -0
  455. /package/{shaders → src/shaders}/DepthEdges.js +0 -0
  456. /package/{shaders → src/shaders}/DigitalVideo.js +0 -0
  457. /package/{shaders → src/shaders}/DroneDisplay.js +0 -0
  458. /package/{shaders → src/shaders}/Dufour.js +0 -0
  459. /package/{shaders → src/shaders}/EyeFromDepth.js +0 -0
  460. /package/{shaders → src/shaders}/Filmic.js +0 -0
  461. /package/{shaders → src/shaders}/Flashlight.js +0 -0
  462. /package/{shaders → src/shaders}/Fog.js +0 -0
  463. /package/{shaders → src/shaders}/Frame.js +0 -0
  464. /package/{shaders → src/shaders}/Hash.js +0 -0
  465. /package/{shaders → src/shaders}/Height.js +0 -0
  466. /package/{shaders → src/shaders}/Infrared.js +0 -0
  467. /package/{shaders → src/shaders}/Jello.js +0 -0
  468. /package/{shaders → src/shaders}/LensDistortion.js +0 -0
  469. /package/{shaders → src/shaders}/Lightning.js +0 -0
  470. /package/{shaders → src/shaders}/MotionBlur.js +0 -0
  471. /package/{shaders → src/shaders}/MotionBlurVelocity.js +0 -0
  472. /package/{shaders → src/shaders}/Noise.js +0 -0
  473. /package/{shaders → src/shaders}/Normal.js +0 -0
  474. /package/{shaders → src/shaders}/Phase.js +0 -0
  475. /package/{shaders → src/shaders}/Precipitation.js +0 -0
  476. /package/{shaders → src/shaders}/PrecipitationShaftBlur.js +0 -0
  477. /package/{shaders → src/shaders}/PrecipitationShafts.js +0 -0
  478. /package/{shaders → src/shaders}/PrecipitationWind.js +0 -0
  479. /package/{shaders → src/shaders}/RainHaze.js +0 -0
  480. /package/{shaders → src/shaders}/RainRings.js +0 -0
  481. /package/{shaders → src/shaders}/Shockwave.js +0 -0
  482. /package/{shaders → src/shaders}/SkyTable.js +0 -0
  483. /package/{shaders → src/shaders}/SpeedLines.js +0 -0
  484. /package/{shaders → src/shaders}/Spotlight.js +0 -0
  485. /package/{shaders → src/shaders}/SpotlightBeam.js +0 -0
  486. /package/{shaders → src/shaders}/SpotlightBeamBlur.js +0 -0
  487. /package/{shaders → src/shaders}/SpotlightCone.js +0 -0
  488. /package/{shaders → src/shaders}/Super8.js +0 -0
  489. /package/{shaders → src/shaders}/Technicolor.js +0 -0
  490. /package/{shaders → src/shaders}/TiltShift.js +0 -0
  491. /package/{shaders → src/shaders}/Toy.js +0 -0
  492. /package/{shaders → src/shaders}/Trails.js +0 -0
  493. /package/{shaders → src/shaders}/ValleyFog.js +0 -0
  494. /package/{shaders → src/shaders}/WeatherMap.js +0 -0
  495. /package/{shaders → src/shaders}/WhiteModel.js +0 -0
  496. /package/{speed-lines.js → src/speed-lines.js} +0 -0
  497. /package/{spotlight.js → src/spotlight.js} +0 -0
  498. /package/{strikes.js → src/strikes.js} +0 -0
  499. /package/{super8.js → src/super8.js} +0 -0
  500. /package/{technicolor.js → src/technicolor.js} +0 -0
  501. /package/{tilt-shift.js → src/tilt-shift.js} +0 -0
  502. /package/{toy.js → src/toy.js} +0 -0
  503. /package/{valley-fog.js → src/valley-fog.js} +0 -0
  504. /package/{weather-map.js → src/weather-map.js} +0 -0
  505. /package/{white-model.js → src/white-model.js} +0 -0
package/dist/clouds.js ADDED
@@ -0,0 +1,642 @@
1
+ import { Cartesian3, Ellipsoid, Matrix4, PixelDatatype, Rectangle, Math as CesiumMath } from '@cesium/core';
2
+ import { PostProcessStage, PostProcessStageComposite, TextureMagnificationFilter, TextureMinificationFilter } from '@cesium/engine';
3
+ // @ts-expect-error the engine exports its 3D textures and samplers, but does not type them
4
+ import { Sampler, Texture3D, TextureWrap } from '@cesium/engine';
5
+ // @ts-expect-error the engine exports its textures, framebuffers and render states, but does not type them
6
+ import { Framebuffer, RenderState, Texture } from '@cesium/engine';
7
+ import { acquireCloudCover, releaseCloudCover } from './cloud-cover.js';
8
+ import createCloudMap from './cloud-map.js';
9
+ import createCloudNoise, { createMapNoise } from './cloud-noise.js';
10
+ import { acquireTerrainDepth, releaseTerrainDepth } from './depth-test.js';
11
+ import Effect from './effect.js';
12
+ import { acquireFrames, releaseFrames } from './frame-clock.js';
13
+ import { heightUniforms } from './height.js';
14
+ import CloudsBlur from './shaders/CloudsBlur.js';
15
+ import CloudsComposite from './shaders/CloudsComposite.js';
16
+ import CloudsDensity from './shaders/CloudsDensity.js';
17
+ import CloudsDepth from './shaders/CloudsDepth.js';
18
+ import CloudsMarch from './shaders/CloudsMarch.js';
19
+ import CloudsResolve from './shaders/CloudsResolve.js';
20
+ import CloudsShadow from './shaders/CloudsShadow.js';
21
+ import CloudsShadowMap from './shaders/CloudsShadowMap.js';
22
+ import CloudsSlab from './shaders/CloudsSlab.js';
23
+ import EyeFromDepth from './shaders/EyeFromDepth.js';
24
+ import Fog from './shaders/Fog.js';
25
+ import Height from './shaders/Height.js';
26
+ import Phase from './shaders/Phase.js';
27
+ import RainHaze from './shaders/RainHaze.js';
28
+ import WeatherMapShader from './shaders/WeatherMap.js';
29
+ import WeatherMap from './weather-map.js';
30
+ // the clouds are kilometers wide and soft: a quarter of the resolution, a 16th of the pixels, is
31
+ // enough for their raymarch (CloudsComposite.glsl's CLOUD_SCALE)
32
+ const CLOUD_SCALE = 0.25;
33
+ // voxels along each side of the noise, CloudsDensity.glsl's NOISE_VOXELS
34
+ const NOISE_SIZE = 64;
35
+ // the share of the previous frames in each frame's clouds, about 10 frames' worth (Hillaire 2016,
36
+ // sec. 5.5.3, blends 0.1 of the current one)
37
+ const HISTORY_WEIGHT = 0.9;
38
+ // after the camera, the clock or the map changes, the scene renders this long, in milliseconds, at
39
+ // this frame rate, for the accumulation to settle, also in requestRenderMode
40
+ const SETTLE_TIME = 500;
41
+ const SETTLE_RATE = 30;
42
+ // with a drift, the clouds move all the time: the scene renders at this frame rate while they are
43
+ // active, also in requestRenderMode
44
+ const DRIFT_RATE = 30;
45
+ // the shadow map: its texels across, over a square centered on the ground point under the camera,
46
+ // this many times as wide as the camera is high, between these sides, in meters, so that it covers
47
+ // the view from high above; drawn again once that point moves a 40th of it, its side changes by a
48
+ // quarter, or the clock or the clouds change, rather than at each frame
49
+ const SHADOW_SIZE = 512;
50
+ const SHADOW_SPREAD = 4;
51
+ const SHADOW_EXTENTS = [80000, 800000];
52
+ const SHADOW_MOVE = 1 / 40;
53
+ const SHADOW_RESIZE = 0.25;
54
+ // and at most once in this many milliseconds, while they keep changing, as during playback: a
55
+ // redraw takes as long as a frame of the clouds or longer
56
+ const SHADOW_INTERVAL = 250;
57
+ // the history is a copy of the resolve's output, drawn rather than copied: Cesium does not copy
58
+ // from a framebuffer into a texture of half floats
59
+ const COPY = `precision highp sampler2D;
60
+ uniform sampler2D source;
61
+ in vec2 v_textureCoordinates;
62
+ void main() {
63
+ out_FragColor = texture(source, v_textureCoordinates);
64
+ }
65
+ `;
66
+ // the clouds over the lightest rain are this thick, in meters, CloudsDensity.glsl's THIN_DEPTH
67
+ const THIN_DEPTH = 1500;
68
+ // the wind's offset of the noise wraps at this many meters, a period of its tile, CloudsMarch.glsl's
69
+ // NOISE_TILE, and of its larger lookup, the tile over LARGE_SCALE (0.27): single precision would
70
+ // lose the offset after days of wind
71
+ const WIND_PERIOD = 100 * 16000;
72
+ /**
73
+ * The noise's voxels, made once for all the clouds of the page: about a third of a second.
74
+ * @type {Uint8Array | undefined}
75
+ */
76
+ let noise;
77
+ /**
78
+ * The noise over the clouds' map, made once for all the clouds of the page.
79
+ * @type {Uint8Array | undefined}
80
+ */
81
+ let mapNoise;
82
+ // texels along each side of the map's noise
83
+ const MAP_NOISE_SIZE = 256;
84
+ /**
85
+ * Clouds from a map of the rain: a slab above the cloud base where the map
86
+ * has rain, a flat layer over drizzle and towers up to the cloud top over the
87
+ * heaviest rain, eroded by noise, lit by the sun with a silver lining toward
88
+ * it and by the sky, brighter at their top. Seen from far above they are
89
+ * cloud tops; the camera flies into them as it comes down. Activated before
90
+ * Precipitation, the rain, its shafts and its haze are drawn over them, so
91
+ * from below the cloud base they are seen through the rain. They are
92
+ * raymarched at a quarter of
93
+ * the resolution, accumulated over the frames, and upscaled by the scene's
94
+ * depth. Their noise drifts with the wind by the scene's clock, and with a
95
+ * drift by the real time; after a change, the scene renders for half a second
96
+ * for them to settle, then rests, unless they drift.
97
+ * Without a map, there are no clouds.
98
+ */
99
+ export default class Clouds extends Effect {
100
+ /**
101
+ * @param {import('@cesium/engine').CesiumWidget} viewer
102
+ * @param {{map?: import('./weather-map.js').WeatherMapOptions, cloudBase?: number, cloudTop?: number, density?: number, wind?: number, drift?: number}} [options]
103
+ */
104
+ constructor(viewer, options = {}) {
105
+ super(viewer);
106
+ this.cloudBase_ = options.cloudBase ?? 2500;
107
+ this.cloudTop_ = options.cloudTop ?? 9000;
108
+ this.density_ = options.density ?? 1;
109
+ this.wind_ = options.wind ?? 10;
110
+ this.drift_ = options.drift ?? 0;
111
+ // without a map, no clouds
112
+ this.weatherMap_ = new WeatherMap(0);
113
+ // the maps of the rain, from which the clouds' maps are made
114
+ /** @type {import('./weather-map.js').WeatherMapOptions | undefined} */
115
+ this.map_ = options.map;
116
+ /** @type {import('./weather-map.js').WeatherMapOptions | undefined} */
117
+ this.nextMap_ = undefined;
118
+ this.weatherMap_.map = options.map && createCloudMap(options.map);
119
+ // the map's intensity at the camera when it is inside the clouds, read each frame
120
+ this.localDensity_ = 0;
121
+ // made when the clouds are first drawn, as the map's texture
122
+ /** @type {any} */
123
+ this.noiseTexture_ = undefined;
124
+ /** @type {any} */
125
+ this.mapNoiseTexture_ = undefined;
126
+ // the accumulation over the frames: the frames drawn, the previous frames' clouds, their share,
127
+ // the previous frame's view and projection, and what makes the scene render until it settles
128
+ this.frame_ = 0;
129
+ /** @type {any} */
130
+ this.history_ = undefined;
131
+ /** @type {any} */
132
+ this.historyFramebuffer_ = undefined;
133
+ /** @type {any} */
134
+ this.copy_ = undefined;
135
+ /** @type {any} */
136
+ this.copySource_ = undefined;
137
+ this.historyWeight_ = 0;
138
+ this.previousViewProjection_ = new Matrix4();
139
+ this.reprojection_ = new Matrix4();
140
+ this.lastView_ = new Matrix4();
141
+ this.lastTime_ = { dayNumber: 0, secondsOfDay: 0 };
142
+ this.changed_ = false;
143
+ this.settling_ = false;
144
+ this.settleUntil_ = 0;
145
+ // the shadow map, its ground point and time, and whether the clouds changed since it was drawn
146
+ /** @type {any} */
147
+ this.shadow_ = undefined;
148
+ /** @type {any} */
149
+ this.shadowFramebuffer_ = undefined;
150
+ /** @type {any} */
151
+ this.shadowCommand_ = undefined;
152
+ this.shadowCenter_ = new Cartesian3();
153
+ this.shadowExtent_ = SHADOW_EXTENTS[0];
154
+ this.shadowTime_ = { dayNumber: 0, secondsOfDay: 0 };
155
+ this.shadowDrawnAt_ = -Infinity;
156
+ this.shadowChanged_ = true;
157
+ // for Precipitation, which lights its haze through it
158
+ /** @type {import('./cloud-cover.js').CloudShadow} */
159
+ this.shadowSource_ = { texture: () => this.shadow_, center: this.shadowCenter_, extent: () => this.shadowExtent_, base: () => this.cloudBase_, top: () => this.slabTop_() };
160
+ this.onPreRender_ = () => {
161
+ const { camera } = this.viewer.scene;
162
+ this.drawShadow_(this.viewer.scene);
163
+ const { longitude, latitude, height } = camera.positionCartographic;
164
+ const inside = height >= this.cloudBase_ && height <= this.cloudTop_;
165
+ this.localDensity_ = inside ? this.weatherMap_.intensityAt(longitude, latitude) : 0;
166
+ const time = this.viewer.clock.currentTime;
167
+ if (this.changed_ || !Matrix4.equals(camera.viewMatrix, this.lastView_) || time.dayNumber !== this.lastTime_.dayNumber || time.secondsOfDay !== this.lastTime_.secondsOfDay) {
168
+ this.changed_ = false;
169
+ Matrix4.clone(camera.viewMatrix, this.lastView_);
170
+ this.lastTime_ = { dayNumber: time.dayNumber, secondsOfDay: time.secondsOfDay };
171
+ this.settleUntil_ = Date.now() + SETTLE_TIME;
172
+ if (!this.settling_) {
173
+ this.settling_ = true;
174
+ acquireFrames(this.viewer.scene, SETTLE_RATE);
175
+ }
176
+ }
177
+ };
178
+ this.onPostRender_ = () => {
179
+ const { scene } = this.viewer;
180
+ this.keepHistory_(scene);
181
+ Matrix4.multiply(scene.camera.frustum.projectionMatrix, scene.camera.viewMatrix, this.previousViewProjection_);
182
+ this.frame_ = (this.frame_ + 1) % 1024;
183
+ if (this.settling_ && Date.now() > this.settleUntil_) {
184
+ this.settling_ = false;
185
+ releaseFrames(scene, SETTLE_RATE);
186
+ }
187
+ };
188
+ }
189
+ /**
190
+ * @override
191
+ * @param {import('@cesium/engine').Scene} scene
192
+ */
193
+ createStage_(scene) {
194
+ // the farthest depth of each block of pixels of the march, at its resolution
195
+ const depth = new PostProcessStage({
196
+ fragmentShader: EyeFromDepth + CloudsDepth,
197
+ textureScale: CLOUD_SCALE,
198
+ pixelDatatype: PixelDatatype.FLOAT,
199
+ });
200
+ const march = new PostProcessStage({
201
+ fragmentShader: EyeFromDepth + Height + CloudsSlab + WeatherMapShader + CloudsDensity + Fog + Phase + RainHaze + CloudsMarch,
202
+ uniforms: {
203
+ ...this.slabUniforms_(scene),
204
+ // @ts-expect-error the scene's context is not typed
205
+ ...this.densityUniforms_(scene.context),
206
+ cloudDepth: depth.name,
207
+ // @ts-expect-error the scene's context is not typed
208
+ maxMap: () => this.weatherMap_.maxTexture(scene.context),
209
+ frame: () => this.frame_,
210
+ skyLightIntensity: () => scene.skyAtmosphere?.atmosphereLightIntensity ?? 50,
211
+ },
212
+ textureScale: CLOUD_SCALE,
213
+ });
214
+ // accumulated over the frames
215
+ const resolve = new PostProcessStage({
216
+ fragmentShader: EyeFromDepth + Height + CloudsSlab + CloudsResolve,
217
+ uniforms: {
218
+ ...this.slabUniforms_(scene),
219
+ cloudDepth: depth.name,
220
+ cloudTexture: march.name,
221
+ // @ts-expect-error the scene's context is not typed
222
+ historyTexture: () => this.history_ ?? scene.context.defaultTexture,
223
+ reprojection: () => Matrix4.multiply(this.previousViewProjection_, scene.camera.inverseViewMatrix, this.reprojection_),
224
+ historyWeight: () => (this.history_ ? this.historyWeight_ : 0),
225
+ },
226
+ textureScale: CLOUD_SCALE,
227
+ pixelDatatype: PixelDatatype.HALF_FLOAT,
228
+ });
229
+ // blurred at the same resolution
230
+ const blurred = new PostProcessStage({
231
+ fragmentShader: CloudsBlur,
232
+ uniforms: { cloudTexture: resolve.name, cloudDepth: depth.name },
233
+ textureScale: CLOUD_SCALE,
234
+ });
235
+ return new PostProcessStageComposite({
236
+ stages: [
237
+ depth,
238
+ march,
239
+ resolve,
240
+ blurred,
241
+ new PostProcessStage({
242
+ fragmentShader: EyeFromDepth + CloudsShadow + CloudsComposite,
243
+ uniforms: {
244
+ ...this.shadowUniforms_(scene),
245
+ cloudTexture: blurred.name,
246
+ cloudDepth: depth.name,
247
+ },
248
+ }),
249
+ ],
250
+ // the clouds are drawn over the scene, not over the march
251
+ inputPreviousStageTexture: false,
252
+ });
253
+ }
254
+ /**
255
+ * The top of the tallest cloud the map makes, as CloudsDensity.glsl's cloudDensity makes the
256
+ * clouds of its tallest type, over its heaviest rain: from above, the march starts there rather than at the cloud
257
+ * top, so that its steps are in the clouds rather than in the empty air over them.
258
+ */
259
+ slabTop_() {
260
+ // the clouds' map's tallest type, in blue
261
+ const type = this.weatherMap_.maxValues[2];
262
+ return this.cloudBase_ + THIN_DEPTH + (this.cloudTop_ - this.cloudBase_ - THIN_DEPTH) * type;
263
+ }
264
+ /**
265
+ * The direction the wind blows toward, in world coordinates: the east at the map's center, fixed
266
+ * for the map rather than turning with the camera, which would shift the drifted noise.
267
+ */
268
+ windDirection_() {
269
+ const rectangle = this.weatherMap_.map?.rectangle;
270
+ if (!rectangle) {
271
+ return Cartesian3.ZERO;
272
+ }
273
+ const up = Ellipsoid.WGS84.geodeticSurfaceNormalCartographic(Rectangle.center(rectangle));
274
+ return Cartesian3.normalize(Cartesian3.cross(Cartesian3.UNIT_Z, up, new Cartesian3()), new Cartesian3());
275
+ }
276
+ /**
277
+ * How far the wind has carried the noise by the scene's clock, still while it is paused, and the
278
+ * drift by the real time, in world coordinates, in double precision and wrapped at WIND_PERIOD.
279
+ * @param {number} [seconds] the real time
280
+ */
281
+ windOffset_(seconds = performance.now() / 1000) {
282
+ const { dayNumber, secondsOfDay } = this.viewer.clock.currentTime;
283
+ const distance = this.wind_ * (dayNumber * 86400 + secondsOfDay) + this.drift_ * seconds;
284
+ const offset = Cartesian3.multiplyByScalar(this.windDirection_(), distance, new Cartesian3());
285
+ return new Cartesian3(offset.x % WIND_PERIOD, offset.y % WIND_PERIOD, offset.z % WIND_PERIOD);
286
+ }
287
+ /**
288
+ * The uniforms of CloudsSlab.glsl, with Height.glsl's it needs.
289
+ * @param {import('@cesium/engine').Scene} scene
290
+ */
291
+ slabUniforms_(scene) {
292
+ return { ...heightUniforms(scene), cloudBase: () => this.cloudBase_, slabTop: () => this.slabTop_() };
293
+ }
294
+ /**
295
+ * The uniforms of CloudsDensity.glsl, with WeatherMap.glsl's it needs.
296
+ * @param {any} context the scene's context
297
+ */
298
+ densityUniforms_(context) {
299
+ return {
300
+ map: () => this.weatherMap_.texture(context),
301
+ nextMap: () => this.weatherMap_.nextTexture(context),
302
+ mapBlend: () => this.weatherMap_.blend,
303
+ mapBounds: () => this.weatherMap_.bounds,
304
+ cloudNoise: () => this.createNoiseTexture_(context),
305
+ mapNoise: () => this.createMapNoiseTexture_(context),
306
+ cloudTop: () => this.cloudTop_,
307
+ density: () => this.density_,
308
+ windDirection: () => this.windDirection_(),
309
+ windOffset: () => this.windOffset_(),
310
+ };
311
+ }
312
+ /**
313
+ * The uniforms of CloudsShadow.glsl, for the stages that read the shadow map.
314
+ * @param {import('@cesium/engine').Scene} scene
315
+ */
316
+ shadowUniforms_(scene) {
317
+ return {
318
+ // @ts-expect-error the scene's context is not typed
319
+ shadowMap: () => this.shadow_ ?? scene.context.defaultTexture,
320
+ shadowCenter: () => this.shadowCenter_,
321
+ shadowExtent: () => this.shadowExtent_,
322
+ shadowBase: () => this.cloudBase_,
323
+ shadowTop: () => this.slabTop_(),
324
+ };
325
+ }
326
+ /**
327
+ * The shadow map's side, in meters, for a camera this high.
328
+ * @param {number} height meters
329
+ */
330
+ shadowExtentFor_(height) {
331
+ return CesiumMath.clamp(SHADOW_SPREAD * height, SHADOW_EXTENTS[0], SHADOW_EXTENTS[1]);
332
+ }
333
+ /**
334
+ * Whether the shadow map, drawn around a ground point at a time, is to be drawn again.
335
+ * @param {Cartesian3} ground the ground point under the camera, in world coordinates
336
+ * @param {{dayNumber: number, secondsOfDay: number}} time the clock's
337
+ * @param {number} [extent] the side it would have now, in meters
338
+ */
339
+ shadowStale_(ground, time, extent = this.shadowExtent_) {
340
+ return (this.shadowChanged_ ||
341
+ time.dayNumber !== this.shadowTime_.dayNumber ||
342
+ time.secondsOfDay !== this.shadowTime_.secondsOfDay ||
343
+ Cartesian3.distance(ground, this.shadowCenter_) > SHADOW_MOVE * this.shadowExtent_ ||
344
+ Math.abs(extent - this.shadowExtent_) > SHADOW_RESIZE * this.shadowExtent_ ||
345
+ // the drifting clouds, at every frame
346
+ this.drift_ > 0);
347
+ }
348
+ /**
349
+ * Whether the shadow map is to be drawn again now: stale, and not drawn in the last
350
+ * SHADOW_INTERVAL.
351
+ * @param {Cartesian3} ground
352
+ * @param {{dayNumber: number, secondsOfDay: number}} time
353
+ * @param {number} now milliseconds
354
+ * @param {number} [extent] the side it would have now, in meters
355
+ */
356
+ shadowDue_(ground, time, now, extent) {
357
+ return this.shadowStale_(ground, time, extent) && now - this.shadowDrawnAt_ >= SHADOW_INTERVAL;
358
+ }
359
+ /**
360
+ * @param {Cartesian3} ground
361
+ * @param {{dayNumber: number, secondsOfDay: number}} time
362
+ * @param {number} [now] milliseconds
363
+ * @param {number} [extent] its side, in meters
364
+ */
365
+ shadowDrawn_(ground, time, now = Date.now(), extent = this.shadowExtent_) {
366
+ Cartesian3.clone(ground, this.shadowCenter_);
367
+ this.shadowExtent_ = extent;
368
+ this.shadowTime_ = { dayNumber: time.dayNumber, secondsOfDay: time.secondsOfDay };
369
+ this.shadowDrawnAt_ = now;
370
+ this.shadowChanged_ = false;
371
+ }
372
+ /**
373
+ * Draws the shadow map into its own texture before the stages run, when it is due: the
374
+ * stages' textures are sized after the screen. A redraw put off renders after the change
375
+ * settles, in the frames the accumulation asks for.
376
+ * @param {import('@cesium/engine').Scene} scene
377
+ */
378
+ drawShadow_(scene) {
379
+ const ground = Ellipsoid.WGS84.scaleToGeodeticSurface(scene.camera.positionWC, new Cartesian3());
380
+ const time = this.viewer.clock.currentTime;
381
+ const now = Date.now();
382
+ const extent = this.shadowExtentFor_(scene.camera.positionCartographic.height);
383
+ if (!ground || !this.shadowDue_(ground, time, now, extent)) {
384
+ return;
385
+ }
386
+ this.shadowDrawn_(ground, time, now, extent);
387
+ // @ts-expect-error the scene's context is not typed
388
+ const context = scene.context;
389
+ if (!context) {
390
+ return;
391
+ }
392
+ if (!this.shadow_) {
393
+ this.shadow_ = new Texture({ context, width: SHADOW_SIZE, height: SHADOW_SIZE, pixelDatatype: PixelDatatype.HALF_FLOAT });
394
+ this.shadowFramebuffer_ = new Framebuffer({ context, colorTextures: [this.shadow_], destroyAttachments: false });
395
+ this.shadowCommand_ = context.createViewportQuadCommand(Height + CloudsSlab + WeatherMapShader + CloudsDensity + CloudsShadow + CloudsShadowMap, {
396
+ framebuffer: this.shadowFramebuffer_,
397
+ renderState: RenderState.fromCache({ viewport: { x: 0, y: 0, width: SHADOW_SIZE, height: SHADOW_SIZE } }),
398
+ uniformMap: {
399
+ ...this.slabUniforms_(scene),
400
+ ...this.densityUniforms_(context),
401
+ maxMap: () => this.weatherMap_.maxTexture(context),
402
+ shadowCenter: () => this.shadowCenter_,
403
+ shadowExtent: () => this.shadowExtent_,
404
+ },
405
+ });
406
+ }
407
+ this.shadowCommand_.execute(context);
408
+ }
409
+ destroyShadow_() {
410
+ this.shadowCommand_?.shaderProgram?.destroy();
411
+ this.shadowCommand_ = undefined;
412
+ this.shadowFramebuffer_ = this.shadowFramebuffer_?.destroy();
413
+ this.shadow_ = this.shadow_?.destroy();
414
+ this.shadowChanged_ = true;
415
+ }
416
+ /**
417
+ * Keeps this frame's accumulated clouds for the next one, drawn into the history at the size of
418
+ * the resolve's output, made again when it changes.
419
+ * @param {import('@cesium/engine').Scene} scene
420
+ */
421
+ keepHistory_(scene) {
422
+ // @ts-expect-error the collection's output textures are not typed
423
+ const output = this.stage_ && scene.postProcessStages.getOutputTexture?.(this.stage_.get(2).name);
424
+ if (!output) {
425
+ return;
426
+ }
427
+ // @ts-expect-error the scene's context is not typed
428
+ const context = scene.context;
429
+ if (!this.history_ || this.history_.width !== output.width || this.history_.height !== output.height) {
430
+ this.destroyHistory_();
431
+ this.history_ = new Texture({ context, width: output.width, height: output.height, pixelDatatype: PixelDatatype.HALF_FLOAT });
432
+ this.historyFramebuffer_ = new Framebuffer({ context, colorTextures: [this.history_], destroyAttachments: false });
433
+ this.historyWeight_ = 0;
434
+ }
435
+ this.copySource_ = output;
436
+ this.copy_ ??= context.createViewportQuadCommand(COPY, { uniformMap: { source: () => this.copySource_ } });
437
+ this.copy_.framebuffer = this.historyFramebuffer_;
438
+ this.copy_.renderState = RenderState.fromCache({ viewport: { x: 0, y: 0, width: output.width, height: output.height } });
439
+ this.copy_.execute(context);
440
+ this.historyWeight_ = HISTORY_WEIGHT;
441
+ }
442
+ destroyHistory_() {
443
+ this.historyFramebuffer_ = this.historyFramebuffer_?.destroy();
444
+ this.history_ = this.history_?.destroy();
445
+ }
446
+ /**
447
+ * The noise's texture, repeating in every direction, with its mipmaps for the far clouds.
448
+ * @param {any} context the scene's context
449
+ */
450
+ createNoiseTexture_(context) {
451
+ if (!this.noiseTexture_) {
452
+ noise ??= createCloudNoise(NOISE_SIZE);
453
+ this.noiseTexture_ = new Texture3D({
454
+ context,
455
+ flipY: false,
456
+ source: { width: NOISE_SIZE, height: NOISE_SIZE, depth: NOISE_SIZE, arrayBufferView: noise },
457
+ sampler: new Sampler({
458
+ wrapS: TextureWrap.REPEAT,
459
+ wrapT: TextureWrap.REPEAT,
460
+ wrapR: TextureWrap.REPEAT,
461
+ minificationFilter: TextureMinificationFilter.LINEAR_MIPMAP_LINEAR,
462
+ magnificationFilter: TextureMagnificationFilter.LINEAR,
463
+ }),
464
+ });
465
+ this.noiseTexture_.generateMipmap();
466
+ }
467
+ return this.noiseTexture_;
468
+ }
469
+ /**
470
+ * The noise over the clouds' map, repeating.
471
+ * @param {any} context the scene's context
472
+ */
473
+ createMapNoiseTexture_(context) {
474
+ if (!this.mapNoiseTexture_) {
475
+ mapNoise ??= createMapNoise(MAP_NOISE_SIZE);
476
+ this.mapNoiseTexture_ = new Texture({
477
+ context,
478
+ flipY: false,
479
+ source: { width: MAP_NOISE_SIZE, height: MAP_NOISE_SIZE, arrayBufferView: mapNoise },
480
+ sampler: new Sampler({
481
+ wrapS: TextureWrap.REPEAT,
482
+ wrapT: TextureWrap.REPEAT,
483
+ minificationFilter: TextureMinificationFilter.LINEAR,
484
+ magnificationFilter: TextureMagnificationFilter.LINEAR,
485
+ }),
486
+ });
487
+ }
488
+ return this.mapNoiseTexture_;
489
+ }
490
+ /**
491
+ * @override
492
+ * @param {import('@cesium/engine').Scene} scene
493
+ */
494
+ activated_(scene) {
495
+ if (this.drift_ > 0) {
496
+ acquireFrames(scene, DRIFT_RATE);
497
+ }
498
+ scene.preRender.addEventListener(this.onPreRender_);
499
+ scene.postRender.addEventListener(this.onPostRender_);
500
+ acquireTerrainDepth(scene);
501
+ acquireCloudCover(scene, this.shadowSource_);
502
+ }
503
+ /**
504
+ * @override
505
+ * @param {import('@cesium/engine').Scene} scene
506
+ */
507
+ deactivating_(scene) {
508
+ releaseCloudCover(scene, this.shadowSource_);
509
+ releaseTerrainDepth(scene);
510
+ scene.preRender.removeEventListener(this.onPreRender_);
511
+ scene.postRender.removeEventListener(this.onPostRender_);
512
+ if (this.settling_) {
513
+ this.settling_ = false;
514
+ releaseFrames(scene, SETTLE_RATE);
515
+ }
516
+ if (this.drift_ > 0) {
517
+ releaseFrames(scene, DRIFT_RATE);
518
+ }
519
+ this.destroyHistory_();
520
+ this.destroyShadow_();
521
+ this.copy_?.shaderProgram?.destroy();
522
+ this.copy_ = undefined;
523
+ this.weatherMap_.destroy();
524
+ this.noiseTexture_ = this.noiseTexture_?.destroy();
525
+ this.mapNoiseTexture_ = this.mapNoiseTexture_?.destroy();
526
+ }
527
+ /**
528
+ * Where it rains, or undefined for no clouds: an image whose red channel
529
+ * is the local intensity, 0 to 1, over a rectangle of longitudes and
530
+ * latitudes, north up, as Precipitation's map. Set it again after drawing
531
+ * on the image, which is read then.
532
+ */
533
+ get map() {
534
+ return this.map_;
535
+ }
536
+ set map(value) {
537
+ this.map_ = value;
538
+ this.weatherMap_.map = value && createCloudMap(value);
539
+ this.shadowChanged_ = true;
540
+ // the previous map's clouds would linger
541
+ this.historyWeight_ = 0;
542
+ this.changed_ = true;
543
+ this.viewer.scene.requestRender();
544
+ }
545
+ /**
546
+ * The map the clouds crossfade to by the map blend, over the same
547
+ * rectangle, as the radar's next hour, or undefined for none.
548
+ */
549
+ get nextMap() {
550
+ return this.nextMap_;
551
+ }
552
+ set nextMap(value) {
553
+ this.nextMap_ = value;
554
+ this.weatherMap_.nextMap = value && createCloudMap(value);
555
+ this.shadowChanged_ = true;
556
+ this.viewer.scene.requestRender();
557
+ }
558
+ /**
559
+ * From the map, 0, to the next map, 1.
560
+ */
561
+ get mapBlend() {
562
+ return this.weatherMap_.blend;
563
+ }
564
+ set mapBlend(value) {
565
+ this.weatherMap_.blend = value;
566
+ this.shadowChanged_ = true;
567
+ this.viewer.scene.requestRender();
568
+ }
569
+ /**
570
+ * Altitude of the cloud base, in meters above the ellipsoid, as
571
+ * Precipitation's.
572
+ */
573
+ get cloudBase() {
574
+ return this.cloudBase_;
575
+ }
576
+ set cloudBase(value) {
577
+ this.cloudBase_ = value;
578
+ this.shadowChanged_ = true;
579
+ this.viewer.scene.requestRender();
580
+ }
581
+ /**
582
+ * Altitude of the highest cloud tops, over the heaviest rain, in meters
583
+ * above the ellipsoid; over drizzle the clouds are 1500 m thick.
584
+ */
585
+ get cloudTop() {
586
+ return this.cloudTop_;
587
+ }
588
+ set cloudTop(value) {
589
+ this.cloudTop_ = value;
590
+ this.shadowChanged_ = true;
591
+ this.viewer.scene.requestRender();
592
+ }
593
+ /**
594
+ * Scale of the clouds' opacity: 1 for solid clouds over heavy rain.
595
+ */
596
+ get density() {
597
+ return this.density_;
598
+ }
599
+ set density(value) {
600
+ this.density_ = value;
601
+ this.shadowChanged_ = true;
602
+ this.viewer.scene.requestRender();
603
+ }
604
+ /**
605
+ * Speed of the wind that carries the clouds' noise toward the east, in m/s,
606
+ * by the scene's clock: a time-lapse while it runs faster, still while it
607
+ * is paused.
608
+ */
609
+ get wind() {
610
+ return this.wind_;
611
+ }
612
+ set wind(value) {
613
+ this.wind_ = value;
614
+ this.shadowChanged_ = true;
615
+ this.viewer.scene.requestRender();
616
+ }
617
+ /**
618
+ * Speed of the drift of the clouds' noise toward the east, in m/s, by the
619
+ * real time rather than the scene's clock: the clouds move while the clock
620
+ * is paused, and the scene renders all the time while they are active. 0,
621
+ * by default, for none.
622
+ */
623
+ get drift() {
624
+ return this.drift_;
625
+ }
626
+ set drift(value) {
627
+ const drifting = this.drift_ > 0;
628
+ this.drift_ = value;
629
+ if (this.stage_ && drifting !== value > 0) {
630
+ (value > 0 ? acquireFrames : releaseFrames)(this.viewer.scene, DRIFT_RATE);
631
+ }
632
+ this.viewer.scene.requestRender();
633
+ }
634
+ /**
635
+ * The map's intensity at the camera when it is inside the clouds, 0 to 1,
636
+ * read each frame while active; 0 outside them.
637
+ */
638
+ get localDensity() {
639
+ return this.localDensity_;
640
+ }
641
+ }
642
+ //# sourceMappingURL=clouds.js.map