Adding Models to Canvas at run-time

Hi all,



I am writing a standalone swing application having jME Display Canvas to display geometries.

I was wishing to add/remove models to Canvas at run time, once the application is started.

Any pointers would be highly appreciated.



I am not sure if attaching/Detaching children from rootNode (SimpleApplication class) at run-time and updating the canvas a solution?

Its perfectly fine adding and removing objects, but you don’t have to “update” the canvas, since the update happens in the OpenGl thred. Go through the tutorials to learn more about the jME3 update loop (and jME3 in general).

You have to think about the fact that all Swing button presses are called from the AWT thread and that you can attach objects only on the OpenGL thread, so do it via the queue:

[snippet id=“10”]