首页 > 解决方案 > How to add metadata on a gltf file?

问题描述

I have a gltf that is a set of building.

I would like to add some information on each building, and for this, I need to add some properties to my gltf models.

But, I tried to add something like this

{
  "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
    },
    .....
 }

but this break the gltf.

how do I add some metadata to gltf ?

标签: gltf

解决方案


The glTF specification allows metadata to be attached to objects through an extras property:

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

"extras" : { "description" : "my description 2" } 

In addition, don't forget to include a comma after the property – this change must be valid JSON.


推荐阅读