@xort/cga 0.0.71 → 0.0.72
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.js → @xort_cga.js} +13798 -13792
- package/dist/IKanimation/Bone.js +3 -1
- 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/extrude.js +56 -54
- package/dist/alg/pointset.js +5 -5
- package/dist/alg/trianglution.js +12 -10
- 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 +7 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -2
- package/dist/math/Euler.js +12 -10
- package/dist/math/HVec3.js +3 -1
- package/dist/math/Mat3.js +1 -1
- package/dist/math/Mat4.js +6 -6
- package/dist/math/Quat.js +4 -2
- package/dist/math/Vec.js +3 -1
- package/dist/math/Vec2.js +3 -1
- package/dist/math/Vec3.js +7 -5
- package/dist/math/Vec4.js +3 -1
- package/dist/math/vector.js +9 -7
- package/dist/render/buffer-attribute.js +12 -28
- package/dist/render/eventhandler.d.ts +2 -2
- package/dist/render/eventhandler.js +14 -8
- package/dist/render/geometry.d.ts +1 -1
- package/dist/render/geometry.js +2 -2
- package/dist/render/mesh.js +11 -9
- package/dist/render/thing.js +10 -8
- 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 +4 -4
- package/dist/struct/3d/Path.js +13 -11
- package/dist/struct/3d/Plane.js +12 -10
- package/dist/struct/3d/Point.js +3 -1
- package/dist/struct/3d/Polygon.js +3 -1
- package/dist/struct/3d/Polyline.js +3 -1
- 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/data/ArrayList.js +11 -9
- package/dist/struct/data/ArrayObject.js +3 -1
- package/docs/guide/README.md +6 -6
- package/git.sh +2 -2
- package/package.json +2 -2
- package/readme.md +8 -8
- package/rollup.config.js +1 -1
- package/src/index.ts +2 -0
- package/src/render/eventhandler.ts +5 -2
- package/src/render/geometry.ts +2 -2
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 || Vec3_1.v3();
|
|
8
|
+
this.center = center || (0, 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 = Vec3_1.v3(); }
|
|
12
|
-
if (end === void 0) { end = Vec3_1.v3(); }
|
|
11
|
+
if (origin === void 0) { origin = (0, Vec3_1.v3)(); }
|
|
12
|
+
if (end === void 0) { end = (0, 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] = Vec3_1.v3(-v[0].z, 0, +v[0].x);
|
|
195
|
+
v[1] = (0, Vec3_1.v3)(-v[0].z, 0, +v[0].x);
|
|
196
196
|
}
|
|
197
197
|
else {
|
|
198
|
-
v[1] = Vec3_1.v3(0, +v[0].z, -v[0].y);
|
|
198
|
+
v[1] = (0, 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,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
|
}
|
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) {
|
|
@@ -223,8 +225,8 @@ var Plane = /** @class */ (function () {
|
|
|
223
225
|
* @param polyVS
|
|
224
226
|
*/
|
|
225
227
|
Plane.prototype.splitPolyVS = function (polyVS) {
|
|
226
|
-
polyVS =
|
|
227
|
-
mesh_1.indexable(polyVS);
|
|
228
|
+
polyVS = __spreadArray([], polyVS, true);
|
|
229
|
+
(0, mesh_1.indexable)(polyVS);
|
|
228
230
|
var jd0 = -1; //找出第一个交点
|
|
229
231
|
var jdp0; //找出第一个交点
|
|
230
232
|
var lastOriention = this.orientationPoint(polyVS[0]);
|
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 __());
|
|
@@ -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 __());
|
|
@@ -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 __());
|
|
@@ -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 __());
|
package/docs/guide/README.md
CHANGED
|
@@ -54,9 +54,9 @@ cga 计算库基于 JavaScript,主要用于(**web 图形**)场景的几何
|
|
|
54
54
|
- npm 安装
|
|
55
55
|
|
|
56
56
|
```sh
|
|
57
|
-
npm
|
|
57
|
+
npm i @xtor/cga -D
|
|
58
58
|
#国内镜像
|
|
59
|
-
cnpm
|
|
59
|
+
cnpm i @xtor/cga -D
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
<!-- - yarn 安装
|
|
@@ -69,7 +69,7 @@ yarn add @jiaminghi/data-view
|
|
|
69
69
|
|
|
70
70
|
```js
|
|
71
71
|
// 全部引用
|
|
72
|
-
import * as cga from "@xtor/cga
|
|
72
|
+
import * as cga from "@xtor/cga";
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
## 按需引入
|
|
@@ -77,15 +77,15 @@ import * as cga from "@xtor/cga.js";
|
|
|
77
77
|
按需引入仅支持基于**ES module**的**tree shaking**,按需引入示例如下:
|
|
78
78
|
|
|
79
79
|
```js
|
|
80
|
-
import { Point, Segment } from "@xtor/cga
|
|
80
|
+
import { Point, Segment } from "@xtor/cga";
|
|
81
81
|
```
|
|
82
82
|
|
|
83
83
|
## UMD 版
|
|
84
84
|
|
|
85
|
-
`UMD`版可直接使用`script`标签引入,`UMD`版文件下载请移步[UMD](https://github.com/yszhao91
|
|
85
|
+
`UMD`版可直接使用`script`标签引入,`UMD`版文件下载请移步[UMD](https://github.com/yszhao91/cga.js/tree/master/build), 直接引入使用
|
|
86
86
|
|
|
87
87
|
```html
|
|
88
|
-
<script src="./build
|
|
88
|
+
<script src="./build/@xort_cga.js" />
|
|
89
89
|
```
|
|
90
90
|
|
|
91
91
|
<!--
|
package/git.sh
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xort/cga",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.72",
|
|
4
4
|
"description": "Xtor Compute Geometry Algorithm Libary 计算几何算法库",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"release": "tsc && git.sh",
|
|
8
|
+
"release": "tsc && git.sh && npm publish",
|
|
9
9
|
"dev": "webpack-dev-server",
|
|
10
10
|
"build:dev": "webpack --mode development",
|
|
11
11
|
"build:prod": "webpack --mode production",
|
package/readme.md
CHANGED
|
@@ -27,9 +27,9 @@ Computional Geometry Algorithm implement JavaScript,javascript 实现计算机
|
|
|
27
27
|
## 安装
|
|
28
28
|
|
|
29
29
|
```
|
|
30
|
-
npm
|
|
30
|
+
npm i @xort/cga
|
|
31
31
|
国内
|
|
32
|
-
cnpm
|
|
32
|
+
cnpm i @xort/cga
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
## 使用
|
|
@@ -37,7 +37,7 @@ cnpm install xtorcga -D
|
|
|
37
37
|
- 全部引用;:
|
|
38
38
|
|
|
39
39
|
```javascript
|
|
40
|
-
import * as cga from "
|
|
40
|
+
import * as cga from "@xort/cga";
|
|
41
41
|
function randomV3() {
|
|
42
42
|
return cga.v3(
|
|
43
43
|
Math.random() * 100 - 50,
|
|
@@ -54,7 +54,7 @@ var result = point.distanceSegment(seg);
|
|
|
54
54
|
- 按需求引用:
|
|
55
55
|
|
|
56
56
|
```javascript
|
|
57
|
-
import { v3, Point, Segment } from "
|
|
57
|
+
import { v3, Point, Segment } from "@xort/cga";
|
|
58
58
|
function randomV3() {
|
|
59
59
|
return v3(
|
|
60
60
|
Math.random() * 100 - 50,
|
|
@@ -68,12 +68,12 @@ var seg = new Segment(randomV3(), randomV3());
|
|
|
68
68
|
var result = point.distanceSegment(seg);
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
- 网页嵌入:直接下载使用 build 目录下面的
|
|
71
|
+
- 网页嵌入:直接下载使用 build 目录下面的 @xort/cga,包含到项目中
|
|
72
72
|
|
|
73
73
|
```html
|
|
74
|
-
<script src="
|
|
74
|
+
<script src="@xort/@xort_cga.js" />
|
|
75
75
|
或者
|
|
76
|
-
<script src="https://raw.githack.com/yszhao91/
|
|
76
|
+
<script src="https://raw.githack.com/yszhao91/@xort/cga/master/build/@xort_cga.js" />
|
|
77
77
|
<script>
|
|
78
78
|
var point = new cga.Point(1, 2, 3);
|
|
79
79
|
var line = new cga.Line(
|
|
@@ -87,7 +87,7 @@ var result = point.distanceSegment(seg);
|
|
|
87
87
|
## 项目编译
|
|
88
88
|
|
|
89
89
|
```shell
|
|
90
|
-
npm run build //js 编译到build
|
|
90
|
+
npm run build //js 编译到build目录下生成@xort/cga dist目录下生成每个文件的js和.d.ts
|
|
91
91
|
npm run dev //运行项目,自己更改源码测试
|
|
92
92
|
```
|
|
93
93
|
|
package/rollup.config.js
CHANGED
|
@@ -59,7 +59,7 @@ export default {
|
|
|
59
59
|
external: ['lodash'],
|
|
60
60
|
plugins: plugins,
|
|
61
61
|
output: {
|
|
62
|
-
file: path.join(DIST ? 'dist' : 'build', '
|
|
62
|
+
file: path.join(DIST ? 'dist' : 'build', '@xort_cga' + (MIN ? '.min' : '') + '.js'),
|
|
63
63
|
format: 'umd',
|
|
64
64
|
// format: 'umd',
|
|
65
65
|
name: 'cga',
|
package/src/index.ts
CHANGED
|
@@ -36,8 +36,11 @@ export class EventHandler {
|
|
|
36
36
|
* });
|
|
37
37
|
* obj.fire('test', 1, 2); // prints 3 to the console
|
|
38
38
|
*/
|
|
39
|
-
on(name: string, callback: any, scope?: any) {
|
|
40
|
-
|
|
39
|
+
on(name: string | string[], callback: any, scope?: any) {
|
|
40
|
+
if (Array.isArray(name))
|
|
41
|
+
name.forEach(v => this._addCallback(v, callback, scope, false));
|
|
42
|
+
else
|
|
43
|
+
this._addCallback(name, callback, scope, false);
|
|
41
44
|
|
|
42
45
|
return this;
|
|
43
46
|
}
|
package/src/render/geometry.ts
CHANGED
|
@@ -75,7 +75,7 @@ export class BufferGeometry {
|
|
|
75
75
|
* 转化成BufferArray来计算
|
|
76
76
|
* @param geo
|
|
77
77
|
*/
|
|
78
|
-
setFromGeometry(geo: IGeometry) {
|
|
78
|
+
setFromGeometry(geo: IGeometry | IBufferGeometry) {
|
|
79
79
|
this.setAttribute('position', new Float32BufferAttribute(geo.position, 3))
|
|
80
80
|
if (geo.uv)
|
|
81
81
|
this.setAttribute('uv', new Float32BufferAttribute(geo.uv, 2));
|
|
@@ -932,7 +932,7 @@ export class BufferGeometry {
|
|
|
932
932
|
|
|
933
933
|
}
|
|
934
934
|
|
|
935
|
-
toFlat() {
|
|
935
|
+
toFlat() {
|
|
936
936
|
var indices = this.index!.array;
|
|
937
937
|
var attributes = this.attributes;
|
|
938
938
|
var geometry2 = new BufferGeometry();
|