Add .3ds (Autodesk 3D Studio) file format support#8
Open
fsalexandre wants to merge 1 commit into
Open
Conversation
trimesh 4.x has no built-in .3ds loader, so this adds a from-scratch chunk parser (tds_reader.py) and a 3DS->OBJ converter (tds_to_obj.py), mirroring the existing .kn5 path: convert to a temporary OBJ, then reuse _load_obj_with_real_groups so real per-object names become UI parts and UVs feed the AO bake. No new dependencies. - 3DS is Z-up; the renderer is Y-up. tds_to_obj bakes a Z-up -> Y-up rotation (x,y,z)->(x,z,-y) (-90deg about X, a proper rotation so face winding is preserved), scoped ONLY to the 3DS path — no other format or the global AxisConfig is touched. - Corrupt/truncated input is validated before writing: non-finite vertex coordinates and out-of-range face indices raise a clean ModelLoadError instead of a NaN-blank render or a raw IndexError. - Duplicate 3DS object names are disambiguated safely (probed against all emitted names) so parts don't silently merge. - Registered .3ds in SUPPORTED_EXTENSIONS (also enables .3ds inside zips), the upload accept filter, and the docs. - test_3ds.py: happy-path (hand-encoded 3DS) + corrupt-input/duplicate -name robustness. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds support for loading Autodesk
.3ds(3D Studio) models.trimesh4.xhas no built-in
.3dsloader, so this ships a from-scratch chunk parser(
tds_reader.py) plus a3DS -> OBJconverter (tds_to_obj.py) — mirroring theexisting
.kn5path (convert to a temp OBJ, then reuse_load_obj_with_real_groupsso real per-object names become UI parts and UVs feed the AO bake). No new
dependencies.
Sample output
A real Proton Bus Citiport model (
.3ds) rendered through Ortho:Implementation notes
tds_to_objbakes arotation
(x,y,z) -> (x,z,-y)(−90° about X — a proper rotation, det +1, sotriangle winding is preserved). This is scoped only to the 3DS path; no
other format and no global
AxisConfigis touched.out-of-range face indices are validated before writing and raise a clean
ModelLoadErrorinstead of a NaN-blanked render or a rawIndexError.so parts don't silently merge.
.3dsinSUPPORTED_EXTENSIONS(also enables.3dsinside zips),the upload
acceptfilter, and the docs.Tests
test_3ds.py— happy path (a hand-encoded 3DS as an independent oracle) pluscorrupt-input / duplicate-name robustness cases.
🤖 Generated with Claude Code