LordXido commited on
Commit
f0ea7a1
·
verified ·
1 Parent(s): 19de9b4

Update world.wgsl

Browse files
Files changed (1) hide show
  1. world.wgsl +13 -28
world.wgsl CHANGED
@@ -1,29 +1,14 @@
1
- export class World {
2
- constructor(canvas, gpu) {
3
- this.ctx = canvas.getContext("2d");
4
- this.gpu = gpu;
5
- this.t = 0;
6
- }
7
-
8
- update(dt) {
9
- this.t += dt;
10
- }
11
-
12
- apply(cmd) {
13
- // placeholder for language → world binding
14
- }
15
-
16
- render() {
17
- const w = this.ctx.canvas.width = this.ctx.canvas.clientWidth;
18
- const h = this.ctx.canvas.height = this.ctx.canvas.clientHeight;
19
-
20
- this.ctx.fillStyle = "#000";
21
- this.ctx.fillRect(0, 0, w, h);
22
-
23
- this.ctx.fillStyle = "#00ffd0";
24
- const r = 40 + Math.sin(this.t) * 20;
25
- this.ctx.beginPath();
26
- this.ctx.arc(w / 2, h / 2, r, 0, Math.PI * 2);
27
- this.ctx.fill();
28
- }
29
  }
 
1
+ @group(0) @binding(0)
2
+ var<storage, read_write> field : array<f32>;
3
+
4
+ @compute @workgroup_size(64)
5
+ fn main(@builtin(global_invocation_id) gid : vec3<u32>) {
6
+ let i = gid.x;
7
+ if (i >= arrayLength(&field)) {
8
+ return;
9
+ }
10
+
11
+ // Simple oscillatory field evolution
12
+ let t = f32(i) * 0.01;
13
+ field[i] = sin(t) * 0.5 + 0.5;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  }