So I need a 3D SkyBox.
I tried to scale up the Sphere
, but when the camera is in it, it disappears.
Here's a code where the camera is moving into the Sphere:
package application;
import javafx.animation.TranslateTransition;
import javafx.application.Application;
import javafx.scene.*;
import javafx.scene.layout.AnchorPane;
import javafx.scene.paint.*;
import javafx.scene.shape.Sphere;
import javafx.scene.transform.*;
import javafx.stage.Stage;
import javafx.util.Duration;
public class Main2 extends Application {
public static AnchorPane gui = new AnchorPane();
public static Scene scene = new Scene(gui, 800, 400, true);
public static Group root3D = new Group();
public static SubScene subscene = new SubScene(root3D,800, 400,true,SceneAntialiasing.BALANCED);
public static PerspectiveCamera camera = new PerspectiveCamera(true);
@Override public void start(Stage stage) throws Exception {
PhongMaterial mat = new PhongMaterial();
mat.setDiffuseMap(new Image("SkyBox.png"));
Sphere s = new Sphere(1);
s.setMaterial(mat);
s.setTranslateZ(-15);
root3D.getChildren().add(s);
camera.setFarClip(2000.0);
camera.getTransforms().addAll(new Rotate(0, Rotate.X_AXIS), new Translate(0, 0, -20));
subscene.setCamera(camera);
gui.getChildren().add(subscene);
TranslateTransition move = new TranslateTransition();
move.setNode(camera);
move.setByZ(10);
move.setDuration(Duration.millis(10000));
move.setCycleCount(move.INDEFINITE);
move.setAutoReverse(true);
move.play();
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {launch(args);}
}
Problem: The Sphere will be invisible when the camera is in it.
How can I see the texture of the Sphere
from inside.