xxxxxxxxxx
31
let m;
function setup() {
createCanvas(400, 400, WEBGL);
m = createGraphics(400, 400, WEBGL);
}
function draw() {
if (mouseIsPressed) {
background(220);
push();
rotateX(0.3);
rotateY(0.2);
fill(0, 255, 0);
box(20);
translate(20, 0);
box(20);
pop();
} else {
m.background(220);
m.push();
m.rotateX(0.3);
m.rotateY(0.2);
m.fill(0, 255, 255);
m.box(20);
m.translate(20, 0);
m.box(20);
m.pop();
image(m, -200, -200);
}
}