修复材质序列化后类名出现错误的问题

This commit is contained in:
陈梓阳 2025-06-03 11:53:07 +08:00
parent 59703decc4
commit 990dfa2944
2 changed files with 8 additions and 3 deletions

View File

@ -1,7 +1,7 @@
{
"name": "material-editor",
"private": true,
"version": "1.0.15",
"version": "1.0.16",
"type": "module",
"scripts": {
"dev": "vite",

View File

@ -1,4 +1,4 @@
import { CADFiler, CADObject, Database, DuplicateRecordCloning, Factory, LayerNode, ObjectId, PhysicalMaterialRecord } from "webcad_ue4_api";
import { CADFiler, CADObject, Database, DuplicateRecordCloning, Factory, LayerNode, ObjectId, PhysicalMaterialRecord, TextureTableRecord } from "webcad_ue4_api";
// TODO: Danger: 注意入侵性代码
// 疑似是WebCAD中的漏洞当传入new Database()时,
@ -23,7 +23,12 @@ export function MaterialOut(material: PhysicalMaterialRecord): string
new Map(),
DuplicateRecordCloning.Ignore
);
return JSON.stringify(db.FileWrite().Data);
let json = JSON.stringify(db.FileWrite().Data);
// // TODO: Danger: 因为WebCAD依赖库中的部分类的构造函数名异常所以在生成JSON时需要对类名进行替换
json = json.replace(LayerNode.name, "LayerNode")
.replace(TextureTableRecord.name, "TextureTableRecord")
.replace(PhysicalMaterialRecord.name, "PhysicalMaterialRecord");
return json;
}
export function MaterialIn(fileData: Object[]): PhysicalMaterialRecord