From 65a3779e1a0f0e1d55c73b88141b3cbba454b046 Mon Sep 17 00:00:00 2001 From: "2817212736@qq.com" <2817212736@qq.com> Date: Fri, 30 May 2025 15:47:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=BA=E6=99=AF=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E5=90=8E=E7=BA=B9=E7=90=86=E6=9C=AA=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 +++++++- package.json | 2 +- src/components/MaterialAdjuster.vue | 5 +---- src/components/MaterialView.vue | 1 + src/helpers/helper.async.ts | 15 +++++++++++++++ src/lib/libOutputConfig.ts | 4 ++-- 6 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 src/helpers/helper.async.ts diff --git a/README.md b/README.md index cdd7748..ee29f8f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ # 材质编辑器 -独立实现的WebCAD材质编辑器,提供材质预览,调节和上传功能。 \ No newline at end of file +独立实现的PBR材质编辑器,提供PBR材质的预览,参数调整功能。 + +- 支持PBR材质的序列化输出以及反序列化输入。 +- 支持多种模型的预览(球体,圆环,立方体,环面纽结,圆锥体) +- 支持PBR材质的参数调节(金属度,粗糙度,法线强度,高光强度) +- 支持纹理的参数调节(U/V平铺,偏移,缩放调节) +- 支持任意程序调用,可挂在于HTML元素上 diff --git a/package.json b/package.json index 9b2cbef..50e8be3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "material-editor", "private": true, - "version": "1.0.13", + "version": "1.0.14", "type": "module", "scripts": { "dev": "vite", diff --git a/src/components/MaterialAdjuster.vue b/src/components/MaterialAdjuster.vue index bde426e..12f02ce 100644 --- a/src/components/MaterialAdjuster.vue +++ b/src/components/MaterialAdjuster.vue @@ -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]); diff --git a/src/components/MaterialView.vue b/src/components/MaterialView.vue index a6272bb..813cd86 100644 --- a/src/components/MaterialView.vue +++ b/src/components/MaterialView.vue @@ -53,6 +53,7 @@ async function HandleUpdateConfig() { await scene.ImportMaterialAsync(json); } textureSrc.value = Array.from(config.textureSrc); + await scene.ChangeTextureFromUrlAsync(textureSrc.value[0]); } diff --git a/src/helpers/helper.async.ts b/src/helpers/helper.async.ts new file mode 100644 index 0000000..485a484 --- /dev/null +++ b/src/helpers/helper.async.ts @@ -0,0 +1,15 @@ +/** + * 异步等待 + * @param ms 等待毫秒数 + * @param value 等待完成后返回的值 + * @returns + */ +export function AsyncDelay(ms: number, value?: T) { + return new Promise((resolve) => setTimeout(resolve, ms, value)); +} + +export async function AsyncWaitUntil(predicate: () => boolean, waitTime = 100) { + while (!predicate()) { + await AsyncDelay(waitTime); + } +} \ No newline at end of file diff --git a/src/lib/libOutputConfig.ts b/src/lib/libOutputConfig.ts index 274eecc..652cf16 100644 --- a/src/lib/libOutputConfig.ts +++ b/src/lib/libOutputConfig.ts @@ -20,10 +20,10 @@ export function ConfigureLibOutput(config: Partial) { export type LibOutputConfig = { /** - * 材质文件域名 + * 材质文件域名,用来获取贴图文件 */ host: string, - /** 材质贴图链接列表,场景会只会载入第一个链接作为纹理预览,但是导出提交时会为所有链接创建材质 */ + /** 材质贴图链接列表,用与批量提交,场景会只会载入第一个链接作为纹理预览,但是导出提交时会为所有链接创建材质 */ textureSrc: Array, /** 更新模型,对材质进行编辑时赋值 */ updateModel?: {