framer-form icon indicating copy to clipboard operation
framer-form copied to clipboard

Loading MTL/OBJ with texture filters

Open Oscarnilsson opened this issue 7 years ago • 5 comments

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.

Framer cloud demo

Oscarnilsson avatar Apr 15 '18 12:04 Oscarnilsson

I've now integrated your proposal into the OBJ/MTL-loader. Let me know if something doesn't work as expected.

Thanks! :)

Commit c3943a0

emilwidlund avatar Apr 15 '18 18:04 emilwidlund

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 ✌️

Oscarnilsson avatar Apr 16 '18 12:04 Oscarnilsson

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.

emilwidlund avatar Apr 16 '18 12:04 emilwidlund

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.

emilwidlund avatar Apr 16 '18 12:04 emilwidlund

Sounds great 👏

Oscarnilsson avatar Apr 16 '18 12:04 Oscarnilsson