cleanup No. 2
This commit is contained in:
parent
f2720a559e
commit
2848189fa4
|
@ -17,17 +17,18 @@ public class Main extends Application
|
||||||
|
|
||||||
BorderPane demoPane = new BorderPane(); // Pane for this demo
|
BorderPane demoPane = new BorderPane(); // Pane for this demo
|
||||||
primaryStage.setTitle("jFx3Dtest");
|
primaryStage.setTitle("jFx3Dtest");
|
||||||
|
|
||||||
Scene scene = new Scene(demoPane, 600, 600, true,
|
Scene scene = new Scene(demoPane, 600, 600, true,
|
||||||
SceneAntialiasing.BALANCED);
|
SceneAntialiasing.BALANCED);
|
||||||
|
|
||||||
// Create new Preview
|
// Create new Preview
|
||||||
Texture3DPreview preview = new Texture3DPreview(400, 550);
|
Texture3DPreview preview = new Texture3DPreview(300, 300);
|
||||||
|
|
||||||
//final String DIFFUSE_MAP = "https://bit.ly/2FTajSP";
|
final String DIFFUSE_MAP = "https://bit.ly/2FTajSP";
|
||||||
|
|
||||||
//Image texture = new Image(DIFFUSE_MAP);
|
Image texture = new Image(DIFFUSE_MAP);
|
||||||
|
|
||||||
//preview.setTexture(texture);
|
preview.setTexture(texture);
|
||||||
|
|
||||||
// Get the generated 3D preview as StackPane
|
// Get the generated 3D preview as StackPane
|
||||||
demoPane.setCenter(preview.getPreviewPane());
|
demoPane.setCenter(preview.getPreviewPane());
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package main.java.com.ThreeDtest.application;
|
package main.java.com.ThreeDtest.application;
|
||||||
|
|
||||||
import java.awt.Point;
|
|
||||||
|
|
||||||
import javafx.animation.Interpolator;
|
import javafx.animation.Interpolator;
|
||||||
import javafx.animation.RotateTransition;
|
import javafx.animation.RotateTransition;
|
||||||
import javafx.geometry.Point3D;
|
import javafx.scene.AmbientLight;
|
||||||
import javafx.geometry.Pos;
|
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.PointLight;
|
import javafx.scene.PointLight;
|
||||||
|
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
|
@ -49,7 +49,7 @@ public class Texture3DPreview
|
||||||
textureMaterial.setSpecularColor(Color.RED);
|
textureMaterial.setSpecularColor(Color.RED);
|
||||||
myBox.setMaterial(textureMaterial);
|
myBox.setMaterial(textureMaterial);
|
||||||
|
|
||||||
// light(); // switch on light
|
light(); // switch on light
|
||||||
|
|
||||||
rotateAroundYAxis(myBox).play();
|
rotateAroundYAxis(myBox).play();
|
||||||
previewPane.getChildren().addAll(myBox);
|
previewPane.getChildren().addAll(myBox);
|
||||||
|
@ -111,30 +111,15 @@ public class Texture3DPreview
|
||||||
private void light()
|
private void light()
|
||||||
{
|
{
|
||||||
PointLight pointLightFront = new PointLight(Color.WHITE);
|
PointLight pointLightFront = new PointLight(Color.WHITE);
|
||||||
pointLightFront.setTranslateX(100);
|
pointLightFront.setTranslateX(calcBoxSize());
|
||||||
pointLightFront.setTranslateY(100);
|
pointLightFront.setTranslateY(calcBoxSize());
|
||||||
pointLightFront.setTranslateZ(-300);
|
pointLightFront.setTranslateZ((-2) * calcBoxSize());
|
||||||
pointLightFront.setRotate(90);
|
pointLightFront.setRotate(90);
|
||||||
|
|
||||||
PointLight pointLightSky = new PointLight(Color.WHITE);
|
AmbientLight ambient = new AmbientLight(Color.ANTIQUEWHITE);
|
||||||
pointLightSky.setTranslateX(0);
|
|
||||||
pointLightSky.setTranslateY(-600);
|
|
||||||
pointLightSky.setTranslateZ(0);
|
|
||||||
pointLightSky.setRotate(90);
|
|
||||||
|
|
||||||
PointLight pointLightGround = new PointLight(Color.WHITE);
|
|
||||||
pointLightSky.setTranslateX(0);
|
|
||||||
pointLightSky.setTranslateY(600);
|
|
||||||
pointLightSky.setTranslateZ(0);
|
|
||||||
pointLightSky.setRotate(90);
|
|
||||||
|
|
||||||
previewPane.getChildren().addAll(pointLightFront);
|
previewPane.getChildren().addAll(pointLightFront);
|
||||||
previewPane.getChildren().addAll(pointLightSky);
|
previewPane.getChildren().addAll(ambient);
|
||||||
previewPane.getChildren().addAll(pointLightGround);
|
|
||||||
|
|
||||||
StackPane.setAlignment(pointLightFront, Pos.CENTER);
|
|
||||||
StackPane.setAlignment(pointLightSky, Pos.CENTER);
|
|
||||||
StackPane.setAlignment(pointLightGround, Pos.CENTER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createPreview()
|
private void createPreview()
|
||||||
|
@ -163,4 +148,4 @@ public class Texture3DPreview
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue