New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@box2d/core

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@box2d/core - npm Package Compare versions

Comparing version 0.10.0 to 0.11.0

dist/common/b2_readonly.d.ts

4

dist/collision/b2_broad_phase.d.ts
import { b2Vec2, XY } from "../common/b2_math";
import { b2Readonly } from "../common/b2_readonly";
import { b2AABB, b2RayCastInput } from "./b2_collision";

@@ -30,3 +31,3 @@ import { b2TreeNode } from "./b2_dynamic_tree";

*/
MoveProxy(proxy: b2TreeNode<T>, aabb: b2AABB, displacement: b2Vec2): void;
MoveProxy(proxy: b2TreeNode<T>, aabb: b2AABB, displacement: b2Readonly<b2Vec2>): void;
/**

@@ -50,2 +51,3 @@ * Call to trigger a re-processing of it's pairs on the next call to UpdatePairs.

QueryPoint(point: XY, callback: (node: b2TreeNode<T>) => boolean): void;
/** This is called from b2DynamicTree::Query when we are gathering pairs. */
private QueryCallback;

@@ -52,0 +54,0 @@ /**

@@ -37,2 +37,3 @@ "use strict";

this.m_queryProxy = new b2_dynamic_tree_1.b2TreeNode();
/** This is called from b2DynamicTree::Query when we are gathering pairs. */
this.QueryCallback = (proxy) => {

@@ -39,0 +40,0 @@ // A proxy cannot form a pair with itself.

@@ -7,2 +7,3 @@ import { b2Vec2, b2Transform, XY } from "../common/b2_math";

import { b2Color, b2Draw } from "../common/b2_draw";
import { b2Readonly } from "../common/b2_readonly";
/**

@@ -55,3 +56,3 @@ * A chain shape is a free form sequence of line segments.

*/
TestPoint(_xf: b2Transform, _p: XY): boolean;
TestPoint(_xf: b2Readonly<b2Transform>, _p: XY): boolean;
private static RayCast_s_edgeShape;

@@ -61,3 +62,3 @@ /**

*/
RayCast(output: b2RayCastOutput, input: b2RayCastInput, xf: b2Transform, childIndex: number): boolean;
RayCast(output: b2RayCastOutput, input: b2RayCastInput, xf: b2Readonly<b2Transform>, childIndex: number): boolean;
private static ComputeAABB_s_v1;

@@ -70,3 +71,3 @@ private static ComputeAABB_s_v2;

*/
ComputeAABB(aabb: b2AABB, xf: b2Transform, childIndex: number): void;
ComputeAABB(aabb: b2AABB, xf: b2Readonly<b2Transform>, childIndex: number): void;
/**

@@ -73,0 +74,0 @@ * Chains have zero mass.

@@ -186,9 +186,5 @@ "use strict";

proxy.m_vertices = proxy.m_buffer;
proxy.m_vertices[0].Copy(this.m_vertices[index]);
if (index + 1 < this.m_vertices.length) {
proxy.m_vertices[1].Copy(this.m_vertices[index + 1]);
}
else {
proxy.m_vertices[1].Copy(this.m_vertices[0]);
}
proxy.m_vertices[0] = this.m_vertices[index];
const secondIndex = index + 1 < this.m_vertices.length ? index + 1 : 0;
proxy.m_vertices[1] = this.m_vertices[secondIndex];
proxy.m_count = 2;

@@ -195,0 +191,0 @@ proxy.m_radius = this.m_radius;

import { b2Color, b2Draw } from "../common/b2_draw";
import { b2Vec2, b2Transform, XY } from "../common/b2_math";
import { b2Readonly } from "../common/b2_readonly";
import { b2AABB, b2RayCastInput, b2RayCastOutput } from "./b2_collision";

@@ -28,3 +29,3 @@ import { b2DistanceProxy } from "./b2_distance";

*/
TestPoint(transform: b2Transform, p: XY): boolean;
TestPoint(transform: b2Readonly<b2Transform>, p: XY): boolean;
private static RayCast_s_position;

@@ -42,3 +43,3 @@ private static RayCast_s_s;

*/
RayCast(output: b2RayCastOutput, input: b2RayCastInput, transform: b2Transform, _childIndex: number): boolean;
RayCast(output: b2RayCastOutput, input: b2RayCastInput, transform: b2Readonly<b2Transform>, _childIndex: number): boolean;
private static ComputeAABB_s_p;

@@ -48,3 +49,3 @@ /**

*/
ComputeAABB(aabb: b2AABB, transform: b2Transform, _childIndex: number): void;
ComputeAABB(aabb: b2AABB, transform: b2Readonly<b2Transform>, _childIndex: number): void;
/**

@@ -51,0 +52,0 @@ * @see b2Shape::ComputeMass

@@ -118,3 +118,3 @@ "use strict";

proxy.m_vertices = proxy.m_buffer;
proxy.m_vertices[0].Copy(this.m_p);
proxy.m_vertices[0] = this.m_p;
proxy.m_count = 1;

@@ -121,0 +121,0 @@ proxy.m_radius = this.m_radius;

@@ -5,4 +5,5 @@ import { b2Transform } from "../common/b2_math";

import { b2PolygonShape } from "./b2_polygon_shape";
export declare function b2CollideCircles(manifold: b2Manifold, circleA: b2CircleShape, xfA: b2Transform, circleB: b2CircleShape, xfB: b2Transform): void;
export declare function b2CollidePolygonAndCircle(manifold: b2Manifold, polygonA: b2PolygonShape, xfA: b2Transform, circleB: b2CircleShape, xfB: b2Transform): void;
import { b2Readonly } from "../common/b2_readonly";
export declare function b2CollideCircles(manifold: b2Manifold, circleA: b2CircleShape, xfA: b2Readonly<b2Transform>, circleB: b2CircleShape, xfB: b2Readonly<b2Transform>): void;
export declare function b2CollidePolygonAndCircle(manifold: b2Manifold, polygonA: b2PolygonShape, xfA: b2Readonly<b2Transform>, circleB: b2CircleShape, xfB: b2Readonly<b2Transform>): void;
//# sourceMappingURL=b2_collide_circle.d.ts.map

@@ -6,4 +6,9 @@ import { b2Transform } from "../common/b2_math";

import { b2EdgeShape } from "./b2_edge_shape";
export declare function b2CollideEdgeAndCircle(manifold: b2Manifold, edgeA: b2EdgeShape, xfA: b2Transform, circleB: b2CircleShape, xfB: b2Transform): void;
export declare function b2CollideEdgeAndPolygon(manifold: b2Manifold, edgeA: b2EdgeShape, xfA: b2Transform, polygonB: b2PolygonShape, xfB: b2Transform): void;
import { b2Readonly } from "../common/b2_readonly";
/**
* Compute contact points for edge versus circle.
* This accounts for edge connectivity.
*/
export declare function b2CollideEdgeAndCircle(manifold: b2Manifold, edgeA: b2EdgeShape, xfA: b2Readonly<b2Transform>, circleB: b2CircleShape, xfB: b2Readonly<b2Transform>): void;
export declare function b2CollideEdgeAndPolygon(manifold: b2Manifold, edgeA: b2EdgeShape, xfA: b2Readonly<b2Transform>, polygonB: b2PolygonShape, xfB: b2Readonly<b2Transform>): void;
//# sourceMappingURL=b2_collide_edge.d.ts.map

@@ -34,2 +34,6 @@ "use strict";

const b2CollideEdgeAndCircle_s_id = new b2_collision_1.b2ContactID();
/**
* Compute contact points for edge versus circle.
* This accounts for edge connectivity.
*/
function b2CollideEdgeAndCircle(manifold, edgeA, xfA, circleB, xfB) {

@@ -36,0 +40,0 @@ manifold.pointCount = 0;

import { b2Transform } from "../common/b2_math";
import { b2Readonly } from "../common/b2_readonly";
import { b2Manifold } from "./b2_collision";

@@ -13,3 +14,3 @@ import { b2PolygonShape } from "./b2_polygon_shape";

*/
export declare function b2CollidePolygons(manifold: b2Manifold, polyA: b2PolygonShape, xfA: b2Transform, polyB: b2PolygonShape, xfB: b2Transform): void;
export declare function b2CollidePolygons(manifold: b2Manifold, polyA: b2PolygonShape, xfA: b2Readonly<b2Transform>, polyB: b2PolygonShape, xfB: b2Readonly<b2Transform>): void;
//# sourceMappingURL=b2_collide_polygon.d.ts.map
import { b2Vec2, b2Transform, XY } from "../common/b2_math";
import type { b2Shape } from "./b2_shape";
import { b2Readonly } from "../common/b2_readonly";
export declare enum b2ContactFeatureType {

@@ -120,3 +121,9 @@ e_vertex = 0,

private static Initialize_s_clipPoint;
Initialize(manifold: b2Manifold, xfA: b2Transform, radiusA: number, xfB: b2Transform, radiusB: number): void;
/**
* Evaluate the manifold with supplied transforms. This assumes
* modest motion from the original state. This does not change the
* point count, impulses, etc. The radii must come from the shapes
* that generated the manifold.
*/
Initialize(manifold: b2Manifold, xfA: b2Readonly<b2Transform>, radiusA: number, xfB: b2Readonly<b2Transform>, radiusB: number): void;
}

@@ -211,8 +218,36 @@ /**

* Clipping for contact manifolds.
* Sutherland-Hodgman clipping.
*/
export declare function b2ClipSegmentToLine(vOut: readonly [b2ClipVertex, b2ClipVertex], [vIn0, vIn1]: readonly [b2ClipVertex, b2ClipVertex], normal: b2Vec2, offset: number, vertexIndexA: number): number;
export declare function b2ClipSegmentToLine(vOut: readonly [b2ClipVertex, b2ClipVertex], [vIn0, vIn1]: readonly [b2ClipVertex, b2ClipVertex], normal: b2Readonly<b2Vec2>, offset: number, vertexIndexA: number): number;
/**
* Determine if two generic shapes overlap.
*/
export declare function b2TestOverlap(shapeA: b2Shape, indexA: number, shapeB: b2Shape, indexB: number, xfA: b2Transform, xfB: b2Transform): boolean;
export declare function b2TestOverlap(shapeA: b2Shape, indexA: number, shapeB: b2Shape, indexB: number, xfA: b2Readonly<b2Transform>, xfB: b2Readonly<b2Transform>): boolean;
/** Convex hull used for polygon collision */
export type b2Hull = Array<Readonly<XY>>;
/**
* Compute the convex hull of a set of points.
* quickhull algorithm
* - merges vertices based on b2_linearSlop
* - removes collinear points using b2_linearSlop
* - returns an empty hull if it fails
*
* Some failure cases:
* - all points very close together
* - all points on a line
* - less than 3 points
* - more than b2_maxPolygonVertices points
*
* This welds close points and removes collinear points.
*
* @returns an empty hull if it fails.
*/
export declare function b2ComputeHull(points: ReadonlyArray<Readonly<XY>>, count: number): Readonly<b2Hull>;
/**
* This determines if a hull is valid. Checks for:
* - convexity
* - collinear points
* This is expensive and should not be called at runtime.
*/
export declare function b2ValidateHull(hull: Readonly<b2Hull>, count: number): boolean;
//# sourceMappingURL=b2_collision.d.ts.map
"use strict";
// MIT License
Object.defineProperty(exports, "__esModule", { value: true });
exports.b2TestOverlap = exports.b2ClipSegmentToLine = exports.b2AABB = exports.b2RayCastOutput = exports.b2RayCastInput = exports.b2ClipVertex = exports.b2GetPointStates = exports.b2PointState = exports.b2WorldManifold = exports.b2Manifold = exports.b2ManifoldType = exports.b2ManifoldPoint = exports.b2ContactID = exports.b2ContactFeature = exports.b2ContactFeatureType = void 0;
exports.b2ValidateHull = exports.b2ComputeHull = exports.b2TestOverlap = exports.b2ClipSegmentToLine = exports.b2AABB = exports.b2RayCastOutput = exports.b2RayCastInput = exports.b2ClipVertex = exports.b2GetPointStates = exports.b2PointState = exports.b2WorldManifold = exports.b2Manifold = exports.b2ManifoldType = exports.b2ManifoldPoint = exports.b2ContactID = exports.b2ContactFeature = exports.b2ContactFeatureType = void 0;
// Copyright (c) 2019 Erin Catto

@@ -26,2 +26,3 @@ // Permission is hereby granted, free of charge, to any person obtaining a copy

const b2_distance_1 = require("./b2_distance");
const b2_settings_1 = require("../common/b2_settings");
var b2ContactFeatureType;

@@ -31,3 +32,3 @@ (function (b2ContactFeatureType) {

b2ContactFeatureType[b2ContactFeatureType["e_face"] = 1] = "e_face";
})(b2ContactFeatureType = exports.b2ContactFeatureType || (exports.b2ContactFeatureType = {}));
})(b2ContactFeatureType || (exports.b2ContactFeatureType = b2ContactFeatureType = {}));
/**

@@ -160,3 +161,3 @@ * The features that intersect to form the contact point

b2ManifoldType[b2ManifoldType["e_faceB"] = 2] = "e_faceB";
})(b2ManifoldType = exports.b2ManifoldType || (exports.b2ManifoldType = {}));
})(b2ManifoldType || (exports.b2ManifoldType = b2ManifoldType = {}));
/**

@@ -230,2 +231,8 @@ * A manifold for two touching convex shapes.

}
/**
* Evaluate the manifold with supplied transforms. This assumes
* modest motion from the original state. This does not change the
* point count, impulses, etc. The radii must come from the shapes
* that generated the manifold.
*/
Initialize(manifold, xfA, radiusA, xfB, radiusB) {

@@ -300,3 +307,3 @@ if (manifold.pointCount === 0) {

b2PointState[b2PointState["b2_removeState"] = 3] = "b2_removeState";
})(b2PointState = exports.b2PointState || (exports.b2PointState = {}));
})(b2PointState || (exports.b2PointState = b2PointState = {}));
/**

@@ -571,2 +578,3 @@ * Compute the point states given two manifolds. The states pertain to the transition from manifold1

* Clipping for contact manifolds.
* Sutherland-Hodgman clipping.
*/

