2019-03-24 18:58:32 -05:00
|
|
|
import {Color, Primitives, Renderable} from '@avocado/graphics';
|
|
|
|
import {Rectangle, Vector} from '@avocado/math';
|
|
|
|
|
|
|
|
export class BodyView extends Renderable {
|
|
|
|
|
|
|
|
constructor(body) {
|
|
|
|
super();
|
|
|
|
this.body = body;
|
|
|
|
this.primitives = new Primitives();
|
|
|
|
this.redrawAabb();
|
|
|
|
}
|
|
|
|
|
|
|
|
get internal() {
|
|
|
|
return this.primitives.internal;
|
|
|
|
}
|
|
|
|
|
|
|
|
redrawAabb() {
|
|
|
|
const aabb = this.body.aabb;
|
|
|
|
this.primitives.clear();
|
|
|
|
const xMiddle = aabb[0] + (aabb[2] / 2);
|
|
|
|
this.primitives.drawLine(
|
|
|
|
[xMiddle, aabb[1]],
|
|
|
|
[xMiddle, aabb[1] + (aabb[3] - 0.0001)],
|
2019-03-28 02:39:04 -05:00
|
|
|
Primitives.lineStyle(new Color(255, 255, 0), 0.5)
|
2019-03-24 18:58:32 -05:00
|
|
|
);
|
|
|
|
const yMiddle = aabb[1] + (aabb[3] / 2);
|
|
|
|
this.primitives.drawLine(
|
|
|
|
[aabb[0], yMiddle],
|
|
|
|
[aabb[0] + (aabb[2] -0.0001), yMiddle],
|
2019-03-28 02:39:04 -05:00
|
|
|
Primitives.lineStyle(new Color(255, 255, 0), 0.5)
|
2019-03-24 18:58:32 -05:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|