     tube.addAttribute 'position', new THREE.BufferAttribute(vs, 3)
     tube.addAttribute 'index', new THREE.BufferAttribute(ixs, 1)
 
-  
     #tube.offsets.push {start: 0;index: 0; count: vs.length}
 
     tube.computeBoundingSphere()
-    return  tube
-    
-  createTube1: (xys, i)->
-    tube = new THREE.Geometry
-    vs = tube.vertices
-    fs = tube.faces
-    pushQuad = (i1,i2, i3, i4) ->
-      fs.push new THREE.Face3 i1, i2, i3
-      fs.push new THREE.Face3 i2, i4, i3
-      return
-      
-    r = @tubeRadius
-    for xy, iz in xys
-      z = iz*@stepZ
-      x=xy[i]
-      y=xy[i+1]
-      vindex = vs.length
-      vs.push new THREE.Vector3 x-r,y,z
-      vs.push new THREE.Vector3 x,y+r,z
-      vs.push new THREE.Vector3 x+r,y,z
-      vs.push new THREE.Vector3 x,y-r,z
-      if iz >0
-        for j in [0...4]
-          j1 = (j+1)%4
-          pushQuad vindex-4+j, vindex+j, vindex-4+j1, vindex+j1
     return  tube
     
   step: (dz) ->

    @group.updateMatrix()
        
  makeChunk: ->
    states = for i in [0...@chunkSize] by 1
      @isim.nextTime 1
      @isim.getInterpolatedState()
    #create lines
    chunk = new THREE.Object3D
    for i in [0...@nCells]
      tubeGeom = @createTube states, i*2
      tube = new THREE.Mesh tubeGeom, @materials[i]
      chunk.add tube
    return chunk


  createTube: (xys, i)->
    vs = new Float32Array xys.length*4*3 #x,y,z; 4 vertices
    ixs =  new Uint16Array (xys.length-1)*2*3*4 #2 triangles
    curIx = 0

      return
      
    r = @tubeRadius

    x0 = xy0[i]
    y0 = xy0[i]
    for xy, iz in xys
      z = iz*@stepZ
      x=xy[i]
      y=xy[i+1]

      #vectr from the previous point to this
      dx = x-x0
      dy = y-y0
      dz = @stepZ
      x0 = x
      y0 = y

      #compute normals
      # noraml of form
      # xn1, 0, zn1
      # xn1 dx + zn1 dz = 0
      # xn1 dx = - zn1 dz
      # zn1 = - (dx/dz) xn1
      # #
      # xn1^2 ( 1 + (dx/dz)^2 ) = 1
      # xn1^2 = 1/( 1 + (dx/dz)^2 )
      # xn1^2 = dz^2 / (dx^2+dz^2)
      # 
      # xn1 =   dz / sqrt(dx^2+dz^2)
      # zn1 = - dx / sqrt(dx^2+dz^2)

      qdxdz = r / Math.sqrt( dx*dx+dz*dz)
      xn1 = dz * qdxdz
      zn1 = -dx * qdxdz
      
      qdydz = r / Math.sqrt( dy*dy+dz*dz)
      yn2 = dz * qdydz
      zn2 = -dy * qdydz
      
            
      vindex = curV / 3 | 0

      pushXYZ x-xn1,y,z-zn1
      pushXYZ x,y+yn2,z+zn2
      pushXYZ x+xn1,y,z+zn1
      pushXYZ x,y-yn2,z-zn2
      if iz >0
        for j in [0...4]
          j1 = (j+1)%4
