get method

Map<String, dynamic> get(
  1. dynamic light
)

Implementation

Map<String, dynamic> get(light) {
  if (lights[light.id] != null) {
    return lights[light.id]!;
  }

  Map<String, dynamic>? uniforms;

  switch (light.type) {
    case 'DirectionalLight':
      uniforms = {"direction": Vector3.zero(), "color": Color(0, 0, 0)};
      break;

    case 'SpotLight':
      uniforms = {
        "position": Vector3.zero(),
        "direction": Vector3.zero(),
        "color": Color(0, 0, 0),
        "distance": 0,
        "coneCos": 0,
        "penumbraCos": 0,
        "decay": 0
      };
      break;

    case 'PointLight':
      uniforms = {"position": Vector3.zero(), "color": Color(1, 1, 1), "distance": 0, "decay": 0};
      break;

    case 'HemisphereLight':
      uniforms = {"direction": Vector3.zero(), "skyColor": Color(0, 0, 0), "groundColor": Color(0, 0, 0)};
      break;

    case 'RectAreaLight':
      uniforms = {
        "color": Color(0, 0, 0),
        "position": Vector3.zero(),
        "halfWidth": Vector3.zero(),
        "halfHeight": Vector3.zero()
      };
      break;
  }

  lights[light.id] = uniforms!;

  return uniforms;
}