@openglobus/og 0.11.7 → 0.12.3

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 (211) hide show
  1. package/css/og.css +5 -2
  2. package/dist/@openglobus/og.css +1 -0
  3. package/dist/@openglobus/og.esm.js +21 -0
  4. package/dist/@openglobus/og.esm.js.map +1 -0
  5. package/dist/@openglobus/og.umd.js +21 -0
  6. package/dist/@openglobus/og.umd.js.map +1 -0
  7. package/package.json +11 -11
  8. package/src/og/Globe.js +18 -6
  9. package/src/og/camera/Camera.js +70 -79
  10. package/src/og/camera/PlanetCamera.js +25 -30
  11. package/src/og/control/DebugInfo.js +2 -2
  12. package/src/og/control/EarthNavigation.js +26 -17
  13. package/src/og/control/Lighting.js +52 -73
  14. package/src/og/control/MouseNavigation.js +30 -29
  15. package/src/og/control/MouseWheelZoomControl.js +257 -0
  16. package/src/og/control/Sun.js +3 -3
  17. package/src/og/control/index.js +2 -0
  18. package/src/og/control/visibleExtent/Segment.js +1862 -0
  19. package/src/og/control/visibleExtent/VisibleExtent.js +80 -0
  20. package/src/og/control/visibleExtent/drawnode.js +751 -0
  21. package/src/og/entity/BaseBillboard.js +9 -9
  22. package/src/og/entity/Entity.js +742 -742
  23. package/src/og/entity/GeoObjectHandler.js +138 -134
  24. package/src/og/entity/Label.js +7 -7
  25. package/src/og/entity/LabelHandler.js +2 -1
  26. package/src/og/layer/CanvasTiles.js +8 -12
  27. package/src/og/layer/GeoImage.js +2 -10
  28. package/src/og/layer/GeoTexture2d.js +2 -10
  29. package/src/og/layer/GeoVideo.js +2 -10
  30. package/src/og/layer/KML.js +19 -12
  31. package/src/og/layer/Layer.js +4 -23
  32. package/src/og/layer/WMS.js +0 -2
  33. package/src/og/layer/XYZ.js +31 -33
  34. package/src/og/math/Vec3.js +18 -2
  35. package/src/og/quadTree/Node.js +48 -93
  36. package/src/og/quadTree/quadTree.js +1 -1
  37. package/src/og/renderer/Renderer.js +69 -96
  38. package/src/og/renderer/RendererEvents.js +3 -1
  39. package/src/og/scene/Planet.js +171 -173
  40. package/src/og/segment/Segment.js +99 -268
  41. package/src/og/segment/Slice.js +45 -0
  42. package/src/og/shaders/drawnode.js +171 -350
  43. package/src/og/shaders/geoObject.js +15 -6
  44. package/src/og/terrain/EmptyTerrain.js +3 -2
  45. package/src/og/terrain/GlobusTerrain.js +2 -0
  46. package/src/og/utils/GeoImageCreator.js +5 -1
  47. package/src/og/utils/Loader.js +1 -1
  48. package/src/og/utils/PlainSegmentWorker.js +0 -13
  49. package/src/og/webgl/Handler.js +14 -10
  50. package/types/Clock.d.ts +94 -0
  51. package/types/Deferred.d.ts +6 -0
  52. package/types/Events.d.ts +77 -0
  53. package/types/Extent.d.ts +166 -0
  54. package/types/Globe.d.ts +85 -0
  55. package/types/ImageCanvas.d.ts +123 -0
  56. package/types/Lock.d.ts +12 -0
  57. package/types/LonLat.d.ts +108 -0
  58. package/types/Popup.d.ts +42 -0
  59. package/types/QueueArray.d.ts +19 -0
  60. package/types/Rectangle.d.ts +80 -0
  61. package/types/Stack.d.ts +19 -0
  62. package/types/ajax.d.ts +24 -0
  63. package/types/arial.d.ts +48 -0
  64. package/types/astro/astro.d.ts +38 -0
  65. package/types/astro/earth.d.ts +7 -0
  66. package/types/astro/jd.d.ts +254 -0
  67. package/types/bv/Box.d.ts +30 -0
  68. package/types/bv/Sphere.d.ts +38 -0
  69. package/types/bv/index.d.ts +3 -0
  70. package/types/camera/Camera.d.ts +312 -0
  71. package/types/camera/Frustum.d.ts +133 -0
  72. package/types/camera/PlanetCamera.d.ts +219 -0
  73. package/types/camera/index.d.ts +3 -0
  74. package/types/cons.d.ts +40 -0
  75. package/types/control/CompassButton.d.ts +17 -0
  76. package/types/control/Control.d.ts +104 -0
  77. package/types/control/DebugInfo.d.ts +15 -0
  78. package/types/control/EarthCoordinates.d.ts +47 -0
  79. package/types/control/EarthNavigation.d.ts +43 -0
  80. package/types/control/GeoImageDragControl.d.ts +6 -0
  81. package/types/control/KeyboardNavigation.d.ts +21 -0
  82. package/types/control/LayerSwitcher.d.ts +21 -0
  83. package/types/control/Lighting.d.ts +16 -0
  84. package/types/control/MouseNavigation.d.ts +48 -0
  85. package/types/control/MouseWheelZoomControl.d.ts +45 -0
  86. package/types/control/ScaleControl.d.ts +22 -0
  87. package/types/control/ShowFps.d.ts +11 -0
  88. package/types/control/SimpleNavigation.d.ts +25 -0
  89. package/types/control/Sun.d.ts +50 -0
  90. package/types/control/ToggleWireframe.d.ts +12 -0
  91. package/types/control/TouchNavigation.d.ts +48 -0
  92. package/types/control/ZoomControl.d.ts +27 -0
  93. package/types/control/index.d.ts +18 -0
  94. package/types/ellipsoid/Ellipsoid.d.ts +146 -0
  95. package/types/ellipsoid/index.d.ts +3 -0
  96. package/types/ellipsoid/wgs84.d.ts +6 -0
  97. package/types/entity/BaseBillboard.d.ts +215 -0
  98. package/types/entity/Billboard.d.ts +94 -0
  99. package/types/entity/BillboardHandler.d.ts +79 -0
  100. package/types/entity/Entity.d.ts +348 -0
  101. package/types/entity/EntityCollection.d.ts +317 -0
  102. package/types/entity/GeoObject.d.ts +111 -0
  103. package/types/entity/GeoObjectHandler.d.ts +81 -0
  104. package/types/entity/Geometry.d.ts +74 -0
  105. package/types/entity/GeometryHandler.d.ts +76 -0
  106. package/types/entity/Label.d.ts +189 -0
  107. package/types/entity/LabelHandler.d.ts +31 -0
  108. package/types/entity/LabelWorker.d.ts +11 -0
  109. package/types/entity/PointCloud.d.ts +174 -0
  110. package/types/entity/PointCloudHandler.d.ts +38 -0
  111. package/types/entity/Polyline.d.ts +306 -0
  112. package/types/entity/PolylineHandler.d.ts +18 -0
  113. package/types/entity/Ray.d.ts +124 -0
  114. package/types/entity/RayHandler.d.ts +67 -0
  115. package/types/entity/ShapeHandler.d.ts +22 -0
  116. package/types/entity/Strip.d.ts +119 -0
  117. package/types/entity/StripHandler.d.ts +38 -0
  118. package/types/entity/index.d.ts +8 -0
  119. package/types/index.core.d.ts +65 -0
  120. package/types/index.d.ts +45 -0
  121. package/types/index.webgl.d.ts +7 -0
  122. package/types/input/KeyboardHandler.d.ts +10 -0
  123. package/types/input/MouseHandler.d.ts +5 -0
  124. package/types/input/TouchHandler.d.ts +5 -0
  125. package/types/input/input.d.ts +34 -0
  126. package/types/layer/BaseGeoImage.d.ts +94 -0
  127. package/types/layer/CanvasTiles.d.ts +67 -0
  128. package/types/layer/GeoImage.d.ts +52 -0
  129. package/types/layer/GeoTexture2d.d.ts +8 -0
  130. package/types/layer/GeoVideo.d.ts +55 -0
  131. package/types/layer/KML.d.ts +68 -0
  132. package/types/layer/Layer.d.ts +310 -0
  133. package/types/layer/Material.d.ts +45 -0
  134. package/types/layer/Vector.d.ts +208 -0
  135. package/types/layer/WMS.d.ts +61 -0
  136. package/types/layer/XYZ.d.ts +119 -0
  137. package/types/layer/index.d.ts +10 -0
  138. package/types/light/LightSource.d.ts +178 -0
  139. package/types/math/Line2.d.ts +11 -0
  140. package/types/math/Line3.d.ts +10 -0
  141. package/types/math/Mat3.d.ts +65 -0
  142. package/types/math/Mat4.d.ts +176 -0
  143. package/types/math/Plane.d.ts +18 -0
  144. package/types/math/Quat.d.ts +379 -0
  145. package/types/math/Ray.d.ts +82 -0
  146. package/types/math/Vec2.d.ts +309 -0
  147. package/types/math/Vec3.d.ts +467 -0
  148. package/types/math/Vec4.d.ts +162 -0
  149. package/types/math/coder.d.ts +43 -0
  150. package/types/math/index.d.ts +11 -0
  151. package/types/math.d.ts +261 -0
  152. package/types/mercator.d.ts +92 -0
  153. package/types/proj/EPSG3857.d.ts +6 -0
  154. package/types/proj/EPSG4326.d.ts +6 -0
  155. package/types/proj/Proj.d.ts +42 -0
  156. package/types/quadTree/EntityCollectionNode.d.ts +34 -0
  157. package/types/quadTree/Node.d.ts +60 -0
  158. package/types/quadTree/quadTree.d.ts +40 -0
  159. package/types/renderer/Renderer.d.ts +290 -0
  160. package/types/renderer/RendererEvents.d.ts +237 -0
  161. package/types/res/images.d.ts +3 -0
  162. package/types/scene/Axes.d.ts +11 -0
  163. package/types/scene/BaseNode.d.ts +60 -0
  164. package/types/scene/Planet.d.ts +576 -0
  165. package/types/scene/RenderNode.d.ts +142 -0
  166. package/types/scene/SkyBox.d.ts +10 -0
  167. package/types/scene/index.d.ts +4 -0
  168. package/types/segment/Segment.d.ts +275 -0
  169. package/types/segment/SegmentLonLat.d.ts +17 -0
  170. package/types/segment/Slice.d.ts +10 -0
  171. package/types/segment/segmentHelper.d.ts +13 -0
  172. package/types/shaders/billboard.d.ts +3 -0
  173. package/types/shaders/depth.d.ts +2 -0
  174. package/types/shaders/drawnode.d.ts +7 -0
  175. package/types/shaders/geoObject.d.ts +3 -0
  176. package/types/shaders/label.d.ts +4 -0
  177. package/types/shaders/pointCloud.d.ts +2 -0
  178. package/types/shaders/polyline.d.ts +3 -0
  179. package/types/shaders/ray.d.ts +2 -0
  180. package/types/shaders/screenFrame.d.ts +2 -0
  181. package/types/shaders/shape.d.ts +4 -0
  182. package/types/shaders/skybox.d.ts +2 -0
  183. package/types/shaders/toneMapping.d.ts +2 -0
  184. package/types/shapes/BaseShape.d.ts +250 -0
  185. package/types/shapes/Sphere.d.ts +41 -0
  186. package/types/terrain/BilTerrain.d.ts +7 -0
  187. package/types/terrain/EmptyTerrain.d.ts +73 -0
  188. package/types/terrain/Geoid.d.ts +26 -0
  189. package/types/terrain/GlobusTerrain.d.ts +116 -0
  190. package/types/terrain/MapboxTerrain.d.ts +7 -0
  191. package/types/terrain/index.d.ts +5 -0
  192. package/types/utils/FontAtlas.d.ts +15 -0
  193. package/types/utils/GeoImageCreator.d.ts +30 -0
  194. package/types/utils/ImagesCacheManager.d.ts +10 -0
  195. package/types/utils/Loader.d.ts +25 -0
  196. package/types/utils/NormalMapCreator.d.ts +39 -0
  197. package/types/utils/PlainSegmentWorker.d.ts +10 -0
  198. package/types/utils/TerrainWorker.d.ts +9 -0
  199. package/types/utils/TextureAtlas.d.ts +111 -0
  200. package/types/utils/VectorTileCreator.d.ts +16 -0
  201. package/types/utils/colorTable.d.ts +143 -0
  202. package/types/utils/earcut.d.ts +6 -0
  203. package/types/utils/shared.d.ts +231 -0
  204. package/types/webgl/Framebuffer.d.ts +135 -0
  205. package/types/webgl/Handler.d.ts +417 -0
  206. package/types/webgl/Multisample.d.ts +89 -0
  207. package/types/webgl/Program.d.ts +161 -0
  208. package/types/webgl/ProgramController.d.ts +89 -0
  209. package/types/webgl/callbacks.d.ts +1 -0
  210. package/types/webgl/index.d.ts +6 -0
  211. package/types/webgl/types.d.ts +2 -0
