Annotation Data Loading

  • Protocol which defines the data a strategy needs to provide a [ScreenAnnotation]

    See more

    Declaration

    Swift

    public protocol AnnotationLoadingStrategy
  • Protocol which defines the data an asynchronous strategy needs to provide a [ScreenAnnotation]

    See more

    Declaration

    Swift

    public protocol AsyncAnnotationLoadingStrategy
  • A loading strategy that uses the RealityComposer app. After creating the Reality Composer scene, the entities in the scene correlate to a real world location relative to the image or object anchor. This strategy wraps the anchors that represents these locations with the CardItemModels that they correspond to in a ScreenAnnotation struct for a single source of truth. Loading the data into the ARAnnotationViewModel should be done in the onAppear method.

    If an Object Anchor is used the anchorImage and physicalWidth can be set to nil and are ignored

    Usage

    let cardItems = [ExampleCardItem(id: 0, title_: "Hello"), ExampleCardItem(id: 1, title_: "World")]
    guard let anchorImage = UIImage(named: "qrImage") else { return }
    let strategy = RealityComposerStrategy(cardContents: cardItems, anchorImage: anchorImage, rcFile: "ExampleRC", rcScene: "ExampleScene")
    arModel.load(loadingStrategy: strategy)
    
    See more

    Declaration

    Swift

    public struct RCProjectStrategy<CardItem> : AnnotationLoadingStrategy, SceneLoadable where CardItem : CardItemModel, CardItem.ID : LosslessStringConvertible
    extension RCProjectStrategy: AsyncAnnotationLoadingStrategy where CardItem: Codable
  • A loading strategy that uses the RealityComposer app. After creating the Reality Composer scene, the entities in the scene correlate to a real world location relative to the image or object anchor. This strategy wraps the anchors that represents these locations with the CardItemModels that they correspond to in a ScreenAnnotation struct for a single source of truth. Loading the data into the ARAnnotationViewModel should be done in the onAppear method.

    Usage

    let cardItems = [ExampleCardItem(id: 0, title_: "Hello"), ExampleCardItem(id: 1, title_: "World")]
    guard let anchorImage = UIImage(named: "qrImage") else { return }
    let realityFilePath = FileManager.default.getDocumentsDirectory().appendingPathComponent(FileManager.realityFiles).appendingPathComponent("ExampleRC.reality")
    let strategy = RealityFileStrategy(cardContents: cardItems, anchorImage: anchorImage, physicalWidth: 0.1, realityFilePath: realityFilePath, rcScene: "ExampleScene")
    arModel.load(loadingStrategy: strategy)
    
    See more

    Declaration

    Swift

    public struct RealityFileStrategy<CardItem> : AnnotationLoadingStrategy, SceneLoadable where CardItem : CardItemModel, CardItem.ID : LosslessStringConvertible
  • A loading strategy that makes a network fetch request to Mobile Services to return the data necessary to display an AR Annotation Scene. This strategy wraps the anchors that represents these locations with the CardItemModels that they correspond to in a ScreenAnnotation struct for a single source of truth. Loading the data into the ARAnnotationViewModel should be done in the onAppear method.

    Usage

    @StateObject var serviceStrategy = ServiceStrategy<CodableCardItem>(
        serviceURL: URL(string: IntegrationTest.System.redirectURL)!,
        sapURLSession: SAPURLSession.createOAuthURLSession(
            clientID: IntegrationTest.System.clientID,
            authURL: IntegrationTest.System.authURL,
            redirectURL: IntegrationTest.System.redirectURL,
            tokenURL: IntegrationTest.System.tokenURL
        ),
        sceneIdentifier: SceneIdentifyingAttribute.id(IntegrationTest.TestData.sceneId)
    
     arModel.loadAsync(loadingStrategy: serviceStrategy)
    
    See more

    Declaration

    Swift

    public class ServiceStrategy<CardItem> : ObservableObject, AsyncAnnotationLoadingStrategy where CardItem : CardItemModel, CardItem : Decodable, CardItem : Encodable
  • A loading strategy that uses the RealityComposer app. After creating the Reality Composer scene, the entities in the scene correlate to a real world location relative to the image or object anchor. This strategy wraps the anchors that represents these locations with the CardItemModels that they correspond to in a ScreenAnnotation struct for a single source of truth. Loading the data into the ARAnnotationViewModel should be done in the onAppear method.

    Usage

    let cardItems = [ExampleCardItem(id: 0, title_: "Hello"), ExampleCardItem(id: 1, title_: "World")]
    guard let anchorImage = UIImage(named: "qrImage") else { return }
    let usdzFilePath = FileManager.default.getDocumentsDirectory().appendingPathComponent(FileManager.realityFiles).appendingPathComponent("ExampleRC.reality")
    let strategy = UsdzFileStrategy(cardContents: cardItems, anchorImage: anchorImage, physicalWidth: 0.1, realityFilePath: realityFilePath)
    arModel.load(loadingStrategy: strategy)
    
    See more

    Declaration

    Swift

    public struct UsdzFileStrategy<CardItem> : AnnotationLoadingStrategy, SceneLoadable where CardItem : CardItemModel, CardItem.ID : LosslessStringConvertible
  • A loading strategy that uses the Vectors provided by the CardItemModels PositionComponent to position the Entities relative to the anchor Image. This strategy wraps the anchors that represents these locations with the CardItemModels that they correspond to in a ScreenAnnotation struct for a single source of truth. Loading the data into the ARAnnotationViewModel should be done in the onAppear method.

    Usage

    let cardItems = [ExampleCardItem(id: 0, title_: "Hello"), ExampleCardItem(id: 1, title_: "World")]
    guard let anchorImage = UIImage(named: "qrImage") else { return }
    let strategy = VectorStrategy(cardContents: cardItems, anchorImage: anchorImage, physicalWidth: 0.1, realityFilePath: realityFilePath)
    arModel.load(loadingStrategy: strategy)
    
    See more

    Declaration

    Swift

    public struct VectorStrategy<CardItem> : AnnotationLoadingStrategy where CardItem : CardItemModel