updateProjectionMatrix method

  1. @override
void updateProjectionMatrix()
override

Updates the camera projection matrix. Must be called after any change of parameters.

Implementation

@override
void updateProjectionMatrix() {
  final dx = (this.right - this.left) / (2 * zoom);
  final dy = (this.top - this.bottom) / (2 * zoom);
  final cx = (this.right + this.left) / 2;
  final cy = (this.top + this.bottom) / 2;

  double left = cx - dx;
  double right = cx + dx;
  double top = cy + dy;
  double bottom = cy - dy;

  if (view != null && view!.enabled) {
    final scaleW = (this.right - this.left) / view!.fullWidth / zoom;
    final scaleH = (this.top - this.bottom) / view!.fullHeight / zoom;

    left += scaleW * view!.offsetX;
    right = left + scaleW * view!.width;
    top -= scaleH * view!.offsetY;
    bottom = top - scaleH * view!.height;
  }

  projectionMatrix.makeOrthographic(left, right, top, bottom, near, far);

  projectionMatrixInverse.setFrom(projectionMatrix);
  projectionMatrixInverse.invert();
}