Skip to content

Commit 59d72ed

Browse files
committed
Build
1 parent 1d3d09c commit 59d72ed

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

dist/cannon-es.cjs.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1801,6 +1801,8 @@ class Quaternion {
18011801
target.x = bank;
18021802
}
18031803
/**
1804+
* Set the quaternion components given Euler angle representation.
1805+
*
18041806
* @param order The order to apply angles: 'XYZ' or 'YXZ' or any other combination.
18051807
*
18061808
* See {@link https://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors MathWorks} reference
@@ -10457,7 +10459,8 @@ class Narrowphase {
1045710459

1045810460
if (friction > 0) {
1045910461
// Create 2 tangent equations
10460-
const mug = friction * world.gravity.length();
10462+
// Users may provide a force different from global gravity to use when computing contact friction.
10463+
const mug = friction * (world.frictionGravity || world.gravity).length();
1046110464
let reducedMass = bodyA.invMass + bodyB.invMass;
1046210465

1046310466
if (reducedMass > 0) {
@@ -12115,6 +12118,12 @@ class World extends EventTarget {
1211512118
* The gravity of the world.
1211612119
*/
1211712120

12121+
/**
12122+
* Gravity to use when approximating the friction max force (mu*mass*gravity).
12123+
* If undefined, global gravity will be used.
12124+
* Use to enable friction in a World with a null gravity vector (no gravity).
12125+
*/
12126+
1211812127
/**
1211912128
* The broadphase algorithm to use.
1212012129
* @default NaiveBroadphase
@@ -12191,6 +12200,11 @@ class World extends EventTarget {
1219112200
this.gravity.copy(options.gravity);
1219212201
}
1219312202

12203+
if (options.frictionGravity) {
12204+
this.frictionGravity = new Vec3();
12205+
this.frictionGravity.copy(options.frictionGravity);
12206+
}
12207+
1219412208
this.broadphase = options.broadphase !== undefined ? options.broadphase : new NaiveBroadphase();
1219512209
this.bodies = [];
1219612210
this.hasActiveBodies = false;

dist/cannon-es.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ declare module "world/World" {
799799
default_dt: number;
800800
nextId: number;
801801
gravity: Vec3;
802+
frictionGravity?: Vec3;
802803
broadphase: Broadphase;
803804
bodies: Body[];
804805
hasActiveBodies: boolean;
@@ -837,6 +838,7 @@ declare module "world/World" {
837838
lastCallTime?: number;
838839
constructor(options?: {
839840
gravity?: Vec3;
841+
frictionGravity?: Vec3;
840842
allowSleep?: boolean;
841843
broadphase?: Broadphase;
842844
solver?: Solver;

dist/cannon-es.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1797,6 +1797,8 @@ class Quaternion {
17971797
target.x = bank;
17981798
}
17991799
/**
1800+
* Set the quaternion components given Euler angle representation.
1801+
*
18001802
* @param order The order to apply angles: 'XYZ' or 'YXZ' or any other combination.
18011803
*
18021804
* See {@link https://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors MathWorks} reference
@@ -10453,7 +10455,8 @@ class Narrowphase {
1045310455

1045410456
if (friction > 0) {
1045510457
// Create 2 tangent equations
10456-
const mug = friction * world.gravity.length();
10458+
// Users may provide a force different from global gravity to use when computing contact friction.
10459+
const mug = friction * (world.frictionGravity || world.gravity).length();
1045710460
let reducedMass = bodyA.invMass + bodyB.invMass;
1045810461

1045910462
if (reducedMass > 0) {
@@ -12111,6 +12114,12 @@ class World extends EventTarget {
1211112114
* The gravity of the world.
1211212115
*/
1211312116

12117+
/**
12118+
* Gravity to use when approximating the friction max force (mu*mass*gravity).
12119+
* If undefined, global gravity will be used.
12120+
* Use to enable friction in a World with a null gravity vector (no gravity).
12121+
*/
12122+
1211412123
/**
1211512124
* The broadphase algorithm to use.
1211612125
* @default NaiveBroadphase
@@ -12187,6 +12196,11 @@ class World extends EventTarget {
1218712196
this.gravity.copy(options.gravity);
1218812197
}
1218912198

12199+
if (options.frictionGravity) {
12200+
this.frictionGravity = new Vec3();
12201+
this.frictionGravity.copy(options.frictionGravity);
12202+
}
12203+
1219012204
this.broadphase = options.broadphase !== undefined ? options.broadphase : new NaiveBroadphase();
1219112205
this.bodies = [];
1219212206
this.hasActiveBodies = false;

0 commit comments

Comments
 (0)