{"id":2144,"date":"2021-07-05T20:08:30","date_gmt":"2021-07-05T20:08:30","guid":{"rendered":"https:\/\/sezeromer.com\/?p=2144"},"modified":"2023-03-04T13:45:52","modified_gmt":"2023-03-04T10:45:52","slug":"arkit-ile-nodeun-acisini-degistirmek","status":"publish","type":"post","link":"https:\/\/sezeromer.com\/en\/arkit-ile-nodeun-acisini-degistirmek\/","title":{"rendered":"Changing the angle of the Node with ARKit"},"content":{"rendered":"<p>Hello friends, in this article, we will talk about how to translate the Node we created with <strong>Swift<\/strong> <strong>ARKit<\/strong>. We will do this example on the house project we created earlier. You can find that article <a href=\"https:\/\/sezeromer.com\/arkit-ile-ev-olusturma\/\">here<\/a>.<\/p>\n<p>As we did in previous projects, we first add the node that creates the house to our scene. Then we need to change the <strong>Euler Angle<\/strong> of this house. More information about the <strong>Euler<\/strong> angle can be found <a href=\"https:\/\/en.wikipedia.org\/wiki\/Euler_angles\">here<\/a>. Of course, we cannot give a value in degrees to this angle. So we need to convert degrees to radians. For this we write a variable to Int. Then we can change the angle of the Node with this variable.<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;swift&quot;,&quot;mime&quot;:&quot;text\/x-swift&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:true,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:true,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">\/\/\r\n\/\/  ViewController.swift\r\n\/\/  arkit-rotation\r\n\/\/\r\n\/\/  Created by Omer Sezer on 5.07.2021.\r\n\/\/\r\n\r\nimport UIKit\r\nimport ARKit\r\n\r\nclass ViewController: UIViewController {\r\n\r\n    @IBOutlet weak var sceneView: ARSCNView!\r\n    let configuration = ARWorldTrackingConfiguration()\r\n        \r\n    override func viewDidLoad() {\r\n        super.viewDidLoad()\r\n        setUI()\r\n    }\r\n \r\n    func setUI() {\r\n        \/\/ MARK: sceneView\r\n        sceneView.debugOptions = [.showFeaturePoints, .showWorldOrigin]\r\n        sceneView.session.run(configuration)\r\n        sceneView.autoenablesDefaultLighting = true\r\n        \r\n        setHomeNode()\r\n    }\r\n    \r\n    func setHomeNode() {\r\n        let nodeRoof = SCNNode(geometry: SCNPyramid(width: 0.1, height: 0.1, length: 0.1))\r\n        nodeRoof.geometry?.firstMaterial?.diffuse.contents = UIColor.red\r\n        nodeRoof.eulerAngles = SCNVector3(0, 0, 90.degreesToRadians)\r\n        \r\n        let nodeHome = SCNNode(geometry: SCNBox(width: 0.1, height: 0.1, length: 0.1, chamferRadius: 0))\r\n        nodeHome.geometry?.firstMaterial?.diffuse.contents = UIColor.blue\r\n        \r\n        let nodeDoor = SCNNode(geometry: SCNPlane(width: 0.03, height: 0.06))\r\n        nodeDoor.geometry?.firstMaterial?.diffuse.contents = UIColor.green\r\n        \r\n        nodeRoof.position = SCNVector3(-0.1, 0.1, -0.7)\r\n        nodeHome.position = SCNVector3(0, -0.05, 0)\r\n        nodeDoor.position = SCNVector3(0, -0.02, 0.05)\r\n        \r\n        sceneView.scene.rootNode.addChildNode(nodeRoof)\r\n        nodeRoof.addChildNode(nodeHome)\r\n        nodeHome.addChildNode(nodeDoor)\r\n    }\r\n}\r\n\r\nextension Int {\r\n    var degreesToRadians: Double { return Double(self) * .pi \/ 180}\r\n}<\/pre>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-2147\" src=\"https:\/\/sezeromer.com\/wp-content\/uploads\/2021\/07\/IMG_398A40A26265-1-473x1024.jpeg\" alt=\"\" width=\"473\" height=\"1024\" srcset=\"https:\/\/sezeromer.com\/wp-content\/uploads\/2021\/07\/IMG_398A40A26265-1-473x1024.jpeg 473w, https:\/\/sezeromer.com\/wp-content\/uploads\/2021\/07\/IMG_398A40A26265-1-139x300.jpeg 139w, https:\/\/sezeromer.com\/wp-content\/uploads\/2021\/07\/IMG_398A40A26265-1-768x1662.jpeg 768w, https:\/\/sezeromer.com\/wp-content\/uploads\/2021\/07\/IMG_398A40A26265-1-710x1536.jpeg 710w, https:\/\/sezeromer.com\/wp-content\/uploads\/2021\/07\/IMG_398A40A26265-1-500x1082.jpeg 500w, https:\/\/sezeromer.com\/wp-content\/uploads\/2021\/07\/IMG_398A40A26265-1-800x1731.jpeg 800w, https:\/\/sezeromer.com\/wp-content\/uploads\/2021\/07\/IMG_398A40A26265-1.jpeg 828w\" sizes=\"(max-width: 473px) 100vw, 473px\" \/><\/p>\n<p>Actually, it&#8217;s that easy. You can access the project <a href=\"https:\/\/github.com\/omersezer\/arkit-samples\">here<\/a>. If you have questions, you can reach us by sending an e-mail or comment. Good work.<\/p>","protected":false},"excerpt":{"rendered":"<p>Hello friends, in this article, we will talk about how to translate the Node we created with Swift ARKit. We will do this example on the house project we created earlier. You can find that article here. As we did in previous projects, we first add the node that creates the house to our scene. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2117,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[824,327,706],"tags":[813,812,818,847,822,819,328,707],"class_list":["post-2144","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arkit","category-swift","category-swiftui","tag-ar","tag-arkit","tag-augmented","tag-augmented-rea","tag-augmented-reality","tag-reality","tag-swift","tag-swiftui"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts\/2144"}],"collection":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/comments?post=2144"}],"version-history":[{"count":5,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts\/2144\/revisions"}],"predecessor-version":[{"id":2674,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts\/2144\/revisions\/2674"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/media\/2117"}],"wp:attachment":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/media?parent=2144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/categories?post=2144"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/tags?post=2144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}