Is there a way to keep vertexColors when compressing an obj file in Draco

Hello! So my question is there a way to keep vertexColors when compressing an .obj file in Draco?
I am using the draco_encoder.exe console utility on the server side. Each of my .obj objects is one object with different colors on the vertex. But when calling draco_encoder and opening it via DRACOLoader.js, I get one BufferGeometry and I can’t return the original vertex colors from obj. Maybe there are some options to save colors? Thank you!

Can you please try to decode the drc file back to OBJ via dracodecoder to ensure the issue is in three.js? It’s basically the same idea like suggested in Vertex Colors information gets eliminated in compression · Issue #900 · google/draco · GitHub.

In general, DRACOLoader does support vertex colors.

I tried to decode the drc file via draco_decoder.exe and I got a smaller file (~30%) and the colors are not stored in the decoded file. So that means it is Draco issue?

The colors should be retained after a round-trip. Meaning OBJ → DRC → OBJ. If they get lost, something is wrong during the encode/decode process.

1 Like

Check whether mesh.geometry.attributes.color exists. If it’s there but the colors are not shown, then something else may be wrong (lighting, material, etc.). If it’s missing then the vertex colors did not make it into the .drc file.

In generally I’d recommend converting files to glTF, and using Draco compression on that, rather than using .drc. It’s the same compression, but in a standardized and well-supported format instead.

3 Likes

Thanks everyone for the advice, I decided to use Obj->glTF->Draco. Are there any command line utilities that can convert Obj to glTF and do Draco compression at the same time?

Not that I’m aware of. I think you’d need to do OBJ → glTF in one step, and glTF → glTF+Draco in a second step.

1 Like

Hello everyone. Still don’t have colors after converting Obj to Glb and then to Draco. There is no mesh.geometry.attributes.color in the resulting mesh. Maybe I should use some properties in the resulting Scene or mesh?
Here is an example of an obj file, maybe I’m doing something wrong by converting
test.obj (3.0 MB)

It appears that the obj2gltf tool does not include support for vertex colors yet:

Another option would be to open the OBJ file in three.js editor, export to .glb, and add Draco compression after that. Blender could also be used.

Yes, thanks, I found it recently. Can you navigate me please which script is used to export to glTF (glb) in the Editor? I want to try the same

No script, just FileExport GLB

I want to use it on the server side to convert Obj to Glb. So I find the solution to this. I found GLTFExporter.js and want to make a nodeJS script. How to use three with node js? Maybe there is documentation somewhere? I can’t deal with imports and modules. I get errors.
Maybe there is a version of Three.js that is compatible with NodeJS?

The three.js library does not offer Node.js support, no, the library is meant for the web. It is certainly possible to fork the loaders and exporters, so that they use Node.js APIs instead of Browser APIs (for things like image loading), but I’m not aware of any thorough guides on the subject.

1 Like