Compare commits

..

No commits in common. "07565d42c4f70361f728808f97711741de2a2b9a" and "59703decc4dfce64daad534c03dca15dd9e08a47" have entirely different histories.

4 changed files with 13 additions and 14 deletions

View File

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

View File

@ -1,4 +1,4 @@
import { CADFiler, CADObject, Database, DuplicateRecordCloning, Factory, LayerNode, ObjectId, PhysicalMaterialRecord, TextureTableRecord } from "webcad_ue4_api"; import { CADFiler, CADObject, Database, DuplicateRecordCloning, Factory, LayerNode, ObjectId, PhysicalMaterialRecord } from "webcad_ue4_api";
// TODO: Danger: 注意入侵性代码 // TODO: Danger: 注意入侵性代码
// 疑似是WebCAD中的漏洞当传入new Database()时, // 疑似是WebCAD中的漏洞当传入new Database()时,
@ -23,12 +23,7 @@ export function MaterialOut(material: PhysicalMaterialRecord): string
new Map(), new Map(),
DuplicateRecordCloning.Ignore DuplicateRecordCloning.Ignore
); );
let json = JSON.stringify(db.FileWrite().Data); return 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 export function MaterialIn(fileData: Object[]): PhysicalMaterialRecord

View File

@ -108,13 +108,13 @@
</template> </template>
<script setup lang='ts'> <script setup lang='ts'>
import { ref, reactive, watch } from "vue" import { ref, reactive, watch, onMounted, computed } from "vue"
import { useScene, type TextureAdjustment } from "../stores/sceneStore"; import { useScene, type TextureAdjustment } from "../stores/sceneStore";
import CfFlex from "./CfFlex.vue"; import CfFlex from "./CfFlex.vue";
import { DirectoryId } from "../api/Request"; import { DirectoryId } from "../api/Request";
import { IsNullOrWhitespace } from "../helpers/helper.string"; import { IsNullOrWhitespace } from "../helpers/helper.string";
import { FromDeflateBase64, ToDeflatedBase64 } from "../helpers/helper.material"; import { FromDeflateBase64, ToDeflatedBase64 } from "../helpers/helper.material";
import { storeToRefs } from "pinia"; import { AsyncDelay } from "../helpers/helper.async";
export interface MaterialRequest { export interface MaterialRequest {
/** 材质名 */ /** 材质名 */
@ -126,7 +126,6 @@ export interface MaterialRequest {
} }
const scene = useScene(); const scene = useScene();
const { Material, CurrGeometry, Geometries } = storeToRefs(scene);
const props = defineProps<{ const props = defineProps<{
name?: string; name?: string;
@ -139,6 +138,10 @@ const emits = defineEmits<{
(e: 'submit', data: MaterialRequest[]): void; (e: 'submit', data: MaterialRequest[]): void;
}>(); }>();
const Material = computed(() => scene.Material);
const CurrGeometry = computed(() => scene.CurrGeometry);
const Geometries = computed(() => scene.Geometries);
const debugMode = ref(true); const debugMode = ref(true);
const _textureSrc = ref(props.textureSrcList); const _textureSrc = ref(props.textureSrcList);
const debugTextureSrc = ref(""); const debugTextureSrc = ref("");
@ -171,7 +174,7 @@ watch(() => props.textureSrcList, async (val) => {
watch(textureAdjustment, async (val) => { watch(textureAdjustment, async (val) => {
UpdateTexture(); UpdateTexture();
}, { deep: true }); });
// //
watch(() => scene.CurrTexture, (val) => { watch(() => scene.CurrTexture, (val) => {
@ -202,6 +205,7 @@ async function UpdateMaterial() {
} }
function UpdateTexture() { function UpdateTexture() {
console.log('UpdateTexture')
const texture = scene.CurrTexture; const texture = scene.CurrTexture;
const val = textureAdjustment.value; const val = textureAdjustment.value;
texture.wrapS = val.wrapS; texture.wrapS = val.wrapS;
@ -223,7 +227,6 @@ async function loadData() {
} }
async function HandleUpload() { async function HandleUpload() {
console.log(scene.GetEditor().Viewer.Scene.children);
try { try {
if (IsNullOrWhitespace(materialInfo.materialName)) { if (IsNullOrWhitespace(materialInfo.materialName)) {
alert('材质名称不可为空'); alert('材质名称不可为空');

View File

@ -75,6 +75,7 @@ const sceneSetup = () => {
} }
async function UpdateMaterialAsync() { async function UpdateMaterialAsync() {
console.log(Material.value.Update);
// TODO: Danger: 如果等待下面这一行,会导致更新卡住(未知问题) // TODO: Danger: 如果等待下面这一行,会导致更新卡住(未知问题)
Material.value.Update(); Material.value.Update();
// Material.value.Material.needsUpdate = true; // Material.value.Material.needsUpdate = true;