Hi!
I have an universe with a few objects. I want to change the appearance of one of them in response to a user event. But what occurs is that the first time I call setAppearance on the object, the appearance changes, but subsequent calls have no effect.
The capability bit Shape3D.ALLOW_APPEARANCE_WRITE is set, but not setting it has the same result. Note that my scenegraph is not compiled.
I there something else to do to be able to change the appearance of a live object?
Here is a snippet of the code I use:
do
{
System.out.println(“red”);
theShape.setAppearance(theRed);
view.renderOnce();
view.renderOnce();
view.renderOnce();
view.renderOnce();
view.renderOnce();
Thread.sleep(1000);
System.out.println("green");
theShape.setAppearance(theGreen);
view.renderOnce();
Thread.sleep(1000);
} while (true);
The idea is that I have created a universe and added a Shape3D (theShape) to it. I also created two appearances, theRed and theGreen. Then I have a loop in which I switch between red and green appearances every second.
The multipe calls to view.renderOnce() are included to demonstrate that it is not the fact that the view has already been rendered that prevents the appearance to change, as in the first iteration of the loop the object indeed turns green. But afterwards it stays green forever, although the console keeps printing “red” and “green”, prooving that the loop is still being executed.
If needed I can file an issue and attache the complete test case.
(I’ll edit my other article)