@zaisma/effects 0.0.0-stage → 1.0.0
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/index.d.ts
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @zaisma/effects: spectacle that holds a phone's frame rate, for three.js. Thousands of lit particles, hits,
|
|
3
|
+
* explosions, magic, fire, smoke, trails, shockwaves, marks on surfaces, screen warps, debris that bounces and
|
|
4
|
+
* weather, drawn in the look a game picks. An effect is a small file (EFFECT-FILES.md is its format), and the
|
|
5
|
+
* library/ folder holds the ones that come with the piece.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* import { createEffects } from "./pieces/@zaisma/effects/index.js";
|
|
9
|
+
* const effects = createEffects({ scene, renderer, lighting, settings: { look: "glowing" } });
|
|
10
|
+
* await effects.load(["explosion_large", "campfire", "./effects/my_spell.json"]);
|
|
11
|
+
* // each frame, before rendering:
|
|
12
|
+
* effects.update(camera);
|
|
13
|
+
* renderer.render(scene, camera);
|
|
14
|
+
* // while playing:
|
|
15
|
+
* effects.play("explosion_large", { positionM: { x: 4, y: 0, z: -2 } });
|
|
16
|
+
* const fire = effects.play("campfire", { positionM: camp }); // looping: plays until fire.stop()
|
|
17
|
+
* effects.settings.set({ rainPct: 60, windSpeedMPerSec: 9 }); // the weather turns
|
|
18
|
+
* effects.hooks.on("effectStarted", ({ effectName, positionM }) => playSoundFor(effectName, positionM));
|
|
19
|
+
*/
|
|
20
|
+
import type { Camera, Group, Object3D, Scene, Vector3 } from "three";
|
|
21
|
+
import type { GivenToPiece, Hooks, Settings } from "../piece/index.js";
|
|
22
|
+
|
|
23
|
+
export type QualityLevel = "low" | "medium" | "high";
|
|
24
|
+
export type LookName = "cartoon" | "glowing" | "faceted" | "realistic";
|
|
25
|
+
export type FamilyName = "hits" | "explosions" | "magic" | "fire" | "smoke" | "sparks" | "water" | "trails" | "shockwaves" | "marks" | "warps" | "debris" | "character" | "weather" | "ambient" | "other";
|
|
26
|
+
/** What a particle is made of: the look decides how each is drawn. */
|
|
27
|
+
export type MaterialName = "fire" | "smoke" | "spark" | "ember" | "dust" | "water" | "mist" | "magic" | "glow" | "energy" | "snow" | "leaf" | "stone" | "wood" | "metal" | "glass";
|
|
28
|
+
export type ShapeName = "soft" | "disc" | "puff" | "flame" | "streak" | "star" | "ring" | "shard" | "drop" | "flake" | "splat" | "leaf" | "cross" | "wisp" | "bubble" | "diamond" | "crescent" | "angular_flame";
|
|
29
|
+
export type SurfaceKind = "stone" | "concrete" | "metal" | "wood" | "dirt" | "gravel" | "sand" | "grass" | "mud" | "water" | "snow" | "ice" | "glass" | "carpet" | "flesh";
|
|
30
|
+
export type ElementKind = "particles" | "debris" | "ribbon" | "beam" | "flash" | "mark" | "warp" | "shake";
|
|
31
|
+
/** Why an effect plays: play is the game's own call, shared came from another player's game or the game server, the rest come free with the character and physics pieces. */
|
|
32
|
+
export type PlayReason = "play" | "footstep" | "landing" | "jump" | "body_hit" | "chunk_landed" | "shared";
|
|
33
|
+
|
|
34
|
+
/** A place or a direction: metres for a place, any length for a direction. +y is up. */
|
|
35
|
+
export interface Point {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
z: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Every setting, in JavaScript's names; piece.json states each with its range and default. All change while playing. */
|
|
42
|
+
export interface EffectsSettings {
|
|
43
|
+
[name: string]: number | boolean | string;
|
|
44
|
+
/** How every effect is drawn. "own" is the look defineOwnLook made. Default "cartoon". */
|
|
45
|
+
look: LookName | "own";
|
|
46
|
+
/** "auto" follows the lighting piece's quality when it's given; without it, it starts at medium on phones and tablets and high elsewhere, and steps down while frames run under 25 a second. Default "auto". */
|
|
47
|
+
qualityLevel: QualityLevel | "auto";
|
|
48
|
+
/** The particles alive at once against the quality level's own count, 10 to 400. Default 100. */
|
|
49
|
+
particleBudgetPct: number;
|
|
50
|
+
/** How fast the effects' own time runs, 0 to 400: 30 is slow motion, 0 freezes every effect. Default 100. */
|
|
51
|
+
timeScalePct: number;
|
|
52
|
+
/** Whether effects with a flash light the scene. Off, they still glow. Default true. */
|
|
53
|
+
flashLightsEnabled: boolean;
|
|
54
|
+
/** Whether effects leave marks on surfaces. Default true. */
|
|
55
|
+
marksEnabled: boolean;
|
|
56
|
+
/** Whether effects bend the picture. Never drawn at low quality. Default true. */
|
|
57
|
+
warpsEnabled: boolean;
|
|
58
|
+
/** Whether effects shake the camera: a game's settings screen turns this off for players who ask. Default true. */
|
|
59
|
+
shakesEnabled: boolean;
|
|
60
|
+
/** How hard it rains, 0 to 100. Default 0. */
|
|
61
|
+
rainPct: number;
|
|
62
|
+
/** How hard it snows, 0 to 100. Default 0. */
|
|
63
|
+
snowPct: number;
|
|
64
|
+
/** How much mist drifts over the ground, 0 to 100. Default 0. */
|
|
65
|
+
fogPct: number;
|
|
66
|
+
/** The wind's speed, 0 to 40 metres a second: it carries every particle by as much as its effect says. Default 0. */
|
|
67
|
+
windSpeedMPerSec: number;
|
|
68
|
+
/** The way the wind blows toward, 0 to 360 degrees counterclockwise from above: 0 toward +x, 90 toward -z. Default 0. */
|
|
69
|
+
windDirectionDeg: number;
|
|
70
|
+
/** How much the wind swells and eases, 0 to 100. Default 30. */
|
|
71
|
+
windGustPct: number;
|
|
72
|
+
/** How long the weather takes to reach what it's set to, 0 to 120 seconds. Default 4. */
|
|
73
|
+
weatherChangeDurationSec: number;
|
|
74
|
+
/** Whether rain and snow stay out from under roofs, at medium and high. Default true. */
|
|
75
|
+
rainShelterEnabled: boolean;
|
|
76
|
+
/** The ground's height in metres where the game gave nothing better (no physics, no castRay). Default 0. */
|
|
77
|
+
groundHeightM: number;
|
|
78
|
+
/** Whether a character's footfalls raise dust or a splash, with the character piece. Default true. */
|
|
79
|
+
footstepEffectsEnabled: boolean;
|
|
80
|
+
/** Whether a character's jump and landing raise a puff, with the character piece. Default true. */
|
|
81
|
+
landingEffectsEnabled: boolean;
|
|
82
|
+
/** Whether a physics body that hits something throws an impact, with the physics piece. Default true. */
|
|
83
|
+
impactEffectsEnabled: boolean;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** What beforeEffect is asked with, and may answer changed. */
|
|
87
|
+
export interface EffectProposal {
|
|
88
|
+
effectName: string;
|
|
89
|
+
positionM: Point;
|
|
90
|
+
scalePct: number;
|
|
91
|
+
strengthPct: number;
|
|
92
|
+
/** A tint as "#rrggbb", or null for the effect's own colours. */
|
|
93
|
+
color: string | null;
|
|
94
|
+
surfaceKind: SurfaceKind | null;
|
|
95
|
+
reason: PlayReason;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface EffectsHooks {
|
|
99
|
+
[name: string]: (...given: any[]) => unknown;
|
|
100
|
+
/** Asked before every effect plays. Answer any field changed (another effectName, a tint), null to stop it, or nothing to let it play as it is. */
|
|
101
|
+
beforeEffect: (proposal: EffectProposal) => Partial<Omit<EffectProposal, "positionM" | "reason">> | null | undefined | void;
|
|
102
|
+
/** Told when an effect starts: where a game plays the sound that goes with it. */
|
|
103
|
+
effectStarted: (started: { playId: number; effectName: string; positionM: Point; scalePct: number; strengthPct: number; surfaceKind: SurfaceKind | null; reason: PlayReason }) => void;
|
|
104
|
+
/** Told when an effect's last particle is gone, or it was stopped. */
|
|
105
|
+
effectEnded: (ended: { playId: number; effectName: string }) => void;
|
|
106
|
+
/** Asked what the surface is where a free effect or an impact lands, starting from the piece's guess. Answer a surface kind from the game's own level. */
|
|
107
|
+
surfaceKindAt: (surfaceKind: SurfaceKind, where: { positionM: Point; reason: PlayReason; bodyId: string | null }) => SurfaceKind | undefined | void;
|
|
108
|
+
/** Told when an effect shakes the camera, already faded by its distance: for a game with a camera of its own. */
|
|
109
|
+
shake: (shake: { strengthPct: number; durationSec: number }) => void;
|
|
110
|
+
/** Told when the quality level in use changes. */
|
|
111
|
+
qualityChanged: (changed: { qualityLevel: QualityLevel; reason: "setting" | "lighting_quality" | "slow_frames" }) => void;
|
|
112
|
+
/** Told while the weather turns and when it settles: where a game's sound and sky follow it. */
|
|
113
|
+
weatherChanged: (weather: { rainPct: number; snowPct: number; fogPct: number; windSpeedMPerSec: number; windDirectionDeg: number; isSettled: boolean }) => void;
|
|
114
|
+
/** Told, at most once a second, when the budget was spent and effects played thinner (keptPct) or not at all (0). */
|
|
115
|
+
effectsThinned: (thinned: { effectName: string; keptPct: number }) => void;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** What a level's own ray test is asked, and answers: the first surface along the ray, or null. */
|
|
119
|
+
export interface RayQuery {
|
|
120
|
+
fromM: Point;
|
|
121
|
+
/** The ray's direction, one metre long. */
|
|
122
|
+
directionM: Point;
|
|
123
|
+
maximumDistanceM: number;
|
|
124
|
+
}
|
|
125
|
+
export interface RayHit {
|
|
126
|
+
pointM: Point;
|
|
127
|
+
/** The surface's direction there; up when left out. */
|
|
128
|
+
normal?: Point;
|
|
129
|
+
/** What the surface is made of, when the level knows: a surface kind's name is used as one. */
|
|
130
|
+
materialName?: string | null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface EffectsGiven extends GivenToPiece<EffectsSettings, EffectsHooks> {
|
|
134
|
+
/** The scene the effects play in. */
|
|
135
|
+
scene: Scene;
|
|
136
|
+
/** The renderer that draws it: a THREE.WebGLRenderer. */
|
|
137
|
+
renderer: { render(scene: Scene, camera: Camera): void };
|
|
138
|
+
/** The lighting piece (createLighting's answer): particles take its light and fog, flashes light its scene, quality follows its own. */
|
|
139
|
+
lighting?: object | null;
|
|
140
|
+
/** The physics piece: every collision throws an impact, chunks bounce off its world, marks find its surfaces. */
|
|
141
|
+
physics?: object | null;
|
|
142
|
+
/** The character piece's view: footfalls, jumps and landings raise their effects. */
|
|
143
|
+
character?: object | null;
|
|
144
|
+
/** The camera piece: effects that shake, shake it. Found on the character when that carries one. */
|
|
145
|
+
camera?: object | null;
|
|
146
|
+
/** The level's own ray test, for a game without the physics piece: where marks lie and chunks land. */
|
|
147
|
+
castRay?: (query: RayQuery) => RayHit | null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Where and how an effect plays. Give positionM, or follow. */
|
|
151
|
+
export interface PlayAt {
|
|
152
|
+
/** Where, in metres. With follow, a place measured from the object it rides on. */
|
|
153
|
+
positionM?: Point;
|
|
154
|
+
/** The way the effect points: a muzzle's way, a swing's way. Up when left out. */
|
|
155
|
+
direction?: Point | null;
|
|
156
|
+
/** The direction of the surface it plays on: an impact sprays off it, a mark lies on it. Takes direction's place. */
|
|
157
|
+
normal?: Point | null;
|
|
158
|
+
/** Where a beam or a bolt ends. */
|
|
159
|
+
toPositionM?: Point | null;
|
|
160
|
+
/** How big against its file, above 0 up to 10000. Default 100. */
|
|
161
|
+
scalePct?: number;
|
|
162
|
+
/** How solid and bright, 0 to 1000. Default 100. */
|
|
163
|
+
strengthPct?: number;
|
|
164
|
+
/** A tint over the effect's own colours, "#rrggbb" in lowercase. */
|
|
165
|
+
color?: string | null;
|
|
166
|
+
/** What it lands on: elements written for other surfaces stay out. */
|
|
167
|
+
surfaceKind?: SurfaceKind | null;
|
|
168
|
+
/** An object the effect rides on: a hand, a sword, a projectile. */
|
|
169
|
+
follow?: Object3D | null;
|
|
170
|
+
/** The seed its particles come from: the same seed plays the same on every device. A fresh one when left out. */
|
|
171
|
+
seedNumber?: number;
|
|
172
|
+
/** How long ago it started, in seconds: a late joiner's campfire starts partway through. Default 0. */
|
|
173
|
+
startedAgoSec?: number;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** One effect playing. */
|
|
177
|
+
export interface EffectPlay {
|
|
178
|
+
/** 0 when nothing played: beforeEffect stopped it, the budget was spent, or it was over before it began. */
|
|
179
|
+
readonly playId: number;
|
|
180
|
+
readonly effectName: string | null;
|
|
181
|
+
readonly isEnded: boolean;
|
|
182
|
+
/** Stops it: nothing new is given off, and what's in the air finishes. isImmediate takes everything away at once. */
|
|
183
|
+
stop(stopOptions?: { isImmediate?: boolean }): void;
|
|
184
|
+
/** Moves it: a new place, and a new direction when one is given. Throws PieceError "bad_play". */
|
|
185
|
+
moveTo(positionM: Point, direction?: Point | null): void;
|
|
186
|
+
/** Changes how it plays from now, any of them. */
|
|
187
|
+
set(changes: { scalePct?: number; strengthPct?: number; color?: string; toPositionM?: Point }): void;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* An effect file, as its JSON parses: EFFECT-FILES.md states every field with its unit, range and default, and
|
|
192
|
+
* EFFECT_FIELDS, COMMON_ELEMENT_FIELDS and ELEMENT_FIELDS state the same as data.
|
|
193
|
+
*/
|
|
194
|
+
export interface EffectFile {
|
|
195
|
+
effect_format_version_number: 1;
|
|
196
|
+
/** What play() takes: lowercase words joined by underscores, up to 40 characters. */
|
|
197
|
+
name: string;
|
|
198
|
+
summary?: string;
|
|
199
|
+
family?: FamilyName;
|
|
200
|
+
importance?: "low" | "normal" | "high";
|
|
201
|
+
is_looping?: boolean;
|
|
202
|
+
duration_sec?: number;
|
|
203
|
+
/** 1 to 16 elements. */
|
|
204
|
+
elements: EffectElement[];
|
|
205
|
+
}
|
|
206
|
+
export interface EffectElement {
|
|
207
|
+
element_kind: ElementKind;
|
|
208
|
+
start_delay_sec?: number;
|
|
209
|
+
surface_kinds?: SurfaceKind[] | null;
|
|
210
|
+
look_names?: LookName[] | null;
|
|
211
|
+
minimum_quality_level?: QualityLevel;
|
|
212
|
+
/** The element kind's own fields, as EFFECT-FILES.md states them. */
|
|
213
|
+
[field: string]: unknown;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** One thing wrong with an effect file. field is its path, like "elements[2].move.speed_m_per_sec". */
|
|
217
|
+
export interface EffectProblem {
|
|
218
|
+
code: "bad_effect_file" | "unknown_effect_field" | "missing_effect_field" | "bad_effect_field" | "effect_emits_nothing";
|
|
219
|
+
message: string;
|
|
220
|
+
field: string | null;
|
|
221
|
+
fix: string;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** How one field of an effect file is stated: its kind of value, its range or choices, its default and what it's for. */
|
|
225
|
+
export interface FieldStatement {
|
|
226
|
+
valueKind: "number" | "integer" | "boolean" | "choice" | "color" | "text" | "numbers" | "colors" | "choices_or_null" | "choice_or_null" | "text_or_null" | "number_or_null";
|
|
227
|
+
defaultValue: unknown;
|
|
228
|
+
summary: string;
|
|
229
|
+
isRequired?: boolean;
|
|
230
|
+
minimumNumber?: number;
|
|
231
|
+
maximumNumber?: number;
|
|
232
|
+
minimumCount?: number;
|
|
233
|
+
maximumCount?: number;
|
|
234
|
+
maximumCharacterCount?: number;
|
|
235
|
+
choices?: readonly string[];
|
|
236
|
+
}
|
|
237
|
+
/** Fields by name; a group (emit, move, fade) is a nested object of fields. */
|
|
238
|
+
export interface FieldStatements {
|
|
239
|
+
[name: string]: FieldStatement | FieldStatements;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** How a look draws one material. An effect's own shape, where it names one, keeps its size and count in every look. */
|
|
243
|
+
export interface MaterialStyle {
|
|
244
|
+
shapeName: ShapeName;
|
|
245
|
+
/** A drawn sequence the shape plays through its life, or null. */
|
|
246
|
+
filmName: "smoke_film" | "fire_film" | null;
|
|
247
|
+
/** The little solid drawn instead of a flat shape (the faceted look), or null. */
|
|
248
|
+
chunkShapeName: "tetra" | "octa" | "icosa" | "cube" | "shard" | "plate" | null;
|
|
249
|
+
/** How much it adds light instead of covering what's behind, 0 to 100. */
|
|
250
|
+
addPct: number;
|
|
251
|
+
/** How much the scene's light shades it, 0 to 100. */
|
|
252
|
+
litPct: number;
|
|
253
|
+
/** How round the light makes it look, 0 to 100. */
|
|
254
|
+
roundPct: number;
|
|
255
|
+
/** How crisp its edge is, 0 to 100. */
|
|
256
|
+
hardPct: number;
|
|
257
|
+
/** How many flat tones it's drawn in, 0 to 4: 0 is smooth. */
|
|
258
|
+
toneStepCount: number;
|
|
259
|
+
outlinePct: number;
|
|
260
|
+
/** How bright its middle burns, 0 to 100. */
|
|
261
|
+
corePct: number;
|
|
262
|
+
lightenPct: number;
|
|
263
|
+
/** How many of an effect's particles are drawn, 5 to 400. */
|
|
264
|
+
countPct: number;
|
|
265
|
+
/** How big they're drawn, 10 to 1000. */
|
|
266
|
+
sizePct: number;
|
|
267
|
+
glowPct: number;
|
|
268
|
+
opacityPct: number;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** A look of a game's own: one of the piece's looks, and what differs from it, material by material. */
|
|
272
|
+
export interface OwnLook {
|
|
273
|
+
basedOnLookName: LookName;
|
|
274
|
+
materials?: Partial<Record<MaterialName, Partial<MaterialStyle>>>;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export interface Effects {
|
|
278
|
+
settings: Settings<EffectsSettings>;
|
|
279
|
+
hooks: Hooks<EffectsHooks>;
|
|
280
|
+
/** three's own objects the effects are drawn with, for anything the settings don't reach. */
|
|
281
|
+
readonly group: Group;
|
|
282
|
+
/** Adds an effect from its file, or replaces the one of the same name: what's playing of it plays on as the new one. Answers its name. Throws PieceError with the file's first problem ("bad_effect_file", "unknown_effect_field", "missing_effect_field", "bad_effect_field", "effect_emits_nothing") or "too_many_effects". */
|
|
283
|
+
add(effectFile: EffectFile): string;
|
|
284
|
+
/** Loads effects: "all" for the piece's whole library, or a list of its effects' names and addresses of the game's own files. Answers their names. Throws PieceError "bad_effect_names", "effect_not_loaded", or add's. */
|
|
285
|
+
load(names: "all" | string[]): Promise<string[]>;
|
|
286
|
+
/** Whether an effect is loaded. */
|
|
287
|
+
has(effectName: string): boolean;
|
|
288
|
+
/** An effect's file as loaded, every field there, or null. */
|
|
289
|
+
get(effectName: string): EffectFile | null;
|
|
290
|
+
/** Every effect loaded. */
|
|
291
|
+
list(): { name: string; family: FamilyName; summary: string; importance: "low" | "normal" | "high"; isLooping: boolean }[];
|
|
292
|
+
/** Plays an effect. A looping one plays until its stop(). Throws PieceError "unknown_effect", "bad_play", "unknown_argument". */
|
|
293
|
+
play(effectName: string, at: PlayAt): EffectPlay;
|
|
294
|
+
/** What the online kind calls for an effect another player's game or the game server played: as play, told with the reason shared. */
|
|
295
|
+
playShared(effectName: string, at: PlayAt): EffectPlay;
|
|
296
|
+
/** Stops everything playing. isImmediate takes what's on screen away at once. */
|
|
297
|
+
stopAll(stopOptions?: { isImmediate?: boolean }): void;
|
|
298
|
+
/** Takes every mark off the level: a level starting over. */
|
|
299
|
+
clearMarks(): void;
|
|
300
|
+
/** Every frame, before rendering. nowMs defaults to performance.now(). Throws PieceError "camera_needed". */
|
|
301
|
+
update(camera: Camera, nowMs?: number): void;
|
|
302
|
+
/** For a game that draws through the lighting effects at high quality: call after its last draw, and warps are laid on the picture. */
|
|
303
|
+
drawWarps(camera: Camera): void;
|
|
304
|
+
/** Defines the game's own look and draws in it (the look setting becomes "own"). Throws PieceError "bad_look". */
|
|
305
|
+
defineOwnLook(look: OwnLook): void;
|
|
306
|
+
/** The look in use. */
|
|
307
|
+
readonly lookName: LookName | "own";
|
|
308
|
+
/** The quality level in use, with auto worked out. */
|
|
309
|
+
readonly qualityLevel: QualityLevel;
|
|
310
|
+
/** The weather right now, as it eases toward its settings; windM is the wind this moment, gusts included, in metres a second. */
|
|
311
|
+
readonly weather: {
|
|
312
|
+
readonly rainPct: number;
|
|
313
|
+
readonly snowPct: number;
|
|
314
|
+
readonly fogPct: number;
|
|
315
|
+
readonly windSpeedMPerSec: number;
|
|
316
|
+
readonly windDirectionDeg: number;
|
|
317
|
+
readonly windGustPct: number;
|
|
318
|
+
readonly isSettled: boolean;
|
|
319
|
+
readonly windM: Vector3;
|
|
320
|
+
};
|
|
321
|
+
/** The shake right now, for a game with a camera of its own: add offsetM to the camera's place and rollRad to its roll after placing it. */
|
|
322
|
+
readonly shake: { readonly strengthPct: number; readonly offsetM: Vector3; readonly rollRad: number };
|
|
323
|
+
/** What the effects cost this frame. */
|
|
324
|
+
readonly stats: {
|
|
325
|
+
particleCount: number;
|
|
326
|
+
particleBudgetCount: number;
|
|
327
|
+
playCount: number;
|
|
328
|
+
drawCallCount: number;
|
|
329
|
+
updateDurationMs: number;
|
|
330
|
+
/** The share of particles drawn while smoke and the like would fill the screen: 100 when nothing is thinned for it. */
|
|
331
|
+
keptPct: number;
|
|
332
|
+
markCount: number;
|
|
333
|
+
debrisCount: number;
|
|
334
|
+
flashCount: number;
|
|
335
|
+
};
|
|
336
|
+
/** The seconds the effects have counted, which timeScalePct slows. */
|
|
337
|
+
readonly timeSec: number;
|
|
338
|
+
/** Takes everything out of the scene and frees what it drew with. */
|
|
339
|
+
dispose(): void;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/** Makes a scene's effects. Throws PieceError "unknown_argument", "scene_needed", "renderer_needed", "bad_cast_ray", or the frame's "unknown_setting", "bad_setting", "unknown_hook". */
|
|
343
|
+
export declare function createEffects(given: EffectsGiven): Effects;
|
|
344
|
+
|
|
345
|
+
/** Checks an effect file. Answers every problem found; none means it plays. No three.js: runs in node and on a game server (import it from format.js there). */
|
|
346
|
+
export declare function checkEffect(effect: unknown): EffectProblem[];
|
|
347
|
+
/** An effect with every field there, the ones it left out at their defaults. Give it one that passed checkEffect. */
|
|
348
|
+
export declare function completeEffect(effect: EffectFile): EffectFile;
|
|
349
|
+
/** Every field of an element kind as a flat list, for a tuning panel. */
|
|
350
|
+
export declare function listElementFields(elementKind: ElementKind): { path: string; groupName: string | null; name: string; statement: FieldStatement }[];
|
|
351
|
+
|
|
352
|
+
export declare const EFFECT_FORMAT_VERSION_NUMBER: 1;
|
|
353
|
+
/** The fields at the top of an effect file, the fields every element has, and each element kind's own. */
|
|
354
|
+
export declare const EFFECT_FIELDS: Record<string, FieldStatement>;
|
|
355
|
+
export declare const COMMON_ELEMENT_FIELDS: Record<string, FieldStatement>;
|
|
356
|
+
export declare const ELEMENT_FIELDS: Record<ElementKind, FieldStatements>;
|
|
357
|
+
export declare const ELEMENT_KINDS: readonly ElementKind[];
|
|
358
|
+
export declare const FAMILY_NAMES: readonly FamilyName[];
|
|
359
|
+
export declare const LOOK_NAMES: readonly LookName[];
|
|
360
|
+
export declare const MATERIAL_NAMES: readonly MaterialName[];
|
|
361
|
+
export declare const SHAPE_NAMES: readonly ShapeName[];
|
|
362
|
+
export declare const SURFACE_KINDS: readonly SurfaceKind[];
|
|
363
|
+
|
|
364
|
+
/** The piece's four looks: every material's style in each. */
|
|
365
|
+
export declare const LOOKS: Record<LookName, Record<MaterialName, MaterialStyle>>;
|
|
366
|
+
/** A material style's fields with their ranges and choices: what defineOwnLook checks against. */
|
|
367
|
+
export declare const LOOK_STYLE_FIELDS: Record<keyof MaterialStyle, { valueKind: "choice" | "choice_or_null" | "number" | "integer"; choices?: readonly string[]; minimumNumber?: number; maximumNumber?: number }>;
|
|
368
|
+
/** What each quality level draws. */
|
|
369
|
+
export declare const QUALITY_BUDGETS: Record<QualityLevel, { particleCount: number; markCount: number; debrisCount: number; flashLightCount: number; hasWarps: boolean; hasRainShelter: boolean; hasSunShadows: boolean; keptPct: number; fillScreenCount: number; atlasSizePx: number }>;
|
|
370
|
+
/** Whether the device is a phone or tablet: touch with no mouse. */
|
|
371
|
+
export declare function isTouchDevice(): boolean;
|
|
372
|
+
/** Where "auto" starts without the lighting piece. */
|
|
373
|
+
export declare function startingQualityLevel(): "medium" | "high";
|