Create a 2D image as a SCNNode in scene kit ios swift

Viewed 3839

I am trying to create an SCNNode in scene kit based on a 2D jpg image. This image is to be placed in another 3D SCNNode. I have tried using .background.contents on my scene but this is not what i'm looking for. Any idea of how i can do that? Thanks!

This is my code:

@IBOutlet weak var sceneView: ARSCNView!

in the viewDidLoad method:

let scene = SCNScene()

sceneView.scene = scene

in viewWillAppear:

let ship = SpaceShip()
ship.loadModal()
ship.position = SCNVector3(0, 0, Double(-1.5))
sceneView.scene.rootNode.addChildNode(ship)

this is the class Spaceship:

class SpaceShip: SCNNode {

func loadModal(){
    let virtualObjectScene = SCNScene(named: "ship.scn")!
    let wrapperNode = SCNNode()

    for child in virtualObjectScene.rootNode.childNodes{
        wrapperNode.addChildNode(child)
        }

    self.addChildNode(wrapperNode)
    }
}
2 Answers
Related