Refactor shapes

This commit is contained in:
schmelczerandras 2020-08-16 10:24:12 +02:00
commit 006ab3c4e6

View file

@ -1,61 +0,0 @@
import { vec2 } from 'gl-matrix';
import { IPrimitive } from '../../drawing/drawables/primitives/i-primitive';
export abstract class BoundingBoxBase {
constructor(
public readonly value: IPrimitive,
protected _xMin: number,
protected _xMax: number,
protected _yMin: number,
protected _yMax: number
) {}
public get 0(): number {
return this._xMin;
}
public get 1(): number {
return this._xMax;
}
public get 2(): number {
return this._yMin;
}
public get 3(): number {
return this._yMax;
}
public get xMin(): number {
return this._xMin;
}
public get xMax(): number {
return this._xMax;
}
public get yMin(): number {
return this._yMin;
}
public get yMax(): number {
return this._yMax;
}
public get topLeft(): vec2 {
return vec2.fromValues(this._xMin, this._yMax);
}
public get size(): vec2 {
return vec2.fromValues(this._xMax - this._xMin, this._yMax - this._yMin);
}
public intersects(other: BoundingBoxBase): boolean {
return (
this._xMin < other._xMax &&
this._xMax > other._xMin &&
this._yMin < other._yMax &&
this._yMax > other._yMin
);
}
}