Skip to content

Commit

Permalink
Update builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 committed Jan 25, 2021
1 parent 87e6d9e commit 657b36d
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 103 deletions.
140 changes: 90 additions & 50 deletions build/three.js
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,48 @@
return self;
}

function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}

function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;

for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];

return arr2;
}

function _createForOfIteratorHelperLoose(o, allowArrayLike) {
var it;

if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
return function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
};
}

throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}

it = o[Symbol.iterator]();
return it.next.bind(it);
}

/**
* https://github.com/mrdoob/eventdispatcher.js/
*/
Expand Down Expand Up @@ -17068,24 +17110,10 @@
this._hand = new Group();
this._hand.matrixAutoUpdate = false;
this._hand.visible = false;
this._hand.joints = [];
this._hand.joints = {};
this._hand.inputState = {
pinching: false
};

if (window.XRHand) {
for (var i = 0; i <= window.XRHand.LITTLE_PHALANX_TIP; i++) {
// The transform of this joint will be updated with the joint pose on each frame
var joint = new Group();
joint.matrixAutoUpdate = false;
joint.visible = false;

this._hand.joints.push(joint); // ??


this._hand.add(joint);
}
}
}

return this._hand;
Expand Down Expand Up @@ -17155,43 +17183,55 @@
if (hand && inputSource.hand) {
handPose = true;

for (var i = 0; i <= window.XRHand.LITTLE_PHALANX_TIP; i++) {
if (inputSource.hand[i]) {
// Update the joints groups with the XRJoint poses
var jointPose = frame.getJointPose(inputSource.hand[i], referenceSpace);
var joint = hand.joints[i];
for (var _iterator = _createForOfIteratorHelperLoose(inputSource.hand.values()), _step; !(_step = _iterator()).done;) {
var inputjoint = _step.value;
// Update the joints groups with the XRJoint poses
var jointPose = frame.getJointPose(inputjoint, referenceSpace);

if (jointPose !== null) {
joint.matrix.fromArray(jointPose.transform.matrix);
joint.matrix.decompose(joint.position, joint.rotation, joint.scale);
joint.jointRadius = jointPose.radius;
}
if (hand.joints[inputjoint.jointName] === undefined) {
// The transform of this joint will be updated with the joint pose on each frame
var _joint = new Group();

joint.visible = jointPose !== null; // Custom events
// Check pinch

var indexTip = hand.joints[window.XRHand.INDEX_PHALANX_TIP];
var thumbTip = hand.joints[window.XRHand.THUMB_PHALANX_TIP];
var distance = indexTip.position.distanceTo(thumbTip.position);
var distanceToPinch = 0.02;
var threshold = 0.005;

if (hand.inputState.pinching && distance > distanceToPinch + threshold) {
hand.inputState.pinching = false;
this.dispatchEvent({
type: 'pinchend',
handedness: inputSource.handedness,
target: this
});
} else if (!hand.inputState.pinching && distance <= distanceToPinch - threshold) {
hand.inputState.pinching = true;
this.dispatchEvent({
type: 'pinchstart',
handedness: inputSource.handedness,
target: this
});
}
_joint.matrixAutoUpdate = false;
_joint.visible = false;
hand.joints[inputjoint.jointName] = _joint; // ??

hand.add(_joint);
}

var joint = hand.joints[inputjoint.jointName];

if (jointPose !== null) {
joint.matrix.fromArray(jointPose.transform.matrix);
joint.matrix.decompose(joint.position, joint.rotation, joint.scale);
joint.jointRadius = jointPose.radius;
}

joint.visible = jointPose !== null;
} // Custom events
// Check pinchz


var indexTip = hand.joints['index-finger-tip'];
var thumbTip = hand.joints['thumb-tip'];
var distance = indexTip.position.distanceTo(thumbTip.position);
var distanceToPinch = 0.02;
var threshold = 0.005;

if (hand.inputState.pinching && distance > distanceToPinch + threshold) {
hand.inputState.pinching = false;
this.dispatchEvent({
type: 'pinchend',
handedness: inputSource.handedness,
target: this
});
} else if (!hand.inputState.pinching && distance <= distanceToPinch - threshold) {
hand.inputState.pinching = true;
this.dispatchEvent({
type: 'pinchstart',
handedness: inputSource.handedness,
target: this
});
}
} else {
if (targetRay !== null) {
Expand Down Expand Up @@ -36824,7 +36864,7 @@

}

if (window) {
if (typeof window !== 'undefined') {
if (window.__THREE__) {
console.warn('WARNING: Multiple instances of Three.js being imported.');
} else {
Expand Down
2 changes: 1 addition & 1 deletion build/three.min.js

Large diffs are not rendered by default.

97 changes: 45 additions & 52 deletions build/three.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -21528,25 +21528,9 @@ Object.assign( WebXRController.prototype, {
this._hand.matrixAutoUpdate = false;
this._hand.visible = false;

this._hand.joints = [];
this._hand.joints = {};
this._hand.inputState = { pinching: false };

if ( window.XRHand ) {

for ( let i = 0; i <= window.XRHand.LITTLE_PHALANX_TIP; i ++ ) {

// The transform of this joint will be updated with the joint pose on each frame
const joint = new Group();
joint.matrixAutoUpdate = false;
joint.visible = false;
this._hand.joints.push( joint );
// ??
this._hand.add( joint );

}

}

}

return this._hand;
Expand Down Expand Up @@ -21647,55 +21631,64 @@ Object.assign( WebXRController.prototype, {

handPose = true;

for ( let i = 0; i <= window.XRHand.LITTLE_PHALANX_TIP; i ++ ) {
for ( const inputjoint of inputSource.hand.values() ) {

if ( inputSource.hand[ i ] ) {
// Update the joints groups with the XRJoint poses
const jointPose = frame.getJointPose( inputjoint, referenceSpace );

// Update the joints groups with the XRJoint poses
const jointPose = frame.getJointPose( inputSource.hand[ i ], referenceSpace );
const joint = hand.joints[ i ];
if ( hand.joints[ inputjoint.jointName ] === undefined ) {

if ( jointPose !== null ) {
// The transform of this joint will be updated with the joint pose on each frame
const joint = new Group();
joint.matrixAutoUpdate = false;
joint.visible = false;
hand.joints[ inputjoint.jointName ] = joint;
// ??
hand.add( joint );

joint.matrix.fromArray( jointPose.transform.matrix );
joint.matrix.decompose( joint.position, joint.rotation, joint.scale );
joint.jointRadius = jointPose.radius;
}

}
const joint = hand.joints[ inputjoint.jointName ];

joint.visible = jointPose !== null;
if ( jointPose !== null ) {

// Custom events
joint.matrix.fromArray( jointPose.transform.matrix );
joint.matrix.decompose( joint.position, joint.rotation, joint.scale );
joint.jointRadius = jointPose.radius;

// Check pinch
const indexTip = hand.joints[ window.XRHand.INDEX_PHALANX_TIP ];
const thumbTip = hand.joints[ window.XRHand.THUMB_PHALANX_TIP ];
const distance = indexTip.position.distanceTo( thumbTip.position );
}

const distanceToPinch = 0.02;
const threshold = 0.005;
joint.visible = jointPose !== null;

if ( hand.inputState.pinching && distance > distanceToPinch + threshold ) {
}

hand.inputState.pinching = false;
this.dispatchEvent( {
type: 'pinchend',
handedness: inputSource.handedness,
target: this
} );
// Custom events

} else if ( ! hand.inputState.pinching && distance <= distanceToPinch - threshold ) {
// Check pinchz
const indexTip = hand.joints[ 'index-finger-tip' ];
const thumbTip = hand.joints[ 'thumb-tip' ];
const distance = indexTip.position.distanceTo( thumbTip.position );

hand.inputState.pinching = true;
this.dispatchEvent( {
type: 'pinchstart',
handedness: inputSource.handedness,
target: this
} );
const distanceToPinch = 0.02;
const threshold = 0.005;

}
if ( hand.inputState.pinching && distance > distanceToPinch + threshold ) {

}
hand.inputState.pinching = false;
this.dispatchEvent( {
type: 'pinchend',
handedness: inputSource.handedness,
target: this
} );

} else if ( ! hand.inputState.pinching && distance <= distanceToPinch - threshold ) {

hand.inputState.pinching = true;
this.dispatchEvent( {
type: 'pinchstart',
handedness: inputSource.handedness,
target: this
} );

}

Expand Down Expand Up @@ -49005,7 +48998,7 @@ if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {

}

if ( window ) {
if ( typeof window !== 'undefined' ) {

if ( window.__THREE__ ) {

Expand Down

0 comments on commit 657b36d

Please sign in to comment.