I can get a solid clearColor in threejs, but is there a way to achieve a gradient clearColor. Or some similar way to achieve a little more depth in my sky, maybe with lights?
Here's my relevant code:
renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setClearColor( 0x3dc800 );
var light = new THREE.HemisphereLight( 0xffffff, 0xeeeeee, 0.75 );
light.position.set( 0.5, 1, 0.75 );
scene.add( light );
scene.fog = new THREE.Fog( 0x4ff904, 0, 750 );
I can get a solid clearColor in threejs, but is there a way to achieve a gradient clearColor. Or some similar way to achieve a little more depth in my sky, maybe with lights?
Here's my relevant code:
renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setClearColor( 0x3dc800 );
var light = new THREE.HemisphereLight( 0xffffff, 0xeeeeee, 0.75 );
light.position.set( 0.5, 1, 0.75 );
scene.add( light );
scene.fog = new THREE.Fog( 0x4ff904, 0, 750 );
Share
Improve this question
edited Jan 25, 2015 at 6:01
user128511
asked Jan 24, 2015 at 21:13
mheaversmheavers
30.2k63 gold badges200 silver badges326 bronze badges
2
- take a look at threejs/examples/#webgl_shaders_sky – gaitat Commented Jan 25, 2015 at 0:54
- 1 wow - that's beautiful - I was going for something a bit more retro but I'll see if I can work with that. Thanks for the link. – mheavers Commented Jan 25, 2015 at 3:29
2 Answers
Reset to default 3I ran across this codepen:
http://codepen.io/billimarie/pen/mJLeBY
I take no credit, but it answers the question perfectly.
The relevant chunks are:
renderer = new THREE.CanvasRenderer( { alpha: true }); // gradient
withe the css:
body {
background-color: #1A8FCF;
margin: 0px;
overflow: hidden;
background-image: -webkit-gradient(#1A8FCF,#D1236A,#1A8FCF);
/* Safari 5.1, iOS 5.0-6.1, Chrome 10-25, Android 4.0-4.3 */
background-image: -webkit-linear-gradient(#1A8FCF,#D1236A,#1A8FCF);
/* Firefox 3.6 - 15 */
background-image: -moz-linear-gradient(#1A8FCF,#D1236A,#1A8FCF);
/* Opera 11.1 - 12 */
background-image: -o-linear-gradient(#1A8FCF,#D1236A,#1A8FCF);
/* Opera 15+, Chrome 25+, IE 10+, Firefox 16+, Safari 6.1+, iOS 7+, Android 4.4+ */
background-image: linear-gradient(#1A8FCF,#D1236A,#1A8FCF);
}
**Note, my own colors...
See Transparent background with three.js for transparent background rendering and then you can apply CSS gradients http://www.w3schools./Css/css3_gradients.asp however it won't move with your scene unless you get really tricky.