Как использовать несколько буферов в GLTF 2.0? - PullRequest
0 голосов
/ 17 октября 2019
  • Я пытаюсь использовать несколько буферов для включения разных файлов bin (один для данных геометрии, один для данных анимации), но файл bin анимации в buffers1 не работает в Babylonjs [ Uncaught TypeError: Не удается прочитать свойство'frame' of undefined ].
  • Мои вопросы: есть ли что-то не так в моем файле gltf? Как использовать несколько файлов bin в GLTF? Ниже приведен мой полный файл gltf:
  • И файлы bin
{
  "accessors": [
    {
      "bufferView": 0,
      "componentType": 5126,
      "count": 24,
      "type": "VEC3",
      "max": [
        0.3,
        0.3,
        0.3
      ],
      "min": [
        -0.3,
        -0.3,
        -0.3
      ],
      "name": "Positions Accessor"
    },
    {
      "bufferView": 1,
      "componentType": 5126,
      "count": 24,
      "type": "VEC3",
      "name": "Normals Accessor"
    },
    {
      "bufferView": 2,
      "componentType": 5126,
      "count": 24,
      "type": "VEC2",
      "name": "UV Accessor 0"
    },
    {
      "bufferView": 3,
      "componentType": 5125,
      "count": 36,
      "type": "SCALAR",
      "name": "Indices Accessor"
    },
    {
      "bufferView": 4,
      "componentType": 5126,
      "count": 3,
      "type": "SCALAR",
      "max": [
        2.0
      ],
      "min": [
        0.0
      ],
      "name": "Animation Sampler Input"
    },
    {
      "bufferView": 5,
      "componentType": 5126,
      "count": 3,
      "type": "VEC3",
      "name": "Animation Sampler Output"
    }
  ],
  "animations": [
    {
      "channels": [
        {
          "sampler": 0,
          "target": {
            "node": 0,
            "path": "translation"
          }
        }
      ],
      "samplers": [
        {
          "input": 4,
          "output": 5
        }
      ]
    }
  ],
  "asset": {
    "generator": "glTF Asset Generator",
    "version": "2.0"
  },
  "buffers": [
    {
      "uri": "Test_Geometry.bin",
      "byteLength": 912
    },
    {
      "uri": "Test_Animation.bin",
      "byteLength": 48
    }
  ],
  "bufferViews": [
    {
      "buffer": 0,
      "byteLength": 288,
      "name": "Positions"
    },
    {
      "buffer": 0,
      "byteOffset": 288,
      "byteLength": 288,
      "name": "Normals"
    },
    {
      "buffer": 0,
      "byteOffset": 576,
      "byteLength": 192,
      "name": "Texture Coords 0"
    },
    {
      "buffer": 0,
      "byteOffset": 768,
      "byteLength": 144,
      "name": "Indices"
    },
    {
      "buffer": 1,
      "byteLength": 12,
      "name": "Animation Sampler Input"
    },
    {
      "buffer": 1,
      "byteOffset": 12,
      "byteLength": 36,
      "name": "Animation Sampler Output"
    }
  ],
  "images": [
    {
      "uri": "Test/MultipleBuffers.png"
    }
  ],
  "materials": [
    {
      "pbrMetallicRoughness": {
        "baseColorTexture": {
          "index": 0
        }
      }
    }
  ],
  "meshes": [
    {
      "primitives": [
        {
          "attributes": {
            "POSITION": 0,
            "NORMAL": 1,
            "TEXCOORD_0": 2
          },
          "indices": 3,
          "material": 0
        }
      ]
    }
  ],
  "nodes": [
    {
      "mesh": 0
    }
  ],
  "scene": 0,
  "scenes": [
    {
      "nodes": [
        0
      ]
    }
  ],
  "textures": [
    {
      "source": 0
    }
  ]
}

...