@openglobus/og 0.11.5 → 0.12.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 (267) hide show
  1. package/css/og.css +5 -2
  2. package/package.json +12 -14
  3. package/src/og/Clock.js +6 -10
  4. package/src/og/Events.js +5 -7
  5. package/src/og/Extent.js +73 -32
  6. package/src/og/Globe.js +25 -10
  7. package/src/og/ImageCanvas.js +18 -15
  8. package/src/og/LonLat.js +13 -10
  9. package/src/og/Popup.js +19 -17
  10. package/src/og/QueueArray.js +3 -4
  11. package/src/og/Rectangle.js +4 -6
  12. package/src/og/Stack.js +2 -4
  13. package/src/og/ajax.js +20 -14
  14. package/src/og/astro/earth.js +21 -15
  15. package/src/og/bv/Box.js +2 -3
  16. package/src/og/bv/Sphere.js +10 -7
  17. package/src/og/camera/Camera.js +70 -79
  18. package/src/og/camera/Frustum.js +19 -12
  19. package/src/og/camera/PlanetCamera.js +33 -34
  20. package/src/og/control/CompassButton.js +1 -2
  21. package/src/og/control/Control.js +7 -9
  22. package/src/og/control/DebugInfo.js +2 -3
  23. package/src/og/control/EarthNavigation.js +26 -17
  24. package/src/og/control/KeyboardNavigation.js +9 -9
  25. package/src/og/control/LayerSwitcher.js +21 -20
  26. package/src/og/control/Lighting.js +74 -64
  27. package/src/og/control/MouseNavigation.js +30 -29
  28. package/src/og/control/MouseWheelZoomControl.js +257 -0
  29. package/src/og/control/SegmentBoundVisualization.js +5 -6
  30. package/src/og/control/ShowFps.js +12 -7
  31. package/src/og/control/SimpleNavigation.js +5 -7
  32. package/src/og/control/Sun.js +24 -14
  33. package/src/og/control/ToggleWireframe.js +3 -3
  34. package/src/og/control/TouchNavigation.js +43 -32
  35. package/src/og/control/ZoomControl.js +40 -24
  36. package/src/og/control/index.js +2 -0
  37. package/src/og/control/visibleExtent/Segment.js +1862 -0
  38. package/src/og/control/visibleExtent/VisibleExtent.js +80 -0
  39. package/src/og/control/visibleExtent/drawnode.js +751 -0
  40. package/src/og/ellipsoid/Ellipsoid.js +149 -57
  41. package/src/og/ellipsoid/wgs84.js +3 -3
  42. package/src/og/entity/BaseBillboard.js +72 -30
  43. package/src/og/entity/Billboard.js +9 -5
  44. package/src/og/entity/BillboardHandler.js +315 -62
  45. package/src/og/entity/Entity.js +742 -704
  46. package/src/og/entity/EntityCollection.js +47 -24
  47. package/src/og/entity/GeoObject.js +228 -0
  48. package/src/og/entity/GeoObjectHandler.js +895 -0
  49. package/src/og/entity/GeometryHandler.js +595 -123
  50. package/src/og/entity/Label.js +62 -30
  51. package/src/og/entity/LabelHandler.js +42 -243
  52. package/src/og/entity/LabelWorker.js +218 -0
  53. package/src/og/entity/Object3d.js +504 -0
  54. package/src/og/entity/PointCloud.js +76 -28
  55. package/src/og/entity/PointCloudHandler.js +5 -5
  56. package/src/og/entity/Ray.js +49 -16
  57. package/src/og/entity/Strip.js +72 -43
  58. package/src/og/entity/StripHandler.js +23 -23
  59. package/src/og/layer/BaseGeoImage.js +50 -19
  60. package/src/og/layer/CanvasTiles.js +16 -17
  61. package/src/og/layer/GeoImage.js +8 -16
  62. package/src/og/layer/GeoTexture2d.js +2 -10
  63. package/src/og/layer/GeoVideo.js +2 -10
  64. package/src/og/layer/KML.js +55 -33
  65. package/src/og/layer/Layer.js +24 -33
  66. package/src/og/layer/Material.js +1 -1
  67. package/src/og/layer/Vector.js +94 -48
  68. package/src/og/layer/WMS.js +33 -18
  69. package/src/og/layer/XYZ.js +24 -26
  70. package/src/og/light/LightSource.js +19 -12
  71. package/src/og/math/Mat3.js +24 -12
  72. package/src/og/math/Mat4.js +603 -603
  73. package/src/og/math/Plane.js +19 -18
  74. package/src/og/math/Ray.js +17 -12
  75. package/src/og/math/Vec2.js +24 -14
  76. package/src/og/math/Vec3.js +78 -32
  77. package/src/og/math/coder.js +7 -7
  78. package/src/og/proj/EPSG3857.js +3 -3
  79. package/src/og/proj/EPSG4326.js +3 -3
  80. package/src/og/proj/Proj.js +2 -4
  81. package/src/og/quadTree/Node.js +50 -95
  82. package/src/og/quadTree/quadTree.js +1 -1
  83. package/src/og/renderer/Renderer.js +106 -126
  84. package/src/og/renderer/RendererEvents.js +45 -23
  85. package/src/og/scene/BaseNode.js +2 -3
  86. package/src/og/scene/Planet.js +139 -191
  87. package/src/og/scene/RenderNode.js +15 -8
  88. package/src/og/segment/Segment.js +93 -268
  89. package/src/og/segment/Slice.js +45 -0
  90. package/src/og/shaders/drawnode.js +174 -360
  91. package/src/og/shaders/geoObject.js +211 -0
  92. package/src/og/shaders/pointCloud.js +41 -41
  93. package/src/og/shaders/shape.js +12 -18
  94. package/src/og/shaders/skybox.js +36 -36
  95. package/src/og/shaders/toneMapping.js +1 -0
  96. package/src/og/shapes/BaseShape.js +108 -36
  97. package/src/og/shapes/Icosphere.js +25 -10
  98. package/src/og/shapes/Sphere.js +8 -11
  99. package/src/og/terrain/EmptyTerrain.js +3 -2
  100. package/src/og/terrain/GlobusTerrain.js +2 -0
  101. package/src/og/utils/FontAtlas.js +6 -2
  102. package/src/og/utils/GeoImageCreator.js +5 -1
  103. package/src/og/utils/Loader.js +1 -1
  104. package/src/og/utils/PlainSegmentWorker.js +0 -13
  105. package/src/og/utils/TextureAtlas.js +18 -20
  106. package/src/og/utils/VectorTileCreator.js +1 -3
  107. package/src/og/utils/shared.js +2 -2
  108. package/src/og/webgl/Handler.js +219 -162
  109. package/src/og/webgl/Multisample.js +44 -16
  110. package/src/og/webgl/Program.js +78 -33
  111. package/src/og/webgl/callbacks.js +3 -3
  112. package/types/Clock.d.ts +0 -94
  113. package/types/Deferred.d.ts +0 -6
  114. package/types/Events.d.ts +0 -77
  115. package/types/Extent.d.ts +0 -166
  116. package/types/Globe.d.ts +0 -82
  117. package/types/ImageCanvas.d.ts +0 -123
  118. package/types/Lock.d.ts +0 -12
  119. package/types/LonLat.d.ts +0 -108
  120. package/types/Popup.d.ts +0 -42
  121. package/types/QueueArray.d.ts +0 -19
  122. package/types/Rectangle.d.ts +0 -80
  123. package/types/Stack.d.ts +0 -19
  124. package/types/ajax.d.ts +0 -24
  125. package/types/arial.d.ts +0 -48
  126. package/types/astro/astro.d.ts +0 -38
  127. package/types/astro/earth.d.ts +0 -7
  128. package/types/astro/jd.d.ts +0 -254
  129. package/types/bv/Box.d.ts +0 -30
  130. package/types/bv/Sphere.d.ts +0 -38
  131. package/types/bv/index.d.ts +0 -3
  132. package/types/camera/Camera.d.ts +0 -312
  133. package/types/camera/Frustum.d.ts +0 -133
  134. package/types/camera/PlanetCamera.d.ts +0 -218
  135. package/types/camera/index.d.ts +0 -3
  136. package/types/cons.d.ts +0 -40
  137. package/types/control/CompassButton.d.ts +0 -17
  138. package/types/control/Control.d.ts +0 -104
  139. package/types/control/DebugInfo.d.ts +0 -15
  140. package/types/control/EarthCoordinates.d.ts +0 -47
  141. package/types/control/EarthNavigation.d.ts +0 -42
  142. package/types/control/GeoImageDragControl.d.ts +0 -6
  143. package/types/control/KeyboardNavigation.d.ts +0 -21
  144. package/types/control/LayerSwitcher.d.ts +0 -21
  145. package/types/control/Lighting.d.ts +0 -16
  146. package/types/control/MouseNavigation.d.ts +0 -47
  147. package/types/control/ScaleControl.d.ts +0 -22
  148. package/types/control/ShowFps.d.ts +0 -11
  149. package/types/control/SimpleNavigation.d.ts +0 -25
  150. package/types/control/Sun.d.ts +0 -50
  151. package/types/control/ToggleWireframe.d.ts +0 -12
  152. package/types/control/TouchNavigation.d.ts +0 -48
  153. package/types/control/ZoomControl.d.ts +0 -27
  154. package/types/control/index.d.ts +0 -17
  155. package/types/ellipsoid/Ellipsoid.d.ts +0 -146
  156. package/types/ellipsoid/index.d.ts +0 -3
  157. package/types/ellipsoid/wgs84.d.ts +0 -6
  158. package/types/entity/BaseBillboard.d.ts +0 -208
  159. package/types/entity/Billboard.d.ts +0 -94
  160. package/types/entity/BillboardHandler.d.ts +0 -78
  161. package/types/entity/Entity.d.ts +0 -333
  162. package/types/entity/EntityCollection.d.ts +0 -311
  163. package/types/entity/Geometry.d.ts +0 -74
  164. package/types/entity/GeometryHandler.d.ts +0 -76
  165. package/types/entity/Label.d.ts +0 -189
  166. package/types/entity/LabelHandler.d.ts +0 -29
  167. package/types/entity/PointCloud.d.ts +0 -174
  168. package/types/entity/PointCloudHandler.d.ts +0 -38
  169. package/types/entity/Polyline.d.ts +0 -306
  170. package/types/entity/PolylineHandler.d.ts +0 -18
  171. package/types/entity/Ray.d.ts +0 -124
  172. package/types/entity/RayHandler.d.ts +0 -67
  173. package/types/entity/ShapeHandler.d.ts +0 -22
  174. package/types/entity/Strip.d.ts +0 -119
  175. package/types/entity/StripHandler.d.ts +0 -38
  176. package/types/entity/index.d.ts +0 -8
  177. package/types/index.core.d.ts +0 -65
  178. package/types/index.d.ts +0 -45
  179. package/types/index.webgl.d.ts +0 -7
  180. package/types/input/KeyboardHandler.d.ts +0 -10
  181. package/types/input/MouseHandler.d.ts +0 -5
  182. package/types/input/TouchHandler.d.ts +0 -5
  183. package/types/input/input.d.ts +0 -34
  184. package/types/layer/BaseGeoImage.d.ts +0 -94
  185. package/types/layer/CanvasTiles.d.ts +0 -68
  186. package/types/layer/GeoImage.d.ts +0 -52
  187. package/types/layer/GeoTexture2d.d.ts +0 -8
  188. package/types/layer/GeoVideo.d.ts +0 -55
  189. package/types/layer/KML.d.ts +0 -63
  190. package/types/layer/Layer.d.ts +0 -326
  191. package/types/layer/Material.d.ts +0 -45
  192. package/types/layer/Vector.d.ts +0 -208
  193. package/types/layer/WMS.d.ts +0 -63
  194. package/types/layer/XYZ.d.ts +0 -120
  195. package/types/layer/index.d.ts +0 -10
  196. package/types/light/LightSource.d.ts +0 -178
  197. package/types/math/Line2.d.ts +0 -11
  198. package/types/math/Line3.d.ts +0 -10
  199. package/types/math/Mat3.d.ts +0 -65
  200. package/types/math/Mat4.d.ts +0 -176
  201. package/types/math/Plane.d.ts +0 -18
  202. package/types/math/Quat.d.ts +0 -379
  203. package/types/math/Ray.d.ts +0 -82
  204. package/types/math/Vec2.d.ts +0 -309
  205. package/types/math/Vec3.d.ts +0 -460
  206. package/types/math/Vec4.d.ts +0 -162
  207. package/types/math/coder.d.ts +0 -43
  208. package/types/math/index.d.ts +0 -11
  209. package/types/math.d.ts +0 -261
  210. package/types/mercator.d.ts +0 -92
  211. package/types/proj/EPSG3857.d.ts +0 -6
  212. package/types/proj/EPSG4326.d.ts +0 -6
  213. package/types/proj/Proj.d.ts +0 -42
  214. package/types/quadTree/EntityCollectionNode.d.ts +0 -34
  215. package/types/quadTree/Node.d.ts +0 -61
  216. package/types/quadTree/quadTree.d.ts +0 -40
  217. package/types/renderer/Renderer.d.ts +0 -298
  218. package/types/renderer/RendererEvents.d.ts +0 -233
  219. package/types/res/images.d.ts +0 -3
  220. package/types/scene/Axes.d.ts +0 -11
  221. package/types/scene/BaseNode.d.ts +0 -60
  222. package/types/scene/Planet.d.ts +0 -577
  223. package/types/scene/RenderNode.d.ts +0 -142
  224. package/types/scene/SkyBox.d.ts +0 -10
  225. package/types/scene/index.d.ts +0 -4
  226. package/types/segment/Segment.d.ts +0 -279
  227. package/types/segment/SegmentLonLat.d.ts +0 -16
  228. package/types/segment/segmentHelper.d.ts +0 -13
  229. package/types/shaders/billboard.d.ts +0 -3
  230. package/types/shaders/depth.d.ts +0 -2
  231. package/types/shaders/drawnode.d.ts +0 -7
  232. package/types/shaders/label.d.ts +0 -4
  233. package/types/shaders/pointCloud.d.ts +0 -2
  234. package/types/shaders/polyline.d.ts +0 -3
  235. package/types/shaders/ray.d.ts +0 -2
  236. package/types/shaders/screenFrame.d.ts +0 -2
  237. package/types/shaders/shape.d.ts +0 -4
  238. package/types/shaders/skybox.d.ts +0 -2
  239. package/types/shaders/toneMapping.d.ts +0 -2
  240. package/types/shapes/BaseShape.d.ts +0 -250
  241. package/types/shapes/Sphere.d.ts +0 -41
  242. package/types/terrain/BilTerrain.d.ts +0 -7
  243. package/types/terrain/EmptyTerrain.d.ts +0 -72
  244. package/types/terrain/Geoid.d.ts +0 -26
  245. package/types/terrain/GlobusTerrain.d.ts +0 -116
  246. package/types/terrain/MapboxTerrain.d.ts +0 -7
  247. package/types/terrain/index.d.ts +0 -5
  248. package/types/utils/FontAtlas.d.ts +0 -14
  249. package/types/utils/GeoImageCreator.d.ts +0 -30
  250. package/types/utils/ImagesCacheManager.d.ts +0 -10
  251. package/types/utils/Loader.d.ts +0 -25
  252. package/types/utils/NormalMapCreator.d.ts +0 -39
  253. package/types/utils/PlainSegmentWorker.d.ts +0 -10
  254. package/types/utils/TerrainWorker.d.ts +0 -9
  255. package/types/utils/TextureAtlas.d.ts +0 -111
  256. package/types/utils/VectorTileCreator.d.ts +0 -16
  257. package/types/utils/colorTable.d.ts +0 -143
  258. package/types/utils/earcut.d.ts +0 -6
  259. package/types/utils/shared.d.ts +0 -231
  260. package/types/webgl/Framebuffer.d.ts +0 -135
  261. package/types/webgl/Handler.d.ts +0 -388
  262. package/types/webgl/Multisample.d.ts +0 -89
  263. package/types/webgl/Program.d.ts +0 -155
  264. package/types/webgl/ProgramController.d.ts +0 -89
  265. package/types/webgl/callbacks.d.ts +0 -1
  266. package/types/webgl/index.d.ts +0 -6
  267. package/types/webgl/types.d.ts +0 -2
