Class AnchorNode

  • All Implemented Interfaces:
    TransformProvider

    public class AnchorNode
    extends Node
    Node that is automatically positioned in world space based on an ARCore Anchor.

    When the Anchor isn't tracking, all children of this node are disabled.

    • Constructor Detail

      • AnchorNode

        public AnchorNode()
        Create an AnchorNode with no anchor.
      • AnchorNode

        public AnchorNode​(com.google.ar.core.Anchor anchor)
        Create an AnchorNode with the specified anchor.
        Parameters:
        anchor - the ARCore anchor that this node will automatically position itself to.
    • Method Detail

      • setAnchor

        public void setAnchor​(@Nullable
                              com.google.ar.core.Anchor anchor)
        Set an ARCore anchor and force the position of this node to be updated immediately.
        Parameters:
        anchor - the ARCore anchor that this node will automatically position itself to.
      • getAnchor

        @Nullable
        public com.google.ar.core.Anchor getAnchor()
        Returns the ARCore anchor if it exists or null otherwise.
      • setSmoothed

        public void setSmoothed​(boolean smoothed)
        Set true to smooth the transition between the node’s current position and the anchor position. Set false to apply transformations immediately. Smoothing is true by default.
        Parameters:
        smoothed - Whether the transformations are interpolated.
      • isSmoothed

        public boolean isSmoothed()
        Returns true if the transformations are interpolated or false if they are applied immediately.
      • isTracking

        public boolean isTracking()
        Returns true if the ARCore anchor’s tracking state is TRACKING.
      • onUpdate

        public void onUpdate​(FrameTime frameTime)
        AnchorNode overrides this to update the node's position to match the ARCore Anchor's position.
        Overrides:
        onUpdate in class Node
        Parameters:
        frameTime - provides time information for the current frame
      • setLocalPosition

        public void setLocalPosition​(Vector3 position)
        Set the local-space position of this node if it is not anchored. If the node is anchored, this call does nothing.
        Overrides:
        setLocalPosition in class Node
        Parameters:
        position - The position to apply.
        See Also:
        Node.getLocalPosition()
      • setWorldPosition

        public void setWorldPosition​(Vector3 position)
        Set the world-space position of this node if it is not anchored. If the node is anchored, this call does nothing.
        Overrides:
        setWorldPosition in class Node
        Parameters:
        position - The position to apply.
        See Also:
        Node.getWorldPosition()
      • setLocalRotation

        public void setLocalRotation​(Quaternion rotation)
        Set the local-space rotation of this node if it is not anchored. If the node is anchored, this call does nothing.
        Overrides:
        setLocalRotation in class Node
        Parameters:
        rotation - The rotation to apply.
        See Also:
        Node.getLocalRotation()
      • setWorldRotation

        public void setWorldRotation​(Quaternion rotation)
        Set the world-space rotation of this node if it is not anchored. If the node is anchored, this call does nothing.
        Overrides:
        setWorldRotation in class Node
        Parameters:
        rotation - The rotation to apply.
        See Also:
        Node.getWorldRotation()