Add support for negative vertex indices in OBJ loader for 2.x by avinxshKD · Pull Request #8512 · processing/p5.js

Skip to content

Navigation Menu

Sign in

Appearance settings

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Conversation

@avinxshKD

Copy link

Contributor

Switched OBJ face parsing to use .at() for array access instead of bracket notation. Negative indices (like -1 for last vertex) now work per OBJ spec, positive indices still get converted from 1-based to 0-based.

Resolves #8493

Changes

  • Also removed TODO about negative indices from src/webgl/loading.js
  • Uses .at() for loadedVerts.v, loadedVerts.vt, loadedVerts.vn lookups to handle both negative and positive indexing
  • Added test/unit/assets/cube-negative-indices.obj ,, test file with negative face indices
  • Added two tests confirming negative index OBJs load and produce identical geometry to positive index versions

PR Checklist

  • npm run lint passes
  • Inline reference is included / updated
  • Unit tests are included / updated
Copy link

Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

@davepagurek davepagurek merged commit c538e7d into processing:dev-2.0

Feb 12, 2026

2 checks passed

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

Reviewers

@davepagurek davepagurek davepagurek approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@avinxshKD @davepagurek