Loading src/main/java/org/example/newmat/GraphicsAndWindowsTest.java +33 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,8 @@ import Shape.ObstacleField; import javafx.animation.AnimationTimer; import javafx.application.Application; import javafx.beans.property.DoubleProperty; import javafx.beans.property.SimpleDoubleProperty; import javafx.geometry.Bounds; import javafx.geometry.Point3D; import javafx.geometry.Pos; Loading Loading @@ -38,6 +40,11 @@ import static java.lang.Math.abs; * it includes a real-time FPS counter overlaid on the scene to monitor performance. */ public class GraphicsAndWindowsTest extends Application { private double anchorX, anchorY; private double anchorAngleX = 0; private double anchorAngleY = 0; private final DoubleProperty angleX = new SimpleDoubleProperty(0); private final DoubleProperty angleY = new SimpleDoubleProperty(0); //public static String[] parameters; public static MovingObject[] objects; /** Loading Loading @@ -133,6 +140,8 @@ public class GraphicsAndWindowsTest extends Application { subScene3D.setFill(Color.SILVER); subScene3D.setCamera(camera); initMouseControl(group3D, subScene3D); /* * Text label to display FPS Loading Loading @@ -316,6 +325,30 @@ public class GraphicsAndWindowsTest extends Application { }; timer.start(); } private void initMouseControl(Group group, SubScene scene){ Rotate xRotate; Rotate yRotate; group.getTransforms().addAll( xRotate = new Rotate(0, Rotate.X_AXIS), yRotate = new Rotate(0, Rotate.Y_AXIS) ); xRotate.angleProperty().bind(angleX); yRotate.angleProperty().bind(angleY); scene.setOnMouseClicked(mouseEvent -> { anchorX = mouseEvent.getSceneX(); anchorY = mouseEvent.getSceneY(); anchorAngleX = angleX.get(); anchorAngleY = angleY.get(); }); scene.setOnMouseDragged(mouseEvent -> { angleX.set(anchorAngleX - (anchorY - mouseEvent.getSceneY())); angleY.set(anchorAngleY - (anchorX - mouseEvent.getSceneX())); }); } /** * The entry point of the application. This method is called when the application starts. * Loading Loading
src/main/java/org/example/newmat/GraphicsAndWindowsTest.java +33 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,8 @@ import Shape.ObstacleField; import javafx.animation.AnimationTimer; import javafx.application.Application; import javafx.beans.property.DoubleProperty; import javafx.beans.property.SimpleDoubleProperty; import javafx.geometry.Bounds; import javafx.geometry.Point3D; import javafx.geometry.Pos; Loading Loading @@ -38,6 +40,11 @@ import static java.lang.Math.abs; * it includes a real-time FPS counter overlaid on the scene to monitor performance. */ public class GraphicsAndWindowsTest extends Application { private double anchorX, anchorY; private double anchorAngleX = 0; private double anchorAngleY = 0; private final DoubleProperty angleX = new SimpleDoubleProperty(0); private final DoubleProperty angleY = new SimpleDoubleProperty(0); //public static String[] parameters; public static MovingObject[] objects; /** Loading Loading @@ -133,6 +140,8 @@ public class GraphicsAndWindowsTest extends Application { subScene3D.setFill(Color.SILVER); subScene3D.setCamera(camera); initMouseControl(group3D, subScene3D); /* * Text label to display FPS Loading Loading @@ -316,6 +325,30 @@ public class GraphicsAndWindowsTest extends Application { }; timer.start(); } private void initMouseControl(Group group, SubScene scene){ Rotate xRotate; Rotate yRotate; group.getTransforms().addAll( xRotate = new Rotate(0, Rotate.X_AXIS), yRotate = new Rotate(0, Rotate.Y_AXIS) ); xRotate.angleProperty().bind(angleX); yRotate.angleProperty().bind(angleY); scene.setOnMouseClicked(mouseEvent -> { anchorX = mouseEvent.getSceneX(); anchorY = mouseEvent.getSceneY(); anchorAngleX = angleX.get(); anchorAngleY = angleY.get(); }); scene.setOnMouseDragged(mouseEvent -> { angleX.set(anchorAngleX - (anchorY - mouseEvent.getSceneY())); angleY.set(anchorAngleY - (anchorX - mouseEvent.getSceneX())); }); } /** * The entry point of the application. This method is called when the application starts. * Loading