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 near = this.near;
  double top = near * math.tan((math.pi/180) * 0.5 * fov) / zoom;
  double height = 2 * top;
  double width = aspect * height;
  double left = -0.5 * width;

  if (view != null && view!.enabled) {
    final fullWidth = view!.fullWidth;
    final fullHeight = view!.fullHeight;

    left += view!.offsetX * width / fullWidth;
    top -= view!.offsetY * height / fullHeight;
    width *= view!.width / fullWidth;
    height *= view!.height / fullHeight;
  }

  num skew = filmOffset;
  if (skew != 0) left += near * skew / getFilmWidth();

  projectionMatrix.makePerspective(left, left + width, top, top - height, near, far);
  projectionMatrixInverse.setFrom(projectionMatrix);
  projectionMatrixInverse.invert();
}