Skip to content

Commit

Permalink
Revert "Move assets to public folder so the code is more idomatic"
Browse files Browse the repository at this point in the history
This reverts commit c8195de.
  • Loading branch information
greggman authored Oct 30, 2023
1 parent c8195de commit 3cc691b
Show file tree
Hide file tree
Showing 30 changed files with 98 additions and 33 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: 0 additions & 11 deletions public/examples/base.css

This file was deleted.

4 changes: 3 additions & 1 deletion src/sample/cameras/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
30 changes: 24 additions & 6 deletions src/sample/cubemap/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/sample/imageBlur/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
56 changes: 48 additions & 8 deletions src/sample/normalMap/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 3 additions & 1 deletion src/sample/particles/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/sample/renderBundles/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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({
Expand Down
4 changes: 3 additions & 1 deletion src/sample/texturedCube/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
5 changes: 4 additions & 1 deletion src/sample/videoUploading/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 4 additions & 1 deletion src/sample/videoUploadingWebCodecs/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 3cc691b

Please sign in to comment.