Blender JSON exporter is duplicating vertices.

I noticed that there is an unnecessary repetition of vertices in the output when exporting from blender to JSON in BufferGeometry format.

Consider the following cube example:
cubeflat
When I export it using type: Buffergeometry, I get a 1.8 kb file with 34 vertices:

"metadata":{
    "normal":34,
    "position":34,
    "version":3,
    "type":"BufferGeometry",
    "generator":"io_three"
}

see full output for flat cube

However, when I smooth out the faces, like this…
cubesmooth

… I get a much more reasonable output with only eight vertices, and a 0.9 kb file:

"metadata":{
    "normal":8,
    "position":8,
    "version":3,
    "type":"BufferGeometry",
    "generator":"io_three"
}

see full output for smooth cube

Why does the flat cube get 34 vertices, instead of the expected 8? Shouldn’t the flattening be handled in the normals instead of by making all faces separate? When I export a flat cube using the type: Geometry setting, I get 8 vertices and 6 normals, so it seems that it’s possible.

System Specs:
  • [ x ] Windows
  • [ x ] Blender 2.78a
  • [ x ] io_three version: (1, 5, 0)
  • Exporter settings:
    settings

    • Enabled precision to 2

Author: Fantashit

1 thought on “Blender JSON exporter is duplicating vertices.

  1. In BufferGeometry, a vertex can only be reused if the vertex and all the attributes for that vertex are identical.

    Since each corner of the box has 3 different normals, the fewest number of vertices you could possibly have for a box with orthogonal normals is 8 x 3 = 24.

    With 12 triangles, the max is 12 x 3 = 36 vertices. So you are sharing 2. To determine why that is happening, you will have to step through with a debugger.

Comments are closed.