@@ -187,7 +187,7 @@ public bool Update()
187187 // The decision between low-level access via InputTracking and high-level access via Camera.main.transform should
188188 // be coordinated with the decision between high-level access to WorldAnchor and low-level access to
189189 // Windows.Perception.Spatial.SpatialAnchor -- see comment at top of SpongyAnchor.cs
190- Pose spongyHead = new Pose ( InputTracking . GetLocalPosition ( XRNode . Head ) , InputTracking . GetLocalRotation ( XRNode . Head ) ) ;
190+ Pose spongyHead = GetHeadPose ( ) ;
191191
192192 // place new anchors 1m below head
193193 Pose newSpongyAnchorPose = spongyHead ;
@@ -276,6 +276,39 @@ public bool Update()
276276 return true ;
277277 }
278278
279+ private readonly List < XRNodeState > nodeStates = new List < XRNodeState > ( ) ;
280+
281+ private Pose headPose = Pose . identity ;
282+
283+ public Pose GetHeadPose ( )
284+ {
285+ // Note:
286+ // The low-level input obtained via InputTracking.GetLocal???(XRNode.Head) is automatically kept in sync with
287+ // Camera.main.transform.local??? (unless XRDevice.DisableAutoXRCameraTracking(Camera.main, true) is used to deactivate
288+ // this mechanism). In theory, both could be used interchangeably, potentially allowing to avoid the dependency
289+ // on low-level code at this point. It is not clear though, whether both values follow exactly the same timing or which
290+ // one is more correct to be used at this point. More research might be necessary.
291+ //
292+ // The decision between low-level access via InputTracking and high-level access via Camera.main.transform should
293+ // be coordinated with the decision between high-level access to WorldAnchor and low-level access to
294+ // Windows.Perception.Spatial.SpatialAnchor -- see comment at top of SpongyAnchor.cs
295+ nodeStates . Clear ( ) ;
296+ InputTracking . GetNodeStates ( nodeStates ) ;
297+ for ( int i = 0 ; i < nodeStates . Count ; ++ i )
298+ {
299+ if ( nodeStates [ i ] . nodeType == XRNode . Head )
300+ {
301+ Vector3 position ;
302+ Quaternion rotation ;
303+ if ( nodeStates [ i ] . tracked && nodeStates [ i ] . TryGetPosition ( out position ) && nodeStates [ i ] . TryGetRotation ( out rotation ) )
304+ {
305+ headPose = new Pose ( position , rotation ) ;
306+ }
307+ }
308+ }
309+ return headPose ;
310+ }
311+
279312 private SpongyAnchor CreateAnchor ( AnchorId id )
280313 {
281314 var newAnchorObject = new GameObject ( id . FormatStr ( ) ) ;
0 commit comments