dsh-game-material-master 0.2.0 → 0.3.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/lib/config.js CHANGED
@@ -52,6 +52,10 @@ export function sequenceJobsRoot() {
52
52
  export function rigJobsRoot() {
53
53
  return join(dataRoot(), "rig-jobs");
54
54
  }
55
+ /** 地图地块生成模块的项目根。 */
56
+ export function tileJobsRoot() {
57
+ return join(dataRoot(), "tile-jobs");
58
+ }
55
59
  /**
56
60
  * 旧版本把数据放在 `8dir-sprites/`。第一次以新名字启动时整体搬过去,
57
61
  * 让已有项目和配置无缝接上——只搬一次,之后两个目录互不影响。
@@ -83,7 +87,21 @@ export async function migrateLegacyDataRoot() {
83
87
  export const DEFAULT_CONFIG = {
84
88
  arkApiKey: "",
85
89
  arkBaseUrl: "https://ark.cn-beijing.volces.com/api/v3",
86
- arkModel: "doubao-seedream-4-0-250828",
90
+ /**
91
+ * 默认模型。
92
+ *
93
+ * ⚠️ **不要改回 `doubao-seedream-4-0-*`。** 实测(同一张洋红菱形模板 + 同一段
94
+ * 模板填充提示词,各一次调用):
95
+ *
96
+ * | 模型 | 输出 | 菱形包围盒比例 | 结果是 |
97
+ * |---|---|---|---|
98
+ * | `doubao-seedream-4-0-250828` | **JPEG**(背景烧进 RGB) | **1.058** | 量不出菱形,只能回退模板几何 |
99
+ * | `doubao-seedream-5-0-flash-260915` | PNG | **1.987** | 测量可信,直接规整 |
100
+ *
101
+ * 4.0 会把「2:1 等距菱形」画成一个**接近正方形**的形状 —— 提示词里写满了
102
+ * 「顶点位置必须与参考图一致」也没用。地图地块模块依赖这个几何,所以 4.0 不可用。
103
+ */
104
+ arkModel: "doubao-seedream-5-0-flash-260915",
87
105
  /** 默认跟随主模型;需要时可在设置里单独指定。 */
88
106
  arkRedrawModel: "",
89
107
  arkSize: "2K",
@@ -116,10 +134,13 @@ export const DEFAULT_CONFIG = {
116
134
  concurrency: 3
117
135
  };
118
136
  export const ARK_MODEL_PRESETS = [
119
- { id: "doubao-seedream-4-0-250828", label: "Seedream 4.0(通用、支持图组)" },
137
+ // 地图地块模块对几何很敏感:4.0 会把 2:1 等距菱形画成近正方形(实测比例 1.058),
138
+ // 所以它排在最后并明确标注不适合。见 DEFAULT_CONFIG.arkModel 的注释。
139
+ { id: "doubao-seedream-5-0-flash-260915", label: "Seedream 5.0 Flash(默认 · 快且几何准)" },
140
+ { id: "doubao-seedream-5-0-pro-260628", label: "Seedream 5.0 Pro(单图质量最好)" },
141
+ { id: "doubao-seedream-5-0-260128", label: "Seedream 5.0 Lite" },
120
142
  { 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(单图质量最好)" }
143
+ { id: "doubao-seedream-4-0-250828", label: "Seedream 4.0(⚠️ 不支持透明背景,会把等距菱形画变形,地图地块别用)" }
123
144
  ];
124
145
  export const MINIMAX_HOST_PRESETS = [
125
146
  { id: "https://api.minimaxi.com", label: "国际站 api.minimaxi.com" },
package/lib/directions.js CHANGED
@@ -25,6 +25,10 @@
25
25
  * 4. upLeft / upRight ← back
26
26
  * 5. left / right ← front + back
27
27
  */
28
+ /** 把任意输入规整成提示词语言;认不出来的一律按中文。 */
29
+ export function normalizePromptLang(value) {
30
+ return typeof value === "string" && value.trim().toLowerCase().startsWith("en") ? "en" : "zh";
31
+ }
28
32
  export const DIRECTIONS = [
29
33
  {
30
34
  key: "front",
@@ -32,6 +36,8 @@ export const DIRECTIONS = [
32
36
  label: "南 · 正对镜头",
33
37
  facing: "角色向正南行走(约定:画面上方为北、下方为南),正面朝着镜头迎面走来。",
34
38
  visibility: "完整正脸:双眼、鼻子、嘴全部清晰可见,视线水平看向镜头。身体正对镜头,不要侧身。",
39
+ facingEn: "The character walks due south (convention: the top of the image is north, the bottom is south), walking straight toward the camera with the front of the body facing the lens.",
40
+ visibilityEn: "Full front view: both eyes, nose and mouth all clearly visible, gaze horizontal and looking at the camera. The body faces the camera straight on; do not turn the body sideways.",
35
41
  refs: ["source"]
36
42
  },
37
43
  {
@@ -40,6 +46,8 @@ export const DIRECTIONS = [
40
46
  label: "北 · 背对镜头",
41
47
  facing: "角色向正北行走(画面上方为北),背对镜头向画面深处走去。",
42
48
  visibility: "完全看不到脸:镜头拍到的是**正背面**——后脑勺、头发后侧与平整的后背。不得出现眼睛、鼻子、嘴或任何五官。也不要侧身。",
49
+ facingEn: "The character walks due north (the top of the image is north), walking away from the camera toward the depth of the image with its back to the lens.",
50
+ visibilityEn: "The face is completely invisible: the camera captures a **straight back view** - the back of the head, the rear of the hair and the flat back. No eyes, nose, mouth or any facial features may appear. Do not turn the body sideways either.",
43
51
  refs: ["front"]
44
52
  },
45
53
  {
@@ -48,6 +56,8 @@ export const DIRECTIONS = [
48
56
  label: "西南 · 四分之三正面",
49
57
  facing: "角色向西南行走(约定:画面左下方为西南),身体绕竖轴转向镜头的左前方约 45 度。",
50
58
  visibility: "能看到正脸,但脸和身体一起明显转向画面左侧约 45 度(四分之三正面):双眼都可见,右耳比左耳更靠近镜头,鼻尖指向画面左下。不要正对镜头。",
59
+ facingEn: "The character walks southwest (convention: the lower-left of the image is southwest), the body rotating around the vertical axis about 45 degrees to the camera's front-left.",
60
+ visibilityEn: "The front of the face is visible, but the face and body are both clearly turned about 45 degrees toward the left side of the image (a three-quarter front view): both eyes are visible, the right ear is closer to the camera than the left ear, and the tip of the nose points toward the lower-left of the image. Do not face the camera straight on.",
51
61
  refs: ["front"]
52
62
  },
53
63
  {
@@ -56,6 +66,8 @@ export const DIRECTIONS = [
56
66
  label: "东南 · 四分之三正面",
57
67
  facing: "角色向东南行走(约定:画面右下方为东南),身体绕竖轴转向镜头的右前方约 45 度。",
58
68
  visibility: "能看到正脸,但脸和身体一起明显转向画面右侧约 45 度(四分之三正面):双眼都可见,左耳比右耳更靠近镜头,鼻尖指向画面右下。不要正对镜头。",
69
+ facingEn: "The character walks southeast (convention: the lower-right of the image is southeast), the body rotating around the vertical axis about 45 degrees to the camera's front-right.",
70
+ visibilityEn: "The front of the face is visible, but the face and body are both clearly turned about 45 degrees toward the right side of the image (a three-quarter front view): both eyes are visible, the left ear is closer to the camera than the right ear, and the tip of the nose points toward the lower-right of the image. Do not face the camera straight on.",
59
71
  refs: ["front"]
60
72
  },
61
73
  {
@@ -64,6 +76,8 @@ export const DIRECTIONS = [
64
76
  label: "西北 · 四分之三背面",
65
77
  facing: "角色向西北行走(画面左上方为西北),背对镜头,身体绕竖轴转开约 45 度。",
66
78
  visibility: "完全看不到脸:只看到后脑勺、头发后侧,以及后背偏左的一侧(身体绕竖轴侧转约 45 度,不是正背面)。不得出现眼睛、鼻子、嘴或任何五官。",
79
+ facingEn: "The character walks northwest (the upper-left of the image is northwest), with its back to the camera, the body rotated about 45 degrees around the vertical axis.",
80
+ visibilityEn: "The face is completely invisible: only the back of the head, the rear of the hair, and the left-hand side of the back are seen (the body is turned about 45 degrees around the vertical axis, not a straight back view). No eyes, nose, mouth or any facial features may appear.",
67
81
  refs: ["back"]
68
82
  },
69
83
  {
@@ -72,6 +86,8 @@ export const DIRECTIONS = [
72
86
  label: "东北 · 四分之三背面",
73
87
  facing: "角色向东北行走(画面右上方为东北),背对镜头,身体绕竖轴转开约 45 度。",
74
88
  visibility: "完全看不到脸:只看到后脑勺、头发后侧,以及后背偏右的一侧(身体绕竖轴侧转约 45 度,不是正背面)。不得出现眼睛、鼻子、嘴或任何五官。",
89
+ facingEn: "The character walks northeast (the upper-right of the image is northeast), with its back to the camera, the body rotated about 45 degrees around the vertical axis.",
90
+ visibilityEn: "The face is completely invisible: only the back of the head, the rear of the hair, and the right-hand side of the back are seen (the body is turned about 45 degrees around the vertical axis, not a straight back view). No eyes, nose, mouth or any facial features may appear.",
75
91
  refs: ["back"]
76
92
  },
77
93
  {
@@ -80,6 +96,8 @@ export const DIRECTIONS = [
80
96
  label: "西 · 左侧脸",
81
97
  facing: "角色向正西行走(约定:画面左侧为西),朝画面左侧行走。",
82
98
  visibility: "镜头拍到的是角色的左侧面:身体完全侧对镜头,两只肩膀一前一后、连线与画面垂直,鼻尖指向画面左侧,视线与画面平行、不看镜头。只能看到左半边侧脸——左眼的侧面轮廓、鼻梁侧影、左半边嘴;看不到右眼,右半边脸被头部完全挡住。不要正对镜头,也不要背对镜头。",
99
+ facingEn: "The character walks due west (convention: the left side of the image is west), walking toward the left side of the image.",
100
+ visibilityEn: "The camera captures the character's left side: the body is fully in profile to the camera, the two shoulders are one in front of the other with the line between them perpendicular to the image plane, the tip of the nose points toward the left side of the image, and the gaze is parallel to the image plane and not looking at the camera. Only the left half of the profile is visible - the profile contour of the left eye, the side profile of the nose bridge, the left half of the mouth; the right eye cannot be seen, and the right half of the face is completely hidden by the head. Do not face the camera straight on and do not turn your back to the camera.",
83
101
  refs: ["front", "back"]
84
102
  },
85
103
  {
@@ -88,6 +106,8 @@ export const DIRECTIONS = [
88
106
  label: "东 · 右侧脸",
89
107
  facing: "角色向正东行走(约定:画面右侧为东),朝画面右侧行走。",
90
108
  visibility: "镜头拍到的是角色的右侧面:身体完全侧对镜头,两只肩膀一前一后、连线与画面垂直,鼻尖指向画面右侧,视线与画面平行、不看镜头。只能看到右半边侧脸——右眼的侧面轮廓、鼻梁侧影、右半边嘴;看不到左眼,左半边脸被头部完全挡住。不要正对镜头,也不要背对镜头。",
109
+ facingEn: "The character walks due east (convention: the right side of the image is east), walking toward the right side of the image.",
110
+ visibilityEn: "The camera captures the character's right side: the body is fully in profile to the camera, the two shoulders are one in front of the other with the line between them perpendicular to the image plane, the tip of the nose points toward the right side of the image, and the gaze is parallel to the image plane and not looking at the camera. Only the right half of the profile is visible - the profile contour of the right eye, the side profile of the nose bridge, the right half of the mouth; the left eye cannot be seen, and the left half of the face is completely hidden by the head. Do not face the camera straight on and do not turn your back to the camera.",
91
111
  refs: ["front", "back"]
92
112
  }
93
113
  ];
@@ -116,6 +136,23 @@ export const DEFAULT_IMAGE_PROMPT = [
116
136
  "【背景】纯色绿幕,颜色是标准 chroma key 绿 #00FF00,整幅背景颜色完全均匀一致,不要任何阴影、渐变或噪点。",
117
137
  "【硬性要求】背景必须绝对纯净:不要地面、不要投影、不要文字、不要边框、不要棋盘格、不要任何道具或装饰。人物是画面中唯一对象,尽量占满画面高度(约 80%),全身完整居中且不裁切、不被遮挡。"
118
138
  ].join("\n");
139
+ /**
140
+ * `DEFAULT_IMAGE_PROMPT` 的英文版。
141
+ *
142
+ * 两版必须**逐行对应**:段数与 `{facing}` / `{visibility}` 的位置都一样。
143
+ * 中英两版是同一份提示词工程结论,不是「翻译给界面看的」——它们会真的发给生图模型。
144
+ */
145
+ const DEFAULT_IMAGE_PROMPT_EN = [
146
+ "[Camera] Fixed camera positioned directly in front of the character, lens level with the character's chest, neither looking down nor looking up. The character stands upright on the ground, both feet planted on the floor.",
147
+ "[Turn method] The character turns only around its own vertical axis to change the direction it faces, and the body always stays upright. Strictly forbidden: tilting the head up, tilting the head down, looking up, looking down, bending at the waist, leaning backward, or tilting the body. The gaze stays horizontal at all times, neither looking up nor looking down.",
148
+ "[Consistency] All the images below are the same character turning in place around its vertical axis; height, build, face shape, hairstyle, clothing and color scheme must be exactly identical, only the body orientation differs.",
149
+ "[Subject] Treat the person in the reference image as the only subject; fully preserve their facial features, hairstyle, hair color, clothing style, color scheme and overall art style; it must look like the exact same person.",
150
+ "[Facing] {facing}",
151
+ "[Visible parts] {visibility}",
152
+ "[Art style] Flat cel-shaded coloring, crisp boundaries between color blocks, avoid realistic lighting and shading, gradients, depth of field and noise.",
153
+ "[Background] Solid green screen, the color is standard chroma key green #00FF00, the whole background is a completely uniform single color, with no shadows, gradients or noise of any kind.",
154
+ "[Hard requirements] The background must be absolutely clean: no ground, no cast shadow, no text, no border, no checkerboard, no props or decorations of any kind. The character is the only object in the frame, should fill the frame height as much as possible (about 80%), full body complete and centered, not cropped and not occluded."
155
+ ].join("\n");
119
156
  // ── 转圈截帧(「八方向绿幕图」的默认生成方式)──────────────────────────────
120
157
  //
121
158
  // 思路和「逐方向生图」相反:**一次生成、多次截取**。
@@ -145,6 +182,16 @@ export const DEFAULT_TURN_PROMPT = [
145
182
  "[背景] 纯色绿幕,颜色是标准 chroma key 绿 #00FF00,整幅背景颜色完全均匀一致,全程保持纯绿,不要任何阴影、渐变、地面或投影。",
146
183
  "[画面] 角色始终完整居中在画面内、不被裁切;不要出现第二个人或任何其它物体,不出现转场、抖动、缩放、运镜或镜头移动。"
147
184
  ].join("\n");
185
+ /** `DEFAULT_TURN_PROMPT` 的英文版(逐行对应)。 */
186
+ const DEFAULT_TURN_PROMPT_EN = [
187
+ "[Static camera] Fixed camera position, fixed focal length, fixed framing, the camera stays completely motionless, camera height level with the character's chest, neither looking down nor looking up. The green screen background stays exactly as it is.",
188
+ "[Start pose] At the start of the clip the character must look exactly as in the reference image: a front-facing standing pose facing the camera, both feet on the ground, arms hanging naturally at the sides, fully preserving the reference image's facial features, hairstyle, hair color, clothing style, color scheme and overall art style; it must look like the exact same person.",
189
+ "[Motion] There is only this one character in the frame; the character rotates in place around its own vertical axis at a completely even speed for a full circle (360 degrees), the rotation speed stays constant from beginning to end, and it finishes facing exactly the same direction as at the start, so the first and last frames connect seamlessly.",
190
+ "[No other motion] Apart from rotating around the vertical axis, there must be no other movement: no walking, no stepping, no swinging the arms, no raising the arms, no nodding. The body always stays in an upright standing pose; do not tilt the head up, tilt the head down, bend at the waist, lean backward, crouch or jump.",
191
+ "[Consistency] During the rotation the height, build, face shape, hairstyle, clothing, color scheme and art style must stay exactly identical; only the body orientation changes.",
192
+ "[Background] Solid green screen, the color is standard chroma key green #00FF00, the whole background is a completely uniform single color, pure green throughout, with no shadows, gradients, ground or cast shadow.",
193
+ "[Frame] The character stays fully centered inside the frame the whole time, never cropped; no second person and no other object appears, no transitions, no jitter, no zooming, no camera movement or camera motion."
194
+ ].join("\n");
148
195
  /**
149
196
  * 顺时针(俯视)转圈时,镜头依次看到的朝向:
150
197
  * 正南(正面)→ 西南 → 西 → 西北 → 正北(背面)→ 东北 → 东 → 东南。
@@ -188,15 +235,83 @@ export const DEFAULT_VIDEO_PROMPT = [
188
235
  "保持平涂色块和干净的绿幕,不要补充纹理、光影或背景细节。",
189
236
  "不要走出画面、不要出现第二个人或任何其它物体,不出现转场、抖动、缩放、运镜或镜头移动。"
190
237
  ].join("\n");
238
+ /** `DEFAULT_VIDEO_PROMPT` 的英文版(逐行对应)。 */
239
+ const DEFAULT_VIDEO_PROMPT_EN = [
240
+ "[Static shot] Fixed camera position, fixed focal length, fixed framing, the camera stays completely motionless, camera height level with the character's chest, neither looking down nor looking up. The green screen background stays exactly as it is.",
241
+ "There is only this one character in the frame; keep the orientation and position from the image unchanged - do not turn around, do not change the direction it faces. Perform a natural walking motion in place: the legs step alternately, the arms swing naturally, walk three complete steps.",
242
+ "While walking the body stays upright and the gaze stays horizontal at all times; do not tilt the head up, tilt the head down, or let the body bob and deform.",
243
+ "Keep the flat color blocks and the clean green screen; do not add texture, lighting or background detail.",
244
+ "Do not walk out of the frame, do not let a second person or any other object appear, no transitions, no jitter, no zooming, no camera movement or camera motion."
245
+ ].join("\n");
191
246
  /** 把模板里的两个占位符换成具体方向的描述。 */
192
247
  export function fillImagePrompt(template, facing, visibility) {
193
248
  return template.replace(/\{facing\}/g, facing).replace(/\{visibility\}/g, visibility);
194
249
  }
195
- /** 把八方向默认提示词装配成一张表(每个方向一份,可单独编辑)。 */
196
- export function defaultImagePrompts() {
197
- const out = {};
250
+ /** 某个语言下的三个默认提示词模板。 */
251
+ const TEMPLATES = {
252
+ zh: { image: DEFAULT_IMAGE_PROMPT, turn: DEFAULT_TURN_PROMPT, video: DEFAULT_VIDEO_PROMPT },
253
+ en: { image: DEFAULT_IMAGE_PROMPT_EN, turn: DEFAULT_TURN_PROMPT_EN, video: DEFAULT_VIDEO_PROMPT_EN }
254
+ };
255
+ /**
256
+ * 内置默认提示词(**唯一真源**)。
257
+ *
258
+ * 默认值不止界面要显示,它还真的会发给生图 / 视频模型,所以语言必须跟着 DSH 走:
259
+ * 英文界面下把中文提示词发出去,模型照样能画,但用户读不懂自己在调什么。
260
+ * @param lang - 目标语言;省略按中文。
261
+ */
262
+ export function defaultPrompts(lang = "zh") {
263
+ const template = TEMPLATES[lang] ?? TEMPLATES.zh;
264
+ const images = {};
198
265
  for (const direction of DIRECTIONS) {
199
- out[direction.key] = fillImagePrompt(DEFAULT_IMAGE_PROMPT, direction.facing, direction.visibility);
266
+ const facing = lang === "en" ? direction.facingEn : direction.facing;
267
+ const visibility = lang === "en" ? direction.visibilityEn : direction.visibility;
268
+ images[direction.key] = fillImagePrompt(template.image, facing, visibility);
269
+ }
270
+ return { images, video: template.video, turn: template.turn };
271
+ }
272
+ /** 把八方向默认提示词装配成一张表(每个方向一份,可单独编辑)。 */
273
+ export function defaultImagePrompts(lang = "zh") {
274
+ return defaultPrompts(lang).images;
275
+ }
276
+ /**
277
+ * 把「还是内置默认值」的提示词换成目标语言的默认值。
278
+ *
279
+ * 判定标准是**逐字等于**另一语言的默认值:只有从没被改过(或改回了原样)的条目会被换,
280
+ * 用户自己写过的一个字都不动。这样切换语言时,默认提示词跟着走,
281
+ * 手改过的提示词留着手改的内容。
282
+ *
283
+ * @returns 是否真的改了——没改就别写盘。
284
+ */
285
+ export function localizePrompts(prompts, lang) {
286
+ const target = defaultPrompts(lang);
287
+ const other = defaultPrompts(lang === "en" ? "zh" : "en");
288
+ let changed = false;
289
+ for (const key of DIRECTION_KEYS) {
290
+ const current = prompts.images?.[key];
291
+ if (typeof current !== "string" || current === target.images[key])
292
+ continue;
293
+ if (current === other.images[key]) {
294
+ prompts.images[key] = target.images[key];
295
+ changed = true;
296
+ }
297
+ }
298
+ if (prompts.video !== undefined && prompts.video !== target.video && prompts.video === other.video) {
299
+ prompts.video = target.video;
300
+ changed = true;
301
+ }
302
+ if (prompts.turn !== undefined && prompts.turn !== target.turn && prompts.turn === other.turn) {
303
+ prompts.turn = target.turn;
304
+ changed = true;
305
+ }
306
+ // 单个方向的视频提示词覆盖:同样只换「还是默认值」的那些。
307
+ const per = prompts.videoPerDirection;
308
+ if (per !== undefined && per !== null && typeof per === "object") {
309
+ for (const key of Object.keys(per)) {
310
+ if (per[key] !== target.video && per[key] === other.video) {
311
+ per[key] = target.video;
312
+ changed = true;
313
+ }
314
+ }
200
315
  }
201
- return out;
316
+ return changed;
202
317
  }