@xort/cga 0.0.72 → 0.0.73

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.
Files changed (57) hide show
  1. package/dist/IKanimation/Bone.js +1 -3
  2. package/dist/IKanimation/CCDSolver.js +2 -2
  3. package/dist/IKanimation/constaint/hinge.js +1 -3
  4. package/dist/IKanimation/constaint/slider.js +1 -3
  5. package/dist/alg/common.js +2 -2
  6. package/dist/alg/extrude.js +54 -56
  7. package/dist/alg/pointset.js +5 -5
  8. package/dist/alg/trianglution.js +10 -12
  9. package/dist/app.js +10 -14
  10. package/dist/diamondMaterialShader.js +2 -6
  11. package/dist/effect/breath-light.js +1 -3
  12. package/dist/extends/geometryaid.js +7 -7
  13. package/dist/index.d.ts +1 -0
  14. package/dist/index.js +3 -6
  15. package/dist/math/Color.d.ts +29 -0
  16. package/dist/math/Color.js +195 -0
  17. package/dist/math/Euler.js +10 -12
  18. package/dist/math/HVec3.js +1 -3
  19. package/dist/math/Mat3.js +1 -1
  20. package/dist/math/Mat4.js +6 -6
  21. package/dist/math/Quat.js +2 -4
  22. package/dist/math/Vec.js +1 -3
  23. package/dist/math/Vec2.js +1 -3
  24. package/dist/math/Vec3.js +5 -7
  25. package/dist/math/Vec4.js +1 -3
  26. package/dist/math/vector.js +7 -9
  27. package/dist/render/buffer-attribute.js +28 -12
  28. package/dist/render/eventhandler.d.ts +1 -1
  29. package/dist/render/eventhandler.js +7 -9
  30. package/dist/render/geometry.js +2 -2
  31. package/dist/render/mesh.js +9 -11
  32. package/dist/render/thing.js +8 -10
  33. package/dist/render/types.js +1 -2
  34. package/dist/struct/3d/Box.js +3 -3
  35. package/dist/struct/3d/Capsule.js +1 -3
  36. package/dist/struct/3d/Circle.js +2 -2
  37. package/dist/struct/3d/Disk.js +1 -1
  38. package/dist/struct/3d/Line.js +4 -4
  39. package/dist/struct/3d/Path.js +11 -13
  40. package/dist/struct/3d/Plane.js +10 -12
  41. package/dist/struct/3d/Point.js +1 -3
  42. package/dist/struct/3d/Polygon.js +1 -3
  43. package/dist/struct/3d/Polyline.js +1 -3
  44. package/dist/struct/3d/Rectangle.js +1 -3
  45. package/dist/struct/3d/Segment.js +7 -9
  46. package/dist/struct/3d/Shape.js +1 -3
  47. package/dist/struct/3d/Sphere.js +1 -1
  48. package/dist/struct/3d/Triangle.js +1 -3
  49. package/dist/struct/data/ArrayList.js +9 -11
  50. package/dist/struct/data/ArrayObject.js +1 -3
  51. package/docs/guide/distLineAll.md +5 -5
  52. package/docs/guide/distPointAll.md +6 -6
  53. package/docs/guide/distRayAll.md +4 -4
  54. package/docs/guide/distSegmentAll.md +1 -1
  55. package/package.json +2 -2
  56. package/src/index.ts +1 -0
  57. package/src/math/Color.ts +157 -0
@@ -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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
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 = (0, Math_1.clamp)(vc1.normalize().dot(vc2.normalize()), -1, 1);
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 = (0, Vec3_1.v3)().cross(dir0, dir1).normalize();
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
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 __());
@@ -16,13 +16,13 @@ var XYZSort = function (e1, e2) {
16
16
  else
17
17
  return e1.z - e2.z;
18
18
  };
19
- var _vector = (0, Vec3_1.v3)();
19
+ var _vector = Vec3_1.v3();
20
20
  /**
21
21
  * 数组深度复制
22
22
  * @param {Array} array
23
23
  */
24
24
  function clone(array) {
25
- if (!(0, types_1.isDefined)(array))
25
+ if (!types_1.isDefined(array))
26
26
  return array;
27
27
  if (Array.isArray(array)) {
28
28
  var result = new Array();
@@ -18,14 +18,12 @@ var __assign = (this && this.__assign) || function () {
18
18
  };
19
19
  return __assign.apply(this, arguments);
20
20
  };
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));
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 ((0, types_1.isDefined)(side0[0].index)) {
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
- (0, mesh_1.indexable)(allVertics, index);
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 = (0, common_1.clone)(shapes[0]);
167
+ var startShape = common_1.clone(shapes[0]);
170
168
  allVertics.push(startShape);
171
169
  if (holess && holess[0]) {
172
- var startHoles = (0, common_1.clone)(holess[0]);
170
+ var startHoles = common_1.clone(holess[0]);
173
171
  allVertics.push(startHoles);
174
172
  }
175
- var startTris = (0, trianglution_1.triangulation)(orgShape, orgHoles, { feature: trianglution_1.AxisPlane.XYZ });
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 = (0, common_1.clone)(shapes[shapes.length - 1]);
187
+ var endShape = common_1.clone(shapes[shapes.length - 1]);
190
188
  allVertics.push(endShape);
191
189
  if (holess && holess[0]) {
192
- var endHoles = (0, common_1.clone)((0, common_1.clone)(holess[holess.length - 1]));
190
+ var endHoles = common_1.clone(common_1.clone(holess[holess.length - 1]));
193
191
  allVertics.push(endHoles);
194
192
  }
195
- var endTris = (0, trianglution_1.triangulation)(orgShape, orgHoles, { feature: trianglution_1.AxisPlane.XYZ });
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, __spreadArray(__spreadArray([], sealUvs, false), sealUvs, false));
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 = (0, Mat4_1.m4)();
322
- var _matrix1 = (0, Mat4_1.m4)();
323
- var _quat = (0, Quat_1.quat)();
324
- var _quat1 = (0, Quat_1.quat)();
325
- var _vec1 = (0, Vec3_1.v3)();
326
- var _vec2 = (0, Vec3_1.v3)();
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 ((0, types_1.isUndefined)(shapePath.first.z)) {
374
- shapePath.array = shapePath.array.map(function (e) { return (0, Vec3_1.v3)(e.x, e.y, 0); });
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 || (0, Vec3_1.v3)().crossVecs(right, direction);
382
+ upi = ups[i] || up || Vec3_1.v3().crossVecs(right, direction);
385
383
  var righti = right;
386
384
  if (!right)
387
- righti = (0, Vec3_1.v3)().crossVecs(upi, direction).normalize();
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 = (0, pointset_1.applyMat4)(options.holes, _matrix, false);
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 = (0, common_1.clone)(shape);
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 = (0, common_1.clone)(shape);
461
- (0, common_1.rotateByUnitVectors)(newShape, normal, dir);
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
- (0, common_1.rotateByUnitVectors)([v], normal, dir);
462
+ common_1.rotateByUnitVectors([v], normal, dir);
465
463
  var v1 = v.clone();
466
464
  v1.y = 0;
467
- (0, common_1.rotateByUnitVectors)(newShape, v, v1);
465
+ common_1.rotateByUnitVectors(newShape, v, v1);
468
466
  }
469
- (0, pointset_1.translate)(newShape, node);
467
+ pointset_1.translate(newShape, node);
470
468
  shapeArray.push(newShape);
471
469
  }
472
470
  var gindex = { index: 0 };
473
- var vertices = (0, array_1.flat)(shapeArray);
474
- (0, mesh_1.indexable)(vertices, gindex);
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 = (0, common_1.clone)(startSeal);
481
+ var sealUv = common_1.clone(startSeal);
484
482
  if (normal.dot(Vec3_1.Vec3.UnitZ) < 1 - 1e-4)
485
- (0, common_1.rotateByUnitVectors)(sealUv, normal, Vec3_1.Vec3.UnitZ);
486
- var endSeal = (0, common_1.clone)(startSeal);
487
- (0, common_1.rotateByUnitVectors)(startSeal, normal, path[0].tangent);
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
- (0, common_1.rotateByUnitVectors)([v], normal, path[0].tangent);
488
+ common_1.rotateByUnitVectors([v], normal, path[0].tangent);
491
489
  var v1 = v.clone();
492
490
  v1.y = 0;
493
- (0, common_1.rotateByUnitVectors)(startSeal, v, v1);
491
+ common_1.rotateByUnitVectors(startSeal, v, v1);
494
492
  }
495
- (0, pointset_1.translate)(startSeal, path[0]);
496
- (0, common_1.rotateByUnitVectors)(endSeal, normal, path.get(-1).tangent);
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
- (0, common_1.rotateByUnitVectors)([v], normal, path.get(-1).tangent);
497
+ common_1.rotateByUnitVectors([v], normal, path.get(-1).tangent);
500
498
  var v1 = v.clone();
501
499
  v1.y = 0;
502
- (0, common_1.rotateByUnitVectors)(endSeal, v, v1);
500
+ common_1.rotateByUnitVectors(endSeal, v, v1);
503
501
  }
504
- (0, pointset_1.translate)(endSeal, path.get(-1));
505
- var sealStartTris = (0, trianglution_1.triangulation)(sealUv, [], { normal: normal });
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
- (0, mesh_1.indexable)(startSeal, gindex);
506
+ mesh_1.indexable(startSeal, gindex);
509
507
  if (options.sealEnd)
