SceneKit - Threads - What to do on which thread?

前端 未结 2 1377
深忆病人
深忆病人 2020-12-31 05:24

When using SceneKit, the update method:

func renderer(aRenderer: SCNSceneRenderer, updateAtTime time: NSTimeInterval)    

is not called on

2条回答
  •  北海茫月
    2020-12-31 05:36

    The question is about scenekit. Nodes/geometry aren't actually added on the main thread even if that's where you do it. Scenekit does not render on the main thread. Changes are batched to the rendering thread. If rendering is the UI, it's not on the main thread. In fact, if you make changes on the main thread you'll get bad exc because the rendering thread is trying to render the object that got nuked. Which is why removefromparent is inside a SCNTransaction in Apples banana game. So the removal happens on the rendering thread not the main thread. Adding gets batched the same way. It's not actually added on the main thread.

    So just be aware that there's a rendering thread going at the same time. If you do an enumerate with the scene.rootnode on the main thread you'll get crashes from the rendering thread making changes to the rootnode. But since things happen so fast it will probably be pretty rare. In general go check out the banana game, the fox game, and see how they use it.

提交回复
热议问题