@openglobus/og 0.22.2 → 0.24.0

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 (205) hide show
  1. package/css/og.css +137 -1
  2. package/lib/@openglobus/js/Globe.d.ts +0 -1
  3. package/lib/@openglobus/js/Object3d.d.ts +20 -10
  4. package/lib/@openglobus/js/camera/Camera.d.ts +57 -15
  5. package/lib/@openglobus/js/camera/Frustum.d.ts +3 -0
  6. package/lib/@openglobus/js/camera/PlanetCamera.d.ts +13 -0
  7. package/lib/@openglobus/js/control/CameraLock.d.ts +38 -0
  8. package/lib/@openglobus/js/control/MouseNavigation.d.ts +62 -51
  9. package/lib/@openglobus/js/control/OldMouseNavigation.d.ts +64 -0
  10. package/lib/@openglobus/js/control/SimpleNavigation.d.ts +27 -10
  11. package/lib/@openglobus/js/control/geoObjectEditor/ArrowEntity.d.ts +15 -0
  12. package/lib/@openglobus/js/control/geoObjectEditor/AxisTrackEntity.d.ts +9 -0
  13. package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditor.d.ts +13 -0
  14. package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorDialog.d.ts +69 -0
  15. package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +78 -9
  16. package/lib/@openglobus/js/control/geoObjectEditor/MoveAxisEntity.d.ts +17 -0
  17. package/lib/@openglobus/js/control/geoObjectEditor/MovePlaneEntity.d.ts +7 -0
  18. package/lib/@openglobus/js/control/geoObjectEditor/RotateEntity.d.ts +9 -0
  19. package/lib/@openglobus/js/control/geoObjectEditor/colors.d.ts +8 -0
  20. package/lib/@openglobus/js/control/index.d.ts +3 -2
  21. package/lib/@openglobus/js/entity/Entity.d.ts +282 -19
  22. package/lib/@openglobus/js/entity/EntityCollection.d.ts +8 -9
  23. package/lib/@openglobus/js/entity/GeoObject.d.ts +135 -39
  24. package/lib/@openglobus/js/entity/GeoObjectHandler.d.ts +39 -63
  25. package/lib/@openglobus/js/entity/InstanceData.d.ts +76 -0
  26. package/lib/@openglobus/js/entity/Polyline.d.ts +19 -6
  27. package/lib/@openglobus/js/entity/PolylineHandler.d.ts +7 -0
  28. package/lib/@openglobus/js/index.d.ts +2 -1
  29. package/lib/@openglobus/js/input/MouseHandler.d.ts +1 -0
  30. package/lib/@openglobus/js/layer/Vector.d.ts +4 -0
  31. package/lib/@openglobus/js/light/LightSource.d.ts +1 -139
  32. package/lib/@openglobus/js/math/Mat3.d.ts +1 -1
  33. package/lib/@openglobus/js/math/Mat4.d.ts +10 -1
  34. package/lib/@openglobus/js/math/Plane.d.ts +3 -1
  35. package/lib/@openglobus/js/math/Quat.d.ts +47 -33
  36. package/lib/@openglobus/js/math/Ray.d.ts +10 -14
  37. package/lib/@openglobus/js/math/Vec2.d.ts +22 -0
  38. package/lib/@openglobus/js/math/Vec3.d.ts +15 -0
  39. package/lib/@openglobus/js/math.d.ts +2 -2
  40. package/lib/@openglobus/js/quadTree/EntityCollectionNode.d.ts +2 -2
  41. package/lib/@openglobus/js/quadTree/Node.d.ts +1 -1
  42. package/lib/@openglobus/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +1 -1
  43. package/lib/@openglobus/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +1 -1
  44. package/lib/@openglobus/js/renderer/Renderer.d.ts +63 -44
  45. package/lib/@openglobus/js/renderer/RendererEvents.d.ts +2 -0
  46. package/lib/@openglobus/js/scene/Planet.d.ts +15 -7
  47. package/lib/@openglobus/js/scene/RenderNode.d.ts +10 -25
  48. package/lib/@openglobus/js/shaders/drawnode.d.ts +1 -0
  49. package/lib/@openglobus/js/shaders/geoObject.d.ts +1 -0
  50. package/lib/@openglobus/js/shaders/utils.d.ts +1 -1
  51. package/lib/@openglobus/js/ui/Checkbox.d.ts +31 -0
  52. package/lib/@openglobus/js/ui/Dialog.d.ts +3 -0
  53. package/lib/@openglobus/js/ui/Input.d.ts +32 -0
  54. package/lib/@openglobus/js/ui/View.d.ts +3 -1
  55. package/lib/@openglobus/js/utils/objParser.d.ts +44 -12
  56. package/lib/@openglobus/js/utils/shared.d.ts +22 -0
  57. package/lib/@openglobus/js/webgl/BaseFramebuffer.d.ts +0 -1
  58. package/lib/@openglobus/js/webgl/Framebuffer.d.ts +35 -8
  59. package/lib/@openglobus/js/webgl/Handler.d.ts +22 -12
  60. package/lib/@openglobus/og.css +1 -1
  61. package/lib/@openglobus/og.esm.js +1 -1
  62. package/lib/@openglobus/og.esm.js.map +1 -1
  63. package/lib/@openglobus/og.umd.js +1 -1
  64. package/lib/@openglobus/og.umd.js.map +1 -1
  65. package/lib/js/Globe.d.ts +0 -1
  66. package/lib/js/Globe.js +4 -2
  67. package/lib/js/Object3d.d.ts +20 -10
  68. package/lib/js/Object3d.js +124 -48
  69. package/lib/js/Popup.js +1 -1
  70. package/lib/js/camera/Camera.d.ts +57 -15
  71. package/lib/js/camera/Camera.js +109 -29
  72. package/lib/js/camera/Frustum.d.ts +3 -0
  73. package/lib/js/camera/Frustum.js +7 -0
  74. package/lib/js/camera/PlanetCamera.d.ts +13 -0
  75. package/lib/js/camera/PlanetCamera.js +52 -5
  76. package/lib/js/control/Atmosphere.js +10 -6
  77. package/lib/js/control/CameraLock.d.ts +38 -0
  78. package/lib/js/control/CameraLock.js +216 -0
  79. package/lib/js/control/Control.js +1 -1
  80. package/lib/js/control/DebugInfo.js +38 -8
  81. package/lib/js/control/KeyboardNavigation.js +9 -9
  82. package/lib/js/control/MouseNavigation.d.ts +62 -51
  83. package/lib/js/control/MouseNavigation.js +361 -305
  84. package/lib/js/control/MouseWheelZoomControl.d.ts +0 -44
  85. package/lib/js/control/MouseWheelZoomControl.js +270 -181
  86. package/lib/js/control/OldMouseNavigation.d.ts +64 -0
  87. package/lib/js/control/OldMouseNavigation.js +368 -0
  88. package/lib/js/control/ScaleControl.js +11 -5
  89. package/lib/js/control/SimpleNavigation.d.ts +27 -10
  90. package/lib/js/control/SimpleNavigation.js +149 -49
  91. package/lib/js/control/Sun.js +6 -6
  92. package/lib/js/control/TouchNavigation.js +11 -8
  93. package/lib/js/control/elevationProfile/ElevationProfileScene.js +6 -5
  94. package/lib/js/control/geoObjectEditor/ArrowEntity.d.ts +15 -0
  95. package/lib/js/control/geoObjectEditor/ArrowEntity.js +59 -0
  96. package/lib/js/control/geoObjectEditor/AxisTrackEntity.d.ts +9 -0
  97. package/lib/js/control/geoObjectEditor/AxisTrackEntity.js +93 -0
  98. package/lib/js/control/geoObjectEditor/GeoObjectEditor.d.ts +13 -0
  99. package/lib/js/control/geoObjectEditor/GeoObjectEditor.js +30 -0
  100. package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.d.ts +69 -0
  101. package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.js +488 -0
  102. package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +78 -9
  103. package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.js +487 -43
  104. package/lib/js/control/geoObjectEditor/MoveAxisEntity.d.ts +17 -0
  105. package/lib/js/control/geoObjectEditor/MoveAxisEntity.js +107 -0
  106. package/lib/js/control/geoObjectEditor/MovePlaneEntity.d.ts +7 -0
  107. package/lib/js/control/geoObjectEditor/MovePlaneEntity.js +31 -0
  108. package/lib/js/control/geoObjectEditor/RotateEntity.d.ts +9 -0
  109. package/lib/js/control/geoObjectEditor/RotateEntity.js +105 -0
  110. package/lib/js/control/geoObjectEditor/colors.d.ts +8 -0
  111. package/lib/js/control/geoObjectEditor/colors.js +8 -0
  112. package/lib/js/control/index.d.ts +3 -2
  113. package/lib/js/control/index.js +3 -2
  114. package/lib/js/control/timeline/TimelineControl.js +2 -0
  115. package/lib/js/control/visibleExtent/Segment.js +4 -4
  116. package/lib/js/entity/Entity.d.ts +282 -19
  117. package/lib/js/entity/Entity.js +497 -62
  118. package/lib/js/entity/EntityCollection.d.ts +8 -9
  119. package/lib/js/entity/EntityCollection.js +48 -45
  120. package/lib/js/entity/GeoObject.d.ts +135 -39
  121. package/lib/js/entity/GeoObject.js +150 -90
  122. package/lib/js/entity/GeoObjectHandler.d.ts +39 -63
  123. package/lib/js/entity/GeoObjectHandler.js +198 -295
  124. package/lib/js/entity/InstanceData.d.ts +76 -0
  125. package/lib/js/entity/InstanceData.js +347 -0
  126. package/lib/js/entity/Polyline.d.ts +19 -6
  127. package/lib/js/entity/Polyline.js +76 -36
  128. package/lib/js/entity/PolylineHandler.d.ts +7 -0
  129. package/lib/js/entity/PolylineHandler.js +26 -1
  130. package/lib/js/index.d.ts +2 -1
  131. package/lib/js/index.js +2 -1
  132. package/lib/js/input/MouseHandler.d.ts +1 -0
  133. package/lib/js/input/MouseHandler.js +12 -1
  134. package/lib/js/layer/Bing.js +2 -2
  135. package/lib/js/layer/Vector.d.ts +4 -0
  136. package/lib/js/layer/Vector.js +16 -0
  137. package/lib/js/light/LightSource.d.ts +1 -139
  138. package/lib/js/light/LightSource.js +21 -227
  139. package/lib/js/math/Mat3.d.ts +1 -1
  140. package/lib/js/math/Mat3.js +1 -1
  141. package/lib/js/math/Mat4.d.ts +10 -1
  142. package/lib/js/math/Mat4.js +17 -1
  143. package/lib/js/math/Plane.d.ts +3 -1
  144. package/lib/js/math/Plane.js +11 -1
  145. package/lib/js/math/Quat.d.ts +47 -33
  146. package/lib/js/math/Quat.js +92 -90
  147. package/lib/js/math/Ray.d.ts +10 -14
  148. package/lib/js/math/Ray.js +56 -33
  149. package/lib/js/math/Vec2.d.ts +22 -0
  150. package/lib/js/math/Vec2.js +32 -0
  151. package/lib/js/math/Vec3.d.ts +15 -0
  152. package/lib/js/math/Vec3.js +30 -1
  153. package/lib/js/math.d.ts +2 -2
  154. package/lib/js/math.js +3 -3
  155. package/lib/js/quadTree/EntityCollectionNode.d.ts +2 -2
  156. package/lib/js/quadTree/EntityCollectionNode.js +8 -8
  157. package/lib/js/quadTree/Node.d.ts +1 -1
  158. package/lib/js/quadTree/Node.js +2 -2
  159. package/lib/js/quadTree/QuadTreeStrategy.js +1 -1
  160. package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +1 -1
  161. package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.js +2 -2
  162. package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +1 -1
  163. package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.js +2 -2
  164. package/lib/js/renderer/Renderer.d.ts +63 -44
  165. package/lib/js/renderer/Renderer.js +267 -266
  166. package/lib/js/renderer/RendererEvents.d.ts +2 -0
  167. package/lib/js/renderer/RendererEvents.js +5 -2
  168. package/lib/js/scene/Planet.d.ts +15 -7
  169. package/lib/js/scene/Planet.js +133 -90
  170. package/lib/js/scene/RenderNode.d.ts +10 -25
  171. package/lib/js/scene/RenderNode.js +70 -58
  172. package/lib/js/segment/Segment.js +4 -4
  173. package/lib/js/shaders/depth.js +2 -5
  174. package/lib/js/shaders/drawnode.d.ts +1 -0
  175. package/lib/js/shaders/drawnode.js +51 -52
  176. package/lib/js/shaders/geoObject.d.ts +1 -0
  177. package/lib/js/shaders/geoObject.js +154 -91
  178. package/lib/js/shaders/polyline.js +68 -51
  179. package/lib/js/shaders/utils.d.ts +1 -1
  180. package/lib/js/shaders/utils.js +11 -0
  181. package/lib/js/terrain/GlobusTerrain.js +2 -2
  182. package/lib/js/ui/Checkbox.d.ts +31 -0
  183. package/lib/js/ui/Checkbox.js +110 -0
  184. package/lib/js/ui/Color.js +2 -1
  185. package/lib/js/ui/Dialog.d.ts +3 -0
  186. package/lib/js/ui/Dialog.js +20 -0
  187. package/lib/js/ui/Input.d.ts +32 -0
  188. package/lib/js/ui/Input.js +107 -0
  189. package/lib/js/ui/View.d.ts +3 -1
  190. package/lib/js/ui/View.js +6 -0
  191. package/lib/js/utils/objParser.d.ts +44 -12
  192. package/lib/js/utils/objParser.js +241 -149
  193. package/lib/js/utils/shared.d.ts +22 -0
  194. package/lib/js/utils/shared.js +34 -0
  195. package/lib/js/webgl/BaseFramebuffer.d.ts +0 -1
  196. package/lib/js/webgl/Framebuffer.d.ts +35 -8
  197. package/lib/js/webgl/Framebuffer.js +136 -29
  198. package/lib/js/webgl/Handler.d.ts +22 -12
  199. package/lib/js/webgl/Handler.js +53 -34
  200. package/lib/js/webgl/Program.js +0 -8
  201. package/package.json +5 -3
  202. package/lib/@openglobus/js/control/EarthNavigation.d.ts +0 -50
  203. package/lib/@openglobus/js/control/MouseWheelZoomControl.d.ts +0 -44
  204. package/lib/js/control/EarthNavigation.d.ts +0 -50
  205. package/lib/js/control/EarthNavigation.js +0 -202
