xxxxxxxxxx
var pg;
var angle = 0;
var activeCamera = 0;
var canvas;
var img;
function preload(){
img = loadImage("https://marketplace.canva.com/MADFCeNIbe0/1/thumbnail_large/canva-wood-texture-MADFCeNIbe0.jpg");
}
function setup() {
frameRate(60);
smooth();
canvas = createCanvas(800,380);
pg = createGraphics(200,200,WEBGL);
pg.stroke(0);
pg.fill(255);
pg.pointLight(255,0,0,400,0,0); // Red (from the right)
pg.pointLight(0,255,0,0,400,0); // Green (gtom the bottom)
pg.pointLight(0,0,255,0,0,400); // Blue (from the front);
pg.ambientMaterial(255,255,255);
// pg.texture(img);
background(200);
textSize(16);
textAlign(CENTER);
stroke(255);
noFill();
rect(0,0,800,380);
}
function draw() {
canvas.position(windowWidth/2 - width/2, windowHeight/2 - height/2);
pg.background(0);
pg.ambientLight(20);
pg.push();
pg.rotateX(angle);
pg.rotateY(angle);
pg.rotateZ(angle);
updateModel();
pg.pop();
if(activeCamera == 0){
pg.camera(0, 0, 100, 0, 0, 0, 0, 1, 0);
image(pg,0,0,200,200,0,0,200,200);
rect(0,0,200,200);
text('B', 100, 300);
}
if(activeCamera==1){
pg.camera(0, 0, -100, 0, 0, 0, 0, 1, 0);
image(pg,200,0,200,200,0,0,200,200);
rect(200,0,200,200);
text('F', 300, 300);
}
if(activeCamera==2){
pg.camera(100, 0, 0, 0, 0, 0, 0, 0, 1);
image(pg,400,0,200,200,0,0,200,200);
rect(400,0,200,200);
text('R', 500, 300);
}
if(activeCamera==3){
pg.camera(-100, 0, 0, 0, 0, 0, 0, 0, 1);
image(pg,600,0,200,200,0,0,200,200);
rect(600,0,200,200);
text('L', 700, 300);
}
activeCamera++;
if(activeCamera>3) {
activeCamera = 0;
angle += 0.05;
}
}
function updateModel(){
pg.box(50);
}