@itwin/frontend-devtools 3.0.0-extension.1 → 3.0.2
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.
- package/CHANGELOG.md +106 -1
- package/LICENSE.md +1 -1
- package/README.md +28 -3
- package/lib/cjs/FrontEndDevTools.d.ts.map +1 -1
- package/lib/cjs/FrontEndDevTools.js +6 -1
- package/lib/cjs/FrontEndDevTools.js.map +1 -1
- package/lib/cjs/effects/Explosion.d.ts.map +1 -1
- package/lib/cjs/effects/Explosion.js +3 -2
- package/lib/cjs/effects/Explosion.js.map +1 -1
- package/lib/cjs/effects/Snow.d.ts.map +1 -1
- package/lib/cjs/effects/Snow.js +3 -2
- package/lib/cjs/effects/Snow.js.map +1 -1
- package/lib/cjs/frontend-devtools.d.ts +1 -1
- package/lib/cjs/frontend-devtools.js +1 -1
- package/lib/cjs/frontend-devtools.js.map +1 -1
- package/lib/cjs/tools/ClipTools.d.ts +2 -2
- package/lib/cjs/tools/ClipTools.d.ts.map +1 -1
- package/lib/cjs/tools/ClipTools.js +2 -2
- package/lib/cjs/tools/ClipTools.js.map +1 -1
- package/lib/cjs/tools/DisplayStyleTools.d.ts +75 -16
- package/lib/cjs/tools/DisplayStyleTools.d.ts.map +1 -1
- package/lib/cjs/tools/DisplayStyleTools.js +219 -15
- package/lib/cjs/tools/DisplayStyleTools.js.map +1 -1
- package/lib/cjs/tools/PlanProjectionTools.d.ts +6 -6
- package/lib/cjs/tools/PlanProjectionTools.d.ts.map +1 -1
- package/lib/cjs/tools/PlanProjectionTools.js +6 -6
- package/lib/cjs/tools/PlanProjectionTools.js.map +1 -1
- package/lib/cjs/tools/PlanarMaskTools.d.ts +3 -2
- package/lib/cjs/tools/PlanarMaskTools.d.ts.map +1 -1
- package/lib/cjs/tools/PlanarMaskTools.js +47 -22
- package/lib/cjs/tools/PlanarMaskTools.js.map +1 -1
- package/lib/cjs/tools/RenderSystemTools.d.ts +0 -7
- package/lib/cjs/tools/RenderSystemTools.d.ts.map +1 -1
- package/lib/cjs/tools/RenderSystemTools.js +1 -11
- package/lib/cjs/tools/RenderSystemTools.js.map +1 -1
- package/lib/cjs/tools/SourceAspectIdTools.js +1 -1
- package/lib/cjs/tools/SourceAspectIdTools.js.map +1 -1
- package/lib/cjs/tools/ViewportTools.d.ts +15 -0
- package/lib/cjs/tools/ViewportTools.d.ts.map +1 -1
- package/lib/cjs/tools/ViewportTools.js +46 -1
- package/lib/cjs/tools/ViewportTools.js.map +1 -1
- package/lib/cjs/widgets/DiagnosticsPanel.d.ts +2 -0
- package/lib/cjs/widgets/DiagnosticsPanel.d.ts.map +1 -1
- package/lib/cjs/widgets/DiagnosticsPanel.js +6 -0
- package/lib/cjs/widgets/DiagnosticsPanel.js.map +1 -1
- package/lib/cjs/widgets/MemoryTracker.js +2 -2
- package/lib/cjs/widgets/MemoryTracker.js.map +1 -1
- package/lib/cjs/widgets/RenderCommandBreakdown.d.ts +16 -0
- package/lib/cjs/widgets/RenderCommandBreakdown.d.ts.map +1 -0
- package/lib/cjs/widgets/RenderCommandBreakdown.js +69 -0
- package/lib/cjs/widgets/RenderCommandBreakdown.js.map +1 -0
- package/lib/esm/FrontEndDevTools.d.ts.map +1 -1
- package/lib/esm/FrontEndDevTools.js +9 -4
- package/lib/esm/FrontEndDevTools.js.map +1 -1
- package/lib/esm/effects/Explosion.d.ts.map +1 -1
- package/lib/esm/effects/Explosion.js +3 -2
- package/lib/esm/effects/Explosion.js.map +1 -1
- package/lib/esm/effects/Snow.d.ts.map +1 -1
- package/lib/esm/effects/Snow.js +3 -2
- package/lib/esm/effects/Snow.js.map +1 -1
- package/lib/esm/frontend-devtools.d.ts +1 -1
- package/lib/esm/frontend-devtools.js +1 -1
- package/lib/esm/frontend-devtools.js.map +1 -1
- package/lib/esm/tools/ClipTools.d.ts +2 -2
- package/lib/esm/tools/ClipTools.d.ts.map +1 -1
- package/lib/esm/tools/ClipTools.js +2 -2
- package/lib/esm/tools/ClipTools.js.map +1 -1
- package/lib/esm/tools/DisplayStyleTools.d.ts +75 -16
- package/lib/esm/tools/DisplayStyleTools.d.ts.map +1 -1
- package/lib/esm/tools/DisplayStyleTools.js +215 -16
- package/lib/esm/tools/DisplayStyleTools.js.map +1 -1
- package/lib/esm/tools/PlanProjectionTools.d.ts +6 -6
- package/lib/esm/tools/PlanProjectionTools.d.ts.map +1 -1
- package/lib/esm/tools/PlanProjectionTools.js +6 -6
- package/lib/esm/tools/PlanProjectionTools.js.map +1 -1
- package/lib/esm/tools/PlanarMaskTools.d.ts +3 -2
- package/lib/esm/tools/PlanarMaskTools.d.ts.map +1 -1
- package/lib/esm/tools/PlanarMaskTools.js +47 -22
- package/lib/esm/tools/PlanarMaskTools.js.map +1 -1
- package/lib/esm/tools/RenderSystemTools.d.ts +0 -7
- package/lib/esm/tools/RenderSystemTools.d.ts.map +1 -1
- package/lib/esm/tools/RenderSystemTools.js +0 -9
- package/lib/esm/tools/RenderSystemTools.js.map +1 -1
- package/lib/esm/tools/SourceAspectIdTools.js +1 -1
- package/lib/esm/tools/SourceAspectIdTools.js.map +1 -1
- package/lib/esm/tools/ViewportTools.d.ts +15 -0
- package/lib/esm/tools/ViewportTools.d.ts.map +1 -1
- package/lib/esm/tools/ViewportTools.js +44 -0
- package/lib/esm/tools/ViewportTools.js.map +1 -1
- package/lib/esm/widgets/DiagnosticsPanel.d.ts +2 -0
- package/lib/esm/widgets/DiagnosticsPanel.d.ts.map +1 -1
- package/lib/esm/widgets/DiagnosticsPanel.js +6 -0
- package/lib/esm/widgets/DiagnosticsPanel.js.map +1 -1
- package/lib/esm/widgets/MemoryTracker.js +2 -2
- package/lib/esm/widgets/MemoryTracker.js.map +1 -1
- package/lib/esm/widgets/RenderCommandBreakdown.d.ts +16 -0
- package/lib/esm/widgets/RenderCommandBreakdown.d.ts.map +1 -0
- package/lib/esm/widgets/RenderCommandBreakdown.js +65 -0
- package/lib/esm/widgets/RenderCommandBreakdown.js.map +1 -0
- package/lib/public/locales/en/FrontendDevTools.json +464 -449
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,111 @@
|
|
|
1
1
|
# Change Log - @itwin/frontend-devtools
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 10 Mar 2022 21:18:13 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 3.0.2
|
|
6
|
+
Thu, 10 Mar 2022 21:18:13 GMT
|
|
7
|
+
|
|
8
|
+
_Version update only_
|
|
9
|
+
|
|
10
|
+
## 3.0.1
|
|
11
|
+
Thu, 24 Feb 2022 15:26:55 GMT
|
|
12
|
+
|
|
13
|
+
_Version update only_
|
|
14
|
+
|
|
15
|
+
## 3.0.0
|
|
16
|
+
Mon, 24 Jan 2022 14:00:52 GMT
|
|
17
|
+
|
|
18
|
+
### Updates
|
|
19
|
+
|
|
20
|
+
- Update release tags
|
|
21
|
+
- Upgrade target to ES2019 and deliver both a CommonJs and ESModule version of package
|
|
22
|
+
- Added keyins for setting images to be used for sky sphere or sky cube.
|
|
23
|
+
- fix ecsql row format
|
|
24
|
+
- Now use 'DisplayStyleState.backgroundMapBase' instead of 'DisplayStyleState.changeBaseMapProps' to update the mapImagery.
|
|
25
|
+
- Support -1 to modify all reality models. Fix messages
|
|
26
|
+
- rename to @itwin/frontend-devtools
|
|
27
|
+
- Fix typo.
|
|
28
|
+
- Add support for inverting planar clip mask (inside vs outside)
|
|
29
|
+
- Replace usage of I18N with generic Localization interface.
|
|
30
|
+
- Renamed an iModel's parent container to iTwin
|
|
31
|
+
- tool.run and tool.parseAndRun are now async methods
|
|
32
|
+
- Add `fdt bgcolor` keyin for changing the viewport's background color.
|
|
33
|
+
- Replace `fdt toggle wiremesh` keyin with `fdt wiremesh` that produces real wiremesh.
|
|
34
|
+
|
|
35
|
+
## 2.19.28
|
|
36
|
+
Wed, 12 Jan 2022 14:52:38 GMT
|
|
37
|
+
|
|
38
|
+
_Version update only_
|
|
39
|
+
|
|
40
|
+
## 2.19.27
|
|
41
|
+
Wed, 05 Jan 2022 20:07:20 GMT
|
|
42
|
+
|
|
43
|
+
_Version update only_
|
|
44
|
+
|
|
45
|
+
## 2.19.26
|
|
46
|
+
Wed, 08 Dec 2021 20:54:52 GMT
|
|
47
|
+
|
|
48
|
+
_Version update only_
|
|
49
|
+
|
|
50
|
+
## 2.19.25
|
|
51
|
+
Fri, 03 Dec 2021 20:05:49 GMT
|
|
52
|
+
|
|
53
|
+
_Version update only_
|
|
54
|
+
|
|
55
|
+
## 2.19.24
|
|
56
|
+
Mon, 29 Nov 2021 18:44:31 GMT
|
|
57
|
+
|
|
58
|
+
_Version update only_
|
|
59
|
+
|
|
60
|
+
## 2.19.23
|
|
61
|
+
Mon, 22 Nov 2021 20:41:39 GMT
|
|
62
|
+
|
|
63
|
+
_Version update only_
|
|
64
|
+
|
|
65
|
+
## 2.19.22
|
|
66
|
+
Wed, 17 Nov 2021 01:23:26 GMT
|
|
67
|
+
|
|
68
|
+
_Version update only_
|
|
69
|
+
|
|
70
|
+
## 2.19.21
|
|
71
|
+
Wed, 10 Nov 2021 10:58:24 GMT
|
|
72
|
+
|
|
73
|
+
_Version update only_
|
|
74
|
+
|
|
75
|
+
## 2.19.20
|
|
76
|
+
Fri, 29 Oct 2021 16:14:22 GMT
|
|
77
|
+
|
|
78
|
+
_Version update only_
|
|
79
|
+
|
|
80
|
+
## 2.19.19
|
|
81
|
+
Mon, 25 Oct 2021 16:16:25 GMT
|
|
82
|
+
|
|
83
|
+
_Version update only_
|
|
84
|
+
|
|
85
|
+
## 2.19.18
|
|
86
|
+
Thu, 21 Oct 2021 20:59:44 GMT
|
|
87
|
+
|
|
88
|
+
_Version update only_
|
|
89
|
+
|
|
90
|
+
## 2.19.17
|
|
91
|
+
Thu, 14 Oct 2021 21:19:43 GMT
|
|
92
|
+
|
|
93
|
+
_Version update only_
|
|
94
|
+
|
|
95
|
+
## 2.19.16
|
|
96
|
+
Mon, 11 Oct 2021 17:37:46 GMT
|
|
97
|
+
|
|
98
|
+
_Version update only_
|
|
99
|
+
|
|
100
|
+
## 2.19.15
|
|
101
|
+
Fri, 08 Oct 2021 16:44:23 GMT
|
|
102
|
+
|
|
103
|
+
_Version update only_
|
|
104
|
+
|
|
105
|
+
## 2.19.14
|
|
106
|
+
Fri, 01 Oct 2021 13:07:03 GMT
|
|
107
|
+
|
|
108
|
+
_Version update only_
|
|
4
109
|
|
|
5
110
|
## 2.19.13
|
|
6
111
|
Tue, 21 Sep 2021 21:06:40 GMT
|
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# MIT License
|
|
2
2
|
|
|
3
|
-
Copyright © 2017-
|
|
3
|
+
Copyright © 2017-2022 Bentley Systems, Incorporated. All rights reserved.
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
6
|
|
package/README.md
CHANGED
|
@@ -55,6 +55,7 @@ The key-ins below enable, disable, or toggle a specific feature. They take at mo
|
|
|
55
55
|
|
|
56
56
|
* `fdt project extents` - Toggles display of a decoration illustrating the iModel's project extents.
|
|
57
57
|
* `fdt freeze scene` - Toggles scene freeze for the active viewport. While scene freeze is enabled, the same set of tiles will continue to be displayed until the scene is unfrozen - no new tiles will be loaded. Useful for zooming in or out to inspect geometry inside specific tiles.
|
|
58
|
+
* `fdt wiremesh` - Toggles the display of wiremesh overlay on surfaces in the selected viewport.
|
|
58
59
|
* `fdt section cut` - Specify whether a clip volume applied to the view should produce cut geometry at intersections with the design models. This controls `ViewState.details.clipStyle.produceCutGeometry`.
|
|
59
60
|
* `fdt particle snow` - Toggle a particle effect simulating snowfall for the active viewport.
|
|
60
61
|
* `fdt frustum selected` - Toggles a decoration representing the current frustum of the selected viewport. The decoration is displayed in any *other* open viewports - so if no other viewports are open, this key-in has no effect.
|
|
@@ -188,7 +189,7 @@ Reality models can be attached to a display style to provide context when that d
|
|
|
188
189
|
### Planar Mask keyins
|
|
189
190
|
|
|
190
191
|
This package supplies several keyins to control planar masking for background maps and reality models. These masks provide a two and a half dimensional method for masking the regions where the background map, reality models and BIM geometry overlap.
|
|
191
|
-
Planar masks include an optional transparency override. If a transparency values is specified, a value of 0 will completely mask the reality model - the masked portion will be omitted completely, higher values will produce less masking and a semit translucent display of the masked geometry. If no transparency is included then the transparency value from the mask elements is used.
|
|
192
|
+
Planar masks include an optional transparency override. If a transparency values is specified, a value of 0 will completely mask the reality model - the masked portion will be omitted completely, higher values will produce less masking and a semit translucent display of the masked geometry. If no transparency is included then the transparency value from the mask elements is used. An additional argument boolean argument will invert the mask and mask the area outside the mask geometry rather than inside.
|
|
192
193
|
|
|
193
194
|
#### Background map planar masks
|
|
194
195
|
|
|
@@ -196,15 +197,19 @@ These keyins control the planar masking of the background map.
|
|
|
196
197
|
|
|
197
198
|
* `fdt set map mask by priority` Set the background map to be masked based on priority. Masking by priority will mask by higher priority models. By default background map have lowest priorty (-2048) Unless their priority is overridden reality models are higher priority and BIM models are always higher priority, therefore if priority masking is selected then the background map will be masked by all reality and BIM models. A value for transparency may optionally be included.
|
|
198
199
|
* `transparency`: (optional) - A value for the mask transparency override. [0...1]
|
|
199
|
-
* `
|
|
200
|
+
* `invert`: (optional) - If `on` or `true` then the mask sense is inverted and the area outside the mask geometry will be masked and the area inside the mask is displayed.
|
|
200
201
|
* `fdt set map mask elements` Set the background map to be masked by one or more elements. If elements are already selected they are used for the mask, otherwise the mask elements may be selected individually.
|
|
201
202
|
* `transparency`: (optional) - A value for the mask transparency override. [0...1]
|
|
203
|
+
* `invert`: (optional) - If `on` or `true` then the mask sense is inverted and the area outside the mask geometry will be masked and the area inside the mask is displayed.
|
|
202
204
|
* `fdt set map mask exclude elements` Set the background map to be masked by all elements except the selected (or individually picked) excluded elements.
|
|
203
205
|
* `transparency`: (optional) - A value for the mask transparency override. [0...1]
|
|
206
|
+
* `invert`: (optional) - If `on` or `true` then the mask sense is inverted and the area outside the mask geometry will be masked and the area inside the mask is displayed.
|
|
204
207
|
* `fdt set map mask models` Set the background map to be masked by the selected models. The selected models can come from either the current selection set or can be picked individually.
|
|
205
208
|
* `transparency`: (optional) - A value for the mask transparency override. [0...1]
|
|
209
|
+
* `invert`: (optional) - If `on` or `true` then the mask sense is inverted and the area outside the mask geometry will be masked and the area inside the mask is displayed.
|
|
206
210
|
* `fdt set map mask subcategory` Set the background map to be masked by one or more picked subcategories.
|
|
207
211
|
* `transparency`: (optional) - A value for the mask transparency override. [0...1]
|
|
212
|
+
* `invert`: (optional) - If `on` or `true` then the mask sense is inverted and the area outside the mask geometry will be masked and the area inside the mask is displayed.
|
|
208
213
|
* `fdt unmask map` Removes the current background map masks.
|
|
209
214
|
|
|
210
215
|
#### Reality model planar masks
|
|
@@ -214,14 +219,19 @@ These keysins control the planar masking of reality models.
|
|
|
214
219
|
* `fdt set reality model mask by priority` Set the reality model to masked based on priority. Masking by priority will cause the masked model to be masked by all higher priority models. By default global reality models (such as the OpenStreetMap building layer) have a priority of -1024 and standard reality models have a priority of zero. BIM models have a priority of 1024. Therefore with default priorities reality models are always masked by BIM model and global reality models are masked by standard reality models. By specifying a priority bias for the when creating the masks for a reality model the masking of reality models by other reality models can be controlled.
|
|
215
220
|
* `transparency`: (optional) - A value for the mask transparency override. [0...1]
|
|
216
221
|
* `priority`: (optional) - A bias to be applied to the default reality model priority. As lower priority models are masked by higher priority ones, specifying a priority of -1 would cause the reality model to be masked by other reality models.
|
|
222
|
+
* `invert`: (optional) - If `on` or `true` then the mask sense is inverted and the area outside the mask geometry will be masked and the area inside the mask is displayed.
|
|
217
223
|
* `fdt set reality model mask models`
|
|
218
224
|
* `transparency`: (optional)- A value for the mask transparency override. A value of 0 (the default) will completely mask the reality model, higher values will produce less masking and more more map display [0..1] If no transparency is included then the transparency value from the mask elements is used.
|
|
225
|
+
* `invert`: (optional) - If `on` or `true` then the mask sense is inverted and the area outside the mask geometry will be masked and the area inside the mask is displayed.
|
|
219
226
|
* `fdt set reality model mask elements` Set the reality model to be masked by one or more elements. If elements are already selected they are used for the mask, otherwise the mask elements may be selected individually.
|
|
220
227
|
* `transparency`: (optional) - A value for the mask transparency override. [0...1]
|
|
228
|
+
* `invert`: (optional) - If `on` or `true` then the mask sense is inverted and the area outside the mask geometry will be masked and the area inside the mask is displayed.
|
|
221
229
|
* `fdt set reality model mask exclude elements` Set a reality model to be masked by all elements except the selected (or individually picked) excluded elements.
|
|
222
230
|
* `transparency`: (optional) - A value for the mask transparency override. [0...1]
|
|
231
|
+
* `invert`: (optional) - If `on` or `true` then the mask sense is inverted and the area outside the mask geometry will be masked and the area inside the mask is displayed.
|
|
223
232
|
* `fdt set reality model mask subcategory` Set a reality mdel to be masked by one or more picked subcategories.
|
|
224
233
|
* `transparency`: (optional) - A value for the mask transparency override. [0...1]
|
|
234
|
+
* `invert`: (optional) - If `on` or `true` then the mask sense is inverted and the area outside the mask geometry will be masked and the area inside the mask is displayed
|
|
225
235
|
* `fdt unmask reality model` Removes the masks from the selected reality model.
|
|
226
236
|
|
|
227
237
|
### Other key-ins
|
|
@@ -239,6 +249,7 @@ These keysins control the planar masking of reality models.
|
|
|
239
249
|
* `copy`: copy result to system clipboard.
|
|
240
250
|
* `quote`: format the result so it can be directly parsed by `fdt apply rendering style` as a single quoted string argument.
|
|
241
251
|
* `fdt apply rendering style` - Given a rendering style as a JSON string (see `fdt save rendering style`), applies it to the active viewport's display style. See `DisplayStyleSettings.applyOverrides`. Takes a single required argument: the JSON string.
|
|
252
|
+
* `fdt bgcolor` - change the background color for the active viewport. It requires a single argument - the string representation of the color. See ColorDef.fromString for supported formats.
|
|
242
253
|
* `fdt change viewflags` - Changes any number of ViewFlags for the active viewport. Each argument is of the format "flag=value". For boolean flags, the value is `0` for `false` or `1` for `true`. Flag names are case-insensitive.
|
|
243
254
|
* Boolean flags: "dimensions", "patterns", "weights", "styles", "transparency", "fill", "textures", "materials", "acsTriad", "grid", "visibleEdges", "hiddenEdges", "lighting", "shadows", "clipVolume", "constructions", "monochrome", "backgroundMap", "ambientOcclusion", "forceSurfaceDiscard"
|
|
244
255
|
* "renderMode": 0 = wireframe, 3 = hidden line, 4 = solid fill, 6 = smooth shade (numeric values of RenderMode enum).
|
|
@@ -252,6 +263,14 @@ These keysins control the planar masking of reality models.
|
|
|
252
263
|
* "copy=0|1" where `1` indicates the output should be copied to the system clipboard.
|
|
253
264
|
* `fdt select elements` - given a list of element Ids separated by whitespace, replace the contents of the selection set with those Ids.
|
|
254
265
|
* `fdt toggle skybox` - If the active viewport is displaying a spatial view, toggles display of the skybox.
|
|
266
|
+
* `fdt sky sphere` - set the image used for the skybox as a Url or texture Id.
|
|
267
|
+
* `fdt sky cube` - set the images used for the skybox, mapping each to one or more faces of the box. Each image is specified as a Url or texture Id. The images are mapped in the following orders based on how many are supplied:
|
|
268
|
+
* 1: all faces use the same image
|
|
269
|
+
* 2: top/bottom, sides
|
|
270
|
+
* 3: top/bottom, left/right, front/back
|
|
271
|
+
* 4: top, bottom, left/right, front/back
|
|
272
|
+
* 5: top/bottom, left, right, front, back
|
|
273
|
+
* 6: top, bottom, left, right, front, back
|
|
255
274
|
* `fdt emphasize selection` - Emphasizes all elements in the selection set, and de-emphasizes all other elements by making them semi-transparent and grey. If the selection set is empty, clear the effects of any previous use of this key-in. Accepts one of the following arguments:
|
|
256
275
|
* "none": Don't override color, don't apply silhouette.
|
|
257
276
|
* "color": Override color to white.
|
|
@@ -263,7 +282,6 @@ These keysins control the planar masking of reality models.
|
|
|
263
282
|
* `fdt clear emphasized` - Undo the effects of `fdt emphasize selection` or `fdt emphasize visible`.
|
|
264
283
|
* `fdt isolate selection` - Causes all elements except those currently in the selection set to stop drawing.
|
|
265
284
|
* `fdt clear isolate` - Reverse the effects of `fdt isolate selection`.
|
|
266
|
-
* `fdt toggle wiremesh` - Toggles "pseudo-wiremesh" display. This causes surfaces to be rendered using `GL_LINES` instead of `GL_TRIANGLES`. Useful for visualizing the triangles of a mesh - but not suitable for "real" wiremesh display.
|
|
267
285
|
* `fdt test clip style ON|OFF` - Toggles a ClipStyle for the active viewport with hard-coded symbology overrides.
|
|
268
286
|
* `fdt tile bounds` - Sets the type of bounding volume decorations that will be displayed for each tile displayed in the view. Accepts at most one argument; if none is specified, it defaults to "volume", unless tile bounds are already displayed, in which it toggles them back off.
|
|
269
287
|
* "none": Don't display bounding volumes.
|
|
@@ -289,6 +307,13 @@ These keysins control the planar masking of reality models.
|
|
|
289
307
|
* `fdt webgl lose context` - Force a webgl context loss.
|
|
290
308
|
* `fdt compile shaders` - Compile all un-compiled registered shader programs and report whether any errors occurred. Useful for testing/debugging platform-specific shader issues.
|
|
291
309
|
* `fdt animation interval` - Changes the `IModelApp.animationInterval` settings. Specify milliseconds in non-negative milliseconds; or anything not parseable as an integer to disable the interval callback entirely.
|
|
310
|
+
* `fdt query schedule script` - Queries the schedule script associated with the RenderTimeline or DisplayStyle element specified by Id. All arguments are optional:
|
|
311
|
+
- "id=<Id>": The Id of the element hosting the script. If omitted, obtains the Id from the schedule script applied to the active viewport.
|
|
312
|
+
- "action=<break|copy>": Specifies what to do after obtaining the script. "break" causes execution to pause in the debugger. "copy" (the default) copies the script JSON to the clipboard.
|
|
313
|
+
- "elementIds=<include|count|expand>": Specifies what to do with the list of element Ids in the script. By default, they are omitted.
|
|
314
|
+
* "include": Include the Ids as they are stored in the script - possibly in compressed format.
|
|
315
|
+
* "expand": Include the Ids, decompressing them if they are in compressed format.
|
|
316
|
+
* "count": Replace each list of Ids with the number of Ids in that list.
|
|
292
317
|
* `fdt visibility` - Controls whether instanced, un-instanced (batched), or all geometry is displayed in the active viewport. Accepts at most one argument; defaults to "all" if none is specified:
|
|
293
318
|
* "instanced": Display only instanced geometry.
|
|
294
319
|
* "batched": Display only un-instanced (batched) geometry.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FrontEndDevTools.d.ts","sourceRoot":"","sources":["../../src/FrontEndDevTools.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"FrontEndDevTools.d.ts","sourceRoot":"","sources":["../../src/FrontEndDevTools.ts"],"names":[],"mappings":"AAIA;;GAEG;AA+DH;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,YAAY,CAAS;IAEpC;;;;;;;OAOG;WACiB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAwJhD"}
|
|
@@ -72,6 +72,7 @@ class FrontendDevTools {
|
|
|
72
72
|
DisplayStyleTools_1.ApplyRenderingStyleTool,
|
|
73
73
|
SavedViews_1.ApplyViewByIdTool,
|
|
74
74
|
SavedViews_1.ApplyViewTool,
|
|
75
|
+
DisplayStyleTools_1.ChangeBackgroundColorTool,
|
|
75
76
|
ViewportTools_1.ChangeCameraTool,
|
|
76
77
|
ViewportTools_1.ChangeEmphasisSettingsTool,
|
|
77
78
|
ViewportTools_1.ChangeFlashSettingsTool,
|
|
@@ -113,6 +114,7 @@ class FrontendDevTools {
|
|
|
113
114
|
MeasureTileLoadTime_1.MeasureTileLoadTimeTool,
|
|
114
115
|
DisplayStyleTools_1.OverrideSubCategoryTool,
|
|
115
116
|
PlanProjectionTools_1.OverrideSubCategoryPriorityTool,
|
|
117
|
+
DisplayStyleTools_1.QueryScheduleScriptTool,
|
|
116
118
|
RealityTransitionTool_1.RealityTransitionTool,
|
|
117
119
|
MapLayerTool_1.ReorderMapLayers,
|
|
118
120
|
ReportWebGLCompatibilityTool_1.ReportWebGLCompatibilityTool,
|
|
@@ -128,6 +130,8 @@ class FrontendDevTools {
|
|
|
128
130
|
Convolution_1.SharpenEffect,
|
|
129
131
|
Convolution_1.SharpnessEffect,
|
|
130
132
|
ViewportTools_1.ShowTileVolumesTool,
|
|
133
|
+
DisplayStyleTools_1.SkyCubeTool,
|
|
134
|
+
DisplayStyleTools_1.SkySphereTool,
|
|
131
135
|
Snow_1.SnowEffect,
|
|
132
136
|
SourceAspectIdTools_1.SourceAspectIdFromElementIdTool,
|
|
133
137
|
ClipTools_1.TestClipStyleTool,
|
|
@@ -145,11 +149,12 @@ class FrontendDevTools {
|
|
|
145
149
|
DisplayStyleTools_1.ToggleSkyboxTool,
|
|
146
150
|
TileRequestDecoration_1.ToggleTileRequestDecorationTool,
|
|
147
151
|
TileTreeBoundsDecoration_1.ToggleTileTreeBoundsDecorationTool,
|
|
152
|
+
ViewportTools_1.ToggleTileTreeReferencesTool,
|
|
148
153
|
ToolTipProvider_1.ToggleToolTipsTool,
|
|
149
154
|
ViewportTools_1.ToggleViewAttachmentBoundariesTool,
|
|
150
155
|
ViewportTools_1.ToggleViewAttachmentClipShapesTool,
|
|
151
156
|
ViewportTools_1.ToggleViewAttachmentsTool,
|
|
152
|
-
|
|
157
|
+
DisplayStyleTools_1.ToggleWiremeshTool,
|
|
153
158
|
RenderTargetTools_1.ToggleRealityTileBounds,
|
|
154
159
|
RenderTargetTools_1.ToggleRealityTilePreload,
|
|
155
160
|
RenderTargetTools_1.ToggleRealityTileLogging,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FrontEndDevTools.js","sourceRoot":"","sources":["../../src/FrontEndDevTools.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAAiD;AACjD,uDAA+I;AAC/I,uDAAyD;AACzD,mDAAsD;AACtD,mDAAuE;AACvE,6DAAsF;AACtF,qDAA0E;AAC1E,yCAA4C;AAC5C,iDAAoE;AACpE,6DAAma;AACna,yDAAqe;AACre,yEAAsE;AACtE,6DAA0D;AAC1D,iDAA2F;AAC3F,iEAEmC;AACnC,yEAEuC;AACvC,iEAA8H;AAC9H,mEAAgE;AAChE,uDAI8B;AAC9B,qEAAsE;AACtE,uEAGsC;AACtC,qEAAgJ;AAChJ,2DAAkE;AAClE,iEAGmC;AACnC,yEAAsE;AACtE,iEAA8H;AAC9H,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,CAAC;;AA7JH,4CA8JC;AA7JgB,6BAAY,GAAG,KAAK,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 Utilities\r\n */\r\n\r\nimport { IModelApp } from \"@itwin/core-frontend\";\r\nimport { EdgeDetectionEffect, EmbossEffect, GaussianBlurEffect, SharpenEffect, SharpnessEffect, UnsharpenEffect } from \"./effects/Convolution\";\r\nimport { ClearEffectsTool } from \"./effects/EffectTools\";\r\nimport { ExplosionEffect } from \"./effects/Explosion\";\r\nimport { FlipImageConfig, FlipImageEffect } from \"./effects/FlipImage\";\r\nimport { LensDistortionConfig, LensDistortionEffect } from \"./effects/LensDistortion\";\r\nimport { SaturationConfig, SaturationEffect } from \"./effects/Saturation\";\r\nimport { SnowEffect } from \"./effects/Snow\";\r\nimport { VignetteConfig, VignetteEffect } from \"./effects/Vignette\";\r\nimport { MaskBackgroundMapByElementTool, MaskBackgroundMapByExcludedElementTool, MaskBackgroundMapByModelTool, MaskBackgroundMapBySubCategoryTool, MaskRealityModelByElementTool, MaskRealityModelByExcludedElementTool, MaskRealityModelByModelTool, MaskRealityModelBySubCategoryTool, SetHigherPriorityRealityModelMasking, SetMapHigherPriorityMasking, UnmaskMapTool, UnmaskRealityModelTool } from \"./tools/PlanarMaskTools\";\r\nimport { ChangeCameraTool, ChangeEmphasisSettingsTool, ChangeFlashSettingsTool, ChangeHiliteSettingsTool, DefaultTileSizeModifierTool, FadeOutTool, FreezeSceneTool, SetAspectRatioSkewTool, ShowTileVolumesTool, Toggle3dManipulationsTool, ToggleDrawingGraphicsTool, ToggleSectionDrawingSpatialViewTool, ToggleViewAttachmentBoundariesTool, ToggleViewAttachmentClipShapesTool, ToggleViewAttachmentsTool, ViewportAddRealityModel, ViewportTileSizeModifierTool } from \"./tools/ViewportTools\";\r\nimport { AnimationIntervalTool } from \"./tools/AnimationIntervalTool\";\r\nimport { ChangeUnitsTool } from \"./tools/ChangeUnitsTool\";\r\nimport { ClipColorTool, TestClipStyleTool, ToggleSectionCutTool } from \"./tools/ClipTools\";\r\nimport {\r\n ApplyRenderingStyleTool, ChangeViewFlagsTool, OverrideSubCategoryTool, SaveRenderingStyleTool, ToggleSkyboxTool, WoWIgnoreBackgroundTool,\r\n} from \"./tools/DisplayStyleTools\";\r\nimport {\r\n ClearEmphasizedElementsTool, ClearIsolatedElementsTool, EmphasizeSelectedElementsTool, EmphasizeVisibleElementsTool, IsolateSelectedElementsTool,\r\n} from \"./tools/EmphasizeElementsTool\";\r\nimport { ToggleFrustumSnapshotTool, ToggleSelectedViewFrustumTool, ToggleShadowFrustumTool } from \"./tools/FrustumDecoration\";\r\nimport { InspectElementTool } from \"./tools/InspectElementTool\";\r\nimport {\r\n AttachArcGISMapLayerByUrlTool, AttachMapLayerTool, AttachMapOverlayTool, AttachTileURLMapLayerByUrlTool, AttachWmsMapLayerByUrlTool,\r\n AttachWmtsMapLayerByUrlTool, DetachMapLayersTool, MapBaseColorTool, MapBaseTransparencyTool, MapBaseVisibilityTool, MapLayerSubLayerVisibilityTool,\r\n MapLayerTransparencyTool, MapLayerVisibilityTool, MapLayerZoomTool, ReorderMapLayers, SetMapBaseTool, ToggleTerrainTool,\r\n} from \"./tools/MapLayerTool\";\r\nimport { MeasureTileLoadTimeTool } from \"./tools/MeasureTileLoadTime\";\r\nimport {\r\n ClearModelAppearanceOverrides, SetModelColorTool, SetModelEmphasizedTool, SetModelIgnoresMaterialsTool, SetModelLineCodeTool,\r\n SetModelLineWeightTool, SetModelLocateTool, SetModelTransparencyTool,\r\n} from \"./tools/ModelAppearanceTools\";\r\nimport { ChangePlanProjectionSettingsTool, DumpPlanProjectionSettingsTool, OverrideSubCategoryPriorityTool } from \"./tools/PlanProjectionTools\";\r\nimport { ToggleProjectExtentsTool } from \"./tools/ProjectExtents\";\r\nimport {\r\n AttachCesiumAssetTool, AttachRealityModelTool, ClearRealityModelAppearanceOverrides, DetachRealityModelTool, SaveRealityModelTool,\r\n SetRealityModelColorTool, SetRealityModelEmphasizedTool, SetRealityModelLocateTool, SetRealityModelTransparencyTool, ToggleOSMBuildingDisplay,\r\n} from \"./tools/RealityModelTools\";\r\nimport { RealityTransitionTool } from \"./tools/RealityTransitionTool\";\r\nimport { CompileShadersTool, LoseWebGLContextTool, ToggleDPIForLODTool, ToggleWiremeshTool } from \"./tools/RenderSystemTools\";\r\nimport {\r\n SetAASamplesTool, ToggleDrapeFrustumTool, TogglePrimitiveVisibilityTool, ToggleReadPixelsTool, ToggleRealityTileBounds, ToggleRealityTileFreeze,\r\n ToggleRealityTileLogging, ToggleRealityTilePreload, ToggleVolClassIntersect,\r\n} from \"./tools/RenderTargetTools\";\r\nimport { ReportWebGLCompatibilityTool } from \"./tools/ReportWebGLCompatibilityTool\";\r\nimport { ApplyViewByIdTool, ApplyViewTool, SaveViewTool } from \"./tools/SavedViews\";\r\nimport { SelectElementsByIdTool } from \"./tools/SelectionTools\";\r\nimport { SetGpuMemoryLimitTool } from \"./tools/SetGpuMemoryLimitTool\";\r\nimport { ElementIdFromSourceAspectIdTool, SourceAspectIdFromElementIdTool } from \"./tools/SourceAspectIdTools\";\r\nimport { ToggleTileRequestDecorationTool } from \"./tools/TileRequestDecoration\";\r\nimport { ToggleTileTreeBoundsDecorationTool } from \"./tools/TileTreeBoundsDecoration\";\r\nimport { ToggleToolTipsTool } from \"./tools/ToolTipProvider\";\r\n\r\n/** Entry-point for the package. Before using the package you *must* call [[FrontendDevTools.initialize]].\r\n * @beta\r\n */\r\nexport class FrontendDevTools {\r\n private static _initialized = false;\r\n\r\n /** Call this before using the package (e.g., before instantiating any of its widgets or attempting to use any of its tools.\r\n * To initialize when starting up your app:\r\n * ```ts\r\n * IModelApp.startup();\r\n * await FrontendDevTools.initialize();\r\n * ```\r\n * @beta\r\n */\r\n public static async initialize(): Promise<void> {\r\n if (this._initialized)\r\n return;\r\n\r\n this._initialized = true;\r\n\r\n const namespace = \"FrontendDevTools\";\r\n const namespacePromise = IModelApp.localization.registerNamespace(namespace);\r\n const tools = [\r\n AttachMapLayerTool,\r\n AttachMapOverlayTool,\r\n AttachArcGISMapLayerByUrlTool,\r\n AttachWmsMapLayerByUrlTool,\r\n AttachWmtsMapLayerByUrlTool,\r\n AttachTileURLMapLayerByUrlTool,\r\n AnimationIntervalTool,\r\n ApplyRenderingStyleTool,\r\n ApplyViewByIdTool,\r\n ApplyViewTool,\r\n ChangeCameraTool,\r\n ChangeEmphasisSettingsTool,\r\n ChangeFlashSettingsTool,\r\n ChangeHiliteSettingsTool,\r\n ChangePlanProjectionSettingsTool,\r\n ChangeUnitsTool,\r\n ChangeViewFlagsTool,\r\n ClearEffectsTool,\r\n ClearEmphasizedElementsTool,\r\n ClearIsolatedElementsTool,\r\n ClipColorTool,\r\n CompileShadersTool,\r\n DefaultTileSizeModifierTool,\r\n DetachMapLayersTool,\r\n DumpPlanProjectionSettingsTool,\r\n EdgeDetectionEffect,\r\n EmbossEffect,\r\n ElementIdFromSourceAspectIdTool,\r\n EmphasizeSelectedElementsTool,\r\n EmphasizeVisibleElementsTool,\r\n ExplosionEffect,\r\n FadeOutTool,\r\n FlipImageConfig,\r\n FlipImageEffect,\r\n FreezeSceneTool,\r\n GaussianBlurEffect,\r\n InspectElementTool,\r\n IsolateSelectedElementsTool,\r\n LensDistortionConfig,\r\n LensDistortionEffect,\r\n LoseWebGLContextTool,\r\n MapLayerTransparencyTool,\r\n MapLayerVisibilityTool,\r\n MapLayerSubLayerVisibilityTool,\r\n MapLayerZoomTool,\r\n MapBaseColorTool,\r\n MapBaseTransparencyTool,\r\n MapBaseVisibilityTool,\r\n MeasureTileLoadTimeTool,\r\n OverrideSubCategoryTool,\r\n OverrideSubCategoryPriorityTool,\r\n RealityTransitionTool,\r\n ReorderMapLayers,\r\n ReportWebGLCompatibilityTool,\r\n SaturationConfig,\r\n SaturationEffect,\r\n SaveRenderingStyleTool,\r\n SaveViewTool,\r\n SelectElementsByIdTool,\r\n SetAASamplesTool,\r\n SetAspectRatioSkewTool,\r\n ToggleVolClassIntersect,\r\n SetMapBaseTool,\r\n SharpenEffect,\r\n SharpnessEffect,\r\n ShowTileVolumesTool,\r\n SnowEffect,\r\n SourceAspectIdFromElementIdTool,\r\n TestClipStyleTool,\r\n Toggle3dManipulationsTool,\r\n ToggleDrawingGraphicsTool,\r\n ToggleDPIForLODTool,\r\n ToggleDrapeFrustumTool,\r\n ToggleFrustumSnapshotTool,\r\n TogglePrimitiveVisibilityTool,\r\n ToggleProjectExtentsTool,\r\n ToggleReadPixelsTool,\r\n ToggleSectionDrawingSpatialViewTool,\r\n ToggleSelectedViewFrustumTool,\r\n ToggleShadowFrustumTool,\r\n ToggleSkyboxTool,\r\n ToggleTileRequestDecorationTool,\r\n ToggleTileTreeBoundsDecorationTool,\r\n ToggleToolTipsTool,\r\n ToggleViewAttachmentBoundariesTool,\r\n ToggleViewAttachmentClipShapesTool,\r\n ToggleViewAttachmentsTool,\r\n ToggleWiremeshTool,\r\n ToggleRealityTileBounds,\r\n ToggleRealityTilePreload,\r\n ToggleRealityTileLogging,\r\n ToggleRealityTileFreeze,\r\n ToggleSectionCutTool,\r\n ToggleTerrainTool,\r\n UnsharpenEffect,\r\n ViewportAddRealityModel,\r\n ViewportTileSizeModifierTool,\r\n VignetteConfig,\r\n VignetteEffect,\r\n AttachRealityModelTool,\r\n DetachRealityModelTool,\r\n SaveRealityModelTool,\r\n SetGpuMemoryLimitTool,\r\n SetRealityModelLocateTool,\r\n SetRealityModelEmphasizedTool,\r\n SetRealityModelTransparencyTool,\r\n SetRealityModelColorTool,\r\n SetModelLocateTool,\r\n SetModelEmphasizedTool,\r\n SetModelTransparencyTool,\r\n SetModelColorTool,\r\n SetModelLineWeightTool,\r\n SetModelLineCodeTool,\r\n SetModelIgnoresMaterialsTool,\r\n ClearRealityModelAppearanceOverrides,\r\n ClearModelAppearanceOverrides,\r\n AttachCesiumAssetTool,\r\n ToggleOSMBuildingDisplay,\r\n SetHigherPriorityRealityModelMasking,\r\n SetMapHigherPriorityMasking,\r\n MaskRealityModelByModelTool,\r\n MaskRealityModelBySubCategoryTool,\r\n MaskRealityModelByElementTool,\r\n MaskRealityModelByExcludedElementTool,\r\n UnmaskRealityModelTool,\r\n MaskBackgroundMapByModelTool,\r\n MaskBackgroundMapBySubCategoryTool,\r\n MaskBackgroundMapByElementTool,\r\n MaskBackgroundMapByExcludedElementTool,\r\n UnmaskMapTool,\r\n WoWIgnoreBackgroundTool,\r\n ];\r\n\r\n for (const tool of tools)\r\n tool.register(namespace);\r\n\r\n return namespacePromise;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"FrontEndDevTools.js","sourceRoot":"","sources":["../../src/FrontEndDevTools.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAAiD;AACjD,uDAA+I;AAC/I,uDAAyD;AACzD,mDAAsD;AACtD,mDAAuE;AACvE,6DAAsF;AACtF,qDAA0E;AAC1E,yCAA4C;AAC5C,iDAAoE;AACpE,6DAGiC;AACjC,yDAI+B;AAC/B,yEAAsE;AACtE,6DAA0D;AAC1D,iDAA2F;AAC3F,iEAGmC;AACnC,yEAEuC;AACvC,iEAA8H;AAC9H,mEAAgE;AAChE,uDAI8B;AAC9B,qEAAsE;AACtE,uEAGsC;AACtC,qEAAgJ;AAChJ,2DAAkE;AAClE,iEAGmC;AACnC,yEAAsE;AACtE,iEAA0G;AAC1G,iEAGmC;AACnC,uFAAoF;AACpF,mDAAoF;AACpF,2DAAgE;AAChE,yEAAsE;AACtE,qEAA+G;AAC/G,yEAAgF;AAChF,+EAAsF;AACtF,6DAA6D;AAE7D;;GAEG;AACH,MAAa,gBAAgB;IAG3B;;;;;;;OAOG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU;QAC5B,IAAI,IAAI,CAAC,YAAY;YACnB,OAAO;QAET,IAAI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YACzB,yCAAyB;YACzB,uCAAmB;YACnB,0CAAsB;YACtB,6CAAyB;YACzB,iDAA6B;YAC7B,yCAAwB;YACxB,wCAAoB;YACpB,mDAAmC;YACnC,iDAA6B;YAC7B,2CAAuB;YACvB,oCAAgB;YAChB,uDAA+B;YAC/B,6DAAkC;YAClC,4CAA4B;YAC5B,oCAAkB;YAClB,kDAAkC;YAClC,kDAAkC;YAClC,yCAAyB;YACzB,sCAAkB;YAClB,2CAAuB;YACvB,4CAAwB;YACxB,4CAAwB;YACxB,2CAAuB;YACvB,gCAAoB;YACpB,gCAAiB;YACjB,6BAAe;YACf,uCAAuB;YACvB,4CAA4B;YAC5B,yBAAc;YACd,yBAAc;YACd,0CAAsB;YACtB,0CAAsB;YACtB,wCAAoB;YACpB,6CAAqB;YACrB,6CAAyB;YACzB,iDAA6B;YAC7B,mDAA+B;YAC/B,4CAAwB;YACxB,yCAAkB;YAClB,6CAAsB;YACtB,+CAAwB;YACxB,wCAAiB;YACjB,6CAAsB;YACtB,2CAAoB;YACpB,mDAA4B;YAC5B,wDAAoC;YACpC,oDAA6B;YAC7B,yCAAqB;YACrB,4CAAwB;YACxB,sDAAoC;YACpC,6CAA2B;YAC3B,6CAA2B;YAC3B,mDAAiC;YACjC,+CAA6B;YAC7B,uDAAqC;YACrC,wCAAsB;YACtB,8CAA4B;YAC5B,oDAAkC;YAClC,gDAA8B;YAC9B,wDAAsC;YACtC,+BAAa;YACb,2CAAuB;SACxB,CAAC;QAEF,KAAK,MAAM,IAAI,IAAI,KAAK;YACtB,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAE3B,OAAO,gBAAgB,CAAC;IAC1B,CAAC;;AAlKH,4CAmKC;AAlKgB,6BAAY,GAAG,KAAK,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 Utilities\r\n */\r\n\r\nimport { IModelApp } from \"@itwin/core-frontend\";\r\nimport { EdgeDetectionEffect, EmbossEffect, GaussianBlurEffect, SharpenEffect, SharpnessEffect, UnsharpenEffect } from \"./effects/Convolution\";\r\nimport { ClearEffectsTool } from \"./effects/EffectTools\";\r\nimport { ExplosionEffect } from \"./effects/Explosion\";\r\nimport { FlipImageConfig, FlipImageEffect } from \"./effects/FlipImage\";\r\nimport { LensDistortionConfig, LensDistortionEffect } from \"./effects/LensDistortion\";\r\nimport { SaturationConfig, SaturationEffect } from \"./effects/Saturation\";\r\nimport { SnowEffect } from \"./effects/Snow\";\r\nimport { VignetteConfig, VignetteEffect } from \"./effects/Vignette\";\r\nimport {\r\n MaskBackgroundMapByElementTool, MaskBackgroundMapByExcludedElementTool, MaskBackgroundMapByModelTool, MaskBackgroundMapBySubCategoryTool, MaskRealityModelByElementTool, MaskRealityModelByExcludedElementTool,\r\n MaskRealityModelByModelTool, MaskRealityModelBySubCategoryTool, SetHigherPriorityRealityModelMasking, SetMapHigherPriorityMasking, UnmaskMapTool, UnmaskRealityModelTool,\r\n} from \"./tools/PlanarMaskTools\";\r\nimport {\r\n ChangeCameraTool, ChangeEmphasisSettingsTool, ChangeFlashSettingsTool, ChangeHiliteSettingsTool, DefaultTileSizeModifierTool, FadeOutTool, FreezeSceneTool, SetAspectRatioSkewTool, ShowTileVolumesTool,\r\n Toggle3dManipulationsTool, ToggleDrawingGraphicsTool, ToggleSectionDrawingSpatialViewTool, ToggleTileTreeReferencesTool, ToggleViewAttachmentBoundariesTool, ToggleViewAttachmentClipShapesTool,\r\n ToggleViewAttachmentsTool, ViewportAddRealityModel, ViewportTileSizeModifierTool,\r\n} from \"./tools/ViewportTools\";\r\nimport { AnimationIntervalTool } from \"./tools/AnimationIntervalTool\";\r\nimport { ChangeUnitsTool } from \"./tools/ChangeUnitsTool\";\r\nimport { ClipColorTool, TestClipStyleTool, ToggleSectionCutTool } from \"./tools/ClipTools\";\r\nimport {\r\n ApplyRenderingStyleTool, ChangeBackgroundColorTool, ChangeViewFlagsTool, OverrideSubCategoryTool, QueryScheduleScriptTool, SaveRenderingStyleTool, SkyCubeTool, SkySphereTool, ToggleSkyboxTool,\r\n ToggleWiremeshTool, WoWIgnoreBackgroundTool,\r\n} from \"./tools/DisplayStyleTools\";\r\nimport {\r\n ClearEmphasizedElementsTool, ClearIsolatedElementsTool, EmphasizeSelectedElementsTool, EmphasizeVisibleElementsTool, IsolateSelectedElementsTool,\r\n} from \"./tools/EmphasizeElementsTool\";\r\nimport { ToggleFrustumSnapshotTool, ToggleSelectedViewFrustumTool, ToggleShadowFrustumTool } from \"./tools/FrustumDecoration\";\r\nimport { InspectElementTool } from \"./tools/InspectElementTool\";\r\nimport {\r\n AttachArcGISMapLayerByUrlTool, AttachMapLayerTool, AttachMapOverlayTool, AttachTileURLMapLayerByUrlTool, AttachWmsMapLayerByUrlTool,\r\n AttachWmtsMapLayerByUrlTool, DetachMapLayersTool, MapBaseColorTool, MapBaseTransparencyTool, MapBaseVisibilityTool, MapLayerSubLayerVisibilityTool,\r\n MapLayerTransparencyTool, MapLayerVisibilityTool, MapLayerZoomTool, ReorderMapLayers, SetMapBaseTool, ToggleTerrainTool,\r\n} from \"./tools/MapLayerTool\";\r\nimport { MeasureTileLoadTimeTool } from \"./tools/MeasureTileLoadTime\";\r\nimport {\r\n ClearModelAppearanceOverrides, SetModelColorTool, SetModelEmphasizedTool, SetModelIgnoresMaterialsTool, SetModelLineCodeTool,\r\n SetModelLineWeightTool, SetModelLocateTool, SetModelTransparencyTool,\r\n} from \"./tools/ModelAppearanceTools\";\r\nimport { ChangePlanProjectionSettingsTool, DumpPlanProjectionSettingsTool, OverrideSubCategoryPriorityTool } from \"./tools/PlanProjectionTools\";\r\nimport { ToggleProjectExtentsTool } from \"./tools/ProjectExtents\";\r\nimport {\r\n AttachCesiumAssetTool, AttachRealityModelTool, ClearRealityModelAppearanceOverrides, DetachRealityModelTool, SaveRealityModelTool,\r\n SetRealityModelColorTool, SetRealityModelEmphasizedTool, SetRealityModelLocateTool, SetRealityModelTransparencyTool, ToggleOSMBuildingDisplay,\r\n} from \"./tools/RealityModelTools\";\r\nimport { RealityTransitionTool } from \"./tools/RealityTransitionTool\";\r\nimport { CompileShadersTool, LoseWebGLContextTool, ToggleDPIForLODTool } from \"./tools/RenderSystemTools\";\r\nimport {\r\n SetAASamplesTool, ToggleDrapeFrustumTool, TogglePrimitiveVisibilityTool, ToggleReadPixelsTool, ToggleRealityTileBounds, ToggleRealityTileFreeze,\r\n ToggleRealityTileLogging, ToggleRealityTilePreload, ToggleVolClassIntersect,\r\n} from \"./tools/RenderTargetTools\";\r\nimport { ReportWebGLCompatibilityTool } from \"./tools/ReportWebGLCompatibilityTool\";\r\nimport { ApplyViewByIdTool, ApplyViewTool, SaveViewTool } from \"./tools/SavedViews\";\r\nimport { SelectElementsByIdTool } from \"./tools/SelectionTools\";\r\nimport { SetGpuMemoryLimitTool } from \"./tools/SetGpuMemoryLimitTool\";\r\nimport { ElementIdFromSourceAspectIdTool, SourceAspectIdFromElementIdTool } from \"./tools/SourceAspectIdTools\";\r\nimport { ToggleTileRequestDecorationTool } from \"./tools/TileRequestDecoration\";\r\nimport { ToggleTileTreeBoundsDecorationTool } from \"./tools/TileTreeBoundsDecoration\";\r\nimport { ToggleToolTipsTool } from \"./tools/ToolTipProvider\";\r\n\r\n/** Entry-point for the package. Before using the package you *must* call [[FrontendDevTools.initialize]].\r\n * @beta\r\n */\r\nexport class FrontendDevTools {\r\n private static _initialized = false;\r\n\r\n /** Call this before using the package (e.g., before instantiating any of its widgets or attempting to use any of its tools.\r\n * To initialize when starting up your app:\r\n * ```ts\r\n * IModelApp.startup();\r\n * await FrontendDevTools.initialize();\r\n * ```\r\n * @beta\r\n */\r\n public static async initialize(): Promise<void> {\r\n if (this._initialized)\r\n return;\r\n\r\n this._initialized = true;\r\n\r\n const namespace = \"FrontendDevTools\";\r\n const namespacePromise = IModelApp.localization.registerNamespace(namespace);\r\n const tools = [\r\n AttachMapLayerTool,\r\n AttachMapOverlayTool,\r\n AttachArcGISMapLayerByUrlTool,\r\n AttachWmsMapLayerByUrlTool,\r\n AttachWmtsMapLayerByUrlTool,\r\n AttachTileURLMapLayerByUrlTool,\r\n AnimationIntervalTool,\r\n ApplyRenderingStyleTool,\r\n ApplyViewByIdTool,\r\n ApplyViewTool,\r\n ChangeBackgroundColorTool,\r\n ChangeCameraTool,\r\n ChangeEmphasisSettingsTool,\r\n ChangeFlashSettingsTool,\r\n ChangeHiliteSettingsTool,\r\n ChangePlanProjectionSettingsTool,\r\n ChangeUnitsTool,\r\n ChangeViewFlagsTool,\r\n ClearEffectsTool,\r\n ClearEmphasizedElementsTool,\r\n ClearIsolatedElementsTool,\r\n ClipColorTool,\r\n CompileShadersTool,\r\n DefaultTileSizeModifierTool,\r\n DetachMapLayersTool,\r\n DumpPlanProjectionSettingsTool,\r\n EdgeDetectionEffect,\r\n EmbossEffect,\r\n ElementIdFromSourceAspectIdTool,\r\n EmphasizeSelectedElementsTool,\r\n EmphasizeVisibleElementsTool,\r\n ExplosionEffect,\r\n FadeOutTool,\r\n FlipImageConfig,\r\n FlipImageEffect,\r\n FreezeSceneTool,\r\n GaussianBlurEffect,\r\n InspectElementTool,\r\n IsolateSelectedElementsTool,\r\n LensDistortionConfig,\r\n LensDistortionEffect,\r\n LoseWebGLContextTool,\r\n MapLayerTransparencyTool,\r\n MapLayerVisibilityTool,\r\n MapLayerSubLayerVisibilityTool,\r\n MapLayerZoomTool,\r\n MapBaseColorTool,\r\n MapBaseTransparencyTool,\r\n MapBaseVisibilityTool,\r\n MeasureTileLoadTimeTool,\r\n OverrideSubCategoryTool,\r\n OverrideSubCategoryPriorityTool,\r\n QueryScheduleScriptTool,\r\n RealityTransitionTool,\r\n ReorderMapLayers,\r\n ReportWebGLCompatibilityTool,\r\n SaturationConfig,\r\n SaturationEffect,\r\n SaveRenderingStyleTool,\r\n SaveViewTool,\r\n SelectElementsByIdTool,\r\n SetAASamplesTool,\r\n SetAspectRatioSkewTool,\r\n ToggleVolClassIntersect,\r\n SetMapBaseTool,\r\n SharpenEffect,\r\n SharpnessEffect,\r\n ShowTileVolumesTool,\r\n SkyCubeTool,\r\n SkySphereTool,\r\n SnowEffect,\r\n SourceAspectIdFromElementIdTool,\r\n TestClipStyleTool,\r\n Toggle3dManipulationsTool,\r\n ToggleDrawingGraphicsTool,\r\n ToggleDPIForLODTool,\r\n ToggleDrapeFrustumTool,\r\n ToggleFrustumSnapshotTool,\r\n TogglePrimitiveVisibilityTool,\r\n ToggleProjectExtentsTool,\r\n ToggleReadPixelsTool,\r\n ToggleSectionDrawingSpatialViewTool,\r\n ToggleSelectedViewFrustumTool,\r\n ToggleShadowFrustumTool,\r\n ToggleSkyboxTool,\r\n ToggleTileRequestDecorationTool,\r\n ToggleTileTreeBoundsDecorationTool,\r\n ToggleTileTreeReferencesTool,\r\n ToggleToolTipsTool,\r\n ToggleViewAttachmentBoundariesTool,\r\n ToggleViewAttachmentClipShapesTool,\r\n ToggleViewAttachmentsTool,\r\n ToggleWiremeshTool,\r\n ToggleRealityTileBounds,\r\n ToggleRealityTilePreload,\r\n ToggleRealityTileLogging,\r\n ToggleRealityTileFreeze,\r\n ToggleSectionCutTool,\r\n ToggleTerrainTool,\r\n UnsharpenEffect,\r\n ViewportAddRealityModel,\r\n ViewportTileSizeModifierTool,\r\n VignetteConfig,\r\n VignetteEffect,\r\n AttachRealityModelTool,\r\n DetachRealityModelTool,\r\n SaveRealityModelTool,\r\n SetGpuMemoryLimitTool,\r\n SetRealityModelLocateTool,\r\n SetRealityModelEmphasizedTool,\r\n SetRealityModelTransparencyTool,\r\n SetRealityModelColorTool,\r\n SetModelLocateTool,\r\n SetModelEmphasizedTool,\r\n SetModelTransparencyTool,\r\n SetModelColorTool,\r\n SetModelLineWeightTool,\r\n SetModelLineCodeTool,\r\n SetModelIgnoresMaterialsTool,\r\n ClearRealityModelAppearanceOverrides,\r\n ClearModelAppearanceOverrides,\r\n AttachCesiumAssetTool,\r\n ToggleOSMBuildingDisplay,\r\n SetHigherPriorityRealityModelMasking,\r\n SetMapHigherPriorityMasking,\r\n MaskRealityModelByModelTool,\r\n MaskRealityModelBySubCategoryTool,\r\n MaskRealityModelByElementTool,\r\n MaskRealityModelByExcludedElementTool,\r\n UnmaskRealityModelTool,\r\n MaskBackgroundMapByModelTool,\r\n MaskBackgroundMapBySubCategoryTool,\r\n MaskBackgroundMapByElementTool,\r\n MaskBackgroundMapByExcludedElementTool,\r\n UnmaskMapTool,\r\n WoWIgnoreBackgroundTool,\r\n ];\r\n\r\n for (const tool of tools)\r\n tool.register(namespace);\r\n\r\n return namespacePromise;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Explosion.d.ts","sourceRoot":"","sources":["../../../src/effects/Explosion.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,
|
|
1
|
+
{"version":3,"file":"Explosion.d.ts","sourceRoot":"","sources":["../../../src/effects/Explosion.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EACgI,IAAI,EAC1I,MAAM,sBAAsB,CAAC;AAyL9B;;GAEG;AACH,qBAAa,eAAgB,SAAQ,IAAI;IACvC,OAAuB,MAAM,SAAqB;IAElD,wEAAwE;IAClD,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;CAO9C"}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.ExplosionEffect = void 0;
|
|
11
11
|
const core_geometry_1 = require("@itwin/core-geometry");
|
|
12
|
+
const core_common_1 = require("@itwin/core-common");
|
|
12
13
|
const core_frontend_1 = require("@itwin/core-frontend");
|
|
13
14
|
const Random_1 = require("./Random");
|
|
14
15
|
/** Represents one particle in the system. */
|
|
@@ -141,10 +142,10 @@ class ParticleSystem {
|
|
|
141
142
|
}
|
|
142
143
|
static async addDecorator(iModel) {
|
|
143
144
|
// Note: The decorator takes ownership of the texture, and disposes of it when the decorator is disposed.
|
|
144
|
-
const image = await (0, core_frontend_1.imageElementFromUrl)(
|
|
145
|
+
const image = await (0, core_frontend_1.imageElementFromUrl)(`${core_frontend_1.IModelApp.publicPath}sprites/particle_explosion.png`);
|
|
145
146
|
const texture = core_frontend_1.IModelApp.renderSystem.createTexture({
|
|
146
147
|
ownership: "external",
|
|
147
|
-
image: { source: image, transparency:
|
|
148
|
+
image: { source: image, transparency: core_common_1.TextureTransparency.Mixed },
|
|
148
149
|
});
|
|
149
150
|
if (texture)
|
|
150
151
|
core_frontend_1.IModelApp.viewManager.addDecorator(new ParticleSystem(texture, iModel, (0, Random_1.randomIntegerInRange)(this.numEmissionsRange)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Explosion.js","sourceRoot":"","sources":["../../../src/effects/Explosion.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,wDAAkE;AAElE,wDAE8B;AAC9B,qCAAwG;AAExG,6CAA6C;AAC7C,MAAM,QAAQ;IAkBZ,YAAmB,QAAiB,EAAE,QAAkB,EAAE,QAAgB,EAAE,IAAY;QAbxF,sDAAsD;QAC/C,QAAG,GAAG,CAAC,CAAC;QAKf,yCAAyC;QAClC,iBAAY,GAAG,CAAC,CAAC;QAOtB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IATD,IAAW,CAAC,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,IAAW,CAAC,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,IAAW,CAAC,KAAK,OAAO,IAAI,CAA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AAO,EAAE,KAAK,IAAI,CAAC,WAAW,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAAC,IAAe;QAC/C,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,MAAwB;QACvD,yGAAyG;QACzG,MAAM,KAAK,GAAG,MAAM,IAAA,mCAAmB,EAAC,kCAAkC,CAAC,CAAC;QAC5E,MAAM,OAAO,GAAG,yBAAS,CAAC,YAAY,CAAC,aAAa,CAAC;YACnD,SAAS,EAAE,UAAU;YACrB,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,mCAAmB,CAAC,KAAK,EAAE;SAClE,CAAC,CAAC;QACH,IAAI,OAAO;YACT,yBAAS,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,IAAA,6BAAoB,EAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAC1H,CAAC;;AA1Ga,gCAAiB,GAAG,uBAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AA6G3D;;GAEG;AACH,MAAa,eAAgB,SAAQ,oBAAI;IAGvC,wEAAwE;IACxD,KAAK,CAAC,GAAG;QACvB,MAAM,EAAE,GAAG,yBAAS,CAAC,WAAW,CAAC,YAAY,CAAC;QAC9C,IAAI,EAAE;YACJ,MAAM,cAAc,CAAC,YAAY,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;QAE/C,OAAO,IAAI,CAAC;IACd,CAAC;;AAVH,0CAWC;AAVwB,sBAAM,GAAG,iBAAiB,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 { Id64String } from \"@itwin/core-bentley\";\r\nimport { Point3d, Range1d, Vector3d } from \"@itwin/core-geometry\";\r\nimport { RenderTexture } from \"@itwin/core-common\";\r\nimport {\r\n DecorateContext, GraphicType, HitDetail, imageElementFromUrl, IModelApp, IModelConnection, ParticleCollectionBuilder, ParticleProps, TextureTransparency, Tool,\r\n} from \"@itwin/core-frontend\";\r\nimport { randomFloat, randomFloatInRange, randomIntegerInRange, randomPositionInRange } from \"./Random\";\r\n\r\n/** Represents one particle in the system. */\r\nclass Particle implements ParticleProps {\r\n /** Current position in the particle system's local coordinate space. */\r\n public readonly position: Point3d;\r\n /** Current velocity in meters per second. */\r\n public readonly velocity: Vector3d;\r\n /** Current age in seconds, incremented each frame. */\r\n public age = 0;\r\n /** Maximum age in seconds. When `this.age` exceeds `this.lifetime`, the particle expires. */\r\n public readonly lifetime: number;\r\n /** Particle size in meters. */\r\n public size: number;\r\n /** Particle transparency in [0..255]. */\r\n public transparency = 0;\r\n\r\n public get x() { return this.position.x; }\r\n public get y() { return this.position.y; }\r\n public get z() { return this.position.z; }\r\n\r\n public constructor(position: Point3d, velocity: Vector3d, lifetime: number, size: number) {\r\n this.position = position;\r\n this.velocity = velocity;\r\n this.lifetime = lifetime;\r\n this.size = size;\r\n }\r\n\r\n public get isExpired() { return this.age >= this.lifetime; }\r\n}\r\n\r\n/** Emits particles in a sphere with its center at the origin.\r\n * Each particle is emitted from the center of the sphere with random velocity toward the surface of the sphere.\r\n */\r\nclass ParticleEmitter {\r\n /** Range from which each particle's initial speed in meters per second will be selected. */\r\n public readonly speedRange = Range1d.createXX(1, 2);\r\n /** Range from which each particle's lifetime in seconds will be selected. */\r\n public readonly lifetimeRange = Range1d.createXX(5, 10);\r\n /** Range from which each particle's size in meters will be selected. */\r\n public readonly sizeRange = Range1d.createXX(0.2, 1.0);\r\n /** Range from which the number of particles emitted will be selected. */\r\n public numParticlesRange = Range1d.createXX(1600, 2200);\r\n\r\n /** Emit an explosion of particles from the center of the sphere. */\r\n public emit(): Particle[] {\r\n const particles = [];\r\n const numParticles = randomIntegerInRange(this.numParticlesRange);\r\n for (let i = 0; i < numParticles; i++) {\r\n const velocity = new Vector3d(randomFloat(-1.0, 1.0), randomFloat(-1.0, 1.0), randomFloat(-1.0, 1.0));\r\n velocity.normalizeInPlace();\r\n velocity.scaleInPlace(randomFloatInRange(this.speedRange));\r\n\r\n const lifetime = randomFloatInRange(this.lifetimeRange);\r\n const size = randomFloatInRange(this.sizeRange);\r\n particles.push(new Particle(new Point3d(0, 0, 0), velocity, lifetime, size));\r\n }\r\n\r\n return particles;\r\n }\r\n}\r\n\r\nclass ParticleSystem {\r\n private readonly _origin: Point3d;\r\n private readonly _pickableId: Id64String;\r\n private readonly _emitter = new ParticleEmitter();\r\n private _numEmissions: number;\r\n private readonly _texture: RenderTexture;\r\n private _lastUpdateTime: number;\r\n private _particles: Particle[] = [];\r\n private readonly _scratchVector3d = new Vector3d();\r\n private _dispose?: VoidFunction;\r\n /** Acceleration in Z applied to particles, in meters per second squared. */\r\n public gravity = -3;\r\n\r\n public static numEmissionsRange = Range1d.createXX(1, 5);\r\n\r\n public constructor(texture: RenderTexture, iModel: IModelConnection, numEmissions: number) {\r\n this._texture = texture;\r\n this._pickableId = iModel.transientIds.next;\r\n this._numEmissions = numEmissions;\r\n this._lastUpdateTime = Date.now();\r\n\r\n this._origin = randomPositionInRange(iModel.projectExtents);\r\n\r\n this._dispose = iModel.onClose.addListener(() => this.dispose());\r\n }\r\n\r\n public dispose(): void {\r\n if (this._dispose) {\r\n this._dispose();\r\n this._dispose = undefined;\r\n }\r\n\r\n IModelApp.viewManager.dropDecorator(this);\r\n this._texture.dispose();\r\n }\r\n\r\n public update(): void {\r\n const now = Date.now();\r\n let deltaMillis = now - this._lastUpdateTime;\r\n deltaMillis = Math.min(100, deltaMillis);\r\n this._lastUpdateTime = now;\r\n\r\n let numParticles = this._particles.length;\r\n if (numParticles === 0) {\r\n this._numEmissions--;\r\n if (this._numEmissions < 0)\r\n this.dispose();\r\n else\r\n this._particles = this._emitter.emit();\r\n\r\n return;\r\n }\r\n\r\n const elapsedSeconds = deltaMillis / 1000;\r\n for (let i = 0; i < numParticles; i++) {\r\n const particle = this._particles[i];\r\n this.updateParticle(particle, elapsedSeconds);\r\n if (particle.isExpired) {\r\n this._particles[i] = this._particles[numParticles - 1];\r\n --i;\r\n --numParticles;\r\n }\r\n }\r\n\r\n this._particles.length = numParticles;\r\n }\r\n\r\n private updateParticle(particle: Particle, elapsedSeconds: number): void {\r\n const velocity = particle.velocity.clone(this._scratchVector3d);\r\n velocity.scale(elapsedSeconds, velocity);\r\n velocity.z += elapsedSeconds * this.gravity;\r\n particle.position.addInPlace(velocity);\r\n particle.transparency = 255 * (particle.age / particle.lifetime);\r\n\r\n particle.age += elapsedSeconds;\r\n }\r\n\r\n public decorate(context: DecorateContext): void {\r\n if (!context.viewport.view.isSpatialView())\r\n return;\r\n\r\n this.update();\r\n\r\n const builder = ParticleCollectionBuilder.create({\r\n viewport: context.viewport,\r\n texture: this._texture,\r\n size: (this._emitter.sizeRange.high - this._emitter.sizeRange.low) / 2,\r\n transparency: 0,\r\n origin: this._origin,\r\n pickableId: this._pickableId,\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.WorldDecoration, graphic);\r\n context.viewport.onRender.addOnce((vp) => vp.invalidateDecorations());\r\n }\r\n }\r\n\r\n public testDecorationHit(id: Id64String): boolean {\r\n return id === this._pickableId;\r\n }\r\n\r\n public async getDecorationToolTip(_hit: HitDetail): Promise<HTMLElement | string> {\r\n return \"Explosion effect\";\r\n }\r\n\r\n public static async addDecorator(iModel: IModelConnection): Promise<void> {\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(\"./sprites/particle_explosion.png\");\r\n const texture = IModelApp.renderSystem.createTexture({\r\n ownership: \"external\",\r\n image: { source: image, transparency: TextureTransparency.Mixed },\r\n });\r\n if (texture)\r\n IModelApp.viewManager.addDecorator(new ParticleSystem(texture, iModel, randomIntegerInRange(this.numEmissionsRange)));\r\n }\r\n}\r\n\r\n/** This tool applies an explosion particle effect used for testing [ParticleCollectionBuilder]($frontend).\r\n * @beta\r\n */\r\nexport class ExplosionEffect extends Tool {\r\n public static override toolId = \"ExplosionEffect\";\r\n\r\n /** This method runs the tool, applying an explosion particle effect. */\r\n public override async run(): Promise<boolean> {\r\n const vp = IModelApp.viewManager.selectedView;\r\n if (vp)\r\n await ParticleSystem.addDecorator(vp.iModel);\r\n\r\n return true;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Explosion.js","sourceRoot":"","sources":["../../../src/effects/Explosion.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,wDAAkE;AAClE,oDAAwE;AACxE,wDAE8B;AAC9B,qCAAwG;AAExG,6CAA6C;AAC7C,MAAM,QAAQ;IAkBZ,YAAmB,QAAiB,EAAE,QAAkB,EAAE,QAAgB,EAAE,IAAY;QAbxF,sDAAsD;QAC/C,QAAG,GAAG,CAAC,CAAC;QAKf,yCAAyC;QAClC,iBAAY,GAAG,CAAC,CAAC;QAOtB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IATD,IAAW,CAAC,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,IAAW,CAAC,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,IAAW,CAAC,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAS1C,IAAW,SAAS,KAAK,OAAO,IAAI,CAAC,G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,IAAe;QAC/C,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,MAAwB;QACvD,yGAAyG;QACzG,MAAM,KAAK,GAAG,MAAM,IAAA,mCAAmB,EAAC,GAAG,yBAAS,CAAC,UAAU,gCAAgC,CAAC,CAAC;QACjG,MAAM,OAAO,GAAG,yBAAS,CAAC,YAAY,CAAC,aAAa,CAAC;YACnD,SAAS,EAAE,UAAU;YACrB,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,iCAAmB,CAAC,KAAK,EAAE;SAClE,CAAC,CAAC;QACH,IAAI,OAAO;YACT,yBAAS,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,IAAA,6BAAoB,EAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAC1H,CAAC;;AA1Ga,gCAAiB,GAAG,uBAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AA6G3D;;GAEG;AACH,MAAa,eAAgB,SAAQ,oBAAI;IAGvC,wEAAwE;IACxD,KAAK,CAAC,GAAG;QACvB,MAAM,EAAE,GAAG,yBAAS,CAAC,WAAW,CAAC,YAAY,CAAC;QAC9C,IAAI,EAAE;YACJ,MAAM,cAAc,CAAC,YAAY,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;QAE/C,OAAO,IAAI,CAAC;IACd,CAAC;;AAVH,0CAWC;AAVwB,sBAAM,GAAG,iBAAiB,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 { Id64String } from \"@itwin/core-bentley\";\r\nimport { Point3d, Range1d, Vector3d } from \"@itwin/core-geometry\";\r\nimport { RenderTexture, TextureTransparency } from \"@itwin/core-common\";\r\nimport {\r\n DecorateContext, GraphicType, HitDetail, imageElementFromUrl, IModelApp, IModelConnection, ParticleCollectionBuilder, ParticleProps, Tool,\r\n} from \"@itwin/core-frontend\";\r\nimport { randomFloat, randomFloatInRange, randomIntegerInRange, randomPositionInRange } from \"./Random\";\r\n\r\n/** Represents one particle in the system. */\r\nclass Particle implements ParticleProps {\r\n /** Current position in the particle system's local coordinate space. */\r\n public readonly position: Point3d;\r\n /** Current velocity in meters per second. */\r\n public readonly velocity: Vector3d;\r\n /** Current age in seconds, incremented each frame. */\r\n public age = 0;\r\n /** Maximum age in seconds. When `this.age` exceeds `this.lifetime`, the particle expires. */\r\n public readonly lifetime: number;\r\n /** Particle size in meters. */\r\n public size: number;\r\n /** Particle transparency in [0..255]. */\r\n public transparency = 0;\r\n\r\n public get x() { return this.position.x; }\r\n public get y() { return this.position.y; }\r\n public get z() { return this.position.z; }\r\n\r\n public constructor(position: Point3d, velocity: Vector3d, lifetime: number, size: number) {\r\n this.position = position;\r\n this.velocity = velocity;\r\n this.lifetime = lifetime;\r\n this.size = size;\r\n }\r\n\r\n public get isExpired() { return this.age >= this.lifetime; }\r\n}\r\n\r\n/** Emits particles in a sphere with its center at the origin.\r\n * Each particle is emitted from the center of the sphere with random velocity toward the surface of the sphere.\r\n */\r\nclass ParticleEmitter {\r\n /** Range from which each particle's initial speed in meters per second will be selected. */\r\n public readonly speedRange = Range1d.createXX(1, 2);\r\n /** Range from which each particle's lifetime in seconds will be selected. */\r\n public readonly lifetimeRange = Range1d.createXX(5, 10);\r\n /** Range from which each particle's size in meters will be selected. */\r\n public readonly sizeRange = Range1d.createXX(0.2, 1.0);\r\n /** Range from which the number of particles emitted will be selected. */\r\n public numParticlesRange = Range1d.createXX(1600, 2200);\r\n\r\n /** Emit an explosion of particles from the center of the sphere. */\r\n public emit(): Particle[] {\r\n const particles = [];\r\n const numParticles = randomIntegerInRange(this.numParticlesRange);\r\n for (let i = 0; i < numParticles; i++) {\r\n const velocity = new Vector3d(randomFloat(-1.0, 1.0), randomFloat(-1.0, 1.0), randomFloat(-1.0, 1.0));\r\n velocity.normalizeInPlace();\r\n velocity.scaleInPlace(randomFloatInRange(this.speedRange));\r\n\r\n const lifetime = randomFloatInRange(this.lifetimeRange);\r\n const size = randomFloatInRange(this.sizeRange);\r\n particles.push(new Particle(new Point3d(0, 0, 0), velocity, lifetime, size));\r\n }\r\n\r\n return particles;\r\n }\r\n}\r\n\r\nclass ParticleSystem {\r\n private readonly _origin: Point3d;\r\n private readonly _pickableId: Id64String;\r\n private readonly _emitter = new ParticleEmitter();\r\n private _numEmissions: number;\r\n private readonly _texture: RenderTexture;\r\n private _lastUpdateTime: number;\r\n private _particles: Particle[] = [];\r\n private readonly _scratchVector3d = new Vector3d();\r\n private _dispose?: VoidFunction;\r\n /** Acceleration in Z applied to particles, in meters per second squared. */\r\n public gravity = -3;\r\n\r\n public static numEmissionsRange = Range1d.createXX(1, 5);\r\n\r\n public constructor(texture: RenderTexture, iModel: IModelConnection, numEmissions: number) {\r\n this._texture = texture;\r\n this._pickableId = iModel.transientIds.next;\r\n this._numEmissions = numEmissions;\r\n this._lastUpdateTime = Date.now();\r\n\r\n this._origin = randomPositionInRange(iModel.projectExtents);\r\n\r\n this._dispose = iModel.onClose.addListener(() => this.dispose());\r\n }\r\n\r\n public dispose(): void {\r\n if (this._dispose) {\r\n this._dispose();\r\n this._dispose = undefined;\r\n }\r\n\r\n IModelApp.viewManager.dropDecorator(this);\r\n this._texture.dispose();\r\n }\r\n\r\n public update(): void {\r\n const now = Date.now();\r\n let deltaMillis = now - this._lastUpdateTime;\r\n deltaMillis = Math.min(100, deltaMillis);\r\n this._lastUpdateTime = now;\r\n\r\n let numParticles = this._particles.length;\r\n if (numParticles === 0) {\r\n this._numEmissions--;\r\n if (this._numEmissions < 0)\r\n this.dispose();\r\n else\r\n this._particles = this._emitter.emit();\r\n\r\n return;\r\n }\r\n\r\n const elapsedSeconds = deltaMillis / 1000;\r\n for (let i = 0; i < numParticles; i++) {\r\n const particle = this._particles[i];\r\n this.updateParticle(particle, elapsedSeconds);\r\n if (particle.isExpired) {\r\n this._particles[i] = this._particles[numParticles - 1];\r\n --i;\r\n --numParticles;\r\n }\r\n }\r\n\r\n this._particles.length = numParticles;\r\n }\r\n\r\n private updateParticle(particle: Particle, elapsedSeconds: number): void {\r\n const velocity = particle.velocity.clone(this._scratchVector3d);\r\n velocity.scale(elapsedSeconds, velocity);\r\n velocity.z += elapsedSeconds * this.gravity;\r\n particle.position.addInPlace(velocity);\r\n particle.transparency = 255 * (particle.age / particle.lifetime);\r\n\r\n particle.age += elapsedSeconds;\r\n }\r\n\r\n public decorate(context: DecorateContext): void {\r\n if (!context.viewport.view.isSpatialView())\r\n return;\r\n\r\n this.update();\r\n\r\n const builder = ParticleCollectionBuilder.create({\r\n viewport: context.viewport,\r\n texture: this._texture,\r\n size: (this._emitter.sizeRange.high - this._emitter.sizeRange.low) / 2,\r\n transparency: 0,\r\n origin: this._origin,\r\n pickableId: this._pickableId,\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.WorldDecoration, graphic);\r\n context.viewport.onRender.addOnce((vp) => vp.invalidateDecorations());\r\n }\r\n }\r\n\r\n public testDecorationHit(id: Id64String): boolean {\r\n return id === this._pickableId;\r\n }\r\n\r\n public async getDecorationToolTip(_hit: HitDetail): Promise<HTMLElement | string> {\r\n return \"Explosion effect\";\r\n }\r\n\r\n public static async addDecorator(iModel: IModelConnection): Promise<void> {\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_explosion.png`);\r\n const texture = IModelApp.renderSystem.createTexture({\r\n ownership: \"external\",\r\n image: { source: image, transparency: TextureTransparency.Mixed },\r\n });\r\n if (texture)\r\n IModelApp.viewManager.addDecorator(new ParticleSystem(texture, iModel, randomIntegerInRange(this.numEmissionsRange)));\r\n }\r\n}\r\n\r\n/** This tool applies an explosion particle effect used for testing [ParticleCollectionBuilder]($frontend).\r\n * @beta\r\n */\r\nexport class ExplosionEffect extends Tool {\r\n public static override toolId = \"ExplosionEffect\";\r\n\r\n /** This method runs the tool, applying an explosion particle effect. */\r\n public override async run(): Promise<boolean> {\r\n const vp = IModelApp.viewManager.selectedView;\r\n if (vp)\r\n await ParticleSystem.addDecorator(vp.iModel);\r\n\r\n return true;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Snow.d.ts","sourceRoot":"","sources":["../../../src/effects/Snow.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAW,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE3E,OAAO,EACL,eAAe,EAAE,SAAS,EAA0E,aAAa,
|
|
1
|
+
{"version":3,"file":"Snow.d.ts","sourceRoot":"","sources":["../../../src/effects/Snow.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAW,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE3E,OAAO,EACL,eAAe,EAAE,SAAS,EAA0E,aAAa,EAAE,IAAI,EAAE,QAAQ,EAClI,MAAM,sBAAsB,CAAC;AAI9B;;;GAGG;AACH,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,oDAAoD;IACpD,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IAEV,8CAA8C;IAC9C,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,sKAAsK;IACtK,YAAY,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,SAAS,EAAE,OAAO,CAAC;IACnB,wEAAwE;IACxE,iBAAiB,EAAE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@ -10,6 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.SnowEffect = exports.SnowDecorator = void 0;
|
|
11
11
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
12
|
const core_geometry_1 = require("@itwin/core-geometry");
|
|
13
|
+
const core_common_1 = require("@itwin/core-common");
|
|
13
14
|
const core_frontend_1 = require("@itwin/core-frontend");
|
|
14
15
|
const parseToggle_1 = require("../tools/parseToggle");
|
|
15
16
|
const Random_1 = require("./Random");
|
|
@@ -153,10 +154,10 @@ class SnowDecorator {
|
|
|
153
154
|
else if (undefined === decorator && enable) {
|
|
154
155
|
// Create a texture to use for the particles.
|
|
155
156
|
// Note: the decorator takes ownership of the texture, and disposes of it when the decorator is disposed.
|
|
156
|
-
const image = await (0, core_frontend_1.imageElementFromUrl)(
|
|
157
|
+
const image = await (0, core_frontend_1.imageElementFromUrl)(`${core_frontend_1.IModelApp.publicPath}sprites/particle_snow.png`);
|
|
157
158
|
const texture = core_frontend_1.IModelApp.renderSystem.createTexture({
|
|
158
159
|
ownership: "external",
|
|
159
|
-
image: { source: image, transparency:
|
|
160
|
+
image: { source: image, transparency: core_common_1.TextureTransparency.Mixed },
|
|
160
161
|
});
|
|
161
162
|
new SnowDecorator(viewport, texture);
|
|
162
163
|
}
|
|
@@ -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;AAE3E,wDAE8B;AAC9B,sDAAmD;AACnD,qCAAsD;AAkCtD,+EAA+E;AAC/E,MAAM,iBAAiB,GAAe;IACpC,YAAY,EAAE,IAAI;IAClB,SAAS,EAAE,uBAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC;IAClC,iBAAiB,EAAE,uBAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC;IAC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;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 } from \"@itwin/core-common\";\r\nimport {\r\n DecorateContext, Decorator, GraphicType, imageElementFromUrl, IModelApp, ParticleCollectionBuilder, ParticleProps, TextureTransparency, 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(\"./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;AAkCtD,+EAA+E;AAC/E,MAAM,iBAAiB,GAAe;IACpC,YAAY,EAAE,IAAI;IAClB,SAAS,EAAE,uBAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC;IAClC,iBAAiB,EAAE,uBAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC;IAC1C,aAAa,EAAE,IAAI,uBAAO,CAAC,CAA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AM,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"]}
|
|
@@ -57,7 +57,7 @@ export * from "./widgets/TileMemoryBreakdown";
|
|
|
57
57
|
export * from "./widgets/TileStatisticsTracker";
|
|
58
58
|
export * from "./widgets/ToolSettingsTracker";
|
|
59
59
|
/** @docs-package-description
|
|
60
|
-
* The frontend-devtools package contains various tools and widgets for monitoring and debugging the front-end state of an
|
|
60
|
+
* The frontend-devtools package contains various tools and widgets for monitoring and debugging the front-end state of an iTwin.js application.
|
|
61
61
|
*/
|
|
62
62
|
/**
|
|
63
63
|
* @docs-group-description Widgets
|
|
@@ -73,7 +73,7 @@ __exportStar(require("./widgets/TileMemoryBreakdown"), exports);
|
|
|
73
73
|
__exportStar(require("./widgets/TileStatisticsTracker"), exports);
|
|
74
74
|
__exportStar(require("./widgets/ToolSettingsTracker"), exports);
|
|
75
75
|
/** @docs-package-description
|
|
76
|
-
* The frontend-devtools package contains various tools and widgets for monitoring and debugging the front-end state of an
|
|
76
|
+
* The frontend-devtools package contains various tools and widgets for monitoring and debugging the front-end state of an iTwin.js application.
|
|
77
77
|
*/
|
|
78
78
|
/**
|
|
79
79
|
* @docs-group-description Widgets
|