本文介绍了为什么我调用Canvas3D.repaint()时Java3D画布会闪烁?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Java3D画布上使用postRender()绘制了2D元素,并希望对其进行动画处理.在循环中,我调用Canvas3D.repaint():
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));
}
对于每个简短的动画,这都会导致整个3D画布闪烁一次或两次.
For every short animation, this causes the whole 3D canvas to flicker once or twice.
推荐答案
我认为我找到了一种解决方案:
I think I found a solution in my case:
代替
canvas3d.repaint();
我调用
canvas3d.getView().repaint();
这样,我可以以高帧频更新动画而不会闪烁.
This way I can update my animation with high framerate without flickering.
这篇关于为什么我调用Canvas3D.repaint()时Java3D画布会闪烁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!