<small id='94G7Q'></small><noframes id='94G7Q'>

  • <legend id='94G7Q'><style id='94G7Q'><dir id='94G7Q'><q id='94G7Q'></q></dir></style></legend>

    1. <i id='94G7Q'><tr id='94G7Q'><dt id='94G7Q'><q id='94G7Q'><span id='94G7Q'><b id='94G7Q'><form id='94G7Q'><ins id='94G7Q'></ins><ul id='94G7Q'></ul><sub id='94G7Q'></sub></form><legend id='94G7Q'></legend><bdo id='94G7Q'><pre id='94G7Q'><center id='94G7Q'></center></pre></bdo></b><th id='94G7Q'></th></span></q></dt></tr></i><div id='94G7Q'><tfoot id='94G7Q'></tfoot><dl id='94G7Q'><fieldset id='94G7Q'></fieldset></dl></div>

      • <bdo id='94G7Q'></bdo><ul id='94G7Q'></ul>
      1. <tfoot id='94G7Q'></tfoot>

        如何使用平移手势旋转场景中的对象 - SceneKit

        How to rotate object in a scene with pan gesture - SceneKit(如何使用平移手势旋转场景中的对象 - SceneKit)
        <i id='y8kbq'><tr id='y8kbq'><dt id='y8kbq'><q id='y8kbq'><span id='y8kbq'><b id='y8kbq'><form id='y8kbq'><ins id='y8kbq'></ins><ul id='y8kbq'></ul><sub id='y8kbq'></sub></form><legend id='y8kbq'></legend><bdo id='y8kbq'><pre id='y8kbq'><center id='y8kbq'></center></pre></bdo></b><th id='y8kbq'></th></span></q></dt></tr></i><div id='y8kbq'><tfoot id='y8kbq'></tfoot><dl id='y8kbq'><fieldset id='y8kbq'></fieldset></dl></div>
          <tfoot id='y8kbq'></tfoot>
            <bdo id='y8kbq'></bdo><ul id='y8kbq'></ul>

          • <legend id='y8kbq'><style id='y8kbq'><dir id='y8kbq'><q id='y8kbq'></q></dir></style></legend>
              <tbody id='y8kbq'></tbody>
          • <small id='y8kbq'></small><noframes id='y8kbq'>

                1. 本文介绍了如何使用平移手势旋转场景中的对象 - SceneKit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我想用 Scene 工具包创建一个应用程序来解决 Rubix Cube.我有自己的多维数据集 dae 文件.这是我在 viewDidLoad 中的设置代码

                  I'm tying to create an app with Scene kit to solve Rubix Cube. I've my own dae file for the cube. this is my setup code in viewDidLoad

                      let myscene = SCNScene(named: "Rubik1.scnassets/Rubiks_Cube.dae")
                      scene.rootNode.addChildNode((myscene?.rootNode)!)
                  
                      // retrieve the SCNView
                      let scnView = self.view as! SCNView
                  
                      // set the scene to the view
                      scnView.scene = scene
                  
                      geometryNode = (scnView.scene?.rootNode.childNodeWithName("Cube",recursively: true))!
                  
                      let panRecognizer = UIPanGestureRecognizer(target: self, action: "panGesture:")
                      scnView.addGestureRecognizer(panRecognizer)
                  

                  在识别平移手势以旋转立方体时

                  upon recognising a pan gesture to rotate the cube

                  func panGesture(gestureRecognize: UIPanGestureRecognizer){
                  
                      let translation = gestureRecognize.translationInView(gestureRecognize.view!)
                  
                      let x = Float(translation.x)
                      let y = Float(-translation.y)
                  
                      let anglePan = sqrt(pow(x,2)+pow(y,2))*(Float)(M_PI)/180.0
                  
                      var rotationVector = SCNVector4()
                      rotationVector.x = -y
                      rotationVector.y = x
                      rotationVector.z = 0
                      rotationVector.w = anglePan
                  
                      geometryNode.rotation = rotationVector
                  
                      //geometryNode.transform = SCNMatrix4MakeRotation(anglePan, -y, x, 0)
                  
                      if(gestureRecognize.state == UIGestureRecognizerState.Ended) {
                          //
                      }
                  }
                  

                  上面的代码不保留以前的平移手势.如何使用旋转向量"或

                  above code doesn't preserve the previous pan gestures. how do I use "rotationvector" or

                  SCNMatrix4MakeRotation(anglePan, -y, x, 0)
                  

                  旋转立方体

                  推荐答案

                  问题解决了

                  if(gestureRecognize.state == UIGestureRecognizerState.Ended) {
                  
                      let currentPivot = geometryNode.pivot
                      let changePivot = SCNMatrix4Invert( geometryNode.transform)
                  
                      geometryNode.pivot = SCNMatrix4Mult(changePivot, currentPivot)
                  
                      geometryNode.transform = SCNMatrix4Identity
                  }
                  

                  这篇关于如何使用平移手势旋转场景中的对象 - SceneKit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How To Create a Rotating Wheel Control?(如何创建转轮控件?)
                  iOS 6 rotations: supportedInterfaceOrientations doesn#180;t work?(iOS 6 旋转:supportedInterfaceOrientations 不起作用?)
                  CABasicAnimation rotate returns to original position(CABasicAnimation 旋转返回原始位置)
                  How to avoid restarting activity when orientation changes on Android(如何在 Android 上的方向更改时避免重新启动活动)
                  UITabBarController Rotation Issues in ios 6(ios 6 中的 UITabBarController 旋转问题)
                  iOS: How to run a function after Device has Rotated (Swift)(iOS:设备旋转后如何运行函数(Swift))
                  1. <i id='7H6XK'><tr id='7H6XK'><dt id='7H6XK'><q id='7H6XK'><span id='7H6XK'><b id='7H6XK'><form id='7H6XK'><ins id='7H6XK'></ins><ul id='7H6XK'></ul><sub id='7H6XK'></sub></form><legend id='7H6XK'></legend><bdo id='7H6XK'><pre id='7H6XK'><center id='7H6XK'></center></pre></bdo></b><th id='7H6XK'></th></span></q></dt></tr></i><div id='7H6XK'><tfoot id='7H6XK'></tfoot><dl id='7H6XK'><fieldset id='7H6XK'></fieldset></dl></div>
                    <tfoot id='7H6XK'></tfoot><legend id='7H6XK'><style id='7H6XK'><dir id='7H6XK'><q id='7H6XK'></q></dir></style></legend>
                      <tbody id='7H6XK'></tbody>

                    • <bdo id='7H6XK'></bdo><ul id='7H6XK'></ul>

                          <small id='7H6XK'></small><noframes id='7H6XK'>