如何在JavaFX中将GUI叠加在3D场景上? [英] How to overlay GUI over 3D scene in JavaFX?

查看:169
本文介绍了如何在JavaFX中将GUI叠加在3D场景上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JavaFX中有一个3D场景,需要在3D场景上叠加GUI。我尝试将按钮和文本添加到场景中,但它们总是作为3D对象出现在3d视图中。我环顾四周,还没找到怎么做。唯一的解决方法是创建一个全新的窗口并将设置放在那里但在这种情况下不是一个选项。感谢您的帮助!!

I have a 3D scene in JavaFX and need to overlay GUI over the 3D scene. I have tried adding buttons and text to the scene but they always appear in the 3d view as 3D objects. I have looked around and haven't found how to do it. The only workaround would be creating a whole new window and putting the settings there but that isn't an option in this case. Thanks for the help!!

像这样的东西

或者这个

Something like this Or this

推荐答案

您正在寻找的最佳解决方案是 SubScene ,内置JavaFX 容器

The best solution for what you are looking for is the SubScene, a built-in JavaFX container:


SubScene类是场景图中内容的容器。 SubScene提供场景的不同部分的分离,每个部分都可以使用不同的摄像机,深度缓冲区或场景抗锯齿进行渲染。 SubScene嵌入到主场景或另一个子场景中。

The SubScene class is the container for content in a scene graph. SubScene provides separation of different parts of a scene, each of which can be rendered with a different camera, depth buffer, or scene anti-aliasing. A SubScene is embedded into the main scene or another sub-scene.

如果你看一下 3DViewer 项目,你会发现它就像您发布的图片:

If you have a look at the 3DViewer project, you'll find it is like the pictures you have posted:

< img src =https://i.stack.imgur.com/bzCYX.pngalt =3DViewer>

你可以找一个小的有关如何在此提问中将subScene添加到常规场景的示例

You can find a small sample of how to add a subScene to a regular scene in this question.

这篇关于如何在JavaFX中将GUI叠加在3D场景上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