ARAnnotationViewModel

open class ARAnnotationViewModel<CardItem> : NSObject, ObservableObject, ARSessionDelegate where CardItem : CardItemModel

ViewModel for managing an ARCards experience. Provides and sets the annotation data/anchor locations to the view and the flow for the discovery animations.

  • An array of ScreenAnnotations which are displayed in the scene contain the marker position and their card contents The annotations internal entities within this list should be in the ARView scene. Set by the annotation loading strategy

    Declaration

    Swift

    @Published
    public internal(set) var annotations: [ScreenAnnotation<CardItem>] { get set }
  • The ScreenAnnotation that is focused on in the scene. The CardView and MarkerView will be in their selected states

    Declaration

    Swift

    @Published
    public internal(set) var currentAnnotation: ScreenAnnotation<CardItem>? { get set }
  • Initializer

    Declaration

    Swift

    override public init()

Annotation Management

  • Loads a strategy into the arModel and sets annotations member from the returned [ScreenAnnotation]

    Declaration

    Swift

    public func load<Strategy>(loadingStrategy: Strategy) throws where CardItem == Strategy.CardItem, Strategy : AnnotationLoadingStrategy
  • Loads an asynchronous strategy into the arModel and sets annotations member from the returned [ScreenAnnotation]

    Declaration

    Swift

    public func loadAsync<Strategy>(loadingStrategy: Strategy) throws where CardItem == Strategy.CardItem, Strategy : AsyncAnnotationLoadingStrategy

ARSession Delegate

  • Tells the delegate that one or more anchors have been added to the session.

    Declaration

    Swift

    public func session(_ session: ARSession, didAdd anchors: [ARAnchor])
  • Provides a newly captured camera image and accompanying AR information to the delegate.

    Declaration

    Swift

    public func session(_ session: ARSession, didUpdate frame: ARFrame)
  • Updates the anchorEntities when the underlying ARAnchors update

    Declaration

    Swift

    public func session(_ session: ARSession, didUpdate anchors: [ARAnchor])