【问题标题】:Three.js - What's wrong with this blender exported object?Three.js - 这个搅拌机导出的对象有什么问题?
【发布时间】:2015-08-14 03:31:10
【问题描述】:

我正在从搅拌机中的较大模型中导出单个片段,其中一些对象会引发一些错误并且无法加载。以下是错误:

Uncaught TypeError: Cannot read property 'attributes' of undefined
Uncaught TypeError: Cannot read property 'transparent' of undefined

以下是 blender 中一个不起作用的 json 文件的要点:https://gist.githubusercontent.com/jtmkrueger/7b46cf68975be7d27d67/raw/31be5d92c0749d55bcff61822aaec42985f20205/charger.json

json 文件 lints 正确,来自同一模型的其他对象加载正常。我不确定这个特定的有什么问题。

这是我加载 json 的代码:

  App.JsonLoader.load(mesh, function (geometry, materials) {
    var componentMesh = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(materials));
    componentMesh.scale.set(50, 50, 50);
    componentMesh.position.y = 50;
    componentMesh.position.x = 0;

    App.vehicle.object3d.add(componentMesh);
  });

【问题讨论】:

    标签: javascript json three.js


    【解决方案1】:

    编辑:这个答案不再相关


    您的模型不包含 materials 属性,该属性将被传递到 MeshFaceMaterial。错误信息的第 2 行显示 Three 在 materials 中寻找 transparent,但未定义。

    您可以:

    1. 抛弃 new THREE.MeshFaceMaterial(materials) 并构建自己的材质。

    2. 在您的模型中包含materials

    Here 是一个包含materials 的模型示例。

    【讨论】:

    猜你喜欢
    • 2015-06-23
    • 2013-09-28
    • 2017-04-18
    • 2014-08-19
    • 2015-08-16
    • 1970-01-01
    • 2015-08-24
    • 2018-10-01
    • 2022-06-22
    相关资源
    最近更新 更多