@openglobus/og 0.11.5 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/og.css +5 -2
- package/package.json +12 -14
- package/src/og/Clock.js +6 -10
- package/src/og/Events.js +5 -7
- package/src/og/Extent.js +73 -32
- package/src/og/Globe.js +25 -10
- package/src/og/ImageCanvas.js +18 -15
- package/src/og/LonLat.js +13 -10
- package/src/og/Popup.js +19 -17
- package/src/og/QueueArray.js +3 -4
- package/src/og/Rectangle.js +4 -6
- package/src/og/Stack.js +2 -4
- package/src/og/ajax.js +20 -14
- package/src/og/astro/earth.js +21 -15
- package/src/og/bv/Box.js +2 -3
- package/src/og/bv/Sphere.js +10 -7
- package/src/og/camera/Camera.js +70 -79
- package/src/og/camera/Frustum.js +19 -12
- package/src/og/camera/PlanetCamera.js +33 -34
- package/src/og/control/CompassButton.js +1 -2
- package/src/og/control/Control.js +7 -9
- package/src/og/control/DebugInfo.js +2 -3
- package/src/og/control/EarthNavigation.js +26 -17
- package/src/og/control/KeyboardNavigation.js +9 -9
- package/src/og/control/LayerSwitcher.js +21 -20
- package/src/og/control/Lighting.js +74 -64
- package/src/og/control/MouseNavigation.js +30 -29
- package/src/og/control/MouseWheelZoomControl.js +257 -0
- package/src/og/control/SegmentBoundVisualization.js +5 -6
- package/src/og/control/ShowFps.js +12 -7
- package/src/og/control/SimpleNavigation.js +5 -7
- package/src/og/control/Sun.js +24 -14
- package/src/og/control/ToggleWireframe.js +3 -3
- package/src/og/control/TouchNavigation.js +43 -32
- package/src/og/control/ZoomControl.js +40 -24
- package/src/og/control/index.js +2 -0
- package/src/og/control/visibleExtent/Segment.js +1862 -0
- package/src/og/control/visibleExtent/VisibleExtent.js +80 -0
- package/src/og/control/visibleExtent/drawnode.js +751 -0
- package/src/og/ellipsoid/Ellipsoid.js +149 -57
- package/src/og/ellipsoid/wgs84.js +3 -3
- package/src/og/entity/BaseBillboard.js +72 -30
- package/src/og/entity/Billboard.js +9 -5
- package/src/og/entity/BillboardHandler.js +315 -62
- package/src/og/entity/Entity.js +742 -704
- package/src/og/entity/EntityCollection.js +47 -24
- package/src/og/entity/GeoObject.js +228 -0
- package/src/og/entity/GeoObjectHandler.js +895 -0
- package/src/og/entity/GeometryHandler.js +595 -123
- package/src/og/entity/Label.js +62 -30
- package/src/og/entity/LabelHandler.js +42 -243
- package/src/og/entity/LabelWorker.js +218 -0
- package/src/og/entity/Object3d.js +504 -0
- package/src/og/entity/PointCloud.js +76 -28
- package/src/og/entity/PointCloudHandler.js +5 -5
- package/src/og/entity/Ray.js +49 -16
- package/src/og/entity/Strip.js +72 -43
- package/src/og/entity/StripHandler.js +23 -23
- package/src/og/layer/BaseGeoImage.js +50 -19
- package/src/og/layer/CanvasTiles.js +16 -17
- package/src/og/layer/GeoImage.js +8 -16
- package/src/og/layer/GeoTexture2d.js +2 -10
- package/src/og/layer/GeoVideo.js +2 -10
- package/src/og/layer/KML.js +55 -33
- package/src/og/layer/Layer.js +24 -33
- package/src/og/layer/Material.js +1 -1
- package/src/og/layer/Vector.js +94 -48
- package/src/og/layer/WMS.js +33 -18
- package/src/og/layer/XYZ.js +24 -26
- package/src/og/light/LightSource.js +19 -12
- package/src/og/math/Mat3.js +24 -12
- package/src/og/math/Mat4.js +603 -603
- package/src/og/math/Plane.js +19 -18
- package/src/og/math/Ray.js +17 -12
- package/src/og/math/Vec2.js +24 -14
- package/src/og/math/Vec3.js +78 -32
- package/src/og/math/coder.js +7 -7
- package/src/og/proj/EPSG3857.js +3 -3
- package/src/og/proj/EPSG4326.js +3 -3
- package/src/og/proj/Proj.js +2 -4
- package/src/og/quadTree/Node.js +50 -95
- package/src/og/quadTree/quadTree.js +1 -1
- package/src/og/renderer/Renderer.js +106 -126
- package/src/og/renderer/RendererEvents.js +45 -23
- package/src/og/scene/BaseNode.js +2 -3
- package/src/og/scene/Planet.js +139 -191
- package/src/og/scene/RenderNode.js +15 -8
- package/src/og/segment/Segment.js +93 -268
- package/src/og/segment/Slice.js +45 -0
- package/src/og/shaders/drawnode.js +174 -360
- package/src/og/shaders/geoObject.js +211 -0
- package/src/og/shaders/pointCloud.js +41 -41
- package/src/og/shaders/shape.js +12 -18
- package/src/og/shaders/skybox.js +36 -36
- package/src/og/shaders/toneMapping.js +1 -0
- package/src/og/shapes/BaseShape.js +108 -36
- package/src/og/shapes/Icosphere.js +25 -10
- package/src/og/shapes/Sphere.js +8 -11
- package/src/og/terrain/EmptyTerrain.js +3 -2
- package/src/og/terrain/GlobusTerrain.js +2 -0
- package/src/og/utils/FontAtlas.js +6 -2
- package/src/og/utils/GeoImageCreator.js +5 -1
- package/src/og/utils/Loader.js +1 -1
- package/src/og/utils/PlainSegmentWorker.js +0 -13
- package/src/og/utils/TextureAtlas.js +18 -20
- package/src/og/utils/VectorTileCreator.js +1 -3
- package/src/og/utils/shared.js +2 -2
- package/src/og/webgl/Handler.js +219 -162
- package/src/og/webgl/Multisample.js +44 -16
- package/src/og/webgl/Program.js +78 -33
- package/src/og/webgl/callbacks.js +3 -3
- package/types/Clock.d.ts +0 -94
- package/types/Deferred.d.ts +0 -6
- package/types/Events.d.ts +0 -77
- package/types/Extent.d.ts +0 -166
- package/types/Globe.d.ts +0 -82
- package/types/ImageCanvas.d.ts +0 -123
- package/types/Lock.d.ts +0 -12
- package/types/LonLat.d.ts +0 -108
- package/types/Popup.d.ts +0 -42
- package/types/QueueArray.d.ts +0 -19
- package/types/Rectangle.d.ts +0 -80
- package/types/Stack.d.ts +0 -19
- package/types/ajax.d.ts +0 -24
- package/types/arial.d.ts +0 -48
- package/types/astro/astro.d.ts +0 -38
- package/types/astro/earth.d.ts +0 -7
- package/types/astro/jd.d.ts +0 -254
- package/types/bv/Box.d.ts +0 -30
- package/types/bv/Sphere.d.ts +0 -38
- package/types/bv/index.d.ts +0 -3
- package/types/camera/Camera.d.ts +0 -312
- package/types/camera/Frustum.d.ts +0 -133
- package/types/camera/PlanetCamera.d.ts +0 -218
- package/types/camera/index.d.ts +0 -3
- package/types/cons.d.ts +0 -40
- package/types/control/CompassButton.d.ts +0 -17
- package/types/control/Control.d.ts +0 -104
- package/types/control/DebugInfo.d.ts +0 -15
- package/types/control/EarthCoordinates.d.ts +0 -47
- package/types/control/EarthNavigation.d.ts +0 -42
- package/types/control/GeoImageDragControl.d.ts +0 -6
- package/types/control/KeyboardNavigation.d.ts +0 -21
- package/types/control/LayerSwitcher.d.ts +0 -21
- package/types/control/Lighting.d.ts +0 -16
- package/types/control/MouseNavigation.d.ts +0 -47
- package/types/control/ScaleControl.d.ts +0 -22
- package/types/control/ShowFps.d.ts +0 -11
- package/types/control/SimpleNavigation.d.ts +0 -25
- package/types/control/Sun.d.ts +0 -50
- package/types/control/ToggleWireframe.d.ts +0 -12
- package/types/control/TouchNavigation.d.ts +0 -48
- package/types/control/ZoomControl.d.ts +0 -27
- package/types/control/index.d.ts +0 -17
- package/types/ellipsoid/Ellipsoid.d.ts +0 -146
- package/types/ellipsoid/index.d.ts +0 -3
- package/types/ellipsoid/wgs84.d.ts +0 -6
- package/types/entity/BaseBillboard.d.ts +0 -208
- package/types/entity/Billboard.d.ts +0 -94
- package/types/entity/BillboardHandler.d.ts +0 -78
- package/types/entity/Entity.d.ts +0 -333
- package/types/entity/EntityCollection.d.ts +0 -311
- package/types/entity/Geometry.d.ts +0 -74
- package/types/entity/GeometryHandler.d.ts +0 -76
- package/types/entity/Label.d.ts +0 -189
- package/types/entity/LabelHandler.d.ts +0 -29
- package/types/entity/PointCloud.d.ts +0 -174
- package/types/entity/PointCloudHandler.d.ts +0 -38
- package/types/entity/Polyline.d.ts +0 -306
- package/types/entity/PolylineHandler.d.ts +0 -18
- package/types/entity/Ray.d.ts +0 -124
- package/types/entity/RayHandler.d.ts +0 -67
- package/types/entity/ShapeHandler.d.ts +0 -22
- package/types/entity/Strip.d.ts +0 -119
- package/types/entity/StripHandler.d.ts +0 -38
- package/types/entity/index.d.ts +0 -8
- package/types/index.core.d.ts +0 -65
- package/types/index.d.ts +0 -45
- package/types/index.webgl.d.ts +0 -7
- package/types/input/KeyboardHandler.d.ts +0 -10
- package/types/input/MouseHandler.d.ts +0 -5
- package/types/input/TouchHandler.d.ts +0 -5
- package/types/input/input.d.ts +0 -34
- package/types/layer/BaseGeoImage.d.ts +0 -94
- package/types/layer/CanvasTiles.d.ts +0 -68
- package/types/layer/GeoImage.d.ts +0 -52
- package/types/layer/GeoTexture2d.d.ts +0 -8
- package/types/layer/GeoVideo.d.ts +0 -55
- package/types/layer/KML.d.ts +0 -63
- package/types/layer/Layer.d.ts +0 -326
- package/types/layer/Material.d.ts +0 -45
- package/types/layer/Vector.d.ts +0 -208
- package/types/layer/WMS.d.ts +0 -63
- package/types/layer/XYZ.d.ts +0 -120
- package/types/layer/index.d.ts +0 -10
- package/types/light/LightSource.d.ts +0 -178
- package/types/math/Line2.d.ts +0 -11
- package/types/math/Line3.d.ts +0 -10
- package/types/math/Mat3.d.ts +0 -65
- package/types/math/Mat4.d.ts +0 -176
- package/types/math/Plane.d.ts +0 -18
- package/types/math/Quat.d.ts +0 -379
- package/types/math/Ray.d.ts +0 -82
- package/types/math/Vec2.d.ts +0 -309
- package/types/math/Vec3.d.ts +0 -460
- package/types/math/Vec4.d.ts +0 -162
- package/types/math/coder.d.ts +0 -43
- package/types/math/index.d.ts +0 -11
- package/types/math.d.ts +0 -261
- package/types/mercator.d.ts +0 -92
- package/types/proj/EPSG3857.d.ts +0 -6
- package/types/proj/EPSG4326.d.ts +0 -6
- package/types/proj/Proj.d.ts +0 -42
- package/types/quadTree/EntityCollectionNode.d.ts +0 -34
- package/types/quadTree/Node.d.ts +0 -61
- package/types/quadTree/quadTree.d.ts +0 -40
- package/types/renderer/Renderer.d.ts +0 -298
- package/types/renderer/RendererEvents.d.ts +0 -233
- package/types/res/images.d.ts +0 -3
- package/types/scene/Axes.d.ts +0 -11
- package/types/scene/BaseNode.d.ts +0 -60
- package/types/scene/Planet.d.ts +0 -577
- package/types/scene/RenderNode.d.ts +0 -142
- package/types/scene/SkyBox.d.ts +0 -10
- package/types/scene/index.d.ts +0 -4
- package/types/segment/Segment.d.ts +0 -279
- package/types/segment/SegmentLonLat.d.ts +0 -16
- package/types/segment/segmentHelper.d.ts +0 -13
- package/types/shaders/billboard.d.ts +0 -3
- package/types/shaders/depth.d.ts +0 -2
- package/types/shaders/drawnode.d.ts +0 -7
- package/types/shaders/label.d.ts +0 -4
- package/types/shaders/pointCloud.d.ts +0 -2
- package/types/shaders/polyline.d.ts +0 -3
- package/types/shaders/ray.d.ts +0 -2
- package/types/shaders/screenFrame.d.ts +0 -2
- package/types/shaders/shape.d.ts +0 -4
- package/types/shaders/skybox.d.ts +0 -2
- package/types/shaders/toneMapping.d.ts +0 -2
- package/types/shapes/BaseShape.d.ts +0 -250
- package/types/shapes/Sphere.d.ts +0 -41
- package/types/terrain/BilTerrain.d.ts +0 -7
- package/types/terrain/EmptyTerrain.d.ts +0 -72
- package/types/terrain/Geoid.d.ts +0 -26
- package/types/terrain/GlobusTerrain.d.ts +0 -116
- package/types/terrain/MapboxTerrain.d.ts +0 -7
- package/types/terrain/index.d.ts +0 -5
- package/types/utils/FontAtlas.d.ts +0 -14
- package/types/utils/GeoImageCreator.d.ts +0 -30
- package/types/utils/ImagesCacheManager.d.ts +0 -10
- package/types/utils/Loader.d.ts +0 -25
- package/types/utils/NormalMapCreator.d.ts +0 -39
- package/types/utils/PlainSegmentWorker.d.ts +0 -10
- package/types/utils/TerrainWorker.d.ts +0 -9
- package/types/utils/TextureAtlas.d.ts +0 -111
- package/types/utils/VectorTileCreator.d.ts +0 -16
- package/types/utils/colorTable.d.ts +0 -143
- package/types/utils/earcut.d.ts +0 -6
- package/types/utils/shared.d.ts +0 -231
- package/types/webgl/Framebuffer.d.ts +0 -135
- package/types/webgl/Handler.d.ts +0 -388
- package/types/webgl/Multisample.d.ts +0 -89
- package/types/webgl/Program.d.ts +0 -155
- package/types/webgl/ProgramController.d.ts +0 -89
- package/types/webgl/callbacks.d.ts +0 -1
- package/types/webgl/index.d.ts +0 -6
- package/types/webgl/types.d.ts +0 -2
package/src/og/entity/Label.js
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
* @module og/entity/Label
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
"use strict";
|
|
6
6
|
|
|
7
|
-
import * as utils from
|
|
8
|
-
import { BaseBillboard } from
|
|
9
|
-
import { Vec4 } from
|
|
7
|
+
import * as utils from "../utils/shared.js";
|
|
8
|
+
import { BaseBillboard } from "./BaseBillboard.js";
|
|
9
|
+
import { Vec4 } from "../math/Vec4.js";
|
|
10
|
+
import { LOCK_FREE, LOCK_UPDATE } from "./LabelWorker.js";
|
|
10
11
|
|
|
11
12
|
const ALIGN = {
|
|
12
13
|
RIGHT: 0,
|
|
@@ -84,14 +85,19 @@ class Label extends BaseBillboard {
|
|
|
84
85
|
* @private
|
|
85
86
|
* @type {Vec4}
|
|
86
87
|
*/
|
|
87
|
-
this._outlineColor = utils.createColorRGBA(
|
|
88
|
+
this._outlineColor = utils.createColorRGBA(
|
|
89
|
+
options.outlineColor,
|
|
90
|
+
new Vec4(0.0, 0.0, 0.0, 1.0)
|
|
91
|
+
);
|
|
88
92
|
|
|
89
93
|
/**
|
|
90
94
|
* Text horizontal align: "left", "right" and "center".
|
|
91
95
|
* @private
|
|
92
96
|
* @type {Label.ALIGN}
|
|
93
97
|
*/
|
|
94
|
-
this._align = options.align
|
|
98
|
+
this._align = options.align
|
|
99
|
+
? STR2ALIGN[options.align.trim().toLowerCase()] || ALIGN.RIGHT
|
|
100
|
+
: ALIGN.RIGHT;
|
|
95
101
|
|
|
96
102
|
/**
|
|
97
103
|
* Label font atlas index.
|
|
@@ -111,12 +117,14 @@ class Label extends BaseBillboard {
|
|
|
111
117
|
/**
|
|
112
118
|
* Sets lablel text.
|
|
113
119
|
* @public
|
|
114
|
-
* @param {string} text - Text string.
|
|
120
|
+
* @param {string} text - Text string.
|
|
115
121
|
* It can't be bigger than maximum labelHandler _maxLetters value.
|
|
116
122
|
*/
|
|
117
123
|
setText(text) {
|
|
118
124
|
this._text = text.toString();
|
|
119
|
-
this.
|
|
125
|
+
if (this._isReady && this._handler) {
|
|
126
|
+
this._handler.setText(this._handlerIndex, text, this._fontIndex, this._align);
|
|
127
|
+
}
|
|
120
128
|
}
|
|
121
129
|
|
|
122
130
|
/**
|
|
@@ -135,7 +143,11 @@ class Label extends BaseBillboard {
|
|
|
135
143
|
*/
|
|
136
144
|
setAlign(align) {
|
|
137
145
|
this._align = STR2ALIGN[align.trim().toLowerCase()];
|
|
138
|
-
this.
|
|
146
|
+
if (this._isReady && this._handler) {
|
|
147
|
+
this._handler.setText(this._handlerIndex, this._text, this._fontIndex, this._align);
|
|
148
|
+
} else if (this._lockId !== LOCK_FREE) {
|
|
149
|
+
this._lockId = LOCK_UPDATE;
|
|
150
|
+
}
|
|
139
151
|
}
|
|
140
152
|
|
|
141
153
|
/**
|
|
@@ -172,8 +184,14 @@ class Label extends BaseBillboard {
|
|
|
172
184
|
* @param {number} size - Label size in pixels.
|
|
173
185
|
*/
|
|
174
186
|
setSize(size) {
|
|
175
|
-
this._size
|
|
176
|
-
|
|
187
|
+
if (size !== this._size) {
|
|
188
|
+
this._size = size;
|
|
189
|
+
if (this._isReady && this._handler) {
|
|
190
|
+
this._handler.setSizeArr(this._handlerIndex, size);
|
|
191
|
+
} else if (this._lockId !== LOCK_FREE) {
|
|
192
|
+
this._lockId = LOCK_UPDATE;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
177
195
|
}
|
|
178
196
|
|
|
179
197
|
/**
|
|
@@ -192,7 +210,11 @@ class Label extends BaseBillboard {
|
|
|
192
210
|
*/
|
|
193
211
|
setOutline(outline) {
|
|
194
212
|
this._outline = outline;
|
|
195
|
-
this.
|
|
213
|
+
if (this._isReady && this._handler) {
|
|
214
|
+
this._handler.setOutlineArr(this._handlerIndex, outline);
|
|
215
|
+
} else if (this._lockId !== LOCK_FREE) {
|
|
216
|
+
this._lockId = LOCK_UPDATE;
|
|
217
|
+
}
|
|
196
218
|
}
|
|
197
219
|
|
|
198
220
|
/**
|
|
@@ -210,10 +232,8 @@ class Label extends BaseBillboard {
|
|
|
210
232
|
* @param {number} a - Label opacity.
|
|
211
233
|
*/
|
|
212
234
|
setOpacity(a) {
|
|
213
|
-
|
|
214
|
-
this.
|
|
215
|
-
this._outlineColor.w = a;
|
|
216
|
-
this.setOutlineColor4v(this._outlineColor);
|
|
235
|
+
super.setOpacity(a);
|
|
236
|
+
this.setOutlineOpacity(a);
|
|
217
237
|
}
|
|
218
238
|
|
|
219
239
|
/**
|
|
@@ -225,11 +245,17 @@ class Label extends BaseBillboard {
|
|
|
225
245
|
* @param {number} a - Alpha.
|
|
226
246
|
*/
|
|
227
247
|
setOutlineColor(r, g, b, a) {
|
|
228
|
-
this._outlineColor.x
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
248
|
+
if (a !== this._outlineColor.w || r !== this._outlineColor.x || g !== this._outlineColor.y || b !== this._outlineColor.z) {
|
|
249
|
+
this._outlineColor.x = r;
|
|
250
|
+
this._outlineColor.y = g;
|
|
251
|
+
this._outlineColor.z = b;
|
|
252
|
+
this._outlineColor.w = a;
|
|
253
|
+
if (this._isReady && this._handler) {
|
|
254
|
+
this._handler.setOutlineColorArr(this._handlerIndex, this._outlineColor);
|
|
255
|
+
} else if (this._lockId !== LOCK_FREE) {
|
|
256
|
+
this._lockId = LOCK_UPDATE;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
233
259
|
}
|
|
234
260
|
|
|
235
261
|
/**
|
|
@@ -238,11 +264,7 @@ class Label extends BaseBillboard {
|
|
|
238
264
|
* @param {Vec4} rgba - Color vector.
|
|
239
265
|
*/
|
|
240
266
|
setOutlineColor4v(rgba) {
|
|
241
|
-
this.
|
|
242
|
-
this._outlineColor.y = rgba.y;
|
|
243
|
-
this._outlineColor.z = rgba.z;
|
|
244
|
-
this._outlineColor.w = rgba.w;
|
|
245
|
-
this._handler && this._handler.setOutlineColorArr(this._handlerIndex, rgba);
|
|
267
|
+
this.setOutlineColor(rgba.x, rgba.y, rgba.z, rgba.w);
|
|
246
268
|
}
|
|
247
269
|
|
|
248
270
|
/**
|
|
@@ -269,8 +291,14 @@ class Label extends BaseBillboard {
|
|
|
269
291
|
* @param {number} opacity - Outline opacity.
|
|
270
292
|
*/
|
|
271
293
|
setOutlineOpacity(opacity) {
|
|
272
|
-
this._outlineColor.w
|
|
273
|
-
|
|
294
|
+
if (opacity !== this._outlineColor.w) {
|
|
295
|
+
this._outlineColor.w = opacity;
|
|
296
|
+
if (this._isReady && this._handler) {
|
|
297
|
+
this._handler.setOutlineColorArr(this._handlerIndex, this._outlineColor);
|
|
298
|
+
} else if (this._lockId !== LOCK_FREE) {
|
|
299
|
+
this._lockId = LOCK_UPDATE;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
274
302
|
}
|
|
275
303
|
|
|
276
304
|
/**
|
|
@@ -295,9 +323,11 @@ class Label extends BaseBillboard {
|
|
|
295
323
|
|
|
296
324
|
_applyFontIndex(fontIndex) {
|
|
297
325
|
this._fontIndex = fontIndex;
|
|
298
|
-
if (this._handler) {
|
|
326
|
+
if (this._isReady && this._handler) {
|
|
299
327
|
this._handler.setFontIndexArr(this._handlerIndex, this._fontIndex);
|
|
300
328
|
this._handler.setText(this._handlerIndex, this._text, this._fontIndex, this._align);
|
|
329
|
+
} else if (this._lockId !== LOCK_FREE) {
|
|
330
|
+
this._lockId = LOCK_UPDATE;
|
|
301
331
|
}
|
|
302
332
|
}
|
|
303
333
|
|
|
@@ -307,7 +337,9 @@ class Label extends BaseBillboard {
|
|
|
307
337
|
* @param {utils.FontAtlas} fontAtlas - Font atlas.
|
|
308
338
|
*/
|
|
309
339
|
assignFontAtlas(fontAtlas) {
|
|
310
|
-
|
|
340
|
+
if (!this._fontAtlas) {
|
|
341
|
+
this._fontAtlas = fontAtlas;
|
|
342
|
+
}
|
|
311
343
|
this.update();
|
|
312
344
|
}
|
|
313
345
|
}
|
|
@@ -8,6 +8,7 @@ import * as shaders from "../shaders/label.js";
|
|
|
8
8
|
import { ALIGN } from "./Label.js";
|
|
9
9
|
import { BillboardHandler } from "./BillboardHandler.js";
|
|
10
10
|
import { concatTypedArrays, spliceTypedArray } from "../utils/shared.js";
|
|
11
|
+
import { LOCK_FREE } from "./LabelWorker.js";
|
|
11
12
|
|
|
12
13
|
const PICKINGCOLOR_BUFFER = 0;
|
|
13
14
|
const POSITION_BUFFER = 1;
|
|
@@ -76,19 +77,52 @@ class LabelHandler extends BillboardHandler {
|
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
add(label) {
|
|
79
|
-
if (label.
|
|
80
|
+
if (!label._handler) {
|
|
80
81
|
label._handler = this;
|
|
81
|
-
label._handlerIndex = this._billboards.length;
|
|
82
|
-
this._billboards.push(label);
|
|
83
|
-
this._addBillboardToArrays(label);
|
|
84
|
-
this.refresh();
|
|
85
82
|
this.assignFontAtlas(label);
|
|
83
|
+
this.refresh();
|
|
86
84
|
}
|
|
87
85
|
}
|
|
88
86
|
|
|
87
|
+
_addLabelToArrays(label) {
|
|
88
|
+
this._renderer.labelWorker.make(this, label);
|
|
89
|
+
}
|
|
90
|
+
|
|
89
91
|
assignFontAtlas(label) {
|
|
90
92
|
if (this._entityCollection && this._renderer) {
|
|
91
93
|
label.assignFontAtlas(this._renderer.fontAtlas);
|
|
94
|
+
this._addLabelToArrays(label);
|
|
95
|
+
} else {
|
|
96
|
+
this._billboards.push(label);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
workerCallback(data, label) {
|
|
101
|
+
if (label._lockId !== LOCK_FREE && this.isEqual(label._handler)) {
|
|
102
|
+
label._isReady = true;
|
|
103
|
+
label._lockId = LOCK_FREE;
|
|
104
|
+
label._handlerIndex = this._billboards.length;
|
|
105
|
+
this._billboards.push(label);
|
|
106
|
+
|
|
107
|
+
this._vertexArr = concatTypedArrays(this._vertexArr, data.vertexArr);
|
|
108
|
+
this._texCoordArr = concatTypedArrays(this._texCoordArr, data.texCoordArr);
|
|
109
|
+
this._gliphParamArr = concatTypedArrays(this._gliphParamArr, data.gliphParamArr);
|
|
110
|
+
this._positionHighArr = concatTypedArrays(this._positionHighArr, data.positionHighArr);
|
|
111
|
+
this._positionLowArr = concatTypedArrays(this._positionLowArr, data.positionLowArr);
|
|
112
|
+
this._sizeArr = concatTypedArrays(this._sizeArr, data.sizeArr);
|
|
113
|
+
this._offsetArr = concatTypedArrays(this._offsetArr, data.offsetArr);
|
|
114
|
+
this._rgbaArr = concatTypedArrays(this._rgbaArr, data.rgbaArr);
|
|
115
|
+
this._rotationArr = concatTypedArrays(this._rotationArr, data.rotationArr);
|
|
116
|
+
this._alignedAxisArr = concatTypedArrays(this._alignedAxisArr, data.alignedAxisArr);
|
|
117
|
+
this._fontIndexArr = concatTypedArrays(this._fontIndexArr, data.fontIndexArr);
|
|
118
|
+
this._outlineArr = concatTypedArrays(this._outlineArr, data.outlineArr);
|
|
119
|
+
this._noOutlineArr = concatTypedArrays(this._noOutlineArr, data.noOutlineArr);
|
|
120
|
+
this._outlineColorArr = concatTypedArrays(this._outlineColorArr, data.outlineColorArr);
|
|
121
|
+
this._pickingColorArr = concatTypedArrays(this._pickingColorArr, data.pickingColorArr);
|
|
122
|
+
|
|
123
|
+
label.update();
|
|
124
|
+
|
|
125
|
+
this.refresh();
|
|
92
126
|
}
|
|
93
127
|
}
|
|
94
128
|
|
|
@@ -168,236 +202,6 @@ class LabelHandler extends BillboardHandler {
|
|
|
168
202
|
}
|
|
169
203
|
}
|
|
170
204
|
|
|
171
|
-
_addBillboardToArrays(label) {
|
|
172
|
-
for (var i = 0; i < this._maxLetters; i++) {
|
|
173
|
-
if (label._visibility) {
|
|
174
|
-
this._vertexArr = concatTypedArrays(
|
|
175
|
-
this._vertexArr,
|
|
176
|
-
[0, 0, 0, -1, 1, -1, 1, -1, 1, 0, 0, 0]
|
|
177
|
-
);
|
|
178
|
-
} else {
|
|
179
|
-
this._vertexArr = concatTypedArrays(
|
|
180
|
-
this._vertexArr,
|
|
181
|
-
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
this._texCoordArr = concatTypedArrays(
|
|
186
|
-
this._texCoordArr,
|
|
187
|
-
[0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0]
|
|
188
|
-
);
|
|
189
|
-
this._gliphParamArr = concatTypedArrays(
|
|
190
|
-
this._gliphParamArr,
|
|
191
|
-
[1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
var x = label._positionHigh.x,
|
|
195
|
-
y = label._positionHigh.y,
|
|
196
|
-
z = label._positionHigh.z,
|
|
197
|
-
w;
|
|
198
|
-
this._positionHighArr = concatTypedArrays(this._positionHighArr, [
|
|
199
|
-
x,
|
|
200
|
-
y,
|
|
201
|
-
z,
|
|
202
|
-
x,
|
|
203
|
-
y,
|
|
204
|
-
z,
|
|
205
|
-
x,
|
|
206
|
-
y,
|
|
207
|
-
z,
|
|
208
|
-
x,
|
|
209
|
-
y,
|
|
210
|
-
z,
|
|
211
|
-
x,
|
|
212
|
-
y,
|
|
213
|
-
z,
|
|
214
|
-
x,
|
|
215
|
-
y,
|
|
216
|
-
z
|
|
217
|
-
]);
|
|
218
|
-
|
|
219
|
-
x = label._positionLow.x;
|
|
220
|
-
y = label._positionLow.y;
|
|
221
|
-
z = label._positionLow.z;
|
|
222
|
-
this._positionLowArr = concatTypedArrays(this._positionLowArr, [
|
|
223
|
-
x,
|
|
224
|
-
y,
|
|
225
|
-
z,
|
|
226
|
-
x,
|
|
227
|
-
y,
|
|
228
|
-
z,
|
|
229
|
-
x,
|
|
230
|
-
y,
|
|
231
|
-
z,
|
|
232
|
-
x,
|
|
233
|
-
y,
|
|
234
|
-
z,
|
|
235
|
-
x,
|
|
236
|
-
y,
|
|
237
|
-
z,
|
|
238
|
-
x,
|
|
239
|
-
y,
|
|
240
|
-
z
|
|
241
|
-
]);
|
|
242
|
-
|
|
243
|
-
x = label._size;
|
|
244
|
-
this._sizeArr = concatTypedArrays(this._sizeArr, [x, x, x, x, x, x]);
|
|
245
|
-
|
|
246
|
-
x = label._offset.x;
|
|
247
|
-
y = label._offset.y;
|
|
248
|
-
z = label._offset.z;
|
|
249
|
-
this._offsetArr = concatTypedArrays(this._offsetArr, [
|
|
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
|
-
x,
|
|
263
|
-
y,
|
|
264
|
-
z,
|
|
265
|
-
x,
|
|
266
|
-
y,
|
|
267
|
-
z
|
|
268
|
-
]);
|
|
269
|
-
|
|
270
|
-
x = label._color.x;
|
|
271
|
-
y = label._color.y;
|
|
272
|
-
z = label._color.z;
|
|
273
|
-
w = label._color.w;
|
|
274
|
-
this._rgbaArr = concatTypedArrays(this._rgbaArr, [
|
|
275
|
-
x,
|
|
276
|
-
y,
|
|
277
|
-
z,
|
|
278
|
-
w,
|
|
279
|
-
x,
|
|
280
|
-
y,
|
|
281
|
-
z,
|
|
282
|
-
w,
|
|
283
|
-
x,
|
|
284
|
-
y,
|
|
285
|
-
z,
|
|
286
|
-
w,
|
|
287
|
-
x,
|
|
288
|
-
y,
|
|
289
|
-
z,
|
|
290
|
-
w,
|
|
291
|
-
x,
|
|
292
|
-
y,
|
|
293
|
-
z,
|
|
294
|
-
w,
|
|
295
|
-
x,
|
|
296
|
-
y,
|
|
297
|
-
z,
|
|
298
|
-
w
|
|
299
|
-
]);
|
|
300
|
-
|
|
301
|
-
x = label._rotation;
|
|
302
|
-
this._rotationArr = concatTypedArrays(this._rotationArr, [x, x, x, x, x, x]);
|
|
303
|
-
|
|
304
|
-
x = label._alignedAxis.x;
|
|
305
|
-
y = label._alignedAxis.y;
|
|
306
|
-
z = label._alignedAxis.z;
|
|
307
|
-
this._alignedAxisArr = concatTypedArrays(this._alignedAxisArr, [
|
|
308
|
-
x,
|
|
309
|
-
y,
|
|
310
|
-
z,
|
|
311
|
-
x,
|
|
312
|
-
y,
|
|
313
|
-
z,
|
|
314
|
-
x,
|
|
315
|
-
y,
|
|
316
|
-
z,
|
|
317
|
-
x,
|
|
318
|
-
y,
|
|
319
|
-
z,
|
|
320
|
-
x,
|
|
321
|
-
y,
|
|
322
|
-
z,
|
|
323
|
-
x,
|
|
324
|
-
y,
|
|
325
|
-
z
|
|
326
|
-
]);
|
|
327
|
-
|
|
328
|
-
x = label._fontIndex;
|
|
329
|
-
this._fontIndexArr = concatTypedArrays(this._fontIndexArr, [x, x, x, x, x, x]);
|
|
330
|
-
|
|
331
|
-
x = label._outline;
|
|
332
|
-
this._outlineArr = concatTypedArrays(this._outlineArr, [x, x, x, x, x, x]);
|
|
333
|
-
|
|
334
|
-
const weight = 0.001;
|
|
335
|
-
this._noOutlineArr = concatTypedArrays(this._noOutlineArr, [
|
|
336
|
-
weight,
|
|
337
|
-
weight,
|
|
338
|
-
weight,
|
|
339
|
-
weight,
|
|
340
|
-
weight,
|
|
341
|
-
weight
|
|
342
|
-
]);
|
|
343
|
-
|
|
344
|
-
x = label._outlineColor.x;
|
|
345
|
-
y = label._outlineColor.y;
|
|
346
|
-
z = label._outlineColor.z;
|
|
347
|
-
w = label._outlineColor.w;
|
|
348
|
-
this._outlineColorArr = concatTypedArrays(this._outlineColorArr, [
|
|
349
|
-
x,
|
|
350
|
-
y,
|
|
351
|
-
z,
|
|
352
|
-
w,
|
|
353
|
-
x,
|
|
354
|
-
y,
|
|
355
|
-
z,
|
|
356
|
-
w,
|
|
357
|
-
x,
|
|
358
|
-
y,
|
|
359
|
-
z,
|
|
360
|
-
w,
|
|
361
|
-
x,
|
|
362
|
-
y,
|
|
363
|
-
z,
|
|
364
|
-
w,
|
|
365
|
-
x,
|
|
366
|
-
y,
|
|
367
|
-
z,
|
|
368
|
-
w,
|
|
369
|
-
x,
|
|
370
|
-
y,
|
|
371
|
-
z,
|
|
372
|
-
w
|
|
373
|
-
]);
|
|
374
|
-
|
|
375
|
-
x = label._entity._pickingColor.x / 255;
|
|
376
|
-
y = label._entity._pickingColor.y / 255;
|
|
377
|
-
z = label._entity._pickingColor.z / 255;
|
|
378
|
-
this._pickingColorArr = concatTypedArrays(this._pickingColorArr, [
|
|
379
|
-
x,
|
|
380
|
-
y,
|
|
381
|
-
z,
|
|
382
|
-
x,
|
|
383
|
-
y,
|
|
384
|
-
z,
|
|
385
|
-
x,
|
|
386
|
-
y,
|
|
387
|
-
z,
|
|
388
|
-
x,
|
|
389
|
-
y,
|
|
390
|
-
z,
|
|
391
|
-
x,
|
|
392
|
-
y,
|
|
393
|
-
z,
|
|
394
|
-
x,
|
|
395
|
-
y,
|
|
396
|
-
z
|
|
397
|
-
]);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
205
|
_displayPASS() {
|
|
402
206
|
var r = this._renderer;
|
|
403
207
|
var h = r.handler;
|
|
@@ -665,7 +469,8 @@ class LabelHandler extends BillboardHandler {
|
|
|
665
469
|
this.refresh();
|
|
666
470
|
|
|
667
471
|
label._handlerIndex = -1;
|
|
668
|
-
label._handler = null;
|
|
472
|
+
label._handler = null;
|
|
473
|
+
label._isReady = false;
|
|
669
474
|
}
|
|
670
475
|
|
|
671
476
|
setText(index, text, fontIndex, align) {
|
|
@@ -692,12 +497,6 @@ class LabelHandler extends BillboardHandler {
|
|
|
692
497
|
|
|
693
498
|
let m = n.metrics;
|
|
694
499
|
|
|
695
|
-
//m.nWidth;
|
|
696
|
-
//m.nHeight;
|
|
697
|
-
//m.nAdvance;
|
|
698
|
-
//m.nXOffset;
|
|
699
|
-
//m.nYOffset;
|
|
700
|
-
|
|
701
500
|
a[j] = tc[0];
|
|
702
501
|
a[j + 1] = tc[1];
|
|
703
502
|
a[j + 2] = offset;
|
|
@@ -1240,4 +1039,4 @@ class LabelHandler extends BillboardHandler {
|
|
|
1240
1039
|
}
|
|
1241
1040
|
}
|
|
1242
1041
|
|
|
1243
|
-
export { LabelHandler };
|
|
1042
|
+
export { LabelHandler };
|