@@ -622,1 +630,233 @@ function b2ClipSegmentToLine(vOut, [vIn0, vIn1], normal, offset, vertexIndexA) {

exports.b2TestOverlap = b2TestOverlap;
const b2RecurseHull_s_e = new b2_math_1.b2Vec2();
const b2RecurseHull_s_c = new b2_math_1.b2Vec2();
const emptyHull = [];
/** quickhull recursion */
function b2RecurseHull(p1, p2, ps) {
if (ps.length === 0) {
return emptyHull;
}
// create an edge vector pointing from p1 to p2
const e = b2_math_1.b2Vec2.Subtract(p2, p1, b2RecurseHull_s_e);
e.Normalize();
// discard points left of e and find point furthest to the right of e
const rightPoints = [];
let bestIndex = 0;
let bestDistance = b2_math_1.b2Vec2.Cross(b2_math_1.b2Vec2.Subtract(ps[bestIndex], p1, b2RecurseHull_s_c), e);
if (bestDistance > 0) {
rightPoints.push(ps[bestIndex]);
}
for (let i = 1; i < ps.length; ++i) {
const distance = b2_math_1.b2Vec2.Cross(b2_math_1.b2Vec2.Subtract(ps[i], p1, b2RecurseHull_s_c), e);
if (distance > bestDistance) {
bestIndex = i;
bestDistance = distance;
}
if (distance > 0) {
rightPoints.push(ps[i]);
}
}
if (bestDistance < 2 * b2_common_1.b2_linearSlop) {
return emptyHull;
}
const bestPoint = ps[bestIndex];
// compute hull to the right of p1-bestPoint
const hull1 = b2RecurseHull(p1, bestPoint, rightPoints);
// compute hull to the right of bestPoint-p2
const hull2 = b2RecurseHull(bestPoint, p2, rightPoints);
// stich together hulls
const hull = [...hull1, bestPoint, ...hull2];
(0, b2_common_1.b2Assert)(hull.length < b2_settings_1.b2_maxPolygonVertices);
return hull;
}
const b2ComputeHull_s_e = new b2_math_1.b2Vec2();
const b2ComputeHull_s_v = new b2_math_1.b2Vec2();
const b2ComputeHull_s_c = new b2_math_1.b2Vec2();
const b2ComputeHull_s_d = new b2_math_1.b2Vec2();
const b2ComputeHull_s_aabb = new b2AABB();
/**
* Compute the convex hull of a set of points.
* quickhull algorithm
* - merges vertices based on b2_linearSlop
* - removes collinear points using b2_linearSlop
* - returns an empty hull if it fails
*
* Some failure cases:
* - all points very close together
* - all points on a line
* - less than 3 points
* - more than b2_maxPolygonVertices points
*
* This welds close points and removes collinear points.
*
* @returns an empty hull if it fails.
*/
function b2ComputeHull(points, count) {
if (count < 3 || count > b2_settings_1.b2_maxPolygonVertices) {
// check your data
return emptyHull;
}
count = Math.min(count, b2_settings_1.b2_maxPolygonVertices);
const aabb = b2ComputeHull_s_aabb;
aabb.lowerBound.Set(b2_common_1.b2_maxFloat, b2_common_1.b2_maxFloat);
aabb.upperBound.Set(-b2_common_1.b2_maxFloat, -b2_common_1.b2_maxFloat);
// Perform aggressive point welding. First point always remains.
// Also compute the bounding box for later.
const ps = [];
const tolSqr = 16 * b2_common_1.b2_linearSlop * b2_common_1.b2_linearSlop;
for (let i = 0; i < count; ++i) {
b2_math_1.b2Vec2.Min(aabb.lowerBound, points[i], aabb.lowerBound);
b2_math_1.b2Vec2.Max(aabb.upperBound, points[i], aabb.upperBound);
const vi = points[i];
let unique = true;
for (let j = 0; j < i; ++j) {
const vj = points[j];
const distSqr = b2_math_1.b2Vec2.DistanceSquared(vi, vj);
if (distSqr < tolSqr) {
unique = false;
break;
}
}
if (unique) {
ps.push(vi);
}
}
let n = ps.length;
if (n < 3) {
// all points very close together, check your data and check your scale
return emptyHull;
}
// Find an extreme point as the first point on the hull
const c = aabb.GetCenter(b2ComputeHull_s_c);
let i1 = 0;
let dsq1 = b2_math_1.b2Vec2.DistanceSquared(c, ps[i1]);
for (let i = 1; i < n; ++i) {
const dsq = b2_math_1.b2Vec2.DistanceSquared(c, ps[i]);
if (dsq > dsq1) {
i1 = i;
dsq1 = dsq;
}
}
// remove p1 from working set
const p1 = ps[i1];
ps[i1] = ps[n - 1];
n -= 1;
let i2 = 0;
let dsq2 = b2_math_1.b2Vec2.DistanceSquared(p1, ps[i2]);
for (let i = 1; i < n; ++i) {
const dsq = b2_math_1.b2Vec2.DistanceSquared(p1, ps[i]);
if (dsq > dsq2) {
i2 = i;
dsq2 = dsq;
}
}
// remove p2 from working set
const p2 = ps[i2];
ps[i2] = ps[n - 1];
n -= 1;
// split the points into points that are left and right of the line p1-p2.
const rightPoints = [];
const leftPoints = [];
const e = b2_math_1.b2Vec2.Subtract(p2, p1, b2ComputeHull_s_e);
e.Normalize();
for (let i = 0; i < n; ++i) {
const d = b2_math_1.b2Vec2.Cross(b2_math_1.b2Vec2.Subtract(ps[i], p1, b2ComputeHull_s_d), e);
// slop used here to skip points that are very close to the line p1-p2
if (d >= 2 * b2_common_1.b2_linearSlop) {
rightPoints.push(ps[i]);
}
else if (d <= -2 * b2_common_1.b2_linearSlop) {
leftPoints.push(ps[i]);
}
}
// compute hulls on right and left
const hull1 = b2RecurseHull(p1, p2, rightPoints);
const hull2 = b2RecurseHull(p2, p1, leftPoints);
if (hull1.length === 0 && hull2.length === 0) {
// all points collinear
return emptyHull;
}
// stitch hulls together, preserving CCW winding order
const hull = [p1, ...hull1, p2, ...hull2];
(0, b2_common_1.b2Assert)(hull.length <= b2_settings_1.b2_maxPolygonVertices);
// merge collinear
let searching = true;
while (searching && hull.length > 2) {
searching = false;
for (let i = 0; i < hull.length; ++i) {
const i1b = i;
const i2b = (i + 1) % hull.length;
const i3b = (i + 2) % hull.length;
const p1b = hull[i1b];
const p2b = hull[i2b];
const p3b = hull[i3b];
const eb = b2_math_1.b2Vec2.Subtract(p3b, p1b, b2ComputeHull_s_e);
eb.Normalize();
const v = b2_math_1.b2Vec2.Subtract(p2b, p1b, b2ComputeHull_s_v);
const distance = b2_math_1.b2Vec2.Cross(v, eb);
if (distance <= 2 * b2_common_1.b2_linearSlop) {
// remove midpoint from hull
hull.splice(i2b, 1);
// continue searching for collinear points
searching = true;
break;
}
}
}
if (hull.length < 3) {
// all points collinear, shouldn't be reached since this was validated above
hull.length = 0;
}
return hull;
}
exports.b2ComputeHull = b2ComputeHull;
const b2ValidateHull_s_e = new b2_math_1.b2Vec2();
const b2ValidateHull_s_d = new b2_math_1.b2Vec2();
/**
* This determines if a hull is valid. Checks for:
* - convexity
* - collinear points
* This is expensive and should not be called at runtime.
*/
function b2ValidateHull(hull, count) {
if (count < 3 || b2_settings_1.b2_maxPolygonVertices < count) {
return false;
}
// test that every point is behind every edge
for (let i = 0; i < count; ++i) {
// create an edge vector
const i1 = i;
const i2 = i < count - 1 ? i1 + 1 : 0;
const p = hull[i1];
const e = b2_math_1.b2Vec2.Subtract(hull[i2], p, b2ValidateHull_s_e);
e.Normalize();
for (let j = 0; j < count; ++j) {
// skip points that subtend the current edge
if (j === i1 || j === i2) {
continue;
}
const distance = b2_math_1.b2Vec2.Cross(b2_math_1.b2Vec2.Subtract(hull[j], p, b2ValidateHull_s_d), e);
if (distance >= 0) {
return false;
}
}
}
// test for collinear points
for (let i = 0; i < count; ++i) {
const i1 = i;
const i2 = (i + 1) % count;
const i3 = (i + 2) % count;
const p1 = hull[i1];
const p2 = hull[i2];
const p3 = hull[i3];
const e = b2_math_1.b2Vec2.Subtract(p3, p1, b2ValidateHull_s_e);
e.Normalize();
const distance = b2_math_1.b2Vec2.Cross(b2_math_1.b2Vec2.Subtract(p2, p1, b2ValidateHull_s_d), e);
if (distance <= b2_common_1.b2_linearSlop) {
// p1-p2-p3 are collinear
return false;
}
}
return true;
}
exports.b2ValidateHull = b2ValidateHull;
import { b2Vec2, b2Transform } from "../common/b2_math";
import { b2Readonly } from "../common/b2_readonly";
import type { b2Shape } from "./b2_shape";

@@ -15,7 +16,17 @@ /**

SetShape(shape: b2Shape, index: number): void;
/**
* Initialize the proxy using the given shape. The shape
* must remain in scope while the proxy is in use.
* Initialize the proxy using a vertex cloud and radius. The vertices
* must remain in scope while the proxy is in use.
*/
SetVerticesRadius(vertices: b2Vec2[], count: number, radius: number): void;
GetSupport(d: b2Vec2): number;
GetSupportVertex(d: b2Vec2): b2Vec2;
/** Get the supporting vertex index in the given direction. */
GetSupport(d: b2Readonly<b2Vec2>): number;
/** Get the supporting vertex in the given direction. */
GetSupportVertex(d: b2Readonly<b2Vec2>): b2Readonly<b2Vec2>;
/** Get the vertex count. */
GetVertexCount(): number;
GetVertex(index: number): b2Vec2;
/** Get a vertex by index. Used by b2Distance. */
GetVertex(index: number): b2Readonly<b2Vec2>;
}

@@ -81,2 +92,3 @@ /**

}
/** GJK using Voronoi regions (Christer Ericson) and Barycentric coordinates. */
export declare const b2Gjk: {

@@ -88,2 +100,7 @@ calls: number;

};
/**
* Compute the closest points between two shapes. Supports any combination of:
* b2CircleShape, b2PolygonShape, b2EdgeShape. The simplex cache is input/output.
* On the first call set b2SimplexCache.count to zero.
*/
export declare function b2Distance(output: b2DistanceOutput, cache: b2SimplexCache, input: b2DistanceInput): void;

@@ -95,4 +112,6 @@ /**

* "Smooth Mesh Contacts with GJK" in Game Physics Pearls. 2010
*
* @returns true if hit, false if there is no hit or an initial overlap
*/
export declare function b2ShapeCast(output: b2ShapeCastOutput, input: b2ShapeCastInput): boolean;
//# sourceMappingURL=b2_distance.d.ts.map

@@ -38,4 +38,6 @@ "use strict";

this.m_vertices = this.m_buffer;
this.m_buffer[0].Copy(other.m_buffer[0]);
this.m_buffer[1].Copy(other.m_buffer[1]);
// eslint-disable-next-line prefer-destructuring
this.m_buffer[0] = other.m_buffer[0];
// eslint-disable-next-line prefer-destructuring
this.m_buffer[1] = other.m_buffer[1];
}

