Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 绕单轴旋转SceneKit圆柱体_Ios_Swift_Scenekit - Fatal编程技术网

Ios 绕单轴旋转SceneKit圆柱体

Ios 绕单轴旋转SceneKit圆柱体,ios,swift,scenekit,Ios,Swift,Scenekit,我有以下代码可以在视图中显示三维圆柱体。在设备上查看时,手势会在x轴上下滑动手势和y轴左右滑动手势上旋转圆柱体,但z轴被锁定。我相信这是AllowCameraControl的默认设置 我想我要做的是锁定x轴,这样只有向左和向右滑动手势才能工作。我应该看不到圆柱体的顶部或底部。我希望在左右滑动时保持默认旋转,即在滑动后旋转速度自然减慢 感谢您的帮助 class MyCollectionViewController: UIViewController { @IBOutlet weak var sc

我有以下代码可以在视图中显示三维圆柱体。在设备上查看时,手势会在x轴上下滑动手势和y轴左右滑动手势上旋转圆柱体,但z轴被锁定。我相信这是AllowCameraControl的默认设置

我想我要做的是锁定x轴,这样只有向左和向右滑动手势才能工作。我应该看不到圆柱体的顶部或底部。我希望在左右滑动时保持默认旋转,即在滑动后旋转速度自然减慢

感谢您的帮助

class MyCollectionViewController: UIViewController {

@IBOutlet weak var scnView: SCNView!

var scnScene: SCNScene!


override func viewDidLoad() {
    super.viewDidLoad()
    sceneSetup()
}


// MARK: Scene
func sceneSetup() {

    scnScene = SCNScene()

    let cylinder = SCNNode(geometry: SCNCylinder(radius: 5.0, height: 20))
    cylinder.geometry?.firstMaterial?.diffuse.contents = UIImage(named: "image1")
    cylinder.geometry?.firstMaterial?.specular.contents = UIColor.white

    scnView.allowsCameraControl = true

    scnScene.rootNode.addChildNode(cylinder)

    scnView.autoenablesDefaultLighting = true

    scnView.scene = scnScene
}

}

将以下内容添加到您的代码中可以锁定垂直方向

   scnView.defaultCameraController.maximumVerticalAngle = 0.001

添加以下代码可以锁定垂直方向

   scnView.defaultCameraController.maximumVerticalAngle = 0.001

喜欢单线解决方案!谢谢喜欢单线解决方案!谢谢