@openglobus/og 0.11.6 → 0.12.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 (213) hide show
  1. package/css/og.css +5 -2
  2. package/package.json +12 -12
  3. package/src/og/Globe.js +25 -10
  4. package/src/og/Popup.js +3 -2
  5. package/src/og/camera/Camera.js +70 -79
  6. package/src/og/camera/PlanetCamera.js +33 -33
  7. package/src/og/control/DebugInfo.js +2 -2
  8. package/src/og/control/EarthNavigation.js +26 -17
  9. package/src/og/control/Lighting.js +74 -64
  10. package/src/og/control/MouseNavigation.js +30 -29
  11. package/src/og/control/MouseWheelZoomControl.js +257 -0
  12. package/src/og/control/Sun.js +3 -3
  13. package/src/og/control/index.js +2 -0
  14. package/src/og/control/visibleExtent/Segment.js +1862 -0
  15. package/src/og/control/visibleExtent/VisibleExtent.js +80 -0
  16. package/src/og/control/visibleExtent/drawnode.js +751 -0
  17. package/src/og/ellipsoid/Ellipsoid.js +1 -1
  18. package/src/og/entity/BaseBillboard.js +67 -76
  19. package/src/og/entity/BillboardHandler.js +15 -8
  20. package/src/og/entity/Entity.js +742 -742
  21. package/src/og/entity/GeoObjectHandler.js +102 -117
  22. package/src/og/entity/Label.js +45 -48
  23. package/src/og/entity/LabelHandler.js +24 -23
  24. package/src/og/entity/LabelWorker.js +21 -16
  25. package/src/og/layer/CanvasTiles.js +8 -12
  26. package/src/og/layer/GeoImage.js +2 -10
  27. package/src/og/layer/GeoTexture2d.js +2 -10
  28. package/src/og/layer/GeoVideo.js +2 -10
  29. package/src/og/layer/Layer.js +23 -32
  30. package/src/og/layer/Material.js +1 -1
  31. package/src/og/layer/WMS.js +0 -2
  32. package/src/og/layer/XYZ.js +31 -33
  33. package/src/og/math/Vec3.js +18 -2
  34. package/src/og/quadTree/Node.js +52 -111
  35. package/src/og/quadTree/quadTree.js +1 -1
  36. package/src/og/renderer/Renderer.js +85 -122
  37. package/src/og/renderer/RendererEvents.js +44 -22
  38. package/src/og/scene/Planet.js +179 -198
  39. package/src/og/segment/Segment.js +99 -268
  40. package/src/og/segment/Slice.js +45 -0
  41. package/src/og/shaders/drawnode.js +174 -360
  42. package/src/og/shaders/toneMapping.js +1 -0
  43. package/src/og/shapes/BaseShape.js +1 -1
  44. package/src/og/terrain/EmptyTerrain.js +3 -2
  45. package/src/og/terrain/GlobusTerrain.js +2 -0
  46. package/src/og/utils/FontAtlas.js +6 -2
  47. package/src/og/utils/GeoImageCreator.js +5 -1
  48. package/src/og/utils/Loader.js +1 -1
  49. package/src/og/utils/PlainSegmentWorker.js +0 -13
  50. package/src/og/utils/TextureAtlas.js +2 -2
  51. package/src/og/utils/VectorTileCreator.js +1 -3
  52. package/src/og/utils/shared.js +1 -1
  53. package/src/og/webgl/Handler.js +156 -118
  54. package/types/Clock.d.ts +0 -94
  55. package/types/Deferred.d.ts +0 -6
  56. package/types/Events.d.ts +0 -77
  57. package/types/Extent.d.ts +0 -166
  58. package/types/Globe.d.ts +0 -82
  59. package/types/ImageCanvas.d.ts +0 -123
  60. package/types/Lock.d.ts +0 -12
  61. package/types/LonLat.d.ts +0 -108
  62. package/types/Popup.d.ts +0 -42
  63. package/types/QueueArray.d.ts +0 -19
  64. package/types/Rectangle.d.ts +0 -80
  65. package/types/Stack.d.ts +0 -19
  66. package/types/ajax.d.ts +0 -24
  67. package/types/arial.d.ts +0 -48
  68. package/types/astro/astro.d.ts +0 -38
  69. package/types/astro/earth.d.ts +0 -7
  70. package/types/astro/jd.d.ts +0 -254
  71. package/types/bv/Box.d.ts +0 -30
  72. package/types/bv/Sphere.d.ts +0 -38
  73. package/types/bv/index.d.ts +0 -3
  74. package/types/camera/Camera.d.ts +0 -312
  75. package/types/camera/Frustum.d.ts +0 -133
  76. package/types/camera/PlanetCamera.d.ts +0 -218
  77. package/types/camera/index.d.ts +0 -3
  78. package/types/cons.d.ts +0 -40
  79. package/types/control/CompassButton.d.ts +0 -17
  80. package/types/control/Control.d.ts +0 -104
  81. package/types/control/DebugInfo.d.ts +0 -15
  82. package/types/control/EarthCoordinates.d.ts +0 -47
  83. package/types/control/EarthNavigation.d.ts +0 -42
  84. package/types/control/GeoImageDragControl.d.ts +0 -6
  85. package/types/control/KeyboardNavigation.d.ts +0 -21
  86. package/types/control/LayerSwitcher.d.ts +0 -21
  87. package/types/control/Lighting.d.ts +0 -16
  88. package/types/control/MouseNavigation.d.ts +0 -47
  89. package/types/control/ScaleControl.d.ts +0 -22
  90. package/types/control/ShowFps.d.ts +0 -11
  91. package/types/control/SimpleNavigation.d.ts +0 -25
  92. package/types/control/Sun.d.ts +0 -50
  93. package/types/control/ToggleWireframe.d.ts +0 -12
  94. package/types/control/TouchNavigation.d.ts +0 -48
  95. package/types/control/ZoomControl.d.ts +0 -27
  96. package/types/control/index.d.ts +0 -17
  97. package/types/ellipsoid/Ellipsoid.d.ts +0 -146
  98. package/types/ellipsoid/index.d.ts +0 -3
  99. package/types/ellipsoid/wgs84.d.ts +0 -6
  100. package/types/entity/BaseBillboard.d.ts +0 -215
  101. package/types/entity/Billboard.d.ts +0 -94
  102. package/types/entity/BillboardHandler.d.ts +0 -78
  103. package/types/entity/Entity.d.ts +0 -348
  104. package/types/entity/EntityCollection.d.ts +0 -317
  105. package/types/entity/GeoObject.d.ts +0 -111
  106. package/types/entity/GeoObjectHandler.d.ts +0 -77
  107. package/types/entity/Geometry.d.ts +0 -74
  108. package/types/entity/GeometryHandler.d.ts +0 -76
  109. package/types/entity/Label.d.ts +0 -189
  110. package/types/entity/LabelHandler.d.ts +0 -31
  111. package/types/entity/LabelWorker.d.ts +0 -9
  112. package/types/entity/PointCloud.d.ts +0 -174
  113. package/types/entity/PointCloudHandler.d.ts +0 -38
  114. package/types/entity/Polyline.d.ts +0 -306
  115. package/types/entity/PolylineHandler.d.ts +0 -18
  116. package/types/entity/Ray.d.ts +0 -124
  117. package/types/entity/RayHandler.d.ts +0 -67
  118. package/types/entity/ShapeHandler.d.ts +0 -22
  119. package/types/entity/Strip.d.ts +0 -119
  120. package/types/entity/StripHandler.d.ts +0 -38
  121. package/types/entity/index.d.ts +0 -8
  122. package/types/index.core.d.ts +0 -65
  123. package/types/index.d.ts +0 -45
  124. package/types/index.webgl.d.ts +0 -7
  125. package/types/input/KeyboardHandler.d.ts +0 -10
  126. package/types/input/MouseHandler.d.ts +0 -5
  127. package/types/input/TouchHandler.d.ts +0 -5
  128. package/types/input/input.d.ts +0 -34
  129. package/types/layer/BaseGeoImage.d.ts +0 -94
  130. package/types/layer/CanvasTiles.d.ts +0 -68
  131. package/types/layer/GeoImage.d.ts +0 -52
  132. package/types/layer/GeoTexture2d.d.ts +0 -8
  133. package/types/layer/GeoVideo.d.ts +0 -55
  134. package/types/layer/KML.d.ts +0 -63
  135. package/types/layer/Layer.d.ts +0 -326
  136. package/types/layer/Material.d.ts +0 -45
  137. package/types/layer/Vector.d.ts +0 -208
  138. package/types/layer/WMS.d.ts +0 -63
  139. package/types/layer/XYZ.d.ts +0 -120
  140. package/types/layer/index.d.ts +0 -10
  141. package/types/light/LightSource.d.ts +0 -178
  142. package/types/math/Line2.d.ts +0 -11
  143. package/types/math/Line3.d.ts +0 -10
  144. package/types/math/Mat3.d.ts +0 -65
  145. package/types/math/Mat4.d.ts +0 -176
  146. package/types/math/Plane.d.ts +0 -18
  147. package/types/math/Quat.d.ts +0 -379
  148. package/types/math/Ray.d.ts +0 -82
  149. package/types/math/Vec2.d.ts +0 -309
  150. package/types/math/Vec3.d.ts +0 -460
  151. package/types/math/Vec4.d.ts +0 -162
  152. package/types/math/coder.d.ts +0 -43
  153. package/types/math/index.d.ts +0 -11
  154. package/types/math.d.ts +0 -261
  155. package/types/mercator.d.ts +0 -92
  156. package/types/proj/EPSG3857.d.ts +0 -6
  157. package/types/proj/EPSG4326.d.ts +0 -6
  158. package/types/proj/Proj.d.ts +0 -42
  159. package/types/quadTree/EntityCollectionNode.d.ts +0 -34
  160. package/types/quadTree/Node.d.ts +0 -61
  161. package/types/quadTree/quadTree.d.ts +0 -40
  162. package/types/renderer/Renderer.d.ts +0 -300
  163. package/types/renderer/RendererEvents.d.ts +0 -233
  164. package/types/res/images.d.ts +0 -3
  165. package/types/scene/Axes.d.ts +0 -11
  166. package/types/scene/BaseNode.d.ts +0 -60
  167. package/types/scene/Planet.d.ts +0 -577
  168. package/types/scene/RenderNode.d.ts +0 -142
  169. package/types/scene/SkyBox.d.ts +0 -10
  170. package/types/scene/index.d.ts +0 -4
  171. package/types/segment/Segment.d.ts +0 -279
  172. package/types/segment/SegmentLonLat.d.ts +0 -16
  173. package/types/segment/segmentHelper.d.ts +0 -13
  174. package/types/shaders/billboard.d.ts +0 -3
  175. package/types/shaders/depth.d.ts +0 -2
  176. package/types/shaders/drawnode.d.ts +0 -7
  177. package/types/shaders/geoObject.d.ts +0 -3
  178. package/types/shaders/label.d.ts +0 -4
  179. package/types/shaders/pointCloud.d.ts +0 -2
  180. package/types/shaders/polyline.d.ts +0 -3
  181. package/types/shaders/ray.d.ts +0 -2
  182. package/types/shaders/screenFrame.d.ts +0 -2
  183. package/types/shaders/shape.d.ts +0 -4
  184. package/types/shaders/skybox.d.ts +0 -2
  185. package/types/shaders/toneMapping.d.ts +0 -2
  186. package/types/shapes/BaseShape.d.ts +0 -250
  187. package/types/shapes/Sphere.d.ts +0 -41
  188. package/types/terrain/BilTerrain.d.ts +0 -7
  189. package/types/terrain/EmptyTerrain.d.ts +0 -72
  190. package/types/terrain/Geoid.d.ts +0 -26
  191. package/types/terrain/GlobusTerrain.d.ts +0 -116
  192. package/types/terrain/MapboxTerrain.d.ts +0 -7
  193. package/types/terrain/index.d.ts +0 -5
  194. package/types/utils/FontAtlas.d.ts +0 -14
  195. package/types/utils/GeoImageCreator.d.ts +0 -30
  196. package/types/utils/ImagesCacheManager.d.ts +0 -10
  197. package/types/utils/Loader.d.ts +0 -25
  198. package/types/utils/NormalMapCreator.d.ts +0 -39
  199. package/types/utils/PlainSegmentWorker.d.ts +0 -10
  200. package/types/utils/TerrainWorker.d.ts +0 -9
  201. package/types/utils/TextureAtlas.d.ts +0 -111
  202. package/types/utils/VectorTileCreator.d.ts +0 -16
  203. package/types/utils/colorTable.d.ts +0 -143
  204. package/types/utils/earcut.d.ts +0 -6
  205. package/types/utils/shared.d.ts +0 -231
  206. package/types/webgl/Framebuffer.d.ts +0 -135
  207. package/types/webgl/Handler.d.ts +0 -397
  208. package/types/webgl/Multisample.d.ts +0 -89
  209. package/types/webgl/Program.d.ts +0 -161
  210. package/types/webgl/ProgramController.d.ts +0 -89
  211. package/types/webgl/callbacks.d.ts +0 -1
  212. package/types/webgl/index.d.ts +0 -6
  213. package/types/webgl/types.d.ts +0 -2
