     #    verts[vertCount++] = parseFloat s
     # TODO: eventually we will be able to pull normals from the AMF file
     #@_eachFace @_calculateVertexNormals
+
+    @nOfTriangles = nOfTriangles
     undefined
 
   _parseTextObj: (text) ->

    $ "//triangle", (node) ->
      indices[indiceCount++] = parseInt(read node, "v#{k}") for k in [1..3]

    # Expanding (duplicating) the normals and verts so that there is a 1:1 of verts to indices
    # This allows us to modify the normals on a per-face basis in edges and makes mesh spliting trivial
    nOfTriangles = @nOfTriangles = indices.length/3 # TODO: when noftriangles is fixed this will be implicit
    exp = {}
    exp[attr] = new Float32Array(@nOfTriangles*9) for attr in ['vertices', 'normals']
    @_eachFace (face, i) ->
      console.log i
      for attr in ['vertices', 'normals']
        exp[attr][i*9+j*3+k] = face[attr][j][k] for j in [0..2] for k in [0..2]
    indices[i] = i for i in [0..indices.length-1]
    @[attr] = exp[attr] for attr in ['vertices', 'normals']
    @verts = @vertices

    # Define the normals for verts without a normal as the normal vector of the face
    @_eachFace @_calculateVertexNormals

    # Parsing Edges (TODO)

    xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
    xmlDoc.async=false
    xml.loadXML(text)

hermiteSpline = (s, v, t) -> # see http://en.wikipedia.org/wiki/Cubic_Hermite_spline
  # (2*s^3 - 3*s^2 + 1)*v[0] + (s^3 - 2*s^2 + s)*t[0] + (-2*s^3 + 3*s^2)*v[1] + (s^3-s^2)*t[1]
  c = [
    [ 2*Math.pow(s,3) - 3*Math.pow(s,2) + 1, Math.pow(s,3) - 2*Math.pow(s,2) + s ],
    [ -2*Math.pow(s,3) + 3*Math.pow(s,2), Math.pow(s,3) - Math.pow(s,2) ]
  ]
  v[0][i]*c[0][0] + t[0][i]*c[0][1] + v[1][i]*c[1][0] + t[1][i]*c[1][1] for i in [0..2]

base64_encode = (data) ->
  # http://kevin.vanzonneveld.net
