Adding a Floor

Now you can add a floor to your game. SceneKit has a special geometry class made just for this purpose. SCNFloor is an infinite floor to add to your scene. You can get the texture for this floor from http://goo.gl/8YTY5z.

Here’s the code you add for the floor:

func addFloor() {    var floorGeo = SCNFloor()    floorGeo.reflectionFalloffEnd = 0    floorGeo.reflectivity = 0    floor = SCNNode()    floor.geometry = floorGeo    floor.geometry?.firstMaterial?.diffuse.contents = "art.scnassets/wood.png"    floor.geometry?.firstMaterial?.locksAmbientWithDiffuse = true    floor.geometry?.firstMaterial?.diffuse.wrapS = SCNWrapMode.Repeat    floor.geometry?.firstMaterial?.diffuse.wrapT = SCNWrapMode.Repeat    floor.geometry?.firstMaterial?.diffuse.mipFilter ...

Get Learning Swift™ Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.