From 8048c9c69032ad1223b4f379d78d052e7bcdac7d Mon Sep 17 00:00:00 2001 From: Rezmason Date: Tue, 2 Nov 2021 23:19:54 -0700 Subject: [PATCH] That's funny, you can blob a fetch response and chuck it into createImageBitmap(). --- js/webgpu/utils.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/js/webgpu/utils.js b/js/webgpu/utils.js index 1f87d3a..884c0df 100644 --- a/js/webgpu/utils.js +++ b/js/webgpu/utils.js @@ -4,11 +4,9 @@ const getCanvasSize = (canvas) => { }; const loadTexture = async (device, url) => { - const image = new Image(); - image.crossOrigin = "anonymous"; - image.src = url; - await image.decode(); - const imageBitmap = await createImageBitmap(image); + const response = await fetch(url, { credentials: "include" }); + const data = await response.blob(); + const imageBitmap = await createImageBitmap(data); const texture = device.createTexture({ size: [imageBitmap.width, imageBitmap.height, 1],