我正在使用以下代码来使用平移手势旋转节点。我只想在y轴上旋转我的节点。
let translation = gestureRecognize.translation(in: gestureRecognize.view!)
let x = Float(translation.x)
let y = Float(-translation.y)
let anglePan = (sqrt(pow(x,2)+pow(y,2)))*(Float)(Double.pi)/180.0
var rotationVector = SCNVector4()
rotationVector.x = 0.0
rotationVector.y = x
rotationVector.z = 0.0
rotationVector.w = anglePan
node.rotation = rotationVector
if(gestureRecognize.state == UIGestureRecognizerState.ended) {
let currentPivot = node.pivot
let changePivot = SCNMatrix4Invert( node.transform)
node.pivot = SCNMatrix4Mult(changePivot, currentPivot)
node.transform = SCNMatrix4Identity
}
这适用于欧拉角设置为(x:0,y:0,z:0)的节点。但是我的节点具有欧拉角(x:-90,y:0,z:0)。对于我上面的欧拉值,代码旋转了错误的角度。如何使用我的/不同的欧拉值旋转节点?