@itwin/frontend-devtools 4.0.0-dev.7 → 4.0.0-dev.72

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 (359) hide show
  1. package/CHANGELOG.md +41 -1
  2. package/lib/cjs/ClipboardUtilities.d.ts +8 -8
  3. package/lib/cjs/ClipboardUtilities.js +26 -26
  4. package/lib/cjs/FrontEndDevTools.d.ts +19 -19
  5. package/lib/cjs/FrontEndDevTools.js +221 -221
  6. package/lib/cjs/FrontEndDevTools.js.map +1 -1
  7. package/lib/cjs/effects/Convolution.d.ts +68 -68
  8. package/lib/cjs/effects/Convolution.js +148 -148
  9. package/lib/cjs/effects/Convolution.js.map +1 -1
  10. package/lib/cjs/effects/EffectTools.d.ts +33 -33
  11. package/lib/cjs/effects/EffectTools.js +67 -68
  12. package/lib/cjs/effects/EffectTools.js.map +1 -1
  13. package/lib/cjs/effects/Explosion.d.ts +12 -12
  14. package/lib/cjs/effects/Explosion.js +168 -168
  15. package/lib/cjs/effects/Explosion.js.map +1 -1
  16. package/lib/cjs/effects/FlipImage.d.ts +30 -30
  17. package/lib/cjs/effects/FlipImage.js +79 -79
  18. package/lib/cjs/effects/FlipImage.js.map +1 -1
  19. package/lib/cjs/effects/LensDistortion.d.ts +34 -34
  20. package/lib/cjs/effects/LensDistortion.js +88 -88
  21. package/lib/cjs/effects/LensDistortion.js.map +1 -1
  22. package/lib/cjs/effects/Random.d.ts +24 -24
  23. package/lib/cjs/effects/Random.js +49 -49
  24. package/lib/cjs/effects/Saturation.d.ts +30 -30
  25. package/lib/cjs/effects/Saturation.js +59 -59
  26. package/lib/cjs/effects/Saturation.js.map +1 -1
  27. package/lib/cjs/effects/Snow.d.ts +76 -76
  28. package/lib/cjs/effects/Snow.js +187 -187
  29. package/lib/cjs/effects/Snow.js.map +1 -1
  30. package/lib/cjs/effects/Vignette.d.ts +39 -39
  31. package/lib/cjs/effects/Vignette.js +79 -79
  32. package/lib/cjs/effects/Vignette.js.map +1 -1
  33. package/lib/cjs/frontend-devtools.d.ts +82 -82
  34. package/lib/cjs/frontend-devtools.js +102 -98
  35. package/lib/cjs/frontend-devtools.js.map +1 -1
  36. package/lib/cjs/tools/AnimationIntervalTool.d.ts +15 -15
  37. package/lib/cjs/tools/AnimationIntervalTool.js +30 -30
  38. package/lib/cjs/tools/AnimationIntervalTool.js.map +1 -1
  39. package/lib/cjs/tools/ChangeUnitsTool.d.ts +15 -15
  40. package/lib/cjs/tools/ChangeUnitsTool.js +41 -41
  41. package/lib/cjs/tools/ChangeUnitsTool.js.map +1 -1
  42. package/lib/cjs/tools/ClipTools.d.ts +67 -67
  43. package/lib/cjs/tools/ClipTools.js +161 -164
  44. package/lib/cjs/tools/ClipTools.js.map +1 -1
  45. package/lib/cjs/tools/DisplayStyleTools.d.ts +145 -145
  46. package/lib/cjs/tools/DisplayStyleTools.js +368 -370
  47. package/lib/cjs/tools/DisplayStyleTools.js.map +1 -1
  48. package/lib/cjs/tools/EmphasizeElementsTool.d.ts +60 -60
  49. package/lib/cjs/tools/EmphasizeElementsTool.js +154 -154
  50. package/lib/cjs/tools/EmphasizeElementsTool.js.map +1 -1
  51. package/lib/cjs/tools/FrustumDecoration.d.ts +57 -57
  52. package/lib/cjs/tools/FrustumDecoration.js +374 -374
  53. package/lib/cjs/tools/FrustumDecoration.js.map +1 -1
  54. package/lib/cjs/tools/InspectElementTool.d.ts +42 -42
  55. package/lib/cjs/tools/InspectElementTool.js +198 -198
  56. package/lib/cjs/tools/InspectElementTool.js.map +1 -1
  57. package/lib/cjs/tools/MapLayerTool.d.ts +264 -264
  58. package/lib/cjs/tools/MapLayerTool.js +507 -507
  59. package/lib/cjs/tools/MapLayerTool.js.map +1 -1
  60. package/lib/cjs/tools/MeasureTileLoadTime.d.ts +12 -12
  61. package/lib/cjs/tools/MeasureTileLoadTime.js +63 -63
  62. package/lib/cjs/tools/MeasureTileLoadTime.js.map +1 -1
  63. package/lib/cjs/tools/ModelAppearanceTools.d.ts +86 -86
  64. package/lib/cjs/tools/ModelAppearanceTools.js +183 -183
  65. package/lib/cjs/tools/ModelAppearanceTools.js.map +1 -1
  66. package/lib/cjs/tools/PlanProjectionTools.d.ts +40 -40
  67. package/lib/cjs/tools/PlanProjectionTools.js +149 -149
  68. package/lib/cjs/tools/PlanProjectionTools.js.map +1 -1
  69. package/lib/cjs/tools/PlanarMaskTools.d.ts +182 -182
  70. package/lib/cjs/tools/PlanarMaskTools.js +391 -393
  71. package/lib/cjs/tools/PlanarMaskTools.js.map +1 -1
  72. package/lib/cjs/tools/ProjectExtents.d.ts +41 -41
  73. package/lib/cjs/tools/ProjectExtents.js +110 -110
  74. package/lib/cjs/tools/ProjectExtents.js.map +1 -1
  75. package/lib/cjs/tools/RealityModelTools.d.ts +116 -116
  76. package/lib/cjs/tools/RealityModelTools.js +281 -281
  77. package/lib/cjs/tools/RealityModelTools.js.map +1 -1
  78. package/lib/cjs/tools/RealityTransitionTool.d.ts +25 -25
  79. package/lib/cjs/tools/RealityTransitionTool.js +115 -116
  80. package/lib/cjs/tools/RealityTransitionTool.js.map +1 -1
  81. package/lib/cjs/tools/RenderSystemTools.d.ts +38 -38
  82. package/lib/cjs/tools/RenderSystemTools.js +69 -70
  83. package/lib/cjs/tools/RenderSystemTools.js.map +1 -1
  84. package/lib/cjs/tools/RenderTargetTools.d.ts +107 -107
  85. package/lib/cjs/tools/RenderTargetTools.d.ts.map +1 -1
  86. package/lib/cjs/tools/RenderTargetTools.js +174 -174
  87. package/lib/cjs/tools/RenderTargetTools.js.map +1 -1
  88. package/lib/cjs/tools/ReportWebGLCompatibilityTool.d.ts +11 -11
  89. package/lib/cjs/tools/ReportWebGLCompatibilityTool.js +30 -30
  90. package/lib/cjs/tools/ReportWebGLCompatibilityTool.js.map +1 -1
  91. package/lib/cjs/tools/SavedViews.d.ts +46 -46
  92. package/lib/cjs/tools/SavedViews.js +136 -136
  93. package/lib/cjs/tools/SavedViews.js.map +1 -1
  94. package/lib/cjs/tools/ScheduleScriptTools.d.ts +37 -37
  95. package/lib/cjs/tools/ScheduleScriptTools.js +157 -159
  96. package/lib/cjs/tools/ScheduleScriptTools.js.map +1 -1
  97. package/lib/cjs/tools/SelectionTools.d.ts +28 -28
  98. package/lib/cjs/tools/SelectionTools.js +87 -87
  99. package/lib/cjs/tools/SelectionTools.js.map +1 -1
  100. package/lib/cjs/tools/SetGpuMemoryLimitTool.d.ts +15 -15
  101. package/lib/cjs/tools/SetGpuMemoryLimitTool.js +33 -33
  102. package/lib/cjs/tools/SetGpuMemoryLimitTool.js.map +1 -1
  103. package/lib/cjs/tools/SourceAspectIdTools.d.ts +40 -40
  104. package/lib/cjs/tools/SourceAspectIdTools.d.ts.map +1 -1
  105. package/lib/cjs/tools/SourceAspectIdTools.js +86 -86
  106. package/lib/cjs/tools/SourceAspectIdTools.js.map +1 -1
  107. package/lib/cjs/tools/TileRequestDecoration.d.ts +12 -12
  108. package/lib/cjs/tools/TileRequestDecoration.js +83 -83
  109. package/lib/cjs/tools/TileRequestDecoration.js.map +1 -1
  110. package/lib/cjs/tools/TileTreeBoundsDecoration.d.ts +11 -11
  111. package/lib/cjs/tools/TileTreeBoundsDecoration.js +74 -74
  112. package/lib/cjs/tools/TileTreeBoundsDecoration.js.map +1 -1
  113. package/lib/cjs/tools/ToolTipProvider.d.ts +15 -15
  114. package/lib/cjs/tools/ToolTipProvider.js +66 -66
  115. package/lib/cjs/tools/ToolTipProvider.js.map +1 -1
  116. package/lib/cjs/tools/ViewportTools.d.ts +218 -218
  117. package/lib/cjs/tools/ViewportTools.d.ts.map +1 -1
  118. package/lib/cjs/tools/ViewportTools.js +516 -516
  119. package/lib/cjs/tools/ViewportTools.js.map +1 -1
  120. package/lib/cjs/tools/parseArgs.d.ts +23 -23
  121. package/lib/cjs/tools/parseArgs.js +51 -51
  122. package/lib/cjs/tools/parseBoolean.d.ts +8 -8
  123. package/lib/cjs/tools/parseBoolean.js +26 -26
  124. package/lib/cjs/tools/parseToggle.d.ts +8 -8
  125. package/lib/cjs/tools/parseToggle.js +25 -25
  126. package/lib/cjs/ui/Button.d.ts +29 -29
  127. package/lib/cjs/ui/Button.d.ts.map +1 -1
  128. package/lib/cjs/ui/Button.js +26 -26
  129. package/lib/cjs/ui/CheckBox.d.ts +23 -23
  130. package/lib/cjs/ui/CheckBox.d.ts.map +1 -1
  131. package/lib/cjs/ui/CheckBox.js +27 -27
  132. package/lib/cjs/ui/ColorInput.d.ts +27 -27
  133. package/lib/cjs/ui/ColorInput.d.ts.map +1 -1
  134. package/lib/cjs/ui/ColorInput.js +53 -53
  135. package/lib/cjs/ui/ComboBox.d.ts +28 -28
  136. package/lib/cjs/ui/ComboBox.d.ts.map +1 -1
  137. package/lib/cjs/ui/ComboBox.js +42 -42
  138. package/lib/cjs/ui/DataList.d.ts +27 -27
  139. package/lib/cjs/ui/DataList.d.ts.map +1 -1
  140. package/lib/cjs/ui/DataList.js +39 -39
  141. package/lib/cjs/ui/NestedMenu.d.ts +19 -19
  142. package/lib/cjs/ui/NestedMenu.d.ts.map +1 -1
  143. package/lib/cjs/ui/NestedMenu.js +46 -46
  144. package/lib/cjs/ui/NumericInput.d.ts +35 -35
  145. package/lib/cjs/ui/NumericInput.d.ts.map +1 -1
  146. package/lib/cjs/ui/NumericInput.js +61 -61
  147. package/lib/cjs/ui/RadioBox.d.ts +29 -29
  148. package/lib/cjs/ui/RadioBox.d.ts.map +1 -1
  149. package/lib/cjs/ui/RadioBox.js +76 -76
  150. package/lib/cjs/ui/Slider.d.ts +28 -28
  151. package/lib/cjs/ui/Slider.d.ts.map +1 -1
  152. package/lib/cjs/ui/Slider.js +42 -42
  153. package/lib/cjs/ui/TextBox.d.ts +32 -32
  154. package/lib/cjs/ui/TextBox.d.ts.map +1 -1
  155. package/lib/cjs/ui/TextBox.js +56 -56
  156. package/lib/cjs/widgets/DiagnosticsPanel.d.ts +37 -37
  157. package/lib/cjs/widgets/DiagnosticsPanel.js +81 -81
  158. package/lib/cjs/widgets/FpsTracker.d.ts +19 -19
  159. package/lib/cjs/widgets/FpsTracker.js +56 -56
  160. package/lib/cjs/widgets/GpuProfiler.d.ts +16 -16
  161. package/lib/cjs/widgets/GpuProfiler.js +192 -192
  162. package/lib/cjs/widgets/KeyinField.d.ts +61 -61
  163. package/lib/cjs/widgets/KeyinField.js +186 -187
  164. package/lib/cjs/widgets/KeyinField.js.map +1 -1
  165. package/lib/cjs/widgets/MemoryTracker.d.ts +27 -27
  166. package/lib/cjs/widgets/MemoryTracker.js +242 -243
  167. package/lib/cjs/widgets/MemoryTracker.js.map +1 -1
  168. package/lib/cjs/widgets/RenderCommandBreakdown.d.ts +15 -15
  169. package/lib/cjs/widgets/RenderCommandBreakdown.js +67 -68
  170. package/lib/cjs/widgets/RenderCommandBreakdown.js.map +1 -1
  171. package/lib/cjs/widgets/TileMemoryBreakdown.d.ts +30 -30
  172. package/lib/cjs/widgets/TileMemoryBreakdown.js +203 -204
  173. package/lib/cjs/widgets/TileMemoryBreakdown.js.map +1 -1
  174. package/lib/cjs/widgets/TileStatisticsTracker.d.ts +21 -21
  175. package/lib/cjs/widgets/TileStatisticsTracker.d.ts.map +1 -1
  176. package/lib/cjs/widgets/TileStatisticsTracker.js +144 -142
  177. package/lib/cjs/widgets/TileStatisticsTracker.js.map +1 -1
  178. package/lib/cjs/widgets/ToolSettingsTracker.d.ts +9 -9
  179. package/lib/cjs/widgets/ToolSettingsTracker.js +211 -211
  180. package/lib/cjs/widgets/ToolSettingsTracker.js.map +1 -1
  181. package/lib/esm/ClipboardUtilities.d.ts +8 -8
  182. package/lib/esm/ClipboardUtilities.js +22 -22
  183. package/lib/esm/FrontEndDevTools.d.ts +19 -19
  184. package/lib/esm/FrontEndDevTools.js +218 -217
  185. package/lib/esm/FrontEndDevTools.js.map +1 -1
  186. package/lib/esm/effects/Convolution.d.ts +68 -68
  187. package/lib/esm/effects/Convolution.js +144 -138
  188. package/lib/esm/effects/Convolution.js.map +1 -1
  189. package/lib/esm/effects/EffectTools.d.ts +33 -33
  190. package/lib/esm/effects/EffectTools.js +63 -62
  191. package/lib/esm/effects/EffectTools.js.map +1 -1
  192. package/lib/esm/effects/Explosion.d.ts +12 -12
  193. package/lib/esm/effects/Explosion.js +165 -164
  194. package/lib/esm/effects/Explosion.js.map +1 -1
  195. package/lib/esm/effects/FlipImage.d.ts +30 -30
  196. package/lib/esm/effects/FlipImage.js +76 -74
  197. package/lib/esm/effects/FlipImage.js.map +1 -1
  198. package/lib/esm/effects/LensDistortion.d.ts +34 -34
  199. package/lib/esm/effects/LensDistortion.js +85 -83
  200. package/lib/esm/effects/LensDistortion.js.map +1 -1
  201. package/lib/esm/effects/Random.d.ts +24 -24
  202. package/lib/esm/effects/Random.js +41 -41
  203. package/lib/esm/effects/Saturation.d.ts +30 -30
  204. package/lib/esm/effects/Saturation.js +56 -54
  205. package/lib/esm/effects/Saturation.js.map +1 -1
  206. package/lib/esm/effects/Snow.d.ts +76 -76
  207. package/lib/esm/effects/Snow.js +184 -182
  208. package/lib/esm/effects/Snow.js.map +1 -1
  209. package/lib/esm/effects/Vignette.d.ts +39 -39
  210. package/lib/esm/effects/Vignette.js +76 -74
  211. package/lib/esm/effects/Vignette.js.map +1 -1
  212. package/lib/esm/frontend-devtools.d.ts +82 -82
  213. package/lib/esm/frontend-devtools.js +86 -86
  214. package/lib/esm/tools/AnimationIntervalTool.d.ts +15 -15
  215. package/lib/esm/tools/AnimationIntervalTool.js +27 -26
  216. package/lib/esm/tools/AnimationIntervalTool.js.map +1 -1
  217. package/lib/esm/tools/ChangeUnitsTool.d.ts +15 -15
  218. package/lib/esm/tools/ChangeUnitsTool.js +38 -37
  219. package/lib/esm/tools/ChangeUnitsTool.js.map +1 -1
  220. package/lib/esm/tools/ClipTools.d.ts +67 -67
  221. package/lib/esm/tools/ClipTools.js +158 -158
  222. package/lib/esm/tools/ClipTools.js.map +1 -1
  223. package/lib/esm/tools/DisplayStyleTools.d.ts +145 -145
  224. package/lib/esm/tools/DisplayStyleTools.js +364 -356
  225. package/lib/esm/tools/DisplayStyleTools.js.map +1 -1
  226. package/lib/esm/tools/EmphasizeElementsTool.d.ts +60 -60
  227. package/lib/esm/tools/EmphasizeElementsTool.js +150 -145
  228. package/lib/esm/tools/EmphasizeElementsTool.js.map +1 -1
  229. package/lib/esm/tools/FrustumDecoration.d.ts +57 -57
  230. package/lib/esm/tools/FrustumDecoration.js +370 -367
  231. package/lib/esm/tools/FrustumDecoration.js.map +1 -1
  232. package/lib/esm/tools/InspectElementTool.d.ts +42 -42
  233. package/lib/esm/tools/InspectElementTool.js +195 -194
  234. package/lib/esm/tools/InspectElementTool.js.map +1 -1
  235. package/lib/esm/tools/MapLayerTool.d.ts +264 -264
  236. package/lib/esm/tools/MapLayerTool.js +504 -485
  237. package/lib/esm/tools/MapLayerTool.js.map +1 -1
  238. package/lib/esm/tools/MeasureTileLoadTime.d.ts +12 -12
  239. package/lib/esm/tools/MeasureTileLoadTime.js +60 -59
  240. package/lib/esm/tools/MeasureTileLoadTime.js.map +1 -1
  241. package/lib/esm/tools/ModelAppearanceTools.d.ts +86 -86
  242. package/lib/esm/tools/ModelAppearanceTools.js +180 -172
  243. package/lib/esm/tools/ModelAppearanceTools.js.map +1 -1
  244. package/lib/esm/tools/PlanProjectionTools.d.ts +40 -40
  245. package/lib/esm/tools/PlanProjectionTools.js +146 -143
  246. package/lib/esm/tools/PlanProjectionTools.js.map +1 -1
  247. package/lib/esm/tools/PlanarMaskTools.d.ts +182 -182
  248. package/lib/esm/tools/PlanarMaskTools.js +387 -377
  249. package/lib/esm/tools/PlanarMaskTools.js.map +1 -1
  250. package/lib/esm/tools/ProjectExtents.d.ts +41 -41
  251. package/lib/esm/tools/ProjectExtents.js +105 -104
  252. package/lib/esm/tools/ProjectExtents.js.map +1 -1
  253. package/lib/esm/tools/RealityModelTools.d.ts +116 -116
  254. package/lib/esm/tools/RealityModelTools.js +278 -268
  255. package/lib/esm/tools/RealityModelTools.js.map +1 -1
  256. package/lib/esm/tools/RealityTransitionTool.d.ts +25 -25
  257. package/lib/esm/tools/RealityTransitionTool.js +112 -112
  258. package/lib/esm/tools/RealityTransitionTool.js.map +1 -1
  259. package/lib/esm/tools/RenderSystemTools.d.ts +38 -38
  260. package/lib/esm/tools/RenderSystemTools.js +65 -63
  261. package/lib/esm/tools/RenderSystemTools.js.map +1 -1
  262. package/lib/esm/tools/RenderTargetTools.d.ts +107 -107
  263. package/lib/esm/tools/RenderTargetTools.d.ts.map +1 -1
  264. package/lib/esm/tools/RenderTargetTools.js +169 -159
  265. package/lib/esm/tools/RenderTargetTools.js.map +1 -1
  266. package/lib/esm/tools/ReportWebGLCompatibilityTool.d.ts +11 -11
  267. package/lib/esm/tools/ReportWebGLCompatibilityTool.js +27 -26
  268. package/lib/esm/tools/ReportWebGLCompatibilityTool.js.map +1 -1
  269. package/lib/esm/tools/SavedViews.d.ts +46 -46
  270. package/lib/esm/tools/SavedViews.js +131 -128
  271. package/lib/esm/tools/SavedViews.js.map +1 -1
  272. package/lib/esm/tools/ScheduleScriptTools.d.ts +37 -37
  273. package/lib/esm/tools/ScheduleScriptTools.js +154 -153
  274. package/lib/esm/tools/ScheduleScriptTools.js.map +1 -1
  275. package/lib/esm/tools/SelectionTools.d.ts +28 -28
  276. package/lib/esm/tools/SelectionTools.js +84 -82
  277. package/lib/esm/tools/SelectionTools.js.map +1 -1
  278. package/lib/esm/tools/SetGpuMemoryLimitTool.d.ts +15 -15
  279. package/lib/esm/tools/SetGpuMemoryLimitTool.js +30 -29
  280. package/lib/esm/tools/SetGpuMemoryLimitTool.js.map +1 -1
  281. package/lib/esm/tools/SourceAspectIdTools.d.ts +40 -40
  282. package/lib/esm/tools/SourceAspectIdTools.d.ts.map +1 -1
  283. package/lib/esm/tools/SourceAspectIdTools.js +82 -80
  284. package/lib/esm/tools/SourceAspectIdTools.js.map +1 -1
  285. package/lib/esm/tools/TileRequestDecoration.d.ts +12 -12
  286. package/lib/esm/tools/TileRequestDecoration.js +80 -79
  287. package/lib/esm/tools/TileRequestDecoration.js.map +1 -1
  288. package/lib/esm/tools/TileTreeBoundsDecoration.d.ts +11 -11
  289. package/lib/esm/tools/TileTreeBoundsDecoration.js +71 -70
  290. package/lib/esm/tools/TileTreeBoundsDecoration.js.map +1 -1
  291. package/lib/esm/tools/ToolTipProvider.d.ts +15 -15
  292. package/lib/esm/tools/ToolTipProvider.js +63 -62
  293. package/lib/esm/tools/ToolTipProvider.js.map +1 -1
  294. package/lib/esm/tools/ViewportTools.d.ts +218 -218
  295. package/lib/esm/tools/ViewportTools.d.ts.map +1 -1
  296. package/lib/esm/tools/ViewportTools.js +511 -492
  297. package/lib/esm/tools/ViewportTools.js.map +1 -1
  298. package/lib/esm/tools/parseArgs.d.ts +23 -23
  299. package/lib/esm/tools/parseArgs.js +47 -47
  300. package/lib/esm/tools/parseBoolean.d.ts +8 -8
  301. package/lib/esm/tools/parseBoolean.js +22 -22
  302. package/lib/esm/tools/parseToggle.d.ts +8 -8
  303. package/lib/esm/tools/parseToggle.js +21 -21
  304. package/lib/esm/ui/Button.d.ts +29 -29
  305. package/lib/esm/ui/Button.d.ts.map +1 -1
  306. package/lib/esm/ui/Button.js +22 -22
  307. package/lib/esm/ui/CheckBox.d.ts +23 -23
  308. package/lib/esm/ui/CheckBox.d.ts.map +1 -1
  309. package/lib/esm/ui/CheckBox.js +23 -23
  310. package/lib/esm/ui/ColorInput.d.ts +27 -27
  311. package/lib/esm/ui/ColorInput.d.ts.map +1 -1
  312. package/lib/esm/ui/ColorInput.js +48 -48
  313. package/lib/esm/ui/ComboBox.d.ts +28 -28
  314. package/lib/esm/ui/ComboBox.d.ts.map +1 -1
  315. package/lib/esm/ui/ComboBox.js +38 -38
  316. package/lib/esm/ui/DataList.d.ts +27 -27
  317. package/lib/esm/ui/DataList.d.ts.map +1 -1
  318. package/lib/esm/ui/DataList.js +34 -34
  319. package/lib/esm/ui/NestedMenu.d.ts +19 -19
  320. package/lib/esm/ui/NestedMenu.d.ts.map +1 -1
  321. package/lib/esm/ui/NestedMenu.js +42 -42
  322. package/lib/esm/ui/NumericInput.d.ts +35 -35
  323. package/lib/esm/ui/NumericInput.d.ts.map +1 -1
  324. package/lib/esm/ui/NumericInput.js +56 -56
  325. package/lib/esm/ui/RadioBox.d.ts +29 -29
  326. package/lib/esm/ui/RadioBox.d.ts.map +1 -1
  327. package/lib/esm/ui/RadioBox.js +72 -72
  328. package/lib/esm/ui/Slider.d.ts +28 -28
  329. package/lib/esm/ui/Slider.d.ts.map +1 -1
  330. package/lib/esm/ui/Slider.js +38 -38
  331. package/lib/esm/ui/TextBox.d.ts +32 -32
  332. package/lib/esm/ui/TextBox.d.ts.map +1 -1
  333. package/lib/esm/ui/TextBox.js +52 -52
  334. package/lib/esm/widgets/DiagnosticsPanel.d.ts +37 -37
  335. package/lib/esm/widgets/DiagnosticsPanel.js +77 -77
  336. package/lib/esm/widgets/FpsTracker.d.ts +19 -19
  337. package/lib/esm/widgets/FpsTracker.js +52 -52
  338. package/lib/esm/widgets/GpuProfiler.d.ts +16 -16
  339. package/lib/esm/widgets/GpuProfiler.js +188 -188
  340. package/lib/esm/widgets/KeyinField.d.ts +61 -61
  341. package/lib/esm/widgets/KeyinField.js +182 -183
  342. package/lib/esm/widgets/KeyinField.js.map +1 -1
  343. package/lib/esm/widgets/MemoryTracker.d.ts +27 -27
  344. package/lib/esm/widgets/MemoryTracker.js +237 -238
  345. package/lib/esm/widgets/MemoryTracker.js.map +1 -1
  346. package/lib/esm/widgets/RenderCommandBreakdown.d.ts +15 -15
  347. package/lib/esm/widgets/RenderCommandBreakdown.js +63 -64
  348. package/lib/esm/widgets/RenderCommandBreakdown.js.map +1 -1
  349. package/lib/esm/widgets/TileMemoryBreakdown.d.ts +30 -30
  350. package/lib/esm/widgets/TileMemoryBreakdown.js +199 -200
  351. package/lib/esm/widgets/TileMemoryBreakdown.js.map +1 -1
  352. package/lib/esm/widgets/TileStatisticsTracker.d.ts +21 -21
  353. package/lib/esm/widgets/TileStatisticsTracker.d.ts.map +1 -1
  354. package/lib/esm/widgets/TileStatisticsTracker.js +140 -138
  355. package/lib/esm/widgets/TileStatisticsTracker.js.map +1 -1
  356. package/lib/esm/widgets/ToolSettingsTracker.d.ts +9 -9
  357. package/lib/esm/widgets/ToolSettingsTracker.js +208 -207
  358. package/lib/esm/widgets/ToolSettingsTracker.js.map +1 -1
  359. package/package.json +13 -13
@@ -1,188 +1,188 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- /** @packageDocumentation
7
- * @module Effects
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.SnowEffect = exports.SnowDecorator = void 0;
11
- const core_bentley_1 = require("@itwin/core-bentley");
12
- const core_geometry_1 = require("@itwin/core-geometry");
13
- const core_common_1 = require("@itwin/core-common");
14
- const core_frontend_1 = require("@itwin/core-frontend");
15
- const parseToggle_1 = require("../tools/parseToggle");
16
- const Random_1 = require("./Random");
17
- /** The default snow effect parameters used by newly-created SnowDecorators. */
18
- const defaultSnowParams = {
19
- numParticles: 2000,
20
- sizeRange: core_geometry_1.Range1d.createXX(3, 22),
21
- transparencyRange: core_geometry_1.Range1d.createXX(0, 50),
22
- velocityRange: new core_geometry_1.Range2d(-30, 50, 30, 130),
23
- accelerationRange: new core_geometry_1.Range2d(-1, -0.25, 1, 0.25),
24
- windVelocity: 0,
25
- };
26
- /** Simulates snowfall in a [Viewport]($frontend) using particle effects.
27
- * @see [[SnowEffect]] for a [Tool]($frontend) that toggles this decorator.
28
- * @see [ParticleCollectionBuilder]($frontend) for defining custom particle effects.
29
- * @beta
30
- */
31
- class SnowDecorator {
32
- constructor(viewport, texture) {
33
- /** The list of particles being drawn. */
34
- this._particles = [];
35
- this._params = { ...defaultSnowParams };
36
- this.viewport = viewport;
37
- this._dimensions = new core_geometry_1.Point2d(viewport.viewRect.width, viewport.viewRect.height);
38
- this._lastUpdateTime = Date.now();
39
- this._texture = texture;
40
- // Tell the viewport to re-render the decorations every frame so that the snow particles animate smoothly.
41
- const removeOnRender = viewport.onRender.addListener(() => viewport.invalidateDecorations());
42
- // When the viewport is resized, replace this decorator with a new one to match the new dimensions.
43
- const removeOnResized = viewport.onResized.addListener(() => {
44
- // Transfer ownership of the texture to the new decorator.
45
- const tex = this._texture;
46
- this._texture = undefined;
47
- this.dispose();
48
- new SnowDecorator(viewport, tex);
49
- });
50
- // When the viewport is destroyed, dispose of this decorator too.
51
- const removeOnDispose = viewport.onDisposed.addListener(() => this.dispose());
52
- const removeDecorator = core_frontend_1.IModelApp.viewManager.addDecorator(this);
53
- this.dispose = () => {
54
- removeDecorator();
55
- removeOnRender();
56
- removeOnDispose();
57
- removeOnResized();
58
- this._texture = (0, core_bentley_1.dispose)(this._texture);
59
- SnowDecorator._decorators.delete(viewport);
60
- };
61
- SnowDecorator._decorators.set(viewport, this);
62
- // Initialize the particles.
63
- for (let i = 0; i < this._params.numParticles; i++)
64
- this._particles.push(this.emit(true));
65
- }
66
- decorate(context) {
67
- if (context.viewport !== this.viewport || !this._texture)
68
- return;
69
- // Update the particles.
70
- const now = Date.now();
71
- const deltaMillis = now - this._lastUpdateTime;
72
- this._lastUpdateTime = now;
73
- this.updateParticles(deltaMillis / 1000);
74
- // Create particle graphics.
75
- const builder = core_frontend_1.ParticleCollectionBuilder.create({
76
- viewport: this.viewport,
77
- isViewCoords: true,
78
- texture: this._texture,
79
- size: (this._params.sizeRange.high - this._params.sizeRange.low) / 2,
80
- });
81
- for (const particle of this._particles)
82
- builder.addParticle(particle);
83
- const graphic = builder.finish();
84
- if (graphic)
85
- context.addDecoration(core_frontend_1.GraphicType.ViewOverlay, graphic);
86
- }
87
- /** Change some of the parameters affecting this decorator. */
88
- configure(params) {
89
- for (const key of Object.keys(params)) {
90
- const val = params[key];
91
- if (undefined !== val)
92
- this._params[key] = val;
93
- }
94
- }
95
- /** Emit a new particle with randomized properties. */
96
- emit(randomizeHeight) {
97
- return {
98
- x: (0, Random_1.randomInteger)(0, this._dimensions.x),
99
- y: randomizeHeight ? (0, Random_1.randomInteger)(0, this._dimensions.y) : 0,
100
- z: 0,
101
- size: (0, Random_1.randomInteger)(this._params.sizeRange.low, this._params.sizeRange.high),
102
- transparency: (0, Random_1.randomInteger)(this._params.transparencyRange.low, this._params.transparencyRange.high),
103
- velocity: new core_geometry_1.Vector2d((0, Random_1.randomFloat)(this._params.velocityRange.low.x, this._params.velocityRange.high.x), (0, Random_1.randomFloat)(this._params.velocityRange.low.y, this._params.velocityRange.high.y)),
104
- };
105
- }
106
- // Update the positions and velocities of all the particles based on the amount of time that has passed since the last update.
107
- updateParticles(elapsedSeconds) {
108
- // Determine if someone changed the desired number of particles.
109
- const particleDiscrepancy = this._params.numParticles - this._particles.length;
110
- if (particleDiscrepancy > 0) {
111
- // Birth new particles up to the new maximum.
112
- for (let i = 0; i < particleDiscrepancy; i++)
113
- this._particles.push(this.emit(true));
114
- }
115
- else {
116
- // Destroy extra particles.
117
- this._particles.length = this._params.numParticles;
118
- }
119
- const acceleration = new core_geometry_1.Vector2d();
120
- const velocity = new core_geometry_1.Vector2d();
121
- for (let i = 0; i < this._particles.length; i++) {
122
- // Apply some acceleration to produce random drift.
123
- const particle = this._particles[i];
124
- acceleration.set((0, Random_1.randomFloat)(this._params.accelerationRange.low.x, this._params.accelerationRange.high.x), (0, Random_1.randomFloat)(this._params.accelerationRange.low.y, this._params.accelerationRange.high.y));
125
- acceleration.scale(elapsedSeconds, acceleration);
126
- particle.velocity.plus(acceleration, particle.velocity);
127
- // Apply velocity.
128
- particle.velocity.clone(velocity);
129
- velocity.scale(elapsedSeconds, velocity);
130
- particle.x += velocity.x;
131
- particle.y += velocity.y;
132
- // Apply wind
133
- particle.x += this._params.windVelocity * elapsedSeconds;
134
- // Particles that travel beyond the viewport's left or right edges wrap around to the other side.
135
- if (particle.x < 0)
136
- particle.x = this._dimensions.x - 1;
137
- else if (particle.x >= this._dimensions.x)
138
- particle.x = 0;
139
- // Particles that travel beyond the viewport's bottom or top edges are replaced by newborn particles.
140
- if (particle.y < 0 || particle.y >= this._dimensions.y)
141
- this._particles[i] = this.emit(false);
142
- }
143
- }
144
- /** Toggle this decorator for the specified viewport.
145
- * @param viewport The viewport to which the effect should be applied or removed.
146
- * @param enable `true` to enable the effect, `false` to disable it, or `undefined` to toggle the current state.
147
- */
148
- static async toggle(viewport, enable) {
149
- const decorator = this._decorators.get(viewport);
150
- if (undefined === enable)
151
- enable = undefined === decorator;
152
- if (undefined !== decorator && !enable)
153
- decorator.dispose();
154
- else if (undefined === decorator && enable) {
155
- // Create a texture to use for the particles.
156
- // Note: the decorator takes ownership of the texture, and disposes of it when the decorator is disposed.
157
- const image = await (0, core_frontend_1.imageElementFromUrl)(`${core_frontend_1.IModelApp.publicPath}sprites/particle_snow.png`);
158
- const texture = core_frontend_1.IModelApp.renderSystem.createTexture({
159
- ownership: "external",
160
- image: { source: image, transparency: core_common_1.TextureTransparency.Mixed },
161
- });
162
- new SnowDecorator(viewport, texture);
163
- }
164
- }
165
- }
166
- exports.SnowDecorator = SnowDecorator;
167
- SnowDecorator._decorators = new Map();
168
- /** Toggles a decorator that simulates snow using particle effects.
169
- * @see [[SnowDecorator]] for the implementation of the decorator.
170
- * @beta
171
- */
172
- class SnowEffect extends core_frontend_1.Tool {
173
- async run(enable) {
174
- const vp = core_frontend_1.IModelApp.viewManager.selectedView;
175
- if (vp)
176
- await SnowDecorator.toggle(vp, enable);
177
- return true;
178
- }
179
- async parseAndRun(...args) {
180
- const enable = (0, parseToggle_1.parseToggle)(args[0]);
181
- if (typeof enable !== "string")
182
- await this.run(enable);
183
- return true;
184
- }
185
- }
186
- exports.SnowEffect = SnowEffect;
187
- SnowEffect.toolId = "SnowEffect";
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module Effects
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.SnowEffect = exports.SnowDecorator = void 0;
11
+ const core_bentley_1 = require("@itwin/core-bentley");
12
+ const core_geometry_1 = require("@itwin/core-geometry");
13
+ const core_common_1 = require("@itwin/core-common");
14
+ const core_frontend_1 = require("@itwin/core-frontend");
15
+ const parseToggle_1 = require("../tools/parseToggle");
16
+ const Random_1 = require("./Random");
17
+ /** The default snow effect parameters used by newly-created SnowDecorators. */
18
+ const defaultSnowParams = {
19
+ numParticles: 2000,
20
+ sizeRange: core_geometry_1.Range1d.createXX(3, 22),
21
+ transparencyRange: core_geometry_1.Range1d.createXX(0, 50),
22
+ velocityRange: new core_geometry_1.Range2d(-30, 50, 30, 130),
23
+ accelerationRange: new core_geometry_1.Range2d(-1, -0.25, 1, 0.25),
24
+ windVelocity: 0,
25
+ };
26
+ /** Simulates snowfall in a [Viewport]($frontend) using particle effects.
27
+ * @see [[SnowEffect]] for a [Tool]($frontend) that toggles this decorator.
28
+ * @see [ParticleCollectionBuilder]($frontend) for defining custom particle effects.
29
+ * @beta
30
+ */
31
+ class SnowDecorator {
32
+ constructor(viewport, texture) {
33
+ /** The list of particles being drawn. */
34
+ this._particles = [];
35
+ this._params = { ...defaultSnowParams };
36
+ this.viewport = viewport;
37
+ this._dimensions = new core_geometry_1.Point2d(viewport.viewRect.width, viewport.viewRect.height);
38
+ this._lastUpdateTime = Date.now();
39
+ this._texture = texture;
40
+ // Tell the viewport to re-render the decorations every frame so that the snow particles animate smoothly.
41
+ const removeOnRender = viewport.onRender.addListener(() => viewport.invalidateDecorations());
42
+ // When the viewport is resized, replace this decorator with a new one to match the new dimensions.
43
+ const removeOnResized = viewport.onResized.addListener(() => {
44
+ // Transfer ownership of the texture to the new decorator.
45
+ const tex = this._texture;
46
+ this._texture = undefined;
47
+ this.dispose();
48
+ new SnowDecorator(viewport, tex);
49
+ });
50
+ // When the viewport is destroyed, dispose of this decorator too.
51
+ const removeOnDispose = viewport.onDisposed.addListener(() => this.dispose());
52
+ const removeDecorator = core_frontend_1.IModelApp.viewManager.addDecorator(this);
53
+ this.dispose = () => {
54
+ removeDecorator();
55
+ removeOnRender();
56
+ removeOnDispose();
57
+ removeOnResized();
58
+ this._texture = (0, core_bentley_1.dispose)(this._texture);
59
+ SnowDecorator._decorators.delete(viewport);
60
+ };
61
+ SnowDecorator._decorators.set(viewport, this);
62
+ // Initialize the particles.
63
+ for (let i = 0; i < this._params.numParticles; i++)
64
+ this._particles.push(this.emit(true));
65
+ }
66
+ decorate(context) {
67
+ if (context.viewport !== this.viewport || !this._texture)
68
+ return;
69
+ // Update the particles.
70
+ const now = Date.now();
71
+ const deltaMillis = now - this._lastUpdateTime;
72
+ this._lastUpdateTime = now;
73
+ this.updateParticles(deltaMillis / 1000);
74
+ // Create particle graphics.
75
+ const builder = core_frontend_1.ParticleCollectionBuilder.create({
76
+ viewport: this.viewport,
77
+ isViewCoords: true,
78
+ texture: this._texture,
79
+ size: (this._params.sizeRange.high - this._params.sizeRange.low) / 2,
80
+ });
81
+ for (const particle of this._particles)
82
+ builder.addParticle(particle);
83
+ const graphic = builder.finish();
84
+ if (graphic)
85
+ context.addDecoration(core_frontend_1.GraphicType.ViewOverlay, graphic);
86
+ }
87
+ /** Change some of the parameters affecting this decorator. */
88
+ configure(params) {
89
+ for (const key of Object.keys(params)) {
90
+ const val = params[key];
91
+ if (undefined !== val)
92
+ this._params[key] = val;
93
+ }
94
+ }
95
+ /** Emit a new particle with randomized properties. */
96
+ emit(randomizeHeight) {
97
+ return {
98
+ x: (0, Random_1.randomInteger)(0, this._dimensions.x),
99
+ y: randomizeHeight ? (0, Random_1.randomInteger)(0, this._dimensions.y) : 0,
100
+ z: 0,
101
+ size: (0, Random_1.randomInteger)(this._params.sizeRange.low, this._params.sizeRange.high),
102
+ transparency: (0, Random_1.randomInteger)(this._params.transparencyRange.low, this._params.transparencyRange.high),
103
+ velocity: new core_geometry_1.Vector2d((0, Random_1.randomFloat)(this._params.velocityRange.low.x, this._params.velocityRange.high.x), (0, Random_1.randomFloat)(this._params.velocityRange.low.y, this._params.velocityRange.high.y)),
104
+ };
105
+ }
106
+ // Update the positions and velocities of all the particles based on the amount of time that has passed since the last update.
107
+ updateParticles(elapsedSeconds) {
108
+ // Determine if someone changed the desired number of particles.
109
+ const particleDiscrepancy = this._params.numParticles - this._particles.length;
110
+ if (particleDiscrepancy > 0) {
111
+ // Birth new particles up to the new maximum.
112
+ for (let i = 0; i < particleDiscrepancy; i++)
113
+ this._particles.push(this.emit(true));
114
+ }
115
+ else {
116
+ // Destroy extra particles.
117
+ this._particles.length = this._params.numParticles;
118
+ }
119
+ const acceleration = new core_geometry_1.Vector2d();
120
+ const velocity = new core_geometry_1.Vector2d();
121
+ for (let i = 0; i < this._particles.length; i++) {
122
+ // Apply some acceleration to produce random drift.
123
+ const particle = this._particles[i];
124
+ acceleration.set((0, Random_1.randomFloat)(this._params.accelerationRange.low.x, this._params.accelerationRange.high.x), (0, Random_1.randomFloat)(this._params.accelerationRange.low.y, this._params.accelerationRange.high.y));
125
+ acceleration.scale(elapsedSeconds, acceleration);
126
+ particle.velocity.plus(acceleration, particle.velocity);
127
+ // Apply velocity.
128
+ particle.velocity.clone(velocity);
129
+ velocity.scale(elapsedSeconds, velocity);
130
+ particle.x += velocity.x;
131
+ particle.y += velocity.y;
132
+ // Apply wind
133
+ particle.x += this._params.windVelocity * elapsedSeconds;
134
+ // Particles that travel beyond the viewport's left or right edges wrap around to the other side.
135
+ if (particle.x < 0)
136
+ particle.x = this._dimensions.x - 1;
137
+ else if (particle.x >= this._dimensions.x)
138
+ particle.x = 0;
139
+ // Particles that travel beyond the viewport's bottom or top edges are replaced by newborn particles.
140
+ if (particle.y < 0 || particle.y >= this._dimensions.y)
141
+ this._particles[i] = this.emit(false);
142
+ }
143
+ }
144
+ /** Toggle this decorator for the specified viewport.
145
+ * @param viewport The viewport to which the effect should be applied or removed.
146
+ * @param enable `true` to enable the effect, `false` to disable it, or `undefined` to toggle the current state.
147
+ */
148
+ static async toggle(viewport, enable) {
149
+ const decorator = this._decorators.get(viewport);
150
+ if (undefined === enable)
151
+ enable = undefined === decorator;
152
+ if (undefined !== decorator && !enable)
153
+ decorator.dispose();
154
+ else if (undefined === decorator && enable) {
155
+ // Create a texture to use for the particles.
156
+ // Note: the decorator takes ownership of the texture, and disposes of it when the decorator is disposed.
157
+ const image = await (0, core_frontend_1.imageElementFromUrl)(`${core_frontend_1.IModelApp.publicPath}sprites/particle_snow.png`);
158
+ const texture = core_frontend_1.IModelApp.renderSystem.createTexture({
159
+ ownership: "external",
160
+ image: { source: image, transparency: core_common_1.TextureTransparency.Mixed },
161
+ });
162
+ new SnowDecorator(viewport, texture);
163
+ }
164
+ }
165
+ }
166
+ SnowDecorator._decorators = new Map();
167
+ exports.SnowDecorator = SnowDecorator;
168
+ /** Toggles a decorator that simulates snow using particle effects.
169
+ * @see [[SnowDecorator]] for the implementation of the decorator.
170
+ * @beta
171
+ */
172
+ class SnowEffect extends core_frontend_1.Tool {
173
+ async run(enable) {
174
+ const vp = core_frontend_1.IModelApp.viewManager.selectedView;
175
+ if (vp)
176
+ await SnowDecorator.toggle(vp, enable);
177
+ return true;
178
+ }
179
+ async parseAndRun(...args) {
180
+ const enable = (0, parseToggle_1.parseToggle)(args[0]);
181
+ if (typeof enable !== "string")
182
+ await this.run(enable);
183
+ return true;
184
+ }
185
+ }
186
+ SnowEffect.toolId = "SnowEffect";
187
+ exports.SnowEffect = SnowEffect;
188
188
  //# sourceMappingURL=Snow.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Snow.js","sourceRoot":"","sources":["../../../src/effects/Snow.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA8C;AAC9C,wDAA2E;AAC3E,oDAAwE;AACxE,wDAE8B;AAC9B,sDAAmD;AACnD,qC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Aa,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QAEzC,OAAO,IAAI,CAAC;IACd,CAAC;IAEe,KAAK,CAAC,WAAW,CAAC,GAAG,IAAc;QACjD,MAAM,MAAM,GAAG,IAAA,yBAAW,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACpC,IAAI,OAAO,MAAM,KAAK,QAAQ;YAC5B,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAEzB,OAAO,IAAI,CAAC;IACd,CAAC;;AAjBH,gCAkBC;AAjBwB,iBAAM,GAAG,YAAY,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Effects\r\n */\r\n\r\nimport { dispose } from \"@itwin/core-bentley\";\r\nimport { Point2d, Range1d, Range2d, Vector2d } from \"@itwin/core-geometry\";\r\nimport { RenderTexture, TextureTransparency } from \"@itwin/core-common\";\r\nimport {\r\n DecorateContext, Decorator, GraphicType, imageElementFromUrl, IModelApp, ParticleCollectionBuilder, ParticleProps, Tool, Viewport,\r\n} from \"@itwin/core-frontend\";\r\nimport { parseToggle } from \"../tools/parseToggle\";\r\nimport { randomFloat, randomInteger } from \"./Random\";\r\n\r\n/** Represents one particle displayed by a [[SnowDecorator]].\r\n * Particle positions are in [CoordSystem.View]($frontend).\r\n * @beta\r\n */\r\nexport interface SnowParticle extends ParticleProps {\r\n /** Make x, y, and z from ParticleProps writable. */\r\n x: number;\r\n y: number;\r\n z: number;\r\n\r\n /** Current velocity, in pixels per second. */\r\n velocity: Vector2d;\r\n}\r\n\r\n/** Parameters controlling how a [[SnowDecorator]] works.\r\n * @beta\r\n */\r\nexport interface SnowParams {\r\n /** The number of snow particles to produce. This could alternatively be expressed as a density so that small viewports would not be more crowded than larger ones. */\r\n numParticles: number;\r\n /** Range from which to randomly select each particle's size, in pixels. */\r\n sizeRange: Range1d;\r\n /** Range from which to randomly select each particle's transparency. */\r\n transparencyRange: Range1d;\r\n /** Range from which to randomly select each particle's initial velocity, in pixels per second. */\r\n velocityRange: Range2d;\r\n /** Range from which to randomly select an acceleration to apply to each particle's velocity each frame, in pixels per second squared, to simulate wind. */\r\n accelerationRange: Range2d;\r\n /** Wind velocity in pixels per second in X. */\r\n windVelocity: number;\r\n}\r\n\r\n/** The default snow effect parameters used by newly-created SnowDecorators. */\r\nconst defaultSnowParams: SnowParams = {\r\n numParticles: 2000,\r\n sizeRange: Range1d.createXX(3, 22),\r\n transparencyRange: Range1d.createXX(0, 50),\r\n velocityRange: new Range2d(-30, 50, 30, 130),\r\n accelerationRange: new Range2d(-1, -0.25, 1, 0.25),\r\n windVelocity: 0,\r\n};\r\n\r\n/** Simulates snowfall in a [Viewport]($frontend) using particle effects.\r\n * @see [[SnowEffect]] for a [Tool]($frontend) that toggles this decorator.\r\n * @see [ParticleCollectionBuilder]($frontend) for defining custom particle effects.\r\n * @beta\r\n */\r\nexport class SnowDecorator implements Decorator {\r\n /** The viewport being decorated. */\r\n public readonly viewport: Viewport;\r\n /** Invoked when this decorator is to be destroyed. */\r\n public readonly dispose: VoidFunction;\r\n /** The initial width and height of the viewport, from which we randomly select each particle's initial position. */\r\n private readonly _dimensions: Point2d;\r\n /** The list of particles being drawn. */\r\n private readonly _particles: SnowParticle[] = [];\r\n /** The image to display for each particle. */\r\n private _texture?: RenderTexture;\r\n /** The last time `updateParticles()` was invoked, in milliseconds. */\r\n private _lastUpdateTime: number;\r\n private readonly _params: SnowParams;\r\n\r\n private constructor(viewport: Viewport, texture: RenderTexture | undefined) {\r\n this._params = { ...defaultSnowParams };\r\n this.viewport = viewport;\r\n this._dimensions = new Point2d(viewport.viewRect.width, viewport.viewRect.height);\r\n this._lastUpdateTime = Date.now();\r\n this._texture = texture;\r\n\r\n // Tell the viewport to re-render the decorations every frame so that the snow particles animate smoothly.\r\n const removeOnRender = viewport.onRender.addListener(() => viewport.invalidateDecorations());\r\n\r\n // When the viewport is resized, replace this decorator with a new one to match the new dimensions.\r\n const removeOnResized = viewport.onResized.addListener(() => {\r\n // Transfer ownership of the texture to the new decorator.\r\n const tex = this._texture;\r\n this._texture = undefined;\r\n this.dispose();\r\n new SnowDecorator(viewport, tex);\r\n });\r\n\r\n // When the viewport is destroyed, dispose of this decorator too.\r\n const removeOnDispose = viewport.onDisposed.addListener(() => this.dispose());\r\n const removeDecorator = IModelApp.viewManager.addDecorator(this);\r\n\r\n this.dispose = () => {\r\n removeDecorator();\r\n removeOnRender();\r\n removeOnDispose();\r\n removeOnResized();\r\n this._texture = dispose(this._texture);\r\n SnowDecorator._decorators.delete(viewport);\r\n };\r\n\r\n SnowDecorator._decorators.set(viewport, this);\r\n\r\n // Initialize the particles.\r\n for (let i = 0; i < this._params.numParticles; i++)\r\n this._particles.push(this.emit(true));\r\n }\r\n\r\n public decorate(context: DecorateContext): void {\r\n if (context.viewport !== this.viewport || !this._texture)\r\n return;\r\n\r\n // Update the particles.\r\n const now = Date.now();\r\n const deltaMillis = now - this._lastUpdateTime;\r\n this._lastUpdateTime = now;\r\n this.updateParticles(deltaMillis / 1000);\r\n\r\n // Create particle graphics.\r\n const builder = ParticleCollectionBuilder.create({\r\n viewport: this.viewport,\r\n isViewCoords: true,\r\n texture: this._texture,\r\n size: (this._params.sizeRange.high - this._params.sizeRange.low) / 2,\r\n });\r\n\r\n for (const particle of this._particles)\r\n builder.addParticle(particle);\r\n\r\n const graphic = builder.finish();\r\n if (graphic)\r\n context.addDecoration(GraphicType.ViewOverlay, graphic);\r\n }\r\n\r\n /** Change some of the parameters affecting this decorator. */\r\n public configure(params: Partial<SnowParams>): void {\r\n for (const key of Object.keys(params)) {\r\n const val = (params as any)[key];\r\n if (undefined !== val)\r\n (this._params as any)[key] = val;\r\n }\r\n }\r\n\r\n /** Emit a new particle with randomized properties. */\r\n private emit(randomizeHeight: boolean): SnowParticle {\r\n return {\r\n x: randomInteger(0, this._dimensions.x),\r\n y: randomizeHeight ? randomInteger(0, this._dimensions.y) : 0,\r\n z: 0,\r\n size: randomInteger(this._params.sizeRange.low, this._params.sizeRange.high),\r\n transparency: randomInteger(this._params.transparencyRange.low, this._params.transparencyRange.high),\r\n velocity: new Vector2d(randomFloat(this._params.velocityRange.low.x, this._params.velocityRange.high.x),\r\n randomFloat(this._params.velocityRange.low.y, this._params.velocityRange.high.y)),\r\n };\r\n }\r\n\r\n // Update the positions and velocities of all the particles based on the amount of time that has passed since the last update.\r\n private updateParticles(elapsedSeconds: number): void {\r\n // Determine if someone changed the desired number of particles.\r\n const particleDiscrepancy = this._params.numParticles - this._particles.length;\r\n if (particleDiscrepancy > 0) {\r\n // Birth new particles up to the new maximum.\r\n for (let i = 0; i < particleDiscrepancy; i++)\r\n this._particles.push(this.emit(true));\r\n } else {\r\n // Destroy extra particles.\r\n this._particles.length = this._params.numParticles;\r\n }\r\n\r\n const acceleration = new Vector2d();\r\n const velocity = new Vector2d();\r\n for (let i = 0; i < this._particles.length; i++) {\r\n // Apply some acceleration to produce random drift.\r\n const particle = this._particles[i];\r\n acceleration.set(randomFloat(this._params.accelerationRange.low.x, this._params.accelerationRange.high.x),\r\n randomFloat(this._params.accelerationRange.low.y, this._params.accelerationRange.high.y));\r\n\r\n acceleration.scale(elapsedSeconds, acceleration);\r\n particle.velocity.plus(acceleration, particle.velocity);\r\n\r\n // Apply velocity.\r\n particle.velocity.clone(velocity);\r\n velocity.scale(elapsedSeconds, velocity);\r\n particle.x += velocity.x;\r\n particle.y += velocity.y;\r\n\r\n // Apply wind\r\n particle.x += this._params.windVelocity * elapsedSeconds;\r\n\r\n // Particles that travel beyond the viewport's left or right edges wrap around to the other side.\r\n if (particle.x < 0)\r\n particle.x = this._dimensions.x - 1;\r\n else if (particle.x >= this._dimensions.x)\r\n particle.x = 0;\r\n\r\n // Particles that travel beyond the viewport's bottom or top edges are replaced by newborn particles.\r\n if (particle.y < 0 || particle.y >= this._dimensions.y)\r\n this._particles[i] = this.emit(false);\r\n }\r\n }\r\n\r\n private static readonly _decorators = new Map<Viewport, SnowDecorator>();\r\n\r\n /** Toggle this decorator for the specified viewport.\r\n * @param viewport The viewport to which the effect should be applied or removed.\r\n * @param enable `true` to enable the effect, `false` to disable it, or `undefined` to toggle the current state.\r\n */\r\n public static async toggle(viewport: Viewport, enable?: boolean): Promise<void> {\r\n const decorator = this._decorators.get(viewport);\r\n if (undefined === enable)\r\n enable = undefined === decorator;\r\n\r\n if (undefined !== decorator && !enable)\r\n decorator.dispose();\r\n else if (undefined === decorator && enable) {\r\n // Create a texture to use for the particles.\r\n // Note: the decorator takes ownership of the texture, and disposes of it when the decorator is disposed.\r\n const image = await imageElementFromUrl(`${IModelApp.publicPath}sprites/particle_snow.png`);\r\n const texture = IModelApp.renderSystem.createTexture({\r\n ownership: \"external\",\r\n image: { source: image, transparency: TextureTransparency.Mixed },\r\n });\r\n\r\n new SnowDecorator(viewport, texture);\r\n }\r\n }\r\n}\r\n\r\n/** Toggles a decorator that simulates snow using particle effects.\r\n * @see [[SnowDecorator]] for the implementation of the decorator.\r\n * @beta\r\n */\r\nexport class SnowEffect extends Tool {\r\n public static override toolId = \"SnowEffect\";\r\n\r\n public override async run(enable?: boolean): Promise<boolean> {\r\n const vp = IModelApp.viewManager.selectedView;\r\n if (vp)\r\n await SnowDecorator.toggle(vp, enable);\r\n\r\n return true;\r\n }\r\n\r\n public override async parseAndRun(...args: string[]): Promise<boolean> {\r\n const enable = parseToggle(args[0]);\r\n if (typeof enable !== \"string\")\r\n await this.run(enable);\r\n\r\n return true;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Snow.js","sourceRoot":"","sources":["../../../src/effects/Snow.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA8C;AAC9C,wDAA2E;AAC3E,oDAAwE;AACxE,wDAE8B;AAC9B,sDAAmD;AACnD,qCAAsD;A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aAAa,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QAEzC,OAAO,IAAI,CAAC;IACd,CAAC;IAEe,KAAK,CAAC,WAAW,CAAC,GAAG,IAAc;QACjD,MAAM,MAAM,GAAG,IAAA,yBAAW,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACpC,IAAI,OAAO,MAAM,KAAK,QAAQ;YAC5B,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAEzB,OAAO,IAAI,CAAC;IACd,CAAC;;AAhBsB,iBAAM,GAAG,YAAY,CAAC;AADlC,gCAAU","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Effects\r\n */\r\n\r\nimport { dispose } from \"@itwin/core-bentley\";\r\nimport { Point2d, Range1d, Range2d, Vector2d } from \"@itwin/core-geometry\";\r\nimport { RenderTexture, TextureTransparency } from \"@itwin/core-common\";\r\nimport {\r\n DecorateContext, Decorator, GraphicType, imageElementFromUrl, IModelApp, ParticleCollectionBuilder, ParticleProps, Tool, Viewport,\r\n} from \"@itwin/core-frontend\";\r\nimport { parseToggle } from \"../tools/parseToggle\";\r\nimport { randomFloat, randomInteger } from \"./Random\";\r\n\r\n/** Represents one particle displayed by a [[SnowDecorator]].\r\n * Particle positions are in [CoordSystem.View]($frontend).\r\n * @beta\r\n */\r\nexport interface SnowParticle extends ParticleProps {\r\n /** Make x, y, and z from ParticleProps writable. */\r\n x: number;\r\n y: number;\r\n z: number;\r\n\r\n /** Current velocity, in pixels per second. */\r\n velocity: Vector2d;\r\n}\r\n\r\n/** Parameters controlling how a [[SnowDecorator]] works.\r\n * @beta\r\n */\r\nexport interface SnowParams {\r\n /** The number of snow particles to produce. This could alternatively be expressed as a density so that small viewports would not be more crowded than larger ones. */\r\n numParticles: number;\r\n /** Range from which to randomly select each particle's size, in pixels. */\r\n sizeRange: Range1d;\r\n /** Range from which to randomly select each particle's transparency. */\r\n transparencyRange: Range1d;\r\n /** Range from which to randomly select each particle's initial velocity, in pixels per second. */\r\n velocityRange: Range2d;\r\n /** Range from which to randomly select an acceleration to apply to each particle's velocity each frame, in pixels per second squared, to simulate wind. */\r\n accelerationRange: Range2d;\r\n /** Wind velocity in pixels per second in X. */\r\n windVelocity: number;\r\n}\r\n\r\n/** The default snow effect parameters used by newly-created SnowDecorators. */\r\nconst defaultSnowParams: SnowParams = {\r\n numParticles: 2000,\r\n sizeRange: Range1d.createXX(3, 22),\r\n transparencyRange: Range1d.createXX(0, 50),\r\n velocityRange: new Range2d(-30, 50, 30, 130),\r\n accelerationRange: new Range2d(-1, -0.25, 1, 0.25),\r\n windVelocity: 0,\r\n};\r\n\r\n/** Simulates snowfall in a [Viewport]($frontend) using particle effects.\r\n * @see [[SnowEffect]] for a [Tool]($frontend) that toggles this decorator.\r\n * @see [ParticleCollectionBuilder]($frontend) for defining custom particle effects.\r\n * @beta\r\n */\r\nexport class SnowDecorator implements Decorator {\r\n /** The viewport being decorated. */\r\n public readonly viewport: Viewport;\r\n /** Invoked when this decorator is to be destroyed. */\r\n public readonly dispose: VoidFunction;\r\n /** The initial width and height of the viewport, from which we randomly select each particle's initial position. */\r\n private readonly _dimensions: Point2d;\r\n /** The list of particles being drawn. */\r\n private readonly _particles: SnowParticle[] = [];\r\n /** The image to display for each particle. */\r\n private _texture?: RenderTexture;\r\n /** The last time `updateParticles()` was invoked, in milliseconds. */\r\n private _lastUpdateTime: number;\r\n private readonly _params: SnowParams;\r\n\r\n private constructor(viewport: Viewport, texture: RenderTexture | undefined) {\r\n this._params = { ...defaultSnowParams };\r\n this.viewport = viewport;\r\n this._dimensions = new Point2d(viewport.viewRect.width, viewport.viewRect.height);\r\n this._lastUpdateTime = Date.now();\r\n this._texture = texture;\r\n\r\n // Tell the viewport to re-render the decorations every frame so that the snow particles animate smoothly.\r\n const removeOnRender = viewport.onRender.addListener(() => viewport.invalidateDecorations());\r\n\r\n // When the viewport is resized, replace this decorator with a new one to match the new dimensions.\r\n const removeOnResized = viewport.onResized.addListener(() => {\r\n // Transfer ownership of the texture to the new decorator.\r\n const tex = this._texture;\r\n this._texture = undefined;\r\n this.dispose();\r\n new SnowDecorator(viewport, tex);\r\n });\r\n\r\n // When the viewport is destroyed, dispose of this decorator too.\r\n const removeOnDispose = viewport.onDisposed.addListener(() => this.dispose());\r\n const removeDecorator = IModelApp.viewManager.addDecorator(this);\r\n\r\n this.dispose = () => {\r\n removeDecorator();\r\n removeOnRender();\r\n removeOnDispose();\r\n removeOnResized();\r\n this._texture = dispose(this._texture);\r\n SnowDecorator._decorators.delete(viewport);\r\n };\r\n\r\n SnowDecorator._decorators.set(viewport, this);\r\n\r\n // Initialize the particles.\r\n for (let i = 0; i < this._params.numParticles; i++)\r\n this._particles.push(this.emit(true));\r\n }\r\n\r\n public decorate(context: DecorateContext): void {\r\n if (context.viewport !== this.viewport || !this._texture)\r\n return;\r\n\r\n // Update the particles.\r\n const now = Date.now();\r\n const deltaMillis = now - this._lastUpdateTime;\r\n this._lastUpdateTime = now;\r\n this.updateParticles(deltaMillis / 1000);\r\n\r\n // Create particle graphics.\r\n const builder = ParticleCollectionBuilder.create({\r\n viewport: this.viewport,\r\n isViewCoords: true,\r\n texture: this._texture,\r\n size: (this._params.sizeRange.high - this._params.sizeRange.low) / 2,\r\n });\r\n\r\n for (const particle of this._particles)\r\n builder.addParticle(particle);\r\n\r\n const graphic = builder.finish();\r\n if (graphic)\r\n context.addDecoration(GraphicType.ViewOverlay, graphic);\r\n }\r\n\r\n /** Change some of the parameters affecting this decorator. */\r\n public configure(params: Partial<SnowParams>): void {\r\n for (const key of Object.keys(params)) {\r\n const val = (params as any)[key];\r\n if (undefined !== val)\r\n (this._params as any)[key] = val;\r\n }\r\n }\r\n\r\n /** Emit a new particle with randomized properties. */\r\n private emit(randomizeHeight: boolean): SnowParticle {\r\n return {\r\n x: randomInteger(0, this._dimensions.x),\r\n y: randomizeHeight ? randomInteger(0, this._dimensions.y) : 0,\r\n z: 0,\r\n size: randomInteger(this._params.sizeRange.low, this._params.sizeRange.high),\r\n transparency: randomInteger(this._params.transparencyRange.low, this._params.transparencyRange.high),\r\n velocity: new Vector2d(randomFloat(this._params.velocityRange.low.x, this._params.velocityRange.high.x),\r\n randomFloat(this._params.velocityRange.low.y, this._params.velocityRange.high.y)),\r\n };\r\n }\r\n\r\n // Update the positions and velocities of all the particles based on the amount of time that has passed since the last update.\r\n private updateParticles(elapsedSeconds: number): void {\r\n // Determine if someone changed the desired number of particles.\r\n const particleDiscrepancy = this._params.numParticles - this._particles.length;\r\n if (particleDiscrepancy > 0) {\r\n // Birth new particles up to the new maximum.\r\n for (let i = 0; i < particleDiscrepancy; i++)\r\n this._particles.push(this.emit(true));\r\n } else {\r\n // Destroy extra particles.\r\n this._particles.length = this._params.numParticles;\r\n }\r\n\r\n const acceleration = new Vector2d();\r\n const velocity = new Vector2d();\r\n for (let i = 0; i < this._particles.length; i++) {\r\n // Apply some acceleration to produce random drift.\r\n const particle = this._particles[i];\r\n acceleration.set(randomFloat(this._params.accelerationRange.low.x, this._params.accelerationRange.high.x),\r\n randomFloat(this._params.accelerationRange.low.y, this._params.accelerationRange.high.y));\r\n\r\n acceleration.scale(elapsedSeconds, acceleration);\r\n particle.velocity.plus(acceleration, particle.velocity);\r\n\r\n // Apply velocity.\r\n particle.velocity.clone(velocity);\r\n velocity.scale(elapsedSeconds, velocity);\r\n particle.x += velocity.x;\r\n particle.y += velocity.y;\r\n\r\n // Apply wind\r\n particle.x += this._params.windVelocity * elapsedSeconds;\r\n\r\n // Particles that travel beyond the viewport's left or right edges wrap around to the other side.\r\n if (particle.x < 0)\r\n particle.x = this._dimensions.x - 1;\r\n else if (particle.x >= this._dimensions.x)\r\n particle.x = 0;\r\n\r\n // Particles that travel beyond the viewport's bottom or top edges are replaced by newborn particles.\r\n if (particle.y < 0 || particle.y >= this._dimensions.y)\r\n this._particles[i] = this.emit(false);\r\n }\r\n }\r\n\r\n private static readonly _decorators = new Map<Viewport, SnowDecorator>();\r\n\r\n /** Toggle this decorator for the specified viewport.\r\n * @param viewport The viewport to which the effect should be applied or removed.\r\n * @param enable `true` to enable the effect, `false` to disable it, or `undefined` to toggle the current state.\r\n */\r\n public static async toggle(viewport: Viewport, enable?: boolean): Promise<void> {\r\n const decorator = this._decorators.get(viewport);\r\n if (undefined === enable)\r\n enable = undefined === decorator;\r\n\r\n if (undefined !== decorator && !enable)\r\n decorator.dispose();\r\n else if (undefined === decorator && enable) {\r\n // Create a texture to use for the particles.\r\n // Note: the decorator takes ownership of the texture, and disposes of it when the decorator is disposed.\r\n const image = await imageElementFromUrl(`${IModelApp.publicPath}sprites/particle_snow.png`);\r\n const texture = IModelApp.renderSystem.createTexture({\r\n ownership: \"external\",\r\n image: { source: image, transparency: TextureTransparency.Mixed },\r\n });\r\n\r\n new SnowDecorator(viewport, texture);\r\n }\r\n }\r\n}\r\n\r\n/** Toggles a decorator that simulates snow using particle effects.\r\n * @see [[SnowDecorator]] for the implementation of the decorator.\r\n * @beta\r\n */\r\nexport class SnowEffect extends Tool {\r\n public static override toolId = \"SnowEffect\";\r\n\r\n public override async run(enable?: boolean): Promise<boolean> {\r\n const vp = IModelApp.viewManager.selectedView;\r\n if (vp)\r\n await SnowDecorator.toggle(vp, enable);\r\n\r\n return true;\r\n }\r\n\r\n public override async parseAndRun(...args: string[]): Promise<boolean> {\r\n const enable = parseToggle(args[0]);\r\n if (typeof enable !== \"string\")\r\n await this.run(enable);\r\n\r\n return true;\r\n }\r\n}\r\n"]}
