Skip to content

Commit 35eee4c

Browse files
committed
Move assets to public folder so the code is more idomatic
1 parent f2eaf77 commit 35eee4c

File tree

30 files changed

+33
-98
lines changed

30 files changed

+33
-98
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

public/examples/base.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
html, body {
2+
margin: 0;
3+
height: 100%;
4+
}
5+
#canvas {
6+
width: 100%;
7+
max-width: 600px;
8+
aspect-ratio: 1;
9+
display: block;
10+
margin: 0 auto;
11+
}

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/normalMap/main.ts

Lines changed: 8 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -91,96 +91,56 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
9191
// Fetch the image and upload it into a GPUTexture.
9292
let woodDiffuseTexture: GPUTexture;
9393
{
94-
const response = await fetch(
95-
new URL(
96-
'../../../assets/img/wood_diffuse.png',
97-
import.meta.url
98-
).toString()
99-
);
94+
const response = await fetch('/assets/img/wood_diffuse.png');
10095
const imageBitmap = await createImageBitmap(await response.blob());
10196
woodDiffuseTexture = createTextureFromImage(device, imageBitmap);
10297
}
10398

10499
let spiralNormalTexture: GPUTexture;
105100
{
106-
const response = await fetch(
107-
new URL(
108-
'../../../assets/img/spiral_normal.png',
109-
import.meta.url
110-
).toString()
111-
);
101+
const response = await fetch('/assets/img/spiral_normal.png');
112102
const imageBitmap = await createImageBitmap(await response.blob());
113103
spiralNormalTexture = createTextureFromImage(device, imageBitmap);
114104
}
115105

116106
let spiralHeightTexture: GPUTexture;
117107
{
118-
const response = await fetch(
119-
new URL(
120-
'../../../assets/img/spiral_height.png',
121-
import.meta.url
122-
).toString()
123-
);
108+
const response = await fetch('/assets/img/spiral_height.png');
124109
const imageBitmap = await createImageBitmap(await response.blob());
125110
spiralHeightTexture = createTextureFromImage(device, imageBitmap);
126111
}
127112

128113
let toyboxNormalTexture: GPUTexture;
129114
{
130-
const response = await fetch(
131-
new URL(
132-
'../../../assets/img/toybox_normal.png',
133-
import.meta.url
134-
).toString()
135-
);
115+
const response = await fetch('/assets/img/toybox_normal.png');
136116
const imageBitmap = await createImageBitmap(await response.blob());
137117
toyboxNormalTexture = createTextureFromImage(device, imageBitmap);
138118
}
139119

140120
let toyboxHeightTexture: GPUTexture;
141121
{
142-
const response = await fetch(
143-
new URL(
144-
'../../../assets/img/toybox_height.png',
145-
import.meta.url
146-
).toString()
147-
);
122+
const response = await fetch('/assets/img/toybox_height.png');
148123
const imageBitmap = await createImageBitmap(await response.blob());
149124
toyboxHeightTexture = createTextureFromImage(device, imageBitmap);
150125
}
151126

152127
let brickwallDiffuseTexture: GPUTexture;
153128
{
154-
const response = await fetch(
155-
new URL(
156-
'../../../assets/img/brickwall_diffuse.png',
157-
import.meta.url
158-
).toString()
159-
);
129+
const response = await fetch('/assets/img/brickwall_diffuse.png');
160130
const imageBitmap = await createImageBitmap(await response.blob());
161131
brickwallDiffuseTexture = createTextureFromImage(device, imageBitmap);
162132
}
163133

164134
let brickwallNormalTexture: GPUTexture;
165135
{
166-
const response = await fetch(
167-
new URL(
168-
'../../../assets/img/brickwall_normal.png',
169-
import.meta.url
170-
).toString()
171-
);
136+
const response = await fetch('/assets/img/brickwall_normal.png');
172137
const imageBitmap = await createImageBitmap(await response.blob());
173138
brickwallNormalTexture = createTextureFromImage(device, imageBitmap);
174139
}
175140

176141
let brickwallHeightTexture: GPUTexture;
177142
{
178-
const response = await fetch(
179-
new URL(
180-
'../../../assets/img/brickwall_height.png',
181-
import.meta.url
182-
).toString()
183-
);
143+
const response = await fetch('/assets/img/brickwall_height.png');
184144
const imageBitmap = await createImageBitmap(await response.blob());
185145
brickwallHeightTexture = createTextureFromImage(device, imageBitmap);
186146
}

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)