petrbroz / svf-utils

Utilities for working with the SVF file format used by Autodesk Platform Services.
https://petrbroz.github.io/svf-utils/
MIT License
131 stars 56 forks source link

Example to attach custom guid to each mesh #63

Closed leefsmp closed 2 years ago

leefsmp commented 2 years ago

Hi, I'm looking at the sample to attach custom dbId to meshes: https://github.com/petrbroz/forge-convert-utils/blob/develop/samples/custom-gltf-attribute.js

But having a hard time understanding how to modify it so we can attach guid (revit externalId) string instead. Could you give a quick example on how to achieve that pls?

leefsmp commented 2 years ago

maybe we can live with attaching a dbId instead of guid as I understand it may cause the geometry to become significantly heavier... however after running your example my model appears quite coloured ...

Screenshot 2022-08-03 at 23 23 14
petrbroz commented 2 years ago

Hi Philippe, embedding a GUID into the glTF geometry would be very difficult, if possible at all. I'd suggest to just use the 32-bit dbID and embed it into the RGBA components of the vertex colors. Btw. I've just recorded a lightning talk on this topic (incl. the way to retrieve this dbID in Unity) that'll be published during the AU in September.

leefsmp commented 2 years ago

ok but storing the attributes in COLOR_0 can't be the right way to do as it definitely impacts the color of my models ...

petrbroz commented 2 years ago

No worries, in the lightning talk I explain the process of detaching the vertex colors from the geometry so that its appearance is not affected. Btw. the lightning talk is centered around this sample code: https://github.com/petrbroz/forge-unity-poc.