You are on page 1of 2

//007 3D Ellipse

var x1 = 0;
var x2 = 0;
var fillVal = 126;

function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
}

function draw(){
background(0);

var locY = (mouseY / height - 0.5) *(-2);


var locX = (mouseX / width - 0.5) *2;

if (mouseIsPressed){
pointLight(250, 250, 250, locX, locY, 0);
} else {
normalMaterial();
}

if (key === 'a'){


push();
rotateZ(frameCount * 0.01);
rotateX(frameCount * 0.01);
rotateY(frameCount * 0.01);
sphere((x2 * 40), x1, x2);
pop();
} else if (key === 's'){
push();
rotateZ(frameCount * 0.01);
rotateX(frameCount * 0.01);
rotateY(frameCount * 0.01);
box((x2 * 100), x1, x2);
pop();
} else if (key === 'd'){
push();
rotateZ(frameCount * 0.01);
rotateX(frameCount * 0.01);
rotateY(frameCount * 0.01);
torus(x1*10, x2*10);
pop();
} else if (key === 'f'){
push();
rotateZ(frameCount * 0.01);
rotateX(frameCount * 0.01);
rotateY(frameCount * 0.01);
plane(x1*100, x2*100);
pop();
} else if (key === 'g'){
push();
plane(x1 * 100, x2 * 100);
pop();
}
}

function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}

function mouseMoved() {
x1 = int(map(mouseX, 0, width, 2, 20));
x2 = int(map(mouseY, 0, height, 2, 20));
}

function keyTyped() {
if(key === '0') {
var fs = fullscreen();
fullscreen(!fs);
}
}

You might also like