@tsparticles/engine 3.2.1 → 3.2.2
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/373.min.js +1 -1
- package/373.min.js.LICENSE.txt +1 -1
- package/438.min.js +1 -1
- package/438.min.js.LICENSE.txt +1 -1
- package/browser/Core/Container.js +1 -1
- package/browser/Core/Engine.js +1 -1
- package/browser/Core/Particle.js +1 -2
- package/browser/Core/Particles.js +1 -1
- package/browser/Core/Utils/EventListeners.js +4 -3
- package/browser/Core/Utils/QuadTree.js +4 -5
- package/browser/Core/Utils/Ranges.js +55 -0
- package/browser/Core/Utils/{Vector3d.js → Vectors.js} +15 -1
- package/browser/Options/Classes/AnimatableColor.js +1 -1
- package/browser/Options/Classes/BackgroundMask/BackgroundMask.js +1 -1
- package/browser/Options/Classes/Options.js +2 -1
- package/browser/Options/Classes/OptionsColor.js +1 -1
- package/browser/Options/Classes/Particles/Move/Move.js +1 -1
- package/browser/Types/RangeType.js +1 -0
- package/browser/Utils/ColorUtils.js +2 -1
- package/browser/Utils/NumberUtils.js +2 -2
- package/browser/Utils/TypeUtils.js +18 -0
- package/browser/Utils/Utils.js +2 -19
- package/browser/exports.js +3 -5
- package/cjs/Core/Container.js +1 -1
- package/cjs/Core/Engine.js +1 -1
- package/cjs/Core/Particle.js +4 -5
- package/cjs/Core/Particles.js +2 -2
- package/cjs/Core/Utils/EventListeners.js +4 -3
- package/cjs/Core/Utils/QuadTree.js +7 -8
- package/cjs/Core/Utils/Ranges.js +61 -0
- package/cjs/Core/Utils/{Vector3d.js → Vectors.js} +18 -3
- package/cjs/Options/Classes/AnimatableColor.js +2 -2
- package/cjs/Options/Classes/BackgroundMask/BackgroundMask.js +2 -2
- package/cjs/Options/Classes/Options.js +2 -1
- package/cjs/Options/Classes/OptionsColor.js +2 -2
- package/cjs/Options/Classes/Particles/Move/Move.js +4 -4
- package/cjs/Types/RangeType.js +2 -0
- package/cjs/Utils/ColorUtils.js +9 -8
- package/cjs/Utils/NumberUtils.js +9 -9
- package/cjs/Utils/TypeUtils.js +27 -0
- package/cjs/Utils/Utils.js +13 -36
- package/cjs/exports.js +3 -5
- package/dist_browser_Core_Container_js.js +5 -5
- package/dist_browser_Core_Particle_js.js +2 -2
- package/esm/Core/Container.js +1 -1
- package/esm/Core/Engine.js +1 -1
- package/esm/Core/Particle.js +1 -2
- package/esm/Core/Particles.js +1 -1
- package/esm/Core/Utils/EventListeners.js +4 -3
- package/esm/Core/Utils/QuadTree.js +4 -5
- package/esm/Core/Utils/Ranges.js +55 -0
- package/esm/Core/Utils/{Vector3d.js → Vectors.js} +15 -1
- package/esm/Options/Classes/AnimatableColor.js +1 -1
- package/esm/Options/Classes/BackgroundMask/BackgroundMask.js +1 -1
- package/esm/Options/Classes/Options.js +2 -1
- package/esm/Options/Classes/OptionsColor.js +1 -1
- package/esm/Options/Classes/Particles/Move/Move.js +1 -1
- package/esm/Types/RangeType.js +1 -0
- package/esm/Utils/ColorUtils.js +2 -1
- package/esm/Utils/NumberUtils.js +2 -2
- package/esm/Utils/TypeUtils.js +18 -0
- package/esm/Utils/Utils.js +2 -19
- package/esm/exports.js +3 -5
- package/package.json +1 -1
- package/report.html +1 -1
- package/tsparticles.engine.js +30 -50
- package/tsparticles.engine.min.js +1 -1
- package/tsparticles.engine.min.js.LICENSE.txt +1 -1
- package/types/Core/Interfaces/ICircleBouncer.d.ts +1 -1
- package/types/Core/Interfaces/IMovePathGenerator.d.ts +1 -1
- package/types/Core/Particle.d.ts +1 -2
- package/types/Core/Utils/QuadTree.d.ts +2 -3
- package/types/Core/Utils/Ranges.d.ts +21 -0
- package/types/Core/Utils/{Vector3d.d.ts → Vectors.d.ts} +6 -0
- package/types/Types/RangeType.d.ts +4 -0
- package/types/Utils/NumberUtils.d.ts +1 -1
- package/types/Utils/TypeUtils.d.ts +6 -0
- package/types/Utils/Utils.d.ts +0 -6
- package/types/exports.d.ts +3 -5
- package/umd/Core/Container.js +1 -1
- package/umd/Core/Engine.js +1 -1
- package/umd/Core/Particle.js +5 -6
- package/umd/Core/Particles.js +3 -3
- package/umd/Core/Utils/EventListeners.js +5 -4
- package/umd/Core/Utils/QuadTree.js +8 -9
- package/umd/Core/Utils/Ranges.js +71 -0
- package/umd/Core/Utils/{Vector3d.js → Vectors.js} +19 -4
- package/umd/Options/Classes/AnimatableColor.js +3 -3
- package/umd/Options/Classes/BackgroundMask/BackgroundMask.js +3 -3
- package/umd/Options/Classes/Options.js +3 -2
- package/umd/Options/Classes/OptionsColor.js +3 -3
- package/umd/Options/Classes/Particles/Move/Move.js +5 -5
- package/umd/{Core/Utils/Range.js → Types/RangeType.js} +0 -10
- package/umd/Utils/ColorUtils.js +10 -9
- package/umd/Utils/NumberUtils.js +10 -10
- package/umd/Utils/TypeUtils.js +37 -0
- package/umd/Utils/Utils.js +14 -37
- package/umd/exports.js +4 -6
- package/browser/Core/Utils/Circle.js +0 -28
- package/browser/Core/Utils/Range.js +0 -8
- package/browser/Core/Utils/Rectangle.js +0 -22
- package/browser/Core/Utils/Vector.js +0 -20
- package/cjs/Core/Utils/Circle.js +0 -32
- package/cjs/Core/Utils/Range.js +0 -12
- package/cjs/Core/Utils/Rectangle.js +0 -26
- package/cjs/Core/Utils/Vector.js +0 -24
- package/esm/Core/Utils/Circle.js +0 -28
- package/esm/Core/Utils/Range.js +0 -8
- package/esm/Core/Utils/Rectangle.js +0 -22
- package/esm/Core/Utils/Vector.js +0 -20
- package/types/Core/Utils/Circle.d.ts +0 -8
- package/types/Core/Utils/Range.d.ts +0 -7
- package/types/Core/Utils/Rectangle.d.ts +0 -9
- package/types/Core/Utils/Vector.d.ts +0 -8
- package/umd/Core/Utils/Circle.js +0 -42
- package/umd/Core/Utils/Rectangle.js +0 -36
- package/umd/Core/Utils/Vector.js +0 -34
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Range } from "./Range.js";
|
|
2
|
-
import { Rectangle } from "./Rectangle.js";
|
|
3
|
-
import { getDistance } from "../../Utils/NumberUtils.js";
|
|
4
|
-
const squareExp = 2;
|
|
5
|
-
export class Circle extends Range {
|
|
6
|
-
constructor(x, y, radius) {
|
|
7
|
-
super(x, y);
|
|
8
|
-
this.radius = radius;
|
|
9
|
-
}
|
|
10
|
-
contains(point) {
|
|
11
|
-
return getDistance(point, this.position) <= this.radius;
|
|
12
|
-
}
|
|
13
|
-
intersects(range) {
|
|
14
|
-
const pos1 = this.position, pos2 = range.position, distPos = { x: Math.abs(pos2.x - pos1.x), y: Math.abs(pos2.y - pos1.y) }, r = this.radius;
|
|
15
|
-
if (range instanceof Circle) {
|
|
16
|
-
const rSum = r + range.radius, dist = Math.sqrt(distPos.x ** squareExp + distPos.y ** squareExp);
|
|
17
|
-
return rSum > dist;
|
|
18
|
-
}
|
|
19
|
-
else if (range instanceof Rectangle) {
|
|
20
|
-
const { width, height } = range.size, edges = Math.pow(distPos.x - width, squareExp) + Math.pow(distPos.y - height, squareExp);
|
|
21
|
-
return (edges <= r ** squareExp ||
|
|
22
|
-
(distPos.x <= r + width && distPos.y <= r + height) ||
|
|
23
|
-
distPos.x <= width ||
|
|
24
|
-
distPos.y <= height);
|
|
25
|
-
}
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Circle } from "./Circle.js";
|
|
2
|
-
import { Range } from "./Range.js";
|
|
3
|
-
export class Rectangle extends Range {
|
|
4
|
-
constructor(x, y, width, height) {
|
|
5
|
-
super(x, y);
|
|
6
|
-
this.size = {
|
|
7
|
-
height: height,
|
|
8
|
-
width: width,
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
contains(point) {
|
|
12
|
-
const w = this.size.width, h = this.size.height, pos = this.position;
|
|
13
|
-
return point.x >= pos.x && point.x <= pos.x + w && point.y >= pos.y && point.y <= pos.y + h;
|
|
14
|
-
}
|
|
15
|
-
intersects(range) {
|
|
16
|
-
if (range instanceof Circle) {
|
|
17
|
-
range.intersects(this);
|
|
18
|
-
}
|
|
19
|
-
const w = this.size.width, h = this.size.height, pos1 = this.position, pos2 = range.position, size2 = range instanceof Rectangle ? range.size : { width: 0, height: 0 }, w2 = size2.width, h2 = size2.height;
|
|
20
|
-
return pos2.x < pos1.x + w && pos2.x + w2 > pos1.x && pos2.y < pos1.y + h && pos2.y + h2 > pos1.y;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Vector3d } from "./Vector3d.js";
|
|
2
|
-
const origin = {
|
|
3
|
-
x: 0,
|
|
4
|
-
y: 0,
|
|
5
|
-
z: 0,
|
|
6
|
-
};
|
|
7
|
-
export class Vector extends Vector3d {
|
|
8
|
-
constructor(xOrCoords, y) {
|
|
9
|
-
super(xOrCoords, y, origin.z);
|
|
10
|
-
}
|
|
11
|
-
static get origin() {
|
|
12
|
-
return Vector.create(origin.x, origin.y);
|
|
13
|
-
}
|
|
14
|
-
static clone(source) {
|
|
15
|
-
return Vector.create(source.x, source.y);
|
|
16
|
-
}
|
|
17
|
-
static create(x, y) {
|
|
18
|
-
return new Vector(x, y);
|
|
19
|
-
}
|
|
20
|
-
}
|
package/cjs/Core/Utils/Circle.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Circle = void 0;
|
|
4
|
-
const Range_js_1 = require("./Range.js");
|
|
5
|
-
const Rectangle_js_1 = require("./Rectangle.js");
|
|
6
|
-
const NumberUtils_js_1 = require("../../Utils/NumberUtils.js");
|
|
7
|
-
const squareExp = 2;
|
|
8
|
-
class Circle extends Range_js_1.Range {
|
|
9
|
-
constructor(x, y, radius) {
|
|
10
|
-
super(x, y);
|
|
11
|
-
this.radius = radius;
|
|
12
|
-
}
|
|
13
|
-
contains(point) {
|
|
14
|
-
return (0, NumberUtils_js_1.getDistance)(point, this.position) <= this.radius;
|
|
15
|
-
}
|
|
16
|
-
intersects(range) {
|
|
17
|
-
const pos1 = this.position, pos2 = range.position, distPos = { x: Math.abs(pos2.x - pos1.x), y: Math.abs(pos2.y - pos1.y) }, r = this.radius;
|
|
18
|
-
if (range instanceof Circle) {
|
|
19
|
-
const rSum = r + range.radius, dist = Math.sqrt(distPos.x ** squareExp + distPos.y ** squareExp);
|
|
20
|
-
return rSum > dist;
|
|
21
|
-
}
|
|
22
|
-
else if (range instanceof Rectangle_js_1.Rectangle) {
|
|
23
|
-
const { width, height } = range.size, edges = Math.pow(distPos.x - width, squareExp) + Math.pow(distPos.y - height, squareExp);
|
|
24
|
-
return (edges <= r ** squareExp ||
|
|
25
|
-
(distPos.x <= r + width && distPos.y <= r + height) ||
|
|
26
|
-
distPos.x <= width ||
|
|
27
|
-
distPos.y <= height);
|
|
28
|
-
}
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.Circle = Circle;
|
package/cjs/Core/Utils/Range.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Rectangle = void 0;
|
|
4
|
-
const Circle_js_1 = require("./Circle.js");
|
|
5
|
-
const Range_js_1 = require("./Range.js");
|
|
6
|
-
class Rectangle extends Range_js_1.Range {
|
|
7
|
-
constructor(x, y, width, height) {
|
|
8
|
-
super(x, y);
|
|
9
|
-
this.size = {
|
|
10
|
-
height: height,
|
|
11
|
-
width: width,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
contains(point) {
|
|
15
|
-
const w = this.size.width, h = this.size.height, pos = this.position;
|
|
16
|
-
return point.x >= pos.x && point.x <= pos.x + w && point.y >= pos.y && point.y <= pos.y + h;
|
|
17
|
-
}
|
|
18
|
-
intersects(range) {
|
|
19
|
-
if (range instanceof Circle_js_1.Circle) {
|
|
20
|
-
range.intersects(this);
|
|
21
|
-
}
|
|
22
|
-
const w = this.size.width, h = this.size.height, pos1 = this.position, pos2 = range.position, size2 = range instanceof Rectangle ? range.size : { width: 0, height: 0 }, w2 = size2.width, h2 = size2.height;
|
|
23
|
-
return pos2.x < pos1.x + w && pos2.x + w2 > pos1.x && pos2.y < pos1.y + h && pos2.y + h2 > pos1.y;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.Rectangle = Rectangle;
|
package/cjs/Core/Utils/Vector.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Vector = void 0;
|
|
4
|
-
const Vector3d_js_1 = require("./Vector3d.js");
|
|
5
|
-
const origin = {
|
|
6
|
-
x: 0,
|
|
7
|
-
y: 0,
|
|
8
|
-
z: 0,
|
|
9
|
-
};
|
|
10
|
-
class Vector extends Vector3d_js_1.Vector3d {
|
|
11
|
-
constructor(xOrCoords, y) {
|
|
12
|
-
super(xOrCoords, y, origin.z);
|
|
13
|
-
}
|
|
14
|
-
static get origin() {
|
|
15
|
-
return Vector.create(origin.x, origin.y);
|
|
16
|
-
}
|
|
17
|
-
static clone(source) {
|
|
18
|
-
return Vector.create(source.x, source.y);
|
|
19
|
-
}
|
|
20
|
-
static create(x, y) {
|
|
21
|
-
return new Vector(x, y);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.Vector = Vector;
|
package/esm/Core/Utils/Circle.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Range } from "./Range.js";
|
|
2
|
-
import { Rectangle } from "./Rectangle.js";
|
|
3
|
-
import { getDistance } from "../../Utils/NumberUtils.js";
|
|
4
|
-
const squareExp = 2;
|
|
5
|
-
export class Circle extends Range {
|
|
6
|
-
constructor(x, y, radius) {
|
|
7
|
-
super(x, y);
|
|
8
|
-
this.radius = radius;
|
|
9
|
-
}
|
|
10
|
-
contains(point) {
|
|
11
|
-
return getDistance(point, this.position) <= this.radius;
|
|
12
|
-
}
|
|
13
|
-
intersects(range) {
|
|
14
|
-
const pos1 = this.position, pos2 = range.position, distPos = { x: Math.abs(pos2.x - pos1.x), y: Math.abs(pos2.y - pos1.y) }, r = this.radius;
|
|
15
|
-
if (range instanceof Circle) {
|
|
16
|
-
const rSum = r + range.radius, dist = Math.sqrt(distPos.x ** squareExp + distPos.y ** squareExp);
|
|
17
|
-
return rSum > dist;
|
|
18
|
-
}
|
|
19
|
-
else if (range instanceof Rectangle) {
|
|
20
|
-
const { width, height } = range.size, edges = Math.pow(distPos.x - width, squareExp) + Math.pow(distPos.y - height, squareExp);
|
|
21
|
-
return (edges <= r ** squareExp ||
|
|
22
|
-
(distPos.x <= r + width && distPos.y <= r + height) ||
|
|
23
|
-
distPos.x <= width ||
|
|
24
|
-
distPos.y <= height);
|
|
25
|
-
}
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
}
|
package/esm/Core/Utils/Range.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Circle } from "./Circle.js";
|
|
2
|
-
import { Range } from "./Range.js";
|
|
3
|
-
export class Rectangle extends Range {
|
|
4
|
-
constructor(x, y, width, height) {
|
|
5
|
-
super(x, y);
|
|
6
|
-
this.size = {
|
|
7
|
-
height: height,
|
|
8
|
-
width: width,
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
contains(point) {
|
|
12
|
-
const w = this.size.width, h = this.size.height, pos = this.position;
|
|
13
|
-
return point.x >= pos.x && point.x <= pos.x + w && point.y >= pos.y && point.y <= pos.y + h;
|
|
14
|
-
}
|
|
15
|
-
intersects(range) {
|
|
16
|
-
if (range instanceof Circle) {
|
|
17
|
-
range.intersects(this);
|
|
18
|
-
}
|
|
19
|
-
const w = this.size.width, h = this.size.height, pos1 = this.position, pos2 = range.position, size2 = range instanceof Rectangle ? range.size : { width: 0, height: 0 }, w2 = size2.width, h2 = size2.height;
|
|
20
|
-
return pos2.x < pos1.x + w && pos2.x + w2 > pos1.x && pos2.y < pos1.y + h && pos2.y + h2 > pos1.y;
|
|
21
|
-
}
|
|
22
|
-
}
|
package/esm/Core/Utils/Vector.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Vector3d } from "./Vector3d.js";
|
|
2
|
-
const origin = {
|
|
3
|
-
x: 0,
|
|
4
|
-
y: 0,
|
|
5
|
-
z: 0,
|
|
6
|
-
};
|
|
7
|
-
export class Vector extends Vector3d {
|
|
8
|
-
constructor(xOrCoords, y) {
|
|
9
|
-
super(xOrCoords, y, origin.z);
|
|
10
|
-
}
|
|
11
|
-
static get origin() {
|
|
12
|
-
return Vector.create(origin.x, origin.y);
|
|
13
|
-
}
|
|
14
|
-
static clone(source) {
|
|
15
|
-
return Vector.create(source.x, source.y);
|
|
16
|
-
}
|
|
17
|
-
static create(x, y) {
|
|
18
|
-
return new Vector(x, y);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ICoordinates } from "../Interfaces/ICoordinates.js";
|
|
2
|
-
import { Range } from "./Range.js";
|
|
3
|
-
export declare class Circle extends Range {
|
|
4
|
-
readonly radius: number;
|
|
5
|
-
constructor(x: number, y: number, radius: number);
|
|
6
|
-
contains(point: ICoordinates): boolean;
|
|
7
|
-
intersects(range: Range): boolean;
|
|
8
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ICoordinates } from "../Interfaces/ICoordinates.js";
|
|
2
|
-
export declare abstract class Range {
|
|
3
|
-
readonly position: ICoordinates;
|
|
4
|
-
protected constructor(x: number, y: number);
|
|
5
|
-
abstract contains(point: ICoordinates): boolean;
|
|
6
|
-
abstract intersects(range: Range): boolean;
|
|
7
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ICoordinates } from "../Interfaces/ICoordinates.js";
|
|
2
|
-
import type { IDimension } from "../Interfaces/IDimension.js";
|
|
3
|
-
import { Range } from "./Range.js";
|
|
4
|
-
export declare class Rectangle extends Range {
|
|
5
|
-
readonly size: IDimension;
|
|
6
|
-
constructor(x: number, y: number, width: number, height: number);
|
|
7
|
-
contains(point: ICoordinates): boolean;
|
|
8
|
-
intersects(range: Range): boolean;
|
|
9
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ICoordinates } from "../Interfaces/ICoordinates.js";
|
|
2
|
-
import { Vector3d } from "./Vector3d.js";
|
|
3
|
-
export declare class Vector extends Vector3d {
|
|
4
|
-
protected constructor(xOrCoords: number | ICoordinates, y?: number);
|
|
5
|
-
static get origin(): Vector;
|
|
6
|
-
static clone(source: Vector): Vector;
|
|
7
|
-
static create(x: number | ICoordinates, y?: number): Vector;
|
|
8
|
-
}
|
package/umd/Core/Utils/Circle.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./Range.js", "./Rectangle.js", "../../Utils/NumberUtils.js"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Circle = void 0;
|
|
13
|
-
const Range_js_1 = require("./Range.js");
|
|
14
|
-
const Rectangle_js_1 = require("./Rectangle.js");
|
|
15
|
-
const NumberUtils_js_1 = require("../../Utils/NumberUtils.js");
|
|
16
|
-
const squareExp = 2;
|
|
17
|
-
class Circle extends Range_js_1.Range {
|
|
18
|
-
constructor(x, y, radius) {
|
|
19
|
-
super(x, y);
|
|
20
|
-
this.radius = radius;
|
|
21
|
-
}
|
|
22
|
-
contains(point) {
|
|
23
|
-
return (0, NumberUtils_js_1.getDistance)(point, this.position) <= this.radius;
|
|
24
|
-
}
|
|
25
|
-
intersects(range) {
|
|
26
|
-
const pos1 = this.position, pos2 = range.position, distPos = { x: Math.abs(pos2.x - pos1.x), y: Math.abs(pos2.y - pos1.y) }, r = this.radius;
|
|
27
|
-
if (range instanceof Circle) {
|
|
28
|
-
const rSum = r + range.radius, dist = Math.sqrt(distPos.x ** squareExp + distPos.y ** squareExp);
|
|
29
|
-
return rSum > dist;
|
|
30
|
-
}
|
|
31
|
-
else if (range instanceof Rectangle_js_1.Rectangle) {
|
|
32
|
-
const { width, height } = range.size, edges = Math.pow(distPos.x - width, squareExp) + Math.pow(distPos.y - height, squareExp);
|
|
33
|
-
return (edges <= r ** squareExp ||
|
|
34
|
-
(distPos.x <= r + width && distPos.y <= r + height) ||
|
|
35
|
-
distPos.x <= width ||
|
|
36
|
-
distPos.y <= height);
|
|
37
|
-
}
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.Circle = Circle;
|
|
42
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./Circle.js", "./Range.js"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Rectangle = void 0;
|
|
13
|
-
const Circle_js_1 = require("./Circle.js");
|
|
14
|
-
const Range_js_1 = require("./Range.js");
|
|
15
|
-
class Rectangle extends Range_js_1.Range {
|
|
16
|
-
constructor(x, y, width, height) {
|
|
17
|
-
super(x, y);
|
|
18
|
-
this.size = {
|
|
19
|
-
height: height,
|
|
20
|
-
width: width,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
contains(point) {
|
|
24
|
-
const w = this.size.width, h = this.size.height, pos = this.position;
|
|
25
|
-
return point.x >= pos.x && point.x <= pos.x + w && point.y >= pos.y && point.y <= pos.y + h;
|
|
26
|
-
}
|
|
27
|
-
intersects(range) {
|
|
28
|
-
if (range instanceof Circle_js_1.Circle) {
|
|
29
|
-
range.intersects(this);
|
|
30
|
-
}
|
|
31
|
-
const w = this.size.width, h = this.size.height, pos1 = this.position, pos2 = range.position, size2 = range instanceof Rectangle ? range.size : { width: 0, height: 0 }, w2 = size2.width, h2 = size2.height;
|
|
32
|
-
return pos2.x < pos1.x + w && pos2.x + w2 > pos1.x && pos2.y < pos1.y + h && pos2.y + h2 > pos1.y;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.Rectangle = Rectangle;
|
|
36
|
-
});
|
package/umd/Core/Utils/Vector.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./Vector3d.js"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Vector = void 0;
|
|
13
|
-
const Vector3d_js_1 = require("./Vector3d.js");
|
|
14
|
-
const origin = {
|
|
15
|
-
x: 0,
|
|
16
|
-
y: 0,
|
|
17
|
-
z: 0,
|
|
18
|
-
};
|
|
19
|
-
class Vector extends Vector3d_js_1.Vector3d {
|
|
20
|
-
constructor(xOrCoords, y) {
|
|
21
|
-
super(xOrCoords, y, origin.z);
|
|
22
|
-
}
|
|
23
|
-
static get origin() {
|
|
24
|
-
return Vector.create(origin.x, origin.y);
|
|
25
|
-
}
|
|
26
|
-
static clone(source) {
|
|
27
|
-
return Vector.create(source.x, source.y);
|
|
28
|
-
}
|
|
29
|
-
static create(x, y) {
|
|
30
|
-
return new Vector(x, y);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.Vector = Vector;
|
|
34
|
-
});
|