layers and slider
This commit is contained in:
		@ -3,12 +3,16 @@ package main.java.com.ThreeDtest.application;
 | 
				
			|||||||
import javafx.animation.Interpolator;
 | 
					import javafx.animation.Interpolator;
 | 
				
			||||||
import javafx.animation.RotateTransition;
 | 
					import javafx.animation.RotateTransition;
 | 
				
			||||||
import javafx.application.Application;
 | 
					import javafx.application.Application;
 | 
				
			||||||
 | 
					import javafx.beans.value.ChangeListener;
 | 
				
			||||||
 | 
					import javafx.beans.value.ObservableValue;
 | 
				
			||||||
import javafx.event.ActionEvent;
 | 
					import javafx.event.ActionEvent;
 | 
				
			||||||
import javafx.fxml.FXML;
 | 
					import javafx.fxml.FXML;
 | 
				
			||||||
import javafx.fxml.FXMLLoader;
 | 
					import javafx.fxml.FXMLLoader;
 | 
				
			||||||
 | 
					import javafx.geometry.Insets;
 | 
				
			||||||
import javafx.geometry.Pos;
 | 
					import javafx.geometry.Pos;
 | 
				
			||||||
import javafx.stage.Stage;
 | 
					import javafx.stage.Stage;
 | 
				
			||||||
import javafx.util.Duration;
 | 
					import javafx.util.Duration;
 | 
				
			||||||
 | 
					import javafx.scene.Group;
 | 
				
			||||||
import javafx.scene.Node;
 | 
					import javafx.scene.Node;
 | 
				
			||||||
import javafx.scene.PointLight;
 | 
					import javafx.scene.PointLight;
 | 
				
			||||||
import javafx.scene.Scene;
 | 
					import javafx.scene.Scene;
 | 
				
			||||||
@ -17,10 +21,12 @@ import javafx.scene.control.Alert;
 | 
				
			|||||||
import javafx.scene.control.Alert.AlertType;
 | 
					import javafx.scene.control.Alert.AlertType;
 | 
				
			||||||
import javafx.scene.control.Button;
 | 
					import javafx.scene.control.Button;
 | 
				
			||||||
import javafx.scene.control.MenuItem;
 | 
					import javafx.scene.control.MenuItem;
 | 
				
			||||||
 | 
					import javafx.scene.control.Slider;
 | 
				
			||||||
import javafx.scene.image.Image;
 | 
					import javafx.scene.image.Image;
 | 
				
			||||||
import javafx.scene.layout.AnchorPane;
 | 
					import javafx.scene.layout.AnchorPane;
 | 
				
			||||||
import javafx.scene.layout.Background;
 | 
					import javafx.scene.layout.Background;
 | 
				
			||||||
import javafx.scene.layout.BackgroundFill;
 | 
					import javafx.scene.layout.BackgroundFill;
 | 
				
			||||||
 | 
					import javafx.scene.layout.BorderPane;
 | 
				
			||||||
import javafx.scene.layout.StackPane;
 | 
					import javafx.scene.layout.StackPane;
 | 
				
			||||||
import javafx.scene.paint.Color;
 | 
					import javafx.scene.paint.Color;
 | 
				
			||||||
import javafx.scene.paint.PhongMaterial;
 | 
					import javafx.scene.paint.PhongMaterial;
 | 
				
			||||||
@ -35,13 +41,21 @@ public class Main extends Application
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			StackPane pane = new StackPane();
 | 
								BorderPane demoPane = new BorderPane(); // Pane for this demo
 | 
				
			||||||
 | 
					 | 
				
			||||||
			primaryStage.setTitle("jFx3Dtest");
 | 
								primaryStage.setTitle("jFx3Dtest");
 | 
				
			||||||
			Scene scene = new Scene(pane, 600, 600, true,
 | 
								Scene scene = new Scene(demoPane, 600, 600, true,
 | 
				
			||||||
					SceneAntialiasing.BALANCED);
 | 
										SceneAntialiasing.BALANCED);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			Box myBox = new Box(300, 300, 300);
 | 
								StackPane previewPane = new StackPane(); // Stackpane in
 | 
				
			||||||
 | 
																						// textur3dPreview
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								previewPane.setMaxWidth(300);
 | 
				
			||||||
 | 
								previewPane.setMaxHeight(300);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								previewPane.setStyle(
 | 
				
			||||||
 | 
										"-fx-background-color: #383838;-fx-border-color: red;");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								Box myBox = new Box(100, 100, 100);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			final String DIFFUSE_MAP = "https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/D%C3%BClmen%2C_Kreuzkapelle_--_2014_--_2731.jpg/640px-D%C3%BClmen%2C_Kreuzkapelle_--_2014_--_2731.jpg";
 | 
								final String DIFFUSE_MAP = "https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/D%C3%BClmen%2C_Kreuzkapelle_--_2014_--_2731.jpg/640px-D%C3%BClmen%2C_Kreuzkapelle_--_2014_--_2731.jpg";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -71,9 +85,9 @@ public class Main extends Application
 | 
				
			|||||||
			pointLightSky.setTranslateZ(0);
 | 
								pointLightSky.setTranslateZ(0);
 | 
				
			||||||
			pointLightSky.setRotate(90);
 | 
								pointLightSky.setRotate(90);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			pane.getChildren().add(pointLightFront);
 | 
								previewPane.getChildren().add(pointLightFront);
 | 
				
			||||||
			pane.getChildren().add(pointLightSky);
 | 
								previewPane.getChildren().add(pointLightSky);
 | 
				
			||||||
			pane.getChildren().add(pointLightGround);
 | 
								previewPane.getChildren().add(pointLightGround);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			StackPane.setAlignment(pointLightFront, Pos.CENTER);
 | 
								StackPane.setAlignment(pointLightFront, Pos.CENTER);
 | 
				
			||||||
			StackPane.setAlignment(pointLightSky, Pos.CENTER);
 | 
								StackPane.setAlignment(pointLightSky, Pos.CENTER);
 | 
				
			||||||
@ -91,11 +105,46 @@ public class Main extends Application
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			rotateAroundYAxis(myBox).play();
 | 
								rotateAroundYAxis(myBox).play();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			pane.getChildren().add(myBox);
 | 
								previewPane.getChildren().add(myBox);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// demoPane.setCenter(previewPane);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								Slider resSlider = new Slider();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								resSlider.setMin(0);
 | 
				
			||||||
 | 
								resSlider.setMax(400);
 | 
				
			||||||
 | 
								resSlider.setValue(200);
 | 
				
			||||||
 | 
								resSlider.setBlockIncrement(10);
 | 
				
			||||||
 | 
								resSlider.setShowTickLabels(true);
 | 
				
			||||||
 | 
								resSlider.setShowTickMarks(true);
 | 
				
			||||||
 | 
								resSlider.setMajorTickUnit(50);
 | 
				
			||||||
 | 
								resSlider.setMinorTickCount(5);
 | 
				
			||||||
 | 
								resSlider.setBlockIncrement(10);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// Adding Listener to value property.
 | 
				
			||||||
 | 
								resSlider.valueProperty().addListener(new ChangeListener<Number>() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									@Override
 | 
				
			||||||
 | 
									public void changed(ObservableValue<? extends Number> observable, //
 | 
				
			||||||
 | 
											Number oldValue, Number newValue)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										System.out.println("New value: " + newValue);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								BorderPane.setAlignment(resSlider, Pos.TOP_LEFT);
 | 
				
			||||||
 | 
								BorderPane.setMargin(resSlider, new Insets(12, 12, 12, 12));
 | 
				
			||||||
 | 
								demoPane.setBottom(resSlider);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								StackPane.setAlignment(previewPane, Pos.CENTER);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			primaryStage.setScene(scene);
 | 
								primaryStage.setScene(scene);
 | 
				
			||||||
			primaryStage.show();
 | 
								primaryStage.show();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								System.out.println(previewPane.getHeight());
 | 
				
			||||||
 | 
								System.out.println(previewPane.getWidth());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		} catch (Exception e) {
 | 
							} catch (Exception e) {
 | 
				
			||||||
			e.printStackTrace();
 | 
								e.printStackTrace();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,2 +1,3 @@
 | 
				
			|||||||
 | 
					main/java/com/ThreeDtest/application/Main$1.class
 | 
				
			||||||
main/java/com/ThreeDtest/application/Main.class
 | 
					main/java/com/ThreeDtest/application/Main.class
 | 
				
			||||||
main/java/com/ThreeDtest/application/JavaFX11Main.class
 | 
					main/java/com/ThreeDtest/application/JavaFX11Main.class
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user