Skip to content

Commit d783f79

Browse files
committed
Move assets to public folder so the code is more idomatic
1 parent 7349a25 commit d783f79

File tree

20 files changed

+14
-50
lines changed

20 files changed

+14
-50
lines changed
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.

src/sample/cameras/main.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
128128
// Fetch the image and upload it into a GPUTexture.
129129
let cubeTexture: GPUTexture;
130130
{
131-
const response = await fetch(
132-
new URL('../../../assets/img/Di-3d.png', import.meta.url).toString()
133-
);
131+
const response = await fetch('/assets/img/Di-3d.png');
134132
const imageBitmap = await createImageBitmap(await response.blob());
135133

136134
cubeTexture = device.createTexture({

src/sample/cubemap/main.ts

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -107,30 +107,12 @@ const init: SampleInit = async ({ canvas, pageState }) => {
107107
{
108108
// The order of the array layers is [+X, -X, +Y, -Y, +Z, -Z]
109109
const imgSrcs = [
110-
new URL(
111-
`../../../assets/img/cubemap/posx.jpg`,
112-
import.meta.url
113-
).toString(),
114-
new URL(
115-
`../../../assets/img/cubemap/negx.jpg`,
116-
import.meta.url
117-
).toString(),
118-
new URL(
119-
`../../../assets/img/cubemap/posy.jpg`,
120-
import.meta.url
121-
).toString(),
122-
new URL(
123-
`../../../assets/img/cubemap/negy.jpg`,
124-
import.meta.url
125-
).toString(),
126-
new URL(
127-
`../../../assets/img/cubemap/posz.jpg`,
128-
import.meta.url
129-
).toString(),
130-
new URL(
131-
`../../../assets/img/cubemap/negz.jpg`,
132-
import.meta.url
133-
).toString(),
110+
'/assets/img/cubemap/posx.jpg',
111+
'/assets/img/cubemap/negx.jpg',
112+
'/assets/img/cubemap/posy.jpg',
113+
'/assets/img/cubemap/negy.jpg',
114+
'/assets/img/cubemap/posz.jpg',
115+
'/assets/img/cubemap/negz.jpg',
134116
];
135117
const promises = imgSrcs.map(async (src) => {
136118
const response = await fetch(src);

src/sample/imageBlur/main.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
6464
minFilter: 'linear',
6565
});
6666

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

7270
const [srcWidth, srcHeight] = [imageBitmap.width, imageBitmap.height];

src/sample/particles/main.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
185185
let textureHeight = 1;
186186
let numMipLevels = 1;
187187
{
188-
const response = await fetch(
189-
new URL('../../../assets/img/webgpu.png', import.meta.url).toString()
190-
);
188+
const response = await fetch('/assets/img/webgpu.png');
191189
const imageBitmap = await createImageBitmap(await response.blob());
192190

193191
// Calculate number of mip levels required to generate the probability map

src/sample/renderBundles/main.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ const init: SampleInit = async ({ canvas, pageState, gui, stats }) => {
118118
// Fetch the images and upload them into a GPUTexture.
119119
let planetTexture: GPUTexture;
120120
{
121-
const response = await fetch(
122-
new URL('../../../assets/img/saturn.jpg', import.meta.url).toString()
123-
);
121+
const response = await fetch('/assets/img/saturn.jpg');
124122
const imageBitmap = await createImageBitmap(await response.blob());
125123

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

141139
let moonTexture: GPUTexture;
142140
{
143-
const response = await fetch(
144-
new URL('../../../assets/img/moon.jpg', import.meta.url).toString()
145-
);
141+
const response = await fetch('/assets/img/moon.jpg');
146142
const imageBitmap = await createImageBitmap(await response.blob());
147143

148144
moonTexture = device.createTexture({

src/sample/texturedCube/main.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ const init: SampleInit = async ({ canvas, pageState }) => {
110110
// Fetch the image and upload it into a GPUTexture.
111111
let cubeTexture: GPUTexture;
112112
{
113-
const response = await fetch(
114-
new URL('../../../assets/img/Di-3d.png', import.meta.url).toString()
115-
);
113+
const response = await fetch('/assets/img/Di-3d.png');
116114
const imageBitmap = await createImageBitmap(await response.blob());
117115

118116
cubeTexture = device.createTexture({

src/sample/videoUploading/main.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
99
video.loop = true;
1010
video.autoplay = true;
1111
video.muted = true;
12-
video.src = new URL(
13-
'../../../assets/video/pano.webm',
14-
import.meta.url
15-
).toString();
12+
video.src = '/assets/video/pano.webm';
1613
await video.play();
1714

1815
const adapter = await navigator.gpu.requestAdapter();

src/sample/videoUploadingWebCodecs/main.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
99
video.loop = true;
1010
video.autoplay = true;
1111
video.muted = true;
12-
video.src = new URL(
13-
'../../../assets/video/pano.webm',
14-
import.meta.url
15-
).toString();
12+
video.src = '/assets/video/pano.webm';
1613
await video.play();
1714

1815
const adapter = await navigator.gpu.requestAdapter();

0 commit comments

Comments
 (0)