Why does serialization of primitives use vertexData and not geometries?

I noticed (Save Your Scene or Meshes | Babylon.js Documentation) that when serializing a scene, that even if that scene only contains geometric “primitives” like a box, sphere or plane, etc, that the serialized JSON ‘expands’ these primitives into verbose vertexData. While it looks like the serialization format contains a space for geometries

"geometries":{"boxes":[],"spheres":[],"cylinders":[],"toruses":[],"grounds":[],"planes":[],"torusKnots":[]

it appears not to be used.

I’m just wondering why that is? Wouldn’t it have been more efficient to avoid describing vertices, normals, uvs, indices for well known primitives since babylon and most systems know what boxes, cylinders etc, are?

Great question!

I was not here when those decisions were made, but I can only assume this is due to the fact that we don’t save the metadata used to create those primitives. We don’t have this data when serializing the primitive (mesh), so the only thing that can be exported is the vertex data.
That, and the fact that even though it’s a box, it could have been modified by the user (for example - baked transformation).

Exactly.

The geometries are used mostly by exporters (3dsmax, etc)

Hi @owen just checking in, was your question answered? :slight_smile:

Yes. Thanks for asking!

1 Like