xcode9/SceneKit - .dae 文件未加载到 SCNScene - 返回 nil [英] xcode9 / SceneKit - .dae file not loading into SCNScene - returns nil

查看:122
本文介绍了xcode9/SceneKit - .dae 文件未加载到 SCNScene - 返回 nil的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码将 .dae 文件加载到 SCNScene 中:

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)

我使用默认设置从 Blender 导出了 .dae 文件作为 COLLADA,只包含一个简单的对象.

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

当我在 XCode 的 art.scnassets 文件夹中单击 .dae 文件时,它打开没有问题,我可以看到几何图形、相机等.

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.

我就是无法在 SCNScene 中加载它.我在 Blender 方面或 Xcode/Swift 方面有什么遗漏吗?

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

推荐答案

如果有人遇到类似的新手问题,可以通过将 .scnassets 文件夹添加到项目构建阶段下的复制捆绑资源"中来解决该问题 -在某些情况下,可能需要在重新构建之前清理项目.这解决了我的问题.

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.

这篇关于xcode9/SceneKit - .dae 文件未加载到 SCNScene - 返回 nil的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