SceneKit: How to place a 3D object in order to fit the SCNView bounds?

1.1k views Asked by At

I'm new to SceneKit and 3D objects. I've been doing some research but I didn't find an answer to my question.

I need to display several 3D objects in an horizontal UICollectionView, one in each cell. I'd like them to be aligned and the same size so I'd like them to fit the parent view, aka the SCNView.

An image to picture the scenario:

3D objects, each in a SCNView, all the same size

I'd like that the bounds of the 3D object visually matches the bounds of the SCNView. I want the 3D object to "fit" in the view, a bit like UIViewContentMode.scaleAspectFit.


Here's my code so far:

let scene=SCNScene(named: file_name)
let node=scene.rootNode.childNode(withName: node_name, recursively: true)!
node.scale=SCNVector3Make(28, 28, 28)
node.position=SCNVector3Make(0, 0.05, -0.5)
scene.rootNode.addChildNode(node)
sceneview.scene=scene
0

There are 0 answers