three.js set background image

前端 未结 6 1907
深忆病人
深忆病人 2020-12-09 03:55

How to create a static background image?

For default background:

scene = new THREE.Scene();

// ...

renderer = new THREE.WebGLRenderer( { antialias:         


        
6条回答
  •  一整个雨季
    2020-12-09 04:57

    Use Texture loader to load a any image as texture and then apply that to scene like this:

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

    Result:

    Demo:

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

提交回复
热议问题