     console.log "sizesBuffer", @sizesBuffer.toString()
 
 
+  getNodeIndex : (nodeId) ->
+
+    for i in [0..@nodeIDs.length]
+      if @nodeIDs.get(i) == nodeId
+        return i
+
+
+  doWithNodeIndex : (nodeId, f) ->
+
+    index = @getNodeIndex(nodeId)
+    return unless index?
+    f(index)
+
+
   #### Color utility methods
 
   hexToRGB : (hexColor) ->

      for i in [0...array.elementLength]
        array.getAllElements()[index * array.elementLength + i] = lastElement[i]

    # Find index
    for i in [0...@nodeIDs.getLength()]
      if @nodeIDs.get(i) == node.id
        nodesIndex = i
        break

    $.assert(nodesIndex?, "No node found.", { id : node.id, @nodeIDs })

    # swap IDs and nodes


  updateNodeColor : (id, isActiveNode, isBranchPoint) ->

    @doWithNodeIndex(id, (index) =>
      @nodesColorBuffer.set(@getColor(id, isActiveNode, isBranchPoint), index)
    )

    @updateGeometries()


  updateNodeRadius : (id, radius) ->

    @doWithNodeIndex(id, (index) =>
      @sizesBuffer.set([radius * 2], index)
    )

    @updateGeometries()


  startNodeHighlightAnimation : (nodeId) ->

    normal = 1.0
    highlighted = 2.0

    @doWithNodeIndex(nodeId, (index) =>
      @animateNodeScale(normal, highlighted, index, =>
        @animateNodeScale(highlighted, normal, index)
      )
    )


