@openglobus/og 0.11.1 → 0.11.6

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 (255) hide show
  1. package/package.json +18 -20
  2. package/src/og/Clock.js +11 -11
  3. package/src/og/Deferred.js +1 -1
  4. package/src/og/Events.js +9 -7
  5. package/src/og/Extent.js +117 -72
  6. package/src/og/Globe.js +35 -22
  7. package/src/og/ImageCanvas.js +24 -18
  8. package/src/og/Lock.js +2 -2
  9. package/src/og/LonLat.js +40 -37
  10. package/src/og/Popup.js +21 -15
  11. package/src/og/QueueArray.js +7 -3
  12. package/src/og/Rectangle.js +11 -6
  13. package/src/og/Stack.js +8 -5
  14. package/src/og/ajax.js +21 -33
  15. package/src/og/astro/astro.js +5 -5
  16. package/src/og/astro/earth.js +23 -17
  17. package/src/og/astro/jd.js +44 -39
  18. package/src/og/astro/orbit.js +20 -18
  19. package/src/og/astro/rotation.js +17 -8
  20. package/src/og/bv/Box.js +7 -3
  21. package/src/og/bv/Sphere.js +17 -9
  22. package/src/og/camera/Camera.js +137 -86
  23. package/src/og/camera/Frustum.js +30 -19
  24. package/src/og/camera/PlanetCamera.js +30 -26
  25. package/src/og/control/CompassButton.js +8 -2
  26. package/src/og/control/Control.js +13 -11
  27. package/src/og/control/DebugInfo.js +4 -1
  28. package/src/og/control/EarthCoordinates.js +62 -41
  29. package/src/og/control/EarthNavigation.js +20 -22
  30. package/src/og/control/GeoImageDragControl.js +1 -1
  31. package/src/og/control/KeyboardNavigation.js +12 -12
  32. package/src/og/control/LayerSwitcher.js +24 -23
  33. package/src/og/control/Lighting.js +1 -1
  34. package/src/og/control/MouseNavigation.js +1 -1
  35. package/src/og/control/ScaleControl.js +1 -1
  36. package/src/og/control/SegmentBoundVisualization.js +8 -9
  37. package/src/og/control/ShowFps.js +15 -10
  38. package/src/og/control/SimpleNavigation.js +8 -10
  39. package/src/og/control/Sun.js +25 -15
  40. package/src/og/control/ToggleWireframe.js +5 -5
  41. package/src/og/control/TouchNavigation.js +58 -45
  42. package/src/og/control/ZoomControl.js +41 -25
  43. package/src/og/control/index.js +4 -0
  44. package/src/og/ellipsoid/Ellipsoid.js +181 -85
  45. package/src/og/ellipsoid/wgs84.js +4 -4
  46. package/src/og/entity/BaseBillboard.js +97 -44
  47. package/src/og/entity/Billboard.js +15 -11
  48. package/src/og/entity/BillboardHandler.js +314 -64
  49. package/src/og/entity/Entity.js +106 -74
  50. package/src/og/entity/EntityCollection.js +72 -49
  51. package/src/og/entity/GeoObject.js +228 -0
  52. package/src/og/entity/GeoObjectHandler.js +910 -0
  53. package/src/og/entity/Geometry.js +29 -26
  54. package/src/og/entity/GeometryHandler.js +598 -126
  55. package/src/og/entity/Label.js +74 -40
  56. package/src/og/entity/LabelHandler.js +47 -246
  57. package/src/og/entity/LabelWorker.js +213 -0
  58. package/src/og/entity/Object3d.js +504 -0
  59. package/src/og/entity/PointCloud.js +81 -33
  60. package/src/og/entity/PointCloudHandler.js +9 -9
  61. package/src/og/entity/Polyline.js +39 -39
  62. package/src/og/entity/Ray.js +61 -28
  63. package/src/og/entity/ShapeHandler.js +1 -1
  64. package/src/og/entity/Strip.js +77 -48
  65. package/src/og/entity/StripHandler.js +27 -27
  66. package/src/og/entity/index.js +8 -16
  67. package/src/og/input/KeyboardHandler.js +107 -104
  68. package/src/og/input/MouseHandler.js +81 -78
  69. package/src/og/input/TouchHandler.js +55 -51
  70. package/src/og/layer/BaseGeoImage.js +61 -30
  71. package/src/og/layer/CanvasTiles.js +26 -24
  72. package/src/og/layer/GeoImage.js +10 -10
  73. package/src/og/layer/GeoTexture2d.js +1 -1
  74. package/src/og/layer/GeoVideo.js +3 -3
  75. package/src/og/layer/KML.js +66 -40
  76. package/src/og/layer/Layer.js +27 -17
  77. package/src/og/layer/Material.js +93 -61
  78. package/src/og/layer/Vector.js +118 -72
  79. package/src/og/layer/WMS.js +36 -19
  80. package/src/og/layer/XYZ.js +55 -48
  81. package/src/og/light/LightSource.js +47 -40
  82. package/src/og/math/Line2.js +24 -24
  83. package/src/og/math/Line3.js +103 -102
  84. package/src/og/math/Mat3.js +134 -121
  85. package/src/og/math/Mat4.js +603 -459
  86. package/src/og/math/Plane.js +21 -20
  87. package/src/og/math/Quat.js +980 -927
  88. package/src/og/math/Ray.js +195 -187
  89. package/src/og/math/Vec2.js +127 -117
  90. package/src/og/math/Vec3.js +206 -176
  91. package/src/og/math/Vec4.js +49 -53
  92. package/src/og/math/coder.js +18 -18
  93. package/src/og/math.js +12 -12
  94. package/src/og/mercator.js +11 -11
  95. package/src/og/proj/EPSG3857.js +4 -4
  96. package/src/og/proj/EPSG4326.js +4 -4
  97. package/src/og/proj/Proj.js +31 -31
  98. package/src/og/quadTree/EntityCollectionNode.js +310 -300
  99. package/src/og/quadTree/Node.js +1008 -993
  100. package/src/og/renderer/Renderer.js +768 -747
  101. package/src/og/renderer/RendererEvents.js +9 -6
  102. package/src/og/scene/Axes.js +1 -1
  103. package/src/og/scene/BaseNode.js +8 -9
  104. package/src/og/scene/Planet.js +115 -87
  105. package/src/og/scene/RenderNode.js +29 -22
  106. package/src/og/scene/SkyBox.js +1 -1
  107. package/src/og/segment/Segment.js +1886 -1878
  108. package/src/og/segment/SegmentLonLat.js +298 -268
  109. package/src/og/segment/segmentHelper.js +11 -11
  110. package/src/og/shaders/bloom.js +1 -1
  111. package/src/og/shaders/blur.js +2 -2
  112. package/src/og/shaders/depth.js +1 -1
  113. package/src/og/shaders/geoObject.js +211 -0
  114. package/src/og/shaders/label.js +1 -1
  115. package/src/og/shaders/lumFilter.js +1 -1
  116. package/src/og/shaders/pointCloud.js +42 -42
  117. package/src/og/shaders/screenFrame.js +1 -1
  118. package/src/og/shaders/shape.js +15 -21
  119. package/src/og/shaders/skybox.js +37 -37
  120. package/src/og/shaders/toneMapping.js +1 -1
  121. package/src/og/shapes/BaseShape.js +129 -57
  122. package/src/og/shapes/Icosphere.js +30 -15
  123. package/src/og/shapes/Sphere.js +13 -16
  124. package/src/og/terrain/BilTerrain.js +2 -1
  125. package/src/og/terrain/EmptyTerrain.js +2 -2
  126. package/src/og/terrain/Geoid.js +2 -2
  127. package/src/og/terrain/GlobusTerrain.js +10 -10
  128. package/src/og/terrain/MapboxTerrain.js +1 -1
  129. package/src/og/utils/GeoImageCreator.js +9 -9
  130. package/src/og/utils/Loader.js +6 -6
  131. package/src/og/utils/NormalMapCreator.js +13 -13
  132. package/src/og/utils/TerrainWorker.js +1 -1
  133. package/src/og/utils/TextureAtlas.js +20 -22
  134. package/src/og/utils/VectorTileCreator.js +5 -5
  135. package/src/og/utils/earcut.js +1 -1
  136. package/src/og/utils/shared.js +15 -15
  137. package/src/og/webgl/Framebuffer.js +101 -53
  138. package/src/og/webgl/Handler.js +125 -85
  139. package/src/og/webgl/Multisample.js +55 -27
  140. package/src/og/webgl/Program.js +80 -35
  141. package/src/og/webgl/ProgramController.js +27 -23
  142. package/src/og/webgl/callbacks.js +8 -8
  143. package/types/Clock.d.ts +6 -2
  144. package/types/Deferred.d.ts +1 -1
  145. package/types/Events.d.ts +8 -4
  146. package/types/Extent.d.ts +37 -33
  147. package/types/Globe.d.ts +15 -13
  148. package/types/ImageCanvas.d.ts +5 -3
  149. package/types/LonLat.d.ts +24 -24
  150. package/types/Popup.d.ts +4 -0
  151. package/types/QueueArray.d.ts +6 -2
  152. package/types/Rectangle.d.ts +10 -4
  153. package/types/Stack.d.ts +4 -0
  154. package/types/ajax.d.ts +1 -1
  155. package/types/astro/earth.d.ts +3 -2
  156. package/types/bv/Box.d.ts +10 -5
  157. package/types/bv/Sphere.d.ts +13 -7
  158. package/types/camera/Camera.d.ts +90 -81
  159. package/types/camera/Frustum.d.ts +26 -22
  160. package/types/camera/PlanetCamera.d.ts +49 -53
  161. package/types/control/CompassButton.d.ts +4 -4
  162. package/types/control/Control.d.ts +7 -4
  163. package/types/control/DebugInfo.d.ts +3 -4
  164. package/types/control/EarthCoordinates.d.ts +6 -6
  165. package/types/control/EarthNavigation.d.ts +42 -0
  166. package/types/control/KeyboardNavigation.d.ts +3 -4
  167. package/types/control/LayerSwitcher.d.ts +3 -5
  168. package/types/control/Lighting.d.ts +3 -3
  169. package/types/control/MouseNavigation.d.ts +47 -0
  170. package/types/control/ScaleControl.d.ts +3 -3
  171. package/types/control/ShowFps.d.ts +3 -4
  172. package/types/control/SimpleNavigation.d.ts +3 -6
  173. package/types/control/Sun.d.ts +8 -10
  174. package/types/control/ToggleWireframe.d.ts +3 -3
  175. package/types/control/TouchNavigation.d.ts +48 -0
  176. package/types/control/ZoomControl.d.ts +3 -4
  177. package/types/control/index.d.ts +3 -1
  178. package/types/ellipsoid/Ellipsoid.d.ts +47 -43
  179. package/types/ellipsoid/wgs84.d.ts +3 -2
  180. package/types/entity/BaseBillboard.d.ts +41 -34
  181. package/types/entity/Billboard.d.ts +7 -7
  182. package/types/entity/BillboardHandler.d.ts +4 -0
  183. package/types/entity/Entity.d.ts +101 -83
  184. package/types/entity/EntityCollection.d.ts +57 -43
  185. package/types/entity/GeoObject.d.ts +111 -0
  186. package/types/entity/GeoObjectHandler.d.ts +77 -0
  187. package/types/entity/Geometry.d.ts +9 -7
  188. package/types/entity/GeometryHandler.d.ts +2 -2
  189. package/types/entity/Label.d.ts +24 -29
  190. package/types/entity/LabelHandler.d.ts +9 -2
  191. package/types/entity/LabelWorker.d.ts +9 -0
  192. package/types/entity/PointCloud.d.ts +8 -8
  193. package/types/entity/PointCloudHandler.d.ts +3 -3
  194. package/types/entity/Polyline.d.ts +58 -55
  195. package/types/entity/Ray.d.ts +19 -18
  196. package/types/entity/Strip.d.ts +8 -7
  197. package/types/entity/StripHandler.d.ts +3 -3
  198. package/types/entity/index.d.ts +7 -7
  199. package/types/input/KeyboardHandler.d.ts +10 -0
  200. package/types/input/MouseHandler.d.ts +5 -0
  201. package/types/input/TouchHandler.d.ts +5 -0
  202. package/types/layer/BaseGeoImage.d.ts +23 -35
  203. package/types/layer/CanvasTiles.d.ts +15 -22
  204. package/types/layer/GeoImage.d.ts +5 -18
  205. package/types/layer/GeoVideo.d.ts +5 -30
  206. package/types/layer/KML.d.ts +20 -15
  207. package/types/layer/Layer.d.ts +326 -0
  208. package/types/layer/Material.d.ts +45 -0
  209. package/types/layer/Vector.d.ts +208 -0
  210. package/types/layer/WMS.d.ts +4 -7
  211. package/types/layer/XYZ.d.ts +19 -25
  212. package/types/light/LightSource.d.ts +54 -53
  213. package/types/math/Line2.d.ts +11 -0
  214. package/types/math/Line3.d.ts +10 -0
  215. package/types/math/Mat3.d.ts +30 -18
  216. package/types/math/Mat4.d.ts +71 -52
  217. package/types/math/Plane.d.ts +5 -4
  218. package/types/math/Quat.d.ts +379 -0
  219. package/types/math/Ray.d.ts +82 -0
  220. package/types/math/Vec2.d.ts +102 -101
  221. package/types/math/Vec3.d.ts +143 -142
  222. package/types/math/Vec4.d.ts +40 -39
  223. package/types/math/coder.d.ts +12 -11
  224. package/types/math.d.ts +8 -8
  225. package/types/mercator.d.ts +3 -3
  226. package/types/proj/EPSG3857.d.ts +3 -2
  227. package/types/proj/EPSG4326.d.ts +3 -2
  228. package/types/proj/Proj.d.ts +42 -0
  229. package/types/quadTree/EntityCollectionNode.d.ts +34 -0
  230. package/types/quadTree/Node.d.ts +61 -0
  231. package/types/renderer/Renderer.d.ts +300 -0
  232. package/types/renderer/RendererEvents.d.ts +10 -7
  233. package/types/scene/BaseNode.d.ts +9 -9
  234. package/types/scene/Planet.d.ts +131 -126
  235. package/types/scene/RenderNode.d.ts +22 -23
  236. package/types/segment/Segment.d.ts +279 -0
  237. package/types/segment/SegmentLonLat.d.ts +16 -0
  238. package/types/shaders/geoObject.d.ts +3 -0
  239. package/types/shapes/BaseShape.d.ts +43 -40
  240. package/types/shapes/Sphere.d.ts +7 -7
  241. package/types/terrain/BilTerrain.d.ts +0 -1
  242. package/types/terrain/EmptyTerrain.d.ts +4 -4
  243. package/types/terrain/GlobusTerrain.d.ts +17 -54
  244. package/types/terrain/MapboxTerrain.d.ts +0 -1
  245. package/types/utils/GeoImageCreator.d.ts +3 -2
  246. package/types/utils/TextureAtlas.d.ts +8 -8
  247. package/types/utils/shared.d.ts +25 -24
  248. package/types/webgl/Framebuffer.d.ts +5 -5
  249. package/types/webgl/Handler.d.ts +68 -43
  250. package/types/webgl/Multisample.d.ts +5 -5
  251. package/types/webgl/Program.d.ts +8 -2
  252. package/types/webgl/ProgramController.d.ts +18 -13
  253. package/src/og/inherits.js +0 -8
  254. package/src/og/utils/polylabel.js +0 -176
  255. package/types/inherits.d.ts +0 -4
@@ -2,9 +2,9 @@
2
2
  * @module og/math/Vec2
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
- import { Vec3 } from './Vec3.js';
7
+ import { Vec3 } from "./Vec3.js";
8
8
 
9
9
  /**
10
10
  * Class represents a 3d vector.
@@ -13,9 +13,7 @@ import { Vec3 } from './Vec3.js';
13
13
  * @param {number} [y] - Second value.
14
14
  */
15
15
  export class Vec2 {
16
-
17
16
  constructor(x, y) {
18
-
19
17
  /**
20
18
  * @public
21
19
  * @type {number}
@@ -27,156 +25,166 @@ export class Vec2 {
27
25
  * @type {number}
28
26
  */
29
27
  this.y = y || 0.0;
30
- };
28
+ }
31
29
  /** @const */
32
- static get UP() { return new Vec2(0, 1) };
30
+ static get UP() {
31
+ return new Vec2(0, 1);
32
+ }
33
33
  /** @const */
34
- static get DOWN() { return new Vec2(0, -1) };
34
+ static get DOWN() {
35
+ return new Vec2(0, -1);
36
+ }
35
37
  /** @const */
36
- static get RIGHT() { return new Vec2(1, 0) };
38
+ static get RIGHT() {
39
+ return new Vec2(1, 0);
40
+ }
37
41
  /** @const */
