refactor: BodyView renders vertices not aabb
This commit is contained in:
parent
62ff586777
commit
ae95193805
|
@ -7,27 +7,36 @@ export class BodyView extends Renderable {
|
||||||
super();
|
super();
|
||||||
this.body = body;
|
this.body = body;
|
||||||
this.primitives = new Primitives();
|
this.primitives = new Primitives();
|
||||||
this.redrawAabb();
|
this.redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
get internal() {
|
get internal() {
|
||||||
return this.primitives.internal;
|
return this.primitives.internal;
|
||||||
}
|
}
|
||||||
|
|
||||||
redrawAabb() {
|
redraw() {
|
||||||
const aabb = this.body.aabb;
|
const primitives = this.primitives;
|
||||||
this.primitives.clear();
|
const vertices = this.body.vertices;
|
||||||
const xMiddle = aabb[0] + (aabb[2] / 2);
|
primitives.clear();
|
||||||
this.primitives.drawLine(
|
let firstVertice;
|
||||||
[xMiddle, aabb[1]],
|
let lastVertice;
|
||||||
[xMiddle, aabb[1] + (aabb[3] - 0.0001)],
|
for (const vertice of vertices) {
|
||||||
Primitives.lineStyle(new Color(255, 255, 0), 0.5)
|
if (!firstVertice) {
|
||||||
);
|
firstVertice = vertice;
|
||||||
const yMiddle = aabb[1] + (aabb[3] / 2);
|
}
|
||||||
this.primitives.drawLine(
|
if (lastVertice) {
|
||||||
[aabb[0], yMiddle],
|
primitives.drawLine(
|
||||||
[aabb[0] + (aabb[2] -0.0001), yMiddle],
|
lastVertice,
|
||||||
Primitives.lineStyle(new Color(255, 255, 0), 0.5)
|
vertice,
|
||||||
|
Primitives.lineStyle(new Color(255, 255, 0), 0.5),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
lastVertice = vertice;
|
||||||
|
}
|
||||||
|
primitives.drawLine(
|
||||||
|
lastVertice,
|
||||||
|
firstVertice,
|
||||||
|
Primitives.lineStyle(new Color(255, 255, 0), 0.5),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user