@@ -1,5 +1,9 @@
1
1
  import { Control } from "./Control";
2
2
  import { input } from "../input/input";
3
+ import { Vec3 } from "../math/Vec3";
4
+ import * as math from "../math";
5
+ import { Ray } from "../math/Ray";
6
+ import { Plane } from "../math/Plane";
3
7
  /**
4
8
  * Simple keyboard camera navigation with W,S,A,D and shift keys to fly around the scene.
5
9
  */
@@ -9,13 +13,134 @@ export class SimpleNavigation extends Control {
9
13
  name: "SimpleNavigation",
10
14
  autoActivate: true, ...options
11
15
  });
12
- this.speed = options.speed || 1.0;
16
+ this._onMouseLeftButtonClick = (e) => {
17
+ if (this._active && this.renderer) {
18
+ this.renderer.handler.canvas.classList.add("ogGrabbingPoiner");
19
+ this._grabbedPoint = this.renderer.getCartesianFromPixel(e);
20
+ if (this._grabbedPoint) {
21
+ this._eye0.copy(this.renderer.activeCamera.eye);
22
+ }
23
+ }
24
+ };
25
+ this._onMouseLeftButtonUp = (e) => {
26
+ this.renderer.handler.canvas.classList.remove("ogGrabbingPoiner");
27
+ if (e.x === e.prev_x && e.y === e.prev_y) {
28
+ //this.force.set(0, 0, 0);
29
+ }
30
+ };
31
+ this._onMouseLeftButtonDown = (e) => {
32
+ if (this._active && this.renderer) {
33
+ if (!this._grabbedPoint) {
34
+ return;
35
+ }
36
+ if (e.moving) {
37
+ let cam = this.renderer.activeCamera;
38
+ let camSlope = Math.abs(cam.getForward().dot(Vec3.UP));
39
+ let p0 = this._grabbedPoint, p1, p2;
40
+ if (camSlope > 0.7) {
41
+ p1 = Vec3.add(p0, Vec3.LEFT);
42
+ p2 = Vec3.add(p0, cam.getRight());
43
+ }
44
+ else {
45
+ p1 = Vec3.add(p0, cam.getRight());
46
+ p2 = Vec3.add(p0, Vec3.UP);
47
+ }
48
+ let px = new Vec3();
49
+ if (new Ray(cam.eye, e.direction).hitPlaneRes(Plane.fromPoints(p0, p1, p2), px) === Ray.INSIDE) {
50
+ cam.eye = this._eye0.addA(px.subA(p0).negate());
51
+ }
52
+ }
53
+ }
54
+ };
55
+ this._onRHold = (e) => {
56
+ if (this._lookPos && e.moving && this.renderer) {
57
+ const cam = this.renderer.activeCamera;
58
+ this.renderer.controlsBag.scaleRot = 1.0;
59
+ let l = (0.5 / cam.eye.distance(this._lookPos)) * math.RADIANS;
60
+ if (l > 0.007) {
61
+ l = 0.007;
62
+ }
63
+ else if (l < 0.003) {
64
+ l = 0.003;
65
+ }
66
+ cam.rotateHorizontal(l * (e.x - e.prev_x), false, this._lookPos, this._up);
67
+ cam.rotateVertical(l * (e.y - e.prev_y), this._lookPos);
68
+ }
69
+ };
70
+ this._onRDown = (e) => {
71
+ if (this.renderer) {
72
+ this._lookPos = this.renderer.getCartesianFromPixel(e.pos);
73
+ if (this._lookPos) {
74
+ this._up = Vec3.UP; //this.renderer.activeCamera.getUp();
75
+ }
76
+ }
77
+ };
78
+ this._onMouseWheel = (e) => {
79
+ if (this.renderer) {
80
+ let pos = this.renderer.getCartesianFromPixel(e), dist = 10;
81
+ if (pos) {
82
+ dist = this.renderer.activeCamera.eye.distance(pos);
83
+ }
84
+ this.force.addA(e.direction.scale(e.wheelDelta)).normalize().scale(dist);
85
+ }
86
+ };
87
+ this.onCameraMoveForward = () => {
88
+ this.force.addA(this.renderer.activeCamera.getForward()).normalize();
89
+ };
90
+ this.onCameraMoveBackward = () => {
91
+ this.force.addA(this.renderer.activeCamera.getBackward()).normalize();
92
+ };
93
+ this.onCameraStrifeLeft = () => {
94
+ this.force.addA(this.renderer.activeCamera.getLeft()).normalize();
95
+ };
96
+ this.onCameraStrifeRight = () => {
97
+ this.force.addA(this.renderer.activeCamera.getRight()).normalize();
98
+ };
99
+ this.onCameraLookUp = () => {
100
+ let cam = this.renderer.activeCamera;
101
+ cam.setPitch(0.5);
102
+ cam.update();
103
+ };
104
+ this.onCameraLookDown = () => {
105
+ let cam = this.renderer.activeCamera;
106
+ cam.setPitch(-0.5);
107
+ cam.update();
108
+ };
109
+ this.onCameraTurnLeft = () => {
110
+ let cam = this.renderer.activeCamera;
111
+ cam.setYaw(0.5);
112
+ cam.update();
113
+ };
114
+ this.onCameraTurnRight = () => {
115
+ let cam = this.renderer.activeCamera;
116
+ cam.setYaw(-0.5);
117
+ cam.update();
118
+ };
119
+ this.onCameraRollLeft = () => {
120
+ let cam = this.renderer.activeCamera;
121
+ cam.setRoll(-0.5);
122
+ cam.update();
123
+ };
124
+ this.onCameraRollRight = () => {
125
+ let cam = this.renderer.activeCamera;
126
+ cam.setRoll(0.5);
127
+ cam.update();
128
+ };
129
+ this.speed = options.speed || 1.0; // m/s
130
+ this.force = new Vec3();
131
+ this.vel = new Vec3();
132
+ this.mass = 1;
133
+ this._lookPos = undefined;
134
+ this._grabbedPoint = undefined;
135
+ this._up = null;
136
+ this._eye0 = new Vec3();
13
137
  }
