I had some problems with certain faces of my models disappearing when they clearly were still partly in the view.
After some debugging i noticed that the min and max vectors of the disappearing Mesh were incorrect and caused Away to think that the mesh wasn’t on screen.
One of them was a Blender made plane shape of 30 by 20 units and pivot in the center. I noticed that the minX and maxX were both negative.
Depending on the order of vertices this bounding box code in BoundingVolumeBase.fromGeometry() can produce faulty results.
minX = minY = minZ = Number.POSITIVE_INFINITY;
maxX = maxY = maxZ = Number.NEGATIVE_INFINITY;
while( j < lenS ) {
vertices = subs[j++].vertexData;
lenV = vertices.length;
i = 0;
while( i < lenV ) {
v = vertices[i++];
if( v < minX ) minX = v;
else if( v > maxX ) maxX = v;
v = vertices[i++];
if( v < minY ) minY = v;
else if( v > maxY ) maxY = v;
v = vertices[i++];
if( v < minZ ) minZ = v;
else if( v > maxZ ) maxZ = v;
}
}
I think it’s clear that if any of the vertice coordinates has it’s highest value in the first vertex (ie. the first vertex has an X of 1 and all other vertices have a smaller X) that highest value doesn’t get stored in the maxX.
Removing all the “else” words fixes the bug and my polygons show as expected.
I don’t know much about the format of vertex data in 3D models, so if there’s something I’m not getting, please let me know Otherwise i’ll file a bug soon.