dimanche 21 avril 2019

P5 WebGL OBJ disappears, seemingly randomly?

I'm using a P5 canvas to implement a rotating 3d object at the top of my website. I know the code works because I essentially copy and pasted and then modified it slightly from another website I built; when I initially tested it, it worked fine. However, when I added ambient lights from P5's 3D library, it broke. The OBJ disappeared. I deleted the code for the lights and reloaded the page, but the OBJ was still gone. I tried reverting to older versions and I just can't seem to get the OBJ to come back. I'm baffled as to what I can do.

Here's my code:

let angle = 0;


function setup() {

  if (windowWidth > 1000) {
  var myCanvas = createCanvas(120, 120, WEBGL);
  myCanvas.parent("logo");
  model = loadModel('snake.obj');

  }

  else {
  var myCanvas = createCanvas(400, 200, WEBGL);
  myCanvas.parent("logo");
  model = loadModel('snake.obj');
  }


}

function draw() {
//  background rgba(256, 256, 256, 0);

  rotateX(3)
  rotateY(90 + angle);
  camera(0, 0, 0, 0, 0, 0, 0, 0, 0);
  translate(0, 0, 0);

  model(cade);
  angle += .01;




Aucun commentaire:

Enregistrer un commentaire