@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.
- package/dist/cli/index.js +203 -57
- package/dist/index.d.ts +2086 -18
- package/dist/index.js +5343 -22
- package/package.json +5 -3
- package/dist/cli/SceneLoader.d.ts +0 -22
- package/dist/cli/SceneLoader.js +0 -47
- package/dist/cli/commands/export-frame.d.ts +0 -13
- package/dist/cli/commands/export-frame.js +0 -60
- package/dist/cli/commands/list-scenes.d.ts +0 -5
- package/dist/cli/commands/list-scenes.js +0 -22
- package/dist/cli/commands/preview.d.ts +0 -5
- package/dist/cli/commands/preview.js +0 -11
- package/dist/cli/commands/render.d.ts +0 -16
- package/dist/cli/commands/render.js +0 -76
- package/dist/cli/index.d.ts +0 -2
- package/dist/core/animations/Animation.d.ts +0 -41
- package/dist/core/animations/Animation.js +0 -76
- package/dist/core/animations/camera/Follow.d.ts +0 -70
- package/dist/core/animations/camera/Follow.js +0 -69
- package/dist/core/animations/camera/Shake.d.ts +0 -90
- package/dist/core/animations/camera/Shake.js +0 -87
- package/dist/core/animations/camera/index.d.ts +0 -2
- package/dist/core/animations/camera/index.js +0 -2
- package/dist/core/animations/categories/ExitAnimation.d.ts +0 -17
- package/dist/core/animations/categories/ExitAnimation.js +0 -15
- package/dist/core/animations/categories/IntroductoryAnimation.d.ts +0 -16
- package/dist/core/animations/categories/IntroductoryAnimation.js +0 -14
- package/dist/core/animations/categories/TransformativeAnimation.d.ts +0 -25
- package/dist/core/animations/categories/TransformativeAnimation.js +0 -25
- package/dist/core/animations/categories/index.d.ts +0 -3
- package/dist/core/animations/categories/index.js +0 -3
- package/dist/core/animations/composition/Parallel.d.ts +0 -37
- package/dist/core/animations/composition/Parallel.js +0 -79
- package/dist/core/animations/composition/Sequence.d.ts +0 -41
- package/dist/core/animations/composition/Sequence.js +0 -95
- package/dist/core/animations/composition/index.d.ts +0 -2
- package/dist/core/animations/composition/index.js +0 -3
- package/dist/core/animations/draw/Draw.d.ts +0 -30
- package/dist/core/animations/draw/Draw.js +0 -122
- package/dist/core/animations/draw/Unwrite.d.ts +0 -30
- package/dist/core/animations/draw/Unwrite.js +0 -120
- package/dist/core/animations/draw/Write.d.ts +0 -35
- package/dist/core/animations/draw/Write.js +0 -119
- package/dist/core/animations/draw/index.d.ts +0 -3
- package/dist/core/animations/draw/index.js +0 -3
- package/dist/core/animations/draw/partialPath.d.ts +0 -6
- package/dist/core/animations/draw/partialPath.js +0 -138
- package/dist/core/animations/easing/bounce.d.ts +0 -13
- package/dist/core/animations/easing/bounce.js +0 -37
- package/dist/core/animations/easing/index.d.ts +0 -7
- package/dist/core/animations/easing/index.js +0 -11
- package/dist/core/animations/easing/manim.d.ts +0 -46
- package/dist/core/animations/easing/manim.js +0 -102
- package/dist/core/animations/easing/registry.d.ts +0 -8
- package/dist/core/animations/easing/registry.js +0 -25
- package/dist/core/animations/easing/standard.d.ts +0 -113
- package/dist/core/animations/easing/standard.js +0 -151
- package/dist/core/animations/easing/types.d.ts +0 -6
- package/dist/core/animations/easing/types.js +0 -0
- package/dist/core/animations/fade/FadeIn.d.ts +0 -17
- package/dist/core/animations/fade/FadeIn.js +0 -22
- package/dist/core/animations/fade/FadeOut.d.ts +0 -17
- package/dist/core/animations/fade/FadeOut.js +0 -23
- package/dist/core/animations/fade/index.d.ts +0 -2
- package/dist/core/animations/fade/index.js +0 -2
- package/dist/core/animations/index.d.ts +0 -11
- package/dist/core/animations/index.js +0 -17
- package/dist/core/animations/keyframes/KeyframeAnimation.d.ts +0 -33
- package/dist/core/animations/keyframes/KeyframeAnimation.js +0 -40
- package/dist/core/animations/keyframes/KeyframeTrack.d.ts +0 -31
- package/dist/core/animations/keyframes/KeyframeTrack.js +0 -83
- package/dist/core/animations/keyframes/index.d.ts +0 -4
- package/dist/core/animations/keyframes/index.js +0 -5
- package/dist/core/animations/keyframes/types.d.ts +0 -25
- package/dist/core/animations/keyframes/types.js +0 -6
- package/dist/core/animations/morph/MorphTo.d.ts +0 -22
- package/dist/core/animations/morph/MorphTo.js +0 -42
- package/dist/core/animations/morph/index.d.ts +0 -1
- package/dist/core/animations/morph/index.js +0 -1
- package/dist/core/animations/transform/MoveTo.d.ts +0 -24
- package/dist/core/animations/transform/MoveTo.js +0 -38
- package/dist/core/animations/transform/Rotate.d.ts +0 -23
- package/dist/core/animations/transform/Rotate.js +0 -34
- package/dist/core/animations/transform/Scale.d.ts +0 -23
- package/dist/core/animations/transform/Scale.js +0 -35
- package/dist/core/animations/transform/index.d.ts +0 -3
- package/dist/core/animations/transform/index.js +0 -3
- package/dist/core/animations/types.d.ts +0 -52
- package/dist/core/animations/types.js +0 -6
- package/dist/core/camera/Camera.d.ts +0 -87
- package/dist/core/camera/Camera.js +0 -175
- package/dist/core/camera/CameraFrame.d.ts +0 -242
- package/dist/core/camera/CameraFrame.js +0 -322
- package/dist/core/camera/index.d.ts +0 -4
- package/dist/core/camera/index.js +0 -3
- package/dist/core/camera/types.d.ts +0 -17
- package/dist/core/camera/types.js +0 -1
- package/dist/core/errors/AnimationErrors.d.ts +0 -12
- package/dist/core/errors/AnimationErrors.js +0 -37
- package/dist/core/errors/index.d.ts +0 -1
- package/dist/core/errors/index.js +0 -1
- package/dist/core/math/Vector2/Vector2.d.ts +0 -23
- package/dist/core/math/Vector2/Vector2.js +0 -46
- package/dist/core/math/Vector2/index.d.ts +0 -1
- package/dist/core/math/Vector2/index.js +0 -1
- package/dist/core/math/bezier/BezierPath.d.ts +0 -38
- package/dist/core/math/bezier/BezierPath.js +0 -264
- package/dist/core/math/bezier/evaluators.d.ts +0 -9
- package/dist/core/math/bezier/evaluators.js +0 -36
- package/dist/core/math/bezier/index.d.ts +0 -8
- package/dist/core/math/bezier/index.js +0 -6
- package/dist/core/math/bezier/length.d.ts +0 -5
- package/dist/core/math/bezier/length.js +0 -27
- package/dist/core/math/bezier/morphing.d.ts +0 -16
- package/dist/core/math/bezier/morphing.js +0 -151
- package/dist/core/math/bezier/sampling.d.ts +0 -7
- package/dist/core/math/bezier/sampling.js +0 -153
- package/dist/core/math/bezier/split.d.ts +0 -19
- package/dist/core/math/bezier/split.js +0 -44
- package/dist/core/math/bezier/types.d.ts +0 -8
- package/dist/core/math/bezier/types.js +0 -0
- package/dist/core/math/color/Color.d.ts +0 -28
- package/dist/core/math/color/Color.js +0 -60
- package/dist/core/math/color/conversions.d.ts +0 -17
- package/dist/core/math/color/conversions.js +0 -100
- package/dist/core/math/color/index.d.ts +0 -2
- package/dist/core/math/color/index.js +0 -2
- package/dist/core/math/index.d.ts +0 -4
- package/dist/core/math/index.js +0 -5
- package/dist/core/math/matrix/Matrix3x3.d.ts +0 -23
- package/dist/core/math/matrix/Matrix3x3.js +0 -91
- package/dist/core/math/matrix/factories.d.ts +0 -12
- package/dist/core/math/matrix/factories.js +0 -44
- package/dist/core/math/matrix/index.d.ts +0 -2
- package/dist/core/math/matrix/index.js +0 -2
- package/dist/core/renderer/FrameRenderer.d.ts +0 -37
- package/dist/core/renderer/FrameRenderer.js +0 -75
- package/dist/core/renderer/ProgressReporter.d.ts +0 -19
- package/dist/core/renderer/ProgressReporter.js +0 -58
- package/dist/core/renderer/Renderer.d.ts +0 -36
- package/dist/core/renderer/Renderer.js +0 -102
- package/dist/core/renderer/drawMobject.d.ts +0 -8
- package/dist/core/renderer/drawMobject.js +0 -109
- package/dist/core/renderer/formats/index.d.ts +0 -3
- package/dist/core/renderer/formats/index.js +0 -3
- package/dist/core/renderer/formats/png.d.ts +0 -5
- package/dist/core/renderer/formats/png.js +0 -7
- package/dist/core/renderer/formats/sprite.d.ts +0 -6
- package/dist/core/renderer/formats/sprite.js +0 -24
- package/dist/core/renderer/formats/video.d.ts +0 -8
- package/dist/core/renderer/formats/video.js +0 -51
- package/dist/core/renderer/index.d.ts +0 -7
- package/dist/core/renderer/index.js +0 -9
- package/dist/core/renderer/types.d.ts +0 -87
- package/dist/core/renderer/types.js +0 -13
- package/dist/core/scene/Scene.d.ts +0 -104
- package/dist/core/scene/Scene.js +0 -225
- package/dist/core/scene/index.d.ts +0 -2
- package/dist/core/scene/index.js +0 -1
- package/dist/core/scene/types.d.ts +0 -23
- package/dist/core/scene/types.js +0 -0
- package/dist/core/serialization/animation.d.ts +0 -23
- package/dist/core/serialization/animation.js +0 -176
- package/dist/core/serialization/easingLookup.d.ts +0 -13
- package/dist/core/serialization/easingLookup.js +0 -65
- package/dist/core/serialization/index.d.ts +0 -23
- package/dist/core/serialization/index.js +0 -29
- package/dist/core/serialization/mobject.d.ts +0 -23
- package/dist/core/serialization/mobject.js +0 -248
- package/dist/core/serialization/prettyPrint.d.ts +0 -12
- package/dist/core/serialization/prettyPrint.js +0 -16
- package/dist/core/serialization/primitives.d.ts +0 -24
- package/dist/core/serialization/primitives.js +0 -98
- package/dist/core/serialization/registry.d.ts +0 -29
- package/dist/core/serialization/registry.js +0 -39
- package/dist/core/serialization/scene.d.ts +0 -28
- package/dist/core/serialization/scene.js +0 -114
- package/dist/core/serialization/types.d.ts +0 -152
- package/dist/core/serialization/types.js +0 -6
- package/dist/core/timeline/Timeline.d.ts +0 -70
- package/dist/core/timeline/Timeline.js +0 -144
- package/dist/core/timeline/index.d.ts +0 -5
- package/dist/core/timeline/index.js +0 -4
- package/dist/core/timeline/types.d.ts +0 -29
- package/dist/core/timeline/types.js +0 -0
- package/dist/mobjects/Mobject.d.ts +0 -98
- package/dist/mobjects/Mobject.js +0 -343
- package/dist/mobjects/VGroup/VGroup.d.ts +0 -51
- package/dist/mobjects/VGroup/VGroup.js +0 -142
- package/dist/mobjects/VGroup/index.d.ts +0 -3
- package/dist/mobjects/VGroup/index.js +0 -2
- package/dist/mobjects/VGroup/layout.d.ts +0 -20
- package/dist/mobjects/VGroup/layout.js +0 -139
- package/dist/mobjects/VMobject.d.ts +0 -106
- package/dist/mobjects/VMobject.js +0 -216
- package/dist/mobjects/geometry/Arc.d.ts +0 -8
- package/dist/mobjects/geometry/Arc.js +0 -46
- package/dist/mobjects/geometry/Arrow.d.ts +0 -7
- package/dist/mobjects/geometry/Arrow.js +0 -34
- package/dist/mobjects/geometry/Circle.d.ts +0 -4
- package/dist/mobjects/geometry/Circle.js +0 -10
- package/dist/mobjects/geometry/Line.d.ts +0 -8
- package/dist/mobjects/geometry/Line.js +0 -19
- package/dist/mobjects/geometry/Point.d.ts +0 -5
- package/dist/mobjects/geometry/Point.js +0 -11
- package/dist/mobjects/geometry/Polygon.d.ts +0 -7
- package/dist/mobjects/geometry/Polygon.js +0 -21
- package/dist/mobjects/geometry/Rectangle.d.ts +0 -6
- package/dist/mobjects/geometry/Rectangle.js +0 -18
- package/dist/mobjects/geometry/index.d.ts +0 -7
- package/dist/mobjects/geometry/index.js +0 -7
- package/dist/mobjects/graph/Graph.d.ts +0 -28
- package/dist/mobjects/graph/Graph.js +0 -119
- package/dist/mobjects/graph/GraphEdge.d.ts +0 -26
- package/dist/mobjects/graph/GraphEdge.js +0 -64
- package/dist/mobjects/graph/GraphNode.d.ts +0 -19
- package/dist/mobjects/graph/GraphNode.js +0 -63
- package/dist/mobjects/graph/index.d.ts +0 -5
- package/dist/mobjects/graph/index.js +0 -5
- package/dist/mobjects/graph/layouts/circular.d.ts +0 -8
- package/dist/mobjects/graph/layouts/circular.js +0 -23
- package/dist/mobjects/graph/layouts/forceDirected.d.ts +0 -9
- package/dist/mobjects/graph/layouts/forceDirected.js +0 -102
- package/dist/mobjects/graph/layouts/index.d.ts +0 -3
- package/dist/mobjects/graph/layouts/index.js +0 -3
- package/dist/mobjects/graph/layouts/tree.d.ts +0 -9
- package/dist/mobjects/graph/layouts/tree.js +0 -99
- package/dist/mobjects/graph/types.d.ts +0 -35
- package/dist/mobjects/graph/types.js +0 -0
- package/dist/mobjects/index.d.ts +0 -6
- package/dist/mobjects/index.js +0 -6
- package/dist/mobjects/text/Glyph.d.ts +0 -11
- package/dist/mobjects/text/Glyph.js +0 -72
- package/dist/mobjects/text/Text.d.ts +0 -19
- package/dist/mobjects/text/Text.js +0 -76
- package/dist/mobjects/text/index.d.ts +0 -4
- package/dist/mobjects/text/index.js +0 -3
- package/dist/mobjects/text/types.d.ts +0 -12
- package/dist/mobjects/text/types.js +0 -8
package/dist/cli/index.js
CHANGED
|
@@ -1,63 +1,209 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli/index.ts
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
|
|
6
|
+
// src/cli/SceneLoader.ts
|
|
7
|
+
import { Scene } from "@redwilly/anima";
|
|
8
|
+
import { pathToFileURL } from "url";
|
|
9
|
+
import { resolve } from "path";
|
|
10
|
+
var SceneLoader = class {
|
|
11
|
+
/**
|
|
12
|
+
* Loads all scenes from the specified file.
|
|
13
|
+
*
|
|
14
|
+
* @param filePath Path to the TypeScript file containing scenes
|
|
15
|
+
* @returns Loaded scenes and any error
|
|
16
|
+
*/
|
|
17
|
+
async load(filePath) {
|
|
18
|
+
const absolutePath = resolve(filePath);
|
|
19
|
+
const fileUrl = pathToFileURL(absolutePath).href;
|
|
20
|
+
try {
|
|
21
|
+
const module = await import(fileUrl);
|
|
22
|
+
const scenes = /* @__PURE__ */ new Map();
|
|
23
|
+
for (const [name, exportValue] of Object.entries(module)) {
|
|
24
|
+
if (typeof exportValue === "function" && exportValue.prototype instanceof Scene) {
|
|
25
|
+
try {
|
|
26
|
+
const SceneClass = exportValue;
|
|
27
|
+
const instance = new SceneClass();
|
|
28
|
+
scenes.set(name, instance);
|
|
29
|
+
} catch (err) {
|
|
30
|
+
console.warn(`Failed to instantiate scene '${name}':`, err);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (scenes.size === 0) {
|
|
35
|
+
return { scenes, error: "No Scene subclasses found in file." };
|
|
36
|
+
}
|
|
37
|
+
return { scenes };
|
|
38
|
+
} catch (err) {
|
|
39
|
+
return {
|
|
40
|
+
scenes: /* @__PURE__ */ new Map(),
|
|
41
|
+
error: `Failed to load file: ${err instanceof Error ? err.message : String(err)}`
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// src/cli/commands/list-scenes.ts
|
|
48
|
+
import { resolve as resolve2 } from "path";
|
|
49
|
+
async function listScenes(file) {
|
|
50
|
+
const loader = new SceneLoader();
|
|
51
|
+
const { scenes, error } = await loader.load(file);
|
|
52
|
+
if (error) {
|
|
53
|
+
console.error(`Error: ${error}`);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
if (scenes.size === 0) {
|
|
57
|
+
console.log("No scenes found in this file.");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
console.log(`Found ${scenes.size} scene(s) in '${resolve2(file)}':`);
|
|
61
|
+
for (const name of scenes.keys()) {
|
|
62
|
+
console.log(` - ${name}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/cli/commands/render.ts
|
|
67
|
+
import { Renderer, Resolution } from "@redwilly/anima";
|
|
68
|
+
async function render(file, options) {
|
|
69
|
+
const loader = new SceneLoader();
|
|
70
|
+
const { scenes, error } = await loader.load(file);
|
|
71
|
+
if (error) {
|
|
72
|
+
console.error(`Error: ${error}`);
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
let scene;
|
|
76
|
+
if (options.scene) {
|
|
77
|
+
const found = scenes.get(options.scene);
|
|
78
|
+
if (!found) {
|
|
79
|
+
console.error(`Error: Scene '${options.scene}' not found in file.`);
|
|
80
|
+
console.log("Available scenes:");
|
|
81
|
+
for (const name of scenes.keys()) {
|
|
82
|
+
console.log(` - ${name}`);
|
|
83
|
+
}
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
scene = found;
|
|
87
|
+
} else {
|
|
88
|
+
if (scenes.size === 1) {
|
|
89
|
+
scene = scenes.values().next().value;
|
|
90
|
+
} else {
|
|
91
|
+
console.error("Error: Multiple scenes found in file. Please specify one with --scene.");
|
|
92
|
+
for (const name of scenes.keys()) {
|
|
93
|
+
console.log(` - ${name}`);
|
|
94
|
+
}
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (!scene) {
|
|
99
|
+
console.error("Error: No scene found to render.");
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
const renderer = new Renderer();
|
|
103
|
+
const outputPath = options.output ?? `output.${options.format ?? "mp4"}`;
|
|
104
|
+
let width = scene.getWidth();
|
|
105
|
+
let height = scene.getHeight();
|
|
106
|
+
if (options.resolution) {
|
|
107
|
+
const presetKey = `p${options.resolution}`;
|
|
108
|
+
const preset = Resolution[presetKey];
|
|
109
|
+
if (preset) {
|
|
110
|
+
width = preset.width;
|
|
111
|
+
height = preset.height;
|
|
112
|
+
} else {
|
|
113
|
+
console.warn(`Warning: Resolution preset '${options.resolution}' not found. Using scene defaults.`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
console.log(`Rendering scene to '${outputPath}'...`);
|
|
117
|
+
await renderer.render(scene, outputPath, {
|
|
118
|
+
width,
|
|
119
|
+
height,
|
|
120
|
+
frameRate: options.fps ? parseInt(options.fps, 10) : void 0,
|
|
121
|
+
format: options.format,
|
|
122
|
+
quality: options.quality,
|
|
123
|
+
onProgress: (progress) => {
|
|
124
|
+
const percent = progress.percentage.toFixed(1);
|
|
125
|
+
const eta = (progress.estimatedRemainingMs / 1e3).toFixed(1);
|
|
126
|
+
process.stdout.write(`\rProgress: ${percent}% | ETA: ${eta}s `);
|
|
127
|
+
if (progress.percentage === 100) {
|
|
128
|
+
process.stdout.write("\n");
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
console.log("Rendering complete.");
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// src/cli/commands/preview.ts
|
|
136
|
+
async function preview(file, options) {
|
|
137
|
+
await render(file, {
|
|
138
|
+
...options,
|
|
139
|
+
quality: "preview"
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// src/cli/commands/export-frame.ts
|
|
144
|
+
import { Renderer as Renderer2 } from "@redwilly/anima";
|
|
145
|
+
async function exportFrame(file, options) {
|
|
146
|
+
const loader = new SceneLoader();
|
|
147
|
+
const { scenes, error } = await loader.load(file);
|
|
148
|
+
if (error) {
|
|
149
|
+
console.error(`Error: ${error}`);
|
|
150
|
+
process.exit(1);
|
|
151
|
+
}
|
|
152
|
+
let scene;
|
|
153
|
+
if (options.scene) {
|
|
154
|
+
scene = scenes.get(options.scene);
|
|
155
|
+
if (!scene) {
|
|
156
|
+
console.error(`Error: Scene '${options.scene}' not found.`);
|
|
157
|
+
process.exit(1);
|
|
158
|
+
}
|
|
159
|
+
} else if (scenes.size === 1) {
|
|
160
|
+
scene = scenes.values().next().value;
|
|
161
|
+
} else {
|
|
162
|
+
console.error("Error: Multiple scenes found in file. Please specify one with --scene.");
|
|
163
|
+
process.exit(1);
|
|
164
|
+
}
|
|
165
|
+
if (!scene) {
|
|
166
|
+
console.error("Error: No scene found.");
|
|
167
|
+
process.exit(1);
|
|
168
|
+
}
|
|
169
|
+
const renderer = new Renderer2();
|
|
170
|
+
const totalDuration = scene.getTotalDuration();
|
|
171
|
+
const frameRate = scene.getFrameRate();
|
|
172
|
+
let time;
|
|
173
|
+
if (options.frame === "last") {
|
|
174
|
+
time = totalDuration;
|
|
175
|
+
} else {
|
|
176
|
+
const frameIndex = parseInt(options.frame, 10);
|
|
177
|
+
time = frameIndex / frameRate;
|
|
178
|
+
}
|
|
179
|
+
const outputPath = options.output ?? `frame_${options.frame}.png`;
|
|
180
|
+
console.log(`Exporting frame ${options.frame} to '${outputPath}'...`);
|
|
181
|
+
if (options.frame === "last") {
|
|
182
|
+
await renderer.renderLastFrame(scene, outputPath);
|
|
183
|
+
} else {
|
|
184
|
+
await renderer.renderLastFrame(scene, outputPath);
|
|
185
|
+
}
|
|
186
|
+
console.log("Export complete.");
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// src/cli/index.ts
|
|
190
|
+
var program = new Command();
|
|
191
|
+
program.name("anima").description("CLI for Anima animation engine").version("0.1.0");
|
|
192
|
+
program.option("-d, --debug", "output extra debugging");
|
|
193
|
+
program.command("list-scenes").description("List all scenes in a file").argument("<file>", "TypeScript file to load").action(async (file) => {
|
|
194
|
+
await listScenes(file);
|
|
21
195
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
.command('render')
|
|
25
|
-
.description('Render a scene from a file')
|
|
26
|
-
.argument('<file>', 'TypeScript file to load')
|
|
27
|
-
.option('-s, --scene <name>', 'Specific scene to render')
|
|
28
|
-
.option('-f, --format <type>', 'Output format (mp4, webp, gif, sprite, png)', 'mp4')
|
|
29
|
-
.option('-r, --resolution <preset>', 'Resolution preset (480, 720, 1080, 4K)')
|
|
30
|
-
.option('--fps <number>', 'Frames per second')
|
|
31
|
-
.option('-q, --quality <level>', 'Render quality (production, preview)', 'production')
|
|
32
|
-
.option('-o, --output <path>', 'Output file path')
|
|
33
|
-
.action(async (file, options) => {
|
|
34
|
-
await render(file, options);
|
|
196
|
+
program.command("render").description("Render a scene from a file").argument("<file>", "TypeScript file to load").option("-s, --scene <name>", "Specific scene to render").option("-f, --format <type>", "Output format (mp4, webp, gif, sprite, png)", "mp4").option("-r, --resolution <preset>", "Resolution preset (480, 720, 1080, 4K)").option("--fps <number>", "Frames per second").option("-q, --quality <level>", "Render quality (production, preview)", "production").option("-o, --output <path>", "Output file path").action(async (file, options) => {
|
|
197
|
+
await render(file, options);
|
|
35
198
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
.command('preview')
|
|
39
|
-
.description('Quickly preview a scene (lower quality)')
|
|
40
|
-
.argument('<file>', 'TypeScript file to load')
|
|
41
|
-
.option('-s, --scene <name>', 'Specific scene to preview')
|
|
42
|
-
.option('-f, --format <type>', 'Output format', 'mp4')
|
|
43
|
-
.option('-o, --output <path>', 'Output file path')
|
|
44
|
-
.action(async (file, options) => {
|
|
45
|
-
await preview(file, options);
|
|
199
|
+
program.command("preview").description("Quickly preview a scene (lower quality)").argument("<file>", "TypeScript file to load").option("-s, --scene <name>", "Specific scene to preview").option("-f, --format <type>", "Output format", "mp4").option("-o, --output <path>", "Output file path").action(async (file, options) => {
|
|
200
|
+
await preview(file, options);
|
|
46
201
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
.command('export-frame')
|
|
50
|
-
.description('Export a single frame as PNG')
|
|
51
|
-
.argument('<file>', 'TypeScript file to load')
|
|
52
|
-
.option('-s, --scene <name>', 'Specific scene')
|
|
53
|
-
.option('--frame <number|last>', 'Frame number or "last"', 'last')
|
|
54
|
-
.option('-o, --output <path>', 'Output file path')
|
|
55
|
-
.action(async (file, options) => {
|
|
56
|
-
await exportFrame(file, options);
|
|
202
|
+
program.command("export-frame").description("Export a single frame as PNG").argument("<file>", "TypeScript file to load").option("-s, --scene <name>", "Specific scene").option("--frame <number|last>", 'Frame number or "last"', "last").option("-o, --output <path>", "Output file path").action(async (file, options) => {
|
|
203
|
+
await exportFrame(file, options);
|
|
57
204
|
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
process.exit(1);
|
|
205
|
+
program.on("command:*", () => {
|
|
206
|
+
console.error("Invalid command: %s\nSee --help for a list of available commands.", program.args.join(" "));
|
|
207
|
+
process.exit(1);
|
|
62
208
|
});
|
|
63
209
|
program.parse(process.argv);
|