diff --git a/package.json b/package.json index a40d75e..63ea726 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ "dependencies": { "@jscad/modeling": "^2.11.0", "csstype": "^3.1.3", - "fflate": "^0.8.2", "flatbush": "^3.3.0", "js-angusj-clipper": "^1.2.1", "pako": "^1.0.11", @@ -37,11 +36,12 @@ "polylabel": "^1.1.0", "three": "npm:three-cf@^0.122.9", "vue": "^3.5.13", - "webcad_ue4_api": "http://gitea.cf/cx/webcad-ue4-api/archive/3.20.0.tar.gz", + "webcad_ue4_api": "http://gitea.cf/cx/webcad-ue4-api/archive/3.26.0.tar.gz", "xaop": "^2.0.0" }, "devDependencies": { "@types/node": "^22.14.1", + "@types/pako": "1.0.3", "@vitejs/plugin-vue": "^5.2.3", "@vue/tsconfig": "^0.7.0", "sass-embedded": "^1.87.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 58dd3e7..00ea9b1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,9 +14,6 @@ importers: csstype: specifier: ^3.1.3 version: 3.1.3 - fflate: - specifier: ^0.8.2 - version: 0.8.2 flatbush: specifier: ^3.3.0 version: 3.3.1 @@ -39,8 +36,8 @@ importers: specifier: ^3.5.13 version: 3.5.13(typescript@5.7.3) webcad_ue4_api: - specifier: http://gitea.cf/cx/webcad-ue4-api/archive/3.20.0.tar.gz - version: http://gitea.cf/cx/webcad-ue4-api/archive/3.20.0.tar.gz + specifier: http://gitea.cf/cx/webcad-ue4-api/archive/3.26.0.tar.gz + version: http://gitea.cf/cx/webcad-ue4-api/archive/3.26.0.tar.gz xaop: specifier: ^2.0.0 version: 2.1.0 @@ -48,6 +45,9 @@ importers: '@types/node': specifier: ^22.14.1 version: 22.14.1 + '@types/pako': + specifier: 1.0.3 + version: 1.0.3 '@vitejs/plugin-vue': specifier: ^5.2.3 version: 5.2.3(vite@6.2.6(@types/node@22.14.1)(sass-embedded@1.87.0))(vue@3.5.13(typescript@5.7.3)) @@ -412,6 +412,9 @@ packages: '@types/node@22.14.1': resolution: {integrity: sha512-u0HuPQwe/dHrItgHHpmw3N2fYCR6x4ivMNbPHRkBVP4CvN+kiRrKHWk3i8tXiO/joPwXLMYvF9TTF0eqgHIuOw==} + '@types/pako@1.0.3': + resolution: {integrity: sha512-EDxOsHAD5dqjbjEUM1xwa7rpKPFb8ECBE5irONTQU7/OsO3thI5YrNEWSPNMvYmvFM0l/OLQJ6Mgw7PEdXSjhg==} + '@vitejs/plugin-vue@5.2.3': resolution: {integrity: sha512-IYSLEQj4LgZZuoVpdSUCw3dIynTWQgPlaRP6iAvMle4My0HdYwr5g5wQAfwOeHQBmYwEkqF70nRpSilr6PoUDg==} engines: {node: ^18.0.0 || >=20.0.0} @@ -599,9 +602,6 @@ packages: fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} - fflate@0.8.2: - resolution: {integrity: sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==} - flatbush@3.3.1: resolution: {integrity: sha512-oKuPbtT+DS2CxH+9Vhbsq8HifmSCuOw+3Cy5zt/vCIrZl5KyengoTHDBLmtpZoBhcwa7/biNjgL1DwdLMJYm1A==} @@ -1051,9 +1051,9 @@ packages: typescript: optional: true - webcad_ue4_api@http://gitea.cf/cx/webcad-ue4-api/archive/3.20.0.tar.gz: - resolution: {tarball: http://gitea.cf/cx/webcad-ue4-api/archive/3.20.0.tar.gz} - version: 0.3.19 + webcad_ue4_api@http://gitea.cf/cx/webcad-ue4-api/archive/3.26.0.tar.gz: + resolution: {tarball: http://gitea.cf/cx/webcad-ue4-api/archive/3.26.0.tar.gz} + version: 0.3.20 xaop@2.1.0: resolution: {integrity: sha512-/ovWCaQIet3a3VnoVeN1/pNPqCrS/JifF28N7crPhq8BXEWx4Da2o+LYCCxnTWGAjGp5+2W2hd0HIpVESounSQ==} @@ -1302,6 +1302,8 @@ snapshots: dependencies: undici-types: 6.21.0 + '@types/pako@1.0.3': {} + '@vitejs/plugin-vue@5.2.3(vite@6.2.6(@types/node@22.14.1)(sass-embedded@1.87.0))(vue@3.5.13(typescript@5.7.3))': dependencies: vite: 6.2.6(@types/node@22.14.1)(sass-embedded@1.87.0) @@ -1532,8 +1534,6 @@ snapshots: fast-deep-equal@3.1.3: {} - fflate@0.8.2: {} - flatbush@3.3.1: dependencies: flatqueue: 1.2.1 @@ -1906,7 +1906,7 @@ snapshots: optionalDependencies: typescript: 5.7.3 - webcad_ue4_api@http://gitea.cf/cx/webcad-ue4-api/archive/3.20.0.tar.gz: {} + webcad_ue4_api@http://gitea.cf/cx/webcad-ue4-api/archive/3.26.0.tar.gz: {} xaop@2.1.0: {} diff --git a/src/common/MaterialSerializer.ts b/src/common/MaterialSerializer.ts index 400cb38..9837284 100644 --- a/src/common/MaterialSerializer.ts +++ b/src/common/MaterialSerializer.ts @@ -1,4 +1,4 @@ -import { CADFactory, CADFiler, CADObject, Database, DuplicateRecordCloning, Factory, LayerNode, ObjectId, PhysicalMaterialRecord } from "webcad_ue4_api"; +import { CADFiler, CADObject, Database, DuplicateRecordCloning, Factory, LayerNode, ObjectId, PhysicalMaterialRecord } from "webcad_ue4_api"; // TODO: Danger: 注意入侵性代码 // 疑似是WebCAD中的漏洞,当传入new Database()时, diff --git a/src/components/MaterialAdjuster.vue b/src/components/MaterialAdjuster.vue index 55782d1..58477b7 100644 --- a/src/components/MaterialAdjuster.vue +++ b/src/components/MaterialAdjuster.vue @@ -6,12 +6,15 @@ DEBUG + + + - + @@ -111,8 +114,8 @@ import { storeToRefs } from "pinia"; import CfFlex from "./CfFlex.vue"; import { DirectoryId } from "../api/Request"; import { IsNullOrWhitespace } from "../helpers/helper.string"; -import { DeflateAsync } from "../helpers/helper.compression"; -import { ToDeflatedBase64 } from "../helpers/helper.material"; +import { FromDeflateBase64, ToDeflatedBase64 } from "../helpers/helper.material"; +import { MaterialIn } from "../common/MaterialSerializer"; export interface MaterialRequest { /** 材质名 */ @@ -133,7 +136,7 @@ const emits = defineEmits<{ (e: 'submit', data: MaterialRequest): void; }>(); -const debugMode = ref(false); +const debugMode = ref(true); const { CurrGeometry, Geometries, Material } = storeToRefs(scene); const enableTexture = ref(Material.value.useMap); const _textureSrc = ref(props.textureSrc); @@ -155,7 +158,8 @@ const model = reactive({ }); const materialInfo = reactive({ dirId: DirectoryId.MaterialDir, // 正常来说是2 - materialName: '材质1' + materialName: '材质1', + inputText:'', }); onMounted(() => { @@ -220,6 +224,14 @@ async function EnableTexture(enable: boolean) { await scene.UpdateMaterialAsync(); } +async function loadData() { + if(!materialInfo.inputText) return; + const json = JSON.parse(materialInfo.inputText); + const cadFile = FromDeflateBase64(json.file); + MaterialIn(JSON.parse(cadFile)); + +} + async function HandleUpload() { try { if (IsNullOrWhitespace(materialInfo.materialName)) { @@ -250,6 +262,7 @@ defineExpose({ Cancel: HandleCancel }) +