let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = .horizontal
arSceneView.session.run(configuration)
This will give you 6DOF. Just make sure you detect a plane before moving around.
You use your touch location to move your object in the ARKit scene. You can do a ray trace to achieve this. It all works on top of the horizontal plane that you detect through your camera and nothing more.
let hitResult = sceneView.hitTest(touchLocation, types: .existingPlane)
This hitResult array will help you place your object.
for instance.
let velocity :CGPoint = recognizer.velocity(in: self.arSceneView)
self.objectModel.node.position.y = (self.objectModel.node.position.y + Float(velocity.y * -0.0001))
Thats your translation.
let translation = recognizer.translation(in: recognizer.view!)
let x = Float(translation.x)
let y = Float(-translation.y)
let anglePan = (sqrt(pow(GLKMathDegreesToRadians(x),2)+pow(GLKMathDegreesToRadians(y),2)))
var rotationVector = SCNVector4()
rotationVector.x = -y
rotationVector.y = x
rotationVector.z = 0
rotationVector.w = anglePan
self.objectModel.node.rotation = rotationVector
self.sphereNode.rotation = rotationVector
Thats your rotation on a model in the SceneKit. These are just examples of how to do translation and rotation in an ARScene. Make changes as required.
arSceneView.pointOfView is your camera. The rotation and position transform of this node should give you the device's position and rotation.
arSceneView.pointOfView?.transform // Gives you your camera's/device's SCN4Matrix transform
arSceneView.pointOfView?.eulerAngles // Gives you the SCNVector3 rotation matrix.
arSceneView.pointOfView?.position // Gives you the camera's SCNVector3 position matrix.