How to replace all childs of rootnode

Hi,

during testing I hit an exception occasionally

 Uncaught exception thrown in Thread[jME3 Main,6,main]
 IllegalStateException: Scene graph is not properly updated for rendering.
 State was changed after rootNode.updateGeometricState() call.
 Make sure you do not modify the scene from another thread!
 Problem spatial name: Root Node

The usecase for that situation is - user loaded a different file. So I have to wipe out old primitives and generate a new model.

For cleanup I use a function like this:

   public void reset() {
      rootNode.detachAllChildren();
      createOrigin();
   }

… and after that I process the new file to generate the new primitives.

What did I wrong?

You are doing this in another thread. All scene modifications should be done inside the render thread. So if you must modify the scene outside… you can call Application.enqueue() to delegate it to the render thread.

1 Like

Ah, I see. Just like awt/swing.
Thank you.

Tried that with update(), where I tried to change the color of a primitive, but screen does not change anything.
Do I have to call a refresh or something like that, to get the changes to screen?

Code looks fine from here. (AKA: we can’t debug code we can’t see… but no, you don’t have to reset anything. So probably your code isn’t really changing anything… but we can’t see it. So that’s just a guess.)

LOL - you’re right!

I found it by myself. Forgot to set the lost focus behaviour. Had to click on the canvas to see any change and then I remembered the lostfocus setting from sample code …