Skip to content

Instantly share code, notes, and snippets.

@morganwilde
Created May 3, 2015 19:49
Show Gist options
  • Save morganwilde/3c8570845dec8ad91a30 to your computer and use it in GitHub Desktop.
Save morganwilde/3c8570845dec8ad91a30 to your computer and use it in GitHub Desktop.
// Scene view setup
sceneView.autoenablesDefaultLighting = true
sceneView.allowsCameraControl = true
let scene = SCNScene()
let rootNode = scene.rootNode
// Box
let boxGeometry = SCNBox(width: 1, height: 1, length: 1, chamferRadius: 0)
let boxMaterial1 = SCNMaterial()
boxMaterial1.diffuse.contents = UIColor.redColor()
let boxMaterial2 = SCNMaterial()
boxMaterial2.diffuse.contents = UIColor.blueColor()
let boxMaterial3 = SCNMaterial()
boxMaterial3.diffuse.contents = UIColor.orangeColor()
let boxMaterial4 = SCNMaterial()
boxMaterial4.diffuse.contents = UIColor.greenColor()
let boxMaterial5 = SCNMaterial()
boxMaterial5.diffuse.contents = UIColor.magentaColor()
let boxMaterial6 = SCNMaterial()
boxMaterial6.diffuse.contents = UIColor.cyanColor()
boxGeometry.materials = [boxMaterial1, boxMaterial2, boxMaterial3, boxMaterial4, boxMaterial5, boxMaterial6]
for material in boxGeometry.materials as! [SCNMaterial] {
material.doubleSided = true
}
let boxNode = SCNNode(geometry: boxGeometry)
boxNode.position = SCNVector3(
x: 0,
y: 0,
z: -1)
rootNode.addChildNode(boxNode)
// Camera
let camera = SCNCamera()
camera.zNear = 0
// camera.orthographicScale = 1
// camera.usesOrthographicProjection = true
let cameraNode = SCNNode()
cameraNode.position = SCNVector3(
x: 0,
y: 0,
z: 0)
cameraNode.camera = camera
rootNode.addChildNode(cameraNode)
sceneView.scene = scene
println(view.frame)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment