简体   繁体   English

JavaFX标记3D轴

[英]JavaFX Label an Axis in 3D

So I have this scene 所以我有这个场景

The Axes are just JavaFX Boxes that I created to represent the axes. Axes只是我为表示轴而创建的JavaFX Box。

How would I label the axes? 我该如何标记轴? I've tried using JavaFX Label and Text objects but they just display in 2D, but I may be using them wrong. 我已经尝试过使用JavaFX Label和Text对象,但它们只是以2D显示,但我可能错误地使用它们。 Is there some way to label (eg put the numbers 1, 2, 3, 4, 5 along the axes) these axes in 3D? 是否有某种方法可以标记这些轴(例如沿轴排列数字1,2,3,4,5)这些轴是否为3D?

We've added a Floating Label example to fxyz3d.org... check out the sample: FloatingLabels.java 我们在fxyz3d.org中添加了一个浮动标签示例...查看示例: FloatingLabels.java

To generically manage 2D labels connected to a Point3D you need to do a transform along the following: 要一般管理连接到Point3D的2D标签,您需要执行以下转换:

        Point3D coordinates = node.localToScene(javafx.geometry.Point3D.ZERO);
        SubScene oldSubScene = NodeHelper.getSubScene(node);
        coordinates = SceneUtils.subSceneToScene(oldSubScene, coordinates);
        double x = coordinates.getX();
        double y = coordinates.getY();
        label.getTransforms().setAll(new Translate(x, y));

There are other details you have to worry about like properly adding to the subscene and clipping but those are included in the example. 您还需要担心其他细节,例如正确添加到子场景和剪辑,但这些细节包含在示例中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM