{"id":20649480,"url":"https://github.com/leapmotion/leapjs-rigged-hand","last_synced_at":"2025-04-17T01:08:53.113Z","repository":{"id":13907073,"uuid":"16605869","full_name":"leapmotion/leapjs-rigged-hand","owner":"leapmotion","description":"Control hand models with the Leap Motion","archived":false,"fork":false,"pushed_at":"2023-01-07T23:22:42.000Z","size":24092,"stargazers_count":99,"open_issues_count":12,"forks_count":32,"subscribers_count":69,"default_branch":"master","last_synced_at":"2025-04-12T17:46:36.988Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leapmotion.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-02-07T06:00:59.000Z","updated_at":"2025-02-26T13:36:08.000Z","dependencies_parsed_at":"2023-01-14T05:30:11.415Z","dependency_job_id":null,"html_url":"https://github.com/leapmotion/leapjs-rigged-hand","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leapmotion%2Fleapjs-rigged-hand","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leapmotion%2Fleapjs-rigged-hand/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leapmotion%2Fleapjs-rigged-hand/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leapmotion%2Fleapjs-rigged-hand/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leapmotion","download_url":"https://codeload.github.com/leapmotion/leapjs-rigged-hand/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249296392,"owners_count":21246305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T17:14:27.822Z","updated_at":"2025-04-17T01:08:53.085Z","avatar_url":"https://github.com/leapmotion.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"JS Rigged Hand Plugin\n==============\n\nThis allows a Leap-Enabled hand to be added to any Three.JS scene.\nRequires LeapJS Skeletal 0.4.2 or greater with LeapJS-Plugins 0.1.3 or greater.\n\n - Live Demo: [http://leapmotion.github.io/leapjs-rigged-hand/](http://leapmotion.github.io/leapjs-rigged-hand/)\n - If you don't have a Leap, automatic mode is available.  Give it a moment to load and then make sure you have the page in focus for playback.  Insert your hand over the Leap to take control http://leapmotion.github.io/leapjs-rigged-hand/?playback=1\n\n![hands](https://f.cloud.github.com/assets/407497/2405446/5e7ee120-aa50-11e3-8ac0-579b316efc04.png)\n\nAutomatically adds or removes hand meshes to/from the scene as they come in to or out of view of the leap controller.\n\n\n## Usage:\n\n### Basic\n\n```coffeescript\n# simplest possible usage, see `quickstart.html`\n(window.controller = new Leap.Controller)\n  .use('riggedHand')\n  .connect()\n```\n\nThis will create a canvas with fixed position which covers the entire screen.  A neat trick is to allow pointer-events to pass through the canvas with one CSS rule, so that you can interact with your page like normal.\n\n```css\ncanvas{\n  pointer-events: none;\n}\n```\n\n\n\n### Advanced\n\n```coffeescript\n# advanced configuration, see `index.html` and `main.coffee`\n(window.controller = new Leap.Controller)\n  # handHold and handEntry are dependencies of this plugin, available to the controller through leap-plugins.js\n  # By default rigged-hand will use these, but we can call explicitly to provide configuration:\n  .use('handHold', {})\n  .use('handEntry', {})\n  .use('riggedHand', {\n    parent: scene\n\n    # this is called on every animationFrame \n    renderFn: -\u003e\n      renderer.render(scene, camera)\n      # Here we update the camera controls for clicking and rotating\n      controls.update()\n\n    # These options are merged with the material options hash\n    # Any valid Three.js material options are valid here.\n    materialOptions: {\n      wireframe: true,\n      color: new THREE.Color(0xff0000)\n    }\n    geometryOptions: {}\n\n    # This will show pink dots at the raw position of every leap joint.\n    # they will be slightly offset from the rig shape, due to it having slightly different proportions.\n    dotsMode: true\n\n    # Sets the default position offset from the parent/scene. Default of new THREE.Vector3(0,-10,0)\n    offset: new THREE.Vector3(0,0,0)\n\n    # sets the scale of the mesh in the scene.  The default scale works with a camera of distance ~15.\n    scale: 1.5\n\n    # Allows hand movement to be scaled independently of hand size.\n    # With a value of 2, the hand will cover twice the distance on screen as it does in the world.\n    positionScale: 2\n\n    # allows 2d text to be attached to joint positions on the screen\n    # Labels are by default white text with a black dropshadow\n    # this method is called for every bone on each frame\n    # boneMeshes are named Finger_xx, where the first digit is the finger number, and the second the bone, 0 indexed.\n    boneLabels: (boneMesh, leapHand)-\u003e\n      return boneMesh.name\n\n    # allows individual bones to be colorized\n    # Here we turn thumb and index finger blue while pinching\n    # this method is called for every bone on each frame\n    # should return an object with hue, saturation, and an optional lightness ranging from 0 to 1\n    # http://threejs.org/docs/#Reference/Math/Color [setHSL]\n    boneColors: (boneMesh, leapHand)-\u003e\n      if (boneMesh.name.indexOf('Finger_0') == 0) || (boneMesh.name.indexOf('Finger_1') == 0)\n        return {\n          hue: 0.6,\n          saturation: leapHand.pinchStrength\n        }\n\n    # This will add a warning message to the page on browsers which do not support WebGL or do not have it enabled.\n    # By default, this will be used unless a `parent` scene is passed in.\n    # This uses @mrdoob's Detector.js\n    # Chrome, Firefox, Safari Developer mode, and IE11 all support WebGL.  http://caniuse.com/webgl\n    checkWebGL: true\n\n  })\n  .connect()\n```\n\nNote that the size of this file is quite large, as it includes left and right hand models.  It is recommended that you\ninclude the files [from our CDN](https://developer.leapmotion.com/leapjs/plugins), as that will encourage browser caching\nand ensure the assets are gzipped from 845KB to 348KB before sending.\n\n### Scope objects\n\nCertain objects are made available on the plugin scope.  This is the same \"options\" object which is passed in to `use`.\n\n```coffeescript\nscope = controller.plugins.riggedHand; \n\nscope.camera # THREE.js camera\n\nscope.scene # THREE.js camera\n\nscope.Detector # Can be used to detect webgl availability through `if !!Detector.webgl`\n```\n\nThere are many which are currently undocumented.  Inspect the object manually to discover.\n\n### Events\n\n`riggedHand.meshAdded` and `riggedHand.meshRemoved` are available.  These may be useful to customize behaviors of the\nhand or change defaults.  By default, `material.opacity == 0.7`, `material.depthTest == true`, and\n`handMesh.castShadow == true`, but these could be customized in the event callback.\n\n```javascript\ncontroller.on('riggedHand.meshAdded', function(handMesh, leapHand){\n  handMesh.material.opacity = 1;\n});\n```\n\n### Scene Position\n\n`handMesh.scenePosition(leapPosition, scenePosition)` can be used to convert coordinates from Leap Space to THREE scene space.\nleapPosition should be an array [x,y,z] as found on Leap frames, scenePosition should be a `THREE.Vector3` which will be edited in-place.\n\n[LIVE DEMO](http://leapmotion.github.io/leapjs-rigged-hand/?scenePosition=true)\n\n\n```coffeescript\nsphere = new THREE.Mesh(\n  new THREE.SphereGeometry(1),\n  new THREE.MeshBasicMaterial(0x0000ff)\n)\nscene.add(sphere)\n\ncontroller.on 'frame', (frame)-\u003e\n  if hand = frame.hands[0]\n    handMesh = frame.hands[0].data('riggedHand.mesh')\n\n    handMesh.scenePosition(hand.indexFinger.tipPosition, sphere.position)\n\n```\n\n\n### Screen Position\n\nWhen a hand is on the screen, that hand will be available to your application (such as in a plugin or on 'frame' callback)\n through `frame.hands[index].data('riggedHand.mesh')`.  This will be the Three.js mesh, as is.\n\nTo get the css window coordinates of anything in leap-space, use the `handMesh.screenPosition` method, as seen in\nmain.coffee.  The number returned will be distance from the bottom left corner of the WebGL canvas.\n\nNote that if a custom scene is passed in, `scope.renderer` must also be passed in/set.\n\n```coffeescript\ncontroller.on 'frame', (frame)-\u003e\n  if hand = frame.hands[0]\n    handMesh = frame.hands[0].data('riggedHand.mesh')\n    # to use screenPosition, we pass in any leap vector3 and the camera\n    screenPosition = handMesh.screenPosition(\n      hand.fingers[1].tipPosition\n    )\n    cursor.style.left = screenPosition.x\n    cursor.style.bottom = screenPosition.y\n```\n\n\n\nContributing\n===============\n\n#### Open an issue!\n - https://github.com/leapmotion/leapjs-plugins/issues\n - We listen for bug reports, feature requests, contributions, an so on :-)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleapmotion%2Fleapjs-rigged-hand","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleapmotion%2Fleapjs-rigged-hand","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleapmotion%2Fleapjs-rigged-hand/lists"}