0

I'm new to ThreeJS and I made this example which shows one of our model. http://petrie3dtesting.museums.ucl.ac.uk/3DFootCover/index.html

I created a Petrie3Dviewer and in the HTML page created a viewer object which takes as input an .obj and .mtl file. Strangely tho, the objects shows up BLACK and then when I start interacting the texture comes up. I tried everything I think: different browsers, making the texture smaller, different computers, nothing I get a random behaviour all the time. I tried on FIrefox, Chrome mainly. It seems that I need to force the rendering once the obj file is loaded but the OBJMTLLoader.js does not provide any event for it.

Really many thanks for the help. Best, GC

1 Answers1

0

You should call this.DoRender in your Animate function to render the frame.

this.Animate = function() { 
    this.orbitControls.update();
    this.Animate();
    requestAnimationFrame(this.Animate.bind(this));
}

At the moment you call your render function only when the user changes the perspective with the OrbitControls. And because your texture is loaded asynchronously it is not ready the first time when you render the frame.

shi
  • 480
  • 6
  • 10