forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamera.cc
More file actions
36 lines (28 loc) · 891 Bytes
/
camera.cc
File metadata and controls
36 lines (28 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// 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(Radians 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(fov_y_, target_size, z_near_, z_far_) *
Matrix::MakeLookAt(position_, target_, up_);
return transform_.value();
}
} // namespace scene
} // namespace impeller