@xort/cga 0.0.86 → 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.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.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/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
|
@@ -32,7 +32,7 @@ var CCDSolver = /** @class */ (function () {
|
|
|
32
32
|
CCDSolver.prototype.calcAngle = function (v1, v2, dir) {
|
|
33
33
|
var vc1 = v1.clone();
|
|
34
34
|
var vc2 = v2.clone();
|
|
35
|
-
var angle = Math_1.clamp(vc1.normalize().dot(vc2.normalize()), -1, 1);
|
|
35
|
+
var angle = (0, Math_1.clamp)(vc1.normalize().dot(vc2.normalize()), -1, 1);
|
|
36
36
|
angle = Math.acos(angle);
|
|
37
37
|
if (vc1.cross(vc2).dot(dir) < 0)
|
|
38
38
|
return -angle;
|
|
@@ -59,7 +59,7 @@ var CCDSolver = /** @class */ (function () {
|
|
|
59
59
|
CCDSolver.prototype.solveRotation = function (target, zeroPos, effector, contraints) {
|
|
60
60
|
var dir0 = effector.clone().sub(zeroPos).normalize();
|
|
61
61
|
var dir1 = target.clone().sub(zeroPos).normalize();
|
|
62
|
-
var rotationAxis = Vec3_1.v3().cross(dir0, dir1).normalize();
|
|
62
|
+
var rotationAxis = (0, Vec3_1.v3)().cross(dir0, dir1).normalize();
|
|
63
63
|
_plane.setFromPointNormal(zeroPos, rotationAxis);
|
|
64
64
|
//最近点
|
|
65
65
|
var closestDir = this.projectPlane(target, rotationAxis);
|
|
@@ -11,10 +11,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
11
11
|
var extendStatics = function (d, b) {
|
|
12
12
|
extendStatics = Object.setPrototypeOf ||
|
|
13
13
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
14
|
-
function (d, b) { for (var p in b) if (
|
|
14
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
15
15
|
return extendStatics(d, b);
|
|
16
16
|
};
|
|
17
17
|
return function (d, b) {
|
|
18
|
+
if (typeof b !== "function" && b !== null)
|
|
19
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
18
20
|
extendStatics(d, b);
|
|
19
21
|
function __() { this.constructor = d; }
|
|
20
22
|
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 __());
|
package/dist/alg/common.js
CHANGED
|
@@ -16,13 +16,13 @@ var XYZSort = function (e1, e2) {
|
|
|
16
16
|
else
|
|
17
17
|
return e1.z - e2.z;
|
|
18
18
|
};
|
|
19
|
-
var _vector = Vec3_1.v3();
|
|
19
|
+
var _vector = (0, Vec3_1.v3)();
|
|
20
20
|
/**
|
|
21
21
|
* 数组深度复制
|
|
22
22
|
* @param {Array} array
|
|
23
23
|
*/
|
|
24
24
|
function clone(array) {
|
|
25
|
-
if (!types_1.isDefined(array))
|
|
25
|
+
if (!(0, types_1.isDefined)(array))
|
|
26
26
|
return array;
|
|
27
27
|
if (Array.isArray(array)) {
|
|
28
28
|
var result = new Array();
|
package/dist/alg/delaunay.js
CHANGED
|
@@ -5,7 +5,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
5
5
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
6
6
|
function step(op) {
|
|
7
7
|
if (f) throw new TypeError("Generator is already executing.");
|
|
8
|
-
while (_) try {
|
|
8
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
9
9
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
10
10
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
11
11
|
switch (op[0]) {
|
package/dist/alg/extrude.js
CHANGED
|
@@ -18,12 +18,14 @@ var __assign = (this && this.__assign) || function () {
|
|
|
18
18
|
};
|
|
19
19
|
return __assign.apply(this, arguments);
|
|
20
20
|
};
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
22
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
23
|
+
if (ar || !(i in from)) {
|
|
24
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
25
|
+
ar[i] = from[i];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
27
29
|
};
|
|
28
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
31
|
exports.extrudeNext = exports.EndType = exports.JoinType = exports.extrude_obsolete = exports.extrude = exports.linkSides = exports.linkSide = void 0;
|
|
@@ -78,7 +80,7 @@ function linkSide(options) {
|
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
82
|
else {
|
|
81
|
-
if (types_1.isDefined(side0[0].index)) {
|
|
83
|
+
if ((0, types_1.isDefined)(side0[0].index)) {
|
|
82
84
|
//含索引的顶点
|
|
83
85
|
for (var i = 0; i < length; i++) {
|
|
84
86
|
var v00 = side0[i];
|
|
@@ -161,13 +163,13 @@ function linkSides(options) {
|
|
|
161
163
|
triangles.push.apply(triangles, linkSide({ side0: shapes[i], side1: shapes[(i + 1) % shapes.length], shapeClosed: options.shapeClosed }));
|
|
162
164
|
}
|
|
163
165
|
if (options.sealStart) {
|
|
164
|
-
var startShape = common_1.clone(shapes[0]);
|
|
166
|
+
var startShape = (0, common_1.clone)(shapes[0]);
|
|
165
167
|
allVertics.push(startShape);
|
|
166
168
|
if (holess && holess[0]) {
|
|
167
|
-
var startHoles = common_1.clone(holess[0]);
|
|
169
|
+
var startHoles = (0, common_1.clone)(holess[0]);
|
|
168
170
|
allVertics.push(startHoles);
|
|
169
171
|
}
|
|
170
|
-
var startTris = trianglution_1.triangulation(orgShape, orgHoles, { feature: trianglution_1.AxisPlane.XYZ });
|
|
172
|
+
var startTris = (0, trianglution_1.triangulation)(orgShape, orgHoles, { feature: trianglution_1.AxisPlane.XYZ });
|
|
171
173
|
if (index) {
|
|
172
174
|
startTris.forEach(function (v, i) {
|
|
173
175
|
startTris[i] = v + (index === null || index === void 0 ? void 0 : index.index);
|
|
@@ -181,13 +183,13 @@ function linkSides(options) {
|
|
|
181
183
|
triangles.push.apply(triangles, startTris.reverse());
|
|
182
184
|
}
|
|
183
185
|
if (options.sealEnd) {
|
|
184
|
-
var endShape = common_1.clone(shapes[shapes.length - 1]);
|
|
186
|
+
var endShape = (0, common_1.clone)(shapes[shapes.length - 1]);
|
|
185
187
|
allVertics.push(endShape);
|
|
186
188
|
if (holess && holess[0]) {
|
|
187
|
-
var endHoles = common_1.clone(common_1.clone(holess[holess.length - 1]));
|
|
189
|
+
var endHoles = (0, common_1.clone)((0, common_1.clone)(holess[holess.length - 1]));
|
|
188
190
|
allVertics.push(endHoles);
|
|
189
191
|
}
|
|
190
|
-
var endTris = trianglution_1.triangulation(orgShape, orgHoles, { feature: trianglution_1.AxisPlane.XYZ });
|
|
192
|
+
var endTris = (0, trianglution_1.triangulation)(orgShape, orgHoles, { feature: trianglution_1.AxisPlane.XYZ });
|
|
191
193
|
if (index) {
|
|
192
194
|
endTris.forEach(function (v, i) {
|
|
193
195
|
endTris[i] = v + (index === null || index === void 0 ? void 0 : index.index);
|
|
@@ -286,7 +288,7 @@ function linkSides(options) {
|
|
|
286
288
|
default:
|
|
287
289
|
break;
|
|
288
290
|
}
|
|
289
|
-
uvs.push.apply(uvs,
|
|
291
|
+
uvs.push.apply(uvs, __spreadArray(__spreadArray([], sealUvs, false), sealUvs, false));
|
|
290
292
|
}
|
|
291
293
|
var indices = triangles || [];
|
|
292
294
|
// if (isDefined(shapes[0][0].index)) {
|
|
@@ -313,12 +315,12 @@ var defaultExtrudeOption = {
|
|
|
313
315
|
sealEnd: false,
|
|
314
316
|
normal: Vec3_1.Vec3.UnitZ,
|
|
315
317
|
};
|
|
316
|
-
var _matrix = Mat4_1.m4();
|
|
317
|
-
var _matrix1 = Mat4_1.m4();
|
|
318
|
-
var _quat = Quat_1.quat();
|
|
319
|
-
var _quat1 = Quat_1.quat();
|
|
320
|
-
var _vec1 = Vec3_1.v3();
|
|
321
|
-
var _vec2 = Vec3_1.v3();
|
|
318
|
+
var _matrix = (0, Mat4_1.m4)();
|
|
319
|
+
var _matrix1 = (0, Mat4_1.m4)();
|
|
320
|
+
var _quat = (0, Quat_1.quat)();
|
|
321
|
+
var _quat1 = (0, Quat_1.quat)();
|
|
322
|
+
var _vec1 = (0, Vec3_1.v3)();
|
|
323
|
+
var _vec2 = (0, Vec3_1.v3)();
|
|
322
324
|
/**
|
|
323
325
|
* @description : 挤压形状生成几何体
|
|
324
326
|
* @param {IExtrudeOptionsEx} options
|
|
@@ -365,8 +367,8 @@ function extrude(options) {
|
|
|
365
367
|
}
|
|
366
368
|
}
|
|
367
369
|
var ups = options.ups || [];
|
|
368
|
-
if (types_1.isUndefined(shapePath.first.z)) {
|
|
369
|
-
shapePath.array = shapePath.array.map(function (e) { return Vec3_1.v3(e.x, e.y, 0); });
|
|
370
|
+
if ((0, types_1.isUndefined)(shapePath.first.z)) {
|
|
371
|
+
shapePath.array = shapePath.array.map(function (e) { return (0, Vec3_1.v3)(e.x, e.y, 0); });
|
|
370
372
|
options.normal = options.normal || Vec3_1.Vec3.UnitZ;
|
|
371
373
|
}
|
|
372
374
|
var up = options.up;
|
|
@@ -376,17 +378,17 @@ function extrude(options) {
|
|
|
376
378
|
var point = path.get(i);
|
|
377
379
|
var direction = point.direction;
|
|
378
380
|
var upi = void 0;
|
|
379
|
-
upi = ups[i] || up || Vec3_1.v3().crossVecs(right, direction);
|
|
381
|
+
upi = ups[i] || up || (0, Vec3_1.v3)().crossVecs(right, direction);
|
|
380
382
|
var righti = right;
|
|
381
383
|
if (!right)
|
|
382
|
-
righti = Vec3_1.v3().crossVecs(upi, direction).normalize();
|
|
384
|
+
righti = (0, Vec3_1.v3)().crossVecs(upi, direction).normalize();
|
|
383
385
|
_matrix.makeBasis(righti, upi, direction);
|
|
384
386
|
_matrix.setPosition(point);
|
|
385
387
|
var new_shape = shapePath.clone();
|
|
386
388
|
new_shape.applyMat4(_matrix);
|
|
387
389
|
shapes.push(new_shape);
|
|
388
390
|
if (options.holes) {
|
|
389
|
-
var mholes = pointset_1.applyMat4(options.holes, _matrix, false);
|
|
391
|
+
var mholes = (0, pointset_1.applyMat4)(options.holes, _matrix, false);
|
|
390
392
|
newholes.push(mholes);
|
|
391
393
|
}
|
|
392
394
|
}
|
|
@@ -430,7 +432,7 @@ function extrude_obsolete(shape, arg_path, options) {
|
|
|
430
432
|
if (!isCCW)
|
|
431
433
|
shape.reverse();
|
|
432
434
|
var normal = options.normal;
|
|
433
|
-
var startSeal = common_1.clone(shape);
|
|
435
|
+
var startSeal = (0, common_1.clone)(shape);
|
|
434
436
|
var shapepath = new Path_1.Path(shape);
|
|
435
437
|
var insertNum = 0;
|
|
436
438
|
for (var i = 1; i < shapepath.length - 1; i++) { //大角度插入点 角度过大为了呈现flat shader的效果
|
|
@@ -452,20 +454,20 @@ function extrude_obsolete(shape, arg_path, options) {
|
|
|
452
454
|
for (var i = 0; i < path.length; i++) {
|
|
453
455
|
var node = path[i];
|
|
454
456
|
var dir = node.tangent;
|
|
455
|
-
var newShape = common_1.clone(shape);
|
|
456
|
-
common_1.rotateByUnitVectors(newShape, normal, dir);
|
|
457
|
+
var newShape = (0, common_1.clone)(shape);
|
|
458
|
+
(0, common_1.rotateByUnitVectors)(newShape, normal, dir);
|
|
457
459
|
if (options.fixedY) {
|
|
458
460
|
var v = Vec3_1.Vec3.UnitX;
|
|
459
|
-
common_1.rotateByUnitVectors([v], normal, dir);
|
|
461
|
+
(0, common_1.rotateByUnitVectors)([v], normal, dir);
|
|
460
462
|
var v1 = v.clone();
|
|
461
463
|
v1.y = 0;
|
|
462
|
-
common_1.rotateByUnitVectors(newShape, v, v1);
|
|
464
|
+
(0, common_1.rotateByUnitVectors)(newShape, v, v1);
|
|
463
465
|
}
|
|
464
|
-
pointset_1.translate(newShape, node);
|
|
466
|
+
(0, pointset_1.translate)(newShape, node);
|
|
465
467
|
shapeArray.push(newShape);
|
|
466
468
|
}
|
|
467
469
|
var gindex = { index: 0 };
|
|
468
|
-
var vertices = array_1.flat(shapeArray);
|
|
470
|
+
var vertices = (0, array_1.flat)(shapeArray);
|
|
469
471
|
mesh_1.MeshTool.indexable(vertices, gindex);
|
|
470
472
|
var index = linkSides({ shapes: shapeArray, shapeClosed: options.shapeClosed, pathClosed: options.isClosed2, orgShape: shape }).index;
|
|
471
473
|
shapepath = new Path_1.Path(shape);
|
|
@@ -475,29 +477,29 @@ function extrude_obsolete(shape, arg_path, options) {
|
|
|
475
477
|
uvs.push(shapepath.get(j).tlen * options.textureScale.x, path.get(i).tlen * options.textureScale.y);
|
|
476
478
|
}
|
|
477
479
|
}
|
|
478
|
-
var sealUv = common_1.clone(startSeal);
|
|
480
|
+
var sealUv = (0, common_1.clone)(startSeal);
|
|
479
481
|
if (normal.dot(Vec3_1.Vec3.UnitZ) < 1 - 1e-4)
|
|
480
|
-
common_1.rotateByUnitVectors(sealUv, normal, Vec3_1.Vec3.UnitZ);
|
|
481
|
-
var endSeal = common_1.clone(startSeal);
|
|
482
|
-
common_1.rotateByUnitVectors(startSeal, normal, path[0].tangent);
|
|
482
|
+
(0, common_1.rotateByUnitVectors)(sealUv, normal, Vec3_1.Vec3.UnitZ);
|
|
483
|
+
var endSeal = (0, common_1.clone)(startSeal);
|
|
484
|
+
(0, common_1.rotateByUnitVectors)(startSeal, normal, path[0].tangent);
|
|
483
485
|
if (options.fixedY) {
|
|
484
486
|
var v = Vec3_1.Vec3.UnitX;
|
|
485
|
-
common_1.rotateByUnitVectors([v], normal, path[0].tangent);
|
|
487
|
+
(0, common_1.rotateByUnitVectors)([v], normal, path[0].tangent);
|
|
486
488
|
var v1 = v.clone();
|
|
487
489
|
v1.y = 0;
|
|
488
|
-
common_1.rotateByUnitVectors(startSeal, v, v1);
|
|
490
|
+
(0, common_1.rotateByUnitVectors)(startSeal, v, v1);
|
|
489
491
|
}
|
|
490
|
-
pointset_1.translate(startSeal, path[0]);
|
|
491
|
-
common_1.rotateByUnitVectors(endSeal, normal, path.get(-1).tangent);
|
|
492
|
+
(0, pointset_1.translate)(startSeal, path[0]);
|
|
493
|
+
(0, common_1.rotateByUnitVectors)(endSeal, normal, path.get(-1).tangent);
|
|
492
494
|
if (options.fixedY) {
|
|
493
495
|
var v = Vec3_1.Vec3.UnitX;
|
|
494
|
-
common_1.rotateByUnitVectors([v], normal, path.get(-1).tangent);
|
|
496
|
+
(0, common_1.rotateByUnitVectors)([v], normal, path.get(-1).tangent);
|
|
495
497
|
var v1 = v.clone();
|
|
496
498
|
v1.y = 0;
|
|
497
|
-
common_1.rotateByUnitVectors(endSeal, v, v1);
|
|
499
|
+
(0, common_1.rotateByUnitVectors)(endSeal, v, v1);
|
|
498
500
|
}
|
|
499
|
-
pointset_1.translate(endSeal, path.get(-1));
|
|
500
|
-
var sealStartTris = trianglution_1.triangulation(sealUv, [], { normal: normal });
|
|
501
|
+
(0, pointset_1.translate)(endSeal, path.get(-1));
|
|
502
|
+
var sealStartTris = (0, trianglution_1.triangulation)(sealUv, [], { normal: normal });
|
|
501
503
|
sealStartTris.reverse();
|
|
502
504
|
if (options.sealStart)
|
|
503
505
|
mesh_1.MeshTool.indexable(startSeal, gindex);
|
|
@@ -564,10 +566,10 @@ var EndType;
|
|
|
564
566
|
*/
|
|
565
567
|
function extrudeNext(options) {
|
|
566
568
|
options = __assign({ sealEnd: true, sealStart: true, shapeClosed: true, pathClosed: false, generateUV: true, autoIndex: true, axisPlane: trianglution_1.AxisPlane.XY, smoothAngle: 30 * Math_1.RADIANS_PER_DEGREE, enableSmooth: false }, options);
|
|
567
|
-
var path = options.shapeCenter ? pointset_1.translate(options.path, options.shapeCenter, false) : options.path;
|
|
569
|
+
var path = options.shapeCenter ? (0, pointset_1.translate)(options.path, options.shapeCenter, false) : options.path;
|
|
568
570
|
var shape = options.shape;
|
|
569
|
-
array_1.unique(path, function (a, b) { return a.equals(b); });
|
|
570
|
-
array_1.unique(shape, function (a, b) { return a.equals(b); });
|
|
571
|
+
(0, array_1.unique)(path, function (a, b) { return a.equals(b); });
|
|
572
|
+
(0, array_1.unique)(shape, function (a, b) { return a.equals(b); });
|
|
571
573
|
var pathPath = new Path_1.Path(path, options.pathClosed, true);
|
|
572
574
|
var starti = options.shapeClosed ? 0 : 1;
|
|
573
575
|
var shapePath = new Path_1.Path(shape, options.shapeClosed);
|
|
@@ -579,13 +581,13 @@ function extrudeNext(options) {
|
|
|
579
581
|
}
|
|
580
582
|
}
|
|
581
583
|
options.normal = options.normal || Vec3_1.Vec3.UnitZ;
|
|
582
|
-
if (types_1.isUndefined(shapePath.first.z)) {
|
|
583
|
-
shapePath.array = shapePath.array.map(function (e) { return Vec3_1.v3(e.x, e.y, 0); });
|
|
584
|
+
if ((0, types_1.isUndefined)(shapePath.first.z)) {
|
|
585
|
+
shapePath.array = shapePath.array.map(function (e) { return (0, Vec3_1.v3)(e.x, e.y, 0); });
|
|
584
586
|
}
|
|
585
587
|
var up = options.up;
|
|
586
588
|
var right = options.right;
|
|
587
589
|
var shapes = [], newholes = [];
|
|
588
|
-
var accMat = Mat4_1.m4();
|
|
590
|
+
var accMat = (0, Mat4_1.m4)();
|
|
589
591
|
/**
|
|
590
592
|
* 如果路径闭合 要考虑首尾shape矩阵变化后还能一致吻合
|
|
591
593
|
*/
|
package/dist/alg/pointset.js
CHANGED
|
@@ -7,7 +7,7 @@ var Math_1 = require("../math/Math");
|
|
|
7
7
|
var Line_1 = require("../struct/3d/Line");
|
|
8
8
|
var Plane_1 = require("../struct/3d/Plane");
|
|
9
9
|
var common_1 = require("./common");
|
|
10
|
-
var _Vec = Vec3_1.v3();
|
|
10
|
+
var _Vec = (0, Vec3_1.v3)();
|
|
11
11
|
/**
|
|
12
12
|
* 点排序函数
|
|
13
13
|
* @param {Vec*} a
|
|
@@ -53,7 +53,7 @@ function applyQuat(points, quat, ref) {
|
|
|
53
53
|
});
|
|
54
54
|
return points;
|
|
55
55
|
}
|
|
56
|
-
return applyQuat(common_1.clone(points), quat);
|
|
56
|
+
return applyQuat((0, common_1.clone)(points), quat);
|
|
57
57
|
}
|
|
58
58
|
exports.applyQuat = applyQuat;
|
|
59
59
|
/**
|
|
@@ -70,7 +70,7 @@ function translate(points, distance, ref) {
|
|
|
70
70
|
});
|
|
71
71
|
return points;
|
|
72
72
|
}
|
|
73
|
-
return translate(common_1.clone(points));
|
|
73
|
+
return translate((0, common_1.clone)(points));
|
|
74
74
|
}
|
|
75
75
|
exports.translate = translate;
|
|
76
76
|
/**
|
|
@@ -112,7 +112,7 @@ function applyMat4(points, mat4, ref) {
|
|
|
112
112
|
});
|
|
113
113
|
return points;
|
|
114
114
|
}
|
|
115
|
-
return applyMat4(common_1.clone(points), mat4);
|
|
115
|
+
return applyMat4((0, common_1.clone)(points), mat4);
|
|
116
116
|
}
|
|
117
117
|
exports.applyMat4 = applyMat4;
|
|
118
118
|
/**
|
|
@@ -177,7 +177,7 @@ function projectOnPlane(points, plane, projectDirect, ref) {
|
|
|
177
177
|
return points;
|
|
178
178
|
}
|
|
179
179
|
else {
|
|
180
|
-
return projectOnPlane(common_1.clone(points), plane, projectDirect);
|
|
180
|
+
return projectOnPlane((0, common_1.clone)(points), plane, projectDirect);
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
exports.projectOnPlane = projectOnPlane;
|
package/dist/alg/trianglution.js
CHANGED
|
@@ -10,12 +10,14 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
19
21
|
};
|
|
20
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -53,13 +55,13 @@ function triangulation(inboundary, holes, options) {
|
|
|
53
55
|
var dim = options.dim;
|
|
54
56
|
var normal = options.normal;
|
|
55
57
|
if (normal && normal.dot(Vec3_1.Vec3.UnitZ) < 1 - Math_1.delta4) {
|
|
56
|
-
boundary = common_1.clone(inboundary);
|
|
57
|
-
common_1.rotateByUnitVectors(boundary, normal, Vec3_1.Vec3.UnitZ);
|
|
58
|
+
boundary = (0, common_1.clone)(inboundary);
|
|
59
|
+
(0, common_1.rotateByUnitVectors)(boundary, normal, Vec3_1.Vec3.UnitZ);
|
|
58
60
|
}
|
|
59
61
|
else {
|
|
60
62
|
boundary = inboundary;
|
|
61
63
|
}
|
|
62
|
-
var allV =
|
|
64
|
+
var allV = __spreadArray(__spreadArray([], boundary, true), (0, array_1.flat)(holes), true);
|
|
63
65
|
var vertextNumbers = vecs_1.vecs.verctorToNumbers(allV, feature);
|
|
64
66
|
var holesIndex = [];
|
|
65
67
|
var baseIndex = boundary.length;
|
|
@@ -69,7 +71,7 @@ function triangulation(inboundary, holes, options) {
|
|
|
69
71
|
// holesIndex.push(baseIndex + hole.length);
|
|
70
72
|
baseIndex += hole.length;
|
|
71
73
|
}
|
|
72
|
-
var result = earcut_1.default(vertextNumbers, holesIndex, dim);
|
|
74
|
+
var result = (0, earcut_1.default)(vertextNumbers, holesIndex, dim);
|
|
73
75
|
return result;
|
|
74
76
|
}
|
|
75
77
|
exports.triangulation = triangulation;
|
package/dist/alg/voronoi.js
CHANGED
|
@@ -5,7 +5,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
5
5
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
6
6
|
function step(op) {
|
|
7
7
|
if (f) throw new TypeError("Generator is already executing.");
|
|
8
|
-
while (_) try {
|
|
8
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
9
9
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
10
10
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
11
11
|
switch (op[0]) {
|
package/dist/app.js
CHANGED
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
// // document.write(v.toString());
|
|
7
7
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
8
|
if (k2 === undefined) k2 = k;
|
|
9
|
-
Object.
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
10
14
|
}) : (function(o, m, k, k2) {
|
|
11
15
|
if (k2 === undefined) k2 = k;
|
|
12
16
|
o[k2] = m[k];
|
|
@@ -19,7 +23,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
19
23
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
24
|
if (mod && mod.__esModule) return mod;
|
|
21
25
|
var result = {};
|
|
22
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
27
|
__setModuleDefault(result, mod);
|
|
24
28
|
return result;
|
|
25
29
|
};
|
|
@@ -143,7 +147,7 @@ glv.run();
|
|
|
143
147
|
// polyline.offset(1)
|
|
144
148
|
var shape1 = [new cga.Vec3(-10, -10, 0), new cga.Vec3(10, -10, 0), new cga.Vec3(10, 10, 0), new cga.Vec3(-10, 10, 0)];
|
|
145
149
|
var path1 = [new cga.Vec3(), new cga.Vec3(0, 0, 100)];
|
|
146
|
-
extrude_1.extrude({ shape: shape1, path: path1, enableSmooth: true });
|
|
150
|
+
(0, extrude_1.extrude)({ shape: shape1, path: path1, enableSmooth: true });
|
|
147
151
|
var dizhu = function (bottomR, topR, bh, gh, th) {
|
|
148
152
|
var bq = [];
|
|
149
153
|
var tq = [];
|
|
@@ -166,19 +170,19 @@ var dizhu = function (bottomR, topR, bh, gh, th) {
|
|
|
166
170
|
var geometry = cga.toGeometryBuffer(geo);
|
|
167
171
|
return geometry;
|
|
168
172
|
};
|
|
169
|
-
var shape = [Vec3_1.v3(-5, 0, 0), Vec3_1.v3(5, 0, 0), Vec3_1.v3(5, 0, 0), Vec3_1.v3(5, 10, 0), Vec3_1.v3(5, 10, 0), Vec3_1.v3(-5, 10, 0), Vec3_1.v3(-5, 10, 0)];
|
|
170
|
-
var hole3 = [Vec3_1.v3(-4, 5, 0), Vec3_1.v3(-1, 5, 0), Vec3_1.v3(-1, 5, 0), Vec3_1.v3(-4, 9, 0), Vec3_1.v3(-4, 9, 0), Vec3_1.v3(-4, 5, 0)];
|
|
171
|
-
var hole1 = [Vec3_1.v3(1, 5, 0), Vec3_1.v3(4, 5, 0), Vec3_1.v3(4, 5, 0), Vec3_1.v3(4, 9, 0), Vec3_1.v3(4, 9, 0), Vec3_1.v3(1, 9, 0), Vec3_1.v3(1, 9, 0), Vec3_1.v3(1, 5, 0)];
|
|
172
|
-
var hole2 = [Vec3_1.v3(-4, 1, 0), Vec3_1.v3(4, 1, 0), Vec3_1.v3(4, 1, 0), Vec3_1.v3(4, 4, 0), Vec3_1.v3(4, 4, 0), Vec3_1.v3(-4, 4, 0), Vec3_1.v3(-4, 4, 0), Vec3_1.v3(-4, 1, 0)];
|
|
173
|
+
var shape = [(0, Vec3_1.v3)(-5, 0, 0), (0, Vec3_1.v3)(5, 0, 0), (0, Vec3_1.v3)(5, 0, 0), (0, Vec3_1.v3)(5, 10, 0), (0, Vec3_1.v3)(5, 10, 0), (0, Vec3_1.v3)(-5, 10, 0), (0, Vec3_1.v3)(-5, 10, 0)];
|
|
174
|
+
var hole3 = [(0, Vec3_1.v3)(-4, 5, 0), (0, Vec3_1.v3)(-1, 5, 0), (0, Vec3_1.v3)(-1, 5, 0), (0, Vec3_1.v3)(-4, 9, 0), (0, Vec3_1.v3)(-4, 9, 0), (0, Vec3_1.v3)(-4, 5, 0)];
|
|
175
|
+
var hole1 = [(0, Vec3_1.v3)(1, 5, 0), (0, Vec3_1.v3)(4, 5, 0), (0, Vec3_1.v3)(4, 5, 0), (0, Vec3_1.v3)(4, 9, 0), (0, Vec3_1.v3)(4, 9, 0), (0, Vec3_1.v3)(1, 9, 0), (0, Vec3_1.v3)(1, 9, 0), (0, Vec3_1.v3)(1, 5, 0)];
|
|
176
|
+
var hole2 = [(0, Vec3_1.v3)(-4, 1, 0), (0, Vec3_1.v3)(4, 1, 0), (0, Vec3_1.v3)(4, 1, 0), (0, Vec3_1.v3)(4, 4, 0), (0, Vec3_1.v3)(4, 4, 0), (0, Vec3_1.v3)(-4, 4, 0), (0, Vec3_1.v3)(-4, 4, 0), (0, Vec3_1.v3)(-4, 1, 0)];
|
|
173
177
|
var holes = [hole1, hole2, hole3];
|
|
174
178
|
var path = [];
|
|
175
179
|
var ia = Math.PI / 100;
|
|
176
180
|
for (var i = 0; i <= 100; i++) {
|
|
177
181
|
var x = Math.cos(ia * i) * 50 + 50;
|
|
178
182
|
var y = Math.sin(ia * i) * 50;
|
|
179
|
-
path.push(Vec3_1.v3(x, y, 0));
|
|
183
|
+
path.push((0, Vec3_1.v3)(x, y, 0));
|
|
180
184
|
}
|
|
181
|
-
var geo = extrude_1.extrude({ shape: shape, path: path, right: Vec3_1.Vec3.UnitZ, sealStart: true });
|
|
185
|
+
var geo = (0, extrude_1.extrude)({ shape: shape, path: path, right: Vec3_1.Vec3.UnitZ, sealStart: true });
|
|
182
186
|
// var geo = dizhu(1.8, 0.9, 0.3, 0.5, 10);
|
|
183
187
|
var geometry = cga.toGeometryBuffer(geo);
|
|
184
188
|
geometry.computeVertexNormals();
|
|
@@ -233,7 +237,7 @@ planeGeo.translate(0, 5, -1);
|
|
|
233
237
|
var mesh = new three_1.Mesh(planeGeo, shapeMaterial);
|
|
234
238
|
glv.add(mesh);
|
|
235
239
|
var m = new Mat4_1.Mat4();
|
|
236
|
-
var geo = extrude_1.extrude({ shape: shape, path: path, right: Vec3_1.Vec3.UnitZ, sealStart: true });
|
|
240
|
+
var geo = (0, extrude_1.extrude)({ shape: shape, path: path, right: Vec3_1.Vec3.UnitZ, sealStart: true });
|
|
237
241
|
var geometry = cga.toGeometryBuffer(geo);
|
|
238
242
|
geometry.computeVertexNormals();
|
|
239
243
|
var tgeo = new THREE.BufferGeometry();
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
18
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
19
|
if (mod && mod.__esModule) return mod;
|
|
16
20
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
22
|
__setModuleDefault(result, mod);
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
@@ -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 __());
|
|
@@ -17,7 +17,7 @@ exports.toGeometryBuffer = toGeometryBuffer;
|
|
|
17
17
|
* @param {*} options
|
|
18
18
|
*/
|
|
19
19
|
function extrudeToGeometryBuffer(shape, arg_path, options) {
|
|
20
|
-
var extrudeRes = extrude_1.extrude_obsolete(shape, arg_path, options);
|
|
20
|
+
var extrudeRes = (0, extrude_1.extrude_obsolete)(shape, arg_path, options);
|
|
21
21
|
return mesh_1.MeshTool.toGeoBuffer(extrudeRes.vertices, extrudeRes.index, extrudeRes.uvs);
|
|
22
22
|
}
|
|
23
23
|
exports.extrudeToGeometryBuffer = extrudeToGeometryBuffer;
|
|
@@ -31,7 +31,7 @@ exports.extrudeToGeometryBuffer = extrudeToGeometryBuffer;
|
|
|
31
31
|
function linkToGeometry(shape, shape1, axisPlane, shapeClose) {
|
|
32
32
|
if (axisPlane === void 0) { axisPlane = trianglution_1.AxisPlane.XY; }
|
|
33
33
|
if (shapeClose === void 0) { shapeClose = false; }
|
|
34
|
-
var geo = extrude_1.linkSides({ shapes: [shape, shape1], shapeClosed: shapeClose, orgShape: shape, axisPlane: axisPlane });
|
|
34
|
+
var geo = (0, extrude_1.linkSides)({ shapes: [shape, shape1], shapeClosed: shapeClose, orgShape: shape, axisPlane: axisPlane });
|
|
35
35
|
var geometry = toGeometryBuffer(geo);
|
|
36
36
|
return geometry;
|
|
37
37
|
}
|
|
@@ -45,9 +45,9 @@ exports.linkToGeometry = linkToGeometry;
|
|
|
45
45
|
function linksToGeometry(shapes, pathClosed, shapeClosed) {
|
|
46
46
|
if (pathClosed === void 0) { pathClosed = true; }
|
|
47
47
|
if (shapeClosed === void 0) { shapeClosed = true; }
|
|
48
|
-
var vertices = array_1.flat(shapes);
|
|
48
|
+
var vertices = (0, array_1.flat)(shapes);
|
|
49
49
|
mesh_1.MeshTool.indexable(vertices);
|
|
50
|
-
var geo = extrude_1.linkSides({ shapes: shapes, shapeClosed: pathClosed, orgShape: shapes[0] });
|
|
50
|
+
var geo = (0, extrude_1.linkSides)({ shapes: shapes, shapeClosed: pathClosed, orgShape: shapes[0] });
|
|
51
51
|
var geometry = toGeometryBuffer(geo);
|
|
52
52
|
return geometry;
|
|
53
53
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./alg/common";
|
|
|
13
13
|
export * from "./alg/result";
|
|
14
14
|
export * from "./alg/extrude";
|
|
15
15
|
export * from "./alg/delaunay";
|
|
16
|
+
export * from "./alg/trianglution";
|
|
16
17
|
export * from "./render/mesh";
|
|
17
18
|
export * from "./struct/3d/Box";
|
|
18
19
|
export * from "./struct/3d/Capsule";
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
8
12
|
}));
|
|
9
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
15
|
};
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
17
|
__exportStar(require("./utils/array"), exports);
|
|
@@ -26,6 +30,7 @@ __exportStar(require("./alg/common"), exports);
|
|
|
26
30
|
__exportStar(require("./alg/result"), exports);
|
|
27
31
|
__exportStar(require("./alg/extrude"), exports);
|
|
28
32
|
__exportStar(require("./alg/delaunay"), exports);
|
|
33
|
+
__exportStar(require("./alg/trianglution"), exports);
|
|
29
34
|
__exportStar(require("./render/mesh"), exports);
|
|
30
35
|
__exportStar(require("./struct/3d/Box"), exports);
|
|
31
36
|
__exportStar(require("./struct/3d/Capsule"), exports);
|
package/dist/math/Color.d.ts
CHANGED