Skip to content

Commit

Permalink
Build v1.0.7: testbed minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
shakiba committed Nov 17, 2024
1 parent 50ff5fd commit 55a9b17
Show file tree
Hide file tree
Showing 53 changed files with 584 additions and 566 deletions.
20 changes: 10 additions & 10 deletions dist/planck-with-testbed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ declare abstract class Joint {
interface Style {
stroke?: string;
fill?: string;
lineWidth?: number;
}
type KEY = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "right" | "left" | "up" | "down" | "fire";
type ActiveKeys = {
Expand All @@ -596,6 +597,7 @@ declare abstract class Testbed {
x: number;
/** World viewbox center horizontal offset. */
y: number;
/** @hidden */
scaleY: number;
/** World simulation step frequency */
hz: number;
Expand All @@ -610,11 +612,9 @@ declare abstract class Testbed {
keydown: (keyCode: number, label: string) => void;
/** callback, to be implemented by user */
keyup: (keyCode: number, label: string) => void;
private statusText;
private statusMap;
status(name: string, value: any): void;
status(value: object | string): void;
info(text: string): void;
abstract status(name: string, value: any): void;
abstract status(value: object | string): void;
abstract info(text: string): void;
color(r: number, g: number, b: number): string;
abstract drawPoint(p: {
x: number;
Expand Down Expand Up @@ -4895,6 +4895,7 @@ declare namespace planck {
interface Style {
stroke?: string;
fill?: string;
lineWidth?: number;
}
type KEY = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "right" | "left" | "up" | "down" | "fire";
type ActiveKeys = {
Expand All @@ -4920,6 +4921,7 @@ declare namespace planck {
x: number;
/** World viewbox center horizontal offset. */
y: number;
/** @hidden */
scaleY: number;
/** World simulation step frequency */
hz: number;
Expand All @@ -4934,11 +4936,9 @@ declare namespace planck {
keydown: (keyCode: number, label: string) => void;
/** callback, to be implemented by user */
keyup: (keyCode: number, label: string) => void;
private statusText;
private statusMap;
status(name: string, value: any): void;
status(value: object | string): void;
info(text: string): void;
abstract status(name: string, value: any): void;
abstract status(value: object | string): void;
abstract info(text: string): void;
color(r: number, g: number, b: number): string;
abstract drawPoint(p: {
x: number;
Expand Down
2 changes: 1 addition & 1 deletion dist/planck-with-testbed.d.ts.map

Large diffs are not rendered by default.

151 changes: 99 additions & 52 deletions dist/planck-with-testbed.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Planck.js v1.0.6
* Planck.js v1.0.7
* @license The MIT license
* @copyright Copyright (c) 2023 Erin Catto, Ali Shakiba
*
Expand Down Expand Up @@ -14981,6 +14981,7 @@
this.x = 0;
/** World viewbox center horizontal offset. */
this.y = -10;
/** @hidden */
this.scaleY = -1;
/** World simulation step frequency */
this.hz = 60;
Expand All @@ -15000,8 +15001,6 @@
this.keyup = function (keyCode, label) {
return;
};
this.statusText = '';
this.statusMap = {};
}
/**
* Mounts testbed. Call start with a world to start simulation and rendering.
Expand All @@ -15019,39 +15018,6 @@
testbed.start(world);
return testbed;
};
Testbed.prototype.status = function (a, b) {
if (typeof b !== 'undefined') {
var key_1 = a;
var value_1 = b;
if (typeof value_1 !== 'function' && typeof value_1 !== 'object') {
this.statusMap[key_1] = value_1;
}
}
else if (a && typeof a === 'object') {
// tslint:disable-next-line:no-for-in
for (var key_2 in a) {
var value_2 = a[key_2];
if (typeof value_2 !== 'function' && typeof value_2 !== 'object') {
this.statusMap[key_2] = value_2;
}
}
}
else if (typeof a === 'string') {
this.statusText = a;
}
var newline = '\n';
var text = this.statusText || '';
for (var key in this.statusMap) {
var value = this.statusMap[key];
if (typeof value === 'function')
continue;
text += (text && newline) + key + ': ' + value;
}
this._status(text);
};
Testbed.prototype.info = function (text) {
this._info(text);
};
Testbed.prototype.color = function (r, g, b) {
r = r * 256 | 0;
g = g * 256 | 0;
Expand Down Expand Up @@ -17224,6 +17190,8 @@
function() {
function Pin2(owner) {
this.uid = "pin:" + uid();
this._directionX = 1;
this._directionY = 1;
this._owner = owner;
this._parent = null;
this._relativeMatrix = new Matrix();
Expand Down Expand Up @@ -17299,7 +17267,7 @@
if (this._pivoted) {
rel.translate(-this._pivotX * this._width, -this._pivotY * this._height);
}
rel.scale(this._scaleX, this._scaleY);
rel.scale(this._scaleX * this._directionX, this._scaleY * this._directionY);
rel.skew(this._skewX, this._skewY);
rel.rotate(this._rotation);
if (this._pivoted) {
Expand Down Expand Up @@ -17344,8 +17312,8 @@
}
this._x = this._offsetX;
this._y = this._offsetY;
this._x -= this._boxX + this._handleX * this._boxWidth;
this._y -= this._boxY + this._handleY * this._boxHeight;
this._x -= this._boxX + this._handleX * this._boxWidth * this._directionX;
this._y -= this._boxY + this._handleY * this._boxHeight * this._directionY;
if (this._aligned && this._parent) {
this._parent.relativeMatrix();
this._x += this._alignX * this._parent._width;
Expand Down Expand Up @@ -18105,8 +18073,12 @@
Node2.prototype.toString = function() {
return "[" + this._label + "]";
};
Node2.prototype.id = function(id) {
return this.label(id);
Node2.prototype.id = function(label) {
if (typeof label === "undefined") {
return this._label;
}
this._label = label;
return this;
};
Node2.prototype.label = function(label) {
if (typeof label === "undefined") {
Expand Down Expand Up @@ -19063,10 +19035,12 @@
return sprite2;
}
var POINTER_CLICK = "click";
var POINTER_START = "touchstart mousedown";
var POINTER_DOWN = "touchstart mousedown";
var POINTER_MOVE = "touchmove mousemove";
var POINTER_END = "touchend mouseup";
var POINTER_UP = "touchend mouseup";
var POINTER_CANCEL = "touchcancel mousecancel";
var POINTER_START = "touchstart mousedown";
var POINTER_END = "touchend mouseup";
var EventPoint = (
/** @class */
function() {
Expand Down Expand Up @@ -19190,11 +19164,11 @@
payload.collected.push(node);
}
if (payload.event) {
var cancel = false;
var stop = false;
for (var l = 0; l < listeners.length; l++) {
cancel = listeners[l].call(node, syntheticEvent) ? true : cancel;
stop = listeners[l].call(node, syntheticEvent) ? true : stop;
}
return cancel;
return stop;
}
};
}
Expand Down Expand Up @@ -19465,6 +19439,7 @@
if (_this.drawingWidth > 0 && _this.drawingHeight > 0) {
_this.context.setTransform(1, 0, 0, 1, 0, 0);
_this.context.clearRect(0, 0, _this.drawingWidth, _this.drawingHeight);
_this.renderDebug(_this.context);
_this.render(_this.context);
}
} else if (tickRequest) {
Expand All @@ -19474,9 +19449,35 @@
}
stats.fps = elapsed ? 1e3 / elapsed : 0;
};
_this.debugDrawAxis = false;
_this.label("Root");
return _this;
}
Root2.prototype.renderDebug = function(context) {
if (!this.debugDrawAxis) {
return;
}
var m = this.matrix();
context.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
context.beginPath();
context.moveTo(0, 0);
context.lineTo(0, 10);
context.lineTo(-2, 8);
context.lineTo(2, 8);
context.lineTo(0, 10);
context.strokeStyle = "rgba(0,0,255,0.5)";
context.lineWidth = 1;
context.stroke();
context.beginPath();
context.moveTo(0, 0);
context.lineTo(10, 0);
context.lineTo(8, -2);
context.lineTo(8, 2);
context.lineTo(10, 0);
context.strokeStyle = "rgba(255,0,0,0.5)";
context.lineWidth = 1;
context.stroke();
};
Root2.prototype.resume = function() {
if (this.sleep || this.paused) {
this.requestFrame();
Expand Down Expand Up @@ -19577,18 +19578,19 @@
width: viewboxWidth,
height: viewboxHeight
});
this.scaleTo(viewportWidth, viewportHeight, viewboxMode);
this.fit(viewportWidth, viewportHeight, viewboxMode);
var viewboxX = viewbox.x || 0;
var viewboxY = viewbox.y || 0;
var cameraZoom = (camera === null || camera === void 0 ? void 0 : camera.a) || 1;
var cameraZoomX = (camera === null || camera === void 0 ? void 0 : camera.a) || 1;
var cameraZoomY = (camera === null || camera === void 0 ? void 0 : camera.d) || 1;
var cameraX = (camera === null || camera === void 0 ? void 0 : camera.e) || 0;
var cameraY = (camera === null || camera === void 0 ? void 0 : camera.f) || 0;
var scaleX = this.pin("scaleX");
var scaleY = this.pin("scaleY");
this.pin("scaleX", scaleX * cameraZoom);
this.pin("scaleY", scaleY * cameraZoom);
this.pin("offsetX", cameraX - viewboxX * scaleX * cameraZoom);
this.pin("offsetY", cameraY - viewboxY * scaleY * cameraZoom);
this.pin("scaleX", scaleX * cameraZoomX);
this.pin("scaleY", scaleY * cameraZoomY);
this.pin("offsetX", cameraX - viewboxX * scaleX * cameraZoomX);
this.pin("offsetY", cameraY - viewboxY * scaleY * cameraZoomY);
} else if (viewport) {
this.pin({
width: viewport.width,
Expand All @@ -19597,6 +19599,14 @@
}
return this;
};
Root2.prototype.flipX = function(x) {
this._pin._directionX = x ? -1 : 1;
return this;
};
Root2.prototype.flipY = function(y) {
this._pin._directionY = y ? -1 : 1;
return this;
};
return Root2;
}(Node)
);
Expand Down Expand Up @@ -19835,9 +19845,11 @@
Node,
POINTER_CANCEL,
POINTER_CLICK,
POINTER_DOWN,
POINTER_END,
POINTER_MOVE,
POINTER_START,
POINTER_UP,
Pin,
PipeTexture,
Pointer,
Expand Down Expand Up @@ -19990,6 +20002,8 @@
_this.lastDrawHash = "";
_this.newDrawHash = "";
_this.buffer = [];
_this.statusText = '';
_this.statusMap = {};
_this.drawSegment = _this.drawEdge;
return _this;
}
Expand Down Expand Up @@ -20157,6 +20171,39 @@
/** @internal */
StageTestbed.prototype._resume = function () {
};
StageTestbed.prototype.status = function (a, b) {
if (typeof b !== 'undefined') {
var key_1 = a;
var value_1 = b;
if (typeof value_1 !== 'function' && typeof value_1 !== 'object') {
this.statusMap[key_1] = value_1;
}
}
else if (a && typeof a === 'object') {
// tslint:disable-next-line:no-for-in
for (var key_2 in a) {
var value_2 = a[key_2];
if (typeof value_2 !== 'function' && typeof value_2 !== 'object') {
this.statusMap[key_2] = value_2;
}
}
}
else if (typeof a === 'string') {
this.statusText = a;
}
var newline = '\n';
var text = this.statusText || '';
for (var key in this.statusMap) {
var value = this.statusMap[key];
if (typeof value === 'function')
continue;
text += (text && newline) + key + ': ' + value;
}
this._status(text);
};
StageTestbed.prototype.info = function (text) {
this._info(text);
};
/** @internal */
StageTestbed.prototype._status = function (string) {
};
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.

Loading

0 comments on commit 55a9b17

Please sign in to comment.