Need help - VRML Parser
nicrf opened this issue · 1 comments
Hi,
I try to build an VRML parser for xeogl from Threejs & bartmcleod is Vrml parser. I stock on IndexedFaceSet , here is my trie (full source) :
`
if (data.node === 'IndexedFaceSet') {
var normals = data.normalIndex;
var colors = data.colorIndex;
var positions = [];
var indices;
for (var i = 0; i < data.coord.point.length; i ++ ) {
positions.push(data.coord.point[i].x,data.coord.point[i].y,data.coord.point[i].z);
}
if (data.ccw === undefined )
data.ccw = true;
indices = data.coordIndex.toString().split(",");
if (data.coordIndex) {
indices = data.coordIndex.toString().split(",");
} else {
indices = new Int32Array(positions.length / 3);
for (var ni = 0, len = indices.length; ni < len; ni++) {
indices[ni] = ni;
}
}
if ( data.normalIndex) {
normals = data.normalIndex;
} else {
normals = indices;
}
colors = colors && colors.length > 0 ? colors : null;
if (false) {
xeogl.math.faceToVertexNormals(positions, normals);
}
var primitive = "triangles";
if (data.solid && data.solid===true )
primitive = "triangle-strip";
return new xeogl.Geometry(model, {
primitive: primitive,
positions: positions,
//normals: normals,
// autoVertexNormals: !normals,
//colors: colors,
indices: indices
});
} `
Can you help me with that?
Hi,
I don't know why, but the normal calculation seen not working with me?
Also, can we get a tree of Group class? One of my problem is VRML can be use tree hierarchy, but when I parse it, they don't are present in group.
function parseNode(data,parent,model) { console.log("Parse an node " + data.node); if (data.name) { console.log("Parse an node " + data.name); } var object = parent; switch(data.node) { case 'Transform' : case 'Group' : object = new xeogl.Group(); //... } if (data.children) { for ( var i = 0, l = data.children.length; i < l; i ++ ) { parseNode( data.children[ i ], object,model ); } }