mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
add camera:look_at optional interpolation parameter
This commit is contained in:
parent
e0cb57a10a
commit
058daf6117
4 changed files with 15 additions and 2 deletions
|
|
@ -92,7 +92,14 @@ static int l_look_at(lua::State* L) {
|
|||
size_t index = static_cast<size_t>(lua::tointeger(L, 1));
|
||||
auto& camera = *level->cameras.at(index);
|
||||
auto center = lua::tovec<3>(L, 2);
|
||||
camera.rotation = glm::inverse(glm::lookAt(glm::vec3(), center-camera.position, glm::vec3(0, 1, 0)));
|
||||
auto matrix = glm::inverse(glm::lookAt(glm::vec3(), center-camera.position, glm::vec3(0, 1, 0)));
|
||||
if (lua::isnumber(L, 3)) {
|
||||
matrix = glm::mat4_cast(glm::slerp(
|
||||
glm::quat(camera.rotation),
|
||||
glm::quat(matrix),
|
||||
static_cast<float>(lua::tonumber(L, 3))));
|
||||
}
|
||||
camera.rotation = matrix;
|
||||
camera.updateVectors();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue