我正试图用Javafx做一些3D工作(使用TornadFX库),但无法设置我的
PerspectiveCamera
到
Scene
作为
场景
null
.
我这样启动我的程序:
class ThreeDTest : App(HomeView::class, ThreeDStyles::class) {
override fun start(stage: Stage) {
super.start(stage)
stage.show()
stage.scene.fill = Color.BLACK
val primaryScreenBounds = Screen.getPrimary().visualBounds
stage.maxWidth = 1920.0
stage.maxHeight = 1080.0
stage.minWidth = 1920.0
stage.minHeight = 1080.0
}
}
然后在
HomeView
I类有:
class HomeView : View() {
override val root = stackpane {
val axisGroup = Xform()
val world = Xform()
val camera = PerspectiveCamera(true)
val cameraXform = Xform()
val cameraXform2 = Xform()
val cameraXform3 = Xform()
val cameraInitialDistance = -450.0
val cameraInitialXAngle = 70.0
val cameraInitialYAngle = 320.0
val cameraNearClip = 0.1
val cameraFarClip = 10000.0
//just a builder class to add properties to the camera
buildCamera(this, cameraXform, cameraXform2, cameraXform3, camera, cameraNearClip, cameraFarClip, cameraInitialDistance,
cameraInitialYAngle, cameraInitialXAngle)
buildAxes(axisGroup, world)
println(scene)
//returns null
scene.camera = camera
//this does not work as scene is null
}
我做错什么了吗?我不知道为什么
场景
如我所想为空
View
应该创造一个新的
场景
createPrimaryScene
函数,并将代码移动到
init
在
HomeView
查看两者都没有成功。
有什么想法吗?把头发拔出来。
(哦,另一个不相关的问题是,坦率地说,在TornadFX中拥有3D支持将使我的
一生