Skip to content

Commit

Permalink
Merge pull request #172 from AltspaceVR/feature/headbutt-cube
Browse files Browse the repository at this point in the history
headbutt cube
  • Loading branch information
brianpeiris authored Dec 6, 2016
2 parents 15e869e + bfaa85c commit a72fdf2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
10 changes: 7 additions & 3 deletions examples/joint-collision-push.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

var sim = altspace.utilities.Simulation();
var pushOffset = 2;
var cubePos = 80;
var button;
var cubePositionRef;
var enclosure;
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down
31 changes: 16 additions & 15 deletions src/utilities/behaviors/JointCollisionEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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],
];

0 comments on commit a72fdf2

Please sign in to comment.