title: setting the color of a cube with three.js
body: <p>I built a box in a function where its value is assigned to a variable called <code>box</code> then I tried to set the color of the node by pressing "w" invoking my box variable and defining it as another arbitrary variable.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;My first three.js app&lt;/title&gt;
  &lt;style&gt;
      body { margin: 0; }
      canvas { width: 100%; height: 100% }
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;script src="js/three.js"&gt;&lt;/script&gt;
  &lt;script&gt;
      var scene = new THREE.Scene();
      var camera = new THREE.PerspectiveCamera( 75, 
      window.innerWidth/window.innerHeight, 0.1, 1000 );
  
      var renderer = new THREE.WebGLRenderer();
      renderer.setSize( window.innerWidth, window.innerHeight );
      document.body.appendChild( renderer.domElement );
  
      camera.position.z = 5;
      renderer.render( scene, camera );
  
      var box= function() {
  
          this.root = new THREE.Object3D;
  }
      box.prototype.buildBox = function(){
  
          var geometry = new THREE.BoxGeometry( 0.2, 0.3, 0.1 );
  
  
          var material = new THREE.MeshLambertMaterial( {
          color: "white",  // CSS color names can be used!
          } );
  
          var a= new THREE.Mesh( geometry, material );
          this.root.add(a);
          return this.root;
  
  };
  this.scene.add(this.buildBox());
  document.addEventListener("keydown", onDocumentKeyDown, false);
  function onDocumentKeyDown(event) {
      var keyCode = event.which;
      this.Box = new box();
      var b = this.Box.buildBox();
      var keyCode = event.which;
      if (keyCode == 87)  {
          b.material.color.setHex (0xfff00);
  
  }
  
      render();
  &lt;/script&gt;
  </code></pre>
  
  <p></p>