@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.
- package/package.json +13 -13
- package/src/og/Clock.js +10 -10
- package/src/og/Events.js +8 -6
- package/src/og/Extent.js +82 -41
- package/src/og/Globe.js +25 -13
- package/src/og/ImageCanvas.js +22 -16
- package/src/og/LonLat.js +16 -13
- package/src/og/Popup.js +21 -14
- package/src/og/QueueArray.js +6 -2
- package/src/og/Rectangle.js +11 -6
- package/src/og/Stack.js +5 -2
- package/src/og/ajax.js +21 -33
- package/src/og/astro/astro.js +5 -5
- package/src/og/astro/earth.js +22 -16
- package/src/og/astro/jd.js +23 -18
- package/src/og/astro/orbit.js +13 -11
- package/src/og/astro/rotation.js +17 -8
- package/src/og/bv/Box.js +7 -3
- package/src/og/bv/Sphere.js +14 -11
- package/src/og/camera/Camera.js +51 -54
- package/src/og/camera/Frustum.js +29 -18
- package/src/og/camera/PlanetCamera.js +32 -23
- package/src/og/control/CompassButton.js +5 -1
- package/src/og/control/Control.js +12 -10
- package/src/og/control/DebugInfo.js +4 -1
- package/src/og/control/EarthCoordinates.js +54 -33
- package/src/og/control/KeyboardNavigation.js +10 -10
- package/src/og/control/LayerSwitcher.js +22 -21
- package/src/og/control/Lighting.js +34 -3
- package/src/og/control/MouseNavigation.js +1 -1
- package/src/og/control/ScaleControl.js +1 -1
- package/src/og/control/SegmentBoundVisualization.js +6 -7
- package/src/og/control/ShowFps.js +13 -8
- package/src/og/control/SimpleNavigation.js +6 -8
- package/src/og/control/Sun.js +25 -15
- package/src/og/control/ToggleWireframe.js +4 -4
- package/src/og/control/TouchNavigation.js +44 -33
- package/src/og/control/ZoomControl.js +41 -25
- package/src/og/ellipsoid/Ellipsoid.js +162 -66
- package/src/og/ellipsoid/wgs84.js +4 -4
- package/src/og/entity/BaseBillboard.js +100 -56
- package/src/og/entity/Billboard.js +14 -10
- package/src/og/entity/BillboardHandler.js +317 -60
- package/src/og/entity/Entity.js +100 -68
- package/src/og/entity/EntityCollection.js +70 -47
- package/src/og/entity/GeoObject.js +228 -0
- package/src/og/entity/GeoObjectHandler.js +910 -0
- package/src/og/entity/Geometry.js +27 -24
- package/src/og/entity/GeometryHandler.js +596 -124
- package/src/og/entity/Label.js +80 -49
- package/src/og/entity/LabelHandler.js +45 -244
- package/src/og/entity/LabelWorker.js +218 -0
- package/src/og/entity/Object3d.js +504 -0
- package/src/og/entity/PointCloud.js +80 -32
- package/src/og/entity/PointCloudHandler.js +8 -8
- package/src/og/entity/Polyline.js +16 -16
- package/src/og/entity/Ray.js +60 -27
- package/src/og/entity/Strip.js +77 -48
- package/src/og/entity/StripHandler.js +26 -26
- package/src/og/entity/index.js +8 -16
- package/src/og/layer/BaseGeoImage.js +54 -23
- package/src/og/layer/CanvasTiles.js +24 -24
- package/src/og/layer/GeoImage.js +9 -9
- package/src/og/layer/GeoVideo.js +3 -3
- package/src/og/layer/KML.js +63 -37
- package/src/og/layer/Layer.js +44 -21
- package/src/og/layer/Material.js +23 -20
- package/src/og/layer/Vector.js +114 -68
- package/src/og/layer/WMS.js +34 -17
- package/src/og/layer/XYZ.js +48 -46
- package/src/og/light/LightSource.js +46 -39
- package/src/og/math/Mat3.js +34 -22
- package/src/og/math/Mat4.js +603 -459
- package/src/og/math/Plane.js +21 -20
- package/src/og/math/Quat.js +182 -139
- package/src/og/math/Ray.js +38 -33
- package/src/og/math/Vec2.js +85 -75
- package/src/og/math/Vec3.js +142 -112
- package/src/og/math/Vec4.js +27 -31
- package/src/og/math/coder.js +10 -10
- package/src/og/math.js +12 -12
- package/src/og/proj/EPSG3857.js +4 -4
- package/src/og/proj/EPSG4326.js +4 -4
- package/src/og/proj/Proj.js +4 -6
- package/src/og/quadTree/Node.js +8 -8
- package/src/og/renderer/Renderer.js +59 -52
- package/src/og/renderer/RendererEvents.js +50 -27
- package/src/og/scene/BaseNode.js +7 -8
- package/src/og/scene/Planet.js +102 -103
- package/src/og/scene/RenderNode.js +28 -21
- package/src/og/segment/Segment.js +26 -21
- package/src/og/segment/SegmentLonLat.js +5 -5
- package/src/og/shaders/drawnode.js +135 -142
- 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 +126 -54
- package/src/og/shapes/Icosphere.js +29 -14
- package/src/og/shapes/Sphere.js +12 -15
- package/src/og/terrain/BilTerrain.js +1 -0
- package/src/og/terrain/EmptyTerrain.js +2 -2
- package/src/og/terrain/GlobusTerrain.js +9 -9
- package/src/og/utils/FontAtlas.js +6 -2
- package/src/og/utils/TextureAtlas.js +22 -24
- package/src/og/utils/VectorTileCreator.js +1 -3
- package/src/og/utils/shared.js +16 -16
- package/src/og/webgl/Framebuffer.js +88 -40
- package/src/og/webgl/Handler.js +243 -169
- package/src/og/webgl/Multisample.js +47 -19
- package/src/og/webgl/Program.js +79 -34
- package/src/og/webgl/ProgramController.js +17 -13
- package/src/og/webgl/callbacks.js +8 -8
- package/src/og/inherits.js +0 -8
- package/src/og/utils/polylabel.js +0 -176
- package/types/Clock.d.ts +0 -90
- package/types/Deferred.d.ts +0 -6
- package/types/Events.d.ts +0 -73
- package/types/Extent.d.ts +0 -166
- package/types/Globe.d.ts +0 -75
- package/types/ImageCanvas.d.ts +0 -121
- package/types/Lock.d.ts +0 -12
- package/types/LonLat.d.ts +0 -108
- package/types/Popup.d.ts +0 -38
- package/types/QueueArray.d.ts +0 -15
- package/types/Rectangle.d.ts +0 -74
- package/types/Stack.d.ts +0 -15
- 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 -6
- package/types/astro/jd.d.ts +0 -254
- package/types/bv/Box.d.ts +0 -25
- package/types/bv/Sphere.d.ts +0 -38
- package/types/bv/index.d.ts +0 -3
- package/types/camera/Camera.d.ts +0 -303
- package/types/camera/Frustum.d.ts +0 -129
- package/types/camera/PlanetCamera.d.ts +0 -223
- package/types/camera/index.d.ts +0 -3
- package/types/cons.d.ts +0 -40
- package/types/control/CompassButton.d.ts +0 -18
- package/types/control/Control.d.ts +0 -101
- package/types/control/DebugInfo.d.ts +0 -16
- 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 -22
- package/types/control/LayerSwitcher.d.ts +0 -23
- package/types/control/Lighting.d.ts +0 -16
- package/types/control/MouseNavigation.d.ts +0 -51
- package/types/control/ScaleControl.d.ts +0 -22
- package/types/control/ShowFps.d.ts +0 -12
- package/types/control/SimpleNavigation.d.ts +0 -28
- package/types/control/Sun.d.ts +0 -52
- package/types/control/ToggleWireframe.d.ts +0 -12
- package/types/control/TouchNavigation.d.ts +0 -50
- package/types/control/ZoomControl.d.ts +0 -28
- package/types/control/index.d.ts +0 -17
- package/types/ellipsoid/Ellipsoid.d.ts +0 -142
- package/types/ellipsoid/index.d.ts +0 -3
- package/types/ellipsoid/wgs84.d.ts +0 -5
- package/types/entity/BaseBillboard.d.ts +0 -208
- package/types/entity/Billboard.d.ts +0 -94
- package/types/entity/BillboardHandler.d.ts +0 -74
- package/types/entity/Entity.d.ts +0 -331
- package/types/entity/EntityCollection.d.ts +0 -303
- package/types/entity/Geometry.d.ts +0 -73
- package/types/entity/GeometryHandler.d.ts +0 -76
- package/types/entity/Label.d.ts +0 -194
- package/types/entity/LabelHandler.d.ts +0 -24
- package/types/entity/PointCloud.d.ts +0 -174
- package/types/entity/PointCloudHandler.d.ts +0 -38
- package/types/entity/Polyline.d.ts +0 -304
- package/types/entity/PolylineHandler.d.ts +0 -18
- package/types/entity/Ray.d.ts +0 -123
- package/types/entity/RayHandler.d.ts +0 -67
- package/types/entity/ShapeHandler.d.ts +0 -22
- package/types/entity/Strip.d.ts +0 -118
- 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/inherits.d.ts +0 -4
- 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 -107
- package/types/layer/CanvasTiles.d.ts +0 -75
- package/types/layer/GeoImage.d.ts +0 -65
- package/types/layer/GeoTexture2d.d.ts +0 -8
- package/types/layer/GeoVideo.d.ts +0 -80
- package/types/layer/KML.d.ts +0 -58
- package/types/layer/Layer.d.ts +0 -321
- package/types/layer/Material.d.ts +0 -48
- package/types/layer/Vector.d.ts +0 -228
- package/types/layer/WMS.d.ts +0 -66
- package/types/layer/XYZ.d.ts +0 -130
- package/types/layer/index.d.ts +0 -10
- package/types/light/LightSource.d.ts +0 -177
- package/types/math/Line2.d.ts +0 -11
- package/types/math/Line3.d.ts +0 -10
- package/types/math/Mat3.d.ts +0 -63
- package/types/math/Mat4.d.ts +0 -173
- package/types/math/Plane.d.ts +0 -17
- package/types/math/Quat.d.ts +0 -376
- package/types/math/Ray.d.ts +0 -81
- package/types/math/Vec2.d.ts +0 -308
- package/types/math/Vec3.d.ts +0 -459
- package/types/math/Vec4.d.ts +0 -161
- package/types/math/coder.d.ts +0 -42
- 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 -5
- package/types/proj/EPSG4326.d.ts +0 -5
- 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 -296
- package/types/renderer/RendererEvents.d.ts +0 -230
- 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 -574
- package/types/scene/RenderNode.d.ts +0 -143
- package/types/scene/SkyBox.d.ts +0 -10
- package/types/scene/index.d.ts +0 -4
- package/types/segment/Segment.d.ts +0 -271
- package/types/segment/SegmentLonLat.d.ts +0 -62
- 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 -247
- package/types/shapes/Sphere.d.ts +0 -41
- package/types/terrain/BilTerrain.d.ts +0 -8
- package/types/terrain/EmptyTerrain.d.ts +0 -72
- package/types/terrain/Geoid.d.ts +0 -26
- package/types/terrain/GlobusTerrain.d.ts +0 -153
- package/types/terrain/MapboxTerrain.d.ts +0 -8
- 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 -230
- package/types/webgl/Framebuffer.d.ts +0 -135
- package/types/webgl/Handler.d.ts +0 -372
- package/types/webgl/Multisample.d.ts +0 -89
- package/types/webgl/Program.d.ts +0 -155
- package/types/webgl/ProgramController.d.ts +0 -84
- 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,
|
|
@@ -28,13 +29,13 @@ const STR2ALIGN = {
|
|
|
28
29
|
/**
|
|
29
30
|
* Billboard text label.
|
|
30
31
|
* @class
|
|
31
|
-
* @extends {
|
|
32
|
+
* @extends {BaseBillboard}
|
|
32
33
|
* @param {Object} [options] - Label options:
|
|
33
|
-
* @param {
|
|
34
|
+
* @param {Vec3|Array.<number>} [options.position] - Billboard spatial position.
|
|
34
35
|
* @param {number} [options.rotation] - Screen angle rotaion.
|
|
35
|
-
* @param {
|
|
36
|
-
* @param {
|
|
37
|
-
* @param {
|
|
36
|
+
* @param {Vec4|string|Array.<number>} [options.color] - Billboard color.
|
|
37
|
+
* @param {Vec3|Array.<number>} [options.alignedAxis] - Billboard aligned vector.
|
|
38
|
+
* @param {Vec3|Array.<number>} [options.offset] - Billboard center screen offset.
|
|
38
39
|
* @param {boolean} [options.visibility] - Visibility.
|
|
39
40
|
* @param {string} [options.text] - Text string.
|
|
40
41
|
* @param {string} [options.face] - HTML5 font face.
|
|
@@ -42,8 +43,8 @@ const STR2ALIGN = {
|
|
|
42
43
|
* @param {string} [options.style] - HTML5 font style. Example 'normal', 'italic'.
|
|
43
44
|
* @param {string} [options.weight] - HTML5 font weight. Example 'normal', 'bold'.
|
|
44
45
|
* @param {number} [options.outline] - Text outline size. 0 - no outline, 1 - maximum outline. Default 0.58.
|
|
45
|
-
* @param {
|
|
46
|
-
* @param {
|
|
46
|
+
* @param {Vec4|string|Array.<number>} [options.outlineColor] - Outline color.
|
|
47
|
+
* @param {Label.ALIGN} [options.align] - Text horizontal align: "left", "right" and "center".
|
|
47
48
|
*/
|
|
48
49
|
class Label extends BaseBillboard {
|
|
49
50
|
constructor(options) {
|
|
@@ -82,16 +83,21 @@ class Label extends BaseBillboard {
|
|
|
82
83
|
/**
|
|
83
84
|
* Label outline color.
|
|
84
85
|
* @private
|
|
85
|
-
* @type {
|
|
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
|
-
* @type {
|
|
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.
|
|
@@ -103,7 +109,7 @@ class Label extends BaseBillboard {
|
|
|
103
109
|
/**
|
|
104
110
|
* Font atlas pointer.
|
|
105
111
|
* @private
|
|
106
|
-
* @type {
|
|
112
|
+
* @type {utils.FontAtlas}
|
|
107
113
|
*/
|
|
108
114
|
this._fontAtlas = null;
|
|
109
115
|
}
|
|
@@ -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
|
-
|
|
125
|
+
if (this._isReady) {
|
|
126
|
+
this._handler.setText(this._handlerIndex, text, this._fontIndex, this._align);
|
|
127
|
+
}
|
|
120
128
|
}
|
|
121
129
|
|
|
122
130
|
/**
|
|
@@ -131,17 +139,21 @@ class Label extends BaseBillboard {
|
|
|
131
139
|
/**
|
|
132
140
|
* Sets label text align. Could be center, left or right. Left is default.
|
|
133
141
|
* @public
|
|
134
|
-
* @param {
|
|
142
|
+
* @param {Label.ALIGN} align - Text align.
|
|
135
143
|
*/
|
|
136
144
|
setAlign(align) {
|
|
137
145
|
this._align = STR2ALIGN[align.trim().toLowerCase()];
|
|
138
|
-
|
|
146
|
+
if (this._isReady) {
|
|
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
|
/**
|
|
142
154
|
* Gets label text current alignment.
|
|
143
155
|
* @public
|
|
144
|
-
* @returns {
|
|
156
|
+
* @returns {Label.ALIGN}
|
|
145
157
|
*/
|
|
146
158
|
getAlign() {
|
|
147
159
|
return this._align;
|
|
@@ -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) {
|
|
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
|
-
|
|
213
|
+
if (this._isReady) {
|
|
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,24 +245,26 @@ 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) {
|
|
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
|
/**
|
|
236
262
|
* Sets text outline color.
|
|
237
263
|
* @public
|
|
238
|
-
* @param {
|
|
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
|
/**
|
|
@@ -257,7 +279,7 @@ class Label extends BaseBillboard {
|
|
|
257
279
|
/**
|
|
258
280
|
* Gets outline color vector.
|
|
259
281
|
* @public
|
|
260
|
-
* @returns {
|
|
282
|
+
* @returns {Vec4}
|
|
261
283
|
*/
|
|
262
284
|
getOutlineColor() {
|
|
263
285
|
return this._outlineColor;
|
|
@@ -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) {
|
|
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
|
/**
|
|
@@ -286,29 +314,32 @@ class Label extends BaseBillboard {
|
|
|
286
314
|
* Updates label parameters.
|
|
287
315
|
* @public
|
|
288
316
|
*/
|
|
289
|
-
update() {
|
|
317
|
+
async update() {
|
|
290
318
|
if (this._fontAtlas) {
|
|
291
|
-
this._fontAtlas.getFontIndex(this._face)
|
|
292
|
-
|
|
293
|
-
});
|
|
319
|
+
const fontIndex = await this._fontAtlas.getFontIndex(this._face);
|
|
320
|
+
this._applyFontIndex(fontIndex);
|
|
294
321
|
}
|
|
295
322
|
}
|
|
296
323
|
|
|
297
324
|
_applyFontIndex(fontIndex) {
|
|
298
325
|
this._fontIndex = fontIndex;
|
|
299
|
-
if (this.
|
|
326
|
+
if (this._isReady) {
|
|
300
327
|
this._handler.setFontIndexArr(this._handlerIndex, this._fontIndex);
|
|
301
328
|
this._handler.setText(this._handlerIndex, this._text, this._fontIndex, this._align);
|
|
329
|
+
} else if (this._lockId !== LOCK_FREE) {
|
|
330
|
+
this._lockId = LOCK_UPDATE;
|
|
302
331
|
}
|
|
303
332
|
}
|
|
304
333
|
|
|
305
334
|
/**
|
|
306
335
|
* Assigns font atlas and update.
|
|
307
336
|
* @public
|
|
308
|
-
* @param {
|
|
337
|
+
* @param {utils.FontAtlas} fontAtlas - Font atlas.
|
|
309
338
|
*/
|
|
310
339
|
assignFontAtlas(fontAtlas) {
|
|
311
|
-
|
|
340
|
+
if (!this._fontAtlas) {
|
|
341
|
+
this._fontAtlas = fontAtlas;
|
|
342
|
+
}
|
|
312
343
|
this.update();
|
|
313
344
|
}
|
|
314
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;
|
|
@@ -30,6 +31,11 @@ window.dZ = 1.1;
|
|
|
30
31
|
*
|
|
31
32
|
*/
|
|
32
33
|
class LabelHandler extends BillboardHandler {
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* @param {*} entityCollection
|
|
37
|
+
* @param {*} maxLetters
|
|
38
|
+
*/
|
|
33
39
|
constructor(entityCollection, maxLetters = 21) {
|
|
34
40
|
super(entityCollection);
|
|
35
41
|
|
|
@@ -71,19 +77,52 @@ class LabelHandler extends BillboardHandler {
|
|
|
71
77
|
}
|
|
72
78
|
|
|
73
79
|
add(label) {
|
|
74
|
-
if (label.
|
|
80
|
+
if (!label._handler) {
|
|
75
81
|
label._handler = this;
|
|
76
|
-
label._handlerIndex = this._billboards.length;
|
|
77
|
-
this._billboards.push(label);
|
|
78
|
-
this._addBillboardToArrays(label);
|
|
79
|
-
this.refresh();
|
|
80
82
|
this.assignFontAtlas(label);
|
|
83
|
+
this.refresh();
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
|
|
87
|
+
_addLabelToArrays(label) {
|
|
88
|
+
this._renderer.labelWorker.make(this, label);
|
|
89
|
+
}
|
|
90
|
+
|
|
84
91
|
assignFontAtlas(label) {
|
|
85
92
|
if (this._entityCollection && this._renderer) {
|
|
86
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();
|
|
87
126
|
}
|
|
88
127
|
}
|
|
89
128
|
|
|
@@ -163,236 +202,6 @@ class LabelHandler extends BillboardHandler {
|
|
|
163
202
|
}
|
|
164
203
|
}
|
|
165
204
|
|
|
166
|
-
_addBillboardToArrays(label) {
|
|
167
|
-
for (var i = 0; i < this._maxLetters; i++) {
|
|
168
|
-
if (label._visibility) {
|
|
169
|
-
this._vertexArr = concatTypedArrays(
|
|
170
|
-
this._vertexArr,
|
|
171
|
-
[0, 0, 0, -1, 1, -1, 1, -1, 1, 0, 0, 0]
|
|
172
|
-
);
|
|
173
|
-
} else {
|
|
174
|
-
this._vertexArr = concatTypedArrays(
|
|
175
|
-
this._vertexArr,
|
|
176
|
-
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
this._texCoordArr = concatTypedArrays(
|
|
181
|
-
this._texCoordArr,
|
|
182
|
-
[0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0]
|
|
183
|
-
);
|
|
184
|
-
this._gliphParamArr = concatTypedArrays(
|
|
185
|
-
this._gliphParamArr,
|
|
186
|
-
[1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
var x = label._positionHigh.x,
|
|
190
|
-
y = label._positionHigh.y,
|
|
191
|
-
z = label._positionHigh.z,
|
|
192
|
-
w;
|
|
193
|
-
this._positionHighArr = concatTypedArrays(this._positionHighArr, [
|
|
194
|
-
x,
|
|
195
|
-
y,
|
|
196
|
-
z,
|
|
197
|
-
x,
|
|
198
|
-
y,
|
|
199
|
-
z,
|
|
200
|
-
x,
|
|
201
|
-
y,
|
|
202
|
-
z,
|
|
203
|
-
x,
|
|
204
|
-
y,
|
|
205
|
-
z,
|
|
206
|
-
x,
|
|
207
|
-
y,
|
|
208
|
-
z,
|
|
209
|
-
x,
|
|
210
|
-
y,
|
|
211
|
-
z
|
|
212
|
-
]);
|
|
213
|
-
|
|
214
|
-
x = label._positionLow.x;
|
|
215
|
-
y = label._positionLow.y;
|
|
216
|
-
z = label._positionLow.z;
|
|
217
|
-
this._positionLowArr = concatTypedArrays(this._positionLowArr, [
|
|
218
|
-
x,
|
|
219
|
-
y,
|
|
220
|
-
z,
|
|
221
|
-
x,
|
|
222
|
-
y,
|
|
223
|
-
z,
|
|
224
|
-
x,
|
|
225
|
-
y,
|
|
226
|
-
z,
|
|
227
|
-
x,
|
|
228
|
-
y,
|
|
229
|
-
z,
|
|
230
|
-
x,
|
|
231
|
-
y,
|
|
232
|
-
z,
|
|
233
|
-
x,
|
|
234
|
-
y,
|
|
235
|
-
z
|
|
236
|
-
]);
|
|
237
|
-
|
|
238
|
-
x = label._size;
|
|
239
|
-
this._sizeArr = concatTypedArrays(this._sizeArr, [x, x, x, x, x, x]);
|
|
240
|
-
|
|
241
|
-
x = label._offset.x;
|
|
242
|
-
y = label._offset.y;
|
|
243
|
-
z = label._offset.z;
|
|
244
|
-
this._offsetArr = concatTypedArrays(this._offsetArr, [
|
|
245
|
-
x,
|
|
246
|
-
y,
|
|
247
|
-
z,
|
|
248
|
-
x,
|
|
249
|
-
y,
|
|
250
|
-
z,
|
|
251
|
-
x,
|
|
252
|
-
y,
|
|
253
|
-
z,
|
|
254
|
-
x,
|
|
255
|
-
y,
|
|
256
|
-
z,
|
|
257
|
-
x,
|
|
258
|
-
y,
|
|
259
|
-
z,
|
|
260
|
-
x,
|
|
261
|
-
y,
|
|
262
|
-
z
|
|
263
|
-
]);
|
|
264
|
-
|
|
265
|
-
x = label._color.x;
|
|
266
|
-
y = label._color.y;
|
|
267
|
-
z = label._color.z;
|
|
268
|
-
w = label._color.w;
|
|
269
|
-
this._rgbaArr = concatTypedArrays(this._rgbaArr, [
|
|
270
|
-
x,
|
|
271
|
-
y,
|
|
272
|
-
z,
|
|
273
|
-
w,
|
|
274
|
-
x,
|
|
275
|
-
y,
|
|
276
|
-
z,
|
|
277
|
-
w,
|
|
278
|
-
x,
|
|
279
|
-
y,
|
|
280
|
-
z,
|
|
281
|
-
w,
|
|
282
|
-
x,
|
|
283
|
-
y,
|
|
284
|
-
z,
|
|
285
|
-
w,
|
|
286
|
-
x,
|
|
287
|
-
y,
|
|
288
|
-
z,
|
|
289
|
-
w,
|
|
290
|
-
x,
|
|
291
|
-
y,
|
|
292
|
-
z,
|
|
293
|
-
w
|
|
294
|
-
]);
|
|
295
|
-
|
|
296
|
-
x = label._rotation;
|
|
297
|
-
this._rotationArr = concatTypedArrays(this._rotationArr, [x, x, x, x, x, x]);
|
|
298
|
-
|
|
299
|
-
x = label._alignedAxis.x;
|
|
300
|
-
y = label._alignedAxis.y;
|
|
301
|
-
z = label._alignedAxis.z;
|
|
302
|
-
this._alignedAxisArr = concatTypedArrays(this._alignedAxisArr, [
|
|
303
|
-
x,
|
|
304
|
-
y,
|
|
305
|
-
z,
|
|
306
|
-
x,
|
|
307
|
-
y,
|
|
308
|
-
z,
|
|
309
|
-
x,
|
|
310
|
-
y,
|
|
311
|
-
z,
|
|
312
|
-
x,
|
|
313
|
-
y,
|
|
314
|
-
z,
|
|
315
|
-
x,
|
|
316
|
-
y,
|
|
317
|
-
z,
|
|
318
|
-
x,
|
|
319
|
-
y,
|
|
320
|
-
z
|
|
321
|
-
]);
|
|
322
|
-
|
|
323
|
-
x = label._fontIndex;
|
|
324
|
-
this._fontIndexArr = concatTypedArrays(this._fontIndexArr, [x, x, x, x, x, x]);
|
|
325
|
-
|
|
326
|
-
x = label._outline;
|
|
327
|
-
this._outlineArr = concatTypedArrays(this._outlineArr, [x, x, x, x, x, x]);
|
|
328
|
-
|
|
329
|
-
const weight = 0.001;
|
|
330
|
-
this._noOutlineArr = concatTypedArrays(this._noOutlineArr, [
|
|
331
|
-
weight,
|
|
332
|
-
weight,
|
|
333
|
-
weight,
|
|
334
|
-
weight,
|
|
335
|
-
weight,
|
|
336
|
-
weight
|
|
337
|
-
]);
|
|
338
|
-
|
|
339
|
-
x = label._outlineColor.x;
|
|
340
|
-
y = label._outlineColor.y;
|
|
341
|
-
z = label._outlineColor.z;
|
|
342
|
-
w = label._outlineColor.w;
|
|
343
|
-
this._outlineColorArr = concatTypedArrays(this._outlineColorArr, [
|
|
344
|
-
x,
|
|
345
|
-
y,
|
|
346
|
-
z,
|
|
347
|
-
w,
|
|
348
|
-
x,
|
|
349
|
-
y,
|
|
350
|
-
z,
|
|
351
|
-
w,
|
|
352
|
-
x,
|
|
353
|
-
y,
|
|
354
|
-
z,
|
|
355
|
-
w,
|
|
356
|
-
x,
|
|
357
|
-
y,
|
|
358
|
-
z,
|
|
359
|
-
w,
|
|
360
|
-
x,
|
|
361
|
-
y,
|
|
362
|
-
z,
|
|
363
|
-
w,
|
|
364
|
-
x,
|
|
365
|
-
y,
|
|
366
|
-
z,
|
|
367
|
-
w
|
|
368
|
-
]);
|
|
369
|
-
|
|
370
|
-
x = label._entity._pickingColor.x / 255;
|
|
371
|
-
y = label._entity._pickingColor.y / 255;
|
|
372
|
-
z = label._entity._pickingColor.z / 255;
|
|
373
|
-
this._pickingColorArr = concatTypedArrays(this._pickingColorArr, [
|
|
374
|
-
x,
|
|
375
|
-
y,
|
|
376
|
-
z,
|
|
377
|
-
x,
|
|
378
|
-
y,
|
|
379
|
-
z,
|
|
380
|
-
x,
|
|
381
|
-
y,
|
|
382
|
-
z,
|
|
383
|
-
x,
|
|
384
|
-
y,
|
|
385
|
-
z,
|
|
386
|
-
x,
|
|
387
|
-
y,
|
|
388
|
-
z,
|
|
389
|
-
x,
|
|
390
|
-
y,
|
|
391
|
-
z
|
|
392
|
-
]);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
205
|
_displayPASS() {
|
|
397
206
|
var r = this._renderer;
|
|
398
207
|
var h = r.handler;
|
|
@@ -687,12 +496,6 @@ class LabelHandler extends BillboardHandler {
|
|
|
687
496
|
|
|
688
497
|
let m = n.metrics;
|
|
689
498
|
|
|
690
|
-
//m.nWidth;
|
|
691
|
-
//m.nHeight;
|
|
692
|
-
//m.nAdvance;
|
|
693
|
-
//m.nXOffset;
|
|
694
|
-
//m.nYOffset;
|
|
695
|
-
|
|
696
499
|
a[j] = tc[0];
|
|
697
500
|
a[j + 1] = tc[1];
|
|
698
501
|
a[j + 2] = offset;
|
|
@@ -1151,8 +954,6 @@ class LabelHandler extends BillboardHandler {
|
|
|
1151
954
|
}
|
|
1152
955
|
|
|
1153
956
|
setFontIndexArr(index, fontIndex) {
|
|
1154
|
-
fontIndex = fontIndex;
|
|
1155
|
-
|
|
1156
957
|
var i = index * 6 * this._maxLetters;
|
|
1157
958
|
var a = this._fontIndexArr;
|
|
1158
959
|
|
|
@@ -1237,4 +1038,4 @@ class LabelHandler extends BillboardHandler {
|
|
|
1237
1038
|
}
|
|
1238
1039
|
}
|
|
1239
1040
|
|
|
1240
|
-
export { LabelHandler };
|
|
1041
|
+
export { LabelHandler };
|