Dear all, i’m trying to generate my first mesh. Whene i run the application (Adobe AIR Flex 6) the following error occurs:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at away3d.containers::View3D/updateBackBuffer()[/Volumes/WORK/Progetti/Mach-3d/workspace/Away3d/src/away3d/containers/View3D.as:460]
Following the code that generate the error. Of course i’m missing something. Who can help me please?
public function renderer():View3D{
var _view :View3D = new View3D();
var _colorMaterial :ColorMaterial = new ColorMaterial(0xffffff);
var _uvs :Vector.<Number> = new Vector.<Number>;
var _vertices :Vector.<Number> = new Vector.<Number>;
var _triangle :LPGM_8_Triangle = null;
var _vertex :LPGM_8_Vertex = null;
var _subGeometry :SubGeometry = new SubGeometry();
var _geometry :Geometry = new Geometry();
var _lpMesh :Mesh = null;
var _indices :Vector.<uint> = new Vector.<uint>;
_colorMaterial.smooth = true;
_colorMaterial.bothSides = true;
_colorMaterial.diffuseMethod.alphaThreshold = .3;
_colorMaterial.ambient = .2;
//Generate array of vertices setting center of the model in the origin of the image
for(var i:int=0; i<_lpgmmodel.vertices.length; i++){
trace(i);
_vertex = _lpgmmodel.getVertexByIndex(i);
_vertices.push(
(_vertex.x-(_userimage.width/2.0)),
((_userimage.height/2.0)-_vertex.y),
_vertex.z
);
}
for each(var value:* in _lpgmmodel.triangles) {
_triangle = LPGM_8_Triangle(value);
_indices.push(
_triangle.vertex1.id,
_triangle.vertex2.id,
_triangle.vertex3.id
);
}
_subGeometry.updateVertexData(_vertices);
_subGeometry.updateIndexData(_indices);
_subGeometry.autoDeriveVertexTangents = true;
_subGeometry.autoDeriveVertexNormals = true
_geometry.addSubGeometry(_subGeometry);
_lpMesh = new Mesh(_geometry, _colorMaterial);
_view.scene.addChild(_lpMesh);
return _view;