Hello, People [...]
概括
每当我在我的BorderPane或任何组件/控件/元素上使用阴影效果时,3D 图形性能(如下面的预览部分所示)变得太低了。
“令人困惑”的部分是,当效果应用于与我的选项卡、子场景甚至我的移动按钮无关的东西时,它甚至会降低性能,在某种程度上[...]
我使用jdk-12.0.1。
️ 预览
⚠️ 重现问题
所需文件:
应用程序.java | 主.fxml | AnchorPane.css | MathUtils.java | SimpleFPSCamera.java
通用代码
(您也可以参考重新创建问题部分以获取更多信息)
AnchorPane.css
#BorderPane1 {
-fx-effect: dropshadow(three-pass-box, rgb(26, 26, 26), 50, 0.6, 0, 0); /* Comment it*/
}
应用程序.java
public class App extends Application {
@FXML
public Parent root;
public TabPane TabPane1;
public BorderPane BorderPane1;
public static void main(String[] args) throws Exception {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
FXMLLoader loader = new FXMLLoader(getClass().getResource("main.fxml"));
loader.setController(this);
root = loader.load();
Scene RootScene = new Scene(root, 1120, 540);
primaryStage.setScene(RootScene);
Thread t = new Thread() {
public void run() {
//Setting NewButton2
Button NewButton2 = new Button();
NewButton2.setId("Button2");
NewButton2.setText("test2");
NewButton2.setPrefWidth(150);
NewButton2.setPrefHeight(50);
NewButton2.setTranslateX(-75);
NewButton2.setTranslateY(-25);
NewButton2.setTranslateZ(900);
// Setting group
Group SubRootGroup = new Group(NewButton2);
SubRootGroup.setTranslateX(0);
SubRootGroup.setTranslateY(0);
SubRootGroup.setTranslateZ(0);
// Setting Scene
SubScene SubScene1 = new SubScene(SubRootGroup, 0, 0, true, SceneAntialiasing.BALANCED);
SubScene1.setId("SubScene1");
SubScene1.setFill(Color.WHITE);
SubScene1.heightProperty().bind(RootScene.heightProperty());
SubScene1.widthProperty().bind(RootScene.widthProperty());
// Initializing Camera
SimpleFPSCamera SimpleFPSCam = new SimpleFPSCamera();
// Setting Camera To The Scene
SubScene1.setCamera(SimpleFPSCam.getCamera());
// Adding Scene To Stage-TabPane.Tab(0)
TabPane1.getTabs().add(new Tab("Without Shadows"));
TabPane1.getTabs().get(0).setContent(SubScene1);
// Loading Mouse & Keyboard Events
SimpleFPSCam.loadControlsForSubScene(SubScene1);
}
};
t.setDaemon(true);
t.run();
primaryStage.show();
}
}
到目前为止我尝试过的事情
setCache(true);
setCacheShape(true);
setCacheHint(CacheHint.SPEED);
(我尝试将它与所有组件一起使用但没有任何成功[这也可能是我对 javaFX 的了解很差,[以错误的方式使用它?]])
- ...
奥特罗
任何想法?提前致谢,任何帮助将不胜感激,[...]
George。