javascript - When processing Java mode convert to Java script mode, my 3D object doesn't show -


i have problem when upload sketch website.

i write processing program 3d guiding library.this code.

  //camera variables     float x,y,z;     float tx,ty,tz;     float rotx,roty;     float mx, my;     float framecounter;     float xcomp, zcomp;     float angle;    //movement variables     int movex;     int movez;     float vy;     boolean canjump;     boolean moveup,movedown,moveleft,moveright;       //check input     int m =0;  //constants   int ground = 0;   int totalboxes = 100;   int standheight = 100;   int dragmotionconstant = 10;   int pushmotionconstant = 100;   int movementspeed = 50;    //bigger number = slower   float sensitivity = 15;      //bigger number = slower   int stillbox = 100;        //center of pov, mouse must stillbox away center move   float cambuffer = 10;   int cameradistance = 1000;  //distance camera camera target in lookmode... 8?  //options   int lookmode = 8;   int spotlightmode = 4;   int cameramode = 1;   int movemode = 2;  void setup(){   size(800,600,p3d);   nostroke();    //dwa(#edede8);    //camera initialization    //default   x = -28;   y = height/2;     y-= standheight;   z = -4830;   tx = width/2;   ty = height/2;   tz = 0;   rotx = 0;   roty = 0;   xcomp = tx - x;   zcomp = tz - z;   angle = 0;    //movement initialization   movex = 0;   movex = 0;   moveup = false;   movedown = false;   moveleft = false;   moveright = false;     canjump = true;   vy = 0;    }   void draw(){   if(z<-5000)   z=-5000;    if(z>9700)   z=9700;      //println(x,y,z ,mousex , mousey ,tx ,ty,tz);   //update frame   background(0);   lights();     if(m==1)   {     //rotatey(0.5);  fill(#eaff0f);   textsize(50);   text("menu", x-100, y, z+300);    // rotatey(0.5);           //the point     pushmatrix();           fill(#fc1919);      translate(-28,300,4000);     box(10, 20000, -10);     popmatrix();        //the point    }      if(spotlightmode == 0)     lights();   else if(spotlightmode == 1)     spotlight(255,255,255,x,y-standheight,z,tx,ty,tz,pi,1);   else if(spotlightmode == 2)     spotlight(255,255,255,x,y-standheight-200,z,x+100,y+100,z,framecounter/10,1);   else if(spotlightmode == 3)     spotlight(255,255,255,width/2,height/2-1000,0,width/2,height/2,0,pi,1);   else if(spotlightmode == 4)   {     pointlight(255,255,255,x,y,z);    }      /*     for(int i=1;i<=7;i++)     {     spotlight(255, 255, 255, -28, 2000, -5500+i*1875, 1, 1, 1, 360, 1);     }*/     //-5500 9500s      //back wall  pushmatrix();       fill(255);   translate(-28,300,-5500);     box(15000, 5000, -100);     popmatrix();     //back wall        //fount wall  pushmatrix();       fill(255);   translate(-28,300,10500);     box(15000, 5000, -100);     popmatrix();     //fount wall       //l1   bookshielf(800,-4000,7,1);   bookshielf(1000,-4000,7,1);   bookshielf(1200,-4000,7,1);   bookshielf(1400,-4000,7,1);    cameraupdate();   locationupdate();   jumpmanager(10);      //camera mode 1 - original   if(cameramode == 1)     camera(x,y,z,tx,ty,tz,0,1,0);    //camera mode 2 - matrix'd  /* if(cameramode == 2){     begincamera();       camera();       translate(x,y,z);       translate(0,2*-standheight,0);        rotatex(roty/100.0); //this seems work o.o       rotatey(-rotx/100.0);       //rotatex(rotx/100.0);     endcamera();   }*/    //framecounter++;    }   void cylinder(float w, float h, int sides) {   float angle;   float[] x = new float[sides+1];   float[] z = new float[sides+1];  translate(0,100,-500);   //get x , z position on circle sides   for(int i=0; < x.length; i++){     angle = two_pi / (sides) * i;     x[i] = sin(angle) * w;     z[i] = cos(angle) * w;   }    //draw top of cylinder   beginshape(triangle_fan);    vertex(0,   -h/2,    0);    for(int i=0; < x.length; i++){     vertex(x[i], -h/2, z[i]);   }    endshape();    //draw center of cylinder   beginshape(quad_strip);     for(int i=0; < x.length; i++){     vertex(x[i], -h/2, z[i]);     vertex(x[i], h/2, z[i]);   }    endshape();    //draw bottom of cylinder   beginshape(triangle_fan);     vertex(0,   h/2,    0);    for(int i=0; < x.length; i++){     vertex(x[i], h/2, z[i]);   }    endshape(); }  public void bookshielf(int thex ,int thez ,int theheight ,int therotate) {   fill(#938056);    if(theheight==7)   {     if(therotate==1)     {     //left   pushmatrix();    translate(thex,0,thez);     box(20, 500, -100);     popmatrix();      //right      pushmatrix();   translate(thex-200,0,thez);     box(20, 500, -100);     popmatrix();      //back      pushmatrix();        translate(thex-100,0,thez+40);     box(220, 500, -30);     popmatrix();      //middle side     for(int i=1;i<7;i++)     {      pushmatrix();        translate(thex-100,-250+71.5*i,thez-10);     box(220, 5, -100);     popmatrix();     }      //top       pushmatrix();        translate(thex-100,250,thez);     box(220, 10, -100);     popmatrix();      //block       pushmatrix();        translate(thex-100,-250,thez);     box(220, 10, -100);     popmatrix();    }    if(therotate==2)   {      //left   pushmatrix();    translate(thex,0,thez);     box(20, 500, -100);     popmatrix();      //right      pushmatrix();   translate(thex-200,0,thez);     box(20, 500, -100);     popmatrix();      //back      pushmatrix();        translate(thex-100,0,thez-40);     box(220, 500, -30);     popmatrix();      //middle side     for(int i=1;i<7;i++)     {      pushmatrix();        translate(thex-100,-250+71.5*i,thez+10);     box(220, 5, -100);     popmatrix();     }      //top       pushmatrix();        translate(thex-100,250,thez);     box(220, 10, -100);     popmatrix();      //block       pushmatrix();        translate(thex-100,-250,thez);     box(220, 10, -100);     popmatrix();    } } }    public void cameraupdate(){   ty=constrain(dragmotionconstant, -100000, 500000);   //drag-motion   if (lookmode == 1){     if(pmousex > mousex)       tx += dragmotionconstant;     else if (pmousex < mousex)       tx -= dragmotionconstant;      if(pmousey > mousey)       ty -= dragmotionconstant/1.5;     else if (pmousey < mousey)       ty += dragmotionconstant/1.5;   }     //push-motion   else if (lookmode == 2){     if (mousex > (width/2+pushmotionconstant))       tx += dragmotionconstant;     else if (mousex < (width/2-pushmotionconstant))       tx -= dragmotionconstant;     if (mousey > (height/2+pushmotionconstant))       ty += dragmotionconstant;     else if (mousey < (height/2-pushmotionconstant))       ty -= dragmotionconstant;   }    //push-motion v2 (hopefully improved!)   else if (lookmode == 3){     int diffx = mousex - width/2;     int diffy = mousey - width/2;      if (abs(diffx) > pushmotionconstant)       tx += diffx/25;     if (abs(diffy) > pushmotionconstant)       ty += diffy/25;   }    //push motion v3 (for camera-mode 2)   else if (lookmode == 4){     int diffx = mousex - width/2;     int diffy = mousey - width/2;   //println(diffx);   if (abs(diffx) > pushmotionconstant)       rotx += diffx/100;     if (abs(diffy) > pushmotionconstant)       roty += diffy/100;//diffy/100;   }    //push motion v4.1 (because crashed , lost v4.0 t.t   //designed work in cohesion movement mode 2   else if (lookmode == 5){     int diffx = mousex - width/2;     int diffy = mousey - width/2;      if(abs(diffx) > stillbox){       xcomp = tx - x;       zcomp = tz - z;       angle = degrees(atan(xcomp/zcomp));        //---------debug stuff goes here----------       //println("tx:    " + tx);       //println("tz:    " + tz);      // println("xc:    " + xcomp);      // println("zc:    " + zcomp);      // println("angle: " +angle);       //--------------------------------------*/        if (angle < 45 && angle > -45 && zcomp < 0)         tx += diffx/sensitivity;       else if (angle < 45 && angle > -45 && zcomp > 0)         tx -= diffx/sensitivity;        //left sector       else if (angle > 45 && angle < 90 && xcomp < 0 && zcomp < 0)         tz -= diffx/sensitivity;       else if (angle >-90 && angle <-45 && xcomp < 0 && zcomp > 0)         tz -= diffx/sensitivity;        //right sector       else if (angle <-45 && angle >-90)         tz += diffx/sensitivity;       else if (angle < 90 && angle > 45 && xcomp > 0 && zcomp > 0)         tz += diffx/sensitivity;     }      if (abs(diffy) > stillbox)       ty += diffy/(sensitivity/1.5);   }    //lookmode 4.2   //using more proper unit circle.   else if (lookmode == 6){     int diffx = mousex - width/2;     int diffy = mousey - width/2;      if(abs(diffx) > stillbox){       xcomp = tx - x;       zcomp = tz - z;       angle = correctangle(xcomp,zcomp);        //---------debug stuff goes here----------      // println("tx:    " + tx);      // println("tz:    " + tz);      // println("xc:    " + xcomp);      /// println("zc:    " + zcomp);      /// println("angle: " +angle);       //--------------------------------------*/        //looking 'forwards'       if ((angle >= 0 && angle < 45) || (angle > 315 && angle < 360))         tx += diffx/sensitivity;        //looking 'left'       else if (angle > 45 && angle < 135)         tz += diffx/sensitivity;        //looking 'back'       else if (angle > 135 && angle < 225)         tx -= diffx/sensitivity;        //looking 'right'       else if (angle > 225 && angle < 315)         tz -= diffx/sensitivity;      }      if (abs(diffy) > stillbox)       ty += diffy/(sensitivity/1.5);   }    //lookmode 7, trying rid of slowdown in corners sorta-buffer thing   else if (lookmode == 7){     int diffx = mousex - width/2;     int diffy = mousey - width/2;      if(abs(diffx) > stillbox){       xcomp = tx - x;       zcomp = tz - z;       angle = correctangle(xcomp,zcomp);        //---------debug stuff goes here----------      // println("tx:    " + tx);      // println("tz:    " + tz);      // println("xc:    " + xcomp);      // println("zc:    " + zcomp);      // println("angle: " +angle);       //--------------------------------------*/        //looking 'forwards'       if ((angle >= 0-cambuffer && angle < 45+cambuffer) || (angle > 315-cambuffer && angle < 360+cambuffer))         tx += diffx/sensitivity;        //looking 'left'       else if (angle > 45-cambuffer && angle < 135+cambuffer)         tz += diffx/sensitivity;        //looking 'back'       else if (angle > 135-cambuffer && angle < 225+cambuffer)         tx -= diffx/sensitivity;        //looking 'right'       else if (angle > 225-cambuffer && angle < 315+cambuffer)         tz -= diffx/sensitivity;      }      if (abs(diffy) > stillbox)       ty += diffy/(sensitivity/1.5);   }    else if (lookmode == 8){     int diffx = mousex - width/2;     int diffy = mousey - width/2;      if(abs(diffx) > stillbox){       xcomp = tx - x;       zcomp = tz - z;       angle = correctangle(xcomp,zcomp);        angle+= diffx/(sensitivity*10);        if(angle < 0)         angle += 360;       else if (angle >= 360)         angle -= 360;        float newxcomp = cameradistance * sin(radians(angle));       float newzcomp = cameradistance * cos(radians(angle));        tx = newxcomp + x;       tz = -newzcomp + z;        //---------debug stuff goes here----------       /*println("tx:    " + tx);       println("tz:    " + tz);       println("xc:    " + xcomp);       println("newxc: " + newxcomp);       println("zc:    " + zcomp);       println("newzc: " + newzcomp);       println("angle: " +angle);*/       //--------------------------------------*/      }      if (abs(diffy) > stillbox)       ty += diffy/(sensitivity/1.5);   }   }  public void locationupdate(){    /*old method==================================   if(keypressed){     if (keycode == || key == 'w'){       z-=10;       tz-=10;     }     else if (keycode == down || key == 's'){       tz+=10;       z+=10;     }     else if (keycode == left || key == 'a' ){       tx-=10;       x-=10;     }     else if (keycode == right || key == 'd'){       tx+=10;       x+=10;     }   }   ============================================*/    //apply movement   if(movemode == 1){     z += movez;     tz += movez;     x += movex;     tx += movex;   }   else if(movemode == 2){     if(moveup){       z += zcomp/movementspeed;       tz+= zcomp/movementspeed;       x += xcomp/movementspeed;       tx+= xcomp/movementspeed;     }     else if(movedown){       z -= zcomp/movementspeed;       tz-= zcomp/movementspeed;       x -= xcomp/movementspeed;       tx-= xcomp/movementspeed;     }     if (moveright){       z += xcomp/movementspeed;        tz+= xcomp/movementspeed;       x -= zcomp/movementspeed;       tx-= zcomp/movementspeed;     }     if (moveleft){       z -= xcomp/movementspeed;        tz-= xcomp/movementspeed;       x += zcomp/movementspeed;       tx+= zcomp/movementspeed;     }    }   //new method uses keypressed() , keyreleased()   // scroll down!  }  public void jumpmanager(int magnitude){   /*   if(keypressed && key == ' ' && canjump){     vy -= magnitude;     if(vy < -20)       canjump = false;   }   else*/ if (y < ground+standheight)     vy ++;   else if (y >= ground+standheight){     vy = 0;     y = ground + standheight;   }    if((!canjump) && (!keypressed)){     //println("jump reset!");     canjump = true;   }    y += vy; }      public void keypressed(){   if(keycode == || key == 'w'){     movez = -10;     moveup = true;   }    else if(keycode == down || key == 's'){     movez = 10;     movedown = true;   }    else if(keycode == left || key == 'a'){     movex = -10;     moveleft = true;   }    else if(keycode == right || key == 'd'){     movex = 10;     moveright = true;   }      if(key == 'm' && m==1){      m=0;   }   else if(key == 'm' && m==0){      if(key == '1')      {       }     rotatey(180);      fill(#eaff0f);   textsize(50);   text("menu", x-100, y, z+300);      m=1;     }   }  public void keyreleased(){   if(keycode == || key == 'w'){     moveup = false;     movez = 0;   }   else if(keycode == down || key == 's'){     movedown = false;     movez = 0;   }    else if(keycode == left || key == 'a'){     moveleft = false;     movex = 0;   }    else if(keycode == right || key == 'd'){     moveright = false;     movex = 0;   }   }  void mousepressed() {   }     public float correctangle(float xc, float zc){   float newangle = -degrees(atan(xc/zc));   if (xcomp > 0 && zcomp > 0)     newangle = (90 + newangle)+90;   else if (xcomp < 0 && zcomp > 0)     newangle = newangle + 180;   else if (xcomp < 0 && zcomp < 0)     newangle = (90+ newangle) + 270;   return newangle; } 

people can use first person view walk library.it fine in java mode,but when put in java script mode,the view has problem.so , part of code has problems can not run on website? thank much.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -