@openglobus/og 0.14.10 → 0.15.1

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 (140) hide show
  1. package/css/og.css +378 -275
  2. package/dist/@openglobus/og.css +1 -1
  3. package/dist/@openglobus/og.esm.js +2 -2
  4. package/dist/@openglobus/og.esm.js.map +1 -1
  5. package/dist/@openglobus/og.umd.js +2 -2
  6. package/dist/@openglobus/og.umd.js.map +1 -1
  7. package/package.json +18 -17
  8. package/src/og/Clock.js +218 -194
  9. package/src/og/Globe.js +5 -5
  10. package/src/og/Object3d.js +104 -145
  11. package/src/og/camera/Camera.js +31 -27
  12. package/src/og/camera/PlanetCamera.js +22 -14
  13. package/src/og/cons.js +107 -107
  14. package/src/og/control/Atmosphere.js +396 -0
  15. package/src/og/control/CompassButton.js +11 -18
  16. package/src/og/control/Control.js +197 -188
  17. package/src/og/control/GeoImageDragControl.js +84 -66
  18. package/src/og/control/LayerSwitcher.js +56 -138
  19. package/src/og/control/Lighting.js +314 -186
  20. package/src/og/control/MouseNavigation.js +2 -2
  21. package/src/og/control/RulerSwitcher.js +24 -19
  22. package/src/og/control/ScaleControl.js +30 -10
  23. package/src/og/control/SimpleSkyBackground.js +210 -0
  24. package/src/og/control/Sun.js +3 -1
  25. package/src/og/control/ZoomControl.js +30 -42
  26. package/src/og/control/index.js +6 -0
  27. package/src/og/control/ruler/RulerScene.js +5 -23
  28. package/src/og/control/selection/Selection.js +99 -0
  29. package/src/og/control/selection/SelectionScene.js +350 -0
  30. package/src/og/control/timeline/TimelineControl.js +99 -0
  31. package/src/og/control/timeline/TimelineModel.js +133 -0
  32. package/src/og/control/timeline/TimelineView.js +449 -0
  33. package/src/og/control/timeline/timelineUtils.js +132 -0
  34. package/src/og/ellipsoid/Ellipsoid.js +120 -93
  35. package/src/og/ellipsoid/wgs84.js +13 -13
  36. package/src/og/entity/Entity.js +36 -9
  37. package/src/og/entity/EntityCollection.js +0 -2
  38. package/src/og/entity/GeoObject.js +72 -56
  39. package/src/og/entity/GeoObjectHandler.js +487 -656
  40. package/src/og/entity/GeometryHandler.js +1341 -1337
  41. package/src/og/entity/Polyline.js +0 -16
  42. package/src/og/entity/Ray.js +0 -10
  43. package/src/og/entity/RayHandler.js +3 -44
  44. package/src/og/entity/Strip.js +1 -6
  45. package/src/og/index.js +13 -7
  46. package/src/og/input/input.js +3 -1
  47. package/src/og/layer/CanvasTiles.js +39 -34
  48. package/src/og/layer/Layer.js +69 -9
  49. package/src/og/layer/Material.js +1 -8
  50. package/src/og/layer/WMS.js +16 -5
  51. package/src/og/light/LightSource.js +2 -0
  52. package/src/og/math/Line3.js +140 -139
  53. package/src/og/math/Plane.js +118 -117
  54. package/src/og/math/Ray.js +242 -239
  55. package/src/og/math/Vec3.js +56 -37
  56. package/src/og/math/Vec4.js +3 -4
  57. package/src/og/math.js +21 -21
  58. package/src/og/quadTree/Node.js +5 -4
  59. package/src/og/quadTree/index.js +12 -0
  60. package/src/og/renderer/Renderer.js +64 -37
  61. package/src/og/renderer/RendererEvents.js +1071 -1065
  62. package/src/og/scene/Planet.js +354 -174
  63. package/src/og/scene/RenderNode.js +27 -12
  64. package/src/og/segment/Segment.js +0 -5
  65. package/src/og/shaders/atmos.js +332 -0
  66. package/src/og/shaders/drawnode.js +475 -109
  67. package/src/og/shaders/geoObject.js +96 -51
  68. package/src/og/shaders/polyline.js +212 -17
  69. package/src/og/shaders/ray.js +13 -6
  70. package/src/og/shaders/toneMapping.js +5 -5
  71. package/src/og/shaders/utils.js +88 -0
  72. package/src/og/terrain/GlobusTerrain.js +5 -4
  73. package/src/og/terrain/MapboxTerrain.js +231 -52
  74. package/src/og/ui/Button.js +106 -0
  75. package/src/og/ui/ButtonGroup.js +57 -0
  76. package/src/og/ui/Dialog.js +242 -0
  77. package/src/og/ui/Slider.js +144 -0
  78. package/src/og/ui/ToggleButton.js +51 -0
  79. package/src/og/{control → ui}/UIhelpers.js +11 -2
  80. package/src/og/ui/View.js +190 -0
  81. package/src/og/utils/shared.js +960 -942
  82. package/src/og/webgl/Framebuffer.js +308 -387
  83. package/src/og/webgl/Handler.js +90 -30
  84. package/src/og/webgl/Multisample.js +8 -0
  85. package/types/Clock.d.ts +7 -2
  86. package/types/Object3d.d.ts +14 -3
  87. package/types/camera/Camera.d.ts +18 -17
  88. package/types/camera/PlanetCamera.d.ts +3 -1
  89. package/types/control/Atmosphere.d.ts +15 -0
  90. package/types/control/CompassButton.d.ts +1 -2
  91. package/types/control/GeoImageDragControl.d.ts +7 -1
  92. package/types/control/LayerSwitcher.d.ts +5 -6
  93. package/types/control/Lighting.d.ts +32 -7
  94. package/types/control/ScaleControl.d.ts +2 -1
  95. package/types/control/SimpleSkyBackground.d.ts +15 -0
  96. package/types/control/ZoomControl.d.ts +0 -1
  97. package/types/control/index.d.ts +4 -1
  98. package/types/control/ruler/RulerScene.d.ts +0 -1
  99. package/types/control/selection/Selection.d.ts +49 -0
  100. package/types/control/selection/SelectionScene.d.ts +34 -0
  101. package/types/ellipsoid/Ellipsoid.d.ts +3 -2
  102. package/types/entity/Entity.d.ts +8 -0
  103. package/types/entity/GeoObject.d.ts +28 -22
  104. package/types/entity/GeoObjectHandler.d.ts +16 -56
  105. package/types/entity/Ray.d.ts +0 -3
  106. package/types/entity/RayHandler.d.ts +0 -4
  107. package/types/index.d.ts +9 -6
  108. package/types/input/input.d.ts +2 -0
  109. package/types/layer/CanvasTiles.d.ts +1 -0
  110. package/types/layer/Layer.d.ts +9 -0
  111. package/types/layer/WMS.d.ts +7 -3
  112. package/types/math/Plane.d.ts +1 -1
  113. package/types/math/Vec3.d.ts +19 -16
  114. package/types/math/Vec4.d.ts +2 -3
  115. package/types/math.d.ts +20 -20
  116. package/types/quadTree/index.d.ts +10 -0
  117. package/types/renderer/Renderer.d.ts +11 -37
  118. package/types/scene/Planet.d.ts +27 -1
  119. package/types/scene/RenderNode.d.ts +2 -1
  120. package/types/segment/Segment.d.ts +1 -1
  121. package/types/shaders/atmos.d.ts +4 -0
  122. package/types/shaders/drawnode.d.ts +3 -2
  123. package/types/shaders/utils.d.ts +1 -0
  124. package/types/terrain/GlobusTerrain.d.ts +1 -1
  125. package/types/terrain/MapboxTerrain.d.ts +2 -1
  126. package/types/ui/Button.d.ts +21 -0
  127. package/types/ui/Dialog.d.ts +41 -0
  128. package/types/ui/Slider.d.ts +30 -0
  129. package/types/ui/ToggleButton.d.ts +10 -0
  130. package/types/{control → ui}/UIhelpers.d.ts +1 -1
  131. package/types/ui/View.d.ts +32 -0
  132. package/types/utils/shared.d.ts +16 -14
  133. package/types/webgl/Framebuffer.d.ts +2 -5
  134. package/types/webgl/Handler.d.ts +15 -10
  135. package/types/webgl/Multisample.d.ts +2 -0
  136. package/src/og/ajax.js +0 -204
  137. package/src/og/entity/Object3d.js +0 -504
  138. package/src/og/utils/quadTreeType.js +0 -11
  139. package/types/ajax.d.ts +0 -24
  140. package/types/utils/quadTreeType.d.ts +0 -8
