generateMap method

void generateMap(
  1. Canvas canvas,
  2. Size size,
  3. List<Object> objects,
  4. Image? texture,
)

Implementation

void generateMap(Canvas canvas, Size size, List<Object> objects, Image? texture) async {
  final renderMesh = _makeRenderMesh(objects, texture);
  final List<Triangle> renderPolys = _renderObject(renderMesh,objects);
  final int indexCount = renderPolys.length;
  final Uint16List indices = Uint16List(indexCount * 3);

  for (int i = 0; i < indexCount; i++) {
    //if(renderPolys[i] != null){
      final int index0 = i * 3;
      final int index1 = index0 + 1;
      final int index2 = index0 + 2;
      final Triangle triangle = renderPolys[i];

      indices[index0] = triangle.vertexes[0];
      indices[index1] = triangle.vertexes[1];
      indices[index2] = triangle.vertexes[2];
    //}
  }
  _drwaVert(
    canvas,
    renderMesh.positions,
    renderMesh.texcoords,
    renderMesh.colors,
    indices,
    renderMesh.texture
  );
}