<commit_before>var Leap = require('leapjs'),
    HandMesh = require('../lib/leap.hand-mesh'),
    handEntry = require('../lib/leap.hand-entry'),
    handHold = require('../lib/leap.hand-hold'),
    transform = require('../lib/leap.transform.js');

Leap.Controller.plugin('handEntry', handEntry);
Leap.Controller.plugin('handHold', handHold);
Leap.Controller.plugin('transform', transform);

Leap.plugin('boneHands', function(options) {
  options = options || {};

  this.use('handEntry');
  this.use('handHold');
  this.use('transform', {vr: true});

  // this.on('frameEnd', function () { self.frameEnd(this); });
  // this.on('handLost', function () { self.handLost(this); });
  return {hand: function (){}};
});

var controller = Leap.loop()
  .setOptimizeHMD(true)
  .use('boneHands');

module.exports = {
  schema: {
    hand: {default: '', oneOf: ['left', 'right'], required: true}
  },

  init: function () {
    console.info('[box-hand] init()');
    this.controller = controller;
    this.hand = HandMesh.get();
    this.mesh = this.hand.getMesh();
    this.el.setObject3D('mesh', this.mesh);
  },

  remove: function () {
    if (this.hand) this.hand.replace();
    if (this.mesh) this.el.removeObject3D('mesh');
  },

  tick: function () {
    var hand,
        data = this.data,
        frame = this.controller.frame();

    if (frame.hands.length) {
      hand = frame.hands[frame.hands[0].type === data.hand ? 0 : 1];
    }

    if (hand) {
      this.hand.scaleTo(hand);
      this.hand.formTo(hand);
    }<commit_msg>Hide when out of range.<commit_after>var Leap = require('leapjs'),
    HandMesh = require('../lib/leap.hand-mesh'),
    handEntry = require('../lib/leap.hand-entry'),
    handHold = require('../lib/leap.hand-hold'),
    transform = require('../lib/leap.transform.js');

Leap.Controller.plugin('handEntry', handEntry);
Leap.Controller.plugin('handHold', handHold);
Leap.Controller.plugin('transform', transform);

Leap.plugin('boneHands', function(options) {
  options = options || {};

  this.use('handEntry');
  this.use('handHold');
  this.use('transform', {vr: true});

  // this.on('frameEnd', function () { self.frameEnd(this); });
  // this.on('handLost', function () { self.handLost(this); });
  return {hand: function (){}};
});

var controller = Leap.loop()
  .setOptimizeHMD(true)
  .use('boneHands');

module.exports = {
  schema: {
    hand: {default: '', oneOf: ['left', 'right'], required: true}
  },

  init: function () {
    this.controller = controller;
    this.isVisible = false;
    this.hand = HandMesh.get();
    this.mesh = this.hand.getMesh();
    this.el.setObject3D('mesh', this.mesh);
  },

  remove: function () {
    if (this.hand) this.hand.replace();
    if (this.mesh) this.el.removeObject3D('mesh');
  },

  tick: function () {
    var hand,
        data = this.data,
        frame = this.controller.frame();

    if (frame.hands.length) {
      hand = frame.hands[frame.hands[0].type === data.hand ? 0 : 1];
    }

    if (hand) {
      this.hand.scaleTo(hand);
      this.hand.formTo(hand);
    }

    if (hand && !this.isVisible) {
      this.hand.show();
    } else if (!hand && this.isVisible) {
      this.hand.hide();
    }
    this.isVisible = !!hand;
{'fraction_non_alphanumeric': 0.20210787352758836, 'fraction_numerical': 0.0030998140111593306, 'mean_word_length': 3.2018229166666665, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3575831', 'n_tokens_mistral': 1129, 'n_tokens_neox': 1088, 'n_words': 191}