修复场景初始化后纹理未更新的问题
This commit is contained in:
@@ -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]);
|
||||
|
@@ -53,6 +53,7 @@ async function HandleUpdateConfig() {
|
||||
await scene.ImportMaterialAsync(json);
|
||||
}
|
||||
textureSrc.value = Array.from(config.textureSrc);
|
||||
await scene.ChangeTextureFromUrlAsync(textureSrc.value[0]);
|
||||
}
|
||||
|
||||
</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 = {
|
||||
/**
|
||||
* 材质文件域名
|
||||
* 材质文件域名,用来获取贴图文件
|
||||
*/
|
||||
host: string,
|
||||
/** 材质贴图链接列表,场景会只会载入第一个链接作为纹理预览,但是导出提交时会为所有链接创建材质 */
|
||||
/** 材质贴图链接列表,用与批量提交,场景会只会载入第一个链接作为纹理预览,但是导出提交时会为所有链接创建材质 */
|
||||
textureSrc: Array<string>,
|
||||
/** 更新模型,对材质进行编辑时赋值 */
|
||||
updateModel?: {
|
||||
|
Reference in New Issue
Block a user