SpotLightHelper constructor

SpotLightHelper(
  1. Light light, [
  2. int? color
])

light -- The SpotLight to be visualized.

color -- (optional) if this is not the set the helper will take the color of the light.

Implementation

SpotLightHelper(this.light, [this.color]) : super() {
  matrixAutoUpdate = false;
  light.updateMatrixWorld(false);

  matrix = light.matrixWorld;

  final geometry = BufferGeometry();

  List<double> positions = [
    0,
    0,
    0,
    0,
    0,
    1,
    0,
    0,
    0,
    1,
    0,
    1,
    0,
    0,
    0,
    -1,
    0,
    1,
    0,
    0,
    0,
    0,
    1,
    1,
    0,
    0,
    0,
    0,
    -1,
    1
  ];

  for (int i = 0, j = 1, l = 32; i < l; i++, j++) {
    final p1 = (i / l) * math.pi * 2;
    final p2 = (j / l) * math.pi * 2;

    positions.addAll(
        [math.cos(p1), math.sin(p1), 1, math.cos(p2), math.sin(p2), 1]);
  }

  geometry.setAttributeFromString('position',Float32BufferAttribute.fromList(positions, 3, false));

  final material = LineBasicMaterial.fromMap({"fog": false, "toneMapped": false});

  cone = LineSegments(geometry, material);
  add(cone);

  update();
}