Created
May 3, 2015 19:49
-
-
Save morganwilde/3c8570845dec8ad91a30 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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