args?.xr?.frame?.trackedAnchors Problem since needle update

Hi!
In our project, we show an additional UI in AR (Android) to give users a hint, to move their phone (so the anchor can be places automaticly, after the ground was found). Then, when the anchor was set, we activate some objects from our scene.
It worked well, but after we made a needle update (from 3.44.1 to 3.47.10) it stopped working. (if the downgrade the needle version back to 3.44 it is working again).

That is how we checked the anchor:

    onUpdateXR(args: NeedleXREventArgs): void {
        this.xrSession = args?.xr;
        let anchor = args?.xr?.frame?.trackedAnchors != null && args?.xr?.frame?.trackedAnchors?.size > 0;
        HasAnchor.set(anchor);
    }

What I wanted to ask - is there a new way now, how to get the same information?

Hi Llllkatjallll! I’m your AI-powered assistant. I can help with questions about Needle Engine, three.js, and basic Unity or Blender support. Please share your OS, Needle Engine version, and any Unity or Blender versions you’ve used for more tailored help! Looking forward to your question!

2 replies left - GPT 4O
thread_yjcUBFFhGzjRIiq12CkyllNa
Reply to this message to continue the conversation

Hi Katja,

this property didnt change, it’s part of the WebXR device API, see XRFrame: trackedAnchors property - Web APIs | MDN - And access to the XRFrame is still the same (see api)

So perhaps something else in your application changed/stopped working? Or you tested on a different device - as you can see in the linked docs, trackedAnchors is not available on Safari. What you probably want to do instead is to call args.xr.getHitTest() and check if you have any hits

Please note that auto placement is also available as an option in the WebXR component.

Thank you for the answer, Marcel!
We are actuallu using auto placement already. The information, if the ground/anchor was found is needed not for the placement itself, but for switching additional UI on/off.
Here is an example of what I mean:
Build with newer needle version: Map-Hotspots
Build with downgraded version: Map-Hotspots
If you try the AR Mode (Select Hotspot->Click AR), you will see the additional UI I described before.

Ok, we will try to investigate further :wink:

Hi Katja, do you have any update on this?

Hey Marcel, the solution with args.xr.getHitTest() fixed our problem with the anchor, thank you!
And sorry for the late response!