38
- static get LEFT() { return new Vec2(-1, 0) };
42
+ static get LEFT() {
43
+ return new Vec2(-1, 0);
44
+ }
39
45
  /** @const */
40
- static get ZERO() { return new Vec2() };
46
+ static get ZERO() {
47
+ return new Vec2();
48
+ }
41
49
 
42
50
  /**
43
51
  * Returns summary vector.
44
52
  * @static
45
- * @param {og.math.Vec2} a - First vector.
46
- * @param {og.math.Vec2} b - Second vector.
47
- * @returns {og.math.Vec2} - Summary vector.
53
+ * @param {math.Vec2} a - First vector.
54
+ * @param {math.Vec2} b - Second vector.
55
+ * @returns {math.Vec2} - Summary vector.
48
56
  */
49
57
  static add(a, b) {
50
58
  var res = new Vec2(a.x, a.y);
51
59
  res.addA(b);
52
60
  return res;
53
- };
61
+ }
54
62
 
55
63
  /**
56
64
  * Returns two vectors subtraction.
57
65
  * @static
58
- * @param {og.math.Vec2} a - First vector.
59
- * @param {og.math.Vec2} b - Second vector.
60
- * @returns {og.math.Vec2} - Vectors subtraction.
66
+ * @param {math.Vec2} a - First vector.
67
+ * @param {math.Vec2} b - Second vector.
68
+ * @returns {math.Vec2} - Vectors subtraction.
61
69
  */
62
70
  static sub(a, b) {
63
71
  var res = new Vec2(a.x, a.y);
64
72
  res.subA(b);
65
73
  return res;
66
- };
74
+ }
67
75
 
68
76
  /**
69
77
  * Returns scaled vector.
70
78
  * @static
71
- * @param {og.math.Vec2} a - Input vector.
79
+ * @param {math.Vec2} a - Input vector.
72
80
  * @param {number} scale - Scale value.
73
- * @returns {og.math.Vec2}
81
+ * @returns {math.Vec2}
74
82
  */
75
83
  static scale(a, scale) {
76
84
  var res = new Vec2(a.x, a.y);
77
85
  res.scale(scale);
78
86
  return res;
79
- };
87
+ }
80
88
 
81
89
  /**
82
90
  * Returns two vectors production.
83
91
  * @static
84
- * @param {og.math.Vec2} a - First vector.
85
- * @param {og.math.Vec2} b - Second vector.
86
- * @returns {og.math.Vec2}
92
+ * @param {math.Vec2} a - First vector.
93
+ * @param {math.Vec2} b - Second vector.
94
+ * @returns {math.Vec2}
87
95
  */
88
96
  static mul(a, b) {
89
97
  var res = new Vec2(a.x, a.y);
90
98
  res.mulA(b);
91
99
  return res;
92
- };
100
+ }
93
101
 
94
102
  /**
95
103
  * Returns vector components division product one to another.
96
104
  * @static
97
- * @param {og.math.Vec2} a - First vector.
98
- * @param {og.math.Vec2} b - Second vector.
99
- * @returns {og.math.Vec2}
105
+ * @param {math.Vec2} a - First vector.
106
+ * @param {math.Vec2} b - Second vector.
107
+ * @returns {math.Vec2}
100
108
  */
101
109
  static div(a, b) {
102
110
  var res = new Vec2(a.x, a.y);
103
111
  res.divA(b);
104
112
  return res;
105
- };
113
+ }
106
114
 
107
115
  /**
108
116
  * Get projection of the first vector to the second.
109
117
  * @static
110
- * @param {og.math.Vec2} b - First vector.
111
- * @param {og.math.Vec2} a - Second vector.
112
- * @returns {og.math.Vec2}
118
+ * @param {math.Vec2} b - First vector.
119
+ * @param {math.Vec2} a - Second vector.
120
+ * @returns {math.Vec2}
113
121
  */
114
122
  static proj_b_to_a(b, a) {
115
123
  return a.scaleTo(a.dot(b) / a.dot(a));
116
- };
124
+ }
117
125
 
118
126
  /**
119
127
  * Gets angle between two vectors.
120
128
  * @static
121
- * @param {og.math.Vec2} a - First vector.
122
- * @param {og.math.Vec2} b - Second vector.
129
+ * @param {math.Vec2} a - First vector.
130
+ * @param {math.Vec2} b - Second vector.
123
131
  * @returns {number}
124
132
  */
125
133
  static angle(a, b) {
126
134
  return Math.acos(a.dot(b) / Math.sqrt(a.length2() * b.length2()));
127
- };
135
+ }
128
136
 
129
137
  /**
130
138
  * Makes vectors normalized and orthogonal to each other.
131
139
  * @static
132
- * @param {og.math.Vec2} normal - Normal vector.
133
- * @param {og.math.Vec2} tangent - Tangent vector.
134
- * @returns {og.math.Vec2}
140
+ * @param {math.Vec2} normal - Normal vector.
141
+ * @param {math.Vec2} tangent - Tangent vector.
142
+ * @returns {math.Vec2}
135
143
  */
136
144
  static orthoNormalize(normal, tangent) {
137
145
  normal = normal.norm();
138
146
  normal.scale(tangent.dot(normal));
139
147
  return tangent.sub(normal).normalize();
140
- };
148
+ }
141
149
 
142
150
  /**
143
151
  * Converts to 3d vector, third value is 0.0.
144
152
  * @public
145
- * @returns {og.Vec3}
153
+ * @returns {Vec3}
146
154
  */
147
155
  toVector3() {
148
156
  return new Vec3(this.x, this.y, 0);
149
- };
157
+ }
150
158
 
151
159
  /**
152
160
  * Returns clone vector.
153
161
  * @public
154
- * @returns {og.math.Vec2}
162
+ * @returns {math.Vec2}
155
163
  */
156
164
  clone() {
157
165
  return new Vec2(this.x, this.y);
158
- };
166
+ }
159
167
 
160
168
  /**
161
169
  * Compares with vector. Returns true if it equals another.
162
170
  * @public
163
- * @param {og.math.Vec2} p - Vector to compare.
171
+ * @param {math.Vec2} p - Vector to compare.
164
172
  * @returns {boolean}
165
173
  */
166
174
  equal(p) {
167
175
  return this.x === p.x && this.y === p.y;
168
- };
176
+ }
169
177
 
170
178
  /**
171
179
  * Copy input vector's values.
172
- * @param {og.math.Vec2} point2 - Vector to copy.
173
- * @returns {og.math.Vec2}
180
+ * @param {math.Vec2} point2 - Vector to copy.
181
+ * @returns {math.Vec2}
174
182
  */
175
183
  copy(point2) {
176
184
  this.x = point2.x;
177
185
  this.y = point2.y;
178
186
  return this;
179
- };
187
+ }
180
188
 
181
189
  /**
182
190
  * Gets vector's length.
@@ -185,7 +193,7 @@ export class Vec2 {
185
193
  */
186
194
  length() {
187
195
  return Math.sqrt(this.x * this.x + this.y * this.y);
188
- };
196
+ }
189
197
 
190
198
  /**
191
199
  * Returns squared vector's length.
@@ -194,152 +202,152 @@ export class Vec2 {
194
202
  */
195
203
  length2() {
196
204
  return this.x * this.x + this.y * this.y;
197
- };
205
+ }
198
206
 
199
207
  /**
200
208
  * Adds vector to the current.
201
209
  * @public
202
- * @param {og.math.Vec2}
203
- * @returns {og.math.Vec2}
210
+ * @param {math.Vec2}
211
+ * @returns {math.Vec2}
204
212
  */
205
213
  addA(v) {
206
214
  this.x += v.x;
207
215
  this.y += v.y;
208
216
  return this;
209
- };
217
+ }
210
218
 
211
219
  /**
212
220
  * Summarize two vectors.
213
221
  * @public
214
- * @param {og.math.Vec2}
215
- * @returns {og.math.Vec2}
222
+ * @param {math.Vec2}
223
+ * @returns {math.Vec2}
216
224
  */
217
225
  add(v) {
218
226
  return new Vec2(this.x + v.x, this.y + v.y);
219
- };
227
+ }
220
228
 
221
229
  /**
222
230
  * Subtract vector from the current where results saved on the current instance.
223
231
  * @public
224
- * @param {og.math.Vec2} v - Subtract vector.
225
- * @returns {og.math.Vec2}
232
+ * @param {math.Vec2} v - Subtract vector.
233
+ * @returns {math.Vec2}
226
234
  */
227
235
  subA(v) {
228
236
  this.x -= v.x;
229
237
  this.y -= v.y;
230
238
  return this;
231
- };
239
+ }
232
240
 
233
241
  /**
234
242
  * Subtract vector from the current.
235
243
  * @public
236
- * @param {og.math.Vec2} v - Subtract vector.
237
- * @returns {og.math.Vec2}
244
+ * @param {math.Vec2} v - Subtract vector.
245
+ * @returns {math.Vec2}
238
246
  */
239
247
  sub(v) {
240
248
  return new Vec2(this.x - v.x, this.y - v.y);
241
- };
249
+ }
242
250
 
243
251
  /**
244
252
  * Scale current vector.
245
253
  * @public
246
254
  * @param {number} scale - Scale value.
247
- * @returns {og.math.Vec2}
255
+ * @returns {math.Vec2}
248
256
  */
249
257
  scale(scale) {
250
258
  this.x *= scale;
251
259
  this.y *= scale;
252
260
  return this;
253
- };
261
+ }
254
262
 
255
263
  /**
256
264
  * Scale current vector to another instance.
257
265
  * @public
258
266
  * @param {number} scale - Scale value.
259
- * @returns {og.math.Vec2}
267
+ * @returns {math.Vec2}
260
268
  */
261
269
  scaleTo(scale) {
262
270
  return new Vec2(this.x * scale, this.y * scale);
263
- };
271
+ }
264
272
 
265
273
  /**
266
274
  * Multiply current vector object to another and store result in the current instance.
267
275
  * @public
268
- * @param {og.math.Vec2} vec - Multiply vector.
269
- * @returns {og.math.Vec2}
276
+ * @param {math.Vec2} vec - Multiply vector.
277
+ * @returns {math.Vec2}
270
278
  */
271
279
  mulA(vec) {
272
280
  this.x *= vec.x;
273
281
  this.y *= vec.y;
274
282
  return this;
275
- };
283
+ }
276
284
 
277
285
  /**
278
286
  * Multiply current vector object to another and returns new vector instance.
279
287
  * @public
280
- * @param {og.math.Vec2} vec - Multiply vector.
281
- * @returns {og.math.Vec2}
288
+ * @param {math.Vec2} vec - Multiply vector.
289
+ * @returns {math.Vec2}
282
290
  */
283
291
  mul(vec) {
284
292
  return new Vec2(this.x * vec.x, this.y * vec.y);
285
- };
293
+ }
286
294
 
287
295
  /**
288
296
  * Divide current vector's components to another. Results stores in the current vector object.
289
297
  * @public
290
- * @param {og.math.Vec2}
291
- * @returns {og.math.Vec2}
298
+ * @param {math.Vec2}
299
+ * @returns {math.Vec2}
292
300
  */
293
301
  divA(vec) {
294
302
  this.x /= vec.x;
295
303
  this.y /= vec.y;
296
304
  return this;
297
- };
305
+ }
298
306
 
299
307
  /**
300
308
  * Gets vectors dot production.
301
309
  * @public
302
- * @param {og.math.Vec2} v - Another vector.
310
+ * @param {math.Vec2} v - Another vector.
303
311
  * @returns {number}
304
312
  */
305
313
  dot(v) {
306
314
  return v.x * this.x + v.y * this.y;
307
- };
315
+ }
308
316
 
309
317
  /**
310
318
  * Gets vectors dot production.
311
319
  * @public
312
- * @param {Array.<number,number>} arr - Array vector.
320
+ * @param {Array.<number>} arr - Array vector. (exactly 2 entries)
313
321
  * @returns {number}
314
322
  */
315
323
  dotArr(arr) {
316
324
  return arr[0] * this.x + arr[1] * this.y;
317
- };
325
+ }
318
326
 
319
327
  /**
320
328
  * Gets vectors cross production.
321
329
  * @public
322
- * @param {og.math.Vec2} v - Another vector.
323
- * @returns {og.math.Vec2}
330
+ * @param {math.Vec2} v - Another vector.
331
+ * @returns {math.Vec2}
324
332
  */
325
333
  cross(v) {
326
334
  return this.x * v.y - this.y * v.x;
327
- };
335
+ }
328
336
 
329
337
  /**
330
338
  * Sets vector to zero.
331
339
  * @public
332
- * @returns {og.math.Vec2}
340
+ * @returns {math.Vec2}
333
341
  */
334
342
  clear() {
335
343
  this.x = this.y = 0;
336
344
  return this;
337
- };
345
+ }
338
346
 
339
347
  /**
340
348
  * Returns normalized vector.
341
349
  * @public
342
- * @returns {og.math.Vec2}
350
+ * @returns {math.Vec2}
343
351
  */
344
352
  normal() {
345
353
  var res = new Vec2();
@@ -351,12 +359,12 @@ export class Vec2 {
351
359
  res.y *= length;
352
360
 
353
361
  return res;
354
- };
362
+ }
355
363
 
356
364
  /**
357
365
  * Normalize current vector.
358
366
  * @public
359
- * @returns {og.math.Vec2}
367
+ * @returns {math.Vec2}
360
368
  */
361
369
  normalize() {
362
370
  var length = 1.0 / this.length();
@@ -365,90 +373,90 @@ export class Vec2 {
365
373
  this.y *= length;
366
374
 
367
375
  return this;
368
- };
376
+ }
369
377
 
370
378
  /**
371
379
  * Converts vector to a number array.
372
380
  * @public
373
- * @returns {Array.<number,number>}
381
+ * @returns {Array.<number>} - (exactly 2 entries)
374
382
  */
375
383
  toVec() {
376
384
  return [this.x, this.y];
377
- };
385
+ }
378
386
 
379
387
  /**
380
388
  * Gets distance to point.
381
389
  * @public
382
- * @param {og.math.Vec2} p - Distant point.
390
+ * @param {math.Vec2} p - Distant point.
383
391
  * @returns {number}
384
392
  */
385
393
  distance(p) {
386
394
  var vec = Vec2.sub(this, p);
387
395
  return vec.length();
388
- };
396
+ }
389
397
 
390
398
  /**
391
399
  * Sets vector's values.
392
400
  * @public
393
401
  * @param {number} x - Value X.
394
402
  * @param {number} y - Value Y.
395
- * @returns {og.math.Vec2}
403
+ * @returns {math.Vec2}
396
404
  */
397
405
  set(x, y) {
398
406
  this.x = x;
399
407
  this.y = y;
400
408
  return this;
401
- };
409
+ }
402
410
 
403
411
  /**
404
412
  * Negate current vector.
405
413
  * @public
406
- * @returns {og.math.Vec2}
414
+ * @returns {math.Vec2}
407
415
  */
408
416
  negate() {
409
417
  this.x = -this.x;
410
418
  this.y = -this.y;
411
419
  return this;
412
- };
420
+ }
413
421
 
414
422
  /**
415
423
  * Negate current vector to another instance.
416
424
  * @public
417
- * @returns {og.math.Vec2}
425
+ * @returns {math.Vec2}
418
426
  */
419
427
  negateTo() {
420
428
  return new Vec2(-this.x, -this.y);
421
- };
429
+ }
422
430
 
423
431
  /**
424
432
  * Gets projected point coordinates of the current vector on the ray.
425
433
  * @public
426
- * @param {og.math.Vec2} pos - Ray position.
427
- * @param {og.math.Vec2} direction - Ray direction.
428
- * @returns {og.math.Vec2}
434
+ * @param {math.Vec2} pos - Ray position.
435
+ * @param {math.Vec2} direction - Ray direction.
436
+ * @returns {math.Vec2}
429
437
  */
430
438
  projToRay(pos, direction) {
431
439
  var v = Vec2.proj_b_to_a(Vec2.sub(this, pos), direction);
432
440
  v.add(pos);
433
441
  return v;
434
- };
442
+ }
435
443
 
436
444
  /**
437
445
  * Gets angle between two vectors.
438
446
  * @public
439
- * @param {og.math.Vec2} a - Another vector.
447
+ * @param {math.Vec2} a - Another vector.
440
448
  * @returns {number}
441
449
  */
442
450
  angle(a) {
443
451
  return Vec2.angle(this, a);
444
- };
452
+ }
445
453
 
446
454
  /**
447
455
  * Returns two vectors linear interpolation.
448
456
  * @public
449
- * @param {og.math.Vec2} v2 - End vector.
457
+ * @param {math.Vec2} v2 - End vector.
450
458
  * @param {number} l - Interpolate value.
451
- * @returns {og.math.Vec2}
459
+ * @returns {math.Vec2}
452
460
  */
453
461
  lerp(v1, v2, l) {
454
462
  var res = Vec2.clone(this);
@@ -460,19 +468,21 @@ export class Vec2 {
460
468
  res = Vec2.add(v1, Vec2.sub(v2, v1).scale(l));
461
469
  }
462
470
  return res;
463
- };
471
+ }
464
472
 
465
- static get LERP_DELTA() { return 1e-6 };
473
+ static get LERP_DELTA() {
474
+ return 1e-6;
475
+ }
466
476
 
467
477
  /**
468
478
  * Spherically interpolates between two vectors.
469
- * Interpolates between current and v2 vector by amount t. The difference between this and linear interpolation (aka, "lerp") is that
470
- * the vectors are treated as directions rather than points in space. The direction of the returned vector is interpolated
479
+ * Interpolates between current and v2 vector by amount t. The difference between this and linear interpolation (aka, "lerp") is that
480
+ * the vectors are treated as directions rather than points in space. The direction of the returned vector is interpolated
471
481
  * by the angle and its magnitude is interpolated between the magnitudes of from and to.
472
482
  * @public
473
- * @param {og.math.Vec2} v2 -
483
+ * @param {math.Vec2} v2 -
474
484
  * @param {number} t - The parameter t is clamped to the range [0, 1].
475
- * @returns {og.math.Vec2}
485
+ * @returns {math.Vec2}
476
486
  */
477
487
  slerp(v2, t) {
478
488
  var res = new Vec2();
@@ -488,7 +498,7 @@ export class Vec2 {
488
498
  var omega, sinom, scale0, scale1;
489
499
  var cosom = this.dot(v2);
490
500
 
491
- if ((1.0 - cosom) > Vec2.LERP_DELTA) {
501
+ if (1.0 - cosom > Vec2.LERP_DELTA) {
492
502
  omega = Math.acos(cosom);
493
503
  sinom = Math.sin(omega);
494
504
  scale0 = Math.sin((1.0 - t) * omega) / sinom;
@@ -499,7 +509,7 @@ export class Vec2 {
499
509
  }
500
510
 
501
511
  return Vec2.add(this.scale(scale0), v2.scale(scale1));
502
- };
512
+ }
503
513
  }
504
514
 
505
515
  /**
@@ -507,8 +517,8 @@ export class Vec2 {
507
517
  * @function
508
518
  * @param {number} [x] - First cvalue.
509
519
  * @param {number} [y] - Second value.
510
- * @returns {og.math.Vec2}
520
+ * @returns {math.Vec2}
511
521
  */
512
522
  export function vec2(x, y) {
513
523
  return new Vec2(x, y);
514
- };
524
+ }