@xort/cga 0.0.86 → 0.0.88

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 (78) hide show
  1. package/build/cga.d.ts +2032 -0
  2. package/dist/IKanimation/CCDSolver.js +2 -2
  3. package/dist/IKanimation/constaint/hinge.js +3 -1
  4. package/dist/IKanimation/constaint/slider.js +3 -1
  5. package/dist/alg/common.js +2 -2
  6. package/dist/alg/delaunay.js +1 -1
  7. package/dist/alg/extrude.js +52 -50
  8. package/dist/alg/pointset.js +5 -5
  9. package/dist/alg/trianglution.js +12 -10
  10. package/dist/alg/voronoi.js +1 -1
  11. package/dist/app.js +14 -10
  12. package/dist/diamondMaterialShader.js +6 -2
  13. package/dist/effect/breath-light.js +3 -1
  14. package/dist/extends/geometryaid.js +4 -4
  15. package/dist/index.d.ts +1 -0
  16. package/dist/index.js +7 -2
  17. package/dist/math/Color.d.ts +4 -0
  18. package/dist/math/Color.js +30 -6
  19. package/dist/math/Euler.js +9 -9
  20. package/dist/math/Mat3.js +1 -1
  21. package/dist/math/Mat4.js +6 -6
  22. package/dist/math/Quat.js +1 -1
  23. package/dist/math/Vec3.js +4 -4
  24. package/dist/math/vecs.js +9 -7
  25. package/dist/render/bufferAttribute.js +12 -28
  26. package/dist/render/geometry.js +2 -2
  27. package/dist/render/mesh.js +11 -9
  28. package/dist/render/types.d.ts +2 -2
  29. package/dist/render/types.js +2 -1
  30. package/dist/struct/3d/Box.js +3 -3
  31. package/dist/struct/3d/Capsule.js +3 -1
  32. package/dist/struct/3d/Circle.js +2 -2
  33. package/dist/struct/3d/Disk.js +1 -1
  34. package/dist/struct/3d/Line.js +5 -4
  35. package/dist/struct/3d/Path.js +13 -11
  36. package/dist/struct/3d/Plane.d.ts +3 -3
  37. package/dist/struct/3d/Plane.js +23 -18
  38. package/dist/struct/3d/Point.js +3 -1
  39. package/dist/struct/3d/Polygon.js +3 -1
  40. package/dist/struct/3d/Polyline.d.ts +9 -0
  41. package/dist/struct/3d/Polyline.js +25 -2
  42. package/dist/struct/3d/Rectangle.js +3 -1
  43. package/dist/struct/3d/Segment.js +9 -7
  44. package/dist/struct/3d/Shape.js +3 -1
  45. package/dist/struct/3d/Sphere.js +1 -1
  46. package/dist/struct/3d/Triangle.js +3 -1
  47. package/dist/struct/bsp.d.ts +0 -0
  48. package/dist/struct/bsp.js +1 -0
  49. package/dist/struct/btree.d.ts +0 -0
  50. package/dist/struct/btree.js +1 -0
  51. package/dist/struct/data/ArrayList.js +11 -9
  52. package/dist/struct/data/ArrayObject.js +3 -1
  53. package/dist/struct/kdtree.d.ts +0 -0
  54. package/dist/struct/kdtree.js +1 -0
  55. package/dist/struct/polyTree.d.ts +4 -0
  56. package/dist/struct/polyTree.js +27 -0
  57. package/dist/struct/quatTree.d.ts +0 -0
  58. package/dist/struct/quatTree.js +1 -0
  59. package/dist/struct/tree.d.ts +11 -0
  60. package/dist/struct/tree.js +26 -0
  61. package/dist/utils/types.d.ts +2 -2
  62. package/package.json +4 -3
  63. package/rollup.config.js +22 -14
  64. package/src/index.ts +1 -0
  65. package/src/math/Color.ts +6 -0
  66. package/src/struct/3d/Line.ts +1 -1
  67. package/src/struct/3d/Plane.ts +15 -11
  68. package/src/struct/3d/PolyLine.ts +18 -1
  69. package/src/struct/3d/Polygon.ts +2 -0
  70. package/src/struct/bsp.ts +0 -0
  71. package/src/struct/btree.ts +0 -0
  72. package/src/struct/kdtree.ts +0 -0
  73. package/src/struct/polyTree.ts +8 -0
  74. package/src/struct/quatTree.ts +0 -0
  75. package/src/struct/tree.ts +30 -0
  76. package/tsconfig.json +2 -0
  77. package/dist/shape/arc.d.ts +0 -2
  78. package/dist/shape/arc.js +0 -14
@@ -184,28 +184,52 @@ var Color = /** @class */ (function () {
184
184
  Color.prototype.getHexCssString = function () {
185
185
  var r = this.floatToByte(this._r).toString(16);
186
186
  if (r.length < 2) {
187
- r = "0" + r;
187
+ r = "0".concat(r);
188
188
  }
189
189
  var g = this.floatToByte(this._g).toString(16);
190
190
  if (g.length < 2) {
191
- g = "0" + g;
191
+ g = "0".concat(g);
192
192
  }
193
193
  var b = this.floatToByte(this._b).toString(16);
194
194
  if (b.length < 2) {
195
- b = "0" + b;
195
+ b = "0".concat(b);
196
196
  }
197
197
  if (this._a < 1) {
198
198
  var hexAlpha = this.floatToByte(this._a).toString(16);
199
199
  if (hexAlpha.length < 2) {
200
- hexAlpha = "0" + hexAlpha;
200
+ hexAlpha = "0".concat(hexAlpha);
201
201
  }
202
- return "#" + r + g + b + hexAlpha;
202
+ return "#".concat(r).concat(g).concat(b).concat(hexAlpha);
203
203
  }
204
- return "#" + r + g + b;
204
+ return "#".concat(r).concat(g).concat(b);
205
205
  };
206
206
  Color.prototype.toJSON = function () {
207
207
  return this.getHexCssString();
208
208
  };
209
+ Object.defineProperty(Color, "White", {
210
+ get: function () { return Object.freeze(new Color(1, 1, 1)); },
211
+ enumerable: false,
212
+ configurable: true
213
+ });
214
+ ;
215
+ Object.defineProperty(Color, "Red", {
216
+ get: function () { return new Color(1, 0, 0); },
217
+ enumerable: false,
218
+ configurable: true
219
+ });
220
+ ;
221
+ Object.defineProperty(Color, "Green", {
222
+ get: function () { return new Color(0, 1, 0); },
223
+ enumerable: false,
224
+ configurable: true
225
+ });
226
+ ;
227
+ Object.defineProperty(Color, "Blue", {
228
+ get: function () { return new Color(0, 0, 1); },
229
+ enumerable: false,
230
+ configurable: true
231
+ });
232
+ ;
209
233
  return Color;
210
234
  }());
211
235
  exports.Color = Color;
@@ -5,8 +5,8 @@ var Vec3_1 = require("./Vec3");
5
5
  var Math_1 = require("./Math");
6
6
  var Mat4_1 = require("./Mat4");
7
7
  var Quat_1 = require("./Quat");
8
- var _matrix = Mat4_1.m4();
9
- var _Quat = Quat_1.quat();
8
+ var _matrix = (0, Mat4_1.m4)();
9
+ var _Quat = (0, Quat_1.quat)();
10
10
  var RotationOrders = ["XYZ", "YZX", "ZXY", "XZY", "YXZ", "ZYX"];
11
11
  var DefaultOrder = "XYZ";
