Browse Source

WebXRManager: Update controller matrices before dispatching event. (#25951)

mrdoob 2 years ago
parent
commit
deabd3bd83
2 changed files with 4 additions and 0 deletions
  1. 3 0
      src/renderers/webxr/WebXRController.js
  2. 1 0
      src/renderers/webxr/WebXRManager.js

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

@@ -169,6 +169,7 @@ class WebXRController {
 
 
 						joint.matrix.fromArray( jointPose.transform.matrix );
 						joint.matrix.fromArray( jointPose.transform.matrix );
 						joint.matrix.decompose( joint.position, joint.rotation, joint.scale );
 						joint.matrix.decompose( joint.position, joint.rotation, joint.scale );
+						joint.matrixWorldNeedsUpdate = true;
 						joint.jointRadius = jointPose.radius;
 						joint.jointRadius = jointPose.radius;
 
 
 					}
 					}
@@ -217,6 +218,7 @@ class WebXRController {
 
 
 						grip.matrix.fromArray( gripPose.transform.matrix );
 						grip.matrix.fromArray( gripPose.transform.matrix );
 						grip.matrix.decompose( grip.position, grip.rotation, grip.scale );
 						grip.matrix.decompose( grip.position, grip.rotation, grip.scale );
+						grip.matrixWorldNeedsUpdate = true;
 
 
 						if ( gripPose.linearVelocity ) {
 						if ( gripPose.linearVelocity ) {
 
 
@@ -261,6 +263,7 @@ class WebXRController {
 
 
 					targetRay.matrix.fromArray( inputPose.transform.matrix );
 					targetRay.matrix.fromArray( inputPose.transform.matrix );
 					targetRay.matrix.decompose( targetRay.position, targetRay.rotation, targetRay.scale );
 					targetRay.matrix.decompose( targetRay.position, targetRay.rotation, targetRay.scale );
+					targetRay.matrixWorldNeedsUpdate = true;
 
 
 					if ( inputPose.linearVelocity ) {
 					if ( inputPose.linearVelocity ) {
 
 

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

@@ -130,6 +130,7 @@ class WebXRManager extends EventDispatcher {
 
 
 			if ( controller !== undefined ) {
 			if ( controller !== undefined ) {
 
 
+				controller.update( event.inputSource, event.frame, customReferenceSpace || referenceSpace );
 				controller.dispatchEvent( { type: event.type, data: event.inputSource } );
 				controller.dispatchEvent( { type: event.type, data: event.inputSource } );
 
 
 			}
 			}