问题
I have 2D elements I draw with postRender() on a Java3D canvas and want to animate these elements. In a loop I call Canvas3D.repaint():
while(animationIsRunning){
// I update positions of 2D elements here...
// ...
canvas3D.repaint();
Thread.sleep((long)(1.0/30.0 * 1000));
}
For every short animation, this causes the whole 3D canvas to flicker once or twice.
回答1:
I think I found a solution in my case:
Instead of
canvas3d.repaint();
I invoke
canvas3d.getView().repaint();
This way I can update my animation with high framerate without flickering.
来源:https://stackoverflow.com/questions/29038302/why-does-the-java3d-canvas-flicker-when-i-call-canvas3d-repaint