public class ARAnchor
- Object
- ARAnchor
Known subtypesARFaceAnchor, ARImageAnchor
A fixed position and orientation in the real world that the AR session
keeps tracking as its understanding of the environment improves. Anchors
are the attachment points for virtual content: create one with
ARSession#createAnchor(ARPose) or ARHitResult#createAnchor() and hang
an ARNode on it with #setNode(ARNode).
The session refines anchor poses over time; updates are delivered through
the session’s ARAnchorListener and reflected by #getPose().
Constructors
public ARAnchor(String id, ARPose pose) | Creates an anchor. |
Methods
public String getId() | The stable identifier of this anchor. |
public ARPose getPose() | The current world pose. |
public ARTrackingState getTrackingState() | The tracking quality of this anchor. |
public ARNode getNode() | The content root rendered at this anchor, or null when none is attached. |
public void setNode(ARNode node) | Attaches (or replaces) the content root rendered at this anchor. |
public void detach() | Removes this anchor (and any attached content) from the session. |
public boolean isDetached() | True once #detach() has been called or the platform removed the anchor. |
Inherited methods
Constructor details
ARAnchor
public ARAnchor(String id, ARPose pose)Creates an anchor. Intended for platform implementations and tests;
applications create anchors through the session.
Parameters
idString- the stable identifier of this anchor
poseARPose- the initial world pose
Method details
getId
public String getId()The stable identifier of this anchor.
getPose
public ARPose getPose()The current world pose. Updated on the EDT as tracking refines.
getTrackingState
public ARTrackingState getTrackingState()The tracking quality of this anchor.
getNode
public ARNode getNode()The content root rendered at this anchor, or null when none is
attached.
setNode
public void setNode(ARNode node)Attaches (or replaces) the content root rendered at this anchor. Pass
null to remove the content while keeping the anchor.
Parameters
nodeARNode- the root node to render at this anchor, or null
detach
public void detach()Removes this anchor (and any attached content) from the session.
No-op when already detached.
isDetached
public boolean isDetached()True once
#detach() has been called or the platform removed the
anchor.