Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

WorldCast: cases name the person's sides by where the camera stands, with cameras, anchors and the run's fixed settings

Claudefa6ea7b8679c
diff --git a/src/lib/catalog/turnaround.ts b/src/lib/catalog/turnaround.ts
index 69c2dadb..60814175 100644
--- a/src/lib/catalog/turnaround.ts
+++ b/src/lib/catalog/turnaround.ts
@@ -57,23 +57,32 @@ export function pathAzimuth(side: TurnSide): number {
}
/**
- * WorldCast's convention, for N7-9 (new-models-7.md §3.4, §3.11): its 1–4 anchor photos are named front, right_side, back and
- * left_side, with each one's azimuth in body_views_meta.json. Its demo case puts them at 0°, 91.79°, 171.39° and 266.91°, with
- * `left_sign` −1 (the left side is reached turning the other way: −93°, the same place as 267°). That is viewAzimuth's turn:
- * a side keeps its name and sits within a few degrees of the angle here. Convert in worldcastAnchor and nowhere else; a
- * swapped left and right silently hurts identity.
+ * WorldCast's convention (N7-9; new-models-7.md §3.4, §3.11): its 1–4 anchor photos are named front, right_side, back and
+ * left_side, with each one's azimuth in body_views_meta.json. The names are WHERE THE CAMERA STANDS, not the body's own sides:
+ * the demo case's aligned cameras (no_padding_black/anchors_aligned_camera_info.json) put right_side at +x of the first camera
+ * (moved round to the camera's own right, 91.79°) and left_side at −x (266.91°, `left_sign` −1: reached turning the other
+ * way, −93°), and its "right_side" crop shows the boy facing the lens because the first frame shows him in profile. So
+ * WorldCast's azimuth is the camera-path library's (+ = moved round to the right), and a person's own right side, seen from
+ * the camera moved round to its LEFT (pathAzimuth −90°), is WorldCast's left_side. Convert in worldcastAnchor and nowhere
+ * else; a swapped left and right silently hurts identity.
*/
export const WORLDCAST = {
- anchor: { front: "front", right: "right_side", back: "back", left: "left_side" } as const satisfies Record<TurnSide, string>,
+ anchor: { front: "front", right: "left_side", back: "back", left: "right_side" } as const satisfies Record<TurnSide, string>,
/** The demo case's azimuths (demo_case/A360-031__portrait/body_views_vggt/body_views_meta.json). */
demoAzimuth: { front: 0, right_side: 91.79, back: 171.39, left_side: 266.91 },
leftSign: -1 as const,
};
-/** A side as a WorldCast anchor: its name and the azimuth to write for it (left_side signed by `left_sign`: −90°). */
-export function worldcastAnchor(side: TurnSide): { name: (typeof WORLDCAST.anchor)[TurnSide]; azimuth: number; signed: number } {
- const azimuth = viewAzimuth(side);
- return { name: WORLDCAST.anchor[side], azimuth, signed: side === "left" ? WORLDCAST.leftSign * (360 - azimuth) : azimuth };
+export type WorldcastView = (typeof WORLDCAST.anchor)[TurnSide];
+
+/**
+ * A side as a WorldCast anchor: its name, the azimuth to write for it (0–360, + = the camera moved round to its right) and
+ * the signed one (left_side by `left_sign`: −90°), which is also where camera-path keyPose puts its camera.
+ */
+export function worldcastAnchor(side: TurnSide): { name: WorldcastView; azimuth: number; signed: number } {
+ const name = WORLDCAST.anchor[side];
+ const azimuth = (((pathAzimuth(side) % 360) + 360) % 360) + 0;
+ return { name, azimuth, signed: name === "left_side" ? WORLDCAST.leftSign * (360 - azimuth) : azimuth };
}
/**
diff --git a/src/lib/worldcast.ts b/src/lib/worldcast.ts
new file mode 100644
index 00000000..34ddc65a
--- /dev/null
+++ b/src/lib/worldcast.ts
@@ -0,0 +1,231 @@
+/**
+ * WorldCast cases (build plan N7-9; research new-models-7.md §3.1-§3.6, §3.11; the worker contract in docs/workers/worldcast.md).
+ *
+ * WorldCast (PixCtrol, Apache-2.0) films a still along a camera path while the back and sides follow up to four reference
+ * views of the subject. It has no ComfyUI port: it runs as a worker on the user's GPU, and Fuobe prepares each case for it:
+ *
+ * - the still, centre-cropped to the model's portrait 480 × 832, and its person mask (SAM 3.1);
+ * - the path: 81 camera-to-world poses in OpenCV axes and a pixel intrinsic (cam_info.json), from the camera-path library's
+ * keys (framePoses), and the point-cloud render along it with its hole mask (render.mp4 / render_mask.mp4, 0 = covered,
+ * 255 = a hole), drawn from the still's depth (MoGe 2) the way the Uni3C path render is;
+ * - the anchors: the views with their names and azimuths in WorldCast's convention (worldcastAnchor, src/lib/catalog/turnaround.ts),
+ * each with its person mask, and their cameras on a ring at the subject's distance (anchors_aligned_camera_info.json,
+ * world-to-camera, a guess: the paper aligns real cameras with VGGT-Omega).
+ *
+ * Pure: matrices, names, sizes and the multipart's parts. The pixels are made on the server (src/server/worldcast-case.ts).
+ */
+
+import { cropFov, keyPose, type FramePoses, type Mat3, type Mat4 } from "./camera-path";
+import { worldcastAnchor, type TurnSide, type WorldcastView } from "./catalog/turnaround";
+
+/** What the released checkpoint was trained on and the demo runs with (demo.py): fixed, except the seed and the prompt. */
+export const WORLDCAST_RUN = { frames: 81, fps: 15, width: 480, height: 832, steps: 50, cfg: 5, shift: 2, maxAnchors: 4 } as const;
+
+/** The anchors' order in body_views_meta.json's selected_views (and the RoPE slots 25 / 30 / 35 / 40 they take). */
+export const WORLDCAST_VIEWS: readonly WorldcastView[] = ["front", "left_side", "right_side", "back"];
+
+/** A WorldCast anchor: the person's own side it shows, the name WorldCast gives that camera, and its azimuth (0–360). */
+export interface WorldcastAnchor {
+ side: TurnSide;
+ view: WorldcastView;
+ azimuth: number;
+}
+
+/** Where a run's anchors are, stored with the request (params.extra.worldcast) so the provider can read its pictures back. */
+export interface WorldcastLayout {
+ anchors: WorldcastAnchor[];
+}
+
+/** The anchors for these sides: one per side, at most four, in WorldCast's own order. */
+export function worldcastLayout(sides: readonly TurnSide[]): WorldcastLayout {
+ const seen = new Set<WorldcastView>();
+ const anchors: WorldcastAnchor[] = [];
+ for (const side of sides) {
+ const a = worldcastAnchor(side);
+ if (seen.has(a.name)) continue;
+ seen.add(a.name);
+ anchors.push({ side, view: a.name, azimuth: a.azimuth });
+ }
+ anchors.sort((a, b) => WORLDCAST_VIEWS.indexOf(a.view) - WORLDCAST_VIEWS.indexOf(b.view));
+ return { anchors: anchors.slice(0, WORLDCAST_RUN.maxAnchors) };
+}
+
+/** A layout read back from a stored request: only known views, each once, at most four. */
+export function readLayout(v: unknown): WorldcastLayout {
+ const list = (v as { anchors?: unknown } | null)?.anchors;
+ if (!Array.isArray(list)) return { anchors: [] };
+ const sides = list.flatMap((a) => (a && typeof a === "object" && ["front", "right", "back", "left"].includes((a as { side?: string }).side ?? "") ? [(a as { side: TurnSide }).side] : []));
+ return worldcastLayout(sides);
+}
+
+/**
+ * Where each picture sits in the step's images: the still, the anchors, the still's mask, the anchors' masks, then the
+ * still's depth picture (MoGe 2's), which the chain hands in last.
+ */
+export function imageSlots(layout: WorldcastLayout) {
+ const n = layout.anchors.length;
+ return { still: 0, anchor: (i: number) => 1 + i, stillMask: 1 + n, anchorMask: (i: number) => 2 + n + i, depth: 2 + 2 * n, total: 3 + 2 * n };
+}
+
+/** The part of a `width` × `height` picture the model keeps: the largest 480:832 rectangle at its centre. */
+export function worldcastCrop(width: number, height: number): { left: number; top: number; width: number; height: number } {
+ const want = WORLDCAST_RUN.width / WORLDCAST_RUN.height;
+ if (width / height > want) {
+ const w = Math.max(1, Math.round(height * want));
+ return { left: Math.floor((width - w) / 2), top: 0, width: w, height };
+ }
+ const h = Math.max(1, Math.round(width / want));
+ return { left: 0, top: Math.floor((height - h) / 2), width, height: h };
+}
+
+/** The horizontal field of view of that crop, for a photo whose own is `photoHFov`. */
+export function worldcastFov(photoHFov: number, photoAspect: number): number {
+ return cropFov(photoHFov, photoAspect, WORLDCAST_RUN.width / WORLDCAST_RUN.height);
+}
+
+const r6 = (n: number) => Number(n.toFixed(6)) + 0;
+
+/** The inverse of a rigid camera-to-world matrix (R | t): (Rᵀ | −Rᵀt). */
+export function invertRigid(m: Mat4): Mat4 {
+ const R = [0, 1, 2].map((r) => [m[r][0], m[r][1], m[r][2]]);
+ const t = [m[0][3], m[1][3], m[2][3]];
+ const out: Mat4 = [0, 1, 2].map((r) => {
+ const row = [R[0][r], R[1][r], R[2][r]];
+ return [...row, -(row[0] * t[0] + row[1] * t[1] + row[2] * t[2])].map(r6);
+ });
+ out.push([0, 0, 0, 1]);
+ return out;
+}
+
+/** cam_info.json: the path's camera-to-world poses as the pipeline reads them ("as stored", c2w; --invert_camera_extrinsic off). */
+export interface CamInfo {
+ width: number;
+ height: number;
+ num_frames: number;
+ intrinsic: Mat3;
+ extrinsic: Mat4[];
+ extrinsic_convention: string;
+ source: string;
+ alignment: { method: string; scale: number };
+}
+
+export function camInfo(path: FramePoses): CamInfo {
+ return {
+ width: path.width,
+ height: path.height,
+ num_frames: path.poses.length,
+ intrinsic: path.intrinsic,
+ extrinsic: path.poses,
+ extrinsic_convention: "c2w, OpenCV (x right, y down, z forward); the world is the first frame's camera",
+ source: "fuobe_camera_path",
+ alignment: { method: "fuobe_moge_depth", scale: 1 },
+ };
+}
+
+/**
+ * anchors_aligned_camera_info.json: a world-to-camera pose for the first frame and each anchor, in cam_info's world, matched
+ * by name ("first_frame", "front", …). Fuobe has no pose estimator for the views, so each anchor camera sits on a level ring
+ * at the subject's distance at its azimuth, looking at the subject (the research's guess; the paper aligns real cameras).
+ */
+export function alignedAnchors(layout: WorldcastLayout, path: FramePoses, pivotDepth: number) {
+ const views = ["first_frame", ...layout.anchors.map((a) => a.view)];
+ const poses = [path.poses[0], ...layout.anchors.map((a) => keyPose({ t: 0, azimuth: a.azimuth > 180 ? a.azimuth - 360 : a.azimuth, elevation: 0, distance: 1 }, pivotDepth))];
+ return {
+ width: path.width,
+ height: path.height,
+ intrinsic: path.intrinsic,
+ views,
+ extrinsic: poses.map(invertRigid),
+ extrinsic_convention: "w2c in cam_info's world frame (inverse of c2w)",
+ source: "fuobe_ring",
+ view_provenance: Object.fromEntries([["first_frame", { branch: "path" }], ...layout.anchors.map((a) => [a.view, { branch: "ring", azimuth_deg: a.azimuth, side: a.side }])]),
+ };
+}
+
+/** body_views_meta.json's fields the worker writes beside the anchors (selected_views in WorldCast's order, left_sign −1). */
+export function anchorsMeta(layout: WorldcastLayout) {
+ return {
+ az_front_deg: 0,
+ left_sign: -1,
+ selected_views: layout.anchors.map((a) => a.view),
+ per_view: Object.fromEntries(layout.anchors.map((a) => [a.view, { azimuth_deg: a.azimuth }])),
+ };
+}
+
+/** The anchors field of POST /cases: each anchor's view, azimuth and the names of its two files in the form. */
+export function anchorsField(layout: WorldcastLayout) {
+ return layout.anchors.map((a) => ({ side: a.view, azimuth: a.azimuth, image: `anchor_${a.view}.png`, mask: `anchor_${a.view}_mask.png` }));
+}
+
+export interface CaseFiles {
+ firstFrame: Uint8Array;
+ personMask: Uint8Array;
+ render: Uint8Array;
+ renderMask: Uint8Array;
+ anchors: { image: Uint8Array; mask: Uint8Array }[];
+}
+
+export interface CaseOptions {
+ prompt: string;
+ seed: number;
+ /** Leave anchors_aligned_camera_info.json out (WorldCast then skips the anchors' Plücker rays). */
+ noAlignedCameras?: boolean;
+ pivotDepth: number;
+}
+
+export type CasePart = { name: string; value: string } | { name: string; filename: string; contentType: string; data: Uint8Array };
+
+/** Everything POST /cases sends, in order (docs/workers/worldcast.md). */
+export function caseParts(layout: WorldcastLayout, path: FramePoses, files: CaseFiles, o: CaseOptions): CasePart[] {
+ const problem = caseProblem(layout, path, files);
+ if (problem) throw new Error(problem);
+ const json = (name: string, v: unknown): CasePart => ({ name, filename: name, contentType: "application/json", data: new TextEncoder().encode(JSON.stringify(v)) });
+ const parts: CasePart[] = [
+ { name: "first_frame.png", filename: "first_frame.png", contentType: "image/png", data: files.firstFrame },
+ { name: "person_mask.png", filename: "person_mask.png", contentType: "image/png", data: files.personMask },
+ { name: "render.mp4", filename: "render.mp4", contentType: "video/mp4", data: files.render },
+ { name: "render_mask.mp4", filename: "render_mask.mp4", contentType: "video/mp4", data: files.renderMask },
+ json("cam_info.json", camInfo(path)),
+ { name: "anchors", value: JSON.stringify(anchorsField(layout)) },
+ ];
+ layout.anchors.forEach((a, i) => {
+ parts.push({ name: `anchor_${a.view}.png`, filename: `anchor_${a.view}.png`, contentType: "image/png", data: files.anchors[i].image });
+ parts.push({ name: `anchor_${a.view}_mask.png`, filename: `anchor_${a.view}_mask.png`, contentType: "image/png", data: files.anchors[i].mask });
+ });
+ if (layout.anchors.length && !o.noAlignedCameras) parts.push(json("anchors_aligned_camera_info.json", alignedAnchors(layout, path, o.pivotDepth)));
+ const r = WORLDCAST_RUN;
+ parts.push(
+ { name: "prompt", value: o.prompt },
+ { name: "seed", value: String(o.seed) },
+ { name: "steps", value: String(r.steps) },
+ { name: "cfg", value: String(r.cfg) },
+ { name: "shift", value: String(r.shift) },
+ { name: "height", value: String(r.height) },
+ { name: "width", value: String(r.width) },
+ );
+ return parts;
+}
+
+const near = (a: number, b: number, eps = 1e-3) => Math.abs(a - b) <= eps;
+
+/** What is wrong with a case before it is sent, or null. */
+export function caseProblem(layout: WorldcastLayout, path: FramePoses, files: CaseFiles): string | null {
+ if (path.poses.length !== WORLDCAST_RUN.frames) return `WorldCast takes ${WORLDCAST_RUN.frames} camera poses, not ${path.poses.length}`;
+ if (path.width !== WORLDCAST_RUN.width || path.height !== WORLDCAST_RUN.height) return `WorldCast films ${WORLDCAST_RUN.width} × ${WORLDCAST_RUN.height}`;
+ for (const m of path.poses) {
+ if (m.length !== 4 || m.some((row) => row.length !== 4 || row.some((v) => !Number.isFinite(v)))) return "A camera pose isn't a 4 × 4 matrix";
+ if (!(near(m[3][0], 0) && near(m[3][1], 0) && near(m[3][2], 0) && near(m[3][3], 1))) return "A camera pose isn't rigid";
+ const c = [0, 1, 2].map((j) => [m[0][j], m[1][j], m[2][j]]);
+ for (let a = 0; a < 3; a++)
+ for (let b = 0; b < 3; b++) {
+ const dot = c[a][0] * c[b][0] + c[a][1] * c[b][1] + c[a][2] * c[b][2];
+ if (!near(dot, a === b ? 1 : 0)) return "A camera pose isn't a rotation";
+ }
+ }
+ const k = path.intrinsic;
+ if (k.length !== 3 || !(k[0][0] > 0 && k[1][1] > 0) || !near(k[2][2], 1)) return "The camera intrinsic isn't a pixel intrinsic";
+ if (layout.anchors.length > WORLDCAST_RUN.maxAnchors) return `WorldCast takes up to ${WORLDCAST_RUN.maxAnchors} views`;
+ if (files.anchors.length !== layout.anchors.length) return "Each view needs its picture and its mask";
+ if (!files.firstFrame.length || !files.personMask.length || !files.render.length || !files.renderMask.length) return "The case is missing a file";
+ return null;
+}
diff --git a/tests/turnaround.test.ts b/tests/turnaround.test.ts
index 11a3827c..972b8a78 100644
--- a/tests/turnaround.test.ts
+++ b/tests/turnaround.test.ts
@@ -54,14 +54,17 @@ describe("views", () => {
expect(keys.map((k) => [k.t, k.azimuth])).toEqual(TURN_FRAMES.map((f) => [f.t, f.t === 1 ? -360 : pathAzimuth(f.side)]));
});
- it("writes WorldCast's convention down for N7-9: its side names, its demo angles, left_sign −1", () => {
+ it("names WorldCast's anchors by where the camera stands: the person's right side is its left_side, left_sign −1", () => {
for (const s of TURN_SIDES) {
const a = worldcastAnchor(s);
expect(a.name).toBe(WORLDCAST.anchor[s]);
// Each demo anchor sits within 10° of the side's angle here.
- expect(Math.abs(WORLDCAST.demoAzimuth[a.name] - viewAzimuth(s))).toBeLessThan(10);
+ expect(Math.abs(WORLDCAST.demoAzimuth[a.name] - a.azimuth)).toBeLessThan(10);
}
- expect(worldcastAnchor("left")).toEqual({ name: "left_side", azimuth: 270, signed: -90 });
+ expect(worldcastAnchor("right")).toEqual({ name: "left_side", azimuth: 270, signed: -90 });
+ expect(worldcastAnchor("left")).toEqual({ name: "right_side", azimuth: 90, signed: 90 });
+ expect(worldcastAnchor("back")).toEqual({ name: "back", azimuth: 180, signed: 180 });
+ expect(worldcastAnchor("front")).toEqual({ name: "front", azimuth: 0, signed: 0 });
expect(WORLDCAST.leftSign).toBe(-1);
});
diff --git a/tests/worldcast-case.test.ts b/tests/worldcast-case.test.ts
new file mode 100644
index 00000000..00d180dd
--- /dev/null
+++ b/tests/worldcast-case.test.ts
@@ -0,0 +1,112 @@
+import { describe, expect, it } from "vitest";
+import { framePoses, presetKeys } from "@/lib/camera-path";
+import { WORLDCAST_RUN, WORLDCAST_VIEWS, alignedAnchors, anchorsField, anchorsMeta, camInfo, caseParts, caseProblem, imageSlots, invertRigid, readLayout, worldcastCrop, worldcastFov, worldcastLayout } from "@/lib/worldcast";
+
+const path = framePoses(presetKeys("orbit_360_cw")!, WORLDCAST_RUN.frames, 2, 40, { width: WORLDCAST_RUN.width, height: WORLDCAST_RUN.height });
+const bytes = (n = 4) => new Uint8Array(n).fill(1);
+const mul = (a: number[][], b: number[][]) => a.map((row) => b[0].map((_, j) => row.reduce((s, v, k) => s + v * b[k][j], 0)));
+
+describe("a WorldCast case", () => {
+ it("names the person's sides by where the camera stands, in WorldCast's order", () => {
+ const l = worldcastLayout(["right", "front", "left", "back", "right"]);
+ expect(l.anchors.map((a) => a.view)).toEqual(WORLDCAST_VIEWS);
+ expect(l.anchors.map((a) => [a.side, a.azimuth])).toEqual([
+ ["front", 0],
+ ["right", 270],
+ ["left", 90],
+ ["back", 180],
+ ]);
+ expect(readLayout({ anchors: [{ side: "back" }, { side: "nope" }, { side: "back" }] }).anchors).toEqual([{ side: "back", view: "back", azimuth: 180 }]);
+ expect(readLayout(null).anchors).toEqual([]);
+ });
+
+ it("keeps the pictures in fixed places: still, anchors, masks, then the depth", () => {
+ const s = imageSlots(worldcastLayout(["front", "back"]));
+ expect([s.still, s.anchor(0), s.anchor(1), s.stillMask, s.anchorMask(0), s.anchorMask(1), s.depth, s.total]).toEqual([0, 1, 2, 3, 4, 5, 6, 7]);
+ });
+
+ it("crops to the model's portrait 480 × 832 at the centre, and narrows the field of view with it", () => {
+ expect(worldcastCrop(1920, 1080)).toEqual({ left: 648, top: 0, width: 623, height: 1080 });
+ expect(worldcastCrop(480, 1000)).toEqual({ left: 0, top: 84, width: 480, height: 832 });
+ expect(worldcastFov(60, 1080 / 1920)).toBe(60);
+ expect(worldcastFov(60, 16 / 9)).toBeLessThan(25);
+ });
+
+ it("writes cam_info.json as 81 camera-to-world poses in OpenCV axes with the frame's pixel intrinsic", () => {
+ const c = camInfo(path);
+ expect(c.num_frames).toBe(81);
+ expect([c.width, c.height]).toEqual([480, 832]);
+ expect(c.extrinsic[0]).toEqual([
+ [1, 0, 0, 0],
+ [0, 1, 0, 0],
+ [0, 0, 1, 0],
+ [0, 0, 0, 1],
+ ]);
+ // A quarter of a clockwise orbit: the camera has gone round to its left (−x) and looks back at the subject (+x).
+ const q = c.extrinsic[20];
+ expect(q[0][3]).toBeLessThan(-1.5);
+ expect(q[0][2]).toBeGreaterThan(0.9);
+ expect(c.intrinsic[0][2]).toBe(240);
+ expect(c.intrinsic[1][2]).toBe(416);
+ expect(caseProblem({ anchors: [] }, path, { firstFrame: bytes(), personMask: bytes(), render: bytes(), renderMask: bytes(), anchors: [] })).toBeNull();
+ });
+
+ it("puts each anchor camera on a ring at the subject's distance, world-to-camera, the first frame's included", () => {
+ const l = worldcastLayout(["front", "right", "back", "left"]);
+ const a = alignedAnchors(l, path, 2);
+ expect(a.views).toEqual(["first_frame", "front", "left_side", "right_side", "back"]);
+ const centre = (w2c: number[][]) => invertRigid(w2c).slice(0, 3).map((r) => r[3]);
+ expect(centre(a.extrinsic[0])).toEqual([0, 0, 0]);
+ // left_side (the person's right side) stands at −x, right_side at +x, the back beyond the subject: as the demo case's.
+ expect(centre(a.extrinsic[2])[0]).toBeCloseTo(-2, 5);
+ expect(centre(a.extrinsic[3])[0]).toBeCloseTo(2, 5);
+ expect(centre(a.extrinsic[4])[2]).toBeCloseTo(4, 5);
+ // Each is the inverse of a rigid pose.
+ const id = mul(a.extrinsic[3], invertRigid(a.extrinsic[3]));
+ id.forEach((row, i) => row.forEach((v, j) => expect(v).toBeCloseTo(i === j ? 1 : 0, 5)));
+ expect(anchorsMeta(l)).toMatchObject({ left_sign: -1, selected_views: ["front", "left_side", "right_side", "back"], per_view: { left_side: { azimuth_deg: 270 } } });
+ });
+
+ it("sends the files, the anchors and the run's fixed settings", () => {
+ const l = worldcastLayout(["front", "back"]);
+ const files = { firstFrame: bytes(), personMask: bytes(), render: bytes(), renderMask: bytes(), anchors: [{ image: bytes(), mask: bytes() }, { image: bytes(), mask: bytes() }] };
+ const parts = caseParts(l, path, files, { prompt: "A walk", seed: 7, pivotDepth: 2 });
+ const names = parts.map((p) => p.name);
+ expect(names).toEqual([
+ "first_frame.png",
+ "person_mask.png",
+ "render.mp4",
+ "render_mask.mp4",
+ "cam_info.json",
+ "anchors",
+ "anchor_front.png",
+ "anchor_front_mask.png",
+ "anchor_back.png",
+ "anchor_back_mask.png",
+ "anchors_aligned_camera_info.json",
+ "prompt",
+ "seed",
+ "steps",
+ "cfg",
+ "shift",
+ "height",
+ "width",
+ ]);
+ const value = (n: string) => (parts.find((p) => p.name === n) as { value: string }).value;
+ expect([value("steps"), value("cfg"), value("shift"), value("height"), value("width"), value("seed")]).toEqual(["50", "5", "2", "832", "480", "7"]);
+ expect(JSON.parse(value("anchors"))).toEqual(anchorsField(l));
+ expect(caseParts(l, path, files, { prompt: "", seed: 1, pivotDepth: 2, noAlignedCameras: true }).some((p) => p.name === "anchors_aligned_camera_info.json")).toBe(false);
+ });
+
+ it("refuses a case the model can't take", () => {
+ const files = { firstFrame: bytes(), personMask: bytes(), render: bytes(), renderMask: bytes(), anchors: [] };
+ const short = { ...path, poses: path.poses.slice(0, 49) };
+ expect(caseProblem({ anchors: [] }, short, files)).toMatch(/81 camera poses/);
+ const wide = framePoses(presetKeys("orbit_360")!, 81, 2, 40, { width: 832, height: 480 });
+ expect(caseProblem({ anchors: [] }, wide, files)).toMatch(/480 × 832/);
+ const bent = { ...path, poses: path.poses.map((m, i) => (i === 3 ? m.map((r, j) => (j === 0 ? [2, r[1], r[2], r[3]] : r)) : m)) };
+ expect(caseProblem({ anchors: [] }, bent, files)).toMatch(/rotation/);
+ expect(caseProblem(worldcastLayout(["front"]), path, files)).toMatch(/picture and its mask/);
+ expect(() => caseParts({ anchors: [] }, short, files, { prompt: "", seed: 0, pivotDepth: 1 })).toThrow();
+ });
+});