@box2d/debug-draw
Version:
Debug drawing helper for @box2d
59 lines (58 loc) • 2.03 kB
JavaScript
;
// MIT License
Object.defineProperty(exports, "__esModule", { value: true });
exports.b2Shape = exports.b2ShapeType = exports.b2MassData = void 0;
const b2_math_1 = require("../common/b2_math");
/**
* This holds the mass data computed for a shape.
*/
class b2MassData {
constructor() {
/** The mass of the shape, usually in kilograms. */
this.mass = 0;
/** The position of the shape's centroid relative to the shape's origin. */
this.center = new b2_math_1.b2Vec2();
/** The rotational inertia of the shape about the local origin. */
this.I = 0;
}
}
exports.b2MassData = b2MassData;
var b2ShapeType;
(function (b2ShapeType) {
b2ShapeType[b2ShapeType["e_unknown"] = -1] = "e_unknown";
b2ShapeType[b2ShapeType["e_circle"] = 0] = "e_circle";
b2ShapeType[b2ShapeType["e_edge"] = 1] = "e_edge";
b2ShapeType[b2ShapeType["e_polygon"] = 2] = "e_polygon";
b2ShapeType[b2ShapeType["e_chain"] = 3] = "e_chain";
b2ShapeType[b2ShapeType["e_typeCount"] = 4] = "e_typeCount";
})(b2ShapeType || (exports.b2ShapeType = b2ShapeType = {}));
/**
* A shape is used for collision detection. You can create a shape however you like.
* Shapes used for simulation in b2World are created automatically when a b2Fixture
* is created. Shapes may encapsulate a one or more child shapes.
*/
class b2Shape {
constructor(type, radius) {
/**
* Radius of a shape. For polygonal shapes this must be b2_polygonRadius. There is no support for
* making rounded polygons.
*/
this.m_radius = 0;
this.m_type = type;
this.m_radius = radius;
}
Copy(other) {
// DEBUG: b2Assert(this.m_type === other.m_type);
this.m_radius = other.m_radius;
return this;
}
/**
* Get the type of this shape. You can use this to down cast to the concrete shape.
*
* @returns The shape type.
*/
GetType() {
return this.m_type;
}
}
exports.b2Shape = b2Shape;