2 Commits

Author SHA1 Message Date
942c7f1cc7 移除调试内容 2025-06-09 09:39:25 +08:00
10d5595fb6 修复编辑模式传入的材质名失效的问题 2025-06-04 17:12:07 +08:00
3 changed files with 25 additions and 16 deletions

View File

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

View File

@@ -16,19 +16,24 @@ Database.prototype.AllocationObjectId = function (this: Database, object: CADObj
export function MaterialOut(material: PhysicalMaterialRecord): string
{
let db = new Database();
db.WblockCloneObejcts(
[material],
db.MaterialTable,
new Map(),
DuplicateRecordCloning.Ignore
);
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;
try {
let db = new Database();
db.WblockCloneObejcts(
[material],
db.MaterialTable,
new Map(),
DuplicateRecordCloning.Ignore
);
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;
} catch (error) {
console.error("error in MaterialOut:", error, material);
throw error;
}
}
export function MaterialIn(fileData: Object[]): PhysicalMaterialRecord

View File

@@ -108,7 +108,7 @@
</template>
<script setup lang='ts'>
import { ref, reactive, watch } from "vue"
import { ref, reactive, watch, computed } from "vue"
import { useScene, type TextureAdjustment } from "../stores/sceneStore";
import CfFlex from "./CfFlex.vue";
import { DirectoryId } from "../api/Request";
@@ -139,7 +139,7 @@ const emits = defineEmits<{
(e: 'submit', data: MaterialRequest[]): void;
}>();
const debugMode = ref(true);
const debugMode = ref(false);
const _textureSrc = ref(props.textureSrcList);
const debugTextureSrc = ref("");
const textureAdjustment = ref<TextureAdjustment>({
@@ -169,6 +169,10 @@ watch(() => props.textureSrcList, async (val) => {
await scene.ChangeTextureFromUrlAsync(_textureSrc.value[0]);
});
watch(() => props.name, () => {
materialInfo.materialName = props.name || '材质';
});
watch(textureAdjustment, async (val) => {
UpdateTexture();
}, { deep: true });