我一直在 JavaFX 中玩 3D。
我在我的演示应用程序中添加了SubScene一些Box,但它们的边缘Box很脏。如何在不在SceneAntialiasing.BALANCED构造函数中使用的情况下平滑它们?我已经看到有可能添加antiAliasing=""到 FXML 文件中,但是我不知道应该将什么作为参数。WordBALANCED不工作。
Controller.java
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.fxml.FXML;
import javafx.scene.*;
import javafx.scene.layout.AnchorPane;
import javafx.scene.paint.Color;
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.Box;
import javafx.scene.transform.Rotate;
import javafx.scene.transform.Translate;
import javafx.util.Duration;
public class Controller{
@FXML
private SubScene subscene;
@FXML
private AnchorPane pane;
private Box box= new Box();
private PerspectiveCamera camera = new PerspectiveCamera(true);
private Group group = new Group();
final Rotate rx = new Rotate(0, Rotate.X_AXIS);
final Rotate ry = new Rotate(0, Rotate.Y_AXIS);
final Rotate rz = new Rotate(0, Rotate.Z_AXIS);
private Timeline animation;
@FXML
void initialize() {
box.setMaterial(new PhongMaterial(Color.ORANGE));
box.setDepth(10);
box.setWidth(10);
box.setHeight(10);
rx.setAngle(90);
ry.setAngle(25);
box.getTransforms().addAll(rz, ry, rx);
group.getChildren().add(box);
animation = new Timeline();
animation.getKeyFrames().addAll(
new KeyFrame(Duration.ZERO,
new KeyValue(box.depthProperty(), 0d),
new KeyValue(box.translateYProperty(),400d)),
new KeyFrame(Duration.seconds(5),
new KeyValue(box.depthProperty(), 800d),
new KeyValue(box.translateYProperty(), 0d)));
animation.setCycleCount(Timeline.INDEFINITE);
camera.getTransforms().add(new Translate(0, 0, -80));
camera.getTransforms().addAll (
new Rotate(-35, Rotate.X_AXIS),
new Translate(0, 0, 10)
}
}
还有其他方法可以实现吗?
冉冉说
相关分类