# Class ARAnchor

java.lang.Object
com.codename1.ar.ARAnchor

Direct Known Subclasses:
  `ARFaceAnchor, ARImageAnchor`

public class ARAnchor extends Object

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()`.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ARAnchor(String id, ARPose pose)`
  Creates an anchor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `detach()`
  Removes this anchor (and any attached content) from the session.
  `String`
  `getId()`
  The stable identifier of this anchor.
  `ARNode`
  `getNode()`
  The content root rendered at this anchor, or null when none is attached.
  `ARPose`
  `getPose()`
  The current world pose.
  `ARTrackingState`
  `getTrackingState()`
  The tracking quality of this anchor.
  `boolean`
  `isDetached()`
  True once `#detach()` has been called or the platform removed the anchor.
  `void`
  `setNode(ARNode node)`
  Attaches (or replaces) the content root rendered at this anchor.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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

    - `id`: the stable identifier of this anchor

    - `pose`: 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

    - `node`: 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.