Files
Gas-Tank-AR-App/GasTankAR/ContentView.swift
Dennis Nemec 3d9f1ab6bc Initial Commit
2026-08-19 16:14:26 +02:00

41 lines
1022 B
Swift

//
// ContentView.swift
// GasTankAR
//
// Created by Dennis Nemec on 19.08.26.
//
import SwiftUI
import RealityKit
struct ContentView : View {
var body: some View {
RealityView { content in
// Create a cube model
let model = Entity()
let mesh = MeshResource.generateBox(size: 0.1, cornerRadius: 0.005)
let material = SimpleMaterial(color: .gray, roughness: 0.15, isMetallic: true)
model.components.set(ModelComponent(mesh: mesh, materials: [material]))
model.position = [0, 0.05, 0]
// Create horizontal plane anchor for the content
let anchor = AnchorEntity(.plane(.horizontal, classification: .any, minimumBounds: SIMD2<Float>(0.2, 0.2)))
anchor.addChild(model)
// Add the horizontal plane anchor to the scene
content.add(anchor)
content.camera = .spatialTracking
}
.edgesIgnoringSafeArea(.all)
}
}
#Preview {
ContentView()
}