From bfaa85c6411be8eb76354c804b54000e6a9ddd09 Mon Sep 17 00:00:00 2001 From: Brian Peiris Date: Tue, 6 Dec 2016 14:22:46 -0800 Subject: [PATCH] headbutt cube --- examples/joint-collision-push.html | 10 ++++-- .../behaviors/JointCollisionEvents.js | 31 ++++++++++--------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/examples/joint-collision-push.html b/examples/joint-collision-push.html index 6c57c731..e6b9cc38 100644 --- a/examples/joint-collision-push.html +++ b/examples/joint-collision-push.html @@ -11,6 +11,7 @@ var sim = altspace.utilities.Simulation(); var pushOffset = 2; +var cubePos = 80; var button; var cubePositionRef; var enclosure; @@ -49,7 +50,7 @@ // Reset position when button pressed button.addEventListener('cursordown', function(e) { console.log('cursordown'); - cubePositionRef.set(new THREE.Vector3(0, -10, 0)); + cubePositionRef.set(new THREE.Vector3(0, cubePos, 0)); }); //cube @@ -59,6 +60,9 @@ cube.addBehaviors( altspace.utilities.behaviors.Object3DSync(), altspace.utilities.behaviors.JointCollisionEvents({ + joints: altspace.utilities.behaviors.JointCollisionEvents.HAND_JOINTS.concat( + [ ['Head', 'Center', 0] ] + ), jointCubeSize: 15, }), UpdatePosition() @@ -97,10 +101,10 @@ sync = object3d.getBehaviorByType('Object3DSync'); cubePositionRef = sync.dataRef.child('cubePosition'); - // If 'cubePosition' is null, set it to 0, -10, 0 + // If 'cubePosition' is null, set the default. cubePositionRef.on('value', function (snapshot) { if(!snapshot.val()) { - cubePositionRef.set(new THREE.Vector3(0, -10, 0)); + cubePositionRef.set(new THREE.Vector3(0, cubePos, 0)); } else { // Set position diff --git a/src/utilities/behaviors/JointCollisionEvents.js b/src/utilities/behaviors/JointCollisionEvents.js index 003313b7..ca9cdaf5 100644 --- a/src/utilities/behaviors/JointCollisionEvents.js +++ b/src/utilities/behaviors/JointCollisionEvents.js @@ -48,21 +48,7 @@ altspace.utilities.behaviors.JointCollisionEvents = function(_config) { var config = _config || {}; config.jointCubeSize = config.jointCubeSize || 15; - config.joints = config.joints || [ - ['Hand', 'Left', 0], - ['Thumb', 'Left', 3], - ['Index', 'Left', 3], - ['Middle', 'Left', 3], - ['Ring', 'Left', 3], - ['Pinky', 'Left', 3], - - ['Hand', 'Right', 0], - ['Thumb', 'Right', 3], - ['Index', 'Right', 3], - ['Middle', 'Right', 3], - ['Ring', 'Right', 3], - ['Pinky', 'Right', 3], - ]; + config.joints = config.joints || altspace.utilities.behaviors.JointCollisionEvents.HAND_JOINTS; var skeleton; var jointCube; @@ -233,3 +219,18 @@ altspace.utilities.behaviors.JointCollisionEvents = function(_config) { return { awake: awake, update: update, type: 'JointCollisionEvents' }; }; +altspace.utilities.behaviors.JointCollisionEvents.HAND_JOINTS = [ + ['Hand', 'Left', 0], + ['Thumb', 'Left', 3], + ['Index', 'Left', 3], + ['Middle', 'Left', 3], + ['Ring', 'Left', 3], + ['Pinky', 'Left', 3], + + ['Hand', 'Right', 0], + ['Thumb', 'Right', 3], + ['Index', 'Right', 3], + ['Middle', 'Right', 3], + ['Ring', 'Right', 3], + ['Pinky', 'Right', 3], +];