 
         #TODO display message if Webgl required
         _renderer = new THREE.CanvasRenderer()
-      _renderer.setSize(w, h)
+
       _renderer.setClearColorHex(0xEEEEEE, 1.0)
       _renderer.clear()
+
+      updateViewportSize = (event) ->
+        w = container.clientWidth #window.innerWidth
+        h = container.clientHeight #window.innerHeight
+        _renderer.setSize(w, h)
+        _camera.aspect = w /  h
+        _camera.updateProjectionMatrix()
+        #_camerControls.handleResize()
+
+      updateViewportSize()
       container.appendChild(_renderer.domElement)
+      window.addEventListener( 'resize', updateViewportSize, false )
 
       # Lights
       #_scene.add( new THREE.AmbientLight( 0xFFFFFF ) );

          obj.position.y = pos.y
          obj.rotation.z = pos.a

      spawnCube = ->
        _cube = Cube(w / 50)
        _scene.add(_cube)


      _scene = new THREE.Scene()
      _areaBox = null
      _cube = null
      _cameraTargetObjId = null
      _camera = new THREE.PerspectiveCamera(75, 1, 1, 1000)

      #HACK to clean
      #see http://help.dottoro.com/ljorlllt.php
      _camera.position.z = 100
      _scene.add(_camera)

      #_cameraControls = new THREE.DragPanControls(_camera)

      _renderer = if webglDetector.webgl
        _renderer = new THREE.WebGLRenderer({
          antialias: true
          preserveDrawingBuffer: true # to allow screenshot
