internal void OnUpdate() { if (!reportedXRStateSwitch) { reportedXRStateSwitch = true; OnXRChange?.Invoke(xrState, viewsCount, leftRect, rightRect); } if (!updatedControllersOnEnd) { updatedControllersOnEnd = true; UpdateControllersOnEnd(); } if (visibilityStateChanged) { visibilityStateChanged = false; OnVisibilityChange?.Invoke(visibilityState); } if (this.xrState == WebXRState.NORMAL) { return; } UpdateXRCameras(); bool hasHandsData = false; if (OnHandUpdate != null && this.xrState != WebXRState.NORMAL) { if (GetHandFromHandsArray(0, ref leftHand)) { OnHandUpdate?.Invoke(leftHand); } if (GetHandFromHandsArray(1, ref rightHand)) { OnHandUpdate?.Invoke(rightHand); } hasHandsData = leftHand.enabled || rightHand.enabled; } if (!hasHandsData && OnControllerUpdate != null && this.xrState != WebXRState.NORMAL) { if (GetGamepadFromControllersArray(0, ref controller1)) { OnControllerUpdate?.Invoke(controller1); } if (GetGamepadFromControllersArray(1, ref controller2)) { OnControllerUpdate?.Invoke(controller2); } } if (OnViewerHitTestUpdate != null && this.xrState == WebXRState.AR) { if (GetHitTestPoseFromViewerHitTestPoseArray(ref viewerHitTestPose)) { OnViewerHitTestUpdate?.Invoke(viewerHitTestPose); } } }
internal void OnUpdate() { if (switchToEnd) { switchToEnd = false; UpdateControllersOnEnd(); } if (this.xrState == WebXRState.NORMAL) { return; } UpdateXRCameras(); bool hasHandsData = false; if (OnHandUpdate != null && this.xrState != WebXRState.NORMAL) { if (GetHandFromHandsArray(0, ref leftHand)) { OnHandUpdate?.Invoke(leftHand); } if (GetHandFromHandsArray(1, ref rightHand)) { OnHandUpdate?.Invoke(rightHand); } hasHandsData = leftHand.enabled || rightHand.enabled; } if (!hasHandsData && OnControllerUpdate != null && this.xrState != WebXRState.NORMAL) { if (GetGamepadFromControllersArray(0, ref controller1)) { OnControllerUpdate?.Invoke(controller1); } if (GetGamepadFromControllersArray(1, ref controller2)) { OnControllerUpdate?.Invoke(controller2); } } if (OnViewerHitTestUpdate != null && this.xrState == WebXRState.AR) { if (GetHitTestPoseFromViewerHitTestPoseArray(ref viewerHitTestPose)) { OnViewerHitTestUpdate?.Invoke(viewerHitTestPose); } } }