我正在尝试在Three.js中合并网格。网格是从Blender导出的COLLADA模型中加载的。这是不合并而加载的模型:
我认为我在材质UV方面遇到问题,因为我收到288条警告消息,例如:
THREE.DirectGeometry.fromGeometry(): Undefined vertexUv 99945
该数字从99945到100232。
这是我用来合并网格物体的代码:
loader.load(modelPath, function(model)
{
var modelShape = model.scene;
var materialsArray = new Array();
var mergedGeometry = new THREE.Geometry();
var materialIndex = 0;
modelShape.traverse(function(mesh)
{
if(mesh instanceof THREE.Mesh && typeof mesh.material !== "undefined")
{
var modelGeometry = new THREE.Geometry().fromBufferGeometry(mesh.geometry);
modelGeometry.mergeVertices();
mergedGeometry.merge(modelGeometry, mesh.matrix, materialIndex);
materialsArray[materialIndex] = mesh.material;
materialIndex++;
}
});
mergedGeometry.mergeVertices();
mergedGeometry.rotateX(-90 * Math.PI / 180);
var modifier = new THREE.SubdivisionModifier(subdivisions);
var geometrySmoothed = mergedGeometry;
mergedGeometry.groupsNeedUpdate = true;
mergedGeometry.uvsNeedUpdate = true;
var mesh = new THREE.Mesh(geometrySmoothed, materialsArray);
this.models.push(mesh);
}
那么,有人知道错误在哪里吗?从Blender导出会出错吗?