@openglobus/og 0.11.2 → 0.11.7

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 (273) hide show
  1. package/package.json +13 -13
  2. package/src/og/Clock.js +10 -10
  3. package/src/og/Events.js +8 -6
  4. package/src/og/Extent.js +82 -41
  5. package/src/og/Globe.js +25 -13
  6. package/src/og/ImageCanvas.js +22 -16
  7. package/src/og/LonLat.js +16 -13
  8. package/src/og/Popup.js +21 -14
  9. package/src/og/QueueArray.js +6 -2
  10. package/src/og/Rectangle.js +11 -6
  11. package/src/og/Stack.js +5 -2
  12. package/src/og/ajax.js +21 -33
  13. package/src/og/astro/astro.js +5 -5
  14. package/src/og/astro/earth.js +22 -16
  15. package/src/og/astro/jd.js +23 -18
  16. package/src/og/astro/orbit.js +13 -11
  17. package/src/og/astro/rotation.js +17 -8
  18. package/src/og/bv/Box.js +7 -3
  19. package/src/og/bv/Sphere.js +14 -11
  20. package/src/og/camera/Camera.js +51 -54
  21. package/src/og/camera/Frustum.js +29 -18
  22. package/src/og/camera/PlanetCamera.js +32 -23
  23. package/src/og/control/CompassButton.js +5 -1
  24. package/src/og/control/Control.js +12 -10
  25. package/src/og/control/DebugInfo.js +4 -1
  26. package/src/og/control/EarthCoordinates.js +54 -33
  27. package/src/og/control/KeyboardNavigation.js +10 -10
  28. package/src/og/control/LayerSwitcher.js +22 -21
  29. package/src/og/control/Lighting.js +34 -3
  30. package/src/og/control/MouseNavigation.js +1 -1
  31. package/src/og/control/ScaleControl.js +1 -1
  32. package/src/og/control/SegmentBoundVisualization.js +6 -7
  33. package/src/og/control/ShowFps.js +13 -8
  34. package/src/og/control/SimpleNavigation.js +6 -8
  35. package/src/og/control/Sun.js +25 -15
  36. package/src/og/control/ToggleWireframe.js +4 -4
  37. package/src/og/control/TouchNavigation.js +44 -33
  38. package/src/og/control/ZoomControl.js +41 -25
  39. package/src/og/ellipsoid/Ellipsoid.js +162 -66
  40. package/src/og/ellipsoid/wgs84.js +4 -4
  41. package/src/og/entity/BaseBillboard.js +100 -56
  42. package/src/og/entity/Billboard.js +14 -10
  43. package/src/og/entity/BillboardHandler.js +317 -60
  44. package/src/og/entity/Entity.js +100 -68
  45. package/src/og/entity/EntityCollection.js +70 -47
  46. package/src/og/entity/GeoObject.js +228 -0
  47. package/src/og/entity/GeoObjectHandler.js +910 -0
  48. package/src/og/entity/Geometry.js +27 -24
  49. package/src/og/entity/GeometryHandler.js +596 -124
  50. package/src/og/entity/Label.js +80 -49
  51. package/src/og/entity/LabelHandler.js +45 -244
  52. package/src/og/entity/LabelWorker.js +218 -0
  53. package/src/og/entity/Object3d.js +504 -0
  54. package/src/og/entity/PointCloud.js +80 -32
  55. package/src/og/entity/PointCloudHandler.js +8 -8
  56. package/src/og/entity/Polyline.js +16 -16
  57. package/src/og/entity/Ray.js +60 -27
  58. package/src/og/entity/Strip.js +77 -48
  59. package/src/og/entity/StripHandler.js +26 -26
  60. package/src/og/entity/index.js +8 -16
  61. package/src/og/layer/BaseGeoImage.js +54 -23
  62. package/src/og/layer/CanvasTiles.js +24 -24
  63. package/src/og/layer/GeoImage.js +9 -9
  64. package/src/og/layer/GeoVideo.js +3 -3
  65. package/src/og/layer/KML.js +63 -37
  66. package/src/og/layer/Layer.js +44 -21
  67. package/src/og/layer/Material.js +23 -20
  68. package/src/og/layer/Vector.js +114 -68
  69. package/src/og/layer/WMS.js +34 -17
  70. package/src/og/layer/XYZ.js +48 -46
  71. package/src/og/light/LightSource.js +46 -39
  72. package/src/og/math/Mat3.js +34 -22
  73. package/src/og/math/Mat4.js +603 -459
  74. package/src/og/math/Plane.js +21 -20
  75. package/src/og/math/Quat.js +182 -139
  76. package/src/og/math/Ray.js +38 -33
  77. package/src/og/math/Vec2.js +85 -75
  78. package/src/og/math/Vec3.js +142 -112
  79. package/src/og/math/Vec4.js +27 -31
  80. package/src/og/math/coder.js +10 -10
  81. package/src/og/math.js +12 -12
  82. package/src/og/proj/EPSG3857.js +4 -4
  83. package/src/og/proj/EPSG4326.js +4 -4
  84. package/src/og/proj/Proj.js +4 -6
  85. package/src/og/quadTree/Node.js +8 -8
  86. package/src/og/renderer/Renderer.js +59 -52
  87. package/src/og/renderer/RendererEvents.js +50 -27
  88. package/src/og/scene/BaseNode.js +7 -8
  89. package/src/og/scene/Planet.js +102 -103
  90. package/src/og/scene/RenderNode.js +28 -21
  91. package/src/og/segment/Segment.js +26 -21
  92. package/src/og/segment/SegmentLonLat.js +5 -5
  93. package/src/og/shaders/drawnode.js +135 -142
  94. package/src/og/shaders/geoObject.js +211 -0
  95. package/src/og/shaders/pointCloud.js +41 -41
  96. package/src/og/shaders/shape.js +12 -18
  97. package/src/og/shaders/skybox.js +36 -36
  98. package/src/og/shaders/toneMapping.js +1 -0
  99. package/src/og/shapes/BaseShape.js +126 -54
  100. package/src/og/shapes/Icosphere.js +29 -14
  101. package/src/og/shapes/Sphere.js +12 -15
  102. package/src/og/terrain/BilTerrain.js +1 -0
  103. package/src/og/terrain/EmptyTerrain.js +2 -2
  104. package/src/og/terrain/GlobusTerrain.js +9 -9
  105. package/src/og/utils/FontAtlas.js +6 -2
  106. package/src/og/utils/TextureAtlas.js +22 -24
  107. package/src/og/utils/VectorTileCreator.js +1 -3
  108. package/src/og/utils/shared.js +16 -16
  109. package/src/og/webgl/Framebuffer.js +88 -40
  110. package/src/og/webgl/Handler.js +243 -169
  111. package/src/og/webgl/Multisample.js +47 -19
  112. package/src/og/webgl/Program.js +79 -34
  113. package/src/og/webgl/ProgramController.js +17 -13
  114. package/src/og/webgl/callbacks.js +8 -8
  115. package/src/og/inherits.js +0 -8
  116. package/src/og/utils/polylabel.js +0 -176
  117. package/types/Clock.d.ts +0 -90
  118. package/types/Deferred.d.ts +0 -6
  119. package/types/Events.d.ts +0 -73
  120. package/types/Extent.d.ts +0 -166
  121. package/types/Globe.d.ts +0 -75
  122. package/types/ImageCanvas.d.ts +0 -121
  123. package/types/Lock.d.ts +0 -12
  124. package/types/LonLat.d.ts +0 -108
  125. package/types/Popup.d.ts +0 -38
  126. package/types/QueueArray.d.ts +0 -15
  127. package/types/Rectangle.d.ts +0 -74
  128. package/types/Stack.d.ts +0 -15
  129. package/types/ajax.d.ts +0 -24
  130. package/types/arial.d.ts +0 -48
  131. package/types/astro/astro.d.ts +0 -38
  132. package/types/astro/earth.d.ts +0 -6
  133. package/types/astro/jd.d.ts +0 -254
  134. package/types/bv/Box.d.ts +0 -25
  135. package/types/bv/Sphere.d.ts +0 -38
  136. package/types/bv/index.d.ts +0 -3
  137. package/types/camera/Camera.d.ts +0 -303
  138. package/types/camera/Frustum.d.ts +0 -129
  139. package/types/camera/PlanetCamera.d.ts +0 -223
  140. package/types/camera/index.d.ts +0 -3
  141. package/types/cons.d.ts +0 -40
  142. package/types/control/CompassButton.d.ts +0 -18
  143. package/types/control/Control.d.ts +0 -101
  144. package/types/control/DebugInfo.d.ts +0 -16
  145. package/types/control/EarthCoordinates.d.ts +0 -47
  146. package/types/control/EarthNavigation.d.ts +0 -42
  147. package/types/control/GeoImageDragControl.d.ts +0 -6
  148. package/types/control/KeyboardNavigation.d.ts +0 -22
  149. package/types/control/LayerSwitcher.d.ts +0 -23
  150. package/types/control/Lighting.d.ts +0 -16
  151. package/types/control/MouseNavigation.d.ts +0 -51
  152. package/types/control/ScaleControl.d.ts +0 -22
  153. package/types/control/ShowFps.d.ts +0 -12
  154. package/types/control/SimpleNavigation.d.ts +0 -28
  155. package/types/control/Sun.d.ts +0 -52
  156. package/types/control/ToggleWireframe.d.ts +0 -12
  157. package/types/control/TouchNavigation.d.ts +0 -50
  158. package/types/control/ZoomControl.d.ts +0 -28
  159. package/types/control/index.d.ts +0 -17
  160. package/types/ellipsoid/Ellipsoid.d.ts +0 -142
  161. package/types/ellipsoid/index.d.ts +0 -3
  162. package/types/ellipsoid/wgs84.d.ts +0 -5
  163. package/types/entity/BaseBillboard.d.ts +0 -208
  164. package/types/entity/Billboard.d.ts +0 -94
  165. package/types/entity/BillboardHandler.d.ts +0 -74
  166. package/types/entity/Entity.d.ts +0 -331
  167. package/types/entity/EntityCollection.d.ts +0 -303
  168. package/types/entity/Geometry.d.ts +0 -73
  169. package/types/entity/GeometryHandler.d.ts +0 -76
  170. package/types/entity/Label.d.ts +0 -194
  171. package/types/entity/LabelHandler.d.ts +0 -24
  172. package/types/entity/PointCloud.d.ts +0 -174
  173. package/types/entity/PointCloudHandler.d.ts +0 -38
  174. package/types/entity/Polyline.d.ts +0 -304
  175. package/types/entity/PolylineHandler.d.ts +0 -18
  176. package/types/entity/Ray.d.ts +0 -123
  177. package/types/entity/RayHandler.d.ts +0 -67
  178. package/types/entity/ShapeHandler.d.ts +0 -22
  179. package/types/entity/Strip.d.ts +0 -118
  180. package/types/entity/StripHandler.d.ts +0 -38
  181. package/types/entity/index.d.ts +0 -8
  182. package/types/index.core.d.ts +0 -65
  183. package/types/index.d.ts +0 -45
  184. package/types/index.webgl.d.ts +0 -7
  185. package/types/inherits.d.ts +0 -4
  186. package/types/input/KeyboardHandler.d.ts +0 -10
  187. package/types/input/MouseHandler.d.ts +0 -5
  188. package/types/input/TouchHandler.d.ts +0 -5
  189. package/types/input/input.d.ts +0 -34
  190. package/types/layer/BaseGeoImage.d.ts +0 -107
  191. package/types/layer/CanvasTiles.d.ts +0 -75
  192. package/types/layer/GeoImage.d.ts +0 -65
  193. package/types/layer/GeoTexture2d.d.ts +0 -8
  194. package/types/layer/GeoVideo.d.ts +0 -80
  195. package/types/layer/KML.d.ts +0 -58
  196. package/types/layer/Layer.d.ts +0 -321
  197. package/types/layer/Material.d.ts +0 -48
  198. package/types/layer/Vector.d.ts +0 -228
  199. package/types/layer/WMS.d.ts +0 -66
  200. package/types/layer/XYZ.d.ts +0 -130
  201. package/types/layer/index.d.ts +0 -10
  202. package/types/light/LightSource.d.ts +0 -177
  203. package/types/math/Line2.d.ts +0 -11
  204. package/types/math/Line3.d.ts +0 -10
  205. package/types/math/Mat3.d.ts +0 -63
  206. package/types/math/Mat4.d.ts +0 -173
  207. package/types/math/Plane.d.ts +0 -17
  208. package/types/math/Quat.d.ts +0 -376
  209. package/types/math/Ray.d.ts +0 -81
  210. package/types/math/Vec2.d.ts +0 -308
  211. package/types/math/Vec3.d.ts +0 -459
  212. package/types/math/Vec4.d.ts +0 -161
  213. package/types/math/coder.d.ts +0 -42
  214. package/types/math/index.d.ts +0 -11
  215. package/types/math.d.ts +0 -261
  216. package/types/mercator.d.ts +0 -92
  217. package/types/proj/EPSG3857.d.ts +0 -5
  218. package/types/proj/EPSG4326.d.ts +0 -5
  219. package/types/proj/Proj.d.ts +0 -42
  220. package/types/quadTree/EntityCollectionNode.d.ts +0 -34
  221. package/types/quadTree/Node.d.ts +0 -61
  222. package/types/quadTree/quadTree.d.ts +0 -40
  223. package/types/renderer/Renderer.d.ts +0 -296
  224. package/types/renderer/RendererEvents.d.ts +0 -230
  225. package/types/res/images.d.ts +0 -3
  226. package/types/scene/Axes.d.ts +0 -11
  227. package/types/scene/BaseNode.d.ts +0 -60
  228. package/types/scene/Planet.d.ts +0 -574
  229. package/types/scene/RenderNode.d.ts +0 -143
  230. package/types/scene/SkyBox.d.ts +0 -10
  231. package/types/scene/index.d.ts +0 -4
  232. package/types/segment/Segment.d.ts +0 -271
  233. package/types/segment/SegmentLonLat.d.ts +0 -62
  234. package/types/segment/segmentHelper.d.ts +0 -13
  235. package/types/shaders/billboard.d.ts +0 -3
  236. package/types/shaders/depth.d.ts +0 -2
  237. package/types/shaders/drawnode.d.ts +0 -7
  238. package/types/shaders/label.d.ts +0 -4
  239. package/types/shaders/pointCloud.d.ts +0 -2
  240. package/types/shaders/polyline.d.ts +0 -3
  241. package/types/shaders/ray.d.ts +0 -2
  242. package/types/shaders/screenFrame.d.ts +0 -2
  243. package/types/shaders/shape.d.ts +0 -4
  244. package/types/shaders/skybox.d.ts +0 -2
  245. package/types/shaders/toneMapping.d.ts +0 -2
  246. package/types/shapes/BaseShape.d.ts +0 -247
  247. package/types/shapes/Sphere.d.ts +0 -41
  248. package/types/terrain/BilTerrain.d.ts +0 -8
  249. package/types/terrain/EmptyTerrain.d.ts +0 -72
  250. package/types/terrain/Geoid.d.ts +0 -26
  251. package/types/terrain/GlobusTerrain.d.ts +0 -153
  252. package/types/terrain/MapboxTerrain.d.ts +0 -8
  253. package/types/terrain/index.d.ts +0 -5
  254. package/types/utils/FontAtlas.d.ts +0 -14
  255. package/types/utils/GeoImageCreator.d.ts +0 -30
  256. package/types/utils/ImagesCacheManager.d.ts +0 -10
  257. package/types/utils/Loader.d.ts +0 -25
  258. package/types/utils/NormalMapCreator.d.ts +0 -39
  259. package/types/utils/PlainSegmentWorker.d.ts +0 -10
  260. package/types/utils/TerrainWorker.d.ts +0 -9
  261. package/types/utils/TextureAtlas.d.ts +0 -111
  262. package/types/utils/VectorTileCreator.d.ts +0 -16
  263. package/types/utils/colorTable.d.ts +0 -143
  264. package/types/utils/earcut.d.ts +0 -6
  265. package/types/utils/shared.d.ts +0 -230
  266. package/types/webgl/Framebuffer.d.ts +0 -135
  267. package/types/webgl/Handler.d.ts +0 -372
  268. package/types/webgl/Multisample.d.ts +0 -89
  269. package/types/webgl/Program.d.ts +0 -155
  270. package/types/webgl/ProgramController.d.ts +0 -84
  271. package/types/webgl/callbacks.d.ts +0 -1
  272. package/types/webgl/index.d.ts +0 -6
  273. package/types/webgl/types.d.ts +0 -2
