@group(0) @binding(0) var positions : array>; @group(0) @binding(1) var velocities : array>; @group(0) @binding(2) var deltaTime : f32; @group(0) @binding(3) var aspectRatio : f32; @group(0) @binding(4) var mousePos : vec2; @group(0) @binding(5) var hoverRadius : f32; @group(0) @binding(6) var states : array; @compute @workgroup_size(64) fn main(@builtin(global_invocation_id) id : vec3) { let index = id.x; let gravity = vec3(0.0, -29.61, 0.0); var pos = positions[index]; var vel = velocities[index]; // Apply gravity to velocity // Integrate position let dist = distance(vec2(pos.x*aspectRatio, pos.y), mousePos); var newPos = pos.xyz; if (dist < hoverRadius) { states[index] = 1; } if ( states[index] == 1 ) { let newVel = vel.xyz + gravity * deltaTime; newPos = pos.xyz + newVel * 0.001; velocities[index] = vec4(newVel, vel.w); positions[index] = vec4(newPos, pos.w); } else { let newVel = vel.xyz; newPos = pos.xyz + newVel * 0.001; velocities[index] = vec4(newVel, vel.w); positions[index] = vec4(newPos, pos.w); } // Store updated values }