Created
January 30, 2021 00:31
-
-
Save sturdysturge/43753c03d06b57401c5809ab5b93d9ad to your computer and use it in GitHub Desktop.
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
import SwiftUI | |
import RealityKit | |
struct AnyViewRepresentable<T: UIView>: UIViewRepresentable { | |
let view: T | |
func makeUIView(context: Context) -> T { return view } | |
func updateUIView(_ uiView: T, context: Context) {} | |
} | |
struct ContentView : View { | |
let arView = ARView(frame: UIScreen.main.bounds) | |
let models: [ModelEntity] | |
init() { | |
let boxAnchor = try! Experience.loadBox() | |
var models = [ModelEntity]() | |
boxAnchor.getModelEntitiesInDescendants(models: &models) | |
arView.scene.anchors.append(boxAnchor) | |
self.models = models | |
} | |
var body: some View { | |
ZStack { | |
AnyViewRepresentable(view: arView) | |
ARSettingsView(models: models) | |
} | |
.edgesIgnoringSafeArea(.all) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment