嘿,我試圖找出如何保持代替簡單的節點是我走在它周圍ARKit如何保持ARKit SCNNode到位
代碼:
func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
if let planeAnchor = anchor as? ARPlaneAnchor {
if planeDetected == false { // Bool only allows 1 plane to be added
planeDetected = true
self.addPlane(node: node, anchor: planeAnchor)
}
}
}
這增加了SCNNode
func addPlane(node: SCNNode, anchor: ARPlaneAnchor) {
// We add the anchor plane here
let showDebugVisuals = Bool()
let plane = Plane(anchor, showDebugVisuals)
planes[anchor] = plane
node.addChildNode(plane)
// We add our custom SCNNode here
let scene = SCNScene(named: "art.scnassets/PlayerModel.scn")!
let Body = scene.rootNode.childNode(withName: "Body", recursively: true)!
Body.position = SCNVector3.positionFromTransform(anchor.transform)
Body.movabilityHint = .movable
wrapperNode.position = SCNVector3.positionFromTransform(anchor.transform)
wrapperNode.addChildNode(Body)
scnView.scene.rootNode.addChildNode(wrapperNode)
伊夫嘗試添加一個平面/錨節點,並把「身體」節點在,但它依然繼續。我想也許它與更新功能有關。
func renderer(_ renderer: SCNSceneRenderer, didUpdate node: SCNNode, for anchor: ARAnchor) {
}
或者最有可能的位置設置
wrapperNode.position = SCNVector3.positionFromTransform(anchor.transform)
Iv'e通過互聯網上的每個源/項目文件/視頻看了看,沒有人有一個簡單的解決這個簡單的問題。
有沒有簡單的解決方案。您應該使用表面檢測來獲得更好的結果,但對象仍然會稍微移動一點。 –
好的,謝謝你確認這不是一個簡單的解決方案。 – Hunter