How to set camera to see all object in SCNSceneKit?

244 Views Asked by At

I have a weird problem that my text node and frame nodes doesnt fit the screen. I almost tried every suggestion in other answers of questions but could not manage. I tried adding zFar, placing camera so far and so close, scaling objects to different ratios didnt work. the problem same in both physical and simulator devices.

the other problem is I want to set a background to sceneView. when I add image using scene.background.contents = image it works but picture is not aspected.

to make it aspectFit I create imageView but it crashes physical device and blank in virtual device. here is the code

  let image = UIImageView()
    let mainImage = UIImage(named:"mountain")
    image.image = mainImage
    image.contentMode = .scaleAspectFill
    image.sendSubview(toBack: sceneView)
    scene.background.contents = image

here is the pic when camera shows the text node enter image description here

1

There are 1 best solutions below

0
On

Alright Guys, Finally I solve the problem. it is because of how to define z axis in xcode 9. in xcone 9 or swift 4 if you want to put an object to forward you need to define z axis with minus like node.position = SCNVector3(0,0,-5) if not objects are put backward and you cant see them.