@zilibobi/forge-vfx 2.4.0 → 3.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/README.md +5 -3
- package/out/ForgeVFX.rbxm +0 -0
- package/out/index.d.ts +574 -10
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
|
-
<a href="https://docs.
|
|
5
|
-
<a href="https://
|
|
4
|
+
<a href="https://docs.zili.dev/forge/authoring/emit-module"><img alt="View Documentation" src="https://img.shields.io/badge/Documentation-View?style=for-the-badge&label=View&color=c4a7e7"></a>
|
|
5
|
+
<a href="https://zili.dev/discord"><img alt="Join Discord" src="https://img.shields.io/discord/1401872327162986626?logo=discord&style=for-the-badge&color=c4a7e7&logoColor=ffffff&label=Join%20Discord"></a>
|
|
6
6
|
</div>
|
|
7
7
|
|
|
8
8
|
# Emit Module
|
|
@@ -28,7 +28,9 @@ npm i @zilibobi/forge-vfx
|
|
|
28
28
|
|
|
29
29
|
#### Manual
|
|
30
30
|
|
|
31
|
-
Check the [releases page](https://github.com/
|
|
31
|
+
Check the [releases page](https://github.com/vfx-forge/module/releases/latest) for prebuilt .rbxm files.
|
|
32
|
+
|
|
33
|
+
The model is named `forge-vfx`, matching the package name so package managers resolve it. A hyphen cannot be indexed with a dot, so either rename it after inserting or write `ReplicatedStorage["forge-vfx"]`. The Wally and npm paths are unaffected: both expose it under the name you import it as.
|
|
32
34
|
|
|
33
35
|
## Usage
|
|
34
36
|
|
package/out/ForgeVFX.rbxm
CHANGED
|
Binary file
|
package/out/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export interface EmitResult {
|
|
5
5
|
/**
|
|
6
|
-
* Promise that resolves when the effect has finished playing
|
|
6
|
+
* Promise that resolves when the effect has finished playing, has been cleared, or its module was deinitialized
|
|
7
7
|
*/
|
|
8
8
|
Finished: Promise<void>;
|
|
9
9
|
|
|
@@ -11,16 +11,252 @@ export interface EmitResult {
|
|
|
11
11
|
* Clear all emitted effects
|
|
12
12
|
*/
|
|
13
13
|
Clear(): void;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Set the speed every effect of this emit runs at, from the next frame. It multiplies with
|
|
17
|
+
* the global setSpeed, any controller over the effects and each effect's own Speed.
|
|
18
|
+
* Errors unless it is a finite number of 0 or more. Once the emit has finished this does
|
|
19
|
+
* nothing.
|
|
20
|
+
* @param speed 1 is authored speed, 0.5 half, 2 double
|
|
21
|
+
*/
|
|
22
|
+
SetSpeed(speed: number): void;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The speed last set with SetSpeed, 1 by default. Pausing does not change it. Reads 1 once
|
|
26
|
+
* the emit has finished.
|
|
27
|
+
*/
|
|
28
|
+
GetSpeed(): number;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Stand every effect of this emit still, from the next frame, until Resume. Once the emit
|
|
32
|
+
* has finished this does nothing.
|
|
33
|
+
*/
|
|
34
|
+
Pause(): void;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Pick every effect of this emit up where Pause left it, at the speed it had.
|
|
38
|
+
*/
|
|
39
|
+
Resume(): void;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Whether this emit is paused by its own Pause. A global pause does not count. Reads false
|
|
43
|
+
* once the emit has finished.
|
|
44
|
+
*/
|
|
45
|
+
IsPaused(): boolean;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Seconds of effect time since the emit: scaled by SetSpeed, the global speed and any
|
|
49
|
+
* controller over the emit, and still while paused. Counted exactly from the first call;
|
|
50
|
+
* the time before it is counted at the speed the emit has at that call, so call it once
|
|
51
|
+
* right after emitting when the speed may change. Ask it while the emit runs: it stands
|
|
52
|
+
* still once the emit has finished, and first asked only after the emit has finished, it
|
|
53
|
+
* answers the real seconds since the emit at the global speed.
|
|
54
|
+
*/
|
|
55
|
+
GetTime(): number;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Rank every write this emit and the emits it starts make against another emit's, from
|
|
59
|
+
* now: on a property or attribute two emits write at once, the higher priority owns it,
|
|
60
|
+
* and at one priority the newer emit does. Warns and keeps the priority unless it is a
|
|
61
|
+
* finite number. Once the emit has finished this does nothing.
|
|
62
|
+
* @param priority 0 by default; higher wins
|
|
63
|
+
*/
|
|
64
|
+
SetPriority(priority: number): void;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The priority set with the emit's options or SetPriority, 0 by default.
|
|
68
|
+
*/
|
|
69
|
+
GetPriority(): number;
|
|
14
70
|
}
|
|
15
71
|
|
|
16
72
|
/**
|
|
17
|
-
*
|
|
73
|
+
* Options an emit may end with, after its instances.
|
|
18
74
|
*/
|
|
19
|
-
export
|
|
75
|
+
export interface EmitOptions {
|
|
76
|
+
/**
|
|
77
|
+
* How this emit's writes rank against another emit's on a property or attribute both
|
|
78
|
+
* write: the higher priority owns it, and at one priority the newer emit does. 0 by
|
|
79
|
+
* default. Anything but a finite number warns and is 0.
|
|
80
|
+
*/
|
|
81
|
+
priority?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Seconds of one frame this emit may spend starting its effects before the rest wait
|
|
84
|
+
* for the next frame, in place of the module's budget. 0 starts every effect in the
|
|
85
|
+
* call. The first effect always starts in the call.
|
|
86
|
+
*/
|
|
87
|
+
budget?: number;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* A handler connected to one of the module's signals.
|
|
92
|
+
*/
|
|
93
|
+
export interface Connection {
|
|
94
|
+
/**
|
|
95
|
+
* Stop calling the handler
|
|
96
|
+
*/
|
|
97
|
+
Disconnect(): void;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* A signal the module fires. Each handler is spawned on a thread of its own and runs
|
|
102
|
+
* synchronously until it first yields, so a handler that yields cannot stall a frame of
|
|
103
|
+
* effects.
|
|
104
|
+
*/
|
|
105
|
+
export interface Signal<T extends unknown[]> {
|
|
106
|
+
Connect(handler: (...args: T) => void): Connection;
|
|
107
|
+
Once(handler: (...args: T) => void): Connection;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Set the global playback speed: every effect emitted from this copy of the module plays at
|
|
112
|
+
* it, live, from the next frame. It multiplies with each emit's SetSpeed, any controller over
|
|
113
|
+
* the effects and each effect's own Speed. Unlike retime, which rewrites an instance's
|
|
114
|
+
* authored values, it leaves every instance as authored and changes only how fast it plays.
|
|
115
|
+
* Errors unless it is a finite number of 0 or more, and the speed stays as it was.
|
|
116
|
+
* @param speed 1 is authored speed, 0.5 half, 2 double
|
|
117
|
+
*/
|
|
118
|
+
export function setSpeed(speed: number): void;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Seconds of one frame an emit may spend starting its effects before the rest wait for
|
|
122
|
+
* the next frame that moves, 0.008 by default, so a large emit is spread over a few
|
|
123
|
+
* frames instead of one long one. undefined or 0 starts every effect in the call. An
|
|
124
|
+
* emit's own `budget` option takes its place for that emit.
|
|
125
|
+
*/
|
|
126
|
+
export function setBudget(seconds?: number): void;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The budget last set with setBudget, 0.008 by default.
|
|
130
|
+
*/
|
|
131
|
+
export function getBudget(): number | undefined;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* How many textures the frame sets of mesh effects may keep loaded at once, 128 by default.
|
|
135
|
+
* A texture is one map of one frame. The least recently played sets are let go first, at once
|
|
136
|
+
* when the budget is lowered, and the budget may be exceeded while a playing set needs it.
|
|
137
|
+
* A set holding no textures is never let go. Errors are logged, not thrown:
|
|
138
|
+
* anything but a finite number of 0 or more leaves the budget as it was.
|
|
139
|
+
*/
|
|
140
|
+
export function setFrameBudget(textures: number): void;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* The budget last set with setFrameBudget, 128 by default.
|
|
144
|
+
*/
|
|
145
|
+
export function getFrameBudget(): number;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The global speed last set with setSpeed, 1 by default. Pausing does not change it, and
|
|
149
|
+
* Global controllers are not counted in it (see getEffectiveSpeed).
|
|
150
|
+
*/
|
|
151
|
+
export function getSpeed(): number;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Stand every effect emitted from this copy of the module still, from the next frame, until
|
|
155
|
+
* resume. Each emit keeps its own speed and Pause under it. Calling it again does nothing.
|
|
156
|
+
*/
|
|
157
|
+
export function pause(): void;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Pick every effect up where pause left it, at the speed it had. Calling it again does
|
|
161
|
+
* nothing.
|
|
162
|
+
*/
|
|
163
|
+
export function resume(): void;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Whether every effect is held by pause. An emit's own Pause does not count.
|
|
167
|
+
*/
|
|
168
|
+
export function isPaused(): boolean;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* The global speed times every Global controller running: the speed every effect plays at
|
|
172
|
+
* before each emit's own. Pausing does not change it; isPaused reports that.
|
|
173
|
+
*/
|
|
174
|
+
export function getEffectiveSpeed(): number;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Fires with getEffectiveSpeed's new value whenever it changes: on setSpeed, and as a Global
|
|
178
|
+
* controller starts, ramps or ends, which can be every frame while one ramps.
|
|
179
|
+
*/
|
|
180
|
+
export const SpeedChanged: Signal<[effectiveSpeed: number]>;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Fires with true on pause and false on resume, only when the global pause really changes.
|
|
184
|
+
*/
|
|
185
|
+
export const PausedChanged: Signal<[paused: boolean]>;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* What ForgeVFX would write to a property or attribute, for game code to read in place of
|
|
189
|
+
* having it written. While any hook on a target is connected ForgeVFX never writes it, not
|
|
190
|
+
* even to put it back at the end. The fields change only when an effect writes, so a read at
|
|
191
|
+
* Camera priority or later sees this frame's value.
|
|
192
|
+
*/
|
|
193
|
+
export interface WriteHook<T> {
|
|
194
|
+
/** False after Disconnect, or once the instance is destroyed. */
|
|
195
|
+
readonly Connected: boolean;
|
|
196
|
+
|
|
197
|
+
/** Whether any emit is writing the target. */
|
|
198
|
+
readonly Active: boolean;
|
|
199
|
+
|
|
200
|
+
/** The owning emit's value, frozen while it is paused; undefined when inactive. */
|
|
201
|
+
readonly Value: T | undefined;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Value minus the first value of this active stretch (first:Inverse() * now for a CFrame).
|
|
205
|
+
* The type's identity when inactive. Undefined for a type with no subtraction, such as
|
|
206
|
+
* Color3, booleans, enums and sequences. On the camera's CFrame it is the camera shake,
|
|
207
|
+
* applied with cf * Offset.
|
|
208
|
+
*/
|
|
209
|
+
readonly Offset: T | undefined;
|
|
210
|
+
|
|
211
|
+
/** The owning emit's priority; undefined when inactive. */
|
|
212
|
+
readonly Priority: number | undefined;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Give the target back: if an emit is still writing it, what the game wrote meanwhile goes
|
|
216
|
+
* back once that emit ends, and ForgeVFX writes it again from its next step.
|
|
217
|
+
*/
|
|
218
|
+
Disconnect(): void;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Read what ForgeVFX would write to a property instead of having it written.
|
|
223
|
+
* hookProperty(workspace.CurrentCamera, "CFrame") hooks the camera shake: its Offset is the
|
|
224
|
+
* shake, and the camera is left alone.
|
|
225
|
+
*/
|
|
226
|
+
export function hookProperty<T = unknown>(
|
|
227
|
+
instance: Instance,
|
|
228
|
+
property: string,
|
|
229
|
+
): WriteHook<T>;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Read what ForgeVFX would write to an attribute instead of having it written.
|
|
233
|
+
*/
|
|
234
|
+
export function hookAttribute<T = unknown>(
|
|
235
|
+
instance: Instance,
|
|
236
|
+
name: string,
|
|
237
|
+
): WriteHook<T>;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Options for init.
|
|
241
|
+
*/
|
|
242
|
+
export interface InitOptions {
|
|
243
|
+
/**
|
|
244
|
+
* Whether ModuleScripts tagged VFXForgeEffect are found and registered as custom effects.
|
|
245
|
+
* True when left out.
|
|
246
|
+
*/
|
|
247
|
+
discover?: boolean;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Initialize the Forge VFX system, registering every custom effect tagged VFXForgeEffect.
|
|
252
|
+
*/
|
|
253
|
+
export function init(options?: InitOptions): void;
|
|
20
254
|
|
|
21
255
|
/**
|
|
22
256
|
* Clean up and shut down the Forge VFX system.
|
|
23
|
-
* Destroys all caches and disconnects event handlers.
|
|
257
|
+
* Destroys all caches and disconnects event handlers. The global speed goes
|
|
258
|
+
* back to 1 and a global pause is lifted, firing SpeedChanged and
|
|
259
|
+
* PausedChanged if either moved, so a later init starts at full speed.
|
|
24
260
|
*/
|
|
25
261
|
export function deinit(): void;
|
|
26
262
|
|
|
@@ -33,12 +269,11 @@ export function deinit(): void;
|
|
|
33
269
|
export function emit(...instances: Instance[]): EmitResult;
|
|
34
270
|
|
|
35
271
|
/**
|
|
36
|
-
* Emit VFX effects with
|
|
37
|
-
* @param
|
|
38
|
-
* @param instances One or more Roblox instances to emit effects from
|
|
272
|
+
* Emit VFX effects from the provided instances, with options after them.
|
|
273
|
+
* @param args One or more Roblox instances, then an EmitOptions table
|
|
39
274
|
* @returns Result object with a Finished promise
|
|
40
275
|
*/
|
|
41
|
-
export function emit(
|
|
276
|
+
export function emit(...args: [...instances: Instance[], options: EmitOptions]): EmitResult;
|
|
42
277
|
|
|
43
278
|
/**
|
|
44
279
|
* Emit VFX effects with a specific render depth.
|
|
@@ -54,7 +289,11 @@ export function emitWithDepth(
|
|
|
54
289
|
/**
|
|
55
290
|
* Enable a VFX instance and all its descendants.
|
|
56
291
|
* For ParticleEmitters and Beams, sets the Enabled property directly.
|
|
57
|
-
* For other instances, sets the "Enabled" attribute
|
|
292
|
+
* For other instances, sets the "Enabled" attribute, in the attribute cache
|
|
293
|
+
* when the instance's attributes are cached.
|
|
294
|
+
* A lightning, bezier or mesh instance starts emitting at its Rate at once,
|
|
295
|
+
* with or without the ConstantVFX tag; in Studio edit mode it also gets the
|
|
296
|
+
* tag, so the place saves with it.
|
|
58
297
|
* @param obj The instance to enable (propagates to descendants)
|
|
59
298
|
*/
|
|
60
299
|
export function enable(obj: Instance): void;
|
|
@@ -62,7 +301,11 @@ export function enable(obj: Instance): void;
|
|
|
62
301
|
/**
|
|
63
302
|
* Disable a VFX instance and all its descendants.
|
|
64
303
|
* For ParticleEmitters and Beams, sets the Enabled property directly.
|
|
65
|
-
* For other instances, sets the "Enabled" attribute
|
|
304
|
+
* For other instances, sets the "Enabled" attribute, in the attribute cache
|
|
305
|
+
* when the instance's attributes are cached.
|
|
306
|
+
* A lightning, bezier or mesh instance stops emitting at its Rate. An emit
|
|
307
|
+
* with an EmitDuration still running keeps going. In Studio edit mode the
|
|
308
|
+
* ConstantVFX tag is removed; in a running game it stays.
|
|
66
309
|
* @param obj The instance to disable (propagates to descendants)
|
|
67
310
|
*/
|
|
68
311
|
export function disable(obj: Instance): void;
|
|
@@ -114,3 +357,324 @@ export function cacheAttributes(obj: Instance, shallow: boolean): void;
|
|
|
114
357
|
* @param shallow If true, only restore the instance itself (skip descendants)
|
|
115
358
|
*/
|
|
116
359
|
export function restoreAttributes(obj: Instance, shallow?: boolean): void;
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* A registered effect, built-in or custom, as the runtime holds it.
|
|
363
|
+
*/
|
|
364
|
+
export interface RegisteredEffect {
|
|
365
|
+
readonly id: string;
|
|
366
|
+
readonly display: {
|
|
367
|
+
readonly name: string;
|
|
368
|
+
readonly icon?: string;
|
|
369
|
+
readonly order?: number;
|
|
370
|
+
readonly category?: SDK.Category;
|
|
371
|
+
/** The engine properties a custom effect's panel mirrors: "all", or their names. */
|
|
372
|
+
readonly reflect?: "all" | readonly string[];
|
|
373
|
+
};
|
|
374
|
+
readonly classifier: string;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Every registered effect, built-in and custom, to read and never to change.
|
|
379
|
+
*/
|
|
380
|
+
export const effects: {
|
|
381
|
+
/** Every registered effect, in the order the panel shows them. */
|
|
382
|
+
list(): ReadonlyArray<RegisteredEffect>;
|
|
383
|
+
/** The effect registered under an id. */
|
|
384
|
+
get(id: string): RegisteredEffect | undefined;
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* The custom effect SDK, version 1. A custom effect is a ModuleScript tagged VFXForgeEffect
|
|
389
|
+
* whose module is an SDK.Effect; every method of it is handed the facade, SDK.V1, first.
|
|
390
|
+
*/
|
|
391
|
+
export namespace SDK {
|
|
392
|
+
/** A param's rule, run with the read's ctx and the other params. */
|
|
393
|
+
export type Rule = (
|
|
394
|
+
ctx: Ctx,
|
|
395
|
+
attrs: Record<string, unknown>,
|
|
396
|
+
props: Record<string, unknown>,
|
|
397
|
+
) => unknown;
|
|
398
|
+
|
|
399
|
+
/** What a number param measures. */
|
|
400
|
+
export type Unit =
|
|
401
|
+
| "seconds"
|
|
402
|
+
| "perSecond"
|
|
403
|
+
| "perSecondSquared"
|
|
404
|
+
| "studs"
|
|
405
|
+
| "studsPerSecond"
|
|
406
|
+
| "studsPerSecondSquared"
|
|
407
|
+
| "studsCubedPerSecondSquared";
|
|
408
|
+
|
|
409
|
+
/** The built-ins an effect is grouped with in the adder. */
|
|
410
|
+
export type Category =
|
|
411
|
+
| "emitters"
|
|
412
|
+
| "meshes"
|
|
413
|
+
| "paths"
|
|
414
|
+
| "shockwaves"
|
|
415
|
+
| "camera"
|
|
416
|
+
| "motion";
|
|
417
|
+
|
|
418
|
+
/** A param: one row in the panel and one value in attrs or props. */
|
|
419
|
+
export interface Knob {
|
|
420
|
+
/** The lowest value, a number or one of the value's own type. */
|
|
421
|
+
min(value: unknown): Knob;
|
|
422
|
+
/** The highest value, a number or one of the value's own type. */
|
|
423
|
+
max(value: unknown): Knob;
|
|
424
|
+
/** Older names the value is still read under. */
|
|
425
|
+
aliases(...names: string[]): Knob;
|
|
426
|
+
/** The strings a text param may hold, shown as a dropdown. */
|
|
427
|
+
options(list: string[]): Knob;
|
|
428
|
+
/** The row's name in the panel. */
|
|
429
|
+
label(text: string): Knob;
|
|
430
|
+
/** The row's tooltip. */
|
|
431
|
+
hint(text: string): Knob;
|
|
432
|
+
/** A curve param edited in the curve editor, starting as this preset. */
|
|
433
|
+
curve(preset: string): Knob;
|
|
434
|
+
/** What the number measures. */
|
|
435
|
+
unit(unit: Unit): Knob;
|
|
436
|
+
/** Hides the row while the rule answers true. */
|
|
437
|
+
hidden(rule: Rule): Knob;
|
|
438
|
+
/** Locks the row to its default while the rule answers true. */
|
|
439
|
+
readonly(rule: Rule): Knob;
|
|
440
|
+
/** A param that holds an instance the artist picks, read as undefined until one is. Classes are matched with IsA; leave them out to take any instance. */
|
|
441
|
+
instance(classes?: string[]): Knob;
|
|
442
|
+
/** A number param drawn as a slider, dragged from low to high (its min and max when left out); a typed value still clamps to min and max. */
|
|
443
|
+
slider(low?: number, high?: number): Knob;
|
|
444
|
+
/** A value modifiers can animate, read as a Track, with default modifiers. */
|
|
445
|
+
mod(...mods: Mod[]): Knob;
|
|
446
|
+
/** Whether a Color3 or ColorSequence param follows a recolor, the color picker's or recolor()'s; one follows unless declared recolor(false). */
|
|
447
|
+
recolor(on?: boolean): Knob;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/** A default modifier on an animated param. */
|
|
451
|
+
export interface Mod {
|
|
452
|
+
/** Seconds it runs, or a rule answering them. */
|
|
453
|
+
duration(seconds: number | Rule): Mod;
|
|
454
|
+
/** The preset or curve param value it eases with. */
|
|
455
|
+
curve(shape: string | Rule): Mod;
|
|
456
|
+
/** Seconds it waits before it starts. */
|
|
457
|
+
delay(seconds: number | Rule): Mod;
|
|
458
|
+
/** The moment of the effect it runs from. */
|
|
459
|
+
lane(name: "start" | "end"): Mod;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/** What params answers. */
|
|
463
|
+
export interface Params {
|
|
464
|
+
/** Params stored as attributes, by name. */
|
|
465
|
+
attributes?: Record<string, Knob>;
|
|
466
|
+
/** Params that are properties of the emitted instance, by property name. */
|
|
467
|
+
properties?: Record<string, Knob>;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/** An animated param's value. */
|
|
471
|
+
export interface Track<T = unknown> {
|
|
472
|
+
/** The value at the start. */
|
|
473
|
+
readonly value: T;
|
|
474
|
+
/** False when no modifier moves it. */
|
|
475
|
+
readonly animated: boolean;
|
|
476
|
+
/** Seconds the modifiers run. */
|
|
477
|
+
readonly duration: number;
|
|
478
|
+
/** The value at a time in seconds. */
|
|
479
|
+
at(elapsed: number): T;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/** What emit is handed about the instance it plays. */
|
|
483
|
+
export interface Ctx {
|
|
484
|
+
/** The instance being emitted. */
|
|
485
|
+
readonly ref: Instance;
|
|
486
|
+
/** The effect's length in seconds, from duration, else 1. */
|
|
487
|
+
readonly duration: number;
|
|
488
|
+
/** True when an Enabled loop emitted it. */
|
|
489
|
+
readonly constant?: boolean;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/** A value over time. */
|
|
493
|
+
export interface Curve {
|
|
494
|
+
/** Seconds it runs. */
|
|
495
|
+
readonly duration: number;
|
|
496
|
+
/** The value at t, 0 to 1 over the curve. */
|
|
497
|
+
at(t: number): number;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/** A preset's name, a curve param's value, a chain of points, or a function of t from 0 to 1. */
|
|
501
|
+
export type CurveShape =
|
|
502
|
+
| string
|
|
503
|
+
| buffer
|
|
504
|
+
| Vector3[]
|
|
505
|
+
| ((t: number) => number);
|
|
506
|
+
|
|
507
|
+
/** One property or attribute this effect writes, handed over between overlapping emits and put back at the end. */
|
|
508
|
+
export interface Writer<T = unknown> {
|
|
509
|
+
/** Writes the value now. */
|
|
510
|
+
set(value: T): void;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/** A group of pieces the effect waits for. */
|
|
514
|
+
export interface Join {
|
|
515
|
+
readonly _nominal_Join: never;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/** A 3D path through a chain of points. */
|
|
519
|
+
export interface Bezier {
|
|
520
|
+
/** New points, in the same format. */
|
|
521
|
+
set(points: Vector3[]): void;
|
|
522
|
+
/** The point at t, 0 to 1 with each segment an equal share. */
|
|
523
|
+
at(t: number): Vector3;
|
|
524
|
+
/** The point u of the way along by distance, 0 to 1. */
|
|
525
|
+
atUniform(u: number): Vector3;
|
|
526
|
+
/** The length in studs. */
|
|
527
|
+
length(): number;
|
|
528
|
+
/** The unit direction of travel at t, zero where the path stands still. */
|
|
529
|
+
tangent(t: number): Vector3;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/** Where a shape draws its point. */
|
|
533
|
+
export interface ShapeOptions {
|
|
534
|
+
/** On the surface rather than inside. */
|
|
535
|
+
surface?: boolean;
|
|
536
|
+
/** How much of the shape it draws from, 0 to 1. */
|
|
537
|
+
partial?: number;
|
|
538
|
+
/** The way the shape faces, Top when none is given. */
|
|
539
|
+
normal?: Enum.NormalId;
|
|
540
|
+
/** The same seed draws the same point. */
|
|
541
|
+
seed?: number;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/** A random point in a shape at cframe with size, in world space. */
|
|
545
|
+
export type ShapeFunction = (
|
|
546
|
+
cframe: CFrame,
|
|
547
|
+
size: Vector3,
|
|
548
|
+
options?: ShapeOptions,
|
|
549
|
+
) => Vector3;
|
|
550
|
+
|
|
551
|
+
/** What every method of a custom effect is handed first. */
|
|
552
|
+
export interface V1 {
|
|
553
|
+
/** A param with its default value, or a rule answering it. */
|
|
554
|
+
knob(defaultValue?: unknown): Knob;
|
|
555
|
+
/** Default modifiers for an animated param. */
|
|
556
|
+
readonly mod: {
|
|
557
|
+
/** Runs from value to the param's own value. */
|
|
558
|
+
from(value: unknown): Mod;
|
|
559
|
+
/** Runs from the param's own value to value. */
|
|
560
|
+
to(value: unknown): Mod;
|
|
561
|
+
};
|
|
562
|
+
/** Waits seconds of effect time, and answers the seconds waited. */
|
|
563
|
+
wait(ctx: Ctx, seconds: number): number;
|
|
564
|
+
/** Calls fn every frame, and answers a function that stops it. */
|
|
565
|
+
step(ctx: Ctx, fn: (dt: number, elapsed: number) => void): () => void;
|
|
566
|
+
/** A curve running for duration seconds. */
|
|
567
|
+
curve(
|
|
568
|
+
duration: number,
|
|
569
|
+
shape: CurveShape,
|
|
570
|
+
options?: Record<string, never>,
|
|
571
|
+
): Curve;
|
|
572
|
+
/** Plays the curve on effect time, calling fn with each value; the effect waits for it. */
|
|
573
|
+
tween(ctx: Ctx, curve: Curve, fn: (alpha: number) => void): void;
|
|
574
|
+
/** Cleans thing up when the effect ends. */
|
|
575
|
+
hold<T extends Instance | RBXScriptConnection | Callback | thread>(
|
|
576
|
+
ctx: Ctx,
|
|
577
|
+
thing: T,
|
|
578
|
+
): T;
|
|
579
|
+
/** The part this effect parents what it makes under, workspace.Terrain.VFXForge.<id>; attachments, parts and sounds work under it as under Terrain. */
|
|
580
|
+
container(ctx: Ctx): BasePart;
|
|
581
|
+
/** A group of pieces the effect waits for. */
|
|
582
|
+
join(ctx: Ctx): Join;
|
|
583
|
+
/** Runs fn on a thread of its own, counted into join. */
|
|
584
|
+
spawn<A extends unknown[]>(
|
|
585
|
+
join: Join,
|
|
586
|
+
fn: (...args: A) => void,
|
|
587
|
+
...args: A
|
|
588
|
+
): void;
|
|
589
|
+
/** Waits until every piece of join is done. */
|
|
590
|
+
await(join: Join): void;
|
|
591
|
+
/** Emits instance as a nested effect the effect waits for. */
|
|
592
|
+
emit(ctx: Ctx, instance: Instance): void;
|
|
593
|
+
/** Plays the effect's Enabled loop for seconds of effect time, a tick at once and one every 1 / Rate after, and returns once the last tick has ended; constant modules only, and never from a tick. */
|
|
594
|
+
window(ctx: Ctx, seconds: number): void;
|
|
595
|
+
/** A writer for a property of obj. */
|
|
596
|
+
getWriter<T = unknown>(
|
|
597
|
+
ctx: Ctx,
|
|
598
|
+
obj: Instance,
|
|
599
|
+
property: string,
|
|
600
|
+
): Writer<T>;
|
|
601
|
+
/** A writer for an attribute of obj. */
|
|
602
|
+
getAttributeWriter<T = unknown>(
|
|
603
|
+
ctx: Ctx,
|
|
604
|
+
obj: Instance,
|
|
605
|
+
name: string,
|
|
606
|
+
): Writer<T>;
|
|
607
|
+
/** Runs the effect's time at an animated param's value. */
|
|
608
|
+
speed(ctx: Ctx, track: Track<number>): void;
|
|
609
|
+
/** t of the way from a to b, for any value that blends. */
|
|
610
|
+
lerp<T>(a: T, b: T, t: number): T;
|
|
611
|
+
/** Colors blended the way eyes see them. */
|
|
612
|
+
readonly color: {
|
|
613
|
+
/** t of the way from a to b, in Oklab. */
|
|
614
|
+
blend(a: Color3, b: Color3, t: number): Color3;
|
|
615
|
+
/** A color as Oklab lightness and its two hues. */
|
|
616
|
+
toOklab(color: Color3): Vector3;
|
|
617
|
+
/** An Oklab value back as a color, clamped into range. */
|
|
618
|
+
fromOklab(lab: Vector3): Color3;
|
|
619
|
+
};
|
|
620
|
+
/** Random points in shapes. */
|
|
621
|
+
readonly shape: {
|
|
622
|
+
/** A point in a box. */
|
|
623
|
+
box: ShapeFunction;
|
|
624
|
+
/** A point in a cylinder whose axis runs along the normal. */
|
|
625
|
+
cylinder: ShapeFunction;
|
|
626
|
+
/** A point in a sphere. */
|
|
627
|
+
sphere: ShapeFunction;
|
|
628
|
+
/** A point in a disc lying across the normal. */
|
|
629
|
+
disc: ShapeFunction;
|
|
630
|
+
};
|
|
631
|
+
/** 3D paths. */
|
|
632
|
+
readonly bezier: {
|
|
633
|
+
/** A path through 3n + 1 points, or 2 for a straight one. */
|
|
634
|
+
new (points: Vector3[]): Bezier;
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/** A custom effect module. */
|
|
639
|
+
export interface Effect {
|
|
640
|
+
/** The facade version it is written against. */
|
|
641
|
+
sdk_version: 1;
|
|
642
|
+
/** Unique across every effect. */
|
|
643
|
+
id: string;
|
|
644
|
+
/** How the panel shows it, the built-ins the adder groups it with, under Custom when none, and the engine properties of its instance the panel mirrors like a built-in's. */
|
|
645
|
+
display: {
|
|
646
|
+
name: string;
|
|
647
|
+
icon?: string;
|
|
648
|
+
category?: Category;
|
|
649
|
+
/** "all", or the names of the properties mirrored; none when absent. */
|
|
650
|
+
reflect?: "all" | string[];
|
|
651
|
+
};
|
|
652
|
+
/** The selector an instance must match to play it. */
|
|
653
|
+
classifier: string;
|
|
654
|
+
/** A selector for the descendants it plays itself. */
|
|
655
|
+
components?: string;
|
|
656
|
+
/** The panel's rows: param names and groups of them. */
|
|
657
|
+
layout?: unknown[];
|
|
658
|
+
/** True when an Enabled loop may emit it. */
|
|
659
|
+
constant?: boolean;
|
|
660
|
+
/** The params, called once per load. */
|
|
661
|
+
params?(sdk: V1): Params;
|
|
662
|
+
/** The effect's length in seconds. */
|
|
663
|
+
duration?(
|
|
664
|
+
sdk: V1,
|
|
665
|
+
attrs: Record<string, unknown>,
|
|
666
|
+
props: Record<string, unknown>,
|
|
667
|
+
): number;
|
|
668
|
+
/** Plays the effect on ctx.ref. */
|
|
669
|
+
emit(
|
|
670
|
+
sdk: V1,
|
|
671
|
+
ctx: Ctx,
|
|
672
|
+
attrs: Record<string, unknown>,
|
|
673
|
+
props: Record<string, unknown>,
|
|
674
|
+
): void;
|
|
675
|
+
/** Called on the old version before a reload drops it. */
|
|
676
|
+
unload?(): void;
|
|
677
|
+
/** A new instance the classifier finds, unparented, made by the plugin's adder. */
|
|
678
|
+
template?(sdk: V1): Instance;
|
|
679
|
+
}
|
|
680
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zilibobi/forge-vfx",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "The official emit module from the VFX Forge plugin used to emit visual effects in-game.",
|
|
5
5
|
"main": "out/init.luau",
|
|
6
6
|
"types": "out/index.d.ts",
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
],
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "git+https://github.com/
|
|
13
|
+
"url": "git+https://github.com/vfx-forge/module.git"
|
|
14
14
|
},
|
|
15
|
-
"homepage": "https://docs.
|
|
15
|
+
"homepage": "https://docs.zili.dev/forge/authoring/emit-module",
|
|
16
16
|
"author": "zilibobi",
|
|
17
17
|
"license": "VFX-DL-1.1",
|
|
18
18
|
"scripts": {
|