JavaFX 3D 文本旋转
JavaFX 3D text rotation
我是 javaFX-3D 的新手,我想查看带有标签的简单 3D 形状,例如节点号等。我从 oracle 的 MoleculeSampleApp 开始,我正在尝试添加文本。到目前为止,我已经达到了这个:
Axes with text
已添加文字如下:
Text t = new Text("Hello world");
t.setFont(Font.font("Calibri", FontWeight.BOLD, 30));
t.translateXProperty().set(125 + 10);
t.translateYProperty().set(125 + 10);
t.translateZProperty().set(125+10);
Xform from = new Xform();
from.getChildren().add(t);
from.setRotateX(180);
world.getChildren().add(from);
当我开始旋转视图时,文本也会翻转过来,变得无法阅读。有没有办法让文字不向各个方向旋转?理想情况下,文本应始终像正常的“2D”文本一样显示,同时随着视图调整(缩放、旋转等)与其关联的 3D 对象一起移动。
一段时间后,我决定改用工具提示。这不完全是我的想法,但当鼠标悬停在形状上时它会正确显示文本。举例如下:
Sphere ball= new Sphere(30/2);
Tooltip t = new Tooltip(tooltip);
Tooltip.install(ball, t);
我是 javaFX-3D 的新手,我想查看带有标签的简单 3D 形状,例如节点号等。我从 oracle 的 MoleculeSampleApp 开始,我正在尝试添加文本。到目前为止,我已经达到了这个:
Axes with text
已添加文字如下:
Text t = new Text("Hello world");
t.setFont(Font.font("Calibri", FontWeight.BOLD, 30));
t.translateXProperty().set(125 + 10);
t.translateYProperty().set(125 + 10);
t.translateZProperty().set(125+10);
Xform from = new Xform();
from.getChildren().add(t);
from.setRotateX(180);
world.getChildren().add(from);
当我开始旋转视图时,文本也会翻转过来,变得无法阅读。有没有办法让文字不向各个方向旋转?理想情况下,文本应始终像正常的“2D”文本一样显示,同时随着视图调整(缩放、旋转等)与其关联的 3D 对象一起移动。
一段时间后,我决定改用工具提示。这不完全是我的想法,但当鼠标悬停在形状上时它会正确显示文本。举例如下:
Sphere ball= new Sphere(30/2);
Tooltip t = new Tooltip(tooltip);
Tooltip.install(ball, t);