修复材质加载与导出
This commit is contained in:
@@ -6,12 +6,15 @@
|
||||
<legend>DEBUG</legend>
|
||||
<label>上传路径ID</label>
|
||||
<input v-model="materialInfo.dirId" type="text" placeholder="材质路径ID" />
|
||||
<label>配置JSON</label>
|
||||
<input v-model="materialInfo.inputText" type="text" />
|
||||
<button class="btn-success" style="min-width: 110px;" @click="loadData">加载</button>
|
||||
</fieldset>
|
||||
<label>材质名</label>
|
||||
<input v-model.trim="materialInfo.materialName" type="text" placeholder="材质名" />
|
||||
|
||||
<CfFlex gap="1em" v-if="debugMode">
|
||||
<button class="btn-success" style="min-width: 110px;" @click="HandleUpload">上传</button>
|
||||
<button class="btn-success" style="min-width: 110px;" @click="HandleUpload">保存</button>
|
||||
<button class="btn-danger" style="min-width: 110px;" @click="HandleCancel">取消</button>
|
||||
</CfFlex>
|
||||
</div>
|
||||
@@ -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
|
||||
})
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
Reference in New Issue
Block a user