Add native OBJ + MTL + texture loader for custom objects#13
Add native OBJ + MTL + texture loader for custom objects#13Ishan-Banjara wants to merge 3 commits into
Conversation
|
Very nice, thank you :D I will try to push an update of the live website in the next few weeks. Sorry for not replying to this sooner! |
|
I'll need you to cleanup the comments before I can accept this PR. Also the readme should absolutely not be a part of this PR at all. I'm generally not too stoked about purely AI generated PRs that have not even been cross checked. |
|
Really sorry about the sloppy first pass. This is my first PR, leaned on AI too much and didn't review carefully before submitting. Also didn't realize the README change would be the part of the PR, thought it would be only a fork edit. It is all on me. I have reverted the README and removed the AI-style comments and branded console logs. Also, I found the material conversion I added in attachOBJToSimObject was not doing anything. One artifact that remains is the hover-highlight feature is not working with the OBJ models. But no crash, just silently no-ops on hover/click. |
Summary
Extends the "Custom object..." loader to natively support
.objfiles with optional.mtlmaterial files and texture images, alongside existing.stlsupport.🔗 Live demo: https://ishan-banjara.github.io/Rocksi/
Motivation
The original custom object loader only supports
.stlfiles, which lack material and color information. Many common 3D models (especially from Free3D, Sketchfab, etc.) ship as.obj+.mtl+ textures. This PR lets users load those directly with full visual fidelity.Changes
All changes contained in
src/simulator/objects/createObjects.js:OBJLoaderandMTLLoaderimports fromthree/examples/jsm/loaders/loadUserSTL()→loadUserFile()as a format router.obj+.mtl+ texturesloadUserOBJ()withLoadingManager.setURLModifierfor blob URL resolution of texture referencesattachOBJToSimObject()which:MeshPhongMaterialfor compatibility with Rocksi's highlight system (prevents amaterial.emissivecrash)The existing STL path is completely unchanged; backward compatible.
How to Test
.obj+.mtl+ texture images in the pickerOr try directly at the live demo above.
Notes
three)createObjects.js