setViewport method

Future setViewport(
  1. int width,
  2. int height
)
override

Implementation

Future setViewport(int width, int height) async {
  await view.setViewport(width.toInt(), height.toInt());

  for (final camera in _cameras) {
    var near = await camera.getNear();
    if (near.abs() < 0.000001) {
      near = kNear;
    }
    var far = await camera.getCullingFar();
    if (far.abs() < 0.000001) {
      far = kFar;
    }

    var aspect = width.toDouble() / height.toDouble();
    var focalLength = await camera.getFocalLength();
    if (focalLength.abs() < 0.1) {
      focalLength = kFocalLength;
    }
    await camera.setLensProjection(
      near: near,
      far: far,
      aspect: aspect,
      focalLength: focalLength,
    );
  }
}