Package com.google.ar.sceneform
Class AnchorNode
- java.lang.Object
-
- com.google.ar.sceneform.NodeParent
-
- com.google.ar.sceneform.Node
-
- com.google.ar.sceneform.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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.ar.sceneform.Node
Node.LifecycleListener, Node.OnTapListener, Node.OnTouchListener, Node.TransformChangedListener
-
-
Constructor Summary
Constructors Constructor Description AnchorNode()
Create an AnchorNode with no anchor.AnchorNode(com.google.ar.core.Anchor anchor)
Create an AnchorNode with the specified anchor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.ar.core.Anchor
getAnchor()
Returns the ARCore anchor if it exists or null otherwise.boolean
isSmoothed()
Returns true if the transformations are interpolated or false if they are applied immediately.boolean
isTracking()
Returns true if the ARCore anchor’s tracking state is TRACKING.void
onUpdate(FrameTime frameTime)
AnchorNode overrides this to update the node's position to match the ARCore Anchor's position.void
setAnchor(com.google.ar.core.Anchor anchor)
Set an ARCore anchor and force the position of this node to be updated immediately.void
setLocalPosition(Vector3 position)
Set the local-space position of this node if it is not anchored.void
setLocalRotation(Quaternion rotation)
Set the local-space rotation of this node if it is not anchored.void
setSmoothed(boolean smoothed)
Set true to smooth the transition between the node’s current position and the anchor position.void
setWorldPosition(Vector3 position)
Set the world-space position of this node if it is not anchored.void
setWorldRotation(Quaternion rotation)
Set the world-space rotation of this node if it is not anchored.-
Methods inherited from class com.google.ar.sceneform.Node
addLifecycleListener, addTransformChangedListener, callOnHierarchy, findInHierarchy, getBack, getCollisionShape, getDown, getForward, getLeft, getLight, getLocalPosition, getLocalRotation, getLocalScale, getName, getParent, getRenderable, getRenderableInstance, getRight, getScene, getUp, getWorldModelMatrix, getWorldPosition, getWorldRotation, getWorldScale, isActive, isDescendantOf, isEnabled, isSelectable, isTopLevel, localToWorldDirection, localToWorldPoint, onActivate, onDeactivate, onTouchEvent, onTransformChange, removeLifecycleListener, removeTransformChangedListener, setCollisionShape, setEnabled, setLight, setLocalScale, setLookDirection, setLookDirection, setName, setOnTapListener, setOnTouchListener, setParent, setRenderable, setSelectable, setWorldScale, toString, worldToLocalDirection, worldToLocalPoint
-
Methods inherited from class com.google.ar.sceneform.NodeParent
addChild, findByName, getChildren, removeChild
-
-
-
-
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.
-
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 classNode
- 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 classNode
- 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 classNode
- 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 classNode
- Parameters:
rotation
- The rotation to apply.- See Also:
Node.getWorldRotation()
-
-