瀏覽代碼

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

Mario Zechner 3 年之前
父節點
當前提交
d9696997ac
共有 1 個文件被更改,包括 4 次插入2 次删除
  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) {
 	constructor (image: HTMLImageElement | ImageBitmap) {
 		super(image);
 		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.flipY = false;
 		this.texture.needsUpdate = true;
 		this.texture.needsUpdate = true;
 	}
 	}