2024-04-01
This commit is contained in:
30
three_d/build.gradle.kts
Normal file
30
three_d/build.gradle.kts
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
plugins {
|
||||
id("elex-application")
|
||||
idea
|
||||
id("org.openjfx.javafxplugin") version "0.1.0"
|
||||
id("org.beryx.jlink") version "3.0.1"
|
||||
}
|
||||
application {
|
||||
mainClass.set("kr.pe.elex.examples.three_d.MyApplication")
|
||||
// mainModule.set("kr.pe.elex.examples.components")
|
||||
}
|
||||
javafx {
|
||||
version = "23-ea+3"
|
||||
modules = listOf("javafx.controls", "javafx.fxml")
|
||||
}
|
||||
jlink {
|
||||
launcher {
|
||||
name = project.name
|
||||
}
|
||||
}
|
||||
idea{
|
||||
module {
|
||||
isDownloadJavadoc=true
|
||||
isDownloadSources=true
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2024. Elex. All Rights Reesrved.
|
||||
* https://www.elex-project.com/
|
||||
*/
|
||||
|
||||
package kr.pe.elex.examples.three_d;
|
||||
|
||||
import javafx.scene.Camera;
|
||||
import javafx.scene.PerspectiveCamera;
|
||||
|
||||
public class Cameras {
|
||||
|
||||
public static Camera camera(){
|
||||
final Camera camera = new PerspectiveCamera();
|
||||
|
||||
return camera;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2024. Elex. All Rights Reesrved.
|
||||
* https://www.elex-project.com/
|
||||
*/
|
||||
|
||||
package kr.pe.elex.examples.three_d;
|
||||
|
||||
import javafx.scene.AmbientLight;
|
||||
import javafx.scene.PointLight;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
public class Lights {
|
||||
public static PointLight pointLight() {
|
||||
final PointLight light = new PointLight();
|
||||
light.setColor(Color.YELLOW);
|
||||
return light;
|
||||
}
|
||||
|
||||
public static AmbientLight ambientLight() {
|
||||
final AmbientLight light = new AmbientLight();
|
||||
light.setColor(Color.GOLD);
|
||||
return light;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2024. Elex. All Rights Reesrved.
|
||||
* https://www.elex-project.com/
|
||||
*/
|
||||
|
||||
package kr.pe.elex.examples.three_d;
|
||||
|
||||
public class Materials {
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2024. Elex. All Rights Reesrved.
|
||||
* https://www.elex-project.com/
|
||||
*/
|
||||
|
||||
package kr.pe.elex.examples.three_d;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.scene.*;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.PhongMaterial;
|
||||
import javafx.scene.shape.Box;
|
||||
import javafx.scene.shape.DrawMode;
|
||||
import javafx.scene.transform.Rotate;
|
||||
import javafx.scene.transform.Translate;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public class MyApplication extends Application {
|
||||
private Parent content(){
|
||||
Box box = new Box(5,5,5);
|
||||
box.setMaterial(new PhongMaterial(Color.RED));
|
||||
box.setDrawMode(DrawMode.LINE);
|
||||
|
||||
Camera camera = new PerspectiveCamera(true);
|
||||
camera.getTransforms().addAll(
|
||||
new Rotate(-20, Rotate.Y_AXIS),
|
||||
new Rotate(-20,Rotate.X_AXIS),
|
||||
new Translate(0,0,-15)
|
||||
);
|
||||
|
||||
Group root = new Group();
|
||||
root.getChildren().add(box);
|
||||
root.getChildren().add(camera);
|
||||
|
||||
SubScene subScene = new SubScene(root, 300, 300);
|
||||
subScene.setFill(Color.ALICEBLUE);
|
||||
subScene.setCamera(camera);
|
||||
Group group = new Group();
|
||||
group.getChildren().add(subScene);
|
||||
return group;
|
||||
}
|
||||
public static void main(String... args){
|
||||
launch(args);
|
||||
}
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
primaryStage.setTitle("3D Example");
|
||||
primaryStage.setResizable(false);
|
||||
primaryStage.setScene(new Scene(content()));
|
||||
primaryStage.show();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2024. Elex. All Rights Reesrved.
|
||||
* https://www.elex-project.com/
|
||||
*/
|
||||
|
||||
package kr.pe.elex.examples.three_d;
|
||||
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.PhongMaterial;
|
||||
import javafx.scene.shape.Box;
|
||||
import javafx.scene.shape.Cylinder;
|
||||
import javafx.scene.shape.Sphere;
|
||||
import javafx.scene.shape.TriangleMesh;
|
||||
|
||||
public class Shapes {
|
||||
public static Box box(){
|
||||
final Box shape = new Box(100, 100, 30);
|
||||
final PhongMaterial material = new PhongMaterial();
|
||||
material.setSpecularColor(Color.ORANGE);
|
||||
material.setDiffuseColor(Color.RED);
|
||||
shape.setMaterial(material);
|
||||
return shape;
|
||||
}
|
||||
public static Cylinder cylinder(){
|
||||
final Cylinder shape = new Cylinder(100, 100);
|
||||
final PhongMaterial material = new PhongMaterial();
|
||||
material.setSpecularColor(Color.BLUE);
|
||||
material.setDiffuseColor(Color.LIGHTBLUE);
|
||||
shape.setMaterial(material);
|
||||
return shape;
|
||||
}
|
||||
public static Sphere sphere(){
|
||||
final Sphere shape = new Sphere(100);
|
||||
final PhongMaterial material = new PhongMaterial();
|
||||
material.setSpecularColor(Color.BLUE);
|
||||
material.setDiffuseColor(Color.LIGHTBLUE);
|
||||
shape.setMaterial(material);
|
||||
return shape;
|
||||
}
|
||||
|
||||
public static TriangleMesh triangleMesh(){
|
||||
final TriangleMesh shape = new TriangleMesh();
|
||||
final float[] points = {};
|
||||
shape.getPoints().addAll(points);
|
||||
final float[] texCoords = {};
|
||||
shape.getTexCoords().addAll(texCoords);
|
||||
final int[] faces = {};
|
||||
shape.getFaces().addAll(faces);
|
||||
final int[] smoothingGroups = {};
|
||||
shape.getFaceSmoothingGroups().addAll(smoothingGroups);
|
||||
|
||||
return shape;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2024. Elex. All Rights Reesrved.
|
||||
* https://www.elex-project.com/
|
||||
*/
|
||||
|
||||
package kr.pe.elex.examples.three_d;
|
||||
7
three_d/src/main/java/module-info.java
Normal file
7
three_d/src/main/java/module-info.java
Normal file
@@ -0,0 +1,7 @@
|
||||
module javafx.examples.fxml.main {
|
||||
requires javafx.graphics;
|
||||
requires javafx.controls;
|
||||
requires javafx.fxml;
|
||||
|
||||
exports kr.pe.elex.examples.three_d;
|
||||
}
|
||||
Reference in New Issue
Block a user