How to draw dynamic line or curve per frame in SceneKit

I have a Metal-enabled SceneKit project in which I would like to draw a curve that has been changed on the cpu in every frame. It seems like it should be a simple task; the one I've done in OpenGL many times.

Something like:

array_of_points[0].x = 25
array_of_points[0].y = 35
upload_array_to_gpu()
render_frame()

      

It seems that changing the SCNGeometrySource SCNNode is not possible. Playing and setting node.geometry works, but position lags / jitters compared to other nodes in the scene. Playing the entire node of each frame also lags behind.

One possible possibility might be a geometry shader modifier, but I still have to navigate to my calculated curve positions somehow.

Another option is to use metal APIs directly. Although this approach seems to require a lot more code, and I couldn't find too much information on mixing SceneKit with Metal.

I also tried setting the preferred RenderingAPI in OpenGL, but it doesn't change the renderAPI.

+3


source to share





All Articles