question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[GLTF] Reuse mesh buffer items

See original GitHub issue

Multiple copies of the mesh data are included when with the same mesh is added to the scene multiple times. I would be nice to identify that the mesh data is already present and avoid adding it again. This will allow us to have smaller files and in some cases speed up write times.

Bellow is a simple example of a scene where we should try to have a single buffer item.

from trimesh import Scene
from trimesh.creation import box
from trimesh.transformations import translation_matrix
import trimesh

scene = Scene()
box_1 = box()
box_2 = box()
print(trimesh)

scene.add_geometry(box_1, 'box_1', transform=translation_matrix((1, 1, 1)))
scene.add_geometry(box_2, 'box_2', transform=translation_matrix((-1, -1, -1)))

scene.export('boxes2.glb')

I may have a chance to tackle this myself, but wanted to capture this task here incase there were any upfront objections to adding this.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mikedhcommented, Mar 15, 2021

Ah nevermind that just combines them into one big buffer. Dedupe branch here with the hashing strategy works for meshes: https://github.com/mikedh/trimesh/tree/gltf/dedupe

0reactions
mikedhcommented, Mar 15, 2021

Hmm, what about the existing merge_buffers option? IE scene.export(file_type='gltf', merge_buffers=True). It seems like it does pretty much this, maybe it should be selected by default?

# merge_buffers=False
len(acc): 7 len(buff): 7
# merge_buffers=True
len(acc): 7 len(buff): 1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mesh - glTF-Transform
Meshes define reusable geometry (triangles, lines, or points) and are instantiated by Nodes. Each draw call required to render a mesh is represented...
Read more >
glTF in Unity optimization - 1. Buffers, Accessors and Primitives
In Unity you render geometry via a Unity Mesh, which is a data structure that tightly bundles vertex attribute buffers and (sub) mesh...
Read more >
How do indices work (under primitives)? - glTF
Hi, In the mesh attribute I got a vector of positions and textures. ... This arrangement allows vertices to be reused by multiple...
Read more >
Mesh and PointCloud Loaders - loaders.gl
Keys are glTF attribute names and values are accessor objects. indices, Object (Optional), If present, describes the indices (elements) of the geometry as...
Read more >
Mesh | API Reference | ArcGIS Maps SDK for JavaScript 4.25
To support multiple materials (as is often the case for complex 3D models), meshes may define components that define a material for a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found