Is there anyway to center the pivot of a model? Currently (by default) it is set to the bottom left. I want to set to the center. How can I do that?
Here is the image:
UPDATE: I added another node and added the chair as a child.
So, now it works better but it does not rotate all the way and it resets the position if I continue to rotate. Here is the code for the panned operation:
@objc func panned(recognizer :UIPanGestureRecognizer) {
var newAngleY :Float = 0.0
if recognizer.state == .changed {
let sceneView = recognizer.view as! ARSCNView
let touchPoint = recognizer.location(in: sceneView)
let translation = recognizer.translation(in: sceneView)
print(translation.x)
let scnHitTestResults = self.sceneView.hitTest(touchPoint, options: nil)
if let hitTestResult = scnHitTestResults.first {
if let parentNode = hitTestResult.node.parent {
newAngleY = (Float)(translation.x)*(Float)(Double.pi)/180
newAngleY += currentAngleY
parentNode.eulerAngles.y = newAngleY
}
}
}
else if recognizer.state == .ended {
currentAngleY = newAngleY
}
}