arcade-physics
Version:
Use Arcade Physics without Phaser.
43 lines • 1.94 kB
JavaScript
;
/**
* @author Florian Vazelle
* @author Geoffrey Glaive
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const TriangleToTriangle_1 = __importDefault(require("./TriangleToTriangle"));
const GetTriangleToLine_1 = __importDefault(require("./GetTriangleToLine"));
/**
* Checks if two Triangles intersect, and returns the intersection points as a Point object array.
*
* A Triangle intersects another Triangle if any pair of their lines intersects or if any point of one Triangle is within the other Triangle. Thus, the Triangles are considered "solid".
*
* @function Phaser.Geom.Intersects.GetTriangleToTriangle
* @since 3.0.0
*
* @param {Phaser.Geom.Triangle} triangleA - The first Triangle to check for intersection.
* @param {Phaser.Geom.Triangle} triangleB - The second Triangle to check for intersection.
* @param {array} [out] - An optional array in which to store the points of intersection.
*
* @return {array} An array with the points of intersection if objects intersect, otherwise an empty array.
*/
const GetTriangleToTriangle = (triangleA, triangleB, out) => {
if (out === undefined) {
out = [];
}
if ((0, TriangleToTriangle_1.default)(triangleA, triangleB)) {
const lineA = triangleB.getLineA();
const lineB = triangleB.getLineB();
const lineC = triangleB.getLineC();
(0, GetTriangleToLine_1.default)(triangleA, lineA, out);
(0, GetTriangleToLine_1.default)(triangleA, lineB, out);
(0, GetTriangleToLine_1.default)(triangleA, lineC, out);
}
return out;
};
exports.default = GetTriangleToTriangle;
//# sourceMappingURL=GetTriangleToTriangle.js.map