@sarmal/core 0.10.0 → 0.12.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/auto-init.cjs +78 -15
- package/dist/auto-init.cjs.map +1 -1
- package/dist/auto-init.js +78 -15
- package/dist/auto-init.js.map +1 -1
- package/dist/curves/artemis2.d.cts +1 -1
- package/dist/curves/artemis2.d.ts +1 -1
- package/dist/curves/astroid.d.cts +1 -1
- package/dist/curves/astroid.d.ts +1 -1
- package/dist/curves/deltoid.d.cts +1 -1
- package/dist/curves/deltoid.d.ts +1 -1
- package/dist/curves/epicycloid3.d.cts +1 -1
- package/dist/curves/epicycloid3.d.ts +1 -1
- package/dist/curves/epitrochoid7.d.cts +1 -1
- package/dist/curves/epitrochoid7.d.ts +1 -1
- package/dist/curves/index.cjs.map +1 -1
- package/dist/curves/index.d.cts +15 -3
- package/dist/curves/index.d.ts +15 -3
- package/dist/curves/index.js.map +1 -1
- package/dist/curves/lame.d.cts +1 -1
- package/dist/curves/lame.d.ts +1 -1
- package/dist/curves/lissajous32.d.cts +1 -1
- package/dist/curves/lissajous32.d.ts +1 -1
- package/dist/curves/lissajous43.d.cts +1 -1
- package/dist/curves/lissajous43.d.ts +1 -1
- package/dist/curves/rose3.d.cts +1 -1
- package/dist/curves/rose3.d.ts +1 -1
- package/dist/curves/rose5.d.cts +1 -1
- package/dist/curves/rose5.d.ts +1 -1
- package/dist/index.cjs +85 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +85 -25
- package/dist/index.js.map +1 -1
- package/dist/{types-DcyISvnH.d.cts → types-BzgdhxE0.d.cts} +67 -37
- package/dist/{types-DcyISvnH.d.ts → types-BzgdhxE0.d.ts} +67 -37
- package/package.json +1 -1
|
@@ -65,6 +65,66 @@ type SeekOptions = {
|
|
|
65
65
|
step?: number;
|
|
66
66
|
};
|
|
67
67
|
type MorpStrategy = "raw" | "normalized";
|
|
68
|
+
/**
|
|
69
|
+
* The shared animation state types
|
|
70
|
+
* Both `Engine` and `SarmalInstance` extend this
|
|
71
|
+
* In the renderer, these are passthroughs
|
|
72
|
+
*/
|
|
73
|
+
interface AnimationControls {
|
|
74
|
+
/**
|
|
75
|
+
* Resets the simulation state, clearing the trail and reverting internal time `t` to 0
|
|
76
|
+
* The next call to `tick` will start fresh from the beginning of the curve
|
|
77
|
+
*/
|
|
78
|
+
reset(): void;
|
|
79
|
+
/**
|
|
80
|
+
* Instantly moves the head to position `t`.
|
|
81
|
+
*
|
|
82
|
+
* ! Does NOT update `actualTime`.
|
|
83
|
+
*
|
|
84
|
+
* Trail is left untouched by default. You can pass `clearTrail: true` to wipe it.
|
|
85
|
+
* Use for morphing mid-flight or any time you don't need trail context.
|
|
86
|
+
* @param t The position to jump to (will be wrapped into [0, period))
|
|
87
|
+
*/
|
|
88
|
+
jump(t: number, options?: JumpOptions): void;
|
|
89
|
+
/**
|
|
90
|
+
* Moves to `t` AND reconstructs the trail as if the animation naturally arrived there from `t=0`
|
|
91
|
+
* Also updates `actualTime` to match. Trail is always rebuilt from scratch
|
|
92
|
+
* Use for initialisation or any jump where you want the trail to look meaningful
|
|
93
|
+
* @param t The position to seek to (will be wrapped into [0, period))
|
|
94
|
+
*/
|
|
95
|
+
seek(t: number, options?: SeekOptions): void;
|
|
96
|
+
/**
|
|
97
|
+
* Overrides the animation speed at runtime
|
|
98
|
+
* `0` freezes `t` but the loop keeps running
|
|
99
|
+
* Negative values reverse traversal.
|
|
100
|
+
*
|
|
101
|
+
* ! Does NOT affect a curve's inherent speed given in CurveDef
|
|
102
|
+
* @param speed 0 = freeze, negative = reverse, no upper bound
|
|
103
|
+
*/
|
|
104
|
+
setSpeed(speed: number): void;
|
|
105
|
+
/**
|
|
106
|
+
* Returns the *effective speed* the engine is currently using:
|
|
107
|
+
* `userSpeedOverride` if set, otherwise the curve's default speed.
|
|
108
|
+
* This is what `tick()` actually uses
|
|
109
|
+
*/
|
|
110
|
+
getSpeed(): number;
|
|
111
|
+
/**
|
|
112
|
+
* Drops the speed override and defers back to the curve's inherent default speed.
|
|
113
|
+
* ! Sets `userSpeedOverride` to `null`
|
|
114
|
+
*/
|
|
115
|
+
resetSpeed(): void;
|
|
116
|
+
/**
|
|
117
|
+
* Transitions to the target speed over `duration` milliseconds using linear interpolation.
|
|
118
|
+
* Resolves when the transition completes.
|
|
119
|
+
*
|
|
120
|
+
* Calling this while a transition is already in progress cancels the old transition
|
|
121
|
+
* (rejecting its Promise) and starts a new one from the current interpolated speed.
|
|
122
|
+
*
|
|
123
|
+
* @param speed Target speed
|
|
124
|
+
* @param duration Transition duration in milliseconds (must be > 0)
|
|
125
|
+
*/
|
|
126
|
+
setSpeedOver(speed: number, duration: number): Promise<void>;
|
|
127
|
+
}
|
|
68
128
|
type MorphOptions = {
|
|
69
129
|
/**
|
|
70
130
|
* Duration of the morph transition in milliseconds
|
|
@@ -79,7 +139,7 @@ type MorphOptions = {
|
|
|
79
139
|
*/
|
|
80
140
|
morphStrategy?: MorpStrategy;
|
|
81
141
|
};
|
|
82
|
-
interface Engine {
|
|
142
|
+
interface Engine extends AnimationControls {
|
|
83
143
|
/**
|
|
84
144
|
* Advances the Sarmal simulation by the given delta time (dt) in seconds.
|
|
85
145
|
* Internally, this increases the simulation time `t` by `speed * dt`,
|
|
@@ -95,11 +155,6 @@ interface Engine {
|
|
|
95
155
|
* ! Use this instead of `trail.length`
|
|
96
156
|
*/
|
|
97
157
|
readonly trailCount: number;
|
|
98
|
-
/**
|
|
99
|
-
* Resets the simulation state, by clearing the trail and reverting internal time `t` to 0.
|
|
100
|
-
* The next call to `tick` will start fresh from the beginning of the curve.
|
|
101
|
-
*/
|
|
102
|
-
reset(): void;
|
|
103
158
|
/**
|
|
104
159
|
* Returns the *skeleton* of the curve.
|
|
105
160
|
* In technicality, it just represents the complete traversal of the curve over one full period,
|
|
@@ -113,20 +168,6 @@ interface Engine {
|
|
|
113
168
|
*/
|
|
114
169
|
getSarmalSkeleton(): Array<Point>;
|
|
115
170
|
readonly isLiveSkeleton: boolean;
|
|
116
|
-
/**
|
|
117
|
-
* Instantly moves the head to position `t`. Does NOT update `actualTime`.
|
|
118
|
-
* Trail is left untouched by default — pass `clearTrail: true` to wipe it.
|
|
119
|
-
* Use for morphing mid-flight, raw scrubbing, or any time you don't need trail context.
|
|
120
|
-
* @param t The position to jump to (will be wrapped into [0, period))
|
|
121
|
-
*/
|
|
122
|
-
jump(t: number, options?: JumpOptions): void;
|
|
123
|
-
/**
|
|
124
|
-
* Moves to `t` AND reconstructs the trail as if the animation naturally arrived there from `t=0`.
|
|
125
|
-
* Also updates `actualTime` to match. Trail is always rebuilt from scratch.
|
|
126
|
-
* Use for initialisation or any jump where you want the trail to look meaningful.
|
|
127
|
-
* @param t The position to seek to (will be wrapped into [0, period))
|
|
128
|
-
*/
|
|
129
|
-
seek(t: number, options?: SeekOptions): void;
|
|
130
171
|
/**
|
|
131
172
|
* Begins a smooth transition from the current curve to `target`
|
|
132
173
|
* Saves the current curve as `curveA`, registers `target` as `curveB`, and resets `morphAlpha` to `0`
|
|
@@ -155,28 +196,17 @@ interface Engine {
|
|
|
155
196
|
* `null` when no morph is in progress
|
|
156
197
|
*/
|
|
157
198
|
readonly morphAlpha: number | null;
|
|
199
|
+
/**
|
|
200
|
+
* Cancels any in-progress speed transition initiated by `setSpeedOver()`.
|
|
201
|
+
* Called internally by the renderer's `stop()` method.
|
|
202
|
+
*/
|
|
203
|
+
cancelSpeedTransition(): void;
|
|
158
204
|
}
|
|
159
|
-
interface SarmalInstance {
|
|
205
|
+
interface SarmalInstance extends AnimationControls {
|
|
160
206
|
start(): void;
|
|
161
207
|
stop(): void;
|
|
162
|
-
/** Resets the engine and clears the trail */
|
|
163
|
-
reset(): void;
|
|
164
208
|
/** Stops the animation and cleans up resources */
|
|
165
209
|
destroy(): void;
|
|
166
|
-
/**
|
|
167
|
-
* Instantly moves the head to position `t`. Does NOT update `actualTime`.
|
|
168
|
-
* Trail is left untouched by default — pass `clearTrail: true` to wipe it.
|
|
169
|
-
* Use for morphing mid-flight, raw scrubbing, or any time you don't need trail context.
|
|
170
|
-
* @param t The position to jump to (will be wrapped into [0, period))
|
|
171
|
-
*/
|
|
172
|
-
jump(t: number, options?: JumpOptions): void;
|
|
173
|
-
/**
|
|
174
|
-
* Moves to `t` AND reconstructs the trail as if the animation naturally arrived there from `t=0`.
|
|
175
|
-
* Also updates `actualTime` to match. Trail is always rebuilt from scratch.
|
|
176
|
-
* Use for initialisation or any jump where you want the trail to look meaningful.
|
|
177
|
-
* @param t The position to seek to (will be wrapped into [0, period))
|
|
178
|
-
*/
|
|
179
|
-
seek(t: number, options?: SeekOptions): void;
|
|
180
210
|
/**
|
|
181
211
|
* Smoothly transitions from the current curve to `target`.
|
|
182
212
|
* The trail naturally reflects the new curve as new points are added.
|