@zaisma/effects 0.0.0-stage → 1.0.1
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/EFFECT-FILES.md +301 -0
- package/LICENSE.txt +93 -0
- package/README.md +63 -2
- package/batches/chunks.js +294 -0
- package/batches/marks.js +160 -0
- package/batches/ribbons.js +233 -0
- package/batches/shared.js +155 -0
- package/batches/sprites.js +447 -0
- package/batches/warps.js +222 -0
- package/budget.js +115 -0
- package/debris.js +173 -0
- package/emit.js +143 -0
- package/flashes.js +113 -0
- package/format.js +365 -0
- package/index.d.ts +373 -0
- package/index.js +1168 -0
- package/library/bubbles_rising.json +47 -0
- package/library/bullet_impact.json +588 -0
- package/library/campfire.json +235 -0
- package/library/candle_flame.json +100 -0
- package/library/confetti.json +165 -0
- package/library/dash_burst.json +73 -0
- package/library/debris_glass.json +96 -0
- package/library/debris_metal.json +106 -0
- package/library/debris_stone.json +106 -0
- package/library/debris_wood.json +101 -0
- package/library/dust_motes.json +51 -0
- package/library/dust_puff.json +49 -0
- package/library/electric_sparks.json +175 -0
- package/library/embers_drift.json +55 -0
- package/library/exhaust_puff.json +62 -0
- package/library/explosion_air.json +232 -0
- package/library/explosion_large.json +373 -0
- package/library/explosion_magic.json +266 -0
- package/library/explosion_medium.json +289 -0
- package/library/explosion_small.json +289 -0
- package/library/explosion_water.json +177 -0
- package/library/falling_leaves.json +54 -0
- package/library/fire_burst.json +185 -0
- package/library/fire_large.json +279 -0
- package/library/fireball.json +288 -0
- package/library/fireflies.json +51 -0
- package/library/firework_burst.json +127 -0
- package/library/footstep.json +270 -0
- package/library/fountain_spray.json +80 -0
- package/library/frost_burst.json +202 -0
- package/library/ground_mist.json +50 -0
- package/library/ground_slam.json +122 -0
- package/library/heat_haze.json +24 -0
- package/library/hit_blade.json +150 -0
- package/library/hit_block.json +157 -0
- package/library/hit_critical.json +293 -0
- package/library/hit_heavy.json +211 -0
- package/library/hit_light.json +122 -0
- package/library/hit_magic.json +114 -0
- package/library/impact.json +417 -0
- package/library/impact_heavy.json +279 -0
- package/library/index.json +464 -0
- package/library/jump_puff.json +46 -0
- package/library/landing_heavy.json +105 -0
- package/library/landing_puff.json +75 -0
- package/library/level_up.json +164 -0
- package/library/lightning_arc.json +90 -0
- package/library/lightning_strike.json +387 -0
- package/library/magic_aura.json +127 -0
- package/library/magic_bolt.json +107 -0
- package/library/magic_bolt_impact.json +181 -0
- package/library/magic_cast.json +115 -0
- package/library/magic_charge.json +91 -0
- package/library/magic_heal.json +123 -0
- package/library/magic_shield.json +89 -0
- package/library/magic_teleport.json +177 -0
- package/library/mark_bullet_hole.json +20 -0
- package/library/mark_crack.json +18 -0
- package/library/mark_footprint.json +20 -0
- package/library/mark_frost.json +18 -0
- package/library/mark_puddle.json +18 -0
- package/library/mark_scorch.json +18 -0
- package/library/mark_slash.json +18 -0
- package/library/mark_splat.json +18 -0
- package/library/pickup_collect.json +117 -0
- package/library/pickup_glow.json +76 -0
- package/library/poison_cloud.json +107 -0
- package/library/portal.json +328 -0
- package/library/shockwave_air.json +71 -0
- package/library/shockwave_ground.json +95 -0
- package/library/slide_dust.json +48 -0
- package/library/smoke_column.json +93 -0
- package/library/smoke_puff.json +48 -0
- package/library/smoke_screen.json +87 -0
- package/library/sparks_burst.json +85 -0
- package/library/sparks_fountain.json +93 -0
- package/library/sparks_shower.json +89 -0
- package/library/splash_large.json +181 -0
- package/library/splash_small.json +111 -0
- package/library/steam_vent.json +64 -0
- package/library/summon_circle.json +494 -0
- package/library/swim_splash.json +77 -0
- package/library/torch_flame.json +219 -0
- package/library/trail_blade.json +39 -0
- package/library/trail_blade_fire.json +90 -0
- package/library/trail_dash.json +80 -0
- package/library/trail_magic.json +94 -0
- package/library/trail_projectile.json +31 -0
- package/library/trail_smoke.json +125 -0
- package/library/warp_pulse.json +22 -0
- package/library/warp_ripple.json +23 -0
- package/library/water_ripple.json +69 -0
- package/library/waterfall_mist.json +95 -0
- package/looks.js +162 -0
- package/motion.js +145 -0
- package/online.d.ts +79 -0
- package/online.js +32 -0
- package/package.json +69 -4
- package/partners.js +255 -0
- package/piece.json +415 -0
- package/piece.json.js +416 -0
- package/server.d.ts +55 -0
- package/server.js +26 -0
- package/shapes.js +269 -0
- package/sync.js +528 -0
- package/tables.js +109 -0
- package/weather.js +289 -0
package/EFFECT-FILES.md
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
# Effect files
|
|
2
|
+
|
|
3
|
+
An effect for `@zaisma/effects` is one small JSON file: `explosion_large.json`. This page is everything needed to write one. The files in `library/` are worked examples of every kind; start from the nearest one.
|
|
4
|
+
|
|
5
|
+
An effect file says **what happens** (what's emitted, how it moves, how it fades, when). It never says how that's drawn: the game's look does (`cartoon`, `glowing`, `faceted`, `realistic`, or the game's own), so one file plays in every look. Write the behaviour and real-world colours, and each look draws it its own way.
|
|
6
|
+
|
|
7
|
+
## Rules
|
|
8
|
+
|
|
9
|
+
- **Every field is named with its unit:** `_sec`, `_m`, `_m_per_sec`, `_deg`, `_pct`, `_count`, `_per_sec`, `_lux`.
|
|
10
|
+
- **Closed:** an unknown field, a value out of range or a word not in a list is refused, with the field and the fix. Check a file before using it: `checkEffect(file)` answers a list of problems, each `{ code, message, field, fix }`, empty when it's right. The workbench shows the same as the file is saved.
|
|
11
|
+
- **Only `effect_format_version_number`, `name` and `elements` are required.** Every other field has a default: leave out what the default already says.
|
|
12
|
+
- **The file's name is the effect's name:** `fire_burst.json` holds `"name": "fire_burst"`. Lowercase words joined by underscores, up to 40 characters.
|
|
13
|
+
- **Up to 16 elements** an effect. Most need two to six.
|
|
14
|
+
- **Sizes are in metres and real.** A campfire's flame is 0.3 m, an explosion 4 m. A game plays an effect bigger or smaller with `scalePct`, so write it at its natural size.
|
|
15
|
+
- **A list "over life"** (`size_over_life_m`, `colors_over_life`, `opacity_over_life_pct`) is evenly spaced keys from birth to death: `[0, 100, 0]` fades in then out; one key is constant.
|
|
16
|
+
|
|
17
|
+
## An example
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"effect_format_version_number": 1,
|
|
22
|
+
"name": "hit_light",
|
|
23
|
+
"summary": "A quick bright pop with a few sparks: a jab, a light weapon landing.",
|
|
24
|
+
"family": "hits",
|
|
25
|
+
"elements": [
|
|
26
|
+
{
|
|
27
|
+
"element_kind": "particles",
|
|
28
|
+
"material": "glow",
|
|
29
|
+
"emit": {
|
|
30
|
+
"burst_count": 1
|
|
31
|
+
},
|
|
32
|
+
"move": {
|
|
33
|
+
"speed_m_per_sec": 0
|
|
34
|
+
},
|
|
35
|
+
"fade": {
|
|
36
|
+
"life_sec": 0.1,
|
|
37
|
+
"life_variation_pct": 0,
|
|
38
|
+
"size_over_life_m": [0.2, 0.7, 0.45],
|
|
39
|
+
"size_variation_pct": 0,
|
|
40
|
+
"colors_over_life": ["#fffbe0", "#ffd870"],
|
|
41
|
+
"opacity_over_life_pct": [100, 60, 0],
|
|
42
|
+
"glow_pct": 150
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"element_kind": "particles",
|
|
47
|
+
"material": "glow",
|
|
48
|
+
"emit": {
|
|
49
|
+
"burst_count": 1
|
|
50
|
+
},
|
|
51
|
+
"move": {
|
|
52
|
+
"speed_m_per_sec": 0
|
|
53
|
+
},
|
|
54
|
+
"fade": {
|
|
55
|
+
"life_sec": 0.16,
|
|
56
|
+
"life_variation_pct": 0,
|
|
57
|
+
"size_over_life_m": [0.3, 0.95, 0.8],
|
|
58
|
+
"size_variation_pct": 0,
|
|
59
|
+
"colors_over_life": ["#ffffff", "#ffe070"],
|
|
60
|
+
"opacity_over_life_pct": [100, 100, 0],
|
|
61
|
+
"glow_pct": 120,
|
|
62
|
+
"spin_deg_per_sec": 1
|
|
63
|
+
},
|
|
64
|
+
"shape": "star",
|
|
65
|
+
"look_names": ["cartoon"]
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"element_kind": "particles",
|
|
69
|
+
"material": "spark",
|
|
70
|
+
"emit": {
|
|
71
|
+
"burst_count": 8
|
|
72
|
+
},
|
|
73
|
+
"move": {
|
|
74
|
+
"direction_kind": "along",
|
|
75
|
+
"speed_m_per_sec": 5,
|
|
76
|
+
"speed_variation_pct": 60,
|
|
77
|
+
"drag_per_sec": 1.2,
|
|
78
|
+
"gravity_pct": 100,
|
|
79
|
+
"spread_deg": 70
|
|
80
|
+
},
|
|
81
|
+
"fade": {
|
|
82
|
+
"life_sec": 0.3,
|
|
83
|
+
"life_variation_pct": 50,
|
|
84
|
+
"size_over_life_m": [0.06, 0.025],
|
|
85
|
+
"size_variation_pct": 40,
|
|
86
|
+
"colors_over_life": ["#fff6d8", "#ffb040", "#ff5a10"],
|
|
87
|
+
"opacity_over_life_pct": [100, 100, 0],
|
|
88
|
+
"glow_pct": 380,
|
|
89
|
+
"facing_kind": "velocity",
|
|
90
|
+
"streak_duration_sec": 0.05
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"element_kind": "flash",
|
|
95
|
+
"color": "#ffe0a0",
|
|
96
|
+
"strength_lux": 6,
|
|
97
|
+
"radius_m": 4,
|
|
98
|
+
"duration_sec": 0.12,
|
|
99
|
+
"strength_over_life_pct": [100, 45, 0]
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Four elements: a ball of light that swells and goes, a drawn star that only the cartoon look shows (`look_names`), sparks thrown along the surface's normal, and a flash that lights the scene for an eighth of a second.
|
|
106
|
+
|
|
107
|
+
## The effect
|
|
108
|
+
|
|
109
|
+
| Field | Takes | Default | What it is |
|
|
110
|
+
| --- | --- | --- | --- |
|
|
111
|
+
| `effect_format_version_number` (required) | whole number, 1 to 1 | | The format this file is written in: 1. |
|
|
112
|
+
| `name` (required) | text, up to 40 characters | | The effect's name, what play() takes: lowercase words joined by underscores. |
|
|
113
|
+
| `summary` | text, up to 200 characters | | A sentence on what it looks like and what it's for. |
|
|
114
|
+
| `family` | one of the list below | `"other"` | The group it's listed under in the workbench. |
|
|
115
|
+
| `importance` | `low`, `normal`, `high` | `"normal"` | Which effects thin out first when the device's budget is spent: low goes first, high last. |
|
|
116
|
+
| `is_looping` | `true` or `false` | `false` | Whether it plays until stopped (a campfire, an aura) instead of once. |
|
|
117
|
+
| `duration_sec` | number, 0.01 to 600 | `1` | How long its emitters run. A looping effect starts over each time this passes. |
|
|
118
|
+
| `elements` (required) | 1 to 16 elements | | What the effect is made of, each one of the kinds below. They all start with the effect, each after its own `start_delay_sec`. |
|
|
119
|
+
|
|
120
|
+
`family` is one of: `hits`, `explosions`, `magic`, `fire`, `smoke`, `sparks`, `water`, `trails`, `shockwaves`, `marks`, `warps`, `debris`, `character`, `weather`, `ambient`, `other`.
|
|
121
|
+
|
|
122
|
+
## Every element
|
|
123
|
+
|
|
124
|
+
| Field | Takes | Default | What it is |
|
|
125
|
+
| --- | --- | --- | --- |
|
|
126
|
+
| `element_kind` (required) | `particles`, `debris`, `ribbon`, `beam`, `flash`, `mark`, `warp`, `shake` | | What this element is. |
|
|
127
|
+
| `start_delay_sec` | number, 0 to 60 | `0` | How long after the effect starts this element does. |
|
|
128
|
+
| `surface_kinds` | a list of them, or `null` | `null` | The surfaces this element plays on, from the play's surfaceKind: sparks on metal, splinters on wood. null plays on any. |
|
|
129
|
+
| `look_names` | a list of them, or `null` | `null` | The looks this element plays in. null plays in every look. |
|
|
130
|
+
| `minimum_quality_level` | `low`, `medium`, `high` | `"low"` | The lowest quality level this element plays at: an extra layer of smoke only strong devices draw. |
|
|
131
|
+
|
|
132
|
+
Surface kinds: `stone`, `concrete`, `metal`, `wood`, `dirt`, `gravel`, `sand`, `grass`, `mud`, `water`, `snow`, `ice`, `glass`, `carpet`, `flesh`. A game says what an effect lands on with `play(name, { surfaceKind })`; an element with `surface_kinds` plays only on those, so one `bullet_impact` throws sparks off metal and splinters off wood.
|
|
133
|
+
|
|
134
|
+
## `particles`
|
|
135
|
+
|
|
136
|
+
Many small things that are born, move and fade: the fire, smoke, sparks, dust, water and magic of an effect. Three groups say what happens: `emit` (how many, when, from where), `move` (which way, how fast, what pulls on them) and `fade` (how long each lives and how its size, colour and opacity change over that life). `material` says what they are; the look in use decides how that's drawn.
|
|
137
|
+
|
|
138
|
+
| Field | Takes | Default | What it is |
|
|
139
|
+
| --- | --- | --- | --- |
|
|
140
|
+
| `material` (required) | one of the list below | | What the particles are made of. The look in use draws each material its own way. |
|
|
141
|
+
| `shape` | one of the list below, or `null` | `null` | A shape to draw instead of the look's own for this material. null takes the look's. |
|
|
142
|
+
| `emit.burst_count` | whole number, 0 to 2000 | `0` | How many particles it throws at once as it starts, and again each time a looping effect starts over. |
|
|
143
|
+
| `emit.per_sec` | number, 0 to 5000 | `0` | How many particles it gives off each second while it runs. |
|
|
144
|
+
| `emit.emit_duration_sec` | number, 0.01 to 600, or `null` | `null` | How long it gives off particles. null runs as long as the effect. |
|
|
145
|
+
| `emit.from_kind` | `point`, `sphere`, `ring`, `box`, `line` | `"point"` | Where particles start: a point, inside a sphere, on a flat ring, inside a box, or along a line through the effect's direction. |
|
|
146
|
+
| `emit.from_radius_m` | number, 0 to 200 | `0` | The sphere's or ring's radius, or half the line's length, in metres. |
|
|
147
|
+
| `emit.from_size_m` | 3 numbers, each 0 to 400 | `[1,1,1]` | The box's width, height and depth, in metres. |
|
|
148
|
+
| `emit.is_from_edge` | `true` or `false` | `false` | Whether particles start only on the sphere's shell or the ring's rim, never inside. |
|
|
149
|
+
| `move.direction_kind` | `outward`, `along`, `up`, `random`, `inward` | `"outward"` | Which way particles set off: outward from the centre, along the play's direction, up, any way at random, or inward toward the centre. |
|
|
150
|
+
| `move.spread_deg` | number, 0 to 180 | `0` | How far from its direction a particle may start, in degrees: 0 is exact, 180 is anywhere. |
|
|
151
|
+
| `move.speed_m_per_sec` | number, 0 to 200 | `1` | How fast a particle sets off. |
|
|
152
|
+
| `move.speed_variation_pct` | number, 0 to 100 | `30` | How much each particle's speed differs from that, either way. |
|
|
153
|
+
| `move.gravity_pct` | number, -1000 to 1000 | `0` | How much of gravity pulls it down: 100 falls like a stone, 0 floats, below 0 rises like smoke. |
|
|
154
|
+
| `move.drag_per_sec` | number, 0 to 30 | `0` | How quickly the air slows it: 0 keeps its speed, 3 loses most of it in a second. |
|
|
155
|
+
| `move.wind_pct` | number, 0 to 400 | `0` | How much the wind carries it: 0 ignores the wind, 100 drifts with it like smoke. |
|
|
156
|
+
| `move.turbulence_m` | number, 0 to 20 | `0` | How far it wanders off its path, in metres: embers that waver, smoke that curls. |
|
|
157
|
+
| `move.turbulence_per_sec` | number, 0.05 to 20 | `1` | How quickly it wanders: low is a slow curl, high a jitter. |
|
|
158
|
+
| `move.swirl_deg_per_sec` | number, -3600 to 3600 | `0` | How fast particles circle the effect's axis: a vortex, a spell winding up. |
|
|
159
|
+
| `move.pull_pct` | number, -100 to 100 | `0` | How far particles are drawn to the centre over their life: 100 arrives there as it ends (a charge gathering), below 0 pushes away. |
|
|
160
|
+
| `move.is_attached` | `true` or `false` | `false` | Whether live particles move with the effect when it moves (an aura), instead of staying where they were let go (a trail). |
|
|
161
|
+
| `fade.life_sec` | number, 0.02 to 120 | `1` | How long a particle lasts. |
|
|
162
|
+
| `fade.life_variation_pct` | number, 0 to 100 | `25` | How much each particle's life differs from that, either way. |
|
|
163
|
+
| `fade.size_over_life_m` | 2 to 4 numbers, each 0 to 200 | `[0.2,0.2]` | How big across it is through its life, in metres: 2 to 4 values spread evenly from birth to end. |
|
|
164
|
+
| `fade.size_variation_pct` | number, 0 to 100 | `25` | How much each particle's size differs, either way. |
|
|
165
|
+
| `fade.colors_over_life` | 1 to 4 colours | `["#ffffff"]` | Its colour through its life: 1 to 4 colours spread evenly from birth to end. |
|
|
166
|
+
| `fade.opacity_over_life_pct` | 2 to 4 numbers, each 0 to 100 | `[100,0]` | How solid it is through its life: 2 to 4 values spread evenly. |
|
|
167
|
+
| `fade.glow_pct` | number, 0 to 3000 | `100` | How bright it is against its colour: 100 as coloured, above that it shines and blooms. |
|
|
168
|
+
| `fade.facing_kind` | `camera`, `velocity`, `ground`, `along` | `"camera"` | How it turns: to face the camera, stretched along its own motion (sparks, rain), flat on the ground (a ring spreading), or flat across the effect's direction. |
|
|
169
|
+
| `fade.streak_duration_sec` | number, 0 to 1 | `0.03` | With facing_kind velocity: it's drawn as long as the way it travels in this time. |
|
|
170
|
+
| `fade.spin_deg_per_sec` | number, 0 to 3600 | `0` | How fast it turns on itself; each particle turns its own way. |
|
|
171
|
+
| `fade.is_upright` | `true` or `false` | `true` | With a flame or a drop facing the camera: whether it stands upright and sways (a campfire), or turns its own way like the rest (flames churning round a fireball in flight). |
|
|
172
|
+
|
|
173
|
+
## `debris`
|
|
174
|
+
|
|
175
|
+
A few solid chunks thrown out that fall, bounce off the level and come to rest: rubble, splinters, shell casings. Each is simulated, so keep counts small.
|
|
176
|
+
|
|
177
|
+
| Field | Takes | Default | What it is |
|
|
178
|
+
| --- | --- | --- | --- |
|
|
179
|
+
| `material` (required) | one of the list below | | What the chunks are made of: their shape and how they catch the light. |
|
|
180
|
+
| `count` | whole number, 1 to 200 | `8` | How many chunks fly off. |
|
|
181
|
+
| `from_radius_m` | number, 0 to 50 | `0.1` | How far from the centre chunks start, in metres. |
|
|
182
|
+
| `direction_kind` | `outward`, `along`, `up`, `random`, `inward` | `"outward"` | Which way chunks set off. |
|
|
183
|
+
| `spread_deg` | number, 0 to 180 | `0` | How far from its direction a particle may start, in degrees: 0 is exact, 180 is anywhere. |
|
|
184
|
+
| `speed_m_per_sec` | number, 0 to 100 | `5` | How fast a chunk sets off. |
|
|
185
|
+
| `speed_variation_pct` | number, 0 to 100 | `40` | How much each chunk's speed differs, either way. |
|
|
186
|
+
| `gravity_pct` | number, -1000 to 1000 | `100` | How much of gravity pulls it down: 100 falls like a stone, 0 floats, below 0 rises like smoke. |
|
|
187
|
+
| `bounce_pct` | number, 0 to 100 | `40` | How much of its speed a chunk keeps when it bounces. |
|
|
188
|
+
| `grip_pct` | number, 0 to 100 | `50` | How much a surface slows a chunk sliding along it. |
|
|
189
|
+
| `size_m` | number, 0.01 to 5 | `0.12` | How big a chunk is across, in metres. |
|
|
190
|
+
| `size_variation_pct` | number, 0 to 100 | `50` | How much each chunk's size differs, either way. |
|
|
191
|
+
| `life_sec` | number, 0.1 to 120 | `3` | How long a chunk lasts before it shrinks away. |
|
|
192
|
+
| `colors` | 1 to 4 colours | `["#8a8a8a"]` | The chunks' colours: each chunk takes one. |
|
|
193
|
+
| `spin_deg_per_sec` | number, 0 to 3600 | `360` | How fast a chunk tumbles in the air. |
|
|
194
|
+
| `bounce_effect_name` | text, up to 40 characters, or `null` | `null` | An effect played small where a chunk first lands: a puff of dust. null plays none. |
|
|
195
|
+
|
|
196
|
+
## `ribbon`
|
|
197
|
+
|
|
198
|
+
A strip drawn along the path the play has moved: a blade's arc, a projectile's trail. It needs a play that moves (`follow`, or `moveTo` each frame). With `from_offset_m` and `to_offset_m` apart it spans an edge, like a blade from hilt to tip.
|
|
199
|
+
|
|
200
|
+
| Field | Takes | Default | What it is |
|
|
201
|
+
| --- | --- | --- | --- |
|
|
202
|
+
| `life_sec` | number, 0.02 to 10 | `0.3` | How long each part of the trail lasts behind what it follows. |
|
|
203
|
+
| `width_over_length_m` | 2 to 4 numbers, each 0 to 20 | `[0.2,0]` | How wide it is from its head to its tail, in metres: 2 to 4 values spread evenly. |
|
|
204
|
+
| `colors_over_length` | 1 to 4 colours | `["#ffffff"]` | Its colour from its head to its tail. |
|
|
205
|
+
| `opacity_over_length_pct` | 2 to 4 numbers, each 0 to 100 | `[100,0]` | How solid it is from its head to its tail. |
|
|
206
|
+
| `glow_pct` | number, 0 to 3000 | `100` | How bright it is against its colour. |
|
|
207
|
+
| `minimum_step_m` | number, 0.005 to 5 | `0.05` | How far what it follows must move before the trail gains a point: smaller is smoother. |
|
|
208
|
+
| `from_offset_m` | 3 numbers, each -50 to 50 | `[0,0,0]` | Where the trail's edge is on what it follows, in that object's own space: a blade's base. |
|
|
209
|
+
| `to_offset_m` | 3 numbers, each -50 to 50 | `[0,0,0]` | The trail's other edge: a blade's tip. The same as from_offset_m draws a ribbon of its width facing the camera. |
|
|
210
|
+
|
|
211
|
+
## `beam`
|
|
212
|
+
|
|
213
|
+
A line from the play's place to its `toPositionM`: lightning, a laser, a tether. Without one it reaches `reach_m` along the effect's direction, and `spread_deg` turns each path off it: electricity crackling at a spot. `jitter_m` makes it jagged.
|
|
214
|
+
|
|
215
|
+
| Field | Takes | Default | What it is |
|
|
216
|
+
| --- | --- | --- | --- |
|
|
217
|
+
| `life_sec` | number, 0.02 to 60 | `0.15` | How long it shows. |
|
|
218
|
+
| `width_m` | number, 0.005 to 20 | `0.1` | How wide it is, in metres. |
|
|
219
|
+
| `segment_count` | whole number, 1 to 64 | `1` | How many straight parts it's made of: 1 is a straight line, more lets it be jagged. |
|
|
220
|
+
| `jitter_m` | number, 0 to 10 | `0` | How far each joint strays off the straight line, in metres: lightning. |
|
|
221
|
+
| `rejitter_per_sec` | number, 0 to 120 | `0` | How often it takes a new jagged path while it shows; 0 keeps its first. |
|
|
222
|
+
| `reach_m` | number, 0.05 to 200 | `10` | With no toPositionM given: how far it reaches along the effect's direction, in metres, scaled with the effect. |
|
|
223
|
+
| `spread_deg` | number, 0 to 180 | `0` | With no toPositionM given: how far each path turns off the effect's direction, at random: 180 strikes any way, crackling electricity. |
|
|
224
|
+
| `tip_width_pct` | number, 0 to 100 | `100` | How wide it is at its far end, as a share of its width: below 100 it tapers like an arc or a branch. |
|
|
225
|
+
| `colors_over_life` | 1 to 4 colours | `["#ffffff"]` | Its colour through its life. |
|
|
226
|
+
| `opacity_over_life_pct` | 2 to 4 numbers, each 0 to 100 | `[100,0]` | How solid it is through its life. |
|
|
227
|
+
| `glow_pct` | number, 0 to 3000 | `300` | How bright it is against its colour. |
|
|
228
|
+
|
|
229
|
+
## `flash`
|
|
230
|
+
|
|
231
|
+
A light that lights the scene for a moment, or for as long as a looping effect plays. The brightest, nearest flashes throw real light; the rest only glow.
|
|
232
|
+
|
|
233
|
+
| Field | Takes | Default | What it is |
|
|
234
|
+
| --- | --- | --- | --- |
|
|
235
|
+
| `color` | a colour, `"#rrggbb"` in lowercase | `"#ffd9a0"` | The light's colour. |
|
|
236
|
+
| `strength_lux` | number, 0 to 2000 | `20` | How bright it lights a surface one metre away, on the lighting piece's scale: its sun at noon is about 3. |
|
|
237
|
+
| `radius_m` | number, 0.1 to 200 | `8` | How far the light reaches, in metres. |
|
|
238
|
+
| `duration_sec` | number, 0.01 to 600 | `0.2` | How long it shines. In a looping effect it starts over with the effect. |
|
|
239
|
+
| `strength_over_life_pct` | 2 to 4 numbers, each 0 to 100 | `[100,0]` | How bright it is through its life: 2 to 4 values spread evenly. |
|
|
240
|
+
| `flicker_pct` | number, 0 to 100 | `0` | How much it flickers, like a flame. |
|
|
241
|
+
| `offset_m` | 3 numbers, each -50 to 50 | `[0,0,0]` | Where the light is from the effect's place, in metres: a little above the ground, so the ground is lit. |
|
|
242
|
+
|
|
243
|
+
## `mark`
|
|
244
|
+
|
|
245
|
+
A mark left on the nearest surface: a scorch, a crack, a splat. It stays after the effect is over, and the oldest go first.
|
|
246
|
+
|
|
247
|
+
| Field | Takes | Default | What it is |
|
|
248
|
+
| --- | --- | --- | --- |
|
|
249
|
+
| `shape` (required) | `scorch`, `crack`, `splat`, `slash`, `hole`, `print`, `puddle`, `frost` | | What's left on the surface. |
|
|
250
|
+
| `size_m` | number, 0.01 to 50 | `0.5` | How big it is across, in metres. |
|
|
251
|
+
| `size_variation_pct` | number, 0 to 100 | `20` | How much each mark's size differs, either way. |
|
|
252
|
+
| `life_sec` | number, 0.1 to 600 | `20` | How long it stays before it fades. |
|
|
253
|
+
| `color` | a colour, `"#rrggbb"` in lowercase | `"#1a1410"` | Its colour. |
|
|
254
|
+
| `opacity_pct` | number, 0 to 100 | `80` | How solid it is. |
|
|
255
|
+
| `glow_color` | a colour, `"#rrggbb"` in lowercase | `"#ff6a1a"` | The colour it glows while hot. |
|
|
256
|
+
| `glow_duration_sec` | number, 0 to 60 | `0` | How long it glows before it cools; 0 never glows. |
|
|
257
|
+
| `search_distance_m` | number, 0 to 50 | `1.5` | How far from the effect's place a surface is looked for, against the play's normal (or down), in metres. |
|
|
258
|
+
|
|
259
|
+
## `warp`
|
|
260
|
+
|
|
261
|
+
A bend in the picture: a shockwave's ripple, a swell, the shimmer over heat. Off at low quality.
|
|
262
|
+
|
|
263
|
+
| Field | Takes | Default | What it is |
|
|
264
|
+
| --- | --- | --- | --- |
|
|
265
|
+
| `warp_kind` | `ripple`, `pulse`, `haze` | `"ripple"` | How it bends the picture: a ring spreading out, a bulge, or the shimmer over heat. |
|
|
266
|
+
| `life_sec` | number, 0.02 to 600 | `0.5` | How long it lasts. A haze in a looping effect lasts while the effect plays. |
|
|
267
|
+
| `radius_over_life_m` | 2 to 4 numbers, each 0 to 200 | `[0.2,3]` | How far it reaches through its life, in metres. |
|
|
268
|
+
| `strength_over_life_pct` | 2 to 4 numbers, each 0 to 100 | `[60,0]` | How hard it bends the picture through its life. |
|
|
269
|
+
| `thickness_pct` | number, 5 to 100 | `30` | How thick a ripple's ring is, against its radius. |
|
|
270
|
+
|
|
271
|
+
## `shake`
|
|
272
|
+
|
|
273
|
+
A shake of the camera, fading with distance.
|
|
274
|
+
|
|
275
|
+
| Field | Takes | Default | What it is |
|
|
276
|
+
| --- | --- | --- | --- |
|
|
277
|
+
| `strength_pct` | number, 0 to 100 | `30` | How hard the camera shakes for a player standing at the effect. |
|
|
278
|
+
| `duration_sec` | number, 0.02 to 10 | `0.3` | How long it shakes, fading out. |
|
|
279
|
+
| `radius_m` | number, 0.5 to 500 | `15` | How far away it's felt, fading with distance, in metres. |
|
|
280
|
+
|
|
281
|
+
## The lists
|
|
282
|
+
|
|
283
|
+
- **Materials** (`material`): `fire`, `smoke`, `spark`, `ember`, `dust`, `water`, `mist`, `magic`, `glow`, `energy`, `snow`, `leaf`, `stone`, `wood`, `metal`, `glass`. Pick what the thing is: the look decides its shape, whether it glows, whether it's lit, and how many are drawn.
|
|
284
|
+
- **Shapes** (`shape`): `soft`, `disc`, `puff`, `flame`, `streak`, `star`, `ring`, `shard`, `drop`, `flake`, `splat`, `leaf`, `cross`, `wisp`, `bubble`, `diamond`, `crescent`, `angular_flame`. Leave it `null` and the look picks. Name one only for a figure the effect means exactly (a `ring` spreading on the ground, a `star` that pops): a named shape keeps its size and count in every look.
|
|
285
|
+
- **Where particles start** (`emit.from_kind`): `point`, `sphere`, `ring`, `box`, `line`.
|
|
286
|
+
- **Which way they go** (`move.direction_kind`): `outward`, `along`, `up`, `random`, `inward`. `along` is the play's direction or the surface's normal; `outward` is away from the middle.
|
|
287
|
+
- **How a particle faces** (`fade.facing_kind`): `camera`, `velocity`, `ground`, `along`. `velocity` stretches it along its motion (sparks, rain); `ground` lays it flat; `along` lays it across the play's direction (a ring on the wall that was hit).
|
|
288
|
+
- **Mark shapes** (`mark.shape`): `scorch`, `crack`, `splat`, `slash`, `hole`, `print`, `puddle`, `frost`.
|
|
289
|
+
- **Warp kinds** (`warp_kind`): `ripple`, `pulse`, `haze`.
|
|
290
|
+
|
|
291
|
+
## What makes an effect read
|
|
292
|
+
|
|
293
|
+
- **Layer it.** A good hit is a flash of light, a core that pops, sparks that fly and dust that lingers, each a separate element with its own timing. One element rarely reads.
|
|
294
|
+
- **Stagger with `start_delay_sec`:** the flash at 0, the smoke 0.05 s later, the embers after that.
|
|
295
|
+
- **Fast in, slow out.** Things appear at once and take their time leaving: `opacity_over_life_pct: [100, 80, 0]`, sizes that grow as they fade.
|
|
296
|
+
- **Few and big beats many and small** on a phone. A burst of 12 well-sized puffs costs less than 60 small ones and reads better. Each look also scales counts its own way.
|
|
297
|
+
- **`importance`** decides what thins out first when a device's budget is spent: `low` for ambience and footsteps, `high` for what the player must see.
|
|
298
|
+
- **`minimum_quality_level`** keeps an extra layer for devices that can afford it: a second sheet of smoke at `high`, a warp at `medium`.
|
|
299
|
+
- **Glow.** `glow_pct` above 100 is brighter than white and blooms when the game has bloom on: about 170 for fire, 300 to 400 for sparks.
|
|
300
|
+
- **Wind.** `move.wind_pct` is how much the game's wind carries a particle: 100 for smoke and leaves, 0 for a spark.
|
|
301
|
+
- **Sound isn't in the file.** The piece tells the game `effect_started` with the effect's name, and the game (or the sound piece) plays the sound that goes with it.
|
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# PolyForm Shield License 1.0.0
|
|
2
|
+
|
|
3
|
+
<https://polyformproject.org/licenses/shield/1.0.0>
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
|
|
8
|
+
|
|
9
|
+
## Copyright License
|
|
10
|
+
|
|
11
|
+
The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
|
|
12
|
+
|
|
13
|
+
## Distribution License
|
|
14
|
+
|
|
15
|
+
The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
|
|
16
|
+
|
|
17
|
+
## Notices
|
|
18
|
+
|
|
19
|
+
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
|
|
20
|
+
|
|
21
|
+
> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
|
|
22
|
+
|
|
23
|
+
## Changes and New Works License
|
|
24
|
+
|
|
25
|
+
The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
|
|
26
|
+
|
|
27
|
+
## Patent License
|
|
28
|
+
|
|
29
|
+
The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
|
|
30
|
+
|
|
31
|
+
## Noncompete
|
|
32
|
+
|
|
33
|
+
Any purpose is a permitted purpose, except for providing any product that competes with the software or any product the licensor or any of its affiliates provides using the software.
|
|
34
|
+
|
|
35
|
+
## Competition
|
|
36
|
+
|
|
37
|
+
Goods and services compete even when they provide functionality through different kinds of interfaces or for different technical platforms. Applications can compete with services, libraries with plugins, frameworks with development tools, and so on, even if they're written in different programming languages or for different computer architectures. Goods and services compete even when provided free of charge. If you market a product as a practical substitute for the software or another product, it definitely competes.
|
|
38
|
+
|
|
39
|
+
## New Products
|
|
40
|
+
|
|
41
|
+
If you are using the software to provide a product that does not compete, but the licensor or any of its affiliates brings your product into competition by providing a new version of the software or another product using the software, you may continue using versions of the software available under these terms beforehand to provide your competing product, but not any later versions.
|
|
42
|
+
|
|
43
|
+
## Discontinued Products
|
|
44
|
+
|
|
45
|
+
You may begin using the software to compete with a product or service that the licensor or any of its affiliates has stopped providing, unless the licensor includes a plain-text line beginning with `Licensor Line of Business:` with the software that mentions that line of business. For example:
|
|
46
|
+
|
|
47
|
+
> Licensor Line of Business: YoyodyneCMS Content Management System (http://example.com/cms)
|
|
48
|
+
|
|
49
|
+
## Sales of Business
|
|
50
|
+
|
|
51
|
+
If the licensor or any of its affiliates sells a line of business developing the software or using the software to provide a product, the buyer can also enforce [Noncompete](#noncompete) for that product.
|
|
52
|
+
|
|
53
|
+
## Fair Use
|
|
54
|
+
|
|
55
|
+
You may have "fair use" rights for the software under the law. These terms do not limit them.
|
|
56
|
+
|
|
57
|
+
## No Other Rights
|
|
58
|
+
|
|
59
|
+
These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
|
|
60
|
+
|
|
61
|
+
## Patent Defense
|
|
62
|
+
|
|
63
|
+
If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
64
|
+
|
|
65
|
+
## Violations
|
|
66
|
+
|
|
67
|
+
The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
|
|
68
|
+
|
|
69
|
+
## No Liability
|
|
70
|
+
|
|
71
|
+
***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
|
|
72
|
+
|
|
73
|
+
## Definitions
|
|
74
|
+
|
|
75
|
+
The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
|
|
76
|
+
|
|
77
|
+
A **product** can be a good or service, or a combination of them.
|
|
78
|
+
|
|
79
|
+
**You** refers to the individual or entity agreeing to these terms.
|
|
80
|
+
|
|
81
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all its affiliates.
|
|
82
|
+
|
|
83
|
+
**Affiliates** means the other organizations than an organization has control over, is under the control of, or is under common control with.
|
|
84
|
+
|
|
85
|
+
**Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
86
|
+
|
|
87
|
+
**Your licenses** are all the licenses granted to you for the software under these terms.
|
|
88
|
+
|
|
89
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
|
90
|
+
|
|
91
|
+
Required Notice: Copyright (c) 2026 Zaisma LLC (https://zaisma.com)
|
|
92
|
+
|
|
93
|
+
Versions of @zaisma/lighting before 1.2.0 were published under the MIT License, and stay under it.
|
package/README.md
CHANGED
|
@@ -1,3 +1,64 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @zaisma/effects
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Spectacle that holds a phone's frame rate, for three.js: thousands of lit particles, hits, explosions, magic, fire, smoke, trails, shockwaves, marks on surfaces, screen warps, debris that bounces and weather, drawn in the look a game picks. An effect is a small file an AI writes, and 92 come with the piece.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
npx @zaisma/cli pieces add @zaisma/effects
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import { createEffects } from "./pieces/@zaisma/effects/index.js";
|
|
11
|
+
|
|
12
|
+
const effects = createEffects({ scene, renderer, lighting, settings: { look: "glowing" } });
|
|
13
|
+
await effects.load(["explosion_large", "hit_heavy", "campfire", "./effects/my_spell.json"]);
|
|
14
|
+
|
|
15
|
+
function frame() {
|
|
16
|
+
effects.update(camera); // before rendering
|
|
17
|
+
renderer.render(scene, camera);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
effects.play("explosion_large", { positionM: { x: 4, y: 0, z: -2 } });
|
|
21
|
+
effects.play("hit_heavy", { positionM: hit.pointM, normal: hit.normal, surfaceKind: "metal" });
|
|
22
|
+
const fire = effects.play("campfire", { positionM: camp }); // a looping effect plays until it's stopped
|
|
23
|
+
fire.stop();
|
|
24
|
+
|
|
25
|
+
effects.settings.set({ rainPct: 60, windSpeedMPerSec: 9 }); // the weather turns, over a few seconds
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
A page with no bundler needs the import map `zaisma pieces add` prints, so the piece finds three.js.
|
|
29
|
+
|
|
30
|
+
## What it does
|
|
31
|
+
|
|
32
|
+
- **Particles that cost nothing while they fly.** A particle is written once, when it's born; the graphics chip places it from the time alone, with its speed, drag, gravity, wind, swirl, pull and turbulence. The page works only for the particles born that frame, so 6,000 in the air cost about what 60 do, in ten draw calls at most however many effects play.
|
|
33
|
+
- **A look is a setting.** `look` draws every effect as `cartoon` (few big shapes, crisp edges, flat tones), `glowing` (soft light that blooms), `faceted` (little low-poly solids with flat faces) or `realistic` (textured, lit by the scene, soft where it meets a surface). It changes while playing, and `effects.defineOwnLook({ basedOnLookName, materials })` makes a game's own from any of them. Every shape is drawn by the piece, so it ships no pictures.
|
|
34
|
+
- **An effect is a file.** What it gives off, how that moves and fades, its flash, its mark, its warp and its shake, in plain fields each named with its unit. [`EFFECT-FILES.md`](EFFECT-FILES.md) is the format, written for an AI; the files in `library/` are the examples. A wrong field is refused with its name and the fix (`checkEffect`).
|
|
35
|
+
- **The library:** hits, explosions, magic (casts, charges, bolts, auras, lightning, frost, healing, portals), fire, smoke, sparks, splashes, trails, shockwaves, marks, warps, debris, and impacts and footsteps that differ by surface. `effects.load("all")` loads every one; a game loads the ones it plays. `library/index.json` lists them.
|
|
36
|
+
- **Lit by the scene.** With the lighting piece given, particles take its sun or moon, its fill light and its fog. The brightest, nearest flashes throw real light on the level (two at medium quality, four at high) and the rest only glow, so twenty explosions cost no more than two.
|
|
37
|
+
- **Marks, debris, warps, shakes.** Scorches and cracks lie on the surface where an effect landed, found with the physics piece's ray test or a `castRay` of the game's own; chunks bounce off the level; a shockwave bends the picture behind it; a blast shakes the camera (the camera piece's, or `effects.shake` for a game's own).
|
|
38
|
+
- **Weather** is settings: `rainPct`, `snowPct`, `fogPct`, `windSpeedMPerSec`, `windDirectionDeg` and `windGustPct`, eased over `weatherChangeDurationSec`. Rain stays out from under roofs and splashes where it lands; wind leans every particle by as much as its effect says. `effects.weather` reads what it is right now, for sound and foliage.
|
|
39
|
+
- **Free with the other pieces.** Given the character, each footfall raises dust, a jump and a landing raise a puff sized by the fall, and water splashes. Given physics, every collision throws an impact sized by its speed and weight. `footstepEffectsEnabled`, `landingEffectsEnabled` and `impactEffectsEnabled` turn each off; `beforeEffect` swaps or tints any of them, and `surfaceKindAt` says what the ground is.
|
|
40
|
+
- **A budget, never a stall.** 2,000 particles at `low`, 6,000 at `medium`, 20,000 at `high` (`particleBudgetPct` scales it). Over it, the least important and farthest effects thin first, and smoke thins before it fills the screen. `qualityLevel` `auto` follows the lighting piece's, or steps down by the same rule without it. `effects.stats` reads live particles, draw calls and the time an update took.
|
|
41
|
+
|
|
42
|
+
Every setting changes while playing (`effects.settings.set`), and `effects.settings.list()` lists them.
|
|
43
|
+
|
|
44
|
+
## Online
|
|
45
|
+
|
|
46
|
+
Its own file, so a game played alone never loads the online core:
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
import { effectsKind } from "./pieces/@zaisma/effects/online.js";
|
|
50
|
+
|
|
51
|
+
const shared = net.use(effectsKind());
|
|
52
|
+
shared.attach(effects);
|
|
53
|
+
shared.play("explosion_large", { positionM }); // here and for every player, particle for particle
|
|
54
|
+
const fire = shared.start("campfire", { positionM }); // kept: a player who joins late sees it, as far along as it is
|
|
55
|
+
shared.setWeather({ rainPct: 80 }); // the room's weather, kept for late joiners too
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
A play is one message of about 40 bytes on the room's clock; nothing is sent while nothing plays. The effects that come free need no messages: every player's game sees the same landing and the same collision. Each game takes at most `maximumPlaysPerSec` (20) from one player. With a game server, give `defineNetServer` the same kind from `server.js`: it holds each player to the rate, refuses what `beforePlay` refuses, keeps what's kept and plays effects of its own for the room.
|
|
59
|
+
|
|
60
|
+
## The workbench
|
|
61
|
+
|
|
62
|
+
[`@zaisma/effects-workbench`](../effects-workbench) is a page that plays every effect in every look, with a slider for every number and a meter. It watches a folder of effect files, so an effect redraws the moment it's saved.
|
|
63
|
+
|
|
64
|
+
`index.d.ts` is the reference. How pieces work: [docs/PIECES.md](https://github.com/zaisma/zaisma-sdk/blob/main/docs/PIECES.md). PolyForm Shield 1.0.0 licensed (`LICENSE.txt`): use it in any game, sold or free, on Zaisma, on your own server or anywhere else; only a product that competes with it, or with what Zaisma makes with it, is ruled out.
|