@@ -2,20 +2,21 @@
2
2
  * @module og/entity/BaseBillboard
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
- import * as utils from '../utils/shared.js';
8
- import { Vec3 } from '../math/Vec3.js';
7
+ import * as utils from "../utils/shared.js";
8
+ import { Vec3 } from "../math/Vec3.js";
9
+ import { LOCK_FREE, LOCK_UPDATE } from "./LabelWorker.js";
9
10
 
10
11
  /**
11
12
  * Base prototype for billboard and label classes.
12
13
  * @class
13
14
  * @param {Object} [options] - Options:
14
- * @param {og.Vec3|Array.<number>} [options.position] - Billboard spatial position.
15
+ * @param {Vec3|Array.<number>} [options.position] - Billboard spatial position.
15
16
  * @param {number} [options.rotation] - Screen angle rotaion.
16
- * @param {og.Vec4|string|Array.<number>} [options.color] - Billboard color.
17
- * @param {og.Vec3|Array.<number>} [options.alignedAxis] - Billboard aligned vector.
18
- * @param {og.Vec3|Array.<number>} [options.offset] - Billboard center screen offset.
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.
19
20
  * @param {boolean} [options.visibility] - Visibility.
20
21
  */
21
22
  class BaseBillboard {
@@ -33,14 +34,14 @@ class BaseBillboard {
33
34
  /**
34
35
  * Billboard center cartesian position.
35
36
  * @protected
36
- * @type {og.Vec3}
37
+ * @type {Vec3}
37
38
  */
38
39
  this._position = utils.createVector3(options.position);
39
40
 
40
41
  this._positionHigh = new Vec3();
41
-
42
+
42
43
  this._positionLow = new Vec3();
43
-
44
+
44
45
  Vec3.doubleToTwoFloats(this._position, this._positionHigh, this._positionLow);
45
46
 
46
47
  /**
@@ -53,21 +54,21 @@ class BaseBillboard {
53
54
  /**
54
55
  * RGBA color.
55
56
  * @protected
56
- * @type {og.Vec4}
57
+ * @type {Vec4}
57
58
  */
58
59
  this._color = utils.createColorRGBA(options.color);
59
60
 
60
61
  /**
61
62
  * Cartesian aligned axis vector.
62
63
  * @protected
63
- * @type {og.Vec3}
64
+ * @type {Vec3}
64
65
  */
65
66
  this._alignedAxis = utils.createVector3(options.alignedAxis);
66
67
 
67
68
  /**
68
69
  * Billboard center screen space offset. Where x,y - screen space offset and z - depth offset.
69
70
  * @protected
70
- * @type {og.math.Vecto3}
71
+ * @type {math.Vecto3}
71
72
  */
72
73
  this._offset = utils.createVector3(options.offset);
73
74
 
@@ -81,14 +82,14 @@ class BaseBillboard {
81
82
  /**
82
83
  * Entity instance that holds this billboard.
83
84
  * @protected
84
- * @type {og.Entity}
85
+ * @type {Entity}
85
86
  */
86
87
  this._entity = null;
87
88
 
88
89
  /**
89
90
  * Handler that stores and renders this billboard object.
90
91
  * @protected
91
- * @type {og.BillboardHandler}
92
+ * @type {BillboardHandler}
92
93
  */
93
94
  this._handler = null;
94
95
 
@@ -98,6 +99,15 @@ class BaseBillboard {
98
99
  * @type {number}
99
100
  */
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;
101
111
  }
102
112
 
103
113
  static get _staticCounter() {
@@ -121,28 +131,36 @@ class BaseBillboard {
121
131
  setPosition(x, y, z) {
122
132
  this._position.x = x;
123
133
  this._position.y = y;
124
- this._position.z = z;
125
- Vec3.doubleToTwoFloats(position, this._positionHigh, this._positionLow);
126
- this._handler && this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow);
134
+ this._position.z = z;
135
+ Vec3.doubleToTwoFloats(this._position, this._positionHigh, this._positionLow);
136
+ if (this._isReady) {
137
+ this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow);
138
+ } else if (this._lockId !== LOCK_FREE) {
139
+ this._lockId = LOCK_UPDATE;
140
+ }
127
141
  }
128
142
 
129
143
  /**
130
144
  * Sets billboard position.
131
145
  * @public
132
- * @param {og.Vec3} position - Cartesian coordinates.
146
+ * @param {Vec3} position - Cartesian coordinates.
133
147
  */
134
148
  setPosition3v(position) {
135
149
  this._position.x = position.x;
136
150
  this._position.y = position.y;
137
151
  this._position.z = position.z;
138
152
  Vec3.doubleToTwoFloats(position, this._positionHigh, this._positionLow);
139
- this._handler && this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow);
153
+ if (this._isReady) {
154
+ this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow);
155
+ } else if (this._lockId !== LOCK_FREE) {
156
+ this._lockId = LOCK_UPDATE;
157
+ }
140
158
  }
141
159
 
142
160
  /**
143
161
  * Returns billboard position.
144
162
  * @public
145
- * @returns {og.Vec3}
163
+ * @returns {Vec3}
146
164
  */
147
165
  getPosition() {
148
166
  return this._position;
@@ -158,26 +176,27 @@ class BaseBillboard {
158
176
  setOffset(x, y, z) {
159
177
  this._offset.x = x;
160
178
  this._offset.y = y;
161
- (z != undefined) && (this._offset.z = z);
162
- this._handler && this._handler.setOffsetArr(this._handlerIndex, this._offset);
179
+ z != undefined && (this._offset.z = z);
180
+ if (this._isReady) {
181
+ this._handler.setOffsetArr(this._handlerIndex, this._offset);
182
+ } else if (this._lockId !== LOCK_FREE) {
183
+ this._lockId = LOCK_UPDATE;
184
+ }
163
185
  }
164
186
 
165
187
  /**
166
188
  * Sets screen space offset.
167
189
  * @public
168
- * @param {og.Vec2} offset - Offset size.
190
+ * @param {Vec2} offset - Offset size.
169
191
  */
170
192
  setOffset3v(offset) {
171
- this._offset.x = offset.x;
172
- this._offset.y = offset.y;
173
- (offset.z != undefined) && (this._offset.z = offset.z);
174
- this._handler && this._handler.setOffsetArr(this._handlerIndex, offset);
193
+ this.setOffset(offset.x, offset.y, offset.z);
175
194
  }
176
195
 
177
196
  /**
178
197
  * Returns billboard screen space offset size.
179
198
  * @public
180
- * @returns {og.Vec3}
199
+ * @returns {Vec3}
181
200
  */
182
201
  getOffset() {
183
202
  return this._offset;
@@ -189,8 +208,14 @@ class BaseBillboard {
189
208
  * @param {number} rotation - Screen space rotation in radians.
190
209
  */
191
210
  setRotation(rotation) {
192
- this._rotation = rotation;
193
- this._handler && this._handler.setRotationArr(this._handlerIndex, rotation);
211
+ if (rotation !== this._rotation) {
212
+ this._rotation = rotation;
213
+ if (this._isReady) {
214
+ this._handler.setRotationArr(this._handlerIndex, rotation);
215
+ } else if (this._lockId !== LOCK_FREE) {
216
+ this._lockId = LOCK_UPDATE;
217
+ }
218
+ }
194
219
  }
195
220
 
196
221
  /**
@@ -208,8 +233,14 @@ class BaseBillboard {
208
233
  * @param {number} a - Billboard opacity.
209
234
  */
210
235
  setOpacity(a) {
211
- this._color.w = a;
212
- this.setColor(this._color.x, this._color.y, this._color.z, a);
236
+ if (a !== this._color.w) {
237
+ a != undefined && (this._color.w = a);
238
+ if (this._isReady) {
239
+ this._handler.setRgbaArr(this._handlerIndex, this._color);
240
+ } else if (this._lockId !== LOCK_FREE) {
241
+ this._lockId = LOCK_UPDATE;
242
+ }
243
+ }
213
244
  }
214
245
 
215
246
  /**
@@ -221,24 +252,26 @@ class BaseBillboard {
221
252
  * @param {number} a - Alpha.
222
253
  */
223
254
  setColor(r, g, b, a) {
224
- this._color.x = r;
225
- this._color.y = g;
226
- this._color.z = b;
227
- (a != undefined) && (this._color.w = a);
228
- this._handler && this._handler.setRgbaArr(this._handlerIndex, this._color);
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) {
261
+ this._handler.setRgbaArr(this._handlerIndex, this._color);
262
+ } else if (this._lockId !== LOCK_FREE) {
263
+ this._lockId = LOCK_UPDATE;
264
+ }
265
+ }
229
266
  }
230
267
 
231
268
  /**
232
269
  * Sets RGBA color. Each channel from 0.0 to 1.0.
233
270
  * @public
234
- * @param {og.Vec4} color - RGBA vector.
271
+ * @param {Vec4} color - RGBA vector.
235
272
  */
236
273
  setColor4v(color) {
237
- this._color.x = color.x;
238
- this._color.y = color.y;
239
- this._color.z = color.z;
240
- (color.w != undefined) && (this._color.w = color.w);
241
- this._handler && this._handler.setRgbaArr(this._handlerIndex, color);
274
+ this.setColor(color.x, color.y, color.z, color.w);
242
275
  }
243
276
 
244
277
  /**
@@ -253,7 +286,7 @@ class BaseBillboard {
253
286
  /**
254
287
  * Returns RGBA color.
255
288
  * @public
256
- * @returns {og.Vec4}
289
+ * @returns {Vec4}
257
290
  */
258
291
  getColor() {
259
292
  return this._color;
@@ -265,8 +298,14 @@ class BaseBillboard {
265
298
  * @param {boolean} visibility - Visibility flag.
266
299
  */
267
300
  setVisibility(visibility) {
268
- this._visibility = visibility;
269
- this._handler && this._handler.setVisibility(this._handlerIndex, visibility);
301
+ if (visibility !== this._visibility) {
302
+ this._visibility = visibility;
303
+ if (this._isReady) {
304
+ this._handler.setVisibility(this._handlerIndex, visibility);
305
+ } else if (this._lockId !== LOCK_FREE) {
306
+ this._lockId = LOCK_UPDATE;
307
+ }
308
+ }
270
309
  }
271
310
 
272
311
  /**
@@ -289,25 +328,26 @@ class BaseBillboard {
289
328
  this._alignedAxis.x = x;
290
329
  this._alignedAxis.y = y;
291
330
  this._alignedAxis.z = z;
292
- this._handler && this._handler.setAlignedAxisArr(this._handlerIndex, this._alignedAxis);
331
+ if (this._isReady) {
332
+ this._handler.setAlignedAxisArr(this._handlerIndex, this._alignedAxis);
333
+ } else if (this._lockId !== LOCK_FREE) {
334
+ this._lockId = LOCK_UPDATE;
335
+ }
293
336
  }
294
337
 
295
338
  /**
296
339
  * Sets billboard aligned vector.
297
340
  * @public
298
- * @param {og.math.Vecto3} alignedAxis - Vector to align.
341
+ * @param {math.Vecto3} alignedAxis - Vector to align.
299
342
  */
300
343
  setAlignedAxis3v(alignedAxis) {
301
- this._alignedAxis.x = alignedAxis.x;
302
- this._alignedAxis.y = alignedAxis.y;
303
- this._alignedAxis.z = alignedAxis.z;
304
- this._handler && this._handler.setAlignedAxisArr(this._handlerIndex, alignedAxis);
344
+ this.setAlignedAxis(alignedAxis.x, alignedAxis.y, alignedAxis.z);
305
345
  }
306
346
 
307
347
  /**
308
348
  * Returns aligned vector.
309
349
  * @public
310
- * @returns {og.Vec3}
350
+ * @returns {Vec3}
311
351
  */
312
352
  getAlignedAxis() {
313
353
  return this._alignedAxis;
@@ -325,10 +365,14 @@ class BaseBillboard {
325
365
  /**
326
366
  * Sets billboard picking color.
327
367
  * @public
328
- * @param {og.Vec3} color - Picking color.
368
+ * @param {Vec3} color - Picking color.
329
369
  */
330
370
  setPickingColor3v(color) {
331
- this._handler && this._handler.setPickingColorArr(this._handlerIndex, color);
371
+ if (this._isReady) {
372
+ this._handler.setPickingColorArr(this._handlerIndex, color);
373
+ } else if (this._lockId !== LOCK_FREE) {
374
+ this._lockId = LOCK_UPDATE;
375
+ }
332
376
  }
333
377
  }
334
378
 
@@ -2,20 +2,20 @@
2
2
  * @module og/entity/Billboard
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
- import { BaseBillboard } from './BaseBillboard.js';
7
+ import { BaseBillboard } from "./BaseBillboard.js";
8
8
 
9
9
  /**
10
10
  * Represents basic quad billboard image.
11
11
  * @class
12
- * @extends {og.BaseBillboard}
12
+ * @extends {BaseBillboard}
13
13
  * @param {Object} [options] - Options:
14
- * @param {og.Vec3|Array.<number>} [options.position] - Billboard spatial position.
14
+ * @param {Vec3|Array.<number>} [options.position] - Billboard spatial position.
15
15
  * @param {number} [options.rotation] - Screen angle rotaion.
16
- * @param {og.Vec4|string|Array.<number>} [options.color] - Billboard color.
17
- * @param {og.Vec3|Array.<number>} [options.alignedAxis] - Billboard aligned vector.
18
- * @param {og.Vec3|Array.<number>} [options.offset] - Billboard center screen offset.
16
+ * @param {Vec4|string|Array.<number>} [options.color] - Billboard color.
17
+ * @param {Vec3|Array.<number>} [options.alignedAxis] - Billboard aligned vector.
18
+ * @param {Vec3|Array.<number>} [options.offset] - Billboard center screen offset.
19
19
  * @param {boolean} [options.visibility] - Visibility.
20
20
  * @param {string} [options.src] - Billboard image url source.
21
21
  * @param {Image} [options.image] - Billboard image object.
@@ -76,7 +76,10 @@ class Billboard extends BaseBillboard {
76
76
  ta.loadImage(src, function (img) {
77
77
  if (ta.nodes[img.__nodeIndex]) {
78
78
  that._image = img;
79
- bh.setTexCoordArr(that._handlerIndex, ta.nodes[that._image.__nodeIndex].texCoords);
79
+ bh.setTexCoordArr(
80
+ that._handlerIndex,
81
+ ta.nodes[that._image.__nodeIndex].texCoords
82
+ );
80
83
  } else {
81
84
  ta.addImage(img);
82
85
  ta.createTexture();
@@ -106,7 +109,8 @@ class Billboard extends BaseBillboard {
106
109
  setSize(width, height) {
107
110
  this._width = width;
108
111
  this._height = height;
109
- this._handler && this._handler.setSizeArr(this._handlerIndex, width * this._scale, height * this._scale);
112
+ this._handler &&
113
+ this._handler.setSizeArr(this._handlerIndex, width * this._scale, height * this._scale);
110
114
  }
111
115
 
112
116
  /**
@@ -158,4 +162,4 @@ class Billboard extends BaseBillboard {
158
162
  }
159
163
  }
160
164
 
161
- export { Billboard };
165
+ export { Billboard };