Skip to content

Commit

Permalink
feat: add the ability to adjust the lifetime of particles in weather …
Browse files Browse the repository at this point in the history
…effects
  • Loading branch information
ghost91- committed Jan 9, 2022
1 parent 6974d31 commit edc7972
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 17 deletions.
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,23 @@ You can get a complete list by typing `CONFIG.fxmaster.filters` in your web cons

#### Available Weather Effects With Supported Options

| Type | `scale` | `direction` | `speed` | `density` | `tint` |
| ------------ | :-----: | :---------: | :-----: | :-------: | :----: |
| `snowstorm` ||||||
| `bubbles` || ||||
| `clouds` |||| ||
| `embers` || ||||
| `rainsimple` ||||||
| `stars` || ||||
| `crows` || ||||
| `bats` || ||||
| `spiders` || ||||
| `fog` || ||||
| `raintop` ||||||
| `birds` || ||||
| `leaves` || ||||
| `rain` ||||||
| `snow` ||||||
| Type | `scale` | `direction` | `speed` | `lifetime` | `density` | `tint` |
| ------------ | :-----: | :---------: | :-----: | :--------: | :-------: | :----: |
| `snowstorm` |||| |||
| `bubbles` || || |||
| `clouds` |||| | ||
| `embers` || || |||
| `rainsimple` |||| |||
| `stars` || || |||
| `crows` || || |||
| `bats` || || |||
| `spiders` || || |||
| `fog` || || |||
| `raintop` |||| |||
| `birds` || || |||
| `leaves` || || |||
| `rain` |||| |||
| `snow` |||| |||

#### Weather Effect Options

Expand All @@ -118,6 +118,7 @@ You can get a complete list by typing `CONFIG.fxmaster.filters` in your web cons
| `scale` | `number` | A factor that scales the effect relative to its base size. |
| `direction` | `number` | The direction of the effect in degrees. |
| `speed` | `number` | A factor that adjusts the speed of the effect relative to its base speed. |
| `lieftime` | `number` | A factor that adjusts the lifetime of the individual particles. |
| `density` | `number` | The density of the effect. For most effects, it represents the number of particles per grid unit. |
| `tint` | `{value: string, apply: boolean}` | Tint the effect with this color. |

Expand Down
1 change: 1 addition & 0 deletions src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"FXMASTER.Scale": "Scale",
"FXMASTER.ScaleHint": "Video scaling",
"FXMASTER.Speed": "Speed",
"FXMASTER.Lifetime": "Lifetime",
"FXMASTER.Blur": "Blur",
"FXMASTER.Bloom": "Bloom",
"FXMASTER.Sepia": "Sepia",
Expand Down
18 changes: 18 additions & 0 deletions src/module/weatherEffects/effects/AbstractWeatherEffect.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ export class AbstractWeatherEffect extends SpecialEffect {
step: 0.1,
decimals: 1,
},
lifetime: {
label: "FXMASTER.Lifetime",
type: "range",
min: 0.1,
value: 1,
max: 5,
step: 0.1,
decimals: 1,
},
density: {
label: "FXMASTER.Density",
type: "range",
Expand Down Expand Up @@ -75,6 +84,7 @@ export class AbstractWeatherEffect extends SpecialEffect {
this._applyScaleToConfig(config);
this._applySpeedToConfig(config);
this._applyDirectionToConfig(config);
this._applyLifetimeToConfig(config);
this._applyTintToConfig(config);
}

Expand Down Expand Up @@ -129,6 +139,14 @@ export class AbstractWeatherEffect extends SpecialEffect {
}
}

/** @protected */
_applyLifetimeToConfig(config) {
const lifetime = config.lifetime ?? {};
const factor = this.options.lifetime?.value ?? 1;
this._applyFactorToBasicTweenableOrValueListOrRandNumber(lifetime, factor);
config.frequency *= factor;
}

/** @protected */
_applyTintToConfig(config) {
if (this.options.tint?.value.apply) {
Expand Down

0 comments on commit edc7972

Please sign in to comment.