Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gradient clearColor in threejs

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 );

enter image description here

like image 672
mheavers Avatar asked Jan 24 '15 21:01

mheavers


1 Answers

I 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...

like image 61
Tim Gottgetreu Avatar answered Sep 20 '22 10:09

Tim Gottgetreu