   
   #
   camera = new THREE.PerspectiveCamera(27, window.innerWidth / window.innerHeight, 1, 10500)
-  camera.position.set 500, 0, -1750
+  camera.position.set 300, 0, -1550
   scene = new THREE.Scene()
-  scene.fog = new THREE.Fog 0x050505, 2000, 10500
+  scene.fog = new THREE.Fog 0x000505, visibilityDistance*0.85, visibilityDistance
   #scene.add new THREE.AmbientLight 0x444444 
 
   controls = new THREE.TrackballControls  camera
 
   controls.rotateSpeed = 1.0
-  controls.zoomSpeed = 1.2
+  controls.zoomSpeed = 2.2
   controls.panSpeed = 0.8
 
   controls.noZoom = false
   controls.noPan = false
 
   controls.staticMoving = true
-  controls.dynamicDampingFactor = 0.3
+  controls.dynamicDampingFactor = 0.9
 
   controls.keys = [ 65, 83, 68 ]
 
   #controls.addEventListener 'change', render
 
   #curves = new ChunkedFlyingCurves
-  curves = new WorkerFlyingCurves
+  curves = new WorkerFlyingCurves visibilityDistance, -0.5*visibilityDistance
   
   lines = new THREE.Object3D
   lines.add curves.group

controls = undefined
stepsPerMs = 10 / 1000

showStats = false

palette = [0xfe8f0f, 0xf7325e, 0x7dc410, 0xfef8cf, 0x0264ed]

requestStop = false

class WorkerFlyingCurves
  constructor: ->
    @worker = new Worker "./tubing_worker_browser.js"
    @worker.addEventListener "message", (e)=>@_onMsg(e)


    @worker.postMessage
      cmd: "init"
      pattern: pattern
      chunkSize: @chunkSize
      skipSteps: 1
      size: 100
      # _finishInitialize invoked on responce
    
  step: (dz) ->
