-
Notifications
You must be signed in to change notification settings - Fork 4
feat: add axes #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| """ | ||
| Tests for CoordinateAxis, CoordinateAxes, and Scene.axes | ||
| """ | ||
|
|
||
| import os | ||
|
|
||
| import pytest | ||
|
|
||
| import ufbx | ||
|
|
||
|
|
||
| def test_coordinate_axis_enum(): | ||
| """CoordinateAxis has all 7 values matching ufbx C API.""" | ||
| assert hasattr(ufbx.CoordinateAxis, "COORDINATE_AXIS_POSITIVE_X") | ||
| assert hasattr(ufbx.CoordinateAxis, "COORDINATE_AXIS_NEGATIVE_X") | ||
| assert hasattr(ufbx.CoordinateAxis, "COORDINATE_AXIS_POSITIVE_Y") | ||
| assert hasattr(ufbx.CoordinateAxis, "COORDINATE_AXIS_NEGATIVE_Y") | ||
| assert hasattr(ufbx.CoordinateAxis, "COORDINATE_AXIS_POSITIVE_Z") | ||
| assert hasattr(ufbx.CoordinateAxis, "COORDINATE_AXIS_NEGATIVE_Z") | ||
| assert hasattr(ufbx.CoordinateAxis, "COORDINATE_AXIS_UNKNOWN") | ||
|
|
||
| assert ufbx.CoordinateAxis.COORDINATE_AXIS_POSITIVE_X == 0 | ||
| assert ufbx.CoordinateAxis.COORDINATE_AXIS_NEGATIVE_X == 1 | ||
| assert ufbx.CoordinateAxis.COORDINATE_AXIS_POSITIVE_Y == 2 | ||
| assert ufbx.CoordinateAxis.COORDINATE_AXIS_NEGATIVE_Y == 3 | ||
| assert ufbx.CoordinateAxis.COORDINATE_AXIS_POSITIVE_Z == 4 | ||
| assert ufbx.CoordinateAxis.COORDINATE_AXIS_NEGATIVE_Z == 5 | ||
| assert ufbx.CoordinateAxis.COORDINATE_AXIS_UNKNOWN == 6 | ||
|
|
||
| assert isinstance(ufbx.CoordinateAxis.COORDINATE_AXIS_POSITIVE_X, int) | ||
|
|
||
|
|
||
| def test_coordinate_axes(): | ||
| """CoordinateAxes construction, .right/.up/.front, clamping, __repr__.""" | ||
| from ufbx._ufbx import CoordinateAxes | ||
|
|
||
| ax = CoordinateAxes(0, 2, 4) | ||
| assert ax.right == ufbx.CoordinateAxis.COORDINATE_AXIS_POSITIVE_X | ||
| assert ax.up == ufbx.CoordinateAxis.COORDINATE_AXIS_POSITIVE_Y | ||
| assert ax.front == ufbx.CoordinateAxis.COORDINATE_AXIS_POSITIVE_Z | ||
|
|
||
| ax2 = CoordinateAxes(1, 3, 5) | ||
| assert ax2.right == ufbx.CoordinateAxis.COORDINATE_AXIS_NEGATIVE_X | ||
| assert ax2.up == ufbx.CoordinateAxis.COORDINATE_AXIS_NEGATIVE_Y | ||
| assert ax2.front == ufbx.CoordinateAxis.COORDINATE_AXIS_NEGATIVE_Z | ||
|
|
||
| # Out-of-range -> UNKNOWN | ||
| ax3 = CoordinateAxes(99, -1, 7) | ||
| assert ax3.right == ufbx.CoordinateAxis.COORDINATE_AXIS_UNKNOWN | ||
| assert ax3.up == ufbx.CoordinateAxis.COORDINATE_AXIS_UNKNOWN | ||
| assert ax3.front == ufbx.CoordinateAxis.COORDINATE_AXIS_UNKNOWN | ||
|
|
||
| assert "CoordinateAxes" in repr(ax) | ||
| assert "right=" in repr(ax) and "up=" in repr(ax) and "front=" in repr(ax) | ||
|
|
||
|
|
||
| def test_scene_has_axes_property(): | ||
| """Scene exposes axes property.""" | ||
| assert hasattr(ufbx.Scene, "axes") | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def fbx_path(): | ||
| p = os.path.join(os.path.dirname(__file__), "fixtures", "maya_cube.fbx") | ||
| return p if os.path.exists(p) else None | ||
|
|
||
|
|
||
| def test_scene_axes(fbx_path): | ||
| """Scene.axes returns CoordinateAxes with right/up/front as CoordinateAxis.""" | ||
| if fbx_path is None: | ||
| pytest.skip("maya_cube.fbx not found (see tests/fixtures/README.md)") | ||
|
|
||
| with ufbx.load_file(fbx_path) as scene: | ||
| ax = scene.axes | ||
| assert ax is not None | ||
| assert hasattr(ax, "right") and hasattr(ax, "up") and hasattr(ax, "front") | ||
| assert isinstance(ax.right, ufbx.CoordinateAxis) | ||
| assert isinstance(ax.up, ufbx.CoordinateAxis) | ||
| assert isinstance(ax.front, ufbx.CoordinateAxis) | ||
| assert "CoordinateAxes" in repr(ax) | ||
|
|
||
|
|
||
| def test_scene_axes_after_close(fbx_path): | ||
| """Accessing axes after scene.close() raises RuntimeError.""" | ||
| if fbx_path is None: | ||
| pytest.skip("maya_cube.fbx not found (see tests/fixtures/README.md)") | ||
|
|
||
| scene = ufbx.load_file(fbx_path) | ||
| scene.close() | ||
| with pytest.raises(RuntimeError, match="closed"): | ||
| _ = scene.axes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This stub declares a top-level
CoordinateAxes, butufbx/__init__.pynever imports it from_ufbx, soufbx.CoordinateAxeswill raiseAttributeErrorat runtime even though type checkers accept it. That mismatch is triggered whenever users follow the stub (e.g., forisinstance(x, ufbx.CoordinateAxes)or type annotations) and will fail in regular execution; consider importing and adding it to__all__to match the stub andScene.axesreturn type.Useful? React with 👍 / 👎.