改变面部组的颜色

时间:2014-05-21 10:33:29

标签: json import three.js geometry

我知道可以从加载/导入的对象中更改面的颜色。但我想知道在搅拌机中是否有模型(将以JSON格式或OBJ导出)制作一组面并在运行时更改颜色。这个解决方案用于避免纹理,因为我的几何图形非常简单。

1 个答案:

答案 0 :(得分:3)

如果使用JSON,您基本上可以将材料从Blender中导出。如果操作MeshFaceMaterials,则操纵链接到网格组的材质。

Blender的JSON导出包括网格组的材质。您可以在jsonLoader的回调函数中操作它们。

var mesh;

jsonLoader.load( url, function( geometry, materials ) {
  mesh = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ) );

  /*
    The MeshFaceMaterial contains the exported materials from blender.
    If you manipulate one entry of the material array, every object that uses
    this material, will display the changes.
  */
  mesh.material.materials[0].color.setHex(0xff0000);

  scene.add( mesh );
});
相关问题