Game Development Reference
In-Depth Information
The following code checks whether it has the face color and then reads and stores the
index of the color array. Each face will have a color:
if ( hasFaceColor ) {
colorIndex = faces[ offset++ ];
face.colorIndex = colorIndex;
}
The following code checks whether it has vertex colors and then reads and stores
the color array's indices for each vertex of the face. Every vertex of the face will have
a color:
if ( hasFaceVertexColor ) {
for ( i = 0; i < nVertices; i++ ) {
colorIndex = faces[ offset++ ];
face.vertexColors.push( colorIndex );
}
}
faceArray.push( face );
}
The following function, getIndicesFromFaces() , iterates over the faces array and
populates the indices array:
return faceArray;
}
function getIndicesFromFaces(faces){
var indices=[];
for(var i=0;i<faces.length;++i){
indices.push(faces[i].a);
indices.push(faces[i].b);
indices.push(faces[i].c);
}
return indices;
}
This JSON array format discussed here is not an industry
standard. This format was created by developers of three.js
(a WebGL library). This JSON format is capable of storing
objects as well as the complete scene.
 
Search WWH ::




Custom Search