Skip to content

Fix glTF perspective camera ignoring aspectRatio - #3016

Open
Lay-quq wants to merge 1 commit into
jMonkeyEngine:masterfrom
Lay-quq:contrib/jMonkeyEngine__jmonkeyengine__2717
Open

Lay-quq wants to merge 1 commit into
jMonkeyEngine:masterfrom
Lay-quq:contrib/jMonkeyEngine__jmonkeyengine__2717

Conversation

@Lay-quq

@Lay-quq Lay-quq commented Oct 19, 2026

Copy link
Copy Markdown

Fixes #2717

GltfLoader.readCameras() looked up the perspective camera's aspect ratio under the key "aspectRation", but the glTF 2.0 spec names it aspectRatio. The lookup never matched, so every perspective camera loaded from a glTF file got an aspect ratio of 1 regardless of what the file said.

This changes the key to aspectRatio. The fallback when the property is missing is still 1, as before; using the viewport's aspect ratio in that case (as the spec suggests) is a separate change and not part of this PR.

Tests: two small embedded glTF files under jme3-plugins/src/test/resources/gltf/camera/, each with one node referencing a perspective camera. GltfLoaderTest loads them and checks the frustum of the resulting CameraNode's camera: with aspectRatio: 1.5 the frustum's right/top ratio is 1.5 (this fails on master with expected: <1.5> but was: <1.0>), and without aspectRatio it stays 1.

./gradlew :jme3-plugins:test passes (44 tests). I also built and tested the JVM modules; I couldn't run the Android modules locally (no Android SDK). The project's Checkstyle task only covers com/jme3/renderer, so it doesn't check these files; running the same checkstyle.xml on the two changed Java files reports no new warnings.

@jaime-jmebot jaime-jmebot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! This clean fix directly resolves the typo and adds great test coverage.

  • Fixes "aspectRation" key typo in GltfLoader.java to match the glTF 2.0 specification.
  • Adds unit tests covering perspective camera loading with and without aspectRatio.
  • Includes lightweight test glTF files and updates gltf/README.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

typo in gltf loader aspectRation -> aspectRatio

2 participants