@@ -0,0 +1,895 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * @module og/entity/ShapeHandler
5
+ */
6
+ import * as shaders from "../shaders/geoObject.js";
7
+ import { concatArrays, makeArrayTyped, spliceArray } from "../utils/shared.js";
8
+
9
+ const VERTEX_BUFFER = 0,
10
+ POSITION_BUFFER = 1,
11
+ RGBA_BUFFER = 2,
12
+ NORMALS_BUFFER = 3,
13
+ INDECIES_BUFFER = 4,
14
+ DIRECTION_BUFFER = 5,
15
+ PITCH_ROLL_BUFFER = 6,
16
+ SIZE_BUFFER = 7,
17
+ PICKINGCOLOR_BUFFER = 8;
18
+
19
+ const setParametersToArray = (arr = [], index = 0, length, itemSize, ...params) => {
20
+ const currIndex = index * length;
21
+ for (let i = currIndex, len = currIndex + length; i < len; i++) {
22
+ arr[i] = params[i % itemSize];
23
+ }
24
+ return arr;
25
+ };
26
+
27
+ class GeoObjectHandler {
28
+ constructor(entityCollection) {
29
+ /**
30
+ * Picking rendering option.
31
+ * @public
32
+ * @type {boolean}
33
+ */
34
+ this.pickingEnabled = true;
35
+
36
+ this._entityCollection = entityCollection;
37
+ this._renderer = null;
38
+ this._planet = null;
39
+
40
+ this._geoObjects = [];
41
+ this._pitchRollArr = [[]];
42
+ this._sizeArr = [[]];
43
+ this._vertexArr = [[]];
44
+ this._positionHighArr = [[]];
45
+ this._positionLowArr = [[]];
46
+ this._directionArr = [[]];
47
+ this._rgbaArr = [[]];
48
+ this._normalsArr = [[]];
49
+ this._indicesArr = [[]];
50
+ this._pickingColorArr = [[]];
51
+
52
+ this._pitchRollBuffer = [];
53
+ this._sizeBuffer = [];
54
+ this._vertexBuffer = [];
55
+ this._positionHighBuffer = [];
56
+ this._positionLowBuffer = [];
57
+ this._directionBuffer = [];
58
+ this._rgbaBuffer = [];
59
+ this._normalsBuffer = [];
60
+ this._indicesBuffer = [];
61
+ this._pickingColorBuffer = [];
62
+
63
+ this.__staticId = GeoObjectHandler._staticCounter++;
64
+ this._buffersUpdateCallbacks = [];
65
+ this._buffersUpdateCallbacks[PICKINGCOLOR_BUFFER] = this.createPickingColorBuffer;
66
+ this._buffersUpdateCallbacks[POSITION_BUFFER] = this.createPositionBuffer;
67
+ this._buffersUpdateCallbacks[DIRECTION_BUFFER] = this.createDirectionBuffer;
68
+ this._buffersUpdateCallbacks[NORMALS_BUFFER] = this.createNormalsBuffer;
69
+ this._buffersUpdateCallbacks[RGBA_BUFFER] = this.createRgbaBuffer;
70
+ this._buffersUpdateCallbacks[INDECIES_BUFFER] = this.createIndicesBuffer;
71
+ this._buffersUpdateCallbacks[VERTEX_BUFFER] = this.createVertexBuffer;
72
+ this._buffersUpdateCallbacks[SIZE_BUFFER] = this.createSizeBuffer;
73
+ this._buffersUpdateCallbacks[PITCH_ROLL_BUFFER] = this.createPitchRollBuffer;
74
+
75
+ this._changedBuffers = new Array(this._buffersUpdateCallbacks.length);
76
+
77
+ this._instancedTags = new Map();
78
+ }
79
+
80
+ getObjectByIndex(index) {
81
+ return this._geoObjects[index];
82
+ }
83
+
84
+ //Create buffers
85
+ createVertexBuffer() {
86
+ const h = this._renderer.handler;
87
+ for (let i = 0, len = this._vertexArr.length; i < len; i++) {
88
+ this._vertexBuffer && h.gl.deleteBuffer(this._vertexBuffer[i]);
89
+ this._vertexArr[i] = makeArrayTyped(this._vertexArr[i]);
90
+ this._vertexBuffer[i] = h.createArrayBuffer(this._vertexArr[i], 3, this._vertexArr[i].length / 3);
91
+ }
92
+ }
93
+
94
+ createPitchRollBuffer() {
95
+ const h = this._renderer.handler;
96
+ for (let i = 0, len = this._pitchRollArr.length; i < len; i++) {
97
+ this._pitchRollBuffer && h.gl.deleteBuffer(this._pitchRollBuffer[i]);
98
+ this._pitchRollArr[i] = makeArrayTyped(this._pitchRollArr[i]);
99
+ this._pitchRollBuffer[i] = h.createArrayBuffer(this._pitchRollArr[i], 2, this._pitchRollArr[i].length / 2);
100
+ }
101
+ }
102
+
103
+ createSizeBuffer() {
104
+ const h = this._renderer.handler;
105
+ for (let i = 0, len = this._sizeArr.length; i < len; i++) {
106
+ this._sizeBuffer && h.gl.deleteBuffer(this._sizeBuffer[i]);
107
+ this._sizeArr[i] = makeArrayTyped(this._sizeArr[i]);
108
+ this._sizeBuffer[i] = h.createArrayBuffer(this._sizeArr[i], 1, this._sizeArr[i].length);
109
+ }
110
+ }
111
+
112
+ createPositionBuffer() {
113
+ let h = this._renderer.handler;
114
+ for (let i = 0, len = this._positionHighArr.length; i < len; i++) {
115
+ this._positionHighBuffer && h.gl.deleteBuffer(this._positionHighBuffer[i]);
116
+ this._positionHighArr[i] = makeArrayTyped(this._positionHighArr[i]);
117
+ this._positionHighBuffer[i] = h.createArrayBuffer(this._positionHighArr[i], 3, this._positionHighArr[i].length / 3);
118
+ this._positionLowBuffer && h.gl.deleteBuffer(this._positionLowBuffer[i]);
119
+ this._positionLowArr[i] = makeArrayTyped(this._positionLowArr[i]);
120
+ this._positionLowBuffer[i] = h.createArrayBuffer(this._positionLowArr[i], 3, this._positionLowArr[i].length / 3);
121
+ }
122
+ }
123
+
124
+ createRgbaBuffer() {
125
+ const h = this._renderer.handler;
126
+ for (let i = 0, len = this._rgbaArr.length; i < len; i++) {
127
+ this._rgbaBuffer && h.gl.deleteBuffer(this._rgbaBuffer[i]);
128
+ this._rgbaArr[i] = makeArrayTyped(this._rgbaArr[i]);
129
+ this._rgbaBuffer[i] = h.createArrayBuffer(this._rgbaArr[i], 4, this._rgbaArr[i].length / 4);
130
+ }
131
+ }
132
+
133
+ createDirectionBuffer() {
134
+ const h = this._renderer.handler;
135
+ for (let i = 0, len = this._directionArr.length; i < len; i++) {
136
+ this._directionBuffer && h.gl.deleteBuffer(this._directionBuffer[i]);
137
+ this._directionArr[i] = makeArrayTyped(this._directionArr[i]);
138
+ this._directionBuffer[i] = h.createArrayBuffer(this._directionArr[i], 3, this._directionArr[i].length / 3);
139
+ }
140
+ }
141
+
142
+ createNormalsBuffer() {
143
+ const h = this._renderer.handler;
144
+ for (let i = 0, len = this._normalsArr.length; i < len; i++) {
145
+ this._normalsBuffer && h.gl.deleteBuffer(this._normalsBuffer[i]);
146
+ this._normalsArr[i] = makeArrayTyped(this._normalsArr[i]);
147
+ this._normalsBuffer[i] = h.createArrayBuffer(this._normalsArr[i], 3, this._normalsArr[i].length / 3);
148
+ }
149
+ }
150
+
151
+ createIndicesBuffer() {
152
+ const h = this._renderer.handler;
153
+ for (let i = 0, len = this._indicesArr.length; i < len; i++) {
154
+ this._indicesBuffer && h.gl.deleteBuffer(this._indicesBuffer[i]);
155
+ this._indicesArr[i] = makeArrayTyped(this._indicesArr[i], Uint16Array);
156
+ this._indicesBuffer[i] = h.createElementArrayBuffer(this._indicesArr[i], 1, this._indicesArr[i].length);
157
+ }
158
+ }
159
+
160
+ createPickingColorBuffer() {
161
+ const h = this._renderer.handler;
162
+ for (let i = 0, len = this._pickingColorArr.length; i < len; i++) {
163
+ this._pickingColorBuffer && h.gl.deleteBuffer(this._pickingColorBuffer[i]);
164
+ this._pickingColorArr[i] = makeArrayTyped(this._pickingColorArr[i]);
165
+ this._pickingColorBuffer[i] = h.createArrayBuffer(this._pickingColorArr[i], 3, this._pickingColorArr[i].length / 3);
166
+ }
167
+ }
168
+
169
+ static get _staticCounter() {
170
+ if (!this._counter && this._counter !== 0) {
171
+ this._counter = 0;
172
+ }
173
+ return this._counter;
174
+ }
175
+
176
+ static set _staticCounter(n) {
177
+ this._counter = n;
178
+ }
179
+
180
+ initProgram() {
181
+ if (this._renderer.handler) {
182
+ if (!this._renderer.handler.programs.geo_object) {
183
+ this._renderer.handler.addProgram(shaders.geo_object());
184
+ }
185
+ if (!this._renderer.handler.programs.geo_object_picking) {
186
+ this._renderer.handler.addProgram(shaders.geo_object_picking());
187
+ }
188
+ }
189
+ }
190
+
191
+ setRenderNode(renderNode) {
192
+ this._renderer = renderNode.renderer;
193
+ this._planet = renderNode;
194
+ this.initProgram();
195
+ }
196
+
197
+ setRenderer(planet) {
198
+ super.setRenderer(planet);
199
+ }
200
+
201
+ _addGeoObjectToArray(geoObject) {
202
+ let itemSize = 3;
203
+
204
+ const tag = geoObject.tag,
205
+ alreadyAdded = this._instancedTags.has(tag);
206
+
207
+ if (!alreadyAdded) {
208
+ this._instancedTags.set(tag, {
209
+ iCounts: 1,
210
+ maxIndex: Math.max(...geoObject._indices),
211
+ index: this._instancedTags.size
212
+ });
213
+ } else {
214
+ const prevState = this._instancedTags.get(tag),
215
+ nextCount = prevState.iCounts + 1;
216
+ this._instancedTags.set(tag, {
217
+ ...prevState,
218
+ iCounts: nextCount
219
+ });
220
+ }
221
+ const tagData = this._instancedTags.get(tag),
222
+ ti = tagData.index;
223
+
224
+ /**
225
+ * mark object by index for recalc indices array
226
+ */
227
+ geoObject._tagIndex = tagData.iCounts - 1;
228
+ if (geoObject._visibility) {
229
+ if (!this._vertexArr[ti] || this._vertexArr[ti].length !== geoObject._vertices.length) {
230
+
231
+ this._vertexArr[ti] = concatArrays(
232
+ this._vertexArr[ti],
233
+ setParametersToArray(
234
+ [],
235
+ 0,
236
+ geoObject._verticesCount * itemSize,
237
+ geoObject._verticesCount * itemSize,
238
+ ...geoObject._vertices
239
+ )
240
+ );
241
+ this._normalsArr[ti] = concatArrays(
242
+ this._normalsArr[ti],
243
+ setParametersToArray(
244
+ [],
245
+ 0,
246
+ geoObject._verticesCount * itemSize,
247
+ geoObject._verticesCount * itemSize,
248
+ ...geoObject._normals
249
+ // ...getTriangleNormals(geoObject._vertices, geoObject._indices)
250
+ )
251
+ );
252
+ }
253
+ } else {
254
+ this._vertexArr[ti] = concatArrays(
255
+ this._vertexArr[ti],
256
+ setParametersToArray([], 0, geoObject._verticesCount * itemSize, 1, 0)
257
+ );
258
+ }
259
+ let x = geoObject._positionHigh.x,
260
+ y = geoObject._positionHigh.y,
261
+ z = geoObject._positionHigh.z,
262
+ w;
263
+
264
+ this._positionHighArr[ti] = concatArrays(
265
+ this._positionHighArr[ti],
266
+ setParametersToArray([], 0, itemSize, itemSize, x, y, z)
267
+ );
268
+ x = geoObject._positionLow.x;
269
+ y = geoObject._positionLow.y;
270
+ z = geoObject._positionLow.z;
271
+ this._positionLowArr[ti] = concatArrays(
272
+ this._positionLowArr[ti],
273
+ setParametersToArray([], 0, itemSize, itemSize, x, y, z)
274
+ );
275
+
276
+ x = geoObject._entity._pickingColor.x / 255;
277
+ y = geoObject._entity._pickingColor.y / 255;
278
+ z = geoObject._entity._pickingColor.z / 255;
279
+ this._pickingColorArr[ti] = concatArrays(
280
+ this._pickingColorArr[ti],
281
+ setParametersToArray([], 0, itemSize, itemSize, x, y, z)
282
+ );
283
+
284
+ x = geoObject._direction.x;
285
+ y = geoObject._direction.y;
286
+ z = geoObject._direction.z;
287
+ this._directionArr[ti] = concatArrays(
288
+ this._directionArr[ti],
289
+ setParametersToArray([], 0, itemSize, itemSize, x, y, z)
290
+ );
291
+
292
+ itemSize = 4;
293
+
294
+ x = geoObject._color.x;
295
+ y = geoObject._color.y;
296
+ z = geoObject._color.z;
297
+ w = geoObject._color.w;
298
+ this._rgbaArr[ti] = concatArrays(
299
+ this._rgbaArr[ti],
300
+ setParametersToArray([], 0, itemSize, itemSize, x, y, z, w)
301
+ );
302
+
303
+ x = geoObject._pitch;
304
+ y = geoObject._roll;
305
+
306
+ itemSize = 2;
307
+
308
+ this._pitchRollArr[ti] = concatArrays(
309
+ this._pitchRollArr[ti],
310
+ setParametersToArray([], 0, itemSize, itemSize, x, y)
311
+ );
312
+
313
+ itemSize = 1;
314
+
315
+ this._sizeArr[ti] = concatArrays(
316
+ this._sizeArr[ti],
317
+ setParametersToArray([], 0, itemSize, itemSize, geoObject.scale)
318
+ );
319
+ this._addIndices(geoObject);
320
+ }
321
+
322
+ _displayPASS() {
323
+ const r = this._renderer,
324
+ sh = r.handler.programs.geo_object,
325
+ p = sh._program,
326
+ u = p.uniforms,
327
+ a = p.attributes,
328
+ gl = r.handler.gl,
329
+ ec = this._entityCollection;
330
+
331
+ sh.activate();
332
+
333
+ gl.enable(gl.CULL_FACE);
334
+ gl.uniform3fv(u.uScaleByDistance, ec.scaleByDistance);
335
+
336
+ gl.uniform3fv(u.eyePositionHigh, r.activeCamera.eyeHigh);
337
+ gl.uniform3fv(u.eyePositionLow, r.activeCamera.eyeLow);
338
+
339
+ gl.uniformMatrix4fv(u.projectionMatrix, false, r.activeCamera.getProjectionMatrix());
340
+ gl.uniformMatrix4fv(u.viewMatrix, false, r.activeCamera.getViewMatrix());
341
+ gl.uniformMatrix3fv(u.normalMatrix, false, r.activeCamera._normalMatrix._m);
342
+
343
+ gl.uniform4fv(u.lightsPositions, this._planet._lightsTransformedPositions);
344
+ gl.uniform3fv(u.lightsParamsv, this._planet._lightsParamsv);
345
+ gl.uniform1fv(u.lightsParamsf, this._planet._lightsParamsf);
346
+
347
+ for (const tag of this._instancedTags) {
348
+ const tagData = tag[1],
349
+ ti = tagData.index;
350
+
351
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._normalsBuffer[ti]);
352
+ gl.vertexAttribPointer(a.aVertexNormal, this._normalsBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
353
+
354
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer[ti]);
355
+ gl.vertexAttribPointer(a.aVertexPosition, this._vertexBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
356
+
357
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._directionBuffer[ti]);
358
+ gl.vertexAttribPointer(a.aDirection, this._directionBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
359
+
360
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._sizeBuffer[ti]);
361
+ gl.vertexAttribPointer(a.aScale, this._sizeBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
362
+
363
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._pitchRollBuffer[ti]);
364
+ gl.vertexAttribPointer(a.aPitchRoll, this._pitchRollBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
365
+
366
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._rgbaBuffer[ti]);
367
+ gl.vertexAttribPointer(a.aColor, this._rgbaBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
368
+
369
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._positionHighBuffer[ti]);
370
+ gl.vertexAttribPointer(
371
+ a.aPositionHigh,
372
+ this._positionHighBuffer[ti].itemSize,
373
+ gl.FLOAT,
374
+ false,
375
+ 0,
376
+ 0
377
+ );
378
+
379
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._positionLowBuffer[ti]);
380
+ gl.vertexAttribPointer(
381
+ a.aPositionLow,
382
+ this._positionLowBuffer[ti].itemSize,
383
+ gl.FLOAT,
384
+ false,
385
+ 0,
386
+ 0
387
+ );
388
+
389
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indicesBuffer[ti]);
390
+
391
+ if (tagData.iCounts) {
392
+ gl.drawElementsInstanced(
393
+ gl.TRIANGLES,
394
+ this._indicesBuffer[ti].numItems / tagData.iCounts,
395
+ gl.UNSIGNED_SHORT,
396
+ 0,
397
+ tagData.iCounts
398
+ );
399
+ } else {
400
+ gl.drawElements(
401
+ gl.TRIANGLES,
402
+ this._indicesBuffer[ti].numItems,
403
+ gl.UNSIGNED_SHORT,
404
+ 0
405
+ );
406
+ }
407
+ }
408
+ gl.disable(gl.CULL_FACE);
409
+ }
410
+
411
+ drawPicking() {
412
+ if (this._geoObjects.length && this.pickingEnabled) {
413
+ this._pickingPASS();
414
+ }
415
+ }
416
+
417
+ _pickingPASS() {
418
+ const r = this._renderer,
419
+ sh = r.handler.programs.geo_object_picking,
420
+ p = sh._program,
421
+ u = p.uniforms,
422
+ a = p.attributes,
423
+ gl = r.handler.gl,
424
+ ec = this._entityCollection;
425
+
426
+ sh.activate();
427
+
428
+ gl.enable(gl.CULL_FACE);
429
+ gl.uniform3fv(u.uScaleByDistance, ec.scaleByDistance);
430
+
431
+ gl.uniform1f(u.pickingScale, ec.pickingScale);
432
+
433
+ gl.uniform3fv(u.eyePositionHigh, r.activeCamera.eyeHigh);
434
+ gl.uniform3fv(u.eyePositionLow, r.activeCamera.eyeLow);
435
+
436
+ gl.uniformMatrix4fv(u.projectionMatrix, false, r.activeCamera.getProjectionMatrix());
437
+ gl.uniformMatrix4fv(u.viewMatrix, false, r.activeCamera.getViewMatrix());
438
+
439
+ for (const tag of this._instancedTags) {
440
+ const tagData = tag[1],
441
+ ti = tagData.index;
442
+
443
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer[ti]);
444
+ gl.vertexAttribPointer(
445
+ a.aVertexPosition,
446
+ this._vertexBuffer[ti].itemSize,
447
+ gl.FLOAT,
448
+ false,
449
+ 0,
450
+ 0
451
+ );
452
+
453
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._directionBuffer[ti]);
454
+ gl.vertexAttribPointer(
455
+ a.aDirection,
456
+ this._directionBuffer[ti].itemSize,
457
+ gl.FLOAT,
458
+ false,
459
+ 0,
460
+ 0
461
+ );
462
+
463
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._sizeBuffer[ti]);
464
+ gl.vertexAttribPointer(a.aScale, this._sizeBuffer[ti].itemSize, gl.FLOAT, false, 0, 0);
465
+
466
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._pitchRollBuffer[ti]);
467
+ gl.vertexAttribPointer(
468
+ a.aPitchRoll,
469
+ this._pitchRollBuffer[ti].itemSize,
470
+ gl.FLOAT,
471
+ false,
472
+ 0,
473
+ 0
474
+ );
475
+
476
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._pickingColorBuffer[ti]);
477
+ gl.vertexAttribPointer(
478
+ a.aPickingColor,
479
+ this._pickingColorBuffer[ti].itemSize,
480
+ gl.FLOAT,
481
+ false,
482
+ 0,
483
+ 0
484
+ );
485
+
486
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._positionHighBuffer[ti]);
487
+ gl.vertexAttribPointer(
488
+ a.aPositionHigh,
489
+ this._positionHighBuffer[ti].itemSize,
490
+ gl.FLOAT,
491
+ false,
492
+ 0,
493
+ 0
494
+ );
495
+
496
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._positionLowBuffer[ti]);
497
+ gl.vertexAttribPointer(
498
+ a.aPositionLow,
499
+ this._positionLowBuffer[ti].itemSize,
500
+ gl.FLOAT,
501
+ false,
502
+ 0,
503
+ 0
504
+ );
505
+
506
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indicesBuffer[ti]);
507
+
508
+ if (tagData.iCounts) {
509
+ gl.drawElementsInstanced(
510
+ gl.TRIANGLES,
511
+ this._indicesBuffer[ti].numItems / tagData.iCounts,
512
+ gl.UNSIGNED_SHORT,
513
+ 0,
514
+ tagData.iCounts
515
+ );
516
+ } else {
517
+ gl.drawElements(
518
+ gl.TRIANGLES,
519
+ this._indicesBuffer[ti].numItems,
520
+ gl.UNSIGNED_SHORT,
521
+ 0
522
+ );
523
+ }
524
+ }
525
+ gl.disable(gl.CULL_FACE);
526
+ }
527
+
528
+ _recalculateIndices(startIndex) {
529
+ const allIndices = this._indicesArr,
530
+ goArr = this._geoObjects,
531
+ maxIndicesByTags = new Array(this._instancedTags.size).fill(0);
532
+
533
+ for (let gi = 0; gi < goArr.length; gi++) {
534
+ const go = goArr[gi],
535
+ ti = this.getTagIndexByObjectIndex(go._handlerIndex),
536
+ gIndices = go._indices;
537
+
538
+ for (let ii = 0; ii < gIndices.length; ii++) {
539
+ const gIndex = gIndices[ii];
540
+
541
+ const i = go._indicesCount * go._tagIndex + ii;
542
+ if (go._tagIndex > 0) {
543
+ allIndices[ti][i] = gIndex + maxIndicesByTags[ti];
544
+ if (allIndices[ti][i] > maxIndicesByTags[ti]) {
545
+ maxIndicesByTags[ti] = allIndices[ti][i] + 1;
546
+ }
547
+ } else {
548
+ allIndices[ti][i] = gIndex;
549
+ if (gIndex > maxIndicesByTags[ti]) {
550
+ maxIndicesByTags[ti] = gIndex + 1;
551
+ }
552
+ }
553
+ }
554
+ }
555
+ }
556
+
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
+
613
+ }
614
+
615
+ setDirectionArr(index, direction) {
616
+ const itemSize = 3,
617
+ ob = this.getObjectByIndex(index),
618
+ ti = this.getTagIndexByObjectIndex(index);
619
+ let length = ob._verticesCount * itemSize;
620
+
621
+ if (ob.instanced) {
622
+ length = itemSize;
623
+ }
624
+
625
+ setParametersToArray(this._directionArr[ti], ob._tagIndex, length, itemSize, direction.x, direction.y, direction.z);
626
+ this._changedBuffers[DIRECTION_BUFFER] = true;
627
+ }
628
+
629
+ setVisibility(index, visibility) {
630
+ const ob = this.getObjectByIndex(index);
631
+ let vArr;
632
+ if (visibility) {
633
+ vArr = ob._vertices;
634
+ } else {
635
+ vArr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
636
+ }
637
+ this.setVertexArr(index, vArr);
638
+ }
639
+
640
+ setPositionArr(index, positionHigh, positionLow) {
641
+ const itemSize = 3,
642
+ ob = this.getObjectByIndex(index),
643
+ ti = this.getTagIndexByObjectIndex(index);
644
+ let length = ob._verticesCount * itemSize;
645
+
646
+ if (ob.instanced) {
647
+ length = itemSize;
648
+ }
649
+
650
+ setParametersToArray(this._positionHighArr[ti], ob._tagIndex, length, itemSize, positionHigh.x, positionHigh.y, positionHigh.z);
651
+
652
+ // Low
653
+ setParametersToArray(this._positionLowArr[ti], ob._tagIndex, length, itemSize, positionLow.x, positionLow.y, positionLow.z);
654
+
655
+ this._changedBuffers[POSITION_BUFFER] = true;
656
+ }
657
+
658
+ setRgbaArr(index, rgba) {
659
+ const itemSize = 4,
660
+ ob = this.getObjectByIndex(index),
661
+ ti = this.getTagIndexByObjectIndex(index);
662
+ let length = ob._verticesCount * itemSize;
663
+
664
+ if (ob.instanced) {
665
+ length = itemSize;
666
+ }
667
+
668
+ setParametersToArray(this._rgbaArr[ti], ob._tagIndex, length, itemSize, rgba.x, rgba.y, rgba.z, rgba.w);
669
+
670
+ this._changedBuffers[RGBA_BUFFER] = true;
671
+ }
672
+
673
+ getTagIndexByObjectIndex(index) {
674
+ return this._instancedTags.get(this.getObjectByIndex(index).tag).index;
675
+ }
676
+
677
+ getTagDataByObjectIndex(index) {
678
+ return this._instancedTags.get(this.getObjectByIndex(index).tag);
679
+ }
680
+
681
+ setPickingColorArr(index, color) {
682
+ const itemSize = 3,
683
+ ti = this.getTagIndexByObjectIndex(index),
684
+ ob = this.getObjectByIndex(index),
685
+ x = color.x / 255,
686
+ y = color.y / 255,
687
+ z = color.z / 255;
688
+
689
+ let length = ob._verticesCount * itemSize;
690
+
691
+ if (ob.instanced) {
692
+ length = itemSize;
693
+ }
694
+
695
+ setParametersToArray(this._pickingColorArr[ti], ob._tagIndex, length, itemSize, x, y, z);
696
+ this._changedBuffers[PICKINGCOLOR_BUFFER] = true;
697
+ }
698
+
699
+ setPitchRollArr(index, pitch, roll) {
700
+ const itemSize = 2,
701
+ ti = this.getTagIndexByObjectIndex(index),
702
+ ob = this.getObjectByIndex(index);
703
+ let length = ob._verticesCount * itemSize;
704
+
705
+ if (ob.instanced) {
706
+ length = itemSize;
707
+ }
708
+
709
+ setParametersToArray(this._pitchRollArr[ti], ob._tagIndex, length, itemSize, pitch, roll);
710
+ this._changedBuffers[PITCH_ROLL_BUFFER] = true;
711
+ }
712
+
713
+ setScaleArr(index, scale) {
714
+ const itemSize = 1,
715
+ ti = this.getTagIndexByObjectIndex(index),
716
+ ob = this.getObjectByIndex(index);
717
+ let length = ob._verticesCount * itemSize;
718
+
719
+ if (ob.instanced) {
720
+ length = itemSize;
721
+ }
722
+
723
+ setParametersToArray(this._sizeArr[ti], ob._tagIndex, length, itemSize, scale);
724
+ this._changedBuffers[SIZE_BUFFER] = true;
725
+ }
726
+
727
+ refresh() {
728
+ let i = this._changedBuffers.length;
729
+ while (i--) {
730
+ this._changedBuffers[i] = true;
731
+ }
732
+ }
733
+
734
+ _removeGeoObjects() {
735
+ let i = this._geoObjects.length;
736
+ while (i--) {
737
+ const bi = this._geoObjects[i];
738
+ bi._handlerIndex = -1;
739
+ bi._handler = null;
740
+ }
741
+ this._geoObjects.length = 0;
742
+ this._geoObjects = [];
743
+ }
744
+
745
+ clear() {
746
+ this._sizeArr = null;
747
+ this._pitchRollArr = null;
748
+ this._vertexArr = null;
749
+ this._positionHighArr = null;
750
+ this._positionLowArr = null;
751
+ this._directionArr = null;
752
+ this._rgbaArr = null;
753
+ this._normalsArr = null;
754
+ this._indicesArr = null;
755
+ this._pickingColorArr = null;
756
+
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()];
767
+
768
+ this._removeGeoObjects();
769
+ this._deleteBuffers();
770
+ this.refresh();
771
+ }
772
+
773
+ _deleteBuffers() {
774
+ if (this._renderer) {
775
+ const gl = this._renderer.handler.gl;
776
+ gl.deleteBuffer(this._sizeBuffer);
777
+ gl.deleteBuffer(this._pitchRollBuffer);
778
+ gl.deleteBuffer(this._vertexBuffer);
779
+ gl.deleteBuffer(this._positionHighBuffer);
780
+ gl.deleteBuffer(this._positionLowBuffer);
781
+ gl.deleteBuffer(this._rgbaBuffer);
782
+ gl.deleteBuffer(this._indicesBuffer);
783
+ gl.deleteBuffer(this._normalsBuffer);
784
+ gl.deleteBuffer(this._directionBuffer);
785
+ gl.deleteBuffer(this._pickingColorBuffer);
786
+ }
787
+
788
+ this._pitchRollBuffer = null;
789
+ this._sizeBuffer = null;
790
+ this._vertexBuffer = null;
791
+ this._positionHighBuffer = null;
792
+ this._positionLowBuffer = null;
793
+ this._rgbaBuffer = null;
794
+ this._indicesBuffer = null;
795
+ this._normalsBuffer = null;
796
+ this._directionBuffer = null;
797
+ this._pickingColorBuffer = null;
798
+ }
799
+
800
+ update() {
801
+ if (this._renderer) {
802
+ let i = this._changedBuffers.length;
803
+ while (i--) {
804
+ if (this._changedBuffers[i]) {
805
+ this._buffersUpdateCallbacks[i].call(this);
806
+ this._changedBuffers[i] = false;
807
+ }
808
+ }
809
+ }
810
+ }
811
+
812
+ draw() {
813
+ if (this._geoObjects.length) {
814
+ this.update();
815
+ this._displayPASS();
816
+ }
817
+ }
818
+
819
+ _reindexGeoObjects(startIndex, tag) {
820
+ const b = this._geoObjects;
821
+
822
+ for (let i = startIndex; i < b.length; i++) {
823
+ const go = b[i];
824
+
825
+ b[i]._handlerIndex = i;
826
+ if (tag === go.tag) {
827
+ --b[i]._tagIndex;
828
+ }
829
+ }
830
+ }
831
+
832
+ add(geoObject) {
833
+ if (geoObject._handlerIndex === -1) {
834
+ geoObject._handler = this;
835
+ geoObject._handlerIndex = this._geoObjects.length;
836
+ this._geoObjects.push(geoObject);
837
+ this._addGeoObjectToArray(geoObject);
838
+ this.refresh();
839
+ }
840
+ }
841
+
842
+ remove(geoObject) {
843
+ if (geoObject._handler && this.__staticId == geoObject._handler.__staticId) {
844
+ this._removeGeoObject(geoObject);
845
+ }
846
+ }
847
+
848
+ _removeGeoObject(geoObject) {
849
+ const gi = geoObject._handlerIndex,
850
+ tag = geoObject.tag,
851
+ ti = this.getTagIndexByObjectIndex(gi),
852
+ prevState = this._instancedTags.get(tag),
853
+ iCount = prevState.iCounts - 1;
854
+
855
+ this._instancedTags.set(tag, {
856
+ ...prevState,
857
+ iCounts: iCount
858
+ });
859
+
860
+ this._geoObjects.splice(gi, 1);
861
+
862
+ let i = geoObject._tagIndex * 4;
863
+ this._rgbaArr[ti] = spliceArray(this._rgbaArr[ti], i, 4);
864
+
865
+ i = geoObject._tagIndex * 3;
866
+ if (prevState.iCounts <= 1) {
867
+ this._vertexArr[ti] = spliceArray(this._vertexArr[ti], 0, geoObject._verticesCount * 3);
868
+ this._normalsArr[ti] = spliceArray(
869
+ this._normalsArr[ti],
870
+ 0,
871
+ geoObject._verticesCount * 3
872
+ );
873
+ }
874
+ this._positionHighArr[ti] = spliceArray(this._positionHighArr[ti], i, 3);
875
+ this._positionLowArr[ti] = spliceArray(this._positionLowArr[ti], i, 3);
876
+ this._directionArr[ti] = spliceArray(this._directionArr[ti], i, 3);
877
+ this._pickingColorArr[ti] = spliceArray(this._pickingColorArr[ti], i, 3);
878
+
879
+ i = geoObject._tagIndex * 2;
880
+ this._pitchRollArr[ti] = spliceArray(this._pitchRollArr[ti], i, 2);
881
+ i = geoObject._tagIndex;
882
+ this._sizeArr[ti] = spliceArray(this._sizeArr[ti], i, 1);
883
+
884
+ this._removeIndices(geoObject);
885
+
886
+ this._reindexGeoObjects(gi, tag);
887
+
888
+ this.refresh();
889
+
890
+ geoObject._handlerIndex = -1;
891
+ geoObject._handler = null;
892
+ }
893
+ }
894
+
895
+ export { GeoObjectHandler };