Scale SCNNode in SceneKit Scale SCNNode in SceneKit ios ios

Scale SCNNode in SceneKit


I just tested in a playground and it worked perfectly for me. Perhaps your camera is zooming in to compensate for the smaller box?

import SceneKitimport SpriteKitimport XCPlaygroundlet sceneView = SCNView(frame: CGRect(x: 0, y: 0, width: 800, height: 600))XCPlaygroundPage.currentPage.liveView = sceneViewvar scene = SCNScene()sceneView.scene = scenesceneView.backgroundColor = SKColor.greenColor()sceneView.debugOptions = .ShowWireframe// default lightingsceneView.autoenablesDefaultLighting = true// a cameravar cameraNode = SCNNode()cameraNode.camera = SCNCamera()cameraNode.position = SCNVector3(x: 15, y: 15, z: 30)scene.rootNode.addChildNode(cameraNode)let box = SCNBox(width: 10.0, height: 10.0, length: 10.0, chamferRadius: 0)let boxNode = SCNNode(geometry: box)boxNode.position = SCNVector3(x: 0, y: 0, z: 0)scene.rootNode.addChildNode(boxNode)let centerConstraint = SCNLookAtConstraint(target: boxNode)cameraNode.constraints = [centerConstraint]let sphere = SCNSphere(radius: 4)let sphereNode = SCNNode(geometry: sphere)sphereNode.position = SCNVector3(x:15, y:0, z:0)scene.rootNode.addChildNode(sphereNode)//boxNode.scale = SCNVector3(x: 0.5, y: 0.5, z: 0.5)

Uncomment the last line and you'll see the box (10 x 10 x 10) switch switch from being larger than the sphere (diameter of 8) to being smaller than the sphere. Here it is after the scaling:

enter image description here