From 73e038249dd3d1e342248915a419a26163a7acd5 Mon Sep 17 00:00:00 2001 From: Donovan Hutchence Date: Thu, 9 Nov 2023 10:31:03 +0000 Subject: [PATCH] Build webgpu module full from relative path (#5802) --- .../graphics/webgpu/webgpu-graphics-device.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/platform/graphics/webgpu/webgpu-graphics-device.js b/src/platform/graphics/webgpu/webgpu-graphics-device.js index 9df58e76cb3..b975b35e775 100644 --- a/src/platform/graphics/webgpu/webgpu-graphics-device.js +++ b/src/platform/graphics/webgpu/webgpu-graphics-device.js @@ -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];