I have a few problems with this. Essentially, I want to be able to specify a point to a scale and zoom into that point. When the point is constant, it works perfectly. However, when the point changes, the first time I change the scale the camera "jumps". I also have noticed that the coordinate of the camera no longer represents the top left corner, but when I go back to the original scale it does. Is there any way to fix these two issues?
public class CameraTest extends Application {
ParallelCamera camera = new ParallelCamera();
Scale scale = new Scale();
Group world = new Group();
SubScene subScene = new SubScene(world, 480, 720);
Group root = new Group();
Scene scene = new Scene(root);
double orthoScale = 1;
@Override
public void start(Stage stage) throws Exception {
Rectangle floor = new Rectangle(100, 0, 200, 200);
floor.setTranslateZ(300);
floor.setFill(Color.ALICEBLUE);
floor.setRotationAxis(new Point3D(1,0,0));
floor.setRotate(90);
world.getChildren().add(floor);
camera.setTranslateY(100);
camera.setRotationAxis(Rotate.X_AXIS);
camera.setRotate(90);
camera.getTransforms().add(scale);
subScene.setOnScroll(event -> {
orthoScale -= event.getDeltaY() / 70;
scale.setPivotX(event.getX());
scale.setPivotY(event.getY());
scale.setX(orthoScale);
scale.setY(orthoScale);
scale.setZ(orthoScale);
System.out.println(orthoScale);
});
subScene.setCamera(camera);
subScene.setFill(Color.LIGHTGREY);
root.getChildren().add(subScene);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}