@xort/cga 0.0.74 → 0.0.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/IKanimation/Bone.js +1 -3
- package/dist/IKanimation/CCDSolver.js +2 -2
- package/dist/IKanimation/constaint/hinge.js +1 -3
- package/dist/IKanimation/constaint/slider.js +1 -3
- package/dist/alg/common.js +2 -2
- package/dist/alg/extrude.js +54 -56
- package/dist/alg/pointset.js +5 -5
- package/dist/alg/trianglution.js +10 -12
- package/dist/app.js +10 -14
- package/dist/diamondMaterialShader.js +2 -6
- package/dist/effect/breath-light.js +1 -3
- package/dist/extends/geometryaid.js +7 -7
- package/dist/index.js +2 -6
- package/dist/math/Color.d.ts +2 -5
- package/dist/math/Color.js +3 -52
- package/dist/math/Euler.js +10 -12
- package/dist/math/HVec3.js +1 -3
- package/dist/math/Mat3.js +1 -1
- package/dist/math/Mat4.js +6 -6
- package/dist/math/Quat.js +2 -4
- package/dist/math/Vec.js +1 -3
- package/dist/math/Vec2.js +1 -3
- package/dist/math/Vec3.js +5 -7
- package/dist/math/Vec4.js +1 -3
- package/dist/math/vector.js +7 -9
- package/dist/render/buffer-attribute.js +28 -12
- package/dist/render/eventhandler.d.ts +1 -1
- package/dist/render/eventhandler.js +7 -9
- package/dist/render/geometry.js +2 -2
- package/dist/render/mesh.js +9 -11
- package/dist/render/thing.js +8 -10
- package/dist/render/types.js +1 -2
- package/dist/struct/3d/Box.js +3 -3
- package/dist/struct/3d/Capsule.js +1 -3
- package/dist/struct/3d/Circle.js +2 -2
- package/dist/struct/3d/Disk.js +1 -1
- package/dist/struct/3d/Line.js +4 -4
- package/dist/struct/3d/Path.js +11 -13
- package/dist/struct/3d/Plane.js +10 -12
- package/dist/struct/3d/Point.js +1 -3
- package/dist/struct/3d/Polygon.js +1 -3
- package/dist/struct/3d/Polyline.js +1 -3
- package/dist/struct/3d/Rectangle.js +1 -3
- package/dist/struct/3d/Segment.js +7 -9
- package/dist/struct/3d/Shape.js +1 -3
- package/dist/struct/3d/Sphere.js +1 -1
- package/dist/struct/3d/Triangle.js +1 -3
- package/dist/struct/data/ArrayList.js +9 -11
- package/dist/struct/data/ArrayObject.js +1 -3
- package/package.json +4 -3
- package/src/math/Color.ts +6 -31
package/dist/IKanimation/Bone.js
CHANGED
|
@@ -3,12 +3,10 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -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 =
|
|
35
|
+
var angle = 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 =
|
|
62
|
+
var rotationAxis = Vec3_1.v3().cross(dir0, dir1).normalize();
|
|
63
63
|
_plane.setFromPointNormal(zeroPos, rotationAxis);
|
|
64
64
|
//最近点
|
|
65
65
|
var closestDir = this.projectPlane(target, rotationAxis);
|
|
@@ -11,12 +11,10 @@ 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 (b.hasOwnProperty(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");
|
|
20
18
|
extendStatics(d, b);
|
|
21
19
|
function __() { this.constructor = d; }
|
|
22
20
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -3,12 +3,10 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
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 =
|
|
19
|
+
var _vector = Vec3_1.v3();
|
|
20
20
|
/**
|
|
21
21
|
* 数组深度复制
|
|
22
22
|
* @param {Array} array
|
|
23
23
|
*/
|
|
24
24
|
function clone(array) {
|
|
25
|
-
if (!
|
|
25
|
+
if (!types_1.isDefined(array))
|
|
26
26
|
return array;
|
|
27
27
|
if (Array.isArray(array)) {
|
|
28
28
|
var result = new Array();
|
package/dist/alg/extrude.js
CHANGED
|
@@ -18,14 +18,12 @@ var __assign = (this && this.__assign) || function () {
|
|
|
18
18
|
};
|
|
19
19
|
return __assign.apply(this, arguments);
|
|
20
20
|
};
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
22
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
23
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
24
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
25
|
+
r[k] = a[j];
|
|
26
|
+
return r;
|
|
29
27
|
};
|
|
30
28
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -83,7 +81,7 @@ function linkSide(options) {
|
|
|
83
81
|
}
|
|
84
82
|
}
|
|
85
83
|
else {
|
|
86
|
-
if (
|
|
84
|
+
if (types_1.isDefined(side0[0].index)) {
|
|
87
85
|
//含索引的顶点
|
|
88
86
|
for (var i = 0; i < length; i++) {
|
|
89
87
|
var v00 = side0[i];
|
|
@@ -158,7 +156,7 @@ function linkSides(options) {
|
|
|
158
156
|
var orgShape = options.orgShape || shapes[0];
|
|
159
157
|
var orgHoles = options.orgHoles || (holess && holess[0]);
|
|
160
158
|
if (index)
|
|
161
|
-
|
|
159
|
+
mesh_1.indexable(allVertics, index);
|
|
162
160
|
for (var i = 0; i < length; i++) {
|
|
163
161
|
if (holess)
|
|
164
162
|
triangles.push.apply(triangles, linkSide({ side0: shapes[i], side1: shapes[(i + 1) % shapes.length], holes0: holess[i], holes1: holess[(i + 1) % shapes.length], shapeClosed: options.shapeClosed }));
|
|
@@ -166,13 +164,13 @@ function linkSides(options) {
|
|
|
166
164
|
triangles.push.apply(triangles, linkSide({ side0: shapes[i], side1: shapes[(i + 1) % shapes.length], shapeClosed: options.shapeClosed }));
|
|
167
165
|
}
|
|
168
166
|
if (options.sealStart) {
|
|
169
|
-
var startShape =
|
|
167
|
+
var startShape = common_1.clone(shapes[0]);
|
|
170
168
|
allVertics.push(startShape);
|
|
171
169
|
if (holess && holess[0]) {
|
|
172
|
-
var startHoles =
|
|
170
|
+
var startHoles = common_1.clone(holess[0]);
|
|
173
171
|
allVertics.push(startHoles);
|
|
174
172
|
}
|
|
175
|
-
var startTris =
|
|
173
|
+
var startTris = trianglution_1.triangulation(orgShape, orgHoles, { feature: trianglution_1.AxisPlane.XYZ });
|
|
176
174
|
if (index) {
|
|
177
175
|
startTris.forEach(function (v, i) {
|
|
178
176
|
startTris[i] = v + (index === null || index === void 0 ? void 0 : index.index);
|
|
@@ -186,13 +184,13 @@ function linkSides(options) {
|
|
|
186
184
|
triangles.push.apply(triangles, startTris.reverse());
|
|
187
185
|
}
|
|
188
186
|
if (options.sealEnd) {
|
|
189
|
-
var endShape =
|
|
187
|
+
var endShape = common_1.clone(shapes[shapes.length - 1]);
|
|
190
188
|
allVertics.push(endShape);
|
|
191
189
|
if (holess && holess[0]) {
|
|
192
|
-
var endHoles =
|
|
190
|
+
var endHoles = common_1.clone(common_1.clone(holess[holess.length - 1]));
|
|
193
191
|
allVertics.push(endHoles);
|
|
194
192
|
}
|
|
195
|
-
var endTris =
|
|
193
|
+
var endTris = trianglution_1.triangulation(orgShape, orgHoles, { feature: trianglution_1.AxisPlane.XYZ });
|
|
196
194
|
if (index) {
|
|
197
195
|
endTris.forEach(function (v, i) {
|
|
198
196
|
endTris[i] = v + (index === null || index === void 0 ? void 0 : index.index);
|
|
@@ -291,7 +289,7 @@ function linkSides(options) {
|
|
|
291
289
|
default:
|
|
292
290
|
break;
|
|
293
291
|
}
|
|
294
|
-
uvs.push.apply(uvs,
|
|
292
|
+
uvs.push.apply(uvs, __spreadArrays(sealUvs, sealUvs));
|
|
295
293
|
}
|
|
296
294
|
var indices = triangles || [];
|
|
297
295
|
// if (isDefined(shapes[0][0].index)) {
|
|
@@ -318,12 +316,12 @@ var defaultExtrudeOption = {
|
|
|
318
316
|
sealEnd: false,
|
|
319
317
|
normal: Vec3_1.Vec3.UnitZ,
|
|
320
318
|
};
|
|
321
|
-
var _matrix =
|
|
322
|
-
var _matrix1 =
|
|
323
|
-
var _quat =
|
|
324
|
-
var _quat1 =
|
|
325
|
-
var _vec1 =
|
|
326
|
-
var _vec2 =
|
|
319
|
+
var _matrix = Mat4_1.m4();
|
|
320
|
+
var _matrix1 = Mat4_1.m4();
|
|
321
|
+
var _quat = Quat_1.quat();
|
|
322
|
+
var _quat1 = Quat_1.quat();
|
|
323
|
+
var _vec1 = Vec3_1.v3();
|
|
324
|
+
var _vec2 = Vec3_1.v3();
|
|
327
325
|
/**
|
|
328
326
|
* @description : 挤压形状生成几何体
|
|
329
327
|
* @param {IExtrudeOptionsEx} options
|
|
@@ -370,8 +368,8 @@ function extrude(options) {
|
|
|
370
368
|
}
|
|
371
369
|
}
|
|
372
370
|
var ups = options.ups || [];
|
|
373
|
-
if (
|
|
374
|
-
shapePath.array = shapePath.array.map(function (e) { return
|
|
371
|
+
if (types_1.isUndefined(shapePath.first.z)) {
|
|
372
|
+
shapePath.array = shapePath.array.map(function (e) { return Vec3_1.v3(e.x, e.y, 0); });
|
|
375
373
|
options.normal = options.normal || Vec3_1.Vec3.UnitZ;
|
|
376
374
|
}
|
|
377
375
|
var up = options.up;
|
|
@@ -381,17 +379,17 @@ function extrude(options) {
|
|
|
381
379
|
var point = path.get(i);
|
|
382
380
|
var direction = point.direction;
|
|
383
381
|
var upi = void 0;
|
|
384
|
-
upi = ups[i] || up ||
|
|
382
|
+
upi = ups[i] || up || Vec3_1.v3().crossVecs(right, direction);
|
|
385
383
|
var righti = right;
|
|
386
384
|
if (!right)
|
|
387
|
-
righti =
|
|
385
|
+
righti = Vec3_1.v3().crossVecs(upi, direction).normalize();
|
|
388
386
|
_matrix.makeBasis(righti, upi, direction);
|
|
389
387
|
_matrix.setPosition(point);
|
|
390
388
|
var new_shape = shapePath.clone();
|
|
391
389
|
new_shape.applyMat4(_matrix);
|
|
392
390
|
shapes.push(new_shape);
|
|
393
391
|
if (options.holes) {
|
|
394
|
-
var mholes =
|
|
392
|
+
var mholes = pointset_1.applyMat4(options.holes, _matrix, false);
|
|
395
393
|
newholes.push(mholes);
|
|
396
394
|
}
|
|
397
395
|
}
|
|
@@ -435,7 +433,7 @@ function extrude_obsolete(shape, arg_path, options) {
|
|
|
435
433
|
if (!isCCW)
|
|
436
434
|
shape.reverse();
|
|
437
435
|
var normal = options.normal;
|
|
438
|
-
var startSeal =
|
|
436
|
+
var startSeal = common_1.clone(shape);
|
|
439
437
|
var shapepath = new Path_1.Path(shape);
|
|
440
438
|
var insertNum = 0;
|
|
441
439
|
for (var i = 1; i < shapepath.length - 1; i++) { //大角度插入点 角度过大为了呈现flat shader的效果
|
|
@@ -457,21 +455,21 @@ function extrude_obsolete(shape, arg_path, options) {
|
|
|
457
455
|
for (var i = 0; i < path.length; i++) {
|
|
458
456
|
var node = path[i];
|
|
459
457
|
var dir = node.tangent;
|
|
460
|
-
var newShape =
|
|
461
|
-
|
|
458
|
+
var newShape = common_1.clone(shape);
|
|
459
|
+
common_1.rotateByUnitVectors(newShape, normal, dir);
|
|
462
460
|
if (options.fixedY) {
|
|
463
461
|
var v = Vec3_1.Vec3.UnitX;
|
|
464
|
-
|
|
462
|
+
common_1.rotateByUnitVectors([v], normal, dir);
|
|
465
463
|
var v1 = v.clone();
|
|
466
464
|
v1.y = 0;
|
|
467
|
-
|
|
465
|
+
common_1.rotateByUnitVectors(newShape, v, v1);
|
|
468
466
|
}
|
|
469
|
-
|
|
467
|
+
pointset_1.translate(newShape, node);
|
|
470
468
|
shapeArray.push(newShape);
|
|
471
469
|
}
|
|
472
470
|
var gindex = { index: 0 };
|
|
473
|
-
var vertices =
|
|
474
|
-
|
|
471
|
+
var vertices = array_1.flat(shapeArray);
|
|
472
|
+
mesh_1.indexable(vertices, gindex);
|
|
475
473
|
var index = linkSides({ shapes: shapeArray, shapeClosed: options.shapeClosed, pathClosed: options.isClosed2, orgShape: shape }).index;
|
|
476
474
|
shapepath = new Path_1.Path(shape);
|
|
477
475
|
var uvs = [];
|
|
@@ -480,34 +478,34 @@ function extrude_obsolete(shape, arg_path, options) {
|
|
|
480
478
|
uvs.push(shapepath.get(j).tlen * options.textureScale.x, path.get(i).tlen * options.textureScale.y);
|
|
481
479
|
}
|
|
482
480
|
}
|
|
483
|
-
var sealUv =
|
|
481
|
+
var sealUv = common_1.clone(startSeal);
|
|
484
482
|
if (normal.dot(Vec3_1.Vec3.UnitZ) < 1 - 1e-4)
|
|
485
|
-
|
|
486
|
-
var endSeal =
|
|
487
|
-
|
|
483
|
+
common_1.rotateByUnitVectors(sealUv, normal, Vec3_1.Vec3.UnitZ);
|
|
484
|
+
var endSeal = common_1.clone(startSeal);
|
|
485
|
+
common_1.rotateByUnitVectors(startSeal, normal, path[0].tangent);
|
|
488
486
|
if (options.fixedY) {
|
|
489
487
|
var v = Vec3_1.Vec3.UnitX;
|
|
490
|
-
|
|
488
|
+
common_1.rotateByUnitVectors([v], normal, path[0].tangent);
|
|
491
489
|
var v1 = v.clone();
|
|
492
490
|
v1.y = 0;
|
|
493
|
-
|
|
491
|
+
common_1.rotateByUnitVectors(startSeal, v, v1);
|
|
494
492
|
}
|
|
495
|
-
|
|
496
|
-
|
|
493
|
+
pointset_1.translate(startSeal, path[0]);
|
|
494
|
+
common_1.rotateByUnitVectors(endSeal, normal, path.get(-1).tangent);
|
|
497
495
|
if (options.fixedY) {
|
|
498
496
|
var v = Vec3_1.Vec3.UnitX;
|
|
499
|
-
|
|
497
|
+
common_1.rotateByUnitVectors([v], normal, path.get(-1).tangent);
|
|
500
498
|
var v1 = v.clone();
|
|
501
499
|
v1.y = 0;
|
|
502
|
-
|
|
500
|
+
common_1.rotateByUnitVectors(endSeal, v, v1);
|
|
503
501
|
}
|
|
504
|
-
|
|
505
|
-
var sealStartTris =
|
|
502
|
+
pointset_1.translate(endSeal, path.get(-1));
|
|
503
|
+
var sealStartTris = trianglution_1.triangulation(sealUv, [], { normal: normal });
|
|
506
504
|
sealStartTris.reverse();
|
|
507
505
|
if (options.sealStart)
|
|
508
|
-
|
|
506
|
+
mesh_1.indexable(startSeal, gindex);
|
|
509
507
|
if (options.sealEnd)
|
|
510
|
-
|
|
508
|
+
mesh_1.indexable(endSeal, gindex);
|
|
511
509
|
var sealEndTris = [];
|
|
512
510
|
var hasVLen = vertices.length;
|
|
513
511
|
if (options.sealStart)
|
|
@@ -569,10 +567,10 @@ var EndType;
|
|
|
569
567
|
*/
|
|
570
568
|
function extrudeNext(options) {
|
|
571
569
|
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);
|
|
572
|
-
var path = options.shapeCenter ?
|
|
570
|
+
var path = options.shapeCenter ? pointset_1.translate(options.path, options.shapeCenter, false) : options.path;
|
|
573
571
|
var shape = options.shape;
|
|
574
|
-
|
|
575
|
-
|
|
572
|
+
array_1.unique(path, function (a, b) { return a.equals(b); });
|
|
573
|
+
array_1.unique(shape, function (a, b) { return a.equals(b); });
|
|
576
574
|
var pathPath = new Path_1.Path(path, options.pathClosed, true);
|
|
577
575
|
var starti = options.shapeClosed ? 0 : 1;
|
|
578
576
|
var shapePath = new Path_1.Path(shape, options.shapeClosed);
|
|
@@ -584,13 +582,13 @@ function extrudeNext(options) {
|
|
|
584
582
|
}
|
|
585
583
|
}
|
|
586
584
|
options.normal = options.normal || Vec3_1.Vec3.UnitZ;
|
|
587
|
-
if (
|
|
588
|
-
shapePath.array = shapePath.array.map(function (e) { return
|
|
585
|
+
if (types_1.isUndefined(shapePath.first.z)) {
|
|
586
|
+
shapePath.array = shapePath.array.map(function (e) { return Vec3_1.v3(e.x, e.y, 0); });
|
|
589
587
|
}
|
|
590
588
|
var up = options.up;
|
|
591
589
|
var right = options.right;
|
|
592
590
|
var shapes = [], newholes = [];
|
|
593
|
-
var accMat =
|
|
591
|
+
var accMat = Mat4_1.m4();
|
|
594
592
|
/**
|
|
595
593
|
* 如果路径闭合 要考虑首尾shape矩阵变化后还能一致吻合
|
|
596
594
|
*/
|
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 =
|
|
10
|
+
var _Vec = 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(
|
|
56
|
+
return applyQuat(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(
|
|
73
|
+
return translate(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(
|
|
115
|
+
return applyMat4(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(
|
|
180
|
+
return projectOnPlane(common_1.clone(points), plane, projectDirect);
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
exports.projectOnPlane = projectOnPlane;
|
package/dist/alg/trianglution.js
CHANGED
|
@@ -10,14 +10,12 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
13
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
14
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
15
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
16
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
17
|
+
r[k] = a[j];
|
|
18
|
+
return r;
|
|
21
19
|
};
|
|
22
20
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
21
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -55,13 +53,13 @@ function triangulation(inboundary, holes, options) {
|
|
|
55
53
|
var dim = options.dim;
|
|
56
54
|
var normal = options.normal;
|
|
57
55
|
if (normal && normal.dot(Vec3_1.Vec3.UnitZ) < 1 - Math_1.delta4) {
|
|
58
|
-
boundary =
|
|
59
|
-
|
|
56
|
+
boundary = common_1.clone(inboundary);
|
|
57
|
+
common_1.rotateByUnitVectors(boundary, normal, Vec3_1.Vec3.UnitZ);
|
|
60
58
|
}
|
|
61
59
|
else {
|
|
62
60
|
boundary = inboundary;
|
|
63
61
|
}
|
|
64
|
-
var allV =
|
|
62
|
+
var allV = __spreadArrays(boundary, array_1.flat(holes));
|
|
65
63
|
var vertextNumbers = vector_1.default.verctorToNumbers(allV, feature);
|
|
66
64
|
var holesIndex = [];
|
|
67
65
|
var baseIndex = boundary.length;
|
|
@@ -71,7 +69,7 @@ function triangulation(inboundary, holes, options) {
|
|
|
71
69
|
// holesIndex.push(baseIndex + hole.length);
|
|
72
70
|
baseIndex += hole.length;
|
|
73
71
|
}
|
|
74
|
-
var result =
|
|
72
|
+
var result = earcut_1.default(vertextNumbers, holesIndex, dim);
|
|
75
73
|
return result;
|
|
76
74
|
}
|
|
77
75
|
exports.triangulation = triangulation;
|
package/dist/app.js
CHANGED
|
@@ -6,11 +6,7 @@
|
|
|
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
|
-
|
|
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);
|
|
9
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
14
10
|
}) : (function(o, m, k, k2) {
|
|
15
11
|
if (k2 === undefined) k2 = k;
|
|
16
12
|
o[k2] = m[k];
|
|
@@ -23,7 +19,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
23
19
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
24
20
|
if (mod && mod.__esModule) return mod;
|
|
25
21
|
var result = {};
|
|
26
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
27
23
|
__setModuleDefault(result, mod);
|
|
28
24
|
return result;
|
|
29
25
|
};
|
|
@@ -147,7 +143,7 @@ glv.run();
|
|
|
147
143
|
// polyline.offset(1)
|
|
148
144
|
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)];
|
|
149
145
|
var path1 = [new cga.Vec3(), new cga.Vec3(0, 0, 100)];
|
|
150
|
-
|
|
146
|
+
extrude_1.extrude({ shape: shape1, path: path1, enableSmooth: true });
|
|
151
147
|
var dizhu = function (bottomR, topR, bh, gh, th) {
|
|
152
148
|
var bq = [];
|
|
153
149
|
var tq = [];
|
|
@@ -170,19 +166,19 @@ var dizhu = function (bottomR, topR, bh, gh, th) {
|
|
|
170
166
|
var geometry = cga.toGeometryBuffer(geo);
|
|
171
167
|
return geometry;
|
|
172
168
|
};
|
|
173
|
-
var shape = [
|
|
174
|
-
var hole3 = [
|
|
175
|
-
var hole1 = [
|
|
176
|
-
var hole2 = [
|
|
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)];
|
|
177
173
|
var holes = [hole1, hole2, hole3];
|
|
178
174
|
var path = [];
|
|
179
175
|
var ia = Math.PI / 100;
|
|
180
176
|
for (var i = 0; i <= 100; i++) {
|
|
181
177
|
var x = Math.cos(ia * i) * 50 + 50;
|
|
182
178
|
var y = Math.sin(ia * i) * 50;
|
|
183
|
-
path.push(
|
|
179
|
+
path.push(Vec3_1.v3(x, y, 0));
|
|
184
180
|
}
|
|
185
|
-
var geo =
|
|
181
|
+
var geo = extrude_1.extrude({ shape: shape, path: path, right: Vec3_1.Vec3.UnitZ, sealStart: true });
|
|
186
182
|
// var geo = dizhu(1.8, 0.9, 0.3, 0.5, 10);
|
|
187
183
|
var geometry = cga.toGeometryBuffer(geo);
|
|
188
184
|
geometry.computeVertexNormals();
|
|
@@ -234,7 +230,7 @@ planeGeo.translate(0, 5, -1);
|
|
|
234
230
|
var mesh = new three_1.Mesh(planeGeo, shapeMaterial);
|
|
235
231
|
glv.add(mesh);
|
|
236
232
|
var m = new Mat4_1.Mat4();
|
|
237
|
-
var geo =
|
|
233
|
+
var geo = extrude_1.extrude({ shape: shape, path: path, right: Vec3_1.Vec3.UnitZ, sealStart: true });
|
|
238
234
|
var geometry = cga.toGeometryBuffer(geo);
|
|
239
235
|
geometry.computeVertexNormals();
|
|
240
236
|
var tgeo = new THREE.BufferGeometry();
|
|
@@ -1,11 +1,7 @@
|
|
|
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
|
-
|
|
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);
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
5
|
}) : (function(o, m, k, k2) {
|
|
10
6
|
if (k2 === undefined) k2 = k;
|
|
11
7
|
o[k2] = m[k];
|
|
@@ -18,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
18
14
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
15
|
if (mod && mod.__esModule) return mod;
|
|
20
16
|
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
18
|
__setModuleDefault(result, mod);
|
|
23
19
|
return result;
|
|
24
20
|
};
|
|
@@ -3,12 +3,10 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -14,7 +14,7 @@ var extrude_1 = require("../alg/extrude");
|
|
|
14
14
|
var trianglution_1 = require("../alg/trianglution");
|
|
15
15
|
var array_1 = require("../utils/array");
|
|
16
16
|
function toGeometryBuffer(geo) {
|
|
17
|
-
var buffer =
|
|
17
|
+
var buffer = mesh_1.toGeoBuffer(geo.position, geo.index, geo.uv);
|
|
18
18
|
return buffer;
|
|
19
19
|
}
|
|
20
20
|
exports.toGeometryBuffer = toGeometryBuffer;
|
|
@@ -25,8 +25,8 @@ exports.toGeometryBuffer = toGeometryBuffer;
|
|
|
25
25
|
* @param {*} options
|
|
26
26
|
*/
|
|
27
27
|
function extrudeToGeometryBuffer(shape, arg_path, options) {
|
|
28
|
-
var extrudeRes =
|
|
29
|
-
return
|
|
28
|
+
var extrudeRes = extrude_1.extrude_obsolete(shape, arg_path, options);
|
|
29
|
+
return mesh_1.toGeoBuffer(extrudeRes.vertices, extrudeRes.index, extrudeRes.uvs);
|
|
30
30
|
}
|
|
31
31
|
exports.extrudeToGeometryBuffer = extrudeToGeometryBuffer;
|
|
32
32
|
/**
|
|
@@ -39,7 +39,7 @@ exports.extrudeToGeometryBuffer = extrudeToGeometryBuffer;
|
|
|
39
39
|
function linkToGeometry(shape, shape1, axisPlane, shapeClose) {
|
|
40
40
|
if (axisPlane === void 0) { axisPlane = trianglution_1.AxisPlane.XY; }
|
|
41
41
|
if (shapeClose === void 0) { shapeClose = false; }
|
|
42
|
-
var geo =
|
|
42
|
+
var geo = extrude_1.linkSides({ shapes: [shape, shape1], shapeClosed: shapeClose, orgShape: shape, axisPlane: axisPlane });
|
|
43
43
|
var geometry = toGeometryBuffer(geo);
|
|
44
44
|
return geometry;
|
|
45
45
|
}
|
|
@@ -53,9 +53,9 @@ exports.linkToGeometry = linkToGeometry;
|
|
|
53
53
|
function linksToGeometry(shapes, pathClosed, shapeClosed) {
|
|
54
54
|
if (pathClosed === void 0) { pathClosed = true; }
|
|
55
55
|
if (shapeClosed === void 0) { shapeClosed = true; }
|
|
56
|
-
var vertices =
|
|
57
|
-
|
|
58
|
-
var geo =
|
|
56
|
+
var vertices = array_1.flat(shapes);
|
|
57
|
+
mesh_1.indexable(vertices);
|
|
58
|
+
var geo = extrude_1.linkSides({ shapes: shapes, shapeClosed: pathClosed, orgShape: shapes[0] });
|
|
59
59
|
var geometry = toGeometryBuffer(geo);
|
|
60
60
|
return geometry;
|
|
61
61
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
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
|
-
|
|
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);
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
5
|
}) : (function(o, m, k, k2) {
|
|
10
6
|
if (k2 === undefined) k2 = k;
|
|
11
7
|
o[k2] = m[k];
|
|
12
8
|
}));
|
|
13
9
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !
|
|
10
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
15
11
|
};
|
|
16
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
13
|
__exportStar(require("./utils/array"), exports);
|
package/dist/math/Color.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { EventHandler } from "
|
|
2
|
-
export declare function hue2rgb(p: number, q: number, t: number): number;
|
|
3
|
-
export declare function SRGBToLinear(c: number): number;
|
|
4
|
-
export declare function LinearToSRGB(c: number): number;
|
|
1
|
+
import { EventHandler } from "../render/eventhandler";
|
|
5
2
|
export declare class Color extends EventHandler {
|
|
6
3
|
private _r;
|
|
7
4
|
private _g;
|
|
8
5
|
private _b;
|
|
9
6
|
private _a;
|
|
10
|
-
get isColor(): boolean;
|
|
11
7
|
constructor(_r?: number, _g?: number, _b?: number, _a?: number);
|
|
8
|
+
get isColor(): boolean;
|
|
12
9
|
get r(): number;
|
|
13
10
|
set r(value: number);
|
|
14
11
|
get g(): number;
|