There are lot's of advices for the UIKit with UIImage class, but I'm using AppKit for macos and NSImage class. And none of the options I found in the web haven't worked for me yet. Probably I misunderstand something fundamental. Well, firstly I dragndroped a picture named "sims.jpg" to my project folder and to art.scnassets folder. And also added them with File → Add files to "art.scnassets" and general folder. And did nothing with Assets.xcassets.
This is the full code: pastebin.com/vw4CUYRm. Function called createOctahedron() is where I would like to add material to the shape. I haven't left there any of my tryings. And here they are:
№1
Expand|Select|Wrap|Line Numbers
- let imageMaterial = SCNMaterial()
- let image = NSImage(named: NSImage.Name("sims"))
- imageMaterial.diffuse.contents = image
- geometry.materials = [imageMaterial, imageMaterial, imageMaterial, imageMaterial, imageMaterial, imageMaterial, imageMaterial, imageMaterial]
Expand|Select|Wrap|Line Numbers
- node.geometry?.firstMaterial?.diffuse.contents = NSImage(named: NSImage.Name("sims"))