Search code examples
javascriptthree.jstexturesautodesk-forge

Texture not displayed on object Forge Three.js


I am trying to display a textured plane with Three.js. I'm working with Forge RCDB. At first, I managed to display the plane, but instead of being textured, it was completely black... I made some changes and now nothing is displayed anymore...

Here is my code :

render () {
    var viewer=NOP_VIEWER;
    var scene=viewer.impl.scene;
    var camera = viewer.autocamCamera;
    var renderer = viewer.impl.renderer();
    renderer.render( scene, camera ); 
  }

and in the function supposed to display the textured plane :

new THREE.TextureLoader(texture).load(texture, this.render);
tex.wrapS  = THREE.RepeatWrapping   //ClampToEdgeWrapping  //MirroredRepeatWrapping
tex.wrapT = THREE.RepeatWrapping    //ClampToEdgeWrapping   //MirroredRepeatWrapping 
tex.mapping = THREE.UVMapping

At the beginning I used loadTexture(). I managed to display my plane, but it was all black, and no texture was applied on it.

Then, I use THREE.TextureLoader().load(), in this case, I believe it is trying to find the image on localhost. The image is downloaded, I can see it on the console.

But now I get these errors :

Uncaught TypeError: scope.manager.itemStart is not a function

and :

Uncaught TypeError: renderer.render is not a function

Now the object is not displayed, even in black.

So I think this may be linked to render, but I don't understand how...


Solution

  • I found this, and it answers my question partially.

    Finally, I decided to keep THREE.ImageUtils.loadTexture(), and I replaced MeshLambertMaterial by MeshBasicMaterial.

    No need for render.