修复场景初始化后纹理未更新的问题

This commit is contained in:
陈梓阳 2025-05-30 15:47:17 +08:00
parent 9335c16763
commit 65a3779e1a
6 changed files with 27 additions and 8 deletions

View File

@ -1,3 +1,9 @@
# 材质编辑器
独立实现的WebCAD材质编辑器提供材质预览调节和上传功能。
独立实现的PBR材质编辑器提供PBR材质的预览参数调整功能。
- 支持PBR材质的序列化输出以及反序列化输入。
- 支持多种模型的预览(球体,圆环,立方体,环面纽结,圆锥体)
- 支持PBR材质的参数调节金属度粗糙度法线强度高光强度
- 支持纹理的参数调节U/V平铺偏移缩放调节
- 支持任意程序调用可挂在于HTML元素上

View File

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

View File

@ -114,6 +114,7 @@ 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";
export interface MaterialRequest {
/** 材质名 */
@ -164,10 +165,6 @@ const materialInfo = reactive({
inputText:'',
});
onMounted(async () => {
await scene.ChangeTextureFromUrlAsync(_textureSrc.value[0]);
})
watch(() => props.textureSrcList, async (val) => {
_textureSrc.value = val;
await scene.ChangeTextureFromUrlAsync(_textureSrc.value[0]);

View File

@ -53,6 +53,7 @@ async function HandleUpdateConfig() {
await scene.ImportMaterialAsync(json);
}
textureSrc.value = Array.from(config.textureSrc);
await scene.ChangeTextureFromUrlAsync(textureSrc.value[0]);
}
</script>

View 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);
}
}

View File

@ -20,10 +20,10 @@ export function ConfigureLibOutput(config: Partial<LibOutputConfig>) {
export type LibOutputConfig = {
/**
*
*
*/
host: string,
/** 材质贴图链接列表,场景会只会载入第一个链接作为纹理预览,但是导出提交时会为所有链接创建材质 */
/** 材质贴图链接列表,用与批量提交,场景会只会载入第一个链接作为纹理预览,但是导出提交时会为所有链接创建材质 */
textureSrc: Array<string>,
/** 更新模型,对材质进行编辑时赋值 */
updateModel?: {