import UIKit
import SceneKit
import QuartzCore
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let scene = SCNScene()
let scnView = self.view as! SCNView
scnView.scene = scene
let cameraNode = SCNNode()
cameraNode.camera = SCNCamera()
scene.rootNode.addChildNode(cameraNode)
cameraNode.position = SCNVector3(x: 0, y: 0, z: 15) //where will be situated a cube
scnView.allowsCameraControl = true //that's for you can spin it any direction with your finger if you are bored
scnView.autoenablesDefaultLighting = true //Lightting
var geometries = [
SCNBox(width: 4.0, height: 4.0, length: 4.0, chamferRadius: 0),
] //This is the cube with parameters of 4
var materials = [SCNMaterial]()
for i in 1...6 {
let material = SCNMaterial()
if i == 1 { material.diffuse.contents = UIImage (named: "qr.png") }
if i == 2 { material.diffuse.contents = UIColor(red: 0.6784, green: 0.698, blue: 0.7412, alpha: 1.0) }
if i == 3 { material.diffuse.contents = UIColor(red: 0.6784, green: 0.698, blue: 0.7412, alpha: 1.0) }
if i == 4 { material.diffuse.contents = UIColor(red: 0.6784, green: 0.698, blue: 0.7412, alpha: 1.0) }
if i == 5 { material.diffuse.contents = UIColor(red: 0.6784, green: 0.698, blue: 0.7412, alpha: 1.0) }
if i == 6 { material.diffuse.contents = UIColor(red: 0.7882, green: 0.7961, blue: 0.8863, alpha: 1.0) }
materials.append(material)
} //this is to coloring each side of cube
for i in 0..<geometries.count {
let geometry = geometries[i]
let node = SCNNode(geometry: geometry)
node.geometry?.materials = materials
node.runAction(SCNAction.repeatForever(SCNAction.rotateBy(x: 1, y: 1, z: 1, duration: 5)))
scene.rootNode.addChildNode(node)
}
}
"von Bild"? Wie in ... – tktsubota
@ tktsubota als eine seiner Seiten. Genau wie in der Verbindung getan. – Curnelious
Haben Sie SceneKit ausprobiert? – tktsubota