var scale = d3.scale.category20c(),
    i = 0;

// original position
var originX = 600;
var originY = 300;
var originZ = 200;
var posX, posY;

var maxX = originX;
var maxY = originY;
var maxZ = originZ;

var maxSpan = 100;

function translateXScreenDistance(distance) {
  return (distance / maxSpan) * maxX;
}

function translateYScreenDistance(distance) {
  return maxY - ((distance / maxSpan) * maxY);
}

function translateZScreenDistance(distance){
  return (distance / maxSpan) * maxZ;
}

var svg = d3.select("body").append("svg:svg");

function particle(x, y, z) {
  svg.append("svg:circle")
      .attr("cx", x)
      .attr("cy", y)
      .attr("r", 1e-6 + (z / 5))
      .style("stroke", scale(++i))
      .style("stroke-opacity", 1 - ((maxZ -z) / 1000))
    .transition()
      .duration(2000)
      .ease(Math.sqrt)
      .attr("r", 100 + (z / 5))
      .style("stroke-opacity", 1e-6)
      .remove();
}

var pointer;

Leap.loop(function(frame) {
  for (var i = 0; i < frame.pointables.length; i++) {
    pointer = frame.pointables[i];
    posX = originX + translateXScreenDistance(pointer.tipPosition[0]);
    posY = originY + translateYScreenDistance(pointer.tipPosition[1]);
    posZ = originZ + translateZScreenDistance(pointer.tipPosition[2]);
    particle(posX, posY, posZ);
  }
});

@@ -114,17 +114,17 @@
 iginZ = 
-2
+6
 00;%0Avar 
@@ -215,16 +215,36 @@
 n = 100;
+%0Avar maxZSpan = 160;
 %0A%0Afuncti
@@ -481,32 +481,33 @@
  (distance / max
+Z
 Span) * maxZ;%0A%7D%0A
@@ -674,33 +674,34 @@
 r%22, 1e-6 + (z / 
-5
+20
 ))%0A      .style(
@@ -872,9 +872,10 @@
 z / 
-5
+20
 ))%0A 
@@ -1199,24 +1199,24 @@
 sition%5B1%5D);%0A
-
     posZ = o
@@ -1270,24 +1270,25 @@
 sition%5B2%5D);%0A
+%0A
     particle

fix negative z issues