p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

GSOC 26: multi-material model parts (obj/mtl)

Open Nixxx19 opened this issue 5 months ago • 1 comments

Part of my Google Summer of Code 2026 project, "Full Texture Support for .mtl Files in p5.js". Works toward #6924.

This PR covers phase 1 and phase 2 of the project: the design and the data + parser foundation that multi-material support is built on. The renderer side (phase 3) follows as a separate PR once this lands. Public API is unchanged across the whole project; everything happens underneath loadModel().

Project phases for context:

  • phase 1: design + pipeline study
  • phase 2: data model + obj/mtl parser (this PR)
  • phase 3: per-part rendering (next PR, already working locally)

what's in here:

  • new p5.GeometryPart, holds one material's verts/faces/uvs plus its draw state
  • p5.Geometry now holds parts. single-material models get one part so the shape stays uniform
  • parseMtl reads the full token set (Kd/Ka/Ks/Ns/d/illum/map_Kd/map_Ka/map_Ks/bump), split into a pure parser so it's testable
  • obj faces get bucketed into one part per material with localised verts
  • map_Kd textures load onto the part state

tests:

  • parseMtl tokens + mtl to part-state mapping (test/unit/io/parseMtl.js)
  • geometrypart + single-part wrap (test/unit/webgl/p5.GeometryPart.js)
  • multi-material obj splits into the right parts, textures load, a missing texture doesn't fail the load (test/unit/io/loadModel.js)

internally a loaded multi-material model now carries geometry._parts, each a GeometryPart with its own buffers + partState (fill/specular/shininess/opacity/texture). public loadModel/model api is unchanged.

Nixxx19 avatar Jun 07 '26 10:06 Nixxx19

Continuous Release

CDN link

  • https://raw.esm.sh/pr/p5@f7aa03c/lib/p5.min.js

Published Packages

  • https://pkg.pr.new/p5@f7aa03c

Commit hash: 40d520a

Previous deployments

0101168

  • https://raw.esm.sh/pr/p5@3cef9af/lib/p5.min.js
  • https://pkg.pr.new/p5@3cef9af

1234024

  • https://raw.esm.sh/pr/p5@ef96d47/lib/p5.min.js
  • https://pkg.pr.new/p5@ef96d47

b086d81

  • https://raw.esm.sh/pr/p5@4dd0f2b/lib/p5.min.js
  • https://pkg.pr.new/p5@4dd0f2b

962112d

  • https://raw.esm.sh/pr/p5@4598ddb/lib/p5.min.js
  • https://pkg.pr.new/p5@4598ddb

This is an automated message.

p5-bot[bot] avatar Jun 07 '26 10:06 p5-bot[bot]