从Blender导出面部和面部材料三个.js

时间:2017-06-26 08:35:10

标签: json three.js blender

我正在尝试将Blender设计的网格导入到three.js项目中。

我添加了io_three插件,我现在可以导出Blender的json文件。

当我尝试加载网格物体(使用THREE.JSONLoader)时,我从三个.min.js的第684行得到一个“未捕获的TypeError:无法读取未定义的属性'长度” - 这听起来就像一个数组未定义。

我已经读过,在Blender中,应该在three.js导出器中检查'face materials'复选框,但对我来说,该选项是灰色的。另外我注意到,在三个导出器的“几何”部分中,导出面部的选项未选中并且显示为灰色。我怀疑这是问题,但为什么我无法检查这些复选框?

有没有人有任何想法为什么Blender可能会阻止我在three.js导出器中启用“面部材料”和“面孔”选项?

修改
为了完整起见,这里是我用来加载网格的代码:

var loader = new THREE.JSONLoader();
// load a resource
loader.load( 'assets/meshes/cube.json', function ( geometry ) {
        var material = new THREE.MeshLambertMaterial( { color: 0x006666 } );
        mesh = new THREE.Mesh(geometry, material);
        scene.add( mesh );
    }
)

cube.json文件确实位于assets / mesh文件夹中 我也尝试将其加载为'cube.js'(改变Windows中的文件扩展名),但我想解决的初始问题是从Blender导出的问题。谢谢。

这是不玩球的cube.json文件......

{
    "data":{
        "index":{
            "type":"Uint16Array",
            "array":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35],
            "itemSize":1
        },
        "attributes":{
            "uv":{
                "type":"Float32Array",
                "array":[1,0,0,1,0,0,0.999999,1,0,0,1,0,0.999999,1,0,0,1,0,0.999999,1,0,0,1,0,1,0,0,1,0,0,0.999999,1,0,0,1,0,1,0,0.999999,1,0,1,0.999999,1,0,1,0,0,0.999999,1,0,1,0,0,0.999999,1,0,1,0,0,1,0,0.999999,1,0,1,0.999999,1,0,1,0,0],
                "itemSize":2
            },
            "normal":{
                "type":"Float32Array",
                "array":[-7.10543e-15,-1,2.98023e-08,-7.10543e-15,-1,2.98023e-08,-7.10543e-15,-1,2.98023e-08,7.10543e-15,1,-2.98023e-08,7.10543e-15,1,-2.98023e-08,7.10543e-15,1,-2.98023e-08,1,-2.38419e-07,7.10543e-15,1,-2.38419e-07,7.10543e-15,1,-2.38419e-07,7.10543e-15,-5.96046e-08,-2.98023e-07,1,-5.96046e-08,-2.98023e-07,1,-5.96046e-08,-2.98023e-07,1,-1,-1.49012e-07,-2.38419e-07,-1,-1.49012e-07,-2.38419e-07,-1,-1.49012e-07,-2.38419e-07,2.38419e-07,1.78814e-07,-1,2.38419e-07,1.78814e-07,-1,2.38419e-07,1.78814e-07,-1,-1.77636e-15,-1,2.98023e-08,-1.77636e-15,-1,2.98023e-08,-1.77636e-15,-1,2.98023e-08,1.5099e-14,1,-2.98023e-08,1.5099e-14,1,-2.98023e-08,1.5099e-14,1,-2.98023e-08,1,3.27825e-07,5.66244e-07,1,3.27825e-07,5.66244e-07,1,3.27825e-07,5.66244e-07,-5.0664e-07,1.49012e-07,1,-5.0664e-07,1.49012e-07,1,-5.0664e-07,1.49012e-07,1,-1,-1.19209e-07,-2.08616e-07,-1,-1.19209e-07,-2.08616e-07,-1,-1.19209e-07,-2.08616e-07,2.38419e-07,1.78814e-07,-1,2.38419e-07,1.78814e-07,-1,2.38419e-07,1.78814e-07,-1],
                "itemSize":3
            },
            "position":{
                "type":"Float32Array",
                "array":[1,-1,-1,-1,-1,1,-1,-1,-1,-1,1,-1,0.999999,1,1,1,1,-1,1,1,-1,1,-1,1,1,-1,-1,0.999999,1,1,-1,-1,1,1,-1,1,-1,-1,1,-1,1,-1,-1,-1,-1,1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,0.999999,1,1,1,1,-1,0.999999,1,1,1,-1,1,0.999999,1,1,-1,1,1,-1,-1,1,-1,-1,1,-1,1,1,-1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1],
                "itemSize":3
            }
        }
    },
    "metadata":{
        "normal":36,
        "type":"BufferGeometry",
        "uv":36,
        "generator":"io_three",
        "position":36,
        "version":3
    }
}

1 个答案:

答案 0 :(得分:0)

在cube.json中将其类型声明为" BufferGeometry"

如果您为THREE.BufferGeometryLoader交换THREE.JSONLoader,它可以正常工作 enter image description here

var loader = new THREE.BufferGeometryLoader();
        loader.load("cube.json", function (g) {
            var mesh = new THREE.Mesh(g, new THREE.MeshBasicMaterial({color:0xffffff}));
            scene.add(mesh);
        });