Hi,
I’m trying parsing mesh with AS3 Worker.
It’s based on MeshSave class.
https://github.com/nixxle/Away3DAdds/blob/master/com/nixxle/away3d/MeshSave.as3
I convert a Mesh to an Object through this class for receiving from parsing worker.
Separated SubGeometry is OK.
And I add some functions for Compact one.
Attached image is results of addChild on same 3d model.
the Compact seems having a problem on index buffer.
So, If you know about constructing CompactSubGeo by code,
tell me what is the problem.
I’m working on latest dev.
Thanks.
[In Worker thread:]
public static function meshToObjectWithCompactSubGeo(mesh:Mesh):Object
{
if(!mesh.geometry)
return {};
var m:Object = {geometry:{subGeometries:[]}, position:{x:mesh.position.x, y:mesh.position.y, z:mesh.position.z}};
for each(var g:CompactSubGeometry in mesh.geometry.subGeometries)
{
m.geometry.subGeometries.push(compactSubGeometryToObject(g));
}
return m;
}
public static function compactSubGeometryToObject(s:CompactSubGeometry):Object
{
return {
vertices:s.vertexData,
uvs:s.UVData,
vertexNormals:s.vertexNormalData,
vertexTangents:s.vertexTangentData,
indices:s.indexData
}
}
[In Main thread:]
public static function objectToMeshWithCompactSubGeo(obj:Object):Mesh
{
var geo:Geometry = new Geometry();
var subGeo:CompactSubGeometry;
for each(var subObj:Object in obj.geometry.subGeometries)
geo.addSubGeometry(objectToCompactSubGeometry(subObj));
var mesh:Mesh = new Mesh(geo);
return mesh;
}
public static function objectToCompactSubGeometry(obj:Object):CompactSubGeometry
{
var s:CompactSubGeometry = new CompactSubGeometry();
s.updateData(GeometryUtil.interleaveBuffers(uint(obj.vertices.length/3), obj.vertices, obj.vertexNormals, obj.vertexTangents, obj.uvs, obj.uvs));
s.updateIndexData(Vector.<uint>(obj.indices));
return s;
}