SceneKit beginner here, doing an iOS project.
I have been wrapping textures around SCN geometry (spheres, so far) like this:
let scene = SCNScene()
var planet : SCNGeometry
planet = SCNSphere(radius: 1.0)
let material = SCNMaterial()
material.diffuse.contents = UIImage(named: "texture.jpg")
planet.materials = [material]
let planetNode = SCNNode(geometry: planet)
scene.rootNode.addChildNode(planetNode)
And this seems to be working fine. I have textures that are meant to apply to spheres anyways.
However, when I try to load a custom obj file, texture materials seem to refuse to map onto it when I load the geometry from the obj like so:
let scene = SCNScene()
var planet : SCNGeometry
let tempScene = SCNScene(named: "model.obj")
planet = tempScene!.rootNode.childNodes[0].geometry!
let material = SCNMaterial()
material.diffuse.contents = UIImage(named: "texture.jpg")
planet.materials = [material]
let planetNode = SCNNode(geometry: planet)
scene.rootNode.addChildNode(planetNode)
The model object, however, appears to show just fine, albeit, without the texture.
Any pointers?