/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://p5js.sketchpad.cc/sp/pad/view/ro.xQ8IXABA9wC/rev.668
*
* authors:
* Kris Frajer
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
let vx = [];
let showAxis=true;
function setup() {
createCanvas(400,300, WEBGL);
one = createGraphics(300, 300);
//vx[0]=createVector(76,30);
//vx[1]=createVector(63,69);
//vx[2]=createVector(20,86);
//vx[3]=createVector(31,38);
vx[0]=createVector(0,-30,0);
vx[1]=createVector(60,-60,0);
vx[2]=createVector(0,-90,0);
vx[3]=createVector(-60,-120,0);
}
function draw(){
background(144);
//sides
one.clear();
//one.background(100, 50);
one.fill(255);
one.textAlign(CENTER);
one.textSize(64);
one.text('one', 150, 150);
//if (showAxis)
drawAxis(200,200,200);
translate(0,height/4,0);
push();
//texture(one)
stroke(0,0,250);
//quad(38, 31, 86, 20, 69, 63, 30, 76);
//quad(vx[0].x,vx[0].y,vx[0].z, vx[1].x,vx[1].y,vx[1].z,vx[2].x,vx[2].y,vx[2].z,vx[3].x,vx[3].y,vx[3].z);
plane(80);
pop();
//camera(0, map(mouseY,0,height,-50,50), map(mouseX,0,width,-50,300),
//0, 0, 0, //Center
//0, 1, 0); //Up vector
//REFERENCE: https://github.com/processing/p5.js/issues/1561
push();
texture(one);
translate(-150, -100, 0);
rotateZ(frameCount * 0.01);
rotateX(frameCount * 0.01);
rotateY(frameCount * 0.01);
box(70);
pop();
push();
texture(one);fill(255,0,0);
beginShape(TRIANGLE_STRIP);
vertex(100, 100, 0);
vertex(-100, 100, 0);
vertex(0, 0, 0);
endShape(CLOSE);
pop();
}
// -------------------------------------------------------
function drawAxis(len) {
drawAxis(len, len, len);
}
// -------------------------------------------------------
function drawAxis(len1, len2, len3) {
console.log("drawing axis");
push();
strokeWeight(3);
stroke(255, 0, 10); //RED
line(0, 0, 0, len1, 0, 0);
stroke(0, 255, 10); //GREEN
line(0, 0, 0, 0, len2, 0);
stroke(0, 0, 255); //BLUE
line(0, 0, 0, 0, 0, len3);
pop();
}