@xort/cga 0.0.86 → 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 (77) 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 +4 -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/Plane.ts +15 -11
  67. package/src/struct/3d/PolyLine.ts +18 -1
  68. package/src/struct/3d/Polygon.ts +2 -0
  69. package/src/struct/bsp.ts +0 -0
  70. package/src/struct/btree.ts +0 -0
  71. package/src/struct/kdtree.ts +0 -0
  72. package/src/struct/polyTree.ts +8 -0
  73. package/src/struct/quatTree.ts +0 -0
  74. package/src/struct/tree.ts +30 -0
  75. package/tsconfig.json +2 -0
  76. package/dist/shape/arc.d.ts +0 -2
  77. package/dist/shape/arc.js +0 -14
package/build/cga.d.ts ADDED
@@ -0,0 +1,2032 @@
1
+ /**
2
+ * 遍历多级数组中所有对象
3
+ * @param {Array} array
4
+ * @param {Function} method
5
+ */
6
+ declare function forall(array: Array<any>, method: (arg0: any, index?: number, that?: Array<any>) => void): void;
7
+ declare function flat(array: any[]): any[];
8
+ /**
9
+ * 分类
10
+ * example:
11
+ * var arry = [1,2,3,4,5,6]
12
+ * var result = classify(array,(a)={return a%2===0})
13
+ *
14
+ * @param {Array} array
15
+ * @param {Function} classifyMethod 分类方法
16
+ */
17
+ declare function classify(array: Array<any>, classifyMethod: (arg0: any, arg1: any, arg2: any[]) => any): any;
18
+ /**
19
+ * 去掉重复元素
20
+ * @param {Array} array
21
+ * @param {Function} uniqueMethod 去重复
22
+ * @param {Function} sortMethod 排序 存在就先排序再去重复
23
+ */
24
+ declare function unique(array: any[], uniqueMethod: (arg0: any, arg1: any) => boolean, sortMethod?: (a: any, b: any) => number): any[];
25
+
26
+ declare class Euler {
27
+ _x: number;
28
+ _y: number;
29
+ _z: number;
30
+ _order: string;
31
+ isEuler: boolean;
32
+ constructor(_x?: number, _y?: number, _z?: number, _order?: string);
33
+ get x(): number;
34
+ set x(value: number);
35
+ get y(): number;
36
+ set y(value: number);
37
+ get z(): number;
38
+ set z(value: number);
39
+ get order(): string;
40
+ set order(value: string);
41
+ set(x: number, y: number, z: number, order: string): this;
42
+ clone(): Euler;
43
+ copy(Euler: {
44
+ _x: number;
45
+ _y: number;
46
+ _z: number;
47
+ _order: string;
48
+ }): this;
49
+ setFromRotationMat(m: Mat4, order: string, update: boolean | undefined): this | undefined;
50
+ setFromQuat(q: Quat, order?: any, update?: boolean): this | undefined;
51
+ setFromVec3(v: {
52
+ x: any;
53
+ y: any;
54
+ z: any;
55
+ }, order: any): this;
56
+ reorder(newOrder: any): this | undefined;
57
+ equals(Euler: {
58
+ _x: number;
59
+ _y: number;
60
+ _z: number;
61
+ _order: string;
62
+ }): boolean;
63
+ fromArray(array: any[]): this;
64
+ toArray(array?: any[], offset?: number): any[];
65
+ toVec3(optionalResult: {
66
+ set: (arg0: number, arg1: number, arg2: number) => any;
67
+ }): any;
68
+ }
69
+ declare function euler(x?: number, y?: number, z?: number): Euler;
70
+
71
+ declare class Quat {
72
+ _x: number;
73
+ _y: number;
74
+ _z: number;
75
+ _w: number;
76
+ isQuat: boolean;
77
+ constructor(_x?: number, _y?: number, _z?: number, _w?: number);
78
+ get x(): number;
79
+ set x(value: number);
80
+ get y(): number;
81
+ set y(value: number);
82
+ get z(): number;
83
+ set z(value: number);
84
+ get w(): number;
85
+ set w(value: number);
86
+ static slerp(qa: any, qb: any, qm: {
87
+ copy: (arg0: any) => {
88
+ (): any;
89
+ new (): any;
90
+ slerp: {
91
+ (arg0: any, arg1: any): any;
92
+ new (): any;
93
+ };
94
+ };
95
+ }, t: any): any;
96
+ static slerpFlat(dst: {
97
+ [x: string]: any;
98
+ }, dstOffset: number, src0: {
99
+ [x: string]: any;
100
+ }, srcOffset0: number, src1: {
101
+ [x: string]: any;
102
+ }, srcOffset1: number, t: number): void;
103
+ static multiplyQuatsFlat(dst: {
104
+ [x: string]: number;
105
+ }, dstOffset: number, src0: {
106
+ [x: string]: any;
107
+ }, srcOffset0: number, src1: {
108
+ [x: string]: any;
109
+ }, srcOffset1: number): {
110
+ [x: string]: number;
111
+ };
112
+ set(x: number, y: number, z: number, w: number): this;
113
+ clone(): Quat;
114
+ copy(quat: Quat): this;
115
+ setFromEuler(euler: Euler, update?: boolean): this;
116
+ setFromAxisAngle(axis: {
117
+ x: number;
118
+ y: number;
119
+ z: number;
120
+ }, angle: number): this;
121
+ setFromRotationMat(m: {
122
+ elements: any;
123
+ }): this;
124
+ setFromUnitVecs(vFrom: {
125
+ dot: (arg0: any) => number;
126
+ x: number;
127
+ z: number;
128
+ y: number;
129
+ }, vTo: {
130
+ z: number;
131
+ y: number;
132
+ x: number;
133
+ }): this;
134
+ angleTo(q: any): number;
135
+ rotateTowards(q: any, step: number): this;
136
+ inverse(): this;
137
+ invert(): this;
138
+ conjugate(): this;
139
+ dot(v: Quat): number;
140
+ lengthSq(): number;
141
+ length(): number;
142
+ normalize(): this;
143
+ multiply(q: Quat, p?: Quat): this;
144
+ premultiply(q: Quat): this;
145
+ multiplyQuats(a: Quat, b: Quat): this;
146
+ slerp(qb: Quat, t: number): this;
147
+ equals(quat: Quat): boolean;
148
+ fromArray(array: Array<number>, offset?: number): this;
149
+ toArray(array?: number[], offset?: number): number[];
150
+ }
151
+ declare function quat(x?: number, y?: number, z?: number, w?: number): Quat;
152
+
153
+ interface DistanceResult {
154
+ rayParameter?: any;
155
+ lineParameter?: any;
156
+ closests?: Array<any>;
157
+ parameters?: Array<any>;
158
+ distance?: number;
159
+ distanceSqr?: number;
160
+ equidistant?: boolean;
161
+ interior?: boolean;
162
+ triangleParameters?: Array<any>;
163
+ rectangleParameters?: Array<any>;
164
+ circleClosest?: Vec3;
165
+ signedDistance?: number;
166
+ segmentIndex?: number;
167
+ diskClosest?: Vec3;
168
+ }
169
+ interface IntersectResult extends DistanceResult {
170
+ interserct?: boolean;
171
+ equals?: boolean;
172
+ intersetctPts: Array<Array<Vec3>>;
173
+ }
174
+
175
+ declare enum Orientation {
176
+ None = -1,
177
+ Positive = 1,
178
+ Negative = 2,
179
+ Common = 3,
180
+ Intersect = 3
181
+ }
182
+
183
+ declare class Triangle extends Array {
184
+ constructor(_p0: Vec3, _p1: Vec3, _p2: Vec3);
185
+ get p0(): any;
186
+ get p1(): any;
187
+ get p2(): any;
188
+ distanceTriangle(triangle: Triangle): void;
189
+ }
190
+
191
+ type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
192
+ type TypedArrayLike = number[] | Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
193
+
194
+ /**
195
+ * 几何体buffer属性
196
+ * 记录每个几何数据属性的细节
197
+ */
198
+ declare class BufferAttribute {
199
+ name: string;
200
+ itemSize: number;
201
+ array: TypedArray;
202
+ version: number;
203
+ normalized: boolean;
204
+ count: number;
205
+ updateRange: {
206
+ offset: number;
207
+ count: number;
208
+ };
209
+ readonly isBufferAttribute: true;
210
+ /**
211
+ *
212
+ * @param array {BufferArray} Buffer数据
213
+ * @param itemSize 单元长度,vec3是3,vec4是4
214
+ * @param normalized
215
+ */
216
+ constructor(array: TypedArray, itemSize: number, normalized?: boolean);
217
+ set needsUpdate(value: boolean);
218
+ onUploadCallback?: () => void;
219
+ onUpload(callback: () => void): this;
220
+ setUsage(usage: any): this;
221
+ copy(source: BufferAttribute): this;
222
+ copyAt(index1: number, attribute: BufferAttribute, index2: number): this;
223
+ copyArray(array: ArrayLike<number>): this;
224
+ copyColorsArray(colors: {
225
+ r: number;
226
+ g: number;
227
+ b: number;
228
+ }[]): this;
229
+ copyVec2sArray(vectors: {
230
+ x: number;
231
+ y: number;
232
+ }[]): this;
233
+ copyVec3sArray(vectors: {
234
+ x: number;
235
+ y: number;
236
+ z: number;
237
+ }[]): this;
238
+ copyVec4sArray(vectors: {
239
+ x: number;
240
+ y: number;
241
+ z: number;
242
+ w: number;
243
+ }[]): this;
244
+ applyMat3(m: Mat3): this;
245
+ applyMat4(m: Mat4): this;
246
+ applyNormalMat(m: Mat3): this;
247
+ transformDirection(m: Mat4): this;
248
+ set(value: ArrayLike<number>, offset: number): this;
249
+ getX(index: number): number;
250
+ setX(index: number, x: number): this;
251
+ getY(index: number): number;
252
+ setY(index: number, y: number): this;
253
+ getZ(index: number): number;
254
+ setZ(index: number, z: number): this;
255
+ getW(index: number): number;
256
+ setW(index: number, w: number): this;
257
+ setXY(index: number, x: number, y: number): this;
258
+ setXYZ(index: number, x: number, y: number, z: number): this;
259
+ setXYZW(index: number, x: number, y: number, z: number, w: number): this;
260
+ clone(): BufferAttribute;
261
+ toJSON(): {
262
+ itemSize: number;
263
+ type: string;
264
+ array: number[];
265
+ normalized: boolean;
266
+ };
267
+ }
268
+ declare class Int8BufferAttribute extends BufferAttribute {
269
+ constructor(array: any, itemSize: number, normalized?: boolean);
270
+ }
271
+ declare class Uint8BufferAttribute extends BufferAttribute {
272
+ constructor(array: any, itemSize: number, normalized?: boolean);
273
+ }
274
+ declare class Uint8ClampedBufferAttribute extends BufferAttribute {
275
+ constructor(array: any, itemSize: number, normalized?: boolean);
276
+ }
277
+ declare class Int16BufferAttribute extends BufferAttribute {
278
+ constructor(array: any, itemSize: number, normalized?: boolean);
279
+ }
280
+ declare class Uint16BufferAttribute extends BufferAttribute {
281
+ constructor(array: any, itemSize: number, normalized?: boolean);
282
+ }
283
+ declare class Int32BufferAttribute extends BufferAttribute {
284
+ constructor(array: any, itemSize: number, normalized?: boolean);
285
+ }
286
+ declare class Uint32BufferAttribute extends BufferAttribute {
287
+ constructor(array: any, itemSize: number, normalized?: boolean);
288
+ }
289
+ declare class Float32BufferAttribute extends BufferAttribute {
290
+ constructor(array: any, itemSize: number, normalized?: boolean);
291
+ }
292
+ declare class Float64BufferAttribute extends BufferAttribute {
293
+ constructor(array: any, itemSize: number, normalized?: boolean);
294
+ }
295
+
296
+ declare class Box {
297
+ min: Vec3;
298
+ max: Vec3;
299
+ _center: Vec3;
300
+ constructor(min?: Vec3, max?: Vec3);
301
+ get center(): Vec3;
302
+ /**
303
+ *
304
+ * @param {Array<Vec3>} points
305
+ */
306
+ setFromPoints(points: any): void;
307
+ expand(...points: any[]): void;
308
+ makeEmpty(): this;
309
+ clone(): Box | undefined;
310
+ copy(box: Box): Box;
311
+ setFromCenterAndSize(center: Vec3, size: Vec3): this;
312
+ setFromBufferAttribute(attribute: BufferAttribute): this;
313
+ expandByPoint(point: Vec3): this;
314
+ isEmpty(): boolean;
315
+ getCenter(target: Vec3): Vec3;
316
+ }
317
+
318
+ declare class Sphere {
319
+ applyMat4(mat: Mat4): void;
320
+ center: Vec3;
321
+ radius: number;
322
+ constructor(center?: Vec3, radius?: number);
323
+ setComponents(cx: number, cy: number, cz: number, radius: number): this;
324
+ copy(sphere: Sphere): this;
325
+ clone(): Sphere | undefined;
326
+ }
327
+
328
+ declare class Vec4 {
329
+ private _x;
330
+ private _y;
331
+ private _z;
332
+ private _w;
333
+ isVec4: boolean;
334
+ constructor(_x?: number, _y?: number, _z?: number, _w?: number);
335
+ get x(): number;
336
+ set x(value: number);
337
+ get y(): number;
338
+ set y(value: number);
339
+ get z(): number;
340
+ set z(value: number);
341
+ get w(): number;
342
+ set w(value: number);
343
+ static isVec4(v: Vec4): boolean;
344
+ get width(): number;
345
+ set width(value: number);
346
+ get height(): number;
347
+ set height(value: number);
348
+ set(x: number, y: number, z: number, w: number): this;
349
+ setScalar(scalar: number): this;
350
+ setX(x: number): this;
351
+ setY(y: number): this;
352
+ setZ(z: number): this;
353
+ setW(w: number): this;
354
+ setComponent(index: number, value: number): this;
355
+ getComponent(index: number): number;
356
+ clone(): Vec4;
357
+ copy(v: {
358
+ x: number;
359
+ y: number;
360
+ z: number;
361
+ w: number | undefined;
362
+ }): this;
363
+ add(v: Vec4, w?: Vec4): Vec4;
364
+ addScalar(s: number): this;
365
+ addVecs(a: Vec4, b: Vec4): this;
366
+ addScaledVec(v: Vec4, s: number): this;
367
+ sub(v: Vec4, w?: Vec4): this;
368
+ subScalar(s: number): this;
369
+ subVecs(a: Vec4, b: Vec4): this;
370
+ multiplyScalar(scalar: number): this;
371
+ applyMat4(m: {
372
+ elements: any;
373
+ }): this;
374
+ divideScalar(scalar: number): this;
375
+ setAxisAngleFromQuat(q: {
376
+ w: number;
377
+ x: number;
378
+ y: number;
379
+ z: number;
380
+ }): this;
381
+ setAxisAngleFromRotationMat(m: {
382
+ elements: any;
383
+ }): this;
384
+ min(v: Vec4): this;
385
+ max(v: Vec4): this;
386
+ clamp(min: Vec4, max: Vec4): this;
387
+ clampScalar(minVal: number, maxVal: number): this;
388
+ clampLength(min: number, max: number): this;
389
+ floor(): this;
390
+ ceil(): this;
391
+ round(): this;
392
+ roundToZero(): this;
393
+ negate(): this;
394
+ dot(v: Vec4): number;
395
+ lengthSq(): number;
396
+ length(): number;
397
+ manhattanLength(): number;
398
+ normalize(): this;
399
+ setLength(length: any): this;
400
+ lerp(v: Vec4, alpha: number): this;
401
+ lerpVecs(v1: Vec4, v2: any, alpha: any): Vec4;
402
+ equals(v: Vec4): boolean;
403
+ fromArray(array: TypedArrayLike, offset?: number): this;
404
+ toArray(array?: TypedArrayLike, offset?: number): TypedArrayLike;
405
+ fromBufferAttribute(attribute: any, index: any, offset: undefined): this;
406
+ }
407
+ declare function v4(x?: number, y?: number, z?: number, w?: number): Vec4;
408
+
409
+ interface IGeometry {
410
+ position: number[];
411
+ normal?: number[];
412
+ index?: number[];
413
+ uv?: number[];
414
+ uv2?: number[];
415
+ tangent?: number[];
416
+ }
417
+ interface IBufferGeometry {
418
+ position: Float32Array | undefined;
419
+ index?: Uint32Array | Uint16Array;
420
+ normal?: Float32Array;
421
+ uv?: Float32Array;
422
+ uv2?: Float32Array;
423
+ tangent?: Float32Array;
424
+ }
425
+ /**
426
+ * BufferType 几何体,用于独立计算几何体
427
+ */
428
+ declare class BufferGeometry {
429
+ name: string;
430
+ boundingBox: Box | undefined;
431
+ boundingSphere: Sphere | undefined;
432
+ morphAttributes: any;
433
+ morphTargetsRelative: boolean;
434
+ index: BufferAttribute | undefined;
435
+ attributes: {
436
+ [key: string]: BufferAttribute;
437
+ };
438
+ groups: {
439
+ start: number;
440
+ count: number;
441
+ materialIndex?: number;
442
+ }[];
443
+ drawRange: {
444
+ start: number;
445
+ count: number;
446
+ };
447
+ parameters: any;
448
+ readonly isBufferGeometry: true;
449
+ constructor();
450
+ /**
451
+ * 转化成BufferArray来计算
452
+ * @param geo
453
+ */
454
+ setFromGeometry(geo: IGeometry | IBufferGeometry): this;
455
+ getIndex(): BufferAttribute | undefined;
456
+ setIndex(index: BufferAttribute | TypedArray | number[]): void;
457
+ getAttribute(name: string): BufferAttribute;
458
+ setAttribute(name: string, attribute: BufferAttribute): this;
459
+ addAttribute(name: string, attribute: BufferAttribute | TypedArray | Array<number | Vec2 | Vec3 | Vec4>, itemSize?: number): this;
460
+ deleteAttribute(name: string): this;
461
+ addGroup(start: number, count: number, materialIndex?: number): void;
462
+ clearGroups(): void;
463
+ setDrawRange(start: number, count: number): void;
464
+ applyMat4(matrix: Mat4): this;
465
+ rotateX(angle: number): this;
466
+ rotateY(angle: number): this;
467
+ rotateZ(angle: number): this;
468
+ translate(x: number, y: number, z: number): this;
469
+ scale(x: number, y: number, z: number): this;
470
+ lookAt(vector: Vec3): this;
471
+ center(): this;
472
+ setFromObject(object: any): this;
473
+ setFromPoints(points: Vec3[]): this;
474
+ updateFromObject(object: any): this;
475
+ computeBoundingBox(): void;
476
+ computeBoundingSphere(): void;
477
+ computeFaceNormals(): void;
478
+ computeVertexNormals(): void;
479
+ merge(geometry: BufferGeometry, offset: number): this | undefined;
480
+ normalizeNormals(): void;
481
+ toFlat(): BufferGeometry;
482
+ toNonIndexed(): BufferGeometry;
483
+ toJSON(): any;
484
+ userData(userData: any): void;
485
+ clone(): BufferGeometry;
486
+ copy(source: BufferGeometry): this;
487
+ }
488
+
489
+ interface ISplitResult {
490
+ negative: Vec3[];
491
+ positive: Vec3[];
492
+ common: Vec3[];
493
+ orientation: Orientation;
494
+ }
495
+
496
+ declare class Plane {
497
+ normal: Vec3;
498
+ w: number;
499
+ origin: Vec3;
500
+ constructor(normal?: Vec3, w?: number);
501
+ static setFromPointNormal(p: Vec3, normal: Vec3): Plane;
502
+ setFromPointNormal(p: Vec3, normal: Vec3): void;
503
+ set(normal: Vec3, w: number): void;
504
+ setComponents(x: number, y: number, z: number, w: number): this;
505
+ normalize(): this;
506
+ setFromThreePoint(p0: Vec3, p1: Vec3, p2: Vec3): void;
507
+ negate(): void;
508
+ /**
509
+ * 判断一个点在平面的正面或者反面
510
+ * @param {Vec3} point
511
+ * @returns {Number} -1 or 1 or z
512
+ */
513
+ frontback(point: any): 0 | 1 | -1;
514
+ distancePoint(point: any): number;
515
+ distanceRay(ray: any): void;
516
+ distanceLine(line: any): void;
517
+ distanceSegment(segment: any): void;
518
+ distancePlane(plane: any): void;
519
+ /**
520
+ * 只返回交点
521
+ * Lw --Lightweight
522
+ * @param {Segment|Array<Vec3> segment
523
+ */
524
+ intersectSegmentLw(segment: Segment | Vec3[]): Vec3 | Vec3[] | Segment | null;
525
+ intersectLine(line: Line, result?: Vec3): Vec3 | undefined;
526
+ /**
527
+ * 切割线段 代码完成 等待测试
528
+ * @param {Segment} segment
529
+ * @returns {
530
+ * positive: [], //正面点
531
+ * negative: [],// 反面位置点
532
+ * common: [], 在平面上的点
533
+ * orientation: Orientation.None 线段的总体位置
534
+ * };
535
+ */
536
+ splitSegment(segment: Segment | Vec3[]): any;
537
+ /**
538
+ * 切割三角形 编码完成 等待测试
539
+ * @param {Triangle} triangle
540
+ */
541
+ splitTriangle(triangle: Triangle | Vec3[]): ISplitResult;
542
+ /**
543
+ * 平面切割线段
544
+ * @param polygon
545
+ */
546
+ splitConvexPolygon(polygon: Vec3[]): void;
547
+ /**
548
+ * 点在平面的位置判断
549
+ * @param {Point} point
550
+ * @returns {Orientation} 方位
551
+ */
552
+ orientationPoint(point: Vec3): Orientation;
553
+ /**
554
+ * @description : 平面分割几何体
555
+ * @param {Plane} plane
556
+ * @param {IGeometry} geometry
557
+ * @return {IGeometry[]} 返回多个几何体
558
+ * @example :
559
+ */
560
+ static splitGeometry(plane: Plane, geometry: IGeometry): void;
561
+ }
562
+
563
+ declare class Segment extends Array {
564
+ center: Vec3;
565
+ extentDirection: Vec3;
566
+ extentSqr: number;
567
+ extent: number;
568
+ direction: Vec3;
569
+ normal: Vec3 | undefined;
570
+ /**
571
+ * 线段
572
+ * @param {Point|Vec3} p0
573
+ * @param {Point|Vec3} p1
574
+ */
575
+ constructor(_p0?: Vec3, _p1?: Vec3);
576
+ set(p0: Vec3, p1: Vec3): void;
577
+ private change;
578
+ get p0(): Vec3;
579
+ set p0(v: Vec3);
580
+ get p1(): Vec3;
581
+ set p1(v: Vec3);
582
+ offset(distance: number, normal?: Vec3): void;
583
+ /**
584
+ * 线段到线段的距离
585
+ * @param {Segment} segment
586
+ */
587
+ distanceSegment(segment: Segment): DistanceResult;
588
+ distancePlane(plane: Plane): void;
589
+ intersectSegment(segment: Segment): void;
590
+ }
591
+ declare function segment(p0: Vec3, p1: Vec3): Segment;
592
+
593
+ declare class Ray {
594
+ origin: Vec3;
595
+ direction: Vec3;
596
+ constructor(origin: Vec3, direction: Vec3);
597
+ /**
598
+ * 射线到射线的距离
599
+ * @param {Ray} ray
600
+ */
601
+ distanceRay(ray: Ray): DistanceResult;
602
+ /**
603
+ * 射线到线段的距离
604
+ * @param segment
605
+ */
606
+ distanceSegment(segment: Segment): DistanceResult;
607
+ distanceTriangle(triangle: Triangle): DistanceResult;
608
+ distancePloyline(): DistanceResult;
609
+ }
610
+
611
+ declare enum AxisPlane {
612
+ XY = "xy",
613
+ XZ = "xz",
614
+ YZ = "yz",
615
+ XYZ = "xyz"
616
+ }
617
+ interface ITriangulationOption {
618
+ feature?: AxisPlane;
619
+ dim?: number;
620
+ normal?: Vec3;
621
+ }
622
+ /**
623
+ * 三角剖分 earcut.js
624
+ * @param {Array} boundary 边界
625
+ * @param {Array<Array>} holes 洞的数组
626
+ * @param {options:{feature,dim,normal}} feature 选择平平面
627
+ * @returns {Array<Number>} 三角形索引数组
628
+ */
629
+ declare function triangulation(inboundary: any, holes?: any[], options?: ITriangulationOption): number[];
630
+
631
+ declare class ArrayList<T> {
632
+ protected _array: Array<T>;
633
+ isArrayList: boolean;
634
+ constructor(data?: Array<T> | ArrayList<T>);
635
+ get array(): T[];
636
+ set array(val: T[]);
637
+ get length(): number;
638
+ get last(): any;
639
+ get first(): T;
640
+ map(callbackfn: (value: T, index: number, array: T[]) => unknown): unknown[];
641
+ push(...values: any[]): void;
642
+ reverse(): this;
643
+ pop(): any;
644
+ unshift(...items: any[]): number;
645
+ insertAt(i: number, ...value: T[]): void;
646
+ splice(start: number, deleteCount: number, ...items: any[]): void;
647
+ get(index: number): any;
648
+ /**
649
+ * 遍历
650
+ * @param {*} method
651
+ */
652
+ forall(method: (arg0: any) => void): void;
653
+ /**
654
+ * 克隆
655
+ */
656
+ clone(): any;
657
+ /**
658
+ * 分类
659
+ * example:
660
+ * var arry = [1,2,3,4,5,6]
661
+ * var result = classify(this._array,(a)={return a%2===0})
662
+ *
663
+ * @param {Function} classifyMethod 分类方法
664
+ */
665
+ classify(classifyMethod: (arg0: any, arg1: any, arg2: any[]) => any): T[][];
666
+ /**
667
+ * 去掉重复元素
668
+ * @param {Function} uniqueMethod 去重复
669
+ * @param {Function} sortMethod 排序
670
+ */
671
+ unique(uniqueMethod: (arg0: T, arg1: T) => boolean, sortMethod?: ((a: T, b: T) => number)): this;
672
+ }
673
+
674
+ interface ILinkSideOption {
675
+ side0: {
676
+ x: number;
677
+ y: number;
678
+ z: number;
679
+ index?: number;
680
+ }[] | number[];
681
+ side1: {
682
+ x: number;
683
+ y: number;
684
+ z: number;
685
+ index?: number;
686
+ }[] | number[];
687
+ holes0?: Array<Array<Vec3>>;
688
+ holes1?: Array<Array<Vec3>>;
689
+ shapeClosed?: boolean;
690
+ autoUV?: boolean;
691
+ uvScalars?: number[];
692
+ segs?: [];
693
+ }
694
+ /**
695
+ * 常用shape几何操作
696
+ */
697
+ /**
698
+ * @description : 缝合两个边 不提供uv生成 uv有@linkSides 生成
699
+ * @param { ILinkSideOption } options
700
+ * @returns { Array<Vec3>} 三角形数组,每三个为一个三角形
701
+ * @example :
702
+ */
703
+ declare function linkSide(options: ILinkSideOption): number[];
704
+ /**
705
+ * 缝合shape集合
706
+ * @param {Array<Array<Point|Vec3>} shapes 路基 点集的集合, 每个shape的点数量一致
707
+ * @param {Boolean} sealStart 每一个shape是否是封闭的界面 默认false
708
+ * @param {Boolean} isClosed 每一个shape是否是封闭的界面 默认false
709
+ * @param {Boolean} isClosed2 每一个shape是否是封闭的首尾 默认false
710
+ * @returns {Array} 返回三角形集合 如果有所用范围索引,否则返回顶点
711
+ */
712
+ interface ILinkSideOptions {
713
+ shapes: Array<Array<IVec3 | any | IVec3>>;
714
+ orgShape?: Array<IVec3 | any | IVec3>;
715
+ orgHoles?: any;
716
+ sealStart?: boolean;
717
+ sealEnd?: boolean;
718
+ shapeClosed?: boolean;
719
+ pathClosed?: boolean;
720
+ index?: {
721
+ index: number;
722
+ };
723
+ autoIndex?: boolean;
724
+ generateUV?: boolean;
725
+ axisPlane?: AxisPlane;
726
+ holes?: Array<Array<IVec3 | any | IVec3>>[];
727
+ }
728
+ /**
729
+ * @description : 链接多个shape 生成几何体
730
+ * @param {ILinkSideOptions} optionsILinkSideOptions {
731
+ * shapes: Array<Array<IVec3 | number | any>>;
732
+ * sealStart?: boolean,//开始封面
733
+ * sealEnd?: boolean;//结束封面
734
+ * shapeClosed?: boolean,//shape是否闭合
735
+ * pathClosed?: boolean,//路径是否闭合
736
+ * index?: { index: number },
737
+ * generateUV?: boolean
738
+ * }
739
+ *
740
+ * @return {*}
741
+ * @example :
742
+ *
743
+ */
744
+ declare function linkSides(options: ILinkSideOptions): IGeometry;
745
+ interface IExtrudeOptions {
746
+ fixedY?: boolean;
747
+ shapeClosed?: boolean;
748
+ isClosed2?: boolean;
749
+ textureEnable?: boolean;
750
+ textureScale?: Vec2;
751
+ smoothAngle?: number;
752
+ sealStart?: boolean;
753
+ sealEnd?: boolean;
754
+ normal?: Vec3;
755
+ }
756
+ interface IExtrudeOptionsEx {
757
+ shape: Array<Vec3 | IVec3 | Vec2 | IVec2>;
758
+ path: Array<Vec3 | IVec3>;
759
+ ups?: Array<Vec3 | IVec3>;
760
+ up?: Vec3 | IVec3;
761
+ right?: Vec3;
762
+ shapeClosed?: boolean;
763
+ pathClosed?: boolean;
764
+ textureEnable?: boolean;
765
+ smoothAngle?: number;
766
+ enableSmooth?: boolean;
767
+ sealStart?: boolean;
768
+ sealEnd?: boolean;
769
+ normal?: Vec3;
770
+ autoIndex?: boolean;
771
+ axisPlane?: AxisPlane;
772
+ generateUV?: boolean;
773
+ index?: {
774
+ index: number;
775
+ };
776
+ holes?: Array<Vec3 | IVec3 | Vec2 | IVec2>[];
777
+ }
778
+ /**
779
+ * @description : 挤压形状生成几何体
780
+ * @param {IExtrudeOptionsEx} options
781
+ * IExtrudeOptionsEx {
782
+ * shape: Array<Vec3 | IVec3 | Vec2 | IVec2>;//shape默认的矩阵为正交矩阵
783
+ * path: Array<Vec3 | IVec3>;//挤压路径
784
+ * ups?: Array<Vec3 | IVec3>;
785
+ * up?: Vec3 | IVec3;
786
+ * shapeClosed?: boolean;//闭合为多边形 界面
787
+ * pathClosed?: boolean;//首尾闭合为圈
788
+ * textureEnable?: boolean;
789
+ * smoothAngle?: number;
790
+ * sealStart?: boolean;
791
+ * sealEnd?: boolean;
792
+ * normal?: Vec3,//面的法线
793
+ * autoIndex?: boolean,
794
+ * index?: { index: number }
795
+ * holes?: Array<Vec3 | IVec3 | Vec2 | IVec2>[]
796
+ *}
797
+ * @return {IGeometry}
798
+ * @example :
799
+ *
800
+ */
801
+ declare function extrude(options: IExtrudeOptionsEx): IGeometry;
802
+ /**
803
+ * 挤压
804
+ * @param {Polygon|Array<Point|Vec3> } shape 多边形或顶点数组
805
+ * @param {Path|Array<Point|Vec3> } path 路径或者或顶点数组
806
+ * @param {Object} options {
807
+ * isClosed: false,闭合为多边形 界面
808
+ * isClosed2: false, 闭合为圈
809
+ * textureEnable: true, 计算纹理坐标
810
+ * textureScale: new Vec2(1, 1),纹理坐标缩放
811
+ * smoothAngle: Math.PI / 180 * 30,大于这个角度则不平滑
812
+ * sealStart: true, 是否密封开始面
813
+ * sealEnd: true,是否密封结束面}
814
+ */
815
+ declare function extrude_obsolete<T extends Vec3>(shape: ArrayList<T>, arg_path: Array<Vec3> | any, options?: IExtrudeOptions): {
816
+ vertices: any[];
817
+ index: number[] | undefined;
818
+ uvs: any[];
819
+ };
820
+ declare enum JoinType {
821
+ Square = 0,
822
+ Round = 1,
823
+ Miter = 2,
824
+ Bevel = 0
825
+ }
826
+ declare enum EndType {
827
+ Square = 0,
828
+ Round = 1,
829
+ Butt = 2,
830
+ etClosedLine = 3,
831
+ etClosedPolygon = 4,
832
+ etOpenButt = 5,
833
+ etOpenSquare = 6
834
+ }
835
+ interface IExtrudeOptionsNext {
836
+ shape: Array<Vec3>;
837
+ path: Array<Vec3 | IVec3>;
838
+ up?: Array<Vec3 | IVec3> | Vec3 | IVec3;
839
+ right?: Array<Vec3> | Vec3;
840
+ shapeClosed?: boolean;
841
+ pathClosed?: boolean;
842
+ textureEnable?: boolean;
843
+ shapeCenter?: Vec3;
844
+ smoothAngle?: number;
845
+ enableSmooth?: boolean;
846
+ sealStart?: boolean;
847
+ sealEnd?: boolean;
848
+ normal?: Vec3;
849
+ autoIndex?: boolean;
850
+ axisPlane?: AxisPlane;
851
+ generateUV?: boolean;
852
+ index?: {
853
+ index: number;
854
+ };
855
+ holes?: Array<Vec3 | IVec3 | Vec2 | IVec2>[];
856
+ jtType?: JoinType;
857
+ etType?: EndType;
858
+ bevelSize?: any;
859
+ }
860
+ /**
861
+ * 将路径看做挤压操作中心
862
+ *
863
+ * @param shape
864
+ * @param followPath
865
+ * @param options
866
+ */
867
+ declare function extrudeNext(options: IExtrudeOptionsNext): IGeometry;
868
+
869
+ declare class Polygon<T> extends Polyline<T> {
870
+ isPolygon: boolean;
871
+ constructor(vs?: any[]);
872
+ offset(distance: number, normal?: Vec3): Polygon<T>;
873
+ containPoint(point: Vec3): void;
874
+ }
875
+
876
+ /**
877
+ * 线段正反原则:右手坐标系中,所在平面为XZ平面,把指向方向看着负Z轴,x正为正方向,x负为负方向
878
+ */
879
+ declare class Polyline<T> extends ArrayList<T> {
880
+ isCoPlanar: boolean;
881
+ isPolyline: boolean;
882
+ normal: Vec3;
883
+ constructor(vs?: Array<T> | Polyline<T> | Polygon<T>, normal?: Vec3);
884
+ /**
885
+ * 偏移
886
+ * @param {Number} distance 偏移距离
887
+ * @param {Vector3} normal 折线所在平面法线
888
+ */
889
+ offset(distance: number, normal?: Vec3, endtype?: EndType, jointype?: JoinType): Polyline<T>;
890
+ /**
891
+ * 圆角 将折线拐点圆角化
892
+ * @param {Number} useDistance 圆角段距离
893
+ * @param {Number} segments 分切割段数
894
+ */
895
+ corner(useDistance: number, normal?: Vec3): Polyline<T>;
896
+ }
897
+
898
+ declare class Line {
899
+ origin: Vec3;
900
+ end: Vec3;
901
+ direction: Vec3;
902
+ constructor(origin?: Vec3, end?: Vec3);
903
+ set(origin: Vec3, end: Vec3): this;
904
+ distancePoint(pt: Vec3): DistanceResult;
905
+ distanceSegment(segment: Segment): DistanceResult;
906
+ /**
907
+ * 直线到直线的距离
908
+ * 参数与最近点顺序一致
909
+ * @param {Line} line
910
+ */
911
+ distanceLine(line: Line): DistanceResult;
912
+ /**
913
+ * 直线与射线的距离
914
+ * @param {Ray} ray
915
+ */
916
+ distanceRay(ray: Ray): DistanceResult;
917
+ /**
918
+ *
919
+ * @param triangle
920
+ */
921
+ distanceTriangle(triangle: Triangle): DistanceResult;
922
+ distancePolyline(polyline: Polyline<Vec3> | Vec3[]): DistanceResult;
923
+ /**
924
+ * 线与平面相交
925
+ * @param plane
926
+ * @param result
927
+ */
928
+ intersectPlane(plane: Plane, result?: Vec3): Vec3 | undefined;
929
+ }
930
+ declare function line(start?: Vec3, end?: Vec3): Line;
931
+
932
+ declare class Capsule extends Segment {
933
+ radius: number;
934
+ /**
935
+ * 胶囊体
936
+ * @param {Point|Vec3} p0 点0
937
+ * @param {Point|Vec3} p1 点1
938
+ * @param {Number} radius 半径
939
+ */
940
+ constructor(p0: Vec3, p1: Vec3, radius?: number);
941
+ }
942
+
943
+ declare class Rectangle extends Array {
944
+ extent: number[];
945
+ axis: Vec3[];
946
+ center: Vec3;
947
+ constructor(v0: Vec3, v1: Vec3, v2: Vec3, v3: Vec3);
948
+ }
949
+
950
+ declare class Circle {
951
+ center: Vec3;
952
+ radius: number;
953
+ normal: Vec3;
954
+ startAngle: number;
955
+ lengthAngle: number;
956
+ radiusSqr: number;
957
+ /**
958
+ * 圆圈
959
+ * @param {Vec3} center 中心点
960
+ * @param {Vec3} normal 法线
961
+ * @param {Number} radius 半径
962
+ */
963
+ constructor(center?: Vec3, radius?: number, startAngle?: number, lengthAngle?: number, normal?: Vec3);
964
+ area(): number;
965
+ /**
966
+ * 两个点
967
+ * @param fixp0
968
+ * @param fixp1
969
+ * @param movep
970
+ * @param normal
971
+ */
972
+ arc1(fixp0: Vec3, fixp1: Vec3, movep: Vec3, normal?: Vec3): void;
973
+ /**
974
+ * 全两个点确定半径,后面点确定 弧度 ,只需要检测鼠标移动时鼠标是否跨过第一条半径即可确定顺逆时针
975
+ * @param fixp0
976
+ * @param fixp1
977
+ * @param movep
978
+ */
979
+ arc2(center: Vec3, fixp1: Vec3, movep: Vec3, ccw?: boolean, normal?: Vec3): void;
980
+ setFrom3Points(p0: Vec3, p1: Vec3, p2: Vec3, normal?: Vec3): this;
981
+ /**
982
+ * 将圆环或者圆弧转化为路径点,生成XY平面上得三维点
983
+ * @param center 中心点
984
+ * @param radius 半径
985
+ * @param startAngle 起始角 右手坐标系 以X正坐标轴为起点 单位弧度
986
+ * @param lengthAngle 弧度长度 单位弧度
987
+ * @param segment 分段
988
+ */
989
+ static toVertices(center: Vec3, radius: number, startAngle?: number, lengthAngle?: number, segment?: number): Vec3[];
990
+ }
991
+ declare function circle(center?: Vec3, radius?: number): Circle;
992
+
993
+ declare class Disk {
994
+ center: Vec3;
995
+ normal: Vec3;
996
+ radius: number;
997
+ w: number;
998
+ constructor(center: Vec3, radius: number, normal?: Vec3);
999
+ area(): number;
1000
+ }
1001
+ declare function disk(center: Vec3, radius: number, normal: Vec3): Disk;
1002
+
1003
+ interface IVec2 {
1004
+ x: number;
1005
+ y: number;
1006
+ }
1007
+ interface IVec3 extends IVec2 {
1008
+ z: number;
1009
+ }
1010
+ interface IVec4 extends IVec3 {
1011
+ w: number;
1012
+ }
1013
+ declare class Vec3 implements IVec3 {
1014
+ private _x;
1015
+ private _y;
1016
+ private _z;
1017
+ constructor(_x?: number, _y?: number, _z?: number);
1018
+ get x(): number;
1019
+ set x(value: number);
1020
+ get y(): number;
1021
+ set y(value: number);
1022
+ get z(): number;
1023
+ set z(value: number);
1024
+ static isVec3(v: any): boolean;
1025
+ get isVec3(): boolean;
1026
+ static get Up(): Vec3;
1027
+ static get Down(): Vec3;
1028
+ static get UnitX(): Vec3;
1029
+ static get UnitY(): Vec3;
1030
+ static get UnitZ(): Vec3;
1031
+ set(x: number, y: number, z: number): this;
1032
+ setScalar(scalar: number): this;
1033
+ setComponent(index: number, value: number): this;
1034
+ getComponent(index: number): number;
1035
+ clone(): Vec3;
1036
+ copy(v: Vec3): this;
1037
+ add(v: Vec3, w?: Vec3): this;
1038
+ addScalar(s: number): this;
1039
+ addVecs(a: Vec3, b: Vec3): this;
1040
+ addScaledVec(v: Vec3, s: number): this;
1041
+ sub(v: Vec3, w?: Vec3): this;
1042
+ subScalar(s: number): this;
1043
+ subVecs(a: Vec3, b: Vec3): this;
1044
+ multiply(v: Vec3, w?: Vec3): this;
1045
+ multiplyScalar(scalar: number): this;
1046
+ multiplyVecs(a: Vec3, b: Vec3): this;
1047
+ applyEuler(euler: Euler): this;
1048
+ applyAxisAngle(axis: any, angle: any): this;
1049
+ applyNormalMat(m: Mat3): this;
1050
+ applyMat3(m: Mat3): this;
1051
+ applyMat4(m: Mat4): this;
1052
+ applyQuat(q: Quat): this;
1053
+ project(camera: {
1054
+ matrixWorldInverse: any;
1055
+ projectionMat: any;
1056
+ }): this;
1057
+ unproject(camera: {
1058
+ projectionMatInverse: any;
1059
+ matrixWorld: any;
1060
+ }): this;
1061
+ transformDirection(m: Mat4): this;
1062
+ divide(v: Vec3): this;
1063
+ divideScalar(scalar: number): this;
1064
+ min(v: Vec3): this;
1065
+ max(v: Vec3): this;
1066
+ clamp(min: Vec3, max: Vec3): this;
1067
+ clampScalar(minVal: number, maxVal: number): this;
1068
+ clampLength(min: number, max: number): this;
1069
+ floor(): this;
1070
+ ceil(): this;
1071
+ round(): this;
1072
+ roundToZero(): this;
1073
+ negate(): this;
1074
+ dot(v: Vec3): number;
1075
+ lengthSq(): number;
1076
+ length(): number;
1077
+ manhattanLength(): number;
1078
+ normalize(robust?: boolean): this;
1079
+ setLength(length: any): this;
1080
+ lerp(v: Vec3, alpha: number): this;
1081
+ lerpVecs(v1: Vec3, v2: any, alpha: any): this;
1082
+ slerp(v2: any, radian: number): void;
1083
+ /**
1084
+ * v1 到 v2 选择angle弧度 v1,v2构成一个平面
1085
+ * @param v1
1086
+ * @param v2
1087
+ * @param alpha
1088
+ * @returns
1089
+ */
1090
+ slerpVecs(v1: Vec3, v2: any, radian: number): void;
1091
+ cross(v: Vec3, w?: Vec3): this;
1092
+ crossVecs(a: Vec3, b: Vec3): this;
1093
+ projectOnVec(vec: Vec3): this;
1094
+ /**
1095
+ * 投影到法线的所在平面 相当于平面上距离点最近的点
1096
+ * @param planeNormal
1097
+ * @returns
1098
+ */
1099
+ projectOnPlaneNormal(planeNormal: any): this;
1100
+ /**
1101
+ * 投影到平面
1102
+ * @param normal 正交化的法线
1103
+ * @param w 距离
1104
+ * @returns
1105
+ */
1106
+ projectOnPlaneNormalDis(normal: Vec3, w: number): this;
1107
+ /**
1108
+ * 投影到平面
1109
+ * @param plane 平面
1110
+ * @returns
1111
+ */
1112
+ projectOnPlane(plane: Plane): this;
1113
+ /**
1114
+ * 从指定方向线(斜线,也可能是法线)上投影到平面
1115
+ * @param planeNormal
1116
+ * @param dir
1117
+ */
1118
+ projectDirectionOnPlane(plane: Plane, dir: Vec3): this;
1119
+ reflect(normal: any): this;
1120
+ angleTo(v: Vec3, normal?: Vec3 | any): number;
1121
+ angleToEx(v: Vec3, normal: Vec3): number;
1122
+ distanceTo(v: any): number;
1123
+ distanceToSquared(v: Vec3): number;
1124
+ manhattanDistanceTo(v: Vec3): number;
1125
+ setFromSpherical(s: {
1126
+ radius: number;
1127
+ phi: number;
1128
+ theta: number;
1129
+ }): this;
1130
+ setFromSphericalCoords(radius: number, phi: number, theta: number): this;
1131
+ setFromCylindrical(c: {
1132
+ radius: any;
1133
+ theta: any;
1134
+ y: any;
1135
+ }): this;
1136
+ setFromCylindricalCoords(radius: number, theta: number, y: number): this;
1137
+ setFromMatPosition(m: {
1138
+ elements: any;
1139
+ }): this;
1140
+ setFromMatScale(m: any): this;
1141
+ setFromMatColumn(m: {
1142
+ elements: any;
1143
+ }, index: number): this;
1144
+ equals(v: Vec3): boolean;
1145
+ fromArray(array: ArrayLike<number>, offset?: number): this;
1146
+ toArray(array?: TypedArrayLike, offset?: number): TypedArrayLike;
1147
+ fromBufferAttribute(attribute: {
1148
+ getX: (arg0: any) => number;
1149
+ getY: (arg0: any) => number;
1150
+ getZ: (arg0: any) => number;
1151
+ }, index: any, offset?: number): this;
1152
+ toFixed(fractionDigits: number | undefined): this;
1153
+ distancePoint(point: Vec3): DistanceResult;
1154
+ distanceVec3(point: Vec3): DistanceResult;
1155
+ /**
1156
+ * 点到直线的距离 point distance to Line
1157
+ * @param line
1158
+ */
1159
+ distanceLine(line: Line): DistanceResult;
1160
+ /**
1161
+ * Test success
1162
+ * 到射线的距离
1163
+ * @param {Line} line
1164
+ * @returns {Object} lineParameter 最近点的参数 lineClosest 最近点 distanceSqr 到最近点距离的平方 distance 到最近点距离
1165
+ */
1166
+ distanceRay(ray: Ray): DistanceResult;
1167
+ /**
1168
+ * Test success
1169
+ * 到线段的距离
1170
+ * @param {Line} line
1171
+ * @returns {Object} lineParameter 最近点的参数 lineClosest 最近点 distanceSqr 到最近点距离的平方 distance 到最近点距离
1172
+ */
1173
+ distanceSegment(segment: Segment): DistanceResult;
1174
+ /**
1175
+ * 点与线段的距离
1176
+ * @param plane
1177
+ */
1178
+ distancePlane(plane: Plane): DistanceResult;
1179
+ /**
1180
+ * 点与圆圈的距离
1181
+ * @param {*} circle
1182
+ * @param {*} disk
1183
+ * @returns {} result
1184
+ */
1185
+ distanceCircle(circle: Circle): DistanceResult;
1186
+ /**
1187
+ * 点与圆盘的距离
1188
+ * @param {*} Disk
1189
+ * @returns {} result
1190
+ */
1191
+ distanceDisk(disk: Disk): DistanceResult;
1192
+ /**
1193
+ * 点与线段的距离
1194
+ * 点与折线的距离 测试排除法,平均比线性检索(暴力法)要快两倍以上
1195
+ * @param { Polyline | Vec3[]} polyline
1196
+ */
1197
+ distancePolyline(polyline: Polyline<Vec3> | Vec3[]): DistanceResult | null;
1198
+ /**
1199
+ * 点到三角形的距离
1200
+ * @param {Triangle} triangle
1201
+ */
1202
+ distanceTriangle(triangle: Triangle): DistanceResult;
1203
+ /**
1204
+ * 点到矩形的距离
1205
+ * @param {Rectangle} rectangle
1206
+ */
1207
+ distanceRectangle(rectangle: Rectangle): DistanceResult;
1208
+ /**
1209
+ * 点到胶囊的距离
1210
+ * @param {Capsule} capsule
1211
+ */
1212
+ distanceCapsule(capsule: Capsule): DistanceResult;
1213
+ }
1214
+ declare function v3(x?: number, y?: number, z?: number): Vec3;
1215
+
1216
+ declare class Mat4 {
1217
+ elements: number[];
1218
+ isMat4: boolean;
1219
+ constructor();
1220
+ set(n11: number, n12: number, n13: number, n14: number, n21: number, n22: number, n23: number, n24: number, n31: number, n32: number, n33: number, n34: number, n41: number, n42: number, n43: number, n44: number): this;
1221
+ static get Identity(): Mat4;
1222
+ identity(): this;
1223
+ clone(): Mat4;
1224
+ copy(m: Mat4): this;
1225
+ copyPosition(m: {
1226
+ elements: any;
1227
+ }): this;
1228
+ extractBasis(xAxis: Vec3, yAxis: Vec3, zAxis: Vec3): this;
1229
+ makeBasis(xAxis: Vec3, yAxis: Vec3, zAxis: Vec3): this;
1230
+ extractRotation(m: Mat4): this;
1231
+ makeRotationFromEuler(euler: Euler): this;
1232
+ makeRotationFromQuat(q: any): this;
1233
+ lookAt(eye: Vec3, target: Vec3, up: Vec3): this;
1234
+ multiply(m: Mat4, n?: Mat4): this;
1235
+ premultiply(m: Mat4): this;
1236
+ multiplyMats(a: Mat4, b: Mat4): this;
1237
+ multiplyScalar(s: number): this;
1238
+ applyToBufferAttribute(attribute: {
1239
+ count: any;
1240
+ getX: (arg0: number) => number;
1241
+ getY: (arg0: number) => number;
1242
+ getZ: (arg0: number) => number;
1243
+ setXYZ: (arg0: number, arg1: number, arg2: number, arg3: number) => void;
1244
+ }): {
1245
+ count: any;
1246
+ getX: (arg0: number) => number;
1247
+ getY: (arg0: number) => number;
1248
+ getZ: (arg0: number) => number;
1249
+ setXYZ: (arg0: number, arg1: number, arg2: number, arg3: number) => void;
1250
+ };
1251
+ determinant(): number;
1252
+ transpose(): this;
1253
+ setPosition(x: number | Vec3 | any, y?: number, z?: number): this;
1254
+ /**
1255
+ * 矩阵求逆
1256
+ * @returns 自己
1257
+ */
1258
+ invert(): Mat4;
1259
+ getInverse(m: Mat4, throwOnDegenerate?: boolean): this;
1260
+ scale(v: {
1261
+ x: any;
1262
+ y: any;
1263
+ z: any;
1264
+ }): this;
1265
+ getMaxScaleOnAxis(): number;
1266
+ makeTranslation(x: number, y: number, z: number): this;
1267
+ makeRotationX(theta: number): this;
1268
+ makeRotationY(theta: number): this;
1269
+ makeRotationZ(theta: number): this;
1270
+ makeRotationAxis(axis: {
1271
+ x: any;
1272
+ y: any;
1273
+ z: any;
1274
+ }, angle: number): this;
1275
+ makeScale(x: number, y: number, z: number): this;
1276
+ /**
1277
+ * 6个参数 都是由两个值来影响 [v1][v2] v1表示v2轴在v1轴产生效果
1278
+ * @param xy
1279
+ * @param xz
1280
+ * @param yx
1281
+ * @param yz
1282
+ * @param zx
1283
+ * @param zy
1284
+ * @returns
1285
+ */
1286
+ makeShear(xy: number, xz: number, yx: number, yz: number, zx: number, zy: number): this;
1287
+ compose(position: Vec3, quat: Quat, scale: Euler | Vec3): this;
1288
+ decompose(position: Vec3, quat: Quat, scale: Vec3): this;
1289
+ makePerspective(left: number, right: number, top: number, bottom: number, near: number, far: number): this;
1290
+ makeOrthographic(left: number, right: number, top: number, bottom: number, near: number, far: number): this;
1291
+ equals(matrix: {
1292
+ elements: any;
1293
+ }): boolean;
1294
+ fromArray(array: number[], offset?: number): this;
1295
+ toArray(array?: number[], offset?: number): number[];
1296
+ }
1297
+ declare function m4(): Mat4;
1298
+
1299
+ declare class Mat3 {
1300
+ elements: number[];
1301
+ isMat3: boolean;
1302
+ constructor();
1303
+ set(n11: number, n12: number, n13: number, n21: number, n22: number, n23: number, n31: number, n32: number, n33: number): this;
1304
+ identity(): this;
1305
+ clone(): Mat3;
1306
+ copy(m: Mat3): this;
1307
+ setFromMat4(m: Mat4): this;
1308
+ applyToBufferAttribute(attribute: any): any;
1309
+ multiply(m: Mat3): this;
1310
+ premultiply(m: Mat3): this;
1311
+ multiplyMatrices(a: Mat3, b: Mat3): this;
1312
+ multiplyScalar(s: number): this;
1313
+ determinant(): number;
1314
+ getInverse(matrix: Mat3 | Mat4 | any, throwOnDegenerate?: boolean): this;
1315
+ transpose(): this;
1316
+ getNormalMat(mat4: Mat4): this;
1317
+ transposeIntoArray(r: number[]): this;
1318
+ setUvTransform(tx: any, ty: any, sx: number, sy: number, rotation: number, cx: number, cy: number): void;
1319
+ scale(sx: number, sy: number): this;
1320
+ rotate(theta: number): this;
1321
+ translate(tx: number, ty: number): this;
1322
+ equals(matrix: Mat3): boolean;
1323
+ fromArray(array: number[], offset?: number): this;
1324
+ toArray(array?: number[], offset?: number): number[];
1325
+ }
1326
+ declare function m3(): Mat3;
1327
+
1328
+ declare class Vec2 {
1329
+ private _x;
1330
+ private _y;
1331
+ isVec2: boolean;
1332
+ constructor(_x?: number, _y?: number);
1333
+ get x(): number;
1334
+ set x(value: number);
1335
+ get y(): number;
1336
+ set y(value: number);
1337
+ static isVec2(v: any): boolean;
1338
+ get width(): number;
1339
+ set width(value: number);
1340
+ get height(): number;
1341
+ set height(value: number);
1342
+ static get UnitX(): Vec2;
1343
+ static get UnitY(): Vec2;
1344
+ set(x: number, y: number): this;
1345
+ setScalar(scalar: number): this;
1346
+ setX(x: number): this;
1347
+ setY(y: number): this;
1348
+ setComponent(index: number, value: number): this;
1349
+ getComponent(index: number): number;
1350
+ clone(): Vec2;
1351
+ copy(v: Vec2): Vec2;
1352
+ add(v: Vec2, w?: Vec2): this;
1353
+ addScalar(s: number): this;
1354
+ addVecs(a: Vec2, b: Vec2): this;
1355
+ addScaledVec(v: Vec2, s: number): this;
1356
+ sub(v: Vec2, w: Vec2): this;
1357
+ subScalar(s: number): this;
1358
+ subVecs(a: Vec2, b: Vec2): this;
1359
+ multiply(v: Vec2): this;
1360
+ multiplyScalar(scalar: number): this;
1361
+ divide(v: Vec2): this;
1362
+ divideScalar(scalar: number): this;
1363
+ applyMat3(m: Mat3): this;
1364
+ min(v: Vec2): this;
1365
+ max(v: Vec2): this;
1366
+ clamp(min: Vec2, max: Vec2): this;
1367
+ clampScalar(minVal: number, maxVal: number): this;
1368
+ clampLength(min: number, max: number): this;
1369
+ floor(): this;
1370
+ ceil(): this;
1371
+ round(): this;
1372
+ roundToZero(): this;
1373
+ negate(): this;
1374
+ dot(v: Vec2): number;
1375
+ cross(v: Vec2): number;
1376
+ lengthSq(): number;
1377
+ length(): number;
1378
+ manhattanLength(): number;
1379
+ normalize(): this;
1380
+ angle(): number;
1381
+ distanceTo(v: Vec2): number;
1382
+ distanceToSquared(v: Vec2): number;
1383
+ manhattanDistanceTo(v: Vec2): number;
1384
+ setLength(length: number): this;
1385
+ lerp(v: Vec2, alpha: number): this;
1386
+ lerpVecs(v1: Vec2, v2: Vec2, alpha: number): this;
1387
+ equals(v: Vec2): boolean;
1388
+ fromArray(array: TypedArrayLike, offset?: number): this;
1389
+ toArray(array?: TypedArrayLike, offset?: number): TypedArrayLike;
1390
+ fromBufferAttribute(attribute: any, index: number, offset: any): this;
1391
+ rotateAround(center: Vec2, angle: number): this;
1392
+ }
1393
+ declare function v2(): Vec2;
1394
+
1395
+ declare const delta4 = 0.0001;
1396
+ declare const delta5 = 0.00001;
1397
+ declare const delta6 = 0.000001;
1398
+ declare const delta7 = 1e-7;
1399
+ declare const delta8 = 1e-8;
1400
+ declare const delta9 = 1e-9;
1401
+ /**
1402
+ * pi
1403
+ *
1404
+ * @type {Number}
1405
+ * @constant
1406
+ */
1407
+ declare const PI: number;
1408
+ /**
1409
+ * 1/pi
1410
+ *
1411
+ * @type {Number}
1412
+ * @constant
1413
+ */
1414
+ declare const ONE_OVER_PI: number;
1415
+ /**
1416
+ * pi/2
1417
+ *
1418
+ * @type {Number}
1419
+ * @constant
1420
+ */
1421
+ declare const PI_OVER_TWO: number;
1422
+ /**
1423
+ * pi/3
1424
+ *
1425
+ * @type {Number}
1426
+ * @constant
1427
+ */
1428
+ declare const PI_OVER_THREE: number;
1429
+ /**
1430
+ * pi/4
1431
+ *
1432
+ * @type {Number}
1433
+ * @constant
1434
+ */
1435
+ declare const PI_OVER_FOUR: number;
1436
+ /**
1437
+ * pi/6
1438
+ *
1439
+ * @type {Number}
1440
+ * @constant
1441
+ */
1442
+ declare const PI_OVER_SIX: number;
1443
+ /**
1444
+ * 3pi/2
1445
+ *
1446
+ * @type {Number}
1447
+ * @constant
1448
+ */
1449
+ declare const THREE_PI_OVER_TWO: number;
1450
+ /**
1451
+ * 2pi
1452
+ *
1453
+ * @type {Number}
1454
+ * @constant
1455
+ */
1456
+ declare const PI_TWO: number;
1457
+ /**
1458
+ * 1/2pi
1459
+ *
1460
+ * @type {Number}
1461
+ * @constant
1462
+ */
1463
+ declare const ONE_OVER_TWO_PI: number;
1464
+ /**
1465
+ * The number of radians in a degree.
1466
+ *
1467
+ * @type {Number}
1468
+ * @constant
1469
+ */
1470
+ declare const RADIANS_PER_DEGREE: number;
1471
+ /**
1472
+ * The number of degrees in a radian.
1473
+ *
1474
+ * @type {Number}
1475
+ * @constant
1476
+ */
1477
+ declare const DEGREES_PER_RADIAN: number;
1478
+ /**
1479
+ * The number of radians in an arc second.
1480
+ *
1481
+ * @type {Number}
1482
+ * @constant
1483
+ */
1484
+ declare const RADIANS_PER_ARCSECOND: number;
1485
+ declare function sign(value: number): 1 | -1;
1486
+ declare function approximateEqual(v1: number, v2: number, precision?: number): boolean;
1487
+ declare function clamp(value: number, min: number, max: number): number;
1488
+ declare function lerp(x: number, y: number, t: number): number;
1489
+ declare function smoothstep(x: number, min: number, max: number): number;
1490
+ declare function smootherstep(x: number, min: number, max: number): number;
1491
+ declare function randInt(low: number, high: number): number;
1492
+ /**
1493
+ * 生成一个low~high之间的浮点数
1494
+ * @param {*} low
1495
+ * @param {*} high
1496
+ */
1497
+ declare function randFloat(low: number, high: number): number;
1498
+ declare function isPowerOfTwo(value: number): boolean;
1499
+ declare function ceilPowerOfTwo(value: number): number;
1500
+ declare function floorPowerOfTwo(value: number): number;
1501
+ declare function toRadians(degrees: number): number;
1502
+ declare function ToDegrees(radians: number): number;
1503
+ /**
1504
+ * 数字或者向量固定位数
1505
+ * @param {Object} obj 数字或者向量
1506
+ * @param {*} fractionDigits
1507
+ */
1508
+ declare function toFixed(obj: {
1509
+ toFixed: (arg0: any) => string;
1510
+ x: number | undefined;
1511
+ y: number | undefined;
1512
+ z: number | undefined;
1513
+ }, fractionDigits: number | undefined): number | {
1514
+ toFixed: (arg0: any) => string;
1515
+ x: number | undefined;
1516
+ y: number | undefined;
1517
+ z: number | undefined;
1518
+ };
1519
+ /**
1520
+ * 数组中所有数字或者向量固定位数
1521
+ * @param {Array} array
1522
+ * @param {Number} precision
1523
+ */
1524
+ declare function toFixedAry(array: Array<any>, precision?: number): void;
1525
+
1526
+ declare class Color {
1527
+ _r: number;
1528
+ _g: number;
1529
+ _b: number;
1530
+ _a: number;
1531
+ constructor(r?: number, g?: number, b?: number, a?: number);
1532
+ get isColor(): boolean;
1533
+ get r(): number;
1534
+ set r(value: number);
1535
+ get g(): number;
1536
+ set g(value: number);
1537
+ get b(): number;
1538
+ set b(value: number);
1539
+ get a(): number;
1540
+ set a(value: number);
1541
+ set(value: any): this;
1542
+ setHex(hex: number): this;
1543
+ setHexCssString(style: string): this | undefined;
1544
+ setRGB(r: number, g: number, b: number, a?: number): this;
1545
+ clone(): any;
1546
+ copy(color: this): this;
1547
+ equals(c: this): boolean;
1548
+ toArray(array?: number[], offset?: number): number[];
1549
+ fromArray(array?: number[], offset?: number): number[];
1550
+ private byteToFloat;
1551
+ private floatToByte;
1552
+ getHexCssString(): string;
1553
+ toJSON(): string;
1554
+ static get White(): Readonly<Color>;
1555
+ static get Red(): Color;
1556
+ static get Green(): Color;
1557
+ static get Blue(): Color;
1558
+ }
1559
+
1560
+ /**
1561
+ * 当向量以数组的方式出现,一个计算单元库
1562
+ * @Description : 向量数组
1563
+ * @Author : 赵耀圣
1564
+ * @QQ : 549184003
1565
+ * @Date : 2021-08-02 15:09:33
1566
+ * @LastEditTime : 2021-08-02 15:50:16
1567
+ * @FilePath : \cga.js\src\math\VecArray.ts
1568
+ */
1569
+
1570
+ /**
1571
+ * 矢量几何操作,数字数组/矢量数组,常用工具集合
1572
+ */
1573
+ declare class vecs {
1574
+ /**
1575
+ * 去除相邻的重复向量
1576
+ * @param vs 矢量集合
1577
+ * @param delta 误差
1578
+ * @returns
1579
+ */
1580
+ static uniqueNeighborVecs(vs: Array<Vec3>, delta?: number): Vec3[];
1581
+ /**
1582
+ * 找到最大值
1583
+ * @param array
1584
+ * @returns
1585
+ */
1586
+ static max(array: ArrayLike<number>): number;
1587
+ /**
1588
+ * 找到最小值
1589
+ * @param array
1590
+ * @returns
1591
+ */
1592
+ static min(array: ArrayLike<number>): number;
1593
+ /**
1594
+ * 去除相邻没有重复点
1595
+ */
1596
+ static uniqueNeighbor(vs: number[], component?: number, delta?: number): number[];
1597
+ /**
1598
+ * 去除任意重复点
1599
+ * @param vs 向量数组
1600
+ * @param component 向量组件数量
1601
+ * @returns 无重复向量数组
1602
+ */
1603
+ static unique(vs: number[], component?: number): number[];
1604
+ /**
1605
+ * 翻转向量数组
1606
+ * @param vecs 向量数组
1607
+ * @param component 组件数量
1608
+ * @returns
1609
+ */
1610
+ static reverse(vecs: number[], component?: number): number[];
1611
+ /**
1612
+ * 点积
1613
+ * @param vecs
1614
+ * @returns
1615
+ */
1616
+ static dot(...vecs: number[]): number;
1617
+ /**
1618
+ * 长度平方
1619
+ * @param vecs
1620
+ * @returns
1621
+ */
1622
+ static distanceSq(...vecs: number[]): number;
1623
+ /**
1624
+ * 长度
1625
+ * @param vecs
1626
+ * @returns
1627
+ */
1628
+ static distance(...vecs: number[]): number;
1629
+ /**
1630
+ * 相加
1631
+ * @param vecs
1632
+ * @returns
1633
+ */
1634
+ static add(...vecs: number[]): number[] | (number & any[]);
1635
+ /**
1636
+ * 相减
1637
+ * @param vecs
1638
+ * @returns
1639
+ */
1640
+ static sub(...vecs: number[]): number[];
1641
+ /**
1642
+ * 相乘
1643
+ * @param vecs
1644
+ * @returns
1645
+ */
1646
+ static mul(...vecs: number[]): number[] | (number & any[]);
1647
+ /**
1648
+ * 获取矢量数组的i个矢量
1649
+ * @param vecs
1650
+ * @param i
1651
+ * @param component
1652
+ * @returns
1653
+ */
1654
+ static getVecAt(vecs: number[], i: number, component?: number): number[];
1655
+ /**
1656
+ * 在第 i 个位置插入一个向量
1657
+ * @param vecs
1658
+ * @param i
1659
+ * @param vec
1660
+ */
1661
+ static insertAt(vecs: number[], i: number, ...vec: number[]): void;
1662
+ /**
1663
+ * 是否逆时针
1664
+ * counterclockwise
1665
+ */
1666
+ static isCCW<T>(shape: Array<T> | ArrayList<T>, component?: number): boolean;
1667
+ /**
1668
+ * 将向量深度拆解为数字
1669
+ * @param {Array} Array<Vec4 | Vec3 | Vec2 | any> | any
1670
+ * @param {String} comSort 'x','y','z','w' 按顺序选取后自由组合
1671
+ * @returns {Array<Number>} 数字数组
1672
+ */
1673
+ static verctorToNumbers(vectors: Array<Vec4 | Vec3 | Vec2 | any> | any, comSort?: string): number[];
1674
+ static vec(component?: number): Vec3 | Vec4 | Vec2;
1675
+ /**
1676
+ * 数字数组 转 适量数组
1677
+ * @param vss 数字数组
1678
+ * @param component 矢量维度,默认为3
1679
+ * @returns
1680
+ */
1681
+ static numbersToVecs(vss: TypedArrayLike, component?: number): Vec2[] | Vec3[] | Vec4[];
1682
+ static applyQuat(vss: TypedArrayLike, quat: Quat, component?: number): void;
1683
+ static applyMat4(vss: TypedArrayLike, mat: Mat4, component?: number): void;
1684
+ static translate(vss: TypedArrayLike, distance: number[], component?: number): void;
1685
+ static rotate(vss: TypedArrayLike, axis: Vec3, angle: number): void;
1686
+ static scale(vss: TypedArrayLike, _scale: number[], component?: number): void;
1687
+ }
1688
+
1689
+ /**
1690
+ * 数组深度复制
1691
+ * @param {Array} array
1692
+ */
1693
+ declare function clone(array: any | any[]): any;
1694
+ /**
1695
+ * 点排序函数 xyz 有序排序回调
1696
+ * @param {Vector*} a
1697
+ * @param {Vector*} b
1698
+ */
1699
+ declare function vectorCompare(a: any | Vec3, b: any | Vec3): number;
1700
+ /**
1701
+ * 计算包围盒
1702
+ * @param {*} points 点集
1703
+ * @returns {Array[min,max]} 返回最小最大值
1704
+ */
1705
+ declare function boundingBox(points: Vec3[]): Vec3[];
1706
+ /**
1707
+ *
1708
+ * @param {*} points
1709
+ * @param {*} quat
1710
+ * @param {Boolean} ref 是否是引用
1711
+ */
1712
+ declare function applyQuat(points: any | Vec3[], quat: Quat, ref?: boolean): Vec3 | any;
1713
+ /**
1714
+ * 平移
1715
+ * @param {*} points
1716
+ * @param {*} distance
1717
+ * @param {*} ref
1718
+ */
1719
+ declare function translate(points: any | Vec3[], distance: Vec3, ref?: boolean): Vec3[] | any;
1720
+ /**
1721
+ * 旋转
1722
+ * @param {*} points
1723
+ * @param {*} axis
1724
+ * @param {*} angle
1725
+ * @param {*} ref
1726
+ */
1727
+ declare function rotate(points: any | Vec3[], axis: Vec3, angle: number, ref?: boolean): any;
1728
+ /**
1729
+ * 两个向量之间存在的旋转量来旋转点集
1730
+ * @param {*} points
1731
+ * @param {*} axis
1732
+ * @param {*} angle
1733
+ * @param {*} ref
1734
+ */
1735
+ declare function rotateByUnitVectors(points: any | Vec3[], vFrom: Vec3, vTo: Vec3, ref?: boolean): any;
1736
+ /**
1737
+ * 缩放
1738
+ * @param {*} points
1739
+ * @param {*} axis
1740
+ * @param {*} angle
1741
+ * @param {*} ref
1742
+ */
1743
+ declare function scale(points: any | Vec3[], _scale: Vec3, ref?: boolean): Vec3[] | any;
1744
+ /**
1745
+ * 响应矩阵
1746
+ * @param {*} points
1747
+ * @param {*} axis
1748
+ * @param {*} angle
1749
+ * @param {*} ref
1750
+ */
1751
+ declare function applyMatrix4(points: any | Vec3[], matrix: Mat4, ref?: boolean): Vec3[] | any;
1752
+ /**
1753
+ * 简化点集数组,折线,路径
1754
+ * @param {*} points 点集数组,折线,路径 ,继承Array
1755
+ * @param {*} maxDistance 简化最大距离
1756
+ * @param {*} maxAngle 简化最大角度
1757
+ */
1758
+ declare function simplifyPointList(points: any | Vec3[], maxDistance?: number, maxAngle?: number): any;
1759
+ /**
1760
+ * 以某个平面生成对称镜像
1761
+ * @param {*} points 点集
1762
+ * @param {*} plane 对称镜像平面
1763
+ */
1764
+ declare function reverseOnPlane(points: any | Vec3[], plane: Plane): void;
1765
+ /**
1766
+ * 投影到平面
1767
+ * @param {*} points 点集
1768
+ * @param {*} plane 投影平面
1769
+ * @param {*} projectDirect 默认是法线的方向
1770
+ */
1771
+ declare function projectOnPlane(points: any | Vec3[], plane: Plane, projectDirect: Vec3): any;
1772
+ /**
1773
+ * 计算共面点集所在的平面
1774
+ * @param {Array<Vec3|Point>} points
1775
+ */
1776
+ declare function recognitionPlane(points: Vec3[] | any): Plane;
1777
+ /**
1778
+ * 判断所有点是否在同一个平面
1779
+ * @param {Array<Vec3|Point>} points
1780
+ * @param {*} precision
1781
+ * @returns {Boolean|Plane} 如果在同一个平面返回所在平面,否则返回false
1782
+ */
1783
+ declare function isInOnePlane(points: Vec3[] | any, precision?: number): false | Plane;
1784
+ /**
1785
+ * 判断多边是否共线:
1786
+ * 考虑情况点之间的距离应该大于最小容忍值
1787
+ * @param {...Vec3[]} ps
1788
+ */
1789
+ declare function pointsCollinear(...ps: Vec3[]): boolean;
1790
+ /**
1791
+ * 三点计算圆
1792
+ * @param p0
1793
+ * @param p1
1794
+ * @param p2
1795
+ */
1796
+ declare function calcCircleFromThreePoint(p0: Vec3, p1: Vec3, p2: Vec3): Circle;
1797
+ declare function angle(v0: Vec3, v1: Vec3, normal?: Vec3): number;
1798
+
1799
+ declare class Delaunator {
1800
+ coords: Float64Array;
1801
+ _triangles: Uint32Array;
1802
+ _halfedges: Int32Array;
1803
+ _hashSize: number;
1804
+ _hullPrev: Uint32Array;
1805
+ _hullNext: Uint32Array;
1806
+ _hullTri: Uint32Array;
1807
+ _hullHash: Int32Array;
1808
+ _ids: Uint32Array;
1809
+ _dists: Float64Array;
1810
+ hull: Uint32Array;
1811
+ triangles: Uint32Array;
1812
+ halfedges: any;
1813
+ _cx: any;
1814
+ _cy: any;
1815
+ _hullStart: number;
1816
+ trianglesLen: number;
1817
+ static from(points: number[]): Delaunator;
1818
+ static fromVecs(points: Vec2[] | Vec3[]): Delaunator;
1819
+ constructor(coords: Float64Array);
1820
+ update(): void;
1821
+ _hashKey(x: number, y: number): number;
1822
+ _legalize(a: number): number;
1823
+ _link(a: number, b: number): void;
1824
+ _addTriangle(i0: number, i1: number, i2: number, a: number, b: number, c: number): number;
1825
+ }
1826
+
1827
+ declare class Voronoi {
1828
+ delaunay: any;
1829
+ _circumcenters: Float64Array;
1830
+ vectors: Float64Array;
1831
+ xmax: number;
1832
+ xmin: number;
1833
+ ymax: number;
1834
+ ymin: number;
1835
+ circumcenters: any;
1836
+ constructor(delaunay: Delaunay, [xmin, ymin, xmax, ymax]?: [number, number, number, number]);
1837
+ update(): this;
1838
+ _init(): void;
1839
+ cellPolygons(): Generator<any, void, unknown>;
1840
+ cellPolygon(i: number): any[] | null;
1841
+ _renderSegment(x0: any, y0: any, x1: any, y1: any, context: {
1842
+ moveTo: (arg0: any, arg1: any) => void;
1843
+ lineTo: (arg0: any, arg1: any) => void;
1844
+ }): void;
1845
+ contains(i: any, x: number | any, y: number | any): boolean;
1846
+ neighbors(i: any): Generator<any, void, unknown>;
1847
+ _cell(i: string | number): any[] | null;
1848
+ _clip(i: number): any;
1849
+ _clipFinite(i: any, points: string | any[]): any;
1850
+ _clipSegment(x0: number, y0: number, x1: number, y1: number, c0: number, c1: number): number[] | null;
1851
+ _clipInfinite(i: any, points: any, vx0: number, vy0: number, vxn: number, vyn: number): unknown[];
1852
+ _edge(i: any, e0: number, e1: number, P: any[], j: number): number;
1853
+ _project(x0: any, y0: any, vx: number, vy: number): any[] | null;
1854
+ _edgecode(x: unknown, y: unknown): number;
1855
+ _regioncode(x: number, y: number): number;
1856
+ }
1857
+
1858
+ declare class Delaunay {
1859
+ _delaunator: Delaunator;
1860
+ inedges: Int32Array;
1861
+ _hullIndex: Int32Array;
1862
+ points: Float64Array;
1863
+ collinear?: Int32Array;
1864
+ halfedges: any;
1865
+ hull: Uint32Array;
1866
+ triangles: Uint32Array;
1867
+ static from(points: number[]): Delaunay;
1868
+ constructor(points: Float64Array);
1869
+ update(): this;
1870
+ _init(): void;
1871
+ voronoi(bounds: [number, number, number, number] | undefined): Voronoi;
1872
+ neighbors(i: number): Generator<number, void, unknown>;
1873
+ find(x: number, y: number, i?: number): number;
1874
+ _step(i: number, x: number, y: number): number;
1875
+ }
1876
+
1877
+ /**
1878
+ * 网格工具
1879
+ */
1880
+ declare class MeshTool {
1881
+ static indexable(obj: any[] | any, refIndexInfo?: {
1882
+ index: number;
1883
+ }, force?: boolean): void;
1884
+ static triangListToBuffer(vertices: Vec3[], triangleList: Vec3[]): BufferGeometry;
1885
+ /**
1886
+ * 顶点纹理坐标所以转化为buffer数据
1887
+ * @param {Array<Verctor3|Number>} vertices
1888
+ * @param {Array<Number>} indices
1889
+ * @param {Array<Verctor2|Number>} uvs
1890
+ */
1891
+ static toGeoBuffer(vertices: BufferAttribute | Array<number | Vec2 | Vec3 | Vec4> | TypedArray, indices: number[] | Uint32Array | Uint16Array, uvs?: BufferAttribute | TypedArray | Array<Vec2 | number>): BufferGeometry;
1892
+ /**
1893
+ * 三角剖分后转成几何体
1894
+ * 只考虑XY平面
1895
+ * @param {*} boundary
1896
+ * @param {*} hole
1897
+ * @param {*} options
1898
+ */
1899
+ static trianglutionToGeometryBuffer(boundary: any, holes?: any[], options?: any): BufferGeometry;
1900
+ }
1901
+
1902
+ declare class Point extends Vec3 {
1903
+ constructor(_x?: number, _y?: number, _z?: number);
1904
+ }
1905
+
1906
+ interface IDistanceResut {
1907
+ isNode: boolean;
1908
+ point: Vec3;
1909
+ direction: Vec3;
1910
+ }
1911
+ declare class Path<T extends Vec3> extends ArrayList<T> {
1912
+ _closed: boolean;
1913
+ _calcNoraml: boolean;
1914
+ /**
1915
+ *
1916
+ * @param vs 假定是没有重复的点集
1917
+ * @param closed
1918
+ * @param calcNormal
1919
+ */
1920
+ constructor(vs: Array<T> | ArrayList<T>, closed?: boolean, calcNormal?: boolean);
1921
+ init(calcNormal: boolean): void;
1922
+ set closed(val: boolean);
1923
+ get closed(): boolean;
1924
+ get tlen(): number;
1925
+ applyMat4(mat4: Mat4): void;
1926
+ scale(x: number, y: number, z: number): void;
1927
+ /**
1928
+ * 截取一段从from到to的path
1929
+ * @param {Number} from
1930
+ * @param {Number} to
1931
+ */
1932
+ splitByFromToDistance(from?: number, to?: number): Path<never> | null;
1933
+ /**
1934
+ * 从起点出发到距离等于distance位置 的坐标 二分查找
1935
+ * @param {Number} distance
1936
+ */
1937
+ getPointByDistance(arg_distance: number, left?: number, right?: number): IDistanceResut | null;
1938
+ /**
1939
+ * 从起点出发到距离等于distance位置 的坐标 二分查找
1940
+ * @param {Number} distance
1941
+ */
1942
+ getPointByDistancePure(arg_distance: number, left?: number, right?: number): Vec3 | null;
1943
+ /**
1944
+ * 平均切割为 splitCount 段
1945
+ * @param {Number} splitCount
1946
+ * @returns {Path} 新的path
1947
+ */
1948
+ splitAverage(splitCount: number): Path<T>;
1949
+ /**
1950
+ * 通过测试
1951
+ * 平均切割为 splitCount 段
1952
+ * @param {Number} splitCount
1953
+ * @param {Boolean} integer 是否取整
1954
+ * @returns {Path} 新的path
1955
+ */
1956
+ splitAverageLength(splitLength: number, integer?: boolean): Path<T>;
1957
+ /**
1958
+ *
1959
+ * @param {...any} ps
1960
+ */
1961
+ add(...ps: Vec3[] | Point[]): void;
1962
+ /**
1963
+ * @description : 计算一段线段的总长度
1964
+ * @param {ArrayLike} ps
1965
+ * @return {number} 总长度
1966
+ */
1967
+ static totalMileages(ps: ArrayLike<Vec3>): number;
1968
+ /**
1969
+ * @description : 获取没一点的里程 里程是指从第一个点出发的长度
1970
+ * @param {ArrayLike} ps 里程上的点集
1971
+ * @param {boolean} normalize 是否归一化
1972
+ * @return {number[]} 每一个点的里程数组
1973
+ * @example :
1974
+ */
1975
+ static getPerMileages(ps: ArrayLike<Vec3>, normalize?: boolean, totalMileage?: number): number[];
1976
+ }
1977
+
1978
+ /**
1979
+ * 视锥体
1980
+ */
1981
+ declare class Frustum {
1982
+ planes: Plane[];
1983
+ constructor();
1984
+ get front(): Plane;
1985
+ get back(): Plane;
1986
+ get top(): Plane;
1987
+ get bottom(): Plane;
1988
+ get left(): Plane;
1989
+ get right(): Plane;
1990
+ /**
1991
+ * 从投影矩阵计算视锥体
1992
+ * @param m
1993
+ * @returns
1994
+ */
1995
+ setFromProjectionMatrix(m: Mat4): this;
1996
+ static fromProjectionMatrix(m: Mat4): Frustum;
1997
+ setFromPerspective(position: Vec3, target: Vec3, up: Vec3, fov: number, aspect: number, near: number, far: number): void;
1998
+ intersectsObject(geometry: BufferGeometry, mat: Mat4): boolean;
1999
+ intersectsSphere(sphere: Sphere): boolean;
2000
+ intersectsSphereComponents(cx: number, cy: number, cz: number, radius: number): boolean;
2001
+ containsPoint(point: Vec3): boolean;
2002
+ intersectSegment(segment: Segment | Vec3[]): Vec3 | Vec3[] | Segment | null;
2003
+ simpleIntersectVS(vs: Vec3[]): Vec3[];
2004
+ copy(frustum: Frustum): void;
2005
+ clone(): any;
2006
+ }
2007
+
2008
+ declare function toGeometryBuffer(geo: IGeometry): BufferGeometry;
2009
+ /**
2010
+ * shape 挤压后转几何体
2011
+ * @param {*} shape
2012
+ * @param {*} arg_path
2013
+ * @param {*} options
2014
+ */
2015
+ declare function extrudeToGeometryBuffer(shape: ArrayList<Vec3>, arg_path: Array<Vec3>, options: IExtrudeOptions): BufferGeometry;
2016
+ /**
2017
+ * 两个轮廓缝合
2018
+ * @param {*} shape
2019
+ * @param {*} arg_path
2020
+ * @param {*} options
2021
+ * @param {*} material
2022
+ */
2023
+ declare function linkToGeometry(shape: Array<Vec3>, shape1: Array<Vec3>, axisPlane?: AxisPlane, shapeClose?: boolean): BufferGeometry;
2024
+ /**
2025
+ * 多个轮廓缝合
2026
+ * @param shapes
2027
+ * @param isClose
2028
+ * @param material
2029
+ */
2030
+ declare function linksToGeometry(shapes: Array<Vec3>[], pathClosed?: boolean, shapeClosed?: boolean): BufferGeometry;
2031
+
2032
+ export { AxisPlane, Box, BufferAttribute, BufferGeometry, Capsule, Circle, Color, DEGREES_PER_RADIAN, Delaunator, Disk, DistanceResult, EndType, Euler, Float32BufferAttribute, Float64BufferAttribute, Frustum, IBufferGeometry, IDistanceResut, IExtrudeOptions, IExtrudeOptionsEx, IExtrudeOptionsNext, IGeometry, ILinkSideOption, ILinkSideOptions, ITriangulationOption, IVec2, IVec3, IVec4, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, IntersectResult, JoinType, Line, Mat3, Mat4, MeshTool, ONE_OVER_PI, ONE_OVER_TWO_PI, PI, PI_OVER_FOUR, PI_OVER_SIX, PI_OVER_THREE, PI_OVER_TWO, PI_TWO, Path, Plane, Point, Polygon, Polyline, Quat, RADIANS_PER_ARCSECOND, RADIANS_PER_DEGREE, Ray, Segment, Sphere, THREE_PI_OVER_TWO, ToDegrees, Triangle, Uint16BufferAttribute, Uint32BufferAttribute, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Vec2, Vec3, Vec4, Voronoi, angle, applyMatrix4, applyQuat, approximateEqual, boundingBox, calcCircleFromThreePoint, ceilPowerOfTwo, circle, clamp, classify, clone, delta4, delta5, delta6, delta7, delta8, delta9, disk, euler, extrude, extrudeNext, extrudeToGeometryBuffer, extrude_obsolete, flat, floorPowerOfTwo, forall, isInOnePlane, isPowerOfTwo, lerp, line, linkSide, linkSides, linkToGeometry, linksToGeometry, m3, m4, pointsCollinear, projectOnPlane, quat, randFloat, randInt, recognitionPlane, reverseOnPlane, rotate, rotateByUnitVectors, scale, segment, sign, simplifyPointList, smootherstep, smoothstep, toFixed, toFixedAry, toGeometryBuffer, toRadians, translate, triangulation, unique, v2, v3, v4, vecs, vectorCompare };