@xort/cga 0.0.85 → 0.0.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) 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.d.ts +12 -3
  33. package/dist/struct/3d/Circle.js +34 -6
  34. package/dist/struct/3d/Disk.js +1 -1
  35. package/dist/struct/3d/Line.js +4 -4
  36. package/dist/struct/3d/Path.js +13 -11
  37. package/dist/struct/3d/Plane.d.ts +3 -3
  38. package/dist/struct/3d/Plane.js +23 -18
  39. package/dist/struct/3d/Point.js +3 -1
  40. package/dist/struct/3d/Polygon.js +3 -1
  41. package/dist/struct/3d/Polyline.d.ts +9 -0
  42. package/dist/struct/3d/Polyline.js +25 -2
  43. package/dist/struct/3d/Rectangle.js +3 -1
  44. package/dist/struct/3d/Segment.js +9 -7
  45. package/dist/struct/3d/Shape.js +3 -1
  46. package/dist/struct/3d/Sphere.js +1 -1
  47. package/dist/struct/3d/Triangle.js +3 -1
  48. package/dist/struct/bsp.d.ts +0 -0
  49. package/dist/struct/bsp.js +1 -0
  50. package/dist/struct/btree.d.ts +0 -0
  51. package/dist/struct/btree.js +1 -0
  52. package/dist/struct/data/ArrayList.js +11 -9
  53. package/dist/struct/data/ArrayObject.js +3 -1
  54. package/dist/struct/kdtree.d.ts +0 -0
  55. package/dist/struct/kdtree.js +1 -0
  56. package/dist/struct/polyTree.d.ts +4 -0
  57. package/dist/struct/polyTree.js +27 -0
  58. package/dist/struct/quatTree.d.ts +0 -0
  59. package/dist/struct/quatTree.js +1 -0
  60. package/dist/struct/tree.d.ts +11 -0
  61. package/dist/struct/tree.js +26 -0
  62. package/dist/utils/types.d.ts +2 -2
  63. package/package.json +4 -3
  64. package/rollup.config.js +22 -14
  65. package/src/index.ts +1 -0
  66. package/src/math/Color.ts +6 -0
  67. package/src/struct/3d/Circle.ts +37 -8
  68. package/src/struct/3d/Plane.ts +15 -11
  69. package/src/struct/3d/PolyLine.ts +18 -1
  70. package/src/struct/3d/Polygon.ts +2 -0
  71. package/src/struct/bsp.ts +0 -0
  72. package/src/struct/btree.ts +0 -0
  73. package/src/struct/kdtree.ts +0 -0
  74. package/src/struct/polyTree.ts +8 -0
  75. package/src/struct/quatTree.ts +0 -0
  76. package/src/struct/tree.ts +30 -0
  77. package/tsconfig.json +2 -0
  78. package/dist/shape/arc.d.ts +0 -2
  79. package/dist/shape/arc.js +0 -14
  80. package/src/shape/arc.ts +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 __());
@@ -4,7 +4,7 @@ export declare class Circle {
4
4
  radius: number;
5
5
  normal: Vec3;
6
6
  startAngle: number;
7
- endAngle: number;
7
+ lengthAngle: number;
8
8
  radiusSqr: number;
9
9
  /**
10
10
  * 圆圈
@@ -12,7 +12,7 @@ export declare class Circle {
12
12
  * @param {Vec3} normal 法线
13
13
  * @param {Number} radius 半径
14
14
  */
15
- constructor(center?: Vec3, radius?: number, normal?: Vec3);
15
+ constructor(center?: Vec3, radius?: number, startAngle?: number, lengthAngle?: number, normal?: Vec3);
16
16
  area(): number;
17
17
  /**
18
18
  * 两个点
@@ -30,5 +30,14 @@ export declare class Circle {
30
30
  */
31
31
  arc2(center: Vec3, fixp1: Vec3, movep: Vec3, ccw?: boolean, normal?: Vec3): void;
32
32
  setFrom3Points(p0: Vec3, p1: Vec3, p2: Vec3, normal?: Vec3): this;
33
+ /**
34
+ * 将圆环或者圆弧转化为路径点,生成XY平面上得三维点
35
+ * @param center 中心点
36
+ * @param radius 半径
37
+ * @param startAngle 起始角 右手坐标系 以X正坐标轴为起点 单位弧度
38
+ * @param lengthAngle 弧度长度 单位弧度
39
+ * @param segment 分段
40
+ */
41
+ static toVertices(center: Vec3, radius: number, startAngle?: number, lengthAngle?: number, segment?: number): Vec3[];
33
42
  }
