Skip to content

Commit 79e61fc

Browse files
committed
Improve project template
1 parent 086b780 commit 79e61fc

3 files changed

Lines changed: 46 additions & 6 deletions

File tree

scripts/template/src/main.ts

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,52 @@
1+
// You can grab the text of other files like so. Note the `?raw` at the end.
2+
// import exampleShader from "./exampleShader.wgsl?raw"
3+
4+
interface Params {
5+
navigator: Navigator;
6+
canvas: HTMLCanvasElement;
7+
context: GPUCanvasContext;
8+
/**
9+
* A logger for sending messages to the UI log
10+
*/
11+
logger: Record<
12+
"trace" | "debug" | "info" | "warn" | "error",
13+
(msg: string) => void
14+
>;
15+
/**
16+
* Contains the text of any other files in the folder given to Jacket
17+
*
18+
* More useful if you aren't using a bundler.
19+
*/
20+
files: Record<string, string>;
21+
}
22+
23+
/**
24+
* The entry point exposed to Jacket.
25+
* You typically put your one-time setup code here, and return a closure to draw/compute repeatedly.
26+
*
27+
* > It is important that you use the {@link Navigator} and {@link GPUCanvasContext} supplied in the params,
28+
* > rather than obtaining them by normal means. These objects are proxied in order to track execution.
29+
*
30+
* @param params Inputs to your program from Jacket
31+
* @returns A function called by Jacket repeatedly, once per frame
32+
*
33+
* ## Useful links
34+
* - https://webgpufundamentals.org/
35+
* - https://developer.mozilla.org/en-US/docs/Web/API/WebGPU_API
36+
*
37+
* ## WebGPU diagrams
38+
* ### Draw Process
39+
* ![WebGPU draw diagram](./webgpu-draw-diagram.svg)
40+
* ### Compute Process
41+
* ![WebGPU simple compute diagram](./webgpu-simple-compute-diagram.svg)
42+
*/
143
export async function program({
244
navigator,
345
canvas,
46+
context,
447
files,
548
logger,
6-
}: {
7-
navigator: Navigator;
8-
canvas: HTMLCanvasElement;
9-
logger: Record<string, (msg: string) => void>;
10-
files: Record<string, string>;
11-
}) {
49+
}: Params) {
1250
const frame = async () => {};
1351
return frame;
1452
}

scripts/template/src/webgpu-draw-diagram.svg

Lines changed: 1 addition & 0 deletions
Loading

scripts/template/src/webgpu-simple-compute-diagram.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)