修复更改预览模型和纹理参数不生效的问题
This commit is contained in:
		@@ -1,7 +1,7 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "material-editor",
 | 
			
		||||
  "private": true,
 | 
			
		||||
  "version": "1.0.16",
 | 
			
		||||
  "version": "1.0.17",
 | 
			
		||||
  "type": "module",
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "dev": "vite",
 | 
			
		||||
 
 | 
			
		||||
@@ -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('材质名称不可为空');
 | 
			
		||||
 
 | 
			
		||||
@@ -75,7 +75,6 @@ const sceneSetup = () => {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async function UpdateMaterialAsync() {
 | 
			
		||||
        console.log(Material.value.Update);
 | 
			
		||||
        // TODO: Danger: 如果等待下面这一行,会导致更新卡住(未知问题)
 | 
			
		||||
        Material.value.Update();
 | 
			
		||||
        // Material.value.Material.needsUpdate = true;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user