multi-material model parts (obj/mtl)#8879
Conversation
Continuous ReleaseCDN linkPublished PackagesCommit hash: 962112d Previous deploymentsThis is an automated message. |
| ambientColor: null, // Ka | ||
| specularColor: null, // Ks | ||
| shininess: null, // Ns | ||
| opacity: null, // d |
There was a problem hiding this comment.
I think we don't yet have an actual global concept of opacity in our shaders -- we have tint, which can do opacity, but only for textured assets. Maybe worth making an issue for this (something like drawingContext2D's globalAlpha but for WebGL) and not putting too much effort into it here until that's added?
Also, should texture be in here too?
| } | ||
|
|
||
| if (this._parts.length === 0) { | ||
| this._wrapInSinglePart(); |
There was a problem hiding this comment.
Maybe double check, but I assume that since this check is in the constructor, geometry built via buildGeometry will hit this path too and end up having its vertices mapped to a single part.
One thought: maybe we can default to having one part if none have been made yet, and that's where the data lives, and on the geometry itself we just have getter/setters that map to that first part? If we mark it as empty with a flag, then a method to add a part can check for that first and delete the old one if it's the default empty one?
Regardless, we maybe want to make parts a documented thing (so, maybe without the _ prefix on the name) and mark the direct access of vertices.faces/etc deprecated so that it's still there for now, but the expectation is that it's removed in 3.0?
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:
what's in here:
p5.GeometryPart, holds one material's verts/faces/uvs plus its draw statep5.Geometrynow holds parts. single-material models get one part so the shape stays uniformparseMtlreads 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 testabletests:
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.