🔥 Move: AR assets in ARObjects

master
Nathan VERDIER 10 months ago
parent e8d7133896
commit ae9c6c3728

@ -10,7 +10,7 @@ import ARKit
import RealityKit
import DouShouQiModel
class ARKitViewRepresentable: ARView {
class ARKitView: ARView {
required init(frame frameRect: CGRect) {
super.init(frame: frameRect)
@ -41,4 +41,27 @@ class ARKitViewRepresentable: ARView {
anchor.addChild(arBoard)
self.scene.addAnchor(anchor)
}
func makeUIView(context: Context) -> ARView {
let arView = ARView(frame: .zero)
// Create a cube model
let mesh = MeshResource.generateBox(size: 0.1, cornerRadius: 0.005)
let material = SimpleMaterial(color: .gray, roughness: 0.15, isMetallic: true)
let model = ModelEntity(mesh: mesh, materials: [material])
model.transform.translation.y = 0.05
// Create horizontal plane anchor for the content
let anchor = AnchorEntity(.plane(.horizontal, classification: .any, minimumBounds: SIMD2<Float>(0.2, 0.2)))
anchor.children.append(model)
// Add the horizontal plane anchor to the scene
arView.scene.anchors.append(anchor)
return arView
}
func updateUIView(_ uiView: ARView, context: Context) {}
}
Loading…
Cancel
Save