Browse Source

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

Mario Zechner 3 năm trước cách đây
mục cha
commit
d9696997ac
1 tập tin đã thay đổi với 4 bổ sung2 xóa
  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;
 	}