Skip to content

Commit

Permalink
[ui] Add ring rotation speed control.
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoppex committed Oct 8, 2024
1 parent b1a7c7b commit 0d85c21
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
time: f32,
unionSmoothness: f32,
ringVariation: f32,
control2: f32,
rotationSpeed: f32,
};
@group(2) @binding(0) var<uniform> uAttributes: DensityUniformAttribute;
Expand Down Expand Up @@ -98,7 +98,7 @@
d += opIntersection(dot(helix, hs * ws.xz), d);
p = ws.yzx;
// p = rotateAxisAngle(vec3f(1, 1, 0), 0.5 * uAttributes.time) * p;
p = rotateAxisAngle(vec3f(1, 1, 1), uAttributes.rotationSpeed * uAttributes.time) * p;
d = opSmoothUnion(
d,
Expand Down Expand Up @@ -223,9 +223,11 @@
const uiParams = {
unionSmoothness: 0.5,
ringVariation: 0.0,
rotationSpeed: 0.0,
};
pane.addBinding(uiParams, 'unionSmoothness', {min:0.0, max:0.95});
pane.addBinding(uiParams, 'ringVariation', {min:0, max:2.0});
pane.addBinding(uiParams, 'ringVariation', {min:0.0, max:2.0});
pane.addBinding(uiParams, 'rotationSpeed', {min:0.0, max:1.0});

// -- Density function bind group & uniform.

Expand Down Expand Up @@ -705,12 +707,14 @@
function frame() {
const tick = Date.now() / 1000.0;
const dt = tick - lastTick;
const elapsedTime = tick - firstTick;
lastTick = tick;

const densityAtttribs = new Float32Array([
tick - firstTick,
elapsedTime,
uiParams.unionSmoothness,
uiParams.ringVariation,
uiParams.rotationSpeed,
]);
device.queue.writeBuffer(density_uniformBuffer, 0, densityAtttribs.buffer, densityAtttribs.byteOffset, densityAtttribs.byteLength);

Expand Down

0 comments on commit 0d85c21

Please sign in to comment.