@openglobus/og 0.16.2 → 0.17.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 (181) hide show
  1. package/README.md +1 -1
  2. package/css/og.css +24 -2
  3. package/dist/@openglobus/og.css +1 -1
  4. package/dist/@openglobus/og.esm.js +2 -2
  5. package/dist/@openglobus/og.esm.js.map +1 -1
  6. package/dist/@openglobus/og.umd.js +2 -2
  7. package/dist/@openglobus/og.umd.js.map +1 -1
  8. package/package.json +1 -1
  9. package/src/og/Clock.js +1 -5
  10. package/src/og/Events.js +0 -4
  11. package/src/og/Extent.js +5 -9
  12. package/src/og/Globe.js +92 -55
  13. package/src/og/ImageCanvas.js +12 -5
  14. package/src/og/Lock.js +44 -48
  15. package/src/og/LonLat.js +0 -4
  16. package/src/og/Object3d.js +1 -1
  17. package/src/og/Stack.js +49 -53
  18. package/src/og/astro/earth.js +112 -116
  19. package/src/og/astro/jd.js +514 -518
  20. package/src/og/astro/orbit.js +119 -123
  21. package/src/og/astro/rotation.js +36 -40
  22. package/src/og/bv/Box.js +77 -81
  23. package/src/og/bv/Sphere.js +57 -61
  24. package/src/og/camera/Camera.js +20 -7
  25. package/src/og/camera/PlanetCamera.js +8 -15
  26. package/src/og/control/Atmosphere.js +0 -4
  27. package/src/og/control/Control.js +9 -8
  28. package/src/og/control/DebugInfo.js +0 -4
  29. package/src/og/control/DrawingSwitcher.js +117 -0
  30. package/src/og/control/EarthCoordinates.js +214 -214
  31. package/src/og/control/GeoImageDragControl.js +0 -4
  32. package/src/og/control/KeyboardNavigation.js +0 -4
  33. package/src/og/control/LayerAnimation.js +0 -4
  34. package/src/og/control/LayerSwitcher.js +2 -4
  35. package/src/og/control/Lighting.js +11 -15
  36. package/src/og/control/MouseNavigation.js +0 -4
  37. package/src/og/control/MouseWheelZoomControl.js +0 -4
  38. package/src/og/control/RulerSwitcher.js +0 -4
  39. package/src/og/control/ScaleControl.js +2 -6
  40. package/src/og/control/ShowFps.js +40 -44
  41. package/src/og/control/SimpleNavigation.js +10 -10
  42. package/src/og/control/SimpleSkyBackground.js +0 -4
  43. package/src/og/control/Sun.js +0 -4
  44. package/src/og/control/ToggleWireframe.js +35 -39
  45. package/src/og/control/ZoomControl.js +0 -4
  46. package/src/og/control/drawing/DrawingControl.js +51 -0
  47. package/src/og/control/drawing/LineStringDrawingScene.js +203 -0
  48. package/src/og/control/drawing/PolygonDrawingScene.js +785 -0
  49. package/src/og/control/elevationProfile/ElevationProfile.js +275 -0
  50. package/src/og/control/index.js +5 -1
  51. package/src/og/control/ruler/Ruler.js +0 -4
  52. package/src/og/control/ruler/RulerScene.js +3 -2
  53. package/src/og/control/selection/Selection.js +0 -4
  54. package/src/og/control/selection/SelectionScene.js +2 -4
  55. package/src/og/control/timeline/TimelineControl.js +4 -4
  56. package/src/og/control/timeline/TimelineModel.js +2 -2
  57. package/src/og/control/timeline/TimelineView.js +1 -0
  58. package/src/og/control/visibleExtent/Segment.js +5 -5
  59. package/src/og/control/visibleExtent/drawnode.js +0 -4
  60. package/src/og/ellipsoid/Ellipsoid.js +205 -275
  61. package/src/og/ellipsoid/wgs84.js +0 -4
  62. package/src/og/entity/BaseBillboard.js +375 -379
  63. package/src/og/entity/Billboard.js +0 -4
  64. package/src/og/entity/BillboardHandler.js +0 -4
  65. package/src/og/entity/Entity.js +22 -22
  66. package/src/og/entity/EntityCollection.js +7 -11
  67. package/src/og/entity/GeoObject.js +0 -4
  68. package/src/og/entity/GeoObjectHandler.js +0 -4
  69. package/src/og/entity/Geometry.js +5 -4
  70. package/src/og/entity/GeometryHandler.js +3 -4
  71. package/src/og/entity/Label.js +0 -4
  72. package/src/og/entity/LabelHandler.js +0 -4
  73. package/src/og/entity/PointCloud.js +0 -4
  74. package/src/og/entity/PointCloudHandler.js +122 -126
  75. package/src/og/entity/Polyline.js +4 -6
  76. package/src/og/entity/PolylineHandler.js +104 -108
  77. package/src/og/entity/Ray.js +29 -29
  78. package/src/og/entity/Strip.js +1 -1
  79. package/src/og/index.js +3 -1
  80. package/src/og/input/KeyboardHandler.js +128 -132
  81. package/src/og/input/MouseHandler.js +94 -98
  82. package/src/og/input/TouchHandler.js +59 -63
  83. package/src/og/input/input.js +44 -48
  84. package/src/og/layer/BaseGeoImage.js +5 -8
  85. package/src/og/layer/CanvasTiles.js +0 -4
  86. package/src/og/layer/GeoImage.js +0 -4
  87. package/src/og/layer/GeoTexture2d.js +0 -4
  88. package/src/og/layer/GeoVideo.js +0 -4
  89. package/src/og/layer/KML.js +2 -3
  90. package/src/og/layer/Layer.js +22 -26
  91. package/src/og/layer/Material.js +0 -4
  92. package/src/og/layer/Vector.js +23 -20
  93. package/src/og/layer/WMS.js +182 -186
  94. package/src/og/layer/XYZ.js +0 -4
  95. package/src/og/light/LightSource.js +0 -4
  96. package/src/og/math/Line2.js +28 -32
  97. package/src/og/math/Mat3.js +152 -156
  98. package/src/og/math/Ray.js +0 -4
  99. package/src/og/math/Vec2.js +0 -4
  100. package/src/og/math/Vec3.js +0 -4
  101. package/src/og/math/Vec4.js +0 -4
  102. package/src/og/math/coder.js +104 -104
  103. package/src/og/math.js +39 -7
  104. package/src/og/proj/EPSG3857.js +13 -13
  105. package/src/og/proj/Proj.js +59 -63
  106. package/src/og/quadTree/EPSG4326QuadTreeStrategy.js +1 -0
  107. package/src/og/quadTree/EarthQuadTreeStrategy.js +1 -0
  108. package/src/og/quadTree/EntityCollectionNode.js +12 -16
  109. package/src/og/quadTree/MarsQuadTreeStrategy.js +1 -0
  110. package/src/og/quadTree/QuadTreeStrategy.js +1 -0
  111. package/src/og/quadTree/Wgs84QuadTreeStrategy.js +1 -0
  112. package/src/og/renderer/Renderer.js +109 -22
  113. package/src/og/renderer/RendererEvents.js +0 -4
  114. package/src/og/scene/Axes.js +74 -78
  115. package/src/og/scene/BaseNode.js +0 -4
  116. package/src/og/scene/Planet.js +114 -112
  117. package/src/og/scene/RenderNode.js +11 -3
  118. package/src/og/scene/SkyBox.js +104 -108
  119. package/src/og/segment/Segment.js +8 -4
  120. package/src/og/segment/SegmentLonLat.js +2 -6
  121. package/src/og/segment/segmentHelper.js +229 -225
  122. package/src/og/shaders/billboard.js +0 -4
  123. package/src/og/shaders/drawnode.js +5 -9
  124. package/src/og/shaders/geoObject.js +0 -4
  125. package/src/og/shaders/label.js +0 -4
  126. package/src/og/shaders/pickingMask.js +0 -4
  127. package/src/og/shaders/pointCloud.js +0 -4
  128. package/src/og/shaders/polyline.js +0 -4
  129. package/src/og/shaders/ray.js +0 -4
  130. package/src/og/shaders/skybox.js +0 -4
  131. package/src/og/terrain/EmptyTerrain.js +0 -4
  132. package/src/og/utils/FontAtlas.js +0 -4
  133. package/src/og/utils/GeoImageCreator.js +1 -2
  134. package/src/og/utils/NormalMapCreator.js +8 -9
  135. package/src/og/utils/VectorTileCreator.js +3 -9
  136. package/src/og/utils/shared.js +20 -1
  137. package/src/og/webgl/Framebuffer.js +0 -4
  138. package/src/og/webgl/Handler.js +45 -19
  139. package/src/og/webgl/Multisample.js +0 -4
  140. package/src/og/webgl/Program.js +0 -4
  141. package/src/og/webgl/ProgramController.js +2 -2
  142. package/types/Clock.d.ts +1 -1
  143. package/types/Extent.d.ts +5 -5
  144. package/types/Globe.d.ts +15 -1
  145. package/types/ImageCanvas.d.ts +5 -0
  146. package/types/bv/Box.d.ts +1 -1
  147. package/types/bv/Sphere.d.ts +3 -3
  148. package/types/camera/Camera.d.ts +3 -2
  149. package/types/camera/PlanetCamera.d.ts +4 -4
  150. package/types/control/DrawingSwitcher.d.ts +13 -0
  151. package/types/control/EarthCoordinates.d.ts +1 -1
  152. package/types/control/Lighting.d.ts +8 -8
  153. package/types/control/drawing/DrawingControl.d.ts +14 -0
  154. package/types/control/drawing/LineStringDrawingScene.d.ts +5 -0
  155. package/types/control/drawing/PolygonDrawingScene.d.ts +99 -0
  156. package/types/control/index.d.ts +3 -1
  157. package/types/control/ruler/RulerScene.d.ts +0 -1
  158. package/types/control/selection/SelectionScene.d.ts +0 -1
  159. package/types/ellipsoid/Ellipsoid.d.ts +50 -63
  160. package/types/entity/Entity.d.ts +3 -2
  161. package/types/entity/Geometry.d.ts +5 -0
  162. package/types/entity/Polyline.d.ts +1 -1
  163. package/types/entity/Ray.d.ts +1 -0
  164. package/types/index.d.ts +1 -0
  165. package/types/layer/BaseGeoImage.d.ts +1 -1
  166. package/types/layer/CanvasTiles.d.ts +1 -1
  167. package/types/layer/Layer.d.ts +1 -1
  168. package/types/layer/Vector.d.ts +1 -0
  169. package/types/math.d.ts +7 -0
  170. package/types/renderer/Renderer.d.ts +7 -1
  171. package/types/scene/Axes.d.ts +0 -1
  172. package/types/scene/Planet.d.ts +26 -24
  173. package/types/scene/RenderNode.d.ts +2 -0
  174. package/types/scene/SkyBox.d.ts +0 -1
  175. package/types/segment/Segment.d.ts +3 -2
  176. package/types/segment/SegmentLonLat.d.ts +0 -1
  177. package/types/utils/GeoImageCreator.d.ts +1 -1
  178. package/types/utils/NormalMapCreator.d.ts +1 -1
  179. package/types/utils/VectorTileCreator.d.ts +2 -2
  180. package/types/utils/shared.d.ts +2 -0
  181. package/types/webgl/Handler.d.ts +6 -4
