Skip to content

Instantly share code, notes, and snippets.

@anupamchugh
Created January 19, 2020 18:55
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 anupamchugh/5f6df4d97896744b06539d5f543cde9a to your computer and use it in GitHub Desktop.
Save anupamchugh/5f6df4d97896744b06539d5f543cde9a to your computer and use it in GitHub Desktop.
import SwiftUI
struct ContentView : View {
var body: some View {
return ARViewContainer().edgesIgnoringSafeArea(.all)
}
}
struct ARViewContainer: UIViewRepresentable {
func makeUIView(context: Context) -> ARView {
let arView = ARView(frame: .zero)
let config = ARWorldTrackingConfiguration()
config.planeDetection = .horizontal
arView.session.run(config, options: [])
let box1 = CustomEntity(
color: .yellow,
position: [0.5,-1.5,-3]
)
arView.scene.anchors.append(box1)
let box2 = CustomEntity(
color: .green,
position: [-0.5,-1.5, -3]
)
arView.scene.anchors.append(box2)
box1.addCollisions()
arView.installGestures(.all, for: box1)
return arView
}
func updateUIView(_ uiView: ARView, context: Context) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment