javascript - Threejs blender 导出器以错误的格式导出

标签 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 的新手,所以也许我在那里做错了什么?我正在使用 Blender 2.73a 和刚刚从存储库中克隆的 threejs。

最佳答案

我怀疑您正在使用 JSONLoader。尝试改用 ObjectLoader

关于javascript - Threejs blender 导出器以错误的格式导出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28078556/

相关文章:

javascript - CSS3D矩阵生成

javascript - 在 Google map 街景 View 中绘制多段线

javascript - 使用await 与react-native 不起作用

javascript - 如何在 indexedDB 中存储 JSON 对象?

javascript - 如何访问以@ 符号作为对象名称的 Json 对象?

javascript - 无法访问从 $http.post 接收的 JSON 文件中的值

python - 立即转义整个字典/JSON

javascript - 如何在 Three.js 中加载 .x 模型?

javascript - 将 z-index 设置为传单中的图层控件

javascript - 更新 Vue 出现错误 window.Vue.use is not a function