use fyrox_core::{
algebra::{Matrix3, Vector3},
math::Matrix3Ext,
reflect::prelude::*,
visitor::prelude::*,
};
#[derive(Debug, Clone, Visit, Reflect)]
pub struct Listener {
basis: Matrix3<f32>,
position: Vector3<f32>,
}
impl Default for Listener {
fn default() -> Self {
Self::new()
}
}
impl Listener {
pub(crate) fn new() -> Self {
Self {
basis: Matrix3::identity(),
position: Vector3::new(0.0, 0.0, 0.0),
}
}
pub fn set_orientation_lh(&mut self, look: Vector3<f32>, up: Vector3<f32>) {
self.basis = Matrix3::from_columns(&[look.cross(&up), up, look])
}
pub fn set_orientation_rh(&mut self, look: Vector3<f32>, up: Vector3<f32>) {
self.basis = Matrix3::from_columns(&[up.cross(&look), up, look])
}
pub fn set_basis(&mut self, matrix: Matrix3<f32>) {
self.basis = matrix;
}
pub fn basis(&self) -> &Matrix3<f32> {
&self.basis
}
pub fn set_position(&mut self, position: Vector3<f32>) {
self.position = position;
}
pub fn position(&self) -> Vector3<f32> {
self.position
}
pub fn up_axis(&self) -> Vector3<f32> {
self.basis.up()
}
pub fn look_axis(&self) -> Vector3<f32> {
self.basis.look()
}
pub fn ear_axis(&self) -> Vector3<f32> {
self.basis.side()
}
}