I am working on ARKit project and trying to place some objects on a detected plane. But it doesn't work properly once i move the device to place an other object, the first object doesn't stand on his position. I want that every rendered object be stuck in the first position until the user start interacting with it.
I already see this:
ARKIT : place object on a plane doesn't work properly
But there is no solution yet.
func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
guard let planeAnchor = anchor as? ARPlaneAnchor else { return }
self.planeAnchor = planeAnchor
self.floorNode = node
DispatchQueue.main.async {
self.messageLabel.text = "Surface Detectée - Taper + pour choisir des objets"
self.addModelButton.isEnabled = true
self.addModelButton.alpha = 1
}
}
func addFurniture(selectedNode:SCNNode) {
selectedNode.simdPosition = float3(planeAnchor.center.x, planeAnchor.center.y, planeAnchor.center.z)
floorNode.addChildNode(selectedNode)
messageLabel.text = "Model chargé - Vous pouvez le positionner, le faire tourner ou ajouter d'autres. "
}
Once the plane is detected, the user select a model from a collectionView then the model is placed in the detected plane once addFurniture(selectedNode:SCNNode) is called.
What am I doing wrong or what I'm not doing ? please can any one help me ?