lecodes-sdk 0.20.2 → 1.1.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.
Files changed (129) hide show
  1. package/dist/global.d.ts +35 -9
  2. package/dist/types/animate/tween/Animation.d.ts +69 -0
  3. package/dist/types/animate/tween/Timeline.d.ts +55 -0
  4. package/dist/types/animate/tween/animateValue.d.ts +27 -0
  5. package/dist/types/animate/tween/easing.d.ts +29 -0
  6. package/dist/types/animate/tween/spec.d.ts +178 -0
  7. package/dist/types/canvas/Canvas.d.ts +2 -0
  8. package/dist/types/g2/Node2D.d.ts +16 -0
  9. package/dist/types/g2/Sprite.d.ts +11 -1
  10. package/dist/types/gl/Camera.d.ts +15 -1
  11. package/dist/types/gl/DecalSet.d.ts +48 -3
  12. package/dist/types/gl/Foliage.d.ts +47 -0
  13. package/dist/types/gl/Geometry.d.ts +36 -0
  14. package/dist/types/gl/Light.d.ts +25 -7
  15. package/dist/types/gl/Lightmap.d.ts +90 -51
  16. package/dist/types/gl/Material.d.ts +32 -20
  17. package/dist/types/gl/Mesh.d.ts +7 -1
  18. package/dist/types/gl/Model.d.ts +41 -5
  19. package/dist/types/gl/Node.d.ts +18 -0
  20. package/dist/types/gl/Particles.d.ts +53 -1
  21. package/dist/types/gl/Scene.d.ts +21 -1
  22. package/dist/types/gl/animation/AnimationClip.d.ts +19 -0
  23. package/dist/types/gl/animation/Animator.d.ts +27 -0
  24. package/dist/types/gl/animation/DynamicBone.d.ts +184 -0
  25. package/dist/types/gl/animation/IK.d.ts +109 -0
  26. package/dist/types/gl/{Locomotion.d.ts → animation/Locomotion.d.ts} +6 -6
  27. package/dist/types/gl/animation/Warp.d.ts +2 -1
  28. package/dist/types/gl/animation/core.d.ts +35 -4
  29. package/dist/types/gl/{AudioSource.d.ts → audio/AudioSource.d.ts} +6 -6
  30. package/dist/types/gl/{AudioZone.d.ts → audio/AudioZone.d.ts} +4 -4
  31. package/dist/types/gl/{SceneAudio.d.ts → audio/SceneAudio.d.ts} +1 -1
  32. package/dist/types/gl/{NavAgent.d.ts → nav/NavAgent.d.ts} +4 -4
  33. package/dist/types/gl/{NavMesh.d.ts → nav/NavMesh.d.ts} +4 -4
  34. package/dist/types/gl/{CharacterController.d.ts → physics/CharacterController.d.ts} +5 -5
  35. package/dist/types/gl/{Physics.d.ts → physics/Physics.d.ts} +6 -5
  36. package/dist/types/gl/physics/Ragdoll.d.ts +161 -0
  37. package/dist/types/gl/{Shape.d.ts → physics/Shape.d.ts} +3 -3
  38. package/dist/types/gl/{Trigger.d.ts → physics/Trigger.d.ts} +2 -2
  39. package/dist/types/gl/{Terrain.d.ts → terrain/Terrain.d.ts} +10 -8
  40. package/dist/types/gl/{terrainMesh.d.ts → terrain/terrainMesh.d.ts} +1 -1
  41. package/dist/types/gl/vehicle/Vehicle.d.ts +300 -0
  42. package/dist/types/gl/vehicle/Wheel.d.ts +147 -0
  43. package/dist/types/inject.d.ts +35 -27
  44. package/dist/types/runtime/files.d.ts +24 -1
  45. package/dist/types/scene/defineScene.d.ts +50 -31
  46. package/dist/types/ui/UIButton.d.ts +3 -1
  47. package/dist/types/ui/UIInput.d.ts +5 -1
  48. package/dist/types/ui/UINode.d.ts +24 -24
  49. package/dist/types.json +1 -1
  50. package/package.json +1 -1
  51. package/prompts/README.md +142 -142
  52. package/prompts/core-design.md +27 -4
  53. package/prompts/core.md +35 -6
  54. package/prompts/select.ts +19 -4
  55. package/src/animate/tween/Animation.ts +378 -0
  56. package/src/animate/tween/Timeline.ts +175 -0
  57. package/src/animate/tween/animateValue.ts +100 -0
  58. package/src/animate/tween/easing.ts +172 -0
  59. package/src/animate/tween/spec.ts +479 -0
  60. package/src/bridges.d.ts +1760 -1481
  61. package/src/canvas/Canvas.ts +21 -0
  62. package/src/compile/__tests__/assetMacro.test.ts +26 -0
  63. package/src/compile/__tests__/compile.test.ts +11 -0
  64. package/src/compile/__tests__/detectEntry.test.ts +19 -0
  65. package/src/compile/__tests__/serverSplit.test.ts +27 -0
  66. package/src/compile/bundler.ts +34 -4
  67. package/src/compile/compileProject.ts +31 -1
  68. package/src/compile/detectEntry.ts +8 -3
  69. package/src/compile/header.ts +6 -3
  70. package/src/compile/index.ts +3 -0
  71. package/src/compile/sceneEditor.ts +42 -1
  72. package/src/compile/serverSplit.ts +9 -3
  73. package/src/g2/Node2D.ts +38 -0
  74. package/src/g2/Sprite.ts +20 -1
  75. package/src/gl/Camera.ts +34 -1
  76. package/src/gl/DecalSet.ts +132 -5
  77. package/src/gl/Foliage.ts +102 -0
  78. package/src/gl/Geometry.ts +109 -0
  79. package/src/gl/Light.ts +46 -16
  80. package/src/gl/Lightmap.ts +440 -249
  81. package/src/gl/Material.ts +69 -36
  82. package/src/gl/Mesh.ts +120 -102
  83. package/src/gl/Model.ts +167 -124
  84. package/src/gl/Node.ts +40 -1
  85. package/src/gl/Particles.ts +82 -5
  86. package/src/gl/Scene.ts +35 -2
  87. package/src/gl/animation/AnimationClip.ts +52 -0
  88. package/src/gl/animation/Animator.ts +42 -2
  89. package/src/gl/animation/DynamicBone.ts +482 -0
  90. package/src/gl/animation/IK.ts +214 -0
  91. package/src/gl/{Locomotion.ts → animation/Locomotion.ts} +7 -7
  92. package/src/gl/animation/Playback.ts +5 -4
  93. package/src/gl/animation/Warp.ts +5 -2
  94. package/src/gl/animation/core.ts +65 -4
  95. package/src/gl/{AudioSource.ts → audio/AudioSource.ts} +7 -7
  96. package/src/gl/{AudioZone.ts → audio/AudioZone.ts} +75 -75
  97. package/src/gl/{SceneAudio.ts → audio/SceneAudio.ts} +2 -2
  98. package/src/gl/{NavAgent.ts → nav/NavAgent.ts} +5 -5
  99. package/src/gl/{NavMesh.ts → nav/NavMesh.ts} +8 -8
  100. package/src/gl/{CharacterController.ts → physics/CharacterController.ts} +5 -5
  101. package/src/gl/{Physics.ts → physics/Physics.ts} +12 -5
  102. package/src/gl/physics/Ragdoll.ts +451 -0
  103. package/src/gl/{Shape.ts → physics/Shape.ts} +3 -3
  104. package/src/gl/{Trigger.ts → physics/Trigger.ts} +45 -45
  105. package/src/gl/{physicsEvents.ts → physics/physicsEvents.ts} +1 -1
  106. package/src/gl/{Terrain.ts → terrain/Terrain.ts} +14 -12
  107. package/src/gl/{terrainMesh.ts → terrain/terrainMesh.ts} +1 -1
  108. package/src/gl/vehicle/Vehicle.ts +666 -0
  109. package/src/gl/vehicle/Wheel.ts +290 -0
  110. package/src/inject.ts +236 -224
  111. package/src/runtime/files.ts +32 -2
  112. package/src/scene/defineScene.ts +92 -66
  113. package/src/scene/level.ts +2 -2
  114. package/src/ui/UIButton.ts +2 -2
  115. package/src/ui/UIInput.ts +3 -3
  116. package/src/ui/UINode.ts +61 -36
  117. package/dist/types/animate/animate.d.ts +0 -20
  118. package/dist/types/gl/Gearbox.d.ts +0 -86
  119. package/dist/types/gl/IK.d.ts +0 -53
  120. package/dist/types/gl/Ragdoll.d.ts +0 -86
  121. package/dist/types/gl/Vehicle.d.ts +0 -191
  122. package/dist/types/gl/Wheel.d.ts +0 -95
  123. package/src/animate/animate.ts +0 -238
  124. package/src/gl/Gearbox.ts +0 -212
  125. package/src/gl/IK.ts +0 -193
  126. package/src/gl/Ragdoll.ts +0 -270
  127. package/src/gl/Vehicle.ts +0 -473
  128. package/src/gl/Wheel.ts +0 -240
  129. /package/dist/types/gl/{physicsEvents.d.ts → physics/physicsEvents.d.ts} +0 -0
