mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-27 09:50:52 -05:00
fix issue when Bodies.trapezoid slope === 1, closes #138
This commit is contained in:
parent
e04de5fb4e
commit
449774c94d
1 changed files with 9 additions and 2 deletions
|
@ -74,12 +74,19 @@ var Vector = require('../geometry/Vector');
|
||||||
|
|
||||||
var x1 = width * slope,
|
var x1 = width * slope,
|
||||||
x2 = x1 + roof,
|
x2 = x1 + roof,
|
||||||
x3 = x2 + x1;
|
x3 = x2 + x1,
|
||||||
|
verticesPath;
|
||||||
|
|
||||||
|
if (slope < 0.5) {
|
||||||
|
verticesPath = 'L 0 0 L ' + x1 + ' ' + (-height) + ' L ' + x2 + ' ' + (-height) + ' L ' + x3 + ' 0';
|
||||||
|
} else {
|
||||||
|
verticesPath = 'L 0 0 L ' + x2 + ' ' + (-height) + ' L ' + x3 + ' 0';
|
||||||
|
}
|
||||||
|
|
||||||
var trapezoid = {
|
var trapezoid = {
|
||||||
label: 'Trapezoid Body',
|
label: 'Trapezoid Body',
|
||||||
position: { x: x, y: y },
|
position: { x: x, y: y },
|
||||||
vertices: Vertices.fromPath('L 0 0 L ' + x1 + ' ' + (-height) + ' L ' + x2 + ' ' + (-height) + ' L ' + x3 + ' 0')
|
vertices: Vertices.fromPath(verticesPath)
|
||||||
};
|
};
|
||||||
|
|
||||||
if (options.chamfer) {
|
if (options.chamfer) {
|
||||||
|
|
Loading…
Reference in a new issue