Opus Motion Library
根目錄:此 repo 被 clone 進去的資料夾,或目前主機專案內部的複本。先閱讀該處的 AGENTS.md — 決策程序、圖層規則、網頁效能規則與反模式。然後閱讀 docs/CHOOSING.md(意圖 → 動畫)和 docs/INTEGRATION.md(依技術棧)。
1. 選擇(絕不憑記憶猜測)
node cli/mgl.mjs suggest "<使用者描述的簡要說明>"— 對 ★ 配方和動畫進行排名,解釋原因,並輸出 props 片段。支援篩選--overlay --image --text --loop --light --category <c> --json。node cli/mgl.mjs recipes— 即用混合(預覽圖位於recipes/previews/<id>.jpg):hero-aurora-night、hero-paper-sketch、hero-blueprint-logo、product-launch、stats-reveal、testimonial-chat、testimonial-quote、loading-loop、section-divider、success-celebration、error-glitch、onboarding-steps、event-countdown、music-neon-promo、ocean-explainer、history-timeline、app-store-preview (9:16)、social-short-captions (9:16)、end-card。node cli/mgl.mjs info <id>— props +roles、overlay/overlayProps、loopable、mood、weight、pairsWith、textProps。- 混合 = 背景 + 主體 + 類型 + 細微強調;每個鏡頭一個主視覺;淡化支援層;取代所有範例文字;傳入品牌顏色。
2. 影片(Remotion)
node cli/mgl.mjs render <id> --props '{"key":"value"}' [--format landscape|square|portrait] [--frames N] --out out/<name>.mp4
node cli/mgl.mjs recipe <id> --overrides '{"<motion-id>":{…}}' [--format …] --out out/<name>.mp4
node cli/mgl.mjs still <id> --at 10,60,120 --out out/<name>-sheet.jpg # 先預覽,再讀取表單
node cli/mgl.mjs compose specs/<name>.json --out out/<name>.mp4 # scenes[] (motion 或 layers[])、transitions、overlays、audio
node cli/direct.mjs storyboards/<name>.json # 含旁白:本地 Qwen3-TTS -> 字幕 -> 渲染 -> 主影片
圖片:使用 public/ 路徑(例如 "demo/owl.jpg")或 https URL。絕不使用雲端語音/音樂服務;音樂/SFX 來自 public/music、public/sfx。
在另一個 Remotion 專案內:node cli/mgl.mjs add <motions|recipes> --to <host>/src(只複製必要的原始碼 + 本地註冊表;會印出 npm install 指令)。
3. 網站 / 網頁應用程式
- 在函式庫中執行
npm run build:lib,然後import {MotionBackground, MotionPlayer, MotionMix} from 'opus-motion-library/web'(Vite:設定resolve.dedupe處理 react/remotion/@remotion/*/three),或mgl add … --player --to <app>/src(Next.js:從'use client'檔案中使用)。 - 純 HTML / WordPress / Vue / Svelte:
<script src="opus-motion.element.js">+<opus-motion recipe="…" background>/<opus-motion motion="…" props='{…}'>。 - HTML 中的文字可疊在
MotionBackground上方(它會移除type圖層);overlay動畫會浮在頁面上;playOnView、 reduced-motion 靜止畫面、懶加載掛載、每個視口最多 2 個活躍播放器;重度 3D 請在手機上使用匯出的影片。 - 提供所使用的函式庫
public/檔案(或assetBase/ 絕對 URL)。
4. 原生應用程式、簡報、編輯器
node cli/mgl.mjs export <motion|recipe> --as mp4|webm|webm-alpha|prores-alpha|gif|png|poster [--format …] [--props …]
(Alpha 匯出會套用 overlayProps;可使用 ffprobe -c:v libvpx-vp9 … pix_fmt 檢查 → yuva420p)。
5. 交接前檢查
將渲染結果拼成圖格(ffmpeg -i out/x.mp4 -vf "fps=1,scale=480:-2,tile=6x5" -frames:v 1 out/x-sheet.jpg)或截取頁面
(node examples/screenshot.mjs <url> <dir> --targets "top,#section" — 兩張截圖間隔 1 秒,回報變動百分比),進行檢查並修正。
新增動畫至函式庫
請遵循 docs/AUTHORING.md,將動畫放入 src/motions/<family>/<id>.tsx,執行 node cli/gen-registry.mjs && npx tsc --noEmit && node cli/gen-docs.mjs;
可選地執行 node cli/probe-meta.mjs --only <id>(測量 loop / overlay / luma)並在 docs/motion-meta.json 中加入覆寫設定。