bevy_panorbit_camera 0.11.1

A basic pan and orbit camera in Bevy
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use bevy::math::Vec2;
use std::ops::{Add, Sub};

pub trait Midpoint {
    type V: Add + Sub;

    fn midpoint(&self, other: Self::V) -> Self::V;
}

impl Midpoint for Vec2 {
    type V = Vec2;

    fn midpoint(&self, other: Vec2) -> Vec2 {
        let vec_to_other = other - *self;
        let half = vec_to_other / 2.0;
        *self + half
    }
}