Loading MTL/OBJ with texture filters
Hey!
Currently using 3D in Framer with just stock Three.js and this model loading workflow:
mtlLoader = new THREE.MTLLoader();
mtlLoader.setBaseUrl('models/');
mtlLoader.setPath('models/');
mtlLoader.crossOrigin = '';
mtlLoader.load('alex.mtl', (materials) ->
materials.preload();
materials.materials.default.map.magFilter = THREE.NearestFilter;
materials.materials.default.map.minFilter = THREE.LinearFilter;
objLoader = new THREE.OBJLoader();
objLoader.setMaterials(materials);
objLoader.setPath('models/');
objLoader.load('alex.obj', (object) ->
scene.add(object);
)
)
Would be super cool if something like that could be made to work with a Form model. Pretty sure it's not possible right now, but I'm not super confident in the Three.js API so I might be mistaken 🤔
Also note how the .PNG texture is loaded from the MTL file here.
I've now integrated your proposal into the OBJ/MTL-loader. Let me know if something doesn't work as expected.
Thanks! :)
Commit c3943a0
Cool!! Thanks for looking into this so quickly! 🙏
However, not sure if this is a good general solution? I assume other texture use-cases would need other filters? 🤔Thinking that it might be better if I just maintain this change on my end for now, since these filters are pretty specific my usecase.
In the long run however, maybe filters might be something that can be exposed on the Form model API?
Also, this does not really work out-of the box for me, since the material used for me seems to be in the materials.materials.defaults object. Not sure if this is ideal though, just what works on my end!
Cheers ✌️
Yeah, I had some second thoughts on this, this morning as well. I will probably revert this and implement a proper filter-property on the Model-class.
OBJLoader is now reverted to as it was before. I will branch off to a new branch so we can follow up on a good way to handle the support for texture filters.
Sounds great 👏