@@ -87,7 +87,7 @@ class GeoObjectHandler {
87
87
  for (let i = 0, len = this._vertexArr.length; i < len; i++) {
88
88
  this._vertexBuffer && h.gl.deleteBuffer(this._vertexBuffer[i]);
89
89
  this._vertexArr[i] = makeArrayTyped(this._vertexArr[i]);
90
- this._vertexBuffer[i] = h.createArrayBuffer(this._vertexArr[i], 3, len / 3);
90
+ this._vertexBuffer[i] = h.createArrayBuffer(this._vertexArr[i], 3, this._vertexArr[i].length / 3);
91
91
  }
92
92
  }
93
93
 
@@ -96,7 +96,7 @@ class GeoObjectHandler {
96
96
  for (let i = 0, len = this._pitchRollArr.length; i < len; i++) {
97
97
  this._pitchRollBuffer && h.gl.deleteBuffer(this._pitchRollBuffer[i]);
98
98
  this._pitchRollArr[i] = makeArrayTyped(this._pitchRollArr[i]);
99
- this._pitchRollBuffer[i] = h.createArrayBuffer(this._pitchRollArr[i], 2, len / 2);
99
+ this._pitchRollBuffer[i] = h.createArrayBuffer(this._pitchRollArr[i], 2, this._pitchRollArr[i].length / 2);
100
100
  }
101
101
  }
102
102
 
@@ -105,7 +105,7 @@ class GeoObjectHandler {
105
105
  for (let i = 0, len = this._sizeArr.length; i < len; i++) {
106
106
  this._sizeBuffer && h.gl.deleteBuffer(this._sizeBuffer[i]);
107
107
  this._sizeArr[i] = makeArrayTyped(this._sizeArr[i]);
108
- this._sizeBuffer[i] = h.createArrayBuffer(this._sizeArr[i], 1, len);
108
+ this._sizeBuffer[i] = h.createArrayBuffer(this._sizeArr[i], 1, this._sizeArr[i].length);
109
109
  }
110
110
  }
111
111
 
@@ -114,14 +114,10 @@ class GeoObjectHandler {
114
114
  for (let i = 0, len = this._positionHighArr.length; i < len; i++) {
115
115
  this._positionHighBuffer && h.gl.deleteBuffer(this._positionHighBuffer[i]);
116
116
  this._positionHighArr[i] = makeArrayTyped(this._positionHighArr[i]);
117
- this._positionHighBuffer[i] = h.createArrayBuffer(this._positionHighArr[i], 3, len / 3);
117
+ this._positionHighBuffer[i] = h.createArrayBuffer(this._positionHighArr[i], 3, this._positionHighArr[i].length / 3);
118
118
  this._positionLowBuffer && h.gl.deleteBuffer(this._positionLowBuffer[i]);
119
119
  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
- );
120
+ this._positionLowBuffer[i] = h.createArrayBuffer(this._positionLowArr[i], 3, this._positionLowArr[i].length / 3);
125
121
  }
