Plant launch lerp animation

This commit is contained in:
Anuken
2022-01-08 23:42:20 -05:00
parent c788f4a7f8
commit 61025972eb
4 changed files with 29 additions and 2 deletions

View File

@@ -10,6 +10,10 @@ import mindustry.type.*;
public class PlanetParams{
/** Camera direction relative to the planet. Length is determined by zoom. */
public Vec3 camPos = new Vec3(0f, 0f, 4f);
/** If not null, this is the position of the "previous" planet for smooth camera movement. */
public @Nullable Vec3 otherCamPos;
/** Interpolation value for otherCamPos. */
public float otherCamAlpha = 0f;
/** Camera up vector. */
public Vec3 camUp = new Vec3(0f, 1f, 0f);
/** the unit length direction vector of the camera **/

View File

@@ -69,7 +69,12 @@ public class PlanetRenderer implements Disposable{
cam.resize(w, h);
params.camPos.setLength((params.planet.radius + params.planet.camRadius) * camLength + (params.zoom-1f) * (params.planet.radius + params.planet.camRadius) * 2);
cam.position.set(params.planet.position).add(params.camPos);
if(params.otherCamPos != null){
cam.position.set(params.otherCamPos).lerp(params.planet.position, params.otherCamAlpha).add(params.camPos);
}else{
cam.position.set(params.planet.position).add(params.camPos);
}
//cam.up.set(params.camUp); //TODO broken
cam.lookAt(params.planet.position);
cam.update();