Skip to content
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

Pose is not preserved when loading multiple meshes within a GLB #135

Closed
jaspreetdhanjan opened this issue Aug 21, 2020 · 4 comments
Closed

Comments

@jaspreetdhanjan
Copy link

jaspreetdhanjan commented Aug 21, 2020

Here is a GLB file loaded into Unity:

Screenshot (118)

And here is the same GLB loaded using Pyrender/trimesh

Screenshot (117)

This is just an example, I know these are different frameworks. However, how can I preserve the pose of each object within the scene-graph so that my cube is in the correct position relative to the plane?

Here is my code:

loaded_payload = trimesh.load(BytesIO(payload), file_type='glb') mesh = Mesh.from_trimesh(list(loaded_payload.geometry.values())) self.scene.add(mesh)

@mikedh
Copy link

mikedh commented Aug 21, 2020

Hey, I'm not sure of the details on this, but geometry.values is untransformed geometry. You can either try from_trimesh_scene:

In [1]: import trimesh

In [2]: s = trimesh.load('models/CesiumMilkTruck.glb')

In [3]: s.show()
Out[3]: SceneViewer(width=1800, height=1350)

In [4]: import pyrender

In [6]: p = pyrender.scene.Scene()

In [7]: p.from_trimesh_scene(s)

Or you can "bake" the transforms from the trimesh scene into a list of copied/transformed meshes:

loaded_payload = trimesh.load(BytesIO(payload), file_type='glb') 
mesh = Mesh.from_trimesh(loaded_payload.dump())
self.scene.add(mesh)

@jaspreetdhanjan
Copy link
Author

Thanks @mikedh. Your solution worked great. I guess I misinterpreted the doc; would be great to get a few more examples up on the repo!

@jaspreetdhanjan
Copy link
Author

Hi @mikedh do you have an email or a way to contact you? I have some questions about your trimesh package

@jaspreetdhanjan
Copy link
Author

@mikedh I just wanted to ask if I am able to get the name of a node from the GLB file using your API...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants