How to create a static background image?
For default background:
scene = new THREE.Scene();
// ...
renderer = new THREE.WebGLRenderer( { antialias: false } );
renderer.setClearColor( scene.fog.color, 1 );
How to set a image for scene.fog
, or set opacity for clearcolor
?
An background image can be set by setting the
scene.background
attribute of theTHREE.Scene
:The aspect ratio of the image can be adjusted to the aspect ratio of the canvas like this:
See the code snippet:
If you are trying to set a static background image (even if you rotate your main camera, the background doesn't change), you have to create 2 scenes and 2 cameras.
The first scene will be composed of a basic plane on which a texture is applied.
The second scene will have all your objects.
Here is a code that would do it :
**Demo right here **
Hope this helps.
NOTE (2014/06/28): This code works with the latest release of Three.js: R67
this run:
thank you ))
I found yet another solution:
Use Texture loader to load a any image as texture and then apply that to scene like this:
Result:
Demo:
See the Pen Flat Earth Three.JS by Hitesh Sahu (@hiteshsahu) on CodePen.