Search code examples
cocoapodstexturesbundlescenekitscnscene

SCNScene load with textures from pod


I am trying to create pod which contains SCNScene with textures and got an error:

SceneKit Error: Failed loading : C3DImage
src:file:///Users/.../Example.app/Templates.scnassets/grid.png

Texture and scene are in the same folder.

I've tried to load with SCNSceneSource

let sceneData = try Data(contentsOf: sceneUrl)
let options = [.overrideAssetURLs: true,
               .assetDirectoryURLs: MYPod.bundle().bundleURL
               ] as [SCNSceneSource.LoadingOption : Any]
let source = SCNSceneSource(data: sceneData, options:options)
scene = (source?.scene(options: options))!

but got same result (path not changing)


Solution

  • You should go trough all of the materials with the code and (sorry for pseudo code)

    If material.contents.type == String.type { 
    material.contents = UIImage(named: <path tofolder>/material.contents) 
    }