dsh-game-material-master 0.1.0
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/LICENSE +21 -0
- package/README.md +104 -0
- package/cordis.patch.yml +6 -0
- package/lib/ark.js +128 -0
- package/lib/chroma.js +466 -0
- package/lib/client.js +5106 -0
- package/lib/config.js +252 -0
- package/lib/directions.js +141 -0
- package/lib/imagegen.js +388 -0
- package/lib/index.js +1602 -0
- package/lib/jsonio.js +38 -0
- package/lib/links.js +125 -0
- package/lib/media.js +235 -0
- package/lib/minimax.js +390 -0
- package/lib/pipeline.js +650 -0
- package/lib/png.js +57 -0
- package/lib/rigexport.js +391 -0
- package/lib/riggen.js +3639 -0
- package/lib/rigmesh.js +167 -0
- package/lib/rigpath.js +125 -0
- package/lib/rigpose.js +1872 -0
- package/lib/rigpreview.js +816 -0
- package/lib/rigqa.js +271 -0
- package/lib/rigsemantics.js +411 -0
- package/lib/rigvalidate.js +802 -0
- package/lib/seqgen.js +686 -0
- package/lib/spine.js +1392 -0
- package/lib/store.js +309 -0
- package/lib/tools.js +1365 -0
- package/lib/wire.js +535 -0
- package/package.json +49 -0
package/lib/config.js
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 插件配置:API 凭证、模型选择、以及整条流水线的默认参数。
|
|
3
|
+
*
|
|
4
|
+
* 落盘位置:`${DSH_HOME:-~/.dsh}/game-material-master/config.json`。
|
|
5
|
+
* Key 只存在宿主本机,从不回传给浏览器明文(`maskConfig` 负责脱敏)。
|
|
6
|
+
*/
|
|
7
|
+
import { mkdir, readFile, rename, stat, writeFile } from "node:fs/promises";
|
|
8
|
+
import { homedir } from "node:os";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
import { DEFAULT_ROW_ORDER } from "./directions.js";
|
|
11
|
+
/**
|
|
12
|
+
* 上一版的默认行序(按生成依赖顺序)。方位语义修正后,默认改成罗盘顺时针;
|
|
13
|
+
* 配置里还留着旧默认值的用户应当自动迁过去,而不是被卡在旧顺序上。
|
|
14
|
+
*/
|
|
15
|
+
const LEGACY_ROW_ORDER = ["front", "back", "downLeft", "downRight", "upLeft", "upRight", "left", "right"];
|
|
16
|
+
/**
|
|
17
|
+
* 行序语义版本。1 = 旧的生成依赖顺序,2 = 罗盘顺时针。
|
|
18
|
+
* 迁移只在「没有版本号且恰好等于旧默认值」时发生一次,之后用户显式设成
|
|
19
|
+
* 任何顺序(哪怕是旧默认那串)都会被尊重,不会被反复迁走。
|
|
20
|
+
*/
|
|
21
|
+
export const ROW_ORDER_VERSION = 2;
|
|
22
|
+
/** 判断一份行序是不是「上一版的默认值」。 */
|
|
23
|
+
export function isLegacyRowOrder(order) {
|
|
24
|
+
return (Array.isArray(order) &&
|
|
25
|
+
order.length === LEGACY_ROW_ORDER.length &&
|
|
26
|
+
order.every((key, index) => key === LEGACY_ROW_ORDER[index]));
|
|
27
|
+
}
|
|
28
|
+
import { COMP_SHARE_MODEL_ID, normalizeDuration, normalizeResolution, rootOf } from "./minimax.js";
|
|
29
|
+
export function dshHome() {
|
|
30
|
+
const raw = process.env.DSH_HOME?.trim();
|
|
31
|
+
return raw && raw !== "" ? raw : join(homedir(), ".dsh");
|
|
32
|
+
}
|
|
33
|
+
export function dataRoot() {
|
|
34
|
+
return join(dshHome(), "game-material-master");
|
|
35
|
+
}
|
|
36
|
+
export function configPath() {
|
|
37
|
+
return join(dataRoot(), "config.json");
|
|
38
|
+
}
|
|
39
|
+
/** 八方向图模块的项目根。 */
|
|
40
|
+
export function projectsRoot() {
|
|
41
|
+
return join(dataRoot(), "projects");
|
|
42
|
+
}
|
|
43
|
+
/** 图片生成模块的任务根。 */
|
|
44
|
+
export function imageJobsRoot() {
|
|
45
|
+
return join(dataRoot(), "image-jobs");
|
|
46
|
+
}
|
|
47
|
+
/** 序列帧生成模块的任务根。 */
|
|
48
|
+
export function sequenceJobsRoot() {
|
|
49
|
+
return join(dataRoot(), "sequence-jobs");
|
|
50
|
+
}
|
|
51
|
+
/** 骨骼动画生成模块的任务根。 */
|
|
52
|
+
export function rigJobsRoot() {
|
|
53
|
+
return join(dataRoot(), "rig-jobs");
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 旧版本把数据放在 `8dir-sprites/`。第一次以新名字启动时整体搬过去,
|
|
57
|
+
* 让已有项目和配置无缝接上——只搬一次,之后两个目录互不影响。
|
|
58
|
+
*/
|
|
59
|
+
export async function migrateLegacyDataRoot() {
|
|
60
|
+
const legacy = join(dshHome(), "8dir-sprites");
|
|
61
|
+
const current = dataRoot();
|
|
62
|
+
try {
|
|
63
|
+
await stat(legacy);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
await stat(current);
|
|
70
|
+
return false; // 新目录已存在,不动
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
/* 新目录不存在,执行迁移 */
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
await rename(legacy, current);
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export const DEFAULT_CONFIG = {
|
|
84
|
+
arkApiKey: "",
|
|
85
|
+
arkBaseUrl: "https://ark.cn-beijing.volces.com/api/v3",
|
|
86
|
+
arkModel: "doubao-seedream-4-0-250828",
|
|
87
|
+
/** 默认跟随主模型;需要时可在设置里单独指定。 */
|
|
88
|
+
arkRedrawModel: "",
|
|
89
|
+
arkSize: "2K",
|
|
90
|
+
arkWatermark: false,
|
|
91
|
+
arkTimeoutMs: 180000,
|
|
92
|
+
minimaxApiKey: "",
|
|
93
|
+
minimaxBaseUrl: "https://api.minimaxi.com",
|
|
94
|
+
minimaxModel: "MiniMax-H3",
|
|
95
|
+
minimaxDuration: 5,
|
|
96
|
+
minimaxResolution: "2K",
|
|
97
|
+
minimaxPromptOptimizer: true,
|
|
98
|
+
minimaxTimeoutMs: 120000,
|
|
99
|
+
cellWidth: 256,
|
|
100
|
+
cellHeight: 256,
|
|
101
|
+
frameCount: 8,
|
|
102
|
+
fitMode: "contain",
|
|
103
|
+
workingLongEdge: 768,
|
|
104
|
+
pixelSize: 0,
|
|
105
|
+
autoCrop: true,
|
|
106
|
+
fillRatio: 0.94,
|
|
107
|
+
bottomMargin: 2,
|
|
108
|
+
cropInset: 0,
|
|
109
|
+
keyLow: 14,
|
|
110
|
+
keyHigh: 80,
|
|
111
|
+
despill: 0.65,
|
|
112
|
+
bgTolerance: 90,
|
|
113
|
+
edgeShrink: 0,
|
|
114
|
+
rowOrder: [...DEFAULT_ROW_ORDER],
|
|
115
|
+
rowOrderVersion: ROW_ORDER_VERSION,
|
|
116
|
+
concurrency: 3
|
|
117
|
+
};
|
|
118
|
+
export const ARK_MODEL_PRESETS = [
|
|
119
|
+
{ id: "doubao-seedream-4-0-250828", label: "Seedream 4.0(通用、支持图组)" },
|
|
120
|
+
{ id: "doubao-seedream-4-5-251128", label: "Seedream 4.5" },
|
|
121
|
+
{ id: "doubao-seedream-5-0-260128", label: "Seedream 5.0 Lite(支持 PNG 输出)" },
|
|
122
|
+
{ id: "doubao-seedream-5-0-pro-260628", label: "Seedream 5.0 Pro(单图质量最好)" }
|
|
123
|
+
];
|
|
124
|
+
export const MINIMAX_HOST_PRESETS = [
|
|
125
|
+
{ id: "https://api.minimaxi.com", label: "国际站 api.minimaxi.com" },
|
|
126
|
+
{ id: "https://api.minimax.cn", label: "国内站 api.minimax.cn" }
|
|
127
|
+
];
|
|
128
|
+
/**
|
|
129
|
+
* 视频模型下拉。优云智算版 H3 与官方 H3 是同一个模型,只是走第三方网关,
|
|
130
|
+
* 所以做成一个独立的可选项——由用户显式选择,而不是从 Base URL / Key 前缀去猜。
|
|
131
|
+
*/
|
|
132
|
+
export const MINIMAX_MODEL_PRESETS = [
|
|
133
|
+
{ id: "MiniMax-H3", label: "MiniMax-H3(v2 · 768P/2K · 4~15 秒,推荐)" },
|
|
134
|
+
{ id: COMP_SHARE_MODEL_ID, label: "优云智算网关 · 768P/1080P/2K · 4~30 秒" },
|
|
135
|
+
{ id: "MiniMax-H3-Max", label: "MiniMax-H3-Max(v2 极速 · 480P/768P · 5~15 秒)" },
|
|
136
|
+
{ id: "MiniMax-Hailuo-02", label: "MiniMax-Hailuo-02(v1 · 6/10 秒)" },
|
|
137
|
+
{ id: "I2V-01-Director", label: "I2V-01-Director(v1 · 支持运镜指令)" },
|
|
138
|
+
{ id: "I2V-01", label: "I2V-01(v1)" },
|
|
139
|
+
{ id: "I2V-01-live", label: "I2V-01-live(v1)" }
|
|
140
|
+
];
|
|
141
|
+
function asInt(value, fallback, min, max) {
|
|
142
|
+
const n = typeof value === "number" ? value : Number.parseInt(String(value ?? ""), 10);
|
|
143
|
+
if (!Number.isFinite(n))
|
|
144
|
+
return fallback;
|
|
145
|
+
return Math.min(max, Math.max(min, Math.round(n)));
|
|
146
|
+
}
|
|
147
|
+
function asBool(value, fallback) {
|
|
148
|
+
return typeof value === "boolean" ? value : fallback;
|
|
149
|
+
}
|
|
150
|
+
function asString(value, fallback) {
|
|
151
|
+
return typeof value === "string" ? value : fallback;
|
|
152
|
+
}
|
|
153
|
+
function asNumber(value, fallback, min, max) {
|
|
154
|
+
const n = typeof value === "number" ? value : Number.parseFloat(String(value ?? ""));
|
|
155
|
+
if (!Number.isFinite(n))
|
|
156
|
+
return fallback;
|
|
157
|
+
return Math.min(max, Math.max(min, n));
|
|
158
|
+
}
|
|
159
|
+
/** 把任意读入的 JSON 收敛成一份合法配置,缺项一律回落默认值。 */
|
|
160
|
+
export function normalizeConfig(input) {
|
|
161
|
+
const raw = (input ?? {});
|
|
162
|
+
const rowOrderRaw = Array.isArray(raw.rowOrder) ? raw.rowOrder.filter((k) => typeof k === "string") : [];
|
|
163
|
+
// 一次性迁移:只有「没有版本号」的旧配置才会被迁到罗盘顺序。
|
|
164
|
+
const needsOrderMigration = raw.rowOrderVersion === undefined && isLegacyRowOrder(rowOrderRaw);
|
|
165
|
+
const rowOrder = rowOrderRaw.length === 0 || needsOrderMigration ? [...DEFAULT_ROW_ORDER] : rowOrderRaw;
|
|
166
|
+
const keyLow = asInt(raw.keyLow, DEFAULT_CONFIG.keyLow, 0, 255);
|
|
167
|
+
// 上限必须严格大于下限,否则抠像区间为空;单独改任一项时自动让路。
|
|
168
|
+
const keyHigh = Math.min(255, Math.max(keyLow + 1, asInt(raw.keyHigh, DEFAULT_CONFIG.keyHigh, 1, 255)));
|
|
169
|
+
// 视频参数都跟着模型走:换到 H3 之后旧的 `1080P` / `6 秒` 未必合法;
|
|
170
|
+
// 选「优云智算版 H3」时档位放宽到 1080P、4~30 秒。
|
|
171
|
+
const minimaxModel = asString(raw.minimaxModel, DEFAULT_CONFIG.minimaxModel);
|
|
172
|
+
const minimaxBaseUrl = rootOf(asString(raw.minimaxBaseUrl, DEFAULT_CONFIG.minimaxBaseUrl)) || DEFAULT_CONFIG.minimaxBaseUrl;
|
|
173
|
+
const minimaxDuration = normalizeDuration(minimaxModel, raw.minimaxDuration ?? DEFAULT_CONFIG.minimaxDuration);
|
|
174
|
+
const minimaxResolution = normalizeResolution(minimaxModel, raw.minimaxResolution ?? DEFAULT_CONFIG.minimaxResolution);
|
|
175
|
+
return {
|
|
176
|
+
arkApiKey: asString(raw.arkApiKey, DEFAULT_CONFIG.arkApiKey),
|
|
177
|
+
arkBaseUrl: asString(raw.arkBaseUrl, DEFAULT_CONFIG.arkBaseUrl).replace(/\/+$/, ""),
|
|
178
|
+
arkModel: asString(raw.arkModel, DEFAULT_CONFIG.arkModel),
|
|
179
|
+
arkRedrawModel: asString(raw.arkRedrawModel, DEFAULT_CONFIG.arkRedrawModel),
|
|
180
|
+
arkSize: asString(raw.arkSize, DEFAULT_CONFIG.arkSize),
|
|
181
|
+
arkWatermark: asBool(raw.arkWatermark, DEFAULT_CONFIG.arkWatermark),
|
|
182
|
+
arkTimeoutMs: asInt(raw.arkTimeoutMs, DEFAULT_CONFIG.arkTimeoutMs, 10000, 900000),
|
|
183
|
+
minimaxApiKey: asString(raw.minimaxApiKey, DEFAULT_CONFIG.minimaxApiKey),
|
|
184
|
+
minimaxBaseUrl,
|
|
185
|
+
minimaxModel,
|
|
186
|
+
minimaxDuration,
|
|
187
|
+
minimaxResolution,
|
|
188
|
+
minimaxPromptOptimizer: asBool(raw.minimaxPromptOptimizer, DEFAULT_CONFIG.minimaxPromptOptimizer),
|
|
189
|
+
minimaxTimeoutMs: asInt(raw.minimaxTimeoutMs, DEFAULT_CONFIG.minimaxTimeoutMs, 10000, 900000),
|
|
190
|
+
cellWidth: asInt(raw.cellWidth, DEFAULT_CONFIG.cellWidth, 16, 2048),
|
|
191
|
+
cellHeight: asInt(raw.cellHeight, DEFAULT_CONFIG.cellHeight, 16, 2048),
|
|
192
|
+
frameCount: asInt(raw.frameCount, DEFAULT_CONFIG.frameCount, 1, 64),
|
|
193
|
+
fitMode: raw.fitMode === "stretch" ? "stretch" : "contain",
|
|
194
|
+
workingLongEdge: asInt(raw.workingLongEdge, DEFAULT_CONFIG.workingLongEdge, 128, 2048),
|
|
195
|
+
pixelSize: asInt(raw.pixelSize, DEFAULT_CONFIG.pixelSize, 0, 32),
|
|
196
|
+
autoCrop: asBool(raw.autoCrop, DEFAULT_CONFIG.autoCrop),
|
|
197
|
+
fillRatio: asNumber(raw.fillRatio, DEFAULT_CONFIG.fillRatio, 0.5, 1),
|
|
198
|
+
bottomMargin: asInt(raw.bottomMargin, DEFAULT_CONFIG.bottomMargin, 0, 64),
|
|
199
|
+
cropInset: asNumber(raw.cropInset, DEFAULT_CONFIG.cropInset, 0, 0.2),
|
|
200
|
+
keyLow,
|
|
201
|
+
keyHigh,
|
|
202
|
+
despill: asNumber(raw.despill, DEFAULT_CONFIG.despill, 0, 1),
|
|
203
|
+
bgTolerance: asInt(raw.bgTolerance, DEFAULT_CONFIG.bgTolerance, 0, 160),
|
|
204
|
+
edgeShrink: asInt(raw.edgeShrink, DEFAULT_CONFIG.edgeShrink, 0, 8),
|
|
205
|
+
rowOrder,
|
|
206
|
+
rowOrderVersion: ROW_ORDER_VERSION,
|
|
207
|
+
concurrency: asInt(raw.concurrency, DEFAULT_CONFIG.concurrency, 1, 8)
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
let cache;
|
|
211
|
+
export async function loadConfig() {
|
|
212
|
+
if (cache !== undefined)
|
|
213
|
+
return cache;
|
|
214
|
+
try {
|
|
215
|
+
const text = await readFile(configPath(), "utf8");
|
|
216
|
+
cache = normalizeConfig(JSON.parse(text));
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
cache = { ...DEFAULT_CONFIG, rowOrder: [...DEFAULT_ROW_ORDER] };
|
|
220
|
+
}
|
|
221
|
+
return cache;
|
|
222
|
+
}
|
|
223
|
+
export async function saveConfig(patch) {
|
|
224
|
+
const current = await loadConfig();
|
|
225
|
+
const next = normalizeConfig({ ...current, ...patch });
|
|
226
|
+
await mkdir(dataRoot(), { recursive: true });
|
|
227
|
+
const target = configPath();
|
|
228
|
+
const tmp = `${target}.tmp`;
|
|
229
|
+
await writeFile(tmp, `${JSON.stringify(next, null, 2)}\n`, "utf8");
|
|
230
|
+
await rename(tmp, target);
|
|
231
|
+
cache = next;
|
|
232
|
+
return next;
|
|
233
|
+
}
|
|
234
|
+
export function maskConfig(config) {
|
|
235
|
+
const { arkApiKey, minimaxApiKey, ...rest } = config;
|
|
236
|
+
return {
|
|
237
|
+
...rest,
|
|
238
|
+
rowOrder: [...config.rowOrder],
|
|
239
|
+
arkApiKeySet: arkApiKey.trim() !== "",
|
|
240
|
+
arkApiKeyHint: hintOf(arkApiKey),
|
|
241
|
+
minimaxApiKeySet: minimaxApiKey.trim() !== "",
|
|
242
|
+
minimaxApiKeyHint: hintOf(minimaxApiKey)
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function hintOf(key) {
|
|
246
|
+
const trimmed = key.trim();
|
|
247
|
+
if (trimmed === "")
|
|
248
|
+
return "";
|
|
249
|
+
if (trimmed.length <= 8)
|
|
250
|
+
return "已配置";
|
|
251
|
+
return `…${trimmed.slice(-4)}`;
|
|
252
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 八方向定义与默认提示词。
|
|
3
|
+
*
|
|
4
|
+
* ── 方位约定 ──────────────────────────────────────────────────────────────
|
|
5
|
+
* 这是 RPG 地图上的八方向行走,不是「抬头 / 低头」。约定画面上方为北:
|
|
6
|
+
*
|
|
7
|
+
* N 北 = 屏幕上方 = 背对镜头,看不到脸
|
|
8
|
+
* NE 东北 = 屏幕右上 = 四分之三背面,看不到脸
|
|
9
|
+
* E 东 = 屏幕右侧 = 右侧脸
|
|
10
|
+
* SE 东南 = 屏幕右下 = 四分之三正面,看得见脸
|
|
11
|
+
* S 南 = 屏幕下方 = 正对镜头,完整正脸
|
|
12
|
+
* SW 西南 = 屏幕左下 = 四分之三正面,看得见脸
|
|
13
|
+
* W 西 = 屏幕左侧 = 左侧脸
|
|
14
|
+
* NW 西北 = 屏幕左上 = 四分之三背面,看不到脸
|
|
15
|
+
*
|
|
16
|
+
* 「看不见脸 / 侧脸 / 看得见脸」完全由 Y 轴朝向决定:朝北(屏幕上方)走就是
|
|
17
|
+
* 背对镜头。提示词必须把**转身**和**视线**分开写——只说「朝左上方」时模型
|
|
18
|
+
* 经常理解成抬头仰视,这是上一版提示词的毛病。
|
|
19
|
+
*
|
|
20
|
+
* ── 生成顺序 ──────────────────────────────────────────────────────────────
|
|
21
|
+
* DIRECTIONS 的数组顺序 = 生成顺序(依赖顺序),同层内可并发:
|
|
22
|
+
* 1. front ← 源图
|
|
23
|
+
* 2. back ← front
|
|
24
|
+
* 3. downLeft / downRight ← front
|
|
25
|
+
* 4. upLeft / upRight ← back
|
|
26
|
+
* 5. left / right ← front + back
|
|
27
|
+
*/
|
|
28
|
+
export const DIRECTIONS = [
|
|
29
|
+
{
|
|
30
|
+
key: "front",
|
|
31
|
+
compass: "S",
|
|
32
|
+
label: "南 · 正对镜头",
|
|
33
|
+
facing: "角色向正南行走(约定:画面上方为北、下方为南),正面朝着镜头迎面走来。",
|
|
34
|
+
visibility: "完整正脸:双眼、鼻子、嘴全部清晰可见,视线水平看向镜头。身体正对镜头,不要侧身。",
|
|
35
|
+
refs: ["source"]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
key: "back",
|
|
39
|
+
compass: "N",
|
|
40
|
+
label: "北 · 背对镜头",
|
|
41
|
+
facing: "角色向正北行走(画面上方为北),背对镜头向画面深处走去。",
|
|
42
|
+
visibility: "完全看不到脸:镜头拍到的是**正背面**——后脑勺、头发后侧与平整的后背。不得出现眼睛、鼻子、嘴或任何五官。也不要侧身。",
|
|
43
|
+
refs: ["front"]
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
key: "downLeft",
|
|
47
|
+
compass: "SW",
|
|
48
|
+
label: "西南 · 四分之三正面",
|
|
49
|
+
facing: "角色向西南行走(约定:画面左下方为西南),身体绕竖轴转向镜头的左前方约 45 度。",
|
|
50
|
+
visibility: "能看到正脸,但脸和身体一起明显转向画面左侧约 45 度(四分之三正面):双眼都可见,右耳比左耳更靠近镜头,鼻尖指向画面左下。不要正对镜头。",
|
|
51
|
+
refs: ["front"]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
key: "downRight",
|
|
55
|
+
compass: "SE",
|
|
56
|
+
label: "东南 · 四分之三正面",
|
|
57
|
+
facing: "角色向东南行走(约定:画面右下方为东南),身体绕竖轴转向镜头的右前方约 45 度。",
|
|
58
|
+
visibility: "能看到正脸,但脸和身体一起明显转向画面右侧约 45 度(四分之三正面):双眼都可见,左耳比右耳更靠近镜头,鼻尖指向画面右下。不要正对镜头。",
|
|
59
|
+
refs: ["front"]
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
key: "upLeft",
|
|
63
|
+
compass: "NW",
|
|
64
|
+
label: "西北 · 四分之三背面",
|
|
65
|
+
facing: "角色向西北行走(画面左上方为西北),背对镜头,身体绕竖轴转开约 45 度。",
|
|
66
|
+
visibility: "完全看不到脸:只看到后脑勺、头发后侧,以及后背偏左的一侧(身体绕竖轴侧转约 45 度,不是正背面)。不得出现眼睛、鼻子、嘴或任何五官。",
|
|
67
|
+
refs: ["back"]
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
key: "upRight",
|
|
71
|
+
compass: "NE",
|
|
72
|
+
label: "东北 · 四分之三背面",
|
|
73
|
+
facing: "角色向东北行走(画面右上方为东北),背对镜头,身体绕竖轴转开约 45 度。",
|
|
74
|
+
visibility: "完全看不到脸:只看到后脑勺、头发后侧,以及后背偏右的一侧(身体绕竖轴侧转约 45 度,不是正背面)。不得出现眼睛、鼻子、嘴或任何五官。",
|
|
75
|
+
refs: ["back"]
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
key: "left",
|
|
79
|
+
compass: "W",
|
|
80
|
+
label: "西 · 左侧脸",
|
|
81
|
+
facing: "角色向正西行走(约定:画面左侧为西),朝画面左侧行走。",
|
|
82
|
+
visibility: "镜头拍到的是角色的左侧面:身体完全侧对镜头,两只肩膀一前一后、连线与画面垂直,鼻尖指向画面左侧,视线与画面平行、不看镜头。只能看到左半边侧脸——左眼的侧面轮廓、鼻梁侧影、左半边嘴;看不到右眼,右半边脸被头部完全挡住。不要正对镜头,也不要背对镜头。",
|
|
83
|
+
refs: ["front", "back"]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
key: "right",
|
|
87
|
+
compass: "E",
|
|
88
|
+
label: "东 · 右侧脸",
|
|
89
|
+
facing: "角色向正东行走(约定:画面右侧为东),朝画面右侧行走。",
|
|
90
|
+
visibility: "镜头拍到的是角色的右侧面:身体完全侧对镜头,两只肩膀一前一后、连线与画面垂直,鼻尖指向画面右侧,视线与画面平行、不看镜头。只能看到右半边侧脸——右眼的侧面轮廓、鼻梁侧影、右半边嘴;看不到左眼,左半边脸被头部完全挡住。不要正对镜头,也不要背对镜头。",
|
|
91
|
+
refs: ["front", "back"]
|
|
92
|
+
}
|
|
93
|
+
];
|
|
94
|
+
export const DIRECTION_KEYS = DIRECTIONS.map((d) => d.key);
|
|
95
|
+
export function directionOf(key) {
|
|
96
|
+
return DIRECTIONS.find((d) => d.key === key);
|
|
97
|
+
}
|
|
98
|
+
/** 罗盘顺时针顺序,用于整图行序。 */
|
|
99
|
+
export const COMPASS_ORDER = ["N", "NE", "E", "SE", "S", "SW", "W", "NW"];
|
|
100
|
+
/** 默认整图行序:北 → 东北 → 东 → 东南 → 南 → 西南 → 西 → 西北(罗盘顺时针)。 */
|
|
101
|
+
export const DEFAULT_ROW_ORDER = COMPASS_ORDER.map((compass) => DIRECTIONS.find((direction) => direction.compass === compass)?.key ?? "").filter((key) => key !== "");
|
|
102
|
+
/**
|
|
103
|
+
* 生图提示词模板。
|
|
104
|
+
*
|
|
105
|
+
* `{facing}` 只描述**转身**(角色朝哪个方位走),`{visibility}` 描述**镜头看到什么**。
|
|
106
|
+
* 两者必须分开写:合成一句时,模型会把「朝画面左上方」理解成抬头仰视。
|
|
107
|
+
*/
|
|
108
|
+
export const DEFAULT_IMAGE_PROMPT = [
|
|
109
|
+
"【机位】固定正对角色的摄像机,镜头与角色胸口齐平,不俯视也不仰视。角色直立站在地面上,双脚着地。",
|
|
110
|
+
"【转身方式】角色只绕自身竖直轴转身来改变面朝的方向,身体始终保持直立。严格禁止抬头、低头、仰视、俯视、弯腰、后仰或身体倾斜;视线始终水平,既不向上看也不向下看。",
|
|
111
|
+
"【一致性】以下所有图都是同一个角色在原地绕竖轴转身得到的,身高、体型、脸型、发型、服装、配色必须完全一致,只有身体朝向不同。",
|
|
112
|
+
"【主体】把参考图中的人物当作唯一主体,完整保留其五官、发型、发色、服装款式、配色和整体画风,必须看起来是同一个人。",
|
|
113
|
+
"【朝向】{facing}",
|
|
114
|
+
"【可见部位】{visibility}",
|
|
115
|
+
"【画风】平涂赛璐璐上色,色块边界清晰,避免写实光影、渐变、景深与噪点。",
|
|
116
|
+
"【背景】纯色绿幕,颜色是标准 chroma key 绿 #00FF00,整幅背景颜色完全均匀一致,不要任何阴影、渐变或噪点。",
|
|
117
|
+
"【硬性要求】背景必须绝对纯净:不要地面、不要投影、不要文字、不要边框、不要棋盘格、不要任何道具或装饰。人物是画面中唯一对象,尽量占满画面高度(约 80%),全身完整居中且不裁切、不被遮挡。"
|
|
118
|
+
].join("\n");
|
|
119
|
+
/**
|
|
120
|
+
* 视频提示词模板(MiniMax 图生视频)。
|
|
121
|
+
* 同样要防俯仰:视频模型也会把「朝上」理解成抬头。
|
|
122
|
+
*/
|
|
123
|
+
export const DEFAULT_VIDEO_PROMPT = [
|
|
124
|
+
"[Static shot] 固定机位、固定焦距、固定构图,镜头完全静止不动,镜头高度与角色胸口齐平,不俯视也不仰视。绿幕背景保持原样不变。",
|
|
125
|
+
"画面中只有这一个角色,保持图中的朝向和位置不变——不要转身、不要改变面朝的方向。原地做出自然的行走动作:双腿交替迈步,手臂自然摆动,完整走三步。",
|
|
126
|
+
"行走过程中身体保持直立,视线始终水平,不要抬头、低头或身体起伏变形。",
|
|
127
|
+
"保持平涂色块和干净的绿幕,不要补充纹理、光影或背景细节。",
|
|
128
|
+
"不要走出画面、不要出现第二个人或任何其它物体,不出现转场、抖动、缩放、运镜或镜头移动。"
|
|
129
|
+
].join("\n");
|
|
130
|
+
/** 把模板里的两个占位符换成具体方向的描述。 */
|
|
131
|
+
export function fillImagePrompt(template, facing, visibility) {
|
|
132
|
+
return template.replace(/\{facing\}/g, facing).replace(/\{visibility\}/g, visibility);
|
|
133
|
+
}
|
|
134
|
+
/** 把八方向默认提示词装配成一张表(每个方向一份,可单独编辑)。 */
|
|
135
|
+
export function defaultImagePrompts() {
|
|
136
|
+
const out = {};
|
|
137
|
+
for (const direction of DIRECTIONS) {
|
|
138
|
+
out[direction.key] = fillImagePrompt(DEFAULT_IMAGE_PROMPT, direction.facing, direction.visibility);
|
|
139
|
+
}
|
|
140
|
+
return out;
|
|
141
|
+
}
|