feat(models): 模型一律转 VRM(契约 0.5.0)+ 可用性门槛 + 管理端版本号展示
按《DSH 开发文档 v1.6》4.9 与第十一章实现,Web 端第一步:
1. 契约先行(先改 contracts/ 再同步三端):
* model-formats.md -> 0.5.0:模型主力格式改为 VRM,所有上传模型一律转 VRM
(.pmx/.fbx: assimp -> GLB -> VRM;glb/gltf: 包装为 VRM);
新增 humanoid 硬门槛与"不达标回退 GLB + usable=false"的交付表;
* data-models.md -> 0.5.0:Model 新增 usable / unusableReason,明确
usable=false 不进入 catalog/export;format 说明改为主力 vrm;
* VERSION 与 contract-versions.ts 同步(三端契约文件逐字节一致)。
2. 实现:
* MODEL_CONVERT_FORMAT 默认改为 vrm(deploy/.env.example 同步);
* 新增 isUsableModel()/unusableReason():usable 等价于"已产出 VRM",
原因从 stats 里带出 humanoid 覆盖度;
* catalog/export 与 catalog/version 指纹都只统计 format=vrm 的已发布模型,
resolveDefaultModelId 同样只在可用模型中选;
* 管理端:模型列表与审核面板显示「不可用」及原因;
* 管理端左下角展示当前版本号(构建期从 web-server/package.json 注入
__APP_VERSION__,与 GET /health 同源),并去掉写死的"契约 rest-api 0.1.0"。
3. 测试:新增 test/model-usability.spec.ts 5 项;规模 16 文件 / 225 项。
4. 版本 0.3.0。
This commit is contained in:
@@ -101,7 +101,7 @@ opendance-web/
|
|||||||
│ ├── admin/ # React 管理端
|
│ ├── admin/ # React 管理端
|
||||||
│ │ ├── src/components/ModelReviewPanel.tsx # 模型审核面板 + 骨骼详细界面
|
│ │ ├── src/components/ModelReviewPanel.tsx # 模型审核面板 + 骨骼详细界面
|
||||||
│ │ └── src/lib/bone-tree.ts # 骨骼树过滤(搜索保留祖先链)
|
│ │ └── src/lib/bone-tree.ts # 骨骼树过滤(搜索保留祖先链)
|
||||||
│ ├── test/ # 单元测试 + 端到端冒烟(15 文件 / 220 项)
|
│ ├── test/ # 单元测试 + 端到端冒烟(16 文件 / 225 项)
|
||||||
│ │ # mmd-vmd 31 / model-archive 24 / model-inspector 25
|
│ │ # mmd-vmd 31 / model-archive 24 / model-inspector 25
|
||||||
│ │ # / model-thumbnail 8 / admin-bone-filter 8
|
│ │ # / model-thumbnail 8 / admin-bone-filter 8
|
||||||
│ │ # / preprocess 25 / init-env 16 / admin-port 16
|
│ │ # / preprocess 25 / init-env 16 / admin-port 16
|
||||||
@@ -291,6 +291,9 @@ POST /api/models ─┬─.glb /.vrm /.gltf ─▶ importModelFile() 直接导
|
|||||||
`baseColorFactor x diffuse`、清掉 `KHR_materials_specular/volume/transmission/ior`、
|
`baseColorFactor x diffuse`、清掉 `KHR_materials_specular/volume/transmission/ior`、
|
||||||
修正 Assimp 写坏的 `accessor.min/max`。PMX 的球面贴图与 toon 阶梯在 glTF core 里
|
修正 Assimp 写坏的 `accessor.min/max`。PMX 的球面贴图与 toon 阶梯在 glTF core 里
|
||||||
没有槽位,数量写入 `conversion_note`。`MODEL_SHADING=unlit` 可交付"颜色=贴图"的平涂观感。
|
没有槽位,数量写入 `conversion_note`。`MODEL_SHADING=unlit` 可交付"颜色=贴图"的平涂观感。
|
||||||
|
- **模型一律转 VRM(v0.5.0)**: `MODEL_CONVERT_FORMAT` 默认 `vrm`; humanoid 必需骨齐全才产出
|
||||||
|
VRM, 不达标时回退交付 GLB 且 `usable=false`(可入库可审核, **不进入 `catalog/export`**),
|
||||||
|
待按 `skeleton-topology` 标准重绑定骨骼后重新导入即转为可用。
|
||||||
- **入库后自动**: `inspectModelFile()` 分析写入 `models.stats`
|
- **入库后自动**: `inspectModelFile()` 分析写入 `models.stats`
|
||||||
(迁移 `AddModelStats1789460000000`,新增 `models.stats TEXT`);
|
(迁移 `AddModelStats1789460000000`,新增 `models.stats TEXT`);
|
||||||
`renderModelThumbnail()` 写入 `models.thumbnail_asset_id` / `thumbnailUrl`。
|
`renderModelThumbnail()` 写入 `models.thumbnail_asset_id` / `thumbnailUrl`。
|
||||||
@@ -343,7 +346,7 @@ POST /api/models ─┬─.glb /.vrm /.gltf ─▶ importModelFile() 直接导
|
|||||||
T-pose 角色图;真实 10MB VRM(83 关节、5307 顶点)单张耗时 60-121ms(中位 79ms)。
|
T-pose 角色图;真实 10MB VRM(83 关节、5307 顶点)单张耗时 60-121ms(中位 79ms)。
|
||||||
- 管理端 3D 预览放开到 `vrm/glb/gltf`(`fbx` 仍提示"仅归档,请先转换为 GLB/VRM");
|
- 管理端 3D 预览放开到 `vrm/glb/gltf`(`fbx` 仍提示"仅归档,请先转换为 GLB/VRM");
|
||||||
列表页显示 40px 缩略图。
|
列表页显示 40px 缩略图。
|
||||||
- 测试:`npx vitest run` -> **15 个文件 / 220 项通过**
|
- 测试:`npx vitest run` -> **16 个文件 / 225 项通过**
|
||||||
(`model-inspector` 25、`model-thumbnail` 8、`admin-bone-filter` 8、
|
(`model-inspector` 25、`model-thumbnail` 8、`admin-bone-filter` 8、
|
||||||
`model-archive` 24、`mmd-vmd` 31、`preprocess` 25、`init-env` 16、
|
`model-archive` 24、`mmd-vmd` 31、`preprocess` 25、`init-env` 16、
|
||||||
`admin-port` 16、`access-log` 9、`vrm-inspector` 6)。
|
`admin-port` 16、`access-log` 9、`vrm-inspector` 6)。
|
||||||
|
|||||||
@@ -10,7 +10,15 @@ OpenDance Studio **阶段一**: Web 管理服务端(NestJS + TypeORM + 现有 My
|
|||||||
|
|
||||||
## 状态
|
## 状态
|
||||||
|
|
||||||
**阶段一已完成**: T-WEB-001 -> T-WEB-010 全部落地,当前版本 **v0.2.5**(契约 `rest-api / data-models / model-formats 0.4.0`、`database 0.3.0`)。
|
**阶段一已完成**: T-WEB-001 -> T-WEB-010 全部落地,当前版本 **v0.3.0**(契约 `rest-api / data-models / model-formats 0.4.0`、`database 0.3.0`)。
|
||||||
|
|
||||||
|
v0.3.0 修订(**VRM 主力化**,契约 data-models / model-formats -> 0.5.0):
|
||||||
|
|
||||||
|
1. **所有上传的模型一律转 VRM**:`MODEL_CONVERT_FORMAT` 默认改为 `vrm` —— `.pmx/.fbx` 经 `assimp -> GLB -> VRM 1.0`,`glb/gltf` 导入后包装为 VRM;支持库沿用自研 `vrm-writer`/`vrm-inspector` + Assimp(可选 `@gltf-transform/core` 做结构校验);
|
||||||
|
2. **humanoid 门槛与可用性标记**(`usable`):必需骨齐全才产出 VRM;不达标(如 MMD 日文骨名 `0/22`)时回退交付 GLB、`usable=false` —— **可入库、可审核,但不进入 `catalog/export`**(`/api/catalog/version` 指纹同步过滤);待骨骼重绑定后重新导入即转为可用;
|
||||||
|
3. 模型列表与审核面板显示 **「不可用」及其原因**(`unusableReason`,例如 `humanoid 不达标(0/22),未产出 VRM`);`resolveDefaultModelId` 只在可用模型中选择;
|
||||||
|
4. **管理端左下角展示当前版本号**(v1.5 文档第十一章要求):构建期从 `web-server/package.json` 注入 `v__APP_VERSION__`,与 `GET /health` 的 version **同源**;顺带修掉右下角写死的 `契约 rest-api 0.1.0`;
|
||||||
|
5. 新增 5 项测试(`test/model-usability.spec.ts`);规模 16 文件 / 225 项。
|
||||||
|
|
||||||
v0.2.5 修订:
|
v0.2.5 修订:
|
||||||
|
|
||||||
@@ -77,15 +85,15 @@ v0.2.0 主要变更:
|
|||||||
3. 取得发布包并校验(地址用你们自己的制品库替换; 下面是本仓库的发布地址)
|
3. 取得发布包并校验(地址用你们自己的制品库替换; 下面是本仓库的发布地址)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -LO https://gitea.kasugano.cn/zijunchiang/opendance-web/releases/download/v0.2.5/opendance-web-v0.2.5.tar.gz
|
curl -LO https://gitea.kasugano.cn/zijunchiang/opendance-web/releases/download/v0.3.0/opendance-web-v0.3.0.tar.gz
|
||||||
curl -LO https://gitea.kasugano.cn/zijunchiang/opendance-web/releases/download/v0.2.5/SHA256SUMS
|
curl -LO https://gitea.kasugano.cn/zijunchiang/opendance-web/releases/download/v0.3.0/SHA256SUMS
|
||||||
sha256sum -c SHA256SUMS # 期望输出 "OK"
|
sha256sum -c SHA256SUMS # 期望输出 "OK"
|
||||||
```
|
```
|
||||||
|
|
||||||
4. 解压并生成配置(交互式引导,逐项问答,口令不回显)
|
4. 解压并生成配置(交互式引导,逐项问答,口令不回显)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
tar -xzf opendance-web-v0.2.5.tar.gz && cd opendance-web-v0.2.5
|
tar -xzf opendance-web-v0.3.0.tar.gz && cd opendance-web-v0.3.0
|
||||||
bash deploy/init-env.sh
|
bash deploy/init-env.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -155,8 +163,8 @@ FLUSH PRIVILEGES;
|
|||||||
### 5. 部署步骤
|
### 5. 部署步骤
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
tar -xzf opendance-web-v0.2.5.tar.gz
|
tar -xzf opendance-web-v0.3.0.tar.gz
|
||||||
cd opendance-web-v0.2.5
|
cd opendance-web-v0.3.0
|
||||||
bash deploy/init-env.sh # 首次启动引导: 逐项问答生成 deploy/.env(见下)
|
bash deploy/init-env.sh # 首次启动引导: 逐项问答生成 deploy/.env(见下)
|
||||||
bash deploy/install.sh # 已以 root 登录, 不需要 sudo
|
bash deploy/install.sh # 已以 root 登录, 不需要 sudo
|
||||||
```
|
```
|
||||||
@@ -329,12 +337,12 @@ npm run dev # http://localhost:5173(/api 与 /health 代理到 3000)
|
|||||||
cd web-server
|
cd web-server
|
||||||
npm run contracts:check # 契约版本一致性
|
npm run contracts:check # 契约版本一致性
|
||||||
npm run typecheck # TypeScript 严格检查
|
npm run typecheck # TypeScript 严格检查
|
||||||
npm run test # 220 项单元测试 / 15 个文件(VMD 31、模型压缩包 27、
|
npm run test # 225 项单元测试 / 16 个文件(VMD 31、模型压缩包 27、
|
||||||
# 模型检查器 25、缩略图 8、骨骼过滤 8、
|
# 模型检查器 25、缩略图 8、骨骼过滤 8、
|
||||||
# 预处理 25、init-env 16、admin-port 16、
|
# 预处理 25、init-env 16、admin-port 16、
|
||||||
# access-log 9、VRM 检查器 6、.env 预检 12、
|
# access-log 9、VRM 检查器 6、.env 预检 12、
|
||||||
# Assimp 定位与安装 13、stats 容量与编码 12、
|
# Assimp 定位与安装 13、stats 容量与编码 12、
|
||||||
# 缩略图贴图采样 6、MMD 材质对齐 9)
|
# 缩略图贴图采样 6、MMD 材质对齐 9、模型可用性 5)
|
||||||
npm run build # 生产构建
|
npm run build # 生产构建
|
||||||
npm run start:prod & # 启动
|
npm run start:prod & # 启动
|
||||||
npm run test:smoke # 57 项端到端冒烟(需要数据库可连通)
|
npm run test:smoke # 57 项端到端冒烟(需要数据库可连通)
|
||||||
@@ -357,7 +365,7 @@ cd ../admin && npm run build # 管理端构建
|
|||||||
| `STORAGE_DIR` | `/var/lib/opendance/storage` | 上传文件存储目录(原生部署默认值) |
|
| `STORAGE_DIR` | `/var/lib/opendance/storage` | 上传文件存储目录(原生部署默认值) |
|
||||||
| `UPLOAD_MAX_BYTES` | `536870912`(512 MiB) | 单文件上限。反向代理层的同名限制必须不小于此值,否则大模型上传会在代理层被拒(nginx `client_max_body_size` / IIS `requestLimits`),详见 `deploy/proxy/README.md` |
|
| `UPLOAD_MAX_BYTES` | `536870912`(512 MiB) | 单文件上限。反向代理层的同名限制必须不小于此值,否则大模型上传会在代理层被拒(nginx `client_max_body_size` / IIS `requestLimits`),详见 `deploy/proxy/README.md` |
|
||||||
| `ASSIMP_BIN` | `assimp` | Assimp 可执行文件(`install.sh` 会自动安装并解析出绝对路径写入此项)。`.pmx/.fbx` 模型转换与 FBX/glTF 动作预处理需要;缺失时上传会失败并给出安装命令,只上传 `.glb/.vrm` 不受影响 |
|
| `ASSIMP_BIN` | `assimp` | Assimp 可执行文件(`install.sh` 会自动安装并解析出绝对路径写入此项)。`.pmx/.fbx` 模型转换与 FBX/glTF 动作预处理需要;缺失时上传会失败并给出安装命令,只上传 `.glb/.vrm` 不受影响 |
|
||||||
| `MODEL_CONVERT_FORMAT` | `glb` | 需要转换的模型(PMX/FBX)的交付格式:`glb`(两个客户端都原生加载)或 `vrm`。`vrm` = 在 GLB 之上补 `VRMC_vrm` 扩展(humanoid 骨骼 / 表情语义),humanoid 骨骼映射不全时自动回退交付 GLB 并写进 `conversion_note`。产物一律用 `assimp info` 回读校验 |
|
| `MODEL_CONVERT_FORMAT` | `vrm` | 需要转换的模型(PMX/FBX)的交付格式:`glb`(两个客户端都原生加载)或 `vrm`。`vrm` = 在 GLB 之上补 `VRMC_vrm` 扩展(humanoid 骨骼 / 表情语义),humanoid 骨骼映射不全时自动回退交付 GLB 并写进 `conversion_note`。产物一律用 `assimp info` 回读校验 |
|
||||||
| `MODEL_CONVERT_PMX` | `"Hatsune Miku.pmx"` | 压缩包内优先选用的 PMX 文件名(大小写不敏感);找不到时按「格式优先级 -> 目录最浅 -> 文件最大」挑选 |
|
| `MODEL_CONVERT_PMX` | `"Hatsune Miku.pmx"` | 压缩包内优先选用的 PMX 文件名(大小写不敏感);找不到时按「格式优先级 -> 目录最浅 -> 文件最大」挑选 |
|
||||||
| `MODEL_SHADING` | `pbr` | 转换后模型的着色模式。`pbr`:标准 PBR,并按 PMX 参数修正 `doubleSided` / `metallic` / `roughness`;`unlit`:写 `KHR_materials_unlit`,颜色 = 贴图 x `baseColorFactor`、与场景光照无关,最接近 MMD 的平涂观感 |
|
| `MODEL_SHADING` | `pbr` | 转换后模型的着色模式。`pbr`:标准 PBR,并按 PMX 参数修正 `doubleSided` / `metallic` / `roughness`;`unlit`:写 `KHR_materials_unlit`,颜色 = 贴图 x `baseColorFactor`、与场景光照无关,最接近 MMD 的平涂观感 |
|
||||||
| `MODEL_CONVERT_TIMEOUT_MS` | `180000` | 单次转换超时(毫秒) |
|
| `MODEL_CONVERT_TIMEOUT_MS` | `180000` | 单次转换超时(毫秒) |
|
||||||
|
|||||||
+18
-7
@@ -1,5 +1,5 @@
|
|||||||
================================================================
|
================================================================
|
||||||
OpenDance Studio -- Web 管理服务端 v0.2.5 使用说明
|
OpenDance Studio -- Web 管理服务端 v0.3.0 使用说明
|
||||||
================================================================
|
================================================================
|
||||||
|
|
||||||
本服务端是 OpenDance Studio 三端中的第一端, 负责管理歌曲、VRM 模型与
|
本服务端是 OpenDance Studio 三端中的第一端, 负责管理歌曲、VRM 模型与
|
||||||
@@ -8,6 +8,17 @@ OpenDance Studio -- Web 管理服务端 v0.2.5 使用说明
|
|||||||
重要: 本服务端 不部署、不管理 MySQL。数据库为部署方提供的现有实例,
|
重要: 本服务端 不部署、不管理 MySQL。数据库为部署方提供的现有实例,
|
||||||
连接信息通过 .env 注入。
|
连接信息通过 .env 注入。
|
||||||
|
|
||||||
|
v0.3.0 修订 - VRM 主力化(契约 data-models / model-formats -> 0.5.0)
|
||||||
|
1. 所有上传的模型一律转 VRM: MODEL_CONVERT_FORMAT 默认改为 vrm -
|
||||||
|
.pmx/.fbx 经 assimp -> GLB -> VRM 1.0, glb/gltf 导入后包装为 VRM。
|
||||||
|
2. humanoid 门槛与可用性标记(usable): 必需骨齐全才产出 VRM; 不达标
|
||||||
|
(如 MMD 日文骨名 0/22)时回退交付 GLB、usable=false - 可入库、可审核,
|
||||||
|
但不进入 catalog/export(指纹同步过滤); 待骨骼重绑定后重新导入即转为可用。
|
||||||
|
3. 模型列表与审核面板显示"不可用"及原因; 默认模型只在可用模型中选择。
|
||||||
|
4. 管理端左下角展示当前版本号(构建期从 web-server/package.json 注入,
|
||||||
|
与 GET /health 的 version 同源)。
|
||||||
|
5. 新增 5 项测试; 规模 16 文件 / 225 项。
|
||||||
|
|
||||||
v0.2.5 修订 - MMD 材质/着色对齐
|
v0.2.5 修订 - MMD 材质/着色对齐
|
||||||
PMX 的着色模型(卡通阶梯 + 球面贴图 + 平坦环境光)与 glTF PBR 不是一回事,
|
PMX 的着色模型(卡通阶梯 + 球面贴图 + 平坦环境光)与 glTF PBR 不是一回事,
|
||||||
Assimp 转换会丢东西。实测样本 【奥黛塔】_by_原神.zip(39 个材质):
|
Assimp 转换会丢东西。实测样本 【奥黛塔】_by_原神.zip(39 个材质):
|
||||||
@@ -90,11 +101,11 @@ v0.2.1 修订
|
|||||||
2. 准备一个现有的 MySQL / MariaDB 实例, 并建好库与账号(见下方"前置要求")
|
2. 准备一个现有的 MySQL / MariaDB 实例, 并建好库与账号(见下方"前置要求")
|
||||||
本项目不会创建数据库本身
|
本项目不会创建数据库本身
|
||||||
3. 取得发布包并校验(地址用你们自己的制品库替换)
|
3. 取得发布包并校验(地址用你们自己的制品库替换)
|
||||||
curl -LO https://<制品库地址>/opendance-web-v0.2.5.tar.gz
|
curl -LO https://<制品库地址>/opendance-web-v0.3.0.tar.gz
|
||||||
curl -LO https://<制品库地址>/SHA256SUMS
|
curl -LO https://<制品库地址>/SHA256SUMS
|
||||||
sha256sum -c SHA256SUMS # 期望输出 "OK"
|
sha256sum -c SHA256SUMS # 期望输出 "OK"
|
||||||
4. 解压并生成配置(交互式引导, 逐项问答, 口令不回显)
|
4. 解压并生成配置(交互式引导, 逐项问答, 口令不回显)
|
||||||
tar -xzf opendance-web-v0.2.5.tar.gz && cd opendance-web-v0.2.5
|
tar -xzf opendance-web-v0.3.0.tar.gz && cd opendance-web-v0.3.0
|
||||||
bash deploy/init-env.sh
|
bash deploy/init-env.sh
|
||||||
5. 安装(建用户与目录 -> 装依赖 -> 迁移 -> 注册系统服务 -> 等健康检查)
|
5. 安装(建用户与目录 -> 装依赖 -> 迁移 -> 注册系统服务 -> 等健康检查)
|
||||||
bash deploy/install.sh
|
bash deploy/install.sh
|
||||||
@@ -152,8 +163,8 @@ v0.2.1 修订
|
|||||||
(本项目不会创建数据库本身, 也不需要 GRANT OPTION / FILE / SUPER 等管理权限)
|
(本项目不会创建数据库本身, 也不需要 GRANT OPTION / FILE / SUPER 等管理权限)
|
||||||
|
|
||||||
部署步骤
|
部署步骤
|
||||||
tar -xzf opendance-web-v0.2.5.tar.gz
|
tar -xzf opendance-web-v0.3.0.tar.gz
|
||||||
cd opendance-web-v0.2.5
|
cd opendance-web-v0.3.0
|
||||||
bash deploy/init-env.sh # 首次启动引导: 逐项问答生成 deploy/.env(见下)
|
bash deploy/init-env.sh # 首次启动引导: 逐项问答生成 deploy/.env(见下)
|
||||||
bash deploy/install.sh # 已以 root 登录, 不需要 sudo
|
bash deploy/install.sh # 已以 root 登录, 不需要 sudo
|
||||||
|
|
||||||
@@ -328,12 +339,12 @@ deploy/.env 初始化引导(deploy/init-env.sh)
|
|||||||
cd web-server
|
cd web-server
|
||||||
npm run contracts:check # 契约版本一致性
|
npm run contracts:check # 契约版本一致性
|
||||||
npm run typecheck # TypeScript 严格检查
|
npm run typecheck # TypeScript 严格检查
|
||||||
npm run test # 220 项单元测试 / 15 个文件(VMD 31、模型压缩包 24、
|
npm run test # 225 项单元测试 / 16 个文件(VMD 31、模型压缩包 24、
|
||||||
# 模型检查器 25、缩略图 8、骨骼过滤 8、
|
# 模型检查器 25、缩略图 8、骨骼过滤 8、
|
||||||
# 预处理 25、init-env 16、admin-port 16、
|
# 预处理 25、init-env 16、admin-port 16、
|
||||||
# access-log 9、VRM 检查器 6、.env 预检 12、
|
# access-log 9、VRM 检查器 6、.env 预检 12、
|
||||||
# Assimp 定位与安装 13、stats 容量与编码 12、缩略图贴图 6、
|
# Assimp 定位与安装 13、stats 容量与编码 12、缩略图贴图 6、
|
||||||
# MMD 材质对齐 9)
|
# MMD 材质对齐 9、模型可用性 5)
|
||||||
npm run build # 生产构建
|
npm run build # 生产构建
|
||||||
npm run start:prod & # 启动
|
npm run start:prod & # 启动
|
||||||
npm run test:smoke # 57 项端到端冒烟(需要数据库可连通)
|
npm run test:smoke # 57 项端到端冒烟(需要数据库可连通)
|
||||||
|
|||||||
+2
-2
@@ -2,7 +2,7 @@
|
|||||||
# 规则:任何字段级变更必须提升对应条目版本,并回到 opendance-web 修改后再向另两端建迁移任务。
|
# 规则:任何字段级变更必须提升对应条目版本,并回到 opendance-web 修改后再向另两端建迁移任务。
|
||||||
rest-api: 0.4.0
|
rest-api: 0.4.0
|
||||||
websocket-keypoints: 0.1.0
|
websocket-keypoints: 0.1.0
|
||||||
data-models: 0.4.0
|
data-models: 0.5.0
|
||||||
skeleton-topology: 0.1.0
|
skeleton-topology: 0.1.0
|
||||||
model-formats: 0.4.0
|
model-formats: 0.5.0
|
||||||
database: 0.3.0
|
database: 0.3.0
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# contracts/data-models.md - 数据模型契约 v0.4.0
|
# contracts/data-models.md - 数据模型契约 v0.5.0
|
||||||
|
|
||||||
Web 服务端是唯一权威定义,本文件是另两端消费的**稳定视图**。
|
Web 服务端是唯一权威定义,本文件是另两端消费的**稳定视图**。
|
||||||
字段名在 JSON 中统一 `camelCase`;数据库列名 `snake_case`(见 `database.md`)。
|
字段名在 JSON 中统一 `camelCase`;数据库列名 `snake_case`(见 `database.md`)。
|
||||||
@@ -96,8 +96,10 @@ rejected 已驳回
|
|||||||
|--|--|--|--|
|
|--|--|--|--|
|
||||||
| `id` | number | 读 | |
|
| `id` | number | 读 | |
|
||||||
| `name` | string | ✅ | 模型名称,<=200 |
|
| `name` | string | ✅ | 模型名称,<=200 |
|
||||||
| `format` | enum | ✅ | `glb` / `vrm`(主力)/ `gltf` / `fbx`(历史数据)。上传的 PMX/FBX 会被服务端转换成 glb 或 vrm 再入库,见 model-formats.md 1.1 |
|
| `format` | enum | ✅ | `vrm`(主力)/ `glb`(回退或历史数据)/ `gltf` / `fbx`。**所有上传模型一律转换为 VRM**,只有 humanoid 不达标时回退为 `glb` 并置 `usable=false`,见 model-formats.md 1.1 |
|
||||||
| `vrmVersion` | string\|null | 读 | `0.x` / `1.0`,非 VRM 为 null |
|
| `vrmVersion` | string\|null | 读 | `0.x` / `1.0`,非 VRM 为 null |
|
||||||
|
| `usable` | boolean | 读 | **是否可被客户端使用**:等价于"已产出 VRM"(`format=vrm`)。`false` 的模型**不出现在 `catalog/export`**(v0.5.0) |
|
||||||
|
| `unusableReason` | string\|null | 读 | `usable=false` 时的原因,例如 `humanoid 不达标(0/22),未产出 VRM` |
|
||||||
| `isPrimary` | boolean | | 全局默认模型;**同一时刻全库至多一个 `true`** |
|
| `isPrimary` | boolean | | 全局默认模型;**同一时刻全库至多一个 `true`** |
|
||||||
| `fileUrl` | string | 读 | |
|
| `fileUrl` | string | 读 | |
|
||||||
| `fileSize` | number | 读 | |
|
| `fileSize` | number | 读 | |
|
||||||
|
|||||||
@@ -1,20 +1,41 @@
|
|||||||
# contracts/model-formats.md - 模型与动作格式契约 v0.4.0
|
# contracts/model-formats.md - 模型与动作格式契约 v0.5.0
|
||||||
|
|
||||||
## 1. 角色模型(models)
|
## 1. 角色模型(models)
|
||||||
|
|
||||||
**系统以 GLB / VRM 为主力格式**(两个客户端都原生加载),其余格式一律在服务端转换。
|
**v0.5.0 起模型主力格式为 VRM**: **所有上传的模型都转换为 VRM**(`MODEL_CONVERT_FORMAT`
|
||||||
|
默认 `vrm`);GLB 退为**转换中间产物**与 **humanoid 不达标时的回退交付**。
|
||||||
|
两个客户端(Godot `godot-vrm` / 管理端 `@pixiv/three-vrm`)都原生加载 VRM。
|
||||||
|
|
||||||
| 格式 | 扩展名 | 支持级别 | 服务端行为 |
|
| 格式 | 扩展名 | 支持级别 | 服务端行为 |
|
||||||
|--|--|--|--|
|
|--|--|--|--|
|
||||||
| glTF Binary | `.glb` | **主力(P0)** | **直接导入**,不重编码 |
|
|
||||||
| VRM | `.vrm` | **主力(P0)** | **直接导入**; = GLB + VRM 扩展(humanoid / 表情 / springBone / meta) |
|
| VRM | `.vrm` | **主力(P0)** | **直接导入**; = GLB + VRM 扩展(humanoid / 表情 / springBone / meta) |
|
||||||
|
| glTF Binary | `.glb` | 输入(P0) | 导入后**包装为 VRM**(含 `VRMC_vrm`);humanoid 不齐时保留 GLB 并标记 `usable=false` |
|
||||||
| glTF | `.gltf` (+ `.bin`, 贴图) | P1 | 直接导入(分离文件在 zip 内可用;单文件上传会缺.bin) |
|
| glTF | `.gltf` (+ `.bin`, 贴图) | P1 | 直接导入(分离文件在 zip 内可用;单文件上传会缺.bin) |
|
||||||
| MMD 压缩包 | `.zip` | P1 | **自动搜索包内可用模型**:优先直接导入 `.vrm`/`.glb`/`.gltf`,否则转换 `.pmx`/`.fbx`,见 1.1 |
|
| MMD 压缩包 | `.zip` | P1 | **自动搜索包内可用模型**:优先直接导入 `.vrm`/`.glb`/`.gltf`,否则转换 `.pmx`/`.fbx`,见 1.1 |
|
||||||
| MMD 模型 | `.pmx` | P2(输入) | 服务端转换(优先 GLB、其次 VRM);单文件上传无贴图 |
|
| MMD 模型 | `.pmx` | P2(输入) | 服务端转换:`assimp -> GLB -> VRM`;单文件上传无贴图 |
|
||||||
| FBX | `.fbx` | P2(输入) | 服务端转换(优先 GLB、其次 VRM) |
|
| FBX | `.fbx` | P2(输入) | 服务端转换:`assimp -> GLB -> VRM` |
|
||||||
|
|
||||||
### 1.1 上传与转换策略
|
### 1.1 上传与转换策略
|
||||||
|
|
||||||
|
**v0.5.0 起的一律转换链路**:
|
||||||
|
|
||||||
|
```
|
||||||
|
.vrm -> 直接导入(已是 VRM)
|
||||||
|
.glb / .gltf -> 包装为 VRM 1.0(写 VRMC_vrm)
|
||||||
|
.pmx / .fbx -> assimp -> GLB -> 包装为 VRM 1.0
|
||||||
|
.zip -> 自动搜索包内模型,按上面三种处理
|
||||||
|
```
|
||||||
|
|
||||||
|
**humanoid 门槛(硬性)**: VRM 1.0 要求 humanoid 必需骨骼齐全。服务端判定规则:
|
||||||
|
|
||||||
|
| 情况 | 交付 | `models.usable` | 是否进入客户端目录 |
|
||||||
|
|--|--|--|--|
|
||||||
|
| humanoid 必需骨齐全 | **VRM**(`format=vrm`, `vrmVersion=1.0`) | `true` | ✅ 可发布、可选用 |
|
||||||
|
| humanoid 不齐(如 MMD 日文骨名未重绑定) | 回退交付 **GLB**, `vrmVersion=null`, `conversionNote` 注明原因 | `false` | ❌ 不进入 `catalog/export` |
|
||||||
|
|
||||||
|
即:**不达标模型仍可入库与审核,但标记为不可用、不进入已发布目录**;
|
||||||
|
待骨骼按 `skeleton-topology.md` 的标准重绑定成功后重新转换即变为可用。
|
||||||
|
|
||||||
**`.glb` / `.vrm` / `.gltf` 直接导入**(不重编码,零损失);**`.pmx` / `.fbx` 由服务端转换**:
|
**`.glb` / `.vrm` / `.gltf` 直接导入**(不重编码,零损失);**`.pmx` / `.fbx` 由服务端转换**:
|
||||||
**优先 GLB,其次 VRM**。
|
**优先 GLB,其次 VRM**。
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -44,11 +44,11 @@ UPLOAD_MAX_BYTES=536870912
|
|||||||
# ---- 可选的 Assimp(FBX/glTF 动作预处理;也用于压缩包模型的转换)----
|
# ---- 可选的 Assimp(FBX/glTF 动作预处理;也用于压缩包模型的转换)----
|
||||||
# 上传 .zip(内含 .pmx 的 MMD 模型包)时必须能调用到它,否则转换会失败
|
# 上传 .zip(内含 .pmx 的 MMD 模型包)时必须能调用到它,否则转换会失败
|
||||||
ASSIMP_BIN=assimp
|
ASSIMP_BIN=assimp
|
||||||
# 需要转换的模型(PMX / FBX)交付格式:glb(默认,两个客户端都原生加载)| vrm
|
# 模型交付格式:vrm(默认,v0.5.0 起所有上传模型一律转 VRM)| glb
|
||||||
# glb:通用,客户端直接加载
|
# vrm:在 GLB 之上补 VRMC_vrm 扩展(humanoid 骨骼 / 表情语义)
|
||||||
# vrm:在 GLB 之上补 VRMC_vrm 扩展(humanoid 骨骼 / 表情语义);
|
# glb:仅作为转换中间产物;humanoid 不达标时会回退交付 GLB,
|
||||||
# humanoid 骨骼名映射不全时会自动回退交付 GLB 并写进 conversion_note
|
# 该模型 usable=false(可入库可审核,但不进入客户端目录)
|
||||||
MODEL_CONVERT_FORMAT=glb
|
MODEL_CONVERT_FORMAT=vrm
|
||||||
# 压缩包里优先选用的 PMX 文件名(大小写不敏感);找不到时按"格式优先级 -> 目录最浅 -> 文件最大"挑
|
# 压缩包里优先选用的 PMX 文件名(大小写不敏感);找不到时按"格式优先级 -> 目录最浅 -> 文件最大"挑
|
||||||
# 值里含空格或 shell 元字符时必须用引号包起来(install.sh 会用
|
# 值里含空格或 shell 元字符时必须用引号包起来(install.sh 会用
|
||||||
# `set -a; . deploy/.env` 真的执行本文件;不加引号会把 "Miku.pmx" 当命令)
|
# `set -a; . deploy/.env` 真的执行本文件;不加引号会把 "Miku.pmx" 当命令)
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
project: opendance-web-server
|
project: opendance-web-server
|
||||||
version: 0.2.5
|
version: 0.3.0
|
||||||
repository: opendance-web
|
repository: opendance-web
|
||||||
default_branch: main
|
default_branch: main
|
||||||
contracts_version: 0.4.0
|
contracts_version: 0.4.0
|
||||||
@@ -60,7 +60,7 @@ tasks:
|
|||||||
status: done
|
status: done
|
||||||
|
|
||||||
deliverable:
|
deliverable:
|
||||||
artifact: opendance-web-v0.2.5.tar.gz
|
artifact: opendance-web-v0.3.0.tar.gz
|
||||||
packaging: Linux 业务服务(系统服务托管,双端口:软件 API + 管理端,不含 MySQL、不含反向代理、不使用 Docker)
|
packaging: Linux 业务服务(系统服务托管,双端口:软件 API + 管理端,不含 MySQL、不含反向代理、不使用 Docker)
|
||||||
includes:
|
includes:
|
||||||
- web-server/ # NestJS 源码 + 构建产物(含 BVH / VMD 内置解析、ZIP 读取与模型压缩包转换)
|
- web-server/ # NestJS 源码 + 构建产物(含 BVH / VMD 内置解析、ZIP 读取与模型压缩包转换)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# 打包发布产物:opendance-web-v0.2.5.tar.gz
|
# 打包发布产物:opendance-web-v0.3.0.tar.gz
|
||||||
#
|
#
|
||||||
# 产物结构(Linux 业务服务部署,不使用 Docker、不部署反向代理):
|
# 产物结构(Linux 业务服务部署,不使用 Docker、不部署反向代理):
|
||||||
# web-server/ NestJS 源码 + 构建产物
|
# web-server/ NestJS 源码 + 构建产物
|
||||||
@@ -21,7 +21,7 @@ set -euo pipefail
|
|||||||
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||||
cd "$REPO_ROOT"
|
cd "$REPO_ROOT"
|
||||||
|
|
||||||
VERSION="${1:-0.2.5}"
|
VERSION="${1:-0.3.0}"
|
||||||
NAME="opendance-web-v${VERSION}"
|
NAME="opendance-web-v${VERSION}"
|
||||||
OUT_DIR="$REPO_ROOT/dist-release"
|
OUT_DIR="$REPO_ROOT/dist-release"
|
||||||
STAGE="$OUT_DIR/$NAME"
|
STAGE="$OUT_DIR/$NAME"
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ node scripts/import-default-model.mjs --write-source-only --model-id 22 --dry-ru
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd web-server
|
cd web-server
|
||||||
npx vitest run # 15 个文件 / 220 项通过
|
npx vitest run # 16 个文件 / 225 项通过
|
||||||
npm run test:smoke # 冒烟 [4] 段落
|
npm run test:smoke # 冒烟 [4] 段落
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ draft ──submit──▶ pending ──approve──▶ published
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd web-server
|
cd web-server
|
||||||
npx vitest run # 15 个文件 / 220 项通过(含 admin-bone-filter 8 项、.env 预检 12 项、Assimp 13 项、缩略图贴图 6 项、MMD 材质对齐 9 项)
|
npx vitest run # 16 个文件 / 225 项通过(含 admin-bone-filter 8 项、.env 预检 12 项、Assimp 13 项、缩略图贴图 6 项、MMD 材质对齐 9 项、模型可用性 5 项)
|
||||||
npm run test:smoke
|
npm run test:smoke
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "opendance-admin",
|
"name": "opendance-admin",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.2.5",
|
"version": "0.3.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "OpenDance Studio 管理端(React + TypeScript + Vite)",
|
"description": "OpenDance Studio 管理端(React + TypeScript + Vite)",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -160,6 +160,10 @@ export interface Model extends SourceFields {
|
|||||||
name: string;
|
name: string;
|
||||||
format: ModelFormat;
|
format: ModelFormat;
|
||||||
vrmVersion: string | null;
|
vrmVersion: string | null;
|
||||||
|
/** 是否可用于客户端(= 已产出 VRM);false 的模型不进入客户端目录(v0.5.0) */
|
||||||
|
usable: boolean;
|
||||||
|
/** usable=false 的原因,例如「humanoid 不达标(0/22),未产出 VRM」 */
|
||||||
|
unusableReason: string | null;
|
||||||
isPrimary: boolean;
|
isPrimary: boolean;
|
||||||
fileUrl: string | null;
|
fileUrl: string | null;
|
||||||
fileSize: number | null;
|
fileSize: number | null;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import { NavLink, Outlet } from 'react-router-dom';
|
import { NavLink, Outlet } from 'react-router-dom';
|
||||||
|
|
||||||
|
import { APP_VERSION_LABEL } from '../lib/version';
|
||||||
|
|
||||||
interface NavItem {
|
interface NavItem {
|
||||||
to: string;
|
to: string;
|
||||||
label: string;
|
label: string;
|
||||||
@@ -44,9 +46,13 @@ export function Layout() {
|
|||||||
))}
|
))}
|
||||||
</nav>
|
</nav>
|
||||||
<div className="sidebar-foot">
|
<div className="sidebar-foot">
|
||||||
|
{/* 当前版本号:左下角固定展示,来源 web-server/package.json(与 /health 同源) */}
|
||||||
|
<span className="app-version" title="当前版本号">
|
||||||
|
{APP_VERSION_LABEL}
|
||||||
|
</span>
|
||||||
<span>API 基址</span>
|
<span>API 基址</span>
|
||||||
<code>{API_BASE === '' ? '同源(dev proxy / nginx)' : API_BASE}</code>
|
<code>{API_BASE === '' ? '同源(dev proxy / nginx)' : API_BASE}</code>
|
||||||
<span className="muted">契约 rest-api 0.1.0</span>
|
<span className="muted">契约版本见「概览」页</span>
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
<main className="content">
|
<main className="content">
|
||||||
|
|||||||
@@ -203,6 +203,17 @@ function ModelStatsView({ model, stats }: { model: Model; stats: ModelStats }) {
|
|||||||
<Metric label="骨骼最大层级" value={formatCount(stats.maxBoneDepth)} />
|
<Metric label="骨骼最大层级" value={formatCount(stats.maxBoneDepth)} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* 可用性门槛(v0.5.0):未产出 VRM 的模型不进入客户端目录 */}
|
||||||
|
{!model.usable ? (
|
||||||
|
<div className="banner banner-danger" role="alert">
|
||||||
|
<strong>不可用:该模型不会进入客户端目录</strong>
|
||||||
|
<span>{model.unusableReason ?? '未产出 VRM'}</span>
|
||||||
|
<span className="muted">
|
||||||
|
依据契约 model-formats 1.1,所有模型一律转 VRM;humanoid 必需骨齐全后重新导入即可转为可用。
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
|
||||||
{/* 可驱动性结论 */}
|
{/* 可驱动性结论 */}
|
||||||
<div className={`banner ${BANNER_CLASS[drivable.kind]}`} role={drivable.kind === 'error' ? 'alert' : 'status'}>
|
<div className={`banner ${BANNER_CLASS[drivable.kind]}`} role={drivable.kind === 'error' ? 'alert' : 'status'}>
|
||||||
<strong>
|
<strong>
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* 应用版本号(构建期由 vite.config.ts 从 web-server/package.json 注入)。
|
||||||
|
* 页面左下角必须展示它,且与 `GET /health` 的 version、发布产物文件名一致
|
||||||
|
* (开发文档 v1.5 第十一章)。SSR / 测试环境下回退为 '0.0.0'。
|
||||||
|
*/
|
||||||
|
export const APP_VERSION: string =
|
||||||
|
typeof __APP_VERSION__ === 'string' && __APP_VERSION__.length > 0 ? __APP_VERSION__ : '0.0.0';
|
||||||
|
|
||||||
|
/** 展示用:带 v 前缀 */
|
||||||
|
export const APP_VERSION_LABEL = `v${APP_VERSION}`;
|
||||||
@@ -492,6 +492,14 @@ export function ModelsPage() {
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<FormatBadge format={model.format} kind="model" />
|
<FormatBadge format={model.format} kind="model" />
|
||||||
|
{!model.usable ? (
|
||||||
|
<span
|
||||||
|
className="badge badge-rejected"
|
||||||
|
title={model.unusableReason ?? '未产出 VRM,不进入客户端目录'}
|
||||||
|
>
|
||||||
|
不可用
|
||||||
|
</span>
|
||||||
|
) : null}
|
||||||
</td>
|
</td>
|
||||||
<td className="mono">{model.vrmVersion ?? '—'}</td>
|
<td className="mono">{model.vrmVersion ?? '—'}</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -173,6 +173,14 @@ h3 {
|
|||||||
color: var(--text-mute);
|
color: var(--text-mute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.app-version {
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-strong, #e8ecf3);
|
||||||
|
letter-spacing: 0.02em;
|
||||||
|
}
|
||||||
|
|
||||||
.sidebar-foot code {
|
.sidebar-foot code {
|
||||||
color: var(--text-dim);
|
color: var(--text-dim);
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
|
|||||||
Vendored
+3
@@ -7,3 +7,6 @@ interface ImportMetaEnv {
|
|||||||
interface ImportMeta {
|
interface ImportMeta {
|
||||||
readonly env: ImportMetaEnv;
|
readonly env: ImportMetaEnv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 构建期注入的应用版本号(来自 web-server/package.json) */
|
||||||
|
declare const __APP_VERSION__: string;
|
||||||
|
|||||||
@@ -1,11 +1,26 @@
|
|||||||
|
import { readFileSync } from 'node:fs';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
import react from '@vitejs/plugin-react';
|
import react from '@vitejs/plugin-react';
|
||||||
|
|
||||||
const API_TARGET = 'http://localhost:3000';
|
const API_TARGET = 'http://localhost:3000';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 版本号唯一来源:`web-server/package.json`(与 `GET /health` 的 version 同源)。
|
||||||
|
* 构建期注入 `__APP_VERSION__`,管理端左下角直接展示,避免代码里再手写一份
|
||||||
|
* (见开发文档 v1.5 第十一章「版本号展示」)。
|
||||||
|
*/
|
||||||
|
const serverPackage = JSON.parse(
|
||||||
|
readFileSync(fileURLToPath(new URL('../package.json', import.meta.url)), 'utf8'),
|
||||||
|
) as { version?: string };
|
||||||
|
const APP_VERSION = serverPackage.version ?? '0.0.0';
|
||||||
|
|
||||||
// base './' 让产物可挂在任意子路径;开发期 /api 与 /health 代理到 NestJS 服务。
|
// base './' 让产物可挂在任意子路径;开发期 /api 与 /health 代理到 NestJS 服务。
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
base: './',
|
base: './',
|
||||||
|
define: {
|
||||||
|
__APP_VERSION__: JSON.stringify(APP_VERSION),
|
||||||
|
},
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
server: {
|
server: {
|
||||||
port: 5173,
|
port: 5173,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "opendance-web-server",
|
"name": "opendance-web-server",
|
||||||
"version": "0.2.5",
|
"version": "0.3.0",
|
||||||
"description": "OpenDance Studio Web 管理服务端(NestJS + TypeORM + 现有 MySQL 实例)",
|
"description": "OpenDance Studio Web 管理服务端(NestJS + TypeORM + 现有 MySQL 实例)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';
|
|||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { createHash } from 'node:crypto';
|
import { createHash } from 'node:crypto';
|
||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
import { PublishStatus } from '../common/enums';
|
import { ModelFormat, PublishStatus } from '../common/enums';
|
||||||
import { AppConfig } from '../config/configuration';
|
import { AppConfig } from '../config/configuration';
|
||||||
import { CharacterModel } from '../entities/model.entity';
|
import { CharacterModel } from '../entities/model.entity';
|
||||||
import { Motion } from '../entities/motion.entity';
|
import { Motion } from '../entities/motion.entity';
|
||||||
@@ -43,7 +43,11 @@ export class CatalogService {
|
|||||||
const [songs, motions, models] = await Promise.all([
|
const [songs, motions, models] = await Promise.all([
|
||||||
this.songs.find({ where: { status: PublishStatus.Published }, order: { id: 'ASC' } }),
|
this.songs.find({ where: { status: PublishStatus.Published }, order: { id: 'ASC' } }),
|
||||||
this.motions.find({ where: { status: PublishStatus.Published }, order: { id: 'ASC' } }),
|
this.motions.find({ where: { status: PublishStatus.Published }, order: { id: 'ASC' } }),
|
||||||
this.models.find({ where: { status: PublishStatus.Published }, order: { id: 'ASC' } }),
|
// v0.5.0:只交付**已产出 VRM** 的模型(usable),未产出 VRM 的不进入客户端目录
|
||||||
|
this.models.find({
|
||||||
|
where: { status: PublishStatus.Published, format: ModelFormat.Vrm },
|
||||||
|
order: { id: 'ASC' },
|
||||||
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const [songDtos, motionDtos, modelDtos, defaultModelId] = await Promise.all([
|
const [songDtos, motionDtos, modelDtos, defaultModelId] = await Promise.all([
|
||||||
@@ -71,7 +75,11 @@ export class CatalogService {
|
|||||||
const [songs, motions, models] = await Promise.all([
|
const [songs, motions, models] = await Promise.all([
|
||||||
this.songs.find({ where: { status: PublishStatus.Published }, order: { id: 'ASC' } }),
|
this.songs.find({ where: { status: PublishStatus.Published }, order: { id: 'ASC' } }),
|
||||||
this.motions.find({ where: { status: PublishStatus.Published }, order: { id: 'ASC' } }),
|
this.motions.find({ where: { status: PublishStatus.Published }, order: { id: 'ASC' } }),
|
||||||
this.models.find({ where: { status: PublishStatus.Published }, order: { id: 'ASC' } }),
|
// v0.5.0:只交付**已产出 VRM** 的模型(usable),未产出 VRM 的不进入客户端目录
|
||||||
|
this.models.find({
|
||||||
|
where: { status: PublishStatus.Published, format: ModelFormat.Vrm },
|
||||||
|
order: { id: 'ASC' },
|
||||||
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const fingerprint = JSON.stringify({
|
const fingerprint = JSON.stringify({
|
||||||
|
|||||||
@@ -88,7 +88,9 @@ export class AppConfig {
|
|||||||
* 设为 `vrm` 时会在 GLB 之上补 `VRMC_vrm` 扩展,humanoid 骨骼不全则回退 GLB。
|
* 设为 `vrm` 时会在 GLB 之上补 `VRMC_vrm` 扩展,humanoid 骨骼不全则回退 GLB。
|
||||||
*/
|
*/
|
||||||
get modelConvertFormat(): 'glb' | 'vrm' {
|
get modelConvertFormat(): 'glb' | 'vrm' {
|
||||||
return (this.config.get<string>('modelConvertFormat') ?? 'glb') === 'vrm' ? 'vrm' : 'glb';
|
// v0.5.0 起默认 **vrm**:所有上传模型一律转 VRM(见 contracts/model-formats.md 1.1);
|
||||||
|
// humanoid 不达标时管线自动回退交付 GLB 并置 usable=false。
|
||||||
|
return (this.config.get<string>('modelConvertFormat') ?? 'vrm') === 'glb' ? 'glb' : 'vrm';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -207,7 +209,7 @@ export const configuration = () => {
|
|||||||
adminDir: process.env.ADMIN_DIR ?? resolve(process.cwd(), '..', 'admin'),
|
adminDir: process.env.ADMIN_DIR ?? resolve(process.cwd(), '..', 'admin'),
|
||||||
uploadMaxBytes: Number(process.env.UPLOAD_MAX_BYTES ?? 512 * 1024 * 1024),
|
uploadMaxBytes: Number(process.env.UPLOAD_MAX_BYTES ?? 512 * 1024 * 1024),
|
||||||
assimpBin: process.env.ASSIMP_BIN ?? 'assimp',
|
assimpBin: process.env.ASSIMP_BIN ?? 'assimp',
|
||||||
modelConvertFormat: process.env.MODEL_CONVERT_FORMAT ?? 'glb',
|
modelConvertFormat: process.env.MODEL_CONVERT_FORMAT ?? 'vrm',
|
||||||
modelShading: process.env.MODEL_SHADING ?? 'pbr',
|
modelShading: process.env.MODEL_SHADING ?? 'pbr',
|
||||||
modelConvertPmx: process.env.MODEL_CONVERT_PMX ?? 'Hatsune Miku.pmx',
|
modelConvertPmx: process.env.MODEL_CONVERT_PMX ?? 'Hatsune Miku.pmx',
|
||||||
modelConvertTimeoutMs: Number(process.env.MODEL_CONVERT_TIMEOUT_MS ?? 180_000),
|
modelConvertTimeoutMs: Number(process.env.MODEL_CONVERT_TIMEOUT_MS ?? 180_000),
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import { join } from 'node:path';
|
|||||||
export const CONTRACT_VERSIONS: Readonly<Record<string, string>> = Object.freeze({
|
export const CONTRACT_VERSIONS: Readonly<Record<string, string>> = Object.freeze({
|
||||||
'rest-api': '0.4.0',
|
'rest-api': '0.4.0',
|
||||||
'websocket-keypoints': '0.1.0',
|
'websocket-keypoints': '0.1.0',
|
||||||
'data-models': '0.4.0',
|
'data-models': '0.5.0',
|
||||||
'skeleton-topology': '0.1.0',
|
'skeleton-topology': '0.1.0',
|
||||||
'model-formats': '0.4.0',
|
'model-formats': '0.5.0',
|
||||||
database: '0.3.0',
|
database: '0.3.0',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { ModelFormat, PublishStatus, SourceType } from '../common/enums';
|
import { ModelFormat, PublishStatus, SourceType } from '../common/enums';
|
||||||
|
import type { ModelStats } from './model-inspector';
|
||||||
import { CharacterModel } from '../entities/model.entity';
|
import { CharacterModel } from '../entities/model.entity';
|
||||||
|
|
||||||
/** 契约 data-models.md §4 的对外表示 */
|
/** 契约 data-models.md §4 的对外表示 */
|
||||||
@@ -7,6 +8,13 @@ export interface ModelDto {
|
|||||||
name: string;
|
name: string;
|
||||||
format: ModelFormat;
|
format: ModelFormat;
|
||||||
vrmVersion: string | null;
|
vrmVersion: string | null;
|
||||||
|
/**
|
||||||
|
* 是否可被客户端使用(v0.5.0):等价于"已产出 VRM"。
|
||||||
|
* `false` 的模型**不进入 `catalog/export`**,但仍可入库与审核。
|
||||||
|
*/
|
||||||
|
usable: boolean;
|
||||||
|
/** `usable=false` 时的原因(中文,供审核面板直接展示) */
|
||||||
|
unusableReason: string | null;
|
||||||
isPrimary: boolean;
|
isPrimary: boolean;
|
||||||
fileUrl: string | null;
|
fileUrl: string | null;
|
||||||
fileSize: number | null;
|
fileSize: number | null;
|
||||||
@@ -37,12 +45,35 @@ export interface ModelUrlLookup {
|
|||||||
sourceSha256?: string | null;
|
sourceSha256?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型是否可用于客户端(v0.5.0 门槛):**必须已产出 VRM**。
|
||||||
|
*
|
||||||
|
* 依据 `contracts/model-formats.md` 1.1:所有上传模型一律转 VRM;
|
||||||
|
* humanoid 不达标时管线回退交付 GLB,此时模型可入库、可审核,但**不可用**、
|
||||||
|
* 不进入 `catalog/export` —— 待按 skeleton-topology 标准重绑定骨骼后重新转换即转为可用。
|
||||||
|
*/
|
||||||
|
export function isUsableModel(model: CharacterModel): boolean {
|
||||||
|
return model.format === ModelFormat.Vrm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 不可用的原因(可用时返回 null);从 stats 取 humanoid 覆盖度,便于人工定位 */
|
||||||
|
export function unusableReason(model: CharacterModel): string | null {
|
||||||
|
if (isUsableModel(model)) return null;
|
||||||
|
const stats = (model.stats ?? null) as Partial<ModelStats> | null;
|
||||||
|
if (stats && typeof stats.humanoidMapped === 'number' && typeof stats.humanoidTotal === 'number') {
|
||||||
|
return `humanoid 不达标(${stats.humanoidMapped}/${stats.humanoidTotal}),未产出 VRM`;
|
||||||
|
}
|
||||||
|
return '未产出 VRM(格式为 GLB),不可用于客户端';
|
||||||
|
}
|
||||||
|
|
||||||
export function toModelDto(model: CharacterModel, urls: ModelUrlLookup): ModelDto {
|
export function toModelDto(model: CharacterModel, urls: ModelUrlLookup): ModelDto {
|
||||||
return {
|
return {
|
||||||
id: model.id,
|
id: model.id,
|
||||||
name: model.name,
|
name: model.name,
|
||||||
format: model.format,
|
format: model.format,
|
||||||
vrmVersion: model.vrmVersion,
|
vrmVersion: model.vrmVersion,
|
||||||
|
usable: isUsableModel(model),
|
||||||
|
unusableReason: unusableReason(model),
|
||||||
isPrimary: model.isPrimary,
|
isPrimary: model.isPrimary,
|
||||||
fileUrl: urls.fileUrl,
|
fileUrl: urls.fileUrl,
|
||||||
fileSize: urls.fileSize ?? null,
|
fileSize: urls.fileSize ?? null,
|
||||||
|
|||||||
@@ -451,8 +451,9 @@ export class ModelsService {
|
|||||||
* 4. id 最小的已发布模型
|
* 4. id 最小的已发布模型
|
||||||
*/
|
*/
|
||||||
async resolveDefaultModelId(): Promise<number | null> {
|
async resolveDefaultModelId(): Promise<number | null> {
|
||||||
|
// v0.5.0:默认模型必须来自**可用**模型(已产出 VRM);未产出 VRM 的不进客户端目录
|
||||||
const published = await this.models.find({
|
const published = await this.models.find({
|
||||||
where: { status: PublishStatus.Published },
|
where: { status: PublishStatus.Published, format: ModelFormat.Vrm },
|
||||||
order: { id: 'ASC' },
|
order: { id: 'ASC' },
|
||||||
});
|
});
|
||||||
if (published.length === 0) return null;
|
if (published.length === 0) return null;
|
||||||
|
|||||||
@@ -0,0 +1,110 @@
|
|||||||
|
import { describe, expect, it, vi } from 'vitest';
|
||||||
|
|
||||||
|
import { CatalogService } from '../src/catalog/catalog.service';
|
||||||
|
import { ModelFormat, PublishStatus, SourceType } from '../src/common/enums';
|
||||||
|
import type { CharacterModel } from '../src/entities/model.entity';
|
||||||
|
import { isUsableModel, toModelDto, unusableReason } from '../src/models/model.serializer';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* v0.5.0「模型一律转 VRM」的可用性门槛。
|
||||||
|
*
|
||||||
|
* 规则(contracts/model-formats.md 1.1):所有上传模型都转 VRM;
|
||||||
|
* humanoid 不达标时回退交付 GLB —— 这种模型**可入库、可审核,但不可用**,
|
||||||
|
* **不进入 `catalog/export`**(用户明确选择"入库但标记不可用,不进已发布目录")。
|
||||||
|
*/
|
||||||
|
|
||||||
|
function model(overrides: Partial<CharacterModel> = {}): CharacterModel {
|
||||||
|
return {
|
||||||
|
id: 1,
|
||||||
|
name: 'model',
|
||||||
|
format: ModelFormat.Vrm,
|
||||||
|
vrmVersion: '1.0',
|
||||||
|
isPrimary: false,
|
||||||
|
fileAssetId: 1,
|
||||||
|
sourceAssetId: null,
|
||||||
|
thumbnailAssetId: null,
|
||||||
|
conversionNote: null,
|
||||||
|
stats: null,
|
||||||
|
sourceType: SourceType.Other,
|
||||||
|
sourceName: 'x',
|
||||||
|
sourceUrl: 'x',
|
||||||
|
license: 'x',
|
||||||
|
author: 'x',
|
||||||
|
status: PublishStatus.Published,
|
||||||
|
createdAt: new Date('2026-01-01T00:00:00Z'),
|
||||||
|
updatedAt: new Date('2026-01-01T00:00:00Z'),
|
||||||
|
...overrides,
|
||||||
|
} as CharacterModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('模型可用性(usable)', () => {
|
||||||
|
it('VRM → 可用,且没有不可用原因', () => {
|
||||||
|
const vrm = model({ format: ModelFormat.Vrm });
|
||||||
|
expect(isUsableModel(vrm)).toBe(true);
|
||||||
|
expect(unusableReason(vrm)).toBeNull();
|
||||||
|
expect(toModelDto(vrm, { fileUrl: '/f', thumbnailUrl: null }).usable).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('GLB(humanoid 不达标)→ 不可用,原因带 humanoid 覆盖度', () => {
|
||||||
|
const glb = model({
|
||||||
|
format: ModelFormat.Glb,
|
||||||
|
vrmVersion: null,
|
||||||
|
stats: { humanoidMapped: 0, humanoidTotal: 22 } as Record<string, unknown>,
|
||||||
|
});
|
||||||
|
expect(isUsableModel(glb)).toBe(false);
|
||||||
|
expect(unusableReason(glb)).toBe('humanoid 不达标(0/22),未产出 VRM');
|
||||||
|
const dto = toModelDto(glb, { fileUrl: '/f', thumbnailUrl: null });
|
||||||
|
expect(dto.usable).toBe(false);
|
||||||
|
expect(dto.unusableReason).toContain('0/22');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('GLB 且没有 stats → 给出通用原因(不抛错)', () => {
|
||||||
|
const glb = model({ format: ModelFormat.Glb, vrmVersion: null, stats: null });
|
||||||
|
expect(unusableReason(glb)).toContain('未产出 VRM');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('目录导出只含可用模型', () => {
|
||||||
|
function buildService(captured: { modelsWhere?: unknown }): CatalogService {
|
||||||
|
const songs = { find: vi.fn().mockResolvedValue([]) };
|
||||||
|
const motions = { find: vi.fn().mockResolvedValue([]) };
|
||||||
|
const models = {
|
||||||
|
find: vi.fn().mockImplementation((options: { where: unknown }) => {
|
||||||
|
captured.modelsWhere = options.where;
|
||||||
|
return Promise.resolve([model({ id: 7, format: ModelFormat.Vrm })]);
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
const songsService = { toDtos: vi.fn().mockResolvedValue([]) };
|
||||||
|
const motionsService = { toDtos: vi.fn().mockResolvedValue([]) };
|
||||||
|
const modelsService = {
|
||||||
|
toDtos: vi.fn().mockImplementation((rows: CharacterModel[]) =>
|
||||||
|
rows.map((row) => toModelDto(row, { fileUrl: '/f', thumbnailUrl: null })),
|
||||||
|
),
|
||||||
|
resolveDefaultModelId: vi.fn().mockResolvedValue(7),
|
||||||
|
};
|
||||||
|
const config = { contractVersions: { 'rest-api': '0.5.0' } };
|
||||||
|
return new CatalogService(
|
||||||
|
songs as never,
|
||||||
|
motions as never,
|
||||||
|
models as never,
|
||||||
|
songsService as never,
|
||||||
|
motionsService as never,
|
||||||
|
modelsService as never,
|
||||||
|
config as never,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
it('查询条件限定 status=published 且 format=vrm', async () => {
|
||||||
|
const captured: { modelsWhere?: unknown } = {};
|
||||||
|
const bundle = await buildService(captured).exportBundle();
|
||||||
|
expect(captured.modelsWhere).toEqual({ status: PublishStatus.Published, format: ModelFormat.Vrm });
|
||||||
|
expect(bundle.models.map((m) => m.id)).toEqual([7]);
|
||||||
|
expect(bundle.models.every((m) => m.usable)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('目录指纹同样只统计可用模型(否则客户端会因"不可见变化"反复刷新)', async () => {
|
||||||
|
const captured: { modelsWhere?: unknown } = {};
|
||||||
|
await buildService(captured).version();
|
||||||
|
expect(captured.modelsWhere).toEqual({ status: PublishStatus.Published, format: ModelFormat.Vrm });
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user