package/dist/global.d.ts CHANGED
@@ -28,11 +28,14 @@ declare global {
28
28
  const Color: typeof SDK.Color
29
29
  const DateValue: typeof SDK.DateValue
30
30
  const DecalSet: typeof SDK.DecalSet
31
+ const DecalTrail: typeof SDK.DecalTrail
32
+ const DynamicBone: typeof SDK.DynamicBone
33
+ const DynamicBoneCollider: typeof SDK.DynamicBoneCollider
31
34
  const Feet: typeof SDK.Feet
32
35
  const File: typeof SDK.File
36
+ const Foliage: typeof SDK.Foliage
33
37
  const FollowPath: typeof SDK.FollowPath
34
38
  const FormData: typeof SDK.FormData
35
- const Gearbox: typeof SDK.Gearbox
36
39
  const Geolocation: typeof SDK.Geolocation
37
40
  const Geometry: typeof SDK.Geometry
38
41
  const Gizmos: typeof SDK.Gizmos
@@ -108,6 +111,8 @@ declare global {
108
111
  const Tilemap: typeof SDK.Tilemap
109
112
  const Tileset: typeof SDK.Tileset
110
113
  const Time: typeof SDK.Time
114
+ const Timeline: typeof SDK.Timeline
115
+ const Tire: typeof SDK.Tire
111
116
  const TouchStartEvent: typeof SDK.TouchStartEvent
112
117
  const Trail: typeof SDK.Trail
113
118
  const Trigger: typeof SDK.Trigger
@@ -160,7 +165,6 @@ declare global {
160
165
  const __uiMap: typeof SDK.__uiMap
161
166
  const __withGizmoScope: typeof SDK.__withGizmoScope
162
167
  const animate: typeof SDK.animate
163
- const animateMat4: typeof SDK.animateMat4
164
168
  const app: typeof SDK.app
165
169
  const audio: typeof SDK.audio
166
170
  const cells: typeof SDK.cells
@@ -193,20 +197,18 @@ declare global {
193
197
  const openFilePicker: typeof SDK.openFilePicker
194
198
  const openURL: typeof SDK.openURL
195
199
  const packTile: typeof SDK.packTile
196
- const pauseAnimation: typeof SDK.pauseAnimation
197
200
  const rawCell: typeof SDK.rawCell
198
201
  const rawIndex: typeof SDK.rawIndex
199
202
  const ref: typeof SDK.ref
200
203
  const registerEditorTool: typeof SDK.registerEditorTool
201
204
  const registerEditorWindow: typeof SDK.registerEditorWindow
202
205
  const registerFont: typeof SDK.registerFont
203
- const resumeAnimation: typeof SDK.resumeAnimation
206
+ const resolveTire: typeof SDK.resolveTire
204
207
  const rot180: typeof SDK.rot180
205
208
  const rot270: typeof SDK.rot270
206
209
  const rot90: typeof SDK.rot90
207
210
  const share: typeof SDK.share
208
211
  const signal: typeof SDK.signal
209
- const stopAnimation: typeof SDK.stopAnimation
210
212
  const theme: typeof SDK.theme
211
213
  const tileFlip: typeof SDK.tileFlip
212
214
  const tileIndex: typeof SDK.tileIndex
@@ -217,6 +219,10 @@ declare global {
217
219
  type ARScene<T extends ARMode = "default"> = SDK.ARScene<T>
218
220
  type ActiveClip = SDK.ActiveClip
219
221
  type AeroConfig = SDK.AeroConfig
222
+ type AnimateOptions<T extends AnimateValue> = SDK.AnimateOptions<T>
223
+ type AnimateOut<T> = SDK.AnimateOut<T>
224
+ type AnimateValue = SDK.AnimateValue
225
+ type Animation = SDK.Animation
220
226
  type AnimationClip = SDK.AnimationClip
221
227
  type Animator = SDK.Animator
222
228
  type AppState = SDK.AppState
@@ -267,9 +273,17 @@ declare global {
267
273
  type DecalSet = SDK.DecalSet
268
274
  type DecalSetOptions = SDK.DecalSetOptions
269
275
  type DecalSpawnOptions = SDK.DecalSpawnOptions
276
+ type DecalTrail = SDK.DecalTrail
277
+ type DecalTrailOptions = SDK.DecalTrailOptions
270
278
  type DifferentialMode = SDK.DifferentialMode
271
279
  type Displacement = SDK.Displacement
272
280
  type DriveLayout = SDK.DriveLayout
281
+ type DynamicBone = SDK.DynamicBone
282
+ type DynamicBoneCollider = SDK.DynamicBoneCollider
283
+ type DynamicBoneColliders = SDK.DynamicBoneColliders
284
+ type DynamicBoneCurve = SDK.DynamicBoneCurve
285
+ type DynamicBoneFloor = SDK.DynamicBoneFloor
286
+ type EasingInput = SDK.EasingInput
273
287
  type EchoParams = SDK.EchoParams
274
288
  type EdgeSlot = SDK.EdgeSlot
275
289
  type EditorApi = SDK.EditorApi
@@ -286,13 +300,14 @@ declare global {
286
300
  type FileData = SDK.FileData
287
301
  type FillBlock = SDK.FillBlock
288
302
  type FitOptions = SDK.FitOptions
303
+ type FoliageOptions = SDK.FoliageOptions
304
+ type FoliageWind = SDK.FoliageWind
289
305
  type FollowPath = SDK.FollowPath
290
306
  type FootState = SDK.FootState
291
307
  type FormData = SDK.FormData
292
308
  type Gait = SDK.Gait
293
309
  type GamepadAxisName = SDK.GamepadAxisName
294
310
  type GamepadState = SDK.GamepadState
295
- type Gearbox = SDK.Gearbox
296
311
  type GeoOptions = SDK.GeoOptions
297
312
  type GeoPosition = SDK.GeoPosition
298
313
  type GeoWatch = SDK.GeoWatch
@@ -407,6 +422,7 @@ declare global {
407
422
  type PlayOptions = SDK.PlayOptions
408
423
  type PlaySoundOptions = SDK.PlaySoundOptions
409
424
  type Playback = SDK.Playback
425
+ type Point = SDK.Point
410
426
  type PresentOptions = SDK.PresentOptions
411
427
  type Presentable = SDK.Presentable
412
428
  type PushEvent = SDK.PushEvent
@@ -416,7 +432,11 @@ declare global {
416
432
  type QRScanner = SDK.QRScanner
417
433
  type Quat = SDK.Quat
418
434
  type Ragdoll = SDK.Ragdoll
435
+ type RagdollActivateOptions = SDK.RagdollActivateOptions
436
+ type RagdollDeactivateOptions = SDK.RagdollDeactivateOptions
437
+ type RagdollFacing = SDK.RagdollFacing
419
438
  type RagdollHinge = SDK.RagdollHinge
439
+ type RagdollHitOptions = SDK.RagdollHitOptions
420
440
  type RagdollPart = SDK.RagdollPart
421
441
  type Ray = SDK.Ray
422
442
  type Replicated = SDK.Replicated
@@ -460,6 +480,8 @@ declare global {
460
480
  type StateMachineEvents = SDK.StateMachineEvents
461
481
  type StatesDef<C> = SDK.StatesDef<C>
462
482
  type SteeringConfig = SDK.SteeringConfig
483
+ type SteeringDriver = SDK.SteeringDriver
484
+ type SteeringFeedback = SDK.SteeringFeedback
463
485
  type StepHandler = SDK.StepHandler
464
486
  type StepWarpOptions = SDK.StepWarpOptions
465
487
  type StopOptions = SDK.StopOptions
@@ -485,15 +507,21 @@ declare global {
485
507
  type TilemapSourceDef = SDK.TilemapSourceDef
486
508
  type Tileset = SDK.Tileset
487
509
  type TilesetDef = SDK.TilesetDef
488
- type TireCurve = SDK.TireCurve
510
+ type Timeline = SDK.Timeline
511
+ type TimelineAddOptions = SDK.TimelineAddOptions
512
+ type TimelineOptions = SDK.TimelineOptions
513
+ type TimelinePosition = SDK.TimelinePosition
514
+ type Tire = SDK.Tire
489
515
  type TouchStartEvent<T = any> = SDK.TouchStartEvent<T>
490
516
  type Trail = SDK.Trail
491
517
  type Transition = SDK.Transition
492
518
  type TransitionName = SDK.TransitionName
493
519
  type TransitionSpec = SDK.TransitionSpec
494
520
  type TransitionTransform = SDK.TransitionTransform
521
+ type TrianglePick = SDK.TrianglePick
495
522
  type Trigger = SDK.Trigger
496
523
  type Trigger2D = SDK.Trigger2D
524
+ type TweenMeta = SDK.TweenMeta
497
525
  type UIBottomSheet = SDK.UIBottomSheet
498
526
  type UIBottomSheetStyle = SDK.UIBottomSheetStyle
499
527
  type UIBox = SDK.UIBox
@@ -546,8 +574,6 @@ declare global {
546
574
  type WebSocket = SDK.WebSocket
547
575
  type Wheel = SDK.Wheel
548
576
  type WheelSuspension = SDK.WheelSuspension
549
- type WheelTire = SDK.WheelTire
550
- type WheelVisual = SDK.WheelVisual
551
577
  type With<N, A extends Aspect<any, any, any>> = SDK.With<N, A>
552
578
  type __GizmoBuffer = SDK.__GizmoBuffer
553
579
  // ---- server globals (available in *.server.ts; using them in client code is a build error) ----
@@ -0,0 +1,69 @@
1
+ import { CLOCK_GAME, CLOCK_UI, type TweenSpec } from "./spec";
2
+ /** Playback control shared by element tweens and timelines. Times are **milliseconds**. */
3
+ export interface Animation {
4
+ /** One iteration, ms. */
5
+ readonly duration: number;
6
+ /** Position inside the current iteration, ms. Writable = seek. */
7
+ time: number;
8
+ /** 0..1 of the whole animation (iterations included). Writable = seek. */
9
+ progress: number;
10
+ /** Playback rate; negative runs backwards, 0 freezes. */
11
+ rate: number;
12
+ readonly playing: boolean;
13
+ /** Resolves `true` when the animation reaches its end, `false` when cancelled, replaced or replayed. Never rejects. */
14
+ readonly finished: Promise<boolean>;
15
+ /** Start from t = 0 (a running animation restarts). */
16
+ play(): this;
17
+ pause(): this;
18
+ resume(): this;
19
+ /** Jump to `ms`; playback state is unchanged. */
20
+ seek(ms: number): this;
21
+ /** Jump to the end: values land, commits apply, `finished` resolves `true`. */
22
+ finish(): this;
23
+ /** Stop where it is — no commit, `finished` resolves `false`. */
24
+ cancel(): this;
25
+ onFinish(fn: (done: boolean) => void): this;
26
+ }
27
+ /** The concrete handle — what the SDK instantiates behind `animateTo` / `animateFrom` / `Timeline`.
28
+ * User code sees the {@link Animation} interface; the class itself must stay in the public
29
+ * declarations because `TimelineImpl` extends it — marking it internal (even mentioning the tag in
30
+ * this comment: the strip is a substring match) drops the timeline's playback members. */
31
+ export declare class TweenAnimation implements Animation {
32
+ private _id;
33
+ private _started;
34
+ private _endTime;
35
+ private _playing;
36
+ private _rate;
37
+ private _finished;
38
+ private _resolve;
39
+ private _settled;
40
+ private _listeners;
41
+ private _fb?;
42
+ constructor(spec: TweenSpec);
43
+ private _newPromise;
44
+ private _settle;
45
+ get duration(): number;
46
+ get playing(): boolean;
47
+ get finished(): Promise<boolean>;
48
+ get rate(): number;
49
+ set rate(r: number);
50
+ get time(): number;
51
+ set time(ms: number);
52
+ get progress(): number;
53
+ set progress(p: number);
54
+ private _totalMs;
55
+ private _elapsedMs;
56
+ private _seekTotal;
57
+ /** Create the host animation (paused at t = 0) if it doesn't exist. */
58
+ private _ensure;
59
+ private _destroy;
60
+ play(): this;
61
+ pause(): this;
62
+ resume(): this;
63
+ seek(ms: number): this;
64
+ finish(): this;
65
+ cancel(): this;
66
+ onFinish(fn: (done: boolean) => void): this;
67
+ private _ensureFallback;
68
+ }
69
+ export { CLOCK_UI, CLOCK_GAME };
@@ -0,0 +1,55 @@
1
+ import { TweenAnimation } from "./Animation";
2
+ import { type AnimateOptions, type AnimateValue } from "./animateValue";
3
+ import { type TweenMeta, type TweenTarget } from "./spec";
4
+ export type TimelineOptions = {
5
+ /** `'ui'` (default) = wall time; `'game'` follows `Time.scale` and pauses with the game. */
6
+ clock?: "ui" | "game";
7
+ /** Repeat the whole timeline: `true` = forever, a number = cycles. */
8
+ loop?: boolean | number;
9
+ loopMode?: "restart" | "ping-pong";
10
+ /** Wait before the first play, ms. */
11
+ delay?: number;
12
+ };
13
+ /** Where a track goes: ms, a label, or `[label, offsetMs]`. Default = the current end (sequencing). */
14
+ export type TimelinePosition = number | string | [string, number];
15
+ export type TimelineAddOptions = {
16
+ at?: TimelinePosition;
17
+ /** With several targets: each starts this many ms after the previous one. */
18
+ stagger?: number;
19
+ };
20
+ /** A choreography: tracks on many targets at absolute times, JS calls, labels and holds, driven by
21
+ * one clock. Build it once, `play()` on every entrance — `play()` restarts from t = 0 and the pose
22
+ * at any time is fully defined by the tracks (the first keyframe of a track holds before it
23
+ * starts, the last one after it ends). */
24
+ export declare class TimelineImpl extends TweenAnimation {
25
+ private _labels;
26
+ private _end;
27
+ constructor(options?: TimelineOptions);
28
+ private _at;
29
+ private _grow;
30
+ /** Animate `props` on one target or several (staggered), like `animateTo` — arrays are keyframes,
31
+ * `duration` / `easing` / `times` / `commit` apply. The bag's `delay` shifts the track after `at`. */
32
+ add(target: TweenTarget | TweenTarget[], props: Record<string, unknown> & TweenMeta, options?: TimelineAddOptions): this;
33
+ /** Like `add` with the `animateFrom` shape: the target's own state is the implicit last keyframe. */
34
+ addFrom(target: TweenTarget | TweenTarget[], props: Record<string, unknown> & TweenMeta, options?: TimelineAddOptions): this;
35
+ /** A free-value track (see the `animate()` global): the host evaluates it and calls `onUpdate`
36
+ * every frame with the value. */
37
+ animate<T extends AnimateValue>(options: AnimateOptions<T>, at?: TimelinePosition): this;
38
+ /** Call `fn` when playback crosses `at` (forward or backward), in time order, always before
39
+ * finish, never from a previous run. */
40
+ call(at: TimelinePosition, fn: () => void): this;
41
+ /** Name a time — for `at`, `seek` and callers (`tl.labels.landed`). Default = the current end. */
42
+ label(name: string, at?: TimelinePosition): this;
43
+ /** Named times, ms. */
44
+ get labels(): Record<string, number>;
45
+ /** Extend the timeline with stillness after its current end. */
46
+ hold(ms: number): this;
47
+ /** The current end, ms (tracks, calls and holds). */
48
+ get end(): number;
49
+ /** `seek` also accepts a label. */
50
+ seek(at: number | string): this;
51
+ }
52
+ /** The timeline handle type (see {@link TimelineImpl} for the members). */
53
+ export type Timeline = TimelineImpl;
54
+ /** Create a timeline — `Timeline()` / `Timeline({ clock: 'game', loop: true })`. */
55
+ export declare function Timeline(options?: TimelineOptions): Timeline;
@@ -0,0 +1,27 @@
1
+ import { type Animation } from "./Animation";
2
+ import type { Vec2Like, Vec3Like } from "../../math/vec";
3
+ import type { QuatLike } from "../../math/quat";
4
+ import type { Mat4Like } from "../../math/mat4";
5
+ import type { ColorInput } from "../../core/color";
6
+ import { type TweenMeta } from "./spec";
7
+ /** What `animate()` tweens: a number, a color (string / packed / rgb(a) array — delivered as rgba
8
+ * 0..1), a 2 / 3-vector, a quaternion (slerp), or a 4x4 matrix (position / rotation / scale). */
9
+ export type AnimateValue = number | string | Vec2Like | Vec3Like | QuatLike | Mat4Like | ColorInput;
10
+ /** `onUpdate` receives a number for a number; every other kind arrives as the SAME `Float32Array`
11
+ * every frame (overwritten in place — copy it if you keep it). A matrix is the 16 floats. */
12
+ export type AnimateOut<T> = T extends number ? number : Float32Array;
13
+ export type AnimateOptions<T extends AnimateValue> = Omit<TweenMeta, "commit" | "layer"> & {
14
+ /** Start value (required unless `values` is given). */
15
+ from?: T;
16
+ /** End value. */
17
+ to?: T;
18
+ /** Keyframes instead of from/to (offsets via `times`). */
19
+ values?: T[];
20
+ onUpdate(value: AnimateOut<T>): void;
21
+ /** After the last frame of a run that reached its end (not on cancel). */
22
+ onComplete?(): void;
23
+ };
24
+ /** Tween a free value and apply it yourself in `onUpdate` — the primitive for anything without a
25
+ * native channel (material params, volumes, numbers a Canvas draws). Same easing / keyframes /
26
+ * `loop` / `clock` as `animateTo`; returns the {@link Animation} handle. Default clock: `'ui'`. */
27
+ export declare const animate: <T extends AnimateValue>(options: AnimateOptions<T>) => Animation;
@@ -0,0 +1,29 @@
1
+ import type { Easing } from "../easings";
2
+ export declare const EASE_LINEAR = 0;
3
+ export declare const EASE_NAMED = 1;
4
+ export declare const EASE_BEZIER = 2;
5
+ export declare const EASE_STEPS = 3;
6
+ export declare const EASE_TABLE = 4;
7
+ /** Samples per table (t = i / 64). Interpolation error for the smooth built-ins is < 1e-3. */
8
+ export declare const EASE_TABLE_SIZE = 65;
9
+ export type EasingSpec = {
10
+ kind: number;
11
+ /** kind-specific parameters: NAMED [id], BEZIER [x1, y1, x2, y2], STEPS [n, jumpAtStart], TABLE [tableIndex] */
12
+ p: [number, number, number, number];
13
+ /** TABLE only — the samples, appended to the blob's table section by the builder. */
14
+ table?: Float32Array;
15
+ };
16
+ /** A curve in the options bag: a name, `"cubic-bezier(x1,y1,x2,y2)"`, `"steps(n)"`, a bezier tuple,
17
+ * or any `Easing` function. */
18
+ export type EasingInput = string | readonly [number, number, number, number] | Easing;
19
+ /** id → (name, formula). The formulas are the standard easings.net set; creator-tween's
20
+ * `ctweenEaseNamed` implements the same list by id. */
21
+ export declare const NAMED_EASINGS: ReadonlyArray<readonly [string, Easing]>;
22
+ /** Sample an `Easing` function into a table. Endpoints are forced exact so a curve that is
23
+ * numerically 0.9999 at 1 still lands on the keyframe. */
24
+ export declare const sampleEasing: (fn: Easing) => Float32Array;
25
+ /** Normalize one easing input. Unknown strings fall back to linear with a console warning (a typo
26
+ * should be visible, not a silent snap). */
27
+ export declare const parseEasing: (input: EasingInput | undefined) => EasingSpec;
28
+ /** Evaluate an `EasingSpec` at `u` ∈ [0, 1] — the JS twin of `ctweenEase`. */
29
+ export declare const evalEasing: (e: EasingSpec, u: number) => number;
@@ -0,0 +1,178 @@
1
+ import { type EasingInput, type EasingSpec } from "./easing";
2
+ export declare const BLOB_VERSION = 1;
3
+ export declare const DOM_UI = 0;
4
+ export declare const DOM_GL_NODE = 1;
5
+ export declare const DOM_GL_LIGHT = 2;
6
+ export declare const DOM_GL_CAMERA = 3;
7
+ export declare const DOM_NODE2D = 4;
8
+ export declare const DOM_SPRITE2D = 5;
9
+ export declare const DOM_VALUE = 6;
10
+ export declare const KIND_FLOAT = 0;
11
+ export declare const KIND_FLOAT_UNIT = 1;
12
+ export declare const KIND_COLOR = 2;
13
+ export declare const KIND_TRANSFORM = 3;
14
+ export declare const KIND_TRANSFORM_MATRIX = 4;
15
+ export declare const KIND_VEC3 = 5;
16
+ export declare const KIND_QUAT = 6;
17
+ export declare const KIND_EULER = 7;
18
+ export declare const KIND_DISCRETE = 8;
19
+ export declare const KIND_STRING = 9;
20
+ export declare const KIND_VEC2 = 10;
21
+ export declare const KIND_MAT4 = 11;
22
+ export declare const CLOCK_UI = 0;
23
+ export declare const CLOCK_GAME = 1;
24
+ export declare const lanesOf: (kind: number) => number;
25
+ /** One normalized value: numeric lanes, or a string (string-lane kinds). */
26
+ export type TweenValue = {
27
+ lanes: number[];
28
+ } | {
29
+ str: string;
30
+ };
31
+ /** A target's answer to "can you animate `prop`?": the writer domain, the id resolver, the value
32
+ * normalizer, and the commit hook (UI writes the last key into its stored style). */
33
+ export type TweenChannel = {
34
+ domain: number;
35
+ /** Host handle at play time — a number (entity, web node id) or the host's opaque node object
36
+ * (creator-pkg hands `_id` out as one); falsy = not addressable right now (unmounted), the
37
+ * track is skipped. Handed to the host in the blob's `targets` list, never in the float data. */
38
+ id: () => unknown;
39
+ /** Normalize one keyframe value; `null` = not animatable (a warning, the value is committed only). */
40
+ value: (v: unknown) => ({
41
+ kind: number;
42
+ sig?: string;
43
+ } & TweenValue) | null;
44
+ commit?: (v: unknown) => void;
45
+ };
46
+ /** Implemented by every animatable class (Element, Node, Node2D, Sprite, Light, Camera). */
47
+ export interface TweenTarget {
48
+ }
49
+ export type Keyframe = {
50
+ /** 0..1 within the track. */
51
+ t: number;
52
+ easing: EasingSpec;
53
+ /** `undefined` = capture at play. */
54
+ value?: TweenValue;
55
+ /** The bag value as written — what the old-host path forwards verbatim. */
56
+ raw?: unknown;
57
+ };
58
+ export type Track = {
59
+ target: TweenTarget;
60
+ prop: string;
61
+ channel: TweenChannel;
62
+ kind: number;
63
+ lanes: number;
64
+ sig?: string;
65
+ atMs: number;
66
+ durMs: number;
67
+ commit: boolean;
68
+ keys: Keyframe[];
69
+ };
70
+ export type TweenSpec = {
71
+ clock: number;
72
+ /** One iteration, ms — the last track's end (holds included). */
73
+ durationMs: number;
74
+ delayMs: number;
75
+ /** -1 = forever. */
76
+ iterations: number;
77
+ pingPong: boolean;
78
+ rate: number;
79
+ tracks: Track[];
80
+ /** Time-callbacks, ms; index = the event index the host reports. */
81
+ calls: number[];
82
+ };
83
+ /** Meta keys of an `animateTo` / `Timeline.add` bag — everything that is not a prop target. */
84
+ export declare const TWEEN_META: Set<string>;
85
+ export type TweenMeta = {
86
+ /** Tween length in **milliseconds** (default 225). */
87
+ duration?: number;
88
+ /** Wait before starting, **milliseconds**. The first keyframe holds through the wait. A loop delays once. */
89
+ delay?: number;
90
+ /** A curve for every prop, or a per-prop map (`{ width: 'outExpo', opacity: 'linear' }`). Names
91
+ * (`outCubic`, `inOutSine`, `outBack`, …), `cubic-bezier(…)` / a `[x1, y1, x2, y2]` tuple,
92
+ * `steps(n)`, or any `Easing` function. Default linear. */
93
+ easing?: EasingInput | Record<string, EasingInput>;
94
+ /** Keyframe offsets 0..1 for array-valued props (default: evenly spaced). */
95
+ times?: number[];
96
+ /** `true` = forever, a number = that many cycles. A loop never commits. */
97
+ loop?: boolean | number;
98
+ /** `"ping-pong"` (default) there and back each cycle; `"restart"` snaps back and replays. */
99
+ loopMode?: "restart" | "ping-pong";
100
+ /** `false` = animate without writing the last keyframe into the element's style. */
101
+ commit?: boolean;
102
+ /** `'ui'` = wall time (menus animate while the game is paused); `'game'` follows `Time.scale`.
103
+ * Default: `'ui'` on UI elements, `'game'` on 3D / 2D nodes. */
104
+ clock?: "ui" | "game";
105
+ /** Legacy escape hatch (old hosts only). */
106
+ layer?: number;
107
+ };
108
+ export declare const DEFAULT_DURATION_MS = 225;
109
+ export declare const warnOnce: (key: string, msg: string) => void;
110
+ /** Resolve the per-prop easing from the bag. */
111
+ export declare const easingFor: (easing: TweenMeta["easing"], prop: string) => EasingSpec;
112
+ /** Iteration count from `loop`: 1 = one-shot, -1 = forever, n = cycles. */
113
+ export declare const iterationsOf: (loop: TweenMeta["loop"]) => number;
114
+ /** A UI style value: number → FLOAT; "12px" / "50%" → FLOAT_UNIT; other strings → STRING (the host
115
+ * decides color vs discrete); booleans → DISCRETE. */
116
+ export declare const uiValue: (v: unknown) => ({
117
+ kind: number;
118
+ sig?: string;
119
+ } & TweenValue) | null;
120
+ /** Parse `"translate(10px, 20px) rotate(45deg) scale(1.2)"` into a signature + lanes, or null when a
121
+ * function is unknown (the caller falls back to matrix decomposition on the host). `scale(2)` and
122
+ * `translate(5px)` complete their second argument like CSS. */
123
+ export declare const parseTransformList: (s: string) => {
124
+ sig: string;
125
+ lanes: number[];
126
+ } | null;
127
+ export declare const transformLanes: (sig: string) => number;
128
+ export declare const vec3Value: (v: unknown) => {
129
+ kind: number;
130
+ lanes: number[];
131
+ } | null;
132
+ export declare const quatValue: (v: unknown) => {
133
+ kind: number;
134
+ lanes: number[];
135
+ } | null;
136
+ export declare const eulerValue: (v: unknown) => {
137
+ kind: number;
138
+ lanes: number[];
139
+ } | null;
140
+ export declare const vec2Value: (v: unknown) => {
141
+ kind: number;
142
+ lanes: number[];
143
+ } | null;
144
+ export declare const floatValue: (v: unknown) => {
145
+ kind: number;
146
+ lanes: number[];
147
+ } | null;
148
+ export declare const colorValue: (v: unknown, toRgba: (c: any) => [number, number, number, number]) => {
149
+ kind: number;
150
+ lanes: [number, number, number, number];
151
+ } | null;
152
+ /** A free value for animate(): number → FLOAT, a color string → COLOR, arrays / vectors by length
153
+ * (2 → VEC2, 3 → VEC3, 4 → QUAT, 16 → MAT4 decomposed into position · quaternion · scale). */
154
+ export declare const valueValue: (v: unknown) => ({
155
+ kind: number;
156
+ } & TweenValue) | null;
157
+ /** Is this bag value a KEYFRAME ARRAY for a vector prop, as opposed to one vector? A vector value
158
+ * is an array of NUMBERS (`[0, 2, 0]`); anything else in the array is a list of keyframes —
159
+ * `[[0,0,0], [0,2,0]]`, `[new Vec3(), …]`, and the UI's `color: ['#fff', '#e29a22']`. */
160
+ export declare const isVectorKeyframes: (v: unknown) => boolean;
161
+ /** Build one track's keyframes from a bag value: a single value = one explicit key (the other end
162
+ * captured), an array = explicit keys spaced by `times` or evenly. `fromCurrent` says which end is
163
+ * implicit (animateTo: the first; animateFrom: the last). Returns null when a value can't be
164
+ * animated (already warned). */
165
+ export declare const makeTrack: (target: TweenTarget, prop: string, raw: unknown, meta: TweenMeta, atMs: number, fromCurrent: boolean, vectorProp: boolean) => Track | null;
166
+ /** Every (prop → value) entry of a bag, meta keys stripped. */
167
+ export declare const bagProps: (bag: Record<string, unknown>) => [string, unknown][];
168
+ /** The value of a numeric track at local time `ms` (the C evaluator's rule: first key holds before,
169
+ * last after; eased segment between). `out` receives `track.lanes` numbers. */
170
+ export declare const evaluateTrack: (track: Track, ms: number, out: number[]) => void;
171
+ export type TweenBlob = {
172
+ data: Float32Array;
173
+ strings: string[];
174
+ targets: unknown[];
175
+ };
176
+ /** Flatten a spec for `_creatorUI.tweenCreate`. Tracks whose target has no host id right now are
177
+ * dropped (the animation still runs its clock, calls and finish). */
178
+ export declare const buildBlob: (spec: TweenSpec) => TweenBlob;
@@ -56,6 +56,8 @@ export declare class Canvas {
56
56
  private _surfaceId;
57
57
  private _tex2d?;
58
58
  private _uiBound;
59
+ private _lastBakeLen;
60
+ private _warnedGrowth;
59
61
  constructor(width: number, height: number, opts?: {
60
62
  pixelRatio?: number;
61
63
  });
@@ -3,6 +3,17 @@ import type { CompAxis, CompWriter } from "../core/compWrite";
3
3
  import { Registry } from "../core/registry";
4
4
  import { Vec2, type Vec2Like } from "../math/vec";
5
5
  import type { ClickEvent, TouchStartEvent } from "../runtime/touch";
6
+ import type { Animation } from "../animate/tween/Animation";
7
+ import { type TweenMeta } from "../animate/tween/spec";
8
+ /** Animatable transform props of a 2D node; an array of values is a keyframe list. */
9
+ export type Node2DTweenProps = {
10
+ x?: number | number[];
11
+ y?: number | number[];
12
+ position?: Vec2Like | Vec2Like[];
13
+ /** Degrees. */
14
+ rotation?: number | number[];
15
+ scale?: number | Vec2Like | (number | Vec2Like)[];
16
+ };
6
17
  export { Vec2, type Vec2Like };
7
18
  export type Node2DEvents = {
8
19
  /** A looping animation clip wrapped around (fires each loop). */
@@ -59,6 +70,11 @@ export declare class Node2D extends AspectHost<Node2DEvents> implements CompWrit
59
70
  set rotation(deg: number);
60
71
  get scale(): Vec2;
61
72
  set scale(v: Vec2Like | number);
73
+ /** Tween the transform — `node.animateTo({ x: 120, rotation: 90, duration: 400, easing: 'outBack' })`;
74
+ * arrays are keyframes. Game clock unless `clock: 'ui'`. Returns the {@link Animation} handle. */
75
+ animateTo(props: Node2DTweenProps & TweenMeta): Animation;
76
+ /** Tween FROM the given values to the node's current transform. */
77
+ animateFrom(props: Node2DTweenProps & TweenMeta): Animation;
62
78
  /** Draw layer (int). Higher layers render on top. */
63
79
  get layer(): number;
64
80
  set layer(v: number);
@@ -1,8 +1,15 @@
1
1
  import { type ColorInput } from "../core/color";
2
2
  import { Vec2, type Vec2Like } from "../math/vec";
3
3
  import { Canvas } from "../canvas/Canvas";
4
- import { Node2D } from "./Node2D";
4
+ import { Node2D, type Node2DTweenProps } from "./Node2D";
5
5
  import type { Texture2D } from "./Texture2D";
6
+ import { type TweenMeta } from "../animate/tween/spec";
7
+ import type { Animation } from "../animate/tween/Animation";
8
+ /** Animatable sprite props on top of the 2D transform. */
9
+ export type SpriteTweenProps = Node2DTweenProps & {
10
+ opacity?: number | number[];
11
+ color?: ColorInput | ColorInput[];
12
+ };
6
13
  /** Anything that can back a sprite: a texture, or a Canvas (baked to a texture on assign). */
7
14
  export type TextureSource = Texture2D | Canvas;
8
15
  export type SpriteOptions = {
@@ -40,6 +47,9 @@ export declare class Sprite extends Node2D {
40
47
  set frame(uv: [number, number, number, number]);
41
48
  /** Set the sub-rect in texture pixels. */
42
49
  setFramePx(px: number, py: number, pw: number, ph: number): this;
50
+ /** Tween `opacity` / `color` and the transform — see {@link Node2D.animateTo}. */
51
+ animateTo(props: SpriteTweenProps & TweenMeta): Animation;
52
+ animateFrom(props: SpriteTweenProps & TweenMeta): Animation;
43
53
  get color(): ColorInput;
44
54
  set color(c: ColorInput);
45
55
  get opacity(): number;
@@ -1,6 +1,14 @@
1
1
  import { Vec3 } from "../math/vec";
2
- import { Node } from "./Node";
2
+ import { Node, type NodeTweenProps } from "./Node";
3
3
  import { Ray } from "./Ray";
4
+ import { type TweenMeta } from "../animate/tween/spec";
5
+ import type { Animation } from "../animate/tween/Animation";
6
+ /** Animatable camera props on top of the node transform. */
7
+ export type CameraTweenProps = NodeTweenProps & {
8
+ fov?: number | number[];
9
+ near?: number | number[];
10
+ far?: number | number[];
11
+ };
4
12
  /** Projection every host starts a scene with (creator-gl scene.cpp / the lite core agree on these). */
5
13
  export declare const CAMERA_DEFAULTS: {
6
14
  fov: number;
@@ -9,6 +17,9 @@ export declare const CAMERA_DEFAULTS: {
9
17
  };
10
18
  export declare class Camera extends Node {
11
19
  private _sceneId;
20
+ /** Tween `fov` / `near` / `far` (a zoom, a dolly) and the transform — see {@link Node.animateTo}. */
21
+ animateTo(props: CameraTweenProps & TweenMeta): Animation;
22
+ animateFrom(props: CameraTweenProps & TweenMeta): Animation;
12
23
  /** Live projection matrix (updated by the host when the viewport/fov changes). */
13
24
  readonly projectionMatrix: Float32Array<ArrayBuffer>;
14
25
  private _fov;
@@ -25,6 +36,9 @@ export declare class Camera extends Node {
25
36
  * adaptation when the sun swings into view (drop it, and the sun stays at the display's peak
26
37
  * while everything else darkens). Scene light follows it; particle `emissive` is post-exposure
27
38
  * and does not, so a fireball keeps its on-screen brightness. Cheap to animate every frame. */
39
+ /** The camera's EV100 with the compensation in: log2(aperture² / shutterSpeed x 100 / iso) - compensation. Sunny 16 is
40
+ * ~15; a lit surface of luminance L lands on screen at L / (1.2 x 2^ev100). */
41
+ get ev100(): number;
28
42
  get exposureCompensation(): number;
29
43
  set exposureCompensation(stops: number);
30
44
  /** The physical camera: `aperture` in f-stops, `shutterSpeed` in seconds, `iso`, plus the same