@xort/cga 0.0.78 → 0.0.79

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 (51) 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.js +2 -6
  14. package/dist/math/Color.d.ts +1 -0
  15. package/dist/math/Color.js +40 -5
  16. package/dist/math/Euler.js +10 -12
  17. package/dist/math/HVec3.js +1 -3
  18. package/dist/math/Mat3.js +1 -1
  19. package/dist/math/Mat4.js +6 -6
  20. package/dist/math/Quat.js +2 -4
  21. package/dist/math/Vec.js +1 -3
  22. package/dist/math/Vec2.js +1 -3
  23. package/dist/math/Vec3.js +5 -7
  24. package/dist/math/Vec4.js +1 -3
  25. package/dist/math/vector.js +7 -9
  26. package/dist/render/buffer-attribute.js +28 -12
  27. package/dist/render/eventhandler.d.ts +1 -1
  28. package/dist/render/eventhandler.js +7 -9
  29. package/dist/render/geometry.js +2 -2
  30. package/dist/render/mesh.js +9 -11
  31. package/dist/render/thing.js +8 -10
  32. package/dist/render/types.js +1 -2
  33. package/dist/struct/3d/Box.js +3 -3
  34. package/dist/struct/3d/Capsule.js +1 -3
  35. package/dist/struct/3d/Circle.js +2 -2
  36. package/dist/struct/3d/Disk.js +1 -1
  37. package/dist/struct/3d/Line.js +4 -4
  38. package/dist/struct/3d/Path.js +11 -13
  39. package/dist/struct/3d/Plane.js +10 -12
  40. package/dist/struct/3d/Point.js +1 -3
  41. package/dist/struct/3d/Polygon.js +1 -3
  42. package/dist/struct/3d/Polyline.js +1 -3
  43. package/dist/struct/3d/Rectangle.js +1 -3
  44. package/dist/struct/3d/Segment.js +7 -9
  45. package/dist/struct/3d/Shape.js +1 -3
  46. package/dist/struct/3d/Sphere.js +1 -1
  47. package/dist/struct/3d/Triangle.js +1 -3
  48. package/dist/struct/data/ArrayList.js +9 -11
  49. package/dist/struct/data/ArrayObject.js +1 -3
  50. package/package.json +1 -1
  51. package/src/math/Color.ts +50 -8
@@ -5,9 +5,9 @@ var Vec3_1 = require("../../math/Vec3");
5
5
  var _vector = new Vec3_1.Vec3();
