Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/components/networked-hand-tracking.js
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' }
Copy link
Member

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:

<template id="hand-joint-template">
  <a-sphere radius="0.01"></a-sphere>
</template>

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

          <a-entity id="left" hand-tracking-controls="hand:left; modelStyle:dots;" networked-hand-tracking="{options: 'template:#hand-joint-template; attachTemplateToLocal:false'}"></a-entity>

I didn't know we could use an object like that as attribute value, this is really working?

},

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);
}
Copy link
Member

Choose a reason for hiding this comment

The 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 = [];
Copy link
Member

Choose a reason for hiding this comment

The 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.
Why this line? It doesn't seem to be needed to me.


for (var i = 0; i < jointEls.length; i++) {
jointEls[i].removeAttribute('networked');
}
},
});
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ require('./components/networked');
require('./components/networked-audio-source');
require('./components/networked-video-source');
require('./components/networked-hand-controls');
require('./components/networked-hand-tracking');