ThreeJS - How can I apply an environment map to an imported obj model?

后端 未结 1 1525
失恋的感觉
失恋的感觉 2021-01-24 09:15

EDIT: I have come across a solution on this post -- How to assign a material to ColladaLoader or OBJLoader. I used the following code which achieved the effect

相关标签:
1条回答
  • 2021-01-24 09:57

    You can add an environment map to the existing materials of your OBJ model using a pattern like this one:

        var loader = new THREE.OBJLoader();
    
        loader.load( 'myModel.obj', function ( object ) {
    
          object.traverse( function ( child ) {
    
              if ( child instanceof THREE.Mesh ) {
    
                  child.material.envMap = myEnvironmentMap;
                  // add any other properties you want here. check the docs.
    
              }
    
          } );
    
          scene.add( object );
    
        } );
    
    0 讨论(0)
提交回复
热议问题