I’m using Away3D 4 to load MD2 model files in my project and found some small model files were not loaded correctly because event AssetEvent.ASSET_COMPLETE was not dispatched for event type ‘AssetType.MESH’.
After doing some researching, I found there is a potential bug in function proceedParsing() of MD2Parser.as. The problem is, if the function executes too fast (finished within in 30ms), the follow line of code has no chance to execute:
finalizeAsset(_mesh);
Thus the event ‘AssetType.MESH’ will not be dispatched.
FYI, to fix this problem, I added a ‘break’ after ‘parseMaterialNames();’:
if (!_parsedHeader) {
_byteData.endian = Endian.LITTLE_ENDIAN;
// TODO: Create a mesh only when encountered (if it makes sense
// for this file format) and return it using finalizeAsset()
_mesh = new Mesh;
_mesh.material = new BitmapMaterial(defaultBitmapData);
_geometry = _mesh.geometry;
_geometry.animation = new VertexAnimation(2, VertexAnimationMode.ABSOLUTE);
_animator = new VertexAnimator(VertexAnimationState(_mesh.animationState));
// Parse header and decompress body
parseHeader();
parseMaterialNames();
break;
}