@@ -58,2 +60,8 @@ else {

}
/**
* Initialize the proxy using the given shape. The shape
* must remain in scope while the proxy is in use.
* Initialize the proxy using a vertex cloud and radius. The vertices
* must remain in scope while the proxy is in use.
*/
SetVerticesRadius(vertices, count, radius) {

@@ -64,2 +72,3 @@ this.m_vertices = vertices;

}
/** Get the supporting vertex index in the given direction. */
GetSupport(d) {

@@ -77,2 +86,3 @@ let bestIndex = 0;

}
/** Get the supporting vertex in the given direction. */
GetSupportVertex(d) {

@@ -90,5 +100,7 @@ let bestIndex = 0;

}
/** Get the vertex count. */
GetVertexCount() {
return this.m_count;
}
/** Get a vertex by index. Used by b2Distance. */
GetVertex(index) {

@@ -191,2 +203,3 @@ // DEBUG: b2Assert(0 <= index && index < this.m_count);

exports.b2ShapeCastOutput = b2ShapeCastOutput;
/** GJK using Voronoi regions (Christer Ericson) and Barycentric coordinates. */
exports.b2Gjk = {

@@ -355,2 +368,22 @@ calls: 0,

}
/**
* Solve a line segment using barycentric coordinates.
* p = a1 * w1 + a2 * w2
* a1 + a2 = 1
* The vector from the origin to the closest point on the line is
* perpendicular to the line.
* e12 = w2 - w1
* dot(p, e) = 0
* a1 * dot(w1, e) + a2 * dot(w2, e) = 0
* 2-by-2 linear system
* [1 1 ][a1] = [1]
* [w1.e12 w2.e12][a2] = [0]
* Define
* d12_1 = dot(w2, e12)
* d12_2 = -dot(w1, e12)
* d12 = d12_1 + d12_2
* Solution
* a1 = d12_1 / d12
* a2 = d12_2 / d12
*/
Solve2() {

@@ -383,2 +416,9 @@ const w1 = this.m_v1.w;

}
/**
* Possible regions:
* - points[2]
* - edge points[0]-points[2]
* - edge points[1]-points[2]
* - inside the triangle
*/
Solve3() {

@@ -485,2 +525,7 @@ const w1 = this.m_v1.w;

const b2Distance_s_supportB = new b2_math_1.b2Vec2();
/**
* Compute the closest points between two shapes. Supports any combination of:
* b2CircleShape, b2PolygonShape, b2EdgeShape. The simplex cache is input/output.
* On the first call set b2SimplexCache.count to zero.
*/
function b2Distance(output, cache, input) {

@@ -568,23 +613,22 @@ ++exports.b2Gjk.calls;

simplex.WriteCache(cache);
// Apply radii if requested.
// Apply radii if requested
if (input.useRadii) {
const rA = proxyA.m_radius;
const rB = proxyB.m_radius;
if (output.distance > rA + rB && output.distance > b2_common_1.b2_epsilon) {
// Shapes are still no overlapped.
// Move the witness points to the outer surface.
output.distance -= rA + rB;
if (output.distance < b2_common_1.b2_epsilon) {
// Shapes are too close to safely compute normal
const p = b2_math_1.b2Vec2.Mid(output.pointA, output.pointB, b2Distance_s_p);
output.pointA.Copy(p);
output.pointB.Copy(p);
output.distance = 0;
}
else {
// Keep closest points on perimeter even if overlapped, this way
// the points move smoothly.
const rA = proxyA.m_radius;
const rB = proxyB.m_radius;
const normal = b2_math_1.b2Vec2.Subtract(output.pointB, output.pointA, b2Distance_s_normal);
normal.Normalize();
output.distance = Math.max(0, output.distance - rA - rB);
output.pointA.AddScaled(rA, normal);
output.pointB.SubtractScaled(rB, normal);
}
else {
// Shapes are overlapped when radii are considered.
// Move the witness points to the middle.
const p = b2_math_1.b2Vec2.Mid(output.pointA, output.pointB, b2Distance_s_p);
output.pointA.Copy(p);
output.pointB.Copy(p);
output.distance = 0;
}
}

@@ -606,2 +650,4 @@ }

* "Smooth Mesh Contacts with GJK" in Game Physics Pearls. 2010
*
* @returns true if hit, false if there is no hit or an initial overlap
*/

@@ -608,0 +654,0 @@ function b2ShapeCast(output, input) {

import { b2Vec2, XY } from "../common/b2_math";
import { b2Readonly } from "../common/b2_readonly";
import { b2AABB, b2RayCastInput } from "./b2_collision";

@@ -20,2 +21,3 @@ /**

GetArea(): number;
/** Compute the height of a sub-tree. */
ComputeHeight(): number;

@@ -38,18 +40,63 @@ GetMaxBalance(): number;

private m_freeList;
/**
* Query an AABB for overlapping proxies. The callback class
* is called for each proxy that overlaps the supplied AABB.
*/
Query(aabb: b2AABB, callback: (node: b2TreeNode<T>) => boolean): void;
QueryPoint(point: XY, callback: (node: b2TreeNode<T>) => boolean): void;
/**
* Ray-cast against the proxies in the tree. This relies on the callback
* to perform a exact ray-cast in the case were the proxy contains a shape.
* The callback also performs the any collision filtering. This has performance
* roughly equal to k * log(n), where k is the number of collisions and n is the
* number of proxies in the tree.
* @param input the ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).
* @param callback a callback class that is called for each proxy that is hit by the ray.
*/
RayCast(input: b2RayCastInput, callback: (input: b2RayCastInput, node: b2TreeNode<T>) => number): void;
/** Allocate a node from the pool. Grow the pool if necessary. */
private AllocateNode;
/** Return a node to the pool. */
private FreeNode;
/**
* Create a proxy. Provide a tight fitting AABB and a userData pointer.
* Create a proxy in the tree as a leaf node. We return the index
* of the node instead of a pointer so that we can grow
* the node pool.
*/
CreateProxy(aabb: b2AABB, userData: T): b2TreeNode<T>;
/** Destroy a proxy. This asserts if the id is invalid. */
DestroyProxy(node: b2TreeNode<T>): void;
MoveProxy(node: b2TreeNode<T>, aabb: b2AABB, displacement: b2Vec2): boolean;
/**
* Move a proxy with a swepted AABB. If the proxy has moved outside of its fattened AABB,
* the function returns immediately.
* @return true if the proxy was re-inserted.
*/
MoveProxy(node: b2TreeNode<T>, aabb: b2AABB, displacement: b2Readonly<b2Vec2>): boolean;
private InsertLeaf;
private RemoveLeaf;
/**
* Perform a left or right rotation if node A is imbalanced.
* Returns the new root index.
*/
private Balance;
/**
* Compute the height of the binary tree in O(N) time. Should not be
* called often.
*/
GetHeight(): number;
/** Get the ratio of the sum of the node areas to the root area. */
GetAreaRatio(): number;
/**
* Get the maximum balance of an node in the tree. The balance is the difference
* in height of the two children of a node.
*/
GetMaxBalance(): number;
/**
* Shift the world origin. Useful for large worlds.
* The shift formula is: position -= newOrigin
* @param newOrigin the new origin with respect to the old origin
*/
ShiftOrigin(newOrigin: XY): void;
}
//# sourceMappingURL=b2_dynamic_tree.d.ts.map

@@ -75,2 +75,3 @@ "use strict";

}
/** Compute the height of a sub-tree. */
ComputeHeight() {

@@ -116,2 +117,6 @@ if (this.IsLeaf())

}
/**
* Query an AABB for overlapping proxies. The callback class
* is called for each proxy that overlaps the supplied AABB.
*/
Query(aabb, callback) {

@@ -157,2 +162,11 @@ const stack = temp.stack;

}
/**
* Ray-cast against the proxies in the tree. This relies on the callback
* to perform a exact ray-cast in the case were the proxy contains a shape.
* The callback also performs the any collision filtering. This has performance
* roughly equal to k * log(n), where k is the number of collisions and n is the
* number of proxies in the tree.
* @param input the ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).
* @param callback a callback class that is called for each proxy that is hit by the ray.
*/
RayCast(input, callback) {

@@ -215,2 +229,3 @@ const { p1, p2 } = input;

}
/** Allocate a node from the pool. Grow the pool if necessary. */
AllocateNode() {

@@ -230,2 +245,3 @@ // Expand the node pool as needed.

}
/** Return a node to the pool. */
FreeNode(node) {

@@ -236,2 +252,8 @@ node.parent = this.m_freeList;

}
/**
* Create a proxy. Provide a tight fitting AABB and a userData pointer.
* Create a proxy in the tree as a leaf node. We return the index
* of the node instead of a pointer so that we can grow
* the node pool.
*/
CreateProxy(aabb, userData) {

@@ -249,2 +271,3 @@ const node = this.AllocateNode();

}
/** Destroy a proxy. This asserts if the id is invalid. */
DestroyProxy(node) {

@@ -255,2 +278,7 @@ // DEBUG: b2Assert(node.IsLeaf());

}
/**
* Move a proxy with a swepted AABB. If the proxy has moved outside of its fattened AABB,
* the function returns immediately.
* @return true if the proxy was re-inserted.
*/
MoveProxy(node, aabb, displacement) {

@@ -433,2 +461,6 @@ // DEBUG: b2Assert(node.IsLeaf());

}
/**
* Perform a left or right rotation if node A is imbalanced.
* Returns the new root index.
*/
Balance(A) {

@@ -528,2 +560,6 @@ // DEBUG: b2Assert(A !== null);

}
/**
* Compute the height of the binary tree in O(N) time. Should not be
* called often.
*/
GetHeight() {

@@ -535,2 +571,3 @@ if (this.m_root === null) {

}
/** Get the ratio of the sum of the node areas to the root area. */
GetAreaRatio() {

@@ -545,2 +582,6 @@ if (this.m_root === null) {

}
/**
* Get the maximum balance of an node in the tree. The balance is the difference
* in height of the two children of a node.
*/
GetMaxBalance() {

@@ -552,2 +593,7 @@ if (this.m_root === null) {

}
/**
* Shift the world origin. Useful for large worlds.
* The shift formula is: position -= newOrigin
* @param newOrigin the new origin with respect to the old origin
*/
ShiftOrigin(newOrigin) {

@@ -554,0 +600,0 @@ var _a;

import { b2Color, b2Draw } from "../common/b2_draw";
import { b2Vec2, b2Transform, XY } from "../common/b2_math";
import { b2Readonly } from "../common/b2_readonly";
import { b2AABB, b2RayCastInput, b2RayCastOutput } from "./b2_collision";

@@ -44,3 +45,3 @@ import { b2DistanceProxy } from "./b2_distance";

*/
TestPoint(_xf: b2Transform, _p: XY): boolean;
TestPoint(_xf: b2Readonly<b2Transform>, _p: XY): boolean;
private static RayCast_s_p1;

@@ -60,3 +61,3 @@ private static RayCast_s_p2;

*/
RayCast(output: b2RayCastOutput, input: b2RayCastInput, xf: b2Transform, _childIndex: number): boolean;
RayCast(output: b2RayCastOutput, input: b2RayCastInput, xf: b2Readonly<b2Transform>, _childIndex: number): boolean;
private static ComputeAABB_s_v1;

@@ -67,3 +68,3 @@ private static ComputeAABB_s_v2;

*/
ComputeAABB(aabb: b2AABB, xf: b2Transform, _childIndex: number): void;
ComputeAABB(aabb: b2AABB, xf: b2Readonly<b2Transform>, _childIndex: number): void;
/**

@@ -70,0 +71,0 @@ * @see b2Shape::ComputeMass

@@ -168,4 +168,4 @@ "use strict";

proxy.m_vertices = proxy.m_buffer;
proxy.m_vertices[0].Copy(this.m_vertex1);
proxy.m_vertices[1].Copy(this.m_vertex2);
proxy.m_vertices[0] = this.m_vertex1;
proxy.m_vertices[1] = this.m_vertex2;
proxy.m_count = 2;

@@ -172,0 +172,0 @@ proxy.m_radius = this.m_radius;

import { b2Color, b2Draw } from "../common/b2_draw";
import { b2Vec2, b2Transform, XY } from "../common/b2_math";
import { b2AABB, b2RayCastInput, b2RayCastOutput } from "./b2_collision";
import { b2Readonly } from "../common/b2_readonly";
import { b2AABB, b2Hull, b2RayCastInput, b2RayCastOutput } from "./b2_collision";
import { b2DistanceProxy } from "./b2_distance";

@@ -28,11 +29,17 @@ import { b2MassData, b2Shape } from "./b2_shape";

/**
* Create a convex hull from the given array of points.
* Create a convex hull from the given array of local points.
* The count must be in the range [3, b2_maxPolygonVertices].
*
* @warning the points may be re-ordered, even if they form a convex polygon
* @warning collinear points are handled but not removed. Collinear points
* may lead to poor stacking behavior.
* @warning if this fails then the polygon is invalid
* @returns true if valid
*/
Set(vertices: XY[], count?: number): b2PolygonShape;
Set(vertices: XY[], count?: number): boolean;
/**
* Build vertices to represent an axis-aligned box or an oriented box.
* Create a polygon from a given convex hull (see b2ComputeHull).
* @warning the hull must be valid or this will crash or have unexpected behavior
*/
SetHull(hull: Readonly<b2Hull>, count: number): b2PolygonShape;
/**
* Build vertices to represent an axis-aligned box centered on the local origin.
*

@@ -48,3 +55,3 @@ * @param hx The half-width.

*/
TestPoint(xf: b2Transform, p: XY): boolean;
TestPoint(xf: b2Readonly<b2Transform>, p: XY): boolean;
/**

@@ -56,7 +63,7 @@ * Implement b2Shape.

*/
RayCast(output: b2RayCastOutput, input: b2RayCastInput, xf: b2Transform, _childIndex: number): boolean;
RayCast(output: b2RayCastOutput, input: b2RayCastInput, xf: b2Readonly<b2Transform>, _childIndex: number): boolean;
/**
* @see b2Shape::ComputeAABB
*/
ComputeAABB(aabb: b2AABB, xf: b2Transform, _childIndex: number): void;
ComputeAABB(aabb: b2AABB, xf: b2Readonly<b2Transform>, _childIndex: number): void;
/**

@@ -66,2 +73,6 @@ * @see b2Shape::ComputeMass

ComputeMass(massData: b2MassData, density: number): void;
/**
* Validate convexity. This is a very time consuming operation.
* @returns true if valid
*/
Validate(): boolean;

@@ -68,0 +79,0 @@ SetupDistanceProxy(proxy: b2DistanceProxy, _index: number): void;

@@ -25,2 +25,3 @@ "use strict";

const b2_settings_1 = require("../common/b2_settings");
const b2_collision_1 = require("./b2_collision");
const b2_shape_1 = require("./b2_shape");

@@ -65,3 +66,2 @@ const temp = {

};
const weldingDistanceSquared = (0.5 * b2_common_1.b2_linearSlop) ** 2;
function ComputeCentroid(vs, count, out) {

@@ -98,2 +98,3 @@ // DEBUG: b2Assert(count >= 3);

}
const setHull_s_edge = new b2_math_1.b2Vec2();
/**

@@ -139,92 +140,45 @@ * A solid convex polygon. It is assumed that the interior of the polygon is to

/**
* Create a convex hull from the given array of points.
* Create a convex hull from the given array of local points.
* The count must be in the range [3, b2_maxPolygonVertices].
*
* @warning the points may be re-ordered, even if they form a convex polygon
* @warning collinear points are handled but not removed. Collinear points
* may lead to poor stacking behavior.
* @warning if this fails then the polygon is invalid
* @returns true if valid
*/
Set(vertices, count = vertices.length) {
// DEBUG: b2Assert(3 <= count && count <= b2_maxPolygonVertices);
if (count < 3) {
return this.SetAsBox(1, 1);
const hull = (0, b2_collision_1.b2ComputeHull)(vertices, count);
if (hull.length < 3) {
return false;
}
let n = Math.min(count, b2_settings_1.b2_maxPolygonVertices);
// Perform welding and copy vertices into local buffer.
const ps = [];
for (let i = 0; i < n; ++i) {
const v = vertices[i];
const unique = ps.every((p) => b2_math_1.b2Vec2.DistanceSquared(v, p) >= weldingDistanceSquared);
if (unique) {
ps.push(v);
}
this.SetHull(hull, hull.length);
return true;
}
/**
* Create a polygon from a given convex hull (see b2ComputeHull).
* @warning the hull must be valid or this will crash or have unexpected behavior
*/
SetHull(hull, count) {
(0, b2_common_1.b2Assert)(count >= 3);
this.m_count = count;
// Copy vertices
this.m_vertices = (0, b2_common_1.b2MakeArray)(count, b2_math_1.b2Vec2);
for (let i = 0; i < count; ++i) {
this.m_vertices[i].Copy(hull[i]);
}
n = ps.length;
if (n < 3) {
// Polygon is degenerate.
// DEBUG: b2Assert(false);
return this.SetAsBox(1, 1);
}
// Create the convex hull using the Gift wrapping algorithm
// http://en.wikipedia.org/wiki/Gift_wrapping_algorithm
// Find the right most point on the hull
let i0 = 0;
let x0 = ps[0].x;
for (let i = 1; i < n; ++i) {
const { x } = ps[i];
if (x > x0 || (x === x0 && ps[i].y < ps[i0].y)) {
i0 = i;
x0 = x;
}
}
const hull = [];
let m = 0;
let ih = i0;
for (;;) {
// DEBUG: b2Assert(m < b2_maxPolygonVertices);
hull[m] = ih;
let ie = 0;
for (let j = 1; j < n; ++j) {
if (ie === ih) {
ie = j;
continue;
}
const r = b2_math_1.b2Vec2.Subtract(ps[ie], ps[hull[m]], temp.Set.r);
const v = b2_math_1.b2Vec2.Subtract(ps[j], ps[hull[m]], temp.Set.v);
const c = b2_math_1.b2Vec2.Cross(r, v);
if (c < 0) {
ie = j;
}
// Collinearity check
if (c === 0 && v.LengthSquared() > r.LengthSquared()) {
ie = j;
}
}
++m;
ih = ie;
if (ie === i0) {
break;
}
}
(0, b2_common_1.b2Assert)(m >= 3, "Polygon is degenerate");
this.m_count = m;
this.m_vertices = (0, b2_common_1.b2MakeArray)(this.m_count, b2_math_1.b2Vec2);
this.m_normals = (0, b2_common_1.b2MakeArray)(this.m_count, b2_math_1.b2Vec2);
// Copy vertices.
for (let i = 0; i < m; ++i) {
this.m_vertices[i].Copy(ps[hull[i]]);
}
// Compute normals. Ensure the edges have non-zero length.
for (let i = 0; i < m; ++i) {
this.m_normals = (0, b2_common_1.b2MakeArray)(count, b2_math_1.b2Vec2);
for (let i = 0; i < this.m_count; ++i) {
const i1 = i;
const i2 = i + 1 < m ? i + 1 : 0;
const edge = b2_math_1.b2Vec2.Subtract(this.m_vertices[i2], this.m_vertices[i1], b2_math_1.b2Vec2.s_t0);
// DEBUG: b2Assert(edge.LengthSquared() > b2_epsilon_sq);
b2_math_1.b2Vec2.CrossVec2One(edge, this.m_normals[i]).Normalize();
const i2 = i + 1 < this.m_count ? i + 1 : 0;
const edge = b2_math_1.b2Vec2.Subtract(this.m_vertices[i2], this.m_vertices[i1], setHull_s_edge);
// DEBUG: b2Assert(edge.LengthSquared() > b2_epsilon * b2_epsilon);
b2_math_1.b2Vec2.CrossVec2Scalar(edge, 1, this.m_normals[i]);
this.m_normals[i].Normalize();
}
// Compute the polygon centroid.
ComputeCentroid(this.m_vertices, m, this.m_centroid);
ComputeCentroid(this.m_vertices, this.m_count, this.m_centroid);
return this;
}
/**
* Build vertices to represent an axis-aligned box or an oriented box.
* Build vertices to represent an axis-aligned box centered on the local origin.
*

@@ -411,21 +365,11 @@ * @param hx The half-width.

}
/**
* Validate convexity. This is a very time consuming operation.
* @returns true if valid
*/
Validate() {
const { e, v } = temp.Validate;
for (let i = 0; i < this.m_count; ++i) {
const i1 = i;
const i2 = i < this.m_count - 1 ? i1 + 1 : 0;
const p = this.m_vertices[i1];
b2_math_1.b2Vec2.Subtract(this.m_vertices[i2], p, e);
for (let j = 0; j < this.m_count; ++j) {
if (j === i1 || j === i2) {
continue;
}
b2_math_1.b2Vec2.Subtract(this.m_vertices[j], p, v);
const c = b2_math_1.b2Vec2.Cross(e, v);
if (c < 0) {
return false;
}
}
if (this.m_count < 3 || b2_settings_1.b2_maxPolygonVertices < this.m_count) {
return false;
}
return true;
return (0, b2_collision_1.b2ValidateHull)(this.m_vertices, this.m_count);
}

@@ -432,0 +376,0 @@ SetupDistanceProxy(proxy, _index) {

import { b2Color, b2Draw } from "../common/b2_draw";
import { b2Vec2, b2Transform, XY } from "../common/b2_math";
import { b2Readonly } from "../common/b2_readonly";
import { b2AABB, b2RayCastInput, b2RayCastOutput } from "./b2_collision";

@@ -58,3 +59,3 @@ import { b2DistanceProxy } from "./b2_distance";

*/
abstract TestPoint(xf: b2Transform, p: XY): boolean;
abstract TestPoint(xf: b2Readonly<b2Transform>, p: XY): boolean;
/**

@@ -68,3 +69,3 @@ * Cast a ray against a child shape.

*/
abstract RayCast(output: b2RayCastOutput, input: b2RayCastInput, transform: b2Transform, childIndex: number): boolean;
abstract RayCast(output: b2RayCastOutput, input: b2RayCastInput, transform: b2Readonly<b2Transform>, childIndex: number): boolean;
/**

@@ -77,3 +78,3 @@ * Given a transform, compute the associated axis aligned bounding box for a child shape.

*/
abstract ComputeAABB(aabb: b2AABB, xf: b2Transform, childIndex: number): void;
abstract ComputeAABB(aabb: b2AABB, xf: b2Readonly<b2Transform>, childIndex: number): void;
/**

@@ -80,0 +81,0 @@ * Compute the mass properties of this shape using its dimensions and density.

@@ -28,3 +28,3 @@ "use strict";

b2ShapeType[b2ShapeType["e_typeCount"] = 4] = "e_typeCount";
})(b2ShapeType = exports.b2ShapeType || (exports.b2ShapeType = {}));
})(b2ShapeType || (exports.b2ShapeType = b2ShapeType = {}));
/**

@@ -31,0 +31,0 @@ * A shape is used for collision detection. You can create a shape however you like.

@@ -37,3 +37,11 @@ import { b2Sweep } from "../common/b2_math";

}
/**
* CCD via the local separating axis method. This seeks progression
* by computing the largest time at which separation is maintained.
* Compute the upper bound on time before two shapes penetrate. Time is represented as
* a fraction between [0,tMax]. This uses a swept separating axis and may miss some intermediate,
* again.
* Note: use b2Distance to compute the contact point and normal at the time of impact.
*/
export declare function b2TimeOfImpact(output: b2TOIOutput, input: b2TOIInput): void;
//# sourceMappingURL=b2_time_of_impact.d.ts.map

@@ -72,3 +72,3 @@ "use strict";

b2TOIOutputState[b2TOIOutputState["e_separated"] = 4] = "e_separated";
})(b2TOIOutputState = exports.b2TOIOutputState || (exports.b2TOIOutputState = {}));
})(b2TOIOutputState || (exports.b2TOIOutputState = b2TOIOutputState = {}));
/**

@@ -240,2 +240,10 @@ * Output parameters for b2TimeOfImpact.

const b2TimeOfImpact_s_sweepB = new b2_math_1.b2Sweep();
/**
* CCD via the local separating axis method. This seeks progression
* by computing the largest time at which separation is maintained.
* Compute the upper bound on time before two shapes penetrate. Time is represented as
* a fraction between [0,tMax]. This uses a swept separating axis and may miss some intermediate,
* again.
* Note: use b2Distance to compute the contact point and normal at the time of impact.
*/
function b2TimeOfImpact(output, input) {

@@ -242,0 +250,0 @@ const timer = b2TimeOfImpact_s_timer.Reset();

@@ -1,2 +0,2 @@

export declare type b2Augmentation<T extends {
export type b2Augmentation<T extends {
[s: string]: any;

@@ -9,5 +9,5 @@ }> = {

}>(host: T, augmentations: b2Augmentation<T>): void;
export declare type b2Writeable<T> = {
export type b2Writeable<T> = {
-readonly [P in keyof T]: T[P];
};
//# sourceMappingURL=b2_augment.d.ts.map

@@ -119,3 +119,3 @@ "use strict";

minor: 4,
patch: 0,
patch: 1,
};

@@ -122,0 +122,0 @@ function b2MakeNumberArray(length, init = 0) {

import { b2Transform, XY } from "./b2_math";
import { b2Readonly } from "./b2_readonly";
export interface RGB {

@@ -47,11 +48,21 @@ r: number;

export interface b2Draw {
PushTransform(xf: b2Transform): void;
PopTransform(xf: b2Transform): void;
DrawPolygon(vertices: XY[], vertexCount: number, color: RGBA): void;
DrawSolidPolygon(vertices: XY[], vertexCount: number, color: RGBA): void;
DrawCircle(center: XY, radius: number, color: RGBA): void;
DrawSolidCircle(center: XY, radius: number, axis: XY, color: RGBA): void;
DrawSegment(p1: XY, p2: XY, color: RGBA): void;
DrawTransform(xf: b2Transform): void;
DrawPoint(p: XY, size: number, color: RGBA): void;
PushTransform(xf: b2Readonly<b2Transform>): void;
PopTransform(xf: b2Readonly<b2Transform>): void;
/** Draw a closed polygon provided in CCW order. */
DrawPolygon(vertices: ReadonlyArray<Readonly<XY>>, vertexCount: number, color: RGBA): void;
/** Draw a solid closed polygon provided in CCW order. */
DrawSolidPolygon(vertices: ReadonlyArray<Readonly<XY>>, vertexCount: number, color: RGBA): void;
/** Draw a circle. */
DrawCircle(center: Readonly<XY>, radius: number, color: RGBA): void;
/** Draw a solid circle. */
DrawSolidCircle(center: Readonly<XY>, radius: number, axis: Readonly<XY>, color: RGBA): void;
/** Draw a line segment. */
DrawSegment(p1: Readonly<XY>, p2: Readonly<XY>, color: RGBA): void;
/**
* Draw a transform. Choose your own length scale.
* @param xf a transform.
*/
DrawTransform(xf: b2Readonly<b2Transform>): void;
/** Draw a point. */
DrawPoint(p: Readonly<XY>, size: number, color: RGBA): void;
}

@@ -58,0 +69,0 @@ export declare const debugColors: {

@@ -0,1 +1,2 @@

import type { b2Readonly } from "./b2_readonly";
export declare const b2_pi_over_180: number;

@@ -27,5 +28,5 @@ export declare const b2_180_over_pi: number;

export declare class b2Vec2 implements XY {
static readonly ZERO: Readonly<XY>;
static readonly UNITX: Readonly<XY>;
static readonly UNITY: Readonly<XY>;
static readonly ZERO: b2Readonly<b2Vec2>;
static readonly UNITX: b2Readonly<b2Vec2>;
static readonly UNITY: b2Readonly<b2Vec2>;
static readonly s_t0: b2Vec2;

@@ -47,7 +48,7 @@ static readonly s_t1: b2Vec2;

Set(x: number, y: number): this;
Copy(other: XY): this;
Copy(other: Readonly<XY>): this;
/**
* Add a vector to this vector.
*/
Add(v: XY): this;
Add(v: Readonly<XY>): this;
/**

@@ -60,3 +61,3 @@ * Add a vector to this vector.

*/
Subtract(v: XY): this;
Subtract(v: Readonly<XY>): this;
/**

@@ -70,12 +71,12 @@ * Subtract a vector from this vector.

Scale(s: number): this;
AddScaled(s: number, v: XY): this;
SubtractScaled(s: number, v: XY): this;
AddScaled(s: number, v: Readonly<XY>): this;
SubtractScaled(s: number, v: Readonly<XY>): this;
/**
* Perform the dot product on two vectors.
*/
Dot(v: XY): number;
Dot(v: Readonly<XY>): number;
/**
* Perform the cross product on two vectors. In 2D this produces a scalar.
*/
Cross(v: XY): number;
Cross(v: Readonly<XY>): number;
/**

@@ -110,8 +111,10 @@ * Get the length of this vector (the norm).

Skew(): this;
static Min<T extends XY>(a: XY, b: XY, out: T): T;
static Max<T extends XY>(a: XY, b: XY, out: T): T;
static Clamp<T extends XY>(v: XY, lo: XY, hi: XY, out: T): T;
static Rotate<T extends XY>(v: XY, radians: number, out: T): T;
static Dot(a: XY, b: XY): number;
static Cross(a: XY, b: XY): number;
static Min<T extends XY>(a: Readonly<XY>, b: Readonly<XY>, out: T): T;
static Max<T extends XY>(a: Readonly<XY>, b: Readonly<XY>, out: T): T;
static Clamp<T extends XY>(v: Readonly<XY>, lo: Readonly<XY>, hi: Readonly<XY>, out: T): T;
static Rotate<T extends XY>(v: Readonly<XY>, radians: number, out: T): T;
/** Perform the dot product on two vectors. */
static Dot(a: Readonly<XY>, b: Readonly<XY>): number;
/** Perform the cross product on two vectors. In 2D this produces a scalar. */
static Cross(a: Readonly<XY>, b: Readonly<XY>): number;
/**

@@ -121,4 +124,4 @@ * Perform the cross product on a vector and a scalar. In 2D this produces

*/
static CrossVec2Scalar<T extends XY>(v: XY, s: number, out: T): T;
static CrossVec2One<T extends XY>(v: XY, out: T): T;
static CrossVec2Scalar<T extends XY>(v: Readonly<XY>, s: number, out: T): T;
static CrossVec2One<T extends XY>(v: Readonly<XY>, out: T): T;
/**

@@ -128,30 +131,30 @@ * Perform the cross product on a scalar and a vector. In 2D this produces

*/
static CrossScalarVec2<T extends XY>(s: number, v: XY, out: T): T;
static CrossOneVec2<T extends XY>(v: XY, out: T): T;
static CrossScalarVec2<T extends XY>(s: number, v: Readonly<XY>, out: T): T;
static CrossOneVec2<T extends XY>(v: Readonly<XY>, out: T): T;
/**
* Add two vectors component-wise.
*/
static Add<T extends XY>(a: XY, b: XY, out: T): T;
static Add<T extends XY>(a: Readonly<XY>, b: Readonly<XY>, out: T): T;
/**
* Subtract two vectors component-wise.
*/
static Subtract<T extends XY>(a: XY, b: XY, out: T): T;
static Scale<T extends XY>(s: number, v: XY, out: T): T;
static AddScaled<T extends XY>(a: XY, s: number, b: XY, out: T): T;
static SubtractScaled<T extends XY>(a: XY, s: number, b: XY, out: T): T;
static AddCrossScalarVec2<T extends XY>(a: XY, s: number, v: XY, out: T): T;
static Mid<T extends XY>(a: XY, b: XY, out: T): T;
static Extents<T extends XY>(a: XY, b: XY, out: T): T;
static Equals(a: XY, b: XY): boolean;
static Distance(a: XY, b: XY): number;
static DistanceSquared(a: XY, b: XY): number;
static Subtract<T extends XY>(a: Readonly<XY>, b: Readonly<XY>, out: T): T;
static Scale<T extends XY>(s: number, v: Readonly<XY>, out: T): T;
static AddScaled<T extends XY>(a: Readonly<XY>, s: number, b: Readonly<XY>, out: T): T;
static SubtractScaled<T extends XY>(a: Readonly<XY>, s: number, b: Readonly<XY>, out: T): T;
static AddCrossScalarVec2<T extends XY>(a: Readonly<XY>, s: number, v: Readonly<XY>, out: T): T;
static Mid<T extends XY>(a: Readonly<XY>, b: Readonly<XY>, out: T): T;
static Extents<T extends XY>(a: Readonly<XY>, b: Readonly<XY>, out: T): T;
static Equals(a: Readonly<XY>, b: Readonly<XY>): boolean;
static Distance(a: Readonly<XY>, b: Readonly<XY>): number;
static DistanceSquared(a: Readonly<XY>, b: Readonly<XY>): number;
/**
* Negate a vector.
*/
static Negate<T extends XY>(v: XY, out: T): T;
static Normalize<T extends XY>(v: XY, out: T): T;
static Negate<T extends XY>(v: Readonly<XY>, out: T): T;
static Normalize<T extends XY>(v: Readonly<XY>, out: T): T;
/**
* Skew a vector such that dot(skew_vec, other) == cross(vec, other)
*/
static Skew<T extends XY>(v: XY, out: T): T;
static Skew<T extends XY>(v: Readonly<XY>, out: T): T;
}

@@ -165,3 +168,3 @@ export interface XYZ extends XY {

export declare class b2Vec3 implements XYZ {
static readonly ZERO: Readonly<XYZ>;
static readonly ZERO: b2Readonly<b2Vec3>;
static readonly s_t0: b2Vec3;

@@ -181,3 +184,3 @@ x: number;

Set(x: number, y: number, z: number): this;
Copy(other: XYZ): this;
Copy(other: Readonly<XYZ>): this;
/**

@@ -190,3 +193,3 @@ * Negate this vector.

*/
Add(v: XYZ): this;
Add(v: Readonly<XYZ>): this;
/**

@@ -199,3 +202,3 @@ * Add a vector to this vector.

*/
Subtract(v: XYZ): this;
Subtract(v: Readonly<XYZ>): this;
/**

@@ -212,7 +215,7 @@ * Subtract a vector from this vector.

*/
static Dot(a: XYZ, b: XYZ): number;
static Dot(a: Readonly<XYZ>, b: Readonly<XYZ>): number;
/**
* Perform the cross product on two vectors.
*/
static Cross<T extends XYZ>(a: XYZ, b: XYZ, out: T): T;
static Cross<T extends XYZ>(a: Readonly<XYZ>, b: Readonly<XYZ>, out: T): T;
}

@@ -223,3 +226,3 @@ /**

export declare class b2Mat22 {
static readonly IDENTITY: Readonly<b2Mat22>;
static readonly IDENTITY: b2Readonly<b2Mat22>;
readonly ex: b2Vec2;

@@ -231,3 +234,3 @@ readonly ey: b2Vec2;

*/
static FromColumns(c1: XY, c2: XY): b2Mat22;
static FromColumns(c1: Readonly<XY>, c2: Readonly<XY>): b2Mat22;
/**

@@ -245,5 +248,5 @@ * Construct a matrix using scalars.

*/
SetColumns(c1: XY, c2: XY): this;
SetColumns(c1: Readonly<XY>, c2: Readonly<XY>): this;
SetAngle(radians: number): this;
Copy(other: b2Mat22): this;
Copy(other: b2Readonly<b2Mat22>): this;
/**

@@ -265,4 +268,4 @@ * Set this to the identity matrix.

Inverse(): this;
Add(M: b2Mat22): this;
Subtract(M: b2Mat22): this;
Add(M: b2Readonly<b2Mat22>): this;
Subtract(M: b2Readonly<b2Mat22>): this;
GetInverse(out: b2Mat22): b2Mat22;

@@ -274,3 +277,3 @@ GetAbs(out: b2Mat22): b2Mat22;

*/
static MultiplyVec2<T extends XY>(M: b2Mat22, v: XY, out: T): T;
static MultiplyVec2<T extends XY>(M: b2Readonly<b2Mat22>, v: Readonly<XY>, out: T): T;
/**

@@ -280,8 +283,8 @@ * Multiply a matrix transpose times a vector. If a rotation matrix is provided,

*/
static TransposeMultiplyVec2<T extends XY>(M: b2Mat22, v: XY, out: T): T;
static Add(A: b2Mat22, B: b2Mat22, out: b2Mat22): b2Mat22;
static TransposeMultiplyVec2<T extends XY>(M: b2Readonly<b2Mat22>, v: Readonly<XY>, out: T): T;
static Add(A: b2Readonly<b2Mat22>, B: b2Readonly<b2Mat22>, out: b2Mat22): b2Mat22;
/** A * B */
static Multiply(A: b2Mat22, B: b2Mat22, out: b2Mat22): b2Mat22;
static Multiply(A: b2Readonly<b2Mat22>, B: b2Readonly<b2Mat22>, out: b2Mat22): b2Mat22;
/** A^T * B */
static TransposeMultiply(A: b2Mat22, B: b2Mat22, out: b2Mat22): b2Mat22;
static TransposeMultiply(A: b2Readonly<b2Mat22>, B: b2Readonly<b2Mat22>, out: b2Mat22): b2Mat22;
}

@@ -292,3 +295,3 @@ /**

export declare class b2Mat33 {
static readonly IDENTITY: Readonly<b2Mat33>;
static readonly IDENTITY: b2Readonly<b2Mat33>;
readonly ex: b2Vec3;

@@ -301,4 +304,4 @@ readonly ey: b2Vec3;

*/
SetColumns(c1: XYZ, c2: XYZ, c3: XYZ): this;
Copy(other: b2Mat33): this;
SetColumns(c1: Readonly<XYZ>, c2: Readonly<XYZ>, c3: Readonly<XYZ>): this;
Copy(other: b2Readonly<b2Mat33>): this;
SetIdentity(): this;

@@ -309,3 +312,3 @@ /**

SetZero(): this;
Add(M: b2Mat33): this;
Add(M: b2Readonly<b2Mat33>): this;
/**

@@ -335,7 +338,7 @@ * Solve A * x = b, where b is a column vector. This is more efficient

*/
static MultiplyVec3<T extends XYZ>(A: b2Mat33, v: XYZ, out: T): T;
static MultiplyVec3<T extends XYZ>(A: b2Readonly<b2Mat33>, v: Readonly<XYZ>, out: T): T;
/**
* Multiply a matrix times a vector.
*/
static MultiplyVec2<T extends XY>(A: b2Mat33, v: XY, out: T): T;
static MultiplyVec2<T extends XY>(A: b2Readonly<b2Mat33>, v: Readonly<XY>, out: T): T;
}

@@ -346,3 +349,3 @@ /**

export declare class b2Rot {
static readonly IDENTITY: Readonly<b2Rot>;
static readonly IDENTITY: b2Readonly<b2Rot>;
/** Sine */

@@ -357,3 +360,3 @@ s: number;

Clone(): b2Rot;
Copy(other: b2Rot): this;
Copy(other: b2Readonly<b2Rot>): this;
/**

@@ -382,15 +385,15 @@ * Set using an angle in radians.

*/
static Multiply(q: b2Rot, r: b2Rot, out: b2Rot): b2Rot;
static Multiply(q: b2Readonly<b2Rot>, r: b2Readonly<b2Rot>, out: b2Rot): b2Rot;
/**
* Transpose multiply two rotations: qT * r
*/
static TransposeMultiply(q: b2Rot, r: b2Rot, out: b2Rot): b2Rot;
static TransposeMultiply(q: b2Readonly<b2Rot>, r: b2Readonly<b2Rot>, out: b2Rot): b2Rot;
/**
* Rotate a vector
*/
static MultiplyVec2<T extends XY>(q: b2Rot, v: XY, out: T): T;
static MultiplyVec2<T extends XY>(q: b2Readonly<b2Rot>, v: Readonly<XY>, out: T): T;
/**
* Inverse rotate a vector
*/
static TransposeMultiplyVec2<T extends XY>(q: b2Rot, v: XY, out: T): T;
static TransposeMultiplyVec2<T extends XY>(q: b2Readonly<b2Rot>, v: Readonly<XY>, out: T): T;
}

@@ -402,7 +405,7 @@ /**

export declare class b2Transform {
static readonly IDENTITY: Readonly<b2Transform>;
static readonly IDENTITY: b2Readonly<b2Transform>;
readonly p: b2Vec2;
readonly q: b2Rot;
Clone(): b2Transform;
Copy(other: b2Transform): this;
Copy(other: b2Readonly<b2Transform>): this;
/**

@@ -415,16 +418,16 @@ * Set this to the identity transform.

*/
SetPositionRotation(position: XY, q: Readonly<b2Rot>): this;
SetPositionRotation(position: Readonly<XY>, q: b2Readonly<b2Rot>): this;
/**
* Set this based on the position and angle.
*/
SetPositionAngle(pos: XY, a: number): this;
SetPosition(position: XY): this;
SetPositionAngle(pos: Readonly<XY>, a: number): this;
SetPosition(position: Readonly<XY>): this;
SetPositionXY(x: number, y: number): this;
SetRotation(rotation: Readonly<b2Rot>): this;
SetRotation(rotation: b2Readonly<b2Rot>): this;
SetRotationAngle(radians: number): this;
GetPosition(): Readonly<b2Vec2>;
GetRotation(): Readonly<b2Rot>;
GetPosition(): b2Readonly<b2Vec2>;
GetRotation(): b2Readonly<b2Rot>;
GetAngle(): number;
static MultiplyVec2<T extends XY>(T: b2Transform, v: Readonly<XY>, out: T): T;
static TransposeMultiplyVec2<T extends XY>(T: b2Transform, v: Readonly<XY>, out: T): T;
static MultiplyVec2<T extends XY>(T: b2Readonly<b2Transform>, v: Readonly<XY>, out: T): T;
static TransposeMultiplyVec2<T extends XY>(T: b2Readonly<b2Transform>, v: Readonly<XY>, out: T): T;
/**

@@ -434,3 +437,3 @@ * v2 = A.q.Rot(B.q.Rot(v1) + B.p) + A.p

*/
static Multiply(A: b2Transform, B: b2Transform, out: b2Transform): b2Transform;
static Multiply(A: b2Readonly<b2Transform>, B: b2Readonly<b2Transform>, out: b2Transform): b2Transform;
/**

@@ -440,3 +443,3 @@ * v2 = A.q' * (B.q * v1 + B.p - A.p)

*/
static TransposeMultiply(A: b2Transform, B: b2Transform, out: b2Transform): b2Transform;
static TransposeMultiply(A: b2Readonly<b2Transform>, B: b2Readonly<b2Transform>, out: b2Transform): b2Transform;
}

@@ -443,0 +446,0 @@ /**

@@ -5,19 +5,2 @@ "use strict";

exports.b2Sweep = exports.b2Transform = exports.b2Rot = exports.b2Mat33 = exports.b2Mat22 = exports.b2Vec3 = exports.b2Vec2 = exports.b2RandomInt = exports.b2RandomFloat = exports.b2Random = exports.b2IsPowerOfTwo = exports.b2NextPowerOfTwo = exports.b2RadToDeg = exports.b2DegToRad = exports.b2Clamp = exports.b2_two_pi = exports.b2_180_over_pi = exports.b2_pi_over_180 = void 0;
// Copyright (c) 2019 Erin Catto
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// DEBUG: import { b2Assert } from "./b2_common";
const b2_common_1 = require("./b2_common");

@@ -266,5 +249,7 @@ exports.b2_pi_over_180 = Math.PI / 180;

}
/** Perform the dot product on two vectors. */
static Dot(a, b) {
return a.x * b.x + a.y * b.y;
}
/** Perform the cross product on two vectors. In 2D this produces a scalar. */
static Cross(a, b) {

@@ -271,0 +256,0 @@ return a.x * b.y - a.y * b.x;

@@ -5,3 +5,3 @@ /**

*/
export declare const b2_lengthUnitsPerMeter = 1;
export declare const b2_lengthUnitsPerMeter: number;
/**

@@ -11,3 +11,3 @@ * The maximum number of vertices on a convex polygon. You cannot increase

*/
export declare const b2_maxPolygonVertices = 8;
export declare const b2_maxPolygonVertices: number;
//# sourceMappingURL=b2_settings.d.ts.map

@@ -5,2 +5,3 @@ "use strict";

exports.b2_maxPolygonVertices = exports.b2_lengthUnitsPerMeter = void 0;
const config_1 = require("../config");
// Copyright (c) 2019 Erin Catto

@@ -23,3 +24,2 @@ // Permission is hereby granted, free of charge, to any person obtaining a copy

// Tunable Constants
// TODO: Make this overridable by user as box2d allows it too.
/**

@@ -29,3 +29,3 @@ * You can use this to change the length scale used by your game.

*/
exports.b2_lengthUnitsPerMeter = 1;
exports.b2_lengthUnitsPerMeter = config_1.settings.lengthUnitsPerMeter;
/**

@@ -35,2 +35,2 @@ * The maximum number of vertices on a convex polygon. You cannot increase

*/
exports.b2_maxPolygonVertices = 8;
exports.b2_maxPolygonVertices = config_1.settings.maxPolygonVertices;

@@ -7,2 +7,4 @@ import { b2Vec2, b2Transform, XY } from "../common/b2_math";

import type { b2World } from "./b2_world";
import type { b2BodyUserData } from "..";
import { b2Readonly } from "../common/b2_readonly";
/**

@@ -74,3 +76,3 @@ * The body type.

/** Use this to store application specific body data. */
userData?: any;
userData?: b2BodyUserData;
/** Scale the gravity applied to this body. */

@@ -113,3 +115,3 @@ gravityScale?: number;

private m_sleepTime;
private m_userData;
private readonly m_userData;
private constructor();

@@ -148,3 +150,3 @@ /**

SetTransformXY(x: number, y: number, angle: number): void;
SetTransform(xf: b2Transform): void;
SetTransform(xf: b2Readonly<b2Transform>): void;
/**

@@ -155,3 +157,3 @@ * Get the body transform for the body's origin.

*/
GetTransform(): Readonly<b2Transform>;
GetTransform(): b2Readonly<b2Transform>;
/**

@@ -162,3 +164,3 @@ * Get the world body origin position.

*/
GetPosition(): Readonly<b2Vec2>;
GetPosition(): b2Readonly<b2Vec2>;
/**

@@ -174,7 +176,7 @@ * Get the angle in radians.

*/
GetWorldCenter(): Readonly<b2Vec2>;
GetWorldCenter(): b2Readonly<b2Vec2>;
/**
* Get the local position of the center of mass.
*/
GetLocalCenter(): Readonly<b2Vec2>;
GetLocalCenter(): b2Readonly<b2Vec2>;
/**

@@ -191,3 +193,3 @@ * Set the linear velocity of the center of mass.

*/
GetLinearVelocity(): Readonly<b2Vec2>;
GetLinearVelocity(): b2Readonly<b2Vec2>;
/**

@@ -241,3 +243,3 @@ * Set the angular velocity.

/**
* Apply an impulse at the center of gravity. This immediately modifies the velocity.
* Apply an impulse to the center of mass. This immediately modifies the velocity.
*

@@ -393,3 +395,3 @@ * @param impulse The world impulse vector, usually in N-seconds or kg-m/s.

*
* @returns true if the body is sleeping.
* @returns true if the body is awake.
*/

@@ -445,9 +447,10 @@ IsAwake(): boolean;

/**
* Get the user data pointer that was provided in the body definition.
* Get the user data reference that was provided in the body definition.
*/
GetUserData(): any;
GetUserData(): b2BodyUserData;
/**
* Set the user data. Use this to store your application specific data.
* This is a merge operation. Only specified keys will be overridden.
*/
SetUserData(data: any): void;
SetUserData(data: b2BodyUserData): void;
/**

@@ -454,0 +457,0 @@ * Get the parent world of this body.

@@ -37,3 +37,3 @@ "use strict";

b2BodyType[b2BodyType["b2_dynamicBody"] = 2] = "b2_dynamicBody";
})(b2BodyType = exports.b2BodyType || (exports.b2BodyType = {}));
})(b2BodyType || (exports.b2BodyType = b2BodyType = {}));
/**

@@ -108,3 +108,3 @@ * A rigid body. These are created via b2World::CreateBody.

/** @internal */
this.m_userData = null;
this.m_userData = {};
this.m_bulletFlag = (_a = bd.bullet) !== null && _a !== void 0 ? _a : false;

@@ -138,3 +138,4 @@ this.m_fixedRotationFlag = (_b = bd.fixedRotation) !== null && _b !== void 0 ? _b : false;

this.m_invI = 0;
this.m_userData = bd.userData;
if (bd.userData)
this.SetUserData(bd.userData);
this.m_fixtureList = null;

@@ -206,2 +207,3 @@ this.m_fixtureCount = 0;

// DEBUG: b2Assert(found);
const density = fixture.m_density;
// Destroy any contacts associated with the fixture.

@@ -228,3 +230,6 @@ let edge = this.m_contactList;

// Reset the mass data.
this.ResetMassData();
// Reset the mass data
if (density > 0.0) {
this.ResetMassData();
}
}

@@ -429,3 +434,3 @@ /**

/**
* Apply an impulse at the center of gravity. This immediately modifies the velocity.
* Apply an impulse to the center of mass. This immediately modifies the velocity.
*

@@ -768,3 +773,3 @@ * @param impulse The world impulse vector, usually in N-seconds or kg-m/s.

*
* @returns true if the body is sleeping.
* @returns true if the body is awake.
*/

@@ -870,3 +875,3 @@ IsAwake() {

/**
* Get the user data pointer that was provided in the body definition.
* Get the user data reference that was provided in the body definition.
*/

@@ -878,5 +883,6 @@ GetUserData() {

* Set the user data. Use this to store your application specific data.
* This is a merge operation. Only specified keys will be overridden.
*/
SetUserData(data) {
this.m_userData = data;
Object.assign(this.m_userData, data);
}

@@ -883,0 +889,0 @@ /**

import { b2Contact } from "./b2_contact";
import { b2Fixture } from "./b2_fixture";
declare type CreateFcn = (fixtureA: b2Fixture, indexA: number, fixtureB: b2Fixture, indexB: number) => b2Contact;
declare type DestroyFcn = (contact: b2Contact) => void;
export declare type b2ContactRegister = undefined | {
type CreateFcn = (fixtureA: b2Fixture, indexA: number, fixtureB: b2Fixture, indexB: number) => b2Contact;
type DestroyFcn = (contact: b2Contact) => void;
export type b2ContactRegister = undefined | {
createFcn: CreateFcn;

@@ -7,0 +7,0 @@ destroyFcn: DestroyFcn;

@@ -239,2 +239,3 @@ "use strict";

}
/** Initialize position dependent portions of the velocity constraints. */
InitializeVelocityConstraints() {

@@ -581,2 +582,3 @@ const xfA = b2ContactSolver.InitializeVelocityConstraints_s_xfA;

}
/** Sequential solver. */
SolvePositionConstraints() {

@@ -636,2 +638,3 @@ const xfA = b2ContactSolver.SolvePositionConstraints_s_xfA;

}
/** Sequential position solver for position constraints. */
SolveTOIPositionConstraints(toiIndexA, toiIndexB) {

@@ -638,0 +641,0 @@ const xfA = b2ContactSolver.SolveTOIPositionConstraints_s_xfA;

@@ -7,2 +7,3 @@ import { b2Transform } from "../common/b2_math";

import type { b2ContactListener } from "./b2_world_callbacks";
import { b2Readonly } from "../common/b2_readonly";
/**

@@ -95,21 +96,57 @@ * Friction mixing law. The idea is to allow either fixture to drive the friction to zero.

protected m_oldManifold: b2Manifold;
/**
* Get the contact manifold.
* Do not modify the manifold unless you understand the internals of Box2D.
*/
GetManifold(): b2Manifold;
/** Get the world manifold. */
GetWorldManifold(worldManifold: b2WorldManifold): void;
/** Is this contact touching? */
IsTouching(): boolean;
/**
* Enable/disable this contact. This can be used inside the pre-solve
* contact listener. The contact is only disabled for the current
* time step (or sub-step in continuous collisions).
*/
SetEnabled(flag: boolean): void;
/** Has this contact been disabled? */
IsEnabled(): boolean;
/** Get the next contact in the world's contact list. */
GetNext(): b2Contact | null;
/** Get fixture A in this contact. */
GetFixtureA(): b2Fixture;
/** Get the child primitive index for fixture A. */
GetChildIndexA(): number;
/** Get fixture A in this contact. */
GetShapeA(): A;
/** Get fixture B in this contact. */
GetFixtureB(): b2Fixture;
/** Get the child primitive index for fixture B. */
GetChildIndexB(): number;
GetShapeB(): B;
abstract Evaluate(manifold: b2Manifold, xfA: b2Transform, xfB: b2Transform): void;
/** Evaluate this contact with your own manifold and transforms. */
abstract Evaluate(manifold: b2Manifold, xfA: b2Readonly<b2Transform>, xfB: b2Readonly<b2Transform>): void;
/**
* Flag this contact for filtering. Filtering will occur the next time step.
*/
protected FlagForFiltering(): void;
/**
* Override the default friction mixture.
* You can call this in b2ContactListener::PreSolve.
* This value persists until set or reset.
*/
SetFriction(friction: number): void;
/** Get the friction. */
GetFriction(): number;
/** Reset the friction mixture to the default value. */
ResetFriction(): void;
/**
* Override the default restitution mixture.
* You can call this in b2ContactListener::PreSolve.
* The value persists until you set or reset.
*/
SetRestitution(restitution: number): void;
/** Get the restitution. */
GetRestitution(): number;
/** Reset the restitution to the default value. */
ResetRestitution(): void;

@@ -129,7 +166,13 @@ /**

ResetRestitutionThreshold(): void;
/** Set the desired tangent speed for a conveyor belt behavior. In meters per second. */
SetTangentSpeed(speed: number): void;
/** Get the desired tangent speed. In meters per second. */
GetTangentSpeed(): number;
Reset(fixtureA: b2Fixture, indexA: number, fixtureB: b2Fixture, indexB: number): void;
/**
* Update the contact manifold and touching status.
* Note: do not assume the fixture AABBs are overlapping or are valid.
*/
protected Update(listener: b2ContactListener): void;
}
//# sourceMappingURL=b2_contact.d.ts.map

@@ -54,2 +54,10 @@ "use strict";

class b2ContactEdge {
get other() {
(0, b2_common_1.b2Assert)(this.m_other !== null);
return this.m_other;
}
set other(value) {
(0, b2_common_1.b2Assert)(this.m_other === null);
this.m_other = value;
}
constructor(contact) {

@@ -64,10 +72,2 @@ /** Provides quick access to the other body attached. */

}
get other() {
(0, b2_common_1.b2Assert)(this.m_other !== null);
return this.m_other;
}
set other(value) {
(0, b2_common_1.b2Assert)(this.m_other === null);
this.m_other = value;
}
Reset() {

@@ -159,5 +159,10 @@ this.m_other = null;

}
/**
* Get the contact manifold.
* Do not modify the manifold unless you understand the internals of Box2D.
*/
GetManifold() {
return this.m_manifold;
}
/** Get the world manifold. */
GetWorldManifold(worldManifold) {

@@ -170,26 +175,39 @@ const bodyA = this.m_fixtureA.GetBody();

}
/** Is this contact touching? */
IsTouching() {
return this.m_touchingFlag;
}
/**
* Enable/disable this contact. This can be used inside the pre-solve
* contact listener. The contact is only disabled for the current
* time step (or sub-step in continuous collisions).
*/
SetEnabled(flag) {
this.m_enabledFlag = flag;
}
/** Has this contact been disabled? */
IsEnabled() {
return this.m_enabledFlag;
}
/** Get the next contact in the world's contact list. */
GetNext() {
return this.m_next;
}
/** Get fixture A in this contact. */
GetFixtureA() {
return this.m_fixtureA;
}
/** Get the child primitive index for fixture A. */
GetChildIndexA() {
return this.m_indexA;
}
/** Get fixture A in this contact. */
GetShapeA() {
return this.m_fixtureA.GetShape();
}
/** Get fixture B in this contact. */
GetFixtureB() {
return this.m_fixtureB;
}
/** Get the child primitive index for fixture B. */
GetChildIndexB() {

@@ -201,21 +219,39 @@ return this.m_indexB;

}
/** @internal protected */
/**
* Flag this contact for filtering. Filtering will occur the next time step.
*
* @internal protected
*/
FlagForFiltering() {
this.m_filterFlag = true;
}
/**
* Override the default friction mixture.
* You can call this in b2ContactListener::PreSolve.
* This value persists until set or reset.
*/
SetFriction(friction) {
this.m_friction = friction;
}
/** Get the friction. */
GetFriction() {
return this.m_friction;
}
/** Reset the friction mixture to the default value. */
ResetFriction() {
this.m_friction = b2MixFriction(this.m_fixtureA.m_friction, this.m_fixtureB.m_friction);
}
/**
* Override the default restitution mixture.
* You can call this in b2ContactListener::PreSolve.
* The value persists until you set or reset.
*/
SetRestitution(restitution) {
this.m_restitution = restitution;
}
/** Get the restitution. */
GetRestitution() {
return this.m_restitution;
}
/** Reset the restitution to the default value. */
ResetRestitution() {

@@ -243,5 +279,7 @@ this.m_restitution = b2MixRestitution(this.m_fixtureA.m_restitution, this.m_fixtureB.m_restitution);

}
/** Set the desired tangent speed for a conveyor belt behavior. In meters per second. */
SetTangentSpeed(speed) {
this.m_tangentSpeed = speed;
}
/** Get the desired tangent speed. In meters per second. */
GetTangentSpeed() {

@@ -271,3 +309,8 @@ return this.m_tangentSpeed;

}
/** @internal protected */
/**
* Update the contact manifold and touching status.
* Note: do not assume the fixture AABBs are overlapping or are valid.
*
* @internal protected
*/
Update(listener) {

@@ -274,0 +317,0 @@ const tManifold = this.m_oldManifold;

@@ -6,2 +6,3 @@ import { b2Vec2, XY } from "../common/b2_math";

import { b2Draw } from "../common/b2_draw";
import { b2Readonly } from "../common/b2_readonly";
export interface b2IDistanceJointDef extends b2IJointDef {

@@ -38,2 +39,6 @@ localAnchorA: XY;

constructor();
/**
* Initialize the bodies, anchors, and rest length using world space anchors.
* The minimum and maximum lengths are set to the rest length.
*/
Initialize(b1: b2Body, b2: b2Body, anchor1: XY, anchor2: XY): void;

@@ -75,16 +80,46 @@ }

GetAnchorB<T extends XY>(out: T): T;
/**
* Get the reaction force given the inverse time step.
* Unit is N.
*/
GetReactionForce<T extends XY>(inv_dt: number, out: T): T;
/**
* Get the reaction torque given the inverse time step.
* Unit is N*m. This is always zero for a distance joint.
*/
GetReactionTorque(_inv_dt: number): number;
GetLocalAnchorA(): Readonly<b2Vec2>;
GetLocalAnchorB(): Readonly<b2Vec2>;
/** The local anchor point relative to bodyA's origin. */
GetLocalAnchorA(): b2Readonly<b2Vec2>;
/** The local anchor point relative to bodyB's origin. */
GetLocalAnchorB(): b2Readonly<b2Vec2>;
/**
* Set the rest length
* @returns clamped rest length
*/
SetLength(length: number): number;
/** Get the rest length */
GetLength(): number;
/**
* Set the minimum length
* @returns the clamped minimum length
*/
SetMinLength(minLength: number): number;
/** Get the minimum length */
GetMinLength(): number;
/**
* Set the maximum length
* @returns the clamped maximum length
*/
SetMaxLength(maxLength: number): number;
/** Get the maximum length */
GetMaxLength(): number;
/** Get the current length */
GetCurrentLength(): number;
/** Set the linear stiffness in N/m */
SetStiffness(stiffness: number): void;
/** Get the linear stiffness in N/m */
GetStiffness(): number;
/** Set linear damping in N*s/m */
SetDamping(damping: number): void;
/** Get linear damping in N*s/m */
GetDamping(): number;

@@ -91,0 +126,0 @@ protected InitVelocityConstraints(data: b2SolverData): void;

@@ -25,2 +25,14 @@ "use strict";

const b2_draw_1 = require("../common/b2_draw");
// 1-D constrained system
// m (v2 - v1) = lambda
// v2 + (beta/h) * x1 + gamma * lambda = 0, gamma has units of inverse mass.
// x2 = x1 + h * v2
// 1-D mass-damper-spring system
// m (v2 - v1) + h * d * v2 + h * k *
// C = norm(p2 - p1) - L
// u = (p2 - p1) / norm(p2 - p1)
// Cdot = dot(u, v2 + cross(w2, r2) - v1 - cross(w1, r1))
// J = [-u -cross(r1, u) u cross(r2, u)]
// K = J * invM * JT
// = invMass1 + invI1 * cross(r1, u)^2 + invMass2 + invI2 * cross(r2, u)^2
const temp = {

@@ -70,2 +82,6 @@ worldPointA: new b2_math_1.b2Vec2(),

}
/**
* Initialize the bodies, anchors, and rest length using world space anchors.
* The minimum and maximum lengths are set to the rest length.
*/
Initialize(b1, b2, anchor1, anchor2) {

@@ -128,2 +144,6 @@ this.bodyA = b1;

}
/**
* Get the reaction force given the inverse time step.
* Unit is N.
*/
GetReactionForce(inv_dt, out) {

@@ -135,11 +155,21 @@ const f = inv_dt * (this.m_impulse + this.m_lowerImpulse - this.m_upperImpulse);

}
/**
* Get the reaction torque given the inverse time step.
* Unit is N*m. This is always zero for a distance joint.
*/
GetReactionTorque(_inv_dt) {
return 0;
}
/** The local anchor point relative to bodyA's origin. */
GetLocalAnchorA() {
return this.m_localAnchorA;
}
/** The local anchor point relative to bodyB's origin. */
GetLocalAnchorB() {
return this.m_localAnchorB;
}
/**
* Set the rest length
* @returns clamped rest length
*/
SetLength(length) {

@@ -150,5 +180,10 @@ this.m_impulse = 0;

}
/** Get the rest length */
GetLength() {
return this.m_length;
}
/**
* Set the minimum length
* @returns the clamped minimum length
*/
SetMinLength(minLength) {

@@ -159,5 +194,10 @@ this.m_lowerImpulse = 0;

}
/** Get the minimum length */
GetMinLength() {
return this.m_minLength;
}
/**
* Set the maximum length
* @returns the clamped maximum length
*/
SetMaxLength(maxLength) {

@@ -168,5 +208,7 @@ this.m_upperImpulse = 0;

}
/** Get the maximum length */
GetMaxLength() {
return this.m_maxLength;
}
/** Get the current length */
GetCurrentLength() {

@@ -177,11 +219,15 @@ const pA = this.m_bodyA.GetWorldPoint(this.m_localAnchorA, temp.worldPointA);

}
/** Set the linear stiffness in N/m */
SetStiffness(stiffness) {
this.m_stiffness = stiffness;
}
/** Get the linear stiffness in N/m */
GetStiffness() {
return this.m_stiffness;
}
/** Set linear damping in N*s/m */
SetDamping(damping) {
this.m_damping = damping;
}
/** Get linear damping in N*s/m */
GetDamping() {

@@ -188,0 +234,0 @@ return this.m_damping;

@@ -6,3 +6,5 @@ import { b2Transform, XY } from "../common/b2_math";

import type { b2Body } from "./b2_body";
import { b2Readonly } from "../common/b2_readonly";
import { b2BroadPhase } from "../collision/b2_broad_phase";
import type { b2FixtureUserData } from "..";
/**

@@ -38,3 +40,3 @@ * This holds contact filtering data.

/** Use this to store application specific fixture data. */
userData?: any;
userData?: b2FixtureUserData;
/** The friction coefficient, usually in the range [0,1]. */

@@ -67,3 +69,3 @@ friction?: number;

readonly treeNode: b2TreeNode<b2FixtureProxy>;
constructor(fixture: b2Fixture, broadPhase: b2BroadPhase<b2FixtureProxy>, xf: b2Transform, childIndex: number);
constructor(fixture: b2Fixture, broadPhase: b2BroadPhase<b2FixtureProxy>, xf: b2Readonly<b2Transform>, childIndex: number);
}

@@ -90,3 +92,3 @@ /**

protected m_isSensor: boolean;
protected m_userData: any;
protected readonly m_userData: b2FixtureUserData;
protected constructor(body: b2Body, def: b2FixtureDef);

@@ -130,3 +132,3 @@ /**

/**
* Get the parent body of this fixture. This is NULL if the fixture is not attached.
* Get the parent body of this fixture.
*

@@ -146,7 +148,8 @@ * @returns The parent body.

*/
GetUserData(): any;
GetUserData(): b2FixtureUserData;
/**
* Set the user data. Use this to store your application specific data.
* This is a merge operation. Only specified keys will be overridden.
*/
SetUserData(data: any): void;
SetUserData(data: b2FixtureUserData): void;
/**

@@ -198,2 +201,8 @@ * Test a point for containment in this fixture.

SetRestitution(restitution: number): void;
/** Get the restitution velocity threshold. */
GetRestitutionThreshold(): number;
/**
* Set the restitution threshold. This will _not_ change the restitution threshold of
* existing contacts.
*/
SetRestitutionThreshold(threshold: number): void;

@@ -209,10 +218,10 @@ /**

*/
protected CreateProxies(broadPhase: b2BroadPhase<b2FixtureProxy>, xf: b2Transform): void;
protected CreateProxies(broadPhase: b2BroadPhase<b2FixtureProxy>, xf: b2Readonly<b2Transform>): void;
protected DestroyProxies(broadPhase: b2BroadPhase<b2FixtureProxy>): void;
protected Synchronize(
broadPhase: b2BroadPhase<b2FixtureProxy>,
transform1: b2Transform,
transform2: b2Transform
transform1: b2Readonly<b2Transform>,
transform2: b2Readonly<b2Transform>
): void;
}
//# sourceMappingURL=b2_fixture.d.ts.map

@@ -62,2 +62,6 @@ "use strict";

/** @internal protected */
get m_proxyCount() {
return this.m_proxies.length;
}
/** @internal protected */
constructor(body, def) {

@@ -79,6 +83,7 @@ var _a, _b, _c, _d, _e;

this.m_isSensor = false;
this.m_userData = null;
this.m_userData = {};
this.m_body = body;
this.m_shape = def.shape.Clone();
this.m_userData = def.userData;
if (def.userData)
this.SetUserData(def.userData);
this.m_friction = (_a = def.friction) !== null && _a !== void 0 ? _a : 0.2;

@@ -94,6 +99,2 @@ this.m_restitution = (_b = def.restitution) !== null && _b !== void 0 ? _b : 0;

}
/** @internal protected */
get m_proxyCount() {
return this.m_proxies.length;
}
/**

@@ -173,3 +174,3 @@ * Get the type of the child shape. You can use this to down cast to the concrete shape.

/**
* Get the parent body of this fixture. This is NULL if the fixture is not attached.
* Get the parent body of this fixture.
*

@@ -198,5 +199,6 @@ * @returns The parent body.

* Set the user data. Use this to store your application specific data.
* This is a merge operation. Only specified keys will be overridden.
*/
SetUserData(data) {
this.m_userData = data;
Object.assign(this.m_userData, data);
}

@@ -269,2 +271,10 @@ /**

}
/** Get the restitution velocity threshold. */
GetRestitutionThreshold() {
return this.m_restitutionThreshold;
}
/**
* Set the restitution threshold. This will _not_ change the restitution threshold of
* existing contacts.
*/
SetRestitutionThreshold(threshold) {

@@ -271,0 +281,0 @@ this.m_restitutionThreshold = threshold;

@@ -5,2 +5,3 @@ import { b2Vec2, b2Mat22, XY } from "../common/b2_math";

import { b2Body } from "./b2_body";
import { b2Readonly } from "../common/b2_readonly";
export interface b2IFrictionJointDef extends b2IJointDef {

@@ -25,3 +26,7 @@ localAnchorA: XY;

constructor();
Initialize(bA: b2Body, bB: b2Body, anchor: b2Vec2): void;
/**
* Initialize the bodies, anchors, axis, and reference angle using the world
* anchor and world axis.
*/
Initialize(bA: b2Body, bB: b2Body, anchor: b2Readonly<b2Vec2>): void;
}

@@ -59,9 +64,15 @@ /**

GetReactionTorque(inv_dt: number): number;
GetLocalAnchorA(): Readonly<b2Vec2>;
GetLocalAnchorB(): Readonly<b2Vec2>;
/** The local anchor point relative to bodyA's origin. */
GetLocalAnchorA(): b2Readonly<b2Vec2>;
/** The local anchor point relative to bodyB's origin. */
GetLocalAnchorB(): b2Readonly<b2Vec2>;
/** Set the maximum friction force in N. */
SetMaxForce(force: number): void;
/** Get the maximum friction force in N. */
GetMaxForce(): number;
/** Set the maximum friction torque in N*m. */
SetMaxTorque(torque: number): void;
/** Get the maximum friction torque in N*m. */
GetMaxTorque(): number;
}
//# sourceMappingURL=b2_friction_joint.d.ts.map

@@ -23,2 +23,12 @@ "use strict";

const b2_joint_1 = require("./b2_joint");
// Point-to-point constraint
// Cdot = v2 - v1
// = v2 + cross(w2, r2) - v1 - cross(w1, r1)
// J = [-I -r1_skew I r2_skew ]
// Identity used:
// w k % (rx i + ry j) = w * (-ry i + rx j)
// Angle constraint
// Cdot = w2 - w1
// J = [0 0 -1 0 0 1]
// K = invI1 + invI2
const temp = {

@@ -48,2 +58,6 @@ qA: new b2_math_1.b2Rot(),

}
/**
* Initialize the bodies, anchors, axis, and reference angle using the world
* anchor and world axis.
*/
Initialize(bA, bB, anchor) {

@@ -210,8 +224,11 @@ this.bodyA = bA;

}
/** The local anchor point relative to bodyA's origin. */
GetLocalAnchorA() {
return this.m_localAnchorA;
}
/** The local anchor point relative to bodyB's origin. */
GetLocalAnchorB() {
return this.m_localAnchorB;
}
/** Set the maximum friction force in N. */
SetMaxForce(force) {

@@ -221,5 +238,7 @@ // DEBUG: b2Assert(Number.isFinite(force) && force >= 0);

}
/** Get the maximum friction force in N. */
GetMaxForce() {
return this.m_maxForce;
}
/** Set the maximum friction torque in N*m. */
SetMaxTorque(torque) {

@@ -229,2 +248,3 @@ // DEBUG: b2Assert(Number.isFinite(torque) && torque >= 0);

}
/** Get the maximum friction torque in N*m. */
GetMaxTorque() {

@@ -231,0 +251,0 @@ return this.m_maxTorque;

@@ -62,2 +62,3 @@ import { b2Vec2, XY } from "../common/b2_math";

protected m_ratio: number;
protected m_tolerance: number;
protected m_impulse: number;

@@ -95,7 +96,11 @@ protected m_indexA: number;

GetReactionTorque(inv_dt: number): number;
/** Get the first joint. */
GetJoint1(): b2PrismaticJoint | b2RevoluteJoint;
/** Get the second joint. */
GetJoint2(): b2PrismaticJoint | b2RevoluteJoint;
/** Get the gear ratio. */
GetRatio(): number;
/** Set the gear ratio. */
SetRatio(ratio: number): void;
}
//# sourceMappingURL=b2_gear_joint.d.ts.map

@@ -25,2 +25,18 @@ "use strict";

const b2_joint_1 = require("./b2_joint");
// Gear Joint:
// C0 = (coordinate1 + ratio * coordinate2)_initial
// C = (coordinate1 + ratio * coordinate2) - C0 = 0
// J = [J1 ratio * J2]
// K = J * invM * JT
// = J1 * invM1 * J1T + ratio * ratio * J2 * invM2 * J2T
// Revolute:
// coordinate = rotation
// Cdot = angularVelocity
// J = [0 0 1]
// K = J * invM * JT = invI
// Prismatic:
// coordinate = dot(p - pg, ug)
// Cdot = dot(v + cross(w, r), ug)
// J = [ug cross(r, ug)]
// K = J * invM * JT = invMass + invI * cross(r, ug)^2
const temp = {

@@ -91,2 +107,3 @@ qA: new b2_math_1.b2Rot(),

this.m_ratio = 0;
this.m_tolerance = 0;
this.m_impulse = 0;

@@ -142,2 +159,4 @@ // Solver temp

coordinateA = aA - aC - this.m_referenceAngleA;
// position error is measured in radians
this.m_tolerance = b2_common_1.b2_angularSlop;
}

@@ -153,2 +172,4 @@ else {

coordinateA = b2_math_1.b2Vec2.Dot(pA.Subtract(pC), this.m_localAxisC);
// position error is measured in meters
this.m_tolerance = b2_common_1.b2_linearSlop;
}

@@ -321,3 +342,2 @@ this.m_bodyD = this.m_joint2.GetBodyA();

qD.Set(aD);
const linearError = 0;
let coordinateA;

@@ -388,4 +408,6 @@ let coordinateB;

data.positions[this.m_indexD].a = aD;
// TODO_ERIN not implemented
return linearError < b2_common_1.b2_linearSlop;
if (Math.abs(C) < this.m_tolerance) {
return true;
}
return false;
}

@@ -404,11 +426,15 @@ GetAnchorA(out) {

}
/** Get the first joint. */
GetJoint1() {
return this.m_joint1;
}
/** Get the second joint. */
GetJoint2() {
return this.m_joint2;
}
/** Get the gear ratio. */
GetRatio() {
return this.m_ratio;
}
/** Set the gear ratio. */
SetRatio(ratio) {

@@ -415,0 +441,0 @@ // DEBUG: b2Assert(Number.isFinite(ratio));

@@ -0,1 +1,2 @@

import type { b2JointUserData } from "..";
import { b2Draw } from "../common/b2_draw";

@@ -44,3 +45,3 @@ import { XY } from "../common/b2_math";

/** Use this to attach application specific data to your joints. */
userData?: any;
userData: b2JointUserData;
/** The first attached body. */

@@ -60,3 +61,3 @@ bodyA: b2Body;

/** Use this to attach application specific data to your joints. */
userData: any;
readonly userData: b2JointUserData;
/** The first attached body. */

@@ -98,3 +99,3 @@ bodyA: b2Body;

protected m_collideConnected: boolean;
protected m_userData: any;
protected readonly m_userData: b2JointUserData;
protected constructor(def: b2IJointDef);

@@ -134,11 +135,12 @@ /**

/**
* Get the user data pointer.
* Get the user data reference.
*/
GetUserData(): any;
GetUserData(): b2JointUserData;
/**
* Set the user data pointer.
* Set the user data. Use this to store your application specific data.
* This is a merge operation. Only specified keys will be overridden.
*/
SetUserData(data: any): void;
SetUserData(data: b2JointUserData): void;
/**
* Short-cut function to determine if either body is inactive.
* Short-cut function to determine if either body is enabled.
*/

@@ -162,4 +164,5 @@ IsEnabled(): boolean;

protected abstract SolvePositionConstraints(data: b2SolverData): boolean;
/** Debug draw this joint */
Draw(draw: b2Draw): void;
}
//# sourceMappingURL=b2_joint.d.ts.map

@@ -5,19 +5,2 @@ "use strict";

exports.b2Joint = exports.b2AngularStiffness = exports.b2LinearStiffness = exports.b2JointDef = exports.b2JointEdge = exports.b2JointType = void 0;
// Copyright (c) 2019 Erin Catto
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// DEBUG: import { b2Assert } from "../common/b2_common";
const b2_draw_1 = require("../common/b2_draw");

@@ -43,3 +26,3 @@ const b2_math_1 = require("../common/b2_math");

b2JointType[b2JointType["e_areaJoint"] = 11] = "e_areaJoint";
})(b2JointType = exports.b2JointType || (exports.b2JointType = {}));
})(b2JointType || (exports.b2JointType = b2JointType = {}));
/**

@@ -69,3 +52,3 @@ * A joint edge is used to connect bodies and joints together

/** Use this to attach application specific data to your joints. */
this.userData = null;
this.userData = {};
/** Set this flag to true if the attached bodies should collide. */

@@ -136,3 +119,3 @@ this.collideConnected = false;

this.m_collideConnected = false;
this.m_userData = null;
this.m_userData = {};
this.m_type = def.type;

@@ -144,3 +127,3 @@ this.m_edgeA = new b2JointEdge(this, def.bodyB);

this.m_collideConnected = (_a = def.collideConnected) !== null && _a !== void 0 ? _a : false;
this.m_userData = def.userData;
this.SetUserData(def.userData);
}

@@ -172,3 +155,3 @@ /**

/**
* Get the user data pointer.
* Get the user data reference.
*/

@@ -179,9 +162,10 @@ GetUserData() {

/**
* Set the user data pointer.
* Set the user data. Use this to store your application specific data.
* This is a merge operation. Only specified keys will be overridden.
*/
SetUserData(data) {
this.m_userData = data;
Object.assign(this.m_userData, data);
}
/**
* Short-cut function to determine if either body is inactive.
* Short-cut function to determine if either body is enabled.
*/

@@ -203,2 +187,3 @@ IsEnabled() {

ShiftOrigin(_newOrigin) { }
/** Debug draw this joint */
Draw(draw) {

@@ -205,0 +190,0 @@ const x1 = this.m_bodyA.GetTransform().p;

import { b2Vec2, b2Mat22, XY } from "../common/b2_math";
import { b2Readonly } from "../common/b2_readonly";
import { b2Body } from "./b2_body";

@@ -27,2 +28,3 @@ import { b2Joint, b2JointDef, b2IJointDef } from "./b2_joint";

constructor();
/** Initialize the bodies and offsets using the current transforms. */
Initialize(bodyA: b2Body, bodyB: b2Body): void;

@@ -62,11 +64,21 @@ }

GetReactionTorque(inv_dt: number): number;
SetLinearOffset(linearOffset: b2Vec2): void;
/** Set the target linear offset, in frame A, in meters. */
SetLinearOffset(linearOffset: b2Readonly<b2Vec2>): void;
/** Get the target linear offset, in frame A, in meters. */
GetLinearOffset(): b2Vec2;
/** Set the target angular offset, in radians. */
SetAngularOffset(angularOffset: number): void;
/** Get the target angular offset, in radians. */
GetAngularOffset(): number;
/** Set the maximum friction force in N. */
SetMaxForce(force: number): void;
/** Get the maximum friction force in N. */
GetMaxForce(): number;
/** Set the maximum friction torque in N*m. */
SetMaxTorque(torque: number): void;
/** Get the maximum friction torque in N*m. */
GetMaxTorque(): number;
/** Get the position correction factor in the range [0,1]. */
GetCorrectionFactor(): number;
/** Set the position correction factor in the range [0,1]. */
SetCorrectionFactor(factor: number): void;

@@ -73,0 +85,0 @@ protected InitVelocityConstraints(data: b2SolverData): void;

@@ -62,2 +62,3 @@ "use strict";

}
/** Initialize the bodies and offsets using the current transforms. */
Initialize(bodyA, bodyB) {

@@ -127,2 +128,3 @@ this.bodyA = bodyA;

}
/** Set the target linear offset, in frame A, in meters. */
SetLinearOffset(linearOffset) {

@@ -135,5 +137,7 @@ if (!b2_math_1.b2Vec2.Equals(linearOffset, this.m_linearOffset)) {

}
/** Get the target linear offset, in frame A, in meters. */
GetLinearOffset() {
return this.m_linearOffset;
}
/** Set the target angular offset, in radians. */
SetAngularOffset(angularOffset) {

@@ -146,5 +150,7 @@ if (angularOffset !== this.m_angularOffset) {

}
/** Get the target angular offset, in radians. */
GetAngularOffset() {
return this.m_angularOffset;
}
/** Set the maximum friction force in N. */
SetMaxForce(force) {

@@ -154,5 +160,7 @@ // DEBUG: b2Assert(Number.isFinite(force) && force >= 0);

}
/** Get the maximum friction force in N. */
GetMaxForce() {
return this.m_maxForce;
}
/** Set the maximum friction torque in N*m. */
SetMaxTorque(torque) {

@@ -162,8 +170,11 @@ // DEBUG: b2Assert(Number.isFinite(torque) && torque >= 0);

}
/** Get the maximum friction torque in N*m. */
GetMaxTorque() {
return this.m_maxTorque;
}
/** Get the position correction factor in the range [0,1]. */
GetCorrectionFactor() {
return this.m_correctionFactor;
}
/** Set the position correction factor in the range [0,1]. */
SetCorrectionFactor(factor) {

@@ -170,0 +181,0 @@ // DEBUG: b2Assert(Number.isFinite(factor) && factor >= 0 && factor <= 1);

@@ -59,9 +59,16 @@ import { b2Draw } from "../common/b2_draw";

protected constructor(def: b2IMouseJointDef);
/** Use this to update the target point. */
SetTarget(target: XY): void;
GetTarget(): b2Vec2;
/** Set the maximum force in Newtons. */
SetMaxForce(force: number): void;
/** Get the maximum force in Newtons. */
GetMaxForce(): number;
/** Set the linear stiffness in N/m */
SetStiffness(stiffness: number): void;
/** Get the linear stiffness in N/m */
GetStiffness(): number;
/** Set linear damping in N*s/m */
SetDamping(damping: number): void;
/** Get linear damping in N*s/m */
GetDamping(): number;

@@ -68,0 +75,0 @@ protected InitVelocityConstraints(data: b2SolverData): void;

@@ -25,2 +25,9 @@ "use strict";

const b2_joint_1 = require("./b2_joint");
// p = attached point, m = mouse point
// C = p - m
// Cdot = v
// = v + cross(w, r)
// J = [I r_skew]
// Identity used:
// w k % (rx i + ry j) = w * (-ry i + rx j)
const temp = {

@@ -99,2 +106,3 @@ qB: new b2_math_1.b2Rot(),

}
/** Use this to update the target point. */
SetTarget(target) {

@@ -109,17 +117,23 @@ if (!b2_math_1.b2Vec2.Equals(target, this.m_targetA)) {

}
/** Set the maximum force in Newtons. */
SetMaxForce(force) {
this.m_maxForce = force;
}
/** Get the maximum force in Newtons. */
GetMaxForce() {
return this.m_maxForce;
}
/** Set the linear stiffness in N/m */
SetStiffness(stiffness) {
this.m_stiffness = stiffness;
}
/** Get the linear stiffness in N/m */
GetStiffness() {
return this.m_stiffness;
}
/** Set linear damping in N*s/m */
SetDamping(damping) {
this.m_damping = damping;
}
/** Get linear damping in N*s/m */
GetDamping() {

@@ -165,3 +179,3 @@ return this.m_damping;

// Cheat with some damping
wB *= 0.98;
wB *= Math.max(0, 1 - 0.02 * (60 * data.step.dt));
if (data.step.warmStarting) {

@@ -168,0 +182,0 @@ this.m_impulse.Scale(data.step.dtRatio);

import { b2Draw } from "../common/b2_draw";
import { b2Vec2, b2Mat22, XY } from "../common/b2_math";
import { b2Readonly } from "../common/b2_readonly";
import { b2Body } from "./b2_body";

@@ -48,2 +49,6 @@ import { b2Joint, b2JointDef, b2IJointDef } from "./b2_joint";

constructor();
/**
* Initialize the bodies, anchors, axis, and reference angle using the world
* anchor and unit world axis.
*/
Initialize(bA: b2Body, bB: b2Body, anchor: XY, axis: XY): void;

@@ -107,19 +112,37 @@ }

GetReactionTorque(inv_dt: number): number;
GetLocalAnchorA(): Readonly<b2Vec2>;
GetLocalAnchorB(): Readonly<b2Vec2>;
GetLocalAxisA(): Readonly<b2Vec2>;
/** The local anchor point relative to bodyA's origin. */
GetLocalAnchorA(): b2Readonly<b2Vec2>;
/** The local anchor point relative to bodyB's origin. */
GetLocalAnchorB(): b2Readonly<b2Vec2>;
/** The local joint axis relative to bodyA. */
GetLocalAxisA(): b2Readonly<b2Vec2>;
/** Get the reference angle. */
GetReferenceAngle(): number;
/** Get the current joint translation, usually in meters. */
GetJointTranslation(): number;
/** Get the current joint translation speed, usually in meters per second. */
GetJointSpeed(): number;
/** Is the joint limit enabled? */
IsLimitEnabled(): boolean;
/** Enable/disable the joint limit. */
EnableLimit(flag: boolean): boolean;
/** Get the lower joint limit, usually in meters. */
GetLowerLimit(): number;
/** Get the upper joint limit, usually in meters. */
GetUpperLimit(): number;
/** Set the joint limits, usually in meters. */
SetLimits(lower: number, upper: number): void;
/** Is the joint motor enabled? */
IsMotorEnabled(): boolean;
/** Enable/disable the joint motor. */
EnableMotor(flag: boolean): boolean;
/** Set the motor speed, usually in meters per second. */
SetMotorSpeed(speed: number): number;
/** Get the motor speed, usually in meters per second. */
GetMotorSpeed(): number;
/** Set the maximum motor force, usually in N. */
SetMaxMotorForce(force: number): void;
/** Get the maximum motor force, usually in N. */
GetMaxMotorForce(): number;
/** Get the current motor force given the inverse time step, usually in N. */
GetMotorForce(inv_dt: number): number;

@@ -126,0 +149,0 @@ Draw(draw: b2Draw): void;

@@ -25,2 +25,43 @@ "use strict";

const b2_joint_1 = require("./b2_joint");
// Linear constraint (point-to-line)
// d = p2 - p1 = x2 + r2 - x1 - r1
// C = dot(perp, d)
// Cdot = dot(d, cross(w1, perp)) + dot(perp, v2 + cross(w2, r2) - v1 - cross(w1, r1))
// = -dot(perp, v1) - dot(cross(d + r1, perp), w1) + dot(perp, v2) + dot(cross(r2, perp), v2)
// J = [-perp, -cross(d + r1, perp), perp, cross(r2,perp)]
//
// Angular constraint
// C = a2 - a1 + a_initial
// Cdot = w2 - w1
// J = [0 0 -1 0 0 1]
//
// K = J * invM * JT
//
// J = [-a -s1 a s2]
// [0 -1 0 1]
// a = perp
// s1 = cross(d + r1, a) = cross(p2 - x1, a)
// s2 = cross(r2, a) = cross(p2 - x2, a)
// Motor/Limit linear constraint
// C = dot(ax1, d)
// Cdot = -dot(ax1, v1) - dot(cross(d + r1, ax1), w1) + dot(ax1, v2) + dot(cross(r2, ax1), v2)
// J = [-ax1 -cross(d+r1,ax1) ax1 cross(r2,ax1)]
// Predictive limit is applied even when the limit is not active.
// Prevents a constraint speed that can lead to a constraint error in one time step.
// Want C2 = C1 + h * Cdot >= 0
// Or:
// Cdot + C1/h >= 0
// I do not apply a negative constraint error because that is handled in position correction.
// So:
// Cdot + max(C1, 0)/h >= 0
// Block Solver
// We develop a block solver that includes the angular and linear constraints. This makes the limit stiffer.
//
// The Jacobian has 2 rows:
// J = [-uT -s1 uT s2] // linear
// [0 -1 0 1] // angular
//
// u = perp
// s1 = cross(d + r1, u), s2 = cross(r2, u)
// a1 = cross(d + r1, v), a2 = cross(r2, v)
const temp = {

@@ -98,2 +139,6 @@ K3: new b2_math_1.b2Mat33(),

}
/**
* Initialize the bodies, anchors, axis, and reference angle using the world
* anchor and unit world axis.
*/
Initialize(bA, bB, anchor, axis) {

@@ -109,43 +154,2 @@ this.bodyA = bA;

exports.b2PrismaticJointDef = b2PrismaticJointDef;
// Linear constraint (point-to-line)
// d = p2 - p1 = x2 + r2 - x1 - r1
// C = dot(perp, d)
// Cdot = dot(d, cross(w1, perp)) + dot(perp, v2 + cross(w2, r2) - v1 - cross(w1, r1))
// = -dot(perp, v1) - dot(cross(d + r1, perp), w1) + dot(perp, v2) + dot(cross(r2, perp), v2)
// J = [-perp, -cross(d + r1, perp), perp, cross(r2,perp)]
//
// Angular constraint
// C = a2 - a1 + a_initial
// Cdot = w2 - w1
// J = [0 0 -1 0 0 1]
//
// K = J * invM * JT
//
// J = [-a -s1 a s2]
// [0 -1 0 1]
// a = perp
// s1 = cross(d + r1, a) = cross(p2 - x1, a)
// s2 = cross(r2, a) = cross(p2 - x2, a)
// Motor/Limit linear constraint
// C = dot(ax1, d)
// Cdot = -dot(ax1, v1) - dot(cross(d + r1, ax1), w1) + dot(ax1, v2) + dot(cross(r2, ax1), v2)
// J = [-ax1 -cross(d+r1,ax1) ax1 cross(r2,ax1)]
// Predictive limit is applied even when the limit is not active.
// Prevents a constraint speed that can lead to a constraint error in one time step.
// Want C2 = C1 + h * Cdot >= 0
// Or:
// Cdot + C1/h >= 0
// I do not apply a negative constraint error because that is handled in position correction.
// So:
// Cdot + max(C1, 0)/h >= 0
// Block Solver
// We develop a block solver that includes the angular and linear constraints. This makes the limit stiffer.
//
// The Jacobian has 2 rows:
// J = [-uT -s1 uT s2] // linear
// [0 -1 0 1] // angular
//
// u = perp
// s1 = cross(d + r1, u), s2 = cross(r2, u)
// a1 = cross(d + r1, v), a2 = cross(r2, v)
/**

@@ -493,14 +497,19 @@ * A prismatic joint. This joint provides one degree of freedom: translation

}
/** The local anchor point relative to bodyA's origin. */
GetLocalAnchorA() {
return this.m_localAnchorA;
}
/** The local anchor point relative to bodyB's origin. */
GetLocalAnchorB() {
return this.m_localAnchorB;
}
/** The local joint axis relative to bodyA. */
GetLocalAxisA() {
return this.m_localXAxisA;
}
/** Get the reference angle. */
GetReferenceAngle() {
return this.m_referenceAngle;
}
/** Get the current joint translation, usually in meters. */
GetJointTranslation() {

@@ -515,2 +524,3 @@ const { pA, pB, axis, d } = temp.GetJointTranslation;

}
/** Get the current joint translation speed, usually in meters per second. */
GetJointSpeed() {

@@ -534,5 +544,7 @@ const bA = this.m_bodyA;

}
/** Is the joint limit enabled? */
IsLimitEnabled() {
return this.m_enableLimit;
}
/** Enable/disable the joint limit. */
EnableLimit(flag) {

@@ -548,8 +560,11 @@ if (flag !== this.m_enableLimit) {

}
/** Get the lower joint limit, usually in meters. */
GetLowerLimit() {
return this.m_lowerTranslation;
}
/** Get the upper joint limit, usually in meters. */
GetUpperLimit() {
return this.m_upperTranslation;
}
/** Set the joint limits, usually in meters. */
SetLimits(lower, upper) {

@@ -566,5 +581,7 @@ // DEBUG: b2Assert(lower <= upper);

}
/** Is the joint motor enabled? */
IsMotorEnabled() {
return this.m_enableMotor;
}
/** Enable/disable the joint motor. */
EnableMotor(flag) {

@@ -578,2 +595,3 @@ if (flag !== this.m_enableMotor) {

}
/** Set the motor speed, usually in meters per second. */
SetMotorSpeed(speed) {

@@ -587,5 +605,7 @@ if (speed !== this.m_motorSpeed) {

}
/** Get the motor speed, usually in meters per second. */
GetMotorSpeed() {
return this.m_motorSpeed;
}
/** Set the maximum motor force, usually in N. */
SetMaxMotorForce(force) {

@@ -598,5 +618,7 @@ if (force !== this.m_maxMotorForce) {

}
/** Get the maximum motor force, usually in N. */
GetMaxMotorForce() {
return this.m_maxMotorForce;
}
/** Get the current motor force given the inverse time step, usually in N. */
GetMotorForce(inv_dt) {

@@ -603,0 +625,0 @@ return inv_dt * this.m_motorImpulse;

import { b2Draw } from "../common/b2_draw";
import { b2Vec2, XY } from "../common/b2_math";
import { b2Readonly } from "../common/b2_readonly";
import { b2Body } from "./b2_body";

@@ -36,3 +37,4 @@ import { b2Joint, b2JointDef, b2IJointDef } from "./b2_joint";

constructor();
Initialize(bA: b2Body, bB: b2Body, groundA: b2Vec2, groundB: b2Vec2, anchorA: b2Vec2, anchorB: b2Vec2, r: number): void;
/** Initialize the bodies, anchors, lengths, max lengths, and ratio using the world anchors. */
Initialize(bA: b2Body, bB: b2Body, groundA: Readonly<XY>, groundB: Readonly<XY>, anchorA: Readonly<XY>, anchorB: Readonly<XY>, r: number): void;
}

@@ -80,12 +82,19 @@ /**

GetReactionTorque(_inv_dt: number): number;
/** Get the first ground anchor. */
GetGroundAnchorA(): b2Vec2;
/** Get the second ground anchor. */
GetGroundAnchorB(): b2Vec2;
/** Get the current length of the segment attached to bodyA. */
GetLengthA(): number;
/** Get the current length of the segment attached to bodyB. */
GetLengthB(): number;
/** Get the pulley ratio. */
GetRatio(): number;
/** Get the current length of the segment attached to bodyA. */
GetCurrentLengthA(): number;
/** Get the current length of the segment attached to bodyB. */
GetCurrentLengthB(): number;
ShiftOrigin(newOrigin: b2Vec2): void;
ShiftOrigin(newOrigin: b2Readonly<b2Vec2>): void;
Draw(draw: b2Draw): void;
}
//# sourceMappingURL=b2_pulley_joint.d.ts.map

@@ -26,2 +26,13 @@ "use strict";

const b2_joint_1 = require("./b2_joint");
// Pulley:
// length1 = norm(p1 - s1)
// length2 = norm(p2 - s2)
// C0 = (length1 + ratio * length2)_initial
// C = C0 - (length1 + ratio * length2)
// u1 = (p1 - s1) / norm(p1 - s1)
// u2 = (p2 - s2) / norm(p2 - s2)
// Cdot = -dot(u1, v1 + cross(w1, r1)) - ratio * dot(u2, v2 + cross(w2, r2))
// J = -[u1 cross(r1, u1) ratio * u2 ratio * cross(r2, u2)]
// K = J * invM * JT
// = invMass1 + invI1 * cross(r1, u1)^2 + ratio^2 * (invMass2 + invI2 * cross(r2, u2)^2)
exports.b2_minPulleyLength = 2;

@@ -64,2 +75,3 @@ const temp = {

}
/** Initialize the bodies, anchors, lengths, max lengths, and ratio using the world anchors. */
Initialize(bA, bB, groundA, groundB, anchorA, anchorB, r) {

@@ -285,17 +297,23 @@ this.bodyA = bA;

}
/** Get the first ground anchor. */
GetGroundAnchorA() {
return this.m_groundAnchorA;
}
/** Get the second ground anchor. */
GetGroundAnchorB() {
return this.m_groundAnchorB;
}
/** Get the current length of the segment attached to bodyA. */
GetLengthA() {
return this.m_lengthA;
}
/** Get the current length of the segment attached to bodyB. */
GetLengthB() {
return this.m_lengthB;
}
/** Get the pulley ratio. */
GetRatio() {
return this.m_ratio;
}
/** Get the current length of the segment attached to bodyA. */
GetCurrentLengthA() {

@@ -306,2 +324,3 @@ const p = this.m_bodyA.GetWorldPoint(this.m_localAnchorA, temp.p);

}
/** Get the current length of the segment attached to bodyB. */
GetCurrentLengthB() {

@@ -308,0 +327,0 @@ const p = this.m_bodyB.GetWorldPoint(this.m_localAnchorB, temp.p);

import { b2Draw } from "../common/b2_draw";
import { b2Vec2, b2Mat22, XY } from "../common/b2_math";
import { b2Readonly } from "../common/b2_readonly";
import { b2Body } from "./b2_body";

@@ -52,2 +53,3 @@ import { b2Joint, b2JointDef, b2IJointDef } from "./b2_joint";

constructor();
/** Initialize the bodies, anchors, and reference angle using a world anchor point. */
Initialize(bA: b2Body, bB: b2Body, anchor: XY): void;

@@ -96,20 +98,48 @@ }

GetAnchorB<T extends XY>(out: T): T;
/**
* Get the reaction force given the inverse time step.
* Unit is N.
*/
GetReactionForce<T extends XY>(inv_dt: number, out: T): T;
/**
* Get the reaction torque due to the joint limit given the inverse time step.
* Unit is N*m.
*/
GetReactionTorque(inv_dt: number): number;
GetLocalAnchorA(): Readonly<b2Vec2>;
GetLocalAnchorB(): Readonly<b2Vec2>;
/** The local anchor point relative to bodyA's origin. */
GetLocalAnchorA(): b2Readonly<b2Vec2>;
/** The local anchor point relative to bodyB's origin. */
GetLocalAnchorB(): b2Readonly<b2Vec2>;
/** Get the reference angle. */
GetReferenceAngle(): number;
/** Get the current joint angle in radians. */
GetJointAngle(): number;
/** Get the current joint angle speed in radians per second. */
GetJointSpeed(): number;
/** Is the joint motor enabled? */
IsMotorEnabled(): boolean;
/** Enable/disable the joint motor. */
EnableMotor(flag: boolean): boolean;
/**
* Get the current motor torque given the inverse time step.
* Unit is N*m.
*/
GetMotorTorque(inv_dt: number): number;
/** Get the motor speed in radians per second. */
GetMotorSpeed(): number;
/** Set the maximum motor torque, usually in N-m. */
SetMaxMotorTorque(torque: number): void;
/** Get the maximum motor torque, usually in N-m. */
GetMaxMotorTorque(): number;
/** Is the joint limit enabled? */
IsLimitEnabled(): boolean;
/** Enable/disable the joint limit. */
EnableLimit(flag: boolean): boolean;
/** Get the lower joint limit in radians. */
GetLowerLimit(): number;
/** Get the upper joint limit in radians. */
GetUpperLimit(): number;
/** Set the joint limits in radians. */
SetLimits(lower: number, upper: number): void;
/** Set the motor speed in radians per second. */
SetMotorSpeed(speed: number): number;

@@ -116,0 +146,0 @@ Draw(draw: b2Draw): void;

@@ -25,2 +25,13 @@ "use strict";

const b2_joint_1 = require("./b2_joint");
// Point-to-point constraint
// C = p2 - p1
// Cdot = v2 - v1
// = v2 + cross(w2, r2) - v1 - cross(w1, r1)
// J = [-I -r1_skew I r2_skew ]
// Identity used:
// w k % (rx i + ry j) = w * (-ry i + rx j)
// Motor constraint
// Cdot = w2 - w1
// J = [0 0 -1 0 0 1]
// K = invI1 + invI2
const temp = {

@@ -79,2 +90,3 @@ qA: new b2_math_1.b2Rot(),

}
/** Initialize the bodies, anchors, and reference angle using a world anchor point. */
Initialize(bA, bB, anchor) {

@@ -344,2 +356,6 @@ this.bodyA = bA;

}
/**
* Get the reaction force given the inverse time step.
* Unit is N.
*/
GetReactionForce(inv_dt, out) {

@@ -350,23 +366,34 @@ out.x = inv_dt * this.m_impulse.x;

}
/**
* Get the reaction torque due to the joint limit given the inverse time step.
* Unit is N*m.
*/
GetReactionTorque(inv_dt) {
return inv_dt * (this.m_motorImpulse + this.m_lowerImpulse - this.m_upperImpulse);
}
/** The local anchor point relative to bodyA's origin. */
GetLocalAnchorA() {
return this.m_localAnchorA;
}
/** The local anchor point relative to bodyB's origin. */
GetLocalAnchorB() {
return this.m_localAnchorB;
}
/** Get the reference angle. */
GetReferenceAngle() {
return this.m_referenceAngle;
}
/** Get the current joint angle in radians. */
GetJointAngle() {
return this.m_bodyB.m_sweep.a - this.m_bodyA.m_sweep.a - this.m_referenceAngle;
}
/** Get the current joint angle speed in radians per second. */
GetJointSpeed() {
return this.m_bodyB.m_angularVelocity - this.m_bodyA.m_angularVelocity;
}
/** Is the joint motor enabled? */
IsMotorEnabled() {
return this.m_enableMotor;
}
/** Enable/disable the joint motor. */
EnableMotor(flag) {

@@ -380,8 +407,14 @@ if (flag !== this.m_enableMotor) {

}
/**
* Get the current motor torque given the inverse time step.
* Unit is N*m.
*/
GetMotorTorque(inv_dt) {
return inv_dt * this.m_motorImpulse;
}
/** Get the motor speed in radians per second. */
GetMotorSpeed() {
return this.m_motorSpeed;
}
/** Set the maximum motor torque, usually in N-m. */
SetMaxMotorTorque(torque) {

@@ -394,8 +427,11 @@ if (torque !== this.m_maxMotorTorque) {

}
/** Get the maximum motor torque, usually in N-m. */
GetMaxMotorTorque() {
return this.m_maxMotorTorque;
}
/** Is the joint limit enabled? */
IsLimitEnabled() {
return this.m_enableLimit;
}
/** Enable/disable the joint limit. */
EnableLimit(flag) {

@@ -411,8 +447,11 @@ if (flag !== this.m_enableLimit) {

}
/** Get the lower joint limit in radians. */
GetLowerLimit() {
return this.m_lowerAngle;
}
/** Get the upper joint limit in radians. */
GetUpperLimit() {
return this.m_upperAngle;
}
/** Set the joint limits in radians. */
SetLimits(lower, upper) {

@@ -428,2 +467,3 @@ if (lower !== this.m_lowerAngle || upper !== this.m_upperAngle) {

}
/** Set the motor speed in radians per second. */
SetMotorSpeed(speed) {

@@ -430,0 +470,0 @@ if (speed !== this.m_motorSpeed) {

import { b2Vec2, b2Vec3, b2Mat33, XY } from "../common/b2_math";
import { b2Readonly } from "../common/b2_readonly";
import { b2Body } from "./b2_body";

@@ -32,3 +33,9 @@ import { b2Joint, b2JointDef, b2IJointDef } from "./b2_joint";

constructor();
Initialize(bA: b2Body, bB: b2Body, anchor: b2Vec2): void;
/**
* Initialize the bodies, anchors, reference angle, stiffness, and damping.
* @param bodyA the first body connected by this joint
* @param bodyB the second body connected by this joint
* @param anchor the point of connection in world coordinates
*/
Initialize(bA: b2Body, bB: b2Body, anchor: Readonly<XY>): void;
}

@@ -67,10 +74,17 @@ /**

GetReactionTorque(inv_dt: number): number;
GetLocalAnchorA(): Readonly<b2Vec2>;
GetLocalAnchorB(): Readonly<b2Vec2>;
/** The local anchor point relative to bodyA's origin. */
GetLocalAnchorA(): b2Readonly<b2Vec2>;
/** The local anchor point relative to bodyB's origin. */
GetLocalAnchorB(): b2Readonly<b2Vec2>;
/** Get the reference angle. */
GetReferenceAngle(): number;
/** Set stiffness in N*m */
SetStiffness(stiffness: number): void;
/** Get stiffness in N*m */
GetStiffness(): number;
/** Set damping in N*m*s */
SetDamping(damping: number): void;
/** Get damping in N*m*s */
GetDamping(): number;
}
//# sourceMappingURL=b2_weld_joint.d.ts.map

@@ -24,2 +24,14 @@ "use strict";

const b2_joint_1 = require("./b2_joint");
// Point-to-point constraint
// C = p2 - p1
// Cdot = v2 - v1
// = v2 + cross(w2, r2) - v1 - cross(w1, r1)
// J = [-I -r1_skew I r2_skew ]
// Identity used:
// w k % (rx i + ry j) = w * (-ry i + rx j)
// Angle constraint
// C = angle2 - angle1 - referenceAngle
// Cdot = w2 - w1
// J = [0 0 -1 0 0 1]
// K = invI1 + invI2
const temp = {

@@ -62,2 +74,8 @@ qA: new b2_math_1.b2Rot(),

}
/**
* Initialize the bodies, anchors, reference angle, stiffness, and damping.
* @param bodyA the first body connected by this joint
* @param bodyB the second body connected by this joint
* @param anchor the point of connection in world coordinates
*/
Initialize(bA, bB, anchor) {

@@ -308,20 +326,27 @@ this.bodyA = bA;

}
/** The local anchor point relative to bodyA's origin. */
GetLocalAnchorA() {
return this.m_localAnchorA;
}
/** The local anchor point relative to bodyB's origin. */
GetLocalAnchorB() {
return this.m_localAnchorB;
}
/** Get the reference angle. */
GetReferenceAngle() {
return this.m_referenceAngle;
}
/** Set stiffness in N*m */
SetStiffness(stiffness) {
this.m_stiffness = stiffness;
}
/** Get stiffness in N*m */
GetStiffness() {
return this.m_stiffness;
}
/** Set damping in N*m*s */
SetDamping(damping) {
this.m_damping = damping;
}
/** Get damping in N*m*s */
GetDamping() {

@@ -328,0 +353,0 @@ return this.m_damping;

@@ -6,2 +6,3 @@ import { b2Vec2, XY } from "../common/b2_math";

import { b2Draw } from "../common/b2_draw";
import { b2Readonly } from "../common/b2_readonly";
export interface b2IWheelJointDef extends b2IJointDef {

@@ -63,3 +64,7 @@ /** The local anchor point relative to bodyA's origin. */

constructor();
Initialize(bA: b2Body, bB: b2Body, anchor: b2Vec2, axis: b2Vec2): void;
/**
* Initialize the bodies, anchors, axis, and reference angle using the world
* anchor and world axis.
*/
Initialize(bA: b2Body, bB: b2Body, anchor: Readonly<XY>, axis: Readonly<XY>): void;
}

@@ -112,7 +117,13 @@ /**

protected constructor(def: b2IWheelJointDef);
/** Get the motor speed, usually in radians per second. */
GetMotorSpeed(): number;
/** Set/Get the maximum motor force, usually in N-m. */
GetMaxMotorTorque(): number;
/** Set spring stiffness */
SetStiffness(stiffness: number): void;
/** Get spring stiffness */
GetStiffness(): number;
/** Set damping */
SetDamping(damping: number): void;
/** Get damping */
GetDamping(): number;

@@ -126,13 +137,25 @@ protected InitVelocityConstraints(data: b2SolverData): void;

GetReactionTorque(inv_dt: number): number;
GetLocalAnchorA(): Readonly<b2Vec2>;
GetLocalAnchorB(): Readonly<b2Vec2>;
GetLocalAxisA(): Readonly<b2Vec2>;
/** The local anchor point relative to bodyA's origin. */
GetLocalAnchorA(): b2Readonly<b2Vec2>;
/** The local anchor point relative to bodyB's origin. */
GetLocalAnchorB(): b2Readonly<b2Vec2>;
/** The local joint axis relative to bodyA. */
GetLocalAxisA(): b2Readonly<b2Vec2>;
/** Get the current joint translation, usually in meters. */
GetJointTranslation(): number;
/** Get the current joint linear speed, usually in meters per second. */
GetJointLinearSpeed(): number;
/** Get the current joint angle in radians. */
GetJointAngle(): number;
/** Get the current joint angular speed in radians per second. */
GetJointAngularSpeed(): number;
/** Is the joint motor enabled? */
IsMotorEnabled(): boolean;
/** Enable/disable the joint motor. */
EnableMotor(flag: boolean): boolean;
/** Set the motor speed, usually in radians per second. */
SetMotorSpeed(speed: number): number;
/** Set the maximum motor force, usually in N-m. */
SetMaxMotorTorque(torque: number): void;
/** Get the current motor torque given the inverse time step, usually in N-m. */
GetMotorTorque(inv_dt: number): number;

@@ -139,0 +162,0 @@ /**

@@ -26,2 +26,15 @@ "use strict";

const b2_draw_1 = require("../common/b2_draw");
// Linear constraint (point-to-line)
// d = pB - pA = xB + rB - xA - rA
// C = dot(ay, d)
// Cdot = dot(d, cross(wA, ay)) + dot(ay, vB + cross(wB, rB) - vA - cross(wA, rA))
// = -dot(ay, vA) - dot(cross(d + rA, ay), wA) + dot(ay, vB) + dot(cross(rB, ay), vB)
// J = [-ay, -cross(d + rA, ay), ay, cross(rB, ay)]
// Spring linear constraint
// C = dot(ax, d)
// Cdot = = -dot(ax, vA) - dot(cross(d + rA, ax), wA) + dot(ax, vB) + dot(cross(rB, ax), vB)
// J = [-ax -cross(d+rA, ax) ax cross(rB, ax)]
// Motor rotational constraint
// Cdot = wB - wA
// J = [0 0 -1 0 0 1]
const temp = {

@@ -85,2 +98,6 @@ qA: new b2_math_1.b2Rot(),

}
/**
* Initialize the bodies, anchors, axis, and reference angle using the world
* anchor and world axis.
*/
Initialize(bA, bB, anchor, axis) {

@@ -160,17 +177,23 @@ this.bodyA = bA;

}
/** Get the motor speed, usually in radians per second. */
GetMotorSpeed() {
return this.m_motorSpeed;
}
/** Set/Get the maximum motor force, usually in N-m. */
GetMaxMotorTorque() {
return this.m_maxMotorTorque;
}
/** Set spring stiffness */
SetStiffness(stiffness) {
this.m_stiffness = stiffness;
}
/** Get spring stiffness */
GetStiffness() {
return this.m_stiffness;
}
/** Set damping */
SetDamping(damping) {
this.m_damping = damping;
}
/** Get damping */
GetDamping() {

@@ -468,11 +491,15 @@ return this.m_damping;

}
/** The local anchor point relative to bodyA's origin. */
GetLocalAnchorA() {
return this.m_localAnchorA;
}
/** The local anchor point relative to bodyB's origin. */
GetLocalAnchorB() {
return this.m_localAnchorB;
}
/** The local joint axis relative to bodyA. */
GetLocalAxisA() {
return this.m_localXAxisA;
}
/** Get the current joint translation, usually in meters. */
GetJointTranslation() {

@@ -489,2 +516,3 @@ const bA = this.m_bodyA;

}
/** Get the current joint linear speed, usually in meters per second. */
GetJointLinearSpeed() {

@@ -511,5 +539,7 @@ const bA = this.m_bodyA;

}
/** Get the current joint angle in radians. */
GetJointAngle() {
return this.m_bodyB.m_sweep.a - this.m_bodyA.m_sweep.a;
}
/** Get the current joint angular speed in radians per second. */
GetJointAngularSpeed() {

@@ -520,5 +550,7 @@ const wA = this.m_bodyA.m_angularVelocity;

}
/** Is the joint motor enabled? */
IsMotorEnabled() {
return this.m_enableMotor;
}
/** Enable/disable the joint motor. */
EnableMotor(flag) {

@@ -532,2 +564,3 @@ if (flag !== this.m_enableMotor) {

}
/** Set the motor speed, usually in radians per second. */
SetMotorSpeed(speed) {

@@ -541,2 +574,3 @@ if (speed !== this.m_motorSpeed) {

}
/** Set the maximum motor force, usually in N-m. */
SetMaxMotorTorque(torque) {

@@ -549,2 +583,3 @@ if (torque !== this.m_maxMotorTorque) {

}
/** Get the current motor torque given the inverse time step, usually in N-m. */
GetMotorTorque(inv_dt) {

@@ -551,0 +586,0 @@ return inv_dt * this.m_motorImpulse;

@@ -6,2 +6,3 @@ import { b2Vec2 } from "../common/b2_math";

import { b2Fixture } from "./b2_fixture";
import { b2Readonly } from "../common/b2_readonly";
/**

@@ -96,3 +97,3 @@ * Joints and fixtures are destroyed when their associated

*/
export declare type b2QueryCallback = (fixture: b2Fixture) => boolean;
export type b2QueryCallback = (fixture: b2Fixture) => boolean;
/**

@@ -111,6 +112,7 @@ * Callback class for ray casts.

* @param normal The normal vector at the point of intersection
* @param fraction The fraction along the ray at the point of intersection
* @returns -1 to filter, 0 to terminate, fraction to clip the ray for
* closest hit, 1 to continue
*/
export declare type b2RayCastCallback = (fixture: b2Fixture, point: b2Vec2, normal: b2Vec2, fraction: number) => number;
export type b2RayCastCallback = (fixture: b2Fixture, point: b2Readonly<b2Vec2>, normal: b2Readonly<b2Vec2>, fraction: number) => number;
//# sourceMappingURL=b2_world_callbacks.d.ts.map

@@ -22,6 +22,6 @@ import { b2Vec2, b2Transform, XY } from "../common/b2_math";

import { b2ContactFilter, b2ContactListener, b2DestructionListener, b2QueryCallback, b2RayCastCallback } from "./b2_world_callbacks";
import { b2Readonly } from "../common/b2_readonly";
/**
* The world class manages all physics entities, dynamic simulation,
* and asynchronous queries. The world also contains efficient memory
* management facilities.
* and asynchronous queries.
*/

@@ -118,2 +118,5 @@ export declare class b2World {

DestroyJoint(j: b2Joint): void;
private static Step_s_step;
private static Step_s_stepTimer;
private static Step_s_timer;
/**

@@ -123,9 +126,5 @@ * Take a time step. This performs collision detection, integration,

*
* @param timeStep The amount of time to simulate, this should not vary.
* @param velocityIterations For the velocity constraint solver.
* @param positionIterations For the position constraint solver.
* @param dt The amount of time to simulate, this should not vary.
* @param iterations Config for the solvers.
*/
private static Step_s_step;
private static Step_s_stepTimer;
private static Step_s_timer;
Step(dt: number, iterations: b2StepConfig): void;

@@ -162,4 +161,4 @@ /**

private static QueryFixtureShape_s_aabb;
QueryFixtureShape(shape: b2Shape, index: number, transform: b2Transform, callback: b2QueryCallback): void;
QueryAllFixtureShape(shape: b2Shape, index: number, transform: b2Transform, out?: b2Fixture[]): b2Fixture[];
QueryFixtureShape(shape: b2Shape, index: number, transform: b2Readonly<b2Transform>, callback: b2QueryCallback): void;
QueryAllFixtureShape(shape: b2Shape, index: number, transform: b2Readonly<b2Transform>, out?: b2Fixture[]): b2Fixture[];
QueryFixturePoint(point: XY, callback: b2QueryCallback): void;

@@ -261,3 +260,3 @@ QueryAllFixturePoint(point: XY, out?: b2Fixture[]): b2Fixture[];

*/
GetGravity(): Readonly<b2Vec2>;
GetGravity(): b2Readonly<b2Vec2>;
/**

@@ -290,2 +289,3 @@ * Is the world locked (in the middle of a time step).

GetProfile(): b2Profile;
/** Find islands, integrate and solve constraints, solve position constraints */
private Solve;

@@ -292,0 +292,0 @@ private static SolveTOI_s_subStep;

@@ -45,4 +45,3 @@ "use strict";

* The world class manages all physics entities, dynamic simulation,
* and asynchronous queries. The world also contains efficient memory
* management facilities.
* and asynchronous queries.
*/

@@ -318,2 +317,9 @@ class b2World {

}
/**
* Take a time step. This performs collision detection, integration,
* and constraint solution.
*
* @param dt The amount of time to simulate, this should not vary.
* @param iterations Config for the solvers.
*/
Step(dt, iterations) {

@@ -684,2 +690,3 @@ const stepTimer = b2World.Step_s_stepTimer.Reset();

}
/** Find islands, integrate and solve constraints, solve position constraints */
Solve(step) {

@@ -821,3 +828,6 @@ this.m_profile.solveInit = 0;

}
/** @internal */
/**
* Find TOI contacts and solve them.
* @internal
*/
SolveTOI(step) {

@@ -1057,10 +1067,2 @@ const island = this.m_island;

exports.b2World = b2World;
/**
* Take a time step. This performs collision detection, integration,
* and constraint solution.
*
* @param timeStep The amount of time to simulate, this should not vary.
* @param velocityIterations For the velocity constraint solver.
* @param positionIterations For the position constraint solver.
*/
b2World.Step_s_step = b2_time_step_1.b2TimeStep.Create();

@@ -1067,0 +1069,0 @@ b2World.Step_s_stepTimer = new b2_timer_1.b2Timer();

@@ -8,2 +8,3 @@ export * from "./common/b2_common";

export * from "./common/b2_augment";
export * from "./common/b2_readonly";
export * from "./collision/b2_collision";

@@ -44,2 +45,11 @@ export * from "./collision/b2_distance";

export * from "./rope/b2_rope";
export interface b2BodyUserDataMap {
}
export type b2BodyUserData = Partial<b2BodyUserDataMap>;
export interface b2FixtureUserDataMap {
}
export type b2FixtureUserData = Partial<b2FixtureUserDataMap>;
export interface b2JointUserDataMap {
}
export type b2JointUserData = Partial<b2JointUserDataMap>;
//# sourceMappingURL=index.d.ts.map

@@ -42,2 +42,3 @@ "use strict";

__exportStar(require("./common/b2_augment"), exports);
__exportStar(require("./common/b2_readonly"), exports);
__exportStar(require("./collision/b2_collision"), exports);

@@ -44,0 +45,0 @@ __exportStar(require("./collision/b2_distance"), exports);

import { b2Draw } from "../common/b2_draw";
import { b2Vec2, XY } from "../common/b2_math";
import { b2Readonly } from "../common/b2_readonly";
export declare enum b2StretchingModel {

@@ -53,4 +54,4 @@ b2_pbdStretchingModel = 0,

SetTuning(tuning: b2RopeTuning): void;
Step(dt: number, iterations: number, position: Readonly<b2Vec2>): void;
Reset(position: Readonly<b2Vec2>): void;
Step(dt: number, iterations: number, position: b2Readonly<b2Vec2>): void;
Reset(position: b2Readonly<b2Vec2>): void;
private SolveStretch_PBD;

@@ -61,3 +62,8 @@ private SolveStretch_XPBD;

private SolveBend_PBD_Distance;
/**
* Constraint based implementation of:
* P. Volino: Simple Linear Bending Stiffness in Particle Systems
*/
private SolveBend_PBD_Height;
/** M. Kelager: A Triangle Bending Constraint Model for PBD */
private SolveBend_PBD_Triangle;

@@ -64,0 +70,0 @@ private ApplyBendForces;

@@ -46,3 +46,3 @@ "use strict";

b2StretchingModel[b2StretchingModel["b2_xpbdStretchingModel"] = 1] = "b2_xpbdStretchingModel";
})(b2StretchingModel = exports.b2StretchingModel || (exports.b2StretchingModel = {}));
})(b2StretchingModel || (exports.b2StretchingModel = b2StretchingModel = {}));
var b2BendingModel;

@@ -56,3 +56,3 @@ (function (b2BendingModel) {

b2BendingModel[b2BendingModel["b2_pbdTriangleBendingModel"] = 5] = "b2_pbdTriangleBendingModel";
})(b2BendingModel = exports.b2BendingModel || (exports.b2BendingModel = {}));
})(b2BendingModel || (exports.b2BendingModel = b2BendingModel = {}));
class b2RopeTuning {

@@ -64,3 +64,3 @@ constructor() {

this.stretchStiffness = 1;
this.stretchHertz = 0;
this.stretchHertz = 1;
this.stretchDamping = 0;

@@ -507,2 +507,6 @@ this.bendStiffness = 0.5;

}
/**
* Constraint based implementation of:
* P. Volino: Simple Linear Bending Stiffness in Particle Systems
*/
SolveBend_PBD_Height() {

@@ -539,2 +543,3 @@ const stiffness = this.m_tuning.bendStiffness;

}
/** M. Kelager: A Triangle Bending Constraint Model for PBD */
SolveBend_PBD_Triangle() {

@@ -541,0 +546,0 @@ const stiffness = this.m_tuning.bendStiffness;

{
"name": "@box2d/core",
"version": "0.10.0",
"version": "0.11.0",
"description": "A TypeScript port of Box2D",

@@ -35,10 +35,4 @@ "keywords": [

"devDependencies": {
"idtsc": "^1.0.0",
"rimraf": "^3.0.2",
"typescript": "^4.7.2"
},
"publishConfig": {
"access": "public"
},
"gitHead": "072d817b70b19e17215135ea20a241af659e6925"
"idtsc": "^1.1.0"
}
}

@@ -8,2 +8,6 @@ # @box2d/core

## How to Use
Check out the [documentation](https://lusito.github.io/box2d.ts/core/setup.html)
## The @box2d Ecosystem

@@ -18,2 +22,3 @@

Other packages included in the ecosystem:
- Benchmark: Based on [bench2d](https://github.com/joelgwebber/bench2d) by joelgwebber

@@ -20,0 +25,0 @@ - Controllers: From the LiquidFun project

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc