@xort/cga 0.0.86 → 0.0.88
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/build/cga.d.ts +2032 -0
- package/dist/IKanimation/CCDSolver.js +2 -2
- package/dist/IKanimation/constaint/hinge.js +3 -1
- package/dist/IKanimation/constaint/slider.js +3 -1
- package/dist/alg/common.js +2 -2
- package/dist/alg/delaunay.js +1 -1
- package/dist/alg/extrude.js +52 -50
- package/dist/alg/pointset.js +5 -5
- package/dist/alg/trianglution.js +12 -10
- package/dist/alg/voronoi.js +1 -1
- package/dist/app.js +14 -10
- package/dist/diamondMaterialShader.js +6 -2
- package/dist/effect/breath-light.js +3 -1
- package/dist/extends/geometryaid.js +4 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -2
- package/dist/math/Color.d.ts +4 -0
- package/dist/math/Color.js +30 -6
- package/dist/math/Euler.js +9 -9
- package/dist/math/Mat3.js +1 -1
- package/dist/math/Mat4.js +6 -6
- package/dist/math/Quat.js +1 -1
- package/dist/math/Vec3.js +4 -4
- package/dist/math/vecs.js +9 -7
- package/dist/render/bufferAttribute.js +12 -28
- package/dist/render/geometry.js +2 -2
- package/dist/render/mesh.js +11 -9
- package/dist/render/types.d.ts +2 -2
- package/dist/render/types.js +2 -1
- package/dist/struct/3d/Box.js +3 -3
- package/dist/struct/3d/Capsule.js +3 -1
- package/dist/struct/3d/Circle.js +2 -2
- package/dist/struct/3d/Disk.js +1 -1
- package/dist/struct/3d/Line.js +5 -4
- package/dist/struct/3d/Path.js +13 -11
- package/dist/struct/3d/Plane.d.ts +3 -3
- package/dist/struct/3d/Plane.js +23 -18
- package/dist/struct/3d/Point.js +3 -1
- package/dist/struct/3d/Polygon.js +3 -1
- package/dist/struct/3d/Polyline.d.ts +9 -0
- package/dist/struct/3d/Polyline.js +25 -2
- package/dist/struct/3d/Rectangle.js +3 -1
- package/dist/struct/3d/Segment.js +9 -7
- package/dist/struct/3d/Shape.js +3 -1
- package/dist/struct/3d/Sphere.js +1 -1
- package/dist/struct/3d/Triangle.js +3 -1
- package/dist/struct/bsp.d.ts +0 -0
- package/dist/struct/bsp.js +1 -0
- package/dist/struct/btree.d.ts +0 -0
- package/dist/struct/btree.js +1 -0
- package/dist/struct/data/ArrayList.js +11 -9
- package/dist/struct/data/ArrayObject.js +3 -1
- package/dist/struct/kdtree.d.ts +0 -0
- package/dist/struct/kdtree.js +1 -0
- package/dist/struct/polyTree.d.ts +4 -0
- package/dist/struct/polyTree.js +27 -0
- package/dist/struct/quatTree.d.ts +0 -0
- package/dist/struct/quatTree.js +1 -0
- package/dist/struct/tree.d.ts +11 -0
- package/dist/struct/tree.js +26 -0
- package/dist/utils/types.d.ts +2 -2
- package/package.json +4 -3
- package/rollup.config.js +22 -14
- package/src/index.ts +1 -0
- package/src/math/Color.ts +6 -0
- package/src/struct/3d/Line.ts +1 -1
- package/src/struct/3d/Plane.ts +15 -11
- package/src/struct/3d/PolyLine.ts +18 -1
- package/src/struct/3d/Polygon.ts +2 -0
- package/src/struct/bsp.ts +0 -0
- package/src/struct/btree.ts +0 -0
- package/src/struct/kdtree.ts +0 -0
- package/src/struct/polyTree.ts +8 -0
- package/src/struct/quatTree.ts +0 -0
- package/src/struct/tree.ts +30 -0
- package/tsconfig.json +2 -0
- package/dist/shape/arc.d.ts +0 -2
- package/dist/shape/arc.js +0 -14
package/dist/struct/3d/Plane.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
8
10
|
};
|
|
9
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
12
|
exports.Plane = void 0;
|
|
@@ -68,9 +70,9 @@ var Plane = /** @class */ (function () {
|
|
|
68
70
|
*/
|
|
69
71
|
Plane.prototype.frontback = function (point) {
|
|
70
72
|
var value = this.normal.dot(point);
|
|
71
|
-
if (Math_1.approximateEqual(value, 0))
|
|
73
|
+
if ((0, Math_1.approximateEqual)(value, 0))
|
|
72
74
|
return 0;
|
|
73
|
-
return Math_1.sign(this.normal.dot(point));
|
|
75
|
+
return (0, Math_1.sign)(this.normal.dot(point));
|
|
74
76
|
};
|
|
75
77
|
//---Distance-------------------------------------------------------------------------------
|
|
76
78
|
Plane.prototype.distancePoint = function (point) {
|
|
@@ -220,22 +222,25 @@ var Plane = /** @class */ (function () {
|
|
|
220
222
|
};
|
|
221
223
|
/**
|
|
222
224
|
* 平面切割线段
|
|
223
|
-
* @param
|
|
225
|
+
* @param polygon
|
|
224
226
|
*/
|
|
225
|
-
Plane.prototype.
|
|
226
|
-
|
|
227
|
-
mesh_1.MeshTool.indexable(
|
|
227
|
+
Plane.prototype.splitConvexPolygon = function (polygon) {
|
|
228
|
+
polygon = __spreadArray([], polygon, true);
|
|
229
|
+
mesh_1.MeshTool.indexable(polygon);
|
|
228
230
|
var jd0 = -1; //找出第一个交点
|
|
229
231
|
var jdp0; //找出第一个交点
|
|
230
|
-
var lastOriention = this.orientationPoint(
|
|
231
|
-
|
|
232
|
-
|
|
232
|
+
var lastOriention = this.orientationPoint(polygon[0]);
|
|
233
|
+
var plen = polygon.length;
|
|
234
|
+
//分割点
|
|
235
|
+
var splitPoints = [];
|
|
236
|
+
var pVs = [];
|
|
237
|
+
var nVs = [];
|
|
238
|
+
for (var i = 1; i <= plen; i++) {
|
|
239
|
+
var v = polygon[i % plen];
|
|
233
240
|
var oriention = this.orientationPoint(v);
|
|
234
|
-
if (oriention === type_1.Orientation.Common
|
|
241
|
+
if (oriention === type_1.Orientation.Common) {
|
|
235
242
|
jd0 = i;
|
|
236
243
|
jdp0 = v.clone();
|
|
237
|
-
lastOriention = oriention;
|
|
238
|
-
break;
|
|
239
244
|
}
|
|
240
245
|
lastOriention = oriention;
|
|
241
246
|
//TODO
|
package/dist/struct/3d/Point.js
CHANGED
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -2,6 +2,12 @@ import { EndType, JoinType } from "../../alg/extrude";
|
|
|
2
2
|
import { Vec3 } from '../../math/Vec3';
|
|
3
3
|
import { ArrayList } from '../data/ArrayList';
|
|
4
4
|
import { Polygon } from "./Polygon";
|
|
5
|
+
export declare enum ClipType {
|
|
6
|
+
Intersection = 0,
|
|
7
|
+
Union = 1,
|
|
8
|
+
Difference = 2,
|
|
9
|
+
Xor = 3
|
|
10
|
+
}
|
|
5
11
|
/**
|
|
6
12
|
* 线段正反原则:右手坐标系中,所在平面为XZ平面,把指向方向看着负Z轴,x正为正方向,x负为负方向
|
|
7
13
|
*/
|
|
@@ -10,6 +16,9 @@ export declare class Polyline<T> extends ArrayList<T> {
|
|
|
10
16
|
isPolyline: boolean;
|
|
11
17
|
normal: Vec3;
|
|
12
18
|
constructor(vs?: Array<T> | Polyline<T> | Polygon<T>, normal?: Vec3);
|
|
19
|
+
static CleanPolygon(polys: any, delta: number, jointype: JoinType | undefined, endtype: EndType | undefined, limit: number): void;
|
|
20
|
+
static OffsetPaths(polys: any, delta: number, jointype: JoinType | undefined, endtype: EndType | undefined, limit: number): void;
|
|
21
|
+
static SimplifyPolygon(polys: any, delta: number, jointype: JoinType | undefined, endtype: EndType | undefined, limit: number): void;
|
|
13
22
|
/**
|
|
14
23
|
* 偏移
|
|
15
24
|
* @param {Number} distance 偏移距离
|
|
@@ -3,23 +3,33 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
15
|
};
|
|
14
16
|
})();
|
|
15
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.Polyline = void 0;
|
|
18
|
+
exports.Polyline = exports.ClipType = void 0;
|
|
17
19
|
var extrude_1 = require("../../alg/extrude");
|
|
18
20
|
var Math_1 = require("../../math/Math");
|
|
19
21
|
var Vec3_1 = require("../../math/Vec3");
|
|
20
22
|
var Line_1 = require("./Line");
|
|
21
23
|
var Segment_1 = require("./Segment");
|
|
22
24
|
var ArrayList_1 = require("../data/ArrayList");
|
|
25
|
+
var ClipType;
|
|
26
|
+
(function (ClipType) {
|
|
27
|
+
ClipType[ClipType["Intersection"] = 0] = "Intersection";
|
|
28
|
+
ClipType[ClipType["Union"] = 1] = "Union";
|
|
29
|
+
ClipType[ClipType["Difference"] = 2] = "Difference";
|
|
30
|
+
ClipType[ClipType["Xor"] = 3] = "Xor";
|
|
31
|
+
})(ClipType = exports.ClipType || (exports.ClipType = {}));
|
|
32
|
+
;
|
|
23
33
|
/**
|
|
24
34
|
* 线段正反原则:右手坐标系中,所在平面为XZ平面,把指向方向看着负Z轴,x正为正方向,x负为负方向
|
|
25
35
|
*/
|
|
@@ -33,6 +43,19 @@ var Polyline = /** @class */ (function (_super) {
|
|
|
33
43
|
_this.isCoPlanar = true;
|
|
34
44
|
return _this;
|
|
35
45
|
}
|
|
46
|
+
Polyline.CleanPolygon = function (polys, delta, jointype, endtype, limit) {
|
|
47
|
+
if (jointype === void 0) { jointype = extrude_1.JoinType.Square; }
|
|
48
|
+
if (endtype === void 0) { endtype = extrude_1.EndType.etClosedPolygon; }
|
|
49
|
+
};
|
|
50
|
+
Polyline.OffsetPaths = function (polys, delta, jointype, endtype, limit) {
|
|
51
|
+
if (jointype === void 0) { jointype = extrude_1.JoinType.Square; }
|
|
52
|
+
if (endtype === void 0) { endtype = extrude_1.EndType.etClosedPolygon; }
|
|
53
|
+
};
|
|
54
|
+
//转化为简单多边形 (无重复点,无相交的边 )不自交多边形
|
|
55
|
+
Polyline.SimplifyPolygon = function (polys, delta, jointype, endtype, limit) {
|
|
56
|
+
if (jointype === void 0) { jointype = extrude_1.JoinType.Square; }
|
|
57
|
+
if (endtype === void 0) { endtype = extrude_1.EndType.etClosedPolygon; }
|
|
58
|
+
};
|
|
36
59
|
/**
|
|
37
60
|
* 偏移
|
|
38
61
|
* @param {Number} distance 偏移距离
|
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -23,16 +25,16 @@ var Segment = /** @class */ (function (_super) {
|
|
|
23
25
|
* @param {Point|Vec3} p1
|
|
24
26
|
*/
|
|
25
27
|
function Segment(_p0, _p1) {
|
|
26
|
-
if (_p0 === void 0) { _p0 = Vec3_1.v3(); }
|
|
27
|
-
if (_p1 === void 0) { _p1 = Vec3_1.v3(); }
|
|
28
|
+
if (_p0 === void 0) { _p0 = (0, Vec3_1.v3)(); }
|
|
29
|
+
if (_p1 === void 0) { _p1 = (0, Vec3_1.v3)(); }
|
|
28
30
|
var _this = _super.call(this) || this;
|
|
29
31
|
Object.setPrototypeOf(_this, Segment.prototype);
|
|
30
|
-
_this.push(Vec3_1.v3().copy(_p0), Vec3_1.v3().copy(_p1));
|
|
31
|
-
_this.center = Vec3_1.v3().addVecs(_p0, _p1).multiplyScalar(0.5);
|
|
32
|
-
_this.extentDirection = Vec3_1.v3().subVecs(_p1, _p0);
|
|
32
|
+
_this.push((0, Vec3_1.v3)().copy(_p0), (0, Vec3_1.v3)().copy(_p1));
|
|
33
|
+
_this.center = (0, Vec3_1.v3)().addVecs(_p0, _p1).multiplyScalar(0.5);
|
|
34
|
+
_this.extentDirection = (0, Vec3_1.v3)().subVecs(_p1, _p0);
|
|
33
35
|
_this.extentSqr = _this.extentDirection.lengthSq();
|
|
34
36
|
_this.extent = Math.sqrt(_this.extentSqr);
|
|
35
|
-
_this.direction = Vec3_1.v3().copy(_this.extentDirection).normalize();
|
|
37
|
+
_this.direction = (0, Vec3_1.v3)().copy(_this.extentDirection).normalize();
|
|
36
38
|
return _this;
|
|
37
39
|
}
|
|
38
40
|
Segment.prototype.set = function (p0, p1) {
|
package/dist/struct/3d/Shape.js
CHANGED
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
package/dist/struct/3d/Sphere.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.Sphere = void 0;
|
|
|
4
4
|
var Vec3_1 = require("../../math/Vec3");
|
|
5
5
|
var Sphere = /** @class */ (function () {
|
|
6
6
|
function Sphere(center, radius) {
|
|
7
|
-
if (center === void 0) { center = Vec3_1.v3(); }
|
|
7
|
+
if (center === void 0) { center = (0, Vec3_1.v3)(); }
|
|
8
8
|
if (radius === void 0) { radius = 0; }
|
|
9
9
|
this.center = center;
|
|
10
10
|
this.radius = radius;
|
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
8
10
|
};
|
|
9
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
12
|
exports.ArrayList = void 0;
|
|
@@ -83,7 +85,7 @@ var ArrayList = /** @class */ (function () {
|
|
|
83
85
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
84
86
|
value[_i - 1] = arguments[_i];
|
|
85
87
|
}
|
|
86
|
-
(_a = this._array).splice.apply(_a,
|
|
88
|
+
(_a = this._array).splice.apply(_a, __spreadArray([i, 0], value, false));
|
|
87
89
|
};
|
|
88
90
|
ArrayList.prototype.splice = function (start, deleteCount) {
|
|
89
91
|
var _a;
|
|
@@ -91,7 +93,7 @@ var ArrayList = /** @class */ (function () {
|
|
|
91
93
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
92
94
|
items[_i - 2] = arguments[_i];
|
|
93
95
|
}
|
|
94
|
-
(_a = this._array).splice.apply(_a,
|
|
96
|
+
(_a = this._array).splice.apply(_a, __spreadArray([start, deleteCount], items, false));
|
|
95
97
|
};
|
|
96
98
|
ArrayList.prototype.get = function (index) {
|
|
97
99
|
if (index < 0)
|
|
@@ -111,7 +113,7 @@ var ArrayList = /** @class */ (function () {
|
|
|
111
113
|
* 克隆
|
|
112
114
|
*/
|
|
113
115
|
ArrayList.prototype.clone = function () {
|
|
114
|
-
return new this.constructor(common_1.clone(this._array));
|
|
116
|
+
return new this.constructor((0, common_1.clone)(this._array));
|
|
115
117
|
};
|
|
116
118
|
/**
|
|
117
119
|
* 分类
|
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.PolyTree = void 0;
|
|
19
|
+
var tree_1 = require("./tree");
|
|
20
|
+
var PolyTree = /** @class */ (function (_super) {
|
|
21
|
+
__extends(PolyTree, _super);
|
|
22
|
+
function PolyTree() {
|
|
23
|
+
return _super.call(this) || this;
|
|
24
|
+
}
|
|
25
|
+
return PolyTree;
|
|
26
|
+
}(tree_1.Tree));
|
|
27
|
+
exports.PolyTree = PolyTree;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class Tree {
|
|
2
|
+
N: number;
|
|
3
|
+
children: this[];
|
|
4
|
+
findFn: Function;
|
|
5
|
+
objects: any[];
|
|
6
|
+
constructor(N?: number);
|
|
7
|
+
setObject(obj: any, generateFn: Function, findFn: Function): void;
|
|
8
|
+
add(obj: any): void;
|
|
9
|
+
remove(obj: any): void;
|
|
10
|
+
find(condition: any): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Tree = void 0;
|
|
4
|
+
var Tree = /** @class */ (function () {
|
|
5
|
+
function Tree(N) {
|
|
6
|
+
if (N === void 0) { N = -1; }
|
|
7
|
+
this.N = 2; //数量决定是N叉树;
|
|
8
|
+
this.objects = [];
|
|
9
|
+
this.N = N;
|
|
10
|
+
if (N !== -1)
|
|
11
|
+
this.children = new Array(N);
|
|
12
|
+
}
|
|
13
|
+
Tree.prototype.setObject = function (obj, generateFn, findFn) {
|
|
14
|
+
generateFn(this, obj);
|
|
15
|
+
this.findFn = findFn;
|
|
16
|
+
};
|
|
17
|
+
Tree.prototype.add = function (obj) {
|
|
18
|
+
};
|
|
19
|
+
Tree.prototype.remove = function (obj) {
|
|
20
|
+
};
|
|
21
|
+
Tree.prototype.find = function (condition) {
|
|
22
|
+
this.findFn(this, condition);
|
|
23
|
+
};
|
|
24
|
+
return Tree;
|
|
25
|
+
}());
|
|
26
|
+
exports.Tree = Tree;
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -13,11 +13,11 @@ export interface INumberDictionary<T> {
|
|
|
13
13
|
/**
|
|
14
14
|
* Defines a member that can have a value or be null.
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export type Nullable<T> = null | T;
|
|
17
17
|
/**
|
|
18
18
|
* Defines a member that can have a value or be undefined.
|
|
19
19
|
*/
|
|
20
|
-
export
|
|
20
|
+
export type Undefinable<T> = undefined | T;
|
|
21
21
|
export declare function isDefined(value: any): boolean;
|
|
22
22
|
export declare function isUndefined(value: any): boolean;
|
|
23
23
|
export declare function isFinite(value: any): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xort/cga",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.88",
|
|
4
4
|
"description": "Xtor Compute Geometry Algorithm Libary 计算几何算法库",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"gis"
|
|
36
36
|
],
|
|
37
37
|
"license": "MIT",
|
|
38
|
-
"dependencies": {
|
|
38
|
+
"dependencies": {
|
|
39
39
|
"decimal.js": "^10.3.1",
|
|
40
40
|
"earcut": "^2.2.3"
|
|
41
41
|
},
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"rollup": "^1.27.14",
|
|
56
56
|
"rollup-plugin-babel": "^4.3.3",
|
|
57
57
|
"rollup-plugin-commonjs": "^10.1.0",
|
|
58
|
+
"rollup-plugin-dts": "^5.0.0",
|
|
58
59
|
"rollup-plugin-gzip": "^2.2.0",
|
|
59
60
|
"rollup-plugin-node-resolve": "^5.0.1",
|
|
60
61
|
"rollup-plugin-uglify": "^6.0.4",
|
|
@@ -64,7 +65,7 @@
|
|
|
64
65
|
"ts-loader": "^7.0.4",
|
|
65
66
|
"tsconfig-paths": "^3.9.0",
|
|
66
67
|
"tsconfig-paths-webpack-plugin": "3.2.0",
|
|
67
|
-
"typescript": "^
|
|
68
|
+
"typescript": "^4.9.4",
|
|
68
69
|
"vuepress": "^1.9.7",
|
|
69
70
|
"webpack": "^4.43.0",
|
|
70
71
|
"webpack-cli": "^3.3.11",
|
package/rollup.config.js
CHANGED
|
@@ -13,6 +13,7 @@ import gzip from 'rollup-plugin-gzip';
|
|
|
13
13
|
import nodeResolve from 'rollup-plugin-node-resolve';
|
|
14
14
|
import path from 'path';
|
|
15
15
|
import { uglify } from 'rollup-plugin-uglify';
|
|
16
|
+
import dts from "rollup-plugin-dts";
|
|
16
17
|
|
|
17
18
|
// Read package config
|
|
18
19
|
const pkgConfig = require('./package.json');
|
|
@@ -55,17 +56,24 @@ if (MIN) {
|
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
export default {
|
|
58
|
-
input: path.join('dist', 'index.js'),
|
|
59
|
-
external: ['lodash'],
|
|
60
|
-
plugins: plugins,
|
|
61
|
-
output: {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
59
|
+
// input: path.join('dist', 'index.js'),
|
|
60
|
+
// external: ['lodash'],
|
|
61
|
+
// plugins: plugins,
|
|
62
|
+
// output: {
|
|
63
|
+
// file: path.join(DIST ? 'dist' : 'build', '@xort_cga' + (MIN ? '.min' : '') + '.js'),
|
|
64
|
+
// format: 'umd',
|
|
65
|
+
// // format: 'umd',
|
|
66
|
+
// name: 'cga',
|
|
67
|
+
// banner: banner,
|
|
68
|
+
// globals: {
|
|
69
|
+
// lodash: '_'
|
|
70
|
+
// }
|
|
71
|
+
// }
|
|
72
|
+
|
|
73
|
+
input: "dist/index.d.ts",
|
|
74
|
+
output: [{
|
|
75
|
+
file: "build/cga.d.ts", format: "es",
|
|
76
|
+
name: 'cga'
|
|
77
|
+
}],
|
|
78
|
+
plugins: [dts()],
|
|
79
|
+
}
|
package/src/index.ts
CHANGED
package/src/math/Color.ts
CHANGED
|
@@ -216,4 +216,10 @@ export class Color {
|
|
|
216
216
|
return this.getHexCssString();
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
+
|
|
220
|
+
static get White() { return Object.freeze( new Color(1, 1, 1)) };
|
|
221
|
+
static get Red() { return new Color(1, 0, 0) };
|
|
222
|
+
static get Green() { return new Color(0, 1, 0) };
|
|
223
|
+
static get Blue() { return new Color(0, 0, 1) };
|
|
224
|
+
|
|
219
225
|
}
|
package/src/struct/3d/Line.ts
CHANGED
package/src/struct/3d/Plane.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { IGeometry } from '../../render/geometry';
|
|
|
15
15
|
import { ISplitResult } from '../../alg/split';
|
|
16
16
|
import { Line } from './Line';
|
|
17
17
|
import { MeshTool } from '../../render/mesh';
|
|
18
|
+
import { Polygon } from './Polygon';
|
|
18
19
|
|
|
19
20
|
class Plane {
|
|
20
21
|
|
|
@@ -253,23 +254,26 @@ class Plane {
|
|
|
253
254
|
|
|
254
255
|
/**
|
|
255
256
|
* 平面切割线段
|
|
256
|
-
* @param
|
|
257
|
+
* @param polygon
|
|
257
258
|
*/
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
MeshTool.indexable(
|
|
259
|
+
splitConvexPolygon(polygon: Vec3[]) {
|
|
260
|
+
polygon = [...polygon];
|
|
261
|
+
MeshTool.indexable(polygon);
|
|
261
262
|
|
|
262
263
|
let jd0 = -1;//找出第一个交点
|
|
263
264
|
let jdp0: any;//找出第一个交点
|
|
264
|
-
let lastOriention = this.orientationPoint(
|
|
265
|
-
|
|
266
|
-
|
|
265
|
+
let lastOriention = this.orientationPoint(polygon[0]);
|
|
266
|
+
const plen = polygon.length;
|
|
267
|
+
//分割点
|
|
268
|
+
const splitPoints = [];
|
|
269
|
+
const pVs = [];
|
|
270
|
+
const nVs = [];
|
|
271
|
+
for (let i = 1; i <= plen; i++) {
|
|
272
|
+
const v = polygon[i % plen];
|
|
267
273
|
const oriention = this.orientationPoint(v);
|
|
268
|
-
if (oriention === Orientation.Common
|
|
274
|
+
if (oriention === Orientation.Common ) {
|
|
269
275
|
jd0 = i;
|
|
270
|
-
jdp0 = v.clone();
|
|
271
|
-
lastOriention = oriention;
|
|
272
|
-
break;
|
|
276
|
+
jdp0 = v.clone();
|
|
273
277
|
}
|
|
274
278
|
lastOriention = oriention;
|
|
275
279
|
//TODO
|
|
@@ -6,7 +6,12 @@ import { Segment } from "./Segment";
|
|
|
6
6
|
import { ArrayList } from '../data/ArrayList';
|
|
7
7
|
import { Polygon } from "./Polygon";
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
export enum ClipType {
|
|
10
|
+
Intersection = 0,
|
|
11
|
+
Union = 1,
|
|
12
|
+
Difference = 2,
|
|
13
|
+
Xor = 3
|
|
14
|
+
};
|
|
10
15
|
/**
|
|
11
16
|
* 线段正反原则:右手坐标系中,所在平面为XZ平面,把指向方向看着负Z轴,x正为正方向,x负为负方向
|
|
12
17
|
*/
|
|
@@ -20,6 +25,18 @@ export class Polyline<T> extends ArrayList<T> {
|
|
|
20
25
|
this.isCoPlanar = true;
|
|
21
26
|
}
|
|
22
27
|
|
|
28
|
+
static CleanPolygon(polys: any, delta: number, jointype: JoinType = JoinType.Square, endtype: EndType = EndType.etClosedPolygon, limit: number) {
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
static OffsetPaths(polys: any, delta: number, jointype: JoinType = JoinType.Square, endtype: EndType = EndType.etClosedPolygon, limit: number) {
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//转化为简单多边形 (无重复点,无相交的边 )不自交多边形
|
|
36
|
+
static SimplifyPolygon(polys: any, delta: number, jointype: JoinType = JoinType.Square, endtype: EndType = EndType.etClosedPolygon, limit: number) {
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
23
40
|
/**
|
|
24
41
|
* 偏移
|
|
25
42
|
* @param {Number} distance 偏移距离
|