|
44 | 44 | import com.jme3.material.plugin.TestMaterialWrite; |
45 | 45 | import com.jme3.math.ColorRGBA; |
46 | 46 | import com.jme3.math.Vector3f; |
| 47 | +import com.jme3.renderer.Camera; |
| 48 | +import com.jme3.scene.CameraNode; |
47 | 49 | import com.jme3.scene.Geometry; |
48 | 50 | import com.jme3.scene.Mesh; |
49 | 51 | import com.jme3.scene.Node; |
@@ -168,6 +170,27 @@ public void testDracoExtension() { |
168 | 170 | } |
169 | 171 | } |
170 | 172 |
|
| 173 | + @Test |
| 174 | + public void testPerspectiveCameraAspectRatio() { |
| 175 | + Camera camera = loadCamera("gltf/camera/perspectiveCamera.gltf"); |
| 176 | + float aspectRatio = camera.getFrustumRight() / camera.getFrustumTop(); |
| 177 | + Assertions.assertEquals(1.5f, aspectRatio, 1e-5f); |
| 178 | + } |
| 179 | + |
| 180 | + @Test |
| 181 | + public void testPerspectiveCameraWithoutAspectRatio() { |
| 182 | + Camera camera = loadCamera("gltf/camera/perspectiveCameraNoAspectRatio.gltf"); |
| 183 | + float aspectRatio = camera.getFrustumRight() / camera.getFrustumTop(); |
| 184 | + Assertions.assertEquals(1f, aspectRatio, 1e-5f); |
| 185 | + } |
| 186 | + |
| 187 | + private Camera loadCamera(String path) { |
| 188 | + Node scene = (Node) assetManager.loadModel(path); |
| 189 | + Spatial cameraNode = scene.getChild("cameraNode"); |
| 190 | + Assertions.assertInstanceOf(CameraNode.class, cameraNode, "Camera node not found"); |
| 191 | + return ((CameraNode) cameraNode).getCamera(); |
| 192 | + } |
| 193 | + |
171 | 194 | private void dumpScene(Spatial s, int indent) { |
172 | 195 | System.err.print(indentString.substring(0, indent) + s.getName() + " (" + s.getClass().getSimpleName() + ") / " + |
173 | 196 | s.getLocalTransform().getTranslation().toString() + ", " + |
|
0 commit comments