updateMatrices method

  1. @override
void updateMatrices(
  1. Light light, {
  2. int viewportIndex = 0,
})
override

Update the matrices for the camera and shadow, used internally by the renderer.

light - the light for which the shadow is being rendered.

Implementation

@override
void updateMatrices(Light light, {int viewportIndex = 0}) {
  PerspectiveCamera camera = this.camera as PerspectiveCamera;

  final fov = (math.pi / 180.0) * 2 * light.angle! * focus;
  final aspect = mapSize.x / mapSize.y;
  final far = light.distance ?? camera.far;

  if (fov != camera.fov || aspect != camera.aspect || far != camera.far) {
    camera.fov = fov;
    camera.aspect = aspect;
    camera.far = far;
    camera.updateProjectionMatrix();
  }

  super.updateMatrices(light, viewportIndex: viewportIndex);
}