diff --git a/public/assets/img/Di-3d.png b/assets/img/Di-3d.png similarity index 100% rename from public/assets/img/Di-3d.png rename to assets/img/Di-3d.png diff --git a/public/assets/img/brickwall_diffuse.png b/assets/img/brickwall_diffuse.png similarity index 100% rename from public/assets/img/brickwall_diffuse.png rename to assets/img/brickwall_diffuse.png diff --git a/public/assets/img/brickwall_height.png b/assets/img/brickwall_height.png similarity index 100% rename from public/assets/img/brickwall_height.png rename to assets/img/brickwall_height.png diff --git a/public/assets/img/brickwall_normal.png b/assets/img/brickwall_normal.png similarity index 100% rename from public/assets/img/brickwall_normal.png rename to assets/img/brickwall_normal.png diff --git a/public/assets/img/cubemap/negx.jpg b/assets/img/cubemap/negx.jpg similarity index 100% rename from public/assets/img/cubemap/negx.jpg rename to assets/img/cubemap/negx.jpg diff --git a/public/assets/img/cubemap/negy.jpg b/assets/img/cubemap/negy.jpg similarity index 100% rename from public/assets/img/cubemap/negy.jpg rename to assets/img/cubemap/negy.jpg diff --git a/public/assets/img/cubemap/negz.jpg b/assets/img/cubemap/negz.jpg similarity index 100% rename from public/assets/img/cubemap/negz.jpg rename to assets/img/cubemap/negz.jpg diff --git a/public/assets/img/cubemap/posx.jpg b/assets/img/cubemap/posx.jpg similarity index 100% rename from public/assets/img/cubemap/posx.jpg rename to assets/img/cubemap/posx.jpg diff --git a/public/assets/img/cubemap/posy.jpg b/assets/img/cubemap/posy.jpg similarity index 100% rename from public/assets/img/cubemap/posy.jpg rename to assets/img/cubemap/posy.jpg diff --git a/public/assets/img/cubemap/posz.jpg b/assets/img/cubemap/posz.jpg similarity index 100% rename from public/assets/img/cubemap/posz.jpg rename to assets/img/cubemap/posz.jpg diff --git a/public/assets/img/cubemap/readme.txt b/assets/img/cubemap/readme.txt similarity index 100% rename from public/assets/img/cubemap/readme.txt rename to assets/img/cubemap/readme.txt diff --git a/public/assets/img/moon.jpg b/assets/img/moon.jpg similarity index 100% rename from public/assets/img/moon.jpg rename to assets/img/moon.jpg diff --git a/public/assets/img/saturn.jpg b/assets/img/saturn.jpg similarity index 100% rename from public/assets/img/saturn.jpg rename to assets/img/saturn.jpg diff --git a/public/assets/img/spiral_height.png b/assets/img/spiral_height.png similarity index 100% rename from public/assets/img/spiral_height.png rename to assets/img/spiral_height.png diff --git a/public/assets/img/spiral_normal.png b/assets/img/spiral_normal.png similarity index 100% rename from public/assets/img/spiral_normal.png rename to assets/img/spiral_normal.png diff --git a/public/assets/img/toybox_height.png b/assets/img/toybox_height.png similarity index 100% rename from public/assets/img/toybox_height.png rename to assets/img/toybox_height.png diff --git a/public/assets/img/toybox_normal.png b/assets/img/toybox_normal.png similarity index 100% rename from public/assets/img/toybox_normal.png rename to assets/img/toybox_normal.png diff --git a/public/assets/img/webgpu.png b/assets/img/webgpu.png similarity index 100% rename from public/assets/img/webgpu.png rename to assets/img/webgpu.png diff --git a/public/assets/img/wood_diffuse.png b/assets/img/wood_diffuse.png similarity index 100% rename from public/assets/img/wood_diffuse.png rename to assets/img/wood_diffuse.png diff --git a/public/assets/video/pano.webm b/assets/video/pano.webm similarity index 100% rename from public/assets/video/pano.webm rename to assets/video/pano.webm diff --git a/public/examples/base.css b/public/examples/base.css deleted file mode 100644 index cc554439..00000000 --- a/public/examples/base.css +++ /dev/null @@ -1,11 +0,0 @@ -html, body { - margin: 0; - height: 100%; -} -#canvas { - width: 100%; - max-width: 600px; - aspect-ratio: 1; - display: block; - margin: 0 auto; -} diff --git a/src/sample/cameras/main.ts b/src/sample/cameras/main.ts index fabd4797..e4c59c8f 100644 --- a/src/sample/cameras/main.ts +++ b/src/sample/cameras/main.ts @@ -128,7 +128,9 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => { // Fetch the image and upload it into a GPUTexture. let cubeTexture: GPUTexture; { - const response = await fetch('/assets/img/Di-3d.png'); + const response = await fetch( + new URL('../../../assets/img/Di-3d.png', import.meta.url).toString() + ); const imageBitmap = await createImageBitmap(await response.blob()); cubeTexture = device.createTexture({ diff --git a/src/sample/cubemap/main.ts b/src/sample/cubemap/main.ts index ba97f210..7524fbea 100644 --- a/src/sample/cubemap/main.ts +++ b/src/sample/cubemap/main.ts @@ -107,12 +107,30 @@ const init: SampleInit = async ({ canvas, pageState }) => { { // The order of the array layers is [+X, -X, +Y, -Y, +Z, -Z] const imgSrcs = [ - '/assets/img/cubemap/posx.jpg', - '/assets/img/cubemap/negx.jpg', - '/assets/img/cubemap/posy.jpg', - '/assets/img/cubemap/negy.jpg', - '/assets/img/cubemap/posz.jpg', - '/assets/img/cubemap/negz.jpg', + new URL( + `../../../assets/img/cubemap/posx.jpg`, + import.meta.url + ).toString(), + new URL( + `../../../assets/img/cubemap/negx.jpg`, + import.meta.url + ).toString(), + new URL( + `../../../assets/img/cubemap/posy.jpg`, + import.meta.url + ).toString(), + new URL( + `../../../assets/img/cubemap/negy.jpg`, + import.meta.url + ).toString(), + new URL( + `../../../assets/img/cubemap/posz.jpg`, + import.meta.url + ).toString(), + new URL( + `../../../assets/img/cubemap/negz.jpg`, + import.meta.url + ).toString(), ]; const promises = imgSrcs.map(async (src) => { const response = await fetch(src); diff --git a/src/sample/imageBlur/main.ts b/src/sample/imageBlur/main.ts index 0f426d63..2807f92f 100644 --- a/src/sample/imageBlur/main.ts +++ b/src/sample/imageBlur/main.ts @@ -64,7 +64,9 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => { minFilter: 'linear', }); - const response = await fetch('/assets/img/Di-3d.png'); + const response = await fetch( + new URL('../../../assets/img/Di-3d.png', import.meta.url).toString() + ); const imageBitmap = await createImageBitmap(await response.blob()); const [srcWidth, srcHeight] = [imageBitmap.width, imageBitmap.height]; diff --git a/src/sample/normalMap/main.ts b/src/sample/normalMap/main.ts index 047a1d57..18467adb 100644 --- a/src/sample/normalMap/main.ts +++ b/src/sample/normalMap/main.ts @@ -91,56 +91,96 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => { // Fetch the image and upload it into a GPUTexture. let woodDiffuseTexture: GPUTexture; { - const response = await fetch('/assets/img/wood_diffuse.png'); + const response = await fetch( + new URL( + '../../../assets/img/wood_diffuse.png', + import.meta.url + ).toString() + ); const imageBitmap = await createImageBitmap(await response.blob()); woodDiffuseTexture = createTextureFromImage(device, imageBitmap); } let spiralNormalTexture: GPUTexture; { - const response = await fetch('/assets/img/spiral_normal.png'); + const response = await fetch( + new URL( + '../../../assets/img/spiral_normal.png', + import.meta.url + ).toString() + ); const imageBitmap = await createImageBitmap(await response.blob()); spiralNormalTexture = createTextureFromImage(device, imageBitmap); } let spiralHeightTexture: GPUTexture; { - const response = await fetch('/assets/img/spiral_height.png'); + const response = await fetch( + new URL( + '../../../assets/img/spiral_height.png', + import.meta.url + ).toString() + ); const imageBitmap = await createImageBitmap(await response.blob()); spiralHeightTexture = createTextureFromImage(device, imageBitmap); } let toyboxNormalTexture: GPUTexture; { - const response = await fetch('/assets/img/toybox_normal.png'); + const response = await fetch( + new URL( + '../../../assets/img/toybox_normal.png', + import.meta.url + ).toString() + ); const imageBitmap = await createImageBitmap(await response.blob()); toyboxNormalTexture = createTextureFromImage(device, imageBitmap); } let toyboxHeightTexture: GPUTexture; { - const response = await fetch('/assets/img/toybox_height.png'); + const response = await fetch( + new URL( + '../../../assets/img/toybox_height.png', + import.meta.url + ).toString() + ); const imageBitmap = await createImageBitmap(await response.blob()); toyboxHeightTexture = createTextureFromImage(device, imageBitmap); } let brickwallDiffuseTexture: GPUTexture; { - const response = await fetch('/assets/img/brickwall_diffuse.png'); + const response = await fetch( + new URL( + '../../../assets/img/brickwall_diffuse.png', + import.meta.url + ).toString() + ); const imageBitmap = await createImageBitmap(await response.blob()); brickwallDiffuseTexture = createTextureFromImage(device, imageBitmap); } let brickwallNormalTexture: GPUTexture; { - const response = await fetch('/assets/img/brickwall_normal.png'); + const response = await fetch( + new URL( + '../../../assets/img/brickwall_normal.png', + import.meta.url + ).toString() + ); const imageBitmap = await createImageBitmap(await response.blob()); brickwallNormalTexture = createTextureFromImage(device, imageBitmap); } let brickwallHeightTexture: GPUTexture; { - const response = await fetch('/assets/img/brickwall_height.png'); + const response = await fetch( + new URL( + '../../../assets/img/brickwall_height.png', + import.meta.url + ).toString() + ); const imageBitmap = await createImageBitmap(await response.blob()); brickwallHeightTexture = createTextureFromImage(device, imageBitmap); } diff --git a/src/sample/particles/main.ts b/src/sample/particles/main.ts index d9d1069c..76300b63 100644 --- a/src/sample/particles/main.ts +++ b/src/sample/particles/main.ts @@ -185,7 +185,9 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => { let textureHeight = 1; let numMipLevels = 1; { - const response = await fetch('/assets/img/webgpu.png'); + const response = await fetch( + new URL('../../../assets/img/webgpu.png', import.meta.url).toString() + ); const imageBitmap = await createImageBitmap(await response.blob()); // Calculate number of mip levels required to generate the probability map diff --git a/src/sample/renderBundles/main.ts b/src/sample/renderBundles/main.ts index 8eae15ae..96d5c541 100644 --- a/src/sample/renderBundles/main.ts +++ b/src/sample/renderBundles/main.ts @@ -118,7 +118,9 @@ const init: SampleInit = async ({ canvas, pageState, gui, stats }) => { // Fetch the images and upload them into a GPUTexture. let planetTexture: GPUTexture; { - const response = await fetch('/assets/img/saturn.jpg'); + const response = await fetch( + new URL('../../../assets/img/saturn.jpg', import.meta.url).toString() + ); const imageBitmap = await createImageBitmap(await response.blob()); planetTexture = device.createTexture({ @@ -138,7 +140,9 @@ const init: SampleInit = async ({ canvas, pageState, gui, stats }) => { let moonTexture: GPUTexture; { - const response = await fetch('/assets/img/moon.jpg'); + const response = await fetch( + new URL('../../../assets/img/moon.jpg', import.meta.url).toString() + ); const imageBitmap = await createImageBitmap(await response.blob()); moonTexture = device.createTexture({ diff --git a/src/sample/texturedCube/main.ts b/src/sample/texturedCube/main.ts index d052dd2a..750ca142 100644 --- a/src/sample/texturedCube/main.ts +++ b/src/sample/texturedCube/main.ts @@ -110,7 +110,9 @@ const init: SampleInit = async ({ canvas, pageState }) => { // Fetch the image and upload it into a GPUTexture. let cubeTexture: GPUTexture; { - const response = await fetch('/assets/img/Di-3d.png'); + const response = await fetch( + new URL('../../../assets/img/Di-3d.png', import.meta.url).toString() + ); const imageBitmap = await createImageBitmap(await response.blob()); cubeTexture = device.createTexture({ diff --git a/src/sample/videoUploading/main.ts b/src/sample/videoUploading/main.ts index 4aed67df..8c0f2784 100644 --- a/src/sample/videoUploading/main.ts +++ b/src/sample/videoUploading/main.ts @@ -9,7 +9,10 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => { video.loop = true; video.autoplay = true; video.muted = true; - video.src = '/assets/video/pano.webm'; + video.src = new URL( + '../../../assets/video/pano.webm', + import.meta.url + ).toString(); await video.play(); const adapter = await navigator.gpu.requestAdapter(); diff --git a/src/sample/videoUploadingWebCodecs/main.ts b/src/sample/videoUploadingWebCodecs/main.ts index 867f183b..c2098fea 100644 --- a/src/sample/videoUploadingWebCodecs/main.ts +++ b/src/sample/videoUploadingWebCodecs/main.ts @@ -9,7 +9,10 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => { video.loop = true; video.autoplay = true; video.muted = true; - video.src = '/assets/video/pano.webm'; + video.src = new URL( + '../../../assets/video/pano.webm', + import.meta.url + ).toString(); await video.play(); const adapter = await navigator.gpu.requestAdapter();