Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add stroke to preview
  • Loading branch information
lukeplowden committed Jun 16, 2025
commit 4dc493dbe6ae986c5ef738cef6119c2986f5b7f1
49 changes: 40 additions & 9 deletions preview/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,52 @@
const sketch = function (p) {
let fbo;
let sh;
let ssh;

p.setup = async function () {
await p.createCanvas(400, 400, p.WEBGPU);
sh = p.baseMaterialShader().modify({
uniforms: {
'f32 time': () => p.millis(),
},
'Vertex getWorldInputs': `(inputs: Vertex) {
var result = inputs;
result.position.y += 40.0 * sin(uniforms.time * 0.01);
return result;
}`,
})
ssh = p.baseStrokeShader().modify({
uniforms: {
'f32 time': () => p.millis(),
},
'StrokeVertex getWorldInputs': `(inputs: StrokeVertex) {
var result = inputs;
result.position.y += 40.0 * sin(uniforms.time * 0.01);
return result;
}`,
})
};
p.disableFriendlyErrors = true;

p.draw = function () {
p.orbitControl()
const t = p.millis() * 0.008;
p.background(0);
// p.noStroke();
for (const [i, c] of ['red'].entries()) {
p.stroke(0);
p.strokeWeight(2);
p.push();
p.background(200);
p.shader(sh);
p.strokeShader(ssh)
p.ambientLight(50);
p.directionalLight(100, 100, 100, 0, 1, -1);
p.pointLight(155, 155, 155, 0, -200, 500);
p.specularMaterial(255);
p.shininess(300);
p.stroke('white')
for (const [i, c] of ['red', 'lime', 'blue'].entries()) {
p.push();
p.fill(c);
p.sphere(60);
p.translate(
p.width/3 * p.sin(t + i * Math.E),
0, //p.width/3 * p.sin(t * 0.9 + i * Math.E + 0.2),
p.width/3 * p.sin(t * 1.2 + i * Math.E + 0.3),
)
p.sphere(30);
p.pop();
}
};
Expand Down