对于我的项目,我需要3D场景中的2D文本(而不是叠加!).所以我尝试在场景中添加BorderPane
with Label
/ Text
nodes:
然而问题是,当我用相机放大,缩小或飞行时,面板的白色背景有时与标签重叠(它们显然具有相同的深度).
有没有办法从其面板"提升"标签?我试过设置setDepthTest(true);
没有效果.
这是一个显示问题的简单示例.该Xform
课程来自Oracle的分子样本(http://docs.oracle.com/javase/8/javafx/graphics-tutorial/sampleapp3d-code.htm#CJAGGIFG):
package mypackage;
import mypackage.Xform;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.PerspectiveCamera;
import javafx.scene.Scene;
import javafx.scene.SceneAntialiasing;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class Example extends Application {
private Stage primaryStage;
private final Group root = new Group();
@Override
public void start(Stage primaryStage) throws Exception {
this.primaryStage = primaryStage;
primaryStage.setTitle("Example");
this.primaryStage.setWidth(500);
this.primaryStage.setHeight(500);
Scene scene = new Scene(this.root, 500, 500, true, SceneAntialiasing.BALANCED);
scene.setFill(Color.WHITESMOKE);
Text text …
Run Code Online (Sandbox Code Playgroud) 我在JavaFX中有一个3D场景,需要在3D场景上叠加GUI.我尝试将按钮和文本添加到场景中,但它们总是作为3D对象出现在3d视图中.我环顾四周,还没找到怎么做.唯一的解决方法是创建一个全新的窗口并将设置放在那里,但在这种情况下这不是一个选项.谢谢您的帮助!!