3D(s)


  
  <script>
  
   //Makes a 3D coordinate
   //===================================================================
   function Point(x,y,z) {
    this.x = x;
    this.y = y;
    this.z = z;   //if omit z value, just make point 2D
    return this;
   }
   
   //Makes a 3D vector A(x,y,z) -> B(x,y,z)
   //===================================================================
   function Vector(a,b,c) {
    this.a = a;    //Point
    this.b = b;
    this.c = c;
    return this;
   }
   
  
   //The points are projected onto the plane defined by the viewport vector
   var viewport = new Vector(new Point(-100,-100,-100),new Point(100,10,-100), new Point(50,50));
   //var viewport = new Vector(new Point(-200,-200,-200),new Point(200,20,-200), new Point(100,100));
  
   //The camera's position is used for calculating focal length and where
   //the points should be plotted on the viewport
   var camera = new Point(0,-90,-200);
   //var camera = new Point(0,-190,-200);
  
   
   //Set new camera position and redraw scene
   //===================================================================
   function setCamera(x,y,z) {
    camera.x = x;
    camera.y = y;
    camera.z = z;
    init(); 
   }
  
   function setViewport(x,y) {
    viewport.a.x = x;
    viewport.a.y = x;
    viewport.b.x = y;
    viewport.b.y = y;
    //document.getElementById("back").style.width = y-x;
    //document.getElementById("back").style.height = y-x;
   }