@openglobus/og 0.22.2 → 0.23.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 (167) hide show
  1. package/css/og.css +137 -1
  2. package/lib/@openglobus/js/Object3d.d.ts +20 -10
  3. package/lib/@openglobus/js/camera/Camera.d.ts +9 -0
  4. package/lib/@openglobus/js/camera/Frustum.d.ts +3 -0
  5. package/lib/@openglobus/js/control/CameraLock.d.ts +38 -0
  6. package/lib/@openglobus/js/control/SimpleNavigation.d.ts +27 -10
  7. package/lib/@openglobus/js/control/geoObjectEditor/ArrowEntity.d.ts +15 -0
  8. package/lib/@openglobus/js/control/geoObjectEditor/AxisTrackEntity.d.ts +9 -0
  9. package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditor.d.ts +13 -0
  10. package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorDialog.d.ts +69 -0
  11. package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +78 -9
  12. package/lib/@openglobus/js/control/geoObjectEditor/MoveAxisEntity.d.ts +17 -0
  13. package/lib/@openglobus/js/control/geoObjectEditor/MovePlaneEntity.d.ts +7 -0
  14. package/lib/@openglobus/js/control/geoObjectEditor/RotateEntity.d.ts +9 -0
  15. package/lib/@openglobus/js/control/geoObjectEditor/colors.d.ts +8 -0
  16. package/lib/@openglobus/js/control/index.d.ts +2 -0
  17. package/lib/@openglobus/js/entity/Entity.d.ts +278 -19
  18. package/lib/@openglobus/js/entity/EntityCollection.d.ts +8 -9
  19. package/lib/@openglobus/js/entity/GeoObject.d.ts +141 -36
  20. package/lib/@openglobus/js/entity/GeoObjectHandler.d.ts +39 -63
  21. package/lib/@openglobus/js/entity/InstanceData.d.ts +76 -0
  22. package/lib/@openglobus/js/entity/Polyline.d.ts +19 -6
  23. package/lib/@openglobus/js/entity/PolylineHandler.d.ts +7 -0
  24. package/lib/@openglobus/js/index.d.ts +2 -1
  25. package/lib/@openglobus/js/layer/Vector.d.ts +4 -0
  26. package/lib/@openglobus/js/light/LightSource.d.ts +1 -139
  27. package/lib/@openglobus/js/math/Quat.d.ts +46 -33
  28. package/lib/@openglobus/js/math/Ray.d.ts +10 -4
  29. package/lib/@openglobus/js/math/Vec3.d.ts +15 -0
  30. package/lib/@openglobus/js/math.d.ts +2 -2
  31. package/lib/@openglobus/js/quadTree/EntityCollectionNode.d.ts +2 -2
  32. package/lib/@openglobus/js/quadTree/Node.d.ts +1 -1
  33. package/lib/@openglobus/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +1 -1
  34. package/lib/@openglobus/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +1 -1
  35. package/lib/@openglobus/js/renderer/Renderer.d.ts +63 -44
  36. package/lib/@openglobus/js/renderer/RendererEvents.d.ts +1 -0
  37. package/lib/@openglobus/js/scene/Planet.d.ts +11 -7
  38. package/lib/@openglobus/js/scene/RenderNode.d.ts +10 -25
  39. package/lib/@openglobus/js/shaders/drawnode.d.ts +1 -0
  40. package/lib/@openglobus/js/shaders/geoObject.d.ts +1 -0
  41. package/lib/@openglobus/js/shaders/utils.d.ts +1 -1
  42. package/lib/@openglobus/js/ui/Checkbox.d.ts +31 -0
  43. package/lib/@openglobus/js/ui/Dialog.d.ts +3 -0
  44. package/lib/@openglobus/js/ui/Input.d.ts +32 -0
  45. package/lib/@openglobus/js/ui/View.d.ts +3 -1
  46. package/lib/@openglobus/js/utils/objParser.d.ts +44 -12
  47. package/lib/@openglobus/js/utils/shared.d.ts +22 -0
  48. package/lib/@openglobus/js/webgl/BaseFramebuffer.d.ts +0 -1
  49. package/lib/@openglobus/js/webgl/Framebuffer.d.ts +35 -8
  50. package/lib/@openglobus/js/webgl/Handler.d.ts +1 -0
  51. package/lib/@openglobus/og.css +1 -1
  52. package/lib/@openglobus/og.esm.js +1 -1
  53. package/lib/@openglobus/og.esm.js.map +1 -1
  54. package/lib/@openglobus/og.umd.js +1 -1
  55. package/lib/@openglobus/og.umd.js.map +1 -1
  56. package/lib/js/Object3d.d.ts +20 -10
  57. package/lib/js/Object3d.js +124 -48
  58. package/lib/js/camera/Camera.d.ts +9 -0
  59. package/lib/js/camera/Camera.js +27 -1
  60. package/lib/js/camera/Frustum.d.ts +3 -0
  61. package/lib/js/camera/Frustum.js +7 -0
  62. package/lib/js/control/Atmosphere.js +10 -6
  63. package/lib/js/control/CameraLock.d.ts +38 -0
  64. package/lib/js/control/CameraLock.js +216 -0
  65. package/lib/js/control/Control.js +1 -1
  66. package/lib/js/control/DebugInfo.js +13 -3
  67. package/lib/js/control/KeyboardNavigation.js +1 -1
  68. package/lib/js/control/ScaleControl.js +9 -3
  69. package/lib/js/control/SimpleNavigation.d.ts +27 -10
  70. package/lib/js/control/SimpleNavigation.js +148 -49
  71. package/lib/js/control/Sun.js +1 -1
  72. package/lib/js/control/elevationProfile/ElevationProfileScene.js +4 -4
  73. package/lib/js/control/geoObjectEditor/ArrowEntity.d.ts +15 -0
  74. package/lib/js/control/geoObjectEditor/ArrowEntity.js +59 -0
  75. package/lib/js/control/geoObjectEditor/AxisTrackEntity.d.ts +9 -0
  76. package/lib/js/control/geoObjectEditor/AxisTrackEntity.js +93 -0
  77. package/lib/js/control/geoObjectEditor/GeoObjectEditor.d.ts +13 -0
  78. package/lib/js/control/geoObjectEditor/GeoObjectEditor.js +30 -0
  79. package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.d.ts +69 -0
  80. package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.js +502 -0
  81. package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +78 -9
  82. package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.js +487 -43
  83. package/lib/js/control/geoObjectEditor/MoveAxisEntity.d.ts +17 -0
  84. package/lib/js/control/geoObjectEditor/MoveAxisEntity.js +106 -0
  85. package/lib/js/control/geoObjectEditor/MovePlaneEntity.d.ts +7 -0
  86. package/lib/js/control/geoObjectEditor/MovePlaneEntity.js +34 -0
  87. package/lib/js/control/geoObjectEditor/RotateEntity.d.ts +9 -0
  88. package/lib/js/control/geoObjectEditor/RotateEntity.js +105 -0
  89. package/lib/js/control/geoObjectEditor/colors.d.ts +8 -0
  90. package/lib/js/control/geoObjectEditor/colors.js +8 -0
  91. package/lib/js/control/index.d.ts +2 -0
  92. package/lib/js/control/index.js +2 -0
  93. package/lib/js/control/timeline/TimelineControl.js +2 -0
  94. package/lib/js/entity/Entity.d.ts +278 -19
  95. package/lib/js/entity/Entity.js +483 -63
  96. package/lib/js/entity/EntityCollection.d.ts +8 -9
  97. package/lib/js/entity/EntityCollection.js +48 -45
  98. package/lib/js/entity/GeoObject.d.ts +141 -36
  99. package/lib/js/entity/GeoObject.js +153 -90
  100. package/lib/js/entity/GeoObjectHandler.d.ts +39 -63
  101. package/lib/js/entity/GeoObjectHandler.js +198 -295
  102. package/lib/js/entity/InstanceData.d.ts +76 -0
  103. package/lib/js/entity/InstanceData.js +344 -0
  104. package/lib/js/entity/Polyline.d.ts +19 -6
  105. package/lib/js/entity/Polyline.js +76 -36
  106. package/lib/js/entity/PolylineHandler.d.ts +7 -0
  107. package/lib/js/entity/PolylineHandler.js +26 -1
  108. package/lib/js/index.d.ts +2 -1
  109. package/lib/js/index.js +2 -1
  110. package/lib/js/layer/Bing.js +2 -2
  111. package/lib/js/layer/Vector.d.ts +4 -0
  112. package/lib/js/layer/Vector.js +16 -0
  113. package/lib/js/light/LightSource.d.ts +1 -139
  114. package/lib/js/light/LightSource.js +21 -227
  115. package/lib/js/math/Quat.d.ts +46 -33
  116. package/lib/js/math/Quat.js +91 -90
  117. package/lib/js/math/Ray.d.ts +10 -4
  118. package/lib/js/math/Ray.js +20 -4
  119. package/lib/js/math/Vec3.d.ts +15 -0
  120. package/lib/js/math/Vec3.js +30 -1
  121. package/lib/js/math.d.ts +2 -2
  122. package/lib/js/math.js +3 -3
  123. package/lib/js/quadTree/EntityCollectionNode.d.ts +2 -2
  124. package/lib/js/quadTree/EntityCollectionNode.js +8 -8
  125. package/lib/js/quadTree/Node.d.ts +1 -1
  126. package/lib/js/quadTree/Node.js +2 -2
  127. package/lib/js/quadTree/QuadTreeStrategy.js +1 -1
  128. package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +1 -1
  129. package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.js +2 -2
  130. package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +1 -1
  131. package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.js +2 -2
  132. package/lib/js/renderer/Renderer.d.ts +63 -44
  133. package/lib/js/renderer/Renderer.js +260 -263
  134. package/lib/js/renderer/RendererEvents.d.ts +1 -0
  135. package/lib/js/renderer/RendererEvents.js +2 -1
  136. package/lib/js/scene/Planet.d.ts +11 -7
  137. package/lib/js/scene/Planet.js +109 -87
  138. package/lib/js/scene/RenderNode.d.ts +10 -25
  139. package/lib/js/scene/RenderNode.js +70 -58
  140. package/lib/js/shaders/depth.js +2 -5
  141. package/lib/js/shaders/drawnode.d.ts +1 -0
  142. package/lib/js/shaders/drawnode.js +51 -52
  143. package/lib/js/shaders/geoObject.d.ts +1 -0
  144. package/lib/js/shaders/geoObject.js +154 -91
  145. package/lib/js/shaders/polyline.js +68 -51
  146. package/lib/js/shaders/utils.d.ts +1 -1
  147. package/lib/js/shaders/utils.js +11 -0
  148. package/lib/js/ui/Checkbox.d.ts +31 -0
  149. package/lib/js/ui/Checkbox.js +110 -0
  150. package/lib/js/ui/Color.js +2 -1
  151. package/lib/js/ui/Dialog.d.ts +3 -0
  152. package/lib/js/ui/Dialog.js +20 -0
  153. package/lib/js/ui/Input.d.ts +32 -0
  154. package/lib/js/ui/Input.js +107 -0
  155. package/lib/js/ui/View.d.ts +3 -1
  156. package/lib/js/ui/View.js +6 -0
  157. package/lib/js/utils/objParser.d.ts +44 -12
  158. package/lib/js/utils/objParser.js +241 -149
  159. package/lib/js/utils/shared.d.ts +22 -0
  160. package/lib/js/utils/shared.js +34 -0
  161. package/lib/js/webgl/BaseFramebuffer.d.ts +0 -1
  162. package/lib/js/webgl/Framebuffer.d.ts +35 -8
  163. package/lib/js/webgl/Framebuffer.js +136 -29
  164. package/lib/js/webgl/Handler.d.ts +1 -0
  165. package/lib/js/webgl/Handler.js +11 -1
  166. package/lib/js/webgl/Program.js +0 -8
  167. package/package.json +4 -2
