Skip to content

Commit 5dfe0f9

Browse files
machenmusikngokevin
authored andcommitted
Support new hand animations (#2191)
* working remapping to new hands from @arturitu * minor changes requested per discussion on PR update to CDN URLs from aframevr/assets#18
1 parent 4cb0002 commit 5dfe0f9

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

‎docs/components/hand-controls.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ handles hand animations and poses.
4646

4747
## Assets
4848

49-
- [Left hand model](https://cdn.aframe.io/controllers/oculus-hands/leftHand.json)
50-
- [Right hand model](https://cdn.aframe.io/controllers/oculus-hands/rightHand.json)
49+
- [Left hand model](https://cdn.aframe.io/controllers/oculus-hands/v2/leftHand.json)
50+
- [Right hand model](https://cdn.aframe.io/controllers/oculus-hands/v2/rightHand.json)

‎src/components/hand-controls.js‎

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var registerComponent = require('../core/component').registerComponent;
22

3-
var OCULUS_LEFT_HAND_MODEL_URL = 'https://cdn.aframe.io/controllers/oculus-hands/leftHand.json';
4-
var OCULUS_RIGHT_HAND_MODEL_URL = 'https://cdn.aframe.io/controllers/oculus-hands/rightHand.json';
3+
var OCULUS_LEFT_HAND_MODEL_URL = 'https://cdn.aframe.io/controllers/oculus-hands/v2/leftHand.json';
4+
var OCULUS_RIGHT_HAND_MODEL_URL = 'https://cdn.aframe.io/controllers/oculus-hands/v2/rightHand.json';
55

66
/**
77
*
@@ -183,30 +183,32 @@ module.exports.Component = registerComponent('hand-controls', {
183183
},
184184

185185
gestureAnimationMapping: {
186-
'pointing': 'pointing',
187-
'pistol': 'pistol',
188-
'fist': 'press',
189-
'touch': 'touch',
190-
'thumb': 'thumb'
186+
default: 'Open',
187+
pointing: 'Point',
188+
pistol: 'Point + Thumb',
189+
fist: 'Fist',
190+
touch: 'Hold',
191+
thumb: 'Thumb Up'
191192
},
192193

193194
animateGesture: function (gesture) {
194195
var isOculusTouch = this.isOculusTouchController();
195-
if (!gesture) {
196-
this.playAnimation('touch', isOculusTouch);
196+
if (!gesture && !isOculusTouch) {
197+
// for Vive (and other non-Oculus Touch), change rest pose to be thumb down
198+
this.playAnimation('Open', true);
197199
return;
198200
}
199-
var animation = this.gestureAnimationMapping[gesture];
200-
this.playAnimation(animation || 'touch', !animation && isOculusTouch);
201+
var animation = this.gestureAnimationMapping[gesture || 'default'];
202+
this.playAnimation(animation || 'Open', !animation && isOculusTouch);
201203
},
202204

203205
// map to old vive-specific event names for now
204206
gestureEventMapping: {
205-
'fist': 'grip', // fist: e.g. grip active, trigger active, trackpad / surface active
206-
'touch': 'point', // 'touch' e.g. trigger active, grip not active
207-
'thumb': 'thumb', // thumbs up: e.g. grip active, trigger active, trackpad / surface not active
208-
'pointing': 'pointing', // pointing: e.g. grip active, trackpad / surface active, trigger not active
209-
'pistol': 'pistol' // pistol: e.g. grip active, trigger not active, trackpad / surface not active
207+
fist: 'grip', // fist: e.g. grip active, trigger active, trackpad / surface active
208+
touch: 'point', // 'touch' e.g. trigger active, grip not active
209+
thumb: 'thumb', // thumbs up: e.g. grip active, trigger active, trackpad / surface not active
210+
pointing: 'pointing', // pointing: e.g. grip active, trackpad / surface active, trigger not active
211+
pistol: 'pistol' // pistol: e.g. grip active, trigger not active, trackpad / surface not active
210212
},
211213

212214
gestureEventName: function (gesture, active) {
@@ -239,6 +241,7 @@ module.exports.Component = registerComponent('hand-controls', {
239241
var animationActive = this.animationActive;
240242
var timeScale = 1;
241243
var mesh = this.el.getObject3D('mesh');
244+
var clipAction;
242245
if (!mesh) { return; }
243246

244247
// determine direction of the animation.
@@ -248,9 +251,14 @@ module.exports.Component = registerComponent('hand-controls', {
248251
if (animationActive) { mesh.play(animationActive, 0); }
249252

250253
// play new animation.
251-
mesh.mixer.clipAction(animation).loop = 2200;
252-
mesh.mixer.clipAction(animation).clampWhenFinished = true;
253-
mesh.mixer.clipAction(animation).timeScale = timeScale;
254+
clipAction = mesh.mixer.clipAction(animation);
255+
// returning when no clipAction will prevent further issues
256+
// (e.g. controllers no longer updating pose)
257+
// but per https://github.com/aframevr/aframe/pull/2191#discussion_r93121878
258+
// the preference is to NOT prevent the issues to catch bugs earlier in QA.
259+
clipAction.loop = 2200;
260+
clipAction.clampWhenFinished = true;
261+
clipAction.timeScale = timeScale;
254262
mesh.play(animation, 1);
255263
this.animationActive = animation;
256264
}

0 commit comments

Comments
 (0)