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

标签 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
    },
    .....
 }

但这破坏了 gltf。

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

最佳答案

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

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

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

此外,不要忘记在属性后加上逗号——此更改必须是有效的 JSON。

关于gltf - 如何在 gltf 文件上添加元数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57073016/

相关文章:

javascript - 在 Three.js 中将 glTF 对象设置为不同的层时遇到问题

c# - 在 Xamarin Android 项目上使用 glTF C# 加载器

javascript - 无法使用 ThreeJS 和 React 导入 3D 模型

three.js - 导出为 GLTF 时,为什么 blender 操纵的动画会失真?

javascript - 如何向 GLTF 模型添加光泽度/镜面纹理?

glTF 2.0 中节点和子项中的条目之间的关系

assimp - 如何使用 gltf 格式通过 Assimp 加载粗糙度/金属贴图?

node.js - 我们可以在服务器端编辑(位置、比例等)glTF 模型(无需 Three.js)吗?

c# - 了解 OpenGL 引擎的 GLTF2.0 文件的蒙皮部分