【发布时间】:2022-11-23 14:54:03
【问题描述】:
我正在尝试使用 RealityKit 将一个对象放置在世界位置,设置一个计时器,该计时器将清除所有锚点并每 5 秒放置一个新对象。
问题是无论我如何移动我的相机,物体仍然每 5 秒放置在同一个位置。
如何不断更新世界位置 SIMD3?
这是我的代码。
@objc func updateTimer(){
if secondsPassed < 1 {
let anchor = AnchorEntity(world: SIMD3(x: 0, y: -0.25, z: -0.4))
let box = ModelEntity(mesh: .generateBox(size: 0.04), materials: [SimpleMaterial(color: .red, isMetallic: false)])
anchor.addChild(box)
arView.scene.addAnchor(anchor)
secondsPassed += 1
} else if secondsPassed < 5 {
secondsPassed += 1
} else {
secondsPassed = 0
arView.scene.anchors.removeAll()
}
}
【问题讨论】:
标签: ios swift augmented-reality arkit realitykit