Skip to content

Commit d21a9cb

Browse files
authored
fix: Resolve AsyncTexture.ready (#2358)
1 parent 23516ee commit d21a9cb

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

modules/engine/src/async-texture/async-texture.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,13 @@ export class AsyncTexture {
102102
}
103103

104104
async initAsync(props: AsyncTextureProps): Promise<void> {
105-
let resolveReady;
106-
let rejectReady;
107-
108105
const asyncData: AsyncTextureData = props.data;
109-
const data: TextureData = await awaitAllPromises(asyncData).then(resolveReady, rejectReady);
106+
let data: TextureData;
107+
try {
108+
data = await awaitAllPromises(asyncData);
109+
} catch (error) {
110+
this.rejectReady(error as Error);
111+
}
110112

111113
// Check that we haven't been destroyed while waiting for texture data to load
112114
if (this.destroyed) {
@@ -121,6 +123,7 @@ export class AsyncTexture {
121123
this.sampler = this.texture.sampler;
122124
this.view = this.texture.view;
123125
this.isReady = true;
126+
this.resolveReady();
124127
}
125128

126129
destroy(): void {

0 commit comments

Comments
 (0)