I'm looking to model actual distances say measured in centimeters. So the following SubScene containing a simple rectangle has width & height associated with my model distance in cm. The code renders correctly for certain and rectangle size (100 cm) but not others (200 cm). When I say it works, I see the red rectangle with 1/3 the size of the window pane... that is the field of view. When it does not work, the pane is blank. Strangely, I arranged the scaling so all the ratios are fixed by positioning the camera and fieldOfView angle from the size_cm parameter. So I'm confused why changing this absolute scaling should matter. I'm using Kotlin here, but I expect the same for straight up Java. I appreciate any thoughts.
class Scale3D : View("My View") {
val size_cm = 100.0 //works, 200.0 //fails
val cameraFOV_pix = 600.0
val cameraFOV_cm = 3.0 * size_cm
val cameraZOffset_cm = 1.0 * size_cm
val testBox = Rectangle(size_cm, size_cm).apply{
fill= Color.RED
translateX = -size_cm / 2.0
translateY = -size_cm / 2.0
}
val vCamera = PerspectiveCamera(true).apply{
translateZ = -cameraZOffset_cm
fieldOfView = 2.0*Math.toDegrees(Math.atan2(cameraFOV_cm/2.0, cameraZOffset_cm))
println("angle=%.1f deg".format(fieldOfView))
}
override val root = anchorpane {
val rootVx = Group(vCamera,testBox)
val subScene = SubScene(rootVx, cameraFOV_pix, cameraFOV_pix,true, SceneAntialiasing.BALANCED).apply {
fill = Color.ALICEBLUE
camera = vCamera
}
children.addAll(subScene)
}
}