IcosahedronGeometry constructor

IcosahedronGeometry([
  1. double radius = 1,
  2. int detail = 0
])

radius — Default is 1.

detail — Default is 0. Setting this to a value greater than 0 adds more vertices making it no longer an icosahedron. When detail is greater than 1, it's effectively a sphere.

Implementation

factory IcosahedronGeometry([double radius = 1, int detail = 0]) {
  final t = (1 + math.sqrt(5)) / 2;

  final List<double> vertices = [
    -1,
    t,
    0,
    1,
    t,
    0,
    -1,
    -t,
    0,
    1,
    -t,
    0,
    0,
    -1,
    t,
    0,
    1,
    t,
    0,
    -1,
    -t,
    0,
    1,
    -t,
    t,
    0,
    -1,
    t,
    0,
    1,
    -t,
    0,
    -1,
    -t,
    0,
    1
  ];

  final List<int> indices = [
    0,
    11,
    5,
    0,
    5,
    1,
    0,
    1,
    7,
    0,
    7,
    10,
    0,
    10,
    11,
    1,
    5,
    9,
    5,
    11,
    4,
    11,
    10,
    2,
    10,
    7,
    6,
    7,
    1,
    8,
    3,
    9,
    4,
    3,
    4,
    2,
    3,
    2,
    6,
    3,
    6,
    8,
    3,
    8,
    9,
    4,
    9,
    5,
    2,
    4,
    11,
    6,
    2,
    10,
    8,
    6,
    7,
    9,
    8,
    1
  ];

  IcosahedronGeometry ibg = IcosahedronGeometry.create(vertices, indices, radius, detail);

  ibg.parameters = {"radius": radius, "detail": detail};

  return ibg;
}