var geo=new THREE.Geometry();
for(var i=0;i<_vertex.length;i++){
var _n=_vertex[i]; //_vertex顶点数组:[[x1,y1,z1],[x2,y2,z2]...]
geo.vertices.push(new THREE.Vector3(_n[0],_n[1],_n[2]));
}
for(var i=0;i<_faces.length;i++){
var _n=_faces[i]; //_faces面数组[[1,2,3],[4,5,6]]
geo.faces.push(new THREE.Face3(_n[0],_n[1],_n[2]));
}
geo.computeFaceNormals();
geo.computeVertexNormals();
geo.computeBoundingSphere();
var mesh=new THREE.Mesh(geo,phongMtr);
当phongMtr不含有纹理贴图时,则没有问题:
phongMtr = new THREE.MeshPhongMaterial({"color":0xffffff,"specular":0xffffff,"shininess":10});
一旦引入纹理贴图,即下段代码,就会报错。
var _map = THREE.ImageUtils.loadTexture("../../static/3d/mtr01.jpg");
phongMtr = new THREE.MeshPhongMaterial({"color":0xffffff,"specular":0xffffff,"shininess":10,"map":_map});
错误信息:
Error: WebGL: texImage2D: Conversion requires pixel reformatting. three.min.js:561:283
Error: WebGL: drawElements: bound vertex attribute buffers do not have sufficient size for given indices from the bound element array three.min.js:552:87
Error: WebGL: No further warnings will be reported for this WebGL context. (already reported 32 warnings)