Using textures in THREE.js

前端 未结 6 1881
遇见更好的自我
遇见更好的自我 2020-11-27 03:16

I am starting with THREE.js, and I am trying to draw a rectangle with a texture on it, lit by a single source of light. I think this is as simple as it gets (HTML omitted fo

6条回答
  •  春和景丽
    2020-11-27 03:41

    Use TextureLoader to load a image as texture and then simply apply that texture to scene background.

     new THREE.TextureLoader();
         loader.load('https://images.pexels.com/photos/1205301/pexels-photo-1205301.jpeg' , function(texture)
                    {
                     scene.background = texture;  
                    });
    

    Result:

    https://codepen.io/hiteshsahu/pen/jpGLpq?editors=0011

    See the Pen Flat Earth Three.JS by Hitesh Sahu (@hiteshsahu) on CodePen.

提交回复
热议问题