lecodes-sdk 2.4.9 → 2.5.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/dist/global.d.ts +35 -0
- package/dist/types/core/env.d.ts +25 -0
- package/dist/types/core/particlesConfig.d.ts +196 -0
- package/dist/types/g2/Font2D.d.ts +19 -0
- package/dist/types/g2/Material2D.d.ts +24 -0
- package/dist/types/g2/Node2D.d.ts +6 -5
- package/dist/types/g2/Particles2D.d.ts +169 -0
- package/dist/types/g2/Path2D.d.ts +95 -0
- package/dist/types/g2/Physics2D.d.ts +1 -1
- package/dist/types/g2/Scene2D.d.ts +15 -17
- package/dist/types/g2/Sprite.d.ts +12 -1
- package/dist/types/g2/SpriteSheet.d.ts +4 -1
- package/dist/types/g2/Text2D.d.ts +96 -0
- package/dist/types/g2/Tilemap.d.ts +8 -0
- package/dist/types/g2/defineScene2d.d.ts +69 -11
- package/dist/types/gl/Foliage.d.ts +0 -7
- package/dist/types/gl/Lightmap.d.ts +101 -2
- package/dist/types/gl/Material.d.ts +21 -15
- package/dist/types/gl/Model.d.ts +8 -3
- package/dist/types/gl/Particles.d.ts +3 -135
- package/dist/types/gl/Statics.d.ts +56 -0
- package/dist/types/gl/staticsFormat.d.ts +101 -0
- package/dist/types/inject.d.ts +11 -3
- package/dist/types/runtime/env.d.ts +10 -0
- package/dist/types/runtime/envValues.d.ts +8 -0
- package/dist/types/scene/defineScene.d.ts +17 -12
- package/dist/types/server/env.d.ts +14 -0
- package/dist/types/server/inject.d.ts +1 -0
- package/dist/types/ui/fonts.d.ts +4 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/types.json +1 -1
- package/package.json +1 -1
- package/src/bridges/2d.d.ts +65 -5
- package/src/bridges/gl.d.ts +34 -15
- package/src/compile/bakeMacro.ts +3 -0
- package/src/compile/compileProject.ts +25 -4
- package/src/compile/envCompile.ts +74 -0
- package/src/compile/fontMacro.ts +11 -6
- package/src/compile/index.ts +6 -0
- package/src/compile/resourceSlots.ts +1 -0
- package/src/compile/serverSplit.ts +47 -4
- package/src/core/env.ts +47 -0
- package/src/core/particlesConfig.ts +422 -0
- package/src/g2/Font2D.ts +87 -0
- package/src/g2/Material2D.ts +64 -0
- package/src/g2/Node2D.ts +10 -6
- package/src/g2/Particles2D.ts +337 -0
- package/src/g2/Path2D.ts +215 -0
- package/src/g2/Physics2D.ts +1 -1
- package/src/g2/Scene2D.ts +16 -22
- package/src/g2/Sprite.ts +23 -4
- package/src/g2/SpriteSheet.ts +9 -5
- package/src/g2/Text2D.ts +178 -0
- package/src/g2/Tilemap.ts +10 -0
- package/src/g2/defineScene2d.ts +108 -21
- package/src/g2/groups2d.ts +2 -2
- package/src/gl/Foliage.ts +1 -16
- package/src/gl/Lightmap.ts +79 -26
- package/src/gl/Material.ts +51 -21
- package/src/gl/Model.ts +19 -5
- package/src/gl/Particles.ts +22 -361
- package/src/gl/Statics.ts +301 -0
- package/src/gl/nav/NavMesh.ts +4 -1
- package/src/gl/staticsFormat.ts +240 -0
- package/src/inject.ts +18 -3
- package/src/runtime/env.ts +13 -0
- package/src/runtime/envValues.ts +8 -0
- package/src/runtime/fetch.ts +18 -0
- package/src/scene/defineScene.ts +107 -27
- package/src/server/env.ts +25 -0
- package/src/server/host.ts +6 -0
- package/src/server/inject.ts +2 -1
- package/src/ui/fonts.ts +46 -0
- package/src/version.ts +1 -1
package/dist/global.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ declare global {
|
|
|
39
39
|
const File: typeof SDK.File
|
|
40
40
|
const Foliage: typeof SDK.Foliage
|
|
41
41
|
const FollowPath: typeof SDK.FollowPath
|
|
42
|
+
const Font2D: typeof SDK.Font2D
|
|
42
43
|
const FormData: typeof SDK.FormData
|
|
43
44
|
const Geolocation: typeof SDK.Geolocation
|
|
44
45
|
const Geometry: typeof SDK.Geometry
|
|
@@ -60,6 +61,7 @@ declare global {
|
|
|
60
61
|
const MapView: typeof SDK.MapView
|
|
61
62
|
const Mat4: typeof SDK.Mat4
|
|
62
63
|
const Material: typeof SDK.Material
|
|
64
|
+
const Material2D: typeof SDK.Material2D
|
|
63
65
|
const MaterialHandle: typeof SDK.MaterialHandle
|
|
64
66
|
const Mathf: typeof SDK.Mathf
|
|
65
67
|
const MediaStream: typeof SDK.MediaStream
|
|
@@ -80,6 +82,8 @@ declare global {
|
|
|
80
82
|
const Noise: typeof SDK.Noise
|
|
81
83
|
const OneWay2D: typeof SDK.OneWay2D
|
|
82
84
|
const Particles: typeof SDK.Particles
|
|
85
|
+
const Particles2D: typeof SDK.Particles2D
|
|
86
|
+
const Path2D: typeof SDK.Path2D
|
|
83
87
|
const Physics: typeof SDK.Physics
|
|
84
88
|
const Physics2D: typeof SDK.Physics2D
|
|
85
89
|
const PhysicsGroup2D: typeof SDK.PhysicsGroup2D
|
|
@@ -126,6 +130,7 @@ declare global {
|
|
|
126
130
|
const SvgSource: typeof SDK.SvgSource
|
|
127
131
|
const System: typeof SDK.System
|
|
128
132
|
const Terrain: typeof SDK.Terrain
|
|
133
|
+
const Text2D: typeof SDK.Text2D
|
|
129
134
|
const Texture: typeof SDK.Texture
|
|
130
135
|
const Texture2D: typeof SDK.Texture2D
|
|
131
136
|
const Tilemap: typeof SDK.Tilemap
|
|
@@ -176,8 +181,10 @@ declare global {
|
|
|
176
181
|
const __channel: typeof SDK.__channel
|
|
177
182
|
const __compOp: typeof SDK.__compOp
|
|
178
183
|
const __compWrite: typeof SDK.__compWrite
|
|
184
|
+
const __localAsset: typeof SDK.__localAsset
|
|
179
185
|
const __pushChannel: typeof SDK.__pushChannel
|
|
180
186
|
const __pushEnable: typeof SDK.__pushEnable
|
|
187
|
+
const __registerFont: typeof SDK.__registerFont
|
|
181
188
|
const __rpc: typeof SDK.__rpc
|
|
182
189
|
const __serverOnly: typeof SDK.__serverOnly
|
|
183
190
|
const __uiMap: typeof SDK.__uiMap
|
|
@@ -206,6 +213,7 @@ declare global {
|
|
|
206
213
|
const easeOut: typeof SDK.easeOut
|
|
207
214
|
const effect: typeof SDK.effect
|
|
208
215
|
const encodeCells: typeof SDK.encodeCells
|
|
216
|
+
const env: typeof SDK.env
|
|
209
217
|
const failureOf: typeof SDK.failureOf
|
|
210
218
|
const fetch: typeof SDK.fetch
|
|
211
219
|
const fetchLocal: typeof SDK.fetchLocal
|
|
@@ -283,6 +291,7 @@ declare global {
|
|
|
283
291
|
type AutoPaintRules = SDK.AutoPaintRules
|
|
284
292
|
type Autotile2D = SDK.Autotile2D
|
|
285
293
|
type Bitmap = SDK.Bitmap
|
|
294
|
+
type Blend2D = SDK.Blend2D
|
|
286
295
|
type BlendMember = SDK.BlendMember
|
|
287
296
|
type BlendPosition = SDK.BlendPosition
|
|
288
297
|
type BlockEntry = SDK.BlockEntry
|
|
@@ -351,10 +360,13 @@ declare global {
|
|
|
351
360
|
type File = SDK.File
|
|
352
361
|
type FileData = SDK.FileData
|
|
353
362
|
type FillBlock = SDK.FillBlock
|
|
363
|
+
type Filter2D = SDK.Filter2D
|
|
354
364
|
type FitOptions = SDK.FitOptions
|
|
355
365
|
type FoliageOptions = SDK.FoliageOptions
|
|
356
366
|
type FoliageWind = SDK.FoliageWind
|
|
357
367
|
type FollowPath = SDK.FollowPath
|
|
368
|
+
type Font2D = SDK.Font2D
|
|
369
|
+
type Font2DOptions = SDK.Font2DOptions
|
|
358
370
|
type FootState = SDK.FootState
|
|
359
371
|
type FormData = SDK.FormData
|
|
360
372
|
type Gait = SDK.Gait
|
|
@@ -428,6 +440,8 @@ declare global {
|
|
|
428
440
|
type MarkerTap = SDK.MarkerTap
|
|
429
441
|
type Mat4 = SDK.Mat4
|
|
430
442
|
type Material = SDK.Material
|
|
443
|
+
type Material2D = SDK.Material2D
|
|
444
|
+
type Material2DOptions = SDK.Material2DOptions
|
|
431
445
|
type MaterialData = SDK.MaterialData
|
|
432
446
|
type MaterialDef = SDK.MaterialDef
|
|
433
447
|
type MaterialHandle = SDK.MaterialHandle
|
|
@@ -471,10 +485,18 @@ declare global {
|
|
|
471
485
|
type Noise = SDK.Noise
|
|
472
486
|
type OneWay2D = SDK.OneWay2D
|
|
473
487
|
type OrientationLock = SDK.OrientationLock
|
|
488
|
+
type ParticleMode2D = SDK.ParticleMode2D
|
|
489
|
+
type ParticleShape2D = SDK.ParticleShape2D
|
|
474
490
|
type Particles = SDK.Particles
|
|
491
|
+
type Particles2D = SDK.Particles2D
|
|
492
|
+
type Particles2DOptions = SDK.Particles2DOptions
|
|
493
|
+
type Particles2DSourceDef = SDK.Particles2DSourceDef
|
|
475
494
|
type PatchMaterial = SDK.PatchMaterial
|
|
476
495
|
type PatchSlots = SDK.PatchSlots
|
|
496
|
+
type Path2D = SDK.Path2D
|
|
497
|
+
type Path2DOptions = SDK.Path2DOptions
|
|
477
498
|
type PathMaterial = SDK.PathMaterial
|
|
499
|
+
type PathSourceDef = SDK.PathSourceDef
|
|
478
500
|
type PermissionKind = SDK.PermissionKind
|
|
479
501
|
type PermissionState = SDK.PermissionState
|
|
480
502
|
type Physics = SDK.Physics
|
|
@@ -589,6 +611,9 @@ declare global {
|
|
|
589
611
|
type StopOptions = SDK.StopOptions
|
|
590
612
|
type StoredFile = SDK.StoredFile
|
|
591
613
|
type StoredImage = SDK.StoredImage
|
|
614
|
+
type Stroke2D = SDK.Stroke2D
|
|
615
|
+
type StrokeCap2D = SDK.StrokeCap2D
|
|
616
|
+
type StrokeJoin2D = SDK.StrokeJoin2D
|
|
592
617
|
type SvgSource = SDK.SvgSource
|
|
593
618
|
type System<K extends string, S extends SystemHost = Scene, E extends EventMap = {}> = SDK.System<K, S, E>
|
|
594
619
|
type SystemHost = SDK.SystemHost
|
|
@@ -600,6 +625,11 @@ declare global {
|
|
|
600
625
|
type TerrainOptions = SDK.TerrainOptions
|
|
601
626
|
type TerrainRegion = SDK.TerrainRegion
|
|
602
627
|
type TerrainSnapshot = SDK.TerrainSnapshot
|
|
628
|
+
type Text2D = SDK.Text2D
|
|
629
|
+
type Text2DOptions = SDK.Text2DOptions
|
|
630
|
+
type TextAlign2D = SDK.TextAlign2D
|
|
631
|
+
type TextOutline2D = SDK.TextOutline2D
|
|
632
|
+
type TextSourceDef = SDK.TextSourceDef
|
|
603
633
|
type Texture = SDK.Texture
|
|
604
634
|
type Texture2D = SDK.Texture2D
|
|
605
635
|
type TextureLoadOptions = SDK.TextureLoadOptions
|
|
@@ -676,6 +706,8 @@ declare global {
|
|
|
676
706
|
type Vec3 = SDK.Vec3
|
|
677
707
|
type Vec3Like = SDK.Vec3Like
|
|
678
708
|
type Vehicle = SDK.Vehicle
|
|
709
|
+
type VelocityOverLife2D = SDK.VelocityOverLife2D
|
|
710
|
+
type VelocityValue2D = SDK.VelocityValue2D
|
|
679
711
|
type VideoPlayer = SDK.VideoPlayer
|
|
680
712
|
type Voice = SDK.Voice
|
|
681
713
|
type VoiceEvents = SDK.VoiceEvents
|
|
@@ -689,17 +721,20 @@ declare global {
|
|
|
689
721
|
type WheelSuspension = SDK.WheelSuspension
|
|
690
722
|
type WidgetSet<Owner> = SDK.WidgetSet<Owner>
|
|
691
723
|
type With<N, A extends Aspect<any, any, any>> = SDK.With<N, A>
|
|
724
|
+
type Wrap2D = SDK.Wrap2D
|
|
692
725
|
// ---- server globals (available in *.server.ts; using them in client code is a build error) ----
|
|
693
726
|
const ApiError: typeof SERVER.ApiError
|
|
694
727
|
const SvgSource: typeof SERVER.SvgSource
|
|
695
728
|
const channel: typeof SERVER.channel
|
|
696
729
|
const defineDb: typeof SERVER.defineDb
|
|
730
|
+
const env: typeof SERVER.env
|
|
697
731
|
const model: typeof SERVER.model
|
|
698
732
|
const pushChannel: typeof SERVER.pushChannel
|
|
699
733
|
const ref: typeof SERVER.ref
|
|
700
734
|
const request: typeof SERVER.request
|
|
701
735
|
const t: typeof SERVER.t
|
|
702
736
|
type ApiError = SERVER.ApiError
|
|
737
|
+
type Env = SERVER.Env
|
|
703
738
|
type PushChannel<D extends Record<string, unknown> | undefined = undefined> = SERVER.PushChannel<D>
|
|
704
739
|
type PushMessage<D> = SERVER.PushMessage<D>
|
|
705
740
|
type PushNotification<D> = SERVER.PushNotification<D>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The project's keys as code reads them: `env.NAME` — one word on both sides. Server code
|
|
3
|
+
* (`*.server.ts`, src/server/env.ts) reads every key; the app (src/runtime/env.ts) only the
|
|
4
|
+
* `PUBLIC_*` ones, baked into its bundle at compile time — a bundle is public, so a key the app
|
|
5
|
+
* carries is public by its name, and the compile refuses any other name in app code.
|
|
6
|
+
*
|
|
7
|
+
* A key is a `string`, never `string | undefined`: reading one that is not set THROWS `EnvError`,
|
|
8
|
+
* with the fix in the message. `"NAME" in env` tells without throwing; `Object.keys(env)` lists
|
|
9
|
+
* what is set. Only a key's shape throws: `then`, symbols, inspection hooks read as undefined, so
|
|
10
|
+
* `await env`, `console.log(env)` and JSON.stringify behave.
|
|
11
|
+
*/
|
|
12
|
+
export type Env = {
|
|
13
|
+
readonly [name: string]: string;
|
|
14
|
+
};
|
|
15
|
+
/** How a key is named — in `.env`, in Settings → Keys, in code. */
|
|
16
|
+
export declare const ENV_NAME: RegExp;
|
|
17
|
+
/** A key the app may carry: the only names the client bundle gets. */
|
|
18
|
+
export declare const PUBLIC_ENV_PREFIX = "PUBLIC_";
|
|
19
|
+
export declare const isPublicEnvName: (name: string) => boolean;
|
|
20
|
+
export declare class EnvError extends Error {
|
|
21
|
+
readonly key: string;
|
|
22
|
+
constructor(key: string);
|
|
23
|
+
}
|
|
24
|
+
/** The `env` object over a source of values (read on every access: the server's are set by the host). */
|
|
25
|
+
export declare const makeEnv: (read: () => Record<string, string>) => Env;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { type ColorInput } from "./color";
|
|
2
|
+
import { type Vec3Like } from "../math/vec";
|
|
3
|
+
export type Range<T> = T | {
|
|
4
|
+
min: T;
|
|
5
|
+
max: T;
|
|
6
|
+
};
|
|
7
|
+
export declare const TAG_SHAPE = 1;
|
|
8
|
+
export declare const TAG_LIFETIME = 2;
|
|
9
|
+
export declare const TAG_RATE = 3;
|
|
10
|
+
export declare const TAG_VELOCITY = 4;
|
|
11
|
+
export declare const TAG_VELOCITY_RND = 5;
|
|
12
|
+
export declare const TAG_ACCELERATION = 6;
|
|
13
|
+
export declare const TAG_DRAG = 7;
|
|
14
|
+
export declare const TAG_NOISE = 8;
|
|
15
|
+
export declare const TAG_SEED = 9;
|
|
16
|
+
export declare const TAG_PARAM_CURVE = 10;
|
|
17
|
+
export declare const TAG_COLOR_CURVE = 11;
|
|
18
|
+
export declare const TAG_SPACE = 12;
|
|
19
|
+
export declare const TAG_INHERIT_VELOCITY = 13;
|
|
20
|
+
export declare const TAG_RATE_DISTANCE = 14;
|
|
21
|
+
export declare const TAG_RENDER_MODE = 15;
|
|
22
|
+
export declare const TAG_MESH_GEOMETRY = 16;
|
|
23
|
+
export declare const TAG_ANGULAR_VELOCITY = 17;
|
|
24
|
+
export declare const TAG_GROUND = 18;
|
|
25
|
+
export declare const TAG_VELOCITY_LIFE = 19;
|
|
26
|
+
export declare const TAG_ORDER = 20;
|
|
27
|
+
export declare const TAG_SMOOTH_PATH = 21;
|
|
28
|
+
export declare const TAG_RIBBON_ORIENT = 22;
|
|
29
|
+
export declare const TAG_LIT = 23;
|
|
30
|
+
/** 0 / 1 — an XY-plane system; the 2D engine sets it itself at creation (CPART_TAG_PLANAR), the SDK never writes it. */
|
|
31
|
+
export declare const TAG_PLANAR = 24;
|
|
32
|
+
/** RENDER_MODE payloads (CPART_MODE_* in creator-particles.h). */
|
|
33
|
+
export declare const MODE_POINTS = 0;
|
|
34
|
+
export declare const MODE_QUADS = 1;
|
|
35
|
+
export declare const MODE_RIBBON = 2;
|
|
36
|
+
export declare const MODE_MESH = 3;
|
|
37
|
+
/** The PARAM_CURVE slots the named params alias (custom[0..3]). */
|
|
38
|
+
export declare const SLOT_SIZE = 0;
|
|
39
|
+
export declare const SLOT_ROTATION = 1;
|
|
40
|
+
export declare const SLOT_OPACITY = 2;
|
|
41
|
+
export declare const SLOT_FRAME = 3;
|
|
42
|
+
export declare class CurveBuilder {
|
|
43
|
+
private _kind;
|
|
44
|
+
private _lo;
|
|
45
|
+
private _hi;
|
|
46
|
+
private _stops;
|
|
47
|
+
constructor(base: Range<number>, mode: "multiply" | "add");
|
|
48
|
+
/** Curve value at birth (t = 0). Must come before any other stop. */
|
|
49
|
+
from(v: Range<number>): this;
|
|
50
|
+
/** Curve value at `t` (0..1 of the particle's life). Stops must be added in ascending t order. */
|
|
51
|
+
via(t: number, v: Range<number>): this;
|
|
52
|
+
/** Curve value at death (t = 1). */
|
|
53
|
+
to(v: Range<number>): this;
|
|
54
|
+
/** The classic opacity envelope: rise over the first `fadeIn`, fall over the last `fadeOut`. */
|
|
55
|
+
fade(fadeIn?: number, fadeOut?: number): this;
|
|
56
|
+
/** The PARAM_CURVE record payload (sans slot): [kind, baseLo, baseHi, n, (t, lo, hi)×n]. */
|
|
57
|
+
get _data(): Float32Array;
|
|
58
|
+
}
|
|
59
|
+
export declare class ColorCurveBuilder {
|
|
60
|
+
private _lo;
|
|
61
|
+
private _hi;
|
|
62
|
+
private _stops;
|
|
63
|
+
constructor(base: Range<ColorInput>);
|
|
64
|
+
/** Curve color at birth (t = 0). Must come first. The curve multiplies the base color. */
|
|
65
|
+
from(c: Range<ColorInput>): this;
|
|
66
|
+
/** Curve color at `t` (0..1 of the particle's life), in ascending t order. */
|
|
67
|
+
via(t: number, c: Range<ColorInput>): this;
|
|
68
|
+
/** Curve color at death (t = 1). */
|
|
69
|
+
to(c: Range<ColorInput>): this;
|
|
70
|
+
/** The COLOR_CURVE record payload: [baseLo rgba, baseHi rgba, n, (t, lo rgba, hi rgba)×n]. */
|
|
71
|
+
get _data(): Float32Array;
|
|
72
|
+
}
|
|
73
|
+
/** A value curve over each particle's lifetime. Default mode `multiply` (the curve scales the
|
|
74
|
+
* base); `add` offsets it instead. */
|
|
75
|
+
export declare const curve: (base?: Range<number>, mode?: "multiply" | "add") => CurveBuilder;
|
|
76
|
+
/** A color curve over each particle's lifetime — always multiplies the base color. */
|
|
77
|
+
export declare const colorCurve: (base?: Range<ColorInput>) => ColorCurveBuilder;
|
|
78
|
+
export type ParticleValue = Range<number> | CurveBuilder | {
|
|
79
|
+
_data: Float32Array;
|
|
80
|
+
};
|
|
81
|
+
export type ParticleColor = ColorInput | {
|
|
82
|
+
min: ColorInput;
|
|
83
|
+
max: ColorInput;
|
|
84
|
+
} | ColorCurveBuilder | {
|
|
85
|
+
_data: Float32Array;
|
|
86
|
+
};
|
|
87
|
+
/** A start velocity by direction + speed (the object form of `startVelocity`). */
|
|
88
|
+
export type VelocityValue = {
|
|
89
|
+
speed?: Range<number>;
|
|
90
|
+
/** Cone half-angle in radians — jitter the launch direction uniformly within it. */
|
|
91
|
+
spread?: number;
|
|
92
|
+
/** Asymmetric jitter: two angles (u, v — the x/y components) in radians. */
|
|
93
|
+
randomizeAngle?: {
|
|
94
|
+
min: Vec3Like;
|
|
95
|
+
max: Vec3Like;
|
|
96
|
+
};
|
|
97
|
+
} & ({
|
|
98
|
+
from: Vec3Like;
|
|
99
|
+
} | {
|
|
100
|
+
to: Vec3Like;
|
|
101
|
+
} | {
|
|
102
|
+
dir: Vec3Like;
|
|
103
|
+
} | {});
|
|
104
|
+
/** Where particles are born, in emitter space. Sphere / hemisphere / cone have an axis of +Y (the
|
|
105
|
+
* hemisphere is the +Y half, the cone opens along +Y from its base disc at `center`) — aim the
|
|
106
|
+
* node with `lookAt(target, 'y')`. `thickness` 0 emits from the surface only, 1 (default) from the
|
|
107
|
+
* whole volume. A sphere or cone also sets the LAUNCH DIRECTION (outward / from the cone's apex)
|
|
108
|
+
* when `startVelocity` gives a speed but no direction, like Unity's shapes. */
|
|
109
|
+
export type ParticleShape = {
|
|
110
|
+
type: "point";
|
|
111
|
+
v: Vec3Like;
|
|
112
|
+
} | {
|
|
113
|
+
type: "box";
|
|
114
|
+
min: Vec3Like;
|
|
115
|
+
max: Vec3Like;
|
|
116
|
+
} | {
|
|
117
|
+
type: "circle";
|
|
118
|
+
center: Vec3Like;
|
|
119
|
+
radius: number;
|
|
120
|
+
} | {
|
|
121
|
+
type: "sphere";
|
|
122
|
+
center?: Vec3Like;
|
|
123
|
+
radius: number;
|
|
124
|
+
thickness?: number;
|
|
125
|
+
} | {
|
|
126
|
+
type: "hemisphere";
|
|
127
|
+
center?: Vec3Like;
|
|
128
|
+
radius: number;
|
|
129
|
+
thickness?: number;
|
|
130
|
+
} | {
|
|
131
|
+
type: "cone";
|
|
132
|
+
center?: Vec3Like;
|
|
133
|
+
radius: number; /** half-angle, radians */
|
|
134
|
+
angle?: number; /** emit this far up the axis too */
|
|
135
|
+
length?: number;
|
|
136
|
+
thickness?: number;
|
|
137
|
+
};
|
|
138
|
+
/** Extra velocity over each particle's life — evaluated from the curves every frame and ADDED as a
|
|
139
|
+
* displacement (not accumulated like `acceleration`): `radial` pushes outward along the particle's
|
|
140
|
+
* birth direction (a burst that decays: `curve(4).to(0)`), `x`/`y`/`z` drift in the simulation
|
|
141
|
+
* space (rising smoke: `y: curve(2).from(0).to(1)`). Unity's velocityOverLifetime. */
|
|
142
|
+
export type VelocityOverLife = {
|
|
143
|
+
radial?: ParticleValue;
|
|
144
|
+
x?: ParticleValue;
|
|
145
|
+
y?: ParticleValue;
|
|
146
|
+
z?: ParticleValue;
|
|
147
|
+
};
|
|
148
|
+
export type ParticleNoise = {
|
|
149
|
+
strength?: number;
|
|
150
|
+
frequency?: number;
|
|
151
|
+
speed?: number;
|
|
152
|
+
/** How much of the displacement a particle earns with AGE (default 0 = all of it from birth).
|
|
153
|
+
* The field is sampled by position, so at 0 every particle born at the same spot is pushed the
|
|
154
|
+
* same way and a plume's root wanders off its emitter by up to `strength` metres; at 1 a particle
|
|
155
|
+
* is born exactly where the emitter put it and drifts into the field over its life — what you
|
|
156
|
+
* want whenever the source is visible (an exhaust pipe, a contact patch, a muzzle). */
|
|
157
|
+
ramp?: number;
|
|
158
|
+
};
|
|
159
|
+
/** Ground plane for bouncing particles (all render modes). `height` is in the simulation space:
|
|
160
|
+
* world y with `space: 'world'`, emitter-local y otherwise. */
|
|
161
|
+
export type ParticleGround = {
|
|
162
|
+
/** Plane height (default 0). */
|
|
163
|
+
height?: number;
|
|
164
|
+
/** Contact radius — particles stop `radius` above the plane (a mesh's half-extent; default 0). */
|
|
165
|
+
radius?: number;
|
|
166
|
+
/** Fraction of the vertical speed kept on impact, 0..1 (default 0.3). */
|
|
167
|
+
bounce?: number;
|
|
168
|
+
/** Tangential damping while in contact, per second — like `drag` (default 8). */
|
|
169
|
+
friction?: number;
|
|
170
|
+
};
|
|
171
|
+
/** The mesh a mesh-mode system draws per particle — structurally a `Geometry`. */
|
|
172
|
+
export type ParticleMeshData = {
|
|
173
|
+
readonly vertices: ArrayLike<number>;
|
|
174
|
+
readonly normals: ArrayLike<number>;
|
|
175
|
+
readonly uv: ArrayLike<number>;
|
|
176
|
+
readonly indices: ArrayLike<number>;
|
|
177
|
+
};
|
|
178
|
+
/** A PARAM_CURVE record: `slot` 0 size / 1 rotation / 2 opacity / 3 frame. */
|
|
179
|
+
export declare const pushParam: (out: number[], slot: number, value: ParticleValue) => void;
|
|
180
|
+
export declare const pushColor: (out: number[], value: ParticleColor) => void;
|
|
181
|
+
export declare const pushMesh: (out: number[], g: ParticleMeshData) => void;
|
|
182
|
+
export declare const pushAngularVelocity: (out: number[], v: Vec3Like | {
|
|
183
|
+
min: Vec3Like;
|
|
184
|
+
max: Vec3Like;
|
|
185
|
+
}) => void;
|
|
186
|
+
export declare const pushGround: (out: number[], g: ParticleGround | null) => void;
|
|
187
|
+
export declare const pushShape: (out: number[], shape: ParticleShape) => void;
|
|
188
|
+
export declare const pushVelocityLife: (out: number[], v: VelocityOverLife) => void;
|
|
189
|
+
export declare const pushVelocity: (out: number[], val: Vec3Like | VelocityValue) => void;
|
|
190
|
+
/** A NOISE record; `null` turns the field off. */
|
|
191
|
+
export declare const pushNoise: (out: number[], n: ParticleNoise | null) => void;
|
|
192
|
+
/** A LIFETIME record. */
|
|
193
|
+
export declare const pushLifetime: (out: number[], val: Range<number>) => void;
|
|
194
|
+
/** The default flipbook: with a sheet of more than one frame and no explicit `frame`, one full sheet
|
|
195
|
+
* cycle over each particle's lifetime, starting at `startFrame` (`'random'` = desynchronized loops). */
|
|
196
|
+
export declare const pushDefaultFrames: (out: number[], cols: number, rows: number, startFrame?: number | "random") => void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type FetchResponse, type File } from "../runtime/fetch";
|
|
2
|
+
export type Font2DOptions = {
|
|
3
|
+
/** For a registered family: the face's weight (default 400; the nearest registered one is used). */
|
|
4
|
+
weight?: number;
|
|
5
|
+
/** For a registered family: the italic face (default false). */
|
|
6
|
+
italic?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare class Font2D {
|
|
9
|
+
/** Native font handle. */
|
|
10
|
+
readonly id: number;
|
|
11
|
+
private _key?;
|
|
12
|
+
/** A registered family name (what `font("inter")` compiles to, e.g. "Inter") picks the ttf of
|
|
13
|
+
* (weight ?? 400, italic); anything else is a URL / asset path / response / File fetched as is
|
|
14
|
+
* (`asset('./fonts/Brand.ttf')`). Cached per resolved URL: a family loads once. */
|
|
15
|
+
static load(source: string | FetchResponse | File, options?: Font2DOptions): Promise<Font2D>;
|
|
16
|
+
/** Free the native font (and its atlas) — for every holder of this cached font; a later load
|
|
17
|
+
* parses it again. Texts still using it stop drawing. */
|
|
18
|
+
destroy(): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type Blend2D = "alpha" | "additive";
|
|
2
|
+
export type Filter2D = "nearest" | "linear";
|
|
3
|
+
export type Wrap2D = "clamp" | "repeat";
|
|
4
|
+
export type Material2DOptions = {
|
|
5
|
+
/** `'alpha'` (default) covers what is under it by its alpha; `'additive'` adds its colour. */
|
|
6
|
+
blend?: Blend2D;
|
|
7
|
+
/** Texture sampling; unset = the renderer default (the Scene2D `filter`). */
|
|
8
|
+
filter?: Filter2D;
|
|
9
|
+
/** `'clamp'` (default) stretches the edge texel past [0,1]; `'repeat'` tiles the texture. */
|
|
10
|
+
wrap?: Wrap2D;
|
|
11
|
+
};
|
|
12
|
+
export declare class Material2D {
|
|
13
|
+
readonly blend: Blend2D;
|
|
14
|
+
/** Undefined = the renderer default (the Scene2D `filter`). */
|
|
15
|
+
readonly filter?: Filter2D;
|
|
16
|
+
readonly wrap: Wrap2D;
|
|
17
|
+
private constructor();
|
|
18
|
+
/** An alpha-blended material — what every sprite and tilemap has by default. */
|
|
19
|
+
static sprite(options?: Material2DOptions): Material2D;
|
|
20
|
+
/** An additive material: glow, fire, sparks, flashes. */
|
|
21
|
+
static additive(options?: Omit<Material2DOptions, "blend">): Material2D;
|
|
22
|
+
/** The default material (alpha blend, renderer-default filter, clamp). */
|
|
23
|
+
static readonly default: Material2D;
|
|
24
|
+
}
|
|
@@ -47,7 +47,7 @@ export declare class Node2D extends AspectHost<Node2DEvents> implements CompWrit
|
|
|
47
47
|
protected _rotation: number;
|
|
48
48
|
protected _sx: number;
|
|
49
49
|
protected _sy: number;
|
|
50
|
-
protected
|
|
50
|
+
protected _renderPriority: number;
|
|
51
51
|
protected _z: number;
|
|
52
52
|
protected _visible: boolean;
|
|
53
53
|
private _pushXf;
|
|
@@ -70,10 +70,11 @@ export declare class Node2D extends AspectHost<Node2DEvents> implements CompWrit
|
|
|
70
70
|
animateTo(props: Node2DTweenProps & TweenMeta): Animation;
|
|
71
71
|
/** Tween FROM the given values to the node's current transform. */
|
|
72
72
|
animateFrom(props: Node2DTweenProps & TweenMeta): Animation;
|
|
73
|
-
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
/** Coarse draw order: 0 draws first, 7 last, 4 is the default — the 3D `Mesh.renderPriority`.
|
|
74
|
+
* Within one priority `z` orders, then (with `scene.ySort` on) world Y. Rounded and clamped to 0..7. */
|
|
75
|
+
get renderPriority(): number;
|
|
76
|
+
set renderPriority(v: number);
|
|
77
|
+
/** Draw order within a renderPriority (higher = on top); with `scene.ySort` on, equal z sorts by world Y. */
|
|
77
78
|
get z(): number;
|
|
78
79
|
set z(v: number);
|
|
79
80
|
get visible(): boolean;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { type Vec2Like } from "../math/vec";
|
|
2
|
+
import { type ParticleColor, type ParticleGround, type ParticleNoise, type ParticleValue, type Range } from "../core/particlesConfig";
|
|
3
|
+
import { Node2D } from "./Node2D";
|
|
4
|
+
import type { Material2D } from "./Material2D";
|
|
5
|
+
import type { Texture2D } from "./Texture2D";
|
|
6
|
+
export type ParticleMode2D = "quads" | "points" | "trail";
|
|
7
|
+
/** Where particles are born, in the node's local frame.
|
|
8
|
+
* - `point` at `v` (default the origin);
|
|
9
|
+
* - `box` between `min` and `max` (a spawn line: give it no height);
|
|
10
|
+
* - `circle` of `radius` around `center` — a disc, evenly filled; `thickness` 0 = the outline only (a
|
|
11
|
+
* ring). Gives the launch direction (outward) when `startVelocity` has a speed and no direction;
|
|
12
|
+
* - `cone` opening along +y from its base of half-width `radius` at `center`: `angle` (half-angle,
|
|
13
|
+
* radians) flares it, `length` emits that far up the axis too; launches away from the apex.
|
|
14
|
+
* `thickness` 0 = the outline only, 1 (default) = the whole area. */
|
|
15
|
+
export type ParticleShape2D = {
|
|
16
|
+
type: "point";
|
|
17
|
+
v?: Vec2Like;
|
|
18
|
+
} | {
|
|
19
|
+
type: "box";
|
|
20
|
+
min: Vec2Like;
|
|
21
|
+
max: Vec2Like;
|
|
22
|
+
} | {
|
|
23
|
+
type: "circle";
|
|
24
|
+
center?: Vec2Like;
|
|
25
|
+
radius: number;
|
|
26
|
+
thickness?: number;
|
|
27
|
+
} | {
|
|
28
|
+
type: "cone";
|
|
29
|
+
center?: Vec2Like;
|
|
30
|
+
radius: number;
|
|
31
|
+
angle?: number;
|
|
32
|
+
length?: number;
|
|
33
|
+
thickness?: number;
|
|
34
|
+
};
|
|
35
|
+
/** A start velocity by direction + speed. `dir` launches along a vector, `from` away from a point,
|
|
36
|
+
* `to` toward one; with none, a sphere / cone `shape` gives the direction, else a random one.
|
|
37
|
+
* `spread` jitters the direction by up to ± that angle (radians, in the plane). */
|
|
38
|
+
export type VelocityValue2D = {
|
|
39
|
+
speed?: Range<number>;
|
|
40
|
+
spread?: number;
|
|
41
|
+
} & ({
|
|
42
|
+
from: Vec2Like;
|
|
43
|
+
} | {
|
|
44
|
+
to: Vec2Like;
|
|
45
|
+
} | {
|
|
46
|
+
dir: Vec2Like;
|
|
47
|
+
} | {});
|
|
48
|
+
/** Extra velocity over each particle's life, ADDED as a displacement: `radial` along its birth
|
|
49
|
+
* direction (a burst that decays: `curve(200).to(0)`), `x` / `y` a drift (rising smoke:
|
|
50
|
+
* `y: curve(60).from(0).to(1)`). See `VelocityOverLife` (3D). */
|
|
51
|
+
export type VelocityOverLife2D = {
|
|
52
|
+
radial?: ParticleValue;
|
|
53
|
+
x?: ParticleValue;
|
|
54
|
+
y?: ParticleValue;
|
|
55
|
+
};
|
|
56
|
+
export type Particles2DOptions = {
|
|
57
|
+
/** The particle image — one picture or a flipbook sheet (`sheet`). Omit = solid squares of `color`. */
|
|
58
|
+
texture?: Texture2D;
|
|
59
|
+
/** The texture's flipbook grid: `N` = N×N, `[cols, rows]`; frames run left-to-right, top-to-bottom.
|
|
60
|
+
* Default 1. With more than one frame and no `frame`, each particle plays the sheet once over its
|
|
61
|
+
* life, from `startFrame`. */
|
|
62
|
+
sheet?: number | [cols: number, rows: number];
|
|
63
|
+
/** Blend (+ sampling) — `Material2D.additive()` for fire, sparks, glow. Default alpha. */
|
|
64
|
+
material?: Material2D;
|
|
65
|
+
/** Pool capacity (default 1000). */
|
|
66
|
+
maxParticles?: number;
|
|
67
|
+
/** `'quads'` (default) a rotated square each; `'points'` the same look from a cheaper stream;
|
|
68
|
+
* `'trail'` one ribbon strip through the particles in spawn order — `size` is its width (pair it
|
|
69
|
+
* with `space: 'world'` and `rateOverDistance` for a trail behind a moving node). */
|
|
70
|
+
mode?: ParticleMode2D;
|
|
71
|
+
/** Particles emitted per second. */
|
|
72
|
+
rate?: number;
|
|
73
|
+
/** Particles emitted per world unit the emitter MOVES, on top of `rate` (trails; meant for
|
|
74
|
+
* `space: 'world'`). */
|
|
75
|
+
rateOverDistance?: number;
|
|
76
|
+
/** Lay a frame's distance spawns along a curve through the emitter's path, not the straight chord. */
|
|
77
|
+
smooth?: boolean;
|
|
78
|
+
/** `'local'` (default) — particles ride the node; `'world'` — each stays where it was born as the
|
|
79
|
+
* emitter moves on. Switching at runtime resets live particles. */
|
|
80
|
+
space?: "local" | "world";
|
|
81
|
+
/** Fraction of the emitter's own velocity given to each particle at spawn (`space: 'world'`). */
|
|
82
|
+
inheritVelocity?: number;
|
|
83
|
+
shape?: ParticleShape2D;
|
|
84
|
+
/** A vector (its length is the speed) or a direction + speed. World units / s. */
|
|
85
|
+
startVelocity?: Vec2Like | VelocityValue2D;
|
|
86
|
+
velocityOverLife?: VelocityOverLife2D;
|
|
87
|
+
/** Downward acceleration, world units/s² — positive pulls toward -y (sugar for
|
|
88
|
+
* `acceleration: [0, -g]`); negative makes smoke rise. */
|
|
89
|
+
gravity?: number;
|
|
90
|
+
/** Constant acceleration (gravity, wind). Wins over `gravity` when both are set. */
|
|
91
|
+
acceleration?: Vec2Like;
|
|
92
|
+
drag?: number;
|
|
93
|
+
/** Seconds each particle lives. */
|
|
94
|
+
lifetime?: Range<number>;
|
|
95
|
+
color?: ParticleColor;
|
|
96
|
+
/** Diameter in WORLD units (custom[0]). Default 1 — a 2D world is usually pixel-scaled, so set it. */
|
|
97
|
+
size?: ParticleValue;
|
|
98
|
+
/** The particle's spin, radians (custom[1]) — a curve with mode `add` turns it over its life. */
|
|
99
|
+
rotation?: ParticleValue;
|
|
100
|
+
/** 0..1 (custom[2]). Default 1. */
|
|
101
|
+
opacity?: ParticleValue;
|
|
102
|
+
/** Flipbook frame index (custom[3]). */
|
|
103
|
+
frame?: ParticleValue;
|
|
104
|
+
/** Where the default flipbook cycle begins: `'random'` (default) or a frame index. */
|
|
105
|
+
startFrame?: number | "random";
|
|
106
|
+
/** A floor at `height` on the y axis the particles bounce on and rest on; `null` disables it. */
|
|
107
|
+
ground?: ParticleGround | null;
|
|
108
|
+
/** Turbulence; `null` turns it off. */
|
|
109
|
+
noise?: ParticleNoise | null;
|
|
110
|
+
/** Fixed random seed for deterministic tests. */
|
|
111
|
+
seed?: number;
|
|
112
|
+
position?: Vec2Like;
|
|
113
|
+
/** Draw order within a renderPriority — see {@link Node2D.z}. */
|
|
114
|
+
z?: number;
|
|
115
|
+
/** Coarse draw order 0..7, default 4 — see {@link Node2D.renderPriority}. */
|
|
116
|
+
renderPriority?: number;
|
|
117
|
+
};
|
|
118
|
+
export declare class Particles2D extends Node2D {
|
|
119
|
+
private _texture?;
|
|
120
|
+
private _sheet;
|
|
121
|
+
private _material?;
|
|
122
|
+
private _mode;
|
|
123
|
+
private _startFrame;
|
|
124
|
+
private _frameSet;
|
|
125
|
+
readonly maxParticles: number;
|
|
126
|
+
/** Curve-param slots 0..3, live: size / rotation / opacity / frame alias 0..3. The particle
|
|
127
|
+
* rotation is `custom[1] = …` (the node's own `rotation` is the emitter's). */
|
|
128
|
+
readonly custom: ParticleValue[];
|
|
129
|
+
constructor(options?: Particles2DOptions);
|
|
130
|
+
private _sendParticles;
|
|
131
|
+
private _send;
|
|
132
|
+
/** Emit `count` particles now, where the emitter is (a burst). */
|
|
133
|
+
spawn(count: number): this;
|
|
134
|
+
/** Live particles right now. */
|
|
135
|
+
get alive(): number;
|
|
136
|
+
/** The particle image; undefined = solid squares of the colour. */
|
|
137
|
+
get texture(): Texture2D | undefined;
|
|
138
|
+
set texture(t: Texture2D | undefined);
|
|
139
|
+
/** The texture's flipbook grid [cols, rows]. Without an explicit `frame` the default cycle follows. */
|
|
140
|
+
get sheet(): [number, number];
|
|
141
|
+
set sheet(s: number | [number, number]);
|
|
142
|
+
/** Blend ({@link Material2D}). Undefined = the default (alpha). */
|
|
143
|
+
get material(): Material2D | undefined;
|
|
144
|
+
set material(m: Material2D);
|
|
145
|
+
/** How particles are drawn — see `Particles2DOptions.mode`. */
|
|
146
|
+
get mode(): ParticleMode2D;
|
|
147
|
+
set mode(m: ParticleMode2D);
|
|
148
|
+
set rate(val: number);
|
|
149
|
+
/** `'world'` leaves particles behind where they were born (trails). Switching resets live ones. */
|
|
150
|
+
set space(val: "local" | "world");
|
|
151
|
+
set inheritVelocity(val: number);
|
|
152
|
+
set rateOverDistance(val: number);
|
|
153
|
+
set smooth(val: boolean);
|
|
154
|
+
set shape(shape: ParticleShape2D);
|
|
155
|
+
set startVelocity(val: Vec2Like | VelocityValue2D);
|
|
156
|
+
set velocityOverLife(v: VelocityOverLife2D);
|
|
157
|
+
/** Positive pulls toward -y — sugar for `acceleration = [0, -g]`. */
|
|
158
|
+
set gravity(val: number);
|
|
159
|
+
set acceleration(a: Vec2Like);
|
|
160
|
+
set drag(val: number);
|
|
161
|
+
set seed(val: number);
|
|
162
|
+
set lifetime(val: Range<number>);
|
|
163
|
+
set size(val: ParticleValue);
|
|
164
|
+
set opacity(val: ParticleValue);
|
|
165
|
+
set frame(val: ParticleValue);
|
|
166
|
+
set color(value: ParticleColor);
|
|
167
|
+
set ground(g: ParticleGround | null);
|
|
168
|
+
set noise(n: ParticleNoise | null);
|
|
169
|
+
}
|