xcode9 / SceneKit - .dae file not loading into SCNScene - returns nil

吃可爱长大的小学妹 提交于 2019-12-02 06:05:07

问题


I'm trying to load a .dae file into SCNScene, using the following code:

let solutionScene = SCNScene(named: "art.scnassets/level1.dae")
print(solutionScene?.rootNode) // prints nil

solutionNode = solutionScene?.rootNode.childNode(withName: "level1", recursively: true)

I exported the .dae file from Blender as COLLADA with default settings, contains just a one simple object.

When i click on the .dae file in my art.scnassets folder in XCode, it opens without problem and i can see the geometry, camera etc.

I just can't get it loaded in the SCNScene. Is there anything i missed either on Blender side or Xcode/Swift side?


回答1:


In case somebody runs into a similar newbie problem, the issue gets resolved by adding the .scnassets folder into "Copy Bundle Resources" under Build Phases of the project - cleaning the project might be required in some cases before you rebuild again. This solved my issue.



来源:https://stackoverflow.com/questions/46514800/xcode9-scenekit-dae-file-not-loading-into-scnscene-returns-nil

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!