Skip to content

Commit 7c400fa

Browse files
committed
build v1.2.0
1 parent 97bb79e commit 7c400fa

19 files changed

+133
-49
lines changed

.changeset/afraid-glasses-carry.md

-5
This file was deleted.

.changeset/sour-news-float.md

-5
This file was deleted.

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# planck
22

3+
## 1.2.0
4+
5+
### Minor Changes
6+
7+
- f0127f4: Add world.queueUpdate() to queue and defer updates after current simulation step
8+
9+
### Patch Changes
10+
11+
- 97bb79e: Improve world.queueUpdate
12+
313
## 1.1.6
414

515
### Patch Changes

dist/planck-with-testbed.d.ts

+27-9
Original file line numberDiff line numberDiff line change
@@ -1596,6 +1596,8 @@ declare class Body$1 {
15961596
/**
15971597
* Set the type of the body to "static", "kinematic" or "dynamic".
15981598
* @param type The type of the body.
1599+
*
1600+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
15991601
*/
16001602
setType(type: BodyType): void;
16011603
isBullet(): boolean;
@@ -1625,6 +1627,8 @@ declare class Body$1 {
16251627
* in collisions, ray-casts, or queries. Joints connected to an inactive body
16261628
* are implicitly inactive. An inactive body is still owned by a World object
16271629
* and remains
1630+
*
1631+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
16281632
*/
16291633
setActive(flag: boolean): void;
16301634
isFixedRotation(): boolean;
@@ -1641,6 +1645,8 @@ declare class Body$1 {
16411645
* transform may cause non-physical behavior. Note: contacts are updated on the
16421646
* next call to World.step.
16431647
*
1648+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
1649+
*
16441650
* @param position The world position of the body's local origin.
16451651
* @param angle The world rotation in radians.
16461652
*/
@@ -1649,6 +1655,8 @@ declare class Body$1 {
16491655
* Set the position of the body's origin and rotation. Manipulating a body's
16501656
* transform may cause non-physical behavior. Note: contacts are updated on the
16511657
* next call to World.step.
1658+
*
1659+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
16521660
*/
16531661
setTransform(xf: Transform): void;
16541662
synchronizeTransform(): void;
@@ -1751,6 +1759,8 @@ declare class Body$1 {
17511759
* destroying fixtures can also alter the mass. This function has no effect if
17521760
* the body isn't dynamic.
17531761
*
1762+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
1763+
*
17541764
* @param massData The mass properties.
17551765
*/
17561766
setMassData(massData: MassData): void;
@@ -1812,7 +1822,7 @@ declare class Body$1 {
18121822
*
18131823
* Contacts are not created until the next time step.
18141824
*
1815-
* Warning: This function is locked during callbacks.
1825+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
18161826
*/
18171827
createFixture(def: FixtureDef): Fixture;
18181828
createFixture(shape: Shape, opt?: FixtureOpt): Fixture;
@@ -1824,7 +1834,7 @@ declare class Body$1 {
18241834
* All fixtures attached to a body are implicitly destroyed when the body is
18251835
* destroyed.
18261836
*
1827-
* Warning: This function is locked during callbacks.
1837+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
18281838
*
18291839
* @param fixture The fixture to be removed.
18301840
*/
@@ -2074,13 +2084,15 @@ export declare class World {
20742084
* position -= newOrigin
20752085
*
20762086
* @param newOrigin The new origin with respect to the old origin
2087+
*
2088+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
20772089
*/
20782090
shiftOrigin(newOrigin: Vec2Value): void;
20792091
/**
20802092
* Create a rigid body given a definition. No reference to the definition is
20812093
* retained.
20822094
*
2083-
* Warning: This function is locked during callbacks.
2095+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
20842096
*/
20852097
createBody(def?: BodyDef): Body$1;
20862098
createBody(position: Vec2Value, angle?: number): Body$1;
@@ -2089,24 +2101,26 @@ export declare class World {
20892101
createKinematicBody(def?: BodyDef): Body$1;
20902102
createKinematicBody(position: Vec2Value, angle?: number): Body$1;
20912103
/**
2092-
* Destroy a rigid body given a definition. No reference to the definition is
2093-
* retained.
2104+
* Destroy a body from the world.
20942105
*
20952106
* Warning: This automatically deletes all associated shapes and joints.
20962107
*
2097-
* Warning: This function is locked during callbacks.
2108+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
20982109
*/
20992110
destroyBody(b: Body$1): boolean;
21002111
/**
21012112
* Create a joint to constrain bodies together. No reference to the definition
21022113
* is retained. This may cause the connected bodies to cease colliding.
21032114
*
2104-
* Warning: This function is locked during callbacks.
2115+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
21052116
*/
21062117
createJoint<T extends Joint>(joint: T): T | null;
21072118
/**
2108-
* Destroy a joint. This may cause the connected bodies to begin colliding.
2109-
* Warning: This function is locked during callbacks.
2119+
* Destroy a joint.
2120+
*
2121+
* Warning: This may cause the connected bodies to begin colliding.
2122+
*
2123+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
21102124
*/
21112125
destroyJoint(joint: Joint): void;
21122126
/**
@@ -2118,6 +2132,10 @@ export declare class World {
21182132
* @param timeStep Time step, this should not vary.
21192133
*/
21202134
step(timeStep: number, velocityIterations?: number, positionIterations?: number): void;
2135+
/**
2136+
* Queue a function to be called after ongoing simulation step. If no simulation is in progress call it immediately.
2137+
*/
2138+
queueUpdate(callback: (world: World) => unknown): void;
21212139
/**
21222140
* Called when two fixtures begin to touch.
21232141
*

dist/planck-with-testbed.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.planck = {}));
33
})(this, function(exports2) {
44
"use strict";/**
5-
* Planck.js v1.1.6
5+
* Planck.js v1.2.0
66
* @license The MIT license
77
* @copyright Copyright (c) 2024 Erin Catto, Ali Shakiba
88
*
@@ -5953,6 +5953,7 @@
59535953
this.m_velocityIterations = def.velocityIterations;
59545954
this.m_positionIterations = def.positionIterations;
59555955
this.m_t = 0;
5956+
this.m_step_callback = [];
59565957
}
59575958
World2.prototype._serialize = function() {
59585959
var bodies = [];
@@ -6099,7 +6100,7 @@
60996100
return this.m_broadPhase.getTreeQuality();
61006101
};
61016102
World2.prototype.shiftOrigin = function(newOrigin) {
6102-
if (this.m_locked) {
6103+
if (this.isLocked()) {
61036104
return;
61046105
}
61056106
for (var b2 = this.m_bodyList; b2; b2 = b2.m_next) {
@@ -6331,8 +6332,19 @@
63316332
this.clearForces();
63326333
}
63336334
this.m_locked = false;
6335+
var callback;
6336+
while (callback = this.m_step_callback.shift()) {
6337+
callback(this);
6338+
}
63346339
this.publish("post-step", timeStep);
63356340
};
6341+
World2.prototype.queueUpdate = function(callback) {
6342+
if (!this.isLocked()) {
6343+
callback(this);
6344+
} else {
6345+
this.m_step_callback.push(callback);
6346+
}
6347+
};
63366348
World2.prototype.findNewContacts = function() {
63376349
var _this = this;
63386350
this.m_broadPhase.updatePairs(function(proxyA, proxyB) {

dist/planck-with-testbed.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/planck-with-testbed.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/planck-with-testbed.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/planck-with-testbed.mjs

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Planck.js v1.1.6
2+
* Planck.js v1.2.0
33
* @license The MIT license
44
* @copyright Copyright (c) 2024 Erin Catto, Ali Shakiba
55
*
@@ -5949,6 +5949,7 @@ var World = (
59495949
this.m_velocityIterations = def.velocityIterations;
59505950
this.m_positionIterations = def.positionIterations;
59515951
this.m_t = 0;
5952+
this.m_step_callback = [];
59525953
}
59535954
World2.prototype._serialize = function() {
59545955
var bodies = [];
@@ -6095,7 +6096,7 @@ var World = (
60956096
return this.m_broadPhase.getTreeQuality();
60966097
};
60976098
World2.prototype.shiftOrigin = function(newOrigin) {
6098-
if (this.m_locked) {
6099+
if (this.isLocked()) {
60996100
return;
61006101
}
61016102
for (var b2 = this.m_bodyList; b2; b2 = b2.m_next) {
@@ -6327,8 +6328,19 @@ var World = (
63276328
this.clearForces();
63286329
}
63296330
this.m_locked = false;
6331+
var callback;
6332+
while (callback = this.m_step_callback.shift()) {
6333+
callback(this);
6334+
}
63306335
this.publish("post-step", timeStep);
63316336
};
6337+
World2.prototype.queueUpdate = function(callback) {
6338+
if (!this.isLocked()) {
6339+
callback(this);
6340+
} else {
6341+
this.m_step_callback.push(callback);
6342+
}
6343+
};
63326344
World2.prototype.findNewContacts = function() {
63336345
var _this = this;
63346346
this.m_broadPhase.updatePairs(function(proxyA, proxyB) {

dist/planck-with-testbed.mjs.map

+1-1
Large diffs are not rendered by default.

dist/planck.d.ts

+27-9
Original file line numberDiff line numberDiff line change
@@ -1596,6 +1596,8 @@ declare class Body$1 {
15961596
/**
15971597
* Set the type of the body to "static", "kinematic" or "dynamic".
15981598
* @param type The type of the body.
1599+
*
1600+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
15991601
*/
16001602
setType(type: BodyType): void;
16011603
isBullet(): boolean;
@@ -1625,6 +1627,8 @@ declare class Body$1 {
16251627
* in collisions, ray-casts, or queries. Joints connected to an inactive body
16261628
* are implicitly inactive. An inactive body is still owned by a World object
16271629
* and remains
1630+
*
1631+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
16281632
*/
16291633
setActive(flag: boolean): void;
16301634
isFixedRotation(): boolean;
@@ -1641,6 +1645,8 @@ declare class Body$1 {
16411645
* transform may cause non-physical behavior. Note: contacts are updated on the
16421646
* next call to World.step.
16431647
*
1648+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
1649+
*
16441650
* @param position The world position of the body's local origin.
16451651
* @param angle The world rotation in radians.
16461652
*/
@@ -1649,6 +1655,8 @@ declare class Body$1 {
16491655
* Set the position of the body's origin and rotation. Manipulating a body's
16501656
* transform may cause non-physical behavior. Note: contacts are updated on the
16511657
* next call to World.step.
1658+
*
1659+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
16521660
*/
16531661
setTransform(xf: Transform): void;
16541662
synchronizeTransform(): void;
@@ -1751,6 +1759,8 @@ declare class Body$1 {
17511759
* destroying fixtures can also alter the mass. This function has no effect if
17521760
* the body isn't dynamic.
17531761
*
1762+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
1763+
*
17541764
* @param massData The mass properties.
17551765
*/
17561766
setMassData(massData: MassData): void;
@@ -1812,7 +1822,7 @@ declare class Body$1 {
18121822
*
18131823
* Contacts are not created until the next time step.
18141824
*
1815-
* Warning: This function is locked during callbacks.
1825+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
18161826
*/
18171827
createFixture(def: FixtureDef): Fixture;
18181828
createFixture(shape: Shape, opt?: FixtureOpt): Fixture;
@@ -1824,7 +1834,7 @@ declare class Body$1 {
18241834
* All fixtures attached to a body are implicitly destroyed when the body is
18251835
* destroyed.
18261836
*
1827-
* Warning: This function is locked during callbacks.
1837+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
18281838
*
18291839
* @param fixture The fixture to be removed.
18301840
*/
@@ -2074,13 +2084,15 @@ export declare class World {
20742084
* position -= newOrigin
20752085
*
20762086
* @param newOrigin The new origin with respect to the old origin
2087+
*
2088+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
20772089
*/
20782090
shiftOrigin(newOrigin: Vec2Value): void;
20792091
/**
20802092
* Create a rigid body given a definition. No reference to the definition is
20812093
* retained.
20822094
*
2083-
* Warning: This function is locked during callbacks.
2095+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
20842096
*/
20852097
createBody(def?: BodyDef): Body$1;
20862098
createBody(position: Vec2Value, angle?: number): Body$1;
@@ -2089,24 +2101,26 @@ export declare class World {
20892101
createKinematicBody(def?: BodyDef): Body$1;
20902102
createKinematicBody(position: Vec2Value, angle?: number): Body$1;
20912103
/**
2092-
* Destroy a rigid body given a definition. No reference to the definition is
2093-
* retained.
2104+
* Destroy a body from the world.
20942105
*
20952106
* Warning: This automatically deletes all associated shapes and joints.
20962107
*
2097-
* Warning: This function is locked during callbacks.
2108+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
20982109
*/
20992110
destroyBody(b: Body$1): boolean;
21002111
/**
21012112
* Create a joint to constrain bodies together. No reference to the definition
21022113
* is retained. This may cause the connected bodies to cease colliding.
21032114
*
2104-
* Warning: This function is locked during callbacks.
2115+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
21052116
*/
21062117
createJoint<T extends Joint>(joint: T): T | null;
21072118
/**
2108-
* Destroy a joint. This may cause the connected bodies to begin colliding.
2109-
* Warning: This function is locked during callbacks.
2119+
* Destroy a joint.
2120+
*
2121+
* Warning: This may cause the connected bodies to begin colliding.
2122+
*
2123+
* Warning: This function is locked when a world simulation step is in progress. Use queueUpdate to schedule a function to be called after the step.
21102124
*/
21112125
destroyJoint(joint: Joint): void;
21122126
/**
@@ -2118,6 +2132,10 @@ export declare class World {
21182132
* @param timeStep Time step, this should not vary.
21192133
*/
21202134
step(timeStep: number, velocityIterations?: number, positionIterations?: number): void;
2135+
/**
2136+
* Queue a function to be called after ongoing simulation step. If no simulation is in progress call it immediately.
2137+
*/
2138+
queueUpdate(callback: (world: World) => unknown): void;
21212139
/**
21222140
* Called when two fixtures begin to touch.
21232141
*

0 commit comments

Comments
 (0)