swe_primus/learn/java/javafx/Hello3d/Hello3d.java @ efda9938
| 29192059 | torutk | import javafx.application.Application;
|
||
import javafx.scene.Group;
|
||||
import javafx.scene.PerspectiveCamera;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.PhongMaterial;
|
||||
import javafx.scene.shape.Sphere;
|
||||
import javafx.scene.transform.Rotate;
|
||||
import javafx.scene.transform.Translate;
|
||||
import javafx.stage.Stage;
|
||||
public class Hello3d extends Application {
|
||||
@Override
|
||||
public void start(final Stage stage) {
|
||||
final Group root = new Group();
|
||||
// 球体の定義
|
||||
final Sphere earth = new Sphere(100);
|
||||
root.getChildren().add(earth);
|
||||
| a87c4319 | torutk | // 材質の定義
|
||
final PhongMaterial material = new PhongMaterial();
|
||||
material.setDiffuseColor(Color.DODGERBLUE);
|
||||
| efda9938 | torutk | material.setSpecularColor(Color.DEEPSKYBLUE);
|
||
| a87c4319 | torutk | earth.setMaterial(material);
|
||
| 29192059 | torutk | // カメラの定義
|
||
final PerspectiveCamera camera = new PerspectiveCamera(true);
|
||||
camera.setFieldOfView(45.0);
|
||||
camera.getTransforms().addAll(
|
||||
| a87c4319 | torutk | new Translate(0, 0, -190)
|
||
| 29192059 | torutk | );
|
||
final Scene scene = new Scene(root, 800, 600, Color.BLACK);
|
||||
scene.setCamera(camera);
|
||||
stage.setScene(scene);
|
||||
stage.setTitle("Hello JavaFX 3D World");
|
||||
stage.show();
|
||||
}
|
||||
public static void main(final String... args) {
|
||||
launch(args);
|
||||
}
|
||||
| 3cf7d266 | torutk | }
|