@xort/cga 0.0.71 → 0.0.74
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 +2 -0
- package/dist/index.js +8 -2
- package/dist/math/Color.d.ts +29 -0
- package/dist/math/Color.js +201 -0
- 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/docs/guide/distLineAll.md +5 -5
- package/docs/guide/distPointAll.md +6 -6
- package/docs/guide/distRayAll.md +4 -4
- package/docs/guide/distSegmentAll.md +1 -1
- 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 +3 -0
- package/src/math/Color.ts +157 -0
- package/src/render/eventhandler.ts +5 -2
- package/src/render/geometry.ts +2 -2
|
@@ -53,7 +53,7 @@ export declare class BufferGeometry {
|
|
|
53
53
|
* 转化成BufferArray来计算
|
|
54
54
|
* @param geo
|
|
55
55
|
*/
|
|
56
|
-
setFromGeometry(geo: IGeometry): this;
|
|
56
|
+
setFromGeometry(geo: IGeometry | IBufferGeometry): this;
|
|
57
57
|
getIndex(): BufferAttribute | undefined;
|
|
58
58
|
setIndex(index: BufferAttribute | TypedArray | number[]): void;
|
|
59
59
|
getAttribute(name: string): BufferAttribute;
|
package/dist/render/geometry.js
CHANGED
|
@@ -95,7 +95,7 @@ var BufferGeometry = /** @class */ (function () {
|
|
|
95
95
|
else if (attribute instanceof buffer_attribute_1.BufferAttribute) {
|
|
96
96
|
this.attributes[name] = attribute;
|
|
97
97
|
}
|
|
98
|
-
else if (types_1.isBufferArray(attribute)) {
|
|
98
|
+
else if ((0, types_1.isBufferArray)(attribute)) {
|
|
99
99
|
this.setAttribute(name, new buffer_attribute_1.BufferAttribute(attribute, itemSize));
|
|
100
100
|
}
|
|
101
101
|
return this;
|
|
@@ -174,7 +174,7 @@ var BufferGeometry = /** @class */ (function () {
|
|
|
174
174
|
return this;
|
|
175
175
|
};
|
|
176
176
|
BufferGeometry.prototype.lookAt = function (vector) {
|
|
177
|
-
_m1.lookAt(Vec3_1.v3(), vector, Vec3_1.Vec3.UnitY);
|
|
177
|
+
_m1.lookAt((0, Vec3_1.v3)(), vector, Vec3_1.Vec3.UnitY);
|
|
178
178
|
this.applyMat4(_m1);
|
|
179
179
|
return this;
|
|
180
180
|
};
|
package/dist/render/mesh.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.trianglutionToGeometryBuffer = exports.toGeoBuffer = exports.triangListToBuffer = exports.indexable = void 0;
|
|
@@ -38,7 +40,7 @@ exports.indexable = indexable;
|
|
|
38
40
|
function triangListToBuffer(vertices, triangleList) {
|
|
39
41
|
indexable(triangleList);
|
|
40
42
|
var indices = [];
|
|
41
|
-
array_1.forall(triangleList, function (v) {
|
|
43
|
+
(0, array_1.forall)(triangleList, function (v) {
|
|
42
44
|
indices.push(v.index);
|
|
43
45
|
});
|
|
44
46
|
return toGeoBuffer(vertices, indices);
|
|
@@ -68,8 +70,8 @@ exports.toGeoBuffer = toGeoBuffer;
|
|
|
68
70
|
function trianglutionToGeometryBuffer(boundary, holes, options) {
|
|
69
71
|
if (holes === void 0) { holes = []; }
|
|
70
72
|
if (options === void 0) { options = { normal: Vec3_1.Vec3.UnitZ }; }
|
|
71
|
-
var triangles = trianglution_1.triangulation(boundary, holes, options);
|
|
72
|
-
var vertices =
|
|
73
|
+
var triangles = (0, trianglution_1.triangulation)(boundary, holes, options);
|
|
74
|
+
var vertices = __spreadArray(__spreadArray([], boundary, true), (0, array_1.flat)(holes), true);
|
|
73
75
|
var uvs = [];
|
|
74
76
|
vertices.forEach(function (v) {
|
|
75
77
|
uvs.push(v.x, v.z);
|
package/dist/render/thing.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 __());
|
|
@@ -23,7 +25,7 @@ var Thing = /** @class */ (function (_super) {
|
|
|
23
25
|
_this.cache = {};
|
|
24
26
|
_this._useData = {};
|
|
25
27
|
opts = opts || {};
|
|
26
|
-
_this.uuid = uuid_1.v4();
|
|
28
|
+
_this.uuid = (0, uuid_1.v4)();
|
|
27
29
|
_this.id = _this.uuid;
|
|
28
30
|
_this.name = opts.name || "未命名";
|
|
29
31
|
_this.alias = opts.alias;
|
|
@@ -151,11 +153,11 @@ var Thing = /** @class */ (function (_super) {
|
|
|
151
153
|
return;
|
|
152
154
|
Object.defineProperty(bindObject, name, {
|
|
153
155
|
get: function () {
|
|
154
|
-
return bindObject["_"
|
|
156
|
+
return bindObject["_".concat(name)];
|
|
155
157
|
},
|
|
156
158
|
set: function (value) {
|
|
157
|
-
var oldValue = bindObject["_"
|
|
158
|
-
bindObject["_"
|
|
159
|
+
var oldValue = bindObject["_".concat(name)];
|
|
160
|
+
bindObject["_".concat(name)] = value;
|
|
159
161
|
bindObject.fire('set', name, oldValue, value);
|
|
160
162
|
},
|
|
161
163
|
configurable: true
|
|
@@ -175,11 +177,11 @@ function buildAccessor(name, bindObject) {
|
|
|
175
177
|
return;
|
|
176
178
|
Object.defineProperty(bindObject, name, {
|
|
177
179
|
get: function () {
|
|
178
|
-
return bindObject["_"
|
|
180
|
+
return bindObject["_".concat(name)];
|
|
179
181
|
},
|
|
180
182
|
set: function (value) {
|
|
181
|
-
var oldValue = bindObject["_"
|
|
182
|
-
bindObject["_"
|
|
183
|
+
var oldValue = bindObject["_".concat(name)];
|
|
184
|
+
bindObject["_".concat(name)] = value;
|
|
183
185
|
bindObject.fire('set', name, oldValue, value);
|
|
184
186
|
},
|
|
185
187
|
configurable: true
|
package/dist/render/types.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isBufferArray = void 0;
|
|
4
|
-
|
|
4
|
+
var isBufferArray = function (obj) {
|
|
5
5
|
var types = ['Int8Array', 'Uint8Array', 'Uint8ClampedArray', 'Int16Array', 'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array', 'Float64Array'];
|
|
6
6
|
return types.indexOf(obj.constructor.name) > -1;
|
|
7
7
|
};
|
|
8
|
+
exports.isBufferArray = isBufferArray;
|
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 = Vec3_1.v3(Infinity, Infinity, Infinity); }
|
|
9
|
-
if (max === void 0) { max = Vec3_1.v3(-Infinity, -Infinity, -Infinity); }
|
|
10
|
-
this._center = Vec3_1.v3();
|
|
8
|
+
if (min === void 0) { min = (0, Vec3_1.v3)(Infinity, Infinity, Infinity); }
|
|
9
|
+
if (max === void 0) { max = (0, Vec3_1.v3)(-Infinity, -Infinity, -Infinity); }
|
|
10
|
+
this._center = (0, Vec3_1.v3)();
|
|
11
11
|
this.min = min;
|
|
12
12
|
this.max = max;
|
|
13
13
|
// if (points) {
|
|
@@ -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/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 = common_1.angle(fixp0.clone().sub(this.center).normalize(), fixp1.clone().sub(this.center).normalize(), this.normal || normal);
|
|
38
|
+
this.endAngle = (0, 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 = common_1.angle(v1, v2);
|
|
52
|
+
var jd = (0, 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 || 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
|
<!--
|
|
@@ -14,7 +14,7 @@ sidebarDepth: 2
|
|
|
14
14
|
</ClientOnly>
|
|
15
15
|
|
|
16
16
|
```javascript
|
|
17
|
-
import * as cga from "@xtor/cga
|
|
17
|
+
import * as cga from "@xtor/cga";
|
|
18
18
|
var line0 = new cga.Line(randomV3(), randomV3());
|
|
19
19
|
var line1 = new cga.Line(randomV3(), randomV3());
|
|
20
20
|
var result = line0.distanceLine(line1);
|
|
@@ -30,7 +30,7 @@ var result = line0.distanceLine(line1);
|
|
|
30
30
|
</ClientOnly>
|
|
31
31
|
|
|
32
32
|
```javascript
|
|
33
|
-
import * as cga from "@xtor/cga
|
|
33
|
+
import * as cga from "@xtor/cga";
|
|
34
34
|
var line1 = new cga.Line(randomV3(), randomV3());
|
|
35
35
|
var ray = new cga.Ray(randomV3(), randomV3().normalize());
|
|
36
36
|
var result = line.distanceRay(ray);
|
|
@@ -46,7 +46,7 @@ var result = line.distanceRay(ray);
|
|
|
46
46
|
</ClientOnly>
|
|
47
47
|
|
|
48
48
|
```javascript
|
|
49
|
-
import * as cga from "@xtor/cga
|
|
49
|
+
import * as cga from "@xtor/cga";
|
|
50
50
|
var line1 = new cga.Line(randomV3(), randomV3());
|
|
51
51
|
var segment = new cga.Segment(randomV3(), randomV3());
|
|
52
52
|
var result = line.distanceSegment(segment);
|
|
@@ -62,7 +62,7 @@ var result = line.distanceSegment(segment);
|
|
|
62
62
|
</ClientOnly>
|
|
63
63
|
|
|
64
64
|
```javascript
|
|
65
|
-
import * as cga from "@xtor/cga
|
|
65
|
+
import * as cga from "@xtor/cga";
|
|
66
66
|
var line1 = new cga.Line(randomV3(), randomV3());
|
|
67
67
|
var triangle = new cga.Triangle(randomV3(), randomV3(),randomV3());
|
|
68
68
|
var result = line.distanceTriangle(triangle);
|
|
@@ -78,7 +78,7 @@ var result = line.distanceTriangle(triangle);
|
|
|
78
78
|
</ClientOnly>
|
|
79
79
|
|
|
80
80
|
```javascript
|
|
81
|
-
import * as cga from "@xtor/cga
|
|
81
|
+
import * as cga from "@xtor/cga";
|
|
82
82
|
var line1 = new cga.Line(randomV3(), randomV3());
|
|
83
83
|
var circle = new cga.Circle(randomV3(), randomV3().normalize(),Math.random()*50)+5);
|
|
84
84
|
var result = line.distanceCircle(circle);
|