Skip to content

Commit

Permalink
Bump release v0.26.0
Browse files Browse the repository at this point in the history
  • Loading branch information
altspaceautobot committed Dec 6, 2016
1 parent a72fdf2 commit 8a17bf8
Show file tree
Hide file tree
Showing 39 changed files with 1,024 additions and 121 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The AltspaceVR SDK can be used together with [three.js] to create holographic, multi-user web apps for virtual reality. When running inside [AltspaceVR](http://altvr.com/) they can be experienced with consumer VR hardware including the Oculus Rift DK2.

**Latest Version: v0.25.0 -- [See Changes](https://github.com/AltspaceVR/AltspaceSDK/releases/tag/v0.25.0)**
**Latest Version: v0.26.0 -- [See Changes](https://github.com/AltspaceVR/AltspaceSDK/releases/tag/v0.26.0)**

<!--
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand Down Expand Up @@ -32,7 +32,7 @@ Many APIs are present in the client without loading `altspace.js`, but please st

Include the latest version of Altspace in your app with:

`<script src="http://sdk.altvr.com/libs/altspace.js/0.25.0/altspace.min.js"></script>`
`<script src="http://sdk.altvr.com/libs/altspace.js/0.26.0/altspace.min.js"></script>`

If you use npm, you can install altspace.js with:

Expand Down
238 changes: 170 additions & 68 deletions dist/altspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -4641,11 +4641,21 @@ window.altspace.utilities = window.altspace.utilities || {};
window.altspace.utilities.behaviors = window.altspace.utilities.behaviors || {};

/**
* The JointCollisionEvents behavior dispatches a 'jointcollision' event if
* joints collide with an object
* An array in the form of `[bodyPart, side, subIndex]` identifying a joint in the tracking skeleton.
* E.g. `['Index', 'Left', 0]` identifies the first joint on the index finger of the left hand.
* See [TrackingSkeleton#getJoint]{@link module:altspace~TrackingSkeleton#getJoint} for available
* joint names.
* @typedef {Array.<String, String, Number>} module:altspace/utilities/behaviors.JointCollisionEvents~JointId
**/

/**
* The JointCollisionEvents behavior dispatches collision events which have been triggered by
* [TrackingJoints]{@link module:altspace~TrackingJoint} intersecting with the object that has this behavior.
*
* @class JointCollisionEvents
* @param {String} [config.joints] Array of body part names [bodyPart, side, subIndex] of joints to track.<br>
* @param {Object} [config] Optional parameters.
* @param {Array.<JointId>} [config.joints] Array of
* [JointIds]{@link module:altspace/utilities/behaviors.JointCollisionEvents~JointId} to track.<br>
* Defaults to:
*
* [
Expand All @@ -4663,58 +4673,67 @@ window.altspace.utilities.behaviors = window.altspace.utilities.behaviors || {};
* ['Ring', 'Right', 3],
* ['Pinky', 'Right', 3],
* ]
* @param {Number} [config.jointCubeSize=15] Size of dummy cube used to track each joint
* @param {Number} [config.jointCubeSize=15] Size of dummy cube used to track each joint.
* For optimal results, it is recommended that the value
* provided is scaled according to your enclosure scaling factor.
* @memberof module:altspace/utilities/behaviors
**/
// TODO: Add scale option?
altspace.utilities.behaviors.JointCollisionEvents = function (config) {
altspace.utilities.behaviors.JointCollisionEvents = function(_config) {
var object3d;
var config = _config || {};

config = config || {};

if (config.jointCubeSize === undefined) config.jointCubeSize = 15;
if (config.joints === undefined) 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.jointCubeSize = config.jointCubeSize || 15;
config.joints = config.joints || altspace.utilities.behaviors.JointCollisionEvents.HAND_JOINTS;

var skeleton;
var jointCube;
var hasCollided = false;
var collidedJoints = [];
var jointIntersectUnion = null;

// Get the tracking skeleton and the enclosure
var promises = [altspace.getThreeJSTrackingSkeleton(), altspace.getEnclosure()];
Promise.all(promises).then(function (array) {
// Attach skeleton
skeleton = array[0];
sim.scene.add(skeleton);
enclosure = array[1]; // TODO: Use enclosure for scale?
}).catch(function (err) {
console.log('Failed to get Altspace browser properties', err);
});
function initSkeleton(scene) {
return new Promise(function(resolve, reject) {
var skel = null;

function awake(o) {
// Attempt to use existing skeleton when available
scene.traverse(function(child) {
if(child.type === 'TrackingSkeleton') {
skel = child;
return;
}
});

if(skel) return resolve(skel);

// Skeleton has not been assigned to scene yet
altspace.getThreeJSTrackingSkeleton().then(function(trackingSkeleton) {
skel = trackingSkeleton;
scene.add(skel);
return resolve(skel);
});
});
}

function awake(o, s) {
object3d = o;
// TODO: Scale jointCubeSize?
jointCube = new THREE.Vector3(
config.jointCubeSize,
config.jointCubeSize,
config.jointCubeSize
);

// Get the tracking skeleton
initSkeleton(s).then(function(_skeleton) {
// Attach skeleton
skeleton = _skeleton;

jointCube = new THREE.Vector3(
config.jointCubeSize,
config.jointCubeSize,
config.jointCubeSize
);
}).catch(function (err) {
console.log('Failed to get tracking skeleton', err);
});
}

function update(deltaTime) {
if(!skeleton) { return; }
if(!skeleton) return;

// Collect joints based on joints config option
var joints = [];
Expand All @@ -4730,43 +4749,126 @@ altspace.utilities.behaviors.JointCollisionEvents = function (config) {
var objectBB = new THREE.Box3().setFromObject(object3d);

// Add up all colliding joint intersects
var jointIntersectUnion;
var hasCollided = false;
for(var i = 0; i < config.joints.length; i++) {
var joint = joints[i];
if(joint && joint.confidence !== 0) {
var jointBB = new THREE.Box3().setFromCenterAndSize(joint.position, jointCube);
var collision = objectBB.intersectsBox(jointBB);
if(collision) {
var intersectBB = objectBB.intersect(jointBB);
if(jointIntersectUnion) {
jointIntersectUnion.union(intersectBB);
} else {
jointIntersectUnion = intersectBB;
var prevJointIntersectUnion = jointIntersectUnion;
jointIntersectUnion = null;

var prevCollidedJoints = collidedJoints;
collidedJoints = [];

var hasPrevCollided = hasCollided;
hasCollided = false;

if(
object3d.visible &&
object3d.scale.x > Number.EPSILON &&
object3d.scale.y > Number.EPSILON &&
object3d.scale.z > Number.EPSILON
) {
for(var i = 0; i < config.joints.length; i++) {
var joint = joints[i];
if(joint && joint.confidence !== 0) {
var jointBB = new THREE.Box3().setFromCenterAndSize(joint.position, jointCube);
var collision = objectBB.intersectsBox(jointBB);
if(collision) {
var intersectBB = objectBB.intersect(jointBB);
if(jointIntersectUnion) {
jointIntersectUnion.union(intersectBB);
} else {
jointIntersectUnion = intersectBB;
}

hasCollided = true;
collidedJoints.push(joint);
}
hasCollided = true;
}
}
}

// Dispatch collision event
if(!hasPrevCollided && hasCollided) {
/**
* Fires a single event when any specified joints initially collide with the object.
*
* @event jointcollisionenter
* @property {Object} detail Event details
* @property {THREE.Box3} detail.intersect - A union of all joint bounding boxes which intersected with object.
* @property {module:altspace~TrackingJoint[]} detail.joints - An array of joints which which were involved in the intersection union.
* @property {THREE.Object3D} target - The object which was intersected.
* @memberof module:altspace/utilities/behaviors.JointCollisionEvents
*/
object3d.dispatchEvent({
type: 'jointcollisionenter',
detail: {
intersect: jointIntersectUnion,
joints: collidedJoints
},
bubbles: true,
target: object3d
});
}
else if(hasPrevCollided && !hasCollided) {
/**
* Fires a single event when all joints are no longer colliding with the object.
*
* @event jointcollisionleave
* @property {Object} detail Event details
* @property {THREE.Box3} detail.intersect - A union of all joint bounding boxes which last intersected with the object.
* @property {module:altspace~TrackingJoint[]} detail.joints - An array of joints which which were involved in the intersection union.
* @property {THREE.Object3D} target - The object which was intersected.
* @memberof module:altspace/utilities/behaviors.JointCollisionEvents
*/
object3d.dispatchEvent({
type: 'jointcollisionleave',
detail: {
intersect: prevJointIntersectUnion || new THREE.Box3(),
joints: prevCollidedJoints
},
bubbles: true,
target: object3d
});
}

// Dispatch collision event
if(hasCollided) {
var event = new CustomEvent(
'jointcollision',
{
detail: {
intersect: jointIntersectUnion
},
bubbles: true,
cancelable: true
}
);
object3d.dispatchEvent(event);
/**
* Fires a continuous event while any joints are colliding with the object.
*
* @event jointcollision
* @property {Object} detail Event details
* @property {THREE.Box3} detail.intersect - A union of all joint bounding boxes which intersected with the object.
* @property {module:altspace~TrackingJoint[]} detail.joints - An array of joints which which were involved in the intersection union.
* @property {THREE.Object3D} target - The object which was intersected.
* @memberof module:altspace/utilities/behaviors.JointCollisionEvents
*/
object3d.dispatchEvent({
type: 'jointcollision',
detail: {
intersect: jointIntersectUnion,
joints: collidedJoints
},
bubbles: true,
target: object3d
});
}
}

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],
];

window.altspace = window.altspace || {};
window.altspace.utilities = window.altspace.utilities || {};
Expand Down Expand Up @@ -11429,7 +11531,7 @@ window.altspace.utilities.behaviors.SteamVRTrackedObject = SteamVRTrackedObjectB

(function () {

var version = '0.25.0';
var version = '0.26.0';

if (window.altspace && window.altspace.requestVersion) {
window.altspace.requestVersion(version);
Expand Down
10 changes: 5 additions & 5 deletions dist/altspace.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/maps/altspace.min.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 8a17bf8

Please sign in to comment.