aboutsummaryrefslogtreecommitdiff
path: root/web/pw-visualizer/src/webgl/texture.ts
diff options
context:
space:
mode:
Diffstat (limited to 'web/pw-visualizer/src/webgl/texture.ts')
-rw-r--r--web/pw-visualizer/src/webgl/texture.ts26
1 files changed, 12 insertions, 14 deletions
diff --git a/web/pw-visualizer/src/webgl/texture.ts b/web/pw-visualizer/src/webgl/texture.ts
index 9d6adcf..faafe76 100644
--- a/web/pw-visualizer/src/webgl/texture.ts
+++ b/web/pw-visualizer/src/webgl/texture.ts
@@ -11,15 +11,18 @@ export class Texture {
gl: WebGLRenderingContext,
path: string,
name: string,
- ): Texture {
- const out = new Texture(gl, name);
-
- const image = new Image();
- image.onload = out.setImage.bind(out, gl, image);
- image.onerror = error;
- image.src = path;
-
- return out;
+ ): Promise<Texture> {
+ return new Promise((resolve, reject) => {
+ const out = new Texture(gl, name);
+
+ const image = new Image();
+ image.onload = () => {
+ out.setImage(gl, image);
+ resolve(out);
+ }
+ image.onerror = reject;
+ image.src = path;
+ })
}
static fromRenderer(
@@ -99,8 +102,3 @@ export class Texture {
return this.height;
}
}
-
-function error(e: any) {
- console.error("IMAGE LOAD ERROR");
- console.error(e);
-}