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 28, 2023
1 parent 7349a25 commit d783f79
Show file tree
Hide file tree
Showing 20 changed files with 14 additions and 50 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.
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
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 d783f79

Please sign in to comment.