12
12
  var Euler = /** @class */ (function () {
@@ -100,7 +100,7 @@ var Euler = /** @class */ (function () {
100
100
  var m31 = te[2], m32 = te[6], m33 = te[10];
101
101
  order = order || this._order;
102
102
  if (order === "XYZ") {
103
- this._y = Math.asin(Math_1.clamp(m13, -1, 1));
103
+ this._y = Math.asin((0, Math_1.clamp)(m13, -1, 1));
104
104
  if (Math.abs(m13) < 0.9999999) {
105
105
  this._x = Math.atan2(-m23, m33);
106
106
  this._z = Math.atan2(-m12, m11);
@@ -111,7 +111,7 @@ var Euler = /** @class */ (function () {
111
111
  }
112
112
  }
113
113
  else if (order === "YXZ") {
114
- this._x = Math.asin(-Math_1.clamp(m23, -1, 1));
114
+ this._x = Math.asin(-(0, Math_1.clamp)(m23, -1, 1));
115
115
  if (Math.abs(m23) < 0.9999999) {
116
116
  this._y = Math.atan2(m13, m33);
117
117
  this._z = Math.atan2(m21, m22);
@@ -122,7 +122,7 @@ var Euler = /** @class */ (function () {
122
122
  }
123
123
  }
124
124
  else if (order === "ZXY") {
125
- this._x = Math.asin(Math_1.clamp(m32, -1, 1));
125
+ this._x = Math.asin((0, Math_1.clamp)(m32, -1, 1));
126
126
  if (Math.abs(m32) < 0.9999999) {
127
127
  this._y = Math.atan2(-m31, m33);
128
128
  this._z = Math.atan2(-m12, m22);
@@ -133,7 +133,7 @@ var Euler = /** @class */ (function () {
133
133
  }
134
134
  }
135
135
  else if (order === "ZYX") {
136
- this._y = Math.asin(-Math_1.clamp(m31, -1, 1));
136
+ this._y = Math.asin(-(0, Math_1.clamp)(m31, -1, 1));
137
137
  if (Math.abs(m31) < 0.9999999) {
138
138
  this._x = Math.atan2(m32, m33);
139
139
  this._z = Math.atan2(m21, m11);
@@ -144,7 +144,7 @@ var Euler = /** @class */ (function () {
144
144
  }
145
145
  }
146
146
  else if (order === "YZX") {
147
- this._z = Math.asin(Math_1.clamp(m21, -1, 1));
147
+ this._z = Math.asin((0, Math_1.clamp)(m21, -1, 1));
148
148
  if (Math.abs(m21) < 0.9999999) {
149
149
  this._x = Math.atan2(-m23, m22);
150
150
  this._y = Math.atan2(-m31, m11);
@@ -155,7 +155,7 @@ var Euler = /** @class */ (function () {
155
155
  }
156
156
  }
157
157
  else if (order === "XZY") {
158
- this._z = Math.asin(-Math_1.clamp(m12, -1, 1));
158
+ this._z = Math.asin(-(0, Math_1.clamp)(m12, -1, 1));
159
159
  if (Math.abs(m12) < 0.9999999) {
160
160
  this._x = Math.atan2(m32, m22);
161
161
  this._y = Math.atan2(m13, m11);
@@ -213,7 +213,7 @@ var Euler = /** @class */ (function () {
213
213
  return optionalResult.set(this._x, this._y, this._z);
214
214
  }
215
215
  else {
216
- return Vec3_1.v3(this._x, this._y, this._z);
216
+ return (0, Vec3_1.v3)(this._x, this._y, this._z);
217
217
  }
218
218
  };
219
219
  return Euler;
package/dist/math/Mat3.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.m3 = exports.Mat3 = void 0;
4
4
  var Vec3_1 = require("./Vec3");
5
- var _Vec = Vec3_1.v3();
5
+ var _Vec = (0, Vec3_1.v3)();
6
6
  var Mat3 = /** @class */ (function () {
7
7
  function Mat3() {
8
8
  this.elements = [1, 0, 0, 0, 1, 0, 0, 0, 1];
package/dist/math/Mat4.js CHANGED
@@ -777,14 +777,14 @@ var Mat4 = /** @class */ (function () {
777
777
  return Mat4;
778
778
  }());
779
779
  exports.Mat4 = Mat4;
780
- var _v1 = Vec3_1.v3();
780
+ var _v1 = (0, Vec3_1.v3)();
781
781
  var _m1 = m4();
782
782
  var _m2 = m4();
783
- var _zero = Vec3_1.v3(0, 0, 0);
784
- var _one = Vec3_1.v3(1, 1, 1);
785
- var _x = Vec3_1.v3();
786
- var _y = Vec3_1.v3();
787
- var _z = Vec3_1.v3();
783
+ var _zero = (0, Vec3_1.v3)(0, 0, 0);
784
+ var _one = (0, Vec3_1.v3)(1, 1, 1);
785
+ var _x = (0, Vec3_1.v3)();
786
+ var _y = (0, Vec3_1.v3)();
787
+ var _z = (0, Vec3_1.v3)();
788
788
  function m4() {
789
789
  return new Mat4();
790
790
  }
package/dist/math/Quat.js CHANGED
@@ -261,7 +261,7 @@ var Quat = /** @class */ (function () {
261
261
  return this.normalize();
262
262
  };
263
263
  Quat.prototype.angleTo = function (q) {
264
- return 2 * Math.acos(Math.abs(Math_1.clamp(this.dot(q), -1, 1)));
264
+ return 2 * Math.acos(Math.abs((0, Math_1.clamp)(this.dot(q), -1, 1)));
265
265
  };
266
266
  Quat.prototype.rotateTowards = function (q, step) {
267
267
  var angle = this.angleTo(q);
package/dist/math/Vec3.js CHANGED
@@ -531,14 +531,14 @@ var Vec3 = /** @class */ (function () {
531
531
  if (normal)
532
532
  return this.angleToEx(v, normal);
533
533
  var theta = this.dot(v) / Math.sqrt(this.lengthSq() * v.lengthSq());
534
- return Math.acos(Math_1.clamp(theta, -1, 1));
534
+ return Math.acos((0, Math_1.clamp)(theta, -1, 1));
535
535
  };
536
536
  Vec3.prototype.angleToEx = function (v, normal) {
537
537
  var theta = this.dot(v) / Math.sqrt(this.lengthSq() * v.lengthSq());
538
538
  if (this.clone().cross(v).dot(normal) > 0)
539
- return Math.acos(Math_1.clamp(theta, -1, 1));
539
+ return Math.acos((0, Math_1.clamp)(theta, -1, 1));
540
540
  else
541
- return Math.PI * 2 - Math.acos(Math_1.clamp(theta, -1, 1));
541
+ return Math.PI * 2 - Math.acos((0, Math_1.clamp)(theta, -1, 1));
542
542
  };
543
543
  Vec3.prototype.distanceTo = function (v) {
544
544
  return Math.sqrt(this.distanceToSquared(v));
@@ -1063,7 +1063,7 @@ var Vec3 = /** @class */ (function () {
1063
1063
  }());
1064
1064
  exports.Vec3 = Vec3;
1065
1065
  var _vec = v3();
1066
- var _quat = Quat_1.quat();
1066
+ var _quat = (0, Quat_1.quat)();
1067
1067
  function v3(x, y, z) {
1068
1068
  return new Vec3(x, y, z);
1069
1069
  }
package/dist/math/vecs.js CHANGED
@@ -8,12 +8,14 @@
8
8
  * @LastEditTime : 2021-08-02 15:50:16
9
9
  * @FilePath : \cga.js\src\math\VecArray.ts
10
10
  */
11
- var __spreadArrays = (this && this.__spreadArrays) || function () {
12
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
13
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
14
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
15
- r[k] = a[j];
16
- return r;
11
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
12
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
13
+ if (ar || !(i in from)) {
14
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
15
+ ar[i] = from[i];
16
+ }
17
+ }
18
+ return to.concat(ar || Array.prototype.slice.call(from));
17
19
  };
18
20
  Object.defineProperty(exports, "__esModule", { value: true });
19
21
  exports.vecs = void 0;
@@ -291,7 +293,7 @@ var vecs = /** @class */ (function () {
291
293
  for (var _i = 2; _i < arguments.length; _i++) {
292
294
  vec[_i - 2] = arguments[_i];
293
295
  }
294
- vecs.splice.apply(vecs, __spreadArrays([i * vecs.length, 0], vecs));
296
+ vecs.splice.apply(vecs, __spreadArray([i * vecs.length, 0], vecs, false));
295
297
  };
296
298
  //
297
299
  /**
@@ -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 (b.hasOwnProperty(p)) d[p] = b[p]; };
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 __());
@@ -245,11 +247,9 @@ var Int8BufferAttribute = /** @class */ (function (_super) {
245
247
  __extends(Int8BufferAttribute, _super);
246
248
  function Int8BufferAttribute(array, itemSize, normalized) {
247
249
  if (normalized === void 0) { normalized = false; }
248
- var _this = this;
249
250
  if (Array.isArray(array))
250
251
  array = new Int8Array(array);
251
- _this = _super.call(this, new Int8Array(array), itemSize, normalized) || this;
252
- return _this;
252
+ return _super.call(this, new Int8Array(array), itemSize, normalized) || this;
253
253
  }
254
254
  return Int8BufferAttribute;
255
255
  }(BufferAttribute));
@@ -258,11 +258,9 @@ var Uint8BufferAttribute = /** @class */ (function (_super) {
258
258
  __extends(Uint8BufferAttribute, _super);
259
259
  function Uint8BufferAttribute(array, itemSize, normalized) {
260
260
  if (normalized === void 0) { normalized = false; }
261
- var _this = this;
262
261
  if (Array.isArray(array))
263
262
  array = new Uint8Array(array);
264
- _this = _super.call(this, array, itemSize, normalized) || this;
265
- return _this;
263
+ return _super.call(this, array, itemSize, normalized) || this;
266
264
  }
267
265
  return Uint8BufferAttribute;
268
266
  }(BufferAttribute));
@@ -271,11 +269,9 @@ var Uint8ClampedBufferAttribute = /** @class */ (function (_super) {
271
269
  __extends(Uint8ClampedBufferAttribute, _super);
272
270
  function Uint8ClampedBufferAttribute(array, itemSize, normalized) {
273
271
  if (normalized === void 0) { normalized = false; }
274
- var _this = this;
275
272
  if (Array.isArray(array))
276
273
  array = new Uint8ClampedArray(array);
277
- _this = _super.call(this, array, itemSize, normalized) || this;
278
- return _this;
274
+ return _super.call(this, array, itemSize, normalized) || this;
279
275
  }
280
276
  return Uint8ClampedBufferAttribute;
281
277
  }(BufferAttribute));
@@ -284,11 +280,9 @@ var Int16BufferAttribute = /** @class */ (function (_super) {
284
280
  __extends(Int16BufferAttribute, _super);
285
281
  function Int16BufferAttribute(array, itemSize, normalized) {
286
282
  if (normalized === void 0) { normalized = false; }
287
- var _this = this;
288
283
  if (Array.isArray(array))
289
284
  array = new Int16Array(array);
290
- _this = _super.call(this, array, itemSize, normalized) || this;
291
- return _this;
285
+ return _super.call(this, array, itemSize, normalized) || this;
292
286
  }
293
287
  return Int16BufferAttribute;
294
288
  }(BufferAttribute));
@@ -297,11 +291,9 @@ var Uint16BufferAttribute = /** @class */ (function (_super) {
297
291
  __extends(Uint16BufferAttribute, _super);
298
292
  function Uint16BufferAttribute(array, itemSize, normalized) {
299
293
  if (normalized === void 0) { normalized = false; }
300
- var _this = this;
301
294
  if (Array.isArray(array))
302
295
  array = new Uint16Array(array);
303
- _this = _super.call(this, array, itemSize) || this;
304
- return _this;
296
+ return _super.call(this, array, itemSize) || this;
305
297
  }
306
298
  return Uint16BufferAttribute;
307
299
  }(BufferAttribute));
@@ -310,11 +302,9 @@ var Int32BufferAttribute = /** @class */ (function (_super) {
310
302
  __extends(Int32BufferAttribute, _super);
311
303
  function Int32BufferAttribute(array, itemSize, normalized) {
312
304
  if (normalized === void 0) { normalized = false; }
313
- var _this = this;
314
305
  if (Array.isArray(array))
315
306
  array = new Int32Array(array);
316
- _this = _super.call(this, array, itemSize, normalized) || this;
317
- return _this;
307
+ return _super.call(this, array, itemSize, normalized) || this;
318
308
  }
319
309
  return Int32BufferAttribute;
320
310
  }(BufferAttribute));
@@ -323,11 +313,9 @@ var Uint32BufferAttribute = /** @class */ (function (_super) {
323
313
  __extends(Uint32BufferAttribute, _super);
324
314
  function Uint32BufferAttribute(array, itemSize, normalized) {
325
315
  if (normalized === void 0) { normalized = false; }
326
- var _this = this;
327
316
  if (Array.isArray(array))
328
317
  array = new Uint32Array(array);
329
- _this = _super.call(this, array, itemSize, normalized) || this;
330
- return _this;
318
+ return _super.call(this, array, itemSize, normalized) || this;
331
319
  }
332
320
  return Uint32BufferAttribute;
333
321
  }(BufferAttribute));
@@ -336,11 +324,9 @@ var Float32BufferAttribute = /** @class */ (function (_super) {
336
324
  __extends(Float32BufferAttribute, _super);
337
325
  function Float32BufferAttribute(array, itemSize, normalized) {
338
326
  if (normalized === void 0) { normalized = false; }
339
- var _this = this;
340
327
  if (Array.isArray(array))
341
328
  array = new Float32Array(array);
342
- _this = _super.call(this, array, itemSize, normalized) || this;
343
- return _this;
329
+ return _super.call(this, array, itemSize, normalized) || this;
344
330
  }
345
331
  return Float32BufferAttribute;
346
332
  }(BufferAttribute));
@@ -349,11 +335,9 @@ var Float64BufferAttribute = /** @class */ (function (_super) {
349
335
  __extends(Float64BufferAttribute, _super);
350
336
  function Float64BufferAttribute(array, itemSize, normalized) {
351
337
  if (normalized === void 0) { normalized = false; }
352
- var _this = this;
353
338
  if (Array.isArray(array))
354
339
  array = new Float64Array(array);
355
- _this = _super.call(this, array, itemSize, normalized) || this;
356
- return _this;
340
+ return _super.call(this, array, itemSize, normalized) || this;
357
341
  }
358
342
  return Float64BufferAttribute;
359
343
  }(BufferAttribute));
@@ -89,7 +89,7 @@ var BufferGeometry = /** @class */ (function () {
89
89
  else if (attribute instanceof bufferAttribute_1.BufferAttribute) {
90
90
  this.attributes[name] = attribute;
91
91
  }
92
- else if (types_1.isBufferArray(attribute)) {
92
+ else if ((0, types_1.isBufferArray)(attribute)) {
93
93
  this.setAttribute(name, new bufferAttribute_1.BufferAttribute(attribute, itemSize));
94
94
  }
95
95
  return this;
@@ -168,7 +168,7 @@ var BufferGeometry = /** @class */ (function () {
168
168
  return this;
169
169
  };
170
170
  BufferGeometry.prototype.lookAt = function (vector) {
171
- _m1.lookAt(Vec3_1.v3(), vector, Vec3_1.Vec3.UnitY);
171
+ _m1.lookAt((0, Vec3_1.v3)(), vector, Vec3_1.Vec3.UnitY);
172
172
  this.applyMat4(_m1);
173
173
  return this;
174
174
  };
@@ -1,10 +1,12 @@
1
1
  "use strict";
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;
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
8
10
  };
9
11
  Object.defineProperty(exports, "__esModule", { value: true });
10
12
  exports.MeshTool = void 0;
@@ -43,7 +45,7 @@ var MeshTool = /** @class */ (function () {
43
45
  MeshTool.triangListToBuffer = function (vertices, triangleList) {
44
46
  MeshTool.indexable(triangleList);
45
47
  var indices = [];
46
- array_1.forall(triangleList, function (v) {
48
+ (0, array_1.forall)(triangleList, function (v) {
47
49
  indices.push(v.index);
48
50
  });
49
51
  return MeshTool.toGeoBuffer(vertices, indices);
@@ -71,8 +73,8 @@ var MeshTool = /** @class */ (function () {
71
73
  MeshTool.trianglutionToGeometryBuffer = function (boundary, holes, options) {
72
74
  if (holes === void 0) { holes = []; }
73
75
  if (options === void 0) { options = { normal: Vec3_1.Vec3.UnitZ }; }
74
- var triangles = trianglution_1.triangulation(boundary, holes, options);
75
- var vertices = __spreadArrays(boundary, array_1.flat(holes));
76
+ var triangles = (0, trianglution_1.triangulation)(boundary, holes, options);
77
+ var vertices = __spreadArray(__spreadArray([], boundary, true), (0, array_1.flat)(holes), true);
76
78
  var uvs = [];
77
79
  vertices.forEach(function (v) {
78
80
  uvs.push(v.x, v.z);
@@ -1,3 +1,3 @@
1
- export declare type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
1
+ export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
2
2
  export declare const isBufferArray: (obj: any) => boolean;
3
- export declare type TypedArrayLike = number[] | Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
3
+ export type TypedArrayLike = number[] | Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isBufferArray = void 0;
4
- exports.isBufferArray = function (obj) {
4
+ var isBufferArray = function (obj) {
5
5
  var types = ['Int8Array', 'Uint8Array', 'Uint8ClampedArray', 'Int16Array', 'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array', 'Float64Array'];
6
6
  return types.indexOf(obj.constructor.name) > -1;
7
7
  };
8
+ exports.isBufferArray = isBufferArray;
@@ -5,9 +5,9 @@ var Vec3_1 = require("../../math/Vec3");
5
5
  var _vector = new Vec3_1.Vec3();
6
6
  var Box = /** @class */ (function () {
7
7
  function Box(min, max) {
8
- if (min === void 0) { min = Vec3_1.v3(Infinity, Infinity, Infinity); }
9
- if (max === void 0) { max = Vec3_1.v3(-Infinity, -Infinity, -Infinity); }
10
- this._center = Vec3_1.v3();
8
+ if (min === void 0) { min = (0, Vec3_1.v3)(Infinity, Infinity, Infinity); }
9
+ if (max === void 0) { max = (0, Vec3_1.v3)(-Infinity, -Infinity, -Infinity); }
10
+ this._center = (0, Vec3_1.v3)();
11
11
  this.min = min;
12
12
  this.max = max;
13
13
  // if (points) {
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
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 __());
@@ -39,7 +39,7 @@ var Circle = /** @class */ (function () {
39
39
  Circle.prototype.arc1 = function (fixp0, fixp1, movep, normal) {
40
40
  this.setFrom3Points(fixp0, fixp1, movep);
41
41
  this.startAngle = 0;
42
- this.lengthAngle = common_1.angle(fixp0.clone().sub(this.center).normalize(), fixp1.clone().sub(this.center).normalize(), this.normal || normal);
42
+ this.lengthAngle = (0, common_1.angle)(fixp0.clone().sub(this.center).normalize(), fixp1.clone().sub(this.center).normalize(), this.normal || normal);
43
43
  };
44
44
  /**
45
45
  * 全两个点确定半径,后面点确定 弧度 ,只需要检测鼠标移动时鼠标是否跨过第一条半径即可确定顺逆时针
@@ -53,7 +53,7 @@ var Circle = /** @class */ (function () {
53
53
  this.center.copy(center);
54
54
  var v2 = movep.clone().sub(center);
55
55
  var v1 = fixp1.clone().sub(center);
56
- var jd = common_1.angle(v1, v2);
56
+ var jd = (0, common_1.angle)(v1, v2);
57
57
  };
58
58
  Circle.prototype.setFrom3Points = function (p0, p1, p2, normal) {
59
59
  // 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 || Vec3_1.v3();
8
+ this.center = center || (0, Vec3_1.v3)();
9
9
  this.normal = normal;
10
10
  this.radius = radius || 0;
11
11
  this.w = this.normal.dot(center);
@@ -8,8 +8,8 @@ var _v1 = new Vec3_1.Vec3;
8
8
  ;
9
9
  var Line = /** @class */ (function () {
10
10
  function Line(origin, end) {
11
- if (origin === void 0) { origin = Vec3_1.v3(); }
12
- if (end === void 0) { end = Vec3_1.v3(); }
11
+ if (origin === void 0) { origin = (0, Vec3_1.v3)(); }
12
+ if (end === void 0) { end = (0, Vec3_1.v3)(); }
13
13
  this.origin = origin;
14
14
  this.end = end;
15
15
  this.direction = this.end
@@ -20,6 +20,7 @@ var Line = /** @class */ (function () {
20
20
  Line.prototype.set = function (origin, end) {
21
21
  this.origin.copy(origin);
22
22
  this.end.copy(end);
23
+ this.direction.subVecs(end, origin).normalize();
23
24
  return this;
24
25
  };
25
26
  Line.prototype.distancePoint = function (pt) {
@@ -192,10 +193,10 @@ var Line = /** @class */ (function () {
192
193
  if (robust === void 0) { robust = false; }
193
194
  if (numInputs === 1) {
194
195
  if (Math.abs(v[0][0]) > Math.abs(v[0][1])) {
195
- v[1] = Vec3_1.v3(-v[0].z, 0, +v[0].x);
196
+ v[1] = (0, Vec3_1.v3)(-v[0].z, 0, +v[0].x);
196
197
  }
197
198
  else {
198
- v[1] = Vec3_1.v3(0, +v[0].z, -v[0].y);
199
+ v[1] = (0, Vec3_1.v3)(0, +v[0].z, -v[0].y);
199
200
  }
200
201
  ;
201
202
  numInputs = 2;
@@ -10,10 +10,12 @@ var __extends = (this && this.__extends) || (function () {
10
10
  var extendStatics = function (d, b) {
11
11
  extendStatics = Object.setPrototypeOf ||
12
12
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
14
14
  return extendStatics(d, b);
15
15
  };
16
16
  return function (d, b) {
17
+ if (typeof b !== "function" && b !== null)
18
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
17
19
  extendStatics(d, b);
18
20
  function __() { this.constructor = d; }
19
21
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -73,15 +75,15 @@ var Path = /** @class */ (function (_super) {
73
75
  var normal = new Vec3_1.Vec3();
74
76
  normal.crossVecs(d1, d2).normalize();
75
77
  this.get(i).normal = normal;
76
- var bdir = Vec3_1.v3().addVecs(d1, d2).normalize();
78
+ var bdir = (0, Vec3_1.v3)().addVecs(d1, d2).normalize();
77
79
  this.get(i).bdirection = bdir;
78
- this.get(i).bnormal = Vec3_1.v3().crossVecs(bdir, normal).normalize();
80
+ this.get(i).bnormal = (0, Vec3_1.v3)().crossVecs(bdir, normal).normalize();
79
81
  // }
80
82
  }
81
83
  if (!this._closed) { //不闭合路径 最后一个点没有
82
- this.get(-1).bdirection = Vec3_1.v3();
83
- this.get(-1).normal = Vec3_1.v3();
84
- this.get(-1).bnormal = Vec3_1.v3();
84
+ this.get(-1).bdirection = (0, Vec3_1.v3)();
85
+ this.get(-1).normal = (0, Vec3_1.v3)();
86
+ this.get(-1).bnormal = (0, Vec3_1.v3)();
85
87
  }
86
88
  if (!this._closed) {
87
89
  // 不闭合的情况下怎么样去计算端点的up和normal
@@ -116,10 +118,10 @@ var Path = /** @class */ (function (_super) {
116
118
  configurable: true
117
119
  });
118
120
  Path.prototype.applyMat4 = function (mat4) {
119
- pointset_1.applyMat4(this._array, mat4);
121
+ (0, pointset_1.applyMat4)(this._array, mat4);
120
122
  };
121
123
  Path.prototype.scale = function (x, y, z) {
122
- common_1.scale(this._array, Vec3_1.v3(x, y, z), true);
124
+ (0, common_1.scale)(this._array, (0, Vec3_1.v3)(x, y, z), true);
123
125
  };
124
126
  /**
125
127
  * 截取一段从from到to的path
@@ -157,7 +159,7 @@ var Path = /** @class */ (function (_super) {
157
159
  Path.prototype.getPointByDistance = function (arg_distance, left, right) {
158
160
  if (left === void 0) { left = 0; }
159
161
  if (right === void 0) { right = this.length - 1; }
160
- var distance = Math_1.clamp(arg_distance, 0, this.get(-1).tlen);
162
+ var distance = (0, Math_1.clamp)(arg_distance, 0, this.get(-1).tlen);
161
163
  if (distance !== arg_distance)
162
164
  return null;
163
165
  if (right - left === 1) {
@@ -186,7 +188,7 @@ var Path = /** @class */ (function (_super) {
186
188
  Path.prototype.getPointByDistancePure = function (arg_distance, left, right) {
187
189
  if (left === void 0) { left = 0; }
188
190
  if (right === void 0) { right = this.length - 1; }
189
- var distance = Math_1.clamp(arg_distance, 0, this.get(-1).tlen);
191
+ var distance = (0, Math_1.clamp)(arg_distance, 0, this.get(-1).tlen);
190
192
  if (distance !== arg_distance)
191
193
  return null;
192
194
  if (right - left === 1) {
@@ -294,7 +296,7 @@ var Path = /** @class */ (function (_super) {
294
296
  res.push(mileages);
295
297
  }
296
298
  if (normalize) {
297
- var tl = types_1.isDefined(totalMileage) ? totalMileage : this.totalMileages(ps);
299
+ var tl = (0, types_1.isDefined)(totalMileage) ? totalMileage : this.totalMileages(ps);
298
300
  for (var i = 0, len = ps.length; i < len; i++) {
299
301
  res[i] /= tl;
300
302
  }
@@ -22,7 +22,7 @@ declare class Plane {
22
22
  * @param {Vec3} point
23
23
  * @returns {Number} -1 or 1 or z
24
24
  */
25
- frontback(point: any): 1 | -1 | 0;
25
+ frontback(point: any): 0 | 1 | -1;
26
26
  distancePoint(point: any): number;
27
27
  distanceRay(ray: any): void;
28
28
  distanceLine(line: any): void;
@@ -53,9 +53,9 @@ declare class Plane {
53
53
  splitTriangle(triangle: Triangle | Vec3[]): ISplitResult;
54
54
  /**
55
55
  * 平面切割线段
56
- * @param polyVS
56
+ * @param polygon
57
57
  */
58
- splitPolyVS(polyVS: Vec3[]): void;
58
+ splitConvexPolygon(polygon: Vec3[]): void;
59
59
  /**
60
60
  * 点在平面的位置判断
61
61
  * @param {Point} point