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.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Cinema 3D scene: a browser check of the viewer, lens presets read as millimetres
Claude8ded64d7fd57
diff --git a/src/components/cinema/scene-viewer.tsx b/src/components/cinema/scene-viewer.tsxindex 1c73fcd7..69a37572 100644--- a/src/components/cinema/scene-viewer.tsx+++ b/src/components/cinema/scene-viewer.tsx@@ -269,6 +269,7 @@ export default function SceneViewer({ take, projectId, engine, onEngine, settingkey={mm}type="button"aria-pressed={lens === mm}+ aria-label={`${mm} mm`}onClick={() => setLens(mm)}className={cn("h-7 rounded-full px-2.5 font-mono text-[11.5px]", lens === mm ? "bg-primary text-primary-foreground" : "bg-secondary hover:bg-accent")}>diff --git a/tests/e2e/cinema-scene.mjs b/tests/e2e/cinema-scene.mjsnew file mode 100644index 00000000..d4f55f55--- /dev/null+++ b/tests/e2e/cinema-scene.mjs@@ -0,0 +1,145 @@+// Cinema Studio's 3D scene in a real browser (the app must be running in demo mode; WebGL runs on SwiftShader).+// Usage: node tests/e2e/cinema-scene.mjs [appUrl] [--shots=dir]. Exits 1 on the first failure.+//+// 1. Cloud: "Create 3D scene" on a still asks first with the price, builds the demo depth map, and the viewer+// opens it as a point cloud; W A S D and the arrows move the view; Capture uploads the frame as a PNG in the+// frame's ratio and queues a recomposition with the capture as image 1 and the still as image 2.+// 2. Open engine: the scene is MoGe's mesh (the demo GLB here) and opens with its triangle count; at 390 px the+// viewer fits, offers the Camera sheet and keeps Capture in reach.+import assert from "node:assert/strict";+import fs from "node:fs";+import path from "node:path";+import { DESKTOP, PHONE, chromiumPath, loadPlaywright } from "./_browser.mjs";++const args = process.argv.slice(2);+const app = (args.find((a) => !a.startsWith("--")) ?? "http://localhost:3000").replace(/\/$/, "");+const shots = args.find((a) => a.startsWith("--shots="))?.slice(8);+if (shots) fs.mkdirSync(shots, { recursive: true });+const { chromium } = loadPlaywright();+const browser = await chromium.launch({ executablePath: chromiumPath(), args: ["--use-angle=swiftshader", "--enable-unsafe-swiftshader", "--ignore-gpu-blocklist"] });+const step = (name) => console.log(`- ${name}`);+const sleep = (ms) => new Promise((r) => setTimeout(r, ms));+const api = browser.newContext().then((c) => c.request);+async function call(url, method = "GET", data) {+ const res = await (await api).fetch(app + url, { method, headers: { "Content-Type": "application/json" }, data: data === undefined ? undefined : JSON.stringify(data) });+ return res.json();+}+async function until(fn, what, ms = 90_000) {+ const t = Date.now();+ for (;;) {+ const v = await fn();+ if (v) return v;+ if (Date.now() - t > ms) throw new Error(`Timed out waiting for ${what}`);+ await sleep(700);+ }+}+const shoot = (page, name) => shots && page.screenshot({ path: path.join(shots, `${name}.png`) });+/** The dev build's corner badge sits over the viewer's bottom-left controls. */+const hideDevBadge = (ctx) =>+ ctx.addInitScript(() =>+ document.addEventListener("DOMContentLoaded", () => {+ const s = document.createElement("style");+ s.textContent = "nextjs-portal{display:none!important}";+ document.head.append(s);+ }),+ );++const status = await call("/api/status");+assert.notEqual(status.demoMode, "off", "run the app in demo mode (FUOBE_DEMO_MODE=on)");+const project = await call("/api/cinema/projects", "POST", { name: "3D scene check" });+const items = async () => (await call(`/api/cinema/projects/${project.id}/items`)).items;+const errors = [];+let failed = false;++try {+ step("a still to build from");+ const settings = { camera: "modern", lens: "clean-sharp", focal: "24mm" };+ const made = await call(`/api/cinema/projects/${project.id}/generate`, "POST", {+ input: { engine: "cloud", mode: "image", action: "generate", prompt: "A lighthouse on a cliff at dusk", settings, aspectRatio: "16:9" },+ });+ assert.ok(made.items?.length, JSON.stringify(made));+ const still = await until(async () => (await items()).find((g) => g.id === made.items[0].id && g.status === "succeeded"), "the still");++ step("cloud: Create 3D scene asks first, with the price, and builds the point cloud");+ const ctx = await browser.newContext({ ...DESKTOP, colorScheme: "light" });+ await ctx.addInitScript(() => localStorage.setItem("fuobe.engine", "cloud"));+ await hideDevBadge(ctx);+ const page = await ctx.newPage();+ page.on("pageerror", (e) => errors.push(e.message));+ await page.goto(`${app}/cinema/${project.id}`, { waitUntil: "load", timeout: 120_000 });+ const tile = page.locator(`[aria-label^="Open"]`).first();+ await tile.waitFor({ timeout: 90_000 });+ await tile.hover();+ await page.getByRole("button", { name: "Create 3D scene" }).first().click();+ const dialog = page.getByRole("dialog");+ await dialog.getByText("Cloud · Marigold V2 depth").waitFor();+ await dialog.getByRole("button", { name: /Build 3D scene · Demo · free/ }).waitFor();+ await shoot(page, "scene-create-dialog");+ await dialog.getByRole("button", { name: /Build 3D scene/ }).click();+ await page.locator("[data-sonner-toast]").filter({ hasText: "Your 3D scene is ready" }).getByRole("button", { name: "Open" }).click({ timeout: 90_000 });+ await page.getByText(/Point cloud from a depth map · \d+k points/).waitFor({ timeout: 60_000 });+ await page.getByRole("button", { name: /^Capture · Demo · free/ }).last().waitFor();++ step("the view flies and the frame follows the ratio");+ const canvas = page.locator("canvas[aria-roledescription='3D view']");+ await canvas.focus();+ const pixels = () => canvas.screenshot().then((b) => b.toString("base64"));+ const before = await pixels();+ await page.keyboard.down("KeyW");+ await sleep(600);+ await page.keyboard.up("KeyW");+ await page.keyboard.press("ArrowRight");+ await sleep(500);+ assert.notEqual(await pixels(), before, "W and → should move the view");+ await page.getByRole("radio", { name: "9:16" }).click();+ await page.getByText("9:16 · 24 mm · f/5.6").waitFor();+ await page.getByRole("button", { name: "50 mm", exact: true }).click();+ await page.getByText("9:16 · 50 mm · f/5.6").waitFor();+ await shoot(page, "scene-viewer-cloud");++ step("Capture uploads the frame and queues the recomposition");+ await page.getByRole("button", { name: /^Capture/ }).last().click();+ await page.locator("[data-sonner-toast]").filter({ hasText: "Re-rendering this view" }).waitFor({ timeout: 30_000 });+ const rec = await until(async () => (await items()).find((g) => g.feature === "cinema-recompose"), "the recomposition");+ const [capture, ref] = rec.request.inputs.images;+ assert.match(capture, /^\/api\/files\/uploads\/.+\.png$/);+ assert.equal(ref, still.outputs[0].url);+ assert.match(rec.request.prompt, /^Re-render this exact camera view of the scene/);+ const png = Buffer.from(await (await (await api).fetch(app + capture)).body());+ assert.deepEqual([png.readUInt32BE(16), png.readUInt32BE(20)], [864, 1536], "the capture is the 9:16 frame");+ await page.getByRole("button", { name: "Close the 3D scene" }).click();+ await ctx.close();++ step("open engine: MoGe's mesh opens, and fits a phone with the Camera sheet");+ const open = await call(`/api/cinema/projects/${project.id}/generate`, "POST", {+ input: { engine: "open", mode: "image", action: "scene", prompt: "", settings, source: { url: still.outputs[0].url, kind: "image" }, aspectRatio: "16:9" },+ });+ const scene = await until(async () => (await items()).find((g) => g.id === open.items?.[0]?.id && g.status === "succeeded"), "the open scene");+ assert.deepEqual(+ scene.outputs.map((o) => o.kind),+ ["model3d", "image"],+ );+ const phone = await browser.newContext({ ...PHONE, colorScheme: "dark" });+ await phone.addInitScript(() => localStorage.setItem("fuobe.engine", "open"));+ await hideDevBadge(phone);+ const p2 = await phone.newPage();+ p2.on("pageerror", (e) => errors.push(e.message));+ await p2.goto(`${app}/cinema/${project.id}`, { waitUntil: "load", timeout: 120_000 });+ await p2.locator(`button[aria-label="Open 3D scene"]`).first().click({ force: true, timeout: 90_000 });+ await p2.getByText(/· \d+ triangles/).waitFor({ timeout: 60_000 });+ await p2.getByText("Drag to look · two fingers to move").waitFor();+ assert.equal(await p2.evaluate(() => document.documentElement.scrollWidth), 390);+ await shoot(p2, "scene-viewer-phone");+ await p2.getByRole("button", { name: "Camera" }).click();+ await p2.getByRole("dialog", { name: "Camera" }).getByText("Qwen-Image-Edit 2511 + Multiple-Angles LoRA").waitFor();+ await phone.close();+ assert.deepEqual(errors, [], "no page errors");+ console.log("\nAll 3D scene checks passed.");+} catch (e) {+ failed = true;+ console.log(`FAIL ${e.message.split("\n")[0]}`);+} finally {+ await call(`/api/cinema/projects/${project.id}`, "DELETE").catch(() => {});+ await browser.close();+}+process.exit(failed ? 1 : 0);diff --git a/tests/scene3d-provider.test.ts b/tests/scene3d-provider.test.tsindex c3134071..80b44901 100644--- a/tests/scene3d-provider.test.ts+++ b/tests/scene3d-provider.test.ts@@ -71,7 +71,11 @@ describe("open engine: MoGe 2 scene (scene-mesh-moge)", () => {it("returns the scene GLB first and the depth PNG second, each with its role", () => {const file = (filename: string) => ({ filename, subfolder: "fuobe", type: "output" });const outs = collectOutputs(- { status: { status_str: "success", completed: true }, outputs: { "11": { images: [file("gen-scene_00001_.png")] }, "9": { "3d": [file("gen-scene_00001_.glb")] } } },+ // What ComfyUI 0.41 answers for this graph (a live CPU run): SaveGLB also lists camera_info [null].+ {+ status: { status_str: "success", completed: true },+ outputs: { "11": { images: [file("gen-scene_00001_.png")] }, "9": { "3d": [file("gen-scene_00002_.glb")], camera_info: [null], model_3d_info: [] } },+ },manifestOf("scene-mesh-moge"),);expect(outs.map((o) => [o.kind, o.contentType, o.meta?.role])).toEqual([