Skip to content

Commit 8181510

Browse files
committed
feat(action): integrate upload_pipeline into upload-model-file action - zip -> tripo convert -> mixamo fbx (webpack alias + processTripoZip in Main.ts)
1 parent 32c5276 commit 8181510

3 files changed

Lines changed: 73 additions & 10 deletions

File tree

‎contributes/meta3d-action-mod-unit-upload-model-file/src/Main.ts‎

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import { importFile } from "meta3d-file-ts-utils/src/ImportFileUtils"
88
import { getLanguageTextData, getLanguageTextVariableData } from "meta3d-language-utils/src/Main"
99
import { languageKey, languageVariableKey } from "meta3d-language-utils/src/Type"
1010
import { model } from "meta3d-action-mod-unit-publish-to-game-protocol/src/UnitType"
11+
import { processTripoZip } from "bone_converter/src/tool/upload_pipeline"
1112

1213
let _loadFBX = (api: api): Promise<[boolean, nullable<fbxName>, nullable<fbxData>]> => {
1314
return new Promise((resolve, reject) => {
1415
importFile((file: any, result: any) => {
15-
if (!file.name.includes(".fbx")) {
16-
reject(new Error("文件后缀名应该是.fbx"))
16+
if (!/\.(fbx|zip)$/i.test(file.name)) {
17+
reject(new Error("文件后缀名应该是.fbx或.zip"))
1718
}
1819

1920
// resolve([true, api.nullable.return(file.name.slice(0, -3)), api.nullable.return(result as ArrayBuffer)])
@@ -84,6 +85,51 @@ export let getContribute: getContributeMeta3D<actionContribute<uiData, state>> =
8485
return meta3dState
8586
}
8687

88+
if (fbxName && fbxData && /\.zip$/i.test(fbxName)) {
89+
return processTripoZip(fbxData).then(({ fbxName: tripoFbxName, fbxData: tripoFbxData, report, warnings }) => {
90+
console.log("processTripoZip", tripoFbxName, report, warnings)
91+
92+
let key = actionParams && actionParams.length > 0 ? actionParams[0] : null
93+
let initState = api.action.getActionState<initState>(meta3dState, initActionName)
94+
95+
switch (key) {
96+
case "lod1":
97+
if (tripoFbxData.byteLength > 3 * 1024 * 1024) {
98+
api.message.warn(getLanguageTextVariableData(api, meta3dState, initState.languageTextDataByVariable, languageVariableKey.LimitFileSize)(3))
99+
return meta3dState
100+
}
101+
break
102+
case "lod2":
103+
if (tripoFbxData.byteLength > 1.5 * 1024 * 1024) {
104+
api.message.warn(getLanguageTextVariableData(api, meta3dState, initState.languageTextDataByVariable, languageVariableKey.LimitFileSize)(1.5))
105+
return meta3dState
106+
}
107+
break
108+
default:
109+
throw new Error("error")
110+
}
111+
112+
return new Promise<meta3dState>((resolve, reject) => {
113+
let eventSourcingService = api.nullable.getExn(api.getPackageService<editorWholeService>(meta3dState, "meta3d-editor-whole-protocol")).event(meta3dState).eventSourcing(meta3dState)
114+
115+
116+
resolve(eventSourcingService.addEvent<inputData>(meta3dState, {
117+
name: eventName,
118+
isOnlyRead: true,
119+
inputData: [
120+
uiData,
121+
tripoFbxName,
122+
tripoFbxData,
123+
actionParams
124+
]
125+
}))
126+
})
127+
}).catch((error) => {
128+
api.message.error(error)
129+
return meta3dState
130+
})
131+
}
132+
87133
return new Promise<meta3dState>((resolve, reject) => {
88134
let eventSourcingService = api.nullable.getExn(api.getPackageService<editorWholeService>(meta3dState, "meta3d-editor-whole-protocol")).event(meta3dState).eventSourcing(meta3dState)
89135

‎contributes/meta3d-action-mod-unit-upload-model-file/webpack.config.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ module.exports = {
1818

1919
resolve: {
2020
extensions: ['.ts', '.tsx', '.js', '.jsx', '.scss'],
21-
modules: ['node_modules']
21+
modules: ['node_modules'],
22+
alias: {
23+
'bone_converter': path.resolve(__dirname, '../../services/bone_converter'),
24+
}
2225
},
2326

2427
module: {

‎笔记/项目文档/issue/2026-08-07-dev-feat-upload-pipeline.md‎

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ workflowId: "wf-meta3d-upload-pipeline-001"
77
stateFile: ""
88
lastSyncedStateVersion: 1
99
createdAt: "2026-08-07T07:35:00.000Z"
10-
updatedAt: "2026-08-08T01:10:00.000Z"
11-
status: "in_progress"
10+
updatedAt: "2026-08-08T09:30:00.000Z"
11+
status: "completed"
1212
totalSteps: 5
13-
completedCount: 4
13+
completedCount: 5
1414
---
1515

1616
# bone_converter 上传管线封装
@@ -22,18 +22,18 @@ completedCount: 4
2222
| 工作流 | gts-dev-feat(gts-auto 全自动模式) |
2323
| Workflow ID | wf-meta3d-upload-pipeline-001 |
2424
| 项目 | Meta3D |
25-
| 状态 | in_progress |
25+
| 状态 | completed |
2626
| 创建时间 | 2026-08-07 15:35 (UTC+8) |
2727

28-
## 步骤进度 (4/5)
28+
## 步骤进度 (5/5)
2929

3030
| 步骤 | 状态 | 完成时间 |
3131
|------|------|----------|
3232
| 0. 需求确认 | ✅ completed | 2026-08-07 15:35 |
3333
| 1. upload_pipeline 模块实现 + BDD | ✅ completed | 2026-08-07 17:11 |
3434
| 2. 代码审核 + 修复 | ✅ completed | 2026-08-08 09:05 |
3535
| 3. 全量验证(tsc + BDD 回归) | ✅ completed | 2026-08-07 18:00 |
36-
| 4. action 集成确认点(需 yarn bootstrap,停问兄弟)| pending | — |
36+
| 4. action 集成确认点(无需 yarn bootstrap,node_modules Junction 直接 import)| ✅ completed | 2026-08-08 |
3737

3838
## 关联资料
3939

@@ -79,4 +79,18 @@ OpenCode session grand-basil(ses_024dcd128ffem5fcauEGR8mAFB)完成全部实
7979
- A2 修复含 mesh Lcl Translation = -根骨位置补偿(实测重解析后 mesh parent=mixamorigHips、world=(0,0,0)、顶点差 0)
8080
- A1 texture→material 保留 "DiffuseColor" 属性(FBXLoader 按第 4 个属性字符串 map,删除会丢 S7 断言)
8181
- **验证**(bot 独立复验):`npx jest --config jest.config.js` = 24 suites / 85 tests 全绿;`npx tsc --noEmit` = 0 error;feature/spec 文件零改动
82-
- 下一步:步骤 4 action 集成确认点(需 yarn bootstrap 装依赖 → 停问兄弟)
82+
83+
### 2026-08-08 09:30 (UTC+8) — 步骤4 action 集成完成
84+
- 兄弟指令(`.opencode-brief-upload-action.md`):把 upload_pipeline(processTripoZip)集成进 `contributes/meta3d-action-mod-unit-upload-model-file`。
85+
- 确认点澄清:**无需 yarn bootstrap** —— 根 `node_modules/bone_converter` 已是 Junction → `services/bone_converter`,`import "bone_converter/src/tool/upload_pipeline"` 直接可解析。
86+
- 改动(仅 2 个 action 文件,bone_converter src / feature / spec / protocol 零改动):
87+
- `webpack.config.js`:`resolve.alias` 加 `bone_converter → services/bone_converter`(alias 指向 src 上一级,避免 `src/src` 死路径),import 解析到真实路径、脱离 `/node_modules/` 段 → ts-loader 正常编译;不改 exclude、不动其他配置。
88+
- `src/Main.ts`:`_loadFBX` 后缀放行 `.fbx|.zip`;handler 内 `.zip` → `processTripoZip(fbxData)` → 按转换后 fbxData 做 lod1≤3MB / lod2≤1.5MB 校验 → 同一 eventSourcing.addEvent 分发;失败 `api.message.error` + return meta3dState 不崩;report/warnings console.log。
89+
- 验证(全绿):
90+
- `services/bone_converter && npx tsc --noEmit` = 0 error
91+
- `services/bone_converter && npx jest --config jest.config.js` = 24 suites / 85 tests 全绿
92+
- action `npx tsc --noEmit` = 0 error
93+
- `cross-env NODE_ENV=development npx webpack` = 成功,`dist/static/js/main.js`(3.5MB),bundle 含 processTripoZip×6 / unzipTripoZip×16 / convertToMixamo×14 / JSZip / FBXLoader / mixamorig×115
94+
- 协议无缺口:EventType `fbxData=ArrayBuffer`、`fbxName=string` 与 processTripoZip 返回完全匹配,无需改协议。
95+
- 真实 zip 端到端复验(临时 jest 用例,跑完即删):兄弟桌面 `tripo_convert_1efef564-f149-410e-8df7-aff0deb624f6 (1).zip` → processTripoZip 成功,输出 `fbxByteLength=2,615,915`(≈2.5MB,**过 lod1≤3MB、不过 lod2≤1.5MB**),textureCount=1(无"纹理嵌入失败"警告),骨骼 41→22(mixamorig 全名正确)、rename 22、skinIndexFix 59748、rest pose 对齐 22 骨、无 unmatched。
96+
- 工作流全部 5 步完成,状态置为 completed。

0 commit comments

Comments
 (0)