Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import SwiftUI
import RealityKit
struct ARViewContainer: UIViewRepresentable {
func createPreview(boxAnchor: Experience.Box, arView: ARView) -> ARView {
guard let steelBox = boxAnchor.steelBox else { return arView }
let cameraAnchor = AnchorEntity(.camera)
var transform = steelBox.transform
transform.translation = SIMD3<Float>(0,0,1.86)
steelBox.move(to: transform, relativeTo: nil)
return arView
func makeUIView(context: Context) -> ARView {
let arView = ARView(frame: .zero)
guard let boxAnchor = try? Experience.loadBox() else { return arView }
#if targetEnvironment(simulator)
return createPreview(boxAnchor: boxAnchor, arView: arView)
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