510
- (0, mesh_1.indexable)(endSeal, gindex);
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 ? (0, pointset_1.translate)(options.path, options.shapeCenter, false) : options.path;
570
+ var path = options.shapeCenter ? pointset_1.translate(options.path, options.shapeCenter, false) : options.path;
573
571
  var shape = options.shape;
574
- (0, array_1.unique)(path, function (a, b) { return a.equals(b); });
575
- (0, array_1.unique)(shape, function (a, b) { return a.equals(b); });
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 ((0, types_1.isUndefined)(shapePath.first.z)) {
588
- shapePath.array = shapePath.array.map(function (e) { return (0, Vec3_1.v3)(e.x, e.y, 0); });
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 = (0, Mat4_1.m4)();
591
+ var accMat = Mat4_1.m4();
594
592
  /**
595
593
  * 如果路径闭合 要考虑首尾shape矩阵变化后还能一致吻合
596
594
  */
@@ -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 = (0, Vec3_1.v3)();
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((0, common_1.clone)(points), quat);
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((0, common_1.clone)(points));
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((0, common_1.clone)(points), mat4);
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((0, common_1.clone)(points), plane, projectDirect);
180
+ return projectOnPlane(common_1.clone(points), plane, projectDirect);
181
181
  }
182
182
  }
183
183
  exports.projectOnPlane = projectOnPlane;
@@ -10,14 +10,12 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
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));
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 = (0, common_1.clone)(inboundary);
59
- (0, common_1.rotateByUnitVectors)(boundary, normal, Vec3_1.Vec3.UnitZ);
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 = __spreadArray(__spreadArray([], boundary, true), (0, array_1.flat)(holes), true);
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 = (0, earcut_1.default)(vertextNumbers, holesIndex, dim);
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
- 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);
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.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
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
- (0, extrude_1.extrude)({ shape: shape1, path: path1, enableSmooth: true });
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 = [(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)];
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((0, Vec3_1.v3)(x, y, 0));
179
+ path.push(Vec3_1.v3(x, y, 0));
184
180
  }
185
- var geo = (0, extrude_1.extrude)({ shape: shape, path: path, right: Vec3_1.Vec3.UnitZ, sealStart: true });
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 = (0, extrude_1.extrude)({ shape: shape, path: path, right: Vec3_1.Vec3.UnitZ, sealStart: true });
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
- 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);
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.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
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 = (0, mesh_1.toGeoBuffer)(geo.position, geo.index, geo.uv);
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 = (0, extrude_1.extrude_obsolete)(shape, arg_path, options);
29
- return (0, mesh_1.toGeoBuffer)(extrudeRes.vertices, extrudeRes.index, extrudeRes.uvs);
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 = (0, extrude_1.linkSides)({ shapes: [shape, shape1], shapeClosed: shapeClose, orgShape: shape, axisPlane: axisPlane });
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 = (0, array_1.flat)(shapes);
57
- (0, mesh_1.indexable)(vertices);
58
- var geo = (0, extrude_1.linkSides)({ shapes: shapes, shapeClosed: pathClosed, orgShape: shapes[0] });
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.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from "./math/Mat4";
7
7
  export * from "./math/Quat";
8
8
  export * from "./math/Math";
9
9
  export * from "./math/Euler";
10
+ export * from "./math/Color";
10
11
  export * from "./math/vector";
11
12
  export * from "./alg/common";
12
13
  export * from "./alg/result";
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
- 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);
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" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
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);
@@ -23,6 +19,7 @@ __exportStar(require("./math/Mat4"), exports);
23
19
  __exportStar(require("./math/Quat"), exports);
24
20
  __exportStar(require("./math/Math"), exports);
25
21
  __exportStar(require("./math/Euler"), exports);
22
+ __exportStar(require("./math/Color"), exports);
26
23
  //common
27
24
  __exportStar(require("./math/vector"), exports);
28
25
  __exportStar(require("./alg/common"), exports);
@@ -0,0 +1,29 @@
1
+ import { EventHandler } from "src/render/eventhandler";
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;
5
+ export declare class Color extends EventHandler {
6
+ private _r;
7
+ private _g;
8
+ private _b;
9
+ private _a;
10
+ get isColor(): boolean;
11
+ constructor(_r?: number, _g?: number, _b?: number, _a?: number);
12
+ get r(): number;
13
+ set r(value: number);
14
+ get g(): number;
15
+ set g(value: number);
16
+ get b(): number;
17
+ set b(value: number);
18
+ get a(): number;
19
+ set a(value: number);
20
+ set(value: any): this;
21
+ setHex(hex: number): this;
22
+ setRGB(r: number, g: number, b: number, a?: number): this;
23
+ clone(): any;
24
+ copy(color: this): this;
25
+ equals(c: this): boolean;
26
+ toArray(array?: number[], offset?: number): number[];
27
+ getHex(): number;
28
+ toJSON(): number;
29
+ }