Skip to content

Accept optional texture vector components - #157

Open
civilwarinfrance wants to merge 1 commit into
pywavefront:masterfrom
civilwarinfrance:fix/optional-texture-vector-components
Open

civilwarinfrance wants to merge 1 commit into
pywavefront:masterfrom
civilwarinfrance:fix/optional-texture-vector-components

Conversation

@civilwarinfrance

Copy link
Copy Markdown

Loading a material containing map_Kd -s 2 diffuse.png currently raises ValueError because the texture parser requires all three vector components and tries to convert the filename to a number. Offset (-o) and turbulence (-t) have the same problem.

The Alias/Wavefront format manual makes the second and third components optional. Read up to three numbers, preserve the next option or filename, and fill omitted components with the documented defaults: 1 for scale, 0 for offset/turbulence.

Tests cover abbreviated/full vectors, negative and scientific values, following flags, filenames with spaces, repeated options and a complete OBJ/MTL load. The original code fails 14 cases; all 114 tests pass after the fix on macOS/Python 3.11. The CI blocking Flake8 check passes; the advisory check adds no diagnostics in the touched files. Other platforms and GPU rendering were not tested.

AI assistance: Codex investigated, implemented, tested and drafted this contribution under the account owner's authorization.

Preserve filenames and subsequent options after one- or two-component
scale, offset and turbulence vectors. Add parser and OBJ/MTL regressions.

Prepared with Codex assistance.
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.

1 participant