@xort/cga 0.0.74 → 0.0.77
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/IKanimation/Bone.js +1 -3
- package/dist/IKanimation/CCDSolver.js +2 -2
- package/dist/IKanimation/constaint/hinge.js +1 -3
- package/dist/IKanimation/constaint/slider.js +1 -3
- package/dist/alg/common.js +2 -2
- package/dist/alg/extrude.js +54 -56
- package/dist/alg/pointset.js +5 -5
- package/dist/alg/trianglution.js +10 -12
- package/dist/app.js +10 -14
- package/dist/diamondMaterialShader.js +2 -6
- package/dist/effect/breath-light.js +1 -3
- package/dist/extends/geometryaid.js +7 -7
- package/dist/index.js +2 -6
- package/dist/math/Color.d.ts +2 -5
- package/dist/math/Color.js +3 -52
- package/dist/math/Euler.js +10 -12
- package/dist/math/HVec3.js +1 -3
- package/dist/math/Mat3.js +1 -1
- package/dist/math/Mat4.js +6 -6
- package/dist/math/Quat.js +2 -4
- package/dist/math/Vec.js +1 -3
- package/dist/math/Vec2.js +1 -3
- package/dist/math/Vec3.js +5 -7
- package/dist/math/Vec4.js +1 -3
- package/dist/math/vector.js +7 -9
- package/dist/render/buffer-attribute.js +28 -12
- package/dist/render/eventhandler.d.ts +1 -1
- package/dist/render/eventhandler.js +7 -9
- package/dist/render/geometry.js +2 -2
- package/dist/render/mesh.js +9 -11
- package/dist/render/thing.js +8 -10
- package/dist/render/types.js +1 -2
- package/dist/struct/3d/Box.js +3 -3
- package/dist/struct/3d/Capsule.js +1 -3
- package/dist/struct/3d/Circle.js +2 -2
- package/dist/struct/3d/Disk.js +1 -1
- package/dist/struct/3d/Line.js +4 -4
- package/dist/struct/3d/Path.js +11 -13
- package/dist/struct/3d/Plane.js +10 -12
- package/dist/struct/3d/Point.js +1 -3
- package/dist/struct/3d/Polygon.js +1 -3
- package/dist/struct/3d/Polyline.js +1 -3
- package/dist/struct/3d/Rectangle.js +1 -3
- package/dist/struct/3d/Segment.js +7 -9
- package/dist/struct/3d/Shape.js +1 -3
- package/dist/struct/3d/Sphere.js +1 -1
- package/dist/struct/3d/Triangle.js +1 -3
- package/dist/struct/data/ArrayList.js +9 -11
- package/dist/struct/data/ArrayObject.js +1 -3
- package/package.json +4 -3
- package/src/math/Color.ts +6 -31
package/dist/struct/3d/Box.js
CHANGED
|
@@ -5,9 +5,9 @@ var Vec3_1 = require("../../math/Vec3");
|
|
|
5
5
|
var _vector = new Vec3_1.Vec3();
|
|
6
6
|
var Box = /** @class */ (function () {
|
|
7
7
|
function Box(min, max) {
|
|
8
|
-
if (min === void 0) { min =
|
|
9
|
-
if (max === void 0) { max =
|
|
10
|
-
this._center =
|
|
8
|
+
if (min === void 0) { min = Vec3_1.v3(Infinity, Infinity, Infinity); }
|
|
9
|
+
if (max === void 0) { max = Vec3_1.v3(-Infinity, -Infinity, -Infinity); }
|
|
10
|
+
this._center = Vec3_1.v3();
|
|
11
11
|
this.min = min;
|
|
12
12
|
this.max = max;
|
|
13
13
|
// if (points) {
|
|
@@ -3,12 +3,10 @@ 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 (b.hasOwnProperty(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");
|
|
12
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
package/dist/struct/3d/Circle.js
CHANGED
|
@@ -35,7 +35,7 @@ var Circle = /** @class */ (function () {
|
|
|
35
35
|
Circle.prototype.arc1 = function (fixp0, fixp1, movep, normal) {
|
|
36
36
|
this.setFrom3Points(fixp0, fixp1, movep);
|
|
37
37
|
this.startAngle = 0;
|
|
38
|
-
this.endAngle =
|
|
38
|
+
this.endAngle = common_1.angle(fixp0.clone().sub(this.center).normalize(), fixp1.clone().sub(this.center).normalize(), this.normal || normal);
|
|
39
39
|
};
|
|
40
40
|
/**
|
|
41
41
|
* 全两个点确定半径,后面点确定 弧度 ,只需要检测鼠标移动时鼠标是否跨过第一条半径即可确定顺逆时针
|
|
@@ -49,7 +49,7 @@ var Circle = /** @class */ (function () {
|
|
|
49
49
|
this.center.copy(center);
|
|
50
50
|
var v2 = movep.clone().sub(center);
|
|
51
51
|
var v1 = fixp1.clone().sub(center);
|
|
52
|
-
var jd =
|
|
52
|
+
var jd = common_1.angle(v1, v2);
|
|
53
53
|
};
|
|
54
54
|
Circle.prototype.setFrom3Points = function (p0, p1, p2, normal) {
|
|
55
55
|
// if (pointsCollinear(p0, p1, p2))
|
package/dist/struct/3d/Disk.js
CHANGED
|
@@ -5,7 +5,7 @@ var Vec3_1 = require("../../math/Vec3");
|
|
|
5
5
|
var Disk = /** @class */ (function () {
|
|
6
6
|
function Disk(center, radius, normal) {
|
|
7
7
|
if (normal === void 0) { normal = Vec3_1.Vec3.UnitY; }
|
|
8
|
-
this.center = center ||
|
|
8
|
+
this.center = center || Vec3_1.v3();
|
|
9
9
|
this.normal = normal;
|
|
10
10
|
this.radius = radius || 0;
|
|
11
11
|
this.w = this.normal.dot(center);
|
package/dist/struct/3d/Line.js
CHANGED
|
@@ -8,8 +8,8 @@ var _v1 = new Vec3_1.Vec3;
|
|
|
8
8
|
;
|
|
9
9
|
var Line = /** @class */ (function () {
|
|
10
10
|
function Line(origin, end) {
|
|
11
|
-
if (origin === void 0) { origin =
|
|
12
|
-
if (end === void 0) { end =
|
|
11
|
+
if (origin === void 0) { origin = Vec3_1.v3(); }
|
|
12
|
+
if (end === void 0) { end = Vec3_1.v3(); }
|
|
13
13
|
this.origin = origin;
|
|
14
14
|
this.end = end;
|
|
15
15
|
this.direction = this.end
|
|
@@ -192,10 +192,10 @@ var Line = /** @class */ (function () {
|
|
|
192
192
|
if (robust === void 0) { robust = false; }
|
|
193
193
|
if (numInputs === 1) {
|
|
194
194
|
if (Math.abs(v[0][0]) > Math.abs(v[0][1])) {
|
|
195
|
-
v[1] =
|
|
195
|
+
v[1] = Vec3_1.v3(-v[0].z, 0, +v[0].x);
|
|
196
196
|
}
|
|
197
197
|
else {
|
|
198
|
-
v[1] =
|
|
198
|
+
v[1] = Vec3_1.v3(0, +v[0].z, -v[0].y);
|
|
199
199
|
}
|
|
200
200
|
;
|
|
201
201
|
numInputs = 2;
|
package/dist/struct/3d/Path.js
CHANGED
|
@@ -10,12 +10,10 @@ 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 (b.hasOwnProperty(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");
|
|
19
17
|
extendStatics(d, b);
|
|
20
18
|
function __() { this.constructor = d; }
|
|
21
19
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -75,15 +73,15 @@ var Path = /** @class */ (function (_super) {
|
|
|
75
73
|
var normal = new Vec3_1.Vec3();
|
|
76
74
|
normal.crossVecs(d1, d2).normalize();
|
|
77
75
|
this.get(i).normal = normal;
|
|
78
|
-
var bdir =
|
|
76
|
+
var bdir = Vec3_1.v3().addVecs(d1, d2).normalize();
|
|
79
77
|
this.get(i).bdirection = bdir;
|
|
80
|
-
this.get(i).bnormal =
|
|
78
|
+
this.get(i).bnormal = Vec3_1.v3().crossVecs(bdir, normal).normalize();
|
|
81
79
|
// }
|
|
82
80
|
}
|
|
83
81
|
if (!this._closed) { //不闭合路径 最后一个点没有
|
|
84
|
-
this.get(-1).bdirection =
|
|
85
|
-
this.get(-1).normal =
|
|
86
|
-
this.get(-1).bnormal =
|
|
82
|
+
this.get(-1).bdirection = Vec3_1.v3();
|
|
83
|
+
this.get(-1).normal = Vec3_1.v3();
|
|
84
|
+
this.get(-1).bnormal = Vec3_1.v3();
|
|
87
85
|
}
|
|
88
86
|
if (!this._closed) {
|
|
89
87
|
// 不闭合的情况下怎么样去计算端点的up和normal
|
|
@@ -118,10 +116,10 @@ var Path = /** @class */ (function (_super) {
|
|
|
118
116
|
configurable: true
|
|
119
117
|
});
|
|
120
118
|
Path.prototype.applyMat4 = function (mat4) {
|
|
121
|
-
|
|
119
|
+
pointset_1.applyMat4(this._array, mat4);
|
|
122
120
|
};
|
|
123
121
|
Path.prototype.scale = function (x, y, z) {
|
|
124
|
-
|
|
122
|
+
common_1.scale(this._array, Vec3_1.v3(x, y, z), true);
|
|
125
123
|
};
|
|
126
124
|
/**
|
|
127
125
|
* 截取一段从from到to的path
|
|
@@ -159,7 +157,7 @@ var Path = /** @class */ (function (_super) {
|
|
|
159
157
|
Path.prototype.getPointByDistance = function (arg_distance, left, right) {
|
|
160
158
|
if (left === void 0) { left = 0; }
|
|
161
159
|
if (right === void 0) { right = this.length - 1; }
|
|
162
|
-
var distance =
|
|
160
|
+
var distance = Math_1.clamp(arg_distance, 0, this.get(-1).tlen);
|
|
163
161
|
if (distance !== arg_distance)
|
|
164
162
|
return null;
|
|
165
163
|
if (right - left === 1) {
|
|
@@ -188,7 +186,7 @@ var Path = /** @class */ (function (_super) {
|
|
|
188
186
|
Path.prototype.getPointByDistancePure = function (arg_distance, left, right) {
|
|
189
187
|
if (left === void 0) { left = 0; }
|
|
190
188
|
if (right === void 0) { right = this.length - 1; }
|
|
191
|
-
var distance =
|
|
189
|
+
var distance = Math_1.clamp(arg_distance, 0, this.get(-1).tlen);
|
|
192
190
|
if (distance !== arg_distance)
|
|
193
191
|
return null;
|
|
194
192
|
if (right - left === 1) {
|
|
@@ -296,7 +294,7 @@ var Path = /** @class */ (function (_super) {
|
|
|
296
294
|
res.push(mileages);
|
|
297
295
|
}
|
|
298
296
|
if (normalize) {
|
|
299
|
-
var tl =
|
|
297
|
+
var tl = types_1.isDefined(totalMileage) ? totalMileage : this.totalMileages(ps);
|
|
300
298
|
for (var i = 0, len = ps.length; i < len; i++) {
|
|
301
299
|
res[i] /= tl;
|
|
302
300
|
}
|
package/dist/struct/3d/Plane.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
2
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
3
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
4
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
5
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
6
|
+
r[k] = a[j];
|
|
7
|
+
return r;
|
|
10
8
|
};
|
|
11
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
10
|
exports.Plane = void 0;
|
|
@@ -70,9 +68,9 @@ var Plane = /** @class */ (function () {
|
|
|
70
68
|
*/
|
|
71
69
|
Plane.prototype.frontback = function (point) {
|
|
72
70
|
var value = this.normal.dot(point);
|
|
73
|
-
if (
|
|
71
|
+
if (Math_1.approximateEqual(value, 0))
|
|
74
72
|
return 0;
|
|
75
|
-
return
|
|
73
|
+
return Math_1.sign(this.normal.dot(point));
|
|
76
74
|
};
|
|
77
75
|
//---Distance-------------------------------------------------------------------------------
|
|
78
76
|
Plane.prototype.distancePoint = function (point) {
|
|
@@ -225,8 +223,8 @@ var Plane = /** @class */ (function () {
|
|
|
225
223
|
* @param polyVS
|
|
226
224
|
*/
|
|
227
225
|
Plane.prototype.splitPolyVS = function (polyVS) {
|
|
228
|
-
polyVS =
|
|
229
|
-
|
|
226
|
+
polyVS = __spreadArrays(polyVS);
|
|
227
|
+
mesh_1.indexable(polyVS);
|
|
230
228
|
var jd0 = -1; //找出第一个交点
|
|
231
229
|
var jdp0; //找出第一个交点
|
|
232
230
|
var lastOriention = this.orientationPoint(polyVS[0]);
|
package/dist/struct/3d/Point.js
CHANGED
|
@@ -3,12 +3,10 @@ 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 (b.hasOwnProperty(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");
|
|
12
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -3,12 +3,10 @@ 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 (b.hasOwnProperty(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");
|
|
12
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -3,12 +3,10 @@ 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 (b.hasOwnProperty(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");
|
|
12
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -3,12 +3,10 @@ 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 (b.hasOwnProperty(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");
|
|
12
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -3,12 +3,10 @@ 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 (b.hasOwnProperty(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");
|
|
12
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -25,16 +23,16 @@ var Segment = /** @class */ (function (_super) {
|
|
|
25
23
|
* @param {Point|Vec3} p1
|
|
26
24
|
*/
|
|
27
25
|
function Segment(_p0, _p1) {
|
|
28
|
-
if (_p0 === void 0) { _p0 =
|
|
29
|
-
if (_p1 === void 0) { _p1 =
|
|
26
|
+
if (_p0 === void 0) { _p0 = Vec3_1.v3(); }
|
|
27
|
+
if (_p1 === void 0) { _p1 = Vec3_1.v3(); }
|
|
30
28
|
var _this = _super.call(this) || this;
|
|
31
29
|
Object.setPrototypeOf(_this, Segment.prototype);
|
|
32
|
-
_this.push(
|
|
33
|
-
_this.center =
|
|
34
|
-
_this.extentDirection =
|
|
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);
|
|
35
33
|
_this.extentSqr = _this.extentDirection.lengthSq();
|
|
36
34
|
_this.extent = Math.sqrt(_this.extentSqr);
|
|
37
|
-
_this.direction =
|
|
35
|
+
_this.direction = Vec3_1.v3().copy(_this.extentDirection).normalize();
|
|
38
36
|
return _this;
|
|
39
37
|
}
|
|
40
38
|
Segment.prototype.set = function (p0, p1) {
|
package/dist/struct/3d/Shape.js
CHANGED
|
@@ -3,12 +3,10 @@ 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 (b.hasOwnProperty(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");
|
|
12
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
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 =
|
|
7
|
+
if (center === void 0) { center = Vec3_1.v3(); }
|
|
8
8
|
if (radius === void 0) { radius = 0; }
|
|
9
9
|
this.center = center;
|
|
10
10
|
this.radius = radius;
|
|
@@ -3,12 +3,10 @@ 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 (b.hasOwnProperty(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");
|
|
12
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
2
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
3
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
4
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
5
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
6
|
+
r[k] = a[j];
|
|
7
|
+
return r;
|
|
10
8
|
};
|
|
11
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
10
|
exports.ArrayList = void 0;
|
|
@@ -85,7 +83,7 @@ var ArrayList = /** @class */ (function () {
|
|
|
85
83
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
86
84
|
value[_i - 1] = arguments[_i];
|
|
87
85
|
}
|
|
88
|
-
(_a = this._array).splice.apply(_a,
|
|
86
|
+
(_a = this._array).splice.apply(_a, __spreadArrays([i, 0], value));
|
|
89
87
|
};
|
|
90
88
|
ArrayList.prototype.splice = function (start, deleteCount) {
|
|
91
89
|
var _a;
|
|
@@ -93,7 +91,7 @@ var ArrayList = /** @class */ (function () {
|
|
|
93
91
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
94
92
|
items[_i - 2] = arguments[_i];
|
|
95
93
|
}
|
|
96
|
-
(_a = this._array).splice.apply(_a,
|
|
94
|
+
(_a = this._array).splice.apply(_a, __spreadArrays([start, deleteCount], items));
|
|
97
95
|
};
|
|
98
96
|
ArrayList.prototype.get = function (index) {
|
|
99
97
|
if (index < 0)
|
|
@@ -113,7 +111,7 @@ var ArrayList = /** @class */ (function () {
|
|
|
113
111
|
* 克隆
|
|
114
112
|
*/
|
|
115
113
|
ArrayList.prototype.clone = function () {
|
|
116
|
-
return new this.constructor(
|
|
114
|
+
return new this.constructor(common_1.clone(this._array));
|
|
117
115
|
};
|
|
118
116
|
/**
|
|
119
117
|
* 分类
|
|
@@ -3,12 +3,10 @@ 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 (b.hasOwnProperty(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");
|
|
12
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xort/cga",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.77",
|
|
4
4
|
"description": "Xtor Compute Geometry Algorithm Libary 计算几何算法库",
|
|
5
|
-
"main": "dist/
|
|
6
|
-
"types": "dist/
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
+
"pxy":"hpts -s 127.0.0.1:5006 -p 8002",
|
|
8
9
|
"release": "tsc && npm publish && git.sh",
|
|
9
10
|
"dev": "webpack-dev-server",
|
|
10
11
|
"build:dev": "webpack --mode development",
|
package/src/math/Color.ts
CHANGED
|
@@ -1,38 +1,14 @@
|
|
|
1
|
-
import { EventHandler } from "
|
|
2
|
-
import * as THREE from "three"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export function hue2rgb(p: number, q: number, t: number) {
|
|
6
|
-
|
|
7
|
-
if (t < 0) t += 1;
|
|
8
|
-
if (t > 1) t -= 1;
|
|
9
|
-
if (t < 1 / 6) return p + (q - p) * 6 * t;
|
|
10
|
-
if (t < 1 / 2) return q;
|
|
11
|
-
if (t < 2 / 3) return p + (q - p) * 6 * (2 / 3 - t);
|
|
12
|
-
return p;
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function SRGBToLinear(c: number) {
|
|
17
|
-
|
|
18
|
-
return (c < 0.04045) ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function LinearToSRGB(c: number) {
|
|
23
|
-
|
|
24
|
-
return (c < 0.0031308) ? c * 12.92 : 1.055 * (Math.pow(c, 0.41666)) - 0.055;
|
|
25
|
-
|
|
26
|
-
}
|
|
1
|
+
import { EventHandler } from "../render/eventhandler";
|
|
27
2
|
|
|
28
3
|
export class Color extends EventHandler {
|
|
4
|
+
constructor(private _r: number = 0, private _g: number = 0, private _b: number = 0, private _a: number = 1) {
|
|
5
|
+
super();
|
|
6
|
+
}
|
|
7
|
+
|
|
29
8
|
get isColor() {
|
|
30
9
|
return true;
|
|
31
10
|
}
|
|
32
11
|
|
|
33
|
-
constructor(private _r: number = 0, private _g: number = 0, private _b: number = 0, private _a: number = 1) {
|
|
34
|
-
super();
|
|
35
|
-
}
|
|
36
12
|
|
|
37
13
|
get r() {
|
|
38
14
|
return this._r;
|
|
@@ -64,8 +40,7 @@ export class Color extends EventHandler {
|
|
|
64
40
|
if (this._b !== value) {
|
|
65
41
|
this._b = value;
|
|
66
42
|
this.fire('change', 'b', this._b, value)
|
|
67
|
-
}
|
|
68
|
-
THREE.Color
|
|
43
|
+
}
|
|
69
44
|
}
|
|
70
45
|
|
|
71
46
|
get a() {
|