-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🎸 Proposal: Decoding JSON in RealityComposerStrategy (#47)
feat: 🎸 Support for passing data as JSON in Reality Composer Strategy
- Loading branch information
1 parent
9a16ae5
commit 6c14176
Showing
6 changed files
with
186 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
Apps/Examples/Examples/ARCards/CardContentViews/ARCardsJSONLoadingContentView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// ARCardsDefaultContentView.swift | ||
// Examples | ||
// | ||
// Created by O'Brien, Patrick on 5/5/21. | ||
// | ||
|
||
import FioriARKit | ||
import SwiftUI | ||
|
||
struct ARCardsJSONLoadingContentView: View { | ||
@StateObject var arModel = ARAnnotationViewModel<DecodableCardItem>() | ||
|
||
var body: some View { | ||
SingleImageARCardView(arModel: arModel, | ||
image: Image("qrImage"), | ||
cardAction: { id in | ||
// set the card action for id corresponding to the CardItemModel | ||
print(id) | ||
}) | ||
.onAppear(perform: loadInitialData) | ||
} | ||
|
||
func loadInitialData() { | ||
guard let anchorImage = UIImage(named: "qrImage"), let url = Bundle.main.url(forResource: "Tests", withExtension: "json") else { return } | ||
|
||
do { | ||
let jsonData = try Data(contentsOf: url) | ||
let strategy = try RealityComposerStrategy(jsonData: jsonData, anchorImage: anchorImage, physicalWidth: 0.1, rcFile: "ExampleRC", rcScene: "ExampleScene") | ||
arModel.load(loadingStrategy: strategy) | ||
} catch { | ||
print(error) | ||
} | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters