Initial Commit
This commit is contained in:
40
GasTankAR/ContentView.swift
Normal file
40
GasTankAR/ContentView.swift
Normal file
@ -0,0 +1,40 @@
|
||||
//
|
||||
// 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()
|
||||
}
|
||||
Reference in New Issue
Block a user