소스 검색

Fix pinch threshold

Fernando Serrano 5 년 전
부모
커밋
5987375b9a
2개의 변경된 파일6개의 추가작업 그리고 3개의 파일을 삭제
  1. 4 3
      src/renderers/webxr/WebXRController.js
  2. 2 0
      src/renderers/webxr/WebXRManager.js

+ 4 - 3
src/renderers/webxr/WebXRController.js

@@ -39,7 +39,6 @@ Object.assign( WebXRController.prototype, {
 					// ??
 					this._hand.add( joint );
 
-
 				}
 
 			}
@@ -167,8 +166,10 @@ Object.assign( WebXRController.prototype, {
 						const indexTip = hand.joints[ XRHand.INDEX_PHALANX_TIP ];
 						const thumbTip = hand.joints[ XRHand.THUMB_PHALANX_TIP ];
 						const distance = indexTip.position.distanceTo( thumbTip.position );
+
 						const distanceToPinch = 0.02;
-						if ( hand.inputState.pinching && distance > distanceToPinch ) {
+						const threshold = 0.005;
+						if ( hand.inputState.pinching && distance > distanceToPinch + threshold ) {
 
 							hand.inputState.pinching = false;
 							this.dispatchEvent( {
@@ -176,7 +177,7 @@ Object.assign( WebXRController.prototype, {
 								target: this
 							} );
 
-						} else if ( ! hand.inputState.pinching && distance <= distanceToPinch ) {
+						} else if ( ! hand.inputState.pinching && distance <= distanceToPinch - threshold ) {
 
 							hand.inputState.pinching = true;
 							this.dispatchEvent( {

+ 2 - 0
src/renderers/webxr/WebXRManager.js

@@ -230,6 +230,8 @@ function WebXRManager( renderer, gl ) {
 
 		const inputSources = session.inputSources;
 
+		console.log("Update sources", inputSources);
+
 		// Assign inputSources to available controllers
 
 		for ( let i = 0; i < controllers.length; i ++ ) {