Skip to content

Commit

Permalink
Build webgpu module full from relative path (#5802)
Browse files Browse the repository at this point in the history
  • Loading branch information
slimbuck committed Nov 9, 2023
1 parent 612261f commit 73e0382
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/platform/graphics/webgpu/webgpu-graphics-device.js
Expand Up @@ -174,9 +174,17 @@ class WebgpuGraphicsDevice extends GraphicsDevice {
// temporary message to confirm Webgpu is being used
Debug.log("WebgpuGraphicsDevice initialization ..");

// build a full URL from a relative path
const buildUrl = (relativePath) => {
const url = new URL(window.location.href);
url.pathname = relativePath;
url.search = '';
return url.toString();
};

const results = await Promise.all([
import(`${twgslUrl}`).then(module => twgsl(twgslUrl.replace('.js', '.wasm'))),
import(`${glslangUrl}`).then(module => module.default())
import(`${buildUrl(twgslUrl)}`).then(module => twgsl(twgslUrl.replace('.js', '.wasm'))),
import(`${buildUrl(glslangUrl)}`).then(module => module.default())
]);

this.twgsl = results[0];
Expand Down

0 comments on commit 73e0382

Please sign in to comment.