@xort/cga 0.0.85 → 0.0.87
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.d.ts +12 -3
- package/dist/struct/3d/Circle.js +34 -6
- package/dist/struct/3d/Disk.js +1 -1
- package/dist/struct/3d/Line.js +4 -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/Circle.ts +37 -8
- 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/src/shape/arc.ts +0 -14
package/dist/struct/3d/Path.js
CHANGED
|
@@ -10,10 +10,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
10
10
|
var extendStatics = function (d, b) {
|
|
11
11
|
extendStatics = Object.setPrototypeOf ||
|
|
12
12
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
13
|
-
function (d, b) { for (var p in b) if (
|
|
13
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
14
14
|
return extendStatics(d, b);
|
|
15
15
|
};
|
|
16
16
|
return function (d, b) {
|
|
17
|
+
if (typeof b !== "function" && b !== null)
|
|
18
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
17
19
|
extendStatics(d, b);
|
|
18
20
|
function __() { this.constructor = d; }
|
|
19
21
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -73,15 +75,15 @@ var Path = /** @class */ (function (_super) {
|
|
|
73
75
|
var normal = new Vec3_1.Vec3();
|
|
74
76
|
normal.crossVecs(d1, d2).normalize();
|
|
75
77
|
this.get(i).normal = normal;
|
|
76
|
-
var bdir = Vec3_1.v3().addVecs(d1, d2).normalize();
|
|
78
|
+
var bdir = (0, Vec3_1.v3)().addVecs(d1, d2).normalize();
|
|
77
79
|
this.get(i).bdirection = bdir;
|
|
78
|
-
this.get(i).bnormal = Vec3_1.v3().crossVecs(bdir, normal).normalize();
|
|
80
|
+
this.get(i).bnormal = (0, Vec3_1.v3)().crossVecs(bdir, normal).normalize();
|
|
79
81
|
// }
|
|
80
82
|
}
|
|
81
83
|
if (!this._closed) { //不闭合路径 最后一个点没有
|
|
82
|
-
this.get(-1).bdirection = Vec3_1.v3();
|
|
83
|
-
this.get(-1).normal = Vec3_1.v3();
|
|
84
|
-
this.get(-1).bnormal = Vec3_1.v3();
|
|
84
|
+
this.get(-1).bdirection = (0, Vec3_1.v3)();
|
|
85
|
+
this.get(-1).normal = (0, Vec3_1.v3)();
|
|
86
|
+
this.get(-1).bnormal = (0, Vec3_1.v3)();
|
|
85
87
|
}
|
|
86
88
|
if (!this._closed) {
|
|
87
89
|
// 不闭合的情况下怎么样去计算端点的up和normal
|
|
@@ -116,10 +118,10 @@ var Path = /** @class */ (function (_super) {
|
|
|
116
118
|
configurable: true
|
|
117
119
|
});
|
|
118
120
|
Path.prototype.applyMat4 = function (mat4) {
|
|
119
|
-
pointset_1.applyMat4(this._array, mat4);
|
|
121
|
+
(0, pointset_1.applyMat4)(this._array, mat4);
|
|
120
122
|
};
|
|
121
123
|
Path.prototype.scale = function (x, y, z) {
|
|
122
|
-
common_1.scale(this._array, Vec3_1.v3(x, y, z), true);
|
|
124
|
+
(0, common_1.scale)(this._array, (0, Vec3_1.v3)(x, y, z), true);
|
|
123
125
|
};
|
|
124
126
|
/**
|
|
125
127
|
* 截取一段从from到to的path
|
|
@@ -157,7 +159,7 @@ var Path = /** @class */ (function (_super) {
|
|
|
157
159
|
Path.prototype.getPointByDistance = function (arg_distance, left, right) {
|
|
158
160
|
if (left === void 0) { left = 0; }
|
|
159
161
|
if (right === void 0) { right = this.length - 1; }
|
|
160
|
-
var distance = Math_1.clamp(arg_distance, 0, this.get(-1).tlen);
|
|
162
|
+
var distance = (0, Math_1.clamp)(arg_distance, 0, this.get(-1).tlen);
|
|
161
163
|
if (distance !== arg_distance)
|
|
162
164
|
return null;
|
|
163
165
|
if (right - left === 1) {
|
|
@@ -186,7 +188,7 @@ var Path = /** @class */ (function (_super) {
|
|
|
186
188
|
Path.prototype.getPointByDistancePure = function (arg_distance, left, right) {
|
|
187
189
|
if (left === void 0) { left = 0; }
|
|
188
190
|
if (right === void 0) { right = this.length - 1; }
|
|
189
|
-
var distance = Math_1.clamp(arg_distance, 0, this.get(-1).tlen);
|
|
191
|
+
var distance = (0, Math_1.clamp)(arg_distance, 0, this.get(-1).tlen);
|
|
190
192
|
if (distance !== arg_distance)
|
|
191
193
|
return null;
|
|
192
194
|
if (right - left === 1) {
|
|
@@ -294,7 +296,7 @@ var Path = /** @class */ (function (_super) {
|
|
|
294
296
|
res.push(mileages);
|
|
295
297
|
}
|
|
296
298
|
if (normalize) {
|
|
297
|
-
var tl = types_1.isDefined(totalMileage) ? totalMileage : this.totalMileages(ps);
|
|
299
|
+
var tl = (0, types_1.isDefined)(totalMileage) ? totalMileage : this.totalMileages(ps);
|
|
298
300
|
for (var i = 0, len = ps.length; i < len; i++) {
|
|
299
301
|
res[i] /= tl;
|
|
300
302
|
}
|
|
@@ -22,7 +22,7 @@ declare class Plane {
|
|
|
22
22
|
* @param {Vec3} point
|
|
23
23
|
* @returns {Number} -1 or 1 or z
|
|
24
24
|
*/
|
|
25
|
-
frontback(point: any):
|
|
25
|
+
frontback(point: any): 0 | 1 | -1;
|
|
26
26
|
distancePoint(point: any): number;
|
|
27
27
|
distanceRay(ray: any): void;
|
|
28
28
|
distanceLine(line: any): void;
|
|
@@ -53,9 +53,9 @@ declare class Plane {
|
|
|
53
53
|
splitTriangle(triangle: Triangle | Vec3[]): ISplitResult;
|
|
54
54
|
/**
|
|
55
55
|
* 平面切割线段
|
|
56
|
-
* @param
|
|
56
|
+
* @param polygon
|
|
57
57
|
*/
|
|
58
|
-
|
|
58
|
+
splitConvexPolygon(polygon: Vec3[]): void;
|
|
59
59
|
/**
|
|
60
60
|
* 点在平面的位置判断
|
|
61
61
|
* @param {Point} point
|
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.87",
|
|
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
|
}
|