@openglobus/og 0.12.4 → 0.13.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 (93) hide show
  1. package/README.md +0 -2
  2. package/dist/@openglobus/og.esm.js +2 -2
  3. package/dist/@openglobus/og.esm.js.map +1 -1
  4. package/dist/@openglobus/og.umd.js +2 -2
  5. package/dist/@openglobus/og.umd.js.map +1 -1
  6. package/package.json +7 -7
  7. package/src/og/Extent.js +3 -3
  8. package/src/og/Globe.js +277 -275
  9. package/src/og/ImageCanvas.js +3 -3
  10. package/src/og/LonLat.js +9 -9
  11. package/src/og/QueueArray.js +2 -2
  12. package/src/og/Rectangle.js +5 -5
  13. package/src/og/bv/Box.js +1 -1
  14. package/src/og/bv/Sphere.js +2 -2
  15. package/src/og/camera/Camera.js +1 -1
  16. package/src/og/camera/PlanetCamera.js +649 -646
  17. package/src/og/control/LayerSwitcher.js +1 -1
  18. package/src/og/control/MouseNavigation.js +22 -13
  19. package/src/og/control/MouseWheelZoomControl.js +2 -2
  20. package/src/og/control/ScaleControl.js +1 -1
  21. package/src/og/control/TouchNavigation.js +319 -319
  22. package/src/og/control/ZoomControl.js +132 -132
  23. package/src/og/control/visibleExtent/Segment.js +12 -12
  24. package/src/og/ellipsoid/Ellipsoid.js +577 -567
  25. package/src/og/entity/BillboardHandler.js +878 -1051
  26. package/src/og/entity/Entity.js +1 -1
  27. package/src/og/entity/EntityCollection.js +847 -857
  28. package/src/og/entity/GeoObjectHandler.js +2 -2
  29. package/src/og/entity/LabelHandler.js +888 -1040
  30. package/src/og/entity/LabelWorker.js +0 -6
  31. package/src/og/entity/PointCloud.js +495 -495
  32. package/src/og/entity/Polyline.js +2218 -2222
  33. package/src/og/entity/RayHandler.js +1 -1
  34. package/src/og/layer/CanvasTiles.js +6 -3
  35. package/src/og/layer/GeoImage.js +1 -1
  36. package/src/og/layer/KML.js +5 -5
  37. package/src/og/layer/Layer.js +800 -752
  38. package/src/og/layer/Vector.js +997 -1010
  39. package/src/og/layer/XYZ.js +359 -357
  40. package/src/og/math/Line2.js +4 -4
  41. package/src/og/math/Quat.js +2 -2
  42. package/src/og/math/Ray.js +2 -2
  43. package/src/og/math/Vec2.js +524 -524
  44. package/src/og/math/Vec3.js +900 -900
  45. package/src/og/math/Vec4.js +261 -261
  46. package/src/og/math.js +397 -398
  47. package/src/og/quadTree/EntityCollectionNode.js +389 -387
  48. package/src/og/renderer/Renderer.js +14 -20
  49. package/src/og/renderer/RendererEvents.js +1034 -1045
  50. package/src/og/scene/Planet.js +12 -9
  51. package/src/og/scene/RenderNode.js +347 -354
  52. package/src/og/segment/Segment.js +3 -1
  53. package/src/og/segment/SegmentLonLat.js +1 -4
  54. package/src/og/shaders/billboard.js +220 -204
  55. package/src/og/shaders/drawnode.js +603 -603
  56. package/src/og/shaders/label.js +596 -456
  57. package/src/og/shaders/polyline.js +365 -361
  58. package/src/og/terrain/MapboxTerrain.js +1 -1
  59. package/src/og/utils/FontAtlas.js +209 -200
  60. package/src/og/utils/GeoImageCreator.js +4 -5
  61. package/src/og/utils/TextureAtlas.js +4 -4
  62. package/src/og/utils/VectorTileCreator.js +414 -414
  63. package/src/og/utils/shared.js +1 -1
  64. package/src/og/webgl/Handler.js +28 -60
  65. package/src/og/webgl/Multisample.js +260 -260
  66. package/src/og/webgl/Program.js +411 -396
  67. package/types/bv/Box.d.ts +1 -1
  68. package/types/bv/Sphere.d.ts +1 -1
  69. package/types/camera/PlanetCamera.d.ts +3 -3
  70. package/types/control/LayerSwitcher.d.ts +1 -1
  71. package/types/ellipsoid/Ellipsoid.d.ts +9 -2
  72. package/types/entity/BillboardHandler.d.ts +0 -4
  73. package/types/entity/EntityCollection.d.ts +0 -8
  74. package/types/entity/LabelHandler.d.ts +0 -2
  75. package/types/entity/Polyline.d.ts +1 -1
  76. package/types/layer/KML.d.ts +11 -11
  77. package/types/layer/Layer.d.ts +4 -0
  78. package/types/layer/Vector.d.ts +1 -8
  79. package/types/math/Line2.d.ts +4 -4
  80. package/types/math/Ray.d.ts +2 -2
  81. package/types/math/Vec2.d.ts +1 -1
  82. package/types/math/Vec3.d.ts +1 -1
  83. package/types/math/Vec4.d.ts +2 -2
  84. package/types/math.d.ts +1 -1
  85. package/types/renderer/Renderer.d.ts +1 -1
  86. package/types/renderer/RendererEvents.d.ts +1 -1
  87. package/types/shaders/label.d.ts +1 -1
  88. package/types/utils/FontAtlas.d.ts +3 -2
  89. package/types/utils/TextureAtlas.d.ts +3 -3
  90. package/types/utils/VectorTileCreator.d.ts +4 -4
  91. package/types/utils/shared.d.ts +1 -1
  92. package/types/webgl/Handler.d.ts +6 -31
  93. package/types/webgl/Program.d.ts +2 -0
