Skip to content

Commit f8ab5f9

Browse files
authored
Merge pull request #320 from De-Panther/eventscamera_webxrcamera
Added an option for eventsCamera in WebXRCamera
2 parents c33714f + 29abfcb commit f8ab5f9

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

Packages/webxr-interactions/Samples~/XRInteractionToolkit/Prefabs/XR Origin (WebXR Rig).prefab

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,7 @@ MonoBehaviour:
876876
cameraARL: {fileID: 469584278722724955}
877877
cameraARR: {fileID: 2113255073564658967}
878878
cameraFollower: {fileID: 5280121735958530868}
879+
eventsCamera: {fileID: 5934003548109805725}
879880
updateCameraTag: 0
880881
--- !u!1 &1470279098769358944
881882
GameObject:

Packages/webxr/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
### Added
1010
- WebXRHandData pointerPosition and pointerRotation (WebXR targetRaySpace for hands).
11+
- An option for eventsCamera in WebXRCamera.
1112

1213
### Changed
1314
- Enabled stencil buffer when creating the session XRWebGLLayer.

Packages/webxr/Runtime/Scripts/WebXRCamera.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@ public enum CameraID
2222
[SerializeField]
2323
private Transform cameraFollower = null;
2424

25+
[SerializeField]
26+
private Camera eventsCamera = null;
27+
2528
private WebXRState xrState = WebXRState.NORMAL;
2629
private Rect leftRect, rightRect;
2730

2831
private int viewsCount = 1;
2932

3033
private bool hasFollower = false;
34+
private bool hasEventsCamera = false;
3135

3236
[SerializeField]
3337
private bool updateCameraTag = false;
@@ -37,6 +41,7 @@ private void OnEnable()
3741
WebXRManager.OnXRChange += OnXRChange;
3842
WebXRManager.OnHeadsetUpdate += OnHeadsetUpdate;
3943
hasFollower = cameraFollower != null;
44+
hasEventsCamera = eventsCamera != null;
4045
OnXRChange(WebXRManager.Instance.XRState,
4146
WebXRManager.Instance.ViewsCount,
4247
WebXRManager.Instance.ViewsLeftRect,
@@ -102,6 +107,10 @@ private void SwitchXRState()
102107
}
103108
break;
104109
}
110+
if (hasEventsCamera)
111+
{
112+
eventsCamera.projectionMatrix = cameraMain.projectionMatrix;
113+
}
105114
}
106115

107116
private void UpdateFollower()
@@ -235,6 +244,10 @@ private void OnHeadsetUpdate(
235244
cameraARR.transform.localRotation = rightRotation;
236245
#endif
237246
cameraARR.projectionMatrix = rightProjectionMatrix;
247+
if (hasEventsCamera && viewsCount == 1)
248+
{
249+
eventsCamera.projectionMatrix = leftProjectionMatrix;
250+
}
238251
}
239252
}
240253
}

0 commit comments

Comments
 (0)