icosa-foundation / icosa-gallery

Icosa Gallery is a 3D model hosting solution, intended as a replacement for Google's Poly
https://icosa.gallery
5 stars 0 forks source link

Poly API - triangle count #16

Open andybak opened 3 weeks ago

andybak commented 3 weeks ago

Low priority for now but the code expects us to store tri count for uploaded models:

            var gltfFormat = json["formats"].First(x => x["format"].ToString() == "GLTF");
            string gltfTriCount = gltfFormat?["formatComplexity"]?["triangleCount"]?.ToString();
            if (gltfTriCount == null)
            {
                Debug.Log($"{m_AssetId} has no tricount");
            }
            m_GltfTriangleCount = Int32.Parse(gltfTriCount ?? "1");

I can see this being useful metadata in any case - and it's fairly simple to extract from an existing GLTF. For example this file has got 2414688 indices and therefore 804896 triangles.

  "bufferViews": [
    {
      "buffer": 0,
      "byteLength": 7244064,
      "name": "positions",
      "target": 34962,
      "byteOffset": 0
    },
    {
      "buffer": 0,
      "byteLength": 4829376,
      "byteOffset": 7244064,
      "name": "texCoords",
      "target": 34962
    },
    {
      "buffer": 0,
      "byteLength": 7244064,
      "byteOffset": 12073440,
      "name": "color_0",
      "target": 34962
    },
    {
      "buffer": 0,
      "byteLength": 2414688,
      "byteOffset": 19317504,
      "name": "indices",
      "target": 34963
    }
  ]

I think there should only ever be one entry where name="indices" ( @mikeskydev - does that sound right to you? )