From 41bbbe7c9618eb7c6d7f62478e37c96dc1b39fb0 Mon Sep 17 00:00:00 2001 From: Yu1512 Date: Wed, 15 Feb 2023 15:21:00 +0800 Subject: [PATCH] refactor: replace the deprecate api 'globEager' --- .../Decorates/Three/ThreeEarth01/code/world/Assets.ts | 11 +++++------ .../Three/ThreeEarth01/code/world/Resources.ts | 5 +++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/packages/components/Decorates/Three/ThreeEarth01/code/world/Assets.ts b/src/packages/components/Decorates/Three/ThreeEarth01/code/world/Assets.ts index bd8df6c4..b6331dea 100644 --- a/src/packages/components/Decorates/Three/ThreeEarth01/code/world/Assets.ts +++ b/src/packages/components/Decorates/Three/ThreeEarth01/code/world/Assets.ts @@ -5,7 +5,7 @@ interface ITextures { name: string - url: string + url: () => Promise<{ default: string }> } export interface IResources { @@ -15,14 +15,13 @@ export interface IResources { const fileSuffix = ['earth', 'gradient', 'redCircle', 'label', 'aperture', 'glow', 'light_column', 'aircraft'] const textures: ITextures[] = [] -const modules = import.meta.globEager("../../images/earth/*"); - -for(let item in modules) { +const modules = import.meta.glob("../../images/earth/*"); +for (let item in modules) { const n = item.split('/').pop() - if(n) { + if (n) { textures.push({ name: n.split('.')[0], - url: modules[item].default + url: (modules[item] as () => Promise<{ default: string }>) }) } } diff --git a/src/packages/components/Decorates/Three/ThreeEarth01/code/world/Resources.ts b/src/packages/components/Decorates/Three/ThreeEarth01/code/world/Resources.ts index 71468dc2..227c8390 100644 --- a/src/packages/components/Decorates/Three/ThreeEarth01/code/world/Resources.ts +++ b/src/packages/components/Decorates/Three/ThreeEarth01/code/world/Resources.ts @@ -45,8 +45,9 @@ export class Resources { */ private loadResources(): void { this.textureLoader = new TextureLoader(this.manager) - resources.textures?.forEach(item => { - this.textureLoader.load(item.url, t => { + resources.textures?.forEach(async item => { + const url = (await item.url()).default + this.textureLoader.load(url, t => { this.textures[item.name] = t }) })