Skip to content

Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.

Keep only the cat ready-made scene; answer progress questions about a white model

Bowen Xuef0cfe036dc8e
diff --git a/freevideo_engine/agent/guide.py b/freevideo_engine/agent/guide.py
index c274f10..e5dabc9 100644
--- a/freevideo_engine/agent/guide.py
+++ b/freevideo_engine/agent/guide.py
@@ -235,6 +235,10 @@ RULES = [
'continuing again and again is not recommended. One video has at most 5 parts (the first and 4 '
'continuations), each continued part at least 10 seconds, about 70 seconds in all; filling that is not '
'recommended. Past it, cut to a new shot.',
+ 'A question is not a request. When the user asks about progress or status ("is it working?", "what happened?") '
+ 'answer it in one sentence from what you know or from the job and white-model status, and start nothing; never '
+ 'use a question as a prompt. When a row carries "whitebox", the user was starting a white-model scene that is '
+ 'still being prepared or failed: say which, and wait for the answer.',
]
@@ -265,6 +269,9 @@ RULES_ZH = [
'默认切镜头。能切镜头的地方就切:新镜头直接用对应的参考图(人物卡、场景图)生成,不接上一段视频。'
'只有不能切镜的长镜头、必须连贯的动作、必须连贯的声音,才接着上一段生成,而且不建议一段接一段地连续接。'
'一条视频最多 5 段(第一段加 4 次接着生成),接着生成的每一段至少 10 秒,总长约 70 秒;不建议接满,超过就切镜头。',
+ '问话不是要求。用户问进度或状态(“在做吗”“怎么了”)时,用一句话照实回答,依据是你所知道的、任务和白模的状态,'
+ '什么都不要开始;不要把问句当提示词。某条 inbox 带有 whitebox 时,说明用户刚启动了白模场景,'
+ '它还在准备或已经失败:照实说是哪一种,再等用户回话。',
]
@@ -480,7 +487,7 @@ def connection_guide(root, base, lang=None, offers=None, resumed=False):
'不要停下来问用户——你一停,用户在 FreeVideo 里说的话就没人听了。'
'用命令行调接口时,每次等待单独发一条命令(一条命令里不写循环,超时设到 60 秒以上),'
'返回后接着发下一条。'
- '收到话(inbox 里每条的 text)先回一句再动手,例如“好的,开始生成。”:只一句,不复述尺寸、'
+ '收到要求(inbox 里每条的 text)先回一句再动手,例如“好的,开始生成。”:只一句,不复述尺寸、'
'时长这些参数,也不说预计时间(任务卡上都有)。做完再说一句短的,例如“好了。”,'
'或者一句用户需要知道的话,发回同一个 session,再接着等。先把话发出去,再调等待接口;不要写成“等待返回后才发话”,那样这句话会晚到将近一分钟。中文用全角标点。'
'做完一条视频也不是结尾:这句话就是汇报,不要再在自己窗口里写总结(一写总结这一轮就结束了,'
@@ -498,7 +505,7 @@ def connection_guide(root, base, lang=None, offers=None, resumed=False):
'user, because once you stop nobody hears what the user says in FreeVideo. From a command line, '
'each wait is its own command (no loop inside one command, timeout above 60 seconds); when it '
'returns, run the next one. '
- 'When words arrive (text of each inbox row), answer with one sentence before you start, for example '
+ 'When a request arrives (text of each inbox row; a question about progress is answered, not started), answer with one sentence before you start, for example '
'"OK, starting.": one sentence only, without repeating size or length and without an estimate (the '
'job card shows them). When it is done say one short sentence, for example "Done.", or one thing the '
'user needs to know, to the same session, and wait again. Post your words first and call the wait after; never wait and then post, or they reach the user up to a minute late. Chinese text takes full-width punctuation. '
diff --git a/freevideo_engine/agent/routes.py b/freevideo_engine/agent/routes.py
index 74f7eb7..7bd133f 100644
--- a/freevideo_engine/agent/routes.py
+++ b/freevideo_engine/agent/routes.py
@@ -45,6 +45,10 @@ MOVED_BACK = (' It is one the user was in before, and the user means what was sa
RESUMED = ('This conversation is already under way; its last lines are in "before". Do not introduce yourself again: '
'say nothing until the user speaks, then carry on from there.')
BEFORE_LINES, BEFORE_TEXT = 8, 600
+# The user started a white-model scene and then spoke: the words may be about it, not a new request.
+WHITEBOX_PENDING = ('The user started a white-model scene in this conversation ("whitebox" lists it). If the words ask about '
+ 'it or about progress, answer from its status in one sentence (waiting or rendering: still being made; '
+ 'failed: say it was not made, and why) and start nothing. A question is never a prompt.')
def local_address(request):
@@ -1725,6 +1729,10 @@ def register():
follow = store is not None and not request.headers.get('X-FreeVideo-Session', '').strip()
def answer(value):
told, chat['told'][client] = chat['told'].get(client), value['session']
+ scenes = jobs.whitebox.open_for(value['session']) if value['inbox'] else []
+ if scenes:
+ value['whitebox'] = scenes
+ value['next'] = (WHITEBOX_PENDING + ' ' + value.get('next', '')).strip()
if follow and told != value['session']:
first = value['inbox'][0]['seq'] if value['inbox'] else store.get(value['session'])['last_seq'] + 1
if first > 1:
diff --git a/freevideo_engine/agent/whitebox.py b/freevideo_engine/agent/whitebox.py
index 95a157b..16b6fb9 100644
--- a/freevideo_engine/agent/whitebox.py
+++ b/freevideo_engine/agent/whitebox.py
@@ -127,6 +127,18 @@ class Whitebox:
self._save(record)
return self.view(record)
+ def open_for(self, session):
+ """The scenes this conversation started that are still being made, or failed without the user being told."""
+ with self.lock:
+ rows = []
+ for record in sorted(self.records.values(), key=lambda r: r['created_at']):
+ self._expire(record)
+ if record.get('session') == session and record.get('notice') and record['status'] != 'ready' \
+ and self.clock() - record['created_at'] < 1800:
+ rows.append(dict(id=record['id'], status=record['status'], summary=record['summary'],
+ **(dict(error=record['error']) if record['status'] == 'failed' else {})))
+ return rows
+
def take_notice(self, identity):
"""What the server should tell the user's conversation once the scene is ready; handed out once."""
with self.lock:
diff --git a/freevideo_engine/agent/whitebox_presets.py b/freevideo_engine/agent/whitebox_presets.py
index 5ea8f0d..450d146 100644
--- a/freevideo_engine/agent/whitebox_presets.py
+++ b/freevideo_engine/agent/whitebox_presets.py
@@ -1,24 +1,9 @@
"""Ready-made white-model scenes (scene code written to the scene prompt); 'try' and the built-in AI render one without a model writing code."""
PRESETS = (
- dict(id='plane', name='纸飞机飞出教室窗外', shot='一架纸飞机从教室后排飞过一排排课桌,穿过敞开的窗户飞向窗外的操场,镜头跟在纸飞机后面。',
- prompt='A realistic classroom scene: a white paper airplane glides from the back of the classroom over rows of wooden desks and blue chairs, passes through the open window in the far wall and flies out over a sunny sports field with a running track, while the camera follows just behind the plane. Natural daylight, realistic materials, smooth camera motion. Soft ambient classroom sounds fading into a light outdoor breeze.',
- code="export function build(THREE) {\n const scene = new THREE.Scene();\n scene.background = new THREE.Color(0xb7d7f0);\n const camera = new THREE.PerspectiveCamera(65, 960 / 544, 0.1, 200);\n const std = c => new THREE.MeshStandardMaterial({ color: c, roughness: 1, side: THREE.DoubleSide });\n const add = (geo, mat, x, y, z, name) => {\n const m = new THREE.Mesh(geo, mat); m.position.set(x, y, z); m.name = name || '';\n m.castShadow = true; m.receiveShadow = true; scene.add(m); return m;\n };\n scene.add(new THREE.HemisphereLight(0xffffff, 0x8a7f70, 1.2));\n const sun = new THREE.DirectionalLight(0xfff4e0, 2.0);\n sun.position.set(12, 10, -4); sun.castShadow = true;\n sun.shadow.camera.left = -15; sun.shadow.camera.right = 15; sun.shadow.camera.top = 15; sun.shadow.camera.bottom = -15;\n sun.shadow.mapSize.set(2048, 2048); scene.add(sun);\n // room x -4..4, z 0..14 (window wall at z = 0), height 3\n add(new THREE.PlaneGeometry(8, 14).rotateX(-Math.PI / 2), std(0xb08a5e), 0, 0, 7, 'floor');\n add(new THREE.PlaneGeometry(8, 14).rotateX(Math.PI / 2), std(0xffffff), 0, 3, 7, 'ceiling');\n add(new THREE.BoxGeometry(0.2, 3, 14), std(0xe6dfc8), -4, 1.5, 7, 'wall_left');\n add(new THREE.BoxGeometry(0.2, 3, 14), std(0xe6dfc8), 4, 1.5, 7, 'wall_right');\n add(new THREE.BoxGeometry(8, 3, 0.2), std(0xe6dfc8), 0, 1.5, 14, 'wall_back');\n // window wall with a 2.4 x 1.4 opening, sill at 1.0\n add(new THREE.BoxGeometry(8, 1.0, 0.2), std(0xe6dfc8), 0, 0.5, 0, 'wall_below');\n add(new THREE.BoxGeometry(8, 0.6, 0.2), std(0xe6dfc8), 0, 2.7, 0, 'wall_above');\n add(new THREE.BoxGeometry(2.8, 1.4, 0.2), std(0xe6dfc8), -2.6, 1.7, 0, 'wall_l');\n add(new THREE.BoxGeometry(2.8, 1.4, 0.2), std(0xe6dfc8), 2.6, 1.7, 0, 'wall_r');\n add(new THREE.BoxGeometry(2.4, 0.05, 0.3), std(0xffffff), 0, 1.0, 0, 'sill');\n add(new THREE.BoxGeometry(5.5, 1.2, 0.05), std(0x2f5b43), -1.5, 1.6, 13.85, 'blackboard');\n // desks: 3 columns x 4 rows\n for (let c = 0; c < 3; c++) for (let r = 0; r < 4; r++) {\n const x = -2.4 + c * 2.4, z = 4 + r * 2.2;\n add(new THREE.BoxGeometry(1.1, 0.06, 0.6), std(0xc98f4f), x, 0.75, z, 'desk_top');\n add(new THREE.BoxGeometry(0.06, 0.75, 0.06), std(0x777777), x - 0.5, 0.375, z - 0.25, 'desk_leg');\n add(new THREE.BoxGeometry(0.06, 0.75, 0.06), std(0x777777), x + 0.5, 0.375, z + 0.25, 'desk_leg');\n add(new THREE.BoxGeometry(0.45, 0.05, 0.45), std(0x4d7cc9), x, 0.45, z + 0.7, 'chair_seat');\n add(new THREE.BoxGeometry(0.45, 0.45, 0.05), std(0x4d7cc9), x, 0.7, z + 0.92, 'chair_back');\n }\n // outside: grass, running track, goal\n add(new THREE.PlaneGeometry(120, 120).rotateX(-Math.PI / 2), std(0x6fae56), 0, -0.02, -50, 'field');\n add(new THREE.PlaneGeometry(30, 4).rotateX(-Math.PI / 2), std(0xc4654a), 0, 0.0, -12, 'track');\n add(new THREE.BoxGeometry(6, 3, 0.2), std(0xffffff), 0, 1.5, -36, 'goal');\n const plane = new THREE.Group(); plane.name = 'hero_paper_plane'; scene.add(plane);\n const wing = new THREE.Mesh(new THREE.ConeGeometry(0.16, 0.5, 3).rotateX(-Math.PI / 2).scale(1.6, 0.35, 1), std(0xffffff));\n wing.castShadow = true; plane.add(wing);\n const ss = x => x * x * (3 - 2 * x);\n const pts = [[0.4, 1.7, 11.5], [0.2, 1.55, 8.5], [-0.3, 1.5, 6.0], [0.0, 1.55, 2.5], [0.0, 1.6, 0.0], [0.3, 1.5, -4], [0.8, 1.2, -10], [1.4, 0.9, -16]]\n .map(p => new THREE.Vector3(...p));\n const curve = new THREE.CatmullRomCurve3(pts, false, 'centripetal');\n const at = t => curve.getPoint(ss(Math.min(1, t / 5)) * 0.6 + Math.min(1, t / 5) * 0.4);\n return {\n scene, camera,\n update(t) {\n const p = at(t), q = at(t + 0.05);\n plane.position.copy(p); plane.lookAt(q); plane.rotateZ(0.25 * Math.sin(t * 2));\n const behind = at(Math.max(0, t - 0.45));\n camera.position.set(behind.x * 0.5, behind.y + 0.4, behind.z + 1.5);\n camera.lookAt(p.x, p.y, p.z - 2);\n },\n };\n}\n"),
- dict(id='coaster', name='第一人称过山车俯冲', shot='第一人称过山车:先爬到最高点停顿,然后俯冲而下,穿过一个大回环,最后冲向远处的游乐园。',
- prompt='A first-person roller coaster ride at a real amusement park: the cart climbs a steep red steel track to the very top, pauses for a heartbeat, then plunges down in a steep drop, whips through a large vertical loop, and races out toward the colourful rides and a Ferris wheel in the distance. Bright sunny day, green trees, realistic steel and paint, strong sense of speed, smooth camera. Rushing wind and the clatter of the wheels on the track.',
- code='export function build(THREE) {\n const scene = new THREE.Scene();\n const camera = new THREE.PerspectiveCamera(65, 960 / 544, 0.1, 300);\n const std = c => new THREE.MeshStandardMaterial({ color: c, roughness: 1 });\n const add = (geo, mat, x, y, z, name, parent) => {\n const m = new THREE.Mesh(geo, mat); m.position.set(x, y, z); m.name = name || "";\n m.castShadow = true; m.receiveShadow = true; (parent || scene).add(m); return m;\n };\n const ss = x => x * x * (3 - 2 * x);\n const lerp = (a, b, u) => a + (b - a) * u;\n const clamp01 = x => Math.min(1, Math.max(0, x));\n const sun = new THREE.DirectionalLight(0xffffff, 1.8);\n sun.castShadow = true; sun.shadow.mapSize.set(2048, 2048);\n sun.shadow.camera.left = -60; sun.shadow.camera.right = 60; sun.shadow.camera.top = 60; sun.shadow.camera.bottom = -60; sun.shadow.camera.far = 200;\n scene.add(sun);\n\n scene.background = new THREE.Color(0xbfdcf0);\n scene.add(new THREE.HemisphereLight(0xdfeeff, 0x6a7a5a, 1.1)); sun.position.set(-40, 80, 30);\n add(new THREE.PlaneGeometry(600, 600).rotateX(-Math.PI / 2), std(0x7fa86a), 0, 0, 0, "ground");\n // track as a curve: climb, crest, drop, loop, run-out\n const pts = [[0,2,60],[0,12,40],[0,30,20],[0,44,6],[0,46,-4],[0,40,-12],[0,18,-24],[0,4,-34],[0,3,-46],[0,10,-56],[0,18,-50],[0,14,-40],[0,3,-48],[0,2,-70],[0,2,-110]];\n const curve = new THREE.CatmullRomCurve3(pts.map(p => new THREE.Vector3(...p)));\n const N = 120;\n for (let i = 0; i < N; i++) {\n const p = curve.getPoint(i / N), q = curve.getPoint((i + 1) / N);\n const seg = add(new THREE.BoxGeometry(2.6, 0.25, 1.1 * p.distanceTo(q) + 0.2), std(0xd23b2e), p.x, p.y, p.z, "track");\n seg.lookAt(q);\n if (i % 6 === 0 && p.y > 2.5) add(new THREE.BoxGeometry(0.35, p.y, 0.35), std(0xe8e8e8), p.x, p.y / 2 - 0.2, p.z, "pillar");\n }\n for (let i = 0; i < 60; i++) { const a = i * 2.399, r = 20 + (i * 13) % 70; add(new THREE.ConeGeometry(2.2, 7, 6), std(0x3f7a3a), Math.cos(a) * r, 3.5, -40 + Math.sin(a) * r * 1.6, "tree"); }\n // distant park\n const cols = [0xf2c14e, 0x4e9bd6, 0xd65e8b, 0x8bd64e];\n for (let i = 0; i < 14; i++) add(new THREE.BoxGeometry(5 + i % 3, 3 + (i * 5) % 6, 5), std(cols[i % 4]), -30 + i * 5, 2, -150 - (i % 3) * 8, "park");\n const wheel = add(new THREE.TorusGeometry(12, 0.5, 6, 20), std(0xf0f0f0), 30, 14, -140, "ferris");\n add(new THREE.ConeGeometry(2.5, 5, 8), std(0xe8412c), -20, 6, -125, "tent");\n const hero = new THREE.Group(); hero.name = "hero_cart"; scene.add(hero);\n add(new THREE.BoxGeometry(1.6, 0.6, 2.4), std(0xf2c14e), 0, 0, 0, "hero_cart_body", hero);\n const ease = u => u < 0.28 ? 0.55 * (u / 0.28) * 0.5 * 0 + ss(u / 0.28) * 0.46 : u < 0.36 ? 0.46 + (u - 0.28) / 0.08 * 0.02 : 0.48 + ss((u - 0.36) / 0.64) * 0.52;\n return { scene, camera, update(t) {\n const u = ease(clamp01(t / 5));\n wheel.rotation.z = t * 0.2;\n const p = curve.getPoint(u * 0.98), look = curve.getPoint(Math.min(1, u * 0.98 + 0.03));\n hero.position.copy(p); hero.lookAt(look);\n const dir = look.clone().sub(p).normalize(); dir.y *= 0.55; camera.position.set(p.x, p.y + 1.1, p.z); camera.lookAt(p.x + dir.x * 10, p.y + 1.1 + dir.y * 10, p.z + dir.z * 10);\n camera.rotation.z = 0;\n } };\n}\n'),
- dict(id='drone', name='无人机穿过楼间再拉升', shot='无人机贴着两排高楼之间的街道低空飞行,随后拉升冲出楼顶,镜头跟在无人机后上方。',
- prompt="A cinematic drone shot in a real city: a small red quadcopter drone flies low along a narrow street between two rows of tall concrete and glass buildings, then climbs steeply and bursts out above the rooftops into the open blue sky, while the camera follows behind and above the drone. Natural sunlight, soft shadows, realistic materials, smooth camera motion. Ambient city wind sound and the soft hum of the drone's rotors.",
- code="export function build(THREE) {\n const scene = new THREE.Scene();\n scene.background = new THREE.Color(0xbcd6ea);\n const camera = new THREE.PerspectiveCamera(60, 960 / 544, 0.1, 200);\n const std = c => new THREE.MeshStandardMaterial({ color: c, roughness: 1 });\n const add = (geo, mat, x, y, z, name) => {\n const m = new THREE.Mesh(geo, mat); m.position.set(x, y, z); m.name = name || '';\n m.castShadow = true; m.receiveShadow = true; scene.add(m); return m;\n };\n scene.add(new THREE.HemisphereLight(0xdfeeff, 0x666a70, 1.1));\n const sun = new THREE.DirectionalLight(0xffffff, 1.8);\n sun.position.set(-30, 50, 20); sun.castShadow = true;\n sun.shadow.camera.left = -60; sun.shadow.camera.right = 60; sun.shadow.camera.top = 60; sun.shadow.camera.bottom = -60;\n sun.shadow.camera.far = 150; sun.shadow.mapSize.set(2048, 2048);\n scene.add(sun);\n add(new THREE.PlaneGeometry(200, 200).rotateX(-Math.PI / 2), std(0x5d6168), 0, 0, 0, 'ground');\n add(new THREE.PlaneGeometry(9, 200).rotateX(-Math.PI / 2), std(0x3b3e44), 0, 0.02, 0, 'street');\n const palette = [0xc9b8a0, 0x9fb1c4, 0xd6cfc4, 0xa8a39a, 0xb9c4b0];\n for (let side of [-1, 1]) {\n for (let i = 0; i < 9; i++) {\n const z = -80 + i * 17 + (side > 0 ? 6 : 0);\n const h = 14 + ((i * 7 + (side > 0 ? 3 : 0)) % 5) * 5;\n add(new THREE.BoxGeometry(14, h, 14), std(palette[(i + (side > 0 ? 2 : 0)) % 5]), side * 12.5, h / 2, z, 'building');\n }\n }\n const hero = new THREE.Group(); hero.name = 'hero_drone'; scene.add(hero);\n const body = new THREE.Mesh(new THREE.BoxGeometry(0.9, 0.25, 0.9), std(0xe8412c)); body.castShadow = true; hero.add(body);\n for (const [x, z] of [[-0.7, -0.7], [0.7, -0.7], [-0.7, 0.7], [0.7, 0.7]]) {\n const rotor = new THREE.Mesh(new THREE.CylinderGeometry(0.4, 0.4, 0.03, 12), std(0x222222));\n rotor.position.set(x, 0.17, z); hero.add(rotor);\n }\n const ss = x => x * x * (3 - 2 * x);\n const lerp = (a, b, u) => a + (b - a) * u;\n const heroAt = t => {\n const u = Math.min(1, t / 5);\n const z = lerp(60, -60, u);\n const rise = ss(Math.min(1, Math.max(0, (u - 0.55) / 0.35)));\n return new THREE.Vector3(1.5 * Math.sin(u * 6), lerp(3.2, 42, rise), z);\n };\n return {\n scene, camera,\n update(t) {\n const p = heroAt(t);\n hero.position.copy(p);\n const ahead = heroAt(t + 0.1);\n hero.rotation.set(0.25 * Math.min(1, (ahead.z - p.z) / -0.1 * 0.02), 0, 0);\n hero.rotation.x = -0.18; hero.rotation.z = 0.12 * Math.sin(t * 1.3);\n const u = Math.min(1, t / 5);\n const lift = ss(Math.min(1, Math.max(0, (u - 0.55) / 0.35)));\n camera.position.set(p.x * 0.4, p.y + 2.2 + 3 * lift, p.z + 9 + 2 * lift);\n camera.lookAt(p.x, p.y + 0.3, p.z - 4);\n },\n };\n}\n"),
dict(id='cat', name='橘猫跳上书架', shot='一只橘猫在客厅地板上蹲下蓄力,沿着错落的书架层板一级一级跳上去,最后蹲在最高一层,镜头侧面平移并略微上摇跟随。',
prompt='A ginger cat crouches on a living room floor, gathers itself and leaps up a staggered wooden bookshelf, jumping from one shelf to the next between rows of books, and finally settles on the top shelf, while the camera pans sideways and tilts up slightly to follow. Warm indoor daylight, realistic fur and wood, soft shadows, smooth camera motion. Soft room tone and the light thud of paws on wood.',
code='export function build(THREE) {\n const scene = new THREE.Scene();\n const camera = new THREE.PerspectiveCamera(65, 960 / 544, 0.1, 300);\n const std = c => new THREE.MeshStandardMaterial({ color: c, roughness: 1 });\n const add = (geo, mat, x, y, z, name, parent) => {\n const m = new THREE.Mesh(geo, mat); m.position.set(x, y, z); m.name = name || "";\n m.castShadow = true; m.receiveShadow = true; (parent || scene).add(m); return m;\n };\n const ss = x => x * x * (3 - 2 * x);\n const lerp = (a, b, u) => a + (b - a) * u;\n const clamp01 = x => Math.min(1, Math.max(0, x));\n const sun = new THREE.DirectionalLight(0xffffff, 1.8);\n sun.castShadow = true; sun.shadow.mapSize.set(2048, 2048);\n sun.shadow.camera.left = -60; sun.shadow.camera.right = 60; sun.shadow.camera.top = 60; sun.shadow.camera.bottom = -60; sun.shadow.camera.far = 200;\n scene.add(sun);\n\n scene.background = new THREE.Color(0xe9e2d6);\n scene.add(new THREE.HemisphereLight(0xfff4e6, 0x8a7f72, 1.2)); sun.position.set(6, 10, 8);\n add(new THREE.PlaneGeometry(14, 10).rotateX(-Math.PI / 2), std(0xb88f65), 0, 0, 0, "floor");\n add(new THREE.BoxGeometry(14, 4, 0.2), std(0xe9e2d6), 0, 2, -1.2, "wall");\n // bookshelf: two side boards, staggered shelves\n add(new THREE.BoxGeometry(0.1, 2.6, 0.5), std(0x7a5232), -1.4, 1.3, -0.9, "side");\n add(new THREE.BoxGeometry(0.1, 2.6, 0.5), std(0x7a5232), 1.4, 1.3, -0.9, "side");\n const shelves = [[0.6, -0.9], [1.2, -0.4], [1.8, 0.2], [2.4, 0.6]];\n const stepsX = [-0.9, -0.2, 0.5, 1.0], ys = [0.55, 1.05, 1.55, 2.1];\n for (let i = 0; i < 4; i++) {\n add(new THREE.BoxGeometry(1.0, 0.06, 0.5), std(0x9a6b3f), stepsX[i], ys[i] - 0.03, -0.9, "shelf");\n for (let k = 0; k < 3; k++) add(new THREE.BoxGeometry(0.12, 0.28, 0.3), std([0x3c6ea8, 0xb04a4a, 0x4a8a5a][(i + k) % 3]), stepsX[i] - 0.3 + k * 0.2, ys[i] + 0.14, -1.0, "book");\n }\n add(new THREE.BoxGeometry(0.9, 0.5, 0.5), std(0x6b7b8c), -2.6, 0.25, 0.6, "sofa_block");\n const cat = new THREE.Group(); cat.name = "hero_cat"; scene.add(cat);\n const orange = std(0xe58a2e);\n const body = add(new THREE.BoxGeometry(0.42, 0.22, 0.2), orange, 0, 0.18, 0, "hero_cat_body", cat);\n add(new THREE.SphereGeometry(0.11, 10, 8), orange, 0.26, 0.28, 0, "hero_cat_head", cat);\n add(new THREE.ConeGeometry(0.035, 0.08, 4), orange, 0.28, 0.4, 0.06, "hero_cat_ear", cat);\n add(new THREE.ConeGeometry(0.035, 0.08, 4), orange, 0.28, 0.4, -0.06, "hero_cat_ear", cat);\n const tail = add(new THREE.CylinderGeometry(0.03, 0.03, 0.4, 6), orange, -0.34, 0.3, 0, "hero_cat_tail", cat);\n tail.rotation.z = 0.8;\n // waypoints: floor crouch, jump to each shelf\n const wp = [[-1.9, 0.0, 0.1], [-1.9, 0.0, 0.1], [stepsX[0], ys[0], -0.9], [stepsX[1], ys[1], -0.9], [stepsX[2], ys[2], -0.9], [stepsX[3], ys[3], -0.9], [stepsX[3], ys[3], -0.9]];\n const times = [0, 0.7, 1.4, 2.3, 3.2, 4.1, 5.0];\n const pos = t => { let i = 0; while (i < 5 && t > times[i + 1]) i++;\n const u = clamp01((t - times[i]) / (times[i + 1] - times[i])); const a = wp[i], b = wp[i + 1];\n const arc = (i >= 1 && i <= 4) ? Math.sin(Math.PI * u) * 0.45 : 0;\n const e = ss(u); return new THREE.Vector3(lerp(a[0], b[0], e), lerp(a[1], b[1], u) + arc, lerp(a[2], b[2], e)); };\n return { scene, camera, update(t) {\n const p = pos(t); cat.position.copy(p);\n cat.scale.y = (t < 0.7) ? 1 - 0.35 * Math.sin(Math.PI * clamp01(t / 0.7)) : 1;\n cat.rotation.z = (t > 0.7 && t < 4.1) ? 0.35 : 0;\n camera.position.set(p.x * 0.6, 0.9 + p.y * 0.5, 2.7);\n camera.lookAt(p.x * 0.85, 0.35 + p.y * 0.85, -0.9);\n } };\n}\n'),
- dict(id='car', name='赛车入弯漂移环绕', shot='一辆红色赛车在直道尽头高速入弯,车尾漂移甩出,镜头围着赛车做半圈环绕,最后跟着车冲出弯道。',
- prompt='A red race car hits the end of a straight at full speed and throws itself into a corner, the rear sliding out in a controlled drift with a little tyre smoke, while the camera orbits half a circle around the car and then follows it out of the bend. Sunny circuit with red and white kerbs, grandstands and green grass, realistic paint and tarmac, strong sense of speed, smooth camera. Roaring engine and the squeal of tyres.',
- code='export function build(THREE) {\n const scene = new THREE.Scene();\n const camera = new THREE.PerspectiveCamera(65, 960 / 544, 0.1, 300);\n const std = c => new THREE.MeshStandardMaterial({ color: c, roughness: 1 });\n const add = (geo, mat, x, y, z, name, parent) => {\n const m = new THREE.Mesh(geo, mat); m.position.set(x, y, z); m.name = name || "";\n m.castShadow = true; m.receiveShadow = true; (parent || scene).add(m); return m;\n };\n const ss = x => x * x * (3 - 2 * x);\n const lerp = (a, b, u) => a + (b - a) * u;\n const clamp01 = x => Math.min(1, Math.max(0, x));\n const sun = new THREE.DirectionalLight(0xffffff, 1.8);\n sun.castShadow = true; sun.shadow.mapSize.set(2048, 2048);\n sun.shadow.camera.left = -60; sun.shadow.camera.right = 60; sun.shadow.camera.top = 60; sun.shadow.camera.bottom = -60; sun.shadow.camera.far = 200;\n scene.add(sun);\n\n scene.background = new THREE.Color(0xbdd8ee);\n scene.add(new THREE.HemisphereLight(0xdfeeff, 0x6a7a5a, 1.1)); sun.position.set(-30, 60, 25);\n add(new THREE.PlaneGeometry(400, 400).rotateX(-Math.PI / 2), std(0x6f9a58), 0, 0, 0, "grass");\n // road: straight along -z then curving right (to +x)\n const R = 22, cz = -30;\n add(new THREE.BoxGeometry(10, 0.05, 80), std(0x3d4046), 0, 0.03, 10, "road");\n const arc = []; for (let i = 0; i <= 24; i++) { const a = Math.PI * 0.5 * i / 24; arc.push(i); \n add(new THREE.BoxGeometry(10, 0.05, 2 * R * Math.PI / 2 / 24 + 0.6), std(0x3d4046), R - R * Math.cos(a), 0.03, cz - R * Math.sin(a), "bend").rotation.y = -a; }\n add(new THREE.BoxGeometry(10, 0.05, 80), std(0x3d4046), R + 40, 0.03, cz - R, "road2").rotation.y = Math.PI / 2;\n for (let i = 0; i < 16; i++) { const a = Math.PI * 0.5 * i / 15; add(new THREE.BoxGeometry(0.6, 0.6, 0.6), std(i % 2 ? 0xffffff : 0xe8412c), (R + 6) - (R + 6) * Math.cos(a) , 0.3, cz - (R + 6) * Math.sin(a), "kerb"); }\n for (let i = 0; i < 8; i++) add(new THREE.BoxGeometry(3, 5, 3), std(0xc9b8a0), -25 + (i % 2) * 4, 2.5, -60 + i * 6, "stand");\n const hero = new THREE.Group(); hero.name = "hero_car"; scene.add(hero);\n add(new THREE.BoxGeometry(1.8, 0.55, 4.2), std(0xd9261c), 0, 0.5, 0, "hero_car_body", hero);\n add(new THREE.BoxGeometry(1.3, 0.45, 1.6), std(0x20242a), 0, 0.95, -0.2, "hero_car_cabin", hero);\n for (const [x, z] of [[-1, -1.4], [1, -1.4], [-1, 1.4], [1, 1.4]]) { const w = add(new THREE.CylinderGeometry(0.4, 0.4, 0.3, 12), std(0x111111), x, 0.4, z, "hero_car_wheel", hero); w.rotation.z = Math.PI / 2; }\n const path = t => { const u = clamp01(t / 5); const s = u * (80 + R * Math.PI / 2 + 30) - 40; // arclength from z=40\n if (s < 40 - 0) return { x: 0, z: 40 - s, h: Math.PI }; // heading -z (rotation.y = PI points model -z? model faces -z when rotation 0)\n return null; };\n const pos = t => { const u = clamp01(t / 5), L1 = 70, L2 = R * Math.PI / 2, L3 = 40; const s = ss(u * 0.2 + u * 0.8) * (L1 + L2 + L3);\n if (s < L1) return { x: 0, z: 40 - s, yaw: 0 };\n if (s < L1 + L2) { const a = (s - L1) / R; return { x: R - R * Math.cos(a), z: cz - R * Math.sin(a) + 0, yaw: -a }; }\n const d = s - L1 - L2; return { x: R + d, z: cz - R, yaw: -Math.PI / 2 }; };\n return { scene, camera, update(t) {\n const p = pos(t); const drift = Math.sin(Math.PI * clamp01((t - 1.2) / 2.4)) * 0.55;\n hero.position.set(p.x, 0, p.z); hero.rotation.y = p.yaw - drift;\n const orbit = Math.PI * 0.9 * ss(clamp01((t - 1.0) / 3.0));\n const ang = Math.PI * 0.85 - orbit + p.yaw * -0.0;\n const rad = 9 - 2 * Math.sin(Math.PI * clamp01(t / 5));\n camera.position.set(p.x + Math.sin(ang + (p.yaw)) * rad * -1 * -1, 2.2 + 1.5 * Math.sin(Math.PI * clamp01(t / 5)), p.z + Math.cos(ang + p.yaw) * rad);\n camera.lookAt(p.x, 0.8, p.z);\n } };\n}\n'),
- dict(id='door', name='推门长镜头', shot='短剧长镜头:镜头从走廊里缓缓推向一扇半掩的木门,推开门进入昏黄的客厅,一直推到沙发后的落地窗前停住。',
- prompt='A short-drama long take: the camera glides down a dim hallway toward a half-open wooden door, pushes the door open and enters a warmly lit living room, and keeps moving forward past a sofa until it stops in front of the tall window at the far end. Warm tungsten light, soft evening glow from the window, realistic wood, fabric and plaster, smooth steady camera. Quiet room tone and a faint creak of the door.',
- code='export function build(THREE) {\n const scene = new THREE.Scene();\n const camera = new THREE.PerspectiveCamera(65, 960 / 544, 0.1, 300);\n const std = c => new THREE.MeshStandardMaterial({ color: c, roughness: 1 });\n const add = (geo, mat, x, y, z, name, parent) => {\n const m = new THREE.Mesh(geo, mat); m.position.set(x, y, z); m.name = name || "";\n m.castShadow = true; m.receiveShadow = true; (parent || scene).add(m); return m;\n };\n const ss = x => x * x * (3 - 2 * x);\n const lerp = (a, b, u) => a + (b - a) * u;\n const clamp01 = x => Math.min(1, Math.max(0, x));\n const sun = new THREE.DirectionalLight(0xffffff, 1.8);\n sun.castShadow = true; sun.shadow.mapSize.set(2048, 2048);\n sun.shadow.camera.left = -60; sun.shadow.camera.right = 60; sun.shadow.camera.top = 60; sun.shadow.camera.bottom = -60; sun.shadow.camera.far = 200;\n scene.add(sun);\n\n scene.background = new THREE.Color(0x2b2622);\n scene.add(new THREE.HemisphereLight(0xffe9c8, 0x6a5a48, 1.8)); sun.position.set(-6, 8, -4); sun.intensity = 1.6;\n const wall = std(0xcfc4b0), floor = std(0x8a6a4a);\n // corridor z 6 .. 0, living room z 0 .. -9\n add(new THREE.PlaneGeometry(4, 6).rotateX(-Math.PI / 2), floor, 0, 0, 3, "corr_floor");\n add(new THREE.PlaneGeometry(7, 9).rotateX(-Math.PI / 2), floor, 0, 0, -4.5, "room_floor");\n add(new THREE.PlaneGeometry(7, 9).rotateX(Math.PI / 2), std(0xe4dccc), 0, 2.8, -4.5, "room_ceiling");\n add(new THREE.PlaneGeometry(4, 6).rotateX(Math.PI / 2), std(0xe4dccc), 0, 2.8, 3, "corr_ceiling");\n for (const x of [-2, 2]) add(new THREE.BoxGeometry(0.15, 2.8, 6), wall, x, 1.4, 3, "corr_wall");\n for (const x of [-3.5, 3.5]) add(new THREE.BoxGeometry(0.15, 2.8, 9), wall, x, 1.4, -4.5, "room_wall");\n add(new THREE.BoxGeometry(1.0, 0.7, 0.15), wall, 0, 2.45, 0, "door_lintel");\n add(new THREE.BoxGeometry(1.5, 2.8, 0.15), wall, -1.25, 1.4, 0, "door_wall_l");\n add(new THREE.BoxGeometry(1.5, 2.8, 0.15), wall, 1.25, 1.4, 0, "door_wall_r");\n // wall with window at far end\n add(new THREE.BoxGeometry(3.4, 2.8, 0.15), wall, -1.8, 1.4, -9, "far_l"); add(new THREE.BoxGeometry(3.4, 2.8, 0.15), wall, 1.8, 1.4, -9, "far_r");\n add(new THREE.BoxGeometry(0.2, 2.8, 0.15), wall, 0, 1.4, -9, "far_mid");\n add(new THREE.PlaneGeometry(0.1, 0.1), std(0xbfd8f0), 0, 1.4, -9.1, "sky_glow").scale.set(70, 28, 1);\n const hinge = new THREE.Group(); hinge.position.set(-0.5, 0, 0); scene.add(hinge);\n add(new THREE.BoxGeometry(1.0, 2.1, 0.06), std(0x6b4a2e), 0.5, 1.05, 0, "door", hinge);\n hinge.rotation.y = 0.3;\n add(new THREE.BoxGeometry(2.2, 0.8, 0.9), std(0x6b7f94), 0, 0.4, -6.2, "sofa");\n add(new THREE.BoxGeometry(2.2, 0.5, 0.2), std(0x6b7f94), 0, 0.95, -6.6, "sofa_back");\n add(new THREE.BoxGeometry(1.2, 0.35, 0.7), std(0x5a3a22), 0, 0.18, -4.6, "table");\n add(new THREE.CylinderGeometry(0.25, 0.25, 1.6, 10), std(0x3d6b45), 2.6, 0.8, -7.5, "plant");\n add(new THREE.BoxGeometry(0.9, 1.0, 0.1), std(0xb05a3a), -3.4, 1.6, -3, "picture");\n add(new THREE.BoxGeometry(0.5, 1.7, 0.4), std(0x2b2b30), -3.0, 0.85, -1.5, "hero_figure");\n return { scene, camera, update(t) {\n const u = clamp01(t / 5);\n hinge.rotation.y = 0.3 + 1.1 * ss(clamp01((t - 1.0) / 1.2));\n const z = lerp(5.5, -4.6, ss(u * 0.85 + 0.15 * u));\n camera.position.set(0.15 * Math.sin(u * 3), 1.55 - 0.1 * ss(clamp01((u - 0.6) / 0.4)), z);\n camera.lookAt(0.1 * Math.sin(u * 3 + 0.5), 1.4, z - 4);\n } };\n}\n'),
)
diff --git a/web/autopilot_chat.js b/web/autopilot_chat.js
index 75f53b5..1fcd5d2 100644
--- a/web/autopilot_chat.js
+++ b/web/autopilot_chat.js
@@ -291,23 +291,28 @@ export function agentChat(t, api, {open, edit, shown = () => true, changed = ()
let sceneRows = null, entryScene = initialScene || null, sceneWaiting = false;
function toggleScenes(open = sceneMenu.hidden) {
sceneMenu.hidden = !open; scenesButton.setAttribute('aria-expanded', String(open));
- if (!open || sceneRows) return;
+ if (!open) return;
+ // One ready-made scene needs no choosing: the button starts it.
+ if (sceneRows?.length === 1) { toggleScenes(false); void runScene(sceneRows[0].id); return; }
+ if (sceneRows) return;
sceneRows = [];
void sceneList(api).then(rows => {
- sceneRows = rows; sceneMenu.replaceChildren(...rows.map(row => {
+ sceneRows = rows;
+ if (rows.length === 1 && !sceneMenu.hidden) { toggleScenes(false); void runScene(rows[0].id); return; }
+ sceneMenu.replaceChildren(...rows.map(row => {
const item = press('fv-chat-scene-item', row.name, () => { toggleScenes(false); void runScene(row.id); });
item.setAttribute('role', 'menuitem'); return item;
}));
}).catch(() => { sceneRows = null; toggleScenes(false); say(t(...SCENE_TEXT.failed) + t('Connection lost. Try again.', '连接中断,请重试。')); });
}
async function runScene(preset, session = state.session) {
- if (!session || stopped) return;
+ if (!session || stopped || sceneWaiting) return;
say(t(...SCENE_TEXT.preparing)); sceneWaiting = true;
try {
const id = await startScene(api, preset, session);
const result = id ? await watchScene(api, id, {stopped: () => stopped}) : {status: 'ready'};
if (result.status === 'failed') { sceneWaiting = false; say(t(...SCENE_TEXT.failed) + (result.error || '')); }
- else if (result.status === 'timeout') { sceneWaiting = false; say(''); }
+ else if (result.status === 'timeout') { sceneWaiting = false; say(t(...SCENE_TEXT.timeout)); }
} catch (failure) { sceneWaiting = false; say(t(...SCENE_TEXT.failed) + reason(failure)); }
}
form.append(input, scenesButton, whiteboxButton, sendButton); scroller.append(log); main.append(scroller, down, sceneMenu, form); element.append(main);
diff --git a/web/whitebox_scenes.js b/web/whitebox_scenes.js
index 495d818..bec4a06 100644
--- a/web/whitebox_scenes.js
+++ b/web/whitebox_scenes.js
@@ -6,6 +6,7 @@ export const SCENE_TEXT = Object.freeze({
icon: 'M4 5h7v6H4zM13 5h7v6h-7zM4 13h7v6H4zM13 13h7v6h-7z',
label: ['Ready-made', '现成场景'], name: ['Start from a ready-made white-model scene', '用现成的白模场景开始'],
preparing: ['Preparing the white model…', '正在准备白模…'], failed: ['The white model could not be made: ', '白模没有做成:'],
+ timeout: ['The white model took too long and was not made. Try again.', '白模等了太久,没有做成,请重试。'],
});
export async function sceneList(api) {