14
138
  oninit() {
15
139
  }
16
140
  onactivate() {
17
141
  super.onactivate();
18
142
  let r = this.renderer;
143
+ r.events.on("mousewheel", this._onMouseWheel);
19
144
  r.events.on("keypress", input.KEY_W, this.onCameraMoveForward, this);
20
145
  r.events.on("keypress", input.KEY_S, this.onCameraMoveBackward, this);
21
146
  r.events.on("keypress", input.KEY_A, this.onCameraStrifeLeft, this);
@@ -26,10 +151,17 @@ export class SimpleNavigation extends Control {
26
151
  r.events.on("keypress", input.KEY_RIGHT, this.onCameraTurnRight, this);
27
152
  r.events.on("keypress", input.KEY_Q, this.onCameraRollLeft, this);
28
153
  r.events.on("keypress", input.KEY_E, this.onCameraRollRight, this);
154
+ r.events.on("rhold", this._onRHold, this);
155
+ r.events.on("rdown", this._onRDown, this);
156
+ r.events.on("lhold", this._onMouseLeftButtonDown);
157
+ r.events.on("ldown", this._onMouseLeftButtonClick);
158
+ r.events.on("lup", this._onMouseLeftButtonUp);
159
+ r.events.on("draw", this.onDraw, this, -1000);
29
160
  }
30
161
  ondeactivate() {
31
162
  super.ondeactivate();
32
163
  let r = this.renderer;
164
+ r.events.off("mousewheel", this._onMouseWheel);
33
165
  r.events.off("keypress", input.KEY_W, this.onCameraMoveForward);
34
166
  r.events.off("keypress", input.KEY_S, this.onCameraMoveBackward);
35
167
  r.events.off("keypress", input.KEY_A, this.onCameraStrifeLeft);
@@ -40,57 +172,25 @@ export class SimpleNavigation extends Control {
40
172
  r.events.off("keypress", input.KEY_RIGHT, this.onCameraTurnRight);
41
173
  r.events.off("keypress", input.KEY_Q, this.onCameraRollLeft);
42
174
  r.events.off("keypress", input.KEY_E, this.onCameraRollRight);
175
+ r.events.off("rhold", this._onRHold);
176
+ r.events.off("rdown", this._onRDown);
177
+ r.events.off("lhold", this._onMouseLeftButtonDown);
178
+ r.events.off("ldown", this._onMouseLeftButtonClick);
179
+ r.events.off("lup", this._onMouseLeftButtonUp);
180
+ r.events.off("draw", this.onDraw);
181
+ }
182
+ get dt() {
183
+ return 0.001 * this.renderer.handler.deltaTime;
43
184
  }
44
- onCameraMoveForward() {
45
- if (this._active) {
185
+ onDraw() {
186
+ if (this.renderer) {
187
+ let acc = this.force.scale(1.0 / this.mass);
188
+ this.vel.addA(acc);
189
+ this.vel.scale(0.96);
190
+ this.force.set(0, 0, 0);
46
191
  let cam = this.renderer.activeCamera;
47
- cam.slide(0, 0, -this.speed);
192
+ cam.eye = cam.eye.add(this.vel.scaleTo(this.dt));
48
193
  cam.update();
49
194
  }
50
195
  }
51
- onCameraMoveBackward() {
52
- let cam = this.renderer.activeCamera;
53
- cam.slide(0, 0, this.speed);
54
- cam.update();
55
- }
56
- onCameraStrifeLeft() {
57
- let cam = this.renderer.activeCamera;
58
- cam.slide(-this.speed, 0, 0);
59
- cam.update();
60
- }
61
- onCameraStrifeRight() {
62
- let cam = this.renderer.activeCamera;
63
- cam.slide(this.speed, 0, 0);
64
- cam.update();
65
- }
66
- onCameraLookUp() {
67
- let cam = this.renderer.activeCamera;
68
- cam.pitch(0.5);
69
- cam.update();
70
- }
71
- onCameraLookDown() {
72
- let cam = this.renderer.activeCamera;
73
- cam.pitch(-0.5);
74
- cam.update();
75
- }
76
- onCameraTurnLeft() {
77
- let cam = this.renderer.activeCamera;
78
- cam.yaw(0.5);
79
- cam.update();
80
- }
81
- onCameraTurnRight() {
82
- let cam = this.renderer.activeCamera;
83
- cam.yaw(-0.5);
84
- cam.update();
85
- }
86
- onCameraRollLeft() {
87
- let cam = this.renderer.activeCamera;
88
- cam.roll(-0.5);
89
- cam.update();
90
- }
91
- onCameraRollRight() {
92
- let cam = this.renderer.activeCamera;
93
- cam.roll(0.5);
94
- cam.update();
95
- }
96
196
  }
@@ -13,7 +13,7 @@ export class Sun extends Control {
13
13
  this.activationHeight = options.activationHeight || 12079000.0;
14
14
  this.offsetVertical = options.offsetVertical || -5000000;
15
15
  this.offsetHorizontal = options.offsetHorizontal || 5000000;
16
- this.sunlight = new LightSource("Sun", {
16
+ this.sunlight = new LightSource({
17
17
  ambient: new Vec3(0.15, 0.15, 0.25),
18
18
  diffuse: new Vec3(0.9, 0.9, 0.8),
19
19
  specular: new Vec3(0.1, 0.1, 0.06),
@@ -71,18 +71,18 @@ export class Sun extends Control {
71
71
  this._lightOn = true;
72
72
  this._f = 1;
73
73
  let n = cam.eye.normal(), u = cam.getForward();
74
- u.scale(Math.sign(cam._u.dot(n))); // up
74
+ u.scale(Math.sign(cam.getUp().dot(n))); // up
75
75
  if (cam.slope > 0.99) {
76
- u = cam._u;
76
+ u = cam.getUp();
77
77
  }
78
78
  let tu = Vec3.proj_b_to_plane(u, n, u).normalize().scale(this.offsetVertical);
79
- let tr = Vec3.proj_b_to_plane(cam._r, n, cam._r)
79
+ let tr = Vec3.proj_b_to_plane(cam.getRight(), n, cam.getRight())
80
80
  .normalize()
81
81
  .scale(this.offsetHorizontal); // right
82
82
  let d = tu.add(tr);
83
83
  let pos = cam.eye.add(d);
84
84
  if (this._k > 0) {
85
- this._k -= 0.01;
85
+ this._k -= 0.001;
86
86
  let rot = Quat.getRotationBetweenVectors(this.sunlight._position.normal(), pos.normal());
87
87
  let r = rot.slerp(Quat.IDENTITY, this._k).normalize();
88
88
  this.sunlight.setPosition3v(r.mulVec3(this.sunlight._position));
@@ -94,7 +94,7 @@ export class Sun extends Control {
94
94
  else {
95
95
  this._k = 1;
96
96
  if (this._f > 0) {
97
- this._f -= 0.01;
97
+ this._f -= 0.001;
98
98
  let rot = Quat.getRotationBetweenVectors(this.sunlight._position.normal(), getSunPosition(this._currDate).normal());
99
99
  let r = rot.slerp(Quat.IDENTITY, this._f).normalize();
100
100
  this.sunlight.setPosition3v(r.mulVec3(this.sunlight._position));
@@ -7,6 +7,7 @@ import { Ray } from "../math/Ray";
7
7
  import { Sphere } from "../bv/Sphere";
8
8
  import { Vec2 } from "../math/Vec2";
9
9
  import { Vec3 } from "../math/Vec3";
10
+ import { Plane } from "../math/Plane";
10
11
  class TouchExt {
11
12
  constructor() {
12
13
  this.x = 0;
@@ -198,18 +199,19 @@ export class TouchNavigation extends Control {
198
199
  this.qRot = Quat.getRotationBetweenVectors(targetPoint.normal(), t.grabbedPoint.normal());
199
200
  let rot = this.qRot;
200
201
  cam.eye = rot.mulVec3(cam.eye);
201
- cam._r = rot.mulVec3(cam._r);
202
- cam._u = rot.mulVec3(cam._u);
203
- cam._b = rot.mulVec3(cam._b);
202
+ cam.rotate(rot);
203
+ // cam._r = rot.mulVec3(cam._r);
204
+ // cam._u = rot.mulVec3(cam._u);
205
+ // cam._b = rot.mulVec3(cam._b);
204
206
  cam.checkTerrainCollision();
205
207
  cam.update();
206
208
  this.scaleRot = 1;
207
209
  }
208
210
  else {
209
- let p0 = t.grabbedPoint, p1 = Vec3.add(p0, cam._u), p2 = Vec3.add(p0, p0.normal());
211
+ let p0 = t.grabbedPoint, p1 = Vec3.add(p0, cam.getUp()), p2 = Vec3.add(p0, p0.getNormal());
210
212
  let dir = cam.unproject(t.x, t.y);
211
213
  let px = new Vec3();
212
- if (new Ray(cam.eye, dir).hitPlane(p0, p1, p2, px) === Ray.INSIDE) {
214
+ if (new Ray(cam.eye, dir).hitPlaneRes(Plane.fromPoints(p0, p1, p2), px) === Ray.INSIDE) {
213
215
  cam.eye = this._eye0.addA(px.subA(p0).negate());
214
216
  cam.checkTerrainCollision();
215
217
  cam.update();
@@ -243,9 +245,10 @@ export class TouchNavigation extends Control {
243
245
  this.scaleRot = 0;
244
246
  }
245
247
  cam.eye = rot.mulVec3(cam.eye);
246
- cam._r = rot.mulVec3(cam._r);
247
- cam._u = rot.mulVec3(cam._u);
248
- cam._b = rot.mulVec3(cam._b);
248
+ cam.rotate(rot);
249
+ // cam._r = rot.mulVec3(cam._r);
250
+ // cam._u = rot.mulVec3(cam._u);
251
+ // cam._b = rot.mulVec3(cam._b);
249
252
  cam.checkTerrainCollision();
250
253
  cam.update();
251
254
  }
@@ -8,6 +8,7 @@ import { Vector } from '../../layer/Vector';
8
8
  import { Vec2 } from '../../math/Vec2';
9
9
  import { Vec3 } from '../../math/Vec3';
10
10
  import { Ray } from "../../math/Ray";
11
+ import { Plane } from "../../math/Plane";
11
12
  let groundObj3d = Object3d.createCylinder(0.33, 0, 1.0, 20, 1, true, false, 0, 0, 0);
12
13
  let headObj3d = Object3d.createCylinder(0.33, 0.33, 1.1, 20, 1, true, true, 0, -0.55, 0);
13
14
  const POINTER_RAY_OPTIONS = {
@@ -79,7 +80,7 @@ class ElevationProfileScene extends RenderNode {
79
80
  let p1 = p0.add(groundNormal);
80
81
  let p2 = p0.add(cam.getRight());
81
82
  let px = new Vec3();
82
- if (new Ray(cam.eye, e.direction).hitPlane(p0, p1, p2, px) === Ray.INSIDE) {
83
+ if (new Ray(cam.eye, e.direction).hitPlaneRes(Plane.fromPoints(p0, p1, p2), px) === Ray.INSIDE) {
83
84
  let h = Vec3.proj_b_to_a(px, p0);
84
85
  let s = h.sub(p0).dot(p0);
85
86
  let headPos = p0.add(groundNormal.scale(Math.sign(s) * h.distance(p0)));
@@ -379,7 +380,7 @@ class ElevationProfileScene extends RenderNode {
379
380
  groundEntity.setCartesian3v(groundPos);
380
381
  heightLabelEntity.setCartesian3v(headPos);
381
382
  heightLabelEntity.label.setText(`${hEll.toFixed(1)} m`);
382
- heightLabelEntity.childrenNodes[0].label.setText(`${altitude.toFixed(1)} m`);
383
+ heightLabelEntity.childEntities[0].label.setText(`${altitude.toFixed(1)} m`);
383
384
  headEntity.properties.altitude = altitude;
384
385
  headEntity.setCartesian3v(headPos);
385
386
  headEntity.properties.columnEntity.ray.setStartPosition3v(groundPos);
@@ -419,7 +420,7 @@ class ElevationProfileScene extends RenderNode {
419
420
  let headPos = groundPos.add(groundNormal.scale(altitude));
420
421
  heightLabelEntity.setCartesian3v(headPos);
421
422
  heightLabelEntity.label.setText(`${hEll.toFixed(1)} m`);
422
- heightLabelEntity.childrenNodes[0].label.setText(`${altitude.toFixed(1)} m`);
423
+ heightLabelEntity.childEntities[0].label.setText(`${altitude.toFixed(1)} m`);
423
424
  headEntity.setCartesian3v(headPos);
424
425
  headEntity.properties.columnEntity.ray.setEndPosition3v(headPos);
425
426
  this._trackEntity.polyline?.setPoint3v(headPos, headEntity.properties.index);
@@ -444,7 +445,7 @@ class ElevationProfileScene extends RenderNode {
444
445
  headEntity.setCartesian3v(headPos);
445
446
  headEntity.properties.columnEntity.ray.setEndPosition3v(headPos);
446
447
  headEntity.properties.heightLabelEntity.setCartesian3v(headPos);
447
- headEntity.properties.heightLabelEntity.childrenNodes[0].label.setText(`${altitude.toFixed(1)} m`);
448
+ headEntity.properties.heightLabelEntity.childEntities[0].label.setText(`${altitude.toFixed(1)} m`);
448
449
  this._trackEntity.polyline.setPoint3v(headPos, entityIndex);
449
450
  this.events.dispatch(this.events.change, this._pickedHeadEntity);
450
451
  }
@@ -468,7 +469,7 @@ class ElevationProfileScene extends RenderNode {
468
469
  this._trackEntity.polyline?.setPoint3v(headPos, headEntity.properties.index);
469
470
  heightLabelEntity.setCartesian3v(headPos);
470
471
  heightLabelEntity.label.setText(`${lonLat.height.toFixed(1)} m`);
471
- heightLabelEntity.childrenNodes[0].label.setText(`${altitude.toFixed(1)} m`);
472
+ heightLabelEntity.childEntities[0].label.setText(`${altitude.toFixed(1)} m`);
472
473
  this.events.dispatch(this.events.change, groundEntity.properties.headEntity);
473
474
  }
474
475
  }
@@ -0,0 +1,15 @@
1
+ import { Entity, IEntityParams } from "../../entity/Entity";
2
+ export interface IArrowEntityParams extends IEntityParams {
3
+ yaw?: number;
4
+ pitch?: number;
5
+ roll?: number;
6
+ size?: number;
7
+ color?: string;
8
+ properties?: any;
9
+ }
10
+ export declare class ArrowEntity extends Entity {
11
+ protected _size: number;
12
+ constructor(params?: IArrowEntityParams);
13
+ setSize(size: number): void;
14
+ setColorHTML(color: string): void;
15
+ }
@@ -0,0 +1,59 @@
1
+ import { Entity } from "../../entity/Entity";
2
+ import { X_COLOR } from "./colors";
3
+ import { Object3d } from "../../Object3d";
4
+ import { Vec3 } from "../../math/Vec3";
5
+ const SCALE = 0.1;
6
+ const SCALE_VEC = new Vec3(SCALE, SCALE, SCALE);
7
+ const TIP_LENGTH = 0.17;
8
+ const TIP_RADIUS = 0.04;
9
+ const SPIN_RADIUS = 0.0095;
10
+ const lineObj = Object3d.createCylinder(SPIN_RADIUS, SPIN_RADIUS, 1.0 - TIP_LENGTH).scale(SCALE_VEC);
11
+ const tipObj = Object3d.createCylinder(0, TIP_RADIUS, TIP_LENGTH, 16, 16, false, true, 0, -TIP_LENGTH).scale(SCALE_VEC);
12
+ export class ArrowEntity extends Entity {
13
+ constructor(params = {}) {
14
+ const scale = 1.0;
15
+ super({
16
+ independentPicking: true,
17
+ yaw: params.yaw || 0,
18
+ pitch: params.pitch || 0,
19
+ roll: params.roll || 0,
20
+ forceGlobalPosition: true,
21
+ geoObject: {
22
+ color: params.color || X_COLOR,
23
+ scale,
24
+ tag: "line",
25
+ object3d: lineObj,
26
+ },
27
+ properties: params.properties
28
+ });
29
+ this._size = params.size != undefined ? params.size : 1.0;
30
+ this.appendChild(new Entity({
31
+ yaw: params.yaw || 0,
32
+ pitch: params.pitch || 0,
33
+ roll: params.roll || 0,
34
+ forceGlobalPosition: true,
35
+ geoObject: {
36
+ color: params.color || X_COLOR,
37
+ scale,
38
+ tag: "tip",
39
+ object3d: tipObj,
40
+ },
41
+ properties: params.properties
42
+ }));
43
+ }
44
+ setSize(size) {
45
+ this._size = size;
46
+ const scale = new Vec3(1, (this._size - TIP_LENGTH) / (1.0 - TIP_LENGTH), 1);
47
+ const trans = new Vec3(0, this._size * SCALE, 0);
48
+ let line = this;
49
+ let tip = line.childEntities[0];
50
+ line.setScale3v(scale);
51
+ tip.geoObject.setTranslate3v(trans);
52
+ }
53
+ setColorHTML(color) {
54
+ let line = this;
55
+ let tip = line.childEntities[0];
56
+ line.geoObject.setColorHTML(color);
57
+ tip.geoObject.setColorHTML(color);
58
+ }
59
+ }
@@ -0,0 +1,9 @@
1
+ import { Entity, IEntityParams } from "../../entity/Entity";
2
+ import { Vec3 } from "../../math/Vec3";
3
+ export interface IAxisTrackEntityParams extends IEntityParams {
4
+ }
5
+ export declare class AxisTrackEntity extends Entity {
6
+ constructor(params?: IAxisTrackEntityParams);
7
+ private _init;
8
+ setCartesian3v(cart: Vec3): void;
9
+ }
@@ -0,0 +1,93 @@
1
+ import { Entity } from "../../entity/Entity";
2
+ import { Vec3 } from "../../math/Vec3";
3
+ import { SEL_X_COLOR, SEL_Y_COLOR, SEL_Z_COLOR } from "./colors";
4
+ import { LonLat } from "../../LonLat";
5
+ import { htmlColorToFloat32Array } from "../../utils/shared";
6
+ const SEG_SIZE = 20;
7
+ export class AxisTrackEntity extends Entity {
8
+ constructor(params = {}) {
9
+ super({ ...params, forceGlobalPosition: true });
10
+ this._init();
11
+ }
12
+ _init() {
13
+ const length = SEG_SIZE;
14
+ let lonColors = [], latCoords = [], yColors = [];
15
+ let lonCol = htmlColorToFloat32Array(SEL_X_COLOR), yCol = htmlColorToFloat32Array(SEL_Y_COLOR), latCol = htmlColorToFloat32Array(SEL_Z_COLOR);
16
+ for (let i = 0; i < length; i++) {
17
+ let op = 1;
18
+ if (i < 5) {
19
+ let t = i / 5;
20
+ op = 0.5 * (1 - Math.cos(Math.PI * t));
21
+ }
22
+ else if (i > 15) {
23
+ let t = (i - 15) / 5;
24
+ op = 1 - 0.5 * (1 - Math.cos(Math.PI * t));
25
+ }
26
+ latCoords.push([latCol[0], latCol[1], latCol[2], op]);
27
+ lonColors.push([lonCol[0], lonCol[1], lonCol[2], op]);
28
+ yColors.push([yCol[0], yCol[1], yCol[2], op]);
29
+ }
30
+ let axisX = new Entity({
31
+ polyline: {
32
+ path3v: [Array.from({ length }, (_, i) => new Vec3())],
33
+ thickness: 2.5,
34
+ pathColors: [lonColors],
35
+ isClosed: false
36
+ }
37
+ });
38
+ let axisY = new Entity({
39
+ polyline: {
40
+ path3v: [Array.from({ length }, (_, i) => new Vec3())],
41
+ thickness: 2.5,
42
+ pathColors: [yColors],
43
+ isClosed: false
44
+ }
45
+ });
46
+ let axisZ = new Entity({
47
+ polyline: {
48
+ path3v: [Array.from({ length }, (_, i) => new Vec3())],
49
+ thickness: 2.5,
50
+ pathColors: [latCoords],
51
+ isClosed: false
52
+ }
53
+ });
54
+ this.appendChild(axisX);
55
+ this.appendChild(axisY);
56
+ this.appendChild(axisZ);
57
+ }
58
+ setCartesian3v(cart) {
59
+ super.setCartesian3v(cart);
60
+ if (this._entityCollection && this._entityCollection.renderNode) {
61
+ let rn = this._entityCollection.renderNode;
62
+ let cam = rn.renderer.activeCamera;
63
+ let r = cam.eye.distance(cart) * 0.05;
64
+ if (rn.planet) {
65
+ let yCoords = [], lonCoords = [], latCoords = [];
66
+ let n = rn.planet.ellipsoid.getSurfaceNormal3v(cart);
67
+ let ll = this._lonLat;
68
+ let size = SEG_SIZE / 2;
69
+ for (let i = -size; i < size; i++) {
70
+ latCoords.push(new LonLat(ll.lon, ll.lat + i, ll.height));
71
+ lonCoords.push(new LonLat(ll.lon + i, ll.lat, ll.height));
72
+ yCoords.push(cart.add(n.scaleTo(i * r)));
73
+ }
74
+ this.childEntities[0].polyline.setPathLonLatFast([lonCoords]);
75
+ this.childEntities[1].polyline.setPath3vFast([yCoords]);
76
+ this.childEntities[2].polyline.setPathLonLatFast([latCoords]);
77
+ }
78
+ else {
79
+ let zCoords = [], xCoords = [], yCoords = [];
80
+ let y = Vec3.UNIT_Y, x = Vec3.UNIT_X, z = Vec3.UNIT_Z;
81
+ let size = SEG_SIZE / 2;
82
+ for (let i = -size; i < size; i++) {
83
+ xCoords.push(cart.add(x.scaleTo(i * r)));
84
+ yCoords.push(cart.add(y.scaleTo(i * r)));
85
+ zCoords.push(cart.add(z.scaleTo(i * r)));
86
+ }
87
+ this.childEntities[0].polyline.setPath3vFast([xCoords]);
88
+ this.childEntities[1].polyline.setPath3vFast([yCoords]);
89
+ this.childEntities[2].polyline.setPath3vFast([zCoords]);
90
+ }
91
+ }
92
+ }
93
+ }
@@ -0,0 +1,13 @@
1
+ import { Control, IControlParams } from "../Control";
2
+ import { GeoObjectEditorScene } from "./GeoObjectEditorScene";
3
+ import { GeoObjectPropertiesDialog } from "./GeoObjectEditorDialog";
4
+ export interface IGeoObjectEditorParams extends IControlParams {
5
+ }
6
+ export declare class GeoObjectEditor extends Control {
7
+ protected _geoObjectEditopScene: GeoObjectEditorScene;
8
+ protected _dialog: GeoObjectPropertiesDialog;
9
+ constructor(options?: IGeoObjectEditorParams);
10
+ oninit(): void;
11
+ onactivate(): void;
12
+ ondeactivate(): void;
13
+ }
@@ -0,0 +1,30 @@
1
+ import { Control } from "../Control";
2
+ import { GeoObjectEditorScene } from "./GeoObjectEditorScene";
3
+ import { GeoObjectPropertiesDialog } from "./GeoObjectEditorDialog";
4
+ import { CameraLock } from "../CameraLock";
5
+ export class GeoObjectEditor extends Control {
6
+ constructor(options = {}) {
7
+ super(options);
8
+ this._geoObjectEditopScene = new GeoObjectEditorScene({
9
+ name: `geoObjectEditorScene:${this.__id}`
10
+ });
11
+ this._dialog = new GeoObjectPropertiesDialog({
12
+ model: this._geoObjectEditopScene
13
+ });
14
+ }
15
+ oninit() {
16
+ if (this.renderer) {
17
+ this.renderer.addControl(new CameraLock({ planet: this.planet }));
18
+ this._geoObjectEditopScene.bindPlanet(this.planet);
19
+ this._dialog.appendTo(this.renderer.div || document.body);
20
+ this.activate();
21
+ }
22
+ }
23
+ onactivate() {
24
+ this.renderer && this.renderer.addNode(this._geoObjectEditopScene);
25
+ }
26
+ ondeactivate() {
27
+ this.renderer && this.renderer.removeNode(this._geoObjectEditopScene);
28
+ this._dialog.hide();
29
+ }
30
+ }
@@ -0,0 +1,69 @@
1
+ import { Dialog, IDialogParams } from "../../ui/Dialog";
2
+ import { GeoObjectEditorScene } from "./GeoObjectEditorScene";
3
+ import { Entity } from "../../entity/Entity";
4
+ import { Input } from "../../ui/Input";
5
+ import { Checkbox } from "../../ui/Checkbox";
6
+ import { Button } from "../../ui/Button";
7
+ import { Vec3 } from "../../math/Vec3";
8
+ interface IGeoObjectPropertiesDialog extends IDialogParams {
9
+ model: GeoObjectEditorScene;
10
+ }
11
+ export declare class GeoObjectPropertiesDialog extends Dialog<GeoObjectEditorScene> {
12
+ protected _relativePositionView: Checkbox;
13
+ protected _lonView: Input;
14
+ protected _latView: Input;
15
+ protected _heightView: Input;
16
+ protected _xView: Input;
17
+ protected _yView: Input;
18
+ protected _zView: Input;
19
+ protected _absXView: Input;
20
+ protected _absYView: Input;
21
+ protected _absZView: Input;
22
+ protected _pitchView: Input;
23
+ protected _yawView: Input;
24
+ protected _rollView: Input;
25
+ protected _absolutePitchView: Input;
26
+ protected _absoluteYawView: Input;
27
+ protected _absoluteRollView: Input;
28
+ protected _scaleView: Input;
29
+ protected _scaleXView: Input;
30
+ protected _scaleYView: Input;
31
+ protected _scaleZView: Input;
32
+ protected _groundBtn: Button;
33
+ constructor(params: IGeoObjectPropertiesDialog);
34
+ render(params: any): this;
35
+ protected _onVisibility: (vis: boolean) => void;
36
+ remove(): void;
37
+ protected _initSceneEvents(): void;
38
+ protected _clearSceneEvents(): void;
39
+ protected _onSelect: (entity: Entity) => void;
40
+ protected _refresh(entity: Entity): void;
41
+ hide(): void;
42
+ protected _onUnselect: (entity: Entity) => void;
43
+ protected _onChangeRelativePosition: (checked: boolean) => void;
44
+ protected _onPosition: (pos: Vec3, entity: Entity) => void;
45
+ protected _onPitch: (a: number, entity: Entity) => void;
46
+ protected _onYaw: (a: number, entity: Entity) => void;
47
+ protected _onRoll: (a: number, entity: Entity) => void;
48
+ protected _onChangeLon: (val: string) => void;
49
+ protected _onChangeLat: (val: string) => void;
50
+ protected _onChangeHeight: (val: string) => void;
51
+ protected _onChangeX: (val: string) => void;
52
+ protected _onChangeY: (val: string) => void;
53
+ protected _onChangeZ: (val: string) => void;
54
+ protected _onChangeAbsoluteX: (val: string) => void;
55
+ protected _onChangeAbsoluteY: (val: string) => void;
56
+ protected _onChangeAbsoluteZ: (val: string) => void;
57
+ protected _onChangePitch: (val: string) => void;
58
+ protected _onChangeYaw: (val: string) => void;
59
+ protected _onChangeRoll: (val: string) => void;
60
+ protected _onChangeAbsolutePitch: (val: string) => void;
61
+ protected _onChangeAbsoluteYaw: (val: string) => void;
62
+ protected _onChangeAbsoluteRoll: (val: string) => void;
63
+ protected _onChangeScale: (val: string) => void;
64
+ protected _onChangeScaleX: (val: string) => void;
65
+ protected _onChangeScaleY: (val: string) => void;
66
+ protected _onChangeScaleZ: (val: string) => void;
67
+ protected _onGround: () => void;
68
+ }
69
+ export {};