Why does the Java3D canvas flicker when I call Canvas3D.repaint()

大兔子大兔子 提交于 2019-12-24 14:22:54

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!