UNPKG

arcade-physics

Version:
45 lines 2.08 kB
"use strict"; /** * @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 GetLineToRectangle_1 = __importDefault(require("./GetLineToRectangle")); const RectangleToRectangle_1 = __importDefault(require("./RectangleToRectangle")); /** * Checks if two Rectangles intersect and returns the intersection points as a Point object array. * * A Rectangle intersects another Rectangle if any part of its bounds is within the other Rectangle's bounds. As such, the two Rectangles are considered "solid". A Rectangle with no width or no height will never intersect another Rectangle. * * @function Phaser.Geom.Intersects.GetRectangleToRectangle * @since 3.0.0 * * @param {Phaser.Geom.Rectangle} rectA - The first Rectangle to check for intersection. * @param {Phaser.Geom.Rectangle} rectB - The second Rectangle 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 GetRectangleToRectangle = (rectA, rectB, out) => { if (out === undefined) { out = []; } if ((0, RectangleToRectangle_1.default)(rectA, rectB)) { const lineA = rectA.getLineA(); const lineB = rectA.getLineB(); const lineC = rectA.getLineC(); const lineD = rectA.getLineD(); (0, GetLineToRectangle_1.default)(lineA, rectB, out); (0, GetLineToRectangle_1.default)(lineB, rectB, out); (0, GetLineToRectangle_1.default)(lineC, rectB, out); (0, GetLineToRectangle_1.default)(lineD, rectB, out); } return out; }; exports.default = GetRectangleToRectangle; //# sourceMappingURL=GetRectangleToRectangle.js.map