|
@@ -8,6 +8,7 @@ function WebXRController() {
|
|
|
|
|
|
this._targetRay = null;
|
|
|
this._grip = null;
|
|
|
+ this._hand = null;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -15,6 +16,20 @@ Object.assign( WebXRController.prototype, {
|
|
|
|
|
|
constructor: WebXRController,
|
|
|
|
|
|
+ getHandSpace: function () {
|
|
|
+
|
|
|
+ if ( this._hand === null ) {
|
|
|
+
|
|
|
+ this._hand = new Group();
|
|
|
+ this._hand.matrixAutoUpdate = false;
|
|
|
+ this._hand.visible = false;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return this._hand;
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
getTargetRaySpace: function () {
|
|
|
|
|
|
if ( this._targetRay === null ) {
|
|
@@ -57,6 +72,12 @@ Object.assign( WebXRController.prototype, {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ if ( this._hand !== null ) {
|
|
|
+
|
|
|
+ this._hand.dispatchEvent( event );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
return this;
|
|
|
|
|
|
},
|
|
@@ -77,6 +98,12 @@ Object.assign( WebXRController.prototype, {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ if ( this._hand !== null ) {
|
|
|
+
|
|
|
+ this._hand.visible = false;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
return this;
|
|
|
|
|
|
},
|
|
@@ -85,33 +112,41 @@ Object.assign( WebXRController.prototype, {
|
|
|
|
|
|
let inputPose = null;
|
|
|
let gripPose = null;
|
|
|
+ let handPose = null;
|
|
|
|
|
|
const targetRay = this._targetRay;
|
|
|
const grip = this._grip;
|
|
|
+ const hand = this._hand;
|
|
|
|
|
|
if ( inputSource ) {
|
|
|
|
|
|
- if ( targetRay !== null ) {
|
|
|
+ if ( inputSource.hand ) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if ( targetRay !== null ) {
|
|
|
|
|
|
- inputPose = frame.getPose( inputSource.targetRaySpace, referenceSpace );
|
|
|
+ inputPose = frame.getPose( inputSource.targetRaySpace, referenceSpace );
|
|
|
|
|
|
- if ( inputPose !== null ) {
|
|
|
+ if ( inputPose !== null ) {
|
|
|
|
|
|
- targetRay.matrix.fromArray( inputPose.transform.matrix );
|
|
|
- targetRay.matrix.decompose( targetRay.position, targetRay.rotation, targetRay.scale );
|
|
|
+ targetRay.matrix.fromArray( inputPose.transform.matrix );
|
|
|
+ targetRay.matrix.decompose( targetRay.position, targetRay.rotation, targetRay.scale );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
+ if ( grip !== null && inputSource.gripSpace ) {
|
|
|
|
|
|
- if ( grip !== null && inputSource.gripSpace ) {
|
|
|
+ gripPose = frame.getPose( inputSource.gripSpace, referenceSpace );
|
|
|
|
|
|
- gripPose = frame.getPose( inputSource.gripSpace, referenceSpace );
|
|
|
+ if ( gripPose !== null ) {
|
|
|
|
|
|
- if ( gripPose !== null ) {
|
|
|
+ grip.matrix.fromArray( gripPose.transform.matrix );
|
|
|
+ grip.matrix.decompose( grip.position, grip.rotation, grip.scale );
|
|
|
|
|
|
- grip.matrix.fromArray( gripPose.transform.matrix );
|
|
|
- grip.matrix.decompose( grip.position, grip.rotation, grip.scale );
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -131,6 +166,12 @@ Object.assign( WebXRController.prototype, {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ if ( hand !== null ) {
|
|
|
+
|
|
|
+ hand.visible = ( handPose !== null );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
return this;
|
|
|
|
|
|
}
|