Material Dedup functionality
See original GitHub issueWhen preparing a series of glTF objects for sequencing, the materials for each ‘frame’ object are kept despite being the same across all objects. This may be a side effect of the workflow I am using and creating a solution for (i.e. OBJ Sequence from Blender -> single glTF sequence animation)
Describe the solution you’d like
Similar to the existing dedup
function, take the base materials from a mesh and remove the extraneous duplicate materials, then reassign the original material to each subsequent ‘frame’ mesh.
Describe alternatives you’ve considered The current workaround I am using is a naive(see: hamfisted) approach where I simply loop through all the materials on the first mesh in the first frame, ignore the first material then detatch & dispose the materials on subsequent meshes. Then copy the material from the first mesh to the subsequent meshes. It would be neat to have this ability packed in as an option for the dedup function as is. The second part of this is not present in the below gist, i havent gotten as far as to write both that functionality or a better test animation for it.
https://gist.github.com/MrMagicPenguin/db149a701f6e36fade56349884756238
If this meshes (pun intended) with your vision for gltf-transform but isnt reasonably worth your time i’d be happy to give writing it as an extension a shot since I will need to make this happen regardless.
Cheers!
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (13 by maintainers)
Top GitHub Comments
Okay, thank you for the clarification on the TextureLink since that adds up with my experience using the
assert
library to double check my work with the isDeepStrictEqual. I will read those articles you sent, thank you! If its just as well to have the comparison tests written like that , I will just apply ample usage of my IDE’s folding function, lol!Thanks again, I appreciate you lending your ear to my hurdles.
Might be getEmissiveFactor() – that’s a
vec3
and would require a deep equality check. There’s a helper method for comparingnumber[]
types,MathUtils.eq
.I usually run
yarn watch
in a terminal, then edit code in VSC – I would expect it should work the same in any IDE though.