SceneKit

SceneKit, sometimes rendered Scene Kit, is a 3D graphics application programming interface (API) for Apple Inc. platforms written in Objective-C. It is a high-level framework designed to provide an easy-to-use layer over the lower level APIs like OpenGL and Metal.[1] SceneKit maintains an object based scene graph, along with a physics engine, particle system, and links to Core Animation and other frameworks to easily animate that display. SceneKit views can be mixed with other views, for instance, allowing a SpriteKit 2D display to be mapped onto the surface of an object in SceneKit, or a UIBezierPath from Core Graphics to define the geometry of a SceneKit object. SceneKit also supports import and export of 3D scenes using the COLLADA format. SceneKit was first released for macOS in 2012, and iOS in 2014.

Basic concepts

SceneKit maintains a scene graph based on a root object, an instance of the class SCNScene. The SCNScene object is roughly equivalent to the view objects found in most 2D libraries, and is intended to be embedded in a display container like a window or another view object. The only major content of the SCNScene is a link to the rootNode, which points to an SCNNode object.

SCNNodes are the primary contents of the SceneKit hierarchy. Each Node has a Name, and pointers to optional Camera, Light and Geometry objects, as well as an array of childNodes and a pointer to its own parent. A typical scene will contain a single Scene object pointed to a conveniently named Node (often "root") whose primary purpose is to hold a collection of children Nodes. The children nodes can be used to represent cameras, lights, or the various geometry objects in the Scene.

A simple Scene can be created by making a single SCNGeometry object, typically with one of the constructor classes like SCNBox, a single SCNCamera, one or more SCNLights, and then assigning all of these objects to separate Nodes. A single additional generic Node is then created and assigned to the SCNScene object's rootNode, and then all of the objects are added as children of that rootNode.

SCNScenes also contain a number of built-in user interface controls and input/output libraries to greatly ease implementing simple viewers and similar tasks. For instance, setting the Scene's autoenablesDefaultLighting and allowsCameraControl to true, and then adding an object tree read from a COLLADA file will produce viewable content of arbitrary complexity with a few lines of code. The integration with Xcode allows the Scene itself to be placed in a window in Interface Builder, without any code at all.

There is a Scenekit archive file format, using the filename extension .scn.

References


This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.