@@ -14,7 +14,8 @@ const VERTEX_BUFFER = 0,
14
14
  DIRECTION_BUFFER = 5,
15
15
  PITCH_ROLL_BUFFER = 6,
16
16
  SIZE_BUFFER = 7,
17
- PICKINGCOLOR_BUFFER = 8;
17
+ PICKINGCOLOR_BUFFER = 8,
18
+ VISIBLE_BUFFER = 9;
18
19
 
19
20
  const setParametersToArray = (arr = [], index = 0, length, itemSize, ...params) => {
20
21
  const currIndex = index * length;
@@ -48,6 +49,7 @@ class GeoObjectHandler {
48
49
  this._normalsArr = [[]];
49
50
  this._indicesArr = [[]];
50
51
  this._pickingColorArr = [[]];
52
+ this._vehicleVisibleArr = [[]];
51
53
 
52
54
  this._pitchRollBuffer = [];
53
55
  this._sizeBuffer = [];
@@ -59,6 +61,7 @@ class GeoObjectHandler {
59
61
  this._normalsBuffer = [];
60
62
  this._indicesBuffer = [];
61
63
  this._pickingColorBuffer = [];
64
+ this._vehicleVisibleBuffer = [];
62
65
 
63
66
  this.__staticId = GeoObjectHandler._staticCounter++;
64
67
  this._buffersUpdateCallbacks = [];
@@ -71,6 +74,7 @@ class GeoObjectHandler {
71
74
  this._buffersUpdateCallbacks[VERTEX_BUFFER] = this.createVertexBuffer;
72
75
  this._buffersUpdateCallbacks[SIZE_BUFFER] = this.createSizeBuffer;
73
76
  this._buffersUpdateCallbacks[PITCH_ROLL_BUFFER] = this.createPitchRollBuffer;
77
+ this._buffersUpdateCallbacks[VISIBLE_BUFFER] = this.createVisibleBuffer;
74
78
 
75
79
  this._changedBuffers = new Array(this._buffersUpdateCallbacks.length);
76
80
 
@@ -87,7 +91,7 @@ class GeoObjectHandler {
87
91
  for (let i = 0, len = this._vertexArr.length; i < len; i++) {
88
92
  this._vertexBuffer && h.gl.deleteBuffer(this._vertexBuffer[i]);
89
93
  this._vertexArr[i] = makeArrayTyped(this._vertexArr[i]);
90
- this._vertexBuffer[i] = h.createArrayBuffer(this._vertexArr[i], 3, len / 3);
94
+ this._vertexBuffer[i] = h.createArrayBuffer(this._vertexArr[i], 3, this._vertexArr[i].length / 3);
91
95
  }
92
96
  }
93
97
 
@@ -96,7 +100,16 @@ class GeoObjectHandler {
96
100
  for (let i = 0, len = this._pitchRollArr.length; i < len; i++) {
97
101
  this._pitchRollBuffer && h.gl.deleteBuffer(this._pitchRollBuffer[i]);
98
102
  this._pitchRollArr[i] = makeArrayTyped(this._pitchRollArr[i]);
99
- this._pitchRollBuffer[i] = h.createArrayBuffer(this._pitchRollArr[i], 2, len / 2);
103
+ this._pitchRollBuffer[i] = h.createArrayBuffer(this._pitchRollArr[i], 2, this._pitchRollArr[i].length / 2);
104
+ }
105
+ }
106
+
107
+ createVisibleBuffer() {
108
+ const h = this._renderer.handler;
109
+ for (let i = 0, len = this._vehicleVisibleArr.length; i < len; i++) {
110
+ this._vehicleVisibleBuffer && h.gl.deleteBuffer(this._vehicleVisibleBuffer[i]);
111
+ this._vehicleVisibleArr[i] = makeArrayTyped(this._vehicleVisibleArr[i]);
112
+ this._vehicleVisibleBuffer[i] = h.createArrayBuffer(this._vehicleVisibleArr[i], 1, this._vehicleVisibleArr[i].length);
100
113
  }
101
114
  }
102
115
 
@@ -105,7 +118,7 @@ class GeoObjectHandler {
105
118
  for (let i = 0, len = this._sizeArr.length; i < len; i++) {
106
119
  this._sizeBuffer && h.gl.deleteBuffer(this._sizeBuffer[i]);
107
120
  this._sizeArr[i] = makeArrayTyped(this._sizeArr[i]);
108
- this._sizeBuffer[i] = h.createArrayBuffer(this._sizeArr[i], 1, len);
121
+ this._sizeBuffer[i] = h.createArrayBuffer(this._sizeArr[i], 1, this._sizeArr[i].length);
109
122
  }
110
123
  }
111
124
 
@@ -114,14 +127,10 @@ class GeoObjectHandler {
114
127
  for (let i = 0, len = this._positionHighArr.length; i < len; i++) {
115
128
  this._positionHighBuffer && h.gl.deleteBuffer(this._positionHighBuffer[i]);
116
129
  this._positionHighArr[i] = makeArrayTyped(this._positionHighArr[i]);
117
- this._positionHighBuffer[i] = h.createArrayBuffer(this._positionHighArr[i], 3, len / 3);
130
+ this._positionHighBuffer[i] = h.createArrayBuffer(this._positionHighArr[i], 3, this._positionHighArr[i].length / 3);
118
131
  this._positionLowBuffer && h.gl.deleteBuffer(this._positionLowBuffer[i]);
119
132
  this._positionLowArr[i] = makeArrayTyped(this._positionLowArr[i]);
120
- this._positionLowBuffer[i] = h.createArrayBuffer(
121
- this._positionLowArr[i],
122
- 3,
123
- this._positionLowArr[i].length / 3
124
- );
133
+ this._positionLowBuffer[i] = h.createArrayBuffer(this._positionLowArr[i], 3, this._positionLowArr[i].length / 3);
125
134
  }
126
135
  }
127
136
 
@@ -130,7 +139,7 @@ class GeoObjectHandler {
130
139
  for (let i = 0, len = this._rgbaArr.length; i < len; i++) {
131
140
  this._rgbaBuffer && h.gl.deleteBuffer(this._rgbaBuffer[i]);
132
141
  this._rgbaArr[i] = makeArrayTyped(this._rgbaArr[i]);
133
- this._rgbaBuffer[i] = h.createArrayBuffer(this._rgbaArr[i], 4, len / 4);
142
+ this._rgbaBuffer[i] = h.createArrayBuffer(this._rgbaArr[i], 4, this._rgbaArr[i].length / 4);
134
143
  }
135
144
  }
136
145
 
@@ -139,7 +148,7 @@ class GeoObjectHandler {
139
148
  for (let i = 0, len = this._directionArr.length; i < len; i++) {
140
149
  this._directionBuffer && h.gl.deleteBuffer(this._directionBuffer[i]);
141
150
  this._directionArr[i] = makeArrayTyped(this._directionArr[i]);
142
- this._directionBuffer[i] = h.createArrayBuffer(this._directionArr[i], 3, len / 3);
151
+ this._directionBuffer[i] = h.createArrayBuffer(this._directionArr[i], 3, this._directionArr[i].length / 3);
143
152
  }
144
153
  }
145
154
 
@@ -148,7 +157,7 @@ class GeoObjectHandler {
148
157
  for (let i = 0, len = this._normalsArr.length; i < len; i++) {
149
158
  this._normalsBuffer && h.gl.deleteBuffer(this._normalsBuffer[i]);
150
159
  this._normalsArr[i] = makeArrayTyped(this._normalsArr[i]);
151
- this._normalsBuffer[i] = h.createArrayBuffer(this._normalsArr[i], 3, len / 3);
160
+ this._normalsBuffer[i] = h.createArrayBuffer(this._normalsArr[i], 3, this._normalsArr[i].length / 3);
152
161
  }
153
162
  }
154
163
 
@@ -157,11 +166,7 @@ class GeoObjectHandler {
157
166
  for (let i = 0, len = this._indicesArr.length; i < len; i++) {
158
167
  this._indicesBuffer && h.gl.deleteBuffer(this._indicesBuffer[i]);
159
168
  this._indicesArr[i] = makeArrayTyped(this._indicesArr[i], Uint16Array);
160
- this._indicesBuffer[i] = h.createElementArrayBuffer(
161
- this._indicesArr[i],
162
- 1,
163
- this._indicesArr[i].length
164
- );
169
+ this._indicesBuffer[i] = h.createElementArrayBuffer(this._indicesArr[i], 1, this._indicesArr[i].length);
165
170
  }
166
171
  }
167
172
 
@@ -170,7 +175,7 @@ class GeoObjectHandler {
170
175
  for (let i = 0, len = this._pickingColorArr.length; i < len; i++) {
171
176
  this._pickingColorBuffer && h.gl.deleteBuffer(this._pickingColorBuffer[i]);
172
177
  this._pickingColorArr[i] = makeArrayTyped(this._pickingColorArr[i]);
173
- this._pickingColorBuffer[i] = h.createArrayBuffer(this._pickingColorArr[i], 3, len / 3);
178
+ this._pickingColorBuffer[i] = h.createArrayBuffer(this._pickingColorArr[i], 3, this._pickingColorArr[i].length / 3);
174
179
  }
175
180
  }
176
181
 
@@ -215,14 +220,15 @@ class GeoObjectHandler {
215
220
  if (!alreadyAdded) {
216
221
  this._instancedTags.set(tag, {
217
222
  iCounts: 1,
223
+ maxIndex: Math.max(...geoObject._indices),
218
224
  index: this._instancedTags.size
219
225
  });
220
226
  } else {
221
227
  const prevState = this._instancedTags.get(tag),
222
228
  nextCount = prevState.iCounts + 1;
223
229
  this._instancedTags.set(tag, {
224
- iCounts: nextCount,
225
- index: prevState.index
230
+ ...prevState,
231
+ iCounts: nextCount
226
232
  });
227
233
  }
228
234
  const tagData = this._instancedTags.get(tag),
@@ -232,8 +238,9 @@ class GeoObjectHandler {
232
238
  * mark object by index for recalc indices array
233
239
  */
234
240
  geoObject._tagIndex = tagData.iCounts - 1;
235
- if (geoObject._visibility) {
236
- if (!alreadyAdded) {
241
+
242
+ if (!this._vertexArr[ti] || this._vertexArr[ti].length !== geoObject._vertices.length) {
243
+
237
244
  this._vertexArr[ti] = concatArrays(
238
245
  this._vertexArr[ti],
239
246
  setParametersToArray(
@@ -256,12 +263,11 @@ class GeoObjectHandler {
256
263
  )
257
264
  );
258
265
  }
259
- } else {
260
- this._vertexArr[ti] = concatArrays(
261
- this._vertexArr[ti],
262
- setParametersToArray([], 0, geoObject._verticesCount * itemSize, 1, 0)
263
- );
264
- }
266
+ this._vehicleVisibleArr[ti] = concatArrays(
267
+ this._vehicleVisibleArr[ti],
268
+ setParametersToArray([], 0, 1, 1, geoObject._visibility ? 1 : 0)
269
+ );
270
+
265
271
  let x = geoObject._positionHigh.x,
266
272
  y = geoObject._positionHigh.y,
267
273
  z = geoObject._positionHigh.z,
@@ -306,8 +312,6 @@ class GeoObjectHandler {
306
312
  setParametersToArray([], 0, itemSize, itemSize, x, y, z, w)
307
313
  );
308
314
 
309
- this._indicesArr[ti] = concatArrays(this._indicesArr[ti], geoObject._indices);
310
-
311
315
  x = geoObject._pitch;
312
316
  y = geoObject._roll;
313
317
 
@@ -324,7 +328,7 @@ class GeoObjectHandler {
324
328
  this._sizeArr[ti],
325
329
  setParametersToArray([], 0, itemSize, itemSize, geoObject.scale)
326
330
  );
327
- this._recalculateIndices();
331
+ this._addIndices(geoObject);
328
332
  }
329
333
 
330
334
  _displayPASS() {
@@ -357,51 +361,26 @@ class GeoObjectHandler {
357
361
  ti = tagData.index;
358
362
 
359
363
  gl.bindBuffer(gl.ARRAY_BUFFER, this._normalsBuffer[ti]);
360
- gl.vertexAttribPointer(
361
- a.aVertexNormal,
362
- this._normalsBuffer[ti].itemSize,
363
- gl.FLOAT,
364
- false,
365
- 0,
366
- 0
367
- );
364
+ gl.vertexAttribPointer(a.aVertexNormal, this._normalsBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
368
365
 
369
366
  gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer[ti]);
370
- gl.vertexAttribPointer(
371
- a.aVertexPosition,
372
- this._vertexBuffer[ti].itemSize,
373
- gl.FLOAT,
374
- false,
375
- 0,
376
- 0
377
- );
367
+ gl.vertexAttribPointer(a.aVertexPosition, this._vertexBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
378
368
 
379
369
  gl.bindBuffer(gl.ARRAY_BUFFER, this._directionBuffer[ti]);
380
- gl.vertexAttribPointer(
381
- a.aDirection,
382
- this._directionBuffer[ti].itemSize,
383
- gl.FLOAT,
384
- false,
385
- 0,
386
- 0
387
- );
370
+ gl.vertexAttribPointer(a.aDirection, this._directionBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
388
371
 
389
372
  gl.bindBuffer(gl.ARRAY_BUFFER, this._sizeBuffer[ti]);
390
373
  gl.vertexAttribPointer(a.aScale, this._sizeBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
391
374
 
392
375
  gl.bindBuffer(gl.ARRAY_BUFFER, this._pitchRollBuffer[ti]);
393
- gl.vertexAttribPointer(
394
- a.aPitchRoll,
395
- this._pitchRollBuffer[ti].itemSize,
396
- gl.FLOAT,
397
- false,
398
- 0,
399
- 0
400
- );
376
+ gl.vertexAttribPointer(a.aPitchRoll, this._pitchRollBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
401
377
 
402
378
  gl.bindBuffer(gl.ARRAY_BUFFER, this._rgbaBuffer[ti]);
403
379
  gl.vertexAttribPointer(a.aColor, this._rgbaBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
404
380
 
381
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._vehicleVisibleBuffer[ti]);
382
+ gl.vertexAttribPointer(a.aDispose, this._vehicleVisibleBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
383
+
405
384
  gl.bindBuffer(gl.ARRAY_BUFFER, this._positionHighBuffer[ti]);
406
385
  gl.vertexAttribPointer(
407
386
  a.aPositionHigh,
@@ -539,6 +518,9 @@ class GeoObjectHandler {
539
518
  0
540
519
  );
541
520
 
521
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._vehicleVisibleBuffer[ti]);
522
+ gl.vertexAttribPointer(a.aDispose, this._vehicleVisibleBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
523
+
542
524
  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indicesBuffer[ti]);
543
525
 
544
526
  if (tagData.iCounts) {
@@ -561,7 +543,7 @@ class GeoObjectHandler {
561
543
  gl.disable(gl.CULL_FACE);
562
544
  }
563
545
 
564
- _recalculateIndices() {
546
+ _recalculateIndices(startIndex) {
565
547
  const allIndices = this._indicesArr,
566
548
  goArr = this._geoObjects,
567
549
  maxIndicesByTags = new Array(this._instancedTags.size).fill(0);
@@ -590,10 +572,62 @@ class GeoObjectHandler {
590
572
  }
591
573
  }
592
574
 
593
- //todo refactor for support instancing
594
- setVertexArr(index, vertexArr) {
595
- this._vertexArr = [-0.5, 0.0, 0.5, -0.5, 0.0, -0.5, 0.5, 0.0, -0.5, 0.5, 0.0, 0.5];
596
- this._changedBuffers[VERTEX_BUFFER] = true;
575
+ _addIndices(g) {
576
+ let i = g._handlerIndex;
577
+ const allIndices = this._indicesArr,
578
+ gArr = this._geoObjects,
579
+ iLen = g._indices.length,
580
+ tagData = this._instancedTags.get(g.tag),
581
+ maxIndex = tagData.maxIndex,
582
+ ti = tagData.index;
583
+
584
+ allIndices[ti] = concatArrays(allIndices[ti], g._indices);
585
+
586
+ while (gArr[i]) {
587
+ const g = gArr[i];
588
+
589
+ if (g._tagIndex > 0) {
590
+ setParametersToArray(allIndices[ti], g._tagIndex, iLen, iLen, ...g._indices.reduce((acc, cur) => {
591
+ acc.push(cur + ((maxIndex + 1) * g._tagIndex));
592
+ return acc;
593
+ }, []));
594
+ }
595
+ i++;
596
+
597
+ }
598
+
599
+ }
600
+
601
+ _removeIndices(geoObject) {
602
+ const allIndices = this._indicesArr,
603
+ gArr = this._geoObjects,
604
+ iLen = geoObject._indices.length,
605
+ tagData = this._instancedTags.get(geoObject.tag),
606
+ maxIndex = tagData.maxIndex,
607
+ ti = tagData.index,
608
+ count = tagData.iCounts;
609
+
610
+ let i = geoObject._handlerIndex;
611
+
612
+ this._indicesArr[ti] = spliceArray(this._indicesArr[ti], geoObject._tagIndex * geoObject._indicesCount, geoObject._indicesCount);
613
+
614
+ while (gArr[i]) {
615
+ if (geoObject.tag === gArr[i].tag) {
616
+ if (count !== 0) {
617
+ const startI = (gArr[i]._tagIndex - 1) * iLen;
618
+ let stopI = startI + geoObject._indicesCount;
619
+ while (stopI > startI) {
620
+ this._indicesArr[ti][stopI - 1] = allIndices[ti][stopI - 1] - maxIndex - 1;
621
+ stopI--;
622
+ }
623
+ } else {
624
+ allIndices[ti] = geoObject._indices;
625
+ }
626
+ }
627
+ i++;
628
+
629
+ }
630
+
597
631
  }
598
632
 
599
633
  setDirectionArr(index, direction) {
@@ -606,27 +640,17 @@ class GeoObjectHandler {
606
640
  length = itemSize;
607
641
  }
608
642
 
609
- setParametersToArray(
610
- this._directionArr[ti],
611
- ob._tagIndex,
612
- length,
613
- itemSize,
614
- direction.x,
615
- direction.y,
616
- direction.z
617
- );
643
+ setParametersToArray(this._directionArr[ti], ob._tagIndex, length, itemSize, direction.x, direction.y, direction.z);
618
644
  this._changedBuffers[DIRECTION_BUFFER] = true;
619
645
  }
620
646
 
621
647
  setVisibility(index, visibility) {
622
- const ob = this.getObjectByIndex(index);
623
- let vArr;
624
- if (visibility) {
625
- vArr = ob._vertices;
626
- } else {
627
- vArr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
628
- }
629
- this.setVertexArr(index, vArr);
648
+ const ob = this.getObjectByIndex(index),
649
+ ti = this.getTagIndexByObjectIndex(index);
650
+
651
+ setParametersToArray(this._vehicleVisibleArr[ti], ob._tagIndex, 1, 1, visibility ? 1 : 0);
652
+
653
+ this._changedBuffers[VISIBLE_BUFFER] = true;
630
654
  }
631
655
 
632
656
  setPositionArr(index, positionHigh, positionLow) {
@@ -639,26 +663,10 @@ class GeoObjectHandler {
639
663
  length = itemSize;
640
664
  }
641
665
 
642
- setParametersToArray(
643
- this._positionHighArr[ti],
644
- ob._tagIndex,
645
- length,
646
- itemSize,
647
- positionHigh.x,
648
- positionHigh.y,
649
- positionHigh.z
650
- );
666
+ setParametersToArray(this._positionHighArr[ti], ob._tagIndex, length, itemSize, positionHigh.x, positionHigh.y, positionHigh.z);
651
667
 
652
668
  // Low
653
- setParametersToArray(
654
- this._positionLowArr[ti],
655
- ob._tagIndex,
656
- length,
657
- itemSize,
658
- positionLow.x,
659
- positionLow.y,
660
- positionLow.z
661
- );
669
+ setParametersToArray(this._positionLowArr[ti], ob._tagIndex, length, itemSize, positionLow.x, positionLow.y, positionLow.z);
662
670
 
663
671
  this._changedBuffers[POSITION_BUFFER] = true;
664
672
  }
@@ -673,16 +681,7 @@ class GeoObjectHandler {
673
681
  length = itemSize;
674
682
  }
675
683
 
676
- setParametersToArray(
677
- this._rgbaArr[ti],
678
- ob._tagIndex,
679
- length,
680
- itemSize,
681
- rgba.x,
682
- rgba.y,
683
- rgba.z,
684
- rgba.w
685
- );
684
+ setParametersToArray(this._rgbaArr[ti], ob._tagIndex, length, itemSize, rgba.x, rgba.y, rgba.z, rgba.w);
686
685
 
687
686
  this._changedBuffers[RGBA_BUFFER] = true;
688
687
  }
@@ -770,17 +769,19 @@ class GeoObjectHandler {
770
769
  this._normalsArr = null;
771
770
  this._indicesArr = null;
772
771
  this._pickingColorArr = null;
773
-
774
- this._pitchRollArr = new Float32Array();
775
- this._sizeArr = new Float32Array();
776
- this._vertexArr = new Float32Array();
777
- this._positionHighArr = new Float32Array();
778
- this._positionLowArr = new Float32Array();
779
- this._rgbaArr = new Float32Array();
780
- this._directionArr = new Float32Array();
781
- this._normalsArr = new Float32Array();
782
- this._indicesArr = new Uint16Array();
783
- this._pickingColorArr = new Float32Array();
772
+ this._vehicleVisibleArr = null;
773
+
774
+ this._pitchRollArr = [new Float32Array()];
775
+ this._sizeArr = [new Float32Array()];
776
+ this._vertexArr = [new Float32Array()];
777
+ this._positionHighArr = [new Float32Array()];
778
+ this._positionLowArr = [new Float32Array()];
779
+ this._rgbaArr = [new Float32Array()];
780
+ this._directionArr = [new Float32Array()];
781
+ this._normalsArr = [new Float32Array()];
782
+ this._indicesArr = [new Uint16Array()];
783
+ this._pickingColorArr = [new Float32Array()];
784
+ this._vehicleVisibleArr = [new Int8Array()];
784
785
 
785
786
  this._removeGeoObjects();
786
787
  this._deleteBuffers();
@@ -866,19 +867,20 @@ class GeoObjectHandler {
866
867
  const gi = geoObject._handlerIndex,
867
868
  tag = geoObject.tag,
868
869
  ti = this.getTagIndexByObjectIndex(gi),
869
- prevState = this._instancedTags.get(tag);
870
+ prevState = this._instancedTags.get(tag),
871
+ iCount = prevState.iCounts - 1;
870
872
 
871
873
  this._instancedTags.set(tag, {
872
- iCounts: prevState.iCounts - 1,
873
- index: prevState.index
874
+ ...prevState,
875
+ iCounts: iCount
874
876
  });
875
877
 
876
878
  this._geoObjects.splice(gi, 1);
877
879
 
878
- let i = gi * 4;
880
+ let i = geoObject._tagIndex * 4;
879
881
  this._rgbaArr[ti] = spliceArray(this._rgbaArr[ti], i, 4);
880
882
 
881
- i = gi * 3;
883
+ i = geoObject._tagIndex * 3;
882
884
  if (prevState.iCounts <= 1) {
883
885
  this._vertexArr[ti] = spliceArray(this._vertexArr[ti], 0, geoObject._verticesCount * 3);
884
886
  this._normalsArr[ti] = spliceArray(
@@ -892,14 +894,16 @@ class GeoObjectHandler {
892
894
  this._directionArr[ti] = spliceArray(this._directionArr[ti], i, 3);
893
895
  this._pickingColorArr[ti] = spliceArray(this._pickingColorArr[ti], i, 3);
894
896
 
895
- i = gi * 2;
897
+ i = geoObject._tagIndex * 2;
896
898
  this._pitchRollArr[ti] = spliceArray(this._pitchRollArr[ti], i, 2);
897
- this._indicesArr[ti] = spliceArray(this._indicesArr[ti], i, geoObject._indicesCount);
898
- i = gi * 1;
899
+ i = geoObject._tagIndex;
899
900
  this._sizeArr[ti] = spliceArray(this._sizeArr[ti], i, 1);
901
+ this._vehicleVisibleArr[ti] = spliceArray(this._vehicleVisibleArr[ti], i, 1);
902
+
903
+ this._removeIndices(geoObject);
900
904
 
901
905
  this._reindexGeoObjects(gi, tag);
902
- this._recalculateIndices();
906
+
903
907
  this.refresh();
904
908
 
905
909
  geoObject._handlerIndex = -1;
@@ -122,7 +122,7 @@ class Label extends BaseBillboard {
122
122
  */
123
123
  setText(text) {
124
124
  this._text = text.toString();
125
- if (this._isReady) {
125
+ if (this._isReady && this._handler) {
126
126
  this._handler.setText(this._handlerIndex, text, this._fontIndex, this._align);
127
127
  }
128
128
  }
@@ -143,7 +143,7 @@ class Label extends BaseBillboard {
143
143
  */
144
144
  setAlign(align) {
145
145
  this._align = STR2ALIGN[align.trim().toLowerCase()];
146
- if (this._isReady) {
146
+ if (this._isReady && this._handler) {
147
147
  this._handler.setText(this._handlerIndex, this._text, this._fontIndex, this._align);
148
148
  } else if (this._lockId !== LOCK_FREE) {
149
149
  this._lockId = LOCK_UPDATE;
@@ -186,7 +186,7 @@ class Label extends BaseBillboard {
186
186
  setSize(size) {
187
187
  if (size !== this._size) {
188
188
  this._size = size;
189
- if (this._isReady) {
189
+ if (this._isReady && this._handler) {
190
190
  this._handler.setSizeArr(this._handlerIndex, size);
191
191
  } else if (this._lockId !== LOCK_FREE) {
192
192
  this._lockId = LOCK_UPDATE;
@@ -210,7 +210,7 @@ class Label extends BaseBillboard {
210
210
  */
211
211
  setOutline(outline) {
212
212
  this._outline = outline;
213
- if (this._isReady) {
213
+ if (this._isReady && this._handler) {
214
214
  this._handler.setOutlineArr(this._handlerIndex, outline);
215
215
  } else if (this._lockId !== LOCK_FREE) {
216
216
  this._lockId = LOCK_UPDATE;
@@ -250,7 +250,7 @@ class Label extends BaseBillboard {
250
250
  this._outlineColor.y = g;
251
251
  this._outlineColor.z = b;
252
252
  this._outlineColor.w = a;
253
- if (this._isReady) {
253
+ if (this._isReady && this._handler) {
254
254
  this._handler.setOutlineColorArr(this._handlerIndex, this._outlineColor);
255
255
  } else if (this._lockId !== LOCK_FREE) {
256
256
  this._lockId = LOCK_UPDATE;
@@ -293,7 +293,7 @@ class Label extends BaseBillboard {
293
293
  setOutlineOpacity(opacity) {
294
294
  if (opacity !== this._outlineColor.w) {
295
295
  this._outlineColor.w = opacity;
296
- if (this._isReady) {
296
+ if (this._isReady && this._handler) {
297
297
  this._handler.setOutlineColorArr(this._handlerIndex, this._outlineColor);
298
298
  } else if (this._lockId !== LOCK_FREE) {
299
299
  this._lockId = LOCK_UPDATE;
@@ -323,7 +323,7 @@ class Label extends BaseBillboard {
323
323
 
324
324
  _applyFontIndex(fontIndex) {
325
325
  this._fontIndex = fontIndex;
326
- if (this._isReady) {
326
+ if (this._isReady && this._handler) {
327
327
  this._handler.setFontIndexArr(this._handlerIndex, this._fontIndex);
328
328
  this._handler.setText(this._handlerIndex, this._text, this._fontIndex, this._align);
329
329
  } else if (this._lockId !== LOCK_FREE) {
@@ -469,7 +469,8 @@ class LabelHandler extends BillboardHandler {
469
469
  this.refresh();
470
470
 
471
471
  label._handlerIndex = -1;
472
- label._handler = null;
472
+ label._handler = null;
473
+ label._isReady = false;
473
474
  }
474
475
 
475
476
  setText(index, text, fontIndex, align) {
@@ -35,7 +35,6 @@ const EVENT_NAMES = [
35
35
  * @param {String} [name="noname"] - Layer name.
36
36
  * @param {Object} options:
37
37
  * @param {number} [options.opacity=1.0] - Layer opacity.
38
- * @param {Array.<number>} [options.transparentColor=[-1,-1,-1]] - RGB color that defines transparent color. (exactly 3 entries)
39
38
  * @param {number} [options.minZoom=0] - Minimal visibility zoom level.
40
39
  * @param {number} [options.maxZoom=0] - Maximal visibility zoom level.
41
40
  * @param {string} [options.attribution] - Layer attribution that displayed in the attribution area on the screen.
@@ -99,17 +98,14 @@ class CanvasTiles extends Layer {
99
98
  * @public
100
99
  * @param {boolean} visibility - Layer visibility.
101
100
  */
102
- setVisibility(visibility) {
101
+ setVisibility(visibility) {
103
102
  if (visibility !== this._visibility) {
104
- this._visibility = visibility;
105
- if (this._isBaseLayer && visibility) {
106
- this._planet.setBaseLayer(this);
107
- } else if (!visibility) {
103
+ super.setVisibility(visibility);
104
+
105
+ if (!visibility) {
108
106
  this.abortLoading();
109
107
  }
110
- this._planet.updateVisibleLayers();
111
- this.events.dispatch(this.events.visibilitychange, this);
112
- }
108
+ }
113
109
  }
114
110
 
115
111
  /**
@@ -129,7 +125,7 @@ class CanvasTiles extends Layer {
129
125
  material.texture = seg.planet.transparentTexture;
130
126
  }
131
127
 
132
- if (this._planet.layerLock.isFree()) {
128
+ if (this._planet.layerLock.isFree() || material.segment.tileZoom < 2) {
133
129
  material.isReady = false;
134
130
  material.isLoading = true;
135
131
  if (CanvasTiles.__requestsCounter >= CanvasTiles.MAX_REQUESTS && this._counter) {
@@ -241,12 +237,12 @@ class CanvasTiles extends Layer {
241
237
  var mId = this._id;
242
238
  var psegm = material;
243
239
  while (pn.parentNode) {
240
+ pn = pn.parentNode;
241
+ psegm = pn.segment.materials[mId];
244
242
  if (psegm && psegm.isReady) {
245
243
  notEmpty = true;
246
244
  break;
247
245
  }
248
- pn = pn.parentNode;
249
- psegm = pn.segment.materials[mId];
250
246
  }
251
247
 
252
248
  if (notEmpty) {
@@ -141,14 +141,10 @@ class GeoImage extends BaseGeoImage {
141
141
  var sha = sh.attributes,
142
142
  shu = sh.uniforms;
143
143
 
144
- var tr = this.transparentColor[0],
145
- tg = this.transparentColor[1],
146
- tb = this.transparentColor[2];
147
-
148
144
  gl.disable(gl.CULL_FACE);
149
145
 
150
146
  f.bindOutputTexture(this._materialTexture);
151
- gl.clearColor(tr, tg, tb, 0.0);
147
+ gl.clearColor(0.0, 0.0, 0.0, 0.0);
152
148
  gl.clear(gl.COLOR_BUFFER_BIT);
153
149
  gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
154
150
 
@@ -189,14 +185,10 @@ class GeoImage extends BaseGeoImage {
189
185
  var sha = sh.attributes,
190
186
  shu = sh.uniforms;
191
187
 
192
- var tr = this.transparentColor[0],
193
- tg = this.transparentColor[1],
194
- tb = this.transparentColor[2];
195
-
196
188
  gl.disable(gl.CULL_FACE);
197
189
 
198
190
  f.bindOutputTexture(this._materialTexture);
199
- gl.clearColor(tr, tg, tb, 0.0);
191
+ gl.clearColor(0.0, 0.0, 0.0, 0.0);
200
192
  gl.clear(gl.COLOR_BUFFER_BIT);
201
193
  gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
202
194