Code viewer for World: Tutorial 18.4 (clone by Yi...

// Cloned by Yiming Fu on 30 Nov 2022 from World "Tutorial 18.4" by "Coding Train" project 
// Please leave this clone trail here.
 

// Daniel Shiffman
// http://codingtra.in
// http://patreon.com/codingtrain

// Video: https://youtu.be/O1mYw-3Wl_Q

let angle = 4;
let kitten;
let cam;

function preload() {
  kitten = loadImage('/uploads/codingtrain/kitten0.jpg');
  //kitten = loadImage('/uploads/starter/pacman.jpg'        );
}

function setup() {
  createCanvas( ABWorld.fullwidth(), ABWorld.fullheight(),  WEBGL );

  cam = createCapture(VIDEO);
  cam.size(320, 240);
  cam.hide();
}

function draw() {
  let dx = mouseX - width / 2;
  let dy = mouseY - height / 2;
  let v = createVector(dx, dy, 0);
  v.div(100);

  // ambientLight(255);
  directionalLight(255, 255, 255, v);
  background(175);
background("LightBlue");

  push();
  rotateX(angle);
  rotateY(angle * 0.3);
  rotateZ(angle * 1.2);

  noStroke();
  //ambientMaterial(0, 0, 255);
 // texture(cam);
 texture(kitten);
  //torus(100, 25);
  box(100);
  pop();

  translate(0, 100);
  rotateX(HALF_PI);
  ambientMaterial(255);
  plane(500, 500);

  angle += 0.03;
}