-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add networked hand tracking component #445
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* global AFRAME */ | ||
|
||
AFRAME.registerComponent('networked-hand-tracking', { | ||
dependencies: ['hand-tracking-controls'], | ||
|
||
schema: { | ||
options: { default: 'template:#hand-joint-template; attachTemplateToLocal:false' } | ||
}, | ||
|
||
init: function () { | ||
var el = this.el; | ||
this.trackingControls = el.components['hand-tracking-controls']; | ||
|
||
this.onExitVR = AFRAME.utils.bind(this.onExitVR, this); | ||
el.sceneEl.addEventListener('exit-vr', this.onExitVR); | ||
}, | ||
|
||
tick: function () { | ||
var jointEls = this.trackingControls.jointEls; | ||
|
||
for (var i = 0; i < jointEls.length; i++) { | ||
jointEls[i].setAttribute('networked', this.data.options); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doing a setAttribute in tick for all joints are not efficient. You should really do it only once in an enter-vr listener I think. |
||
}, | ||
|
||
onExitVR: function () { | ||
var jointEls = this.trackingControls.jointEls; | ||
this.trackingControls.jointEls = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this should be the responsibility of your component to empty the array of another component. |
||
|
||
for (var i = 0; i < jointEls.length; i++) { | ||
jointEls[i].removeAttribute('networked'); | ||
} | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the hand-joint-template in your PR. What did you use for html template?
Answering this myself looking at your glitch:
What about the networked schema? Default networked schema is only syncing position and rotation, did you add scale? I see hand-tracking-controls is setting scale on the joints https://github.com/aframevr/aframe/blob/e0c4ec6d2d07db426d27d76b32ec7aba7d9f5e60/src/components/hand-tracking-controls.js#L250
You probably want to create your own schema that sync position rotation scale with a correct requiresNetworkUpdate function to minimize networked updates, see
https://github.com/networked-aframe/networked-aframe#tracked-controllers-w-synced-gestures
I didn't know we could use an object like that as attribute value, this is really working?