Skip to content

Commit

Permalink
Move assets to public folder so the code is more idomatic
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Oct 30, 2023
1 parent 17026a9 commit c8195de
Show file tree
Hide file tree
Showing 30 changed files with 33 additions and 98 deletions.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
11 changes: 11 additions & 0 deletions public/examples/base.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
html, body {
margin: 0;
height: 100%;
}
#canvas {
width: 100%;
max-width: 600px;
aspect-ratio: 1;
display: block;
margin: 0 auto;
}
4 changes: 1 addition & 3 deletions src/sample/cameras/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
// Fetch the image and upload it into a GPUTexture.
let cubeTexture: GPUTexture;
{
const response = await fetch(
new URL('../../../assets/img/Di-3d.png', import.meta.url).toString()
);
const response = await fetch('/assets/img/Di-3d.png');
const imageBitmap = await createImageBitmap(await response.blob());

cubeTexture = device.createTexture({
Expand Down
30 changes: 6 additions & 24 deletions src/sample/cubemap/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,30 +107,12 @@ const init: SampleInit = async ({ canvas, pageState }) => {
{
// The order of the array layers is [+X, -X, +Y, -Y, +Z, -Z]
const imgSrcs = [
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(),
'/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',
];
const promises = imgSrcs.map(async (src) => {
const response = await fetch(src);
Expand Down
4 changes: 1 addition & 3 deletions src/sample/imageBlur/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
minFilter: 'linear',
});

const response = await fetch(
new URL('../../../assets/img/Di-3d.png', import.meta.url).toString()
);
const response = await fetch('/assets/img/Di-3d.png');
const imageBitmap = await createImageBitmap(await response.blob());

const [srcWidth, srcHeight] = [imageBitmap.width, imageBitmap.height];
Expand Down
56 changes: 8 additions & 48 deletions src/sample/normalMap/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,96 +91,56 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
// Fetch the image and upload it into a GPUTexture.
let woodDiffuseTexture: GPUTexture;
{
const response = await fetch(
new URL(
'../../../assets/img/wood_diffuse.png',
import.meta.url
).toString()
);
const response = await fetch('/assets/img/wood_diffuse.png');
const imageBitmap = await createImageBitmap(await response.blob());
woodDiffuseTexture = createTextureFromImage(device, imageBitmap);
}

let spiralNormalTexture: GPUTexture;
{
const response = await fetch(
new URL(
'../../../assets/img/spiral_normal.png',
import.meta.url
).toString()
);
const response = await fetch('/assets/img/spiral_normal.png');
const imageBitmap = await createImageBitmap(await response.blob());
spiralNormalTexture = createTextureFromImage(device, imageBitmap);
}

let spiralHeightTexture: GPUTexture;
{
const response = await fetch(
new URL(
'../../../assets/img/spiral_height.png',
import.meta.url
).toString()
);
const response = await fetch('/assets/img/spiral_height.png');
const imageBitmap = await createImageBitmap(await response.blob());
spiralHeightTexture = createTextureFromImage(device, imageBitmap);
}

let toyboxNormalTexture: GPUTexture;
{
const response = await fetch(
new URL(
'../../../assets/img/toybox_normal.png',
import.meta.url
).toString()
);
const response = await fetch('/assets/img/toybox_normal.png');
const imageBitmap = await createImageBitmap(await response.blob());
toyboxNormalTexture = createTextureFromImage(device, imageBitmap);
}

let toyboxHeightTexture: GPUTexture;
{
const response = await fetch(
new URL(
'../../../assets/img/toybox_height.png',
import.meta.url
).toString()
);
const response = await fetch('/assets/img/toybox_height.png');
const imageBitmap = await createImageBitmap(await response.blob());
toyboxHeightTexture = createTextureFromImage(device, imageBitmap);
}

let brickwallDiffuseTexture: GPUTexture;
{
const response = await fetch(
new URL(
'../../../assets/img/brickwall_diffuse.png',
import.meta.url
).toString()
);
const response = await fetch('/assets/img/brickwall_diffuse.png');
const imageBitmap = await createImageBitmap(await response.blob());
brickwallDiffuseTexture = createTextureFromImage(device, imageBitmap);
}

let brickwallNormalTexture: GPUTexture;
{
const response = await fetch(
new URL(
'../../../assets/img/brickwall_normal.png',
import.meta.url
).toString()
);
const response = await fetch('/assets/img/brickwall_normal.png');
const imageBitmap = await createImageBitmap(await response.blob());
brickwallNormalTexture = createTextureFromImage(device, imageBitmap);
}

let brickwallHeightTexture: GPUTexture;
{
const response = await fetch(
new URL(
'../../../assets/img/brickwall_height.png',
import.meta.url
).toString()
);
const response = await fetch('/assets/img/brickwall_height.png');
const imageBitmap = await createImageBitmap(await response.blob());
brickwallHeightTexture = createTextureFromImage(device, imageBitmap);
}
Expand Down
4 changes: 1 addition & 3 deletions src/sample/particles/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
let textureHeight = 1;
let numMipLevels = 1;
{
const response = await fetch(
new URL('../../../assets/img/webgpu.png', import.meta.url).toString()
);
const response = await fetch('/assets/img/webgpu.png');
const imageBitmap = await createImageBitmap(await response.blob());

// Calculate number of mip levels required to generate the probability map
Expand Down
8 changes: 2 additions & 6 deletions src/sample/renderBundles/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ const init: SampleInit = async ({ canvas, pageState, gui, stats }) => {
// Fetch the images and upload them into a GPUTexture.
let planetTexture: GPUTexture;
{
const response = await fetch(
new URL('../../../assets/img/saturn.jpg', import.meta.url).toString()
);
const response = await fetch('/assets/img/saturn.jpg');
const imageBitmap = await createImageBitmap(await response.blob());

planetTexture = device.createTexture({
Expand All @@ -140,9 +138,7 @@ const init: SampleInit = async ({ canvas, pageState, gui, stats }) => {

let moonTexture: GPUTexture;
{
const response = await fetch(
new URL('../../../assets/img/moon.jpg', import.meta.url).toString()
);
const response = await fetch('/assets/img/moon.jpg');
const imageBitmap = await createImageBitmap(await response.blob());

moonTexture = device.createTexture({
Expand Down
4 changes: 1 addition & 3 deletions src/sample/texturedCube/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ const init: SampleInit = async ({ canvas, pageState }) => {
// Fetch the image and upload it into a GPUTexture.
let cubeTexture: GPUTexture;
{
const response = await fetch(
new URL('../../../assets/img/Di-3d.png', import.meta.url).toString()
);
const response = await fetch('/assets/img/Di-3d.png');
const imageBitmap = await createImageBitmap(await response.blob());

cubeTexture = device.createTexture({
Expand Down
5 changes: 1 addition & 4 deletions src/sample/videoUploading/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
video.loop = true;
video.autoplay = true;
video.muted = true;
video.src = new URL(
'../../../assets/video/pano.webm',
import.meta.url
).toString();
video.src = '/assets/video/pano.webm';
await video.play();

const adapter = await navigator.gpu.requestAdapter();
Expand Down
5 changes: 1 addition & 4 deletions src/sample/videoUploadingWebCodecs/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
video.loop = true;
video.autoplay = true;
video.muted = true;
video.src = new URL(
'../../../assets/video/pano.webm',
import.meta.url
).toString();
video.src = '/assets/video/pano.webm';
await video.play();

const adapter = await navigator.gpu.requestAdapter();
Expand Down

0 comments on commit c8195de

Please sign in to comment.