@redwilly/anima 0.1.0 → 0.1.2

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 (239) hide show
  1. package/dist/cli/index.js +203 -57
  2. package/dist/index.d.ts +2086 -18
  3. package/dist/index.js +5343 -22
  4. package/package.json +5 -3
  5. package/dist/cli/SceneLoader.d.ts +0 -22
  6. package/dist/cli/SceneLoader.js +0 -47
  7. package/dist/cli/commands/export-frame.d.ts +0 -13
  8. package/dist/cli/commands/export-frame.js +0 -60
  9. package/dist/cli/commands/list-scenes.d.ts +0 -5
  10. package/dist/cli/commands/list-scenes.js +0 -22
  11. package/dist/cli/commands/preview.d.ts +0 -5
  12. package/dist/cli/commands/preview.js +0 -11
  13. package/dist/cli/commands/render.d.ts +0 -16
  14. package/dist/cli/commands/render.js +0 -76
  15. package/dist/cli/index.d.ts +0 -2
  16. package/dist/core/animations/Animation.d.ts +0 -41
  17. package/dist/core/animations/Animation.js +0 -76
  18. package/dist/core/animations/camera/Follow.d.ts +0 -70
  19. package/dist/core/animations/camera/Follow.js +0 -69
  20. package/dist/core/animations/camera/Shake.d.ts +0 -90
  21. package/dist/core/animations/camera/Shake.js +0 -87
  22. package/dist/core/animations/camera/index.d.ts +0 -2
  23. package/dist/core/animations/camera/index.js +0 -2
  24. package/dist/core/animations/categories/ExitAnimation.d.ts +0 -17
  25. package/dist/core/animations/categories/ExitAnimation.js +0 -15
  26. package/dist/core/animations/categories/IntroductoryAnimation.d.ts +0 -16
  27. package/dist/core/animations/categories/IntroductoryAnimation.js +0 -14
  28. package/dist/core/animations/categories/TransformativeAnimation.d.ts +0 -25
  29. package/dist/core/animations/categories/TransformativeAnimation.js +0 -25
  30. package/dist/core/animations/categories/index.d.ts +0 -3
  31. package/dist/core/animations/categories/index.js +0 -3
  32. package/dist/core/animations/composition/Parallel.d.ts +0 -37
  33. package/dist/core/animations/composition/Parallel.js +0 -79
  34. package/dist/core/animations/composition/Sequence.d.ts +0 -41
  35. package/dist/core/animations/composition/Sequence.js +0 -95
  36. package/dist/core/animations/composition/index.d.ts +0 -2
  37. package/dist/core/animations/composition/index.js +0 -3
  38. package/dist/core/animations/draw/Draw.d.ts +0 -30
  39. package/dist/core/animations/draw/Draw.js +0 -122
  40. package/dist/core/animations/draw/Unwrite.d.ts +0 -30
  41. package/dist/core/animations/draw/Unwrite.js +0 -120
  42. package/dist/core/animations/draw/Write.d.ts +0 -35
  43. package/dist/core/animations/draw/Write.js +0 -119
  44. package/dist/core/animations/draw/index.d.ts +0 -3
  45. package/dist/core/animations/draw/index.js +0 -3
  46. package/dist/core/animations/draw/partialPath.d.ts +0 -6
  47. package/dist/core/animations/draw/partialPath.js +0 -138
  48. package/dist/core/animations/easing/bounce.d.ts +0 -13
  49. package/dist/core/animations/easing/bounce.js +0 -37
  50. package/dist/core/animations/easing/index.d.ts +0 -7
  51. package/dist/core/animations/easing/index.js +0 -11
  52. package/dist/core/animations/easing/manim.d.ts +0 -46
  53. package/dist/core/animations/easing/manim.js +0 -102
  54. package/dist/core/animations/easing/registry.d.ts +0 -8
  55. package/dist/core/animations/easing/registry.js +0 -25
  56. package/dist/core/animations/easing/standard.d.ts +0 -113
  57. package/dist/core/animations/easing/standard.js +0 -151
  58. package/dist/core/animations/easing/types.d.ts +0 -6
  59. package/dist/core/animations/easing/types.js +0 -0
  60. package/dist/core/animations/fade/FadeIn.d.ts +0 -17
  61. package/dist/core/animations/fade/FadeIn.js +0 -22
  62. package/dist/core/animations/fade/FadeOut.d.ts +0 -17
  63. package/dist/core/animations/fade/FadeOut.js +0 -23
  64. package/dist/core/animations/fade/index.d.ts +0 -2
  65. package/dist/core/animations/fade/index.js +0 -2
  66. package/dist/core/animations/index.d.ts +0 -11
  67. package/dist/core/animations/index.js +0 -17
  68. package/dist/core/animations/keyframes/KeyframeAnimation.d.ts +0 -33
  69. package/dist/core/animations/keyframes/KeyframeAnimation.js +0 -40
  70. package/dist/core/animations/keyframes/KeyframeTrack.d.ts +0 -31
  71. package/dist/core/animations/keyframes/KeyframeTrack.js +0 -83
  72. package/dist/core/animations/keyframes/index.d.ts +0 -4
  73. package/dist/core/animations/keyframes/index.js +0 -5
  74. package/dist/core/animations/keyframes/types.d.ts +0 -25
  75. package/dist/core/animations/keyframes/types.js +0 -6
  76. package/dist/core/animations/morph/MorphTo.d.ts +0 -22
  77. package/dist/core/animations/morph/MorphTo.js +0 -42
  78. package/dist/core/animations/morph/index.d.ts +0 -1
  79. package/dist/core/animations/morph/index.js +0 -1
  80. package/dist/core/animations/transform/MoveTo.d.ts +0 -24
  81. package/dist/core/animations/transform/MoveTo.js +0 -38
  82. package/dist/core/animations/transform/Rotate.d.ts +0 -23
  83. package/dist/core/animations/transform/Rotate.js +0 -34
  84. package/dist/core/animations/transform/Scale.d.ts +0 -23
  85. package/dist/core/animations/transform/Scale.js +0 -35
  86. package/dist/core/animations/transform/index.d.ts +0 -3
  87. package/dist/core/animations/transform/index.js +0 -3
  88. package/dist/core/animations/types.d.ts +0 -52
  89. package/dist/core/animations/types.js +0 -6
  90. package/dist/core/camera/Camera.d.ts +0 -87
  91. package/dist/core/camera/Camera.js +0 -175
  92. package/dist/core/camera/CameraFrame.d.ts +0 -242
  93. package/dist/core/camera/CameraFrame.js +0 -322
  94. package/dist/core/camera/index.d.ts +0 -4
  95. package/dist/core/camera/index.js +0 -3
  96. package/dist/core/camera/types.d.ts +0 -17
  97. package/dist/core/camera/types.js +0 -1
  98. package/dist/core/errors/AnimationErrors.d.ts +0 -12
  99. package/dist/core/errors/AnimationErrors.js +0 -37
  100. package/dist/core/errors/index.d.ts +0 -1
  101. package/dist/core/errors/index.js +0 -1
  102. package/dist/core/math/Vector2/Vector2.d.ts +0 -23
  103. package/dist/core/math/Vector2/Vector2.js +0 -46
  104. package/dist/core/math/Vector2/index.d.ts +0 -1
  105. package/dist/core/math/Vector2/index.js +0 -1
  106. package/dist/core/math/bezier/BezierPath.d.ts +0 -38
  107. package/dist/core/math/bezier/BezierPath.js +0 -264
  108. package/dist/core/math/bezier/evaluators.d.ts +0 -9
  109. package/dist/core/math/bezier/evaluators.js +0 -36
  110. package/dist/core/math/bezier/index.d.ts +0 -8
  111. package/dist/core/math/bezier/index.js +0 -6
  112. package/dist/core/math/bezier/length.d.ts +0 -5
  113. package/dist/core/math/bezier/length.js +0 -27
  114. package/dist/core/math/bezier/morphing.d.ts +0 -16
  115. package/dist/core/math/bezier/morphing.js +0 -151
  116. package/dist/core/math/bezier/sampling.d.ts +0 -7
  117. package/dist/core/math/bezier/sampling.js +0 -153
  118. package/dist/core/math/bezier/split.d.ts +0 -19
  119. package/dist/core/math/bezier/split.js +0 -44
  120. package/dist/core/math/bezier/types.d.ts +0 -8
  121. package/dist/core/math/bezier/types.js +0 -0
  122. package/dist/core/math/color/Color.d.ts +0 -28
  123. package/dist/core/math/color/Color.js +0 -60
  124. package/dist/core/math/color/conversions.d.ts +0 -17
  125. package/dist/core/math/color/conversions.js +0 -100
  126. package/dist/core/math/color/index.d.ts +0 -2
  127. package/dist/core/math/color/index.js +0 -2
  128. package/dist/core/math/index.d.ts +0 -4
  129. package/dist/core/math/index.js +0 -5
  130. package/dist/core/math/matrix/Matrix3x3.d.ts +0 -23
  131. package/dist/core/math/matrix/Matrix3x3.js +0 -91
  132. package/dist/core/math/matrix/factories.d.ts +0 -12
  133. package/dist/core/math/matrix/factories.js +0 -44
  134. package/dist/core/math/matrix/index.d.ts +0 -2
  135. package/dist/core/math/matrix/index.js +0 -2
  136. package/dist/core/renderer/FrameRenderer.d.ts +0 -37
  137. package/dist/core/renderer/FrameRenderer.js +0 -75
  138. package/dist/core/renderer/ProgressReporter.d.ts +0 -19
  139. package/dist/core/renderer/ProgressReporter.js +0 -58
  140. package/dist/core/renderer/Renderer.d.ts +0 -36
  141. package/dist/core/renderer/Renderer.js +0 -102
  142. package/dist/core/renderer/drawMobject.d.ts +0 -8
  143. package/dist/core/renderer/drawMobject.js +0 -109
  144. package/dist/core/renderer/formats/index.d.ts +0 -3
  145. package/dist/core/renderer/formats/index.js +0 -3
  146. package/dist/core/renderer/formats/png.d.ts +0 -5
  147. package/dist/core/renderer/formats/png.js +0 -7
  148. package/dist/core/renderer/formats/sprite.d.ts +0 -6
  149. package/dist/core/renderer/formats/sprite.js +0 -24
  150. package/dist/core/renderer/formats/video.d.ts +0 -8
  151. package/dist/core/renderer/formats/video.js +0 -51
  152. package/dist/core/renderer/index.d.ts +0 -7
  153. package/dist/core/renderer/index.js +0 -9
  154. package/dist/core/renderer/types.d.ts +0 -87
  155. package/dist/core/renderer/types.js +0 -13
  156. package/dist/core/scene/Scene.d.ts +0 -104
  157. package/dist/core/scene/Scene.js +0 -225
  158. package/dist/core/scene/index.d.ts +0 -2
  159. package/dist/core/scene/index.js +0 -1
  160. package/dist/core/scene/types.d.ts +0 -23
  161. package/dist/core/scene/types.js +0 -0
  162. package/dist/core/serialization/animation.d.ts +0 -23
  163. package/dist/core/serialization/animation.js +0 -176
  164. package/dist/core/serialization/easingLookup.d.ts +0 -13
  165. package/dist/core/serialization/easingLookup.js +0 -65
  166. package/dist/core/serialization/index.d.ts +0 -23
  167. package/dist/core/serialization/index.js +0 -29
  168. package/dist/core/serialization/mobject.d.ts +0 -23
  169. package/dist/core/serialization/mobject.js +0 -248
  170. package/dist/core/serialization/prettyPrint.d.ts +0 -12
  171. package/dist/core/serialization/prettyPrint.js +0 -16
  172. package/dist/core/serialization/primitives.d.ts +0 -24
  173. package/dist/core/serialization/primitives.js +0 -98
  174. package/dist/core/serialization/registry.d.ts +0 -29
  175. package/dist/core/serialization/registry.js +0 -39
  176. package/dist/core/serialization/scene.d.ts +0 -28
  177. package/dist/core/serialization/scene.js +0 -114
  178. package/dist/core/serialization/types.d.ts +0 -152
  179. package/dist/core/serialization/types.js +0 -6
  180. package/dist/core/timeline/Timeline.d.ts +0 -70
  181. package/dist/core/timeline/Timeline.js +0 -144
  182. package/dist/core/timeline/index.d.ts +0 -5
  183. package/dist/core/timeline/index.js +0 -4
  184. package/dist/core/timeline/types.d.ts +0 -29
  185. package/dist/core/timeline/types.js +0 -0
  186. package/dist/mobjects/Mobject.d.ts +0 -98
  187. package/dist/mobjects/Mobject.js +0 -343
  188. package/dist/mobjects/VGroup/VGroup.d.ts +0 -51
  189. package/dist/mobjects/VGroup/VGroup.js +0 -142
  190. package/dist/mobjects/VGroup/index.d.ts +0 -3
  191. package/dist/mobjects/VGroup/index.js +0 -2
  192. package/dist/mobjects/VGroup/layout.d.ts +0 -20
  193. package/dist/mobjects/VGroup/layout.js +0 -139
  194. package/dist/mobjects/VMobject.d.ts +0 -106
  195. package/dist/mobjects/VMobject.js +0 -216
  196. package/dist/mobjects/geometry/Arc.d.ts +0 -8
  197. package/dist/mobjects/geometry/Arc.js +0 -46
  198. package/dist/mobjects/geometry/Arrow.d.ts +0 -7
  199. package/dist/mobjects/geometry/Arrow.js +0 -34
  200. package/dist/mobjects/geometry/Circle.d.ts +0 -4
  201. package/dist/mobjects/geometry/Circle.js +0 -10
  202. package/dist/mobjects/geometry/Line.d.ts +0 -8
  203. package/dist/mobjects/geometry/Line.js +0 -19
  204. package/dist/mobjects/geometry/Point.d.ts +0 -5
  205. package/dist/mobjects/geometry/Point.js +0 -11
  206. package/dist/mobjects/geometry/Polygon.d.ts +0 -7
  207. package/dist/mobjects/geometry/Polygon.js +0 -21
  208. package/dist/mobjects/geometry/Rectangle.d.ts +0 -6
  209. package/dist/mobjects/geometry/Rectangle.js +0 -18
  210. package/dist/mobjects/geometry/index.d.ts +0 -7
  211. package/dist/mobjects/geometry/index.js +0 -7
  212. package/dist/mobjects/graph/Graph.d.ts +0 -28
  213. package/dist/mobjects/graph/Graph.js +0 -119
  214. package/dist/mobjects/graph/GraphEdge.d.ts +0 -26
  215. package/dist/mobjects/graph/GraphEdge.js +0 -64
  216. package/dist/mobjects/graph/GraphNode.d.ts +0 -19
  217. package/dist/mobjects/graph/GraphNode.js +0 -63
  218. package/dist/mobjects/graph/index.d.ts +0 -5
  219. package/dist/mobjects/graph/index.js +0 -5
  220. package/dist/mobjects/graph/layouts/circular.d.ts +0 -8
  221. package/dist/mobjects/graph/layouts/circular.js +0 -23
  222. package/dist/mobjects/graph/layouts/forceDirected.d.ts +0 -9
  223. package/dist/mobjects/graph/layouts/forceDirected.js +0 -102
  224. package/dist/mobjects/graph/layouts/index.d.ts +0 -3
  225. package/dist/mobjects/graph/layouts/index.js +0 -3
  226. package/dist/mobjects/graph/layouts/tree.d.ts +0 -9
  227. package/dist/mobjects/graph/layouts/tree.js +0 -99
  228. package/dist/mobjects/graph/types.d.ts +0 -35
  229. package/dist/mobjects/graph/types.js +0 -0
  230. package/dist/mobjects/index.d.ts +0 -6
  231. package/dist/mobjects/index.js +0 -6
  232. package/dist/mobjects/text/Glyph.d.ts +0 -11
  233. package/dist/mobjects/text/Glyph.js +0 -72
  234. package/dist/mobjects/text/Text.d.ts +0 -19
  235. package/dist/mobjects/text/Text.js +0 -76
  236. package/dist/mobjects/text/index.d.ts +0 -4
  237. package/dist/mobjects/text/index.js +0 -3
  238. package/dist/mobjects/text/types.d.ts +0 -12
  239. package/dist/mobjects/text/types.js +0 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redwilly/anima",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Animation library for mathematical visualizations",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -20,7 +20,7 @@
20
20
  "scripts": {
21
21
  "typecheck": "tsc --noEmit",
22
22
  "clean": "rimraf dist",
23
- "build": "bun run clean && tsc -p tsconfig.build.json",
23
+ "build": "tsup",
24
24
  "prepublishOnly": "bun run build"
25
25
  },
26
26
  "keywords": [
@@ -38,7 +38,9 @@
38
38
  "@types/bun": "latest",
39
39
  "@types/fontkit": "^2.0.8",
40
40
  "fast-check": "^4.5.3",
41
- "rimraf": "^6.0.1"
41
+ "glob": "^13.0.1",
42
+ "rimraf": "^6.0.1",
43
+ "tsup": "^8.5.1"
42
44
  },
43
45
  "peerDependencies": {
44
46
  "typescript": "^5"
@@ -1,22 +0,0 @@
1
- import { Scene } from '../core/scene/Scene';
2
- /**
3
- * Result of loading scenes from a file.
4
- */
5
- export interface LoadedScenes {
6
- /** Map of class name to Scene instance. */
7
- scenes: Map<string, Scene>;
8
- /** Error message if loading failed. */
9
- error?: string;
10
- }
11
- /**
12
- * Dynamically loads Scene classes from a TypeScript file.
13
- */
14
- export declare class SceneLoader {
15
- /**
16
- * Loads all scenes from the specified file.
17
- *
18
- * @param filePath Path to the TypeScript file containing scenes
19
- * @returns Loaded scenes and any error
20
- */
21
- load(filePath: string): Promise<LoadedScenes>;
22
- }
@@ -1,47 +0,0 @@
1
- import { Scene } from '../core/scene/Scene';
2
- import { pathToFileURL } from 'url';
3
- import { resolve } from 'path';
4
- /**
5
- * Dynamically loads Scene classes from a TypeScript file.
6
- */
7
- export class SceneLoader {
8
- /**
9
- * Loads all scenes from the specified file.
10
- *
11
- * @param filePath Path to the TypeScript file containing scenes
12
- * @returns Loaded scenes and any error
13
- */
14
- async load(filePath) {
15
- const absolutePath = resolve(filePath);
16
- const fileUrl = pathToFileURL(absolutePath).href;
17
- try {
18
- // Dynamically import the file
19
- const module = await import(fileUrl);
20
- const scenes = new Map();
21
- for (const [name, exportValue] of Object.entries(module)) {
22
- // Check if export is a class that extends Scene
23
- if (typeof exportValue === 'function' &&
24
- exportValue.prototype instanceof Scene) {
25
- try {
26
- const SceneClass = exportValue;
27
- const instance = new SceneClass();
28
- scenes.set(name, instance);
29
- }
30
- catch (err) {
31
- console.warn(`Failed to instantiate scene '${name}':`, err);
32
- }
33
- }
34
- }
35
- if (scenes.size === 0) {
36
- return { scenes, error: 'No Scene subclasses found in file.' };
37
- }
38
- return { scenes };
39
- }
40
- catch (err) {
41
- return {
42
- scenes: new Map(),
43
- error: `Failed to load file: ${err instanceof Error ? err.message : String(err)}`,
44
- };
45
- }
46
- }
47
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * Options for the export-frame command.
3
- */
4
- interface ExportFrameOptions {
5
- scene?: string;
6
- frame: string;
7
- output?: string;
8
- }
9
- /**
10
- * Implementation of the 'export-frame' command.
11
- */
12
- export declare function exportFrame(file: string, options: ExportFrameOptions): Promise<void>;
13
- export {};
@@ -1,60 +0,0 @@
1
- import { SceneLoader } from '../SceneLoader';
2
- import { Renderer } from '../../core/renderer/Renderer';
3
- /**
4
- * Implementation of the 'export-frame' command.
5
- */
6
- export async function exportFrame(file, options) {
7
- const loader = new SceneLoader();
8
- const { scenes, error } = await loader.load(file);
9
- if (error) {
10
- console.error(`Error: ${error}`);
11
- process.exit(1);
12
- }
13
- let scene;
14
- if (options.scene) {
15
- scene = scenes.get(options.scene);
16
- if (!scene) {
17
- console.error(`Error: Scene '${options.scene}' not found.`);
18
- process.exit(1);
19
- }
20
- }
21
- else if (scenes.size === 1) {
22
- scene = scenes.values().next().value;
23
- }
24
- else {
25
- console.error('Error: Multiple scenes found in file. Please specify one with --scene.');
26
- process.exit(1);
27
- }
28
- if (!scene) {
29
- console.error('Error: No scene found.');
30
- process.exit(1);
31
- }
32
- const renderer = new Renderer();
33
- const totalDuration = scene.getTotalDuration();
34
- const frameRate = scene.getFrameRate();
35
- let time;
36
- if (options.frame === 'last') {
37
- time = totalDuration;
38
- }
39
- else {
40
- const frameIndex = parseInt(options.frame, 10);
41
- time = frameIndex / frameRate;
42
- }
43
- const outputPath = options.output ?? `frame_${options.frame}.png`;
44
- console.log(`Exporting frame ${options.frame} to '${outputPath}'...`);
45
- // We can use renderLastFrame but it always takes totalDuration.
46
- // So we'll use a custom implementation or seek manually.
47
- // For now, let's just use totalDuration if 'last', otherwise we seek.
48
- if (options.frame === 'last') {
49
- await renderer.renderLastFrame(scene, outputPath);
50
- }
51
- else {
52
- // Need to seek to time. renderLastFrame doesn't support time.
53
- // We'll use the internal logic of renderLastFrame but with specific time.
54
- // But renderLastFrame is on the Renderer class.
55
- // Let's just use what we have in Renderer.
56
- await renderer.renderLastFrame(scene, outputPath); // This is a limitation for now.
57
- // TODO: Update Renderer to support specific time in renderLastFrame
58
- }
59
- console.log('Export complete.');
60
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Implementation of the 'list-scenes' command.
3
- * Loads a file and prints the names of all Scene classes found.
4
- */
5
- export declare function listScenes(file: string): Promise<void>;
@@ -1,22 +0,0 @@
1
- import { SceneLoader } from '../SceneLoader';
2
- import { resolve } from 'path';
3
- /**
4
- * Implementation of the 'list-scenes' command.
5
- * Loads a file and prints the names of all Scene classes found.
6
- */
7
- export async function listScenes(file) {
8
- const loader = new SceneLoader();
9
- const { scenes, error } = await loader.load(file);
10
- if (error) {
11
- console.error(`Error: ${error}`);
12
- process.exit(1);
13
- }
14
- if (scenes.size === 0) {
15
- console.log('No scenes found in this file.');
16
- return;
17
- }
18
- console.log(`Found ${scenes.size} scene(s) in '${resolve(file)}':`);
19
- for (const name of scenes.keys()) {
20
- console.log(` - ${name}`);
21
- }
22
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Implementation of the 'preview' command.
3
- * Shorthand for rendering with 'preview' quality.
4
- */
5
- export declare function preview(file: string, options: any): Promise<void>;
@@ -1,11 +0,0 @@
1
- import { render } from './render';
2
- /**
3
- * Implementation of the 'preview' command.
4
- * Shorthand for rendering with 'preview' quality.
5
- */
6
- export async function preview(file, options) {
7
- await render(file, {
8
- ...options,
9
- quality: 'preview',
10
- });
11
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * Options for the render command.
3
- */
4
- interface RenderOptions {
5
- scene?: string;
6
- format?: string;
7
- resolution?: string;
8
- fps?: string;
9
- quality?: string;
10
- output?: string;
11
- }
12
- /**
13
- * Implementation of the 'render' command.
14
- */
15
- export declare function render(file: string, options: RenderOptions): Promise<void>;
16
- export {};
@@ -1,76 +0,0 @@
1
- import { SceneLoader } from '../SceneLoader';
2
- import { Renderer } from '../../core/renderer/Renderer';
3
- import { Resolution } from '../../core/renderer/types';
4
- /**
5
- * Implementation of the 'render' command.
6
- */
7
- export async function render(file, options) {
8
- const loader = new SceneLoader();
9
- const { scenes, error } = await loader.load(file);
10
- if (error) {
11
- console.error(`Error: ${error}`);
12
- process.exit(1);
13
- }
14
- let scene;
15
- if (options.scene) {
16
- const found = scenes.get(options.scene);
17
- if (!found) {
18
- console.error(`Error: Scene '${options.scene}' not found in file.`);
19
- console.log('Available scenes:');
20
- for (const name of scenes.keys()) {
21
- console.log(` - ${name}`);
22
- }
23
- process.exit(1);
24
- }
25
- scene = found;
26
- }
27
- else {
28
- if (scenes.size === 1) {
29
- scene = scenes.values().next().value;
30
- }
31
- else {
32
- console.error('Error: Multiple scenes found in file. Please specify one with --scene.');
33
- for (const name of scenes.keys()) {
34
- console.log(` - ${name}`);
35
- }
36
- process.exit(1);
37
- }
38
- }
39
- if (!scene) {
40
- console.error('Error: No scene found to render.');
41
- process.exit(1);
42
- }
43
- const renderer = new Renderer();
44
- const outputPath = options.output ?? `output.${options.format ?? 'mp4'}`;
45
- // Resolve resolution preset
46
- let width = scene.getWidth();
47
- let height = scene.getHeight();
48
- if (options.resolution) {
49
- const presetKey = `p${options.resolution}`;
50
- const preset = Resolution[presetKey];
51
- if (preset) {
52
- width = preset.width;
53
- height = preset.height;
54
- }
55
- else {
56
- console.warn(`Warning: Resolution preset '${options.resolution}' not found. Using scene defaults.`);
57
- }
58
- }
59
- console.log(`Rendering scene to '${outputPath}'...`);
60
- await renderer.render(scene, outputPath, {
61
- width,
62
- height,
63
- frameRate: options.fps ? parseInt(options.fps, 10) : undefined,
64
- format: options.format,
65
- quality: options.quality,
66
- onProgress: (progress) => {
67
- const percent = progress.percentage.toFixed(1);
68
- const eta = (progress.estimatedRemainingMs / 1000).toFixed(1);
69
- process.stdout.write(`\rProgress: ${percent}% | ETA: ${eta}s `);
70
- if (progress.percentage === 100) {
71
- process.stdout.write('\n');
72
- }
73
- },
74
- });
75
- console.log('Rendering complete.');
76
- }
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env bun
2
- export {};
@@ -1,41 +0,0 @@
1
- import { Mobject } from '../../mobjects/Mobject';
2
- import type { EasingFunction } from './easing';
3
- import type { AnimationConfig, AnimationLifecycle } from './types';
4
- /**
5
- * Abstract base class for all animations.
6
- * Provides configuration for duration, easing, and delay.
7
- * Subclasses must specify their lifecycle category.
8
- */
9
- export declare abstract class Animation<T extends Mobject = Mobject> {
10
- protected readonly target: T;
11
- protected durationSeconds: number;
12
- protected easingFn: EasingFunction;
13
- protected delaySeconds: number;
14
- /**
15
- * The lifecycle category of this animation.
16
- * Determines how Scene.play() handles scene registration and validation.
17
- */
18
- abstract readonly lifecycle: AnimationLifecycle;
19
- constructor(target: T);
20
- duration(seconds: number): this;
21
- ease(easing: EasingFunction): this;
22
- delay(seconds: number): this;
23
- getDuration(): number;
24
- getDelay(): number;
25
- getEasing(): EasingFunction;
26
- getTarget(): T;
27
- getConfig(): AnimationConfig;
28
- abstract interpolate(progress: number): void;
29
- /**
30
- * Ensures the animation is initialized before interpolation.
31
- * Called before first update to capture start state.
32
- * Default: no-op. Override in subclasses that need lazy initialization.
33
- */
34
- ensureInitialized(): void;
35
- /**
36
- * Resets the animation to its uninitialized state.
37
- * Allows animations to be replayed or looped.
38
- */
39
- reset(): void;
40
- update(progress: number): void;
41
- }
@@ -1,76 +0,0 @@
1
- import { defaultEasing } from './easing';
2
- /**
3
- * Abstract base class for all animations.
4
- * Provides configuration for duration, easing, and delay.
5
- * Subclasses must specify their lifecycle category.
6
- */
7
- export class Animation {
8
- target;
9
- durationSeconds;
10
- easingFn;
11
- delaySeconds;
12
- constructor(target) {
13
- this.target = target;
14
- this.durationSeconds = 1;
15
- this.easingFn = defaultEasing;
16
- this.delaySeconds = 0;
17
- }
18
- duration(seconds) {
19
- if (seconds <= 0) {
20
- throw new Error('Duration must be positive');
21
- }
22
- this.durationSeconds = seconds;
23
- return this;
24
- }
25
- ease(easing) {
26
- this.easingFn = easing;
27
- return this;
28
- }
29
- delay(seconds) {
30
- if (seconds < 0) {
31
- throw new Error('Delay must be non-negative');
32
- }
33
- this.delaySeconds = seconds;
34
- return this;
35
- }
36
- getDuration() {
37
- return this.durationSeconds;
38
- }
39
- getDelay() {
40
- return this.delaySeconds;
41
- }
42
- getEasing() {
43
- return this.easingFn;
44
- }
45
- getTarget() {
46
- return this.target;
47
- }
48
- getConfig() {
49
- return {
50
- durationSeconds: this.durationSeconds,
51
- easing: this.easingFn,
52
- delaySeconds: this.delaySeconds,
53
- };
54
- }
55
- /**
56
- * Ensures the animation is initialized before interpolation.
57
- * Called before first update to capture start state.
58
- * Default: no-op. Override in subclasses that need lazy initialization.
59
- */
60
- ensureInitialized() {
61
- // Default: no-op
62
- }
63
- /**
64
- * Resets the animation to its uninitialized state.
65
- * Allows animations to be replayed or looped.
66
- */
67
- reset() {
68
- // Default: no-op
69
- }
70
- update(progress) {
71
- // this.ensureInitialized();
72
- const clampedProgress = Math.max(0, Math.min(1, progress));
73
- const easedProgress = this.easingFn(clampedProgress);
74
- this.interpolate(easedProgress);
75
- }
76
- }
@@ -1,70 +0,0 @@
1
- import { Animation } from '../Animation';
2
- import type { AnimationLifecycle } from '../types';
3
- import type { CameraFrame } from '../../camera/CameraFrame';
4
- import type { Mobject } from '../../../mobjects/Mobject';
5
- import { Vector2 } from '../../math/Vector2/Vector2';
6
- /**
7
- * Configuration options for the Follow animation.
8
- */
9
- interface FollowConfig {
10
- /**
11
- * Offset from the target's position. The camera will track
12
- * (target.position + offset) instead of the exact target position.
13
- * @default Vector2.ZERO
14
- */
15
- offset?: Vector2;
16
- /**
17
- * Damping factor for smooth following (0 to 1).
18
- * - 0 = instant snap to target (no smoothing)
19
- * - 0.9 = very smooth, slow following
20
- * Higher values create a more "laggy" camera that takes longer to catch up.
21
- * @default 0
22
- */
23
- damping?: number;
24
- }
25
- /**
26
- * Animation that makes a CameraFrame track a target Mobject's position over time.
27
- * Unlike MoveTo which captures position once, Follow reads the target position
28
- * every frame, allowing the camera to track moving objects.
29
- *
30
- * @example
31
- * // Basic follow - camera snaps to target position
32
- * this.play(new Follow(this.frame, movingCircle).duration(5));
33
- *
34
- * @example
35
- * // Smooth follow with damping
36
- * this.play(new Follow(this.frame, player, { damping: 0.8 }).duration(10));
37
- *
38
- * @example
39
- * // Follow with offset (camera leads the target)
40
- * this.play(new Follow(this.frame, car, {
41
- * offset: new Vector2(2, 0), // Camera 2 units ahead
42
- * damping: 0.5
43
- * }).duration(10));
44
- */
45
- export declare class Follow extends Animation<CameraFrame> {
46
- readonly lifecycle: AnimationLifecycle;
47
- private readonly followTarget;
48
- private readonly offset;
49
- private readonly damping;
50
- /**
51
- * Creates a new Follow animation.
52
- *
53
- * @param frame - The CameraFrame to animate
54
- * @param target - The Mobject to follow
55
- * @param config - Configuration options
56
- * @throws Error if frame is null or undefined
57
- * @throws Error if target is null or undefined
58
- *
59
- * @example
60
- * const follow = new Follow(scene.frame, player, { damping: 0.7 });
61
- * this.play(follow.duration(10));
62
- */
63
- constructor(frame: CameraFrame, target: Mobject, config?: FollowConfig);
64
- /**
65
- * Updates the camera position each frame to track the target.
66
- * @param progress - Animation progress (0 to 1)
67
- */
68
- interpolate(progress: number): void;
69
- }
70
- export {};
@@ -1,69 +0,0 @@
1
- import { Animation } from '../Animation';
2
- import { Vector2 } from '../../math/Vector2/Vector2';
3
- /**
4
- * Animation that makes a CameraFrame track a target Mobject's position over time.
5
- * Unlike MoveTo which captures position once, Follow reads the target position
6
- * every frame, allowing the camera to track moving objects.
7
- *
8
- * @example
9
- * // Basic follow - camera snaps to target position
10
- * this.play(new Follow(this.frame, movingCircle).duration(5));
11
- *
12
- * @example
13
- * // Smooth follow with damping
14
- * this.play(new Follow(this.frame, player, { damping: 0.8 }).duration(10));
15
- *
16
- * @example
17
- * // Follow with offset (camera leads the target)
18
- * this.play(new Follow(this.frame, car, {
19
- * offset: new Vector2(2, 0), // Camera 2 units ahead
20
- * damping: 0.5
21
- * }).duration(10));
22
- */
23
- export class Follow extends Animation {
24
- lifecycle = 'transformative';
25
- followTarget;
26
- offset;
27
- damping;
28
- /**
29
- * Creates a new Follow animation.
30
- *
31
- * @param frame - The CameraFrame to animate
32
- * @param target - The Mobject to follow
33
- * @param config - Configuration options
34
- * @throws Error if frame is null or undefined
35
- * @throws Error if target is null or undefined
36
- *
37
- * @example
38
- * const follow = new Follow(scene.frame, player, { damping: 0.7 });
39
- * this.play(follow.duration(10));
40
- */
41
- constructor(frame, target, config = {}) {
42
- if (!frame) {
43
- throw new Error('Follow animation requires a CameraFrame');
44
- }
45
- if (!target) {
46
- throw new Error('Follow animation requires a target Mobject');
47
- }
48
- super(frame);
49
- this.followTarget = target;
50
- this.offset = config.offset ?? Vector2.ZERO;
51
- this.damping = config.damping ?? 0;
52
- }
53
- /**
54
- * Updates the camera position each frame to track the target.
55
- * @param progress - Animation progress (0 to 1)
56
- */
57
- interpolate(progress) {
58
- const targetPos = this.followTarget.position.add(this.offset);
59
- const currentPos = this.target.position;
60
- if (this.damping > 0 && this.damping < 1) {
61
- const lerpFactor = 1 - this.damping;
62
- const newPos = currentPos.lerp(targetPos, lerpFactor);
63
- this.target.pos(newPos.x, newPos.y);
64
- }
65
- else {
66
- this.target.pos(targetPos.x, targetPos.y);
67
- }
68
- }
69
- }
@@ -1,90 +0,0 @@
1
- import { TransformativeAnimation } from '../categories';
2
- import { CameraFrame } from '../../camera/CameraFrame';
3
- /**
4
- * Configuration options for the Shake animation.
5
- */
6
- interface ShakeConfig {
7
- /**
8
- * Maximum displacement distance in world units.
9
- * Higher values create more violent shaking.
10
- * @default 0.2
11
- */
12
- intensity?: number;
13
- /**
14
- * Number of oscillations per second.
15
- * Higher values create faster, more frantic shaking.
16
- * @default 10
17
- */
18
- frequency?: number;
19
- /**
20
- * Controls how quickly the shake diminishes over time.
21
- * - 0 = no decay (constant intensity throughout)
22
- * - 1 = linear decay
23
- * - Higher values = faster decay (shake fades quickly)
24
- * @default 1
25
- */
26
- decay?: number;
27
- }
28
- /**
29
- * Camera shake effect animation.
30
- * Creates procedural displacement using layered sine waves to simulate
31
- * impacts, explosions, or earthquakes.
32
- *
33
- * The shake automatically returns to the original position when complete.
34
- *
35
- * @example
36
- * // Basic shake effect
37
- * this.play(new Shake(this.frame).duration(0.5));
38
- *
39
- * @example
40
- * // Intense explosion shake with quick decay
41
- * this.play(new Shake(this.frame, {
42
- * intensity: 0.5,
43
- * frequency: 20,
44
- * decay: 2
45
- * }).duration(0.3));
46
- *
47
- * @example
48
- * // Subtle earthquake with slow decay
49
- * this.play(new Shake(this.frame, {
50
- * intensity: 0.1,
51
- * frequency: 5,
52
- * decay: 0.5
53
- * }).duration(3));
54
- */
55
- export declare class Shake extends TransformativeAnimation<CameraFrame> {
56
- private originalPosition;
57
- private readonly intensity;
58
- private readonly frequency;
59
- private readonly decay;
60
- private readonly seedX;
61
- private readonly seedY;
62
- /**
63
- * Creates a new Shake animation.
64
- *
65
- * @param frame - The CameraFrame to shake
66
- * @param config - Configuration options for intensity, frequency, and decay
67
- *
68
- * @example
69
- * const shake = new Shake(scene.frame, { intensity: 0.3 });
70
- * this.play(shake.duration(0.5));
71
- */
72
- constructor(frame: CameraFrame, config?: ShakeConfig);
73
- /**
74
- * Captures the original position before shake begins.
75
- */
76
- protected captureStartState(): void;
77
- /**
78
- * Applies procedural shake displacement each frame.
79
- * @param progress - Animation progress (0 to 1)
80
- */
81
- interpolate(progress: number): void;
82
- /**
83
- * Generates pseudo-random noise using layered sine waves.
84
- * @param t - Time value
85
- * @param seed - Random seed for variation
86
- * @returns Noise value between -1 and 1
87
- */
88
- private noise;
89
- }
90
- export {};