@xort/cga 0.0.77 → 0.0.78

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 (261) hide show
  1. package/dist/IKanimation/Bone.js +3 -1
  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/extrude.js +56 -54
  7. package/dist/alg/pointset.js +5 -5
  8. package/dist/alg/trianglution.js +12 -10
  9. package/dist/app.js +18 -11
  10. package/dist/diamondMaterialShader.js +6 -2
  11. package/dist/effect/breath-light.js +3 -1
  12. package/dist/extends/geometryaid.js +7 -7
  13. package/dist/index.js +6 -2
  14. package/dist/math/Color.d.ts +5 -5
  15. package/dist/math/Color.js +16 -10
  16. package/dist/math/Euler.js +12 -10
  17. package/dist/math/HVec3.js +3 -1
  18. package/dist/math/Mat3.js +1 -1
  19. package/dist/math/Mat4.js +6 -6
  20. package/dist/math/Quat.js +4 -2
  21. package/dist/math/Vec.js +3 -1
  22. package/dist/math/Vec2.js +3 -1
  23. package/dist/math/Vec3.js +7 -5
  24. package/dist/math/Vec4.js +3 -1
  25. package/dist/math/vector.js +9 -7
  26. package/dist/render/buffer-attribute.js +12 -28
  27. package/dist/render/eventhandler.d.ts +1 -1
  28. package/dist/render/eventhandler.js +9 -7
  29. package/dist/render/geometry.js +2 -2
  30. package/dist/render/mesh.js +11 -9
  31. package/dist/render/thing.js +10 -8
  32. package/dist/render/types.js +2 -1
  33. package/dist/struct/3d/Box.js +3 -3
  34. package/dist/struct/3d/Capsule.js +3 -1
  35. package/dist/struct/3d/Circle.js +2 -2
  36. package/dist/struct/3d/Disk.js +1 -1
  37. package/dist/struct/3d/Line.js +4 -4
  38. package/dist/struct/3d/Path.js +13 -11
  39. package/dist/struct/3d/Plane.js +12 -10
  40. package/dist/struct/3d/Point.js +3 -1
  41. package/dist/struct/3d/Polygon.js +3 -1
  42. package/dist/struct/3d/Polyline.js +3 -1
  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/data/ArrayList.js +11 -9
  49. package/dist/struct/data/ArrayObject.js +3 -1
  50. package/package.json +1 -1
  51. package/src/app.ts +4 -1
  52. package/src/index.ts +1 -0
  53. package/src/math/Color.ts +13 -6
  54. package/dist/src/IKanimation/Bone.d.ts +0 -9
  55. package/dist/src/IKanimation/Bone.js +0 -40
  56. package/dist/src/IKanimation/CCDSolver.d.ts +0 -37
  57. package/dist/src/IKanimation/CCDSolver.js +0 -93
  58. package/dist/src/IKanimation/Joint.d.ts +0 -3
  59. package/dist/src/IKanimation/Joint.js +0 -17
  60. package/dist/src/IKanimation/constaint/constraint.d.ts +0 -10
  61. package/dist/src/IKanimation/constaint/constraint.js +0 -25
  62. package/dist/src/IKanimation/constaint/hinge.d.ts +0 -12
  63. package/dist/src/IKanimation/constaint/hinge.js +0 -46
  64. package/dist/src/IKanimation/constaint/slider.d.ts +0 -12
  65. package/dist/src/IKanimation/constaint/slider.js +0 -44
  66. package/dist/src/IKanimation/index.d.ts +0 -0
  67. package/dist/src/IKanimation/index.js +0 -9
  68. package/dist/src/IKanimation/isolver.d.ts +0 -4
  69. package/dist/src/IKanimation/isolver.js +0 -10
  70. package/dist/src/IKanimation/skeleton.d.ts +0 -13
  71. package/dist/src/IKanimation/skeleton.js +0 -31
  72. package/dist/src/alg/common.d.ts +0 -114
  73. package/dist/src/alg/common.js +0 -302
  74. package/dist/src/alg/curve.d.ts +0 -4
  75. package/dist/src/alg/curve.js +0 -11
  76. package/dist/src/alg/delaunator.d.ts +0 -29
  77. package/dist/src/alg/delaunator.js +0 -442
  78. package/dist/src/alg/delaunay.d.ts +0 -20
  79. package/dist/src/alg/delaunay.js +0 -199
  80. package/dist/src/alg/delaunayslow.d.ts +0 -18
  81. package/dist/src/alg/delaunayslow.js +0 -140
  82. package/dist/src/alg/extrude/extrude.d.ts +0 -3
  83. package/dist/src/alg/extrude/extrude.js +0 -17
  84. package/dist/src/alg/extrude.d.ts +0 -199
  85. package/dist/src/alg/extrude.js +0 -731
  86. package/dist/src/alg/offset/index.d.ts +0 -0
  87. package/dist/src/alg/offset/index.js +0 -9
  88. package/dist/src/alg/offset.d.ts +0 -0
  89. package/dist/src/alg/offset.js +0 -472
  90. package/dist/src/alg/pointset.d.ts +0 -94
  91. package/dist/src/alg/pointset.js +0 -223
  92. package/dist/src/alg/recognition.d.ts +0 -14
  93. package/dist/src/alg/recognition.js +0 -37
  94. package/dist/src/alg/result.d.ts +0 -22
  95. package/dist/src/alg/result.js +0 -2
  96. package/dist/src/alg/segmentset.d.ts +0 -11
  97. package/dist/src/alg/segmentset.js +0 -45
  98. package/dist/src/alg/sort.d.ts +0 -2
  99. package/dist/src/alg/sort.js +0 -14
  100. package/dist/src/alg/split.d.ts +0 -8
  101. package/dist/src/alg/split.js +0 -10
  102. package/dist/src/alg/trianglution.d.ts +0 -20
  103. package/dist/src/alg/trianglution.js +0 -77
  104. package/dist/src/alg/vol.d.ts +0 -6
  105. package/dist/src/alg/vol.js +0 -18
  106. package/dist/src/alg/voronoi.d.ts +0 -31
  107. package/dist/src/alg/voronoi.js +0 -418
  108. package/dist/src/app.d.ts +0 -1
  109. package/dist/src/app.js +0 -245
  110. package/dist/src/basic/distance.d.ts +0 -12
  111. package/dist/src/basic/distance.js +0 -42
  112. package/dist/src/csg/bsp.d.ts +0 -9
  113. package/dist/src/csg/bsp.js +0 -22
  114. package/dist/src/csg/node.d.ts +0 -12
  115. package/dist/src/csg/node.js +0 -75
  116. package/dist/src/csg/polygon.d.ts +0 -43
  117. package/dist/src/csg/polygon.js +0 -161
  118. package/dist/src/diamondMaterialShader.d.ts +0 -92
  119. package/dist/src/diamondMaterialShader.js +0 -118
  120. package/dist/src/effect/breath-light.d.ts +0 -4
  121. package/dist/src/effect/breath-light.js +0 -39
  122. package/dist/src/extends/geometryaid.d.ts +0 -28
  123. package/dist/src/extends/geometryaid.js +0 -80
  124. package/dist/src/extends/split.d.ts +0 -3
  125. package/dist/src/extends/split.js +0 -13
  126. package/dist/src/glview.d.ts +0 -112
  127. package/dist/src/glview.js +0 -564
  128. package/dist/src/index.d.ts +0 -36
  129. package/dist/src/index.js +0 -54
  130. package/dist/src/math/Euler.d.ts +0 -47
  131. package/dist/src/math/Euler.js +0 -245
  132. package/dist/src/math/HVec3.d.ts +0 -44
  133. package/dist/src/math/HVec3.js +0 -195
  134. package/dist/src/math/Mat3.d.ts +0 -29
  135. package/dist/src/math/Mat3.js +0 -244
  136. package/dist/src/math/Mat4.d.ts +0 -85
  137. package/dist/src/math/Mat4.js +0 -791
  138. package/dist/src/math/Math.d.ts +0 -130
  139. package/dist/src/math/Math.js +0 -198
  140. package/dist/src/math/Quat.d.ts +0 -83
  141. package/dist/src/math/Quat.js +0 -440
  142. package/dist/src/math/Vec.d.ts +0 -7
  143. package/dist/src/math/Vec.js +0 -43
  144. package/dist/src/math/Vec2.d.ts +0 -68
  145. package/dist/src/math/Vec2.js +0 -347
  146. package/dist/src/math/Vec3.d.ts +0 -232
  147. package/dist/src/math/Vec3.js +0 -1089
  148. package/dist/src/math/Vec4.d.ts +0 -81
  149. package/dist/src/math/Vec4.js +0 -494
  150. package/dist/src/math/vector.d.ts +0 -114
  151. package/dist/src/math/vector.js +0 -373
  152. package/dist/src/render/buffer-attribute.d.ts +0 -100
  153. package/dist/src/render/buffer-attribute.js +0 -340
  154. package/dist/src/render/eventhandler.d.ts +0 -78
  155. package/dist/src/render/eventhandler.js +0 -189
  156. package/dist/src/render/geometry.d.ts +0 -89
  157. package/dist/src/render/geometry.js +0 -775
  158. package/dist/src/render/mesh.d.ts +0 -25
  159. package/dist/src/render/mesh.js +0 -82
  160. package/dist/src/render/thing.d.ts +0 -34
  161. package/dist/src/render/thing.js +0 -196
  162. package/dist/src/render/types.d.ts +0 -2
  163. package/dist/src/render/types.js +0 -8
  164. package/dist/src/robust/plane.d.ts +0 -7
  165. package/dist/src/robust/plane.js +0 -17
  166. package/dist/src/robust/vec.d.ts +0 -15
  167. package/dist/src/robust/vec.js +0 -71
  168. package/dist/src/shape/arc.d.ts +0 -2
  169. package/dist/src/shape/arc.js +0 -14
  170. package/dist/src/struct/3d/Box.d.ts +0 -23
  171. package/dist/src/struct/3d/Box.js +0 -109
  172. package/dist/src/struct/3d/Capsule.d.ts +0 -12
  173. package/dist/src/struct/3d/Capsule.js +0 -36
  174. package/dist/src/struct/3d/Circle.d.ts +0 -34
  175. package/dist/src/struct/3d/Circle.js +0 -80
  176. package/dist/src/struct/3d/Disk.d.ts +0 -10
  177. package/dist/src/struct/3d/Disk.js +0 -22
  178. package/dist/src/struct/3d/Frustum.d.ts +0 -35
  179. package/dist/src/struct/3d/Frustum.js +0 -159
  180. package/dist/src/struct/3d/Line.d.ts +0 -40
  181. package/dist/src/struct/3d/Line.js +0 -339
  182. package/dist/src/struct/3d/Path.d.ts +0 -75
  183. package/dist/src/struct/3d/Path.js +0 -308
  184. package/dist/src/struct/3d/Plane.d.ts +0 -74
  185. package/dist/src/struct/3d/Plane.js +0 -295
  186. package/dist/src/struct/3d/Point.d.ts +0 -4
  187. package/dist/src/struct/3d/Point.js +0 -30
  188. package/dist/src/struct/3d/Polygon.d.ts +0 -8
  189. package/dist/src/struct/3d/Polygon.js +0 -55
  190. package/dist/src/struct/3d/Polyline.d.ts +0 -25
  191. package/dist/src/struct/3d/Polyline.js +0 -109
  192. package/dist/src/struct/3d/Ray.d.ts +0 -21
  193. package/dist/src/struct/3d/Ray.js +0 -262
  194. package/dist/src/struct/3d/Rectangle.d.ts +0 -7
  195. package/dist/src/struct/3d/Rectangle.js +0 -35
  196. package/dist/src/struct/3d/Segment.d.ts +0 -32
  197. package/dist/src/struct/3d/Segment.js +0 -334
  198. package/dist/src/struct/3d/Shape.d.ts +0 -4
  199. package/dist/src/struct/3d/Shape.js +0 -27
  200. package/dist/src/struct/3d/Sphere.d.ts +0 -11
  201. package/dist/src/struct/3d/Sphere.js +0 -30
  202. package/dist/src/struct/3d/Triangle.d.ts +0 -8
  203. package/dist/src/struct/3d/Triangle.js +0 -53
  204. package/dist/src/struct/data/ArrayList.d.ts +0 -42
  205. package/dist/src/struct/data/ArrayList.js +0 -172
  206. package/dist/src/struct/data/ArrayObject.d.ts +0 -30
  207. package/dist/src/struct/data/ArrayObject.js +0 -131
  208. package/dist/src/struct/data/type.d.ts +0 -13
  209. package/dist/src/struct/data/type.js +0 -18
  210. package/dist/src/utils/array.d.ts +0 -24
  211. package/dist/src/utils/array.js +0 -89
  212. package/dist/src/utils/types.d.ts +0 -24
  213. package/dist/src/utils/types.js +0 -20
  214. package/dist/src-gis/app.d.ts +0 -1
  215. package/dist/src-gis/app.js +0 -4
  216. package/dist/src-gis/core/Cartographic.d.ts +0 -20
  217. package/dist/src-gis/core/Cartographic.js +0 -52
  218. package/dist/src-gis/core/EllipsoidGeodesic.d.ts +0 -14
  219. package/dist/src-gis/core/EllipsoidGeodesic.js +0 -51
  220. package/dist/src-gis/core/EllipsoidTerrainProvider.d.ts +0 -10
  221. package/dist/src-gis/core/EllipsoidTerrainProvider.js +0 -29
  222. package/dist/src-gis/core/HeightmapTerrainData.d.ts +0 -3
  223. package/dist/src-gis/core/HeightmapTerrainData.js +0 -9
  224. package/dist/src-gis/core/Rectangle.d.ts +0 -45
  225. package/dist/src-gis/core/Rectangle.js +0 -127
  226. package/dist/src-gis/core/TaskProcessor.d.ts +0 -35
  227. package/dist/src-gis/core/TaskProcessor.js +0 -183
  228. package/dist/src-gis/gis.d.ts +0 -5
  229. package/dist/src-gis/gis.js +0 -12
  230. package/dist/src-gis/globe.d.ts +0 -12
  231. package/dist/src-gis/globe.js +0 -61
  232. package/dist/src-gis/math/Cartographic.d.ts +0 -8
  233. package/dist/src-gis/math/Cartographic.js +0 -26
  234. package/dist/src-gis/math/GVec3.d.ts +0 -12
  235. package/dist/src-gis/math/GVec3.js +0 -69
  236. package/dist/src-gis/math/ellipsoid.d.ts +0 -8
  237. package/dist/src-gis/math/ellipsoid.js +0 -14
  238. package/dist/src-gis/provider/DcTerrainProvider.d.ts +0 -15
  239. package/dist/src-gis/provider/DcTerrainProvider.js +0 -19
  240. package/dist/src-gis/provider/TerrainProvider.d.ts +0 -3
  241. package/dist/src-gis/provider/TerrainProvider.js +0 -17
  242. package/dist/src-gis/scene/DcImageryProvider.d.ts +0 -6
  243. package/dist/src-gis/scene/DcImageryProvider.js +0 -35
  244. package/dist/src-gis/scene/GeographicTilingScheme.d.ts +0 -21
  245. package/dist/src-gis/scene/GeographicTilingScheme.js +0 -46
  246. package/dist/src-gis/scene/Globe.d.ts +0 -34
  247. package/dist/src-gis/scene/Globe.js +0 -62
  248. package/dist/src-gis/scene/GlobeSurfaceShaderSet.d.ts +0 -6
  249. package/dist/src-gis/scene/GlobeSurfaceShaderSet.js +0 -11
  250. package/dist/src-gis/scene/GlobeSurfaceTileProvider.d.ts +0 -21
  251. package/dist/src-gis/scene/GlobeSurfaceTileProvider.js +0 -15
  252. package/dist/src-gis/scene/ImageryLayerCollection.d.ts +0 -21
  253. package/dist/src-gis/scene/ImageryLayerCollection.js +0 -87
  254. package/dist/src-gis/scene/ImageryProvider.d.ts +0 -4
  255. package/dist/src-gis/scene/ImageryProvider.js +0 -28
  256. package/dist/src-gis/scene/QuadtreeTile.d.ts +0 -48
  257. package/dist/src-gis/scene/QuadtreeTile.js +0 -137
  258. package/dist/src-gis/scene/UrlTemplateImageryProvider.d.ts +0 -9
  259. package/dist/src-gis/scene/UrlTemplateImageryProvider.js +0 -29
  260. package/dist/src-gis/scene/quadtree_primitive.d.ts +0 -14
  261. package/dist/src-gis/scene/quadtree_primitive.js +0 -50
@@ -1,440 +0,0 @@
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.quat = exports.Quat = void 0;
19
- var Math_1 = require("./Math");
20
- var eventhandler_1 = require("../render/eventhandler");
21
- var Quat = /** @class */ (function (_super) {
22
- __extends(Quat, _super);
23
- function Quat(_x, _y, _z, _w) {
24
- if (_x === void 0) { _x = 0; }
25
- if (_y === void 0) { _y = 0; }
26
- if (_z === void 0) { _z = 0; }
27
- if (_w === void 0) { _w = 1; }
28
- var _this = _super.call(this) || this;
29
- _this._x = _x;
30
- _this._y = _y;
31
- _this._z = _z;
32
- _this._w = _w;
33
- _this.isQuat = true;
34
- return _this;
35
- }
36
- Object.defineProperty(Quat.prototype, "x", {
37
- get: function () {
38
- return this._x;
39
- },
40
- set: function (value) {
41
- if (this._x !== value) {
42
- this._x = value;
43
- this.fire('change', 'x', this._x, value);
44
- }
45
- },
46
- enumerable: false,
47
- configurable: true
48
- });
49
- Object.defineProperty(Quat.prototype, "y", {
50
- get: function () {
51
- return this._y;
52
- },
53
- set: function (value) {
54
- if (this._y !== value) {
55
- this._y = value;
56
- this.fire('change', 'y', this._y, value);
57
- }
58
- },
59
- enumerable: false,
60
- configurable: true
61
- });
62
- Object.defineProperty(Quat.prototype, "z", {
63
- get: function () {
64
- return this._z;
65
- },
66
- set: function (value) {
67
- if (this._z !== value) {
68
- this._z = value;
69
- this.fire('change', 'z', this._z, value);
70
- }
71
- },
72
- enumerable: false,
73
- configurable: true
74
- });
75
- Object.defineProperty(Quat.prototype, "w", {
76
- get: function () {
77
- return this._w;
78
- },
79
- set: function (value) {
80
- if (this._w !== value) {
81
- this._w = value;
82
- this.fire('change', 'w', this._w, value);
83
- }
84
- },
85
- enumerable: false,
86
- configurable: true
87
- });
88
- Quat.slerp = function (qa, qb, qm, t) {
89
- return qm.copy(qa).slerp(qb, t);
90
- };
91
- Quat.slerpFlat = function (dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t) {
92
- // fuzz-free, array-based Quat SLERP operation
93
- var x0 = src0[srcOffset0 + 0], y0 = src0[srcOffset0 + 1], z0 = src0[srcOffset0 + 2], w0 = src0[srcOffset0 + 3], x1 = src1[srcOffset1 + 0], y1 = src1[srcOffset1 + 1], z1 = src1[srcOffset1 + 2], w1 = src1[srcOffset1 + 3];
94
- if (w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1) {
95
- var s = 1 - t, cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1, dir = cos >= 0 ? 1 : -1, sqrSin = 1 - cos * cos;
96
- // Skip the Slerp for tiny steps to avoid numeric problems:
97
- if (sqrSin > Number.EPSILON) {
98
- var sin = Math.sqrt(sqrSin), len = Math.atan2(sin, cos * dir);
99
- s = Math.sin(s * len) / sin;
100
- t = Math.sin(t * len) / sin;
101
- }
102
- var tDir = t * dir;
103
- x0 = x0 * s + x1 * tDir;
104
- y0 = y0 * s + y1 * tDir;
105
- z0 = z0 * s + z1 * tDir;
106
- w0 = w0 * s + w1 * tDir;
107
- // Normalize in case we just did a lerp:
108
- if (s === 1 - t) {
109
- var f = 1 / Math.sqrt(x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0);
110
- x0 *= f;
111
- y0 *= f;
112
- z0 *= f;
113
- w0 *= f;
114
- }
115
- }
116
- dst[dstOffset] = x0;
117
- dst[dstOffset + 1] = y0;
118
- dst[dstOffset + 2] = z0;
119
- dst[dstOffset + 3] = w0;
120
- };
121
- Quat.multiplyQuatsFlat = function (dst, dstOffset, src0, srcOffset0, src1, srcOffset1) {
122
- var x0 = src0[srcOffset0];
123
- var y0 = src0[srcOffset0 + 1];
124
- var z0 = src0[srcOffset0 + 2];
125
- var w0 = src0[srcOffset0 + 3];
126
- var x1 = src1[srcOffset1];
127
- var y1 = src1[srcOffset1 + 1];
128
- var z1 = src1[srcOffset1 + 2];
129
- var w1 = src1[srcOffset1 + 3];
130
- dst[dstOffset] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1;
131
- dst[dstOffset + 1] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1;
132
- dst[dstOffset + 2] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1;
133
- dst[dstOffset + 3] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1;
134
- return dst;
135
- };
136
- Quat.prototype.set = function (x, y, z, w) {
137
- this._x = x;
138
- this._y = y;
139
- this._z = z;
140
- this._w = w;
141
- this.fire("change", this);
142
- return this;
143
- };
144
- Quat.prototype.clone = function () {
145
- return new Quat(this._x, this._y, this._z, this._w);
146
- };
147
- Quat.prototype.copy = function (quat) {
148
- this._x = quat.x;
149
- this._y = quat.y;
150
- this._z = quat.z;
151
- this._w = quat.w;
152
- this.fire("change", this);
153
- return this;
154
- };
155
- Quat.prototype.setFromEuler = function (euler, update) {
156
- if (!(euler && euler.isEuler)) {
157
- throw new Error("Quat: .setFromEuler() now expects an Euler rotation rather than a Vec3 and order.");
158
- }
159
- var x = euler._x, y = euler._y, z = euler._z, order = euler.order;
160
- // http://www.mathworks.com/matlabcentral/fileexchange/
161
- // 20696-function-to-convert-between-dcm-Euler-angles-Quats-and-Euler-Vecs/
162
- // content/SpinCalc.m
163
- var cos = Math.cos;
164
- var sin = Math.sin;
165
- var c1 = cos(x / 2);
166
- var c2 = cos(y / 2);
167
- var c3 = cos(z / 2);
168
- var s1 = sin(x / 2);
169
- var s2 = sin(y / 2);
170
- var s3 = sin(z / 2);
171
- if (order === "XYZ") {
172
- this._x = s1 * c2 * c3 + c1 * s2 * s3;
173
- this._y = c1 * s2 * c3 - s1 * c2 * s3;
174
- this._z = c1 * c2 * s3 + s1 * s2 * c3;
175
- this._w = c1 * c2 * c3 - s1 * s2 * s3;
176
- }
177
- else if (order === "YXZ") {
178
- this._x = s1 * c2 * c3 + c1 * s2 * s3;
179
- this._y = c1 * s2 * c3 - s1 * c2 * s3;
180
- this._z = c1 * c2 * s3 - s1 * s2 * c3;
181
- this._w = c1 * c2 * c3 + s1 * s2 * s3;
182
- }
183
- else if (order === "ZXY") {
184
- this._x = s1 * c2 * c3 - c1 * s2 * s3;
185
- this._y = c1 * s2 * c3 + s1 * c2 * s3;
186
- this._z = c1 * c2 * s3 + s1 * s2 * c3;
187
- this._w = c1 * c2 * c3 - s1 * s2 * s3;
188
- }
189
- else if (order === "ZYX") {
190
- this._x = s1 * c2 * c3 - c1 * s2 * s3;
191
- this._y = c1 * s2 * c3 + s1 * c2 * s3;
192
- this._z = c1 * c2 * s3 - s1 * s2 * c3;
193
- this._w = c1 * c2 * c3 + s1 * s2 * s3;
194
- }
195
- else if (order === "YZX") {
196
- this._x = s1 * c2 * c3 + c1 * s2 * s3;
197
- this._y = c1 * s2 * c3 + s1 * c2 * s3;
198
- this._z = c1 * c2 * s3 - s1 * s2 * c3;
199
- this._w = c1 * c2 * c3 - s1 * s2 * s3;
200
- }
201
- else if (order === "XZY") {
202
- this._x = s1 * c2 * c3 - c1 * s2 * s3;
203
- this._y = c1 * s2 * c3 - s1 * c2 * s3;
204
- this._z = c1 * c2 * s3 + s1 * s2 * c3;
205
- this._w = c1 * c2 * c3 + s1 * s2 * s3;
206
- }
207
- if (update !== false)
208
- this.fire("change", this);
209
- return this;
210
- };
211
- Quat.prototype.setFromAxisAngle = function (axis, angle) {
212
- // http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuat/index.htm
213
- // assumes axis is normalized
214
- var halfAngle = angle / 2, s = Math.sin(halfAngle);
215
- this._x = axis.x * s;
216
- this._y = axis.y * s;
217
- this._z = axis.z * s;
218
- this._w = Math.cos(halfAngle);
219
- this.fire("change", this);
220
- return this;
221
- };
222
- Quat.prototype.setFromRotationMat = function (m) {
223
- // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuat/index.htm
224
- // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
225
- var te = m.elements, m11 = te[0], m12 = te[4], m13 = te[8], m21 = te[1], m22 = te[5], m23 = te[9], m31 = te[2], m32 = te[6], m33 = te[10], trace = m11 + m22 + m33, s;
226
- if (trace > 0) {
227
- s = 0.5 / Math.sqrt(trace + 1.0);
228
- this._w = 0.25 / s;
229
- this._x = (m32 - m23) * s;
230
- this._y = (m13 - m31) * s;
231
- this._z = (m21 - m12) * s;
232
- }
233
- else if (m11 > m22 && m11 > m33) {
234
- s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
235
- this._w = (m32 - m23) / s;
236
- this._x = 0.25 * s;
237
- this._y = (m12 + m21) / s;
238
- this._z = (m13 + m31) / s;
239
- }
240
- else if (m22 > m33) {
241
- s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
242
- this._w = (m13 - m31) / s;
243
- this._x = (m12 + m21) / s;
244
- this._y = 0.25 * s;
245
- this._z = (m23 + m32) / s;
246
- }
247
- else {
248
- s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
249
- this._w = (m21 - m12) / s;
250
- this._x = (m13 + m31) / s;
251
- this._y = (m23 + m32) / s;
252
- this._z = 0.25 * s;
253
- }
254
- this.fire("change", this);
255
- return this;
256
- };
257
- Quat.prototype.setFromUnitVecs = function (vFrom, vTo) {
258
- // assumes direction Vecs vFrom and vTo are normalized
259
- var EPS = 0.000001;
260
- var r = vFrom.dot(vTo) + 1;
261
- if (r < EPS) {
262
- r = 0;
263
- if (Math.abs(vFrom.x) > Math.abs(vFrom.z)) {
264
- this._x = -vFrom.y;
265
- this._y = vFrom.x;
266
- this._z = 0;
267
- this._w = r;
268
- }
269
- else {
270
- this._x = 0;
271
- this._y = -vFrom.z;
272
- this._z = vFrom.y;
273
- this._w = r;
274
- }
275
- }
276
- else {
277
- // crossVecs( vFrom, vTo ); // inlined to avoid cyclic dependency on Vec3
278
- this._x = vFrom.y * vTo.z - vFrom.z * vTo.y;
279
- this._y = vFrom.z * vTo.x - vFrom.x * vTo.z;
280
- this._z = vFrom.x * vTo.y - vFrom.y * vTo.x;
281
- this._w = r;
282
- }
283
- return this.normalize();
284
- };
285
- Quat.prototype.angleTo = function (q) {
286
- return 2 * Math.acos(Math.abs((0, Math_1.clamp)(this.dot(q), -1, 1)));
287
- };
288
- Quat.prototype.rotateTowards = function (q, step) {
289
- var angle = this.angleTo(q);
290
- if (angle === 0)
291
- return this;
292
- var t = Math.min(1, step / angle);
293
- this.slerp(q, t);
294
- return this;
295
- };
296
- Quat.prototype.inverse = function () {
297
- // Quat is assumed to have unit length
298
- return this.conjugate();
299
- };
300
- Quat.prototype.invert = function () {
301
- // quaternion is assumed to have unit length
302
- return this.conjugate();
303
- };
304
- Quat.prototype.conjugate = function () {
305
- this._x *= -1;
306
- this._y *= -1;
307
- this._z *= -1;
308
- this.fire("change", this);
309
- return this;
310
- };
311
- Quat.prototype.dot = function (v) {
312
- return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;
313
- };
314
- Quat.prototype.lengthSq = function () {
315
- return (this._x * this._x +
316
- this._y * this._y +
317
- this._z * this._z +
318
- this._w * this._w);
319
- };
320
- Quat.prototype.length = function () {
321
- return Math.sqrt(this._x * this._x +
322
- this._y * this._y +
323
- this._z * this._z +
324
- this._w * this._w);
325
- };
326
- Quat.prototype.normalize = function () {
327
- var l = this.length();
328
- if (l === 0) {
329
- this._x = 0;
330
- this._y = 0;
331
- this._z = 0;
332
- this._w = 1;
333
- }
334
- else {
335
- l = 1 / l;
336
- this._x = this._x * l;
337
- this._y = this._y * l;
338
- this._z = this._z * l;
339
- this._w = this._w * l;
340
- }
341
- this.fire("change", this);
342
- return this;
343
- };
344
- Quat.prototype.multiply = function (q, p) {
345
- if (p !== undefined) {
346
- return this.multiplyQuats(q, p);
347
- }
348
- return this.multiplyQuats(this, q);
349
- };
350
- Quat.prototype.premultiply = function (q) {
351
- return this.multiplyQuats(q, this);
352
- };
353
- Quat.prototype.multiplyQuats = function (a, b) {
354
- // from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/Quats/code/index.htm
355
- var qax = a._x, qay = a._y, qaz = a._z, qaw = a._w;
356
- var qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w;
357
- this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
358
- this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
359
- this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
360
- this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
361
- this.fire("change", this);
362
- return this;
363
- };
364
- Quat.prototype.slerp = function (qb, t) {
365
- if (t === 0)
366
- return this;
367
- if (t === 1)
368
- return this.copy(qb);
369
- var x = this._x, y = this._y, z = this._z, w = this._w;
370
- // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/Quats/slerp/
371
- var cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;
372
- if (cosHalfTheta < 0) {
373
- this._w = -qb._w;
374
- this._x = -qb._x;
375
- this._y = -qb._y;
376
- this._z = -qb._z;
377
- cosHalfTheta = -cosHalfTheta;
378
- }
379
- else {
380
- this.copy(qb);
381
- }
382
- if (cosHalfTheta >= 1.0) {
383
- this._w = w;
384
- this._x = x;
385
- this._y = y;
386
- this._z = z;
387
- return this;
388
- }
389
- var sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta;
390
- if (sqrSinHalfTheta <= Number.EPSILON) {
391
- var s = 1 - t;
392
- this._w = s * w + t * this._w;
393
- this._x = s * x + t * this._x;
394
- this._y = s * y + t * this._y;
395
- this._z = s * z + t * this._z;
396
- this.normalize();
397
- this.fire("change", this);
398
- return this;
399
- }
400
- var sinHalfTheta = Math.sqrt(sqrSinHalfTheta);
401
- var halfTheta = Math.atan2(sinHalfTheta, cosHalfTheta);
402
- var ratioA = Math.sin((1 - t) * halfTheta) / sinHalfTheta, ratioB = Math.sin(t * halfTheta) / sinHalfTheta;
403
- this._w = w * ratioA + this._w * ratioB;
404
- this._x = x * ratioA + this._x * ratioB;
405
- this._y = y * ratioA + this._y * ratioB;
406
- this._z = z * ratioA + this._z * ratioB;
407
- this.fire("change", this);
408
- return this;
409
- };
410
- Quat.prototype.equals = function (quat) {
411
- return (quat._x === this._x &&
412
- quat._y === this._y &&
413
- quat._z === this._z &&
414
- quat._w === this._w);
415
- };
416
- Quat.prototype.fromArray = function (array, offset) {
417
- if (offset === void 0) { offset = 0; }
418
- this._x = array[offset];
419
- this._y = array[offset + 1];
420
- this._z = array[offset + 2];
421
- this._w = array[offset + 3];
422
- this.fire("change", this);
423
- return this;
424
- };
425
- Quat.prototype.toArray = function (array, offset) {
426
- if (array === void 0) { array = []; }
427
- if (offset === void 0) { offset = 0; }
428
- array[offset] = this._x;
429
- array[offset + 1] = this._y;
430
- array[offset + 2] = this._z;
431
- array[offset + 3] = this._w;
432
- return array;
433
- };
434
- return Quat;
435
- }(eventhandler_1.EventHandler));
436
- exports.Quat = Quat;
437
- function quat(x, y, z, w) {
438
- return new Quat(x, y, z, w);
439
- }
440
- exports.quat = quat;
@@ -1,7 +0,0 @@
1
- /**
2
- * 暂不使用
3
- */
4
- export declare class Vec extends Array {
5
- constructor(n: number);
6
- static max(array: ArrayLike<number>): number;
7
- }
@@ -1,43 +0,0 @@
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.Vec = void 0;
19
- /**
20
- * 暂不使用
21
- */
22
- var Vec = /** @class */ (function (_super) {
23
- __extends(Vec, _super);
24
- function Vec(n) {
25
- var _this = _super.call(this) || this;
26
- while (n-- > 0) {
27
- _this[_this.length] = 0;
28
- }
29
- return _this;
30
- }
31
- Vec.max = function (array) {
32
- if (array.length === 0)
33
- return -Infinity;
34
- var max = array[0];
35
- for (var i = 1, l = array.length; i < l; ++i) {
36
- if (array[i] > max)
37
- max = array[i];
38
- }
39
- return max;
40
- };
41
- return Vec;
42
- }(Array));
43
- exports.Vec = Vec;
@@ -1,68 +0,0 @@
1
- import { Mat3 } from './Mat3';
2
- import { EventHandler } from '../render/eventhandler';
3
- export declare class Vec2 extends EventHandler {
4
- private _x;
5
- private _y;
6
- isVec2: boolean;
7
- constructor(_x?: number, _y?: number);
8
- get x(): number;
9
- set x(value: number);
10
- get y(): number;
11
- set y(value: number);
12
- static isVec2(v: any): boolean;
13
- get width(): number;
14
- set width(value: number);
15
- get height(): number;
16
- set height(value: number);
17
- static get UnitX(): Vec2;
18
- static get UnitY(): Vec2;
19
- set(x: number, y: number): this;
20
- setScalar(scalar: number): this;
21
- setX(x: number): this;
22
- setY(y: number): this;
23
- setComponent(index: number, value: number): this;
24
- getComponent(index: number): number;
25
- clone(): Vec2;
26
- copy(v: Vec2): Vec2;
27
- add(v: Vec2, w?: Vec2): this;
28
- addScalar(s: number): this;
29
- addVecs(a: Vec2, b: Vec2): this;
30
- addScaledVec(v: Vec2, s: number): this;
31
- sub(v: Vec2, w: Vec2): this;
32
- subScalar(s: number): this;
33
- subVecs(a: Vec2, b: Vec2): this;
34
- multiply(v: Vec2): this;
35
- multiplyScalar(scalar: number): this;
36
- divide(v: Vec2): this;
37
- divideScalar(scalar: number): this;
38
- applyMat3(m: Mat3): this;
39
- min(v: Vec2): this;
40
- max(v: Vec2): this;
41
- clamp(min: Vec2, max: Vec2): this;
42
- clampScalar(minVal: number, maxVal: number): this;
43
- clampLength(min: number, max: number): this;
44
- floor(): this;
45
- ceil(): this;
46
- round(): this;
47
- roundToZero(): this;
48
- negate(): this;
49
- dot(v: Vec2): number;
50
- cross(v: Vec2): number;
51
- lengthSq(): number;
52
- length(): number;
53
- manhattanLength(): number;
54
- normalize(): this;
55
- angle(): number;
56
- distanceTo(v: Vec2): number;
57
- distanceToSquared(v: Vec2): number;
58
- manhattanDistanceTo(v: Vec2): number;
59
- setLength(length: number): this;
60
- lerp(v: Vec2, alpha: number): this;
61
- lerpVecs(v1: Vec2, v2: Vec2, alpha: number): this;
62
- equals(v: Vec2): boolean;
63
- fromArray(array: number[], offset?: number): this;
64
- toArray(array?: number[], offset?: number): number[];
65
- fromBufferAttribute(attribute: any, index: number, offset: any): this;
66
- rotateAround(center: Vec2, angle: number): this;
67
- }
68
- export declare function v2(): Vec2;