From 829a25595c13d643926eb4a7aaff07ddb2002b11 Mon Sep 17 00:00:00 2001 From: Jacek Pietal Date: Fri, 4 Oct 2024 00:56:13 +0200 Subject: [PATCH] feat: publish to npm after pull#82 --- dist/bodies/circle.d.ts | 3 - dist/bodies/circle.js | 4 +- dist/bodies/polygon.d.ts | 3 - dist/bodies/polygon.js | 4 +- dist/demo/demo.js | 69 ++++++--- dist/model.d.ts | 11 ++ dist/utils.d.ts | 29 ++++ dist/utils.js | 30 ++++ docs/classes/Box.html | 202 ++++++++++++++++++------ docs/classes/Circle.html | 170 ++++++++++++++++---- docs/classes/Ellipse.html | 202 ++++++++++++++++++------ docs/classes/Line.html | 202 ++++++++++++++++++------ docs/classes/Point.html | 202 ++++++++++++++++++------ docs/classes/Polygon.html | 206 +++++++++++++++++++------ docs/demo/demo.js | 69 ++++++--- docs/enums/BodyGroup.html | 28 ++-- docs/enums/BodyType.html | 28 ++-- docs/functions/bin2dec.html | 4 +- docs/functions/bodyMoved.html | 4 +- docs/functions/canInteract.html | 29 +++- docs/functions/checkAInB.html | 4 +- docs/functions/clonePointsArray.html | 4 +- docs/functions/cloneResponse.html | 4 +- docs/functions/dashLineTo.html | 4 +- docs/functions/drawBVH.html | 4 +- docs/functions/drawPolygon.html | 4 +- docs/functions/ensureNumber.html | 4 +- docs/functions/getBounceDirection.html | 4 +- docs/functions/getGroup.html | 4 +- docs/functions/getSATTest.html | 4 +- docs/functions/groupBits.html | 4 +- docs/functions/intersectAABB.html | 4 +- docs/functions/mapArrayToVector.html | 4 +- docs/functions/mapVectorToArray.html | 4 +- docs/functions/move.html | 4 +- docs/functions/notIntersectAABB.html | 4 +- docs/functions/returnTrue.html | 4 +- docs/interfaces/BBox.html | 20 +-- docs/interfaces/BodyOptions.html | 83 ++++++++-- docs/interfaces/BodyProps.html | 151 ++++++++++++------ docs/interfaces/ChildrenData.html | 8 +- docs/interfaces/Data.html | 8 +- docs/interfaces/GetAABBAsBox.html | 8 +- docs/interfaces/PotentialVector.html | 12 +- docs/interfaces/RaycastHit.html | 12 +- docs/interfaces/Vector.html | 12 +- docs/types/Body.html | 4 +- docs/types/CollisionCallback.html | 4 +- docs/types/InTest.html | 4 +- docs/types/Leaf.html | 4 +- docs/types/SATTest.html | 4 +- docs/types/TraverseFunction.html | 4 +- package.json | 8 +- yarn.lock | 24 +-- 54 files changed, 1434 insertions(+), 503 deletions(-) diff --git a/dist/bodies/circle.d.ts b/dist/bodies/circle.d.ts index 5513b2ff..377ac85b 100644 --- a/dist/bodies/circle.d.ts +++ b/dist/bodies/circle.d.ts @@ -123,9 +123,6 @@ export declare class Circle extends SATCircle implements BBox, BodyProps { * scaleY = scale in case of Circles */ get scaleY(): number; - /** - * group for collision filtering - */ get group(): number; set group(group: number); /** diff --git a/dist/bodies/circle.js b/dist/bodies/circle.js index 8f028cbc..306c416d 100644 --- a/dist/bodies/circle.js +++ b/dist/bodies/circle.js @@ -90,9 +90,7 @@ class Circle extends sat_1.Circle { get scaleY() { return this.scale; } - /** - * group for collision filtering - */ + // Don't overwrite docs from BodyProps get group() { return this._group; } diff --git a/dist/bodies/polygon.d.ts b/dist/bodies/polygon.d.ts index 0be2bed7..33726c2d 100644 --- a/dist/bodies/polygon.d.ts +++ b/dist/bodies/polygon.d.ts @@ -141,9 +141,6 @@ export declare class Polygon extends SATPolygon implements BBox, BodyProps { * allow easier setting of scale */ set scale(scale: number); - /** - * group for collision filtering - */ get group(): number; set group(group: number); /** diff --git a/dist/bodies/polygon.js b/dist/bodies/polygon.js index cd6c8f4d..6fe535eb 100644 --- a/dist/bodies/polygon.js +++ b/dist/bodies/polygon.js @@ -114,9 +114,7 @@ class Polygon extends sat_1.Polygon { set scale(scale) { this.setScale(scale); } - /** - * group for collision filtering - */ + // Don't overwrite docs from BodyProps get group() { return this._group; } diff --git a/dist/demo/demo.js b/dist/demo/demo.js index 1d704423..f8e110ee 100644 --- a/dist/demo/demo.js +++ b/dist/demo/demo.js @@ -2704,9 +2704,7 @@ which is good. See: http://baagoe.com/en/RandomMusings/hash/avalanche.xhtml get scaleY() { return this.scale; } - /** - * group for collision filtering - */ + // Don't overwrite docs from BodyProps get group() { return this._group; } @@ -3240,9 +3238,7 @@ which is good. See: http://baagoe.com/en/RandomMusings/hash/avalanche.xhtml set scale(scale) { this.setScale(scale); } - /** - * group for collision filtering - */ + // Don't overwrite docs from BodyProps get group() { return this._group; } @@ -4345,6 +4341,7 @@ which is good. See: http://baagoe.com/en/RandomMusings/hash/avalanche.xhtml body.isStatic = !!options.isStatic; body.isTrigger = !!options.isTrigger; body.padding = options.padding || 0; + // Default value should be reflected in documentation of `BodyOptions.group` body.group = (_a = options.group) !== null && _a !== void 0 ? _a : 0x7fffffff; if ( @@ -4389,8 +4386,37 @@ which is good. See: http://baagoe.com/en/RandomMusings/hash/avalanche.xhtml /** * checks if two bodies can interact (for collision filtering) * + * Based on {@link https://box2d.org/documentation/md_simulation.html#filtering Box2D} + * ({@link https://aurelienribon.wordpress.com/2011/07/01/box2d-tutorial-collision-filtering/ tutorial}) + * * @param bodyA * @param bodyB + * + * @example + * const body1 = { group: 0b00000000_00000000_00000001_00000000 } + * const body2 = { group: 0b11111111_11111111_00000011_00000000 } + * const body3 = { group: 0b00000010_00000000_00000100_00000000 } + * + * // Body 1 has the first custom group but cannot interact with any other groups + * // except itself because the first 16 bits are all zeros, only bodies with an + * // identical value can interact with it. + * canInteract(body1, body1) // returns true (identical groups can always interact) + * canInteract(body1, body2) // returns false + * canInteract(body1, body3) // returns false + * + * // Body 2 has the first and second group and can interact with all other + * // groups, but only if that body also can interact with is custom group. + * canInteract(body2, body1) // returns false (body1 cannot interact with others) + * canInteract(body2, body2) // returns true (identical groups can always interact) + * canInteract(body2, body3) // returns true + * + * // Body 3 has the third group but can interact with the second group. + * // This means that Body 2 and Body 3 can interact with each other but no other + * // body can interact with Body 1 because it doesn't allow interactions with + * // any other custom group. + * canInteract(body3, body1) // returns false (body1 cannot interact with others) + * canInteract(body3, body2) // returns true + * canInteract(body3, body3) // returns true (identical groups can always interact) */ function canInteract({ group: groupA }, { group: groupB }) { return ( @@ -6173,26 +6199,29 @@ which is good. See: http://baagoe.com/en/RandomMusings/hash/avalanche.xhtml /******/ /************************************************************************/ var __webpack_exports__ = {}; - /*!***************************!*\ + // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. + (() => { + /*!***************************!*\ !*** ./src/demo/index.js ***! \***************************/ - const { TestCanvas } = __webpack_require__( - /*! ./canvas */ "./src/demo/canvas.js", - ); + const { TestCanvas } = __webpack_require__( + /*! ./canvas */ "./src/demo/canvas.js", + ); - const isStressTest = window.location.search.indexOf("?stress") !== -1; - const Test = isStressTest - ? __webpack_require__(/*! ./stress */ "./src/demo/stress.js") - : __webpack_require__(/*! ./tank */ "./src/demo/tank.js"); + const isStressTest = window.location.search.indexOf("?stress") !== -1; + const Test = isStressTest + ? __webpack_require__(/*! ./stress */ "./src/demo/stress.js") + : __webpack_require__(/*! ./tank */ "./src/demo/tank.js"); - const test = new Test(); - const canvas = new TestCanvas(test); + const test = new Test(); + const canvas = new TestCanvas(test); - document.body.appendChild(canvas.element); + document.body.appendChild(canvas.element); - if (test.start) { - test.start(); - } + if (test.start) { + test.start(); + } + })(); /******/ })(); diff --git a/dist/model.d.ts b/dist/model.d.ts index 32c698d0..403f6b48 100644 --- a/dist/model.d.ts +++ b/dist/model.d.ts @@ -91,6 +91,17 @@ export interface BodyOptions { padding?: number; /** * group for collision filtering + * + * Based on {@link https://box2d.org/documentation/md_simulation.html#filtering Box2D} + * ({@link https://aurelienribon.wordpress.com/2011/07/01/box2d-tutorial-collision-filtering/ tutorial}) + * + * Values in {@link BodyGroup} are predefined and used each the body type and + * should not be used for custom filtering + * + * `0b00000001 << 16` to `0b01000000 << 16` (max 0x7fffffff) are free to use for custom groups + * + * @see {@link canInteract} for how groups are used + * @default 0x7fffffff // member of all groups (can interact with everyting) */ group?: number; } diff --git a/dist/utils.d.ts b/dist/utils.d.ts index e5b9099d..b6ec08ee 100644 --- a/dist/utils.d.ts +++ b/dist/utils.d.ts @@ -69,8 +69,37 @@ export declare function intersectAABB(bodyA: BBox, bodyB: BBox): boolean; /** * checks if two bodies can interact (for collision filtering) * + * Based on {@link https://box2d.org/documentation/md_simulation.html#filtering Box2D} + * ({@link https://aurelienribon.wordpress.com/2011/07/01/box2d-tutorial-collision-filtering/ tutorial}) + * * @param bodyA * @param bodyB + * + * @example + * const body1 = { group: 0b00000000_00000000_00000001_00000000 } + * const body2 = { group: 0b11111111_11111111_00000011_00000000 } + * const body3 = { group: 0b00000010_00000000_00000100_00000000 } + * + * // Body 1 has the first custom group but cannot interact with any other groups + * // except itself because the first 16 bits are all zeros, only bodies with an + * // identical value can interact with it. + * canInteract(body1, body1) // returns true (identical groups can always interact) + * canInteract(body1, body2) // returns false + * canInteract(body1, body3) // returns false + * + * // Body 2 has the first and second group and can interact with all other + * // groups, but only if that body also can interact with is custom group. + * canInteract(body2, body1) // returns false (body1 cannot interact with others) + * canInteract(body2, body2) // returns true (identical groups can always interact) + * canInteract(body2, body3) // returns true + * + * // Body 3 has the third group but can interact with the second group. + * // This means that Body 2 and Body 3 can interact with each other but no other + * // body can interact with Body 1 because it doesn't allow interactions with + * // any other custom group. + * canInteract(body3, body1) // returns false (body1 cannot interact with others) + * canInteract(body3, body2) // returns true + * canInteract(body3, body3) // returns true (identical groups can always interact) */ export declare function canInteract( { group: groupA }: Body, diff --git a/dist/utils.js b/dist/utils.js index 2d75c75e..eccf42c3 100644 --- a/dist/utils.js +++ b/dist/utils.js @@ -145,6 +145,7 @@ function extendBody(body, options = {}) { body.isStatic = !!options.isStatic; body.isTrigger = !!options.isTrigger; body.padding = options.padding || 0; + // Default value should be reflected in documentation of `BodyOptions.group` body.group = (_a = options.group) !== null && _a !== void 0 ? _a : 0x7fffffff; if (body.typeGroup !== model_1.BodyGroup.Circle && options.isCentered) { body.isCentered = true; @@ -182,8 +183,37 @@ function intersectAABB(bodyA, bodyB) { /** * checks if two bodies can interact (for collision filtering) * + * Based on {@link https://box2d.org/documentation/md_simulation.html#filtering Box2D} + * ({@link https://aurelienribon.wordpress.com/2011/07/01/box2d-tutorial-collision-filtering/ tutorial}) + * * @param bodyA * @param bodyB + * + * @example + * const body1 = { group: 0b00000000_00000000_00000001_00000000 } + * const body2 = { group: 0b11111111_11111111_00000011_00000000 } + * const body3 = { group: 0b00000010_00000000_00000100_00000000 } + * + * // Body 1 has the first custom group but cannot interact with any other groups + * // except itself because the first 16 bits are all zeros, only bodies with an + * // identical value can interact with it. + * canInteract(body1, body1) // returns true (identical groups can always interact) + * canInteract(body1, body2) // returns false + * canInteract(body1, body3) // returns false + * + * // Body 2 has the first and second group and can interact with all other + * // groups, but only if that body also can interact with is custom group. + * canInteract(body2, body1) // returns false (body1 cannot interact with others) + * canInteract(body2, body2) // returns true (identical groups can always interact) + * canInteract(body2, body3) // returns true + * + * // Body 3 has the third group but can interact with the second group. + * // This means that Body 2 and Body 3 can interact with each other but no other + * // body can interact with Body 1 because it doesn't allow interactions with + * // any other custom group. + * canInteract(body3, body1) // returns false (body1 cannot interact with others) + * canInteract(body3, body2) // returns true + * canInteract(body3, body3) // returns true (identical groups can always interact) */ function canInteract({ group: groupA }, { group: groupB }) { return ( diff --git a/docs/classes/Box.html b/docs/classes/Box.html index 3d19d613..aa65806c 100644 --- a/docs/classes/Box.html +++ b/docs/classes/Box.html @@ -1757,19 +1757,76 @@