WIP: No idea what exactly i did over those past 2 days
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import Vector2 from '$lib/vector';
|
||||
import Rigidbody2D from '../rigidbody/rigidbody2d';
|
||||
|
||||
export class AABB {
|
||||
private size: Vector2 = new Vector2();
|
||||
private halfSize: Vector2 = new Vector2();
|
||||
private rigidbody: Rigidbody2D = new Rigidbody2D();
|
||||
|
||||
constructor(min?: Vector2, max?: Vector2) {
|
||||
if (min !== undefined && max !== undefined) this.size = new Vector2(max).sub(min);
|
||||
|
||||
this.halfSize = new Vector2(this.size.mul(0.5));
|
||||
}
|
||||
|
||||
public get getMin(): Vector2 {
|
||||
return new Vector2(this.rigidbody.Position).sub(this.halfSize);
|
||||
}
|
||||
|
||||
public get getMax(): Vector2 {
|
||||
return new Vector2(this.rigidbody.Position).add(this.halfSize);
|
||||
}
|
||||
}
|
||||
|
||||
export default AABB;
|
||||
Reference in New Issue
Block a user