Skip to content

java: Add getDistance, getWorldAzimuth, and getWorldElevation to Camera API#3236

Open
code2766 wants to merge 9 commits into
f3d-app:masterfrom
code2766:feature-camera-getters
Open

java: Add getDistance, getWorldAzimuth, and getWorldElevation to Camera API#3236
code2766 wants to merge 9 commits into
f3d-app:masterfrom
code2766:feature-camera-getters

Conversation

@code2766

@code2766 code2766 commented Jun 12, 2026

Copy link
Copy Markdown

Describe your changes

This PR exposes three core camera spatial tracking metrics (getDistance(), getWorldAzimuth(), and getWorldElevation()) to the f3d::camera public C++ API.

Per maintainer feedback, the primary focus of this PR is the C++ implementation and ensuring its core functionality is sound.

  • C++ Core (library/): Added tracking and calculation for camera distance and world orientation angles in camera.h and camera_impl.cxx.
  • Testing (library/testing/): Updated TestSDKCamera.cxx to verify the accuracy of these new metrics.
  • Bindings Note: Initial Java API/JNI bindings are included in this commit, but further language bindings (Python, C, Wasm) are intentionally held off until the underlying C++ implementation passes core review.

Issue ticket number and link if any

None. (Feature enhancement developed to support downstream application wrapping).

Checklist for finalizing the PR

  • I have performed a self-review of my code
  • I have added tests for new features and bugfixes
  • I have added documentation for new features
  • If it is a modifying the libf3d API, I have updated bindings (Java bindings drafted; Python/C/Wasm pending C++ API approval)
  • If it is a modifying the .github/workflows/versions.json, I have updated docker_timestamp

AI Disclosure

  • I did not use AI to generate any of the content of that pull request
  • I used AI to generate code in that pull request, if yes please disclose which part of the code was generated and with which model.
    • Details: Assisted by Gemini (Google) to draft the boilerplates for the C++ getter logic, the structural framework for the JNI bridging functions (F3DCameraBindings.cxx), and the Java native method declarations in Camera.java. All logic was compiled, checked, and tested locally.

Continuous integration

Please write a comment to run CI, eg: \ci fast.
See here for more info.

Overview

This PR exposes three core camera spatial metrics (getDistance, getWorldAzimuth, and getWorldElevation) to the Java binding layer. This allows downstream Java applications wrapping F3D to query critical camera position and orientation properties natively without needing to manually recalculate them on the client side.

Changes

  • Core C++ API (library/): Exposed tracking for camera distance and world orientation angles in camera.h and implemented them within camera_impl.h/.cxx.
  • JNI Bridge (java/): Added matching native C++ bridging functions inside F3DCameraBindings.cxx to map the Java runtime calls safely over to the underlying native engine.
  • Java API (java/app/f3d/F3D/): Declared the public native method signatures along with clear JavaDoc documentation inside Camera.java.
  • Testing (library/testing/): Updated TestSDKCamera.cxx to ensure complete coverage of the new camera metrics.

Testing Done

  • Validated that the entire stack compiles cleanly at 100% with -DF3D_BINDINGS_JAVA=ON on macOS (Apple Silicon, Temurin JDK 25).
  • Verified the native shared library (libf3d-java.dylib) and Java archive (f3d.jar) generate successfully.
  • Ran clang-format on all modified C++ files to ensure code alignment with F3D styling rules.

@code2766 code2766 requested a review from a team as a code owner June 12, 2026 06:32
@github-actions

Copy link
Copy Markdown

You are modifying libf3d public API! ⚠️Please update bindings accordingly⚠️!
You can find them in their respective directories: c, python, java, webassembly.

@mwestphal

Copy link
Copy Markdown
Member

@code2766

  1. Do not remove the template PR description. I've put it back, please fill it up.

  2. Do not focus on java first, focus on C++ impl first, bindings will come later once C++ impl is functionnal

@mwestphal mwestphal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not rdy for review until description has been filled.

@code2766

Copy link
Copy Markdown
Author

\ci fast

@code2766

Copy link
Copy Markdown
Author

\ci fast

@mwestphal

Copy link
Copy Markdown
Member

None. (Feature enhancement developed to support downstream application wrapping).

Hum, isnt this fixing #1419 ?

@code2766

Copy link
Copy Markdown
Author

None. (Feature enhancement developed to support downstream application wrapping).

Hum, isnt this fixing #1419 ?

Ah, you are completely right! I wasn't aware of the existing tracker item. This completely implements the camera getters requested in #1419.

I have updated the PR description to link it properly. Thank you!

@code2766

Copy link
Copy Markdown
Author

\ci fast

@mwestphal

mwestphal commented Jun 12, 2026

Copy link
Copy Markdown
Member

None. (Feature enhancement developed to support downstream application wrapping).

Hum, isnt this fixing #1419 ?

Ah, you are completely right! I wasn't aware of the existing tracker item. This completely implements the camera getters requested in #1419.

I have updated the PR description to link it properly. Thank you!

you commented on it 14 hours ago, I'm getting confused now.
#1419 (comment)

I have updated the PR description to link it properly. Thank you!

You did not.

@code2766

Copy link
Copy Markdown
Author

\ci fast

@github-actions

Copy link
Copy Markdown

Style Checks CI failed:

diff --git a/library/testing/TestSDKCamera.cxx b/library/testing/TestSDKCamera.cxx
index ba903f7..e795d79 100644
--- a/library/testing/TestSDKCamera.cxx
+++ b/library/testing/TestSDKCamera.cxx
@@ -39,10 +39,11 @@ int TestSDKCamera([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
       cam.setPosition({ 0, 0, 10 }).setFocalPoint({ 0, 0, 0 }).setViewUp(up);
       cam.azimuth(a).elevation(e);
 
-      std::string title = " (up=" + f3d::options::format(up) + ", a=" + std::to_string(static_cast<int>(a)) + ")";
-      
-      // We use a tolerance of 0.5 degrees. This is required because VTK internally 
-      // re-normalizes the camera's orthonormal basis (Right, Up, Forward) after 
+      std::string title =
+        " (up=" + f3d::options::format(up) + ", a=" + std::to_string(static_cast<int>(a)) + ")";
+
+      // We use a tolerance of 0.5 degrees. This is required because VTK internally
+      // re-normalizes the camera's orthonormal basis (Right, Up, Forward) after
       // floating-point matrix rotations.
       test("get azimuth" + title, cam.getWorldAzimuth(), approx(a, 0.5));
       test("get elevation" + title, cam.getWorldElevation(), approx(e, 0.5));

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants