Add 3d node to sceneView following wwdc code, but the 3d node rotates 90 degrees

余生颓废 提交于 2020-02-06 07:42:35

问题


I use iPad to develop an AR app. I follow the wwdc code to add my first node on the sceneView. If the iPad is landscape, I can get the right result, but if the iPad is Portrait, it rotates 90 degrees. Anybody can help me, thanks?

        guard let frame = sceneView.session.currentFrame else {
            return
        }
        if let scnStr = noti.object as? String {
            // Create a new scene
            let scene = SCNScene(named: "art.scnassets/\(scnStr)")!
            let emojiNode = SCNNode()
            for node in scene.rootNode.childNodes  {
               emojiNode.addChildNode(node)
            }
            sceneView.scene.rootNode.addChildNode(emojiNode)
            var translation = matrix_identity_float4x4
            translation.columns.3.z = -1
            emojiNode.simdTransform = matrix_multiply(frame.camera.transform, translation)
        }

来源:https://stackoverflow.com/questions/60072627/add-3d-node-to-sceneview-following-wwdc-code-but-the-3d-node-rotates-90-degrees

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!