Open RussTedrake opened 6 years ago
This would be nice for getting textures drawn on e.g. Drake's flashy new Skydio quadcopter model, which has relatively complex material setup on its different parts. Would this be easy to do using _meshfile_object
parsing that looks like has come into existence on the javascript side over the last year?
(I'm happy to take a crack at it some time, just don't have a birds-eye view if that's the right strategy.)
Yeah, that's the right thing to do. I'm happy to help out with the details!
There's an example of _meshfile_object
usage from javascript here: https://github.com/rdeits/meshcat/blob/master/test/meshfile_object_obj.html . Adding support in python would just mean creating a MeshFileObject
type in geometry.py
which lowers to the same data format as that example json
data.
The hardest part of this actually getting the texture file into the right format. I'm using the native object loader in Three.js, which expects that the texture files will be at some URL that it can access. Since that's annoying, I'm instead relying on the fact that you can create a data URI which includes the actual contents of the image file as base-64 encoded data. That means that texture loading just works, as long as you're willing to jump through some hoops to encode the data. The example linked above does that. In case it's helpful, the relevant Julia code that parses an obj
file for its associated .mtl
and then parses that .mtl
for its necessary image textures is here: https://github.com/rdeits/MeshCat.jl/blob/8fbf7286a1bd721d80d990f5ea744911fb1adc2f/src/mesh_files.jl#L77-L101
i asked (via email)
and the response was