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

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

// 3D model in P5 

// heavily modified from:

// https://github.com/CodingTrain/website/tree/master/Tutorials/P5JS/18_p5.js_webgl/18.07_p5.js_loadModel
// Daniel Shiffman
// http://codingtra.in
// http://patreon.com/codingtrain
// Video: https://youtu.be/FUI7HEEz9B0


var angle = 0;           // rotate angle - changes every step
var img, train;
let shoe;
import { GLTFLoader } from 'https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/GLTFLoader.js';
const loader = new GLTFLoader();


function preload() 
{
   img = loadImage (  "/uploads/fuy3/town.png" );
    
//  train = loadModel('/uploads/codingtrain/train-corrected.obj');
  //town = loadModel('/uploads/fuy3/town.obj');
  loader.load('free_social_smileyemoji_pack_1.glb')
}


function setup() 
{
        //angle = AB.randomFloatAtoB ( 0, 20 );     // random start angle in radians - note PI is not defined until setup
//      angle = 8.3;                              // good angle for train close to camera for screenshot

  createCanvas(1600, 1600, WEBGL);
}


function draw() 
{
  // colors 
  // https://www.w3schools.com/colors/colors_names.asp
  background("LightBlue");
  scale(30); 


  rotateX(0);
  rotateY(0);
  rotateZ(0);
  
  texture(img);
  model(town);
  shoeMode(CENTER);
  
  

  
        // comment out this line to freeze it, e.g. for screenshot 
}



// play some audio
// http://soundbible.com/tags-train.html
// http://soundbible.com/2177-Steam-Train-Whistle.html
// http://soundbible.com/2164-Steam-Train.html