Pointable

Attributes:

Functions:

class Pointable()

The Pointable class reports the physical characteristics of a detected finger or tool.

Both fingers and tools are classified as Pointable objects. Use the tool property to determine whether a Pointable object represents a tool or finger. The Leap classifies a detected entity as a tool when it is thinner, straighter, and longer than a typical finger.

Note that Pointable objects can be invalid, which means that they do not contain valid tracking data and do not correspond to a physical entity. Invalid Pointable objects can be the result of asking for a Pointable object using an ID from an earlier frame when no Pointable objects with that ID exist in the current frame. A Pointable object created from the Pointable constructor is also invalid. Test for validity with the valid property.

var pointable = frame.pointables[0];
var direction = pointable.direction;
var length = pointable.length;
var width = pointable.width;
var stabilizedPosition = pointable.stabilizedTipPosition;
var position = pointable.tipPosition;
var speed = pointable.tipVelocity;
var touchDistance = pointable.touchDistance;
var zone = pointable.touchZone;
Pointable()

Constructs a Pointable object.

An uninitialized pointable is considered invalid. Get valid Pointable objects from a Frame() or a Hand() object.

Pointable.direction
Type:number[] – A 3-element array representing a unit direction vector.

The direction in which this finger or tool is pointing.

var direction = pointable.direction;

The direction is expressed as a unit vector pointing in the same direction as the tip.

FingerImage

Pointable.id
Type:String

A unique ID assigned to this Pointable object, whose value remains the same across consecutive frames while the tracked finger or tool remains visible. If tracking is lost (for example, when a finger is occluded by another finger or when it is withdrawn from the Leap field of view), the Leap may assign a new ID when it detects the entity in a future frame.

var id = pointable.id;

Use the ID value with the Frame.pointable() and Hand.pointable() functions to find this Pointable object in future frames.

Pointable.length
Type:number

The estimated length of the finger or tool in millimeters.

var length = pointable.length;

The reported length is the visible length of the finger or tool from the hand to tip. If the length isn’t known, then a value of 0 is returned.

Pointable.stabilizedTipPosition
Type:number[] – a 3-element array representing a position vector.

The tip position in millimeters from the Leap origin. Stabilized based on the velocity of the pointable to make precise positioning easier.

<p>Stabilized Position: <span id="stabPosition">…</span></p>
<p>Difference from tip position: <span id="delta">…</span></p>
<script>
var stabilizedDisplay = document.getElementById("stabPosition");
var deltaDisplay = document.getElementById("delta");

var controller = new Leap.Controller();
controller.on('frame', function(frame){
    if(frame.pointables.length > 0)
    {
        var pointable = frame.pointables[0];
        var stabilizedPosition = pointable.stabilizedTipPosition;
        var tipPosition = pointable.tipPosition;
        stabilizedDisplay.innerText = "(" + stabilizedPosition[0] + ", " 
                                          + stabilizedPosition[1] + ", " 
                                          + stabilizedPosition[2] + ")";
        deltaDisplay.innerText = "(" + (tipPosition[0] - stabilizedPosition[0]) + ", "
                                     + (tipPosition[1] - stabilizedPosition[1]) + ", "
                                     + (tipPosition[2] - stabilizedPosition[2]) + ")";
    }
});
controller.connect();
</script>
Pointable.timeVisible
Type:number

The amount of time this pointable has been continuously visible to the Leap Motion controller in seconds.

var secondsVisible = pointable.timeVisible;

By ignoring Pointable objects with a small timeVisible value, can filter out a certain amount of noise and spuriously detected hands or tools.

Pointable.tipPosition
Type:number[] – a 3-element array representing a position vector.

The tip position in millimeters from the Leap origin.

var tipPostition = pointable.tipPosition;
Pointable.tipVelocity
Type:number[] – a 3-element array representing a vector.

The rate of change of the tip position in millimeters/second.

var speed = pointable.tipVelocity;
Pointable.tool
Type:Boolean

Whether or not the Pointable is believed to be a tool. Tools are generally longer, thinner, and straighter than fingers.

If tool is false, then this Pointable must be a finger.

if(pointable.tool){
    //... do tool stuff
}
Pointable.touchDistance
Type:number

A value proportional to the distance between this Pointable object and the adaptive touch plane.

Touch_Plane

The touch distance is a value in the range [-1, 1]. The value 1.0 indicates the Pointable is at the far edge of the hovering zone. The value 0 indicates the Pointable is just entering the touching zone. A value of -1.0 indicates the Pointable is firmly within the touching zone. Values in between are proportional to the distance from the plane. Thus, the touchDistance of 0.5 indicates that the Pointable is halfway into the hovering zone.

<p>Distance: <span id="distance">…</span></p>
<script>
var distanceDisplay = document.getElementById("distance");

var controller = new Leap.Controller();
controller.on('frame', function(frame){
    if(frame.pointables.length > 0)
    {
        var touchDistance = frame.pointables[0].touchDistance;
        distanceDisplay.innerText = touchDistance;
    }
});
controller.connect();
</script>

You can use the touchDistance value to modulate visual feedback given to the user as their fingers close in on a touch target, such as a button.

Pointable.touchZone
Type:String

The Leap Motion software computes the touch zone based on a floating touch plane that adapts to the user’s finger movement and hand posture. The Leap Motion software interprets purposeful movements toward this plane as potential touch points. When a Pointable moves close to the adaptive touch plane, it enters the “hovering” zone. When a Pointable reaches or passes through the plane, it enters the “touching” zone.

<p>Zone: <span id="zone">…</span></p>
<script>
var zoneDisplay = document.getElementById("zone");

var controller = new Leap.Controller();
controller.on('frame', function(frame){
    if(frame.pointables.length > 0)
    {
        var touchZone = frame.pointables[0].touchZone;
        zoneDisplay.innerText = touchZone;
    }
});
controller.connect();
</script>

The following example (plug in your Leap Motion Controller) illustrates both the touch_zone and the touch_distance attributes. Touching pointables are colored red, hovering pointables are green, and those outside either zone are a faint blue.

Pointable.valid
Type:Boolean

Indicates whether this is a valid Pointable object.

if(pointable.valid){
    //...
}
Pointable.width
Type:number

The estimated width of the tool in millimeters.

var averageThickness = pointable.width; 

The reported width is the average width of the visible portion of the tool from the hand to the tip. If the width isn’t known, then a value of 0 is returned.

Pointable.hand()

Gets the hand associated with this a finger.

In version 2+, tools are not associated with hands. This method always returns an invalid Hand object for tools.

var handOfPointable = pointable.hand();

if the Hand object is no longer available, then an invalid Hand object is returned.

Returns:Hand() – the hand to which this pointable is attached.
Pointable.toString()

A string containing a brief, human readable description of the Pointable object.

console.log(pointable.toString());
Returns:String – A description of the Pointable object as a string.
Pointable.Invalid
Type:Pointable

An invalid Pointable object.

You can use this Pointable instance in comparisons testing whether a given Pointable instance is valid or invalid. (You can also use the valid property.)