jkuhlmann / cgltf

:diamond_shape_with_a_dot_inside: Single-file glTF 2.0 loader and writer written in C99
MIT License
1.44k stars 136 forks source link

Add perspective camera aspect ratio and zfar property flags #141

Closed jmousseau closed 3 years ago

jmousseau commented 3 years ago

The perspective camera's aspectRatio and zfar are both optional. Previously, if you ran test_write on

{
    "asset": {
        "version": "2.0"
    },
    "cameras": [
        {
          "type": "perspective",
          "perspective": {
            "yfov": 0.5,
            "znear": 0.01
          }
        }
    ]
}

it would treat the aspect ratio and zfar both as zero

{
  "asset": {
    "version": "2.0"
  },
  "cameras": [
    {
      "type": "perspective",
      "perspective": {
        "aspectRatio": 0,
        "yfov": 0.5,
        "zfar": 0,
        "znear": 0.00999999978
      }
    }
  ]
}

With this change, test_write will produce

{
  "asset": {
    "version": "2.0"
  },
  "cameras": [
    {
      "type": "perspective",
      "perspective": {
        "yfov": 0.5,
        "znear": 0.00999999978
      }
    }
  ]
}