@@ -1,4 +1,4 @@
import { CADFiler , CADObject , Database , DuplicateRecordCloning , Factory , LayerNode , ObjectId , PhysicalMaterialRecord , TextureTableRecord } from "webcad_ue4_api" ;
import { CADFactory , CADFiler, CADObject , Database , DuplicateRecordCloning , Factory , LayerNode , ObjectId , PhysicalMaterialRecord , TextureTableRecord } from "webcad_ue4_api" ;
// TODO: Danger: 注意入侵性代码
// TODO: Danger: 注意入侵性代码
// 疑似是WebCAD中的漏洞, 当传入new Database()时,
// 疑似是WebCAD中的漏洞, 当传入new Database()时,
@@ -14,26 +14,22 @@ Database.prototype.AllocationObjectId = function (this: Database, object: CADObj
this . idMap . set ( object . Id . Index , object . Id ) ;
this . idMap . set ( object . Id . Index , object . Id ) ;
}
}
export function MaterialOut ( material : PhysicalMaterialRecord ) : string
export function MaterialOut ( material : PhysicalMaterialRecord ) : string {
{
let db = new Database ( ) ;
try {
db . WblockCloneObejcts (
let db = new Database ( ) ;
[ material ] ,
db . WblockCloneObejcts (
db . MaterialTable ,
[ material ] ,
new Map ( ) ,
db . MaterialTable ,
DuplicateRecordCloning . Ignore
new Map ( ) ,
) ;
DuplicateRecordCloning . Ignore
let json = JSON . stringify ( db . FileWrite ( ) . Data ) ;
) ;
// // TODO: Danger: 因为WebCAD依赖库中的部分类的构造函数名异常, 所以在生成JSON时需要对类名进行替换
let json = JSON . stringify ( db . FileWrite ( ) . Data ) ;
json = json . replace ( LayerNode . name , "LayerNode" )
// // TODO: Danger: 因为WebCAD依赖库中的部分类的构造函数名异常, 所以在生成JSON时需要对类名进行替换
. replace ( TextureTableRecord . name , "TextureTableRecord" )
json = json . replace ( LayerNode . name , "LayerNode ")
. replace ( PhysicalMaterialRecord . name , "PhysicalMaterialRecord ") ;
. replace ( TextureTableRec ord . name , "TextureTableRecord" )
console . debug ( "DEBUG CAD Object Name" , CADFact ory [ 'factory' ] . objectNameMap ) ;
. replace ( PhysicalMaterialRecord . name , " PhysicalMaterialRecord" ) ;
console . debug ( "CURRENT PROTOTYPE NAME\n" , "LAYERNODE:" , LayerNode . name , "TEXTURETABLERECORD:" , TextureTableRecord . name , "PHYSICALMATERIALRECORD:" , PhysicalMaterialRecord. name ) ;
return json ;
return json ;
} catch ( error ) {
console . error ( "error in MaterialOut:" , error , material ) ;
throw error ;
}
}
}
export function MaterialIn ( fileData : Object [ ] ) : PhysicalMaterialRecord
export function MaterialIn ( fileData : Object [ ] ) : PhysicalMaterialRecord