Skip to content

Commit 62cdf76

Browse files
committed
WebXR Input Profiles 0.3.5 and PR fixes
1 parent dbb615b commit 62cdf76

File tree

10 files changed

+42
-27
lines changed

10 files changed

+42
-27
lines changed

Build/Build/Build.data.unityweb

880 KB
Binary file not shown.

Build/Build/Build.wasm

119 KB
Binary file not shown.

Build/Build/Build.wasm.framework.unityweb

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

MainProject/Packages/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
],
1212
"dependencies": {
13-
"com.de-panther.webxr-input-profiles-loader": "0.3.3",
13+
"com.de-panther.webxr-input-profiles-loader": "0.3.5",
1414
"com.unity.ide.rider": "2.0.5",
1515
"com.unity.ide.vscode": "1.2.3",
1616
"com.unity.test-framework": "1.1.16",

MainProject/Packages/packages-lock.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"dependencies": {
33
"com.atteneder.gltfast": {
4-
"version": "3.0.1",
4+
"version": "3.0.2",
55
"depth": 1,
66
"source": "registry",
77
"dependencies": {
@@ -21,12 +21,12 @@
2121
}
2222
},
2323
"com.de-panther.webxr-input-profiles-loader": {
24-
"version": "0.3.3",
24+
"version": "0.3.5",
2525
"depth": 0,
2626
"source": "registry",
2727
"dependencies": {
2828
"com.unity.nuget.newtonsoft-json": "2.0.0",
29-
"com.atteneder.gltfast": "3.0.1"
29+
"com.atteneder.gltfast": "3.0.2"
3030
},
3131
"url": "https://package.openupm.com"
3232
},

Packages/webxr-interactions/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
- Check for alwaysUseGrip in ControllerInteraction.
1010

1111
### Changed
12-
- Minimum WebXR Input Profiles Loader version 0.3.3.
12+
- Minimum WebXR Input Profiles Loader version 0.3.5.
1313

1414
## [0.6.0] - 2020-01-23
1515
### Added

Packages/webxr-interactions/Runtime/Scripts/WebXR.Interactions.asmdef

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"versionDefines": [
1515
{
1616
"name": "com.de-panther.webxr-input-profiles-loader",
17-
"expression": "0.3.3",
17+
"expression": "0.3.5",
1818
"define": "WEBXR_INPUT_PROFILES"
1919
}
2020
],

Packages/webxr/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Use `targetRaySpace` as the default controller pose instead of `gripSpace`.
1313
- Use generic Input Profile in editor for all controllers types.
1414

15+
### Fixed
16+
- Hack for Oculus on Chrome Desktop wrong `targetRaySpace` bug.
17+
1518
## [0.6.0] - 2020-01-23
1619
### Added
1720
- GetLocalRotation and GetLocalPosition to WebXRCamera.

Packages/webxr/Runtime/Scripts/WebXRController.cs

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public enum Axis2DTypes
6363
private Quaternion oculusOffsetGrip = Quaternion.Euler(-90f, 0, 0);
6464

6565
[SerializeField] private bool alwaysUseGrip = false;
66-
public Vector3 gripPosition { get; private set;} = Vector3.zero;
67-
public Quaternion gripRotation { get; private set;} = Quaternion.identity;
66+
public Vector3 gripPosition { get; private set; } = Vector3.zero;
67+
public Quaternion gripRotation { get; private set; } = Quaternion.identity;
6868

6969
public bool isControllerActive
7070
{
@@ -321,23 +321,17 @@ private void OnControllerUpdate(WebXRControllerData controllerData)
321321
transform.localRotation = controllerData.rotation;
322322
transform.localPosition = controllerData.position;
323323
}
324-
CheckOculusLinkBug();
325-
}
326-
else
327-
{ // Oculus on desktop returns wrong rotation for targetRaySpace, this is an ugly hack to fix it
328-
gripRotation = controllerData.gripRotation * oculusOffsetGrip;
329-
gripPosition = controllerData.gripPosition;
330-
if (alwaysUseGrip)
324+
// Oculus on desktop returns wrong rotation for targetRaySpace, this is an ugly hack to fix it
325+
if (CheckOculusLinkBug())
331326
{
332-
transform.localRotation = controllerData.rotation * controllerData.gripRotation;
333-
transform.localPosition = controllerData.rotation * (controllerData.position + controllerData.gripPosition);
334-
}
335-
else
336-
{
337-
transform.localRotation = controllerData.rotation * oculusOffsetRay;
338-
transform.localPosition = controllerData.position;
327+
HandleOculusLinkBug(controllerData);
339328
}
340329
}
330+
else
331+
{
332+
// Oculus on desktop returns wrong rotation for targetRaySpace, this is an ugly hack to fix it
333+
HandleOculusLinkBug(controllerData);
334+
}
341335

342336
trigger = controllerData.trigger;
343337
squeeze = controllerData.squeeze;
@@ -364,20 +358,39 @@ private void OnControllerUpdate(WebXRControllerData controllerData)
364358
}
365359

