@itwin/frontend-devtools 3.0.0-dev.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +723 -0
- package/LICENSE.md +9 -0
- package/README.md +321 -0
- package/lib/ClipboardUtilities.d.ts +9 -0
- package/lib/ClipboardUtilities.d.ts.map +1 -0
- package/lib/ClipboardUtilities.js +27 -0
- package/lib/ClipboardUtilities.js.map +1 -0
- package/lib/FrontEndDevTools.d.ts +19 -0
- package/lib/FrontEndDevTools.d.ts.map +1 -0
- package/lib/FrontEndDevTools.js +203 -0
- package/lib/FrontEndDevTools.js.map +1 -0
- package/lib/effects/Convolution.d.ts +69 -0
- package/lib/effects/Convolution.d.ts.map +1 -0
- package/lib/effects/Convolution.js +166 -0
- package/lib/effects/Convolution.js.map +1 -0
- package/lib/effects/EffectTools.d.ts +34 -0
- package/lib/effects/EffectTools.d.ts.map +1 -0
- package/lib/effects/EffectTools.js +69 -0
- package/lib/effects/EffectTools.js.map +1 -0
- package/lib/effects/Explosion.d.ts +13 -0
- package/lib/effects/Explosion.d.ts.map +1 -0
- package/lib/effects/Explosion.js +168 -0
- package/lib/effects/Explosion.js.map +1 -0
- package/lib/effects/FlipImage.d.ts +31 -0
- package/lib/effects/FlipImage.d.ts.map +1 -0
- package/lib/effects/FlipImage.js +100 -0
- package/lib/effects/FlipImage.js.map +1 -0
- package/lib/effects/LensDistortion.d.ts +35 -0
- package/lib/effects/LensDistortion.d.ts.map +1 -0
- package/lib/effects/LensDistortion.js +110 -0
- package/lib/effects/LensDistortion.js.map +1 -0
- package/lib/effects/Random.d.ts +25 -0
- package/lib/effects/Random.d.ts.map +1 -0
- package/lib/effects/Random.js +50 -0
- package/lib/effects/Random.js.map +1 -0
- package/lib/effects/Saturation.d.ts +31 -0
- package/lib/effects/Saturation.d.ts.map +1 -0
- package/lib/effects/Saturation.js +86 -0
- package/lib/effects/Saturation.js.map +1 -0
- package/lib/effects/Snow.d.ts +77 -0
- package/lib/effects/Snow.d.ts.map +1 -0
- package/lib/effects/Snow.js +187 -0
- package/lib/effects/Snow.js.map +1 -0
- package/lib/effects/Vignette.d.ts +40 -0
- package/lib/effects/Vignette.d.ts.map +1 -0
- package/lib/effects/Vignette.js +109 -0
- package/lib/effects/Vignette.js.map +1 -0
- package/lib/frontend-devtools.d.ts +82 -0
- package/lib/frontend-devtools.d.ts.map +1 -0
- package/lib/frontend-devtools.js +98 -0
- package/lib/frontend-devtools.js.map +1 -0
- package/lib/public/locales/en/FrontendDevTools.json +449 -0
- package/lib/public/sprites/particle_explosion.png +0 -0
- package/lib/public/sprites/particle_flame.png +0 -0
- package/lib/public/sprites/particle_snow.png +0 -0
- package/lib/tools/AnimationIntervalTool.d.ts +16 -0
- package/lib/tools/AnimationIntervalTool.d.ts.map +1 -0
- package/lib/tools/AnimationIntervalTool.js +31 -0
- package/lib/tools/AnimationIntervalTool.js.map +1 -0
- package/lib/tools/ChangeUnitsTool.d.ts +16 -0
- package/lib/tools/ChangeUnitsTool.d.ts.map +1 -0
- package/lib/tools/ChangeUnitsTool.js +42 -0
- package/lib/tools/ChangeUnitsTool.js.map +1 -0
- package/lib/tools/ClipTools.d.ts +68 -0
- package/lib/tools/ClipTools.d.ts.map +1 -0
- package/lib/tools/ClipTools.js +162 -0
- package/lib/tools/ClipTools.js.map +1 -0
- package/lib/tools/DisplayStyleTools.d.ts +99 -0
- package/lib/tools/DisplayStyleTools.d.ts.map +1 -0
- package/lib/tools/DisplayStyleTools.js +242 -0
- package/lib/tools/DisplayStyleTools.js.map +1 -0
- package/lib/tools/EmphasizeElementsTool.d.ts +61 -0
- package/lib/tools/EmphasizeElementsTool.d.ts.map +1 -0
- package/lib/tools/EmphasizeElementsTool.js +155 -0
- package/lib/tools/EmphasizeElementsTool.js.map +1 -0
- package/lib/tools/FrustumDecoration.d.ts +58 -0
- package/lib/tools/FrustumDecoration.d.ts.map +1 -0
- package/lib/tools/FrustumDecoration.js +372 -0
- package/lib/tools/FrustumDecoration.js.map +1 -0
- package/lib/tools/InspectElementTool.d.ts +42 -0
- package/lib/tools/InspectElementTool.d.ts.map +1 -0
- package/lib/tools/InspectElementTool.js +185 -0
- package/lib/tools/InspectElementTool.js.map +1 -0
- package/lib/tools/MapLayerTool.d.ts +248 -0
- package/lib/tools/MapLayerTool.d.ts.map +1 -0
- package/lib/tools/MapLayerTool.js +462 -0
- package/lib/tools/MapLayerTool.js.map +1 -0
- package/lib/tools/MeasureTileLoadTime.d.ts +13 -0
- package/lib/tools/MeasureTileLoadTime.d.ts.map +1 -0
- package/lib/tools/MeasureTileLoadTime.js +61 -0
- package/lib/tools/MeasureTileLoadTime.js.map +1 -0
- package/lib/tools/ModelAppearanceTools.d.ts +87 -0
- package/lib/tools/ModelAppearanceTools.d.ts.map +1 -0
- package/lib/tools/ModelAppearanceTools.js +184 -0
- package/lib/tools/ModelAppearanceTools.js.map +1 -0
- package/lib/tools/PlanProjectionTools.d.ts +41 -0
- package/lib/tools/PlanProjectionTools.d.ts.map +1 -0
- package/lib/tools/PlanProjectionTools.js +150 -0
- package/lib/tools/PlanProjectionTools.js.map +1 -0
- package/lib/tools/PlanarMaskTools.d.ts +182 -0
- package/lib/tools/PlanarMaskTools.d.ts.map +1 -0
- package/lib/tools/PlanarMaskTools.js +366 -0
- package/lib/tools/PlanarMaskTools.js.map +1 -0
- package/lib/tools/ProjectExtents.d.ts +41 -0
- package/lib/tools/ProjectExtents.d.ts.map +1 -0
- package/lib/tools/ProjectExtents.js +108 -0
- package/lib/tools/ProjectExtents.js.map +1 -0
- package/lib/tools/RealityModelTools.d.ts +117 -0
- package/lib/tools/RealityModelTools.d.ts.map +1 -0
- package/lib/tools/RealityModelTools.js +269 -0
- package/lib/tools/RealityModelTools.js.map +1 -0
- package/lib/tools/RealityTransitionTool.d.ts +26 -0
- package/lib/tools/RealityTransitionTool.d.ts.map +1 -0
- package/lib/tools/RealityTransitionTool.js +110 -0
- package/lib/tools/RealityTransitionTool.js.map +1 -0
- package/lib/tools/RenderSystemTools.d.ts +46 -0
- package/lib/tools/RenderSystemTools.d.ts.map +1 -0
- package/lib/tools/RenderSystemTools.js +81 -0
- package/lib/tools/RenderSystemTools.js.map +1 -0
- package/lib/tools/RenderTargetTools.d.ts +101 -0
- package/lib/tools/RenderTargetTools.d.ts.map +1 -0
- package/lib/tools/RenderTargetTools.js +167 -0
- package/lib/tools/RenderTargetTools.js.map +1 -0
- package/lib/tools/ReportWebGLCompatibilityTool.d.ts +12 -0
- package/lib/tools/ReportWebGLCompatibilityTool.d.ts.map +1 -0
- package/lib/tools/ReportWebGLCompatibilityTool.js +31 -0
- package/lib/tools/ReportWebGLCompatibilityTool.js.map +1 -0
- package/lib/tools/SavedViews.d.ts +47 -0
- package/lib/tools/SavedViews.d.ts.map +1 -0
- package/lib/tools/SavedViews.js +137 -0
- package/lib/tools/SavedViews.js.map +1 -0
- package/lib/tools/SelectionTools.d.ts +17 -0
- package/lib/tools/SelectionTools.d.ts.map +1 -0
- package/lib/tools/SelectionTools.js +28 -0
- package/lib/tools/SelectionTools.js.map +1 -0
- package/lib/tools/SetGpuMemoryLimitTool.d.ts +16 -0
- package/lib/tools/SetGpuMemoryLimitTool.d.ts.map +1 -0
- package/lib/tools/SetGpuMemoryLimitTool.js +34 -0
- package/lib/tools/SetGpuMemoryLimitTool.js.map +1 -0
- package/lib/tools/SourceAspectIdTools.d.ts +41 -0
- package/lib/tools/SourceAspectIdTools.d.ts.map +1 -0
- package/lib/tools/SourceAspectIdTools.js +105 -0
- package/lib/tools/SourceAspectIdTools.js.map +1 -0
- package/lib/tools/TileRequestDecoration.d.ts +13 -0
- package/lib/tools/TileRequestDecoration.d.ts.map +1 -0
- package/lib/tools/TileRequestDecoration.js +84 -0
- package/lib/tools/TileRequestDecoration.js.map +1 -0
- package/lib/tools/TileTreeBoundsDecoration.d.ts +12 -0
- package/lib/tools/TileTreeBoundsDecoration.d.ts.map +1 -0
- package/lib/tools/TileTreeBoundsDecoration.js +75 -0
- package/lib/tools/TileTreeBoundsDecoration.js.map +1 -0
- package/lib/tools/ToolTipProvider.d.ts +16 -0
- package/lib/tools/ToolTipProvider.d.ts.map +1 -0
- package/lib/tools/ToolTipProvider.js +67 -0
- package/lib/tools/ToolTipProvider.js.map +1 -0
- package/lib/tools/ViewportTools.d.ts +194 -0
- package/lib/tools/ViewportTools.d.ts.map +1 -0
- package/lib/tools/ViewportTools.js +451 -0
- package/lib/tools/ViewportTools.js.map +1 -0
- package/lib/tools/parseArgs.d.ts +24 -0
- package/lib/tools/parseArgs.d.ts.map +1 -0
- package/lib/tools/parseArgs.js +52 -0
- package/lib/tools/parseArgs.js.map +1 -0
- package/lib/tools/parseBoolean.d.ts +9 -0
- package/lib/tools/parseBoolean.d.ts.map +1 -0
- package/lib/tools/parseBoolean.js +27 -0
- package/lib/tools/parseBoolean.js.map +1 -0
- package/lib/tools/parseToggle.d.ts +9 -0
- package/lib/tools/parseToggle.d.ts.map +1 -0
- package/lib/tools/parseToggle.js +26 -0
- package/lib/tools/parseToggle.js.map +1 -0
- package/lib/ui/Button.d.ts +30 -0
- package/lib/ui/Button.d.ts.map +1 -0
- package/lib/ui/Button.js +27 -0
- package/lib/ui/Button.js.map +1 -0
- package/lib/ui/CheckBox.d.ts +24 -0
- package/lib/ui/CheckBox.d.ts.map +1 -0
- package/lib/ui/CheckBox.js +28 -0
- package/lib/ui/CheckBox.js.map +1 -0
- package/lib/ui/ColorInput.d.ts +28 -0
- package/lib/ui/ColorInput.d.ts.map +1 -0
- package/lib/ui/ColorInput.js +54 -0
- package/lib/ui/ColorInput.js.map +1 -0
- package/lib/ui/ComboBox.d.ts +29 -0
- package/lib/ui/ComboBox.d.ts.map +1 -0
- package/lib/ui/ComboBox.js +43 -0
- package/lib/ui/ComboBox.js.map +1 -0
- package/lib/ui/DataList.d.ts +28 -0
- package/lib/ui/DataList.d.ts.map +1 -0
- package/lib/ui/DataList.js +40 -0
- package/lib/ui/DataList.js.map +1 -0
- package/lib/ui/NestedMenu.d.ts +20 -0
- package/lib/ui/NestedMenu.d.ts.map +1 -0
- package/lib/ui/NestedMenu.js +47 -0
- package/lib/ui/NestedMenu.js.map +1 -0
- package/lib/ui/NumericInput.d.ts +35 -0
- package/lib/ui/NumericInput.d.ts.map +1 -0
- package/lib/ui/NumericInput.js +60 -0
- package/lib/ui/NumericInput.js.map +1 -0
- package/lib/ui/RadioBox.d.ts +29 -0
- package/lib/ui/RadioBox.d.ts.map +1 -0
- package/lib/ui/RadioBox.js +77 -0
- package/lib/ui/RadioBox.js.map +1 -0
- package/lib/ui/Slider.d.ts +25 -0
- package/lib/ui/Slider.d.ts.map +1 -0
- package/lib/ui/Slider.js +33 -0
- package/lib/ui/Slider.js.map +1 -0
- package/lib/ui/TextBox.d.ts +33 -0
- package/lib/ui/TextBox.d.ts.map +1 -0
- package/lib/ui/TextBox.js +57 -0
- package/lib/ui/TextBox.js.map +1 -0
- package/lib/widgets/DiagnosticsPanel.d.ts +36 -0
- package/lib/widgets/DiagnosticsPanel.d.ts.map +1 -0
- package/lib/widgets/DiagnosticsPanel.js +76 -0
- package/lib/widgets/DiagnosticsPanel.js.map +1 -0
- package/lib/widgets/FpsTracker.d.ts +20 -0
- package/lib/widgets/FpsTracker.d.ts.map +1 -0
- package/lib/widgets/FpsTracker.js +57 -0
- package/lib/widgets/FpsTracker.js.map +1 -0
- package/lib/widgets/GpuProfiler.d.ts +17 -0
- package/lib/widgets/GpuProfiler.d.ts.map +1 -0
- package/lib/widgets/GpuProfiler.js +193 -0
- package/lib/widgets/GpuProfiler.js.map +1 -0
- package/lib/widgets/KeyinField.d.ts +62 -0
- package/lib/widgets/KeyinField.d.ts.map +1 -0
- package/lib/widgets/KeyinField.js +188 -0
- package/lib/widgets/KeyinField.js.map +1 -0
- package/lib/widgets/MemoryTracker.d.ts +28 -0
- package/lib/widgets/MemoryTracker.d.ts.map +1 -0
- package/lib/widgets/MemoryTracker.js +244 -0
- package/lib/widgets/MemoryTracker.js.map +1 -0
- package/lib/widgets/TileMemoryBreakdown.d.ts +31 -0
- package/lib/widgets/TileMemoryBreakdown.d.ts.map +1 -0
- package/lib/widgets/TileMemoryBreakdown.js +205 -0
- package/lib/widgets/TileMemoryBreakdown.js.map +1 -0
- package/lib/widgets/TileStatisticsTracker.d.ts +22 -0
- package/lib/widgets/TileStatisticsTracker.d.ts.map +1 -0
- package/lib/widgets/TileStatisticsTracker.js +143 -0
- package/lib/widgets/TileStatisticsTracker.js.map +1 -0
- package/lib/widgets/ToolSettingsTracker.d.ts +10 -0
- package/lib/widgets/ToolSettingsTracker.d.ts.map +1 -0
- package/lib/widgets/ToolSettingsTracker.js +182 -0
- package/lib/widgets/ToolSettingsTracker.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Effects
|
|
3
|
+
*/
|
|
4
|
+
import { ScreenSpaceEffectBuilder, Tool } from "@itwin/core-frontend";
|
|
5
|
+
import { AddEffectTool } from "./EffectTools";
|
|
6
|
+
/** An extremely simple and mostly useless effect intended to demonstrate the basics of creating a screen-space effect.
|
|
7
|
+
* It flips the Viewport's image on the x and/or y axis, and/or inverts the color of each pixel.
|
|
8
|
+
* @beta
|
|
9
|
+
*/
|
|
10
|
+
export declare class FlipImageEffect extends AddEffectTool {
|
|
11
|
+
static toolId: string;
|
|
12
|
+
protected get effectName(): string;
|
|
13
|
+
protected get textureCoordFromPosition(): boolean;
|
|
14
|
+
protected get source(): {
|
|
15
|
+
vertex: string;
|
|
16
|
+
fragment: string;
|
|
17
|
+
sampleSourcePixel: string;
|
|
18
|
+
};
|
|
19
|
+
protected defineEffect(builder: ScreenSpaceEffectBuilder): void;
|
|
20
|
+
}
|
|
21
|
+
/** Configure the [[FlipImageEffect]].
|
|
22
|
+
* @beta
|
|
23
|
+
*/
|
|
24
|
+
export declare class FlipImageConfig extends Tool {
|
|
25
|
+
static toolId: string;
|
|
26
|
+
static get minArgs(): number;
|
|
27
|
+
static get maxArgs(): number;
|
|
28
|
+
run(horizontal?: boolean, vertical?: boolean, color?: boolean): Promise<boolean>;
|
|
29
|
+
parseAndRun(...input: string[]): Promise<boolean>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=FlipImage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlipImage.d.ts","sourceRoot":"","sources":["../../src/effects/FlipImage.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,wBAAwB,EAAE,IAAI,EAA4B,MAAM,sBAAsB,CAAC;AAEhG,OAAO,EAAE,aAAa,EAA6B,MAAM,eAAe,CAAC;AAMzE;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,aAAa;IAChD,OAAuB,MAAM,SAAqB;IAElD,SAAS,KAAK,UAAU,WAAqB;IAC7C,SAAS,KAAK,wBAAwB,YAAmB;IAEzD,SAAS,KAAK,MAAM;;;;MA8BnB;IAED,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,wBAAwB,GAAG,IAAI;CAwBhE;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,IAAI;IACvC,OAAuB,MAAM,SAAqB;IAClD,WAA2B,OAAO,WAAgB;IAClD,WAA2B,OAAO,WAAgB;IAE5B,GAAG,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAShF,WAAW,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAIxE"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Effects
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.FlipImageConfig = exports.FlipImageEffect = void 0;
|
|
11
|
+
const core_frontend_1 = require("@itwin/core-frontend");
|
|
12
|
+
const parseArgs_1 = require("../tools/parseArgs");
|
|
13
|
+
const EffectTools_1 = require("./EffectTools");
|
|
14
|
+
let flipHorizontal = false;
|
|
15
|
+
let flipVertical = false;
|
|
16
|
+
let flipColor = false;
|
|
17
|
+
/** An extremely simple and mostly useless effect intended to demonstrate the basics of creating a screen-space effect.
|
|
18
|
+
* It flips the Viewport's image on the x and/or y axis, and/or inverts the color of each pixel.
|
|
19
|
+
* @beta
|
|
20
|
+
*/
|
|
21
|
+
class FlipImageEffect extends EffectTools_1.AddEffectTool {
|
|
22
|
+
get effectName() { return "flip"; }
|
|
23
|
+
get textureCoordFromPosition() { return true; }
|
|
24
|
+
get source() {
|
|
25
|
+
return {
|
|
26
|
+
// Compute texture coordinate for use in fragment shader.
|
|
27
|
+
vertex: `
|
|
28
|
+
void effectMain(vec4 pos) {
|
|
29
|
+
vec2 uv = textureCoordFromPosition(pos);
|
|
30
|
+
if (u_flipHorizontal)
|
|
31
|
+
uv.x = 1.0 - uv.x;
|
|
32
|
+
|
|
33
|
+
if (u_flipVertical)
|
|
34
|
+
uv.y = 1.0 - uv.y;
|
|
35
|
+
|
|
36
|
+
v_uv = uv;
|
|
37
|
+
}`,
|
|
38
|
+
// Sample the original image to flip on x and/or y axis, then invert its color.
|
|
39
|
+
fragment: `
|
|
40
|
+
vec4 effectMain() {
|
|
41
|
+
vec4 color = sampleSourcePixel();
|
|
42
|
+
if (u_flipColor) {
|
|
43
|
+
color.r = 1.0 - color.r;
|
|
44
|
+
color.g = 1.0 - color.g;
|
|
45
|
+
color.b = 1.0 - color.b;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return color;
|
|
49
|
+
}`,
|
|
50
|
+
// Because we're moving pixels around, we must tell the render system where the source pixel was originally located - otherwise
|
|
51
|
+
// element locate will not work correctly.
|
|
52
|
+
sampleSourcePixel: "return TEXTURE(u_diffuse, v_uv);",
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
defineEffect(builder) {
|
|
56
|
+
// Don't bother applying the effect if nothing is to be flipped.
|
|
57
|
+
builder.shouldApply = (_context) => flipHorizontal || flipVertical || flipColor;
|
|
58
|
+
// Define the varying for the texture coordinate.
|
|
59
|
+
builder.addVarying("v_uv", core_frontend_1.VaryingType.Vec2);
|
|
60
|
+
// Hook up the uniforms.
|
|
61
|
+
builder.addUniform({
|
|
62
|
+
name: "u_flipHorizontal",
|
|
63
|
+
type: core_frontend_1.UniformType.Bool,
|
|
64
|
+
bind: (uniform, _context) => uniform.setUniform1i(flipHorizontal ? 1 : 0),
|
|
65
|
+
});
|
|
66
|
+
builder.addUniform({
|
|
67
|
+
name: "u_flipVertical",
|
|
68
|
+
type: core_frontend_1.UniformType.Bool,
|
|
69
|
+
bind: (uniform, _context) => uniform.setUniform1i(flipVertical ? 1 : 0),
|
|
70
|
+
});
|
|
71
|
+
builder.addUniform({
|
|
72
|
+
name: "u_flipColor",
|
|
73
|
+
type: core_frontend_1.UniformType.Bool,
|
|
74
|
+
bind: (uniform, _context) => uniform.setUniform1i(flipColor ? 1 : 0),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.FlipImageEffect = FlipImageEffect;
|
|
79
|
+
FlipImageEffect.toolId = "FlipImageEffect";
|
|
80
|
+
/** Configure the [[FlipImageEffect]].
|
|
81
|
+
* @beta
|
|
82
|
+
*/
|
|
83
|
+
class FlipImageConfig extends core_frontend_1.Tool {
|
|
84
|
+
static get minArgs() { return 0; }
|
|
85
|
+
static get maxArgs() { return 3; }
|
|
86
|
+
async run(horizontal, vertical, color) {
|
|
87
|
+
flipHorizontal = !!horizontal;
|
|
88
|
+
flipVertical = !!vertical;
|
|
89
|
+
flipColor = !!color;
|
|
90
|
+
(0, EffectTools_1.refreshViewportsForEffect)("fdt flip");
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
async parseAndRun(...input) {
|
|
94
|
+
const args = (0, parseArgs_1.parseArgs)(input);
|
|
95
|
+
return this.run(args.getBoolean("h"), args.getBoolean("v"), args.getBoolean("c"));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.FlipImageConfig = FlipImageConfig;
|
|
99
|
+
FlipImageConfig.toolId = "FlipImageConfig";
|
|
100
|
+
//# sourceMappingURL=FlipImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlipImage.js","sourceRoot":"","sources":["../../src/effects/FlipImage.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAAgG;AAChG,kDAA+C;AAC/C,+CAAyE;AAEzE,IAAI,cAAc,GAAG,KAAK,CAAC;AAC3B,IAAI,YAAY,GAAG,KAAK,CAAC;AACzB,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB;;;GAGG;AACH,MAAa,eAAgB,SAAQ,2BAAa;IAGhD,IAAc,UAAU,KAAK,OAAO,MAAM,CAAC,CAAC,CAAC;IAC7C,IAAc,wBAAwB,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;IAEzD,IAAc,MAAM;QAClB,OAAO;YACL,yDAAyD;YACzD,MAAM,EAAE;;;;;;;;;;UAUJ;YACJ,+EAA+E;YAC/E,QAAQ,EAAE;;;;;;;;;;UAUN;YACJ,+HAA+H;YAC/H,0CAA0C;YAC1C,iBAAiB,EAAE,kCAAkC;SACtD,CAAC;IACJ,CAAC;IAES,YAAY,CAAC,OAAiC;QACtD,gEAAgE;QAChE,OAAO,CAAC,WAAW,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,cAAc,IAAI,YAAY,IAAI,SAAS,CAAC;QAEhF,iDAAiD;QACjD,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,2BAA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CAAC;QAEpB,IAAA,uCAAyB,EAAC,UAAU,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAEe,KAAK,CAAC,WAAW,CAAC,GAAG,KAAe;QAClD,MAAM,IAAI,GAAG,IAAA,qBAAS,EAAC,KAAK,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IACpF,CAAC;;AAjBH,0CAkBC;AAjBwB,sBAAM,GAAG,iBAAiB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Effects\n */\n\nimport { ScreenSpaceEffectBuilder, Tool, UniformType, VaryingType } from \"@itwin/core-frontend\";\nimport { parseArgs } from \"../tools/parseArgs\";\nimport { AddEffectTool, refreshViewportsForEffect } from \"./EffectTools\";\n\nlet flipHorizontal = false;\nlet flipVertical = false;\nlet flipColor = false;\n\n/** An extremely simple and mostly useless effect intended to demonstrate the basics of creating a screen-space effect.\n * It flips the Viewport's image on the x and/or y axis, and/or inverts the color of each pixel.\n * @beta\n */\nexport class FlipImageEffect extends AddEffectTool {\n public static override toolId = \"FlipImageEffect\";\n\n protected get effectName() { return \"flip\"; }\n protected get textureCoordFromPosition() { return true; }\n\n protected get source() {\n return {\n // Compute texture coordinate for use in fragment shader.\n vertex: `\n void effectMain(vec4 pos) {\n vec2 uv = textureCoordFromPosition(pos);\n if (u_flipHorizontal)\n uv.x = 1.0 - uv.x;\n\n if (u_flipVertical)\n uv.y = 1.0 - uv.y;\n\n v_uv = uv;\n }`,\n // Sample the original image to flip on x and/or y axis, then invert its color.\n fragment: `\n vec4 effectMain() {\n vec4 color = sampleSourcePixel();\n if (u_flipColor) {\n color.r = 1.0 - color.r;\n color.g = 1.0 - color.g;\n color.b = 1.0 - color.b;\n }\n\n return color;\n }`,\n // Because we're moving pixels around, we must tell the render system where the source pixel was originally located - otherwise\n // element locate will not work correctly.\n sampleSourcePixel: \"return TEXTURE(u_diffuse, v_uv);\",\n };\n }\n\n protected defineEffect(builder: ScreenSpaceEffectBuilder): void {\n // Don't bother applying the effect if nothing is to be flipped.\n builder.shouldApply = (_context) => flipHorizontal || flipVertical || flipColor;\n\n // Define the varying for the texture coordinate.\n builder.addVarying(\"v_uv\", VaryingType.Vec2);\n\n // Hook up the uniforms.\n builder.addUniform({\n name: \"u_flipHorizontal\",\n type: UniformType.Bool,\n bind: (uniform, _context) => uniform.setUniform1i(flipHorizontal ? 1 : 0),\n });\n builder.addUniform({\n name: \"u_flipVertical\",\n type: UniformType.Bool,\n bind: (uniform, _context) => uniform.setUniform1i(flipVertical ? 1 : 0),\n });\n builder.addUniform({\n name: \"u_flipColor\",\n type: UniformType.Bool,\n bind: (uniform, _context) => uniform.setUniform1i(flipColor ? 1 : 0),\n });\n }\n}\n\n/** Configure the [[FlipImageEffect]].\n * @beta\n */\nexport class FlipImageConfig extends Tool {\n public static override toolId = \"FlipImageConfig\";\n public static override get minArgs() { return 0; }\n public static override get maxArgs() { return 3; }\n\n public override async run(horizontal?: boolean, vertical?: boolean, color?: boolean): Promise<boolean> {\n flipHorizontal = !!horizontal;\n flipVertical = !!vertical;\n flipColor = !!color;\n\n refreshViewportsForEffect(\"fdt flip\");\n return true;\n }\n\n public override async parseAndRun(...input: string[]): Promise<boolean> {\n const args = parseArgs(input);\n return this.run(args.getBoolean(\"h\"), args.getBoolean(\"v\"), args.getBoolean(\"c\"));\n }\n}\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Effects
|
|
3
|
+
*/
|
|
4
|
+
import { ScreenSpaceEffectBuilder, Tool } from "@itwin/core-frontend";
|
|
5
|
+
import { AddEffectTool } from "./EffectTools";
|
|
6
|
+
/** Adds a screen-space effect to the selected [[Viewport]] to simulate the lens distortion produced by real-world cameras with very wide fields of view.
|
|
7
|
+
* Based on https://www.decarpentier.nl/lens-distortion
|
|
8
|
+
* The effect is improved considerably by enabling anti-aliasing (e.g., via [RenderSystem.Options.antialiasSamples]($frontend) at startup, or using the `fdt aasamples` key-in`).
|
|
9
|
+
* @note Because this effect applies a non-linear transform to each pixel, operations like snapping to geometry will not work properly. Element locate will work however - @see [ScreenSpaceEffectSource.sampleSourcePixel]($frontend).
|
|
10
|
+
* @beta
|
|
11
|
+
*/
|
|
12
|
+
export declare class LensDistortionEffect extends AddEffectTool {
|
|
13
|
+
static toolId: string;
|
|
14
|
+
protected get effectName(): string;
|
|
15
|
+
protected get textureCoordFromPosition(): boolean;
|
|
16
|
+
protected get source(): {
|
|
17
|
+
vertex: string;
|
|
18
|
+
fragment: string;
|
|
19
|
+
sampleSourcePixel: string;
|
|
20
|
+
};
|
|
21
|
+
protected defineEffect(builder: ScreenSpaceEffectBuilder): void;
|
|
22
|
+
}
|
|
23
|
+
/** Configures the [[LensDistortionEffect]].
|
|
24
|
+
* @beta
|
|
25
|
+
*/
|
|
26
|
+
export declare class LensDistortionConfig extends Tool {
|
|
27
|
+
static toolId: string;
|
|
28
|
+
static get minArgs(): number;
|
|
29
|
+
static get maxArgs(): number;
|
|
30
|
+
static strength: number;
|
|
31
|
+
static cylindricalRatio: number;
|
|
32
|
+
run(strength?: number, ratio?: number): Promise<boolean>;
|
|
33
|
+
parseAndRun(...input: string[]): Promise<boolean>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=LensDistortion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LensDistortion.d.ts","sourceRoot":"","sources":["../../src/effects/LensDistortion.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,wBAAwB,EAAE,IAAI,EAA4B,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,aAAa,EAA6B,MAAM,eAAe,CAAC;AAGzE;;;;;GAKG;AACH,qBAAa,oBAAqB,SAAQ,aAAa;IACrD,OAAuB,MAAM,SAA0B;IAEvD,SAAS,KAAK,UAAU,WAA+B;IACvD,SAAS,KAAK,wBAAwB,YAAmB;IAEzD,SAAS,KAAK,MAAM;;;;MA8BnB;IAED,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,wBAAwB,GAAG,IAAI;CAiChE;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,IAAI;IAC5C,OAAuB,MAAM,SAA0B;IACvD,WAA2B,OAAO,WAAgB;IAClD,WAA2B,OAAO,WAAgB;IAElD,OAAc,QAAQ,SAAO;IAC7B,OAAc,gBAAgB,SAAO;IAEf,GAAG,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOxD,WAAW,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAIxE"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Effects
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.LensDistortionConfig = exports.LensDistortionEffect = void 0;
|
|
11
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
|
+
const core_frontend_1 = require("@itwin/core-frontend");
|
|
13
|
+
const EffectTools_1 = require("./EffectTools");
|
|
14
|
+
const parseArgs_1 = require("../tools/parseArgs");
|
|
15
|
+
/** Adds a screen-space effect to the selected [[Viewport]] to simulate the lens distortion produced by real-world cameras with very wide fields of view.
|
|
16
|
+
* Based on https://www.decarpentier.nl/lens-distortion
|
|
17
|
+
* The effect is improved considerably by enabling anti-aliasing (e.g., via [RenderSystem.Options.antialiasSamples]($frontend) at startup, or using the `fdt aasamples` key-in`).
|
|
18
|
+
* @note Because this effect applies a non-linear transform to each pixel, operations like snapping to geometry will not work properly. Element locate will work however - @see [ScreenSpaceEffectSource.sampleSourcePixel]($frontend).
|
|
19
|
+
* @beta
|
|
20
|
+
*/
|
|
21
|
+
class LensDistortionEffect extends EffectTools_1.AddEffectTool {
|
|
22
|
+
get effectName() { return "lensdistortion"; }
|
|
23
|
+
get textureCoordFromPosition() { return true; }
|
|
24
|
+
get source() {
|
|
25
|
+
return {
|
|
26
|
+
vertex: `
|
|
27
|
+
void effectMain(vec4 position) {
|
|
28
|
+
vec2 uv = textureCoordFromPosition(position);
|
|
29
|
+
float scaledHeight = strength * height;
|
|
30
|
+
float cylAspectRatio = aspectRatio * cylindricalRatio;
|
|
31
|
+
float aspectDiagSq = aspectRatio * aspectRatio + 1.0;
|
|
32
|
+
float diagSq = scaledHeight * scaledHeight * aspectDiagSq;
|
|
33
|
+
vec2 signedUV = (2.0 * uv + vec2(-1.0, -1.0));
|
|
34
|
+
|
|
35
|
+
float z = 0.5 * sqrt(diagSq + 1.0) + 0.5;
|
|
36
|
+
float ny = (z - 1.0) / (cylAspectRatio * cylAspectRatio + 1.0);
|
|
37
|
+
|
|
38
|
+
vUVDot = sqrt(ny) * vec2(cylAspectRatio, 1.0) * signedUV;
|
|
39
|
+
vUV = vec3(0.5, 0.5, 1.0) * z + vec3(-0.5, -0.5, 0.0);
|
|
40
|
+
vUV.xy += uv;
|
|
41
|
+
}`,
|
|
42
|
+
// We simply shift pixels - we don't alter their colors.
|
|
43
|
+
fragment: `
|
|
44
|
+
vec4 effectMain() {
|
|
45
|
+
return sampleSourcePixel();
|
|
46
|
+
}`,
|
|
47
|
+
// Because we're moving pixels around, we must tell the render system where the source pixel was originally located - otherwise
|
|
48
|
+
// element locate will not work correctly.
|
|
49
|
+
sampleSourcePixel: `
|
|
50
|
+
vec3 uv = dot(vUVDot, vUVDot) * vec3(-0.5, -0.5, -1.0) + vUV;
|
|
51
|
+
return TEXTURE_PROJ(u_diffuse, uv);
|
|
52
|
+
`,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
defineEffect(builder) {
|
|
56
|
+
// Lens distortion is only applicable to views with the camera enabled.
|
|
57
|
+
builder.shouldApply = (context) => context.viewport.isCameraOn;
|
|
58
|
+
builder.addVarying("vUV", core_frontend_1.VaryingType.Vec3);
|
|
59
|
+
builder.addVarying("vUVDot", core_frontend_1.VaryingType.Vec2);
|
|
60
|
+
builder.addUniform({
|
|
61
|
+
name: "strength",
|
|
62
|
+
type: core_frontend_1.UniformType.Float,
|
|
63
|
+
bind: (uniform) => uniform.setUniform1f(LensDistortionConfig.strength),
|
|
64
|
+
});
|
|
65
|
+
builder.addUniform({
|
|
66
|
+
name: "cylindricalRatio",
|
|
67
|
+
type: core_frontend_1.UniformType.Float,
|
|
68
|
+
bind: (uniform) => uniform.setUniform1f(LensDistortionConfig.cylindricalRatio),
|
|
69
|
+
});
|
|
70
|
+
builder.addUniform({
|
|
71
|
+
name: "aspectRatio",
|
|
72
|
+
type: core_frontend_1.UniformType.Float,
|
|
73
|
+
bind: (uniform, context) => uniform.setUniform1f(context.viewport.viewRect.aspect),
|
|
74
|
+
});
|
|
75
|
+
builder.addUniform({
|
|
76
|
+
name: "height",
|
|
77
|
+
type: core_frontend_1.UniformType.Float,
|
|
78
|
+
bind: (uniform, context) => {
|
|
79
|
+
(0, core_bentley_1.assert)(context.viewport.view.isCameraEnabled());
|
|
80
|
+
const fov = context.viewport.view.camera.lens.radians;
|
|
81
|
+
const height = Math.tan(fov / 2) / context.viewport.viewRect.aspect;
|
|
82
|
+
uniform.setUniform1f(height);
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.LensDistortionEffect = LensDistortionEffect;
|
|
88
|
+
LensDistortionEffect.toolId = "LensDistortionEffect";
|
|
89
|
+
/** Configures the [[LensDistortionEffect]].
|
|
90
|
+
* @beta
|
|
91
|
+
*/
|
|
92
|
+
class LensDistortionConfig extends core_frontend_1.Tool {
|
|
93
|
+
static get minArgs() { return 0; }
|
|
94
|
+
static get maxArgs() { return 2; }
|
|
95
|
+
async run(strength, ratio) {
|
|
96
|
+
LensDistortionConfig.strength = strength !== null && strength !== void 0 ? strength : 0.5;
|
|
97
|
+
LensDistortionConfig.cylindricalRatio = ratio !== null && ratio !== void 0 ? ratio : 0.5;
|
|
98
|
+
(0, EffectTools_1.refreshViewportsForEffect)("fdt lensdistortion");
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
async parseAndRun(...input) {
|
|
102
|
+
const args = (0, parseArgs_1.parseArgs)(input);
|
|
103
|
+
return this.run(args.getFloat("s"), args.getFloat("r"));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.LensDistortionConfig = LensDistortionConfig;
|
|
107
|
+
LensDistortionConfig.toolId = "LensDistortionConfig";
|
|
108
|
+
LensDistortionConfig.strength = 0.5;
|
|
109
|
+
LensDistortionConfig.cylindricalRatio = 0.5;
|
|
110
|
+
//# sourceMappingURL=LensDistortion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LensDistortion.js","sourceRoot":"","sources":["../../src/effects/LensDistortion.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAC7C,wDAAgG;AAChG,+CAAyE;AACzE,kDAA+C;AAE/C;;;;;GAKG;AACH,MAAa,oBAAqB,SAAQ,2BAAa;IAGrD,IAAc,UAAU,KAAK,OAAO,gBAAgB,CAAC,CAAC,CAAC;IACvD,IAAc,wBAAwB,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;IAEzD,IAAc,MA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H,oDAmBC;AAlBwB,2BAAM,GAAG,sBAAsB,CAAC;AAIzC,6BAAQ,GAAG,GAAG,CAAC;AACf,qCAAgB,GAAG,GAAG,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Effects\n */\n\nimport { assert } from \"@itwin/core-bentley\";\nimport { ScreenSpaceEffectBuilder, Tool, UniformType, VaryingType } from \"@itwin/core-frontend\";\nimport { AddEffectTool, refreshViewportsForEffect } from \"./EffectTools\";\nimport { parseArgs } from \"../tools/parseArgs\";\n\n/** Adds a screen-space effect to the selected [[Viewport]] to simulate the lens distortion produced by real-world cameras with very wide fields of view.\n * Based on https://www.decarpentier.nl/lens-distortion\n * The effect is improved considerably by enabling anti-aliasing (e.g., via [RenderSystem.Options.antialiasSamples]($frontend) at startup, or using the `fdt aasamples` key-in`).\n * @note Because this effect applies a non-linear transform to each pixel, operations like snapping to geometry will not work properly. Element locate will work however - @see [ScreenSpaceEffectSource.sampleSourcePixel]($frontend).\n * @beta\n */\nexport class LensDistortionEffect extends AddEffectTool {\n public static override toolId = \"LensDistortionEffect\";\n\n protected get effectName() { return \"lensdistortion\"; }\n protected get textureCoordFromPosition() { return true; }\n\n protected get source() {\n return {\n vertex: `\n void effectMain(vec4 position) {\n vec2 uv = textureCoordFromPosition(position);\n float scaledHeight = strength * height;\n float cylAspectRatio = aspectRatio * cylindricalRatio;\n float aspectDiagSq = aspectRatio * aspectRatio + 1.0;\n float diagSq = scaledHeight * scaledHeight * aspectDiagSq;\n vec2 signedUV = (2.0 * uv + vec2(-1.0, -1.0));\n\n float z = 0.5 * sqrt(diagSq + 1.0) + 0.5;\n float ny = (z - 1.0) / (cylAspectRatio * cylAspectRatio + 1.0);\n\n vUVDot = sqrt(ny) * vec2(cylAspectRatio, 1.0) * signedUV;\n vUV = vec3(0.5, 0.5, 1.0) * z + vec3(-0.5, -0.5, 0.0);\n vUV.xy += uv;\n }`,\n // We simply shift pixels - we don't alter their colors.\n fragment: `\n vec4 effectMain() {\n return sampleSourcePixel();\n }`,\n // Because we're moving pixels around, we must tell the render system where the source pixel was originally located - otherwise\n // element locate will not work correctly.\n sampleSourcePixel: `\n vec3 uv = dot(vUVDot, vUVDot) * vec3(-0.5, -0.5, -1.0) + vUV;\n return TEXTURE_PROJ(u_diffuse, uv);\n `,\n };\n }\n\n protected defineEffect(builder: ScreenSpaceEffectBuilder): void {\n // Lens distortion is only applicable to views with the camera enabled.\n builder.shouldApply = (context) => context.viewport.isCameraOn;\n\n builder.addVarying(\"vUV\", VaryingType.Vec3);\n builder.addVarying(\"vUVDot\", VaryingType.Vec2);\n\n builder.addUniform({\n name: \"strength\",\n type: UniformType.Float,\n bind: (uniform) => uniform.setUniform1f(LensDistortionConfig.strength),\n });\n builder.addUniform({\n name: \"cylindricalRatio\",\n type: UniformType.Float,\n bind: (uniform) => uniform.setUniform1f(LensDistortionConfig.cylindricalRatio),\n });\n builder.addUniform({\n name: \"aspectRatio\",\n type: UniformType.Float,\n bind: (uniform, context) => uniform.setUniform1f(context.viewport.viewRect.aspect),\n });\n builder.addUniform({\n name: \"height\",\n type: UniformType.Float,\n bind: (uniform, context) => {\n assert(context.viewport.view.isCameraEnabled());\n const fov = context.viewport.view.camera.lens.radians;\n const height = Math.tan(fov / 2) / context.viewport.viewRect.aspect;\n uniform.setUniform1f(height);\n },\n });\n }\n}\n\n/** Configures the [[LensDistortionEffect]].\n * @beta\n */\nexport class LensDistortionConfig extends Tool {\n public static override toolId = \"LensDistortionConfig\";\n public static override get minArgs() { return 0; }\n public static override get maxArgs() { return 2; }\n\n public static strength = 0.5;\n public static cylindricalRatio = 0.5;\n\n public override async run(strength?: number, ratio?: number): Promise<boolean> {\n LensDistortionConfig.strength = strength ?? 0.5;\n LensDistortionConfig.cylindricalRatio = ratio ?? 0.5;\n refreshViewportsForEffect(\"fdt lensdistortion\");\n return true;\n }\n\n public override async parseAndRun(...input: string[]): Promise<boolean> {\n const args = parseArgs(input);\n return this.run(args.getFloat(\"s\"), args.getFloat(\"r\"));\n }\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Effects
|
|
3
|
+
*/
|
|
4
|
+
import { Point3d, Range1d, Range3d } from "@itwin/core-geometry";
|
|
5
|
+
/** Generate integer in [min, max].
|
|
6
|
+
* @beta
|
|
7
|
+
*/
|
|
8
|
+
export declare function randomInteger(min: number, max: number): number;
|
|
9
|
+
/** Generate random integer in [range.low, range.high].
|
|
10
|
+
* @beta
|
|
11
|
+
*/
|
|
12
|
+
export declare function randomIntegerInRange(range: Range1d): number;
|
|
13
|
+
/** Generate random floating-point number in [min, max).
|
|
14
|
+
* @beta
|
|
15
|
+
*/
|
|
16
|
+
export declare function randomFloat(min: number, max: number): number;
|
|
17
|
+
/** Generate random floating-point number in [range.low, range.high).
|
|
18
|
+
* @beta
|
|
19
|
+
*/
|
|
20
|
+
export declare function randomFloatInRange(range: Range1d): number;
|
|
21
|
+
/** Generate a random position in the specified range.
|
|
22
|
+
* @beta
|
|
23
|
+
*/
|
|
24
|
+
export declare function randomPositionInRange(range: Range3d): Point3d;
|
|
25
|
+
//# sourceMappingURL=Random.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Random.d.ts","sourceRoot":"","sources":["../../src/effects/Random.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEjE;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE3D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEzD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAK7D"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Effects
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.randomPositionInRange = exports.randomFloatInRange = exports.randomFloat = exports.randomIntegerInRange = exports.randomInteger = void 0;
|
|
11
|
+
const core_geometry_1 = require("@itwin/core-geometry");
|
|
12
|
+
/** Generate integer in [min, max].
|
|
13
|
+
* @beta
|
|
14
|
+
*/
|
|
15
|
+
function randomInteger(min, max) {
|
|
16
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
17
|
+
}
|
|
18
|
+
exports.randomInteger = randomInteger;
|
|
19
|
+
/** Generate random integer in [range.low, range.high].
|
|
20
|
+
* @beta
|
|
21
|
+
*/
|
|
22
|
+
function randomIntegerInRange(range) {
|
|
23
|
+
return Math.floor(Math.random() * (range.high - range.low + 1)) + range.low;
|
|
24
|
+
}
|
|
25
|
+
exports.randomIntegerInRange = randomIntegerInRange;
|
|
26
|
+
/** Generate random floating-point number in [min, max).
|
|
27
|
+
* @beta
|
|
28
|
+
*/
|
|
29
|
+
function randomFloat(min, max) {
|
|
30
|
+
return Math.random() * (max - min) + min;
|
|
31
|
+
}
|
|
32
|
+
exports.randomFloat = randomFloat;
|
|
33
|
+
/** Generate random floating-point number in [range.low, range.high).
|
|
34
|
+
* @beta
|
|
35
|
+
*/
|
|
36
|
+
function randomFloatInRange(range) {
|
|
37
|
+
return randomFloat(range.low, range.high);
|
|
38
|
+
}
|
|
39
|
+
exports.randomFloatInRange = randomFloatInRange;
|
|
40
|
+
/** Generate a random position in the specified range.
|
|
41
|
+
* @beta
|
|
42
|
+
*/
|
|
43
|
+
function randomPositionInRange(range) {
|
|
44
|
+
const x = randomFloat(range.low.x, range.high.x);
|
|
45
|
+
const y = randomFloat(range.low.y, range.high.y);
|
|
46
|
+
const z = randomFloat(range.low.z, range.high.z);
|
|
47
|
+
return new core_geometry_1.Point3d(x, y, z);
|
|
48
|
+
}
|
|
49
|
+
exports.randomPositionInRange = randomPositionInRange;
|
|
50
|
+
//# sourceMappingURL=Random.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Random.js","sourceRoot":"","sources":["../../src/effects/Random.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAAiE;AAEjE;;GAEG;AACH,SAAgB,aAAa,CAAC,GAAW,EAAE,GAAW;IACpD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;AAC3D,CAAC;AAFD,sCAEC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,KAAc;IACjD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC;AAC9E,CAAC;AAFD,oDAEC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,GAAW,EAAE,GAAW;IAClD,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AAC3C,CAAC;AAFD,kCAEC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,KAAc;IAC/C,OAAO,WAAW,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC;AAFD,gDAEC;AAED;;GAEG;AACH,SAAgB,qBAAqB,CAAC,KAAc;IAClD,MAAM,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjD,MAAM,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjD,MAAM,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjD,OAAO,IAAI,uBAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9B,CAAC;AALD,sDAKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Effects\n */\n\nimport { Point3d, Range1d, Range3d } from \"@itwin/core-geometry\";\n\n/** Generate integer in [min, max].\n * @beta\n */\nexport function randomInteger(min: number, max: number): number {\n return Math.floor(Math.random() * (max - min + 1)) + min;\n}\n\n/** Generate random integer in [range.low, range.high].\n * @beta\n */\nexport function randomIntegerInRange(range: Range1d): number {\n return Math.floor(Math.random() * (range.high - range.low + 1)) + range.low;\n}\n\n/** Generate random floating-point number in [min, max).\n * @beta\n */\nexport function randomFloat(min: number, max: number): number {\n return Math.random() * (max - min) + min;\n}\n\n/** Generate random floating-point number in [range.low, range.high).\n * @beta\n */\nexport function randomFloatInRange(range: Range1d): number {\n return randomFloat(range.low, range.high);\n}\n\n/** Generate a random position in the specified range.\n * @beta\n */\nexport function randomPositionInRange(range: Range3d): Point3d {\n const x = randomFloat(range.low.x, range.high.x);\n const y = randomFloat(range.low.y, range.high.y);\n const z = randomFloat(range.low.z, range.high.z);\n return new Point3d(x, y, z);\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Effects
|
|
3
|
+
*/
|
|
4
|
+
import { ScreenSpaceEffectBuilder, Tool } from "@itwin/core-frontend";
|
|
5
|
+
import { AddEffectTool } from "./EffectTools";
|
|
6
|
+
/** Adjusts the saturation of colors in a viewport.
|
|
7
|
+
* @beta
|
|
8
|
+
*/
|
|
9
|
+
export declare class SaturationEffect extends AddEffectTool {
|
|
10
|
+
static toolId: string;
|
|
11
|
+
protected get effectName(): string;
|
|
12
|
+
protected get textureCoordFromPosition(): boolean;
|
|
13
|
+
protected get source(): {
|
|
14
|
+
vertex: string;
|
|
15
|
+
fragment: string;
|
|
16
|
+
};
|
|
17
|
+
protected defineEffect(builder: ScreenSpaceEffectBuilder): void;
|
|
18
|
+
}
|
|
19
|
+
/** Configures the [[SaturationEffect]].
|
|
20
|
+
* @beta
|
|
21
|
+
*/
|
|
22
|
+
export declare class SaturationConfig extends Tool {
|
|
23
|
+
static toolId: string;
|
|
24
|
+
static get minArgs(): number;
|
|
25
|
+
static get maxArgs(): number;
|
|
26
|
+
/** Multiplier applied to the saturation of each color in the source image. */
|
|
27
|
+
static multiplier: number;
|
|
28
|
+
run(multiplier?: number): Promise<boolean>;
|
|
29
|
+
parseAndRun(...input: string[]): Promise<boolean>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=Saturation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Saturation.d.ts","sourceRoot":"","sources":["../../src/effects/Saturation.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,wBAAwB,EAAE,IAAI,EAA4B,MAAM,sBAAsB,CAAC;AAEhG,OAAO,EAAE,aAAa,EAA6B,MAAM,eAAe,CAAC;AAEzE;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,aAAa;IACjD,OAAuB,MAAM,SAAsB;IAEnD,SAAS,KAAK,UAAU,WAA2B;IACnD,SAAS,KAAK,wBAAwB,YAAmB;IAEzD,SAAS,KAAK,MAAM;;;MAkCnB;IAED,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,wBAAwB,GAAG,IAAI;CAQhE;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,IAAI;IACxC,OAAuB,MAAM,SAAsB;IACnD,WAA2B,OAAO,WAAgB;IAClD,WAA2B,OAAO,WAAgB;IAElD,8EAA8E;IAC9E,OAAc,UAAU,SAAO;IAET,GAAG,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAM1C,WAAW,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAIxE"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Effects
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.SaturationConfig = exports.SaturationEffect = void 0;
|
|
11
|
+
const core_frontend_1 = require("@itwin/core-frontend");
|
|
12
|
+
const parseArgs_1 = require("../tools/parseArgs");
|
|
13
|
+
const EffectTools_1 = require("./EffectTools");
|
|
14
|
+
/** Adjusts the saturation of colors in a viewport.
|
|
15
|
+
* @beta
|
|
16
|
+
*/
|
|
17
|
+
class SaturationEffect extends EffectTools_1.AddEffectTool {
|
|
18
|
+
get effectName() { return "Saturation"; }
|
|
19
|
+
get textureCoordFromPosition() { return true; }
|
|
20
|
+
get source() {
|
|
21
|
+
// rgb <-> hsl conversion routines from https://gamedev.stackexchange.com/questions/59797/glsl-shader-change-hue-saturation-brightness
|
|
22
|
+
return {
|
|
23
|
+
// Vertex shader simply computes texture coordinate for source pixel.
|
|
24
|
+
vertex: `
|
|
25
|
+
void effectMain(vec4 pos) {
|
|
26
|
+
v_texCoord = textureCoordFromPosition(pos);
|
|
27
|
+
}`,
|
|
28
|
+
// Fragment shader converts color to HSV, adjusts the saturation, and converts back to RGB.
|
|
29
|
+
fragment: `
|
|
30
|
+
vec3 rgb2hsv(vec3 c) {
|
|
31
|
+
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
|
32
|
+
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
|
33
|
+
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
|
34
|
+
|
|
35
|
+
float d = q.x - min(q.w, q.y);
|
|
36
|
+
float e = 1.0e-10;
|
|
37
|
+
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
vec3 hsv2rgb(vec3 c) {
|
|
41
|
+
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
|
42
|
+
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
|
43
|
+
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
vec4 effectMain() {
|
|
47
|
+
vec4 color = TEXTURE(u_diffuse, v_texCoord);
|
|
48
|
+
color.rgb = rgb2hsv(color.rgb);
|
|
49
|
+
color.rgb.y = color.rgb.y * u_saturationMult;
|
|
50
|
+
color.rgb = hsv2rgb(color.rgb);
|
|
51
|
+
return color;
|
|
52
|
+
}`,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
defineEffect(builder) {
|
|
56
|
+
builder.addVarying("v_texCoord", core_frontend_1.VaryingType.Vec2);
|
|
57
|
+
builder.addUniform({
|
|
58
|
+
name: "u_saturationMult",
|
|
59
|
+
type: core_frontend_1.UniformType.Float,
|
|
60
|
+
bind: (uniform) => uniform.setUniform1f(SaturationConfig.multiplier),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.SaturationEffect = SaturationEffect;
|
|
65
|
+
SaturationEffect.toolId = "SaturationEffect";
|
|
66
|
+
/** Configures the [[SaturationEffect]].
|
|
67
|
+
* @beta
|
|
68
|
+
*/
|
|
69
|
+
class SaturationConfig extends core_frontend_1.Tool {
|
|
70
|
+
static get minArgs() { return 0; }
|
|
71
|
+
static get maxArgs() { return 1; }
|
|
72
|
+
async run(multiplier) {
|
|
73
|
+
SaturationConfig.multiplier = multiplier !== null && multiplier !== void 0 ? multiplier : 2.0;
|
|
74
|
+
(0, EffectTools_1.refreshViewportsForEffect)("fdt Saturation");
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
async parseAndRun(...input) {
|
|
78
|
+
const args = (0, parseArgs_1.parseArgs)(input);
|
|
79
|
+
return this.run(args.getFloat("s"));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.SaturationConfig = SaturationConfig;
|
|
83
|
+
SaturationConfig.toolId = "SaturationConfig";
|
|
84
|
+
/** Multiplier applied to the saturation of each color in the source image. */
|
|
85
|
+
SaturationConfig.multiplier = 2.0;
|
|
86
|
+
//# sourceMappingURL=Saturation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Saturation.js","sourceRoot":"","sources":["../../src/effects/Saturation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAAgG;AAChG,kDAA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,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IACtC,CAAC;;AAjBH,4CAkBC;AAjBwB,uBAAM,GAAG,kBAAkB,CAAC;AAInD,8EAA8E;AAChE,2BAAU,GAAG,GAAG,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Effects\n */\n\nimport { ScreenSpaceEffectBuilder, Tool, UniformType, VaryingType } from \"@itwin/core-frontend\";\nimport { parseArgs } from \"../tools/parseArgs\";\nimport { AddEffectTool, refreshViewportsForEffect } from \"./EffectTools\";\n\n/** Adjusts the saturation of colors in a viewport.\n * @beta\n */\nexport class SaturationEffect extends AddEffectTool {\n public static override toolId = \"SaturationEffect\";\n\n protected get effectName() { return \"Saturation\"; }\n protected get textureCoordFromPosition() { return true; }\n\n protected get source() {\n // rgb <-> hsl conversion routines from https://gamedev.stackexchange.com/questions/59797/glsl-shader-change-hue-saturation-brightness\n return {\n // Vertex shader simply computes texture coordinate for source pixel.\n vertex: `\n void effectMain(vec4 pos) {\n v_texCoord = textureCoordFromPosition(pos);\n }`,\n // Fragment shader converts color to HSV, adjusts the saturation, and converts back to RGB.\n fragment: `\n vec3 rgb2hsv(vec3 c) {\n vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n\n float d = q.x - min(q.w, q.y);\n float e = 1.0e-10;\n return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n }\n\n vec3 hsv2rgb(vec3 c) {\n vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n }\n\n vec4 effectMain() {\n vec4 color = TEXTURE(u_diffuse, v_texCoord);\n color.rgb = rgb2hsv(color.rgb);\n color.rgb.y = color.rgb.y * u_saturationMult;\n color.rgb = hsv2rgb(color.rgb);\n return color;\n }`,\n };\n }\n\n protected defineEffect(builder: ScreenSpaceEffectBuilder): void {\n builder.addVarying(\"v_texCoord\", VaryingType.Vec2);\n builder.addUniform({\n name: \"u_saturationMult\",\n type: UniformType.Float,\n bind: (uniform) => uniform.setUniform1f(SaturationConfig.multiplier),\n });\n }\n}\n\n/** Configures the [[SaturationEffect]].\n * @beta\n */\nexport class SaturationConfig extends Tool {\n public static override toolId = \"SaturationConfig\";\n public static override get minArgs() { return 0; }\n public static override get maxArgs() { return 1; }\n\n /** Multiplier applied to the saturation of each color in the source image. */\n public static multiplier = 2.0;\n\n public override async run(multiplier?: number): Promise<boolean> {\n SaturationConfig.multiplier = multiplier ?? 2.0;\n refreshViewportsForEffect(\"fdt Saturation\");\n return true;\n }\n\n public override async parseAndRun(...input: string[]): Promise<boolean> {\n const args = parseArgs(input);\n return this.run(args.getFloat(\"s\"));\n }\n}\n\n"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Effects
|
|
3
|
+
*/
|
|
4
|
+
import { Range1d, Range2d, Vector2d } from "@itwin/core-geometry";
|
|
5
|
+
import { DecorateContext, Decorator, ParticleProps, Tool, Viewport } from "@itwin/core-frontend";
|
|
6
|
+
/** Represents one particle displayed by a [[SnowDecorator]].
|
|
7
|
+
* Particle positions are in [CoordSystem.View]($frontend).
|
|
8
|
+
* @beta
|
|
9
|
+
*/
|
|
10
|
+
export interface SnowParticle extends ParticleProps {
|
|
11
|
+
/** Make x, y, and z from ParticleProps writable. */
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
z: number;
|
|
15
|
+
/** Current velocity, in pixels per second. */
|
|
16
|
+
velocity: Vector2d;
|
|
17
|
+
}
|
|
18
|
+
/** Parameters controlling how a [[SnowDecorator]] works.
|
|
19
|
+
* @beta
|
|
20
|
+
*/
|
|
21
|
+
export interface SnowParams {
|
|
22
|
+
/** 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. */
|
|
23
|
+
numParticles: number;
|
|
24
|
+
/** Range from which to randomly select each particle's size, in pixels. */
|
|
25
|
+
sizeRange: Range1d;
|
|
26
|
+
/** Range from which to randomly select each particle's transparency. */
|
|
27
|
+
transparencyRange: Range1d;
|
|
28
|
+
/** Range from which to randomly select each particle's initial velocity, in pixels per second. */
|
|
29
|
+
velocityRange: Range2d;
|
|
30
|
+
/** 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. */
|
|
31
|
+
accelerationRange: Range2d;
|
|
32
|
+
/** Wind velocity in pixels per second in X. */
|
|
33
|
+
windVelocity: number;
|
|
34
|
+
}
|
|
35
|
+
/** Simulates snowfall in a [Viewport]($frontend) using particle effects.
|
|
36
|
+
* @see [[SnowEffect]] for a [Tool]($frontend) that toggles this decorator.
|
|
37
|
+
* @see [ParticleCollectionBuilder]($frontend) for defining custom particle effects.
|
|
38
|
+
* @beta
|
|
39
|
+
*/
|
|
40
|
+
export declare class SnowDecorator implements Decorator {
|
|
41
|
+
/** The viewport being decorated. */
|
|
42
|
+
readonly viewport: Viewport;
|
|
43
|
+
/** Invoked when this decorator is to be destroyed. */
|
|
44
|
+
readonly dispose: VoidFunction;
|
|
45
|
+
/** The initial width and height of the viewport, from which we randomly select each particle's initial position. */
|
|
46
|
+
private readonly _dimensions;
|
|
47
|
+
/** The list of particles being drawn. */
|
|
48
|
+
private readonly _particles;
|
|
49
|
+
/** The image to display for each particle. */
|
|
50
|
+
private _texture?;
|
|
51
|
+
/** The last time `updateParticles()` was invoked, in milliseconds. */
|
|
52
|
+
private _lastUpdateTime;
|
|
53
|
+
private readonly _params;
|
|
54
|
+
private constructor();
|
|
55
|
+
decorate(context: DecorateContext): void;
|
|
56
|
+
/** Change some of the parameters affecting this decorator. */
|
|
57
|
+
configure(params: Partial<SnowParams>): void;
|
|
58
|
+
/** Emit a new particle with randomized properties. */
|
|
59
|
+
private emit;
|
|
60
|
+
private updateParticles;
|
|
61
|
+
private static readonly _decorators;
|
|
62
|
+
/** Toggle this decorator for the specified viewport.
|
|
63
|
+
* @param viewport The viewport to which the effect should be applied or removed.
|
|
64
|
+
* @param enable `true` to enable the effect, `false` to disable it, or `undefined` to toggle the current state.
|
|
65
|
+
*/
|
|
66
|
+
static toggle(viewport: Viewport, enable?: boolean): Promise<void>;
|
|
67
|
+
}
|
|
68
|
+
/** Toggles a decorator that simulates snow using particle effects.
|
|
69
|
+
* @see [[SnowDecorator]] for the implementation of the decorator.
|
|
70
|
+
* @beta
|
|
71
|
+
*/
|
|
72
|
+
export declare class SnowEffect extends Tool {
|
|
73
|
+
static toolId: string;
|
|
74
|
+
run(enable?: boolean): Promise<boolean>;
|
|
75
|
+
parseAndRun(...args: string[]): Promise<boolean>;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=Snow.d.ts.map
|
|
@@ -0,0 +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,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,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