如何在 gltf 文件上添加元数据?

Cro*_*csx 2 gltf

我有一个 gltf,它是一套建筑。

我想添加有关每个建筑物的一些信息,为此,我需要向我的 gltf 模型添加一些属性。

但是,我尝试添加这样的东西

{
  "accessors": [
    {
      "name": "object_1_1_0_positions",
      "componentType": 5126,
      "count": 4,
      "min": [
        -232.96347045898438,
        3.5689821243286133,
        -204.4241485595703
      ],
      "max": [
        -230.46347045898438,
        35.427982330322266,
        -204.4241485595703
      ],
      "properties" : { "description" : "my description 1" } 
      "type": "VEC3",
      "bufferView": 0,
      "byteOffset": 0
    },
    {
      "name": "object_1_1_0_normals",
      "componentType": 5126,
      "count": 4,
      "min": [
        -0.1212499663233757,
        0,
        0.9926220178604126
      ],
      "max": [
        -0.1212499663233757,
        0,
        0.9926220178604126
      ],
      "properties" : { "description" : "my description 2" } 
      "type": "VEC3",
      "bufferView": 1,
      "byteOffset": 0
    },
    .....
 }
Run Code Online (Sandbox Code Playgroud)

但这打破了 gltf。

如何向 gltf 添加一些元数据?

Don*_*rdy 7

glTF 规范允许通过属性将元数据附加到对象extras

\n

https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#reference-extras

\n
"extras" : { "description" : "my description 2" } \n
Run Code Online (Sandbox Code Playgroud)\n

另外,不要忘记在属性 \xe2\x80\x93 之后添加逗号,此更改必须是有效的 JSON。

\n