Skip to content

Commit

Permalink
replace vec2 with vec2value in the api, update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
shakiba committed May 23, 2024
1 parent 293c0c6 commit 0d2efe6
Show file tree
Hide file tree
Showing 40 changed files with 445 additions and 364 deletions.
222 changes: 117 additions & 105 deletions dist/planck-with-testbed.d.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/planck-with-testbed.d.ts.map

Large diffs are not rendered by default.

60 changes: 38 additions & 22 deletions dist/planck-with-testbed.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Planck.js v1.0.3
* Planck.js v1.0.4
* @license The MIT license
* @copyright Copyright (c) 2023 Erin Catto, Ali Shakiba
*
Expand Down Expand Up @@ -9463,6 +9463,7 @@
* this for loops.
*/
ChainShape.prototype.setPrevVertex = function (prevVertex) {
// todo: copy or reference
this.m_prevVertex = prevVertex;
this.m_hasPrevVertex = true;
};
Expand All @@ -9474,6 +9475,7 @@
* this for loops.
*/
ChainShape.prototype.setNextVertex = function (nextVertex) {
// todo: copy or reference
this.m_nextVertex = nextVertex;
this.m_hasNextVertex = true;
};
Expand Down Expand Up @@ -15002,17 +15004,15 @@
this.statusMap = {};
}
/**
* Mount testbed.
*
* If you need to customize testbed before starting, use `Testbed.mount()` and `Testbed.start()` separately.
* Mounts testbed. Call start with a world to start simulation and rendering.
*/
Testbed.mount = function (options) {
throw new Error('Not implemented');
};
/**
* Start simulation, and mount testbed if needed.
* Mounts testbed if needed, then starts simulation and rendering.
*
* If you need to customize testbed before starting, use `Testbed.mount().start()` separately.
* If you need to customize testbed before starting, first run `const testbed = Testbed.mount()` and then `testbed.start()`.
*/
Testbed.start = function (world) {
var testbed = Testbed.mount();
Expand Down Expand Up @@ -15114,14 +15114,21 @@
*/
var BoxShape = /** @class */ (function (_super) {
__extends(BoxShape, _super);
function BoxShape(hx, hy, center, angle) {
/**
*
* @param halfWidth
* @param halfHeight
* @param center coordinate of the center of the box relative to the body
* @param angle angle of the box relative to the body
*/
function BoxShape(halfWidth, halfHeight, center, angle) {
var _this = this;
// @ts-ignore
if (!(_this instanceof BoxShape)) {
return new BoxShape(hx, hy, center, angle);
return new BoxShape(halfWidth, halfHeight, center, angle);
}
_this = _super.call(this) || this;
_this._setAsBox(hx, hy, center, angle);
_this._setAsBox(halfWidth, halfHeight, center, angle);
return _this;
}
// note that box is serialized/deserialized as polygon
Expand Down Expand Up @@ -19398,19 +19405,26 @@
var playButton = document.getElementById('testbed-play');
var statusElement = document.getElementById('testbed-status');
var infoElement = document.getElementById('testbed-info');
playButton.addEventListener('click', function () {
mounted.isPaused() ? mounted.resume() : mounted.pause();
});
mounted._pause = function () {
playButton.classList.add('pause');
playButton.classList.remove('play');
};
mounted._resume = function () {
playButton.classList.add('play');
playButton.classList.remove('pause');
};
if (playButton) {
playButton.addEventListener('click', function () {
mounted.isPaused() ? mounted.resume() : mounted.pause();
});
mounted._pause = function () {
playButton.classList.add('pause');
playButton.classList.remove('play');
};
mounted._resume = function () {
playButton.classList.add('play');
playButton.classList.remove('pause');
};
}
else {
console.log("Please create a button with id='testbed-play'");
}
var lastStatus = '';
statusElement.innerText = lastStatus;
if (statusElement) {
statusElement.innerText = lastStatus;
}
mounted._status = function (text) {
if (lastStatus === text) {
return;
Expand All @@ -19421,7 +19435,9 @@
}
};
var lastInfo = '';
infoElement.innerText = lastInfo;
if (infoElement) {
infoElement.innerText = lastInfo;
}
mounted._info = function (text) {
if (lastInfo === text) {
return;
Expand Down
2 changes: 1 addition & 1 deletion dist/planck-with-testbed.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/planck-with-testbed.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/planck-with-testbed.min.js.map

Large diffs are not rendered by default.

60 changes: 38 additions & 22 deletions dist/planck-with-testbed.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Planck.js v1.0.3
* Planck.js v1.0.4
* @license The MIT license
* @copyright Copyright (c) 2023 Erin Catto, Ali Shakiba
*
Expand Down Expand Up @@ -9457,6 +9457,7 @@ var ChainShape = /** @class */ (function (_super) {
* this for loops.
*/
ChainShape.prototype.setPrevVertex = function (prevVertex) {
// todo: copy or reference
this.m_prevVertex = prevVertex;
this.m_hasPrevVertex = true;
};
Expand All @@ -9468,6 +9469,7 @@ var ChainShape = /** @class */ (function (_super) {
* this for loops.
*/
ChainShape.prototype.setNextVertex = function (nextVertex) {
// todo: copy or reference
this.m_nextVertex = nextVertex;
this.m_hasNextVertex = true;
};
Expand Down Expand Up @@ -14996,17 +14998,15 @@ var Testbed = /** @class */ (function () {
this.statusMap = {};
}
/**
* Mount testbed.
*
* If you need to customize testbed before starting, use `Testbed.mount()` and `Testbed.start()` separately.
* Mounts testbed. Call start with a world to start simulation and rendering.
*/
Testbed.mount = function (options) {
throw new Error('Not implemented');
};
/**
* Start simulation, and mount testbed if needed.
* Mounts testbed if needed, then starts simulation and rendering.
*
* If you need to customize testbed before starting, use `Testbed.mount().start()` separately.
* If you need to customize testbed before starting, first run `const testbed = Testbed.mount()` and then `testbed.start()`.
*/
Testbed.start = function (world) {
var testbed = Testbed.mount();
Expand Down Expand Up @@ -15108,14 +15108,21 @@ function testbed(a, b) {
*/
var BoxShape = /** @class */ (function (_super) {
__extends(BoxShape, _super);
function BoxShape(hx, hy, center, angle) {
/**
*
* @param halfWidth
* @param halfHeight
* @param center coordinate of the center of the box relative to the body
* @param angle angle of the box relative to the body
*/
function BoxShape(halfWidth, halfHeight, center, angle) {
var _this = this;
// @ts-ignore
if (!(_this instanceof BoxShape)) {
return new BoxShape(hx, hy, center, angle);
return new BoxShape(halfWidth, halfHeight, center, angle);
}
_this = _super.call(this) || this;
_this._setAsBox(hx, hy, center, angle);
_this._setAsBox(halfWidth, halfHeight, center, angle);
return _this;
}
// note that box is serialized/deserialized as polygon
Expand Down Expand Up @@ -19392,19 +19399,26 @@ Testbed.mount = function () {
var playButton = document.getElementById('testbed-play');
var statusElement = document.getElementById('testbed-status');
var infoElement = document.getElementById('testbed-info');
playButton.addEventListener('click', function () {
mounted.isPaused() ? mounted.resume() : mounted.pause();
});
mounted._pause = function () {
playButton.classList.add('pause');
playButton.classList.remove('play');
};
mounted._resume = function () {
playButton.classList.add('play');
playButton.classList.remove('pause');
};
if (playButton) {
playButton.addEventListener('click', function () {
mounted.isPaused() ? mounted.resume() : mounted.pause();
});
mounted._pause = function () {
playButton.classList.add('pause');
playButton.classList.remove('play');
};
mounted._resume = function () {
playButton.classList.add('play');
playButton.classList.remove('pause');
};
}
else {
console.log("Please create a button with id='testbed-play'");
}
var lastStatus = '';
statusElement.innerText = lastStatus;
if (statusElement) {
statusElement.innerText = lastStatus;
}
mounted._status = function (text) {
if (lastStatus === text) {
return;
Expand All @@ -19415,7 +19429,9 @@ Testbed.mount = function () {
}
};
var lastInfo = '';
infoElement.innerText = lastInfo;
if (infoElement) {
infoElement.innerText = lastInfo;
}
mounted._info = function (text) {
if (lastInfo === text) {
return;
Expand Down
2 changes: 1 addition & 1 deletion dist/planck-with-testbed.mjs.map

Large diffs are not rendered by default.

Loading

0 comments on commit 0d2efe6

Please sign in to comment.