Incorrect AR Plane normals

Unity Editor version: * 2022.3.53f1
ML2 OS version: 1.10.0
Unity SDK version: 2.5.0
Host OS: MacOS
XR Interaction Toolkit: 3.0.4

Hi!
I wanted to make a simple application that will just spawn object on the ar planes using XR Interaction toolkit. I used Unity AR Mobile template as a starting point. Mobile app works as intended, but Magic Leap app spawns objects under the plane. The reason is that in the mobile ar plane normal is (x, 1, z) for the plane on the floor (HorizontalUp plane alignment). While in the Magic Leap app ar plane normal is (x, -1, z) for the plane on the floor. But normal is incorrect for all plane types, not only those with arPlane.alignment == HorizontalUp. This is what I did and how one can reproduce it:

  1. Make Unity project 2022.3.53f1 from the AR Mobile template
  2. Build SampleScene to iPhone - everything is fine
  3. Import ML Setup tool and configure project for ML build
  4. Import ML Rig & OpenXR Input and Planes sample samples
  5. Copy SamplesScene to MLScene
  6. Move Object Spawner from XR Origin to scene root. Set SpawnObjectIndex to 6 (Debug Cube index)
  7. Replace XR Origin (AR Rig) with ML Rig prefab
  8. Remove status text from PlanesSample.cs and add it to scene
  9. Set ARInteractor in ARInteractorSpawnTrigger to Controller
  10. On ML Rig -> Camera Offset -> Controller -> Xr Ray Interactor enable “Enable AR Raycasting”
  11. Remove UI game object from scene
  12. Add Debug.Log("Spawn at plane " + arPlane.alignment + " with normal " + arPlane.normal); to ARInteractorSpawnTrigger.cs right before m_ObjectSpawner.TrySpawnObject(arRaycastHit.pose.position, arPlane.normal); call
  13. Build to device
  14. Spawn debug cube on trigger.
  15. Get "Spawn at plane HorizontalUp with normal (0.05, -1.00, 0.00)" debug message.

Screenshot from mobile:

Screenshot from ML2:

So basically the question is: am I doing something wrong or is it a bug?

1 Like

Hey @mkhlamov,

Welcome to the Magic Leap Developer forums!

I have been able to reproduce this on my end.
I'm currently looking into it to see if this is a bug or intentional for any reason.

Thank you for pointing this out!

If you need a workaround in the meantime, you can try to spawn your objects with:
-arPlane.normal

The whole line would then be:

m_ObjectSpawner.TrySpawnObject(arRaycastHit.pose.position, -arPlane.normal);
1 Like

Hi @cfeist
Thank you for the quick answer!
Yeah, I did the same thing to spawn objects correctly.
But the problem still remains for other scripts. For example, if I wanted to use XR Grab Interactible and AR Transform (to constrain moving to AR planes) scripts that are present on the Debug cube, then this normal issue prevents me from moving the object along the plane. Ideally I would just use the same scripts for mobile and ML as much as possible without these #if MAGICLEAP all around my code.

1 Like