34
- export declare function circle(center?: Vec3, radius?: number, normal?: Vec3): Circle;
43
+ export declare function circle(center?: Vec3, radius?: number): Circle;
@@ -11,16 +11,20 @@ var Circle = /** @class */ (function () {
11
11
  * @param {Vec3} normal 法线
12
12
  * @param {Number} radius 半径
13
13
  */
14
- function Circle(center, radius, normal) {
14
+ function Circle(center, radius, startAngle, lengthAngle, normal) {
15
15
  if (center === void 0) { center = new Vec3_1.Vec3(); }
16
16
  if (radius === void 0) { radius = 0; }
17
+ if (startAngle === void 0) { startAngle = 0; }
18
+ if (lengthAngle === void 0) { lengthAngle = Math.PI * 2; }
17
19
  if (normal === void 0) { normal = Vec3_1.Vec3.UnitY; }
18
20
  this.center = center;
19
21
  this.radius = radius;
20
22
  this.normal = normal;
21
23
  this.startAngle = 0;
22
- this.endAngle = Math.PI * 2;
24
+ this.lengthAngle = Math.PI * 2;
23
25
  this.radiusSqr = 0;
26
+ this.startAngle = startAngle;
27
+ this.lengthAngle = lengthAngle;
24
28
  }
25
29
  Circle.prototype.area = function () {
26
30
  return Math.PI * this.radius * this.radius;
@@ -35,7 +39,7 @@ var Circle = /** @class */ (function () {
35
39
  Circle.prototype.arc1 = function (fixp0, fixp1, movep, normal) {
36
40
  this.setFrom3Points(fixp0, fixp1, movep);
37
41
  this.startAngle = 0;
38
- this.endAngle = 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);
39
43
  };
40
44
  /**
41
45
  * 全两个点确定半径,后面点确定 弧度 ,只需要检测鼠标移动时鼠标是否跨过第一条半径即可确定顺逆时针
@@ -49,7 +53,7 @@ var Circle = /** @class */ (function () {
49
53
  this.center.copy(center);
50
54
  var v2 = movep.clone().sub(center);
51
55
  var v1 = fixp1.clone().sub(center);
52
- var jd = common_1.angle(v1, v2);
56
+ var jd = (0, common_1.angle)(v1, v2);
53
57
  };
54
58
  Circle.prototype.setFrom3Points = function (p0, p1, p2, normal) {
55
59
  // if (pointsCollinear(p0, p1, p2))
@@ -71,10 +75,34 @@ var Circle = /** @class */ (function () {
71
75
  this.normal = normal;
72
76
  return this;
73
77
  };
78
+ /**
79
+ * 将圆环或者圆弧转化为路径点,生成XY平面上得三维点
80
+ * @param center 中心点
81
+ * @param radius 半径
82
+ * @param startAngle 起始角 右手坐标系 以X正坐标轴为起点 单位弧度
83
+ * @param lengthAngle 弧度长度 单位弧度
84
+ * @param segment 分段
85
+ */
86
+ Circle.toVertices = function (center, radius, startAngle, lengthAngle, segment) {
87
+ if (startAngle === void 0) { startAngle = 0; }
88
+ if (lengthAngle === void 0) { lengthAngle = Math.PI * 2; }
89
+ if (segment === void 0) { segment = 16; }
90
+ var Xvec = Vec3_1.Vec3.UnitX;
91
+ Xvec.multiplyScalar(radius);
92
+ var result = [];
93
+ var up = Vec3_1.Vec3.UnitY;
94
+ var perAngle = lengthAngle / segment;
95
+ for (var i = 0; i <= segment; i++) {
96
+ var langlei = perAngle * i + startAngle;
97
+ var vi = Xvec.clone().applyAxisAngle(up, langlei).add(center);
98
+ result.push(vi);
99
+ }
100
+ return result;
101
+ };
74
102
  return Circle;
75
103
  }());
76
104
  exports.Circle = Circle;
77
- function circle(center, radius, normal) {
78
- return new Circle(center, radius, normal);
105
+ function circle(center, radius) {
106
+ return new Circle(center, radius);
79
107
  }
80
108
  exports.circle = circle;
@@ -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
@@ -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] = Vec3_1.v3(-v[0].z, 0, +v[0].x);
195
+ v[1] = (0, Vec3_1.v3)(-v[0].z, 0, +v[0].x);
196
196
  }
197
197
  else {
198
- v[1] = Vec3_1.v3(0, +v[0].z, -v[0].y);
198
+ v[1] = (0, Vec3_1.v3)(0, +v[0].z, -v[0].y);
199
199
  }
200
200
  ;
201
201
  numInputs = 2;