Plane always black

前端 未结 1 1903
萌比男神i
萌比男神i 2020-12-12 07:02

I want to add a texture to my plane that repeats horizontal and vertical. The thing is, when I try to apply the texture, it is always black. I don\'t get any errors, and i a

相关标签:
1条回答
  • 2020-12-12 07:17

    TextureLoader.load() is an asynchronous method. That is why it has an onload argument.

    You are calling render() before the texture loads. One solution is to call render() in the loader callback.

    var loader = new THREE.TextureLoader();
    
    var texture = loader.load( 'myTexture.jpg', function ( texture ) {
    
        renderer.render( scene, camera );
    
    } );
    

    Another solution is to have an animation loop. But that is not required for static scenes.

    three.js r.78

    0 讨论(0)
提交回复
热议问题