126
122
  }
127
123
 
@@ -130,7 +126,7 @@ class GeoObjectHandler {
130
126
  for (let i = 0, len = this._rgbaArr.length; i < len; i++) {
131
127
  this._rgbaBuffer && h.gl.deleteBuffer(this._rgbaBuffer[i]);
132
128
  this._rgbaArr[i] = makeArrayTyped(this._rgbaArr[i]);
133
- this._rgbaBuffer[i] = h.createArrayBuffer(this._rgbaArr[i], 4, len / 4);
129
+ this._rgbaBuffer[i] = h.createArrayBuffer(this._rgbaArr[i], 4, this._rgbaArr[i].length / 4);
134
130
  }
135
131
  }
136
132
 
@@ -139,7 +135,7 @@ class GeoObjectHandler {
139
135
  for (let i = 0, len = this._directionArr.length; i < len; i++) {
140
136
  this._directionBuffer && h.gl.deleteBuffer(this._directionBuffer[i]);
141
137
  this._directionArr[i] = makeArrayTyped(this._directionArr[i]);
142
- this._directionBuffer[i] = h.createArrayBuffer(this._directionArr[i], 3, len / 3);
138
+ this._directionBuffer[i] = h.createArrayBuffer(this._directionArr[i], 3, this._directionArr[i].length / 3);
143
139
  }
144
140
  }
145
141
 
@@ -148,7 +144,7 @@ class GeoObjectHandler {
148
144
  for (let i = 0, len = this._normalsArr.length; i < len; i++) {
149
145
  this._normalsBuffer && h.gl.deleteBuffer(this._normalsBuffer[i]);
150
146
  this._normalsArr[i] = makeArrayTyped(this._normalsArr[i]);
151
- this._normalsBuffer[i] = h.createArrayBuffer(this._normalsArr[i], 3, len / 3);
147
+ this._normalsBuffer[i] = h.createArrayBuffer(this._normalsArr[i], 3, this._normalsArr[i].length / 3);
152
148
  }
153
149
  }
154
150
 
@@ -157,11 +153,7 @@ class GeoObjectHandler {
157
153
  for (let i = 0, len = this._indicesArr.length; i < len; i++) {
158
154
  this._indicesBuffer && h.gl.deleteBuffer(this._indicesBuffer[i]);
159
155
  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
- );
156
+ this._indicesBuffer[i] = h.createElementArrayBuffer(this._indicesArr[i], 1, this._indicesArr[i].length);
165
157
  }
166
158
  }
167
159
 
@@ -170,7 +162,7 @@ class GeoObjectHandler {
170
162
  for (let i = 0, len = this._pickingColorArr.length; i < len; i++) {
171
163
  this._pickingColorBuffer && h.gl.deleteBuffer(this._pickingColorBuffer[i]);
172
164
  this._pickingColorArr[i] = makeArrayTyped(this._pickingColorArr[i]);
173
- this._pickingColorBuffer[i] = h.createArrayBuffer(this._pickingColorArr[i], 3, len / 3);
165
+ this._pickingColorBuffer[i] = h.createArrayBuffer(this._pickingColorArr[i], 3, this._pickingColorArr[i].length / 3);
174
166
  }
175
167
  }
176
168
 
