Compare commits
2 Commits
59703decc4
...
07565d42c4
Author | SHA1 | Date | |
---|---|---|---|
07565d42c4 | |||
990dfa2944 |
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "material-editor",
|
||||
"private": true,
|
||||
"version": "1.0.15",
|
||||
"version": "1.0.17",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
@ -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
|
||||
|
@ -108,13 +108,13 @@
|
||||
</template>
|
||||
|
||||
<script setup lang='ts'>
|
||||
import { ref, reactive, watch, onMounted, computed } from "vue"
|
||||
import { ref, reactive, watch } from "vue"
|
||||
import { useScene, type TextureAdjustment } from "../stores/sceneStore";
|
||||
import CfFlex from "./CfFlex.vue";
|
||||
import { DirectoryId } from "../api/Request";
|
||||
import { IsNullOrWhitespace } from "../helpers/helper.string";
|
||||
import { FromDeflateBase64, ToDeflatedBase64 } from "../helpers/helper.material";
|
||||
import { AsyncDelay } from "../helpers/helper.async";
|
||||
import { storeToRefs } from "pinia";
|
||||
|
||||
export interface MaterialRequest {
|
||||
/** 材质名 */
|
||||
@ -126,6 +126,7 @@ export interface MaterialRequest {
|
||||
}
|
||||
|
||||
const scene = useScene();
|
||||
const { Material, CurrGeometry, Geometries } = storeToRefs(scene);
|
||||
|
||||
const props = defineProps<{
|
||||
name?: string;
|
||||
@ -138,10 +139,6 @@ const emits = defineEmits<{
|
||||
(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 _textureSrc = ref(props.textureSrcList);
|
||||
const debugTextureSrc = ref("");
|
||||
@ -174,7 +171,7 @@ watch(() => props.textureSrcList, async (val) => {
|
||||
|
||||
watch(textureAdjustment, async (val) => {
|
||||
UpdateTexture();
|
||||
});
|
||||
}, { deep: true });
|
||||
|
||||
// 监听纹理更新
|
||||
watch(() => scene.CurrTexture, (val) => {
|
||||
@ -205,7 +202,6 @@ async function UpdateMaterial() {
|
||||
}
|
||||
|
||||
function UpdateTexture() {
|
||||
console.log('UpdateTexture')
|
||||
const texture = scene.CurrTexture;
|
||||
const val = textureAdjustment.value;
|
||||
texture.wrapS = val.wrapS;
|
||||
@ -227,6 +223,7 @@ async function loadData() {
|
||||
}
|
||||
|
||||
async function HandleUpload() {
|
||||
console.log(scene.GetEditor().Viewer.Scene.children);
|
||||
try {
|
||||
if (IsNullOrWhitespace(materialInfo.materialName)) {
|
||||
alert('材质名称不可为空');
|
||||
@ -244,7 +241,7 @@ async function HandleUpload() {
|
||||
file: ToDeflatedBase64(await scene.SerializeMaterialAsync())
|
||||
};
|
||||
result.push(mat);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// 遍历纹理链接列表,更改纹理后将材质序列化,然后还原场景
|
||||
let idx = 0;
|
||||
|
@ -75,7 +75,6 @@ const sceneSetup = () => {
|
||||
}
|
||||
|
||||
async function UpdateMaterialAsync() {
|
||||
console.log(Material.value.Update);
|
||||
// TODO: Danger: 如果等待下面这一行,会导致更新卡住(未知问题)
|
||||
Material.value.Update();
|
||||
// Material.value.Material.needsUpdate = true;
|
||||
|
Loading…
Reference in New Issue
Block a user