pixi.js 8.13.2-dev.0833a7a → 8.13.2-dev.5c2ec18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/packages/advanced-blend-modes.js +1 -1
- package/dist/packages/advanced-blend-modes.min.js +1 -1
- package/dist/packages/gif.js +1 -1
- package/dist/packages/gif.min.js +1 -1
- package/dist/packages/math-extras.js +9 -1
- package/dist/packages/math-extras.js.map +1 -1
- package/dist/packages/math-extras.min.js +2 -2
- package/dist/packages/math-extras.min.js.map +1 -1
- package/dist/packages/unsafe-eval.js +1 -1
- package/dist/packages/unsafe-eval.min.js +1 -1
- package/dist/pixi.js +1 -1
- package/dist/pixi.js.d.ts +32 -0
- package/dist/pixi.min.js +1 -1
- package/dist/pixi.min.mjs +1 -1
- package/dist/pixi.mjs +1 -1
- package/dist/webworker.js +1 -1
- package/dist/webworker.min.js +1 -1
- package/dist/webworker.min.mjs +1 -1
- package/dist/webworker.mjs +1 -1
- package/lib/math-extras/MathExtraMixins.d.ts +36 -0
- package/lib/math-extras/pointExtras.js +8 -0
- package/lib/math-extras/pointExtras.js.map +1 -1
- package/lib/math-extras/pointExtras.mjs +8 -0
- package/lib/math-extras/pointExtras.mjs.map +1 -1
- package/package.json +1 -1
package/dist/packages/gif.js
CHANGED
package/dist/packages/gif.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* PixiJS - v8.13.2
|
|
3
|
-
* Compiled Mon, 06 Oct 2025 21:
|
|
3
|
+
* Compiled Mon, 06 Oct 2025 21:10:06 UTC
|
|
4
4
|
*
|
|
5
5
|
* PixiJS is licensed under the MIT License.
|
|
6
6
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -82,6 +82,14 @@ var math_extras_js = (function (exports) {
|
|
|
82
82
|
outPoint.x = this.x - 2 * dotProduct * normal.x;
|
|
83
83
|
outPoint.y = this.y - 2 * dotProduct * normal.y;
|
|
84
84
|
return outPoint;
|
|
85
|
+
},
|
|
86
|
+
rotate(radians, outPoint) {
|
|
87
|
+
outPoint != null ? outPoint : outPoint = new PIXI.Point();
|
|
88
|
+
const cosTheta = Math.cos(radians);
|
|
89
|
+
const sinTheta = Math.sin(radians);
|
|
90
|
+
outPoint.x = this.x * cosTheta - this.y * sinTheta;
|
|
91
|
+
outPoint.y = this.x * sinTheta + this.y * cosTheta;
|
|
92
|
+
return outPoint;
|
|
85
93
|
}
|
|
86
94
|
};
|
|
87
95
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math-extras.js","sources":["../../src/math-extras/pointExtras.ts","../../src/math-extras/rectangleExtras.ts","../../src/math-extras/init.ts","../../src/math-extras/util.ts"],"sourcesContent":["import { Point } from '../maths/point/Point';\n\nimport type { PointData } from '../maths/point/PointData';\n\n/** @internal */\nexport const pointExtraMixins: any = {\n add<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x + other.x;\n outPoint.y = this.y + other.y;\n\n return outPoint;\n },\n subtract<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x - other.x;\n outPoint.y = this.y - other.y;\n\n return outPoint;\n },\n multiply<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x * other.x;\n outPoint.y = this.y * other.y;\n\n return outPoint;\n },\n multiplyScalar<T extends PointData>(scalar: number, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x * scalar;\n outPoint.y = this.y * scalar;\n\n return outPoint;\n },\n dot(other: PointData): number\n {\n return (this.x * other.x) + (this.y * other.y);\n },\n cross(other: PointData): number\n {\n /*\n * Returns the magnitude of the vector that would result\n * from a regular 3D cross product of the input vectors,\n * taking their Z values implicitly as 0\n * (i.e. treating the 2D space as a plane in the 3D space).\n * The 3D cross product will be perpendicular to that plane,\n * and thus have 0 X & Y components\n * (thus the scalar returned is the Z value of the 3D cross product vector).\n */\n return (this.x * other.y) - (this.y * other.x);\n },\n normalize<T extends PointData>(outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n const magnitude = Math.sqrt((this.x * this.x) + (this.y * this.y));\n\n outPoint.x = this.x / magnitude;\n outPoint.y = this.y / magnitude;\n\n return outPoint;\n },\n magnitude(): number\n {\n return Math.sqrt((this.x * this.x) + (this.y * this.y));\n },\n magnitudeSquared(): number\n {\n return (this.x * this.x) + (this.y * this.y);\n },\n project<T extends PointData>(onto: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n // Math says: a Projected over b = [(a·b) / (b·b)] * b;\n const normalizedScalarProjection = ((this.x * onto.x) + (this.y * onto.y)) / ((onto.x * onto.x) + (onto.y * onto.y));\n\n outPoint.x = onto.x * normalizedScalarProjection;\n outPoint.y = onto.y * normalizedScalarProjection;\n\n return outPoint;\n },\n reflect<T extends PointData>(normal: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n\n // Given an incident vector i and a normal vector n, returns the reflection vector r = i - 2 * dot(i, n) * n\n\n const dotProduct = (this.x * normal.x) + (this.y * normal.y);\n\n outPoint.x = this.x - (2 * dotProduct * normal.x);\n outPoint.y = this.y - (2 * dotProduct * normal.y);\n\n return outPoint;\n }\n};\n","import { Rectangle } from '../maths/shapes/Rectangle';\n\n/** @internal */\nexport const rectangleExtraMixins: Partial<Rectangle> = {\n containsRect(other: Rectangle): boolean\n {\n if (other.width <= 0 || other.height <= 0)\n {\n return other.x > this.x && other.y > this.y && other.right < this.right && other.bottom < this.bottom;\n }\n\n return other.x >= this.x && other.y >= this.y && other.right <= this.right && other.bottom <= this.bottom;\n },\n equals(other: Rectangle): boolean\n {\n if (other === this)\n {\n return true;\n }\n\n return (\n other\n && this.x === other.x\n && this.y === other.y\n && this.width === other.width\n && this.height === other.height\n );\n },\n intersection<T extends Rectangle>(other: Rectangle, outRect?: T): T\n {\n if (!outRect)\n {\n outRect = new Rectangle() as T;\n }\n\n const x0 = this.x < other.x ? other.x : this.x;\n const x1 = this.right > other.right ? other.right : this.right;\n\n if (x1 <= x0)\n {\n outRect.x = outRect.y = outRect.width = outRect.height = 0;\n\n return outRect;\n }\n\n const y0 = this.y < other.y ? other.y : this.y;\n const y1 = this.bottom > other.bottom ? other.bottom : this.bottom;\n\n if (y1 <= y0)\n {\n outRect.x = outRect.y = outRect.width = outRect.height = 0;\n\n return outRect;\n }\n\n outRect.x = x0;\n outRect.y = y0;\n outRect.width = x1 - x0;\n outRect.height = y1 - y0;\n\n return outRect;\n },\n union<T extends Rectangle>(other: Rectangle, outRect?: T): T\n {\n if (!outRect)\n {\n outRect = new Rectangle() as T;\n }\n\n const x1 = Math.min(this.x, other.x);\n const x2 = Math.max(this.x + this.width, other.x + other.width);\n const y1 = Math.min(this.y, other.y);\n const y2 = Math.max(this.y + this.height, other.y + other.height);\n\n outRect.x = x1;\n outRect.y = y1;\n outRect.width = x2 - x1;\n outRect.height = y2 - y1;\n\n return outRect;\n },\n};\n","import { ObservablePoint } from '../maths/point/ObservablePoint';\nimport { Point } from '../maths/point/Point';\nimport { Rectangle } from '../maths/shapes/Rectangle';\nimport { pointExtraMixins } from './pointExtras';\nimport { rectangleExtraMixins } from './rectangleExtras';\n\nObject.assign(Point.prototype, pointExtraMixins);\nObject.assign(ObservablePoint.prototype, pointExtraMixins);\nObject.assign(Rectangle.prototype, rectangleExtraMixins);\n","import { Point } from '../maths/point/Point';\nimport './pointExtras';\nimport './rectangleExtras';\n\nimport type { PointData } from '../maths/point/PointData';\n\n/**\n * The idea of a relative epsilon comparison is to find the difference between the two numbers,\n * and see if it is less than a given epsilon.\n * A good epsilon would be the N% of the largest of the two values or `Math.EPSILON`.\n *\n * _Note: Only available with **pixi.js/math-extras**._\n * @param {number} a - First floating number to compare.\n * @param {number} b - Second floating number to compare.\n * @param {number} epsilon - The epsilon to compare to.\n * The larger the epsilon, the easier for the numbers to be considered equals.\n * @returns {boolean} Returns `true` if the difference between the values is less than the given epsilon;\n * otherwise `false`.\n * @category maths\n * @advanced\n */\nexport function floatEqual(a: number, b: number, epsilon: number = Number.EPSILON): boolean\n{\n if (a === b)\n {\n return true;\n }\n\n const diff = Math.abs(a - b);\n\n return diff < epsilon;\n}\n\n/**\n * Generic line or segment intersection.\n * A line can intersect outside the two points defining it, the segment can't.\n * @param aStart - First point of the first line.\n * @param aEnd - Second point of the first line.\n * @param bStart - First point of the second line.\n * @param bEnd - Second point of the second line.\n * @param isLine - Set to true if you want Line (unbounded) intersection.\n * @param {PointData} [outPoint] - A Point-like object in which to store the value,\n * optional (otherwise will create a new Point).\n * @returns {PointData} The point where the lines/segments intersect or a `NaN` Point.\n */\nfunction genericLineIntersection<T extends PointData>(\n aStart: PointData,\n aEnd: PointData,\n bStart: PointData,\n bEnd: PointData,\n isLine: boolean,\n outPoint?: T): T\n{\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n\n const dxa = aEnd.x - aStart.x;\n const dya = aEnd.y - aStart.y;\n const dxb = bEnd.x - bStart.x;\n const dyb = bEnd.y - bStart.y;\n\n // In order to find the position of the intersection in respect to the line segments, we can define lines\n // in terms of first degree Bézier parameters, and find the two parameters `ua` and `ub` for the two lines to touch.\n // both `ua` and `ub` formula share the same denominator so it is only calculated once.\n\n const denominator = ((dyb * dxa) - (dxb * dya));\n\n // If lines are parallel or overlapping, the intersection can be nowhere or everywhere... NaN.\n if (floatEqual(denominator, 0))\n {\n outPoint.x = NaN;\n outPoint.y = NaN;\n\n return outPoint;\n }\n\n // ua is the factor of line a where the intersection occurs. ub is the factor of line b where the intersection occurs.\n const ua = ((dxb * (aStart.y - bStart.y)) - (dyb * (aStart.x - bStart.x))) / denominator;\n const ub = ((dxa * (aStart.y - bStart.y)) - (dya * (aStart.x - bStart.x))) / denominator;\n\n // Line intersection extends beyond the bounds of the segment.\n // The intersection is inside the segments if 0.0 ≤ ua ≤ 1.0 and 0.0 ≤ ub ≤ 1.0\n if (!isLine && (ua < 0 || ua > 1 || ub < 0 || ub > 1))\n {\n outPoint.x = NaN;\n outPoint.y = NaN;\n\n return outPoint;\n }\n\n outPoint.x = aStart.x + (ua * dxa);\n outPoint.y = bStart.y + (ub * dyb);\n\n return outPoint;\n}\n\n/**\n * Computes the point where non-coincident and non-parallel Lines intersect.\n * Coincident or parallel lines return a `NaN` point `{x: NaN, y: NaN}`.\n * The intersection point may land outside the extents of the lines.\n *\n * _Note: Only available with **pixi.js/math-extras**._\n * @param aStart - First point of the first line.\n * @param aEnd - Second point of the first line.\n * @param bStart - First point of the second line.\n * @param bEnd - Second point of the second line.\n * @param {PointData} outPoint - A Point-like object in which to store the value,\n * optional (otherwise will create a new Point).\n * @returns {PointData} The point where the lines intersect or a `NaN` Point.\n * @category maths\n * @advanced\n */\nexport function lineIntersection\n<T extends PointData = Point>(aStart: PointData, aEnd: PointData, bStart: PointData, bEnd: PointData, outPoint?: T): T\n{\n return genericLineIntersection(aStart, aEnd, bStart, bEnd, true, outPoint);\n}\n\n/**\n * Computes the point where non-coincident and non-parallel segments intersect.\n * Coincident, parallel or non-intersecting segments return a `NaN` point `{x: NaN, y: NaN}`.\n * The intersection point must land inside the extents of the segments or return a `NaN` Point.\n *\n * _Note: Only available with **pixi.js/math-extras**._\n * @param aStart - Starting point of the first segment.\n * @param aEnd - Ending point of the first segment.\n * @param bStart - Starting point of the second segment.\n * @param bEnd - Ending point of the second segment.\n * @param {PointData} outPoint - A Point-like object in which to store the value,\n * optional (otherwise will create a new Point).\n * @returns {PointData} The point where the segments intersect or a `NaN` Point.\n * @category maths\n * @advanced\n */\nexport function segmentIntersection\n<T extends PointData = Point>(aStart: PointData, aEnd: PointData, bStart: PointData, bEnd: PointData, outPoint?: T): T\n{\n return genericLineIntersection(aStart, aEnd,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IAAA,MAAA,CAAA,CAAA,GAAA,MAAA,CAAA,CAAA,CAAA,GAAA,GAAA,IAAA,MAAA,CAAA,CAAA,GAAA,MAAA,CAAA,CAAA,CAAA,IAAA,WAAA,CAAA;IAIA,EAAA,IAAA,CAAA,MAAA,KAAA,EAAA,GAAA,CAAA,IAAA,EAAA,GAAA,CAAA,IAAA,EAAA,GAAA,CAAA,IAAA,EAAA,GAAA,CAAA,CAAA,EAAA;IAEI,IAAA,QAAA,CAAA,CAAA,GAAA,GAAA,CAAA;IACA,IAAA,QAAA,CAAA,CAAA,GAAA,GAAA,CAAA;IAEA,IAAA,OAAA,QAAA,CAAA;IAAO,GAAA;IAGX,EAAA,QAAA,CAAA,CAAA,GAAA,MAAA,CAAA,CAAA,GAAA,EAAA,GAAA,GAAA,CAAA;IACA,EAAA,QAAA,CAAA,CAAA,GAAA,MAAA,CAAA,CAAA,GAAA,EAAA,GAAA,GAAA,CAAA;IAEA,EAAA,OAAA,QAAA,CAAA;IACJ,CAAA;IAkBO,SAAA,gBAAA,CAAA,MAAA,EAAA,IAAA,EAAA,MAAA,EAAA,IAAA,EAAA,QAAA,EAAA;IAGH,EAAA,OAAA,uBAAA,CAAA,MAAA,EAAA,IAAA,EAAA,MAAA,EAAA,IAAA,EAAA,IAAA,EAAA,QAAA,CAAA,CAAA;IACJ,CAAA;IAkBO,SAAA,mBAAA,CAAA,MAAA,EAAA,IAAA,EAAA,MAAA,EAAA,IAAA,EAAA,QAAA,EAAA;IAGH,EAAA,OAAA,uBAAA,CAAA,MAAA,EAAA,IAAA,EAAA,MAAA,EAAA,IAAA,EAAA,KAAA,EAAA,QAAA,CAAA,CAAA;IACJ;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"math-extras.js","sources":["../../src/math-extras/pointExtras.ts","../../src/math-extras/rectangleExtras.ts","../../src/math-extras/init.ts","../../src/math-extras/util.ts"],"sourcesContent":["import { Point } from '../maths/point/Point';\n\nimport type { PointData } from '../maths/point/PointData';\n\n/** @internal */\nexport const pointExtraMixins: any = {\n add<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x + other.x;\n outPoint.y = this.y + other.y;\n\n return outPoint;\n },\n subtract<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x - other.x;\n outPoint.y = this.y - other.y;\n\n return outPoint;\n },\n multiply<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x * other.x;\n outPoint.y = this.y * other.y;\n\n return outPoint;\n },\n multiplyScalar<T extends PointData>(scalar: number, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x * scalar;\n outPoint.y = this.y * scalar;\n\n return outPoint;\n },\n dot(other: PointData): number\n {\n return (this.x * other.x) + (this.y * other.y);\n },\n cross(other: PointData): number\n {\n /*\n * Returns the magnitude of the vector that would result\n * from a regular 3D cross product of the input vectors,\n * taking their Z values implicitly as 0\n * (i.e. treating the 2D space as a plane in the 3D space).\n * The 3D cross product will be perpendicular to that plane,\n * and thus have 0 X & Y components\n * (thus the scalar returned is the Z value of the 3D cross product vector).\n */\n return (this.x * other.y) - (this.y * other.x);\n },\n normalize<T extends PointData>(outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n const magnitude = Math.sqrt((this.x * this.x) + (this.y * this.y));\n\n outPoint.x = this.x / magnitude;\n outPoint.y = this.y / magnitude;\n\n return outPoint;\n },\n magnitude(): number\n {\n return Math.sqrt((this.x * this.x) + (this.y * this.y));\n },\n magnitudeSquared(): number\n {\n return (this.x * this.x) + (this.y * this.y);\n },\n project<T extends PointData>(onto: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n // Math says: a Projected over b = [(a·b) / (b·b)] * b;\n const normalizedScalarProjection = ((this.x * onto.x) + (this.y * onto.y)) / ((onto.x * onto.x) + (onto.y * onto.y));\n\n outPoint.x = onto.x * normalizedScalarProjection;\n outPoint.y = onto.y * normalizedScalarProjection;\n\n return outPoint;\n },\n reflect<T extends PointData>(normal: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n\n // Given an incident vector i and a normal vector n, returns the reflection vector r = i - 2 * dot(i, n) * n\n\n const dotProduct = (this.x * normal.x) + (this.y * normal.y);\n\n outPoint.x = this.x - (2 * dotProduct * normal.x);\n outPoint.y = this.y - (2 * dotProduct * normal.y);\n\n return outPoint;\n },\n rotate<T extends PointData>(radians: number, outPoint?: T): T\n {\n outPoint ??= new Point() as PointData as T;\n\n const cosTheta = Math.cos(radians);\n const sinTheta = Math.sin(radians);\n\n outPoint.x = (this.x * cosTheta) - (this.y * sinTheta);\n outPoint.y = (this.x * sinTheta) + (this.y * cosTheta);\n\n return outPoint;\n }\n};\n","import { Rectangle } from '../maths/shapes/Rectangle';\n\n/** @internal */\nexport const rectangleExtraMixins: Partial<Rectangle> = {\n containsRect(other: Rectangle): boolean\n {\n if (other.width <= 0 || other.height <= 0)\n {\n return other.x > this.x && other.y > this.y && other.right < this.right && other.bottom < this.bottom;\n }\n\n return other.x >= this.x && other.y >= this.y && other.right <= this.right && other.bottom <= this.bottom;\n },\n equals(other: Rectangle): boolean\n {\n if (other === this)\n {\n return true;\n }\n\n return (\n other\n && this.x === other.x\n && this.y === other.y\n && this.width === other.width\n && this.height === other.height\n );\n },\n intersection<T extends Rectangle>(other: Rectangle, outRect?: T): T\n {\n if (!outRect)\n {\n outRect = new Rectangle() as T;\n }\n\n const x0 = this.x < other.x ? other.x : this.x;\n const x1 = this.right > other.right ? other.right : this.right;\n\n if (x1 <= x0)\n {\n outRect.x = outRect.y = outRect.width = outRect.height = 0;\n\n return outRect;\n }\n\n const y0 = this.y < other.y ? other.y : this.y;\n const y1 = this.bottom > other.bottom ? other.bottom : this.bottom;\n\n if (y1 <= y0)\n {\n outRect.x = outRect.y = outRect.width = outRect.height = 0;\n\n return outRect;\n }\n\n outRect.x = x0;\n outRect.y = y0;\n outRect.width = x1 - x0;\n outRect.height = y1 - y0;\n\n return outRect;\n },\n union<T extends Rectangle>(other: Rectangle, outRect?: T): T\n {\n if (!outRect)\n {\n outRect = new Rectangle() as T;\n }\n\n const x1 = Math.min(this.x, other.x);\n const x2 = Math.max(this.x + this.width, other.x + other.width);\n const y1 = Math.min(this.y, other.y);\n const y2 = Math.max(this.y + this.height, other.y + other.height);\n\n outRect.x = x1;\n outRect.y = y1;\n outRect.width = x2 - x1;\n outRect.height = y2 - y1;\n\n return outRect;\n },\n};\n","import { ObservablePoint } from '../maths/point/ObservablePoint';\nimport { Point } from '../maths/point/Point';\nimport { Rectangle } from '../maths/shapes/Rectangle';\nimport { pointExtraMixins } from './pointExtras';\nimport { rectangleExtraMixins } from './rectangleExtras';\n\nObject.assign(Point.prototype, pointExtraMixins);\nObject.assign(ObservablePoint.prototype, pointExtraMixins);\nObject.assign(Rectangle.prototype, rectangleExtraMixins);\n","import { Point } from '../maths/point/Point';\nimport './pointExtras';\nimport './rectangleExtras';\n\nimport type { PointData } from '../maths/point/PointData';\n\n/**\n * The idea of a relative epsilon comparison is to find the difference between the two numbers,\n * and see if it is less than a given epsilon.\n * A good epsilon would be the N% of the largest of the two values or `Math.EPSILON`.\n *\n * _Note: Only available with **pixi.js/math-extras**._\n * @param {number} a - First floating number to compare.\n * @param {number} b - Second floating number to compare.\n * @param {number} epsilon - The epsilon to compare to.\n * The larger the epsilon, the easier for the numbers to be considered equals.\n * @returns {boolean} Returns `true` if the difference between the values is less than the given epsilon;\n * otherwise `false`.\n * @category maths\n * @advanced\n */\nexport function floatEqual(a: number, b: number, epsilon: number = Number.EPSILON): boolean\n{\n if (a === b)\n {\n return true;\n }\n\n const diff = Math.abs(a - b);\n\n return diff < epsilon;\n}\n\n/**\n * Generic line or segment intersection.\n * A line can intersect outside the two points defining it, the segment can't.\n * @param aStart - First point of the first line.\n * @param aEnd - Second point of the first line.\n * @param bStart - First point of the second line.\n * @param bEnd - Second point of the second line.\n * @param isLine - Set to true if you want Line (unbounded) intersection.\n * @param {PointData} [outPoint] - A Point-like object in which to store the value,\n * optional (otherwise will create a new Point).\n * @returns {PointData} The point where the lines/segments intersect or a `NaN` Point.\n */\nfunction genericLineIntersection<T extends PointData>(\n aStart: PointData,\n aEnd: PointData,\n bStart: PointData,\n bEnd: PointData,\n isLine: boolean,\n outPoint?: T): T\n{\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n\n const dxa = aEnd.x - aStart.x;\n const dya = aEnd.y - aStart.y;\n const dxb = bEnd.x - bStart.x;\n const dyb = bEnd.y - bStart.y;\n\n // In order to find the position of the intersection in respect to the line segments, we can define lines\n // in terms of first degree Bézier parameters, and find the two parameters `ua` and `ub` for the two lines to touch.\n // both `ua` and `ub` formula share the same denominator so it is only calculated once.\n\n const denominator = ((dyb * dxa) - (dxb * dya));\n\n // If lines are parallel or overlapping, the intersection can be nowhere or everywhere... NaN.\n if (floatEqual(denominator, 0))\n {\n outPoint.x = NaN;\n outPoint.y = NaN;\n\n return outPoint;\n }\n\n // ua is the factor of line a where the intersection occurs. ub is the factor of line b where the intersection occurs.\n const ua = ((dxb * (aStart.y - bStart.y)) - (dyb * (aStart.x - bStart.x))) / denominator;\n const ub = ((dxa * (aStart.y - bStart.y)) - (dya * (aStart.x - bStart.x))) / denominator;\n\n // Line intersection extends beyond the bounds of the segment.\n // The intersection is inside the segments if 0.0 ≤ ua ≤ 1.0 and 0.0 ≤ ub ≤ 1.0\n if (!isLine && (ua < 0 || ua > 1 || ub < 0 || ub > 1))\n {\n outPoint.x = NaN;\n outPoint.y = NaN;\n\n return outPoint;\n }\n\n outPoint.x = aStart.x + (ua * dxa);\n outPoint.y = bStart.y + (ub * dyb);\n\n return outPoint;\n}\n\n/**\n * Computes the point where non-coincident and non-parallel Lines intersect.\n * Coincident or parallel lines return a `NaN` point `{x: NaN, y: NaN}`.\n * The intersection point may land outside the extents of the lines.\n *\n * _Note: Only available with **pixi.js/math-extras**._\n * @param aStart - First point of the first line.\n * @param aEnd - Second point of the first line.\n * @param bStart - First point of the second line.\n * @param bEnd - Second point of the second line.\n * @param {PointData} outPoint - A Point-like object in which to store the value,\n * optional (otherwise will create a new Point).\n * @returns {PointData} The point where the lines intersect or a `NaN` Point.\n * @category maths\n * @advanced\n */\nexport function lineIntersection\n<T extends PointData = Point>(aStart: PointData, aEnd: PointData, bStart: PointData, bEnd: PointData, outPoint?: T): T\n{\n return genericLineIntersection(aStart, aEnd, bStart, bEnd, true, outPoint);\n}\n\n/**\n * Computes the point where non-coincident and non-parallel segments intersect.\n * Coincident, parallel or non-intersecting segments return a `NaN` point `{x: NaN, y: NaN}`.\n * The intersection point must land inside the extents of the segments or return a `NaN` Point.\n *\n * _Note: Only available with **pixi.js/math-extras**._\n * @param aStart - Starting point of the first segment.\n * @param aEnd - Ending point of the first segment.\n * @param bStart - Starting point of the second segment.\n * @param bEnd - Ending point of the second segment.\n * @param {PointData} outPoint - A Point-like object in which to store the value,\n * optional (otherwise will create a new Point).\n * @returns {PointData} The point where the segments intersect or a `NaN` Point.\n * @category maths\n * @advanced\n */\nexport function segmentIntersection\n<T extends PointData = Point>(aStart: PointData, aEnd: PointData, bStart: PointData, bEnd: PointData, outPoint?: T): T\n{\n return genericLineIntersection(aStart, aEnd, bStart, bEnd, false, outPoint);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAAsB;AAKf,UAAA,gBAAA,GAAA;IAA8B,EAAA,GAAA,CAAA,KAAA,EAAA,QAAA,EAAA;IAG7B,IAAA,IAAA,CAAA,QAAA,EAAA;IAEI,MAAA,QAAA,GAAA,IAAe,IAAM,CAAA,KAAA,EAAA,CAAA;IAAA,KAAA;IAEzB,IAAA,QAAA,CAAA,CAAA,GAAA,IAAA,CAAA,CAAA,GAAA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AAA,KAAA,EAAA,QAAA,CAAA,CAAA;IACJ;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* PixiJS - v8.13.2
|
|
3
|
-
* Compiled Mon, 06 Oct 2025 21:
|
|
3
|
+
* Compiled Mon, 06 Oct 2025 21:10:06 UTC
|
|
4
4
|
*
|
|
5
5
|
* PixiJS is licensed under the MIT License.
|
|
6
6
|
* http://www.opensource.org/licenses/mit-license
|
|
7
|
-
*/this.PIXI=this.PIXI||{};var math_extras_js=function(
|
|
7
|
+
*/this.PIXI=this.PIXI||{};var math_extras_js=function(s){"use strict";"use strict";const x={add(t,i){return i||(i=new PIXI.Point),i.x=this.x+t.x,i.y=this.y+t.y,i},subtract(t,i){return i||(i=new PIXI.Point),i.x=this.x-t.x,i.y=this.y-t.y,i},multiply(t,i){return i||(i=new PIXI.Point),i.x=this.x*t.x,i.y=this.y*t.y,i},multiplyScalar(t,i){return i||(i=new PIXI.Point),i.x=this.x*t,i.y=this.y*t,i},dot(t){return this.x*t.x+this.y*t.y},cross(t){return this.x*t.y-this.y*t.x},normalize(t){t||(t=new PIXI.Point);const i=Math.sqrt(this.x*this.x+this.y*this.y);return t.x=this.x/i,t.y=this.y/i,t},magnitude(){return Math.sqrt(this.x*this.x+this.y*this.y)},magnitudeSquared(){return this.x*this.x+this.y*this.y},project(t,i){i||(i=new PIXI.Point);const h=(this.x*t.x+this.y*t.y)/(t.x*t.x+t.y*t.y);return i.x=t.x*h,i.y=t.y*h,i},reflect(t,i){i||(i=new PIXI.Point);const h=this.x*t.x+this.y*t.y;return i.x=this.x-2*h*t.x,i.y=this.y-2*h*t.y,i},rotate(t,i){i!=null||(i=new PIXI.Point);const h=Math.cos(t),e=Math.sin(t);return i.x=this.x*h-this.y*e,i.y=this.x*e+this.y*h,i}},g={containsRect(t){return t.width<=0||t.height<=0?t.x>this.x&&t.y>this.y&&t.right<this.right&&t.bottom<this.bottom:t.x>=this.x&&t.y>=this.y&&t.right<=this.right&&t.bottom<=this.bottom},equals(t){return t===this?!0:t&&this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height},intersection(t,i){i||(i=new PIXI.Rectangle);const h=this.x<t.x?t.x:this.x,e=this.right>t.right?t.right:this.right;if(e<=h)return i.x=i.y=i.width=i.height=0,i;const r=this.y<t.y?t.y:this.y,n=this.bottom>t.bottom?t.bottom:this.bottom;return n<=r?(i.x=i.y=i.width=i.height=0,i):(i.x=h,i.y=r,i.width=e-h,i.height=n-r,i)},union(t,i){i||(i=new PIXI.Rectangle);const h=Math.min(this.x,t.x),e=Math.max(this.x+this.width,t.x+t.width),r=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return i.x=h,i.y=r,i.width=e-h,i.height=n-r,i}};Object.assign(PIXI.Point.prototype,x),Object.assign(PIXI.ObservablePoint.prototype,x),Object.assign(PIXI.Rectangle.prototype,g);function P(t,i,h=Number.EPSILON){return t===i?!0:Math.abs(t-i)<h}function l(t,i,h,e,r,n){n||(n=new PIXI.Point);const y=i.x-t.x,m=i.y-t.y,w=e.x-h.x,o=e.y-h.y,u=o*y-w*m;if(P(u,0))return n.x=NaN,n.y=NaN,n;const c=(w*(t.y-h.y)-o*(t.x-h.x))/u,I=(y*(t.y-h.y)-m*(t.x-h.x))/u;return!r&&(c<0||c>1||I<0||I>1)?(n.x=NaN,n.y=NaN,n):(n.x=t.x+c*y,n.y=h.y+I*o,n)}function a(t,i,h,e,r){return l(t,i,h,e,!0,r)}function b(t,i,h,e,r){return l(t,i,h,e,!1,r)}return s.floatEqual=P,s.lineIntersection=a,s.pointExtraMixins=x,s.rectangleExtraMixins=g,s.segmentIntersection=b,s}({});Object.assign(this.PIXI,math_extras_js);
|
|
8
8
|
//# sourceMappingURL=math-extras.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math-extras.min.js","sources":["../../src/math-extras/pointExtras.ts","../../src/math-extras/rectangleExtras.ts","../../src/math-extras/init.ts","../../src/math-extras/util.ts"],"sourcesContent":["import { Point } from '../maths/point/Point';\n\nimport type { PointData } from '../maths/point/PointData';\n\n/** @internal */\nexport const pointExtraMixins: any = {\n add<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x + other.x;\n outPoint.y = this.y + other.y;\n\n return outPoint;\n },\n subtract<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x - other.x;\n outPoint.y = this.y - other.y;\n\n return outPoint;\n },\n multiply<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x * other.x;\n outPoint.y = this.y * other.y;\n\n return outPoint;\n },\n multiplyScalar<T extends PointData>(scalar: number, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x * scalar;\n outPoint.y = this.y * scalar;\n\n return outPoint;\n },\n dot(other: PointData): number\n {\n return (this.x * other.x) + (this.y * other.y);\n },\n cross(other: PointData): number\n {\n /*\n * Returns the magnitude of the vector that would result\n * from a regular 3D cross product of the input vectors,\n * taking their Z values implicitly as 0\n * (i.e. treating the 2D space as a plane in the 3D space).\n * The 3D cross product will be perpendicular to that plane,\n * and thus have 0 X & Y components\n * (thus the scalar returned is the Z value of the 3D cross product vector).\n */\n return (this.x * other.y) - (this.y * other.x);\n },\n normalize<T extends PointData>(outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n const magnitude = Math.sqrt((this.x * this.x) + (this.y * this.y));\n\n outPoint.x = this.x / magnitude;\n outPoint.y = this.y / magnitude;\n\n return outPoint;\n },\n magnitude(): number\n {\n return Math.sqrt((this.x * this.x) + (this.y * this.y));\n },\n magnitudeSquared(): number\n {\n return (this.x * this.x) + (this.y * this.y);\n },\n project<T extends PointData>(onto: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n // Math says: a Projected over b = [(a·b) / (b·b)] * b;\n const normalizedScalarProjection = ((this.x * onto.x) + (this.y * onto.y)) / ((onto.x * onto.x) + (onto.y * onto.y));\n\n outPoint.x = onto.x * normalizedScalarProjection;\n outPoint.y = onto.y * normalizedScalarProjection;\n\n return outPoint;\n },\n reflect<T extends PointData>(normal: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n\n // Given an incident vector i and a normal vector n, returns the reflection vector r = i - 2 * dot(i, n) * n\n\n const dotProduct = (this.x * normal.x) + (this.y * normal.y);\n\n outPoint.x = this.x - (2 * dotProduct * normal.x);\n outPoint.y = this.y - (2 * dotProduct * normal.y);\n\n return outPoint;\n }\n};\n","import { Rectangle } from '../maths/shapes/Rectangle';\n\n/** @internal */\nexport const rectangleExtraMixins: Partial<Rectangle> = {\n containsRect(other: Rectangle): boolean\n {\n if (other.width <= 0 || other.height <= 0)\n {\n return other.x > this.x && other.y > this.y && other.right < this.right && other.bottom < this.bottom;\n }\n\n return other.x >= this.x && other.y >= this.y && other.right <= this.right && other.bottom <= this.bottom;\n },\n equals(other: Rectangle): boolean\n {\n if (other === this)\n {\n return true;\n }\n\n return (\n other\n && this.x === other.x\n && this.y === other.y\n && this.width === other.width\n && this.height === other.height\n );\n },\n intersection<T extends Rectangle>(other: Rectangle, outRect?: T): T\n {\n if (!outRect)\n {\n outRect = new Rectangle() as T;\n }\n\n const x0 = this.x < other.x ? other.x : this.x;\n const x1 = this.right > other.right ? other.right : this.right;\n\n if (x1 <= x0)\n {\n outRect.x = outRect.y = outRect.width = outRect.height = 0;\n\n return outRect;\n }\n\n const y0 = this.y < other.y ? other.y : this.y;\n const y1 = this.bottom > other.bottom ? other.bottom : this.bottom;\n\n if (y1 <= y0)\n {\n outRect.x = outRect.y = outRect.width = outRect.height = 0;\n\n return outRect;\n }\n\n outRect.x = x0;\n outRect.y = y0;\n outRect.width = x1 - x0;\n outRect.height = y1 - y0;\n\n return outRect;\n },\n union<T extends Rectangle>(other: Rectangle, outRect?: T): T\n {\n if (!outRect)\n {\n outRect = new Rectangle() as T;\n }\n\n const x1 = Math.min(this.x, other.x);\n const x2 = Math.max(this.x + this.width, other.x + other.width);\n const y1 = Math.min(this.y, other.y);\n const y2 = Math.max(this.y + this.height, other.y + other.height);\n\n outRect.x = x1;\n outRect.y = y1;\n outRect.width = x2 - x1;\n outRect.height = y2 - y1;\n\n return outRect;\n },\n};\n","import { ObservablePoint } from '../maths/point/ObservablePoint';\nimport { Point } from '../maths/point/Point';\nimport { Rectangle } from '../maths/shapes/Rectangle';\nimport { pointExtraMixins } from './pointExtras';\nimport { rectangleExtraMixins } from './rectangleExtras';\n\nObject.assign(Point.prototype, pointExtraMixins);\nObject.assign(ObservablePoint.prototype, pointExtraMixins);\nObject.assign(Rectangle.prototype, rectangleExtraMixins);\n","import { Point } from '../maths/point/Point';\nimport './pointExtras';\nimport './rectangleExtras';\n\nimport type { PointData } from '../maths/point/PointData';\n\n/**\n * The idea of a relative epsilon comparison is to find the difference between the two numbers,\n * and see if it is less than a given epsilon.\n * A good epsilon would be the N% of the largest of the two values or `Math.EPSILON`.\n *\n * _Note: Only available with **pixi.js/math-extras**._\n * @param {number} a - First floating number to compare.\n * @param {number} b - Second floating number to compare.\n * @param {number} epsilon - The epsilon to compare to.\n * The larger the epsilon, the easier for the numbers to be considered equals.\n * @returns {boolean} Returns `true` if the difference between the values is less than the given epsilon;\n * otherwise `false`.\n * @category maths\n * @advanced\n */\nexport function floatEqual(a: number, b: number, epsilon: number = Number.EPSILON): boolean\n{\n if (a === b)\n {\n return true;\n }\n\n const diff = Math.abs(a - b);\n\n return diff < epsilon;\n}\n\n/**\n * Generic line or segment intersection.\n * A line can intersect outside the two points defining it, the segment can't.\n * @param aStart - First point of the first line.\n * @param aEnd - Second point of the first line.\n * @param bStart - First point of the second line.\n * @param bEnd - Second point of the second line.\n * @param isLine - Set to true if you want Line (unbounded) intersection.\n * @param {PointData} [outPoint] - A Point-like object in which to store the value,\n * optional (otherwise will create a new Point).\n * @returns {PointData} The point where the lines/segments intersect or a `NaN` Point.\n */\nfunction genericLineIntersection<T extends PointData>(\n aStart: PointData,\n aEnd: PointData,\n bStart: PointData,\n bEnd: PointData,\n isLine: boolean,\n outPoint?: T): T\n{\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n\n const dxa = aEnd.x - aStart.x;\n const dya = aEnd.y - aStart.y;\n const dxb = bEnd.x - bStart.x;\n const dyb = bEnd.y - bStart.y;\n\n // In order to find the position of the intersection in respect to the line segments, we can define lines\n // in terms of first degree Bézier parameters, and find the two parameters `ua` and `ub` for the two lines to touch.\n // both `ua` and `ub` formula share the same denominator so it is only calculated once.\n\n const denominator = ((dyb * dxa) - (dxb * dya));\n\n // If lines are parallel or overlapping, the intersection can be nowhere or everywhere... NaN.\n if (floatEqual(denominator, 0))\n {\n outPoint.x = NaN;\n outPoint.y = NaN;\n\n return outPoint;\n }\n\n // ua is the factor of line a where the intersection occurs. ub is the factor of line b where the intersection occurs.\n const ua = ((dxb * (aStart.y - bStart.y)) - (dyb * (aStart.x - bStart.x))) / denominator;\n const ub = ((dxa * (aStart.y - bStart.y)) - (dya * (aStart.x - bStart.x))) / denominator;\n\n // Line intersection extends beyond the bounds of the segment.\n // The intersection is inside the segments if 0.0 ≤ ua ≤ 1.0 and 0.0 ≤ ub ≤ 1.0\n if (!isLine && (ua < 0 || ua > 1 || ub < 0 || ub > 1))\n {\n outPoint.x = NaN;\n outPoint.y = NaN;\n\n return outPoint;\n }\n\n outPoint.x = aStart.x + (ua * dxa);\n outPoint.y = bStart.y + (ub * dyb);\n\n return outPoint;\n}\n\n/**\n * Computes the point where non-coincident and non-parallel Lines intersect.\n * Coincident or parallel lines return a `NaN` point `{x: NaN, y: NaN}`.\n * The intersection point may land outside the extents of the lines.\n *\n * _Note: Only available with **pixi.js/math-extras**._\n * @param aStart - First point of the first line.\n * @param aEnd - Second point of the first line.\n * @param bStart - First point of the second line.\n * @param bEnd - Second point of the second line.\n * @param {PointData} outPoint - A Point-like object in which to store the value,\n * optional (otherwise will create a new Point).\n * @returns {PointData} The point where the lines intersect or a `NaN` Point.\n * @category maths\n * @advanced\n */\nexport function lineIntersection\n<T extends PointData = Point>(aStart: PointData, aEnd: PointData, bStart: PointData, bEnd: PointData, outPoint?: T): T\n{\n return genericLineIntersection(aStart, aEnd, bStart, bEnd, true, outPoint);\n}\n\n/**\n * Computes the point where non-coincident and non-parallel segments intersect.\n * Coincident, parallel or non-intersecting segments return a `NaN` point `{x: NaN, y: NaN}`.\n * The intersection point must land inside the extents of the segments or return a `NaN` Point.\n *\n * _Note: Only available with **pixi.js/math-extras**._\n * @param aStart - Starting point of the first segment.\n * @param aEnd - Ending point of the first segment.\n * @param bStart - Starting point of the second segment.\n * @param bEnd - Ending point of the second segment.\n * @param {PointData} outPoint - A Point-like object in which to store the value,\n * optional (otherwise will create a new Point).\n * @returns {PointData} The point where the segments intersect or a `NaN` Point.\n * @category maths\n * @advanced\n */\nexport function segmentIntersection\n<T extends PointData = Point>(aStart: PointData, aEnd: PointData, bStart: PointData, bEnd: PointData, outPoint?: T): T\n{\n return genericLineIntersection(aStart, aEnd, bStart, bEnd, false, outPoint);\n}\n"],"names":["Point","i","s","a","rectangleExtraMixins","Rectangle","n","t","h","x","ObservablePoint"],"mappings":";;;;;;uEAAA,aAU2BA,MAAAA,EAAAA,CAAAA,IAAAA,EAAAA,EAAAA,CAAAA,OAAAA,IAAAA,EAAAA,IAAAA,KAAAA,OAWAA,EAAAA,EAAAA,KAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,KAAAA,EAAAA,EAAAA,EAAAA,CAAAA,EAAAA,SAAAA,EAAAA,EAAAA,CAAAA,OAAAA,IAAAA,EAAAA,IAAAA,KAAAA,OAWAA,EAAAA,EAAAA,KAAAA,EAAAA,EAAAA,E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AM,EAAA,KAAA,IAAA,KAAA,EAAA,KAAA,MAAAN,EAAA,EAAAA,EAAA,KAAA,EAAAO,EAAA,KAAA,IAAA,KAAA,EAAAP,EAAA,CAAA,EAAAQ,EAAA,KAAA,IAAA,KAAA,EAAA,KAAA,OAAAR,EAAA,EAAAA,EAAA,MAAA,EAAA,OAAAC,EAAA,EAAAI,EAAAJ,EAAA,EAAAM,EAAAN,EAAA,MAAAK,EAAAD,EAAAJ,EAAA,OAAAO,EAAAD,EAAAN,CAAA,CAAA,EC/DMF,OAAAA,OAAAA,KAAAA,MACAU,UAAAA,CAAAA,EAAAA,OAAAA,OAAAA,KAAAA,2CACAL,KAAAA,UAAAA,UAAAA,CAAAA,qGC+CSL"}
|
|
1
|
+
{"version":3,"file":"math-extras.min.js","sources":["../../src/math-extras/pointExtras.ts","../../src/math-extras/rectangleExtras.ts","../../src/math-extras/init.ts","../../src/math-extras/util.ts"],"sourcesContent":["import { Point } from '../maths/point/Point';\n\nimport type { PointData } from '../maths/point/PointData';\n\n/** @internal */\nexport const pointExtraMixins: any = {\n add<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x + other.x;\n outPoint.y = this.y + other.y;\n\n return outPoint;\n },\n subtract<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x - other.x;\n outPoint.y = this.y - other.y;\n\n return outPoint;\n },\n multiply<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x * other.x;\n outPoint.y = this.y * other.y;\n\n return outPoint;\n },\n multiplyScalar<T extends PointData>(scalar: number, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x * scalar;\n outPoint.y = this.y * scalar;\n\n return outPoint;\n },\n dot(other: PointData): number\n {\n return (this.x * other.x) + (this.y * other.y);\n },\n cross(other: PointData): number\n {\n /*\n * Returns the magnitude of the vector that would result\n * from a regular 3D cross product of the input vectors,\n * taking their Z values implicitly as 0\n * (i.e. treating the 2D space as a plane in the 3D space).\n * The 3D cross product will be perpendicular to that plane,\n * and thus have 0 X & Y components\n * (thus the scalar returned is the Z value of the 3D cross product vector).\n */\n return (this.x * other.y) - (this.y * other.x);\n },\n normalize<T extends PointData>(outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n const magnitude = Math.sqrt((this.x * this.x) + (this.y * this.y));\n\n outPoint.x = this.x / magnitude;\n outPoint.y = this.y / magnitude;\n\n return outPoint;\n },\n magnitude(): number\n {\n return Math.sqrt((this.x * this.x) + (this.y * this.y));\n },\n magnitudeSquared(): number\n {\n return (this.x * this.x) + (this.y * this.y);\n },\n project<T extends PointData>(onto: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n // Math says: a Projected over b = [(a·b) / (b·b)] * b;\n const normalizedScalarProjection = ((this.x * onto.x) + (this.y * onto.y)) / ((onto.x * onto.x) + (onto.y * onto.y));\n\n outPoint.x = onto.x * normalizedScalarProjection;\n outPoint.y = onto.y * normalizedScalarProjection;\n\n return outPoint;\n },\n reflect<T extends PointData>(normal: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n\n // Given an incident vector i and a normal vector n, returns the reflection vector r = i - 2 * dot(i, n) * n\n\n const dotProduct = (this.x * normal.x) + (this.y * normal.y);\n\n outPoint.x = this.x - (2 * dotProduct * normal.x);\n outPoint.y = this.y - (2 * dotProduct * normal.y);\n\n return outPoint;\n },\n rotate<T extends PointData>(radians: number, outPoint?: T): T\n {\n outPoint ??= new Point() as PointData as T;\n\n const cosTheta = Math.cos(radians);\n const sinTheta = Math.sin(radians);\n\n outPoint.x = (this.x * cosTheta) - (this.y * sinTheta);\n outPoint.y = (this.x * sinTheta) + (this.y * cosTheta);\n\n return outPoint;\n }\n};\n","import { Rectangle } from '../maths/shapes/Rectangle';\n\n/** @internal */\nexport const rectangleExtraMixins: Partial<Rectangle> = {\n containsRect(other: Rectangle): boolean\n {\n if (other.width <= 0 || other.height <= 0)\n {\n return other.x > this.x && other.y > this.y && other.right < this.right && other.bottom < this.bottom;\n }\n\n return other.x >= this.x && other.y >= this.y && other.right <= this.right && other.bottom <= this.bottom;\n },\n equals(other: Rectangle): boolean\n {\n if (other === this)\n {\n return true;\n }\n\n return (\n other\n && this.x === other.x\n && this.y === other.y\n && this.width === other.width\n && this.height === other.height\n );\n },\n intersection<T extends Rectangle>(other: Rectangle, outRect?: T): T\n {\n if (!outRect)\n {\n outRect = new Rectangle() as T;\n }\n\n const x0 = this.x < other.x ? other.x : this.x;\n const x1 = this.right > other.right ? other.right : this.right;\n\n if (x1 <= x0)\n {\n outRect.x = outRect.y = outRect.width = outRect.height = 0;\n\n return outRect;\n }\n\n const y0 = this.y < other.y ? other.y : this.y;\n const y1 = this.bottom > other.bottom ? other.bottom : this.bottom;\n\n if (y1 <= y0)\n {\n outRect.x = outRect.y = outRect.width = outRect.height = 0;\n\n return outRect;\n }\n\n outRect.x = x0;\n outRect.y = y0;\n outRect.width = x1 - x0;\n outRect.height = y1 - y0;\n\n return outRect;\n },\n union<T extends Rectangle>(other: Rectangle, outRect?: T): T\n {\n if (!outRect)\n {\n outRect = new Rectangle() as T;\n }\n\n const x1 = Math.min(this.x, other.x);\n const x2 = Math.max(this.x + this.width, other.x + other.width);\n const y1 = Math.min(this.y, other.y);\n const y2 = Math.max(this.y + this.height, other.y + other.height);\n\n outRect.x = x1;\n outRect.y = y1;\n outRect.width = x2 - x1;\n outRect.height = y2 - y1;\n\n return outRect;\n },\n};\n","import { ObservablePoint } from '../maths/point/ObservablePoint';\nimport { Point } from '../maths/point/Point';\nimport { Rectangle } from '../maths/shapes/Rectangle';\nimport { pointExtraMixins } from './pointExtras';\nimport { rectangleExtraMixins } from './rectangleExtras';\n\nObject.assign(Point.prototype, pointExtraMixins);\nObject.assign(ObservablePoint.prototype, pointExtraMixins);\nObject.assign(Rectangle.prototype, rectangleExtraMixins);\n","import { Point } from '../maths/point/Point';\nimport './pointExtras';\nimport './rectangleExtras';\n\nimport type { PointData } from '../maths/point/PointData';\n\n/**\n * The idea of a relative epsilon comparison is to find the difference between the two numbers,\n * and see if it is less than a given epsilon.\n * A good epsilon would be the N% of the largest of the two values or `Math.EPSILON`.\n *\n * _Note: Only available with **pixi.js/math-extras**._\n * @param {number} a - First floating number to compare.\n * @param {number} b - Second floating number to compare.\n * @param {number} epsilon - The epsilon to compare to.\n * The larger the epsilon, the easier for the numbers to be considered equals.\n * @returns {boolean} Returns `true` if the difference between the values is less than the given epsilon;\n * otherwise `false`.\n * @category maths\n * @advanced\n */\nexport function floatEqual(a: number, b: number, epsilon: number = Number.EPSILON): boolean\n{\n if (a === b)\n {\n return true;\n }\n\n const diff = Math.abs(a - b);\n\n return diff < epsilon;\n}\n\n/**\n * Generic line or segment intersection.\n * A line can intersect outside the two points defining it, the segment can't.\n * @param aStart - First point of the first line.\n * @param aEnd - Second point of the first line.\n * @param bStart - First point of the second line.\n * @param bEnd - Second point of the second line.\n * @param isLine - Set to true if you want Line (unbounded) intersection.\n * @param {PointData} [outPoint] - A Point-like object in which to store the value,\n * optional (otherwise will create a new Point).\n * @returns {PointData} The point where the lines/segments intersect or a `NaN` Point.\n */\nfunction genericLineIntersection<T extends PointData>(\n aStart: PointData,\n aEnd: PointData,\n bStart: PointData,\n bEnd: PointData,\n isLine: boolean,\n outPoint?: T): T\n{\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n\n const dxa = aEnd.x - aStart.x;\n const dya = aEnd.y - aStart.y;\n const dxb = bEnd.x - bStart.x;\n const dyb = bEnd.y - bStart.y;\n\n // In order to find the position of the intersection in respect to the line segments, we can define lines\n // in terms of first degree Bézier parameters, and find the two parameters `ua` and `ub` for the two lines to touch.\n // both `ua` and `ub` formula share the same denominator so it is only calculated once.\n\n const denominator = ((dyb * dxa) - (dxb * dya));\n\n // If lines are parallel or overlapping, the intersection can be nowhere or everywhere... NaN.\n if (floatEqual(denominator, 0))\n {\n outPoint.x = NaN;\n outPoint.y = NaN;\n\n return outPoint;\n }\n\n // ua is the factor of line a where the intersection occurs. ub is the factor of line b where the intersection occurs.\n const ua = ((dxb * (aStart.y - bStart.y)) - (dyb * (aStart.x - bStart.x))) / denominator;\n const ub = ((dxa * (aStart.y - bStart.y)) - (dya * (aStart.x - bStart.x))) / denominator;\n\n // Line intersection extends beyond the bounds of the segment.\n // The intersection is inside the segments if 0.0 ≤ ua ≤ 1.0 and 0.0 ≤ ub ≤ 1.0\n if (!isLine && (ua < 0 || ua > 1 || ub < 0 || ub > 1))\n {\n outPoint.x = NaN;\n outPoint.y = NaN;\n\n return outPoint;\n }\n\n outPoint.x = aStart.x + (ua * dxa);\n outPoint.y = bStart.y + (ub * dyb);\n\n return outPoint;\n}\n\n/**\n * Computes the point where non-coincident and non-parallel Lines intersect.\n * Coincident or parallel lines return a `NaN` point `{x: NaN, y: NaN}`.\n * The intersection point may land outside the extents of the lines.\n *\n * _Note: Only available with **pixi.js/math-extras**._\n * @param aStart - First point of the first line.\n * @param aEnd - Second point of the first line.\n * @param bStart - First point of the second line.\n * @param bEnd - Second point of the second line.\n * @param {PointData} outPoint - A Point-like object in which to store the value,\n * optional (otherwise will create a new Point).\n * @returns {PointData} The point where the lines intersect or a `NaN` Point.\n * @category maths\n * @advanced\n */\nexport function lineIntersection\n<T extends PointData = Point>(aStart: PointData, aEnd: PointData, bStart: PointData, bEnd: PointData, outPoint?: T): T\n{\n return genericLineIntersection(aStart, aEnd, bStart, bEnd, true, outPoint);\n}\n\n/**\n * Computes the point where non-coincident and non-parallel segments intersect.\n * Coincident, parallel or non-intersecting segments return a `NaN` point `{x: NaN, y: NaN}`.\n * The intersection point must land inside the extents of the segments or return a `NaN` Point.\n *\n * _Note: Only available with **pixi.js/math-extras**._\n * @param aStart - Starting point of the first segment.\n * @param aEnd - Ending point of the first segment.\n * @param bStart - Starting point of the second segment.\n * @param bEnd - Ending point of the second segment.\n * @param {PointData} outPoint - A Point-like object in which to store the value,\n * optional (otherwise will create a new Point).\n * @returns {PointData} The point where the segments intersect or a `NaN` Point.\n * @category maths\n * @advanced\n */\nexport function segmentIntersection\n<T extends PointData = Point>(aStart: PointData, aEnd: PointData, bStart: PointData, bEnd: PointData, outPoint?: T): T\n{\n return genericLineIntersection(aStart, aEnd, bStart, bEnd, false, outPoint);\n}\n"],"names":["Point","rectangleExtraMixins","i","s","Rectangle","n","t","h","x","ObservablePoint"],"mappings":";;;;;;uEAAA,aAU2BA,MAAAA,EAAAA,CAAAA,IAAAA,EAAAA,EAAAA,CAAAA,OAAAA,IAAAA,EAAAA,IAAAA,KAAAA,OAWAA,EAAAA,EAAAA,KAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,KAAAA,EAAAA,EAAAA,EAAAA,CAAAA,EAAAA,SAAAA,EAAAA,EAAAA,CAAAA,OAAAA,IAAAA,EAAAA,IAAAA,KAAAA,uEAWAA,kFAWAA,KAAAA,OAAAA,EAAAA,EAAAA,KAAAA,EAAAA,EAAAA,EAAAA,EAAAA,KAAAA,EAAAA,EAAAA,CAAAA,EAAAA,IAAAA,EAAAA,CAAAA,OAAAA,KAAAA,EAAAA,EAAAA,EAAAA,KAAAA,EAAAA,EAAAA,CAAAA,EAAAA,MAAAA,EAAAA,CAAAA,OAAAA,KAAAA,EAAAA,EAAAA,EAAAA,KAAAA,EAAAA,EAAAA,CAAAA,EAAAA,UAAAA,EAAAA,CAAAA,IAAAA,EAAAA,IA4BAA,YAqBAA,MAAAA,EAAAA,KAAAA,KAAAA,KAAAA,EAAAA,KAAAA,EAAAA,KAAAA,EAAAA,KAAAA,CAAAA,EAAAA,OAAAA,EAAAA,EAAAA,KAAAA,EAAAA,EAAAA,EAAAA,EAAAA,KAAAA,EAAAA,EAAAA,CAAAA,EAA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AA,EAAA,EAAAA,EAAA,MAAAA,EAAA,OAAA,EAAAA,EAAA,MAAAI,EAAA,KAAA,EAAAL,EAAA,EAAAA,EAAA,EAAA,KAAA,EAAAM,EAAA,KAAA,OAAAN,EAAA,OAAAA,EAAA,OAAA,KAAA,OAAA,OAAAM,GAAAD,GAAAJ,EAAA,EAAAA,EAAA,EAAAA,EAAA,MAAAA,EAAA,OAAA,EAAAA,IAAAA,EAAA,EAAAE,EAAAF,EAAA,EAAAI,EAAAJ,EAAA,MAAAG,EAAAD,EAAAF,EAAA,OAAAK,EAAAD,EAAAJ,EAAA,EAAA,MAAAD,EAAAC,EAAA,CAAAA,IAAAA,EAAA,IA+BkBC,KAGlB,WAAA,MAAAC,EAAA,KAAA,IAAA,KAAA,EAAAH,EAAA,CAAA,EAAAI,EAAA,KAAA,IAAA,KAAA,EAAA,KAAA,MAAAJ,EAAA,EAAAA,EAAA,KAAA,EAAAK,EAAA,KAAA,IAAA,KAAA,EAAAL,EAAA,CAAA,EAAAM,EAAA,KAAA,IAAA,KAAA,EAAA,KAAA,OAAAN,EAAA,EAAAA,EAAA,MAAA,EAAA,OAAAC,EAAA,EAAAE,EAAAF,EAAA,EAAAI,EAAAJ,EAAA,MAAAG,EAAAD,EAAAF,EAAA,OAAAK,EAAAD,EAAAJ,CAAA,CAAA,EC/DMH,OAAAA,OAAAA,KAAAA,MACAS,UAAAA,CAAAA,EAAAA,OAAAA,OAAAA,KAAAA,2CACAL,KAAAA,UAAAA,UAAAA,CAAAA,qGC+CSJ"}
|
package/dist/pixi.js
CHANGED
package/dist/pixi.js.d.ts
CHANGED
|
@@ -22292,6 +22292,38 @@ declare global {
|
|
|
22292
22292
|
* @see {@link Point.dot} For angle calculations
|
|
22293
22293
|
*/
|
|
22294
22294
|
reflect<T extends PointData = Point>(normal: PointData, outPoint?: T): T;
|
|
22295
|
+
/**
|
|
22296
|
+
* Rotates `this` vector.
|
|
22297
|
+
*
|
|
22298
|
+
* Like a light ray bouncing off a mirror surface.
|
|
22299
|
+
* `this` vector is the light and `normal` is a vector perpendicular to the mirror.
|
|
22300
|
+
* `this.reflect(normal)` is the reflection of `this` on that mirror.
|
|
22301
|
+
*
|
|
22302
|
+
* > [!IMPORTANT] Only available with **pixi.js/math-extras**.
|
|
22303
|
+
* @example
|
|
22304
|
+
* ```ts
|
|
22305
|
+
* // Basic point rotation
|
|
22306
|
+
* const point = new Point(10, 20);
|
|
22307
|
+
* const degrees = 45
|
|
22308
|
+
* const radians = degrees * (Math.PI / 180)
|
|
22309
|
+
* const result = point.rotate(radians);
|
|
22310
|
+
* console.log(result); // {x: -7.071067811865474, y: 21.213203435596427}
|
|
22311
|
+
*
|
|
22312
|
+
* // Using output point for efficiency
|
|
22313
|
+
* const output = new Point(10, 20);
|
|
22314
|
+
* point.rotate(90 * (Math.PI / 180), output);
|
|
22315
|
+
* console.log(result); // {x: -7.071067811865474, y: 21.213203435596427}
|
|
22316
|
+
*
|
|
22317
|
+
* // Chain multiple additions
|
|
22318
|
+
* const final = point.rotate(radians).rotate(radians2);
|
|
22319
|
+
* ```
|
|
22320
|
+
* @remarks
|
|
22321
|
+
* convert degrees to radians with const radians = degrees * (Math.PI / 180)
|
|
22322
|
+
* @param {PointData} radians - The rotation angle in radians
|
|
22323
|
+
* @param {PointData} outPoint - Optional Point-like object to store result
|
|
22324
|
+
* @returns The outPoint or a new Point with rotated result
|
|
22325
|
+
*/
|
|
22326
|
+
rotate<T extends PointData = Point>(radians: number, outPoint?: T): T;
|
|
22295
22327
|
}
|
|
22296
22328
|
}
|
|
22297
22329
|
/**
|
package/dist/pixi.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var DC=Object.defineProperty;var Rx=Object.getOwnPropertySymbols;var UC=Object.prototype.hasOwnProperty,kC=Object.prototype.propertyIsEnumerable;var Mx=(d,Ot,Gt)=>Ot in d?DC(d,Ot,{enumerable:!0,configurable:!0,writable:!0,value:Gt}):d[Ot]=Gt,Cx=(d,Ot)=>{for(var Gt in Ot||(Ot={}))UC.call(Ot,Gt)&&Mx(d,Gt,Ot[Gt]);if(Rx)for(var Gt of Rx(Ot))kC.call(Ot,Gt)&&Mx(d,Gt,Ot[Gt]);return d};/*!
|
|
2
2
|
* PixiJS - v8.13.2
|
|
3
|
-
* Compiled Mon, 06 Oct 2025 21:
|
|
3
|
+
* Compiled Mon, 06 Oct 2025 21:10:06 UTC
|
|
4
4
|
*
|
|
5
5
|
* PixiJS is licensed under the MIT License.
|
|
6
6
|
* http://www.opensource.org/licenses/mit-license
|
package/dist/pixi.min.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var a0=Object.defineProperty;var Ju=Object.getOwnPropertySymbols;var l0=Object.prototype.hasOwnProperty,u0=Object.prototype.propertyIsEnumerable;var th=(r,t,e)=>t in r?a0(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,eh=(r,t)=>{for(var e in t||(t={}))l0.call(t,e)&&th(r,e,t[e]);if(Ju)for(var e of Ju(t))u0.call(t,e)&&th(r,e,t[e]);return r};/*!
|
|
2
2
|
* PixiJS - v8.13.2
|
|
3
|
-
* Compiled Mon, 06 Oct 2025 21:
|
|
3
|
+
* Compiled Mon, 06 Oct 2025 21:10:06 UTC
|
|
4
4
|
*
|
|
5
5
|
* PixiJS is licensed under the MIT License.
|
|
6
6
|
* http://www.opensource.org/licenses/mit-license
|
package/dist/pixi.mjs
CHANGED
package/dist/webworker.js
CHANGED
package/dist/webworker.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var lD=Object.defineProperty;var Wy=Object.getOwnPropertySymbols;var cD=Object.prototype.hasOwnProperty,hD=Object.prototype.propertyIsEnumerable;var Yy=(d,Xt,Mt)=>Xt in d?lD(d,Xt,{enumerable:!0,configurable:!0,writable:!0,value:Mt}):d[Xt]=Mt,qy=(d,Xt)=>{for(var Mt in Xt||(Xt={}))cD.call(Xt,Mt)&&Yy(d,Mt,Xt[Mt]);if(Wy)for(var Mt of Wy(Xt))hD.call(Xt,Mt)&&Yy(d,Mt,Xt[Mt]);return d};/*!
|
|
2
2
|
* PixiJS - v8.13.2
|
|
3
|
-
* Compiled Mon, 06 Oct 2025 21:
|
|
3
|
+
* Compiled Mon, 06 Oct 2025 21:10:06 UTC
|
|
4
4
|
*
|
|
5
5
|
* PixiJS is licensed under the MIT License.
|
|
6
6
|
* http://www.opensource.org/licenses/mit-license
|
package/dist/webworker.min.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var wv=Object.defineProperty;var Vc=Object.getOwnPropertySymbols;var Cv=Object.prototype.hasOwnProperty,Rv=Object.prototype.propertyIsEnumerable;var Wc=(r,t,e)=>t in r?wv(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Yc=(r,t)=>{for(var e in t||(t={}))Cv.call(t,e)&&Wc(r,e,t[e]);if(Vc)for(var e of Vc(t))Rv.call(t,e)&&Wc(r,e,t[e]);return r};/*!
|
|
2
2
|
* PixiJS - v8.13.2
|
|
3
|
-
* Compiled Mon, 06 Oct 2025 21:
|
|
3
|
+
* Compiled Mon, 06 Oct 2025 21:10:06 UTC
|
|
4
4
|
*
|
|
5
5
|
* PixiJS is licensed under the MIT License.
|
|
6
6
|
* http://www.opensource.org/licenses/mit-license
|
package/dist/webworker.mjs
CHANGED
|
@@ -428,6 +428,42 @@ declare global
|
|
|
428
428
|
normal: import('../maths/point/PointData').PointData,
|
|
429
429
|
outPoint?: T
|
|
430
430
|
): T;
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Rotates `this` vector.
|
|
434
|
+
*
|
|
435
|
+
* Like a light ray bouncing off a mirror surface.
|
|
436
|
+
* `this` vector is the light and `normal` is a vector perpendicular to the mirror.
|
|
437
|
+
* `this.reflect(normal)` is the reflection of `this` on that mirror.
|
|
438
|
+
*
|
|
439
|
+
* > [!IMPORTANT] Only available with **pixi.js/math-extras**.
|
|
440
|
+
* @example
|
|
441
|
+
* ```ts
|
|
442
|
+
* // Basic point rotation
|
|
443
|
+
* const point = new Point(10, 20);
|
|
444
|
+
* const degrees = 45
|
|
445
|
+
* const radians = degrees * (Math.PI / 180)
|
|
446
|
+
* const result = point.rotate(radians);
|
|
447
|
+
* console.log(result); // {x: -7.071067811865474, y: 21.213203435596427}
|
|
448
|
+
*
|
|
449
|
+
* // Using output point for efficiency
|
|
450
|
+
* const output = new Point(10, 20);
|
|
451
|
+
* point.rotate(90 * (Math.PI / 180), output);
|
|
452
|
+
* console.log(result); // {x: -7.071067811865474, y: 21.213203435596427}
|
|
453
|
+
*
|
|
454
|
+
* // Chain multiple additions
|
|
455
|
+
* const final = point.rotate(radians).rotate(radians2);
|
|
456
|
+
* ```
|
|
457
|
+
* @remarks
|
|
458
|
+
* convert degrees to radians with const radians = degrees * (Math.PI / 180)
|
|
459
|
+
* @param {PointData} radians - The rotation angle in radians
|
|
460
|
+
* @param {PointData} outPoint - Optional Point-like object to store result
|
|
461
|
+
* @returns The outPoint or a new Point with rotated result
|
|
462
|
+
*/
|
|
463
|
+
rotate<T extends import('../maths/point/PointData').PointData = import('../maths/point/Point').Point>(
|
|
464
|
+
radians: number,
|
|
465
|
+
outPoint?: T
|
|
466
|
+
): T;
|
|
431
467
|
}
|
|
432
468
|
}
|
|
433
469
|
|
|
@@ -74,6 +74,14 @@ const pointExtraMixins = {
|
|
|
74
74
|
outPoint.x = this.x - 2 * dotProduct * normal.x;
|
|
75
75
|
outPoint.y = this.y - 2 * dotProduct * normal.y;
|
|
76
76
|
return outPoint;
|
|
77
|
+
},
|
|
78
|
+
rotate(radians, outPoint) {
|
|
79
|
+
outPoint ?? (outPoint = new Point.Point());
|
|
80
|
+
const cosTheta = Math.cos(radians);
|
|
81
|
+
const sinTheta = Math.sin(radians);
|
|
82
|
+
outPoint.x = this.x * cosTheta - this.y * sinTheta;
|
|
83
|
+
outPoint.y = this.x * sinTheta + this.y * cosTheta;
|
|
84
|
+
return outPoint;
|
|
77
85
|
}
|
|
78
86
|
};
|
|
79
87
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pointExtras.js","sources":["../../src/math-extras/pointExtras.ts"],"sourcesContent":["import { Point } from '../maths/point/Point';\n\nimport type { PointData } from '../maths/point/PointData';\n\n/** @internal */\nexport const pointExtraMixins: any = {\n add<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x + other.x;\n outPoint.y = this.y + other.y;\n\n return outPoint;\n },\n subtract<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x - other.x;\n outPoint.y = this.y - other.y;\n\n return outPoint;\n },\n multiply<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x * other.x;\n outPoint.y = this.y * other.y;\n\n return outPoint;\n },\n multiplyScalar<T extends PointData>(scalar: number, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x * scalar;\n outPoint.y = this.y * scalar;\n\n return outPoint;\n },\n dot(other: PointData): number\n {\n return (this.x * other.x) + (this.y * other.y);\n },\n cross(other: PointData): number\n {\n /*\n * Returns the magnitude of the vector that would result\n * from a regular 3D cross product of the input vectors,\n * taking their Z values implicitly as 0\n * (i.e. treating the 2D space as a plane in the 3D space).\n * The 3D cross product will be perpendicular to that plane,\n * and thus have 0 X & Y components\n * (thus the scalar returned is the Z value of the 3D cross product vector).\n */\n return (this.x * other.y) - (this.y * other.x);\n },\n normalize<T extends PointData>(outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n const magnitude = Math.sqrt((this.x * this.x) + (this.y * this.y));\n\n outPoint.x = this.x / magnitude;\n outPoint.y = this.y / magnitude;\n\n return outPoint;\n },\n magnitude(): number\n {\n return Math.sqrt((this.x * this.x) + (this.y * this.y));\n },\n magnitudeSquared(): number\n {\n return (this.x * this.x) + (this.y * this.y);\n },\n project<T extends PointData>(onto: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n // Math says: a Projected over b = [(a·b) / (b·b)] * b;\n const normalizedScalarProjection = ((this.x * onto.x) + (this.y * onto.y)) / ((onto.x * onto.x) + (onto.y * onto.y));\n\n outPoint.x = onto.x * normalizedScalarProjection;\n outPoint.y = onto.y * normalizedScalarProjection;\n\n return outPoint;\n },\n reflect<T extends PointData>(normal: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n\n // Given an incident vector i and a normal vector n, returns the reflection vector r = i - 2 * dot(i, n) * n\n\n const dotProduct = (this.x * normal.x) + (this.y * normal.y);\n\n outPoint.x = this.x - (2 * dotProduct * normal.x);\n outPoint.y = this.y - (2 * dotProduct * normal.y);\n\n return outPoint;\n }\n};\n"],"names":["Point"],"mappings":";;;;;AAKO,MAAM,gBAAwB,GAAA;AAAA,EACjC,GAAA,CAAyB,OAAkB,QAC3C,EAAA;AACI,IAAA,IAAI,CAAC,QACL,EAAA;AACI,MAAA,QAAA,GAAW,IAAIA,WAAM,EAAA,CAAA;AAAA,KACzB;AACA,IAAS,QAAA,CAAA,CAAA,GAAI,IAAK,CAAA,CAAA,GAAI,KAAM,CAAA,CAAA,CAAA;AAC5B,IAAS,QAAA,CAAA,CAAA,GAAI,IAAK,CAAA,CAAA,GAAI,KAAM,CAAA,CAAA,CAAA;AAE5B,IAAO,OAAA,QAAA,CAAA;AAAA,GACX;AAAA,EACA,QAAA,CAA8B,OAAkB,QAChD,EAAA;AACI,IAAA,IAAI,CAAC,QACL,EAAA;AACI,MAAA,QAAA,GAAW,IAAIA,WAAM,EAAA,CAAA;AAAA,KACzB;AACA,IAAS,QAAA,CAAA,CAAA,GAAI,IAAK,CAAA,CAAA,GAAI,KAAM,CAAA,CAAA,CAAA;AAC5B,IAAS,QA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A,CAAA;AAAA,KACzB;AAIA,IAAA,MAAM,aAAc,IAAK,CAAA,CAAA,GAAI,OAAO,CAAM,GAAA,IAAA,CAAK,IAAI,MAAO,CAAA,CAAA,CAAA;AAE1D,IAAA,QAAA,CAAS,CAAI,GAAA,IAAA,CAAK,CAAK,GAAA,CAAA,GAAI,aAAa,MAAO,CAAA,CAAA,CAAA;AAC/C,IAAA,QAAA,CAAS,CAAI,GAAA,IAAA,CAAK,CAAK,GAAA,CAAA,GAAI,aAAa,MAAO,CAAA,CAAA,CAAA;AAE/C,IAAO,OAAA,QAAA,CAAA;AAAA,GACX;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"pointExtras.js","sources":["../../src/math-extras/pointExtras.ts"],"sourcesContent":["import { Point } from '../maths/point/Point';\n\nimport type { PointData } from '../maths/point/PointData';\n\n/** @internal */\nexport const pointExtraMixins: any = {\n add<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x + other.x;\n outPoint.y = this.y + other.y;\n\n return outPoint;\n },\n subtract<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x - other.x;\n outPoint.y = this.y - other.y;\n\n return outPoint;\n },\n multiply<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x * other.x;\n outPoint.y = this.y * other.y;\n\n return outPoint;\n },\n multiplyScalar<T extends PointData>(scalar: number, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x * scalar;\n outPoint.y = this.y * scalar;\n\n return outPoint;\n },\n dot(other: PointData): number\n {\n return (this.x * other.x) + (this.y * other.y);\n },\n cross(other: PointData): number\n {\n /*\n * Returns the magnitude of the vector that would result\n * from a regular 3D cross product of the input vectors,\n * taking their Z values implicitly as 0\n * (i.e. treating the 2D space as a plane in the 3D space).\n * The 3D cross product will be perpendicular to that plane,\n * and thus have 0 X & Y components\n * (thus the scalar returned is the Z value of the 3D cross product vector).\n */\n return (this.x * other.y) - (this.y * other.x);\n },\n normalize<T extends PointData>(outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n const magnitude = Math.sqrt((this.x * this.x) + (this.y * this.y));\n\n outPoint.x = this.x / magnitude;\n outPoint.y = this.y / magnitude;\n\n return outPoint;\n },\n magnitude(): number\n {\n return Math.sqrt((this.x * this.x) + (this.y * this.y));\n },\n magnitudeSquared(): number\n {\n return (this.x * this.x) + (this.y * this.y);\n },\n project<T extends PointData>(onto: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n // Math says: a Projected over b = [(a·b) / (b·b)] * b;\n const normalizedScalarProjection = ((this.x * onto.x) + (this.y * onto.y)) / ((onto.x * onto.x) + (onto.y * onto.y));\n\n outPoint.x = onto.x * normalizedScalarProjection;\n outPoint.y = onto.y * normalizedScalarProjection;\n\n return outPoint;\n },\n reflect<T extends PointData>(normal: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n\n // Given an incident vector i and a normal vector n, returns the reflection vector r = i - 2 * dot(i, n) * n\n\n const dotProduct = (this.x * normal.x) + (this.y * normal.y);\n\n outPoint.x = this.x - (2 * dotProduct * normal.x);\n outPoint.y = this.y - (2 * dotProduct * normal.y);\n\n return outPoint;\n },\n rotate<T extends PointData>(radians: number, outPoint?: T): T\n {\n outPoint ??= new Point() as PointData as T;\n\n const cosTheta = Math.cos(radians);\n const sinTheta = Math.sin(radians);\n\n outPoint.x = (this.x * cosTheta) - (this.y * sinTheta);\n outPoint.y = (this.x * sinTheta) + (this.y * cosTheta);\n\n return outPoint;\n }\n};\n"],"names":["Point"],"mappings":";;;;;AAKO,MAAM,gBAAwB,GAAA;AAAA,EACjC,GAAA,CAAyB,OAAkB,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AAK,CAAI,GAAA,QAAA,GAAa,KAAK,CAAI,GAAA,QAAA,CAAA;AAC7C,IAAA,QAAA,CAAS,CAAK,GAAA,IAAA,CAAK,CAAI,GAAA,QAAA,GAAa,KAAK,CAAI,GAAA,QAAA,CAAA;AAE7C,IAAO,OAAA,QAAA,CAAA;AAAA,GACX;AACJ;;;;"}
|
|
@@ -72,6 +72,14 @@ const pointExtraMixins = {
|
|
|
72
72
|
outPoint.x = this.x - 2 * dotProduct * normal.x;
|
|
73
73
|
outPoint.y = this.y - 2 * dotProduct * normal.y;
|
|
74
74
|
return outPoint;
|
|
75
|
+
},
|
|
76
|
+
rotate(radians, outPoint) {
|
|
77
|
+
outPoint ?? (outPoint = new Point());
|
|
78
|
+
const cosTheta = Math.cos(radians);
|
|
79
|
+
const sinTheta = Math.sin(radians);
|
|
80
|
+
outPoint.x = this.x * cosTheta - this.y * sinTheta;
|
|
81
|
+
outPoint.y = this.x * sinTheta + this.y * cosTheta;
|
|
82
|
+
return outPoint;
|
|
75
83
|
}
|
|
76
84
|
};
|
|
77
85
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pointExtras.mjs","sources":["../../src/math-extras/pointExtras.ts"],"sourcesContent":["import { Point } from '../maths/point/Point';\n\nimport type { PointData } from '../maths/point/PointData';\n\n/** @internal */\nexport const pointExtraMixins: any = {\n add<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x + other.x;\n outPoint.y = this.y + other.y;\n\n return outPoint;\n },\n subtract<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x - other.x;\n outPoint.y = this.y - other.y;\n\n return outPoint;\n },\n multiply<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x * other.x;\n outPoint.y = this.y * other.y;\n\n return outPoint;\n },\n multiplyScalar<T extends PointData>(scalar: number, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x * scalar;\n outPoint.y = this.y * scalar;\n\n return outPoint;\n },\n dot(other: PointData): number\n {\n return (this.x * other.x) + (this.y * other.y);\n },\n cross(other: PointData): number\n {\n /*\n * Returns the magnitude of the vector that would result\n * from a regular 3D cross product of the input vectors,\n * taking their Z values implicitly as 0\n * (i.e. treating the 2D space as a plane in the 3D space).\n * The 3D cross product will be perpendicular to that plane,\n * and thus have 0 X & Y components\n * (thus the scalar returned is the Z value of the 3D cross product vector).\n */\n return (this.x * other.y) - (this.y * other.x);\n },\n normalize<T extends PointData>(outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n const magnitude = Math.sqrt((this.x * this.x) + (this.y * this.y));\n\n outPoint.x = this.x / magnitude;\n outPoint.y = this.y / magnitude;\n\n return outPoint;\n },\n magnitude(): number\n {\n return Math.sqrt((this.x * this.x) + (this.y * this.y));\n },\n magnitudeSquared(): number\n {\n return (this.x * this.x) + (this.y * this.y);\n },\n project<T extends PointData>(onto: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n // Math says: a Projected over b = [(a·b) / (b·b)] * b;\n const normalizedScalarProjection = ((this.x * onto.x) + (this.y * onto.y)) / ((onto.x * onto.x) + (onto.y * onto.y));\n\n outPoint.x = onto.x * normalizedScalarProjection;\n outPoint.y = onto.y * normalizedScalarProjection;\n\n return outPoint;\n },\n reflect<T extends PointData>(normal: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n\n // Given an incident vector i and a normal vector n, returns the reflection vector r = i - 2 * dot(i, n) * n\n\n const dotProduct = (this.x * normal.x) + (this.y * normal.y);\n\n outPoint.x = this.x - (2 * dotProduct * normal.x);\n outPoint.y = this.y - (2 * dotProduct * normal.y);\n\n return outPoint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AA6B,MAAiB,QAC9C,EAAA;AACI,IAAA,IAAI,CAAC,QACL,EAAA;AACI,MAAA,QAAA,GAAW,IAAI,KAAM,EAAA,CAAA;AAAA,KACzB;AAEA,IAAA,MAAM,0BAA+B,GAAA,CAAA,IAAA,CAAK,CAAI,GAAA,IAAA,CAAK,IAAM,IAAK,CAAA,CAAA,GAAI,IAAK,CAAA,CAAA,KAAQ,KAAK,CAAI,GAAA,IAAA,CAAK,CAAM,GAAA,IAAA,CAAK,IAAI,IAAK,CAAA,CAAA,CAAA,CAAA;AAEjH,IAAS,QAAA,CAAA,CAAA,GAAI,KAAK,CAAI,GAAA,0BAAA,CAAA;AACtB,IAAS,QAAA,CAAA,CAAA,GAAI,KAAK,CAAI,GAAA,0BAAA,CAAA;AAEtB,IAAO,OAAA,QAAA,CAAA;AAAA,GACX;AAAA,EACA,OAAA,CAA6B,QAAmB,QAChD,EAAA;AACI,IAAA,IAAI,CAAC,QACL,EAAA;AACI,MAAA,QAAA,GAAW,IAAI,KAAM,EAAA,CAAA;AAAA,KACzB;AAIA,IAAA,MAAM,aAAc,IAAK,CAAA,CAAA,GAAI,OAAO,CAAM,GAAA,IAAA,CAAK,IAAI,MAAO,CAAA,CAAA,CAAA;AAE1D,IAAA,QAAA,CAAS,CAAI,GAAA,IAAA,CAAK,CAAK,GAAA,CAAA,GAAI,aAAa,MAAO,CAAA,CAAA,CAAA;AAC/C,IAAA,QAAA,CAAS,CAAI,GAAA,IAAA,CAAK,CAAK,GAAA,CAAA,GAAI,aAAa,MAAO,CAAA,CAAA,CAAA;AAE/C,IAAO,OAAA,QAAA,CAAA;AAAA,GACX;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"pointExtras.mjs","sources":["../../src/math-extras/pointExtras.ts"],"sourcesContent":["import { Point } from '../maths/point/Point';\n\nimport type { PointData } from '../maths/point/PointData';\n\n/** @internal */\nexport const pointExtraMixins: any = {\n add<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x + other.x;\n outPoint.y = this.y + other.y;\n\n return outPoint;\n },\n subtract<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x - other.x;\n outPoint.y = this.y - other.y;\n\n return outPoint;\n },\n multiply<T extends PointData>(other: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x * other.x;\n outPoint.y = this.y * other.y;\n\n return outPoint;\n },\n multiplyScalar<T extends PointData>(scalar: number, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n outPoint.x = this.x * scalar;\n outPoint.y = this.y * scalar;\n\n return outPoint;\n },\n dot(other: PointData): number\n {\n return (this.x * other.x) + (this.y * other.y);\n },\n cross(other: PointData): number\n {\n /*\n * Returns the magnitude of the vector that would result\n * from a regular 3D cross product of the input vectors,\n * taking their Z values implicitly as 0\n * (i.e. treating the 2D space as a plane in the 3D space).\n * The 3D cross product will be perpendicular to that plane,\n * and thus have 0 X & Y components\n * (thus the scalar returned is the Z value of the 3D cross product vector).\n */\n return (this.x * other.y) - (this.y * other.x);\n },\n normalize<T extends PointData>(outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n const magnitude = Math.sqrt((this.x * this.x) + (this.y * this.y));\n\n outPoint.x = this.x / magnitude;\n outPoint.y = this.y / magnitude;\n\n return outPoint;\n },\n magnitude(): number\n {\n return Math.sqrt((this.x * this.x) + (this.y * this.y));\n },\n magnitudeSquared(): number\n {\n return (this.x * this.x) + (this.y * this.y);\n },\n project<T extends PointData>(onto: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n // Math says: a Projected over b = [(a·b) / (b·b)] * b;\n const normalizedScalarProjection = ((this.x * onto.x) + (this.y * onto.y)) / ((onto.x * onto.x) + (onto.y * onto.y));\n\n outPoint.x = onto.x * normalizedScalarProjection;\n outPoint.y = onto.y * normalizedScalarProjection;\n\n return outPoint;\n },\n reflect<T extends PointData>(normal: PointData, outPoint?: T): T\n {\n if (!outPoint)\n {\n outPoint = new Point() as PointData as T;\n }\n\n // Given an incident vector i and a normal vector n, returns the reflection vector r = i - 2 * dot(i, n) * n\n\n const dotProduct = (this.x * normal.x) + (this.y * normal.y);\n\n outPoint.x = this.x - (2 * dotProduct * normal.x);\n outPoint.y = this.y - (2 * dotProduct * normal.y);\n\n return outPoint;\n },\n rotate<T extends PointData>(radians: number, outPoint?: T): T\n {\n outPoint ??= new Point() as PointData as T;\n\n const cosTheta = Math.cos(radians);\n const sinTheta = Math.sin(radians);\n\n outPoint.x = (this.x * cosTheta) - (this.y * sinTheta);\n outPoint.y = (this.x * sinTheta) + (this.y * cosTheta);\n\n return outPoint;\n }\n};\n"],"names":[],"mappings":";;;AAKO,MAAM,gBAAwB,GAAA;AAAA,EACjC,GAAA,CAAyB,OAAkB,QAC3C,EAAA;AACI,IAAA,IAAI,CAAC,QACL,EAAA;AACI,MAAA,QAAA,GAAW,IAAI,KAAM,EAAA,CAAA;AAAA,KACzB;AACA,IAAS,QAAA,CAAA,CAAA,GAAI,IAAK,CAAA,CAAA,GAAI,KAAM,CAAA,CAAA,CAAA;AAC5B,IAAS,QAAA,CAAA,CAAA,GAAI,IAAK,CAAA,CAAA,GAAI,KAAM,CAAA,CAAA,CAAA;AAE5B,IAAO,OAAA,QAAA,CAAA;AAAA,GACX;AAAA,EACA,QAAA,CAA8B,OAAkB,QAChD,EAAA;AACI,IAAA,IAAI,CAAC,QACL,EAAA;AACI,MAAA,QAAA,GAAW,IAAI,KAAM,EAAA,CAAA;AAAA,KACzB;AACA,IAAS,QAAA,CAAA,CAAA,GAAI,IAAK,CAAA,CAAA,GAAI,KAAM,CAAA,CAAA,CAAA;AAC5B,IAAS,QAAA,CAAA,CAAA,GAAI,IAAK,CAAA,CAAA,GAAI,KAAM,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