@@ -4,6 +4,7 @@ import { createRendererEvents } from "./RendererEvents";
4
4
  import { depth } from "../shaders/depth";
5
5
  import { Framebuffer, Multisample } from "../webgl/index";
6
6
  import { FontAtlas } from "../utils/FontAtlas";
7
+ import { Handler } from "../webgl/Handler";
7
8
  import { input } from "../input/input";
8
9
  import { isEmpty } from "../utils/shared";
9
10
  import { LabelWorker } from "../entity/LabelWorker";
@@ -13,10 +14,11 @@ import { toneMapping } from "../shaders/toneMapping";
13
14
  import { TextureAtlas } from "../utils/TextureAtlas";
14
15
  import { Vec2 } from "../math/Vec2";
15
16
  import { Vec3 } from "../math/Vec3";
17
+ import { Vec4 } from "../math/Vec4";
16
18
  const MSAA_DEFAULT = 0;
17
19
  let __pickingCallbackCounter__ = 0;
18
20
  let __depthCallbackCounter__ = 0;
19
- let __distanceCallbackCounter__ = 0;
21
+ let _tempDepth_ = new Float32Array(2);
20
22
  function clientWaitAsync(gl, sync, flags) {
21
23
  return new Promise((resolve, reject) => {
22
24
  function check() {
@@ -34,109 +36,27 @@ function clientWaitAsync(gl, sync, flags) {
34
36
  check();
35
37
  });
36
38
  }
37
- /**
38
- * Represents high level WebGL context interface that starts WebGL handler working in real time.
39
- * @class
40
- * @param {Handler} handler - WebGL handler context.
41
- * @param {Object} [params] - Renderer parameters:
42
- * @fires EventsHandler<RendererEventsType>#draw
43
- * @fires EventsHandler<RendererEventsType>#resize
44
- * @fires EventsHandler<RendererEventsType>#mousemove
45
- * @fires EventsHandler<RendererEventsType>#mousestop
46
- * @fires EventsHandler<RendererEventsType>#lclick
47
- * @fires EventsHandler<RendererEventsType>#rclick
48
- * @fires EventsHandler<RendererEventsType>#mclick
49
- * @fires EventsHandler<RendererEventsType>#ldblclick
50
- * @fires EventsHandler<RendererEventsType>#rdblclick
51
- * @fires EventsHandler<RendererEventsType>#mdblclick
52
- * @fires EventsHandler<RendererEventsType>#lup
53
- * @fires EventsHandler<RendererEventsType>#rup
54
- * @fires EventsHandler<RendererEventsType>#mup
55
- * @fires EventsHandler<RendererEventsType>#ldown
56
- * @fires EventsHandler<RendererEventsType>#rdown
57
- * @fires EventsHandler<RendererEventsType>#mdown
58
- * @fires EventsHandler<RendererEventsType>#lhold
59
- * @fires EventsHandler<RendererEventsType>#rhold
60
- * @fires EventsHandler<RendererEventsType>#mhold
61
- * @fires EventsHandler<RendererEventsType>#mousewheel
62
- * @fires EventsHandler<RendererEventsType>#touchstart
63
- * @fires EventsHandler<RendererEventsType>#touchend
64
- * @fires EventsHandler<RendererEventsType>#touchcancel
65
- * @fires EventsHandler<RendererEventsType>#touchmove
66
- * @fires EventsHandler<RendererEventsType>#doubletouch
67
- * @fires EventsHandler<RendererEventsType>#touchleave
68
- * @fires EventsHandler<RendererEventsType>#touchenter
69
- */
70
- let __resizeTimeout;
71
39
  class Renderer {
72
40
  constructor(handler, params = {}) {
73
- this._readPickingBuffer_webgl1 = () => {
74
- this.pickingFramebuffer.activate();
75
- this.pickingFramebuffer.readAllPixels(this._tempPickingPix_);
76
- this.pickingFramebuffer.deactivate();
77
- };
78
- this._readPickingBuffer_webgl2 = () => {
79
- const gl = this.handler.gl;
80
- const buf = this._pickingPixelBuffer;
81
- if (!this._skipPickingFrame) {
82
- this._skipPickingFrame = true;
83
- let dest = this._tempPickingPix_;
84
- let w = this.pickingFramebuffer.width, h = this.pickingFramebuffer.height;
85
- this.pickingFramebuffer.activate();
86
- gl.bindBuffer(gl.PIXEL_PACK_BUFFER, buf);
87
- gl.bufferData(gl.PIXEL_PACK_BUFFER, dest.byteLength, gl.STREAM_READ);
88
- gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, 0);
89
- gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
90
- this.pickingFramebuffer.deactivate();
91
- const sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0);
92
- gl.flush();
93
- clientWaitAsync(gl, sync, 0).then(() => {
94
- this._skipPickingFrame = false;
95
- gl.deleteSync(sync);
96
- gl.bindBuffer(gl.PIXEL_PACK_BUFFER, buf);
97
- gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, dest);
98
- gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
99
- });
100
- }
101
- };
102
- this._readDistanceBuffer_webgl1 = () => {
103
- this.distanceFramebuffer.activate();
104
- this.distanceFramebuffer.readAllPixels(this._tempDistancePix_);
105
- this.distanceFramebuffer.deactivate();
106
- };
107
- this._readDistanceBuffer_webgl2 = () => {
108
- const gl = this.handler.gl;
109
- const buf = this._distancePixelBuffer;
110
- if (!this._skipDistanceFrame) {
111
- this._skipDistanceFrame = true;
112
- let dest = this._tempDistancePix_;
113
- let w = this.distanceFramebuffer.width, h = this.distanceFramebuffer.height;
114
- this.distanceFramebuffer.activate();
115
- gl.bindBuffer(gl.PIXEL_PACK_BUFFER, buf);
116
- gl.bufferData(gl.PIXEL_PACK_BUFFER, dest.byteLength, gl.STREAM_READ);
117
- gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, 0);
118
- gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
119
- this.distanceFramebuffer.deactivate();
120
- const sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0);
121
- gl.flush();
122
- clientWaitAsync(gl, sync, 0).then(() => {
123
- this._skipDistanceFrame = false;
124
- gl.deleteSync(sync);
125
- gl.bindBuffer(gl.PIXEL_PACK_BUFFER, buf);
126
- gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, dest);
127
- gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
128
- });
129
- }
130
- };
131
41
  this.div = null;
132
- this.handler = handler;
42
+ if (handler instanceof Handler) {
43
+ this.handler = handler;
44
+ }
45
+ else {
46
+ this.handler = new Handler(handler, {
47
+ pixelRatio: params.dpi || (window.devicePixelRatio + 0.15),
48
+ autoActivate: true
49
+ });
50
+ }
133
51
  this.exposure = params.exposure || 3.01;
134
52
  this.gamma = params.gamma || 0.47;
135
53
  this.whitepoint = 1.0;
136
54
  this.brightThreshold = 0.9;
137
55
  this._renderNodesArr = [];
138
56
  this.renderNodes = {};
139
- this.activeCamera = null;
57
+ this.activeCamera = new Camera(this, {
58
+ eye: new Vec3(0, 0, 0), look: new Vec3(0, 0, -1), up: new Vec3(0, 1, 0)
59
+ });
140
60
  this.events = createRendererEvents(this);
141
61
  this.controls = {};
142
62
  if (params.controls) {
@@ -148,10 +68,6 @@ class Renderer {
148
68
  this.colorObjects = new Map();
149
69
  this._pickingCallbacks = [];
150
70
  this.pickingFramebuffer = null;
151
- this._tempPickingPix_ = new Uint8Array([]);
152
- this.distanceFramebuffer = null;
153
- this._distanceCallbacks = [];
154
- this._tempDistancePix_ = new Uint8Array([]);
155
71
  this._depthCallbacks = [];
156
72
  this.depthFramebuffer = null;
157
73
  let urlParams = new URLSearchParams(location.search);
@@ -187,20 +103,14 @@ class Renderer {
187
103
  * @type {FontAtlas}
188
104
  */
189
105
  this.fontAtlas = new FontAtlas(params.fontsSrc);
190
- this._entityCollections = [];
106
+ this._entityCollections = [[]];
191
107
  this._currentOutput = "screen";
192
108
  this._fnScreenFrame = null;
193
109
  this.labelWorker = new LabelWorker(4);
194
- this.__useDistanceFramebuffer__ = true;
195
110
  this.screenDepthFramebuffer = null;
196
111
  this.screenFramePositionBuffer = null;
197
112
  this.screenTexture = {};
198
113
  this.outputTexture = null;
199
- this._skipDistanceFrame = false;
200
- this._distancePixelBuffer = null;
201
- this._skipPickingFrame = false;
202
- this._pickingPixelBuffer = null;
203
- this._readDistanceBuffer = this._readDistanceBuffer_webgl2;
204
114
  this._readPickingBuffer = this._readPickingBuffer_webgl2;
205
115
  if (params.autoActivate || isEmpty(params.autoActivate)) {
206
116
  this.start();
@@ -218,6 +128,9 @@ class Renderer {
218
128
  gl.blendEquation(gl.FUNC_ADD);
219
129
  gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE);
220
130
  }
131
+ setRelativeCenter(c) {
132
+ this.events.dispatch(this.events.changerelativecenter, c || this.activeCamera.eye);
133
+ }
221
134
  /**
222
135
  * Sets renderer events activity.
223
136
  * @param {Boolean} activity - Events activity.
@@ -240,21 +153,6 @@ class Renderer {
240
153
  }
241
154
  }
242
155
  }
243
- addDistanceCallback(sender, callback) {
244
- let id = __distanceCallbackCounter__++;
245
- this._distanceCallbacks.push({
246
- id: id, callback: callback, sender: sender
247
- });
248
- return id;
249
- }
250
- removeDistanceCallback(id) {
251
- for (let i = 0; i < this._distanceCallbacks.length; i++) {
252
- if (id === this._distanceCallbacks[i].id) {
253
- this._distanceCallbacks.splice(i, 1);
254
- break;
255
- }
256
- }
257
- }
258
156
  /**
259
157
  * Adds picking rendering callback function.
260
158
  * @param {object} sender - Callback context.
@@ -406,9 +304,6 @@ class Renderer {
406
304
  this.handler.setFrameCallback(() => {
407
305
  this.draw();
408
306
  });
409
- this.activeCamera = new Camera(this, {
410
- eye: new Vec3(0, 0, 0), look: new Vec3(0, 0, -1), up: new Vec3(0, 1, 0)
411
- });
412
307
  this.events.initialize();
413
308
  // Bind console key
414
309
  this.events.on("charkeypress", input.KEY_APOSTROPHE, function () {
@@ -416,23 +311,26 @@ class Renderer {
416
311
  });
417
312
  this.handler.addProgram(screenFrame());
418
313
  this.pickingFramebuffer = new Framebuffer(this.handler, {
419
- width: 640, height: 480
314
+ width: 640,
315
+ height: 480,
316
+ targets: [{
317
+ readAsync: true
318
+ }]
420
319
  });
421
320
  this.pickingFramebuffer.init();
422
- this._tempPickingPix_ = new Uint8Array(this.pickingFramebuffer.width * this.pickingFramebuffer.height * 4);
423
- this.distanceFramebuffer = new Framebuffer(this.handler, {
424
- width: 320, height: 240
425
- });
426
- this.distanceFramebuffer.init();
427
- this._tempDistancePix_ = new Uint8Array(this.distanceFramebuffer.width * this.distanceFramebuffer.height * 4);
428
- //this._tempDistancePix_ = new Uint8Array(4);
429
321
  this.depthFramebuffer = new Framebuffer(this.handler, {
430
- size: 2,
431
- internalFormat: ["RGBA", "DEPTH_COMPONENT24"],
432
- format: ["RGBA", "DEPTH_COMPONENT"],
433
- type: ["UNSIGNED_BYTE", "UNSIGNED_INT"],
434
- attachment: ["COLOR_ATTACHMENT", "DEPTH_ATTACHMENT"],
435
- useDepth: false
322
+ targets: [{
323
+ internalFormat: "RGBA",
324
+ type: "UNSIGNED_BYTE",
325
+ attachment: "COLOR_ATTACHMENT",
326
+ readAsync: true
327
+ }, {
328
+ internalFormat: "RGBA16F",
329
+ type: "FLOAT",
330
+ attachment: "COLOR_ATTACHMENT",
331
+ readAsync: true
332
+ }],
333
+ useDepth: true
436
334
  });
437
335
  this.depthFramebuffer.init();
438
336
  this.screenDepthFramebuffer = new Framebuffer(this.handler, {
@@ -440,7 +338,6 @@ class Renderer {
440
338
  });
441
339
  this.screenDepthFramebuffer.init();
442
340
  if (this.handler.gl.type === "webgl") {
443
- this._readDistanceBuffer = this._readDistanceBuffer_webgl1;
444
341
  this._readPickingBuffer = this._readPickingBuffer_webgl1;
445
342
  this.sceneFramebuffer = new Framebuffer(this.handler);
446
343
  this.sceneFramebuffer.init();
@@ -448,7 +345,6 @@ class Renderer {
448
345
  this.screenTexture = {
449
346
  screen: this.sceneFramebuffer.textures[0],
450
347
  picking: this.pickingFramebuffer.textures[0],
451
- distance: this.distanceFramebuffer.textures[0],
452
348
  depth: this.screenDepthFramebuffer.textures[0]
453
349
  };
454
350
  }
@@ -469,10 +365,12 @@ class Renderer {
469
365
  this.blitFramebuffer = new Framebuffer(this.handler, {
470
366
  size: 1,
471
367
  useDepth: false,
472
- internalFormat: this._internalFormat,
473
- format: this._format,
474
- type: this._type,
475
- filter: "NEAREST"
368
+ targets: [{
369
+ internalFormat: this._internalFormat,
370
+ format: this._format,
371
+ type: this._type,
372
+ filter: "NEAREST"
373
+ }]
476
374
  });
477
375
  this.blitFramebuffer.init();
478
376
  this.toneMappingFramebuffer = new Framebuffer(this.handler, {
@@ -483,11 +381,9 @@ class Renderer {
483
381
  this.screenTexture = {
484
382
  screen: this.toneMappingFramebuffer.textures[0],
485
383
  picking: this.pickingFramebuffer.textures[0],
486
- distance: this.distanceFramebuffer.textures[0],
487
384
  depth: this.screenDepthFramebuffer.textures[0],
488
385
  frustum: this.depthFramebuffer.textures[0]
489
386
  };
490
- this._initReadPixelsBuffers();
491
387
  }
492
388
  this.handler.ONCANVASRESIZE = () => {
493
389
  this._resizeStart();
@@ -505,17 +401,6 @@ class Renderer {
505
401
  this._initializeRenderNodes();
506
402
  this._initializeControls();
507
403
  }
508
- _initReadPixelsBuffers() {
509
- let gl = this.handler.gl;
510
- this._distancePixelBuffer = gl.createBuffer();
511
- gl.bindBuffer(gl.PIXEL_PACK_BUFFER, this._distancePixelBuffer);
512
- gl.bufferData(gl.PIXEL_PACK_BUFFER, this.distanceFramebuffer.width * this.distanceFramebuffer.height * 4, gl.STREAM_READ);
513
- gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
514
- this._pickingPixelBuffer = gl.createBuffer();
515
- gl.bindBuffer(gl.PIXEL_PACK_BUFFER, this._pickingPixelBuffer);
516
- gl.bufferData(gl.PIXEL_PACK_BUFFER, this.pickingFramebuffer.width * this.pickingFramebuffer.height * 4, gl.STREAM_READ);
517
- gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
518
- }
519
404
  _initializeControls() {
520
405
  let temp = this.controls;
521
406
  this.controls = {};
@@ -544,19 +429,17 @@ class Renderer {
544
429
  this.sceneFramebuffer.setSize(c.width, c.height);
545
430
  this.blitFramebuffer && this.blitFramebuffer.setSize(c.width, c.height, true);
546
431
  this.toneMappingFramebuffer && this.toneMappingFramebuffer.setSize(c.width, c.height, true);
547
- this.depthFramebuffer && this.depthFramebuffer.setSize(c.clientWidth, c.clientHeight, true);
548
432
  this.screenDepthFramebuffer && this.screenDepthFramebuffer.setSize(c.clientWidth, c.clientHeight, true);
433
+ this.depthFramebuffer && this.depthFramebuffer.setSize(c.clientWidth, c.clientHeight, true);
549
434
  if (this.handler.gl.type === "webgl") {
550
435
  this.screenTexture.screen = this.sceneFramebuffer.textures[0];
551
436
  this.screenTexture.picking = this.pickingFramebuffer.textures[0];
552
- this.screenTexture.distance = this.distanceFramebuffer.textures[0];
553
437
  this.screenTexture.depth = this.screenDepthFramebuffer.textures[0];
554
438
  this.screenTexture.frustum = this.depthFramebuffer.textures[0];
555
439
  }
556
440
  else {
557
441
  this.screenTexture.screen = this.toneMappingFramebuffer.textures[0];
558
442
  this.screenTexture.picking = this.pickingFramebuffer.textures[0];
559
- this.screenTexture.distance = this.distanceFramebuffer.textures[0];
560
443
  this.screenTexture.depth = this.screenDepthFramebuffer.textures[0];
561
444
  this.screenTexture.frustum = this.depthFramebuffer.textures[0];
562
445
  }
@@ -629,35 +512,27 @@ class Renderer {
629
512
  /**
630
513
  * TODO: replace with cache friendly linked list by BillboardHandler, LabelHandler etc.
631
514
  */
632
- enqueueEntityCollectionsToDraw(ecArr) {
633
- this._entityCollections.push.apply(this._entityCollections, ecArr);
515
+ enqueueEntityCollectionsToDraw(ecArr, depthOrder = 0) {
516
+ if (!this._entityCollections[depthOrder]) {
517
+ this._entityCollections[depthOrder] = [];
518
+ }
519
+ this._entityCollections[depthOrder].push(...ecArr);
634
520
  }
635
521
  /**
636
- * Draws opaque items entity collections.
637
522
  * @protected
638
523
  */
639
- _drawOpaqueEntityCollections() {
640
- let ec = this._entityCollections;
524
+ _drawEntityCollections(depthOrder) {
525
+ let ec = this._entityCollections[depthOrder];
641
526
  if (ec.length) {
527
+ let gl = this.handler.gl;
642
528
  this.enableBlendDefault();
643
- // pointClouds pass
529
+ // Point Clouds
644
530
  let i = ec.length;
645
531
  while (i--) {
646
532
  ec[i]._fadingOpacity && ec[i].pointCloudHandler.draw();
647
533
  }
648
- }
649
- }
650
- /**
651
- * Draws transparent items entity collections.
652
- * @protected
653
- */
654
- _drawTransparentEntityCollections() {
655
- let ec = this._entityCollections;
656
- if (ec.length) {
657
- let gl = this.handler.gl;
658
- this.enableBlendDefault();
659
534
  // GeoObjects
660
- let i = ec.length;
535
+ i = ec.length;
661
536
  while (i--) {
662
537
  let eci = ec[i];
663
538
  if (ec[i]._fadingOpacity) {
@@ -700,9 +575,75 @@ class Renderer {
700
575
  }
701
576
  }
702
577
  }
703
- _clearEntityCollectionQueue() {
704
- this._entityCollections.length = 0;
705
- this._entityCollections = [];
578
+ _drawPickingEntityCollections(depthOrder) {
579
+ let ec = this._entityCollections[depthOrder];
580
+ if (ec.length) {
581
+ // billboard pass
582
+ let i = ec.length;
583
+ while (i--) {
584
+ ec[i]._fadingOpacity && ec[i].billboardHandler.drawPicking();
585
+ }
586
+ // geoObject pass
587
+ i = ec.length;
588
+ while (i--) {
589
+ ec[i]._fadingOpacity && ec[i].geoObjectHandler.drawPicking();
590
+ }
591
+ // label pass
592
+ i = ec.length;
593
+ while (i--) {
594
+ ec[i]._fadingOpacity && ec[i].labelHandler.drawPicking();
595
+ }
596
+ // ray pass
597
+ i = ec.length;
598
+ while (i--) {
599
+ ec[i]._fadingOpacity && ec[i].rayHandler.drawPicking();
600
+ }
601
+ // polyline pass
602
+ i = ec.length;
603
+ while (i--) {
604
+ ec[i]._visibility && ec[i].polylineHandler.drawPicking();
605
+ }
606
+ //Strip pass
607
+ i = ec.length;
608
+ while (i--) {
609
+ ec[i]._visibility && ec[i].stripHandler.drawPicking();
610
+ }
611
+ // //pointClouds pass
612
+ // i = ec.length;
613
+ // while (i--) {
614
+ // ec[i]._visibility && ec[i].pointCloudHandler.drawPicking();
615
+ // }
616
+ }
617
+ }
618
+ _drawDepthEntityCollections(depthOrder) {
619
+ let ec = this._entityCollections[depthOrder];
620
+ if (ec.length) {
621
+ // geoObject pass
622
+ let i = ec.length;
623
+ while (i--) {
624
+ ec[i]._fadingOpacity && ec[i].geoObjectHandler.drawDepth();
625
+ }
626
+ // i = ec.length;
627
+ // while (i--) {
628
+ // ec[i]._fadingOpacity && ec[i].rayHandler.drawDepth();
629
+ // }
630
+ //
631
+ // // polyline pass
632
+ // i = ec.length;
633
+ // while (i--) {
634
+ // ec[i]._visibility && ec[i].polylineHandler.drawDepth();
635
+ // }
636
+ //
637
+ // //Strip pass
638
+ // i = ec.length;
639
+ // while (i--) {
640
+ // ec[i]._visibility && ec[i].stripHandler.drawDepth();
641
+ // }
642
+ }
643
+ }
644
+ _clearEntityCollectionQueue(depthOrder) {
645
+ this._entityCollections[depthOrder].length = 0;
646
+ this._entityCollections[depthOrder] = [];
706
647
  }
707
648
  /**
708
649
  * Draw nodes.
@@ -725,6 +666,9 @@ class Renderer {
725
666
  // Rendering scene nodes and entityCollections
726
667
  let rn = this._renderNodesArr;
727
668
  let k = frustums.length;
669
+ //
670
+ // RenderNodes PASS
671
+ //
728
672
  while (k--) {
729
673
  this.activeCamera.setCurrentFrustum(k);
730
674
  gl.clear(gl.DEPTH_BUFFER_BIT);
@@ -732,30 +676,41 @@ class Renderer {
732
676
  while (i--) {
733
677
  rn[i].preDrawNode();
734
678
  }
735
- this._drawOpaqueEntityCollections();
736
679
  i = rn.length;
737
680
  while (i--) {
738
681
  this.enableBlendDefault();
739
682
  rn[i].drawNode();
740
683
  }
741
- this._drawTransparentEntityCollections();
742
- this._clearEntityCollectionQueue();
684
+ this._drawEntityCollections(0);
743
685
  e.dispatch(e.drawtransparent, this);
744
686
  if (pointerEvent && !mouseHold) {
745
- this._drawPickingBuffer();
687
+ this._drawPickingBuffer(0);
688
+ }
689
+ this._drawDepthBuffer(0);
690
+ this._clearEntityCollectionQueue(0);
691
+ }
692
+ //
693
+ // EntityCollections PASS
694
+ //
695
+ for (let i = 1; i < this._entityCollections.length; i++) {
696
+ gl.clear(gl.DEPTH_BUFFER_BIT);
697
+ let k = frustums.length;
698
+ while (k--) {
699
+ this.activeCamera.setCurrentFrustum(k);
700
+ this._drawEntityCollections(i);
701
+ if (pointerEvent && !mouseHold) {
702
+ this._drawPickingBuffer(i);
703
+ }
704
+ this._drawDepthBuffer(i);
746
705
  }
747
- this.__useDistanceFramebuffer__ && this._drawDistanceBuffer();
706
+ this._clearEntityCollectionQueue(i);
748
707
  }
749
708
  sceneFramebuffer.deactivate();
750
709
  this.blitFramebuffer && sceneFramebuffer.blitTo(this.blitFramebuffer, 0);
751
710
  if (pointerEvent) {
752
- if (h.isWebGl2()) {
753
- // It works ONLY for 0 (closest) frustum
754
- this._drawDepthBuffer();
755
- }
756
711
  this._readPickingBuffer();
757
712
  }
758
- this.__useDistanceFramebuffer__ && this._readDistanceBuffer();
713
+ this._readDepthBuffer();
759
714
  // Tone mapping followed by rendering on the screen
760
715
  this._fnScreenFrame();
761
716
  e.dispatch(e.postdraw, this);
@@ -812,87 +767,86 @@ class Renderer {
812
767
  * Draw picking objects framebuffer.
813
768
  * @private
814
769
  */
815
- _drawPickingBuffer() {
770
+ _drawPickingBuffer(depthOrder) {
816
771
  this.pickingFramebuffer.activate();
817
772
  let h = this.handler;
818
773
  let gl = h.gl;
819
- if (this.activeCamera.isFirstPass) {
774
+ if (this.activeCamera.isFirstPass && depthOrder === 0) {
820
775
  gl.clearColor(0.0, 0.0, 0.0, 1.0);
821
776
  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
822
777
  }
823
778
  else {
824
779
  gl.clear(gl.DEPTH_BUFFER_BIT);
825
780
  }
826
- let dp = this._pickingCallbacks;
827
- for (let i = 0, len = dp.length; i < len; i++) {
828
- //
829
- // draw picking scenes, usually we don't need blending,
830
- // but sometimes set it manually in the callbacks
831
- //
832
- gl.disable(gl.BLEND);
833
- /**
834
- * This callback renders picking frame.
835
- */
836
- dp[i].callback.call(dp[i].sender);
837
- gl.enable(gl.BLEND);
781
+ //
782
+ // draw picking scenes, usually we don't need blending,
783
+ // but sometimes set it manually in the callbacks
784
+ //
785
+ gl.disable(gl.BLEND);
786
+ if (depthOrder === 0) {
787
+ let dp = this._pickingCallbacks;
788
+ for (let i = 0, len = dp.length; i < len; i++) {
789
+ /**
790
+ * This callback renders picking frame.
791
+ */
792
+ dp[i].callback.call(dp[i].sender);
793
+ }
838
794
  }
795
+ this._drawPickingEntityCollections(depthOrder);
796
+ gl.enable(gl.BLEND);
839
797
  this.pickingFramebuffer.deactivate();
840
798
  }
841
- /**
842
- * Draw picking objects framebuffer.
843
- * @protected
844
- */
845
- _drawDistanceBuffer() {
846
- this.distanceFramebuffer.activate();
799
+ _drawDepthBuffer(depthOrder) {
800
+ this.depthFramebuffer.activate();
847
801
  let h = this.handler;
848
802
  let gl = h.gl;
849
- if (this.activeCamera.isFirstPass) {
803
+ gl.disable(gl.BLEND);
804
+ if (this.activeCamera.isFirstPass && depthOrder === 0) {
850
805
  gl.clearColor(0.0, 0.0, 0.0, 1.0);
851
806
  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
852
807
  }
853
808
  else {
854
809
  gl.clear(gl.DEPTH_BUFFER_BIT);
855
810
  }
856
- gl.disable(gl.BLEND);
857
- let dp = this._distanceCallbacks;
858
- let i = dp.length;
859
- while (i--) {
860
- /**
861
- * This callback renders distance frame.
862
- */
863
- dp[i].callback.call(dp[i].sender);
864
- }
865
- gl.enable(gl.BLEND);
866
- this.distanceFramebuffer.deactivate();
867
- }
868
- _drawDepthBuffer() {
869
- this.depthFramebuffer.activate();
870
- let h = this.handler;
871
- let gl = h.gl;
872
- gl.clearColor(0.0, 0.0, 0.0, 1.0);
873
- gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
874
- gl.enable(gl.DEPTH_TEST);
875
- let dp = this._depthCallbacks;
876
- let i = dp.length;
877
- while (i--) {
878
- /**
879
- * This callback renders depth frame.
880
- */
881
- dp[i].callback.call(dp[i].sender);
811
+ if (depthOrder === 0) {
812
+ let dp = this._depthCallbacks;
813
+ let i = dp.length;
814
+ while (i--) {
815
+ /**
816
+ * This callback renders depth frame.
817
+ */
818
+ dp[i].callback.call(dp[i].sender);
819
+ }
882
820
  }
821
+ this._drawDepthEntityCollections(depthOrder);
883
822
  this.depthFramebuffer.deactivate();
884
823
  //
885
- // PASS to depth visualization
886
- this.screenDepthFramebuffer.activate();
887
- let sh = h.programs.depth, p = sh._program;
888
- gl.bindBuffer(gl.ARRAY_BUFFER, this.screenFramePositionBuffer);
889
- gl.vertexAttribPointer(p.attributes.corners, 2, gl.FLOAT, false, 0, 0);
890
- sh.activate();
891
- gl.activeTexture(gl.TEXTURE0);
892
- gl.bindTexture(gl.TEXTURE_2D, this.depthFramebuffer.textures[1]);
893
- gl.uniform1i(p.uniforms.depthTexture, 0);
894
- gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
895
- this.screenDepthFramebuffer.deactivate();
824
+ // DEBUG SCREEN OUTPUTS
825
+ //
826
+ if (this._currentOutput === "depth" || this._currentOutput === "frustum") {
827
+ //
828
+ // PASS to depth visualization
829
+ this.screenDepthFramebuffer.activate();
830
+ let sh = h.programs.depth, p = sh._program;
831
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.screenFramePositionBuffer);
832
+ gl.vertexAttribPointer(p.attributes.corners, 2, gl.FLOAT, false, 0, 0);
833
+ sh.activate();
834
+ gl.activeTexture(gl.TEXTURE0);
835
+ gl.bindTexture(gl.TEXTURE_2D, this.depthFramebuffer.textures[1]);
836
+ gl.uniform1i(p.uniforms.depthTexture, 0);
837
+ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
838
+ this.screenDepthFramebuffer.deactivate();
839
+ gl.enable(gl.BLEND);
840
+ }
841
+ }
842
+ _readDepthBuffer() {
843
+ this.depthFramebuffer.readPixelBuffersAsync();
844
+ }
845
+ _readPickingBuffer_webgl1() {
846
+ this.pickingFramebuffer.readPixelBuffersAsync();
847
+ }
848
+ _readPickingBuffer_webgl2() {
849
+ this.pickingFramebuffer.readPixelBuffersAsync();
896
850
  }
897
851
  readPickingColor(x, y, outColor) {
898
852
  let w = this.pickingFramebuffer.width;
@@ -900,19 +854,65 @@ class Renderer {
900
854
  x = Math.round(x * w);
901
855
  y = Math.round(y * h);
902
856
  let ind = (y * w + x) * 4;
903
- outColor[0] = this._tempPickingPix_[ind];
904
- outColor[1] = this._tempPickingPix_[ind + 1];
905
- outColor[2] = this._tempPickingPix_[ind + 2];
857
+ let _tempPickingPix_ = this.pickingFramebuffer?.pixelBuffers[0].data;
858
+ if (_tempPickingPix_) {
859
+ outColor[0] = _tempPickingPix_[ind];
860
+ outColor[1] = _tempPickingPix_[ind + 1];
861
+ outColor[2] = _tempPickingPix_[ind + 2];
862
+ }
906
863
  }
907
- readDistanceColor(x, y, outColor) {
908
- let w = this.distanceFramebuffer.width;
909
- let h = this.distanceFramebuffer.height;
864
+ readDepth(x, y, outDepth) {
865
+ let w = this.depthFramebuffer.width;
866
+ let h = this.depthFramebuffer.height;
910
867
  x = Math.round(x * w);
911
868
  y = Math.round(y * h);
912
869
  let ind = (y * w + x) * 4;
913
- outColor[0] = this._tempDistancePix_[ind];
914
- outColor[1] = this._tempDistancePix_[ind + 1];
915
- outColor[2] = this._tempDistancePix_[ind + 2];
870
+ let _tempDepthPix_ = this.depthFramebuffer?.pixelBuffers[1].data;
871
+ let _tempFrustumPix_ = this.depthFramebuffer?.pixelBuffers[0].data;
872
+ if (_tempDepthPix_) {
873
+ outDepth[0] = _tempDepthPix_[ind];
874
+ outDepth[1] = Math.round(_tempFrustumPix_[ind] / 10.0) - 1.0; // See Camera.frustumColorIndex
875
+ }
876
+ }
877
+ /**
878
+ * Returns the distance from the active (screen) camera to the 3d-surface using the defined screen coordinates
879
+ * @public
880
+ * @param {Vec2 | IBaseInputState} px - Screen coordinates.
881
+ * @returns {number | undefined} -
882
+ */
883
+ getDistanceFromPixel(px, camera) {
884
+ camera = camera || this.activeCamera;
885
+ let r = this;
886
+ let cnv = r.handler.canvas;
887
+ let spx = px.x / cnv.width;
888
+ let spy = (cnv.height - px.y) / cnv.height;
889
+ _tempDepth_[0] = _tempDepth_[1] = 0.0;
890
+ let dist = 0;
891
+ r.readDepth(spx, spy, _tempDepth_);
892
+ if (_tempDepth_[1] === -1) {
893
+ return;
894
+ }
895
+ let depth = _tempDepth_[0], frustum = camera.frustums[_tempDepth_[1]];
896
+ if (!frustum)
897
+ return;
898
+ let screenPos = new Vec4(spx * 2.0 - 1.0, spy * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0 * 2.0 - 1.0);
899
+ let viewPosition = frustum.inverseProjectionMatrix.mulVec4(screenPos);
900
+ let dir = px.direction || r.activeCamera.unproject(px.x, px.y);
901
+ dist = -(viewPosition.z / viewPosition.w) / dir.dot(r.activeCamera.getForward());
902
+ return dist;
903
+ }
904
+ /**
905
+ * Returns 3d coordinates from screen coordinates
906
+ * @public
907
+ * @param {Vec2 | IBaseInputState} px - Screen coordinates.
908
+ * @returns {Vec3 | undefined} -
909
+ */
910
+ getCartesianFromPixel(px) {
911
+ let distance = this.getDistanceFromPixel(px);
912
+ if (distance) {
913
+ let direction = px.direction || this.activeCamera.unproject(px.x, px.y);
914
+ return direction.scaleTo(distance).addA(this.activeCamera.eye);
915
+ }
916
916
  }
917
917
  /**
918
918
  * Function starts renderer
@@ -934,6 +934,7 @@ class Renderer {
934
934
  this.div = null;
935
935
  this._renderNodesArr = [];
936
936
  this.renderNodes = {};
937
+ //@ts-ignore
937
938
  this.activeCamera = null;
938
939
  this.controls = {};
939
940
  this.controlsBag = {};
@@ -944,10 +945,6 @@ class Renderer {
944
945
  this.pickingFramebuffer = null;
945
946
  //@ts-ignore
946
947
  this._tempPickingPix_ = null;
947
- this.distanceFramebuffer = null;
948
- this._distanceCallbacks = [];
949
- //@ts-ignore
950
- this._tempDistancePix_ = null;
951
948
  this._depthCallbacks = [];
952
949
  this.depthFramebuffer = null;
953
950
  this.sceneFramebuffer = null;
@@ -957,7 +954,7 @@ class Renderer {
957
954
  //this.billboardsTextureAtlas.clear();
958
955
  //this.geoObjectsTextureAtlas.clear()
959
956
  //this.fontAtlas.clear();
960
- this._entityCollections = [];
957
+ this._entityCollections = [[]];
961
958
  this.handler.ONCANVASRESIZE = null;
962
959
  this.handler.destroy();
963
960
  // @ts-ignore