我目前正在尝试将3D几何图形导出到GlTF,但遇到一个我不理解的错误。在一个描述简单灰色立方体的文件中,我在法线访问器上得到了它:
[glTF Validator] Accessor element at index 2 is not of unit length: 0.
[glTF Validator] Accessor element at index 5 is not of unit length: 0.
[glTF Validator] Accessor element at index 8 is not of unit length: 0.
[glTF Validator] Accessor element at index 11 is not of unit length: 0.
[glTF Validator] Accessor element at index 14 is not of unit length: 0.
[glTF Validator] Accessor element at index 17 is not of unit length: 0.
[glTF Validator] Accessor element at index 20 is not of unit length: 0.
[glTF Validator] Accessor element at index 23 is not of unit length: 0.
这是json:
{
"accessors": [
{
"bufferView": 0,
"byteOffset": 0,
"componentType": 5123,
"normalized": false,
"count": 36,
"type": "SCALAR",
"name": "31546_indices"
},
{
"bufferView": 1,
"byteOffset": 0,
"componentType": 5126,
"normalized": false,
"count": 8,
"type": "VEC3",
"max": [
32.808,
32.808,
32.808
],
"min": [
0.0,
0.0,
0.0
],
"name": "31546_vertices"
},
{
"bufferView": 2,
"byteOffset": 0,
"componentType": 5126,
"normalized": false,
"count": 8,
"type": "VEC3",
"name": "31546_normals"
},
{
"bufferView": 3,
"byteOffset": 0,
"componentType": 5126,
"normalized": false,
"count": 8,
"type": "VEC3",
"name": "31546_color"
}
],
"asset": {
"version": "2.0"
},
"buffers": [
{
"uri": "31546.bin",
"byteLength": 360,
"name": "31546"
}
],
"bufferViews": [
{
"buffer": 0,
"byteOffset": 0,
"byteLength": 72,
"name": "31546_indices"
},
{
"buffer": 0,
"byteOffset": 72,
"byteLength": 96,
"name": "31546_vertices"
},
{
"buffer": 0,
"byteOffset": 168,
"byteLength": 96,
"name": "31546_normals"
},
{
"buffer": 0,
"byteOffset": 264,
"byteLength": 96,
"name": "31546_color"
}
],
"meshes": [
{
"primitives": [
{
"attributes": {
"POSITION": 1,
"NORMAL": 2,
"COLOR_0": 3
},
"indices": 0,
"mode": 4
}
],
"name": "31546"
}
],
"nodes": [
{
"mesh": 0
}
],
"scene": 0,
"scenes": [
{
"nodes": [
0
],
"name": "RNT_Viewport"
}
]
}
我不明白验证器在谈论3以上的访问器,因为只有4个访问器...为了实现这一点,我使用了Visual代码的GlTF插件。对于Khronos在线验证器,JSON看起来是正确的(https://github.khronos.org/glTF-Validator/),所以在这一点上,我真的不知道我的错误在哪里...
提前感谢您的见解:)
答案 0 :(得分:1)
在这里,您抱怨JSON引用的31546.bin
文件中的二进制数据。如果您在“文档问题”窗口中单击消息之一,它将使光标聚焦在有问题的访问器上(然后我会弯腰,猜测是索引2的访问器,名为31546_normals
,因为这看起来应该是该模型中唯一要标准化的)。
这些消息中报告的实际索引值是此访问器中包含的数据的索引。在VSCode中,选择正确的访问器后,按 ALT + d 将二进制数据解码为文本缓冲区,以将其检查为文本。
我对这里发生的事情的猜测是您的模型中有一些零长度的法向向量。如果将零长度向量应用于退化三角形,这并不是一个大问题,但是,这种事情充其量只是浪费了可以删除的bin文件中的空间,因此验证器会警告它。
如果要在其他工具(例如Blender或Maya)中编辑此模型,则可以选择查找和删除退化的三角形,然后重新计算法向矢量。这可能会摆脱零长度法线。