= session.currentFrame?.camera.transform else { return } recentVirtualObjectDistances.removeAll() let cameraWorldPos = SCNVector3.positionFromTransform(cameraTransform) var cameraToPosition = pos - cameraWorldPos // Limit the distance of the object from the camera to a maximum of 10 meters. cameraToPosition.setMaximumLength(10) object.position = cameraWorldPos + cameraToPosition if object.parent == nil { sceneView.scene.rootNode.addChildNode(object) } }