Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Add camera node in sceneKit

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 3.22k
    Comment on it

      Adding Camera node  provide us the point of view from which we view our scene. To add camera node we have to simply make the SCNCamera object and assign it to node’s camera property.

         

      let scene = SCNScene ()   // set up a scene
            
            // Add the geometry object , it will make a visible content on scene. Here we are using SCNBox type
            let boxShape = SCNBox.init(width: 1, height: 1, length: 1, chamferRadius: 0)
            
             boxShape.firstMaterial!.diffuse.contents = UIColor.redColor()  // this will add color to the geometry object
            
            let boxNode = SCNNode (geometry: boxShape)
            
            scene.rootNode.addChildNode(boxNode) // add boxNode as the child node to the scene's root node


            
         
           Add camera node to your Scene
           

     let camera = SCNCamera ()
            
            let cameraNode = SCNNode ()
            
            cameraNode.camera = camera
            
            cameraNode.position = SCNVector3Make(0, 0, 10) // set your camera position
            
            scene.rootNode.addChildNode(cameraNode)
            
            sceneView.scene = scene //add scene to your SCNView 
            
            sceneView.allowsCameraControl = true // this will change the point of view by a simple touch.

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: