renderStereo method

void renderStereo(
  1. Canvas canvas,
  2. Size fullSize
)

Renders stereo: left eye then right eye, side by side.

Implementation

void renderStereo(Canvas canvas, Size fullSize) {
  final halfWidth = fullSize.width / 2;
  final eyeSize = Size(halfWidth, fullSize.height);
  final aspect = halfWidth / fullSize.height;

  // Left eye
  canvas.save();
  canvas.clipRect(Rect.fromLTWH(0, 0, halfWidth, fullSize.height));
  render(
    canvas,
    eyeSize,
    viewProjection: cameraRig.leftViewProjection(aspect),
  );
  canvas.restore();

  // Right eye
  canvas.save();
  canvas.clipRect(Rect.fromLTWH(halfWidth, 0, halfWidth, fullSize.height));
  canvas.translate(halfWidth, 0);
  render(
    canvas,
    eyeSize,
    viewProjection: cameraRig.rightViewProjection(aspect),
  );
  canvas.restore();

  // Divider
  canvas.drawRect(
    Rect.fromLTWH(halfWidth - 2, 0, 4, fullSize.height),
    Paint()..color = const Color(0xFF000000),
  );
}