@@ -1,379 +1,375 @@
1
- /**
2
- * @module og/entity/BaseBillboard
3
- */
4
-
5
- "use strict";
6
-
7
- import { Vec3 } from "../math/Vec3.js";
8
- import * as utils from "../utils/shared.js";
9
- import { LOCK_FREE, LOCK_UPDATE } from "./LabelWorker.js";
10
-
11
- /**
12
- * Base prototype for billboard and label classes.
13
- * @class
14
- * @param {Object} [options] - Options:
15
- * @param {Vec3|Array.<number>} [options.position] - Billboard spatial position.
16
- * @param {number} [options.rotation] - Screen angle rotaion.
17
- * @param {Vec4|string|Array.<number>} [options.color] - Billboard color.
18
- * @param {Vec3|Array.<number>} [options.alignedAxis] - Billboard aligned vector.
19
- * @param {Vec3|Array.<number>} [options.offset] - Billboard center screen offset.
20
- * @param {boolean} [options.visibility] - Visibility.
21
- */
22
- class BaseBillboard {
23
- constructor(options) {
24
- options = options || {};
25
-
26
- /**
27
- * Object unic identifier.
28
- * @public
29
- * @readonly
30
- * @type {number}
31
- */
32
- this.id = BaseBillboard._staticCounter++;
33
-
34
- /**
35
- * Billboard center cartesian position.
36
- * @protected
37
- * @type {Vec3}
38
- */
39
- this._position = utils.createVector3(options.position);
40
-
41
- this._positionHigh = new Vec3();
42
-
43
- this._positionLow = new Vec3();
44
-
45
- Vec3.doubleToTwoFloats(this._position, this._positionHigh, this._positionLow);
46
-
47
- /**
48
- * Screen space rotation angle.
49
- * @protected
50
- * @type {number}
51
- */
52
- this._rotation = options.rotation || 0;
53
-
54
- /**
55
- * RGBA color.
56
- * @protected
57
- * @type {Vec4}
58
- */
59
- this._color = utils.createColorRGBA(options.color);
60
-
61
- /**
62
- * Cartesian aligned axis vector.
63
- * @protected
64
- * @type {Vec3}
65
- */
66
- this._alignedAxis = utils.createVector3(options.alignedAxis);
67
-
68
- /**
69
- * Billboard center screen space offset. Where x,y - screen space offset and z - depth offset.
70
- * @protected
71
- * @type {math.Vecto3}
72
- */
73
- this._offset = utils.createVector3(options.offset);
74
-
75
- /**
76
- * Billboard visibility.
77
- * @protected
78
- * @type {boolean}
79
- */
80
- this._visibility = options.visibility != undefined ? options.visibility : true;
81
-
82
- /**
83
- * Entity instance that holds this billboard.
84
- * @protected
85
- * @type {Entity}
86
- */
87
- this._entity = null;
88
-
89
- /**
90
- * Handler that stores and renders this billboard object.
91
- * @protected
92
- * @type {BillboardHandler}
93
- */
94
- this._handler = null;
95
-
96
- /**
97
- * Billboard handler array index.
98
- * @protected
99
- * @type {number}
100
- */
101
- this._handlerIndex = -1;
102
-
103
- /**
104
- * An indication that the object is ready to draw
105
- * @protected
106
- * @type {number}
107
- */
108
- this._isReady = false;
109
-
110
- this._lockId = LOCK_FREE;
111
- }
112
-
113
- static get _staticCounter() {
114
- if (!this._counter && this._counter !== 0) {
115
- this._counter = 0;
116
- }
117
- return this._counter;
118
- }
119
-
120
- static set _staticCounter(n) {
121
- this._counter = n;
122
- }
123
-
124
- /**
125
- * Sets billboard position.
126
- * @public
127
- * @param {number} x - X coordinate.
128
- * @param {number} y - Y coordinate.
129
- * @param {number} z - Z coordinate.
130
- */
131
- setPosition(x, y, z) {
132
- this._position.x = x;
133
- this._position.y = y;
134
- this._position.z = z;
135
- Vec3.doubleToTwoFloats(this._position, this._positionHigh, this._positionLow);
136
- if (this._isReady && this._handler) {
137
- this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow);
138
- } else if (this._lockId !== LOCK_FREE) {
139
- this._lockId = LOCK_UPDATE;
140
- }
141
- }
142
-
143
- /**
144
- * Sets billboard position.
145
- * @public
146
- * @param {Vec3} position - Cartesian coordinates.
147
- */
148
- setPosition3v(position) {
149
- this._position.x = position.x;
150
- this._position.y = position.y;
151
- this._position.z = position.z;
152
- Vec3.doubleToTwoFloats(position, this._positionHigh, this._positionLow);
153
- if (this._isReady && this._handler) {
154
- this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow);
155
- } else if (this._lockId !== LOCK_FREE) {
156
- this._lockId = LOCK_UPDATE;
157
- }
158
- }
159
-
160
- /**
161
- * Returns billboard position.
162
- * @public
163
- * @returns {Vec3}
164
- */
165
- getPosition() {
166
- return this._position;
167
- }
168
-
169
- /**
170
- * Sets screen space offset.
171
- * @public
172
- * @param {number} x - X offset.
173
- * @param {number} y - Y offset.
174
- * @param {number} [z] - Z offset.
175
- */
176
- setOffset(x, y, z) {
177
- this._offset.x = x;
178
- this._offset.y = y;
179
- z != undefined && (this._offset.z = z);
180
- if (this._isReady && this._handler) {
181
- this._handler.setOffsetArr(this._handlerIndex, this._offset);
182
- } else if (this._lockId !== LOCK_FREE) {
183
- this._lockId = LOCK_UPDATE;
184
- }
185
- }
186
-
187
- /**
188
- * Sets screen space offset.
189
- * @public
190
- * @param {Vec2} offset - Offset size.
191
- */
192
- setOffset3v(offset) {
193
- this.setOffset(offset.x, offset.y, offset.z);
194
- }
195
-
196
- /**
197
- * Returns billboard screen space offset size.
198
- * @public
199
- * @returns {Vec3}
200
- */
201
- getOffset() {
202
- return this._offset;
203
- }
204
-
205
- /**
206
- * Sets billboard screen space rotation in radians.
207
- * @public
208
- * @param {number} rotation - Screen space rotation in radians.
209
- */
210
- setRotation(rotation) {
211
- if (rotation !== this._rotation) {
212
- this._rotation = rotation;
213
- if (this._isReady && this._handler) {
214
- this._handler.setRotationArr(this._handlerIndex, rotation);
215
- } else if (this._lockId !== LOCK_FREE) {
216
- this._lockId = LOCK_UPDATE;
217
- }
218
- }
219
- }
220
-
221
- /**
222
- * Gets screen space rotation.
223
- * @public
224
- * @returns {number}
225
- */
226
- getRotation() {
227
- return this._rotation;
228
- }
229
-
230
- /**
231
- * Sets billboard opacity.
232
- * @public
233
- * @param {number} a - Billboard opacity.
234
- */
235
- setOpacity(a) {
236
- if (a !== this._color.w) {
237
- a != undefined && (this._color.w = a);
238
- if (this._isReady && this._handler) {
239
- this._handler.setRgbaArr(this._handlerIndex, this._color);
240
- } else if (this._lockId !== LOCK_FREE) {
241
- this._lockId = LOCK_UPDATE;
242
- }
243
- }
244
- }
245
-
246
- /**
247
- * Sets RGBA color. Each channel from 0.0 to 1.0.
248
- * @public
249
- * @param {number} r - Red.
250
- * @param {number} g - Green.
251
- * @param {number} b - Blue.
252
- * @param {number} a - Alpha.
253
- */
254
- setColor(r, g, b, a) {
255
- if (a !== this._color.w || r !== this._color.x || g !== this._color.y || this._color.z !== b) {
256
- this._color.x = r;
257
- this._color.y = g;
258
- this._color.z = b;
259
- a != undefined && (this._color.w = a);
260
- if (this._isReady && this._handler) {
261
- this._handler.setRgbaArr(this._handlerIndex, this._color);
262
- } else if (this._lockId !== LOCK_FREE) {
263
- this._lockId = LOCK_UPDATE;
264
- }
265
- }
266
- }
267
-
268
- /**
269
- * Sets RGBA color. Each channel from 0.0 to 1.0.
270
- * @public
271
- * @param {Vec4} color - RGBA vector.
272
- */
273
- setColor4v(color) {
274
- this.setColor(color.x, color.y, color.z, color.w);
275
- }
276
-
277
- /**
278
- * Sets billboard color.
279
- * @public
280
- * @param {string} color - HTML style color.
281
- */
282
- setColorHTML(color) {
283
- this.setColor4v(utils.htmlColorToRgba(color));
284
- }
285
-
286
- /**
287
- * Returns RGBA color.
288
- * @public
289
- * @returns {Vec4}
290
- */
291
- getColor() {
292
- return this._color;
293
- }
294
-
295
- /**
296
- * Sets billboard visibility.
297
- * @public
298
- * @param {boolean} visibility - Visibility flag.
299
- */
300
- setVisibility(visibility) {
301
- if (visibility !== this._visibility) {
302
- this._visibility = visibility;
303
- if (this._isReady && this._handler) {
304
- this._handler.setVisibility(this._handlerIndex, visibility);
305
- } else if (this._lockId !== LOCK_FREE) {
306
- this._lockId = LOCK_UPDATE;
307
- }
308
- }
309
- }
310
-
311
- /**
312
- * Returns billboard visibility.
313
- * @public
314
- * @returns {boolean}
315
- */
316
- getVisibility() {
317
- return this._visibility;
318
- }
319
-
320
- /**
321
- * Sets billboard cartesian aligned vector.
322
- * @public
323
- * @param {number} x - Aligned vector X coordinate.
324
- * @param {number} y - Aligned vector Y coordinate.
325
- * @param {number} z - Aligned vector Z coordinate.
326
- */
327
- setAlignedAxis(x, y, z) {
328
- this._alignedAxis.x = x;
329
- this._alignedAxis.y = y;
330
- this._alignedAxis.z = z;
331
- if (this._isReady && this._handler) {
332
- this._handler.setAlignedAxisArr(this._handlerIndex, this._alignedAxis);
333
- } else if (this._lockId !== LOCK_FREE) {
334
- this._lockId = LOCK_UPDATE;
335
- }
336
- }
337
-
338
- /**
339
- * Sets billboard aligned vector.
340
- * @public
341
- * @param {math.Vecto3} alignedAxis - Vector to align.
342
- */
343
- setAlignedAxis3v(alignedAxis) {
344
- this.setAlignedAxis(alignedAxis.x, alignedAxis.y, alignedAxis.z);
345
- }
346
-
347
- /**
348
- * Returns aligned vector.
349
- * @public
350
- * @returns {Vec3}
351
- */
352
- getAlignedAxis() {
353
- return this._alignedAxis;
354
- }
355
-
356
- /**
357
- * Removes billboard from hander.
358
- * @public
359
- */
360
- remove() {
361
- this._entity = null;
362
- this._handler && this._handler.remove(this);
363
- }
364
-
365
- /**
366
- * Sets billboard picking color.
367
- * @public
368
- * @param {Vec3} color - Picking color.
369
- */
370
- setPickingColor3v(color) {
371
- if (this._isReady && this._handler) {
372
- this._handler.setPickingColorArr(this._handlerIndex, color);
373
- } else if (this._lockId !== LOCK_FREE) {
374
- this._lockId = LOCK_UPDATE;
375
- }
376
- }
377
- }
378
-
379
- export { BaseBillboard };
1
+ "use strict";
2
+
3
+ import { Vec3 } from "../math/Vec3.js";
4
+ import * as utils from "../utils/shared.js";
5
+ import { LOCK_FREE, LOCK_UPDATE } from "./LabelWorker.js";
6
+
7
+ /**
8
+ * Base prototype for billboard and label classes.
9
+ * @class
10
+ * @param {Object} [options] - Options:
11
+ * @param {Vec3|Array.<number>} [options.position] - Billboard spatial position.
12
+ * @param {number} [options.rotation] - Screen angle rotaion.
13
+ * @param {Vec4|string|Array.<number>} [options.color] - Billboard color.
14
+ * @param {Vec3|Array.<number>} [options.alignedAxis] - Billboard aligned vector.
15
+ * @param {Vec3|Array.<number>} [options.offset] - Billboard center screen offset.
16
+ * @param {boolean} [options.visibility] - Visibility.
17
+ */
18
+ class BaseBillboard {
19
+ constructor(options) {
20
+ options = options || {};
21
+
22
+ /**
23
+ * Object unic identifier.
24
+ * @public
25
+ * @readonly
26
+ * @type {number}
27
+ */
28
+ this.id = BaseBillboard._staticCounter++;
29
+
30
+ /**
31
+ * Billboard center cartesian position.
32
+ * @protected
33
+ * @type {Vec3}
34
+ */
35
+ this._position = utils.createVector3(options.position);
36
+
37
+ this._positionHigh = new Vec3();
38
+
39
+ this._positionLow = new Vec3();
40
+
41
+ Vec3.doubleToTwoFloats(this._position, this._positionHigh, this._positionLow);
42
+
43
+ /**
44
+ * Screen space rotation angle.
45
+ * @protected
46
+ * @type {number}
47
+ */
48
+ this._rotation = options.rotation || 0;
49
+
50
+ /**
51
+ * RGBA color.
52
+ * @protected
53
+ * @type {Vec4}
54
+ */
55
+ this._color = utils.createColorRGBA(options.color);
56
+
57
+ /**
58
+ * Cartesian aligned axis vector.
59
+ * @protected
60
+ * @type {Vec3}
61
+ */
62
+ this._alignedAxis = utils.createVector3(options.alignedAxis);
63
+
64
+ /**
65
+ * Billboard center screen space offset. Where x,y - screen space offset and z - depth offset.
66
+ * @protected
67
+ * @type {math.Vecto3}
68
+ */
69
+ this._offset = utils.createVector3(options.offset);
70
+
71
+ /**
72
+ * Billboard visibility.
73
+ * @protected
74
+ * @type {boolean}
75
+ */
76
+ this._visibility = options.visibility != undefined ? options.visibility : true;
77
+
78
+ /**
79
+ * Entity instance that holds this billboard.
80
+ * @protected
81
+ * @type {Entity}
82
+ */
83
+ this._entity = null;
84
+
85
+ /**
86
+ * Handler that stores and renders this billboard object.
87
+ * @protected
88
+ * @type {BillboardHandler}
89
+ */
90
+ this._handler = null;
91
+
92
+ /**
93
+ * Billboard handler array index.
94
+ * @protected
95
+ * @type {number}
96
+ */
97
+ this._handlerIndex = -1;
98
+
99
+ /**
100
+ * An indication that the object is ready to draw
101
+ * @protected
102
+ * @type {number}
103
+ */
104
+ this._isReady = false;
105
+
106
+ this._lockId = LOCK_FREE;
107
+ }
108
+
109
+ static get _staticCounter() {
110
+ if (!this._counter && this._counter !== 0) {
111
+ this._counter = 0;
112
+ }
113
+ return this._counter;
114
+ }
115
+
116
+ static set _staticCounter(n) {
117
+ this._counter = n;
118
+ }
119
+
120
+ /**
121
+ * Sets billboard position.
122
+ * @public
123
+ * @param {number} x - X coordinate.
124
+ * @param {number} y - Y coordinate.
125
+ * @param {number} z - Z coordinate.
126
+ */
127
+ setPosition(x, y, z) {
128
+ this._position.x = x;
129
+ this._position.y = y;
130
+ this._position.z = z;
131
+ Vec3.doubleToTwoFloats(this._position, this._positionHigh, this._positionLow);
132
+ if (this._isReady && this._handler) {
133
+ this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow);
134
+ } else if (this._lockId !== LOCK_FREE) {
135
+ this._lockId = LOCK_UPDATE;
136
+ }
137
+ }
138
+
139
+ /**
140
+ * Sets billboard position.
141
+ * @public
142
+ * @param {Vec3} position - Cartesian coordinates.
143
+ */
144
+ setPosition3v(position) {
145
+ this._position.x = position.x;
146
+ this._position.y = position.y;
147
+ this._position.z = position.z;
148
+ Vec3.doubleToTwoFloats(position, this._positionHigh, this._positionLow);
149
+ if (this._isReady && this._handler) {
150
+ this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow);
151
+ } else if (this._lockId !== LOCK_FREE) {
152
+ this._lockId = LOCK_UPDATE;
153
+ }
154
+ }
155
+
156
+ /**
157
+ * Returns billboard position.
158
+ * @public
159
+ * @returns {Vec3}
160
+ */
161
+ getPosition() {
162
+ return this._position;
163
+ }
164
+
165
+ /**
166
+ * Sets screen space offset.
167
+ * @public
168
+ * @param {number} x - X offset.
169
+ * @param {number} y - Y offset.
170
+ * @param {number} [z] - Z offset.
171
+ */
172
+ setOffset(x, y, z) {
173
+ this._offset.x = x;
174
+ this._offset.y = y;
175
+ z != undefined && (this._offset.z = z);
176
+ if (this._isReady && this._handler) {
177
+ this._handler.setOffsetArr(this._handlerIndex, this._offset);
178
+ } else if (this._lockId !== LOCK_FREE) {
179
+ this._lockId = LOCK_UPDATE;
180
+ }
181
+ }
182
+
183
+ /**
184
+ * Sets screen space offset.
185
+ * @public
186
+ * @param {Vec2} offset - Offset size.
187
+ */
188
+ setOffset3v(offset) {
189
+ this.setOffset(offset.x, offset.y, offset.z);
190
+ }
191
+
192
+ /**
193
+ * Returns billboard screen space offset size.
194
+ * @public
195
+ * @returns {Vec3}
196
+ */
197
+ getOffset() {
198
+ return this._offset;
199
+ }
200
+
201
+ /**
202
+ * Sets billboard screen space rotation in radians.
203
+ * @public
204
+ * @param {number} rotation - Screen space rotation in radians.
205
+ */
206
+ setRotation(rotation) {
207
+ if (rotation !== this._rotation) {
208
+ this._rotation = rotation;
209
+ if (this._isReady && this._handler) {
210
+ this._handler.setRotationArr(this._handlerIndex, rotation);
211
+ } else if (this._lockId !== LOCK_FREE) {
212
+ this._lockId = LOCK_UPDATE;
213
+ }
214
+ }
215
+ }
216
+
217
+ /**
218
+ * Gets screen space rotation.
219
+ * @public
220
+ * @returns {number}
221
+ */
222
+ getRotation() {
223
+ return this._rotation;
224
+ }
225
+
226
+ /**
227
+ * Sets billboard opacity.
228
+ * @public
229
+ * @param {number} a - Billboard opacity.
230
+ */
231
+ setOpacity(a) {
232
+ if (a !== this._color.w) {
233
+ a != undefined && (this._color.w = a);
234
+ if (this._isReady && this._handler) {
235
+ this._handler.setRgbaArr(this._handlerIndex, this._color);
236
+ } else if (this._lockId !== LOCK_FREE) {
237
+ this._lockId = LOCK_UPDATE;
238
+ }
239
+ }
240
+ }
241
+
242
+ /**
243
+ * Sets RGBA color. Each channel from 0.0 to 1.0.
244
+ * @public
245
+ * @param {number} r - Red.
246
+ * @param {number} g - Green.
247
+ * @param {number} b - Blue.
248
+ * @param {number} a - Alpha.
249
+ */
250
+ setColor(r, g, b, a) {
251
+ if (a !== this._color.w || r !== this._color.x || g !== this._color.y || this._color.z !== b) {
252
+ this._color.x = r;
253
+ this._color.y = g;
254
+ this._color.z = b;
255
+ a != undefined && (this._color.w = a);
256
+ if (this._isReady && this._handler) {
257
+ this._handler.setRgbaArr(this._handlerIndex, this._color);
258
+ } else if (this._lockId !== LOCK_FREE) {
259
+ this._lockId = LOCK_UPDATE;
260
+ }
261
+ }
262
+ }
263
+
264
+ /**
265
+ * Sets RGBA color. Each channel from 0.0 to 1.0.
266
+ * @public
267
+ * @param {Vec4} color - RGBA vector.
268
+ */
269
+ setColor4v(color) {
270
+ this.setColor(color.x, color.y, color.z, color.w);
271
+ }
272
+
273
+ /**
274
+ * Sets billboard color.
275
+ * @public
276
+ * @param {string} color - HTML style color.
277
+ */
278
+ setColorHTML(color) {
279
+ this.setColor4v(utils.htmlColorToRgba(color));
280
+ }
281
+
282
+ /**
283
+ * Returns RGBA color.
284
+ * @public
285
+ * @returns {Vec4}
286
+ */
287
+ getColor() {
288
+ return this._color;
289
+ }
290
+
291
+ /**
292
+ * Sets billboard visibility.
293
+ * @public
294
+ * @param {boolean} visibility - Visibility flag.
295
+ */
296
+ setVisibility(visibility) {
297
+ if (visibility !== this._visibility) {
298
+ this._visibility = visibility;
299
+ if (this._isReady && this._handler) {
300
+ this._handler.setVisibility(this._handlerIndex, visibility);
301
+ } else if (this._lockId !== LOCK_FREE) {
302
+ this._lockId = LOCK_UPDATE;
303
+ }
304
+ }
305
+ }
306
+
307
+ /**
308
+ * Returns billboard visibility.
309
+ * @public
310
+ * @returns {boolean}
311
+ */
312
+ getVisibility() {
313
+ return this._visibility;
314
+ }
315
+
316
+ /**
317
+ * Sets billboard cartesian aligned vector.
318
+ * @public
319
+ * @param {number} x - Aligned vector X coordinate.
320
+ * @param {number} y - Aligned vector Y coordinate.
321
+ * @param {number} z - Aligned vector Z coordinate.
322
+ */
323
+ setAlignedAxis(x, y, z) {
324
+ this._alignedAxis.x = x;
325
+ this._alignedAxis.y = y;
326
+ this._alignedAxis.z = z;
327
+ if (this._isReady && this._handler) {
328
+ this._handler.setAlignedAxisArr(this._handlerIndex, this._alignedAxis);
329
+ } else if (this._lockId !== LOCK_FREE) {
330
+ this._lockId = LOCK_UPDATE;
331
+ }
332
+ }
333
+
334
+ /**
335
+ * Sets billboard aligned vector.
336
+ * @public
337
+ * @param {math.Vecto3} alignedAxis - Vector to align.
338
+ */
339
+ setAlignedAxis3v(alignedAxis) {
340
+ this.setAlignedAxis(alignedAxis.x, alignedAxis.y, alignedAxis.z);
341
+ }
342
+
343
+ /**
344
+ * Returns aligned vector.
345
+ * @public
346
+ * @returns {Vec3}
347
+ */
348
+ getAlignedAxis() {
349
+ return this._alignedAxis;
350
+ }
351
+
352
+ /**
353
+ * Removes billboard from hander.
354
+ * @public
355
+ */
356
+ remove() {
357
+ this._entity = null;
358
+ this._handler && this._handler.remove(this);
359
+ }
360
+
361
+ /**
362
+ * Sets billboard picking color.
363
+ * @public
364
+ * @param {Vec3} color - Picking color.
365
+ */
366
+ setPickingColor3v(color) {
367
+ if (this._isReady && this._handler) {
368
+ this._handler.setPickingColorArr(this._handlerIndex, color);
369
+ } else if (this._lockId !== LOCK_FREE) {
370
+ this._lockId = LOCK_UPDATE;
371
+ }
372
+ }
373
+ }
374
+
375
+ export { BaseBillboard };