Answer the question
In order to leave comments, you need to log in
How is a smoothly moving camera implemented in 3D space?
Hello! Happy Friday everyone!
The question arose - how to implement a smoothly moving camera in 3D space, which would be controlled by the navigation keys?
Until recently, I used this code and was satisfied.
scene.setOnKeyReleased(e -> codes.clear()); // очищаем коллекцию, когда отпускаем кнопку
scene.setOnKeyPressed(e -> {
if(acceptedKey.contains(e.getCode()))
{
codes.add(e.getCode());
if(codes.contains(KeyCode.UP))
{
ourcamera.setTranslateZ(ourcamera.getTranslateZ()+1);
}
if(codes.contains(KeyCode.DOWN))
{
ourcamera.setTranslateZ(ourcamera.getTranslateZ()-1);
}
if(codes.contains(KeyCode.RIGHT))
{
ourcamera.setTranslateX(ourcamera.getTranslateX()+1);
}
if(codes.contains(KeyCode.LEFT))
{
ourcamera.setTranslateX(ourcamera.getTranslateX()-1);
}
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question