My latest project involved creating a tool to analyze the lengths and angles of faces on a 3D object. However, after updating to version r67 of Three.js, I encountered an issue where Face4 disappeared and I struggled to replicate my previous work. Specifically, the code snippet n = (f instanceof THREE.Face3) ? 3 : 4 allowed me to add 4 uv's to Face4. Yet, I am now unable to discern when a Face4 would have existed so that I can add 2 Face3 instead.
Below is a snippet of code that showcases a function designed to work with the geometry of the object:
function draw(g)
{
objectContainer = new THREE.Object3D();
texture = THREE.ImageUtils.loadTexture('uvmap.png');
texture.flipY = false;
materials = [];
materials.push(new THREE.MeshLambertMaterial({
map: texture,
vertexColors: THREE.VertexColors
}));
var faceIndices = ['a','b','c','d'];
var color = new THREE.Color(0xffffff);
color.setHex(0x333333);
var uvs = [];
uvs.push(new THREE.Vector2(0,1));
uvs.push(new THREE.Vector2(0,0));
uvs.push(new THREE.Vector2(1,1));
uvs.push(new THREE.Vector2(1,0));
for (i = 0; i < g.faces.length; i++)
{
face = g.faces[i];
geo = new THREE.Geometry();
geo.faces.push(new THREE.Face3(0,1,2));
geo.faceVertexUvs[0] = [];
geo.faceVertexUvs[0].push([uvs[0], uvs[1], uvs[3]]);
geo.faces[0].materialIndex = 0;
for (j = 0; j < 3; j++)
{
fi = face[faceIndices[j]];
v = g.vertices[fi];
geo.vertices.push(new THREE.Vector3(v.x,v.y,v.z));
geo.faces[0].vertexColors[j] = color;
}
geo.computeVertexNormals();
geo.computeBoundingBox();
obj = new THREE.SceneUtils.createMultiMaterialObject(geo, materials);
objectContainer.add(obj);
}
scene.add(objectContainer);
}