6
6
  var Box = /** @class */ (function () {
7
7
  function Box(min, max) {
8
- if (min === void 0) { min = (0, Vec3_1.v3)(Infinity, Infinity, Infinity); }
9
- if (max === void 0) { max = (0, Vec3_1.v3)(-Infinity, -Infinity, -Infinity); }
10
- this._center = (0, Vec3_1.v3)();
8
+ if (min === void 0) { min = Vec3_1.v3(Infinity, Infinity, Infinity); }
9
+ if (max === void 0) { max = Vec3_1.v3(-Infinity, -Infinity, -Infinity); }
10
+ this._center = Vec3_1.v3();
11
11
  this.min = min;
12
12
  this.max = max;
13
13
  // if (points) {
@@ -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 __());
@@ -35,7 +35,7 @@ var Circle = /** @class */ (function () {
35
35
  Circle.prototype.arc1 = function (fixp0, fixp1, movep, normal) {
36
36
  this.setFrom3Points(fixp0, fixp1, movep);
37
37
  this.startAngle = 0;
38
- this.endAngle = (0, common_1.angle)(fixp0.clone().sub(this.center).normalize(), fixp1.clone().sub(this.center).normalize(), this.normal || normal);
38
+ this.endAngle = common_1.angle(fixp0.clone().sub(this.center).normalize(), fixp1.clone().sub(this.center).normalize(), this.normal || normal);
39
39
  };
40
40
  /**
41
41
  * 全两个点确定半径,后面点确定 弧度 ,只需要检测鼠标移动时鼠标是否跨过第一条半径即可确定顺逆时针
@@ -49,7 +49,7 @@ var Circle = /** @class */ (function () {
49
49
  this.center.copy(center);
50
50
  var v2 = movep.clone().sub(center);
51
51
  var v1 = fixp1.clone().sub(center);
52
- var jd = (0, common_1.angle)(v1, v2);
52
+ var jd = common_1.angle(v1, v2);
53
53
  };
54
54
  Circle.prototype.setFrom3Points = function (p0, p1, p2, normal) {
55
55
  // if (pointsCollinear(p0, p1, p2))
@@ -5,7 +5,7 @@ var Vec3_1 = require("../../math/Vec3");
5
5
  var Disk = /** @class */ (function () {
6
6
  function Disk(center, radius, normal) {
7
7
  if (normal === void 0) { normal = Vec3_1.Vec3.UnitY; }
8
- this.center = center || (0, Vec3_1.v3)();
8
+ this.center = center || Vec3_1.v3();
9
9
  this.normal = normal;
10
10
  this.radius = radius || 0;
11
11
  this.w = this.normal.dot(center);
@@ -8,8 +8,8 @@ var _v1 = new Vec3_1.Vec3;
8
8
  ;
9
9
  var Line = /** @class */ (function () {
10
10
  function Line(origin, end) {
11
- if (origin === void 0) { origin = (0, Vec3_1.v3)(); }
12
- if (end === void 0) { end = (0, Vec3_1.v3)(); }
11
+ if (origin === void 0) { origin = Vec3_1.v3(); }
12
+ if (end === void 0) { end = Vec3_1.v3(); }
13
13
  this.origin = origin;
14
14
  this.end = end;
15
15
  this.direction = this.end
@@ -192,10 +192,10 @@ var Line = /** @class */ (function () {
192
192
  if (robust === void 0) { robust = false; }
193
193
  if (numInputs === 1) {
194
194
  if (Math.abs(v[0][0]) > Math.abs(v[0][1])) {
195
- v[1] = (0, Vec3_1.v3)(-v[0].z, 0, +v[0].x);
195
+ v[1] = Vec3_1.v3(-v[0].z, 0, +v[0].x);
196
196
  }
197
197
  else {
198
- v[1] = (0, Vec3_1.v3)(0, +v[0].z, -v[0].y);
198
+ v[1] = Vec3_1.v3(0, +v[0].z, -v[0].y);
199
199
  }
200
200
  ;
201
201
  numInputs = 2;
@@ -10,12 +10,10 @@ var __extends = (this && this.__extends) || (function () {
10
10
  var extendStatics = function (d, b) {
11
11
  extendStatics = Object.setPrototypeOf ||
12
12
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
13
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14
14
  return extendStatics(d, b);
15
15
  };
16
16
  return function (d, b) {
17
- if (typeof b !== "function" && b !== null)
18
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
19
17
  extendStatics(d, b);
20
18
  function __() { this.constructor = d; }
21
19
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -75,15 +73,15 @@ var Path = /** @class */ (function (_super) {
75
73
  var normal = new Vec3_1.Vec3();
76
74
  normal.crossVecs(d1, d2).normalize();
77
75
  this.get(i).normal = normal;
78
- var bdir = (0, Vec3_1.v3)().addVecs(d1, d2).normalize();
76
+ var bdir = Vec3_1.v3().addVecs(d1, d2).normalize();
79
77
  this.get(i).bdirection = bdir;
80
- this.get(i).bnormal = (0, Vec3_1.v3)().crossVecs(bdir, normal).normalize();
78
+ this.get(i).bnormal = Vec3_1.v3().crossVecs(bdir, normal).normalize();
81
79
  // }
82
80
  }
83
81
  if (!this._closed) { //不闭合路径 最后一个点没有
84
- this.get(-1).bdirection = (0, Vec3_1.v3)();
85
- this.get(-1).normal = (0, Vec3_1.v3)();
86
- this.get(-1).bnormal = (0, Vec3_1.v3)();
82
+ this.get(-1).bdirection = Vec3_1.v3();
83
+ this.get(-1).normal = Vec3_1.v3();
84
+ this.get(-1).bnormal = Vec3_1.v3();
87
85
  }
88
86
  if (!this._closed) {
89
87
  // 不闭合的情况下怎么样去计算端点的up和normal
@@ -118,10 +116,10 @@ var Path = /** @class */ (function (_super) {
118
116
  configurable: true
119
117
  });
120
118
  Path.prototype.applyMat4 = function (mat4) {
121
- (0, pointset_1.applyMat4)(this._array, mat4);
119
+ pointset_1.applyMat4(this._array, mat4);
122
120
  };
123
121
  Path.prototype.scale = function (x, y, z) {
124
- (0, common_1.scale)(this._array, (0, Vec3_1.v3)(x, y, z), true);
122
+ common_1.scale(this._array, Vec3_1.v3(x, y, z), true);
125
123
  };
126
124
  /**
127
125
  * 截取一段从from到to的path
@@ -159,7 +157,7 @@ var Path = /** @class */ (function (_super) {
159
157
  Path.prototype.getPointByDistance = function (arg_distance, left, right) {
160
158
  if (left === void 0) { left = 0; }
161
159
  if (right === void 0) { right = this.length - 1; }
162
- var distance = (0, Math_1.clamp)(arg_distance, 0, this.get(-1).tlen);
160
+ var distance = Math_1.clamp(arg_distance, 0, this.get(-1).tlen);
163
161
  if (distance !== arg_distance)
164
162
  return null;
165
163
  if (right - left === 1) {
@@ -188,7 +186,7 @@ var Path = /** @class */ (function (_super) {
188
186
  Path.prototype.getPointByDistancePure = function (arg_distance, left, right) {
189
187
  if (left === void 0) { left = 0; }
190
188
  if (right === void 0) { right = this.length - 1; }
191
- var distance = (0, Math_1.clamp)(arg_distance, 0, this.get(-1).tlen);
189
+ var distance = Math_1.clamp(arg_distance, 0, this.get(-1).tlen);
192
190
  if (distance !== arg_distance)
193
191
  return null;
194
192
  if (right - left === 1) {
@@ -296,7 +294,7 @@ var Path = /** @class */ (function (_super) {
296
294
  res.push(mileages);
297
295
  }
298
296
  if (normalize) {
299
- var tl = (0, types_1.isDefined)(totalMileage) ? totalMileage : this.totalMileages(ps);
297
+ var tl = types_1.isDefined(totalMileage) ? totalMileage : this.totalMileages(ps);
300
298
  for (var i = 0, len = ps.length; i < len; i++) {
301
299
  res[i] /= tl;
302
300
  }
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
2
+ var __spreadArrays = (this && this.__spreadArrays) || function () {
3
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
4
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
5
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
6
+ r[k] = a[j];
7
+ return r;
10
8
  };
11
9
  Object.defineProperty(exports, "__esModule", { value: true });
12
10
  exports.Plane = void 0;
@@ -70,9 +68,9 @@ var Plane = /** @class */ (function () {
70
68
  */
71
69
  Plane.prototype.frontback = function (point) {
72
70
  var value = this.normal.dot(point);
73
- if ((0, Math_1.approximateEqual)(value, 0))
71
+ if (Math_1.approximateEqual(value, 0))
74
72
  return 0;
75
- return (0, Math_1.sign)(this.normal.dot(point));
73
+ return Math_1.sign(this.normal.dot(point));
76
74
  };
77
75
  //---Distance-------------------------------------------------------------------------------
78
76
  Plane.prototype.distancePoint = function (point) {
@@ -225,8 +223,8 @@ var Plane = /** @class */ (function () {
225
223
  * @param polyVS
226
224
  */
227
225
  Plane.prototype.splitPolyVS = function (polyVS) {
228
- polyVS = __spreadArray([], polyVS, true);
229
- (0, mesh_1.indexable)(polyVS);
226
+ polyVS = __spreadArrays(polyVS);
227
+ mesh_1.indexable(polyVS);
230
228
  var jd0 = -1; //找出第一个交点
231
229
  var jdp0; //找出第一个交点
232
230
  var lastOriention = this.orientationPoint(polyVS[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 __());
@@ -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 __());
@@ -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 __());
@@ -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 __());
@@ -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 __());
@@ -25,16 +23,16 @@ var Segment = /** @class */ (function (_super) {
25
23
  * @param {Point|Vec3} p1
26
24
  */
27
25
  function Segment(_p0, _p1) {
28
- if (_p0 === void 0) { _p0 = (0, Vec3_1.v3)(); }
29
- if (_p1 === void 0) { _p1 = (0, Vec3_1.v3)(); }
26
+ if (_p0 === void 0) { _p0 = Vec3_1.v3(); }
27
+ if (_p1 === void 0) { _p1 = Vec3_1.v3(); }
30
28
  var _this = _super.call(this) || this;
31
29
  Object.setPrototypeOf(_this, Segment.prototype);
32
- _this.push((0, Vec3_1.v3)().copy(_p0), (0, Vec3_1.v3)().copy(_p1));
33
- _this.center = (0, Vec3_1.v3)().addVecs(_p0, _p1).multiplyScalar(0.5);
34
- _this.extentDirection = (0, Vec3_1.v3)().subVecs(_p1, _p0);
30
+ _this.push(Vec3_1.v3().copy(_p0), Vec3_1.v3().copy(_p1));
31
+ _this.center = Vec3_1.v3().addVecs(_p0, _p1).multiplyScalar(0.5);
32
+ _this.extentDirection = Vec3_1.v3().subVecs(_p1, _p0);
35
33
  _this.extentSqr = _this.extentDirection.lengthSq();
36
34
  _this.extent = Math.sqrt(_this.extentSqr);
37
- _this.direction = (0, Vec3_1.v3)().copy(_this.extentDirection).normalize();
35
+ _this.direction = Vec3_1.v3().copy(_this.extentDirection).normalize();
38
36
  return _this;
39
37
  }
40
38
  Segment.prototype.set = function (p0, p1) {
@@ -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 __());
@@ -4,7 +4,7 @@ exports.Sphere = void 0;
4
4
  var Vec3_1 = require("../../math/Vec3");
5
5
  var Sphere = /** @class */ (function () {
6
6
  function Sphere(center, radius) {
7
- if (center === void 0) { center = (0, Vec3_1.v3)(); }
7
+ if (center === void 0) { center = Vec3_1.v3(); }
8
8
  if (radius === void 0) { radius = 0; }
9
9
  this.center = center;
10
10
  this.radius = radius;
@@ -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 __());
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
2
+ var __spreadArrays = (this && this.__spreadArrays) || function () {
3
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
4
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
5
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
6
+ r[k] = a[j];
7
+ return r;
10
8
  };
11
9
  Object.defineProperty(exports, "__esModule", { value: true });
12
10
  exports.ArrayList = void 0;
@@ -85,7 +83,7 @@ var ArrayList = /** @class */ (function () {
85
83
  for (var _i = 1; _i < arguments.length; _i++) {
86
84
  value[_i - 1] = arguments[_i];
87
85
  }
88
- (_a = this._array).splice.apply(_a, __spreadArray([i, 0], value, false));
86
+ (_a = this._array).splice.apply(_a, __spreadArrays([i, 0], value));
89
87
  };
90
88
  ArrayList.prototype.splice = function (start, deleteCount) {
91
89
  var _a;
@@ -93,7 +91,7 @@ var ArrayList = /** @class */ (function () {
93
91
  for (var _i = 2; _i < arguments.length; _i++) {
94
92
  items[_i - 2] = arguments[_i];
95
93
  }
96
- (_a = this._array).splice.apply(_a, __spreadArray([start, deleteCount], items, false));
94
+ (_a = this._array).splice.apply(_a, __spreadArrays([start, deleteCount], items));
97
95
  };
98
96
  ArrayList.prototype.get = function (index) {
99
97
  if (index < 0)
@@ -113,7 +111,7 @@ var ArrayList = /** @class */ (function () {
113
111
  * 克隆
114
112
  */
115
113
  ArrayList.prototype.clone = function () {
116
- return new this.constructor((0, common_1.clone)(this._array));
114
+ return new this.constructor(common_1.clone(this._array));
117
115
  };
118
116
  /**
119
117
  * 分类
@@ -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 __());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xort/cga",
3
- "version": "0.0.78",
3
+ "version": "0.0.79",
4
4
  "description": "Xtor Compute Geometry Algorithm Libary 计算几何算法库",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/math/Color.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { EventHandler } from "../render/eventhandler";
2
2
 
3
3
  export class Color extends EventHandler {
4
- _r: number =0.0;
5
- _g: number =0.0;
6
- _b: number =0.0;
7
- _a: number =1.0;
4
+ _r: number = 0.0;
5
+ _g: number = 0.0;
6
+ _b: number = 0.0;
7
+ _a: number = 1.0;
8
8
  constructor(r: number = 0, g: number = 0, b: number = 0, a: number = 1) {
9
9
  super();
10
10
  this._r = r;
@@ -74,7 +74,6 @@ export class Color extends EventHandler {
74
74
  }
75
75
 
76
76
  setHex(hex: number) {
77
-
78
77
  hex = Math.floor(hex);
79
78
  if (hex > 0xffffff) {
80
79
  this._r = (hex >> 32 & 255) / 255;
@@ -88,7 +87,50 @@ export class Color extends EventHandler {
88
87
  }
89
88
 
90
89
  return this;
90
+ }
91
+
92
+ setStyle(style: string) {
93
+ let m: any = /^\#([A-Fa-f\d]+)$/.exec(style)
94
+ // hex color
95
+
96
+ const hex = m[1];
97
+ const size = hex.length;
98
+
99
+ if (size === 3) {
100
+
101
+ // #ff0
102
+ this.r = parseInt(hex.charAt(0) + hex.charAt(0), 16) / 255;
103
+ this.g = parseInt(hex.charAt(1) + hex.charAt(1), 16) / 255;
104
+ this.b = parseInt(hex.charAt(2) + hex.charAt(2), 16) / 255;
91
105
 
106
+ return this;
107
+
108
+ } else if (size === 6) {
109
+
110
+ // #ff0000
111
+ this.r = parseInt(hex.charAt(0) + hex.charAt(1), 16) / 255;
112
+ this.g = parseInt(hex.charAt(2) + hex.charAt(3), 16) / 255;
113
+ this.b = parseInt(hex.charAt(4) + hex.charAt(5), 16) / 255;
114
+ return this;
115
+ }
116
+ else if (size === 4) {
117
+
118
+ // #ff0000
119
+ this.r = parseInt(hex.charAt(0) + hex.charAt(0), 16) / 255;
120
+ this.g = parseInt(hex.charAt(1) + hex.charAt(1), 16) / 255;
121
+ this.b = parseInt(hex.charAt(2) + hex.charAt(2), 16) / 255;
122
+ this.a = parseInt(hex.charAt(3) + hex.charAt(3), 16) / 255;
123
+ return this;
124
+ }
125
+ else if (size === 8) {
126
+
127
+ // #ff0000
128
+ this.r = parseInt(hex.charAt(0) + hex.charAt(1), 16) / 255;
129
+ this.g = parseInt(hex.charAt(2) + hex.charAt(3), 16) / 255;
130
+ this.b = parseInt(hex.charAt(4) + hex.charAt(5), 16) / 255;
131
+ this.a = parseInt(hex.charAt(6) + hex.charAt(7), 16) / 255;
132
+ return this;
133
+ }
92
134
  }
93
135
 
94
136
  setRGB(r: number, g: number, b: number, a: number = 1.0) {
@@ -99,7 +141,6 @@ export class Color extends EventHandler {
99
141
  this._a = a;
100
142
 
101
143
  return this;
102
-
103
144
  }
104
145
 
105
146
  clone() {
@@ -110,12 +151,13 @@ export class Color extends EventHandler {
110
151
  this._r = color.r;
111
152
  this._g = color.g;
112
153
  this._b = color.b;
154
+ this._a = color.a;
113
155
 
114
156
  return this;
115
157
  }
116
158
 
117
159
  equals(c: this) {
118
- return (c.r === this.r) && (c.g === this.g) && (c.b === this.b);
160
+ return (c.r === this.r) && (c.g === this.g) && (c.b === this.b) && (c.a === this.a);
119
161
  }
120
162
 
121
163
  toArray(array: number[] = [], offset = 0) {
@@ -129,7 +171,7 @@ export class Color extends EventHandler {
129
171
  }
130
172
 
131
173
  getHex() {
132
- return (this.r * 255) << 32 ^ (this.g * 255) << 16 ^ (this.b * 255) << 8 ^ (this.a * 255) << 0;
174
+ return (this.r * 255) << 24 ^ (this.g * 255) << 16 ^ (this.b * 255) << 8 ^ (this.a * 255) << 0;
133
175
  }
134
176
 
135
177
  toJSON() {