blob: b10673bd4899ce308df8ae0f9175a4c845ad9373 [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "impeller/scene/camera.h"
namespace impeller {
namespace scene {
Camera Camera::MakePerspective(Scalar fov_y, Vector3 position) {
Camera camera;
camera.fov_y_ = fov_y;
camera.position_ = position;
return camera;
}
Camera Camera::LookAt(Vector3 target, Vector3 up) const {
Camera camera = *this;
camera.target_ = target;
camera.up_ = up;
return camera;
}
Matrix Camera::GetTransform(ISize target_size) const {
if (transform_.has_value()) {
return transform_.value();
}
transform_ =
Matrix::MakePerspective(Radians(fov_y_), target_size, z_near_, z_far_) *
Matrix::MakeLookAt(position_, target_, up_).Invert();
return transform_.value();
}
} // namespace scene
} // namespace impeller