366360
// Oculus on desktop returns wrong rotation for targetRaySpace, this is an ugly hack to fix it
367-
private void CheckOculusLinkBug()
361+
private void HandleOculusLinkBug(WebXRControllerData controllerData)
362+
{
363+
gripRotation = controllerData.gripRotation * oculusOffsetGrip;
364+
gripPosition = controllerData.gripPosition;
365+
if (alwaysUseGrip)
366+
{
367+
transform.localRotation = controllerData.rotation * controllerData.gripRotation;
368+
transform.localPosition = controllerData.rotation * (controllerData.position + controllerData.gripPosition);
369+
}
370+
else
371+
{
372+
transform.localRotation = controllerData.rotation * oculusOffsetRay;
373+
transform.localPosition = controllerData.position;
374+
}
375+
}
376+
377+
// Oculus on desktop returns wrong rotation for targetRaySpace, this is an ugly hack to fix it
378+
private bool CheckOculusLinkBug()
368379
{
369380
if (oculusLinkBugTest == 0
370381
&& profiles != null && profiles.Length > 0)
371382
{
372383
if (profiles[0] == "oculus-touch" && gripRotation.x > 0)
373384
{
374385
oculusLinkBugTest = 1;
386+
return true;
375387
}
376388
else
377389
{
378390
oculusLinkBugTest = 2;
379391
}
380392
}
393+
return false;
381394
}
382395

383396
private void OnHandUpdateInternal(WebXRHandData handData)
@@ -528,7 +541,7 @@ private void HandleInputDevicesConnected(InputDevice device)
528541
{
529542
profileName += "-button";
530543
}
531-
profiles = new string[]{profileName};
544+
profiles = new string[] { profileName };
532545
TryUpdateButtons();
533546
SetControllerActive(true);
534547
}

Packages/webxr/Runtime/XRPlugin/WebXRSubsystem.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,6 @@ bool GetGamepadFromControllersArray(int controllerIndex, ref WebXRControllerData
384384
}
385385

386386
newControllerData.frame = frameNumber;
387-
bool wasDisabled = !newControllerData.enabled;
388387
newControllerData.enabled = controllersArray[arrayPosition++] != 0;
389388
newControllerData.hand = (int)controllersArray[arrayPosition++];
390389
if (!newControllerData.enabled)
@@ -405,7 +404,7 @@ bool GetGamepadFromControllersArray(int controllerIndex, ref WebXRControllerData
405404
newControllerData.touchpadY = controllersArray[arrayPosition++];
406405
newControllerData.buttonA = controllersArray[arrayPosition++];
407406
newControllerData.buttonB = controllersArray[arrayPosition++];
408-
if (controllersArray[arrayPosition++] == 1 || wasDisabled)
407+
if (controllersArray[arrayPosition++] == 1)
409408
{
410409
newControllerData.gripPosition = new Vector3(controllersArray[arrayPosition++], controllersArray[arrayPosition++], controllersArray[arrayPosition++]);
411410
newControllerData.gripRotation = new Quaternion(controllersArray[arrayPosition++], controllersArray[arrayPosition++], controllersArray[arrayPosition++],

0 commit comments

Comments
 (0)