-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: _meshfile_object
loaders.
#112
base: master
Are you sure you want to change the base?
WIP: _meshfile_object
loaders.
#112
Conversation
_meshfile_object
loaders for Collada files._meshfile_object
loaders.
Enabled png or jpeg textures for Collada files based on file extension (switching the base64-encoded image mime type accordingly). Added Collada assets of the Valkyrie head with both Updated the notebook to visualize the original head from |
@@ -380,6 +382,43 @@ def data_from_stream(stream): | |||
return data | |||
|
|||
|
|||
#we can't make a MeshFileObject that inherits from Object because we need data and resources and no need for material, geom uuids |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this suggests that the type hierarchy isn't quite right. Over in the Julia version of meshcat (which is a little more developed), I have AbstractObject
as a parent type of Object
and MeshFileObject
, and we might want something similar here.
https://github.com/rdeits/MeshCat.jl/blob/6ca2e706d2ccb9501a0fb5ccd5829c208f26af4f/src/objects.jl#L6
Any progress ? I would love to see this feature merged 😃 |
@duburcqa Sorry, I haven't really had any time to work on this beyond what I've done here. I had an first prototype where I defined an external class that prepared an object dictionary all in one go and returned it from https://gist.github.com/danzimmerman/a392f8eadcf1166eb5bd80e3922dbdc5 Might be a temporary workaround? Hope I can find some more time to work on this soon. |
@danzimmerman nice, thank you ! My meshcat is already so heavily modded that I'm fine with your proposal :) I will try it asap |
OK so it is working, each texture image is loaded systematically even if it is used by multiple files. It is slowing done the mesh loading dramatically :/ |
Is this for a use case like https://github.com/duburcqa/jiminy/tree/master/data/bipedal_robots/atlas/ with files like I was developing against really simple lightweight assets, maybe that's a better test case. To really deal with that kind of thing it seems we'd need a class that knows about the whole URDF or directory structure and probably also good to figure out if image resources can be cached (like #114 ). I suspect they can 🤔 |
Yes exactly. The issue is that the current mechanism based on filling the optional field |
After checking, it is possible to activate the cache of ThreeJS doing |
Yeah, I don't really have a good grip on the data flow after passing the I guess how it's supposed to work is that From #27 (comment)
|
Yes kind of. I implemented a POC using ThreeJS cache to avoid sending and loading the data repeatedly:
On Python side, the texture image converted to base64 is only sent the first time, later on it is just an empty string. Anyway it is going to be loaded from the cache. It works because the commands are queued and processed sequentially by design. |
I've made some potential progress toward #92 and possibly toward #27 and I wanted to open a PR for discussion.
What I've done so far:
meshcat.geometry.MeshFileObject
class that lowers (is this the right term?) to a_meshfile_object
meshcat.geometry.DaeMeshFileObject
that inherits fromMeshFileObject
that for now just has afrom_file()
static method that usesxml.etree.ElementTree
to parse a Collada file for image textures, load the corresponding images (assuming the same directory) andbase64
encode them as image resources.meshcat.commands.SetObject
to deal withMeshFileObjects
color_texture_collada_example.ipynb
and added required assets toexamples
(so I don't have to do a PR onmeshcat
as well). This example pulls UR3 mesh data fromGepetto/example-robot-data
for simply visualizing Collada files with colors.Still a lot of work to do here, OBJ/MTL parsing to add toward #27, and getting some more assets and test cases together, but I could use some feedback on whether I'm on the right track in terms of fitting into the existing code and object hierarchy.