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
|
||||
primaryStage.setTitle("jFx3Dtest");
|
||||
|
||||
Scene scene = new Scene(demoPane, 600, 600, true,
|
||||
SceneAntialiasing.BALANCED);
|
||||
|
||||
// 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
|
||||
demoPane.setCenter(preview.getPreviewPane());
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package main.java.com.ThreeDtest.application;
|
||||
|
||||
import java.awt.Point;
|
||||
|
||||
|
||||
import javafx.animation.Interpolator;
|
||||
import javafx.animation.RotateTransition;
|
||||
import javafx.geometry.Point3D;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.AmbientLight;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.PointLight;
|
||||
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.paint.Color;
|
||||
|
@ -49,7 +49,7 @@ public class Texture3DPreview
|
|||
textureMaterial.setSpecularColor(Color.RED);
|
||||
myBox.setMaterial(textureMaterial);
|
||||
|
||||
// light(); // switch on light
|
||||
light(); // switch on light
|
||||
|
||||
rotateAroundYAxis(myBox).play();
|
||||
previewPane.getChildren().addAll(myBox);
|
||||
|
@ -111,30 +111,15 @@ public class Texture3DPreview
|
|||
private void light()
|
||||
{
|
||||
PointLight pointLightFront = new PointLight(Color.WHITE);
|
||||
pointLightFront.setTranslateX(100);
|
||||
pointLightFront.setTranslateY(100);
|
||||
pointLightFront.setTranslateZ(-300);
|
||||
pointLightFront.setTranslateX(calcBoxSize());
|
||||
pointLightFront.setTranslateY(calcBoxSize());
|
||||
pointLightFront.setTranslateZ((-2) * calcBoxSize());
|
||||
pointLightFront.setRotate(90);
|
||||
|
||||
PointLight pointLightSky = new PointLight(Color.WHITE);
|
||||
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);
|
||||
|
||||
|
||||
AmbientLight ambient = new AmbientLight(Color.ANTIQUEWHITE);
|
||||
|
||||
previewPane.getChildren().addAll(pointLightFront);
|
||||
previewPane.getChildren().addAll(pointLightSky);
|
||||
previewPane.getChildren().addAll(pointLightGround);
|
||||
|
||||
StackPane.setAlignment(pointLightFront, Pos.CENTER);
|
||||
StackPane.setAlignment(pointLightSky, Pos.CENTER);
|
||||
StackPane.setAlignment(pointLightGround, Pos.CENTER);
|
||||
previewPane.getChildren().addAll(ambient);
|
||||
}
|
||||
|
||||
private void createPreview()
|
||||
|
@ -163,4 +148,4 @@ public class Texture3DPreview
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue