Upgrade to Pro — share decks privately, control downloads, hide ads and more …

SceneKit Introduction and Demo

SceneKit Introduction and Demo

Introduction to SceneKit, and a code demo of the minimum information needed to produce SceneKit output.

21 lines of code and 8 concepts.

Patrick Weigel

September 26, 2017
Tweet

More Decks by Patrick Weigel

Other Decks in Programming

Transcript

  1. Cocoa Coders 2017-09-28 SceneKit Targeted Tutorial Code With Me! You’re

    Smart: All You Need: • The Concepts • Working Skeleton Code SceneKit
  2. Cocoa Coders 2017-09-28 SceneKit Targeted Tutorial Code With Me! You’re

    Smart: All You Need: • 8 Concepts • 21 Lines of Code SceneKit
  3. Cocoa Coders 2017-09-28 SceneKit The Concepts Nouns • View •

    Scene • Object • Camera • Light SceneKit 1/3
  4. Cocoa Coders 2017-09-28 SceneKit The Concepts Nouns • View •

    Scene • Object • Camera • Light SceneKit 2/3 Verbs • Attach
  5. Cocoa Coders 2017-09-28 SceneKit The Concepts Nouns • View •

    Scene • Object • Camera • Light SceneKit 3/3 Verbs • Attach More Nouns • Node • Material
  6. Cocoa Coders 2017-09-28 SceneKit Targeted Tutorial You’re Smart: All You

    Need: • 8 Concepts • 21 Lines of Code SceneKit
  7. Cocoa Coders 2017-09-28 SceneKit The Concepts Nouns • View •

    Scene • Object • Camera • Light SceneKit Verbs • Attach More Nouns • Node • Material
  8. Cocoa Coders 2017-09-28 SceneKit The Code // 0 I can

    affect the world around me self.view.backgroundColor = UIColor.cyan // 1 create the view let minimalSceneKitView = self.view as! SCNView // 2 create the scene and attach it to the view let minimalSceneKitScene = SCNScene() minimalSceneKitView.scene = minimalSceneKitScene /// 3 create an object and attach the object to the scene via a node let sphereOne = SCNSphere(radius: 8.0) let sphereOneMaterial = SCNMaterial() sphereOneMaterial.diffuse.contents = UIColor.green sphereOne.materials = [sphereOneMaterial] let sphereOneNode = SCNNode(geometry: sphereOne) minimalSceneKitScene.rootNode.addChildNode(sphereOneNode) SceneKit // 4 create a camera and attach the camera to the scene via a node let cameraOne = SCNCamera() let cameraOneNode = SCNNode() cameraOneNode.camera = cameraOne cameraOneNode.position = SCNVector3Make(0.0, 0.0, 30.0) minimalSceneKitScene.rootNode.addChildNode(cameraOneNode) // 5 create a light and attach the light to the scene via a node let lightOne = SCNLight() let lightOneNode = SCNNode() lightOneNode.light = lightOne lightOneNode.position = SCNVector3Make(-30.0, 30.0, 50.0) minimalSceneKitScene.rootNode.addChildNode(lightOneNode)
  9. Cocoa Coders 2017-09-28 SceneKit Different Objects Multiple Objects Custom Skins/Textures

    Custom Objects Light Characteristics Animatable SceneKit Targeted Tutorial++