dsh-game-material-master 0.11.0 → 0.11.2
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/README.en.md +2 -0
- package/README.md +2 -0
- package/lib/chroma.js +74 -15
- package/lib/client.js +233 -48
- package/lib/config.js +6 -3
- package/lib/customimage.js +43 -0
- package/lib/directions.js +69 -8
- package/lib/imagegen.js +18 -4
- package/lib/imageprovider.js +7 -2
- package/lib/index.js +61 -12
- package/lib/isocompose.js +26 -17
- package/lib/isogen.js +7 -3
- package/lib/keycolor.js +251 -0
- package/lib/mapgen.js +11 -7
- package/lib/pipeline.js +10 -3
- package/lib/riggen.js +4 -4
- package/lib/seqgen.js +7 -0
- package/lib/store.js +23 -12
- package/lib/toolguides.js +14 -14
- package/lib/wire.js +13 -5
- package/package.json +1 -1
package/lib/config.js
CHANGED
|
@@ -8,6 +8,7 @@ import { mkdir, readFile, rename, stat, writeFile } from "node:fs/promises";
|
|
|
8
8
|
import { homedir } from "node:os";
|
|
9
9
|
import { join } from "node:path";
|
|
10
10
|
import { DEFAULT_ROW_ORDER } from "./directions.js";
|
|
11
|
+
import { DEFAULT_KEY_COLOR, normalizeKeyColor } from "./keycolor.js";
|
|
11
12
|
import { STUDIO_MODULES } from "./links.js";
|
|
12
13
|
import { MUSIC_DEFAULT_MODEL } from "./musicmodels.js";
|
|
13
14
|
import { SFX_DEFAULT_BASE_URL, SFX_DEFAULT_FORMAT, SFX_DEFAULT_MODEL, SFX_DEFAULT_SAMPLE_RATE, sfxFormatOrDefault, sfxSampleRateOrDefault } from "./sfxapi.js";
|
|
@@ -225,6 +226,7 @@ export const DEFAULT_CONFIG = {
|
|
|
225
226
|
fillRatio: 0.94,
|
|
226
227
|
bottomMargin: 2,
|
|
227
228
|
cropInset: 0,
|
|
229
|
+
keyColor: DEFAULT_KEY_COLOR,
|
|
228
230
|
keyLow: 14,
|
|
229
231
|
keyHigh: 80,
|
|
230
232
|
despill: 0.65,
|
|
@@ -316,7 +318,7 @@ export function normalizeConfig(input) {
|
|
|
316
318
|
toapisBaseUrl: asString(raw.toapisBaseUrl, DEFAULT_CONFIG.toapisBaseUrl).trim(),
|
|
317
319
|
toapisApiKey: asString(raw.toapisApiKey, DEFAULT_CONFIG.toapisApiKey).trim(),
|
|
318
320
|
toapisImageModel: asString(raw.toapisImageModel, DEFAULT_CONFIG.toapisImageModel).trim(),
|
|
319
|
-
toapisImageSize: asString(raw.toapisImageSize, DEFAULT_CONFIG.toapisImageSize).trim(),
|
|
321
|
+
toapisImageSize: asString(raw.toapisImageSize, DEFAULT_CONFIG.toapisImageSize).trim() || DEFAULT_CONFIG.toapisImageSize,
|
|
320
322
|
toapisImageQuality: asString(raw.toapisImageQuality, DEFAULT_CONFIG.toapisImageQuality).trim(),
|
|
321
323
|
toapisImageBackground: raw.toapisImageBackground === "transparent" || raw.toapisImageBackground === "opaque" ? raw.toapisImageBackground : "auto",
|
|
322
324
|
toapisVideo: asBool(raw.toapisVideo, DEFAULT_CONFIG.toapisVideo),
|
|
@@ -332,7 +334,7 @@ export function normalizeConfig(input) {
|
|
|
332
334
|
customBaseUrl: asString(raw.customBaseUrl, DEFAULT_CONFIG.customBaseUrl).replace(/\/+$/, ""),
|
|
333
335
|
customApiKey: asString(raw.customApiKey, DEFAULT_CONFIG.customApiKey),
|
|
334
336
|
customModel: asString(raw.customModel, DEFAULT_CONFIG.customModel),
|
|
335
|
-
customSize: asString(raw.customSize, DEFAULT_CONFIG.customSize),
|
|
337
|
+
customSize: asString(raw.customSize, DEFAULT_CONFIG.customSize).trim() || DEFAULT_CONFIG.customSize,
|
|
336
338
|
customNegativePrompt: asString(raw.customNegativePrompt, DEFAULT_CONFIG.customNegativePrompt),
|
|
337
339
|
customSteps: asInt(raw.customSteps, DEFAULT_CONFIG.customSteps, 1, 150),
|
|
338
340
|
// 上限放到 30:有些后端把 CFG 当纯缩放用;下限 0 = 完全不看提示词(罕见但合法)。
|
|
@@ -347,7 +349,7 @@ export function normalizeConfig(input) {
|
|
|
347
349
|
arkBaseUrl: asString(raw.arkBaseUrl, DEFAULT_CONFIG.arkBaseUrl).replace(/\/+$/, ""),
|
|
348
350
|
arkModel: asString(raw.arkModel, DEFAULT_CONFIG.arkModel),
|
|
349
351
|
arkRedrawModel: asString(raw.arkRedrawModel, DEFAULT_CONFIG.arkRedrawModel),
|
|
350
|
-
arkSize: asString(raw.arkSize, DEFAULT_CONFIG.arkSize),
|
|
352
|
+
arkSize: asString(raw.arkSize, DEFAULT_CONFIG.arkSize).trim() || DEFAULT_CONFIG.arkSize,
|
|
351
353
|
arkWatermark: asBool(raw.arkWatermark, DEFAULT_CONFIG.arkWatermark),
|
|
352
354
|
arkTimeoutMs: asInt(raw.arkTimeoutMs, DEFAULT_CONFIG.arkTimeoutMs, 10000, 900000),
|
|
353
355
|
minimaxApiKey: asString(raw.minimaxApiKey, DEFAULT_CONFIG.minimaxApiKey),
|
|
@@ -397,6 +399,7 @@ export function normalizeConfig(input) {
|
|
|
397
399
|
fillRatio: asNumber(raw.fillRatio, DEFAULT_CONFIG.fillRatio, 0.5, 1),
|
|
398
400
|
bottomMargin: asInt(raw.bottomMargin, DEFAULT_CONFIG.bottomMargin, 0, 64),
|
|
399
401
|
cropInset: asNumber(raw.cropInset, DEFAULT_CONFIG.cropInset, 0, 0.2),
|
|
402
|
+
keyColor: normalizeKeyColor(raw.keyColor, DEFAULT_CONFIG.keyColor),
|
|
400
403
|
keyLow,
|
|
401
404
|
keyHigh,
|
|
402
405
|
despill: asNumber(raw.despill, DEFAULT_CONFIG.despill, 0, 1),
|
package/lib/customimage.js
CHANGED
|
@@ -358,6 +358,39 @@ function patchLoadImage(node, name) {
|
|
|
358
358
|
}
|
|
359
359
|
return touched;
|
|
360
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* 没写 `{{width}}` / `{{height}}` 时的兜底:直接改空 latent 节点的宽高。
|
|
363
|
+
*
|
|
364
|
+
* 这是「改了尺寸也不生效」的常见原因:用户从 ComfyUI 导出的 API 工作流里,
|
|
365
|
+
* `EmptyLatentImage` 的宽高是写死的数字,而插件只替换占位符、不碰写死的值。
|
|
366
|
+
* 只改**本身是数字**的输入(连线的输入是数组,跳过),并且只认 `Empty*`
|
|
367
|
+
* 这一类节点,避免把放大节点 / 参考图尺寸一起改掉。
|
|
368
|
+
*/
|
|
369
|
+
function patchLatentSize(node, width, height) {
|
|
370
|
+
if (Array.isArray(node))
|
|
371
|
+
return node.some((item) => patchLatentSize(item, width, height));
|
|
372
|
+
if (node === null || typeof node !== "object")
|
|
373
|
+
return false;
|
|
374
|
+
const record = node;
|
|
375
|
+
let touched = false;
|
|
376
|
+
const classType = typeof record.class_type === "string" ? record.class_type : "";
|
|
377
|
+
const inputs = record.inputs;
|
|
378
|
+
if (/empty/i.test(classType) && inputs !== null && typeof inputs === "object") {
|
|
379
|
+
if (typeof inputs.width === "number" || (typeof inputs.width === "string" && /^\d+$/.test(inputs.width))) {
|
|
380
|
+
inputs.width = width;
|
|
381
|
+
touched = true;
|
|
382
|
+
}
|
|
383
|
+
if (typeof inputs.height === "number" || (typeof inputs.height === "string" && /^\d+$/.test(inputs.height))) {
|
|
384
|
+
inputs.height = height;
|
|
385
|
+
touched = true;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
for (const value of Object.values(record)) {
|
|
389
|
+
if (patchLatentSize(value, width, height))
|
|
390
|
+
touched = true;
|
|
391
|
+
}
|
|
392
|
+
return touched;
|
|
393
|
+
}
|
|
361
394
|
function comfyOutputImages(outputs) {
|
|
362
395
|
const found = [];
|
|
363
396
|
if (outputs === null || typeof outputs !== "object")
|
|
@@ -431,6 +464,16 @@ async function generateComfyUi(request, context) {
|
|
|
431
464
|
if (imageNames.length > 0 && !used.has("image")) {
|
|
432
465
|
patchLoadImage(workflow, imageNames[0]);
|
|
433
466
|
}
|
|
467
|
+
/**
|
|
468
|
+
* 工作流里没写 width / height 占位符时,把尺寸写进空 latent 节点 —— 否则
|
|
469
|
+
* 用户在设置里改输出尺寸,ComfyUI 仍然按工作流里写死的值出图(典型表现:
|
|
470
|
+
* 「改了也不行,永远 1254×1254」)。
|
|
471
|
+
*/
|
|
472
|
+
if (!used.has("width") || !used.has("height")) {
|
|
473
|
+
const size = parseSizeSpec(request.size);
|
|
474
|
+
if (size !== undefined)
|
|
475
|
+
patchLatentSize(workflow, size.width, size.height);
|
|
476
|
+
}
|
|
434
477
|
const clientId = `gmm-${Date.now().toString(36)}-${Math.floor(Math.random() * 1e6).toString(36)}`;
|
|
435
478
|
const queued = await fetchOrThrow(joinUrl(base, "/prompt"), {
|
|
436
479
|
method: "POST",
|
package/lib/directions.js
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
* 4. upLeft / upRight ← back
|
|
26
26
|
* 5. left / right ← front + back
|
|
27
27
|
*/
|
|
28
|
+
import { DEFAULT_KEY_COLOR, applyKeyColorToPrompt } from "./keycolor.js";
|
|
28
29
|
/** 把任意输入规整成提示词语言;认不出来的一律按中文。 */
|
|
29
30
|
export function normalizePromptLang(value) {
|
|
30
31
|
return typeof value === "string" && value.trim().toLowerCase().startsWith("en") ? "en" : "zh";
|
|
@@ -266,19 +267,24 @@ const TEMPLATES = {
|
|
|
266
267
|
* 英文界面下把中文提示词发出去,模型照样能画,但用户读不懂自己在调什么。
|
|
267
268
|
* @param lang - 目标语言;省略按中文。
|
|
268
269
|
*/
|
|
269
|
-
export function defaultPrompts(lang = "zh") {
|
|
270
|
+
export function defaultPrompts(lang = "zh", keyColor = DEFAULT_KEY_COLOR) {
|
|
270
271
|
const template = TEMPLATES[lang] ?? TEMPLATES.zh;
|
|
272
|
+
const colorLang = lang === "en" ? "en" : "zh";
|
|
271
273
|
const images = {};
|
|
272
274
|
for (const direction of DIRECTIONS) {
|
|
273
275
|
const facing = lang === "en" ? direction.facingEn : direction.facing;
|
|
274
276
|
const visibility = lang === "en" ? direction.visibilityEn : direction.visibility;
|
|
275
|
-
images[direction.key] = fillImagePrompt(template.image, facing, visibility);
|
|
277
|
+
images[direction.key] = applyKeyColorToPrompt(fillImagePrompt(template.image, facing, visibility), keyColor, colorLang);
|
|
276
278
|
}
|
|
277
|
-
return {
|
|
279
|
+
return {
|
|
280
|
+
images,
|
|
281
|
+
video: applyKeyColorToPrompt(template.video, keyColor, colorLang),
|
|
282
|
+
turn: applyKeyColorToPrompt(template.turn, keyColor, colorLang)
|
|
283
|
+
};
|
|
278
284
|
}
|
|
279
285
|
/** 把八方向默认提示词装配成一张表(每个方向一份,可单独编辑)。 */
|
|
280
|
-
export function defaultImagePrompts(lang = "zh") {
|
|
281
|
-
return defaultPrompts(lang).images;
|
|
286
|
+
export function defaultImagePrompts(lang = "zh", keyColor = DEFAULT_KEY_COLOR) {
|
|
287
|
+
return defaultPrompts(lang, keyColor).images;
|
|
282
288
|
}
|
|
283
289
|
/**
|
|
284
290
|
* 把「还是内置默认值」的提示词换成目标语言的默认值。
|
|
@@ -289,9 +295,9 @@ export function defaultImagePrompts(lang = "zh") {
|
|
|
289
295
|
*
|
|
290
296
|
* @returns 是否真的改了——没改就别写盘。
|
|
291
297
|
*/
|
|
292
|
-
export function localizePrompts(prompts, lang) {
|
|
293
|
-
const target = defaultPrompts(lang);
|
|
294
|
-
const other = defaultPrompts(lang === "en" ? "zh" : "en");
|
|
298
|
+
export function localizePrompts(prompts, lang, keyColor = DEFAULT_KEY_COLOR) {
|
|
299
|
+
const target = defaultPrompts(lang, keyColor);
|
|
300
|
+
const other = defaultPrompts(lang === "en" ? "zh" : "en", keyColor);
|
|
295
301
|
let changed = false;
|
|
296
302
|
for (const key of DIRECTION_KEYS) {
|
|
297
303
|
const current = prompts.images?.[key];
|
|
@@ -322,3 +328,58 @@ export function localizePrompts(prompts, lang) {
|
|
|
322
328
|
}
|
|
323
329
|
return changed;
|
|
324
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* 把项目里**所有**仍是内置默认句式的提示词换成目标底色。
|
|
333
|
+
*
|
|
334
|
+
* 与 `localizePrompts` 是同一套「只认逐字等于默认值」的思路,只是维度从语言
|
|
335
|
+
* 换成了背景色。用户手改过一句,就一个字都不动;老项目里存的「纯绿幕 #00FF00」
|
|
336
|
+
* 会在下次读取 / 生成时自动变成新配色。
|
|
337
|
+
*
|
|
338
|
+
* 中英两种句式都跑一遍:项目可能是在英文界面下建的,也可能中途切过语言。
|
|
339
|
+
*/
|
|
340
|
+
export function applyKeyColorToPrompts(prompts, keyColor) {
|
|
341
|
+
let changed = false;
|
|
342
|
+
const apply = (text) => {
|
|
343
|
+
const zh = applyKeyColorToPrompt(text, keyColor, "zh");
|
|
344
|
+
return applyKeyColorToPrompt(zh, keyColor, "en");
|
|
345
|
+
};
|
|
346
|
+
if (prompts.images !== undefined) {
|
|
347
|
+
for (const key of DIRECTION_KEYS) {
|
|
348
|
+
const current = prompts.images[key];
|
|
349
|
+
if (typeof current !== "string")
|
|
350
|
+
continue;
|
|
351
|
+
const next = apply(current);
|
|
352
|
+
if (next !== current) {
|
|
353
|
+
prompts.images[key] = next;
|
|
354
|
+
changed = true;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (typeof prompts.video === "string") {
|
|
359
|
+
const next = apply(prompts.video);
|
|
360
|
+
if (next !== prompts.video) {
|
|
361
|
+
prompts.video = next;
|
|
362
|
+
changed = true;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
if (typeof prompts.turn === "string") {
|
|
366
|
+
const next = apply(prompts.turn);
|
|
367
|
+
if (next !== prompts.turn) {
|
|
368
|
+
prompts.turn = next;
|
|
369
|
+
changed = true;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
if (prompts.videoPerDirection !== undefined && prompts.videoPerDirection !== null) {
|
|
373
|
+
for (const key of Object.keys(prompts.videoPerDirection)) {
|
|
374
|
+
const current = prompts.videoPerDirection[key];
|
|
375
|
+
if (typeof current !== "string")
|
|
376
|
+
continue;
|
|
377
|
+
const next = apply(current);
|
|
378
|
+
if (next !== current) {
|
|
379
|
+
prompts.videoPerDirection[key] = next;
|
|
380
|
+
changed = true;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return changed;
|
|
385
|
+
}
|
package/lib/imagegen.js
CHANGED
|
@@ -16,11 +16,12 @@ import { mkdir, readFile, rm, stat, writeFile } from "node:fs/promises";
|
|
|
16
16
|
import { basename, join, resolve, sep } from "node:path";
|
|
17
17
|
import { randomUUID } from "node:crypto";
|
|
18
18
|
import { imageJobsRoot, loadConfig } from "./config.js";
|
|
19
|
-
import { generateImageWithProvider, imageModelOf, imageSizeOf, imageWatermarkOf, assertImageProviderReady
|
|
19
|
+
import { generateImageWithProvider, imageModelOf, imageSizeOf, imageWatermarkOf, assertImageProviderReady } from "./imageprovider.js";
|
|
20
20
|
import { decodeToRgba, mimeOf, toDataUri } from "./media.js";
|
|
21
21
|
import { keyGreen } from "./chroma.js";
|
|
22
22
|
import { encodePng } from "./png.js";
|
|
23
23
|
import { appendJobLog, messageOf, readJson, writeJsonAtomic } from "./jsonio.js";
|
|
24
|
+
import { normalizeKeyColor } from "./keycolor.js";
|
|
24
25
|
const JOB_ID_PATTERN = /^i[a-z0-9]{4,40}$/;
|
|
25
26
|
export function imageJobDir(id) {
|
|
26
27
|
return join(imageJobsRoot(), id);
|
|
@@ -57,12 +58,14 @@ export async function createImageJob(name) {
|
|
|
57
58
|
refs: [],
|
|
58
59
|
settings: {
|
|
59
60
|
model: imageModelOf(config),
|
|
61
|
+
sizeMode: "global",
|
|
60
62
|
size: imageSizeOf(config),
|
|
61
63
|
count: 1,
|
|
62
64
|
watermark: imageWatermarkOf(config)
|
|
63
65
|
},
|
|
64
66
|
keying: {
|
|
65
67
|
enabled: false,
|
|
68
|
+
keyColor: config.keyColor,
|
|
66
69
|
keyLow: config.keyLow,
|
|
67
70
|
keyHigh: config.keyHigh,
|
|
68
71
|
despill: config.despill,
|
|
@@ -148,12 +151,15 @@ function normalizeImageJob(raw) {
|
|
|
148
151
|
: [],
|
|
149
152
|
settings: {
|
|
150
153
|
model: typeof raw?.settings?.model === "string" ? raw.settings.model : "",
|
|
154
|
+
sizeMode: raw?.settings?.sizeMode === "custom" ? "custom" : "global",
|
|
151
155
|
size: typeof raw?.settings?.size === "string" ? raw.settings.size : "2K",
|
|
152
156
|
count: Math.min(8, Math.max(1, Number(raw?.settings?.count) || 1)),
|
|
153
157
|
watermark: raw?.settings?.watermark === true
|
|
154
158
|
},
|
|
155
159
|
keying: {
|
|
156
160
|
enabled: raw?.keying?.enabled === true,
|
|
161
|
+
// 老任务没有这个字段:留空,抠像时回落到当前全局配置。
|
|
162
|
+
keyColor: typeof raw?.keying?.keyColor === "string" ? normalizeKeyColor(raw.keying.keyColor) : "",
|
|
157
163
|
keyLow: num(raw?.keying?.keyLow, 14),
|
|
158
164
|
keyHigh: num(raw?.keying?.keyHigh, 80),
|
|
159
165
|
despill: num(raw?.keying?.despill, 0.65),
|
|
@@ -165,6 +171,7 @@ function normalizeImageJob(raw) {
|
|
|
165
171
|
log: Array.isArray(raw?.log) ? raw.log.slice(-200) : []
|
|
166
172
|
};
|
|
167
173
|
}
|
|
174
|
+
/** 归一化时没有配置可读;用默认绿,后续生成时仍会跟随配置。 */
|
|
168
175
|
function num(value, fallback) {
|
|
169
176
|
const n = typeof value === "number" ? value : Number.parseFloat(String(value ?? ""));
|
|
170
177
|
return Number.isFinite(n) ? n : fallback;
|
|
@@ -212,12 +219,17 @@ export async function generateImageItem(jobId, index) {
|
|
|
212
219
|
assertImageProviderReady(config);
|
|
213
220
|
// 生图模型同样是全局设置(设置 → 游戏素材大师 → 生图后端),任务只跟随、不覆盖。
|
|
214
221
|
job.settings.model = imageModelOf(config);
|
|
215
|
-
|
|
216
|
-
|
|
222
|
+
/**
|
|
223
|
+
* 尺寸只在「跟随全局」时取全局值;用户显式把任务改成「自定义」后,
|
|
224
|
+
* 任务自己的 size 才是权威 —— 否则又会回到「改任务尺寸不生效」的老 bug。
|
|
225
|
+
*/
|
|
226
|
+
if (job.settings.sizeMode !== "custom") {
|
|
227
|
+
job.settings.sizeMode = "global";
|
|
217
228
|
job.settings.size = imageSizeOf(config);
|
|
229
|
+
}
|
|
218
230
|
const item = job.items[index] ?? { index, status: "empty", source: "generated" };
|
|
219
231
|
job.items[index] = { ...item, status: "running", error: undefined };
|
|
220
|
-
appendJobLog(job.log, "info", `开始生成第 ${index + 1}
|
|
232
|
+
appendJobLog(job.log, "info", `开始生成第 ${index + 1} 张(尺寸 ${job.settings.size})`);
|
|
221
233
|
await writeImageJob(job);
|
|
222
234
|
try {
|
|
223
235
|
const refs = await Promise.all(job.refs.map((ref) => toDataUri(imageAssetPath(jobId, ref.file), mimeOf(ref.file))));
|
|
@@ -267,8 +279,10 @@ export async function keyItem(job, index) {
|
|
|
267
279
|
const item = job.items[index];
|
|
268
280
|
if (item?.file === undefined)
|
|
269
281
|
return;
|
|
282
|
+
const config = await loadConfig();
|
|
270
283
|
const decoded = await decodeToRgba(imageAssetPath(job.id, item.file), 2048);
|
|
271
284
|
const result = keyGreen(decoded.rgba, decoded.width, decoded.height, {
|
|
285
|
+
keyColor: job.keying.keyColor || config.keyColor,
|
|
272
286
|
keyLow: job.keying.keyLow,
|
|
273
287
|
keyHigh: job.keying.keyHigh,
|
|
274
288
|
despill: job.keying.despill,
|
package/lib/imageprovider.js
CHANGED
|
@@ -15,8 +15,13 @@ import { assertToapisReady, generateToapisImage } from "./toapis.js";
|
|
|
15
15
|
import { generateImage } from "./ark.js";
|
|
16
16
|
import { CUSTOM_PROTOCOL_DEFAULTS, loadConfig } from "./config.js";
|
|
17
17
|
import { CustomImageError, generateCustomImage } from "./customimage.js";
|
|
18
|
-
/**
|
|
19
|
-
|
|
18
|
+
/**
|
|
19
|
+
* 所有后端都使用同一份全局输出尺寸。
|
|
20
|
+
*
|
|
21
|
+
* 历史行为是「Ark 保留任务级尺寸、自定义后端只读全局」,导致同一个设置页里
|
|
22
|
+
* 改尺寸时好时坏;现在统一成全局参数。保留这个函数是为了兼容旧的调用方 / 自检。
|
|
23
|
+
*/
|
|
24
|
+
export function imageUsesConfiguredSize(_config) { return true; }
|
|
20
25
|
/** Only Ark supports a separate redraw model; other backends retain their selected model. */
|
|
21
26
|
export function imageRedrawModelOf(config) {
|
|
22
27
|
return config.imageProvider === "ark" ? config.arkRedrawModel.trim() || config.arkModel : imageModelOf(config);
|
package/lib/index.js
CHANGED
|
@@ -17,10 +17,11 @@ import { spawn } from "node:child_process";
|
|
|
17
17
|
import { TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
18
18
|
import { appendJobLog } from "./jsonio.js";
|
|
19
19
|
import { ARK_MODEL_PRESETS, CUSTOM_PROTOCOLS, CUSTOM_PROTOCOL_DEFAULTS, DEFAULT_CONFIG, ROW_ORDER_VERSION, MINIMAX_HOST_PRESETS, MINIMAX_MODEL_PRESETS, loadConfig, maskConfig, migrateLegacyDataRoot, projectsRoot, saveConfig } from "./config.js";
|
|
20
|
-
import { DEFAULT_ROW_ORDER, DIRECTION_KEYS, TURN_DIRECTION_DEFAULT, TURN_FRAME_COUNT_MAX, TURN_FRAME_COUNT_MIN, defaultPrompts, directionOf, localizePrompts, normalizePromptLang } from "./directions.js";
|
|
20
|
+
import { DEFAULT_ROW_ORDER, DIRECTION_KEYS, TURN_DIRECTION_DEFAULT, TURN_FRAME_COUNT_MAX, TURN_FRAME_COUNT_MIN, defaultPrompts, directionOf, localizePrompts, applyKeyColorToPrompts, normalizePromptLang } from "./directions.js";
|
|
21
|
+
import { DEFAULT_KEY_COLOR, normalizeKeyColor } from "./keycolor.js";
|
|
21
22
|
import { checkFfmpeg } from "./media.js";
|
|
22
23
|
import { testArk } from "./ark.js";
|
|
23
|
-
import { customImageBlocker, imageModelOf, imageSizeOf, imageProviderBlocker, imageProviderSummary,
|
|
24
|
+
import { customImageBlocker, imageModelOf, imageSizeOf, imageProviderBlocker, imageProviderSummary, testCustomImage } from "./imageprovider.js";
|
|
24
25
|
import { detectComfyBindings, fetchComfyObjectInfo, formatBinding, normalizeComfyBaseUrl, normalizeComfyCookies, parseComfyWorkflow, testComfy } from "./comfy.js";
|
|
25
26
|
import { COMP_SHARE_BASE_URL, COMP_SHARE_MODEL_ID, capabilityOf, isCompshareModel, normalizeDuration, normalizeResolution, pathPrefixOf, testMiniMax } from "./minimax.js";
|
|
26
27
|
import { activatePipeline, applyTurnPicks, clearVideos, disposePipeline, ensurePoller, exportImages, importLocalVideo, listJobs, pollVideosOnce, resetFramePicks, resetTurnPicks, setFramePick, setFramePicks, setImageMode, setTurnPick, setTurnPicks, startAllImages, startCompose, startFramePick, startExtract, startImage, startRekey, startTurnFrames, startTurnVideo, startVideos } from "./pipeline.js";
|
|
@@ -389,6 +390,7 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
389
390
|
"fillRatio",
|
|
390
391
|
"bottomMargin",
|
|
391
392
|
"cropInset",
|
|
393
|
+
"keyColor",
|
|
392
394
|
"keyLow",
|
|
393
395
|
"keyHigh",
|
|
394
396
|
"despill",
|
|
@@ -598,9 +600,22 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
598
600
|
let project = await readProject(projectId);
|
|
599
601
|
if (project === undefined)
|
|
600
602
|
throw new Error(`项目不存在:${projectId}`);
|
|
601
|
-
|
|
603
|
+
// 底色也是项目级设置:没在项目里显式改过时跟随全局配置。
|
|
604
|
+
const config = await loadConfig();
|
|
605
|
+
const effectiveKeyColor = project.settings.keyColorOverride === true ? project.settings.keyColor : config.keyColor;
|
|
606
|
+
const effectiveChanged = project.settings.keyColor !== effectiveKeyColor;
|
|
607
|
+
if (effectiveChanged)
|
|
608
|
+
project.settings.keyColor = effectiveKeyColor;
|
|
609
|
+
// 读项目时把「仍是默认句式」的提示词同步到它的底色,这样老项目 / 刚改过底色的
|
|
610
|
+
// 项目在界面上看到的就是生成时会用的那一版。
|
|
611
|
+
const colorChanged = applyKeyColorToPrompts(project.prompts, effectiveKeyColor);
|
|
612
|
+
const localized = lang !== undefined ? localizePrompts(project.prompts, lang, effectiveKeyColor) : false;
|
|
613
|
+
if (colorChanged || localized || effectiveChanged) {
|
|
602
614
|
project = await patchProject(projectId, (draft) => {
|
|
603
|
-
|
|
615
|
+
draft.settings.keyColor = effectiveKeyColor;
|
|
616
|
+
applyKeyColorToPrompts(draft.prompts, effectiveKeyColor);
|
|
617
|
+
if (lang !== undefined)
|
|
618
|
+
localizePrompts(draft.prompts, lang, effectiveKeyColor);
|
|
604
619
|
return draft;
|
|
605
620
|
});
|
|
606
621
|
}
|
|
@@ -689,7 +704,12 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
689
704
|
const resetVideo = input.resetVideoToDefault === true;
|
|
690
705
|
const resetTurn = input.resetTurnToDefault === true;
|
|
691
706
|
// 「重置为默认」要重置成**当前界面语言**的默认值,否则英文界面点一下会掉出中文提示词。
|
|
692
|
-
const
|
|
707
|
+
const configured = await loadConfig();
|
|
708
|
+
const projectForColor = await readProject(projectId);
|
|
709
|
+
const effectiveKeyColor = projectForColor?.settings?.keyColorOverride === true
|
|
710
|
+
? projectForColor.settings.keyColor
|
|
711
|
+
: configured.keyColor;
|
|
712
|
+
const defaults = defaultPrompts(normalizePromptLang(input.lang), effectiveKeyColor);
|
|
693
713
|
await patchProject(projectId, (project) => {
|
|
694
714
|
// 提示词模板升级后(例如这次把方位语义改对),老项目要能一键重新套用默认值。
|
|
695
715
|
if (resetImages)
|
|
@@ -727,6 +747,7 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
727
747
|
const input = asRecord(payload);
|
|
728
748
|
const projectId = asString(input.projectId);
|
|
729
749
|
const raw = asRecord(input.settings);
|
|
750
|
+
const config = await loadConfig();
|
|
730
751
|
const changed = await patchProject(projectId, (project) => {
|
|
731
752
|
const before = { ...project.settings };
|
|
732
753
|
const current = project.settings;
|
|
@@ -741,6 +762,10 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
741
762
|
fillRatio: clampFloat(raw.fillRatio, current.fillRatio, 0.5, 1),
|
|
742
763
|
bottomMargin: clampInt(raw.bottomMargin, current.bottomMargin, 0, 64),
|
|
743
764
|
cropInset: clampFloat(raw.cropInset, current.cropInset, 0, 0.2),
|
|
765
|
+
keyColor: normalizeKeyColor(raw.keyColor, current.keyColor),
|
|
766
|
+
keyColorOverride: raw.keyColor === undefined
|
|
767
|
+
? current.keyColorOverride === true
|
|
768
|
+
: normalizeKeyColor(raw.keyColor, current.keyColor) !== config.keyColor,
|
|
744
769
|
keyLow: clampInt(raw.keyLow, current.keyLow, 0, 255),
|
|
745
770
|
keyHigh: clampInt(raw.keyHigh, current.keyHigh, 1, 255),
|
|
746
771
|
despill: clampFloat(raw.despill, current.despill, 0, 1),
|
|
@@ -759,6 +784,9 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
759
784
|
project.settings.rowOrder = [...DEFAULT_ROW_ORDER];
|
|
760
785
|
if (project.settings.keyHigh <= project.settings.keyLow)
|
|
761
786
|
project.settings.keyHigh = Math.min(255, project.settings.keyLow + 1);
|
|
787
|
+
// 改底色时,把「还是默认句式」的提示词一起换过去;用户手改过一个字都不动。
|
|
788
|
+
if (before.keyColor !== project.settings.keyColor)
|
|
789
|
+
applyKeyColorToPrompts(project.prompts, project.settings.keyColor);
|
|
762
790
|
const differs = (fields) => fields.some((field) => JSON.stringify(before[field]) !== JSON.stringify(project.settings[field]));
|
|
763
791
|
if (differs(["workingLongEdge", "cropInset"])) {
|
|
764
792
|
// 抽帧参数变了:raw.bin 已经作废,必须重抽,不能只重新合成。
|
|
@@ -974,7 +1002,8 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
974
1002
|
anchor: input.anchor,
|
|
975
1003
|
objectScale: input.objectScale,
|
|
976
1004
|
pass: input.pass,
|
|
977
|
-
keyGreen: input.keyGreen
|
|
1005
|
+
keyGreen: input.keyGreen,
|
|
1006
|
+
keyColor: typeof input.keyColor === "string" && input.keyColor.trim() !== "" ? input.keyColor : (await loadConfig()).keyColor
|
|
978
1007
|
});
|
|
979
1008
|
const project = await isogen.readIsoProject(asString(input.projectId));
|
|
980
1009
|
const revisions = await isogen.tilesetRevisions(asString(input.projectId));
|
|
@@ -988,13 +1017,15 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
988
1017
|
}
|
|
989
1018
|
async composeIsoAsset(payload) {
|
|
990
1019
|
const input = asRecord(payload);
|
|
1020
|
+
const config = await loadConfig();
|
|
991
1021
|
return isogen.composeIsoAsset({
|
|
992
1022
|
projectId: asString(input.projectId),
|
|
993
1023
|
name: asString(input.name),
|
|
994
1024
|
files: Array.isArray(input.files) ? input.files.map((file) => asString(file)) : [],
|
|
995
1025
|
kind: input.kind,
|
|
996
1026
|
footprint: input.footprint,
|
|
997
|
-
keyGreen: input.keyGreen === false ? false : true
|
|
1027
|
+
keyGreen: input.keyGreen === false ? false : true,
|
|
1028
|
+
keyColor: typeof input.keyColor === "string" && input.keyColor.trim() !== "" ? input.keyColor : config.keyColor
|
|
998
1029
|
});
|
|
999
1030
|
}
|
|
1000
1031
|
async saveIsoTileset(payload) {
|
|
@@ -1188,8 +1219,9 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
1188
1219
|
loop: input.loop,
|
|
1189
1220
|
// 整图规格(给了它就是整图;校验在 mapgen.parseStampSpec 里)。
|
|
1190
1221
|
stamp: input.stamp,
|
|
1191
|
-
//
|
|
1192
|
-
stampKey: input.stampKey
|
|
1222
|
+
// 整图:导入时抠背景(手动那条路;AI 那条在 composeMapAsset 里已经抠过)。
|
|
1223
|
+
stampKey: input.stampKey,
|
|
1224
|
+
keyColor: typeof input.keyColor === "string" && input.keyColor.trim() !== "" ? input.keyColor : (await loadConfig()).keyColor
|
|
1193
1225
|
});
|
|
1194
1226
|
// `rev` 不在 project.json 里(派生数据),要在回给界面时现取 —— 少了它重烘后界面会拿旧缓存图。
|
|
1195
1227
|
const revisions = await mapgen.tilesetRevisions(asString(input.projectId));
|
|
@@ -1213,6 +1245,7 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
1213
1245
|
async composeMapAsset(payload) {
|
|
1214
1246
|
const input = asRecord(payload);
|
|
1215
1247
|
const files = Array.isArray(input.files) ? input.files.map((file) => asString(file)) : [];
|
|
1248
|
+
const config = await loadConfig();
|
|
1216
1249
|
return mapgen.composeMapAsset({
|
|
1217
1250
|
projectId: asString(input.projectId),
|
|
1218
1251
|
name: asString(input.name),
|
|
@@ -1222,7 +1255,8 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
1222
1255
|
animRows: input.animRows === true ? true : input.animRows === false ? false : undefined,
|
|
1223
1256
|
// 整图:占几格(校验在 mapgen.parseStampSpec 里;不给就按 3×3 常见尺寸?不 —— 明确报错)。
|
|
1224
1257
|
stampCols: input.stampCols,
|
|
1225
|
-
stampRows: input.stampRows
|
|
1258
|
+
stampRows: input.stampRows,
|
|
1259
|
+
keyColor: typeof input.keyColor === "string" && input.keyColor.trim() !== "" ? input.keyColor : config.keyColor
|
|
1226
1260
|
});
|
|
1227
1261
|
}
|
|
1228
1262
|
async recomposeMapTileset(payload) {
|
|
@@ -1660,8 +1694,21 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
1660
1694
|
const current = await loadConfig();
|
|
1661
1695
|
// 生图模型是全局设置(设置 → 游戏素材大师 → 生图后端),任务里不保留可覆盖的副本。
|
|
1662
1696
|
job.settings.model = imageModelOf(current);
|
|
1663
|
-
|
|
1664
|
-
|
|
1697
|
+
/**
|
|
1698
|
+
* 尺寸来源:默认跟随全局;用户显式选「自定义」后,本任务的 size 才保留。
|
|
1699
|
+
*
|
|
1700
|
+
* 兼容老客户端 / 对话工具面:只传 `size` 不传 `sizeMode` 时,如果它和当前
|
|
1701
|
+
* 全局尺寸不同,就视为「这个任务要自定义」,避免「传了 size 却被静默忽略」。
|
|
1702
|
+
*/
|
|
1703
|
+
const globalSize = imageSizeOf(current);
|
|
1704
|
+
const requested = typeof raw.size === "string" ? raw.size.trim() : "";
|
|
1705
|
+
let mode = raw.sizeMode === "custom" ? "custom" : raw.sizeMode === "global" ? "global" : job.settings.sizeMode === "custom" ? "custom" : "global";
|
|
1706
|
+
if (raw.sizeMode === undefined && requested !== "" && requested !== globalSize)
|
|
1707
|
+
mode = "custom";
|
|
1708
|
+
job.settings.sizeMode = mode;
|
|
1709
|
+
job.settings.size = mode === "custom"
|
|
1710
|
+
? requested !== "" ? requested : job.settings.size || globalSize
|
|
1711
|
+
: globalSize;
|
|
1665
1712
|
job.settings.count = clampInt(raw.count, job.settings.count, 1, 8);
|
|
1666
1713
|
job.settings.watermark = raw.watermark === true;
|
|
1667
1714
|
}
|
|
@@ -2647,6 +2694,8 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
2647
2694
|
* 三个模块共用同一套参数名,所以收敛逻辑也共用。
|
|
2648
2695
|
*/
|
|
2649
2696
|
function applyKeying(target, raw) {
|
|
2697
|
+
if (typeof raw.keyColor === "string")
|
|
2698
|
+
target.keyColor = normalizeKeyColor(raw.keyColor, target.keyColor || DEFAULT_KEY_COLOR);
|
|
2650
2699
|
target.keyLow = clampInt(raw.keyLow, target.keyLow, 0, 255);
|
|
2651
2700
|
target.keyHigh = clampInt(raw.keyHigh, target.keyHigh, 1, 255);
|
|
2652
2701
|
if (target.keyHigh <= target.keyLow)
|
package/lib/isocompose.js
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
import { stat } from "node:fs/promises";
|
|
16
16
|
import { decodeFile } from "./bitmap.js";
|
|
17
17
|
import { MAX_ASSET_SCALE, keyStampBackground, resampleToSize, STAMP_KEY_OPTIONS } from "./maptiles.js";
|
|
18
|
+
import { isGreenKeyColor, keyScreenName, normalizeKeyColor } from "./keycolor.js";
|
|
19
|
+
import { keyGreen } from "./chroma.js";
|
|
18
20
|
const MAX_AI_FRAME_BYTES = 64 * 1024 * 1024;
|
|
19
21
|
const MAX_AI_FRAMES = 64;
|
|
20
22
|
function clamp(value, min, max) {
|
|
@@ -57,7 +59,7 @@ function cropOpaque(source) {
|
|
|
57
59
|
return { width, height, rgba };
|
|
58
60
|
}
|
|
59
61
|
/** 读一张原图、抠绿、裁到内容边界;返回可直接缩放的帧。 */
|
|
60
|
-
async function readFrame(file, keyGreen) {
|
|
62
|
+
async function readFrame(file, keyGreen, keyColor) {
|
|
61
63
|
let info;
|
|
62
64
|
try {
|
|
63
65
|
info = await stat(file);
|
|
@@ -81,7 +83,7 @@ async function readFrame(file, keyGreen) {
|
|
|
81
83
|
if (keyGreen) {
|
|
82
84
|
const result = keyStampBackground(bitmap, (rgba, width, height) => {
|
|
83
85
|
// 与「整图」同一条严格绿幕参数:只认饱和纯绿,避免把草地 / 深色阴影误判成背景。
|
|
84
|
-
return
|
|
86
|
+
return keyBackgroundPixels(rgba, width, height, keyColor);
|
|
85
87
|
});
|
|
86
88
|
bitmap = result.bitmap;
|
|
87
89
|
keyed = result.keyed;
|
|
@@ -92,20 +94,25 @@ async function readFrame(file, keyGreen) {
|
|
|
92
94
|
* 严格绿幕(与 maptiles.STAMP_KEY_OPTIONS 同口径)。
|
|
93
95
|
* 这里单独包一层是为了不把 chroma 的默认参数(适合角色)带进地图素材。
|
|
94
96
|
*/
|
|
95
|
-
function
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
out[i * 4 +
|
|
105
|
-
|
|
97
|
+
function keyBackgroundPixels(rgba, width, height, keyColor) {
|
|
98
|
+
const color = normalizeKeyColor(keyColor);
|
|
99
|
+
// 绿色保持原来的严格判据(只认饱和纯绿),避免把草地 / 深色阴影误判成背景。
|
|
100
|
+
if (isGreenKeyColor(color)) {
|
|
101
|
+
const out = Buffer.from(rgba);
|
|
102
|
+
let hit = 0;
|
|
103
|
+
for (let i = 0; i < width * height; i++) {
|
|
104
|
+
const r = out[i * 4];
|
|
105
|
+
const g = out[i * 4 + 1];
|
|
106
|
+
const b = out[i * 4 + 2];
|
|
107
|
+
const advantage = g - Math.max(r, b);
|
|
108
|
+
if (g >= STAMP_KEY_OPTIONS.keyLow && advantage >= STAMP_KEY_OPTIONS.keyHigh) {
|
|
109
|
+
out[i * 4 + 3] = 0;
|
|
110
|
+
hit++;
|
|
111
|
+
}
|
|
106
112
|
}
|
|
113
|
+
return { rgba: out, backgroundFraction: hit / Math.max(1, width * height) };
|
|
107
114
|
}
|
|
108
|
-
return
|
|
115
|
+
return keyGreen(rgba, width, height, { ...STAMP_KEY_OPTIONS, keyColor: color });
|
|
109
116
|
}
|
|
110
117
|
/** 把一帧贴进目标格子的菱形框;只保留菱形内部。 */
|
|
111
118
|
function drawGroundDiamond(source, cell, scale) {
|
|
@@ -205,18 +212,20 @@ export async function composeIsoFrames(input) {
|
|
|
205
212
|
? { cols: 1, rows: 1 }
|
|
206
213
|
: { cols: Math.max(1, Math.round(input.footprint.cols)), rows: Math.max(1, Math.round(input.footprint.rows)) };
|
|
207
214
|
const keyGreen = input.keyGreen !== false;
|
|
215
|
+
const keyColor = normalizeKeyColor(input.keyColor);
|
|
208
216
|
const notes = [];
|
|
209
217
|
const read = [];
|
|
210
218
|
for (const file of files)
|
|
211
|
-
read.push(await readFrame(file, keyGreen));
|
|
219
|
+
read.push(await readFrame(file, keyGreen, keyColor));
|
|
212
220
|
const keyedValues = read.map((entry) => entry.keyed);
|
|
213
221
|
const keyedCount = keyedValues.filter((value) => value > 0).length;
|
|
214
222
|
const keyed = keyedValues.length === 0 ? 0 : keyedValues.reduce((sum, value) => sum + value, 0) / keyedValues.length;
|
|
223
|
+
const screen = keyScreenName(keyColor, "zh");
|
|
215
224
|
if (keyGreen && keyedCount === 0) {
|
|
216
|
-
notes.push(
|
|
225
|
+
notes.push(`没检测到${screen}背景:这次按原图用了。想要透明背景,让模型把背景画成纯色 ${keyColor}(不要渐变 / 阴影)。`);
|
|
217
226
|
}
|
|
218
227
|
else if (keyedCount > 0) {
|
|
219
|
-
notes.push(
|
|
228
|
+
notes.push(`已抠掉${screen}背景(平均 ${Math.round(keyed * 100)}% 的像素变成透明)。`);
|
|
220
229
|
}
|
|
221
230
|
if (input.kind === "ground") {
|
|
222
231
|
const first = read[0].bitmap;
|
package/lib/isogen.js
CHANGED
|
@@ -12,6 +12,7 @@ import { appendJobLog, messageOf, readJson, sweepTempFiles, writeJsonAtomic } fr
|
|
|
12
12
|
import { dataRoot } from "./config.js";
|
|
13
13
|
import { decodeFile, encodeBitmap, pngSize, probeImageSize, sniffImageExt } from "./bitmap.js";
|
|
14
14
|
import { keyGreen } from "./chroma.js";
|
|
15
|
+
import { keyScreenName, normalizeKeyColor } from "./keycolor.js";
|
|
15
16
|
import { MAX_ASSET_SCALE, cropTile, flatTiles, keyStampBackground, parseAssetFps, parseAssetLoop, parseClarity, resampleToSize, safeAssetStem, STAMP_KEY_OPTIONS } from "./maptiles.js";
|
|
16
17
|
import { DEFAULT_ISO_CELL, MAX_ISO_DIM, MAX_ISO_PLAN_CHUNKS, assertIsoCell, assertIsoMapSize, chunkKey, chunksInRange, dirtyChunksFor, layoutOf, normalizeIsoCell, viewCellRange, wrapCell } from "./isogeom.js";
|
|
17
18
|
import { addLayer as docAddLayer, applyIsoOps as applyOpsToDoc, clearLayer as docClearLayer, cellIndex, cloneIsoDoc, createIsoDoc, filledCount, moveLayer as docMoveLayer, normalizeIsoDoc, objectCount, removeLayer as docRemoveLayer, renameLayer as docRenameLayer, resizeDoc } from "./isodoc.js";
|
|
@@ -555,10 +556,12 @@ export async function importIsoTileset(projectId, name, base64, opts = {}) {
|
|
|
555
556
|
anchor = parseIsoAnchor(opts.anchor) ?? { x: 0.5, y: 1 };
|
|
556
557
|
pass = parsePassCells(opts.pass, footprint) ?? new Array(footprint.cols * footprint.rows).fill(1);
|
|
557
558
|
if (opts.keyGreen === true) {
|
|
558
|
-
const
|
|
559
|
+
const keyColor = normalizeKeyColor(opts.keyColor);
|
|
560
|
+
const screen = keyScreenName(keyColor, "zh");
|
|
561
|
+
const keyed = keyStampBackground(bitmap, (rgba, width, height) => keyGreen(rgba, width, height, { ...STAMP_KEY_OPTIONS, keyColor }));
|
|
559
562
|
bitmap = keyed.bitmap;
|
|
560
563
|
if (keyed.keyed === 0)
|
|
561
|
-
warnings.push(
|
|
564
|
+
warnings.push(`没有检测到${screen}背景,按原图用了。`);
|
|
562
565
|
}
|
|
563
566
|
const targetWidth = Math.max(1, Math.round(footprint.cols * project.cell.width * (objectScale ?? 1)));
|
|
564
567
|
stored = objectSheet(bitmap, sourceCell, frames, targetWidth, clarity);
|
|
@@ -652,7 +655,8 @@ export async function composeIsoAsset(input) {
|
|
|
652
655
|
kind: input.kind,
|
|
653
656
|
cell: project.cell,
|
|
654
657
|
footprint,
|
|
655
|
-
keyGreen: input.keyGreen !== false
|
|
658
|
+
keyGreen: input.keyGreen !== false,
|
|
659
|
+
keyColor: input.keyColor
|
|
656
660
|
});
|
|
657
661
|
const name = input.name === undefined || String(input.name).trim() === "" ? "AI 素材" : String(input.name).trim();
|
|
658
662
|
const file = `ai/${safeAssetStem(name)}.png`;
|