修复场景初始化后纹理未更新的问题
This commit is contained in:
		@@ -1,3 +1,9 @@
 | 
				
			|||||||
# 材质编辑器
 | 
					# 材质编辑器
 | 
				
			||||||
 | 
					
 | 
				
			||||||
独立实现的WebCAD材质编辑器,提供材质预览,调节和上传功能。
 | 
					独立实现的PBR材质编辑器,提供PBR材质的预览,参数调整功能。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- 支持PBR材质的序列化输出以及反序列化输入。
 | 
				
			||||||
 | 
					- 支持多种模型的预览(球体,圆环,立方体,环面纽结,圆锥体)
 | 
				
			||||||
 | 
					- 支持PBR材质的参数调节(金属度,粗糙度,法线强度,高光强度)
 | 
				
			||||||
 | 
					- 支持纹理的参数调节(U/V平铺,偏移,缩放调节)
 | 
				
			||||||
 | 
					- 支持任意程序调用,可挂在于HTML元素上
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "name": "material-editor",
 | 
					  "name": "material-editor",
 | 
				
			||||||
  "private": true,
 | 
					  "private": true,
 | 
				
			||||||
  "version": "1.0.13",
 | 
					  "version": "1.0.14",
 | 
				
			||||||
  "type": "module",
 | 
					  "type": "module",
 | 
				
			||||||
  "scripts": {
 | 
					  "scripts": {
 | 
				
			||||||
    "dev": "vite",
 | 
					    "dev": "vite",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -114,6 +114,7 @@ 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 { AsyncDelay } from "../helpers/helper.async";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface MaterialRequest {
 | 
					export interface MaterialRequest {
 | 
				
			||||||
    /** 材质名 */
 | 
					    /** 材质名 */
 | 
				
			||||||
@@ -164,10 +165,6 @@ const materialInfo = reactive({
 | 
				
			|||||||
    inputText:'',
 | 
					    inputText:'',
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
onMounted(async () => {
 | 
					 | 
				
			||||||
    await scene.ChangeTextureFromUrlAsync(_textureSrc.value[0]);
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
watch(() => props.textureSrcList, async (val) => {
 | 
					watch(() => props.textureSrcList, async (val) => {
 | 
				
			||||||
    _textureSrc.value = val;
 | 
					    _textureSrc.value = val;
 | 
				
			||||||
    await scene.ChangeTextureFromUrlAsync(_textureSrc.value[0]);
 | 
					    await scene.ChangeTextureFromUrlAsync(_textureSrc.value[0]);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -53,6 +53,7 @@ async function HandleUpdateConfig() {
 | 
				
			|||||||
        await scene.ImportMaterialAsync(json);
 | 
					        await scene.ImportMaterialAsync(json);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    textureSrc.value = Array.from(config.textureSrc);
 | 
					    textureSrc.value = Array.from(config.textureSrc);
 | 
				
			||||||
 | 
					    await scene.ChangeTextureFromUrlAsync(textureSrc.value[0]);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										15
									
								
								src/helpers/helper.async.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								src/helpers/helper.async.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 异步等待
 | 
				
			||||||
 | 
					 * @param ms 等待毫秒数
 | 
				
			||||||
 | 
					 * @param value 等待完成后返回的值
 | 
				
			||||||
 | 
					 * @returns 
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					export function AsyncDelay<T>(ms: number, value?: T) {
 | 
				
			||||||
 | 
					    return new Promise<T>((resolve) => setTimeout(resolve, ms, value));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export async function AsyncWaitUntil(predicate: () => boolean, waitTime = 100) {
 | 
				
			||||||
 | 
					    while (!predicate()) {
 | 
				
			||||||
 | 
					        await AsyncDelay(waitTime);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -20,10 +20,10 @@ export function ConfigureLibOutput(config: Partial<LibOutputConfig>) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export type LibOutputConfig = {
 | 
					export type LibOutputConfig = {
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 材质文件域名
 | 
					     * 材质文件域名,用来获取贴图文件
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    host: string,
 | 
					    host: string,
 | 
				
			||||||
    /** 材质贴图链接列表,场景会只会载入第一个链接作为纹理预览,但是导出提交时会为所有链接创建材质 */
 | 
					    /** 材质贴图链接列表,用与批量提交,场景会只会载入第一个链接作为纹理预览,但是导出提交时会为所有链接创建材质 */
 | 
				
			||||||
    textureSrc: Array<string>,
 | 
					    textureSrc: Array<string>,
 | 
				
			||||||
    /** 更新模型,对材质进行编辑时赋值 */
 | 
					    /** 更新模型,对材质进行编辑时赋值 */
 | 
				
			||||||
    updateModel?: {
 | 
					    updateModel?: {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user