Created
March 25, 2017 04:15
-
-
Save haydenjameslee/116aed02f37dc65564dee238c8c8c716 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assuming you're following this template: | |
https://github.com/aframevr/aframe/blob/v0.5.0/examples/showcase/tracked-controls/index.html | |
// These are the hands: | |
<a-entity hand-controls="left" aabb-collider="objects: .cube;" grab></a-entity> | |
<a-entity hand-controls="right" aabb-collider="objects: .cube;" grab></a-entity> | |
// Add #id's to the hands: | |
<a-entity id="left-hand" hand-controls="left" aabb-collider="objects: .cube;" grab></a-entity> | |
<a-entity id="right-hand" hand-controls="right" aabb-collider="objects: .cube;" grab></a-entity> | |
// Create a template for a hand: | |
<a-assets> | |
... Other assets here ... | |
<script id="hand-template" type="text/html"> | |
<a-sphere></a-sphere> | |
</script> | |
</a-assets> | |
// Now in javascript create hand network entities and child them to the hand entities: | |
var leftHandNAF = NAF.entities.createEntity('#hand-template', '0 0 0', '0 0 0'); | |
var leftHandEl = document.getElementById('#left-hand'); | |
leftHandEl.appendChild(leftHandNAF); | |
var rightHandNAF = NAF.entities.createEntity('#hand-template', '0 0 0', '0 0 0'); | |
var rightHandEl = document.getElementById('#right-hand'); | |
rightHandEl.appendChild(rightHandNAF); | |
// You might have to zero out the position and rotation of the hands, not sure about this one: | |
leftHandNAF.setAttribute('position', '0 0 0'); | |
leftHandNAF.setAttribute('rotation', '0 0 0'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment