@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
package/src/og/bv/Box.js CHANGED
@@ -11,11 +11,15 @@ import { Vec3 } from "../math/Vec3.js";
11
11
  * @class
12
12
  */
13
13
  class Box {
14
+ /**
15
+ *
16
+ * @param {*} boundsArr
17
+ */
14
18
  constructor(boundsArr) {
15
19
  /**
16
20
  * Vertices array.
17
21
  * @public
18
- * @type{Array.<og.Vec3>}
22
+ * @type{Array.<Vec3>}
19
23
  */
20
24
  this.vertices = [
21
25
  new Vec3(),
@@ -65,8 +69,8 @@ class Box {
65
69
 
66
70
  /**
67
71
  * Sets bounding box coordiantes by ellipsoid geodetic extend.
68
- * @param {og.Ellipsoid} ellipsoid - Ellipsoid.
69
- * @param {og.Extent} extent - Geodetic extent.
72
+ * @param {Ellipsoid} ellipsoid - Ellipsoid.
73
+ * @param {Extent} extent - Geodetic extent.
70
74
  */
71
75
  setFromExtent(ellipsoid, extent) {
72
76
  this.setFromBoundsArr(extent.getCartesianBounds(ellipsoid));
@@ -2,19 +2,23 @@
2
2
  * @module og/bv/Sphere
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
- import { Vec3 } from '../math/Vec3.js';
7
+ import { Vec3 } from "../math/Vec3.js";
8
8
 
9
9
  /**
10
10
  * Bounding sphere class.
11
11
  * @class
12
12
  * @param {Number} [radius] - Bounding sphere radius.
13
- * @param {og.Vec3} [center] - Bounding sphere coordiantes.
13
+ * @param {Vec3} [center] - Bounding sphere coordiantes.
14
14
  */
15
15
  class Sphere {
16
+ /**
17
+ *
18
+ * @param {number} radius
19
+ * @param {Vec3} center
20
+ */
16
21
  constructor(radius, center) {
17
-
18
22
  /**
19
23
  * Sphere radius.
20
24
  * @public
@@ -25,7 +29,7 @@ class Sphere {
25
29
  /**
26
30
  * Sphere coordiantes.
27
31
  * @public
28
- * @type {og.Vec3}
32
+ * @type {Vec3}
29
33
  */
30
34
  this.center = center ? center.clone() : new Vec3();
31
35
  }
@@ -36,18 +40,22 @@ class Sphere {
36
40
  */
37
41
  setFromBounds(bounds) {
38
42
  let m = new Vec3(bounds[0], bounds[1], bounds[2]);
39
- this.center.set(m.x + (bounds[3] - m.x) * 0.5, m.y + (bounds[3] - m.y) * 0.5, m.z + (bounds[5] - m.z) * 0.5);
43
+ this.center.set(
44
+ m.x + (bounds[3] - m.x) * 0.5,
45
+ m.y + (bounds[3] - m.y) * 0.5,
46
+ m.z + (bounds[5] - m.z) * 0.5
47
+ );
40
48
  this.radius = this.center.distance(m);
41
49
  }
42
50
 
43
51
  /**
44
52
  * Sets bounding sphere coordiantes by ellipsoid geodetic extend.
45
- * @param {og.Ellipsoid} ellipsoid - Ellipsoid.
46
- * @param {og.Extent} extent - Geodetic extent.
53
+ * @param {Ellipsoid} ellipsoid - Ellipsoid.
54
+ * @param {Extent} extent - Geodetic extent.
47
55
  */
48
56
  setFromExtent(ellipsoid, extent) {
49
57
  this.setFromBounds(extent.getCartesianBounds(ellipsoid));
50
58
  }
51
- };
59
+ }
52
60
 
53
61
  export { Sphere };
@@ -1,64 +1,67 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- import * as math from '../math.js';
4
- import { Events } from '../Events.js';
5
- import { Frustum } from './Frustum.js';
6
- import { Vec2 } from '../math/Vec2.js';
7
- import { Vec3 } from '../math/Vec3.js';
8
- import { Vec4 } from '../math/Vec4.js';
9
- import { Mat3 } from '../math/Mat3.js';
10
- import { Mat4 } from '../math/Mat4.js';
3
+ import * as math from "../math.js";
4
+ import { Events } from "../Events.js";
5
+ import { Frustum } from "./Frustum.js";
6
+ import { Vec2 } from "../math/Vec2.js";
7
+ import { Vec3 } from "../math/Vec3.js";
8
+ import { Vec4 } from "../math/Vec4.js";
9
+ import { Mat3 } from "../math/Mat3.js";
10
+ import { Mat4 } from "../math/Mat4.js";
11
11
 
12
12
  /**
13
13
  * Camera class.
14
14
  * @class
15
- * @param {og.Renderer} [renderer] - Renderer uses the camera instance.
15
+ * @param {Renderer} [renderer] - Renderer uses the camera instance.
16
16
  * @param {Object} [options] - Camera options:
17
17
  * @param {Object} [options.name] - Camera name.
18
18
  * @param {number} [options.viewAngle=38] - Camera angle of view. Default is 30.0
19
19
  * @param {number} [options.near=1] - Camera near plane distance. Default is 1.0
20
20
  * @param {number} [options.far=og.math.MAX] - Camera far plane distance. Deafult is og.math.MAX
21
- * @param {og.Vec3} [options.eye=[0,0,0]] - Camera eye position. Default (0,0,0)
22
- * @param {og.Vec3} [options.look=[0,0,0]] - Camera look position. Default (0,0,0)
23
- * @param {og.Vec3} [options.up=[0,1,0]] - Camera eye position. Default (0,1,0)
21
+ * @param {Vec3} [options.eye=[0,0,0]] - Camera eye position. Default (0,0,0)
22
+ * @param {Vec3} [options.look=[0,0,0]] - Camera look position. Default (0,0,0)
23
+ * @param {Vec3} [options.up=[0,1,0]] - Camera eye position. Default (0,1,0)
24
24
  *
25
25
  * @fires og.Camera#viewchange
26
26
  */
27
27
  class Camera {
28
+ /**
29
+ * @param {Renderer} [renderer] - Renderer uses the camera instance.
30
+ * @param {Object} [options] - Camera options:
31
+ */
28
32
  constructor(renderer, options) {
29
-
30
33
  /**
31
34
  * Assigned renderer
32
35
  * @public
33
- * @type {og.Renderer}
36
+ * @type {Renderer}
34
37
  */
35
38
  this.renderer = renderer;
36
39
 
37
40
  /**
38
41
  * Camera events handler
39
42
  * @public
40
- * @type {og.Events}
43
+ * @type {Events}
41
44
  */
42
45
  this.events = new Events(EVENT_NAMES, this);
43
46
 
44
47
  /**
45
48
  * Camera position.
46
49
  * @public
47
- * @type {og.Vec3}
50
+ * @type {Vec3}
48
51
  */
49
52
  this.eye = new Vec3();
50
53
 
51
54
  /**
52
55
  * Camera RTE high position
53
56
  * @public
54
- * @type {og.Vec3}
57
+ * @type {Vec3}
55
58
  */
56
59
  this.eyeHigh = new Float32Array(3);
57
60
 
58
61
  /**
59
62
  * Camera RTE low position
60
63
  * @public
61
- * @type {og.Vec3}
64
+ * @type {Vec3}
62
65
  */
63
66
  this.eyeLow = new Float32Array(3);
64
67
 
@@ -79,35 +82,35 @@ class Camera {
79
82
  /**
80
83
  * Camera normal matrix.
81
84
  * @protected
82
- * @type {og.Mat3}
85
+ * @type {Mat3}
83
86
  */
84
87
  this._normalMatrix = new Mat3();
85
88
 
86
89
  /**
87
90
  * Camera view matrix.
88
91
  * @protected
89
- * @type {og.Mat4}
92
+ * @type {Mat4}
90
93
  */
91
94
  this._viewMatrix = new Mat4();
92
95
 
93
96
  /**
94
97
  * Camera right vector.
95
98
  * @protected
96
- * @type {og.Vec3}
99
+ * @type {Vec3}
97
100
  */
98
101
  this._u = new Vec3(0.0, 1.0, 0.0); // up x n
99
102
 
100
103
  /**
101
104
  * Camera up vector.
102
105
  * @protected
103
- * @type {og.Vec3}
106
+ * @type {Vec3}
104
107
  */
105
108
  this._v = new Vec3(1.0, 0.0, 0.0); // n x u - UP
106
109
 
107
110
  /**
108
111
  * Camera forward vector.
109
112
  * @protected
110
- * @type {og.Vec3}
113
+ * @type {Vec3}
111
114
  */
112
115
  this._n = new Vec3(0.0, 0.0, 1.0); // eye - look - FORWARD
113
116
 
@@ -116,7 +119,7 @@ class Camera {
116
119
  this._pv = this._v.clone();
117
120
  this._pn = this._n.clone();
118
121
  this._peye = this.eye.clone();
119
- this._moved = false;
122
+ this.isMoved = false;
120
123
 
121
124
  this._tanViewAngle_hrad = 0.0;
122
125
  this._tanViewAngle_hradOneByHeight = 0.0;
@@ -136,7 +139,7 @@ class Camera {
136
139
  aspect: this._aspect,
137
140
  near: fi[0],
138
141
  far: fi[1]
139
- })
142
+ });
140
143
 
141
144
  fr._cameraFrustumIndex = this.frustums.length;
142
145
  this.frustums.push(fr);
@@ -145,7 +148,6 @@ class Camera {
145
148
  this.frustumColors.push.apply(this.frustumColors, fr._pickingColorU);
146
149
  }
147
150
  } else {
148
-
149
151
  let near = 1.0,
150
152
  far = 10000.0;
151
153
 
@@ -176,18 +178,13 @@ class Camera {
176
178
  n = this._n,
177
179
  eye = this.eye;
178
180
 
179
- if (this.events.moveend.handlers.length) {
180
- if (this._peye.equal(eye) &&
181
- this._pu.equal(u) &&
182
- this._pv.equal(v) &&
183
- this._pn.equal(n)) {
184
- if (this._moved) {
185
- this.events.dispatch(this.events.moveend, this);
186
- }
187
- this._moved = false;
188
- } else {
189
- this._moved = true;
181
+ if (this._peye.equal(eye) && this._pu.equal(u) && this._pv.equal(v) && this._pn.equal(n)) {
182
+ if (this.isMoved) {
183
+ this.events.dispatch(this.events.moveend, this);
190
184
  }
185
+ this.isMoved = false;
186
+ } else {
187
+ this.isMoved = true;
191
188
  }
192
189
 
193
190
  this._pu.copy(u);
@@ -199,23 +196,23 @@ class Camera {
199
196
  /**
200
197
  * Camera initialization.
201
198
  * @public
202
- * @param {og.Renderer} renderer - OpenGlobus renderer object.
199
+ * @param {Renderer} renderer - OpenGlobus renderer object.
203
200
  * @param {Object} [options] - Camera options:
204
201
  * @param {number} [options.viewAngle] - Camera angle of view. Default is 30.0
205
202
  * @param {number} [options.near] - Camera near plane distance. Default is 1.0
206
203
  * @param {number} [options.far] - Camera far plane distance. Deafult is og.math.MAX
207
- * @param {og.Vec3} [options.eye] - Camera eye position. Default (0,0,0)
208
- * @param {og.Vec3} [options.look] - Camera look position. Default (0,0,0)
209
- * @param {og.Vec3} [options.up] - Camera eye position. Default (0,1,0)
204
+ * @param {Vec3} [options.eye] - Camera eye position. Default (0,0,0)
205
+ * @param {Vec3} [options.look] - Camera look position. Default (0,0,0)
206
+ * @param {Vec3} [options.up] - Camera eye position. Default (0,1,0)
210
207
  */
211
208
  _init(options) {
212
-
213
209
  this._setProj(this._viewAngle, this._aspect);
214
210
 
215
211
  this.set(
216
212
  options.eye || new Vec3(0.0, 0.0, 1.0),
217
213
  options.look || new Vec3(),
218
- options.up || new Vec3(0.0, 1.0, 0.0));
214
+ options.up || new Vec3(0.0, 1.0, 0.0)
215
+ );
219
216
  }
220
217
 
221
218
  getUp() {
@@ -248,18 +245,33 @@ class Camera {
248
245
  * @virtual
249
246
  */
250
247
  update() {
251
- var u = this._u, v = this._v, n = this._n, eye = this.eye;
248
+ var u = this._u,
249
+ v = this._v,
250
+ n = this._n,
251
+ eye = this.eye;
252
252
 
253
253
  Vec3.doubleToTwoFloat32Array(eye, this.eyeHigh, this.eyeLow);
254
254
 
255
255
  this._viewMatrix.set([
256
- u.x, v.x, n.x, 0.0,
257
- u.y, v.y, n.y, 0.0,
258
- u.z, v.z, n.z, 0.0,
259
- -eye.dot(u), -eye.dot(v), -eye.dot(n), 1.0
256
+ u.x,
257
+ v.x,
258
+ n.x,
259
+ 0.0,
260
+ u.y,
261
+ v.y,
262
+ n.y,
263
+ 0.0,
264
+ u.z,
265
+ v.z,
266
+ n.z,
267
+ 0.0,
268
+ -eye.dot(u),
269
+ -eye.dot(v),
270
+ -eye.dot(n),
271
+ 1.0
260
272
  ]);
261
273
 
262
- this._normalMatrix = this._viewMatrix.toMatrix3();// this._viewMatrix.toInverseMatrix3().transposeTo();
274
+ this._normalMatrix = this._viewMatrix.toMatrix3(); // this._viewMatrix.toInverseMatrix3().transposeTo();
263
275
 
264
276
  for (let i = 0, len = this.frustums.length; i < len; i++) {
265
277
  this.frustums[i].setViewMatrix(this._viewMatrix);
@@ -306,11 +318,22 @@ class Camera {
306
318
  this._viewAngle = angle;
307
319
  this._aspect = aspect;
308
320
  this._tanViewAngle_hrad = Math.tan(angle * math.RADIANS_HALF);
309
- this._tanViewAngle_hradOneByHeight = this._tanViewAngle_hrad * this.renderer.handler._oneByHeight;
321
+ this._tanViewAngle_hradOneByHeight =
322
+ this._tanViewAngle_hrad * this.renderer.handler._oneByHeight;
310
323
  var c = this.renderer.handler.canvas;
311
- this._projSizeConst = Math.min(c.clientWidth, c.clientHeight) / (angle * math.RADIANS);
324
+ this._projSizeConst =
325
+ Math.min(
326
+ c.clientWidth < 256 ? 256 : c.clientWidth,
327
+ c.clientHeight < 256 ? 256 : c.clientHeight
328
+ ) /
329
+ (angle * math.RADIANS);
312
330
  for (let i = 0, len = this.frustums.length; i < len; i++) {
313
- this.frustums[i].setProjectionMatrix(angle, aspect, this.frustums[i].near, this.frustums[i].far);
331
+ this.frustums[i].setProjectionMatrix(
332
+ angle,
333
+ aspect,
334
+ this.frustums[i].near,
335
+ this.frustums[i].far
336
+ );
314
337
  }
315
338
  }
316
339
 
@@ -327,7 +350,7 @@ class Camera {
327
350
  /**
328
351
  * Gets camera view angle in degrees
329
352
  * @public
330
- * @returns {number} angle -
353
+ * @returns {number} angle -
331
354
  */
332
355
  getViewAngle() {
333
356
  return this._viewAngle;
@@ -336,10 +359,10 @@ class Camera {
336
359
  /**
337
360
  * Sets camera to eye position
338
361
  * @public
339
- * @param {og.Vec3} eye - Camera position
340
- * @param {og.Vec3} look - Look point
341
- * @param {og.Vec3} up - Camera up vector
342
- * @returns {og.Camera} - This camera
362
+ * @param {Vec3} eye - Camera position
363
+ * @param {Vec3} look - Look point
364
+ * @param {Vec3} up - Camera up vector
365
+ * @returns {Camera} - This camera
343
366
  */
344
367
  set(eye, look, up) {
345
368
  this.eye.x = eye.x;
@@ -360,8 +383,8 @@ class Camera {
360
383
  /**
361
384
  * Sets camera look point
362
385
  * @public
363
- * @param {og.Vec3} look - Look point
364
- * @param {og.Vec3} [up] - Camera up vector otherwise camera current up vector(this._v)
386
+ * @param {Vec3} look - Look point
387
+ * @param {Vec3} [up] - Camera up vector otherwise camera current up vector(this._v)
365
388
  */
366
389
  look(look, up) {
367
390
  this._n.set(this.eye.x - look.x, this.eye.y - look.y, this.eye.z - look.z);
@@ -393,8 +416,16 @@ class Camera {
393
416
  var cs = Math.cos(math.RADIANS * angle);
394
417
  var sn = Math.sin(math.RADIANS * angle);
395
418
  var t = this._u.clone();
396
- this._u.set(cs * t.x - sn * this._v.x, cs * t.y - sn * this._v.y, cs * t.z - sn * this._v.z);
397
- this._v.set(sn * t.x + cs * this._v.x, sn * t.y + cs * this._v.y, sn * t.z + cs * this._v.z);
419
+ this._u.set(
420
+ cs * t.x - sn * this._v.x,
421
+ cs * t.y - sn * this._v.y,
422
+ cs * t.z - sn * this._v.z
423
+ );
424
+ this._v.set(
425
+ sn * t.x + cs * this._v.x,
426
+ sn * t.y + cs * this._v.y,
427
+ sn * t.z + cs * this._v.z
428
+ );
398
429
  }
399
430
 
400
431
  /**
@@ -406,8 +437,16 @@ class Camera {
406
437
  var cs = Math.cos(math.RADIANS * angle);
407
438
  var sn = Math.sin(math.RADIANS * angle);
408
439
  var t = this._n.clone();
409
- this._n.set(cs * t.x - sn * this._v.x, cs * t.y - sn * this._v.y, cs * t.z - sn * this._v.z);
410
- this._v.set(sn * t.x + cs * this._v.x, sn * t.y + cs * this._v.y, sn * t.z + cs * this._v.z);
440
+ this._n.set(
441
+ cs * t.x - sn * this._v.x,
442
+ cs * t.y - sn * this._v.y,
443
+ cs * t.z - sn * this._v.z
444
+ );
445
+ this._v.set(
446
+ sn * t.x + cs * this._v.x,
447
+ sn * t.y + cs * this._v.y,
448
+ sn * t.z + cs * this._v.z
449
+ );
411
450
  }
412
451
 
413
452
  /**
@@ -419,8 +458,16 @@ class Camera {
419
458
  var cs = Math.cos(math.RADIANS * angle);
420
459
  var sn = Math.sin(math.RADIANS * angle);
421
460
  var t = this._u.clone();
422
- this._u.set(cs * t.x - sn * this._n.x, cs * t.y - sn * this._n.y, cs * t.z - sn * this._n.z);
423
- this._n.set(sn * t.x + cs * this._n.x, sn * t.y + cs * this._n.y, sn * t.z + cs * this._n.z);
461
+ this._u.set(
462
+ cs * t.x - sn * this._n.x,
463
+ cs * t.y - sn * this._n.y,
464
+ cs * t.z - sn * this._n.z
465
+ );
466
+ this._n.set(
467
+ sn * t.x + cs * this._n.x,
468
+ sn * t.y + cs * this._n.y,
469
+ sn * t.z + cs * this._n.z
470
+ );
424
471
  }
425
472
 
426
473
  /**
@@ -428,7 +475,7 @@ class Camera {
428
475
  * @public
429
476
  * @param {number} x - Scren X coordinate
430
477
  * @param {number} y - Scren Y coordinate
431
- * @returns {og.Vec3} - Direction vector
478
+ * @returns {Vec3} - Direction vector
432
479
  */
433
480
  unproject(x, y) {
434
481
  var c = this.renderer.handler.canvas,
@@ -438,8 +485,12 @@ class Camera {
438
485
  var px = (x - w) / w,
439
486
  py = -(y - h) / h;
440
487
 
441
- var world1 = this.frustums[0]._inverseProjectionViewMatrix.mulVec4(new Vec4(px, py, -1.0, 1.0)).affinity(),
442
- world2 = this.frustums[0]._inverseProjectionViewMatrix.mulVec4(new Vec4(px, py, 0.0, 1.0)).affinity();
488
+ var world1 = this.frustums[0]._inverseProjectionViewMatrix
489
+ .mulVec4(new Vec4(px, py, -1.0, 1.0))
490
+ .affinity(),
491
+ world2 = this.frustums[0]._inverseProjectionViewMatrix
492
+ .mulVec4(new Vec4(px, py, 0.0, 1.0))
493
+ .affinity();
443
494
 
444
495
  return world2.subA(world1).toVec3().normalize();
445
496
  }
@@ -447,8 +498,8 @@ class Camera {
447
498
  /**
448
499
  * Gets projected 3d point to the 2d screen coordiantes
449
500
  * @public
450
- * @param {og.Vec3} v - Cartesian 3d coordiantes
451
- * @returns {og.Vec2} - Screen point coordinates
501
+ * @param {Vec3} v - Cartesian 3d coordiantes
502
+ * @returns {Vec2} - Screen point coordinates
452
503
  */
453
504
  project(v) {
454
505
  var r = this.frustums[0]._projectionViewMatrix.mulVec4(v.toVec4()),
@@ -462,8 +513,8 @@ class Camera {
462
513
  * @param {number} angle - Rotation angle in radians
463
514
  * @param {boolean} isArc - If true camera up vector gets from current up vector every frame,
464
515
  * otherwise up is always input parameter.
465
- * @param {og.Vec3} center - Point that the camera rotates around
466
- * @param {og.math.Vecto3} [up] - Camera up vector
516
+ * @param {Vec3} center - Point that the camera rotates around
517
+ * @param {Vecto3} [up] - Camera up vector
467
518
  */
468
519
  rotateAround(angle, isArc, center, up) {
469
520
  center = center || Vec3.ZERO;
@@ -487,8 +538,8 @@ class Camera {
487
538
  * @param {number} angle - Rotation angle in radians.
488
539
  * @param {boolaen} isArc - If true camera up vector gets from current up vector every frame,
489
540
  * otherwise up is always input parameter.
490
- * @param {og.Vec3} center - Point that the camera rotates around.
491
- * @param {og.Vec3} [up] - Camera up vector.
541
+ * @param {Vec3} center - Point that the camera rotates around.
542
+ * @param {Vec3} [up] - Camera up vector.
492
543
  */
493
544
  rotateHorizontal(angle, isArc, center, up) {
494
545
  this.rotateAround(angle, isArc, center, up);
@@ -497,7 +548,7 @@ class Camera {
497
548
  /**
498
549
  * Rotates camera around center point by vecrtical.
499
550
  * @param {number} angle - Rotation angle in radians.
500
- * @param {og.Vec3} center - Point that the camera rotates around.
551
+ * @param {Vec3} center - Point that the camera rotates around.
501
552
  */
502
553
  rotateVertical(angle, center) {
503
554
  this.rotateAround(angle, false, center, this._u);
@@ -506,8 +557,8 @@ class Camera {
506
557
  /**
507
558
  * Gets 3d size factor. Uses in LOD distance calculation.
508
559
  * @public
509
- * @param {og.Vec3} p - Far point.
510
- * @param {og.Vec3} r - Far point.
560
+ * @param {Vec3} p - Far point.
561
+ * @param {Vec3} r - Far point.
511
562
  * @returns {number} - Size factor.
512
563
  */
513
564
  projectedSize(p, r) {
@@ -517,7 +568,7 @@ class Camera {
517
568
  /**
518
569
  * Returns normal matrix.
519
570
  * @public
520
- * @returns {og.Mat3} - Normal matrix.
571
+ * @returns {Mat3} - Normal matrix.
521
572
  */
522
573
  getNormalMatrix() {
523
574
  return this._normalMatrix._m;
@@ -526,7 +577,7 @@ class Camera {
526
577
  /**
527
578
  * Returns model matrix.
528
579
  * @public
529
- * @returns {og.Mat4} - View matrix.
580
+ * @returns {Mat4} - View matrix.
530
581
  */
531
582
  getViewMatrix() {
532
583
  return this._viewMatrix._m;
@@ -547,7 +598,7 @@ class Camera {
547
598
  /**
548
599
  * Returns projection matrix.
549
600
  * @public
550
- * @returns {og.Mat4} - Projection matrix.
601
+ * @returns {Mat4} - Projection matrix.
551
602
  */
552
603
  getProjectionMatrix() {
553
604
  return this.frustum._projectionMatrix._m;
@@ -556,7 +607,7 @@ class Camera {
556
607
  /**
557
608
  * Returns projection and model matrix product.
558
609
  * @public
559
- * @return {og.Mat4} - Projection-view matrix.
610
+ * @return {Mat4} - Projection-view matrix.
560
611
  */
561
612
  getProjectionViewMatrix() {
562
613
  return this.frustum._projectionViewMatrix._m;
@@ -565,7 +616,7 @@ class Camera {
565
616
  /**
566
617
  * Returns inverse projection and model matrix product.
567
618
  * @public
568
- * @returns {og.Mat4} - Inversed projection-view matrix.
619
+ * @returns {Mat4} - Inversed projection-view matrix.
569
620
  */
570
621
  getInverseProjectionViewMatrix() {
571
622
  return this.frustum._inverseProjectionViewMatrix._m;
@@ -574,12 +625,12 @@ class Camera {
574
625
  /**
575
626
  * Returns inverse projection matrix.
576
627
  * @public
577
- * @returns {og.Mat4} - Inversed projection-view matrix.
628
+ * @returns {Mat4} - Inversed projection-view matrix.
578
629
  */
579
630
  getInverseProjectionMatrix() {
580
631
  return this.frustum._inverseProjectionMatrix._m;
581
632
  }
582
- };
633
+ }
583
634
 
584
635
  const EVENT_NAMES = [
585
636
  /**
@@ -595,4 +646,4 @@ const EVENT_NAMES = [
595
646
  "moveend"
596
647
  ];
597
648
 
598
- export { Camera };
649
+ export { Camera };