Skip to content

Commit 657b36d

Browse files
committed
Update builds.
1 parent 87e6d9e commit 657b36d

File tree

3 files changed

+136
-103
lines changed

3 files changed

+136
-103
lines changed

build/three.js

Lines changed: 90 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,48 @@
10581058
return self;
10591059
}
10601060

1061+
function _unsupportedIterableToArray(o, minLen) {
1062+
if (!o) return;
1063+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
1064+
var n = Object.prototype.toString.call(o).slice(8, -1);
1065+
if (n === "Object" && o.constructor) n = o.constructor.name;
1066+
if (n === "Map" || n === "Set") return Array.from(o);
1067+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
1068+
}
1069+
1070+
function _arrayLikeToArray(arr, len) {
1071+
if (len == null || len > arr.length) len = arr.length;
1072+
1073+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
1074+
1075+
return arr2;
1076+
}
1077+
1078+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
1079+
var it;
1080+
1081+
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
1082+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
1083+
if (it) o = it;
1084+
var i = 0;
1085+
return function () {
1086+
if (i >= o.length) return {
1087+
done: true
1088+
};
1089+
return {
1090+
done: false,
1091+
value: o[i++]
1092+
};
1093+
};
1094+
}
1095+
1096+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1097+
}
1098+
1099+
it = o[Symbol.iterator]();
1100+
return it.next.bind(it);
1101+
}
1102+
10611103
/**
10621104
* https://github.com/mrdoob/eventdispatcher.js/
10631105
*/
@@ -17068,24 +17110,10 @@
1706817110
this._hand = new Group();
1706917111
this._hand.matrixAutoUpdate = false;
1707017112
this._hand.visible = false;
17071-
this._hand.joints = [];
17113+
this._hand.joints = {};
1707217114
this._hand.inputState = {
1707317115
pinching: false
1707417116
};
17075-
17076-
if (window.XRHand) {
17077-
for (var i = 0; i <= window.XRHand.LITTLE_PHALANX_TIP; i++) {
17078-
// The transform of this joint will be updated with the joint pose on each frame
17079-
var joint = new Group();
17080-
joint.matrixAutoUpdate = false;
17081-
joint.visible = false;
17082-
17083-
this._hand.joints.push(joint); // ??
17084-
17085-
17086-
this._hand.add(joint);
17087-
}
17088-
}
1708917117
}
1709017118

1709117119
return this._hand;
@@ -17155,43 +17183,55 @@
1715517183
if (hand && inputSource.hand) {
1715617184
handPose = true;
1715717185

17158-
for (var i = 0; i <= window.XRHand.LITTLE_PHALANX_TIP; i++) {
17159-
if (inputSource.hand[i]) {
17160-
// Update the joints groups with the XRJoint poses
17161-
var jointPose = frame.getJointPose(inputSource.hand[i], referenceSpace);
17162-
var joint = hand.joints[i];
17186+
for (var _iterator = _createForOfIteratorHelperLoose(inputSource.hand.values()), _step; !(_step = _iterator()).done;) {
17187+
var inputjoint = _step.value;
17188+
// Update the joints groups with the XRJoint poses
17189+
var jointPose = frame.getJointPose(inputjoint, referenceSpace);
1716317190

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

17170-
joint.visible = jointPose !== null; // Custom events
17171-
// Check pinch
17172-
17173-
var indexTip = hand.joints[window.XRHand.INDEX_PHALANX_TIP];
17174-
var thumbTip = hand.joints[window.XRHand.THUMB_PHALANX_TIP];
17175-
var distance = indexTip.position.distanceTo(thumbTip.position);
17176-
var distanceToPinch = 0.02;
17177-
var threshold = 0.005;
17178-
17179-
if (hand.inputState.pinching && distance > distanceToPinch + threshold) {
17180-
hand.inputState.pinching = false;
17181-
this.dispatchEvent({
17182-
type: 'pinchend',
17183-
handedness: inputSource.handedness,
17184-
target: this
17185-
});
17186-
} else if (!hand.inputState.pinching && distance <= distanceToPinch - threshold) {
17187-
hand.inputState.pinching = true;
17188-
this.dispatchEvent({
17189-
type: 'pinchstart',
17190-
handedness: inputSource.handedness,
17191-
target: this
17192-
});
17193-
}
17195+
_joint.matrixAutoUpdate = false;
17196+
_joint.visible = false;
17197+
hand.joints[inputjoint.jointName] = _joint; // ??
17198+
17199+
hand.add(_joint);
1719417200
}
17201+
17202+
var joint = hand.joints[inputjoint.jointName];
17203+
17204+
if (jointPose !== null) {
17205+
joint.matrix.fromArray(jointPose.transform.matrix);
17206+
joint.matrix.decompose(joint.position, joint.rotation, joint.scale);
17207+
joint.jointRadius = jointPose.radius;
17208+
}
17209+
17210+
joint.visible = jointPose !== null;
17211+
} // Custom events
17212+
// Check pinchz
17213+
17214+
17215+
var indexTip = hand.joints['index-finger-tip'];
17216+
var thumbTip = hand.joints['thumb-tip'];
17217+
var distance = indexTip.position.distanceTo(thumbTip.position);
17218+
var distanceToPinch = 0.02;
17219+
var threshold = 0.005;
17220+
17221+
if (hand.inputState.pinching && distance > distanceToPinch + threshold) {
17222+
hand.inputState.pinching = false;
17223+
this.dispatchEvent({
17224+
type: 'pinchend',
17225+
handedness: inputSource.handedness,
17226+
target: this
17227+
});
17228+
} else if (!hand.inputState.pinching && distance <= distanceToPinch - threshold) {
17229+
hand.inputState.pinching = true;
17230+
this.dispatchEvent({
17231+
type: 'pinchstart',
17232+
handedness: inputSource.handedness,
17233+
target: this
17234+
});
1719517235
}
1719617236
} else {
1719717237
if (targetRay !== null) {
@@ -36824,7 +36864,7 @@
3682436864

3682536865
}
3682636866

36827-
if (window) {
36867+
if (typeof window !== 'undefined') {
3682836868
if (window.__THREE__) {
3682936869
console.warn('WARNING: Multiple instances of Three.js being imported.');
3683036870
} else {

build/three.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/three.module.js

Lines changed: 45 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -21528,25 +21528,9 @@ Object.assign( WebXRController.prototype, {
2152821528
this._hand.matrixAutoUpdate = false;
2152921529
this._hand.visible = false;
2153021530

21531-
this._hand.joints = [];
21531+
this._hand.joints = {};
2153221532
this._hand.inputState = { pinching: false };
2153321533

21534-
if ( window.XRHand ) {
21535-
21536-
for ( let i = 0; i <= window.XRHand.LITTLE_PHALANX_TIP; i ++ ) {
21537-
21538-
// The transform of this joint will be updated with the joint pose on each frame
21539-
const joint = new Group();
21540-
joint.matrixAutoUpdate = false;
21541-
joint.visible = false;
21542-
this._hand.joints.push( joint );
21543-
// ??
21544-
this._hand.add( joint );
21545-
21546-
}
21547-
21548-
}
21549-
2155021534
}
2155121535

2155221536
return this._hand;
@@ -21647,55 +21631,64 @@ Object.assign( WebXRController.prototype, {
2164721631

2164821632
handPose = true;
2164921633

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

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

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

21658-
if ( jointPose !== null ) {
21641+
// The transform of this joint will be updated with the joint pose on each frame
21642+
const joint = new Group();
21643+
joint.matrixAutoUpdate = false;
21644+
joint.visible = false;
21645+
hand.joints[ inputjoint.jointName ] = joint;
21646+
// ??
21647+
hand.add( joint );
2165921648

21660-
joint.matrix.fromArray( jointPose.transform.matrix );
21661-
joint.matrix.decompose( joint.position, joint.rotation, joint.scale );
21662-
joint.jointRadius = jointPose.radius;
21649+
}
2166321650

21664-
}
21651+
const joint = hand.joints[ inputjoint.jointName ];
2166521652

21666-
joint.visible = jointPose !== null;
21653+
if ( jointPose !== null ) {
2166721654

21668-
// Custom events
21655+
joint.matrix.fromArray( jointPose.transform.matrix );
21656+
joint.matrix.decompose( joint.position, joint.rotation, joint.scale );
21657+
joint.jointRadius = jointPose.radius;
2166921658

21670-
// Check pinch
21671-
const indexTip = hand.joints[ window.XRHand.INDEX_PHALANX_TIP ];
21672-
const thumbTip = hand.joints[ window.XRHand.THUMB_PHALANX_TIP ];
21673-
const distance = indexTip.position.distanceTo( thumbTip.position );
21659+
}
2167421660

21675-
const distanceToPinch = 0.02;
21676-
const threshold = 0.005;
21661+
joint.visible = jointPose !== null;
2167721662

21678-
if ( hand.inputState.pinching && distance > distanceToPinch + threshold ) {
21663+
}
2167921664

21680-
hand.inputState.pinching = false;
21681-
this.dispatchEvent( {
21682-
type: 'pinchend',
21683-
handedness: inputSource.handedness,
21684-
target: this
21685-
} );
21665+
// Custom events
2168621666

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

21689-
hand.inputState.pinching = true;
21690-
this.dispatchEvent( {
21691-
type: 'pinchstart',
21692-
handedness: inputSource.handedness,
21693-
target: this
21694-
} );
21672+
const distanceToPinch = 0.02;
21673+
const threshold = 0.005;
2169521674

21696-
}
21675+
if ( hand.inputState.pinching && distance > distanceToPinch + threshold ) {
2169721676

21698-
}
21677+
hand.inputState.pinching = false;
21678+
this.dispatchEvent( {
21679+
type: 'pinchend',
21680+
handedness: inputSource.handedness,
21681+
target: this
21682+
} );
21683+
21684+
} else if ( ! hand.inputState.pinching && distance <= distanceToPinch - threshold ) {
21685+
21686+
hand.inputState.pinching = true;
21687+
this.dispatchEvent( {
21688+
type: 'pinchstart',
21689+
handedness: inputSource.handedness,
21690+
target: this
21691+
} );
2169921692

2170021693
}
2170121694

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

4900648999
}
4900749000

49008-
if ( window ) {
49001+
if ( typeof window !== 'undefined' ) {
4900949002

4901049003
if ( window.__THREE__ ) {
4901149004

0 commit comments

Comments
 (0)