Browse Source

[threejs] Fixes #2108, create CanvasTexture for ImageBitmap.

Mario Zechner 3 years ago
parent
commit
d9696997ac
1 changed files with 4 additions and 2 deletions
  1. 4 2
      spine-ts/spine-threejs/src/ThreeJsTexture.ts

+ 4 - 2
spine-ts/spine-threejs/src/ThreeJsTexture.ts

@@ -35,8 +35,10 @@ export class ThreeJsTexture extends Texture {
 
 	constructor (image: HTMLImageElement | ImageBitmap) {
 		super(image);
-		if (image instanceof ImageBitmap) throw new Error("ImageBitmap not supported.");
-		this.texture = new THREE.Texture(image);
+		if (image instanceof ImageBitmap)
+			this.texture = new THREE.CanvasTexture(image);
+		else
+			this.texture = new THREE.Texture(image);
 		this.texture.flipY = false;
 		this.texture.needsUpdate = true;
 	}