3D model does not respond to light in instance mode

Hi all,
When I load my blender-made object into a p5.js sketch in instance mode it does not interact with the light source, but appears as a silhouette. Is this a known limitation? Is there a workaround, assuming I need to run my code in instance mode? Thanks!!

let sketch = (p) => {

    let box

    p.preload = ()=> {
      box = p.loadModel('img/box.obj'); // I think this can be any file.

    //sketch setup
    p.setup = () => {
      p.createCanvas(window.innerWidth, window.innerHeight, p.WEBGL);

    p.draw = () => {

      p.rotateX(p.frameCount * 0.01);
      p.rotateY(p.frameCount * 0.01);
      p.pointLight(250, 250, 250, 0, 0, 50);



new p5(sketch);

With p5.js 1.6.0 your code works fine to load a known good model:

It could be an issue with the actual obj file you are using. If you don’t have good normals set for your vertices that could cause problems with lighting. Also make sure your light source isn’t inside the object. That could result in a lack of correct illumination.

1 Like