-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRubiksCube3DApp.java
More file actions
54 lines (42 loc) · 1.78 KB
/
RubiksCube3DApp.java
File metadata and controls
54 lines (42 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package Rubix;
import Rubix.Util.InteractionUtil;
import Rubix.Util.LightingUtil;
import Rubix.Util.UIUtil;
import javafx.application.Application;
import javafx.scene.*;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;
public class RubixCube3DApp extends Application {
private Rotate rotateX = new Rotate(30, Rotate.X_AXIS);
private Rotate rotateY = new Rotate(30, Rotate.Y_AXIS);
@Override
public void start(Stage primaryStage) {
RubixCube cube = new RubixCube();
Group cubeGroup = cube.buildCube();
cubeGroup.getTransforms().addAll(rotateX, rotateY);
PerspectiveCamera camera = new PerspectiveCamera(true);
camera.setTranslateZ(-650);
camera.setNearClip(0.1);
camera.setFarClip(1000.0);
Group sceneContent = new Group(cubeGroup);
sceneContent.getChildren().addAll(LightingUtil.createLighting());
SubScene subScene = new SubScene(sceneContent, 800, 680, true, SceneAntialiasing.BALANCED);
subScene.setCamera(camera);
subScene.setFill(Color.LIGHTGRAY);
InteractionUtil.enableRotation(subScene, rotateX, rotateY);
InteractionUtil.enableZoom(subScene, camera);
AnchorPane uiOverlay = UIUtil.createUI(cube, camera, cubeGroup, rotateX, rotateY);
StackPane root = new StackPane();
root.setStyle("-fx-background-color: white;");
root.getChildren().addAll(subScene, uiOverlay);
Scene scene = new Scene(root, 800, 680);
primaryStage.setScene(scene);
primaryStage.setTitle("Rubik's Cube 3D");
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}