SceneKit Swift - 只是玩dae场景?刚搞白屏?

时间:2018-02-22 19:09:32

标签: swift 3d sprite-kit scenekit arkit

好的,我在Blender中创建了一个动画场景(.dae)并将其导出到Xcode中。我按照教程进行了操作,并在Blender等处制作了相机。

在SceneKit编辑器中,我可以点击底部的播放并播放我的动画,这很棒。我读过你可以设置你的场景视图场景,它应该自动从你的相机中播出。

我的问题是我甚至无法看到我的物体,更不用说我的动画了。我只是有白色屏幕,尽管晚上将背景设置为一种颜色然后设置为图像。我的编辑结构:

enter image description here

相机以前是在电枢中,但我把它移出来看。我检查的场景不是零,这是我将场景添加到场景视图的方式:

@IBOutlet var sceneView: SCNView!
    var scene: SCNScene!
    let str = "Art.scnassets/opening/aircraft.scn"

    //var uiOverlay = Overlay()

    override func viewDidLoad() {
        super.viewDidLoad()

        sceneView.scene = SCNScene(named:"Art.scnassets/openingScene.scn")

        scene = sceneView.scene
        sceneView.isPlaying = true


        setupScene()

在setupScene()中,我尝试这个来获取动画,但它返回nil:

//Get ALL available anims
func extractAnimationsFromSceneSource(sceneName: String) {
    if let sceneURL = Bundle.main.url(forResource: sceneName, withExtension: "dae")
    {
        let source = SCNSceneSource(url: sceneURL, options: nil)

        var anims = [CAAnimation]()
        let animationsIDs = source?.identifiersOfEntries(withClass: CAAnimation.self) as! [String]
        for animationID in animationsIDs {
            if let animation = source?.entryWithIdentifier(animationID, withClass: CAAnimation.self) as? CAAnimation {
                anims.append(animation)
            }
        }
        print("FULL: ", anims)
    }
}

这里有什么问题?我只想在Blender中播放动画,就像在Blender中一样。

0 个答案:

没有答案