@xort/cga 0.0.91 → 0.0.93

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.
package/build/cga.d.ts CHANGED
@@ -608,12 +608,7 @@ declare class Ray {
608
608
  distancePloyline(): DistanceResult;
609
609
  }
610
610
 
611
- declare enum AxisPlane {
612
- XY = "xy",
613
- XZ = "xz",
614
- YZ = "yz",
615
- XYZ = "xyz"
616
- }
611
+ type AxisPlane = 'xy' | 'xz' | 'yz' | 'xyz';
617
612
  interface ITriangulationOption {
618
613
  feature?: AxisPlane;
619
614
  dim?: number;
@@ -873,6 +868,12 @@ declare class Polygon<T> extends Polyline<T> {
873
868
  containPoint(point: Vec3): void;
874
869
  }
875
870
 
871
+ declare enum ClipType {
872
+ Intersection = 0,
873
+ Union = 1,
874
+ Difference = 2,
875
+ Xor = 3
876
+ }
876
877
  /**
877
878
  * 线段正反原则:右手坐标系中,所在平面为XZ平面,把指向方向看着负Z轴,x正为正方向,x负为负方向
878
879
  */
@@ -881,6 +882,9 @@ declare class Polyline<T> extends ArrayList<T> {
881
882
  isPolyline: boolean;
882
883
  normal: Vec3;
883
884
  constructor(vs?: Array<T> | Polyline<T> | Polygon<T>, normal?: Vec3);
885
+ static CleanPolygon(polys: any, delta: number, jointype: JoinType | undefined, endtype: EndType | undefined, limit: number): void;
886
+ static OffsetPaths(polys: any, delta: number, jointype: JoinType | undefined, endtype: EndType | undefined, limit: number): void;
887
+ static SimplifyPolygon(polys: any, delta: number, jointype: JoinType | undefined, endtype: EndType | undefined, limit: number): void;
884
888
  /**
885
889
  * 偏移
886
890
  * @param {Number} distance 偏移距离
@@ -986,7 +990,16 @@ declare class Circle {
986
990
  * @param lengthAngle 弧度长度 单位弧度
987
991
  * @param segment 分段
988
992
  */
989
- static toVertices(center: Vec3, radius: number, startAngle?: number, lengthAngle?: number, segment?: number): Vec3[];
993
+ static toVecs(center: Vec3, radius: number, startAngle?: number, lengthAngle?: number, up?: Vec3, segment?: number): Vec3[];
994
+ /**
995
+ * 在p点延伸a,b两个方向,生成半径为r的圆弧,圆弧所在位置在a,b向量的内夹角
996
+ * @param p 位置
997
+ * @param a a方向
998
+ * @param b b方向
999
+ * @param r 圆弧半径
1000
+ */
1001
+ static PAdBdtoVecs(p: Vec3, a: Vec3, b: Vec3, r: number, segment?: number): Vec3[];
1002
+ static PApBptoVecs(p: Vec3, a: Vec3, b: Vec3, r: number, segment?: number): Vec3[];
990
1003
  }
991
1004
  declare function circle(center?: Vec3, radius?: number): Circle;
992
1005
 
@@ -1117,7 +1130,19 @@ declare class Vec3 implements IVec3 {
1117
1130
  */
1118
1131
  projectDirectionOnPlane(plane: Plane, dir: Vec3): this;
1119
1132
  reflect(normal: any): this;
1133
+ /**
1134
+ * 两个向量的夹角
1135
+ * @param v
1136
+ * @param normal
1137
+ * @returns
1138
+ */
1120
1139
  angleTo(v: Vec3, normal?: Vec3 | any): number;
1140
+ /**
1141
+ * 一个向量到另一个向量的角度
1142
+ * @param v
1143
+ * @param normal
1144
+ * @returns
1145
+ */
1121
1146
  angleToEx(v: Vec3, normal: Vec3): number;
1122
1147
  distanceTo(v: any): number;
1123
1148
  distanceToSquared(v: Vec3): number;
@@ -2029,4 +2054,4 @@ declare function linkToGeometry(shape: Array<Vec3>, shape1: Array<Vec3>, axisPla
2029
2054
  */
2030
2055
  declare function linksToGeometry(shapes: Array<Vec3>[], pathClosed?: boolean, shapeClosed?: boolean): BufferGeometry;
2031
2056
 
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 };
2057
+ export { AxisPlane, Box, BufferAttribute, BufferGeometry, Capsule, Circle, ClipType, 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 };
@@ -131,7 +131,19 @@ export declare class Vec3 implements IVec3 {
131
131
  */
132
132
  projectDirectionOnPlane(plane: Plane, dir: Vec3): this;
133
133
  reflect(normal: any): this;
134
+ /**
135
+ * 两个向量的夹角
136
+ * @param v
137
+ * @param normal
138
+ * @returns
139
+ */
134
140
  angleTo(v: Vec3, normal?: Vec3 | any): number;
141
+ /**
142
+ * 一个向量到另一个向量的角度
143
+ * @param v
144
+ * @param normal
145
+ * @returns
146
+ */
135
147
  angleToEx(v: Vec3, normal: Vec3): number;
136
148
  distanceTo(v: any): number;
137
149
  distanceToSquared(v: Vec3): number;
package/dist/math/Vec3.js CHANGED
@@ -527,12 +527,24 @@ var Vec3 = /** @class */ (function () {
527
527
  // normal is assumed to have unit length
528
528
  return this.sub(_vec.copy(normal).multiplyScalar(2 * this.dot(normal)));
529
529
  };
530
+ /**
531
+ * 两个向量的夹角
532
+ * @param v
533
+ * @param normal
534
+ * @returns
535
+ */
530
536
  Vec3.prototype.angleTo = function (v, normal) {
531
537
  if (normal)
532
538
  return this.angleToEx(v, normal);
533
539
  var theta = this.dot(v) / Math.sqrt(this.lengthSq() * v.lengthSq());
534
540
  return Math.acos((0, Math_1.clamp)(theta, -1, 1));
535
541
  };
542
+ /**
543
+ * 一个向量到另一个向量的角度
544
+ * @param v
545
+ * @param normal
546
+ * @returns
547
+ */
536
548
  Vec3.prototype.angleToEx = function (v, normal) {
537
549
  var theta = this.dot(v) / Math.sqrt(this.lengthSq() * v.lengthSq());
538
550
  if (this.clone().cross(v).dot(normal) > 0)
@@ -38,6 +38,15 @@ export declare class Circle {
38
38
  * @param lengthAngle 弧度长度 单位弧度
39
39
  * @param segment 分段
40
40
  */
41
- static toVertices(center: Vec3, radius: number, startAngle?: number, lengthAngle?: number, segment?: number): Vec3[];
41
+ static toVecs(center: Vec3, radius: number, startAngle?: number, lengthAngle?: number, up?: Vec3, segment?: number): Vec3[];
42
+ /**
43
+ * 在p点延伸a,b两个方向,生成半径为r的圆弧,圆弧所在位置在a,b向量的内夹角
44
+ * @param p 位置
45
+ * @param a a方向
46
+ * @param b b方向
47
+ * @param r 圆弧半径
48
+ */
49
+ static PAdBdtoVecs(p: Vec3, a: Vec3, b: Vec3, r: number, segment?: number): Vec3[];
50
+ static PApBptoVecs(p: Vec3, a: Vec3, b: Vec3, r: number, segment?: number): Vec3[];
42
51
  }
43
52
  export declare function circle(center?: Vec3, radius?: number): Circle;
@@ -4,6 +4,7 @@ exports.circle = exports.Circle = void 0;
4
4
  var Vec3_1 = require("../../math/Vec3");
5
5
  var common_1 = require("../../alg/common");
6
6
  var Line_1 = require("./Line");
7
+ var Quat_1 = require("src/math/Quat");
7
8
  var Circle = /** @class */ (function () {
8
9
  /**
9
10
  * 圆圈
@@ -83,14 +84,14 @@ var Circle = /** @class */ (function () {
83
84
  * @param lengthAngle 弧度长度 单位弧度
84
85
  * @param segment 分段
85
86
  */
86
- Circle.toVertices = function (center, radius, startAngle, lengthAngle, segment) {
87
+ Circle.toVecs = function (center, radius, startAngle, lengthAngle, up, segment) {
87
88
  if (startAngle === void 0) { startAngle = 0; }
88
89
  if (lengthAngle === void 0) { lengthAngle = Math.PI * 2; }
90
+ if (up === void 0) { up = Vec3_1.Vec3.UnitY; }
89
91
  if (segment === void 0) { segment = 16; }
90
92
  var Xvec = Vec3_1.Vec3.UnitX;
91
93
  Xvec.multiplyScalar(radius);
92
94
  var result = [];
93
- var up = Vec3_1.Vec3.UnitY;
94
95
  var perAngle = lengthAngle / segment;
95
96
  for (var i = 0; i <= segment; i++) {
96
97
  var langlei = perAngle * i + startAngle;
@@ -99,6 +100,35 @@ var Circle = /** @class */ (function () {
99
100
  }
100
101
  return result;
101
102
  };
103
+ /**
104
+ * 在p点延伸a,b两个方向,生成半径为r的圆弧,圆弧所在位置在a,b向量的内夹角
105
+ * @param p 位置
106
+ * @param a a方向
107
+ * @param b b方向
108
+ * @param r 圆弧半径
109
+ */
110
+ Circle.PAdBdtoVecs = function (p, a, b, r, segment) {
111
+ if (segment === void 0) { segment = 3; }
112
+ var angle = a.angleTo(b);
113
+ var d = r / Math.tan(angle / 2);
114
+ var cr = r / Math.sin(angle / 2);
115
+ var c = a.clone().add(b).normalize().multiplyScalar(cr).add(p);
116
+ var cd1 = a.clone().multiplyScalar(d).add(p).sub(c).normalize();
117
+ var cd2 = b.clone().multiplyScalar(d).add(p).sub(c).normalize();
118
+ var up = cd1.clone().cross(cd2).normalize();
119
+ var q = (0, Quat_1.quat)().setFromUnitVecs(up, Vec3_1.Vec3.UnitY); //两个向量形成一个旋转4元数
120
+ cd1.applyQuat(q);
121
+ cd2.applyQuat(q);
122
+ var startAngle = Vec3_1.Vec3.UnitX.angleToEx(cd1, Vec3_1.Vec3.UnitY);
123
+ var lengthAngle = Vec3_1.Vec3.UnitX.angleToEx(cd2, Vec3_1.Vec3.UnitY) - startAngle;
124
+ return this.toVecs(c, r, startAngle, lengthAngle, up, segment);
125
+ };
126
+ Circle.PApBptoVecs = function (p, a, b, r, segment) {
127
+ if (segment === void 0) { segment = 3; }
128
+ var pa = a.clone().sub(p).normalize();
129
+ var pb = b.clone().sub(p).normalize();
130
+ return Circle.PAdBdtoVecs(p, pa, pb, r, segment);
131
+ };
102
132
  return Circle;
103
133
  }());
104
134
  exports.Circle = Circle;
@@ -0,0 +1,9 @@
1
+ import { Tree } from "./tree";
2
+ /**
3
+ *
4
+ */
5
+ export declare class BSP extends Tree {
6
+ constructor();
7
+ get pos(): this;
8
+ get neg(): this;
9
+ }
@@ -1 +1,44 @@
1
1
  "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.BSP = void 0;
19
+ var tree_1 = require("./tree");
20
+ /**
21
+ *
22
+ */
23
+ var BSP = /** @class */ (function (_super) {
24
+ __extends(BSP, _super);
25
+ function BSP() {
26
+ return _super.call(this, 2) || this;
27
+ }
28
+ Object.defineProperty(BSP.prototype, "pos", {
29
+ get: function () {
30
+ return this.children[0];
31
+ },
32
+ enumerable: false,
33
+ configurable: true
34
+ });
35
+ Object.defineProperty(BSP.prototype, "neg", {
36
+ get: function () {
37
+ return this.children[1];
38
+ },
39
+ enumerable: false,
40
+ configurable: true
41
+ });
42
+ return BSP;
43
+ }(tree_1.Tree));
44
+ exports.BSP = BSP;
package/gitproxy.sh ADDED
@@ -0,0 +1,6 @@
1
+ git config --global http.proxy 'socks5://127.0.0.1:5006'
2
+ git config --global https.proxy 'socks5://127.0.0.1:5006'
3
+
4
+
5
+ # git config --global --unset http.proxy
6
+ # git config --global --unset https.proxy
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xort/cga",
3
- "version": "0.0.91",
3
+ "version": "0.0.93",
4
4
  "description": "Xtor Compute Geometry Algorithm Libary 计算几何算法库",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/rollup.config.js CHANGED
@@ -55,25 +55,28 @@ if (MIN) {
55
55
  plugins.push(gzip());
56
56
  }
57
57
 
58
- export default {
59
- // input: path.join('dist', 'index.js'),
60
- // external: ['lodash'],
61
- // plugins: plugins,
62
- // output: {
63
- // file: path.join(DIST ? 'dist' : 'build', '@xort_cga' + (MIN ? '.min' : '') + '.js'),
64
- // format: 'umd',
65
- // // format: 'umd',
66
- // name: 'cga',
67
- // banner: banner,
68
- // globals: {
69
- // lodash: '_'
70
- // }
71
- // }
58
+ export default [
59
+ {
60
+ input: path.join('dist', 'index.js'),
61
+ external: ['lodash'],
62
+ plugins: plugins,
63
+ output: {
64
+ file: path.join(DIST ? 'dist' : 'build', '@xort_cga' + (MIN ? '.min' : '') + '.js'),
65
+ format: 'umd',
66
+ // format: 'umd',
67
+ name: 'cga',
68
+ banner: banner,
69
+ globals: {
70
+ lodash: '_'
71
+ }
72
+ }
73
+ },
74
+ {
72
75
 
73
- input: "dist/index.d.ts",
74
- output: [{
75
- file: "build/cga.d.ts", format: "es",
76
- name: 'cga'
77
- }],
78
- plugins: [dts()],
79
- }
76
+ input: "dist/index.d.ts",
77
+ output: [{
78
+ file: "build/cga.d.ts", format: "es",
79
+ name: 'cga'
80
+ }],
81
+ plugins: [dts()],
82
+ }]
@@ -243,7 +243,7 @@ export function linkSides(options: ILinkSideOptions): IGeometry {
243
243
  index.index += endShape.length
244
244
  if (holess && holess[0])
245
245
  endHoles.forEach((h: any) => {
246
- index.index += h.length
246
+ index.index += h.length;
247
247
  })
248
248
  }
249
249
  triangles.push(...endTris);
package/src/math/Vec3.ts CHANGED
@@ -7,7 +7,7 @@ import { DistanceResult } from '../alg/result';
7
7
  import { Line, line } from '../struct/3d/Line';
8
8
  import { Ray } from '../struct/3d/Ray';
9
9
  import { Segment } from '../struct/3d/Segment';
10
- import { Plane } from '../struct/3d/Plane';
10
+ import { Plane } from '../struct/3d/Plane';
11
11
  import { Triangle } from '../struct/3d/Triangle';
12
12
  import { Capsule } from '../struct/3d/Capsule';
13
13
  import { Rectangle } from '../struct/3d/Rectangle';
@@ -27,10 +27,10 @@ export interface IVec4 extends IVec3 {
27
27
  w: number;
28
28
  }
29
29
 
30
- export class Vec3 implements IVec3 {
30
+ export class Vec3 implements IVec3 {
31
31
 
32
32
  constructor(private _x: number = 0, private _y: number = 0, private _z: number = 0) {
33
-
33
+
34
34
  }
35
35
 
36
36
  get x() {
@@ -98,7 +98,7 @@ export class Vec3 implements IVec3 {
98
98
  this._x = x;
99
99
  this._y = y;
100
100
  this._z = z;
101
- //// this.fire('change');
101
+ //// this.fire('change');
102
102
  return this;
103
103
  }
104
104
 
@@ -107,7 +107,7 @@ export class Vec3 implements IVec3 {
107
107
  this._y = scalar;
108
108
  this._z = scalar;
109
109
 
110
- // this.fire('change');
110
+ // this.fire('change');
111
111
  return this;
112
112
  }
113
113
 
@@ -151,7 +151,7 @@ export class Vec3 implements IVec3 {
151
151
  this._y = v.y;
152
152
  this._z = v.z;
153
153
 
154
- // this.fire('change');
154
+ // this.fire('change');
155
155
  return this;
156
156
  }
157
157
 
@@ -167,7 +167,7 @@ export class Vec3 implements IVec3 {
167
167
  this._y += v.y;
168
168
  this._z += v.z;
169
169
 
170
- // this.fire('change');
170
+ // this.fire('change');
171
171
  return this;
172
172
  }
173
173
 
@@ -176,7 +176,7 @@ export class Vec3 implements IVec3 {
176
176
  this._y += s;
177
177
  this._z += s;
178
178
 
179
- // this.fire('change');
179
+ // this.fire('change');
180
180
  return this;
181
181
  }
182
182
 
@@ -185,7 +185,7 @@ export class Vec3 implements IVec3 {
185
185
  this._y = a.y + b.y;
186
186
  this._z = a.z + b.z;
187
187
 
188
- // this.fire('change');
188
+ // this.fire('change');
189
189
  return this;
190
190
  }
191
191
 
@@ -194,7 +194,7 @@ export class Vec3 implements IVec3 {
194
194
  this._y += v.y * s;
195
195
  this._z += v.z * s;
196
196
 
197
- // this.fire('change');
197
+ // this.fire('change');
198
198
  return this;
199
199
  }
200
200
 
@@ -210,7 +210,7 @@ export class Vec3 implements IVec3 {
210
210
  this._y -= v.y;
211
211
  this._z -= v.z;
212
212
 
213
- // this.fire('change');
213
+ // this.fire('change');
214
214
  return this;
215
215
  }
216
216
 
@@ -219,7 +219,7 @@ export class Vec3 implements IVec3 {
219
219
  this._y -= s;
220
220
  this._z -= s;
221
221
 
222
- // this.fire('change');
222
+ // this.fire('change');
223
223
  return this;
224
224
  }
225
225
 
@@ -228,7 +228,7 @@ export class Vec3 implements IVec3 {
228
228
  this._y = a.y - b.y;
229
229
  this._z = a.z - b.z;
230
230
 
231
- // this.fire('change');
231
+ // this.fire('change');
232
232
  return this;
233
233
  }
234
234
 
@@ -241,7 +241,7 @@ export class Vec3 implements IVec3 {
241
241
  this._y *= v.y;
242
242
  this._z *= v.z;
243
243
 
244
- // this.fire('change');
244
+ // this.fire('change');
245
245
  return this;
246
246
  }
247
247
 
@@ -250,7 +250,7 @@ export class Vec3 implements IVec3 {
250
250
  this._y *= scalar;
251
251
  this._z *= scalar;
252
252
 
253
- // this.fire('change');
253
+ // this.fire('change');
254
254
  return this;
255
255
  }
256
256
 
@@ -259,7 +259,7 @@ export class Vec3 implements IVec3 {
259
259
  this._y = a.y * b.y;
260
260
  this._z = a.z * b.z;
261
261
 
262
- // this.fire('change');
262
+ // this.fire('change');
263
263
  return this;
264
264
  }
265
265
 
@@ -291,7 +291,7 @@ export class Vec3 implements IVec3 {
291
291
  this._y = e[1] * x + e[4] * y + e[7] * z;
292
292
  this._z = e[2] * x + e[5] * y + e[8] * z;
293
293
 
294
- // this.fire('change');
294
+ // this.fire('change');
295
295
  return this;
296
296
  }
297
297
 
@@ -307,7 +307,7 @@ export class Vec3 implements IVec3 {
307
307
  this._y = (e[1] * x + e[5] * y + e[9] * z + e[13]) * w;
308
308
  this._z = (e[2] * x + e[6] * y + e[10] * z + e[14]) * w;
309
309
 
310
- // this.fire('change');
310
+ // this.fire('change');
311
311
  return this;
312
312
  }
313
313
 
@@ -333,7 +333,7 @@ export class Vec3 implements IVec3 {
333
333
  this._y = iy * qw + iw * -qy + iz * -qx - ix * -qz;
334
334
  this._z = iz * qw + iw * -qz + ix * -qy - iy * -qx;
335
335
 
336
- // this.fire('change');
336
+ // this.fire('change');
337
337
  return this;
338
338
  }
339
339
 
@@ -362,7 +362,7 @@ export class Vec3 implements IVec3 {
362
362
  this._y = e[1] * x + e[5] * y + e[9] * z;
363
363
  this._z = e[2] * x + e[6] * y + e[10] * z;
364
364
 
365
- // this.fire('change');
365
+ // this.fire('change');
366
366
  return this.normalize();
367
367
  }
368
368
 
@@ -371,7 +371,7 @@ export class Vec3 implements IVec3 {
371
371
  this._y /= v.y;
372
372
  this._z /= v.z;
373
373
 
374
- // this.fire('change');
374
+ // this.fire('change');
375
375
  return this;
376
376
  }
377
377
 
@@ -384,7 +384,7 @@ export class Vec3 implements IVec3 {
384
384
  this._y = Math.min(this._y, v.y);
385
385
  this._z = Math.min(this._z, v.z);
386
386
 
387
- // this.fire('change');
387
+ // this.fire('change');
388
388
  return this;
389
389
  }
390
390
 
@@ -393,7 +393,7 @@ export class Vec3 implements IVec3 {
393
393
  this._y = Math.max(this._y, v.y);
394
394
  this._z = Math.max(this._z, v.z);
395
395
 
396
- // this.fire('change');
396
+ // this.fire('change');
397
397
  return this;
398
398
  }
399
399
 
@@ -404,7 +404,7 @@ export class Vec3 implements IVec3 {
404
404
  this._y = Math.max(min.y, Math.min(max.y, this._y));
405
405
  this._z = Math.max(min.z, Math.min(max.z, this._z));
406
406
 
407
- // this.fire('change');
407
+ // this.fire('change');
408
408
  return this;
409
409
  }
410
410
 
@@ -413,7 +413,7 @@ export class Vec3 implements IVec3 {
413
413
  this._y = Math.max(minVal, Math.min(maxVal, this._y));
414
414
  this._z = Math.max(minVal, Math.min(maxVal, this._z));
415
415
 
416
- // this.fire('change');
416
+ // this.fire('change');
417
417
  return this;
418
418
  }
419
419
 
@@ -430,7 +430,7 @@ export class Vec3 implements IVec3 {
430
430
  this._y = Math.floor(this._y);
431
431
  this._z = Math.floor(this._z);
432
432
 
433
- // this.fire('change');
433
+ // this.fire('change');
434
434
  return this;
435
435
  }
436
436
 
@@ -439,7 +439,7 @@ export class Vec3 implements IVec3 {
439
439
  this._y = Math.ceil(this._y);
440
440
  this._z = Math.ceil(this._z);
441
441
 
442
- // this.fire('change');
442
+ // this.fire('change');
443
443
  return this;
444
444
  }
445
445
 
@@ -448,7 +448,7 @@ export class Vec3 implements IVec3 {
448
448
  this._y = Math.round(this._y);
449
449
  this._z = Math.round(this._z);
450
450
 
451
- // this.fire('change');
451
+ // this.fire('change');
452
452
  return this;
453
453
  }
454
454
 
@@ -457,7 +457,7 @@ export class Vec3 implements IVec3 {
457
457
  this._y = this._y < 0 ? Math.ceil(this._y) : Math.floor(this._y);
458
458
  this._z = this._z < 0 ? Math.ceil(this._z) : Math.floor(this._z);
459
459
 
460
- // this.fire('change');
460
+ // this.fire('change');
461
461
  return this;
462
462
  }
463
463
 
@@ -466,7 +466,7 @@ export class Vec3 implements IVec3 {
466
466
  this._y = -this._y;
467
467
  this._z = -this._z;
468
468
 
469
- // this.fire('change');
469
+ // this.fire('change');
470
470
  return this;
471
471
  }
472
472
 
@@ -671,14 +671,26 @@ export class Vec3 implements IVec3 {
671
671
  return this.sub(_vec.copy(normal).multiplyScalar(2 * this.dot(normal)));
672
672
  }
673
673
 
674
+ /**
675
+ * 两个向量的夹角
676
+ * @param v
677
+ * @param normal
678
+ * @returns
679
+ */
674
680
  angleTo(v: Vec3, normal?: Vec3 | any) {
675
681
  if (normal)
676
- return this.angleToEx(v, normal)
682
+ return this.angleToEx(v, normal);
677
683
 
678
684
  var theta = this.dot(v) / Math.sqrt(this.lengthSq() * v.lengthSq());
679
685
  return Math.acos(clamp(theta, -1, 1));
680
686
  }
681
687
 
688
+ /**
689
+ * 一个向量到另一个向量的角度
690
+ * @param v
691
+ * @param normal
692
+ * @returns
693
+ */
682
694
  angleToEx(v: Vec3, normal: Vec3) {
683
695
  var theta = this.dot(v) / Math.sqrt(this.lengthSq() * v.lengthSq());
684
696