dsh-game-material-master 0.6.0 → 0.7.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/README.en.md CHANGED
@@ -29,11 +29,11 @@ and move on automatically, or stop at every step and wait for your go-ahead.
29
29
 
30
30
  | Module | What it does | What you get |
31
31
  |---|---|---|
32
- | **① Eight-direction sprite sheet** | One character sheet → 8 directions × 8 frames (default "turn capture": eight directions cut from one rotation video) | A walk spritesheet you can drive with WASD |
32
+ | **① Eight-direction sprite sheet** | One character sheet → 8 directions × 8 frames (default "turn capture": eight directions cut from one rotation video; both videos can also be **a local file of your own**) | A walk spritesheet you can drive with WASD (every intermediate image can be saved individually or as one zip) |
33
33
  | **② Image generation** | Prompt (optionally with reference images) → images → green-screen keying | Clean transparent PNG character art / props |
34
34
  | **③ Sequence frames** | First/last frame or a reference video → generate video → extract frames → key | A horizontally laid out, loopable sequence |
35
35
  | **⑤ Map tile generation** | Isometric tiles → assemble a whole map | A tile pack (PNGs) + map PNG + layout JSON |
36
- | **⑥ Map editor** (experimental, **fully local, zero cost**) | Pick a tileset → paint directly (rebuilt after AsLib's RPG Map Maker: one screen, icon-only, no jargon) | PNG + save-file JSON (wrapping map, auto-tiling, animated tiles); tick what to export and multiple files come as one ZIP download |
36
+ | **⑥ Map editor** (**fully local, zero cost**) | Pick a tileset → paint directly (rebuilt after AsLib's RPG Map Maker: one screen, icon-only, no jargon; three default layers — terrain / decor / buildings — that you can rename and reorder; a **marker layer**: one nameable marker per cell, drawn as a numbered circle) | PNG + save-file JSON (wrapping map, auto-tiling, animated tiles, markers); tick what to export and multiple files come as one ZIP download |
37
37
  | ~~④ Rigged animation~~ | Part extraction → assembly → skeletal animation → Spine / DragonBones atlas | **Experimental, not covered in this document** |
38
38
 
39
39
  > 💡 **Module ⑤ "Map tile generation" is built on one idea: geometry by code, content by AI.**
@@ -105,6 +105,31 @@ so old and new orientations never get mixed together). The default positions ass
105
105
  direction or at a different pace, just drag the circles, or click "turn direction" to re-order them. Changing
106
106
  the candidate frame count (8–64) re-extracts automatically and rescales any positions you have dragged.
107
107
 
108
+ ### You can also use **a video from your own computer** (steps ① and ②)
109
+
110
+ Neither of the two "generate a video" places only has the "call the model" path: when you already have a
111
+ suitable video, click **Choose a local video** and pick it — the result is identical to a generated one and
112
+ the later steps work exactly the same.
113
+
114
+ - **Step ① · turn video**: pick a chroma-key video of the character turning a full circle in place; the plugin
115
+ extracts the candidate frames and cuts out the eight directions **immediately**, then you just drag the
116
+ circles to adjust positions.
117
+ - **Step ② · the walk video of one direction**: each cell can pick its own file (fixed camera, walking in
118
+ place), and step 3 "extract all sequence frames" still applies.
119
+ - MP4 / MOV / M4V / WebM / MKV / AVI are supported (detected by **file header**, not by extension), up to
120
+ 100MB each; this path is processed locally with ffmpeg and is never uploaded to any model.
121
+ - Replacing a video invalidates the frames and sheet already derived from it, so frames from the previous
122
+ video can never leak into the new one.
123
+
124
+ ### Every intermediate image can be saved
125
+
126
+ **Every image** produced along the way can be saved: the eight chroma-key images, the turn candidate frames
127
+ and the full-rotation strip, the chroma-key frames and manual-pick candidates extracted from each video, the
128
+ keyed frames, and the final sheet. Every product you can see in the UI has a "Save" link; since one candidate
129
+ extraction produces 32–64 images at once, the bottom toolbar also has **Save all images (zip)** — one archive
130
+ laid out like the project directory (`images/…`, `turn/…`, `frames/…`, `keyed/…`, `out/sheet.png`).
131
+ The generated videos (the turn video and the eight walk videos) each have a "Save video" link too.
132
+
108
133
  ### How to use it
109
134
 
110
135
  1. **Create a project → upload a character sheet**, then write your prompts (turn capture uses **one turn-video
@@ -212,7 +237,7 @@ flowchart LR
212
237
 
213
238
  ## Driving it from chat
214
239
 
215
- **Every feature of all six modules** (including the experimental rigged animation, map tiles and the map editor) **is available through
240
+ **Every feature of all six modules** (including the experimental rigged animation and map tiles) **is available through
216
241
  chat**. The plugin registers the whole pipeline as `game_material_*` tools, so an agent can drive it forward,
217
242
  wait, review, and also stop at each step for you to approve.
218
243
 
@@ -244,7 +269,7 @@ dsh plugin --profile web add /path/to/dsh-game-material-master
244
269
  ```
245
270
 
246
271
  The package is published to npm: [dsh-game-material-master](https://www.npmjs.com/package/dsh-game-material-master)
247
- (currently `0.6.0`, `latest`). It has no runtime dependencies, so `dsh plugin add` is all you need.
272
+ (currently `0.7.0`, `latest`). It has no runtime dependencies, so `dsh plugin add` is all you need.
248
273
 
249
274
  After installing, **restart DSH** (the host half is loaded at startup). The browser half is read from
250
275
  `lib/client.js` on disk on each request, so refreshing the browser is enough for it to take effect.
@@ -264,8 +289,12 @@ point `FFMPEG_PATH` / `FFPROBE_PATH` at absolute paths. The package has **no run
264
289
 
265
290
  | Item | Description |
266
291
  |---|---|
292
+ | Image backend | Pick **Volcengine Ark Seedream** (default) or a **custom image model**; switching here redirects every image-generating module |
267
293
  | Volcengine Ark API Key | "Test connection" really generates a 1K thumbnail (a small charge) and validates both the key and the model |
268
294
  | Image model | Defaults to `doubao-seedream-5-0-flash-260915`; switchable to 5.0 Pro / Lite / 4.5 |
295
+ | Custom protocol | One of `OpenAI API` / `ComfyUI API` / `Stable Diffusion WebUI API`; just give the host root URL |
296
+ | Custom parameters | Model name, output size (width x height), negative prompt, steps / CFG / sampler, img2img denoising, seed, timeout |
297
+ | ComfyUI workflow | Paste the whole JSON from "Export (API)"; placeholders `{{prompt}}` `{{width}}` `{{seed}}` `{{image}}` and friends are supported, and a workflow with none runs as-is |
269
298
  | MiniMax API Key | "Test connection" is free and can tell an invalid key apart from other errors |
270
299
  | Video model | Defaults to `MiniMax-H3` (v2 protocol); Hailuo / I2V use v1; the UCloud version of H3 is selected explicitly |
271
300
  | Base URL | Host root, without `/v1` or `/v2`. `api.minimax.cn` in mainland China, `api.minimaxi.com` internationally |
@@ -273,8 +302,23 @@ point `FFMPEG_PATH` / `FFPROBE_PATH` at absolute paths. The package has **no run
273
302
  | Feature management | Per-module switches: a disabled module disappears from the UI **and the agent cannot call it either** (see below) |
274
303
 
275
304
  Keys are written only to `<DSH_HOME>/game-material-master/config.json` on your machine, and the UI always
276
- masks them when displaying them back. **The model is a plugin-level setting shared by all three modules**;
277
- after you switch models, tasks align to the new tier automatically.
305
+ masks them when displaying them back. **The image backend and model are plugin-level settings shared by
306
+ every module that generates images**; after you switch, tasks align to the new tier automatically.
307
+ Image-to-video always goes through MiniMax and is unaffected by the image backend.
308
+
309
+ ### Custom image backend
310
+
311
+ Besides Volcengine Ark you can plug in **your own image service** (Settings → Game Material Master → Image backend):
312
+
313
+ | Protocol | Text-to-image | With reference images | Notes |
314
+ |---|---|---|---|
315
+ | OpenAI API | `POST {base}/images/generations` | `POST {base}/images/edits` (falls back to the `image` field of generations when the endpoint does not exist) | Works with OpenAI itself and compatible gateways; both `b64_json` and `url` responses are accepted |
316
+ | ComfyUI API | `POST {base}/prompt` → poll `/history` → `GET /view` | `POST {base}/upload/image` first, then the file name goes into the workflow | Needs an **API-format** workflow JSON; when `{{image}}` is absent the `LoadImage` node is patched automatically |
317
+ | Stable Diffusion WebUI API | `POST {base}/sdapi/v1/txt2img` | `POST {base}/sdapi/v1/img2img` (`init_images` + denoising strength) | WebUI must be started with `--api`; an API key of `user:pass` uses HTTP Basic |
318
+
319
+ Local servers usually need no API key; enter the **host root** (for example `http://127.0.0.1:8188`) and the
320
+ plugin appends the protocol-specific endpoint. Hit "Test connection" to really generate one test image and
321
+ prove the whole path works.
278
322
 
279
323
  ### Feature management (hiding modules you do not use)
280
324
 
package/README.md CHANGED
@@ -24,11 +24,11 @@
24
24
 
25
25
  | 模块 | 做什么 | 走完能拿到 |
26
26
  |---|---|---|
27
- | **① 八方向图生成** | 一张设定图 → 8 方位 × 8 帧(默认「转圈截帧」:一段转圈视频截出八个方向) | 可用 WASD 操控预览的行走精灵图 |
27
+ | **① 八方向图生成** | 一张设定图 → 8 方位 × 8 帧(默认「转圈截帧」:一段转圈视频截出八个方向;两处视频都能**自己选本地文件**顶替生成) | 可用 WASD 操控预览的行走精灵图(中间每一张图都能单独存或整包 zip) |
28
28
  | **② 图片生成** | 提示词(可带参考图)→ 出图 → 抠绿幕 | 干净透明的 PNG 立绘 / 道具 |
29
29
  | **③ 序列帧生成** | 首尾帧或参考视频 → 生成视频 → 抽帧 → 抠像 | 横向排布、可循环播放的序列帧 |
30
30
  | **⑤ 45°地图地块生成**(实验性) | 45° 等距地块 → 铺成整张地图 | 地块包(PNG)+ 地图 PNG + 布局 JSON |
31
- | **⑥ 地图编辑器**(实验性,**全本地零计费**) | 选一张素材图 → 直接画(参照 AsLib 的 RPG Map Maker 重做:一屏、纯图标、零术语) | PNG + 存档 JSON(地图四周环绕、自动连接、动画地块);勾几项就导几项,多个产物自动打成一个 ZIP 下载 |
31
+ | **⑥ 地图编辑器**(**全本地零计费**) | 选一张素材图 → 直接画(参照 AsLib 的 RPG Map Maker 重做:一屏、纯图标、零术语;默认「地理层 / 装饰层 / 建筑层」三层且可改名换序;**标记层**:每格放一个可命名的标记,画成圆圈里的数字) | PNG + 存档 JSON(地图四周环绕、自动连接、动画地块、标记点);勾几项就导几项,多个产物自动打成一个 ZIP 下载 |
32
32
  | ~~④ 骨骼动画生成~~ | 拆件 → 装配 → 骨骼动画 → Spine / DragonBones 图集 | **实验性功能,本文不展示** |
33
33
 
34
34
  > 💡 **模块⑤「45°地图地块生成」的核心思路是「几何交给代码,内容交给 AI」。**
@@ -88,6 +88,27 @@ flowchart LR
88
88
  默认位置是「从正面开始、匀速转满一圈」的等分假设;模型实际转的方向或快慢不一样时,
89
89
  直接拖圆圈,或点一下「转圈方向」重排。改变候选帧数(8~64)会自动重抽,并把拖过的位置按比例换算。
90
90
 
91
+ ### 也可以直接用**自己电脑上的视频**(阶段①、②都能)
92
+
93
+ 两处「要生成视频」的地方都不只有「调模型生成」一条路:手上已经有一段合适的视频时,
94
+ 点**选择本地视频**把它选进来即可,产物和生成出来的完全一样,后面几步照旧走。
95
+
96
+ - **阶段①·转圈视频**:选进来的是「角色原地匀速转一圈」的绿幕视频,导入后插件会**立刻**
97
+ 自动抽候选帧并切出八个方向,接着拖圆圈调位置就行。
98
+ - **阶段②·某个方位的行走视频**:每一格都能单独选自己的一段(固定机位、原地走),
99
+ 之后照旧在第 3 步「提取全部序列帧」。
100
+ - 支持 MP4 / MOV / M4V / WebM / MKV / AVI(按**文件头**认,不看扩展名),单个 ≤100MB;
101
+ 这一段只在本机用 ffmpeg 处理,不会上传到任何模型。
102
+ - 换掉某一段视频时,它下游已经抽出来的帧与整图会自动作废,避免拿上一段视频的帧去合成。
103
+
104
+ ### 中间图片都能存下来
105
+
106
+ 一路生成下来的**每一张图**都能保存:八方向绿幕图、转圈候选帧与整圈条带、每段视频抽出来的
107
+ 绿幕帧与手动选帧候选、抠完绿幕的帧、合成整图。界面里看得见的产物每张都有「保存」链接;
108
+ 候选帧一抽就是 32~64 张,所以底部另有一个 **保存全部图片(zip)**——打成一个包,里面按项目
109
+ 目录的结构摆好(`images/…`、`turn/…`、`frames/…`、`keyed/…`、`out/sheet.png`)。
110
+ 生成出来的成片(转圈视频、八段行走视频)同样各自有一个「保存视频」链接。
111
+
91
112
  ### 怎么用
92
113
 
93
114
  1. **新建项目 → 上传设定图**,写提示词(转圈截帧用的是**一份转圈视频提示词**;逐方向生图是每个方位一份,
@@ -178,7 +199,7 @@ flowchart LR
178
199
 
179
200
  ## 用对话驱动
180
201
 
181
- 六个模块(含实验性的骨骼动画、地图地块与地图编辑器)的**全部功能都能通过对话调用**。插件把整条流水线注册成
202
+ 六个模块(含实验性的骨骼动画与地图地块)的**全部功能都能通过对话调用**。插件把整条流水线注册成
182
203
  `game_material_*` 工具,agent 能自己推进、等待、审查,也可以在每一步停下来让你验收。
183
204
 
184
205
  | 工具 | 作用 |
@@ -208,7 +229,7 @@ dsh plugin --profile web add /path/to/dsh-game-material-master
208
229
  ```
209
230
 
210
231
  包已发布到 npm:[dsh-game-material-master](https://www.npmjs.com/package/dsh-game-material-master)
211
- (当前 `0.6.0`,`latest`)。本包没有运行时依赖,`dsh plugin add` 拉下来即可用。
232
+ (当前 `0.7.0`,`latest`)。本包没有运行时依赖,`dsh plugin add` 拉下来即可用。
212
233
 
213
234
  装完**重启 DSH**(宿主半区在启动时装入)。浏览器半区按磁盘上的 `lib/client.js` 现取,
214
235
  刷新浏览器即可生效。
@@ -227,8 +248,12 @@ dsh plugin --profile web add /path/to/dsh-game-material-master
227
248
 
228
249
  | 项 | 说明 |
229
250
  |---|---|
251
+ | 生图后端 | 选**火山方舟 Seedream**(默认)或**自定义生图模型**;换后端只改这一处,所有生图模块都跟着走 |
230
252
  | 火山方舟 API Key | 「测试连接」会真实生成一张 1K 小图(少量费用),同时验证 Key 与模型 |
231
253
  | 生图模型 | 默认 `doubao-seedream-5-0-flash-260915`,可切 5.0 Pro / Lite / 4.5 |
254
+ | 自定义生图协议 | `OpenAI API` / `ComfyUI API` / `Stable Diffusion WebUI API` 三选一,填主机根地址即可 |
255
+ | 自定义生图参数 | 模型名、输出尺寸(宽x高)、负面提示词、采样步数 / CFG / 采样器、图生图重绘强度、种子、超时 |
256
+ | ComfyUI 工作流 | 整段粘贴「导出(API)」的 JSON;支持 `{{prompt}}` `{{width}}` `{{seed}}` `{{image}}` 等占位符,不写占位符就原样跑 |
232
257
  | MiniMax API Key | 「测试连接」免费,能区分 Key 无效与其它错误 |
233
258
  | 视频模型 | 默认 `MiniMax-H3`(v2 协议);Hailuo / I2V 走 v1;优云智算版 H3 显式选择 |
234
259
  | Base URL | 主机根,不含 `/v1` `/v2`。国内 `api.minimax.cn`,国际 `api.minimaxi.com` |
@@ -236,7 +261,21 @@ dsh plugin --profile web add /path/to/dsh-game-material-master
236
261
  | 功能管理 | 逐个开关六个模块:关掉的模块界面上不再出现,**对话里的 AI 也调不到**(见下) |
237
262
 
238
263
  Key 只写入本机 `<DSH_HOME>/game-material-master/config.json`,界面回显始终脱敏。
239
- **模型是插件级设置,三个模块共用**,切换模型后任务自动对齐新档位。
264
+ **生图后端与模型是插件级设置,所有需要生图的模块共用**,切换后任务自动对齐新档位。
265
+ 图生视频始终只走 MiniMax,不受生图后端影响。
266
+
267
+ ### 自定义生图后端
268
+
269
+ 除了火山方舟,插件也支持把你的**自己的生图服务**接进来(设置 → 游戏素材大师 → 生图后端):
270
+
271
+ | 协议 | 生图 | 带参考图 | 说明 |
272
+ |---|---|---|---|
273
+ | OpenAI API | `POST {base}/images/generations` | `POST {base}/images/edits`(端点不存在时退回 generations 的 `image` 字段) | 兼容 OpenAI 官方与各家兼容网关;`b64_json` / `url` 两种返回都认 |
274
+ | ComfyUI API | `POST {base}/prompt` → 轮询 `/history` → `GET /view` | 先 `POST {base}/upload/image`,把文件名写进工作流 | 需要**API 格式**的工作流 JSON;`{{image}}` 占位符没写时自动改 `LoadImage` 节点 |
275
+ | Stable Diffusion WebUI API | `POST {base}/sdapi/v1/txt2img` | `POST {base}/sdapi/v1/img2img`(`init_images` + 重绘强度) | 需要 WebUI 以 `--api` 启动;API Key 填 `user:pass` 走 HTTP Basic |
276
+
277
+ 本地服务通常不需要 API Key;地址填**主机根**(例如 `http://127.0.0.1:8188`),具体端点由插件按协议拼。
278
+ 配好点「测试连接」即可真跑一张测试图确认链路通。
240
279
 
241
280
  ### 功能管理(隐藏不用的模块)
242
281
 
package/lib/ark.js CHANGED
@@ -18,7 +18,7 @@ export class ArkError extends Error {
18
18
  function isFiveSeries(model) {
19
19
  return /seedream-5-0/i.test(model);
20
20
  }
21
- function sniffExt(bytes) {
21
+ export function sniffExt(bytes) {
22
22
  if (bytes.length >= 8 && bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4e && bytes[3] === 0x47)
23
23
  return "png";
24
24
  if (bytes.length >= 3 && bytes[0] === 0xff && bytes[1] === 0xd8 && bytes[2] === 0xff)