xxxxxxxxxx
37
// draw a spinning cylinder
// with radius 20 and height 50
function setup() {
createCanvas(100, 100, WEBGL);
noStroke();
}
let ax = 0, ay = -20, d = 5;
let bx = 0, by = 20;
let cx = 0, cy = 0, dx =15, dy=40;
let z = 0;
function draw() {
background(200);
rotateX(frameCount * 0.01);
//rotateZ(frameCount * 0.01);
fill(200,0,0);
my_ball(ax,ay,z,d);
my_ball(bx,by,z,d);
fill(0,200,0);
my_pipe(cx,cy,z,dx,dy);
}
function my_ball(px,py,pz,d) {
push()
translate(px,py,pz); // center point
sphere(d,24,16);
pop();
}
function my_pipe(px,py,pz,dx,dy) {
push()
translate(px,py,pz); // center point
cylinder(dx, dy, 24,1,false,false);
pop();
}