三个Js搅拌机出口商出口格式错误

时间:2015-01-21 23:07:03

标签: javascript json three.js

我正在尝试使用提供的blender exporter将blender模型导出到threejs json。在解析json文件时,我收到一个错误:

Uncaught TypeError: Cannot read property 'length' of undefined

json文件如下所示(省略顶点和面):

{
    "textures": [],
    "metadata": {
        "version": 4.3,
        "sourceFile": "UV-World.blend",
        "type": "Object",
        "generator": "io_three"
    },
    "images": [],
    "materials": [],
    "object": {
        "matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],
        "children": [{
            "type": "Mesh",
            "name": "Kugel",
            "uuid": "5051D840-9982-4F9A-8CFF-36303B38E091",
            "position": [0.0,0.0,0.0],
            "rotation": [-1.5707964897155762,0.0,0.0],
            "scale": [1.0,0.9999999403953552,0.9999999403953552],
            "visible": true,
            "castShadow": true,
            "receiveShadow": true,
            "geometry": "DEAE2CE2-9824-4F91-BE4C-1C80BEDC566A"
        }],
        "type": "Scene",
        "uuid": "8C543616-2AB0-4D1D-B76D-549E32A0E468"
    },
    "geometries": [{
        "type": "Geometry",
        "data": {
            "name": "KugelGeometry",
            "metadata": {
                "version": 3,
                "faces": 512,
                "vertices": 482,
                "generator": "io_three"
            },
            "vertices": [...],
            "faces": [...]
        },
        "uuid": "DEAE2CE2-9824-4F91-BE4C-1C80BEDC566A"
    }]
}

这似乎不在format that threejs expects中。如果我手动将json更改为以下threejs解析并按预期显示模型。

{
    "scale": 1,
    "vertices": [...],
    "faces": [...]
}

导出和导入/从obj按预期工作。

由于我找不到任何人也遇到此问题,我猜这是一个使用错误。我是搅拌机的新手,所以也许我在那里做错了什么?我正在使用Blender 2.73a和从存储库中克隆的threejs。

2 个答案:

答案 0 :(得分:8)

我怀疑您使用的是JSONLoader。请尝试使用ObjectLoader

答案 1 :(得分:0)

如果您想使用JSONLoader,请取消选中 scene 选项。然后,您将拥有一个单一的网格JSON文件。

enter image description here