@@ -215,14 +207,15 @@ class GeoObjectHandler {
215
207
  if (!alreadyAdded) {
216
208
  this._instancedTags.set(tag, {
217
209
  iCounts: 1,
210
+ maxIndex: Math.max(...geoObject._indices),
218
211
  index: this._instancedTags.size
219
212
  });
220
213
  } else {
221
214
  const prevState = this._instancedTags.get(tag),
222
215
  nextCount = prevState.iCounts + 1;
223
216
  this._instancedTags.set(tag, {
224
- iCounts: nextCount,
225
- index: prevState.index
217
+ ...prevState,
218
+ iCounts: nextCount
226
219
  });
227
220
  }
228
221
  const tagData = this._instancedTags.get(tag),
@@ -233,7 +226,8 @@ class GeoObjectHandler {
233
226
  */
234
227
  geoObject._tagIndex = tagData.iCounts - 1;
235
228
  if (geoObject._visibility) {
236
- if (!alreadyAdded) {
229
+ if (!this._vertexArr[ti] || this._vertexArr[ti].length !== geoObject._vertices.length) {
230
+
237
231
  this._vertexArr[ti] = concatArrays(
238
232
  this._vertexArr[ti],
239
233
  setParametersToArray(
@@ -306,8 +300,6 @@ class GeoObjectHandler {
306
300
  setParametersToArray([], 0, itemSize, itemSize, x, y, z, w)
307
301
  );
308
302
 
309
- this._indicesArr[ti] = concatArrays(this._indicesArr[ti], geoObject._indices);
310
-
311
303
  x = geoObject._pitch;
312
304
  y = geoObject._roll;
313
305
 
@@ -324,7 +316,7 @@ class GeoObjectHandler {
324
316
  this._sizeArr[ti],
325
317
  setParametersToArray([], 0, itemSize, itemSize, geoObject.scale)
326
318
  );
327
- this._recalculateIndices();
319
+ this._addIndices(geoObject);
328
320
  }
329
321
 
330
322
  _displayPASS() {
@@ -357,47 +349,19 @@ class GeoObjectHandler {
357
349
  ti = tagData.index;
358
350
 
359
351
  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
- );
352
+ gl.vertexAttribPointer(a.aVertexNormal, this._normalsBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
368
353
 
369
354
  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
- );
355
+ gl.vertexAttribPointer(a.aVertexPosition, this._vertexBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
378
356
 
379
357
  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
- );
358
+ gl.vertexAttribPointer(a.aDirection, this._directionBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
388
359
 
389
360
  gl.bindBuffer(gl.ARRAY_BUFFER, this._sizeBuffer[ti]);
390
361
  gl.vertexAttribPointer(a.aScale, this._sizeBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
391
362
 
392
363
  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
- );
364
+ gl.vertexAttribPointer(a.aPitchRoll, this._pitchRollBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
401
365
 
402
366
  gl.bindBuffer(gl.ARRAY_BUFFER, this._rgbaBuffer[ti]);
403
367
  gl.vertexAttribPointer(a.aColor, this._rgbaBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
@@ -561,7 +525,7 @@ class GeoObjectHandler {
561
525
  gl.disable(gl.CULL_FACE);
562
526
  }
563
527
 
564
- _recalculateIndices() {
528
+ _recalculateIndices(startIndex) {
565
529
  const allIndices = this._indicesArr,
566
530
  goArr = this._geoObjects,
567
531
  maxIndicesByTags = new Array(this._instancedTags.size).fill(0);
@@ -590,10 +554,62 @@ class GeoObjectHandler {
590
554
  }
591
555
  }
592
556
 
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;
557
+ _addIndices(g) {
558
+ let i = g._handlerIndex;
559
+ const allIndices = this._indicesArr,
560
+ gArr = this._geoObjects,
561
+ iLen = g._indices.length,
562
+ tagData = this._instancedTags.get(g.tag),
563
+ maxIndex = tagData.maxIndex,
564
+ ti = tagData.index;
565
+
566
+ allIndices[ti] = concatArrays(allIndices[ti], g._indices);
567
+
568
+ while (gArr[i]) {
569
+ const g = gArr[i];
570
+
571
+ if (g._tagIndex > 0) {
572
+ setParametersToArray(allIndices[ti], g._tagIndex, iLen, iLen, ...g._indices.reduce((acc, cur) => {
573
+ acc.push(cur + ((maxIndex + 1) * g._tagIndex));
574
+ return acc;
575
+ }, []));
576
+ }
577
+ i++;
578
+
579
+ }
580
+
581
+ }
582
+
583
+ _removeIndices(geoObject) {
584
+ const allIndices = this._indicesArr,
585
+ gArr = this._geoObjects,
586
+ iLen = geoObject._indices.length,
587
+ tagData = this._instancedTags.get(geoObject.tag),
588
+ maxIndex = tagData.maxIndex,
589
+ ti = tagData.index,
590
+ count = tagData.iCounts;
591
+
592
+ let i = geoObject._handlerIndex;
593
+
594
+ this._indicesArr[ti] = spliceArray(this._indicesArr[ti], geoObject._tagIndex * geoObject._indicesCount, geoObject._indicesCount);
595
+
596
+ while (gArr[i]) {
597
+ if (geoObject.tag === gArr[i].tag) {
598
+ if (count !== 0) {
599
+ const startI = (gArr[i]._tagIndex - 1) * iLen;
600
+ let stopI = startI + geoObject._indicesCount;
601
+ while (stopI > startI) {
602
+ this._indicesArr[ti][stopI - 1] = allIndices[ti][stopI - 1] - maxIndex - 1;
603
+ stopI--;
604
+ }
605
+ } else {
606
+ allIndices[ti] = geoObject._indices;
607
+ }
608
+ }
609
+ i++;
610
+
611
+ }
612
+
597
613
  }
598
614
 
599
615
  setDirectionArr(index, direction) {
@@ -606,15 +622,7 @@ class GeoObjectHandler {
606
622
  length = itemSize;
607
623
  }
608
624
 
609
- setParametersToArray(
610
- this._directionArr[ti],
611
- ob._tagIndex,
612
- length,
613
- itemSize,
614
- direction.x,
615
- direction.y,
616
- direction.z
617
- );
625
+ setParametersToArray(this._directionArr[ti], ob._tagIndex, length, itemSize, direction.x, direction.y, direction.z);
618
626
  this._changedBuffers[DIRECTION_BUFFER] = true;
619
627
  }
620
628
 
@@ -639,26 +647,10 @@ class GeoObjectHandler {
639
647
  length = itemSize;
640
648
  }
641
649
 
642
- setParametersToArray(
643
- this._positionHighArr[ti],
644
- ob._tagIndex,
645
- length,
646
- itemSize,
647
- positionHigh.x,
648
- positionHigh.y,
649
- positionHigh.z
650
- );
650
+ setParametersToArray(this._positionHighArr[ti], ob._tagIndex, length, itemSize, positionHigh.x, positionHigh.y, positionHigh.z);
651
651
 
652
652
  // Low
653
- setParametersToArray(
654
- this._positionLowArr[ti],
655
- ob._tagIndex,
656
- length,
657
- itemSize,
658
- positionLow.x,
659
- positionLow.y,
660
- positionLow.z
661
- );
653
+ setParametersToArray(this._positionLowArr[ti], ob._tagIndex, length, itemSize, positionLow.x, positionLow.y, positionLow.z);
662
654
 
663
655
  this._changedBuffers[POSITION_BUFFER] = true;
664
656
  }
@@ -673,16 +665,7 @@ class GeoObjectHandler {
673
665
  length = itemSize;
674
666
  }
675
667
 
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
- );
668
+ setParametersToArray(this._rgbaArr[ti], ob._tagIndex, length, itemSize, rgba.x, rgba.y, rgba.z, rgba.w);
686
669
 
687
670
  this._changedBuffers[RGBA_BUFFER] = true;
688
671
  }
@@ -771,16 +754,16 @@ class GeoObjectHandler {
771
754
  this._indicesArr = null;
772
755
  this._pickingColorArr = null;
773
756
 
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();
757
+ this._pitchRollArr = [new Float32Array()];
758
+ this._sizeArr = [new Float32Array()];
759
+ this._vertexArr = [new Float32Array()];
760
+ this._positionHighArr = [new Float32Array()];
761
+ this._positionLowArr = [new Float32Array()];
762
+ this._rgbaArr = [new Float32Array()];
763
+ this._directionArr = [new Float32Array()];
764
+ this._normalsArr = [new Float32Array()];
765
+ this._indicesArr = [new Uint16Array()];
766
+ this._pickingColorArr = [new Float32Array()];
784
767
 
785
768
  this._removeGeoObjects();
786
769
  this._deleteBuffers();
@@ -866,19 +849,20 @@ class GeoObjectHandler {
866
849
  const gi = geoObject._handlerIndex,
867
850
  tag = geoObject.tag,
868
851
  ti = this.getTagIndexByObjectIndex(gi),
869
- prevState = this._instancedTags.get(tag);
852
+ prevState = this._instancedTags.get(tag),
853
+ iCount = prevState.iCounts - 1;
870
854
 
871
855
  this._instancedTags.set(tag, {
872
- iCounts: prevState.iCounts - 1,
873
- index: prevState.index
856
+ ...prevState,
857
+ iCounts: iCount
874
858
  });
875
859
 
876
860
  this._geoObjects.splice(gi, 1);
877
861
 
878
- let i = gi * 4;
862
+ let i = geoObject._tagIndex * 4;
879
863
  this._rgbaArr[ti] = spliceArray(this._rgbaArr[ti], i, 4);
880
864
 
881
- i = gi * 3;
865
+ i = geoObject._tagIndex * 3;
882
866
  if (prevState.iCounts <= 1) {
883
867
  this._vertexArr[ti] = spliceArray(this._vertexArr[ti], 0, geoObject._verticesCount * 3);
884
868
  this._normalsArr[ti] = spliceArray(
@@ -892,14 +876,15 @@ class GeoObjectHandler {
892
876
  this._directionArr[ti] = spliceArray(this._directionArr[ti], i, 3);
893
877
  this._pickingColorArr[ti] = spliceArray(this._pickingColorArr[ti], i, 3);
894
878
 
895
- i = gi * 2;
879
+ i = geoObject._tagIndex * 2;
896
880
  this._pitchRollArr[ti] = spliceArray(this._pitchRollArr[ti], i, 2);
897
- this._indicesArr[ti] = spliceArray(this._indicesArr[ti], i, geoObject._indicesCount);
898
- i = gi * 1;
881
+ i = geoObject._tagIndex;
899
882
  this._sizeArr[ti] = spliceArray(this._sizeArr[ti], i, 1);
900
883
 
884
+ this._removeIndices(geoObject);
885
+
901
886
  this._reindexGeoObjects(gi, tag);
902
- this._recalculateIndices();
887
+
903
888
  this.refresh();
904
889
 
905
890
  geoObject._handlerIndex = -1;
@@ -7,6 +7,7 @@
7
7
  import * as utils from "../utils/shared.js";
8
8
  import { BaseBillboard } from "./BaseBillboard.js";
9
9
  import { Vec4 } from "../math/Vec4.js";
10
+ import { LOCK_FREE, LOCK_UPDATE } from "./LabelWorker.js";
10
11
 
11
12
  const ALIGN = {
12
13
  RIGHT: 0,
@@ -121,8 +122,8 @@ class Label extends BaseBillboard {
121
122
  */
122
123
  setText(text) {
123
124
  this._text = text.toString();
124
- if (this._isReady) {
125
- this._handler.setText(this._handlerIndex, text, this._fontIndex, this._align);
125
+ if (this._isReady && this._handler) {
126
+ this._handler.setText(this._handlerIndex, text, this._fontIndex, this._align);
126
127
  }
127
128
  }
128
129
 
@@ -142,10 +143,10 @@ class Label extends BaseBillboard {
142
143
  */
143
144
  setAlign(align) {
144
145
  this._align = STR2ALIGN[align.trim().toLowerCase()];
145
- if (this._isReady) {
146
- this._handler.setText(this._handlerIndex, this._text, this._fontIndex, this._align);
147
- } else if (this._lockId !== -1) {
148
- this._lockId = -2;
146
+ if (this._isReady && this._handler) {
147
+ this._handler.setText(this._handlerIndex, this._text, this._fontIndex, this._align);
148
+ } else if (this._lockId !== LOCK_FREE) {
149
+ this._lockId = LOCK_UPDATE;
149
150
  }
150
151
  }
151
152
 
@@ -183,11 +184,13 @@ class Label extends BaseBillboard {
183
184
  * @param {number} size - Label size in pixels.
184
185
  */
185
186
  setSize(size) {
186
- this._size = size;
187
- if (this._isReady) {
188
- this._handler.setSizeArr(this._handlerIndex, size);
189
- } else if (this._lockId !== -1) {
190
- this._lockId = -2;
187
+ if (size !== this._size) {
188
+ this._size = size;
189
+ if (this._isReady && this._handler) {
190
+ this._handler.setSizeArr(this._handlerIndex, size);
191
+ } else if (this._lockId !== LOCK_FREE) {
192
+ this._lockId = LOCK_UPDATE;
193
+ }
191
194
  }
192
195
  }
193
196
 
@@ -207,10 +210,10 @@ class Label extends BaseBillboard {
207
210
  */
208
211
  setOutline(outline) {
209
212
  this._outline = outline;
210
- if (this._isReady) {
211
- this._handler.setOutlineArr(this._handlerIndex, outline);
212
- } else if (this._lockId !== -1) {
213
- this._lockId = -2;
213
+ if (this._isReady && this._handler) {
214
+ this._handler.setOutlineArr(this._handlerIndex, outline);
215
+ } else if (this._lockId !== LOCK_FREE) {
216
+ this._lockId = LOCK_UPDATE;
214
217
  }
215
218
  }
216
219
 
@@ -229,10 +232,8 @@ class Label extends BaseBillboard {
229
232
  * @param {number} a - Label opacity.
230
233
  */
231
234
  setOpacity(a) {
232
- this._color.w = a;
233
- this.setColor4v(this._color);
234
- this._outlineColor.w = a;
235
- this.setOutlineColor4v(this._outlineColor);
235
+ super.setOpacity(a);
236
+ this.setOutlineOpacity(a);
236
237
  }
237
238
 
238
239
  /**
@@ -244,14 +245,16 @@ class Label extends BaseBillboard {
244
245
  * @param {number} a - Alpha.
245
246
  */
246
247
  setOutlineColor(r, g, b, a) {
247
- this._outlineColor.x = r;
248
- this._outlineColor.y = g;
249
- this._outlineColor.z = b;
250
- this._outlineColor.w = a;
251
- if (this._isReady) {
252
- this._handler.setOutlineColorArr(this._handlerIndex, this._outlineColor);
253
- } else if (this._lockId !== -1) {
254
- this._lockId = -2;
248
+ if (a !== this._outlineColor.w || r !== this._outlineColor.x || g !== this._outlineColor.y || b !== this._outlineColor.z) {
249
+ this._outlineColor.x = r;
250
+ this._outlineColor.y = g;
251
+ this._outlineColor.z = b;
252
+ this._outlineColor.w = a;
253
+ if (this._isReady && this._handler) {
254
+ this._handler.setOutlineColorArr(this._handlerIndex, this._outlineColor);
255
+ } else if (this._lockId !== LOCK_FREE) {
256
+ this._lockId = LOCK_UPDATE;
257
+ }
255
258
  }
256
259
  }
257
260
 
@@ -261,15 +264,7 @@ class Label extends BaseBillboard {
261
264
  * @param {Vec4} rgba - Color vector.
262
265
  */
263
266
  setOutlineColor4v(rgba) {
264
- this._outlineColor.x = rgba.x;
265
- this._outlineColor.y = rgba.y;
266
- this._outlineColor.z = rgba.z;
267
- this._outlineColor.w = rgba.w;
268
- if (this._isReady) {
269
- this._handler.setOutlineColorArr(this._handlerIndex, rgba);
270
- } else if (this._lockId !== -1) {
271
- this._lockId = -2;
272
- }
267
+ this.setOutlineColor(rgba.x, rgba.y, rgba.z, rgba.w);
273
268
  }
274
269
 
275
270
  /**
@@ -296,11 +291,13 @@ class Label extends BaseBillboard {
296
291
  * @param {number} opacity - Outline opacity.
297
292
  */
298
293
  setOutlineOpacity(opacity) {
299
- this._outlineColor.w = opacity;
300
- if (this._isReady) {
301
- this._handler.setOutlineColorArr(this._handlerIndex, this._outlineColor);
302
- } else if (this._lockId !== -1) {
303
- this._lockId = -2;
294
+ if (opacity !== this._outlineColor.w) {
295
+ this._outlineColor.w = opacity;
296
+ if (this._isReady && this._handler) {
297
+ this._handler.setOutlineColorArr(this._handlerIndex, this._outlineColor);
298
+ } else if (this._lockId !== LOCK_FREE) {
299
+ this._lockId = LOCK_UPDATE;
300
+ }
304
301
  }
305
302
  }
306
303
 
@@ -326,11 +323,11 @@ class Label extends BaseBillboard {
326
323
 
327
324
  _applyFontIndex(fontIndex) {
328
325
  this._fontIndex = fontIndex;
329
- if (this._isReady) {
326
+ if (this._isReady && this._handler) {
330
327
  this._handler.setFontIndexArr(this._handlerIndex, this._fontIndex);
331
328
  this._handler.setText(this._handlerIndex, this._text, this._fontIndex, this._align);
332
- } else if (this._lockId !== -1) {
333
- this._lockId = -2;
329
+ } else if (this._lockId !== LOCK_FREE) {
330
+ this._lockId = LOCK_UPDATE;
334
331
  }
335
332
  }
336
333
 
@@ -340,11 +337,11 @@ class Label extends BaseBillboard {
340
337
  * @param {utils.FontAtlas} fontAtlas - Font atlas.
341
338
  */
342
339
  assignFontAtlas(fontAtlas) {
343
- if (!this._fontAtlas) {
344
- this._fontAtlas = fontAtlas;
340
+ if (!this._fontAtlas) {
341
+ this._fontAtlas = fontAtlas;
345
342
  }
346
343
  this.update();
347
- }
344
+ }
348
345
  }
349
346
 
350
- export { Label, ALIGN };
347
+ export { Label, ALIGN };
@@ -8,6 +8,7 @@ import * as shaders from "../shaders/label.js";
8
8
  import { ALIGN } from "./Label.js";
9
9
  import { BillboardHandler } from "./BillboardHandler.js";
10
10
  import { concatTypedArrays, spliceTypedArray } from "../utils/shared.js";
11
+ import { LOCK_FREE } from "./LabelWorker.js";
11
12
 
12
13
  const PICKINGCOLOR_BUFFER = 0;
13
14
  const POSITION_BUFFER = 1;
@@ -81,28 +82,28 @@ class LabelHandler extends BillboardHandler {
81
82
  this.assignFontAtlas(label);
82
83
  this.refresh();
83
84
  }
84
- }
85
-
86
- _addLabelToArrays(label) {
87
- this._renderer.labelWorker.make(this, label);
88
- }
89
-
85
+ }
86
+
87
+ _addLabelToArrays(label) {
88
+ this._renderer.labelWorker.make(this, label);
89
+ }
90
+
90
91
  assignFontAtlas(label) {
91
92
  if (this._entityCollection && this._renderer) {
92
93
  label.assignFontAtlas(this._renderer.fontAtlas);
93
94
  this._addLabelToArrays(label);
94
- } else {
95
- this._billboards.push(label);
95
+ } else {
96
+ this._billboards.push(label);
96
97
  }
97
- }
98
-
99
- workerCallback(data, label) {
100
- if (label._lockId !== -1) {
101
- label._isReady = true;
102
- label._lockId = -1;
103
- label._handlerIndex = this._billboards.length;
104
- this._billboards.push(label);
105
-
98
+ }
99
+
100
+ workerCallback(data, label) {
101
+ if (label._lockId !== LOCK_FREE && this.isEqual(label._handler)) {
102
+ label._isReady = true;
103
+ label._lockId = LOCK_FREE;
104
+ label._handlerIndex = this._billboards.length;
105
+ this._billboards.push(label);
106
+
106
107
  this._vertexArr = concatTypedArrays(this._vertexArr, data.vertexArr);
107
108
  this._texCoordArr = concatTypedArrays(this._texCoordArr, data.texCoordArr);
108
109
  this._gliphParamArr = concatTypedArrays(this._gliphParamArr, data.gliphParamArr);
@@ -117,11 +118,11 @@ class LabelHandler extends BillboardHandler {
117
118
  this._outlineArr = concatTypedArrays(this._outlineArr, data.outlineArr);
118
119
  this._noOutlineArr = concatTypedArrays(this._noOutlineArr, data.noOutlineArr);
119
120
  this._outlineColorArr = concatTypedArrays(this._outlineColorArr, data.outlineColorArr);
120
- this._pickingColorArr = concatTypedArrays(this._pickingColorArr, data.pickingColorArr);
121
-
122
- label.update();
123
-
124
- this.refresh();
121
+ this._pickingColorArr = concatTypedArrays(this._pickingColorArr, data.pickingColorArr);
122
+
123
+ label.update();
124
+
125
+ this.refresh();
125
126
  }
126
127
  }
127
128
 
@@ -1038,4 +1039,4 @@ class LabelHandler extends BillboardHandler {
1038
1039
  }
1039
1040
  }
1040
1041
 
1041
- export { LabelHandler };
1042
+ export { LabelHandler };