@@ -1,40 +1,40 @@
1
- /** @packageDocumentation
2
- * @module Effects
3
- */
4
- import { ScreenSpaceEffectBuilder, Tool } from "@itwin/core-frontend";
5
- import { AddEffectTool } from "./EffectTools";
6
- /** Applies a [vignette](https://en.wikipedia.org/wiki/Vignetting) effect to the viewport.
7
- * From https://github.com/TyLindberg/glsl-vignette/blob/master/advanced.glsl.
8
- * @beta
9
- */
10
- export declare class VignetteEffect extends AddEffectTool {
11
- static toolId: string;
12
- protected get effectName(): string;
13
- protected get textureCoordFromPosition(): boolean;
14
- protected get source(): {
15
- vertex: string;
16
- fragment: string;
17
- };
18
- protected defineEffect(builder: ScreenSpaceEffectBuilder): void;
19
- }
20
- /** Configures the [[VignetteEffect]].
21
- * @beta
22
- */
23
- export declare class VignetteConfig extends Tool {
24
- static toolId: string;
25
- static get minArgs(): number;
26
- static get maxArgs(): number;
27
- /** Size of the vignette in the form (width/2, height/2). e.g., to make the vignette start fading in halfway between the center and edges of
28
- * UV space, use (0.25, 0.25).
29
- */
30
- static readonly size: Float32Array;
31
- /** How round the vignette will be, from 0.0 (perfectly rectangular) to 1.0 (perfectly round). */
32
- static roundness: number;
33
- /** How quickly the vignette fades in. The vignette starts fading in at the edge of the values provided by `size` and will be
34
- * fully faded in at (size.x + smoothness, size.y * smoothness). A value of 0.0 produces a hard edge.
35
- */
36
- static smoothness: number;
37
- run(width?: number, height?: number, roundness?: number, smoothness?: number): Promise<boolean>;
38
- parseAndRun(...input: string[]): Promise<boolean>;
39
- }
1
+ /** @packageDocumentation
2
+ * @module Effects
3
+ */
4
+ import { ScreenSpaceEffectBuilder, Tool } from "@itwin/core-frontend";
5
+ import { AddEffectTool } from "./EffectTools";
6
+ /** Applies a [vignette](https://en.wikipedia.org/wiki/Vignetting) effect to the viewport.
7
+ * From https://github.com/TyLindberg/glsl-vignette/blob/master/advanced.glsl.
8
+ * @beta
9
+ */
10
+ export declare class VignetteEffect extends AddEffectTool {
11
+ static toolId: string;
12
+ protected get effectName(): string;
13
+ protected get textureCoordFromPosition(): boolean;
14
+ protected get source(): {
15
+ vertex: string;
16
+ fragment: string;
17
+ };
18
+ protected defineEffect(builder: ScreenSpaceEffectBuilder): void;
19
+ }
20
+ /** Configures the [[VignetteEffect]].
21
+ * @beta
22
+ */
23
+ export declare class VignetteConfig extends Tool {
24
+ static toolId: string;
25
+ static get minArgs(): number;
26
+ static get maxArgs(): number;
27
+ /** Size of the vignette in the form (width/2, height/2). e.g., to make the vignette start fading in halfway between the center and edges of
28
+ * UV space, use (0.25, 0.25).
29
+ */
30
+ static readonly size: Float32Array;
31
+ /** How round the vignette will be, from 0.0 (perfectly rectangular) to 1.0 (perfectly round). */
32
+ static roundness: number;
33
+ /** How quickly the vignette fades in. The vignette starts fading in at the edge of the values provided by `size` and will be
34
+ * fully faded in at (size.x + smoothness, size.y * smoothness). A value of 0.0 produces a hard edge.
35
+ */
36
+ static smoothness: number;
37
+ run(width?: number, height?: number, roundness?: number, smoothness?: number): Promise<boolean>;
38
+ parseAndRun(...input: string[]): Promise<boolean>;
39
+ }
40
40
  //# sourceMappingURL=Vignette.d.ts.map