@@ -17,11 +17,19 @@ import { Planet } from "../scene/Planet.js";
17
17
  */
18
18
 
19
19
  class GeoObject {
20
- constructor(options) {
21
- options = options || {};
20
+ constructor(options = {}) {
22
21
 
23
- this.scale = options.scale || 1.0;
24
- this.scaleByDistance = new Float32Array(options.scaleByDistance || [MAX32, MAX32, MAX32]);
22
+ this.tag = options.tag || "none";
23
+
24
+ // TODO: not instanced
25
+ this.instanced = true;
26
+
27
+ /**
28
+ * Entity instance that holds this geo object.
29
+ * @protected
30
+ * @type {Entity}
31
+ */
32
+ this._entity = null;
25
33
 
26
34
  /**
27
35
  * Geo object center cartesian position.
@@ -31,17 +39,14 @@ class GeoObject {
31
39
  this._position = utils.createVector3(options.position);
32
40
 
33
41
  this._positionHigh = new Vec3();
34
-
35
42
  this._positionLow = new Vec3();
36
-
37
43
  Vec3.doubleToTwoFloats(this._position, this._positionHigh, this._positionLow);
38
44
 
39
45
  this._pitch = options.pitch || 0.0;
40
46
  this._yaw = options.yaw || 0.0;
41
47
  this._roll = options.roll || 0.0;
42
48
 
43
- this._planet = options.planet || null;
44
- this._lonLatAlt = new LonLat(0, 0, 100000);
49
+ this._scale = options.scale || 1.0;
45
50
 
46
51
  /**
47
52
  * RGBA color.
@@ -54,25 +59,51 @@ class GeoObject {
54
59
 
55
60
  this._handler = null;
56
61
  this._handlerIndex = -1;
57
- this._vertices = options.vertices;
58
- this._normals = options.normals;
59
- this._indices = options.indices;
60
- this.instanced = options.instanced;
61
- this.tag = options.tag || "none";
62
- if (options.indices) {
63
- this._indicesCount = options.indices.length;
64
- }
65
- if (options.vertices) {
66
- this._verticesCount = Math.floor(options.vertices.length / 3);
67
- }
62
+
63
+ this._tagData = null;
64
+ this._tagDataIndex = -1;
65
+
66
+ this._object3d = options.object3d;
67
+ }
68
+
69
+ getPosition() {
70
+ return this._position;
71
+ }
72
+
73
+ getPitch() {
74
+ return this._pitch;
68
75
  }
69
76
 
70
- get planet() {
71
- return this._handler && this._handler._planet;
77
+ getYaw() {
78
+ return this._yaw;
72
79
  }
73
80
 
74
- get renderer() {
75
- return this.planet && this.planet.renderer;
81
+ getRoll() {
82
+ return this._roll;
83
+ }
84
+
85
+ getDirection() {
86
+ return this._direction;
87
+ }
88
+
89
+ get object3d() {
90
+ return this._object3d;
91
+ }
92
+
93
+ get vertices() {
94
+ return this._object3d.vertices;
95
+ }
96
+
97
+ get normals() {
98
+ return this._object3d.normals;
99
+ }
100
+
101
+ get texCoords() {
102
+ return this._object3d.texCoords;
103
+ }
104
+
105
+ get indices() {
106
+ return this._object3d.indices;
76
107
  }
77
108
 
78
109
  /**
@@ -86,7 +117,7 @@ class GeoObject {
86
117
  }
87
118
 
88
119
  /**
89
- * Sets RGBA color. Each channel from 0.0 to 1.0.
120
+ * Sets color.
90
121
  * @public
91
122
  * @param {number} r - Red.
92
123
  * @param {number} g - Green.
@@ -98,11 +129,11 @@ class GeoObject {
98
129
  this._color.y = g;
99
130
  this._color.z = b;
100
131
  a != undefined && (this._color.w = a);
101
- this._handler && this._handler.setRgbaArr(this._handlerIndex, this._color);
132
+ this._handler && this._handler.setRgbaArr(this._tagData, this._tagDataIndex, this._color);
102
133
  }
103
134
 
104
135
  /**
105
- * Sets RGBA color. Each channel from 0.0 to 1.0.
136
+ * Sets color.
106
137
  * @public
107
138
  * @param {og.Vec4} color - RGBA vector.
108
139
  */
@@ -111,7 +142,7 @@ class GeoObject {
111
142
  this._color.y = color.y;
112
143
  this._color.z = color.z;
113
144
  color.w != undefined && (this._color.w = color.w);
114
- this._handler && this._handler.setRgbaArr(this._handlerIndex, color);
145
+ this._handler && this._handler.setRgbaArr(this._tagData, this._tagDataIndex, color);
115
146
  }
116
147
 
117
148
  /**
@@ -121,11 +152,11 @@ class GeoObject {
121
152
  */
122
153
  setVisibility(visibility) {
123
154
  this._visibility = visibility;
124
- this._handler && this._handler.setVisibility(this._handlerIndex, visibility);
155
+ this._handler && this._handler.setVisibility(this._tagData, this._tagDataIndex, visibility);
125
156
  }
126
157
 
127
158
  /**
128
- * Returns geo object visibility.
159
+ * Returns geo object visibility.
129
160
  * @public
130
161
  * @returns {boolean}
131
162
  */
@@ -133,16 +164,8 @@ class GeoObject {
133
164
  return this._visibility;
134
165
  }
135
166
 
136
- setLonLat(lon, lat, alt) {
137
- this._lonLatAlt.lon = lon;
138
- this._lonLatAlt.lat = lat;
139
- this._lonLatAlt.height = alt;
140
- this._handler._planet.ellipsoid.lonLatToCartesianRes(this._lonLatAlt, this._position);
141
- this.setPosition3v(this._position);
142
- }
143
-
144
167
  /**
145
- * Sets geoObject position.
168
+ * Sets geo object position.
146
169
  * @public
147
170
  * @param {number} x - X coordinate.
148
171
  * @param {number} y - Y coordinate.
@@ -154,12 +177,12 @@ class GeoObject {
154
177
  this._position.z = z;
155
178
  Vec3.doubleToTwoFloats(this._position, this._positionHigh, this._positionLow);
156
179
  this._handler &&
157
- this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow);
180
+ this._handler.setPositionArr(this._tagData, this._tagDataIndex, this._positionHigh, this._positionLow);
158
181
  this.updateDirection();
159
182
  }
160
183
 
161
184
  /**
162
- * Sets billboard position.
185
+ * Sets geo object position.
163
186
  * @public
164
187
  * @param {og.Vec3} position - Cartesian coordinates.
165
188
  */
@@ -168,8 +191,7 @@ class GeoObject {
168
191
  this._position.y = position.y;
169
192
  this._position.z = position.z;
170
193
  Vec3.doubleToTwoFloats(position, this._positionHigh, this._positionLow);
171
- this._handler &&
172
- this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow);
194
+ this._handler && this._handler.setPositionArr(this._tagData, this._tagDataIndex, this._positionHigh, this._positionLow);
173
195
  this.updateDirection();
174
196
  }
175
197
 
@@ -180,21 +202,21 @@ class GeoObject {
180
202
 
181
203
  setPitch(pitch) {
182
204
  this._pitch = pitch;
183
- this._handler && this._handler.setPitchRollArr(this._handlerIndex, pitch, this._roll);
205
+ this._handler && this._handler.setPitchRollArr(this._tagData, this._tagDataIndex, pitch, this._roll);
184
206
  }
185
207
 
186
208
  setRoll(roll) {
187
209
  this._roll = roll;
188
- this._handler && this._handler.setPitchRollArr(this._handlerIndex, this._pitch, roll);
210
+ this._handler && this._handler.setPitchRollArr(this._tagData, this._tagDataIndex, this._pitch, roll);
189
211
  }
190
212
 
191
213
  setScale(scale) {
192
- this.scale = scale;
193
- this._handler && this._handler.setScaleArr(this._handlerIndex, scale);
214
+ this._scale = scale;
215
+ this._handler && this._handler.setScaleArr(this._tagData, this._tagDataIndex, scale);
194
216
  }
195
217
 
196
218
  getScale() {
197
- return this.scale;
219
+ return this._scale;
198
220
  }
199
221
 
200
222
  /**
@@ -212,20 +234,14 @@ class GeoObject {
212
234
  * @param {og.Vec3} color - Picking color.
213
235
  */
214
236
  setPickingColor3v(color) {
215
- this._handler && this._handler.setPickingColorArr(this._handlerIndex, color);
237
+ this._handler && this._handler.setPickingColorArr(this._tagData, this._tagDataIndex, color);
216
238
  }
217
239
 
218
240
  updateDirection() {
219
- if (this._entity && this._entity.renderNode && this._entity.renderNode.ellipsoid) {
220
- this._entity.renderNode.ellipsoid.lonLatToCartesianRes(this._lonLatAlt, this._position);
221
- }
222
241
  this._qNorthFrame = Planet.getBearingNorthRotationQuat(this._position);
223
-
224
- let qq = Quat.yRotation(this._yaw * RADIANS)
225
- .mul(this._qNorthFrame)
226
- .conjugate();
242
+ let qq = Quat.yRotation(this._yaw).mul(this._qNorthFrame).conjugate();
227
243
  this._direction = qq.mulVec3(new Vec3(0.0, 0.0, -1.0)).normalize();
228
- this._handler && this._handler.setDirectionArr(this._handlerIndex, this._direction);
244
+ this._handler && this._handler.setDirectionArr(this._tagData, this._tagDataIndex, this._direction);
229
245
  }
230
246
  }
231
247