@@ -1,1052 +1,879 @@
1
- /**
2
- * @module og/entity/BillboardHandler
3
- */
4
-
5
- "use strict";
6
-
7
- import * as shaders from "../shaders/billboard.js";
8
- import { concatTypedArrays, spliceTypedArray } from "../utils/shared.js";
9
- import { LOCK_UPDATE, LOCK_FREE } from "./LabelWorker.js";
10
-
11
- const PICKINGCOLOR_BUFFER = 0;
12
- const POSITION_BUFFER = 1;
13
- const SIZE_BUFFER = 2;
14
- const OFFSET_BUFFER = 3;
15
- const RGBA_BUFFER = 4;
16
- const ROTATION_BUFFER = 5;
17
- const TEXCOORD_BUFFER = 6;
18
- const VERTEX_BUFFER = 7;
19
- const ALIGNEDAXIS_BUFFER = 8;
20
-
21
- /*
22
- * og.BillboardHandler
23
- *
24
- *
25
- */
26
- class BillboardHandler {
27
- /**
28
- *
29
- * @param {*} entityCollection
30
- */
31
- constructor(entityCollection) {
32
- /**
33
- * Picking rendering option.
34
- * @public
35
- * @type {boolean}
36
- */
37
- this.pickingEnabled = true;
38
-
39
- this._entityCollection = entityCollection;
40
-
41
- this._renderer = null;
42
-
43
- this._billboards = [];
44
-
45
- this._positionHighBuffer = null;
46
- this._positionLowBuffer = null;
47
- this._sizeBuffer = null;
48
- this._offsetBuffer = null;
49
- this._rgbaBuffer = null;
50
- this._rotationBuffer = null;
51
- this._texCoordBuffer = null;
52
- this._vertexBuffer = null;
53
- this._alignedAxisBuffer = null;
54
-
55
- this._texCoordArr = new Float32Array();
56
- this._vertexArr = new Float32Array();
57
- this._positionHighArr = new Float32Array();
58
- this._positionLowArr = new Float32Array();
59
- this._sizeArr = new Float32Array();
60
- this._offsetArr = new Float32Array();
61
- this._rgbaArr = new Float32Array();
62
- this._rotationArr = new Float32Array();
63
- this._alignedAxisArr = new Float32Array();
64
-
65
- this._pickingColorBuffer = null;
66
- this._pickingColorArr = new Float32Array();
67
-
68
- this._buffersUpdateCallbacks = [];
69
- this._buffersUpdateCallbacks[PICKINGCOLOR_BUFFER] = this.createPickingColorBuffer;
70
- this._buffersUpdateCallbacks[POSITION_BUFFER] = this.createPositionBuffer;
71
- this._buffersUpdateCallbacks[SIZE_BUFFER] = this.createSizeBuffer;
72
- this._buffersUpdateCallbacks[OFFSET_BUFFER] = this.createOffsetBuffer;
73
- this._buffersUpdateCallbacks[RGBA_BUFFER] = this.createRgbaBuffer;
74
- this._buffersUpdateCallbacks[ROTATION_BUFFER] = this.createRotationBuffer;
75
- this._buffersUpdateCallbacks[TEXCOORD_BUFFER] = this.createTexCoordBuffer;
76
- this._buffersUpdateCallbacks[VERTEX_BUFFER] = this.createVertexBuffer;
77
- this._buffersUpdateCallbacks[ALIGNEDAXIS_BUFFER] = this.createAlignedAxisBuffer;
78
-
79
- this._changedBuffers = new Array(this._buffersUpdateCallbacks.length);
80
-
81
- this.__staticId = BillboardHandler._staticCounter++;
82
- }
83
-
84
- isEqual(handler) {
85
- return handler && (handler.__staticId === this.__staticId);
86
- }
87
-
88
- static get _staticCounter() {
89
- if (!this._counter && this._counter !== 0) {
90
- this._counter = 0;
91
- }
92
- return this._counter;
93
- }
94
-
95
- static set _staticCounter(n) {
96
- this._counter = n;
97
- }
98
-
99
- static concArr(dest, curr) {
100
- for (var i = 0; i < curr.length; i++) {
101
- dest.push(curr[i]);
102
- }
103
- }
104
-
105
- initProgram() {
106
- if (this._renderer.handler) {
107
- if (!this._renderer.handler.programs.billboard) {
108
- this._renderer.handler.addProgram(shaders.billboard_screen());
109
- }
110
-
111
- if (!this._renderer.handler.programs.billboardPicking) {
112
- this._renderer.handler.addProgram(shaders.billboardPicking());
113
- }
114
- }
115
- }
116
-
117
- setRenderer(renderer) {
118
- this._renderer = renderer;
119
- this.initProgram();
120
- }
121
-
122
- refresh() {
123
- var i = this._changedBuffers.length;
124
- while (i--) {
125
- this._changedBuffers[i] = true;
126
- }
127
- }
128
-
129
- _removeBillboards() {
130
- var i = this._billboards.length;
131
- while (i--) {
132
- var bi = this._billboards[i];
133
- bi._handlerIndex = -1;
134
- bi._handler = null;
135
- bi._isReady = false;
136
- bi._lockId = LOCK_FREE;
137
- }
138
- this._billboards.length = 0;
139
- this._billboards = [];
140
- }
141
-
142
- clear() {
143
- this._texCoordArr = null;
144
- this._vertexArr = null;
145
- this._positionHighArr = null;
146
- this._positionLowArr = null;
147
- this._sizeArr = null;
148
- this._offsetArr = null;
149
- this._rgbaArr = null;
150
- this._rotationArr = null;
151
- this._alignedAxisArr = null;
152
- this._pickingColorArr = null;
153
-
154
- this._texCoordArr = new Float32Array();
155
- this._vertexArr = new Float32Array();
156
- this._positionHighArr = new Float32Array();
157
- this._positionLowArr = new Float32Array();
158
- this._sizeArr = new Float32Array();
159
- this._offsetArr = new Float32Array();
160
- this._rgbaArr = new Float32Array();
161
- this._rotationArr = new Float32Array();
162
- this._alignedAxisArr = new Float32Array();
163
- this._pickingColorArr = new Float32Array();
164
-
165
- this._removeBillboards();
166
- this._deleteBuffers();
167
- this.refresh();
168
- }
169
-
170
- _deleteBuffers() {
171
- if (this._renderer) {
172
- var gl = this._renderer.handler.gl;
173
- gl.deleteBuffer(this._positionHighBuffer);
174
- gl.deleteBuffer(this._positionLowBuffer);
175
- gl.deleteBuffer(this._sizeBuffer);
176
- gl.deleteBuffer(this._offsetBuffer);
177
- gl.deleteBuffer(this._rgbaBuffer);
178
- gl.deleteBuffer(this._rotationBuffer);
179
- gl.deleteBuffer(this._vertexBuffer);
180
- gl.deleteBuffer(this._texCoordBuffer);
181
- gl.deleteBuffer(this._alignedAxisBuffer);
182
- gl.deleteBuffer(this._pickingColorBuffer);
183
- }
184
-
185
- this._positionHighBuffer = null;
186
- this._positionLowBuffer = null;
187
- this._sizeBuffer = null;
188
- this._offsetBuffer = null;
189
- this._rgbaBuffer = null;
190
- this._rotationBuffer = null;
191
- this._vertexBuffer = null;
192
- this._texCoordBuffer = null;
193
- this._alignedAxisBuffer = null;
194
- this._pickingColorBuffer = null;
195
- }
196
-
197
- update() {
198
- if (this._renderer) {
199
- var i = this._changedBuffers.length;
200
- while (i--) {
201
- if (this._changedBuffers[i]) {
202
- this._buffersUpdateCallbacks[i].call(this);
203
- this._changedBuffers[i] = false;
204
- }
205
- }
206
- }
207
- }
208
-
209
- add(billboard) {
210
- if (billboard._handlerIndex == -1) {
211
- billboard._isReady = true;
212
- billboard._handler = this;
213
- billboard._handlerIndex = this._billboards.length;
214
- this._billboards.push(billboard);
215
- this._addBillboardToArrays(billboard);
216
- this.refresh();
217
- billboard.setSrc(billboard._src || (billboard._image && billboard._image.src));
218
- }
219
- }
220
-
221
- _addBillboardToArrays(billboard) {
222
- if (billboard._visibility) {
223
- this._vertexArr = concatTypedArrays(
224
- this._vertexArr,
225
- [-0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5]
226
- );
227
- } else {
228
- this._vertexArr = concatTypedArrays(
229
- this._vertexArr,
230
- [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
231
- );
232
- }
233
-
234
- this._texCoordArr = concatTypedArrays(
235
- this._texCoordArr,
236
- [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
237
- );
238
-
239
- var x = billboard._positionHigh.x,
240
- y = billboard._positionHigh.y,
241
- z = billboard._positionHigh.z,
242
- w;
243
- this._positionHighArr = concatTypedArrays(this._positionHighArr, [
244
- x,
245
- y,
246
- z,
247
- x,
248
- y,
249
- z,
250
- x,
251
- y,
252
- z,
253
- x,
254
- y,
255
- z,
256
- x,
257
- y,
258
- z,
259
- x,
260
- y,
261
- z
262
- ]);
263
-
264
- x = billboard._positionLow.x;
265
- y = billboard._positionLow.y;
266
- z = billboard._positionLow.z;
267
- this._positionLowArr = concatTypedArrays(this._positionLowArr, [
268
- x,
269
- y,
270
- z,
271
- x,
272
- y,
273
- z,
274
- x,
275
- y,
276
- z,
277
- x,
278
- y,
279
- z,
280
- x,
281
- y,
282
- z,
283
- x,
284
- y,
285
- z
286
- ]);
287
-
288
- x = billboard._width;
289
- y = billboard._height;
290
- this._sizeArr = concatTypedArrays(this._sizeArr, [x, y, x, y, x, y, x, y, x, y, x, y]);
291
-
292
- x = billboard._offset.x;
293
- y = billboard._offset.y;
294
- z = billboard._offset.z;
295
- this._offsetArr = concatTypedArrays(this._offsetArr, [
296
- x,
297
- y,
298
- z,
299
- x,
300
- y,
301
- z,
302
- x,
303
- y,
304
- z,
305
- x,
306
- y,
307
- z,
308
- x,
309
- y,
310
- z,
311
- x,
312
- y,
313
- z
314
- ]);
315
-
316
- x = billboard._color.x;
317
- y = billboard._color.y;
318
- z = billboard._color.z;
319
- w = billboard._color.w;
320
- this._rgbaArr = concatTypedArrays(this._rgbaArr, [
321
- x,
322
- y,
323
- z,
324
- w,
325
- x,
326
- y,
327
- z,
328
- w,
329
- x,
330
- y,
331
- z,
332
- w,
333
- x,
334
- y,
335
- z,
336
- w,
337
- x,
338
- y,
339
- z,
340
- w,
341
- x,
342
- y,
343
- z,
344
- w
345
- ]);
346
-
347
- x = billboard._rotation;
348
- this._rotationArr = concatTypedArrays(this._rotationArr, [x, x, x, x, x, x]);
349
-
350
- x = billboard._alignedAxis.x;
351
- y = billboard._alignedAxis.y;
352
- z = billboard._alignedAxis.z;
353
- this._alignedAxisArr = concatTypedArrays(this._alignedAxisArr, [
354
- x,
355
- y,
356
- z,
357
- x,
358
- y,
359
- z,
360
- x,
361
- y,
362
- z,
363
- x,
364
- y,
365
- z,
366
- x,
367
- y,
368
- z,
369
- x,
370
- y,
371
- z
372
- ]);
373
-
374
- x = billboard._entity._pickingColor.x / 255;
375
- y = billboard._entity._pickingColor.y / 255;
376
- z = billboard._entity._pickingColor.z / 255;
377
- this._pickingColorArr = concatTypedArrays(this._pickingColorArr, [
378
- x,
379
- y,
380
- z,
381
- x,
382
- y,
383
- z,
384
- x,
385
- y,
386
- z,
387
- x,
388
- y,
389
- z,
390
- x,
391
- y,
392
- z,
393
- x,
394
- y,
395
- z
396
- ]);
397
- }
398
-
399
- _displayPASS() {
400
- var r = this._renderer;
401
- var h = r.handler;
402
- h.programs.billboard.activate();
403
- var sh = h.programs.billboard._program;
404
- var sha = sh.attributes,
405
- shu = sh.uniforms;
406
-
407
- var gl = h.gl,
408
- ec = this._entityCollection;
409
-
410
- gl.polygonOffset(ec.polygonOffsetFactor, ec.polygonOffsetUnits);
411
-
412
- gl.uniform1i(shu.u_texture, 0);
413
-
414
- gl.uniformMatrix4fv(shu.viewMatrix, false, r.activeCamera._viewMatrix._m);
415
- gl.uniformMatrix4fv(shu.projectionMatrix, false, r.activeCamera.getProjectionMatrix());
416
-
417
- gl.uniform3fv(shu.eyePositionHigh, r.activeCamera.eyeHigh);
418
- gl.uniform3fv(shu.eyePositionLow, r.activeCamera.eyeLow);
419
-
420
- gl.uniform3fv(shu.uScaleByDistance, ec.scaleByDistance);
421
-
422
- gl.uniform1f(shu.uOpacity, ec._fadingOpacity);
423
-
424
- gl.uniform2fv(shu.uFloatParams, [
425
- ec.renderNode._planetRadius2 || 0,
426
- r.activeCamera._tanViewAngle_hradOneByHeight
427
- ]);
428
-
429
- gl.bindBuffer(gl.ARRAY_BUFFER, this._texCoordBuffer);
430
- gl.vertexAttribPointer(
431
- sha.a_texCoord,
432
- this._texCoordBuffer.itemSize,
433
- gl.FLOAT,
434
- false,
435
- 0,
436
- 0
437
- );
438
-
439
- gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer);
440
- gl.vertexAttribPointer(sha.a_vertices, this._vertexBuffer.itemSize, gl.FLOAT, false, 0, 0);
441
-
442
- gl.bindBuffer(gl.ARRAY_BUFFER, this._positionHighBuffer);
443
- gl.vertexAttribPointer(
444
- sha.a_positionsHigh,
445
- this._positionHighBuffer.itemSize,
446
- gl.FLOAT,
447
- false,
448
- 0,
449
- 0
450
- );
451
-
452
- gl.bindBuffer(gl.ARRAY_BUFFER, this._positionLowBuffer);
453
- gl.vertexAttribPointer(
454
- sha.a_positionsLow,
455
- this._positionLowBuffer.itemSize,
456
- gl.FLOAT,
457
- false,
458
- 0,
459
- 0
460
- );
461
-
462
- gl.bindBuffer(gl.ARRAY_BUFFER, this._rgbaBuffer);
463
- gl.vertexAttribPointer(sha.a_rgba, this._rgbaBuffer.itemSize, gl.FLOAT, false, 0, 0);
464
-
465
- gl.bindBuffer(gl.ARRAY_BUFFER, this._sizeBuffer);
466
- gl.vertexAttribPointer(sha.a_size, this._sizeBuffer.itemSize, gl.FLOAT, false, 0, 0);
467
-
468
- gl.bindBuffer(gl.ARRAY_BUFFER, this._offsetBuffer);
469
- gl.vertexAttribPointer(sha.a_offset, this._offsetBuffer.itemSize, gl.FLOAT, false, 0, 0);
470
-
471
- gl.bindBuffer(gl.ARRAY_BUFFER, this._rotationBuffer);
472
- gl.vertexAttribPointer(
473
- sha.a_rotation,
474
- this._rotationBuffer.itemSize,
475
- gl.FLOAT,
476
- false,
477
- 0,
478
- 0
479
- );
480
-
481
- gl.bindBuffer(gl.ARRAY_BUFFER, this._alignedAxisBuffer);
482
- gl.vertexAttribPointer(
483
- sha.a_alignedAxis,
484
- this._alignedAxisBuffer.itemSize,
485
- gl.FLOAT,
486
- false,
487
- 0,
488
- 0
489
- );
490
-
491
- gl.drawArrays(gl.TRIANGLES, 0, this._vertexBuffer.numItems);
492
- }
493
-
494
- _pickingPASS() {
495
- var r = this._renderer;
496
- var h = r.handler;
497
- h.programs.billboardPicking.activate();
498
- var sh = h.programs.billboardPicking._program;
499
- var sha = sh.attributes,
500
- shu = sh.uniforms;
501
-
502
- var gl = h.gl,
503
- ec = this._entityCollection;
504
-
505
- gl.polygonOffset(ec.polygonOffsetFactor, ec.polygonOffsetUnits);
506
-
507
- gl.uniformMatrix4fv(shu.viewMatrix, false, r.activeCamera._viewMatrix._m);
508
- gl.uniformMatrix4fv(shu.projectionMatrix, false, r.activeCamera.getProjectionMatrix());
509
-
510
- gl.uniform3fv(shu.eyePositionHigh, r.activeCamera.eyeHigh);
511
- gl.uniform3fv(shu.eyePositionLow, r.activeCamera.eyeLow);
512
-
513
- gl.uniform3fv(shu.uScaleByDistance, ec.scaleByDistance);
514
-
515
- gl.uniform1f(shu.uOpacity, ec._fadingOpacity);
516
-
517
- gl.uniform1f(shu.pickingScale, ec.pickingScale);
518
-
519
- gl.uniform2fv(shu.uFloatParams, [
520
- ec.renderNode._planetRadius2 || 0,
521
- r.activeCamera._tanViewAngle_hradOneByHeight
522
- ]);
523
-
524
- gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer);
525
- gl.vertexAttribPointer(sha.a_vertices, this._vertexBuffer.itemSize, gl.FLOAT, false, 0, 0);
526
-
527
- gl.bindBuffer(gl.ARRAY_BUFFER, this._positionHighBuffer);
528
- gl.vertexAttribPointer(
529
- sha.a_positionsHigh,
530
- this._positionHighBuffer.itemSize,
531
- gl.FLOAT,
532
- false,
533
- 0,
534
- 0
535
- );
536
-
537
- gl.bindBuffer(gl.ARRAY_BUFFER, this._positionLowBuffer);
538
- gl.vertexAttribPointer(
539
- sha.a_positionsLow,
540
- this._positionLowBuffer.itemSize,
541
- gl.FLOAT,
542
- false,
543
- 0,
544
- 0
545
- );
546
-
547
- gl.bindBuffer(gl.ARRAY_BUFFER, this._pickingColorBuffer);
548
- gl.vertexAttribPointer(
549
- sha.a_pickingColor,
550
- this._pickingColorBuffer.itemSize,
551
- gl.FLOAT,
552
- false,
553
- 0,
554
- 0
555
- );
556
-
557
- gl.bindBuffer(gl.ARRAY_BUFFER, this._sizeBuffer);
558
- gl.vertexAttribPointer(sha.a_size, this._sizeBuffer.itemSize, gl.FLOAT, false, 0, 0);
559
-
560
- gl.bindBuffer(gl.ARRAY_BUFFER, this._offsetBuffer);
561
- gl.vertexAttribPointer(sha.a_offset, this._offsetBuffer.itemSize, gl.FLOAT, false, 0, 0);
562
-
563
- gl.bindBuffer(gl.ARRAY_BUFFER, this._rotationBuffer);
564
- gl.vertexAttribPointer(
565
- sha.a_rotation,
566
- this._rotationBuffer.itemSize,
567
- gl.FLOAT,
568
- false,
569
- 0,
570
- 0
571
- );
572
-
573
- gl.bindBuffer(gl.ARRAY_BUFFER, this._alignedAxisBuffer);
574
- gl.vertexAttribPointer(
575
- sha.a_alignedAxis,
576
- this._alignedAxisBuffer.itemSize,
577
- gl.FLOAT,
578
- false,
579
- 0,
580
- 0
581
- );
582
-
583
- gl.drawArrays(gl.TRIANGLES, 0, this._vertexBuffer.numItems);
584
- }
585
-
586
- draw() {
587
- if (this._billboards.length) {
588
- this.update();
589
- this._displayPASS();
590
- }
591
- }
592
-
593
- drawPicking() {
594
- if (this._billboards.length && this.pickingEnabled) {
595
- this._pickingPASS();
596
- }
597
- }
598
-
599
- reindexBillbordsArray(startIndex) {
600
- var b = this._billboards;
601
- for (var i = startIndex; i < b.length; i++) {
602
- b[i]._handlerIndex = i;
603
- }
604
- }
605
-
606
- _removeBillboard(billboard) {
607
- var bi = billboard._handlerIndex;
608
-
609
- this._billboards.splice(bi, 1);
610
-
611
- var i = bi * 24;
612
- this._rgbaArr = spliceTypedArray(this._rgbaArr, i, 24);
613
-
614
- i = bi * 18;
615
- this._positionHighArr = spliceTypedArray(this._positionHighArr, i, 18);
616
- this._positionLowArr = spliceTypedArray(this._positionLowArr, i, 18);
617
- this._offsetArr = spliceTypedArray(this._offsetArr, i, 18);
618
- this._alignedAxisArr = spliceTypedArray(this._alignedAxisArr, i, 18);
619
- this._pickingColorArr = spliceTypedArray(this._pickingColorArr, i, 18);
620
-
621
- i = bi * 12;
622
- this._vertexArr = spliceTypedArray(this._vertexArr, i, 12);
623
- this._sizeArr = spliceTypedArray(this._sizeArr, i, 12);
624
- this._texCoordArr = spliceTypedArray(this._texCoordArr, i, 12);
625
-
626
- i = bi * 6;
627
- this._rotationArr = spliceTypedArray(this._rotationArr, i, 6);
628
-
629
- this.reindexBillbordsArray(bi);
630
- this.refresh();
631
-
632
- billboard._handlerIndex = -1;
633
- billboard._handler = null;
634
- billboard._isReady = false;
635
- billboard._lockId = LOCK_FREE;
636
- }
637
-
638
- remove(billboard) {
639
- if (billboard._isReady && this.__staticId == billboard._handler.__staticId) {
640
- this._removeBillboard(billboard);
641
- } else {
642
- billboard._handler = null;
643
- }
644
- }
645
-
646
- setPositionArr(index, positionHigh, positionLow) {
647
- var i = index * 18;
648
-
649
- // High
650
- var a = this._positionHighArr,
651
- x = positionHigh.x,
652
- y = positionHigh.y,
653
- z = positionHigh.z;
654
-
655
- a[i] = x;
656
- a[i + 1] = y;
657
- a[i + 2] = z;
658
-
659
- a[i + 3] = x;
660
- a[i + 4] = y;
661
- a[i + 5] = z;
662
-
663
- a[i + 6] = x;
664
- a[i + 7] = y;
665
- a[i + 8] = z;
666
-
667
- a[i + 9] = x;
668
- a[i + 10] = y;
669
- a[i + 11] = z;
670
-
671
- a[i + 12] = x;
672
- a[i + 13] = y;
673
- a[i + 14] = z;
674
-
675
- a[i + 15] = x;
676
- a[i + 16] = y;
677
- a[i + 17] = z;
678
-
679
- // Low
680
- a = this._positionLowArr;
681
- x = positionLow.x;
682
- y = positionLow.y;
683
- z = positionLow.z;
684
-
685
- a[i] = x;
686
- a[i + 1] = y;
687
- a[i + 2] = z;
688
-
689
- a[i + 3] = x;
690
- a[i + 4] = y;
691
- a[i + 5] = z;
692
-
693
- a[i + 6] = x;
694
- a[i + 7] = y;
695
- a[i + 8] = z;
696
-
697
- a[i + 9] = x;
698
- a[i + 10] = y;
699
- a[i + 11] = z;
700
-
701
- a[i + 12] = x;
702
- a[i + 13] = y;
703
- a[i + 14] = z;
704
-
705
- a[i + 15] = x;
706
- a[i + 16] = y;
707
- a[i + 17] = z;
708
-
709
- this._changedBuffers[POSITION_BUFFER] = true;
710
- }
711
-
712
- setPickingColorArr(index, color) {
713
- var i = index * 18;
714
- var a = this._pickingColorArr,
715
- x = color.x / 255,
716
- y = color.y / 255,
717
- z = color.z / 255;
718
-
719
- a[i] = x;
720
- a[i + 1] = y;
721
- a[i + 2] = z;
722
-
723
- a[i + 3] = x;
724
- a[i + 4] = y;
725
- a[i + 5] = z;
726
-
727
- a[i + 6] = x;
728
- a[i + 7] = y;
729
- a[i + 8] = z;
730
-
731
- a[i + 9] = x;
732
- a[i + 10] = y;
733
- a[i + 11] = z;
734
-
735
- a[i + 12] = x;
736
- a[i + 13] = y;
737
- a[i + 14] = z;
738
-
739
- a[i + 15] = x;
740
- a[i + 16] = y;
741
- a[i + 17] = z;
742
-
743
- this._changedBuffers[PICKINGCOLOR_BUFFER] = true;
744
- }
745
-
746
- setSizeArr(index, width, height) {
747
- var i = index * 12;
748
- var a = this._sizeArr,
749
- x = width,
750
- y = height;
751
-
752
- a[i] = x;
753
- a[i + 1] = y;
754
-
755
- a[i + 2] = x;
756
- a[i + 3] = y;
757
-
758
- a[i + 4] = x;
759
- a[i + 5] = y;
760
-
761
- a[i + 6] = x;
762
- a[i + 7] = y;
763
-
764
- a[i + 8] = x;
765
- a[i + 9] = y;
766
-
767
- a[i + 10] = x;
768
- a[i + 11] = y;
769
-
770
- this._changedBuffers[SIZE_BUFFER] = true;
771
- }
772
-
773
- setOffsetArr(index, offset) {
774
- var i = index * 18;
775
- var a = this._offsetArr,
776
- x = offset.x,
777
- y = offset.y,
778
- z = offset.z;
779
-
780
- a[i] = x;
781
- a[i + 1] = y;
782
- a[i + 2] = z;
783
-
784
- a[i + 3] = x;
785
- a[i + 4] = y;
786
- a[i + 5] = z;
787
-
788
- a[i + 6] = x;
789
- a[i + 7] = y;
790
- a[i + 8] = z;
791
-
792
- a[i + 9] = x;
793
- a[i + 10] = y;
794
- a[i + 11] = z;
795
-
796
- a[i + 12] = x;
797
- a[i + 13] = y;
798
- a[i + 14] = z;
799
-
800
- a[i + 15] = x;
801
- a[i + 16] = y;
802
- a[i + 17] = z;
803
-
804
- this._changedBuffers[OFFSET_BUFFER] = true;
805
- }
806
-
807
- setRgbaArr(index, rgba) {
808
- var i = index * 24;
809
- var a = this._rgbaArr,
810
- x = rgba.x,
811
- y = rgba.y,
812
- z = rgba.z,
813
- w = rgba.w;
814
-
815
- a[i] = x;
816
- a[i + 1] = y;
817
- a[i + 2] = z;
818
- a[i + 3] = w;
819
-
820
- a[i + 4] = x;
821
- a[i + 5] = y;
822
- a[i + 6] = z;
823
- a[i + 7] = w;
824
-
825
- a[i + 8] = x;
826
- a[i + 9] = y;
827
- a[i + 10] = z;
828
- a[i + 11] = w;
829
-
830
- a[i + 12] = x;
831
- a[i + 13] = y;
832
- a[i + 14] = z;
833
- a[i + 15] = w;
834
-
835
- a[i + 16] = x;
836
- a[i + 17] = y;
837
- a[i + 18] = z;
838
- a[i + 19] = w;
839
-
840
- a[i + 20] = x;
841
- a[i + 21] = y;
842
- a[i + 22] = z;
843
- a[i + 23] = w;
844
-
845
- this._changedBuffers[RGBA_BUFFER] = true;
846
- }
847
-
848
- setRotationArr(index, rotation) {
849
- var i = index * 6;
850
- var a = this._rotationArr;
851
-
852
- a[i] = rotation;
853
- a[i + 1] = rotation;
854
- a[i + 2] = rotation;
855
- a[i + 3] = rotation;
856
- a[i + 4] = rotation;
857
- a[i + 5] = rotation;
858
-
859
- this._changedBuffers[ROTATION_BUFFER] = true;
860
- }
861
-
862
- setTexCoordArr(index, tcoordArr) {
863
- var i = index * 12;
864
- var a = this._texCoordArr;
865
-
866
- a[i] = tcoordArr[0];
867
- a[i + 1] = tcoordArr[1];
868
-
869
- a[i + 2] = tcoordArr[2];
870
- a[i + 3] = tcoordArr[3];
871
-
872
- a[i + 4] = tcoordArr[4];
873
- a[i + 5] = tcoordArr[5];
874
-
875
- a[i + 6] = tcoordArr[6];
876
- a[i + 7] = tcoordArr[7];
877
-
878
- a[i + 8] = tcoordArr[8];
879
- a[i + 9] = tcoordArr[9];
880
-
881
- a[i + 10] = tcoordArr[10];
882
- a[i + 11] = tcoordArr[11];
883
-
884
- this._changedBuffers[TEXCOORD_BUFFER] = true;
885
- }
886
-
887
- setVisibility(index, visibility) {
888
- var vArr;
889
- if (visibility) {
890
- vArr = [-0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5];
891
- } else {
892
- vArr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
893
- }
894
- this.setVertexArr(index, vArr);
895
- }
896
-
897
- setVertexArr(index, vertexArr) {
898
- var i = index * 12;
899
- var a = this._vertexArr;
900
-
901
- a[i] = vertexArr[0];
902
- a[i + 1] = vertexArr[1];
903
- a[i + 2] = vertexArr[2];
904
-
905
- a[i + 3] = vertexArr[3];
906
- a[i + 4] = vertexArr[4];
907
- a[i + 5] = vertexArr[5];
908
-
909
- a[i + 6] = vertexArr[6];
910
- a[i + 7] = vertexArr[7];
911
- a[i + 8] = vertexArr[8];
912
-
913
- a[i + 9] = vertexArr[9];
914
- a[i + 10] = vertexArr[10];
915
- a[i + 11] = vertexArr[11];
916
-
917
- this._changedBuffers[VERTEX_BUFFER] = true;
918
- }
919
-
920
- setAlignedAxisArr(index, alignedAxis) {
921
- var i = index * 18;
922
- var a = this._alignedAxisArr,
923
- x = alignedAxis.x,
924
- y = alignedAxis.y,
925
- z = alignedAxis.z;
926
-
927
- a[i] = x;
928
- a[i + 1] = y;
929
- a[i + 2] = z;
930
-
931
- a[i + 3] = x;
932
- a[i + 4] = y;
933
- a[i + 5] = z;
934
-
935
- a[i + 6] = x;
936
- a[i + 7] = y;
937
- a[i + 8] = z;
938
-
939
- a[i + 9] = x;
940
- a[i + 10] = y;
941
- a[i + 11] = z;
942
-
943
- a[i + 12] = x;
944
- a[i + 13] = y;
945
- a[i + 14] = z;
946
-
947
- a[i + 15] = x;
948
- a[i + 16] = y;
949
- a[i + 17] = z;
950
-
951
- this._changedBuffers[ALIGNEDAXIS_BUFFER] = true;
952
- }
953
-
954
- createPositionBuffer() {
955
- let h = this._renderer.handler,
956
- numItems = this._positionHighArr.length / 3;
957
-
958
- if (!this._positionHighBuffer || this._positionHighBuffer.numItems !== numItems) {
959
- h.gl.deleteBuffer(this._positionHighBuffer);
960
- h.gl.deleteBuffer(this._positionLowBuffer);
961
- this._positionHighBuffer = h.createStreamArrayBuffer(3, numItems);
962
- this._positionLowBuffer = h.createStreamArrayBuffer(3, numItems);
963
- }
964
-
965
- h.setStreamArrayBuffer(this._positionHighBuffer, this._positionHighArr);
966
- h.setStreamArrayBuffer(this._positionLowBuffer, this._positionLowArr);
967
- }
968
-
969
- createSizeBuffer() {
970
- var h = this._renderer.handler;
971
- h.gl.deleteBuffer(this._sizeBuffer);
972
- this._sizeBuffer = h.createArrayBuffer(this._sizeArr, 2, this._sizeArr.length / 2);
973
- }
974
-
975
- createOffsetBuffer() {
976
- var h = this._renderer.handler;
977
- h.gl.deleteBuffer(this._offsetBuffer);
978
- this._offsetBuffer = h.createArrayBuffer(this._offsetArr, 3, this._offsetArr.length / 3);
979
- }
980
-
981
- createRgbaBuffer() {
982
- var h = this._renderer.handler;
983
- h.gl.deleteBuffer(this._rgbaBuffer);
984
- this._rgbaBuffer = h.createArrayBuffer(this._rgbaArr, 4, this._rgbaArr.length / 4);
985
- }
986
-
987
- createRotationBuffer() {
988
- let h = this._renderer.handler;
989
-
990
- if (!this._rotationBuffer || this._rotationBuffer.numItems !== this._rotationArr.length) {
991
- h.gl.deleteBuffer(this._rotationBuffer);
992
- this._rotationBuffer = h.createStreamArrayBuffer(1, this._rotationArr.length);
993
- }
994
-
995
- h.setStreamArrayBuffer(this._rotationBuffer, this._rotationArr);
996
- }
997
-
998
- createVertexBuffer() {
999
- var h = this._renderer.handler;
1000
- h.gl.deleteBuffer(this._vertexBuffer);
1001
- this._vertexBuffer = h.createArrayBuffer(this._vertexArr, 2, this._vertexArr.length / 2);
1002
- }
1003
-
1004
- createTexCoordBuffer() {
1005
- var h = this._renderer.handler;
1006
- h.gl.deleteBuffer(this._texCoordBuffer);
1007
- this._texCoordBuffer = h.createArrayBuffer(
1008
- this._texCoordArr,
1009
- 2,
1010
- this._texCoordArr.length / 2
1011
- );
1012
- }
1013
-
1014
- createAlignedAxisBuffer() {
1015
- var h = this._renderer.handler;
1016
- h.gl.deleteBuffer(this._alignedAxisBuffer);
1017
- this._alignedAxisBuffer = h.createArrayBuffer(
1018
- this._alignedAxisArr,
1019
- 3,
1020
- this._alignedAxisArr.length / 3
1021
- );
1022
- }
1023
-
1024
- createPickingColorBuffer() {
1025
- var h = this._renderer.handler;
1026
- h.gl.deleteBuffer(this._pickingColorBuffer);
1027
- this._pickingColorBuffer = h.createArrayBuffer(
1028
- this._pickingColorArr,
1029
- 3,
1030
- this._pickingColorArr.length / 3
1031
- );
1032
- }
1033
-
1034
- refreshTexCoordsArr() {
1035
- var bc = this._entityCollection;
1036
- if (bc && this._renderer) {
1037
- var ta = this._renderer.billboardsTextureAtlas;
1038
- for (var i = 0; i < this._billboards.length; i++) {
1039
- var bi = this._billboards[i];
1040
- var img = bi._image;
1041
- if (img) {
1042
- var imageNode = ta.nodes[bi._image.__nodeIndex];
1043
- if (imageNode) {
1044
- this.setTexCoordArr(bi._handlerIndex, imageNode.texCoords);
1045
- }
1046
- }
1047
- }
1048
- }
1049
- }
1050
- }
1051
-
1
+ /**
2
+ * @module og/entity/BillboardHandler
3
+ */
4
+
5
+ "use strict";
6
+
7
+ import * as shaders from "../shaders/billboard.js";
8
+ import { concatTypedArrays, spliceTypedArray } from "../utils/shared.js";
9
+ import { LOCK_UPDATE, LOCK_FREE } from "./LabelWorker.js";
10
+
11
+ const PICKINGCOLOR_BUFFER = 0;
12
+ const POSITION_BUFFER = 1;
13
+ const SIZE_BUFFER = 2;
14
+ const OFFSET_BUFFER = 3;
15
+ const RGBA_BUFFER = 4;
16
+ const ROTATION_BUFFER = 5;
17
+ const TEXCOORD_BUFFER = 6;
18
+ const VERTEX_BUFFER = 7;
19
+
20
+ window.BILLBOARD_DEPTH_OFFSET = 0.0;
21
+
22
+ /*
23
+ * og.BillboardHandler
24
+ *
25
+ *
26
+ */
27
+ class BillboardHandler {
28
+ /**
29
+ *
30
+ * @param {*} entityCollection
31
+ */
32
+ constructor(entityCollection) {
33
+ /**
34
+ * Picking rendering option.
35
+ * @public
36
+ * @type {boolean}
37
+ */
38
+ this.pickingEnabled = true;
39
+
40
+ this._entityCollection = entityCollection;
41
+
42
+ this._renderer = null;
43
+
44
+ this._billboards = [];
45
+
46
+ this._positionHighBuffer = null;
47
+ this._positionLowBuffer = null;
48
+ this._sizeBuffer = null;
49
+ this._offsetBuffer = null;
50
+ this._rgbaBuffer = null;
51
+ this._rotationBuffer = null;
52
+ this._texCoordBuffer = null;
53
+ this._vertexBuffer = null;
54
+
55
+ this._texCoordArr = new Float32Array();
56
+ this._vertexArr = new Float32Array();
57
+ this._positionHighArr = new Float32Array();
58
+ this._positionLowArr = new Float32Array();
59
+ this._sizeArr = new Float32Array();
60
+ this._offsetArr = new Float32Array();
61
+ this._rgbaArr = new Float32Array();
62
+ this._rotationArr = new Float32Array();
63
+
64
+ this._pickingColorBuffer = null;
65
+ this._pickingColorArr = new Float32Array();
66
+
67
+ this._buffersUpdateCallbacks = [];
68
+ this._buffersUpdateCallbacks[PICKINGCOLOR_BUFFER] = this.createPickingColorBuffer;
69
+ this._buffersUpdateCallbacks[POSITION_BUFFER] = this.createPositionBuffer;
70
+ this._buffersUpdateCallbacks[SIZE_BUFFER] = this.createSizeBuffer;
71
+ this._buffersUpdateCallbacks[OFFSET_BUFFER] = this.createOffsetBuffer;
72
+ this._buffersUpdateCallbacks[RGBA_BUFFER] = this.createRgbaBuffer;
73
+ this._buffersUpdateCallbacks[ROTATION_BUFFER] = this.createRotationBuffer;
74
+ this._buffersUpdateCallbacks[TEXCOORD_BUFFER] = this.createTexCoordBuffer;
75
+ this._buffersUpdateCallbacks[VERTEX_BUFFER] = this.createVertexBuffer;
76
+
77
+ this._changedBuffers = new Array(this._buffersUpdateCallbacks.length);
78
+
79
+ this.__staticId = BillboardHandler._staticCounter++;
80
+ }
81
+
82
+ isEqual(handler) {
83
+ return handler && (handler.__staticId === this.__staticId);
84
+ }
85
+
86
+ static get _staticCounter() {
87
+ if (!this._counter && this._counter !== 0) {
88
+ this._counter = 0;
89
+ }
90
+ return this._counter;
91
+ }
92
+
93
+ static set _staticCounter(n) {
94
+ this._counter = n;
95
+ }
96
+
97
+ static concArr(dest, curr) {
98
+ for (var i = 0; i < curr.length; i++) {
99
+ dest.push(curr[i]);
100
+ }
101
+ }
102
+
103
+ initProgram() {
104
+ if (this._renderer.handler) {
105
+ if (!this._renderer.handler.programs.billboard) {
106
+ this._renderer.handler.addProgram(shaders.billboard_screen());
107
+ }
108
+
109
+ if (!this._renderer.handler.programs.billboardPicking) {
110
+ this._renderer.handler.addProgram(shaders.billboardPicking());
111
+ }
112
+ }
113
+ }
114
+
115
+ setRenderer(renderer) {
116
+ this._renderer = renderer;
117
+ this.initProgram();
118
+ }
119
+
120
+ refresh() {
121
+ var i = this._changedBuffers.length;
122
+ while (i--) {
123
+ this._changedBuffers[i] = true;
124
+ }
125
+ }
126
+
127
+ _removeBillboards() {
128
+ var i = this._billboards.length;
129
+ while (i--) {
130
+ var bi = this._billboards[i];
131
+ bi._handlerIndex = -1;
132
+ bi._handler = null;
133
+ bi._isReady = false;
134
+ bi._lockId = LOCK_FREE;
135
+ }
136
+ this._billboards.length = 0;
137
+ this._billboards = [];
138
+ }
139
+
140
+ clear() {
141
+ this._texCoordArr = null;
142
+ this._vertexArr = null;
143
+ this._positionHighArr = null;
144
+ this._positionLowArr = null;
145
+ this._sizeArr = null;
146
+ this._offsetArr = null;
147
+ this._rgbaArr = null;
148
+ this._rotationArr = null;
149
+ this._pickingColorArr = null;
150
+
151
+ this._texCoordArr = new Float32Array();
152
+ this._vertexArr = new Float32Array();
153
+ this._positionHighArr = new Float32Array();
154
+ this._positionLowArr = new Float32Array();
155
+ this._sizeArr = new Float32Array();
156
+ this._offsetArr = new Float32Array();
157
+ this._rgbaArr = new Float32Array();
158
+ this._rotationArr = new Float32Array();
159
+ this._pickingColorArr = new Float32Array();
160
+
161
+ this._removeBillboards();
162
+ this._deleteBuffers();
163
+ this.refresh();
164
+ }
165
+
166
+ _deleteBuffers() {
167
+ if (this._renderer) {
168
+ var gl = this._renderer.handler.gl;
169
+ gl.deleteBuffer(this._positionHighBuffer);
170
+ gl.deleteBuffer(this._positionLowBuffer);
171
+ gl.deleteBuffer(this._sizeBuffer);
172
+ gl.deleteBuffer(this._offsetBuffer);
173
+ gl.deleteBuffer(this._rgbaBuffer);
174
+ gl.deleteBuffer(this._rotationBuffer);
175
+ gl.deleteBuffer(this._vertexBuffer);
176
+ gl.deleteBuffer(this._texCoordBuffer);
177
+ gl.deleteBuffer(this._pickingColorBuffer);
178
+ }
179
+
180
+ this._positionHighBuffer = null;
181
+ this._positionLowBuffer = null;
182
+ this._sizeBuffer = null;
183
+ this._offsetBuffer = null;
184
+ this._rgbaBuffer = null;
185
+ this._rotationBuffer = null;
186
+ this._vertexBuffer = null;
187
+ this._texCoordBuffer = null;
188
+ this._pickingColorBuffer = null;
189
+ }
190
+
191
+ update() {
192
+ if (this._renderer) {
193
+ var i = this._changedBuffers.length;
194
+ while (i--) {
195
+ if (this._changedBuffers[i]) {
196
+ this._buffersUpdateCallbacks[i].call(this);
197
+ this._changedBuffers[i] = false;
198
+ }
199
+ }
200
+ }
201
+ }
202
+
203
+ add(billboard) {
204
+ if (billboard._handlerIndex == -1) {
205
+ billboard._isReady = true;
206
+ billboard._handler = this;
207
+ billboard._handlerIndex = this._billboards.length;
208
+ this._billboards.push(billboard);
209
+ this._addBillboardToArrays(billboard);
210
+ this.refresh();
211
+ billboard.setSrc(billboard._src || (billboard._image && billboard._image.src));
212
+ }
213
+ }
214
+
215
+ _addBillboardToArrays(billboard) {
216
+ if (billboard._visibility) {
217
+ this._vertexArr = concatTypedArrays(
218
+ this._vertexArr,
219
+ [-0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5]
220
+ );
221
+ } else {
222
+ this._vertexArr = concatTypedArrays(
223
+ this._vertexArr,
224
+ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
225
+ );
226
+ }
227
+
228
+ this._texCoordArr = concatTypedArrays(
229
+ this._texCoordArr,
230
+ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
231
+ );
232
+
233
+ var x = billboard._positionHigh.x,
234
+ y = billboard._positionHigh.y,
235
+ z = billboard._positionHigh.z,
236
+ w;
237
+ this._positionHighArr = concatTypedArrays(this._positionHighArr, [x, y, z, x, y, z, x, y, z,
238
+ x,
239
+ y,
240
+ z,
241
+ x,
242
+ y,
243
+ z,
244
+ x,
245
+ y,
246
+ z
247
+ ]);
248
+
249
+ x = billboard._positionLow.x;
250
+ y = billboard._positionLow.y;
251
+ z = billboard._positionLow.z;
252
+ this._positionLowArr = concatTypedArrays(this._positionLowArr, [
253
+ x,
254
+ y,
255
+ z,
256
+ x,
257
+ y,
258
+ z,
259
+ x,
260
+ y,
261
+ z,
262
+ x,
263
+ y,
264
+ z,
265
+ x,
266
+ y,
267
+ z,
268
+ x,
269
+ y,
270
+ z
271
+ ]);
272
+
273
+ x = billboard._width;
274
+ y = billboard._height;
275
+ this._sizeArr = concatTypedArrays(this._sizeArr, [x, y, x, y, x, y, x, y, x, y, x, y]);
276
+
277
+ x = billboard._offset.x;
278
+ y = billboard._offset.y;
279
+ z = billboard._offset.z;
280
+ this._offsetArr = concatTypedArrays(this._offsetArr, [
281
+ x,
282
+ y,
283
+ z,
284
+ x,
285
+ y,
286
+ z,
287
+ x,
288
+ y,
289
+ z,
290
+ x,
291
+ y,
292
+ z,
293
+ x,
294
+ y,
295
+ z,
296
+ x,
297
+ y,
298
+ z
299
+ ]);
300
+
301
+ x = billboard._color.x;
302
+ y = billboard._color.y;
303
+ z = billboard._color.z;
304
+ w = billboard._color.w;
305
+ this._rgbaArr = concatTypedArrays(this._rgbaArr, [
306
+ x,
307
+ y,
308
+ z,
309
+ w,
310
+ x,
311
+ y,
312
+ z,
313
+ w,
314
+ x,
315
+ y,
316
+ z,
317
+ w,
318
+ x,
319
+ y,
320
+ z,
321
+ w,
322
+ x,
323
+ y,
324
+ z,
325
+ w,
326
+ x,
327
+ y,
328
+ z,
329
+ w
330
+ ]);
331
+
332
+ x = billboard._rotation;
333
+ this._rotationArr = concatTypedArrays(this._rotationArr, [x, x, x, x, x, x]);
334
+
335
+ x = billboard._entity._pickingColor.x / 255;
336
+ y = billboard._entity._pickingColor.y / 255;
337
+ z = billboard._entity._pickingColor.z / 255;
338
+ this._pickingColorArr = concatTypedArrays(this._pickingColorArr, [x, y, z, x, y, z, x, y, z, x, y, z, x, y, z, x, y, z]);
339
+ }
340
+
341
+ _displayPASS() {
342
+ var r = this._renderer;
343
+ var h = r.handler;
344
+ h.programs.billboard.activate();
345
+ var sh = h.programs.billboard._program;
346
+ var sha = sh.attributes,
347
+ shu = sh.uniforms;
348
+
349
+ var gl = h.gl,
350
+ ec = this._entityCollection;
351
+
352
+ gl.uniform1f(shu.depthOffset, ec.polygonOffsetUnits + window.BILLBOARD_DEPTH_OFFSET);
353
+
354
+ gl.uniform1i(shu.u_texture, 0);
355
+
356
+ gl.uniformMatrix4fv(shu.viewMatrix, false, r.activeCamera._viewMatrix._m);
357
+ gl.uniformMatrix4fv(shu.projectionMatrix, false, r.activeCamera.getProjectionMatrix());
358
+
359
+ gl.uniform3fv(shu.eyePositionHigh, r.activeCamera.eyeHigh);
360
+ gl.uniform3fv(shu.eyePositionLow, r.activeCamera.eyeLow);
361
+
362
+ gl.uniform3fv(shu.uScaleByDistance, ec.scaleByDistance);
363
+
364
+ gl.uniform1f(shu.opacity, ec._fadingOpacity);
365
+
366
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._texCoordBuffer);
367
+ gl.vertexAttribPointer(sha.a_texCoord, this._texCoordBuffer.itemSize, gl.FLOAT, false, 0, 0);
368
+
369
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer);
370
+ gl.vertexAttribPointer(sha.a_vertices, this._vertexBuffer.itemSize, gl.FLOAT, false, 0, 0);
371
+
372
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._positionHighBuffer);
373
+ gl.vertexAttribPointer(sha.a_positionsHigh, this._positionHighBuffer.itemSize, gl.FLOAT, false, 0, 0);
374
+
375
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._positionLowBuffer);
376
+ gl.vertexAttribPointer(sha.a_positionsLow, this._positionLowBuffer.itemSize, gl.FLOAT, false, 0, 0);
377
+
378
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._rgbaBuffer);
379
+ gl.vertexAttribPointer(sha.a_rgba, this._rgbaBuffer.itemSize, gl.FLOAT, false, 0, 0);
380
+
381
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._sizeBuffer);
382
+ gl.vertexAttribPointer(sha.a_size, this._sizeBuffer.itemSize, gl.FLOAT, false, 0, 0);
383
+
384
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._offsetBuffer);
385
+ gl.vertexAttribPointer(sha.a_offset, this._offsetBuffer.itemSize, gl.FLOAT, false, 0, 0);
386
+
387
+ gl.uniform1f(shu.planetRadius, ec.renderNode._planetRadius2 || 0);
388
+
389
+ gl.uniform2fv(shu.viewport, [h.canvas.clientWidth, h.canvas.clientHeight]);
390
+
391
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._rotationBuffer);
392
+ gl.vertexAttribPointer(sha.a_rotation, this._rotationBuffer.itemSize, gl.FLOAT, false, 0, 0);
393
+
394
+ gl.drawArrays(gl.TRIANGLES, 0, this._vertexBuffer.numItems);
395
+ }
396
+
397
+ _pickingPASS() {
398
+ var r = this._renderer;
399
+ var h = r.handler;
400
+ h.programs.billboardPicking.activate();
401
+ var sh = h.programs.billboardPicking._program;
402
+ var sha = sh.attributes,
403
+ shu = sh.uniforms;
404
+
405
+ var gl = h.gl,
406
+ ec = this._entityCollection;
407
+
408
+ gl.uniform1f(shu.depthOffset, ec.polygonOffsetUnits + window.BILLBOARD_DEPTH_OFFSET);
409
+
410
+ gl.uniformMatrix4fv(shu.viewMatrix, false, r.activeCamera._viewMatrix._m);
411
+ gl.uniformMatrix4fv(shu.projectionMatrix, false, r.activeCamera.getProjectionMatrix());
412
+
413
+ gl.uniform3fv(shu.eyePositionHigh, r.activeCamera.eyeHigh);
414
+ gl.uniform3fv(shu.eyePositionLow, r.activeCamera.eyeLow);
415
+
416
+ gl.uniform3fv(shu.uScaleByDistance, ec.scaleByDistance);
417
+
418
+ gl.uniform1f(shu.opacity, ec._fadingOpacity);
419
+
420
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer);
421
+ gl.vertexAttribPointer(sha.a_vertices, this._vertexBuffer.itemSize, gl.FLOAT, false, 0, 0);
422
+
423
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._positionHighBuffer);
424
+ gl.vertexAttribPointer(sha.a_positionsHigh, this._positionHighBuffer.itemSize, gl.FLOAT, false, 0, 0);
425
+
426
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._positionLowBuffer);
427
+ gl.vertexAttribPointer(sha.a_positionsLow, this._positionLowBuffer.itemSize, gl.FLOAT, false, 0, 0);
428
+
429
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._pickingColorBuffer);
430
+ gl.vertexAttribPointer(sha.a_rgba, this._pickingColorBuffer.itemSize, gl.FLOAT, false, 0, 0);
431
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._sizeBuffer);
432
+ gl.vertexAttribPointer(sha.a_size, this._sizeBuffer.itemSize, gl.FLOAT, false, 0, 0);
433
+
434
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._offsetBuffer);
435
+ gl.vertexAttribPointer(sha.a_offset, this._offsetBuffer.itemSize, gl.FLOAT, false, 0, 0);
436
+
437
+ gl.uniform1f(shu.planetRadius, ec.renderNode._planetRadius2 || 0);
438
+
439
+ gl.uniform2fv(shu.viewport, [h.canvas.clientWidth, h.canvas.clientHeight]);
440
+
441
+ gl.bindBuffer(gl.ARRAY_BUFFER, this._rotationBuffer);
442
+ gl.vertexAttribPointer(sha.a_rotation, this._rotationBuffer.itemSize, gl.FLOAT, false, 0, 0);
443
+
444
+ gl.drawArrays(gl.TRIANGLES, 0, this._vertexBuffer.numItems);
445
+ }
446
+
447
+ draw() {
448
+ if (this._billboards.length) {
449
+ this.update();
450
+ this._displayPASS();
451
+ }
452
+ }
453
+
454
+ drawPicking() {
455
+ if (this._billboards.length && this.pickingEnabled) {
456
+ this._pickingPASS();
457
+ }
458
+ }
459
+
460
+ reindexBillbordsArray(startIndex) {
461
+ var b = this._billboards;
462
+ for (var i = startIndex; i < b.length; i++) {
463
+ b[i]._handlerIndex = i;
464
+ }
465
+ }
466
+
467
+ _removeBillboard(billboard) {
468
+ var bi = billboard._handlerIndex;
469
+
470
+ this._billboards.splice(bi, 1);
471
+
472
+ var i = bi * 24;
473
+ this._rgbaArr = spliceTypedArray(this._rgbaArr, i, 24);
474
+
475
+ i = bi * 18;
476
+ this._positionHighArr = spliceTypedArray(this._positionHighArr, i, 18);
477
+ this._positionLowArr = spliceTypedArray(this._positionLowArr, i, 18);
478
+ this._offsetArr = spliceTypedArray(this._offsetArr, i, 18);
479
+ //this._alignedAxisArr = spliceTypedArray(this._alignedAxisArr, i, 18);
480
+ this._pickingColorArr = spliceTypedArray(this._pickingColorArr, i, 18);
481
+
482
+ i = bi * 12;
483
+ this._vertexArr = spliceTypedArray(this._vertexArr, i, 12);
484
+ this._sizeArr = spliceTypedArray(this._sizeArr, i, 12);
485
+ this._texCoordArr = spliceTypedArray(this._texCoordArr, i, 12);
486
+
487
+ i = bi * 6;
488
+ this._rotationArr = spliceTypedArray(this._rotationArr, i, 6);
489
+
490
+ this.reindexBillbordsArray(bi);
491
+ this.refresh();
492
+
493
+ billboard._handlerIndex = -1;
494
+ billboard._handler = null;
495
+ billboard._isReady = false;
496
+ billboard._lockId = LOCK_FREE;
497
+ }
498
+
499
+ remove(billboard) {
500
+ if (billboard._isReady && this.__staticId == billboard._handler.__staticId) {
501
+ this._removeBillboard(billboard);
502
+ } else {
503
+ billboard._handler = null;
504
+ }
505
+ }
506
+
507
+ setPositionArr(index, positionHigh, positionLow) {
508
+ var i = index * 18;
509
+
510
+ // High
511
+ var a = this._positionHighArr,
512
+ x = positionHigh.x,
513
+ y = positionHigh.y,
514
+ z = positionHigh.z;
515
+
516
+ a[i] = x;
517
+ a[i + 1] = y;
518
+ a[i + 2] = z;
519
+
520
+ a[i + 3] = x;
521
+ a[i + 4] = y;
522
+ a[i + 5] = z;
523
+
524
+ a[i + 6] = x;
525
+ a[i + 7] = y;
526
+ a[i + 8] = z;
527
+
528
+ a[i + 9] = x;
529
+ a[i + 10] = y;
530
+ a[i + 11] = z;
531
+
532
+ a[i + 12] = x;
533
+ a[i + 13] = y;
534
+ a[i + 14] = z;
535
+
536
+ a[i + 15] = x;
537
+ a[i + 16] = y;
538
+ a[i + 17] = z;
539
+
540
+ // Low
541
+ a = this._positionLowArr;
542
+ x = positionLow.x;
543
+ y = positionLow.y;
544
+ z = positionLow.z;
545
+
546
+ a[i] = x;
547
+ a[i + 1] = y;
548
+ a[i + 2] = z;
549
+
550
+ a[i + 3] = x;
551
+ a[i + 4] = y;
552
+ a[i + 5] = z;
553
+
554
+ a[i + 6] = x;
555
+ a[i + 7] = y;
556
+ a[i + 8] = z;
557
+
558
+ a[i + 9] = x;
559
+ a[i + 10] = y;
560
+ a[i + 11] = z;
561
+
562
+ a[i + 12] = x;
563
+ a[i + 13] = y;
564
+ a[i + 14] = z;
565
+
566
+ a[i + 15] = x;
567
+ a[i + 16] = y;
568
+ a[i + 17] = z;
569
+
570
+ this._changedBuffers[POSITION_BUFFER] = true;
571
+ }
572
+
573
+ setPickingColorArr(index, color) {
574
+ var i = index * 18;
575
+ var a = this._pickingColorArr,
576
+ x = color.x / 255,
577
+ y = color.y / 255,
578
+ z = color.z / 255;
579
+
580
+ a[i] = x;
581
+ a[i + 1] = y;
582
+ a[i + 2] = z;
583
+
584
+ a[i + 3] = x;
585
+ a[i + 4] = y;
586
+ a[i + 5] = z;
587
+
588
+ a[i + 6] = x;
589
+ a[i + 7] = y;
590
+ a[i + 8] = z;
591
+
592
+ a[i + 9] = x;
593
+ a[i + 10] = y;
594
+ a[i + 11] = z;
595
+
596
+ a[i + 12] = x;
597
+ a[i + 13] = y;
598
+ a[i + 14] = z;
599
+
600
+ a[i + 15] = x;
601
+ a[i + 16] = y;
602
+ a[i + 17] = z;
603
+
604
+ this._changedBuffers[PICKINGCOLOR_BUFFER] = true;
605
+ }
606
+
607
+ setSizeArr(index, width, height) {
608
+ var i = index * 12;
609
+ var a = this._sizeArr,
610
+ x = width,
611
+ y = height;
612
+
613
+ a[i] = x;
614
+ a[i + 1] = y;
615
+
616
+ a[i + 2] = x;
617
+ a[i + 3] = y;
618
+
619
+ a[i + 4] = x;
620
+ a[i + 5] = y;
621
+
622
+ a[i + 6] = x;
623
+ a[i + 7] = y;
624
+
625
+ a[i + 8] = x;
626
+ a[i + 9] = y;
627
+
628
+ a[i + 10] = x;
629
+ a[i + 11] = y;
630
+
631
+ this._changedBuffers[SIZE_BUFFER] = true;
632
+ }
633
+
634
+ setOffsetArr(index, offset) {
635
+ var i = index * 18;
636
+ var a = this._offsetArr,
637
+ x = offset.x,
638
+ y = offset.y,
639
+ z = offset.z;
640
+
641
+ a[i] = x;
642
+ a[i + 1] = y;
643
+ a[i + 2] = z;
644
+
645
+ a[i + 3] = x;
646
+ a[i + 4] = y;
647
+ a[i + 5] = z;
648
+
649
+ a[i + 6] = x;
650
+ a[i + 7] = y;
651
+ a[i + 8] = z;
652
+
653
+ a[i + 9] = x;
654
+ a[i + 10] = y;
655
+ a[i + 11] = z;
656
+
657
+ a[i + 12] = x;
658
+ a[i + 13] = y;
659
+ a[i + 14] = z;
660
+
661
+ a[i + 15] = x;
662
+ a[i + 16] = y;
663
+ a[i + 17] = z;
664
+
665
+ this._changedBuffers[OFFSET_BUFFER] = true;
666
+ }
667
+
668
+ setRgbaArr(index, rgba) {
669
+ var i = index * 24;
670
+ var a = this._rgbaArr,
671
+ x = rgba.x,
672
+ y = rgba.y,
673
+ z = rgba.z,
674
+ w = rgba.w;
675
+
676
+ a[i] = x;
677
+ a[i + 1] = y;
678
+ a[i + 2] = z;
679
+ a[i + 3] = w;
680
+
681
+ a[i + 4] = x;
682
+ a[i + 5] = y;
683
+ a[i + 6] = z;
684
+ a[i + 7] = w;
685
+
686
+ a[i + 8] = x;
687
+ a[i + 9] = y;
688
+ a[i + 10] = z;
689
+ a[i + 11] = w;
690
+
691
+ a[i + 12] = x;
692
+ a[i + 13] = y;
693
+ a[i + 14] = z;
694
+ a[i + 15] = w;
695
+
696
+ a[i + 16] = x;
697
+ a[i + 17] = y;
698
+ a[i + 18] = z;
699
+ a[i + 19] = w;
700
+
701
+ a[i + 20] = x;
702
+ a[i + 21] = y;
703
+ a[i + 22] = z;
704
+ a[i + 23] = w;
705
+
706
+ this._changedBuffers[RGBA_BUFFER] = true;
707
+ }
708
+
709
+ setRotationArr(index, rotation) {
710
+ var i = index * 6;
711
+ var a = this._rotationArr;
712
+
713
+ a[i] = rotation;
714
+ a[i + 1] = rotation;
715
+ a[i + 2] = rotation;
716
+ a[i + 3] = rotation;
717
+ a[i + 4] = rotation;
718
+ a[i + 5] = rotation;
719
+
720
+ this._changedBuffers[ROTATION_BUFFER] = true;
721
+ }
722
+
723
+ setTexCoordArr(index, tcoordArr) {
724
+ var i = index * 12;
725
+ var a = this._texCoordArr;
726
+
727
+ a[i] = tcoordArr[0];
728
+ a[i + 1] = tcoordArr[1];
729
+
730
+ a[i + 2] = tcoordArr[2];
731
+ a[i + 3] = tcoordArr[3];
732
+
733
+ a[i + 4] = tcoordArr[4];
734
+ a[i + 5] = tcoordArr[5];
735
+
736
+ a[i + 6] = tcoordArr[6];
737
+ a[i + 7] = tcoordArr[7];
738
+
739
+ a[i + 8] = tcoordArr[8];
740
+ a[i + 9] = tcoordArr[9];
741
+
742
+ a[i + 10] = tcoordArr[10];
743
+ a[i + 11] = tcoordArr[11];
744
+
745
+ this._changedBuffers[TEXCOORD_BUFFER] = true;
746
+ }
747
+
748
+ setVisibility(index, visibility) {
749
+ var vArr;
750
+ if (visibility) {
751
+ vArr = [-0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5];
752
+ } else {
753
+ vArr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
754
+ }
755
+ this.setVertexArr(index, vArr);
756
+ }
757
+
758
+ setVertexArr(index, vertexArr) {
759
+ var i = index * 12;
760
+ var a = this._vertexArr;
761
+
762
+ a[i] = vertexArr[0];
763
+ a[i + 1] = vertexArr[1];
764
+ a[i + 2] = vertexArr[2];
765
+
766
+ a[i + 3] = vertexArr[3];
767
+ a[i + 4] = vertexArr[4];
768
+ a[i + 5] = vertexArr[5];
769
+
770
+ a[i + 6] = vertexArr[6];
771
+ a[i + 7] = vertexArr[7];
772
+ a[i + 8] = vertexArr[8];
773
+
774
+ a[i + 9] = vertexArr[9];
775
+ a[i + 10] = vertexArr[10];
776
+ a[i + 11] = vertexArr[11];
777
+
778
+ this._changedBuffers[VERTEX_BUFFER] = true;
779
+ }
780
+
781
+ createPositionBuffer() {
782
+ let h = this._renderer.handler,
783
+ numItems = this._positionHighArr.length / 3;
784
+
785
+ if (!this._positionHighBuffer || this._positionHighBuffer.numItems !== numItems) {
786
+ h.gl.deleteBuffer(this._positionHighBuffer);
787
+ h.gl.deleteBuffer(this._positionLowBuffer);
788
+ this._positionHighBuffer = h.createStreamArrayBuffer(3, numItems);
789
+ this._positionLowBuffer = h.createStreamArrayBuffer(3, numItems);
790
+ }
791
+
792
+ h.setStreamArrayBuffer(this._positionHighBuffer, this._positionHighArr);
793
+ h.setStreamArrayBuffer(this._positionLowBuffer, this._positionLowArr);
794
+ }
795
+
796
+ createSizeBuffer() {
797
+ var h = this._renderer.handler;
798
+ h.gl.deleteBuffer(this._sizeBuffer);
799
+ this._sizeBuffer = h.createArrayBuffer(this._sizeArr, 2, this._sizeArr.length / 2);
800
+ }
801
+
802
+ createOffsetBuffer() {
803
+ var h = this._renderer.handler;
804
+ h.gl.deleteBuffer(this._offsetBuffer);
805
+ this._offsetBuffer = h.createArrayBuffer(this._offsetArr, 3, this._offsetArr.length / 3);
806
+ }
807
+
808
+ createRgbaBuffer() {
809
+ var h = this._renderer.handler;
810
+ h.gl.deleteBuffer(this._rgbaBuffer);
811
+ this._rgbaBuffer = h.createArrayBuffer(this._rgbaArr, 4, this._rgbaArr.length / 4);
812
+ }
813
+
814
+ createRotationBuffer() {
815
+ let h = this._renderer.handler;
816
+
817
+ if (!this._rotationBuffer || this._rotationBuffer.numItems !== this._rotationArr.length) {
818
+ h.gl.deleteBuffer(this._rotationBuffer);
819
+ this._rotationBuffer = h.createStreamArrayBuffer(1, this._rotationArr.length);
820
+ }
821
+
822
+ h.setStreamArrayBuffer(this._rotationBuffer, this._rotationArr);
823
+ }
824
+
825
+ createVertexBuffer() {
826
+ var h = this._renderer.handler;
827
+ h.gl.deleteBuffer(this._vertexBuffer);
828
+ this._vertexBuffer = h.createArrayBuffer(this._vertexArr, 2, this._vertexArr.length / 2);
829
+ }
830
+
831
+ createTexCoordBuffer() {
832
+ var h = this._renderer.handler;
833
+ h.gl.deleteBuffer(this._texCoordBuffer);
834
+ this._texCoordBuffer = h.createArrayBuffer(
835
+ this._texCoordArr,
836
+ 2,
837
+ this._texCoordArr.length / 2
838
+ );
839
+ }
840
+
841
+ //createAlignedAxisBuffer() {
842
+ // var h = this._renderer.handler;
843
+ // h.gl.deleteBuffer(this._alignedAxisBuffer);
844
+ // this._alignedAxisBuffer = h.createArrayBuffer(
845
+ // this._alignedAxisArr,
846
+ // 3,
847
+ // this._alignedAxisArr.length / 3
848
+ // );
849
+ //}
850
+
851
+ createPickingColorBuffer() {
852
+ var h = this._renderer.handler;
853
+ h.gl.deleteBuffer(this._pickingColorBuffer);
854
+ this._pickingColorBuffer = h.createArrayBuffer(
855
+ this._pickingColorArr,
856
+ 3,
857
+ this._pickingColorArr.length / 3
858
+ );
859
+ }
860
+
861
+ refreshTexCoordsArr() {
862
+ var bc = this._entityCollection;
863
+ if (bc && this._renderer) {
864
+ var ta = this._renderer.billboardsTextureAtlas;
865
+ for (var i = 0; i < this._billboards.length; i++) {
866
+ var bi = this._billboards[i];
867
+ var img = bi._image;
868
+ if (img) {
869
+ var imageNode = ta.nodes[bi._image.__nodeIndex];
870
+ if (imageNode) {
871
+ this.setTexCoordArr(bi._handlerIndex, imageNode.texCoords);
872
+ }
873
+ }
874
+ }
875
+ }
876
+ }
877
+ }
878
+
1052
879
  export { BillboardHandler };