Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Created January 30, 2021 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sturdysturge/43753c03d06b57401c5809ab5b93d9ad to your computer and use it in GitHub Desktop.
Save sturdysturge/43753c03d06b57401c5809ab5b93d9ad to your computer and use it in GitHub Desktop.
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