diff --git a/src/assets/avatars/Bot_SkinnedWithAnim.fbx b/src/assets/avatars/Bot_SkinnedWithAnim.fbx index 38bfe3673af74de3599aadb3fc473cd2196ee820..b1399bef5217ed4a80873a4cdee8031fa04a5d28 100755 Binary files a/src/assets/avatars/Bot_SkinnedWithAnim.fbx and b/src/assets/avatars/Bot_SkinnedWithAnim.fbx differ diff --git a/src/assets/avatars/Bot_SkinnedWithAnim.glb b/src/assets/avatars/Bot_SkinnedWithAnim.glb index 5531da9cf237d1de307ec227c400a7f6e9b80d12..85dbfee555376bd2169b44554e78fd5c6c26fc9f 100755 Binary files a/src/assets/avatars/Bot_SkinnedWithAnim.glb and b/src/assets/avatars/Bot_SkinnedWithAnim.glb differ diff --git a/src/components/robot-hand-gestures.js b/src/components/robot-hand-gestures.js index 6715fe531460544b866dff45489bd83d9b220cd4..f0fa134b812d51ca01e6e341cbfabe8f8d49af82 100644 --- a/src/components/robot-hand-gestures.js +++ b/src/components/robot-hand-gestures.js @@ -1,6 +1,6 @@ // Global THREE, AFRAME const robotGestures = { - open: "pinch", //TODO + open: "grip", //TODO point: "point", pointThumb: "point", fist: "grip", @@ -22,8 +22,10 @@ AFRAME.registerComponent("robot-hand-gestures", { onModelLoaded: function() { var root = this.el.object3D.children[0].children[0].children[0]; // The "Root Scene" in threejs land of type "Scene" - console.log(this.el); - this.mixer = new THREE.AnimationMixer(root); + this.leftMixer = new THREE.AnimationMixer(root); + this.rightMixer = new THREE.AnimationMixer(root); + + window.root = root; //TODO delete this.loaded = true; }, @@ -39,48 +41,32 @@ AFRAME.registerComponent("robot-hand-gestures", { tick: function(_t, dt) { if (!this.loaded) return; - this.mixer.update(dt * 0.001); + this.leftMixer.update(dt); + this.rightMixer.update(dt); }, - /** - * Play hand animation based on button state. - * - * @param {string} gesture - Name of the animation as specified by the model. - * @param {string} lastGesture - Previous pose. - */ playAnimation: function(evt) { + if (!this.loaded) return; const { current, previous } = evt.detail; - var fromAction; - var toAction; - var mixer = this.mixer; + var mixer = this.data.leftHand ? this.leftMixer : this.rightMixer; const suffix = evt.target === this.data.leftHand ? "_L" : "_R"; - const from = robotGestures[previous] + suffix; - const to = robotGestures[current] + suffix; - - // Grab clip action. - toAction = mixer.clipAction(to); - toAction.clampWhenFinished = true; - // toAction.loop = THREE.LoopRepeat; - toAction.repetitions = 0; - toAction.weight = 1; - - // No gesture to gesture or gesture to no gesture. - if (!previous || current === previous) { - // Stop all current animations. - mixer.stopAllAction(); - - // Play animation. - toAction.play(); - return; - } + const prevPose = robotGestures[previous] + suffix; + const currPose = robotGestures[current] + suffix; // Animate or crossfade from gesture to gesture. + //console.log(`Animate from ${prevPose} to ${currPose}`); + const duration = 300; + var from = mixer.clipAction(prevPose); + from.setDuration(duration); + var to = mixer.clipAction(currPose); + to.setDuration(duration); + to = to.crossFadeFrom(from, duration); - fromAction = mixer.clipAction(from); mixer.stopAllAction(); - fromAction.weight = 0.15; - fromAction.play(); - toAction.play(); - fromAction.crossFadeTo(toAction, 0.15, true); + if (this["gesture" + suffix] !== undefined) { + } + to.play(); + + this["gesture" + suffix] = to; } }); diff --git a/src/input-mappings.js b/src/input-mappings.js index 272e3889ada96d6638d27544d3ea27ec379e5395..1f8880cad960f78ff7ae3fcfd52d728ca924ea78 100644 --- a/src/input-mappings.js +++ b/src/input-mappings.js @@ -47,10 +47,10 @@ const config = { thumbsticktouchstart: "thumb_down", thumbsticktouchend: "thumb_up", // @TODO: How do I map more than one action to triggerdown? - // triggerdown: "index_down", - // triggerup: "index_up", - triggerdown: "action_teleport_down", - triggerup: "action_teleport_up", + triggerdown: "index_down", + triggerup: "index_up", + //triggerdown: "action_teleport_down", + //triggerup: "action_teleport_up", "axismove.reverseY": { left: "move" }, right_dpad_east: "snap_rotate_right", right_dpad_west: "snap_rotate_left",