@openglobus/og 0.11.1 → 0.11.6
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 +18 -20
- package/src/og/Clock.js +11 -11
- package/src/og/Deferred.js +1 -1
- package/src/og/Events.js +9 -7
- package/src/og/Extent.js +117 -72
- package/src/og/Globe.js +35 -22
- package/src/og/ImageCanvas.js +24 -18
- package/src/og/Lock.js +2 -2
- package/src/og/LonLat.js +40 -37
- package/src/og/Popup.js +21 -15
- package/src/og/QueueArray.js +7 -3
- package/src/og/Rectangle.js +11 -6
- package/src/og/Stack.js +8 -5
- package/src/og/ajax.js +21 -33
- package/src/og/astro/astro.js +5 -5
- package/src/og/astro/earth.js +23 -17
- package/src/og/astro/jd.js +44 -39
- package/src/og/astro/orbit.js +20 -18
- package/src/og/astro/rotation.js +17 -8
- package/src/og/bv/Box.js +7 -3
- package/src/og/bv/Sphere.js +17 -9
- package/src/og/camera/Camera.js +137 -86
- package/src/og/camera/Frustum.js +30 -19
- package/src/og/camera/PlanetCamera.js +30 -26
- package/src/og/control/CompassButton.js +8 -2
- package/src/og/control/Control.js +13 -11
- package/src/og/control/DebugInfo.js +4 -1
- package/src/og/control/EarthCoordinates.js +62 -41
- package/src/og/control/EarthNavigation.js +20 -22
- package/src/og/control/GeoImageDragControl.js +1 -1
- package/src/og/control/KeyboardNavigation.js +12 -12
- package/src/og/control/LayerSwitcher.js +24 -23
- package/src/og/control/Lighting.js +1 -1
- package/src/og/control/MouseNavigation.js +1 -1
- package/src/og/control/ScaleControl.js +1 -1
- package/src/og/control/SegmentBoundVisualization.js +8 -9
- package/src/og/control/ShowFps.js +15 -10
- package/src/og/control/SimpleNavigation.js +8 -10
- package/src/og/control/Sun.js +25 -15
- package/src/og/control/ToggleWireframe.js +5 -5
- package/src/og/control/TouchNavigation.js +58 -45
- package/src/og/control/ZoomControl.js +41 -25
- package/src/og/control/index.js +4 -0
- package/src/og/ellipsoid/Ellipsoid.js +181 -85
- package/src/og/ellipsoid/wgs84.js +4 -4
- package/src/og/entity/BaseBillboard.js +97 -44
- package/src/og/entity/Billboard.js +15 -11
- package/src/og/entity/BillboardHandler.js +314 -64
- package/src/og/entity/Entity.js +106 -74
- package/src/og/entity/EntityCollection.js +72 -49
- package/src/og/entity/GeoObject.js +228 -0
- package/src/og/entity/GeoObjectHandler.js +910 -0
- package/src/og/entity/Geometry.js +29 -26
- package/src/og/entity/GeometryHandler.js +598 -126
- package/src/og/entity/Label.js +74 -40
- package/src/og/entity/LabelHandler.js +47 -246
- package/src/og/entity/LabelWorker.js +213 -0
- package/src/og/entity/Object3d.js +504 -0
- package/src/og/entity/PointCloud.js +81 -33
- package/src/og/entity/PointCloudHandler.js +9 -9
- package/src/og/entity/Polyline.js +39 -39
- package/src/og/entity/Ray.js +61 -28
- package/src/og/entity/ShapeHandler.js +1 -1
- package/src/og/entity/Strip.js +77 -48
- package/src/og/entity/StripHandler.js +27 -27
- package/src/og/entity/index.js +8 -16
- package/src/og/input/KeyboardHandler.js +107 -104
- package/src/og/input/MouseHandler.js +81 -78
- package/src/og/input/TouchHandler.js +55 -51
- package/src/og/layer/BaseGeoImage.js +61 -30
- package/src/og/layer/CanvasTiles.js +26 -24
- package/src/og/layer/GeoImage.js +10 -10
- package/src/og/layer/GeoTexture2d.js +1 -1
- package/src/og/layer/GeoVideo.js +3 -3
- package/src/og/layer/KML.js +66 -40
- package/src/og/layer/Layer.js +27 -17
- package/src/og/layer/Material.js +93 -61
- package/src/og/layer/Vector.js +118 -72
- package/src/og/layer/WMS.js +36 -19
- package/src/og/layer/XYZ.js +55 -48
- package/src/og/light/LightSource.js +47 -40
- package/src/og/math/Line2.js +24 -24
- package/src/og/math/Line3.js +103 -102
- package/src/og/math/Mat3.js +134 -121
- package/src/og/math/Mat4.js +603 -459
- package/src/og/math/Plane.js +21 -20
- package/src/og/math/Quat.js +980 -927
- package/src/og/math/Ray.js +195 -187
- package/src/og/math/Vec2.js +127 -117
- package/src/og/math/Vec3.js +206 -176
- package/src/og/math/Vec4.js +49 -53
- package/src/og/math/coder.js +18 -18
- package/src/og/math.js +12 -12
- package/src/og/mercator.js +11 -11
- package/src/og/proj/EPSG3857.js +4 -4
- package/src/og/proj/EPSG4326.js +4 -4
- package/src/og/proj/Proj.js +31 -31
- package/src/og/quadTree/EntityCollectionNode.js +310 -300
- package/src/og/quadTree/Node.js +1008 -993
- package/src/og/renderer/Renderer.js +768 -747
- package/src/og/renderer/RendererEvents.js +9 -6
- package/src/og/scene/Axes.js +1 -1
- package/src/og/scene/BaseNode.js +8 -9
- package/src/og/scene/Planet.js +115 -87
- package/src/og/scene/RenderNode.js +29 -22
- package/src/og/scene/SkyBox.js +1 -1
- package/src/og/segment/Segment.js +1886 -1878
- package/src/og/segment/SegmentLonLat.js +298 -268
- package/src/og/segment/segmentHelper.js +11 -11
- package/src/og/shaders/bloom.js +1 -1
- package/src/og/shaders/blur.js +2 -2
- package/src/og/shaders/depth.js +1 -1
- package/src/og/shaders/geoObject.js +211 -0
- package/src/og/shaders/label.js +1 -1
- package/src/og/shaders/lumFilter.js +1 -1
- package/src/og/shaders/pointCloud.js +42 -42
- package/src/og/shaders/screenFrame.js +1 -1
- package/src/og/shaders/shape.js +15 -21
- package/src/og/shaders/skybox.js +37 -37
- package/src/og/shaders/toneMapping.js +1 -1
- package/src/og/shapes/BaseShape.js +129 -57
- package/src/og/shapes/Icosphere.js +30 -15
- package/src/og/shapes/Sphere.js +13 -16
- package/src/og/terrain/BilTerrain.js +2 -1
- package/src/og/terrain/EmptyTerrain.js +2 -2
- package/src/og/terrain/Geoid.js +2 -2
- package/src/og/terrain/GlobusTerrain.js +10 -10
- package/src/og/terrain/MapboxTerrain.js +1 -1
- package/src/og/utils/GeoImageCreator.js +9 -9
- package/src/og/utils/Loader.js +6 -6
- package/src/og/utils/NormalMapCreator.js +13 -13
- package/src/og/utils/TerrainWorker.js +1 -1
- package/src/og/utils/TextureAtlas.js +20 -22
- package/src/og/utils/VectorTileCreator.js +5 -5
- package/src/og/utils/earcut.js +1 -1
- package/src/og/utils/shared.js +15 -15
- package/src/og/webgl/Framebuffer.js +101 -53
- package/src/og/webgl/Handler.js +125 -85
- package/src/og/webgl/Multisample.js +55 -27
- package/src/og/webgl/Program.js +80 -35
- package/src/og/webgl/ProgramController.js +27 -23
- package/src/og/webgl/callbacks.js +8 -8
- package/types/Clock.d.ts +6 -2
- package/types/Deferred.d.ts +1 -1
- package/types/Events.d.ts +8 -4
- package/types/Extent.d.ts +37 -33
- package/types/Globe.d.ts +15 -13
- package/types/ImageCanvas.d.ts +5 -3
- package/types/LonLat.d.ts +24 -24
- package/types/Popup.d.ts +4 -0
- package/types/QueueArray.d.ts +6 -2
- package/types/Rectangle.d.ts +10 -4
- package/types/Stack.d.ts +4 -0
- package/types/ajax.d.ts +1 -1
- package/types/astro/earth.d.ts +3 -2
- package/types/bv/Box.d.ts +10 -5
- package/types/bv/Sphere.d.ts +13 -7
- package/types/camera/Camera.d.ts +90 -81
- package/types/camera/Frustum.d.ts +26 -22
- package/types/camera/PlanetCamera.d.ts +49 -53
- package/types/control/CompassButton.d.ts +4 -4
- package/types/control/Control.d.ts +7 -4
- package/types/control/DebugInfo.d.ts +3 -4
- package/types/control/EarthCoordinates.d.ts +6 -6
- package/types/control/EarthNavigation.d.ts +42 -0
- package/types/control/KeyboardNavigation.d.ts +3 -4
- package/types/control/LayerSwitcher.d.ts +3 -5
- package/types/control/Lighting.d.ts +3 -3
- package/types/control/MouseNavigation.d.ts +47 -0
- package/types/control/ScaleControl.d.ts +3 -3
- package/types/control/ShowFps.d.ts +3 -4
- package/types/control/SimpleNavigation.d.ts +3 -6
- package/types/control/Sun.d.ts +8 -10
- package/types/control/ToggleWireframe.d.ts +3 -3
- package/types/control/TouchNavigation.d.ts +48 -0
- package/types/control/ZoomControl.d.ts +3 -4
- package/types/control/index.d.ts +3 -1
- package/types/ellipsoid/Ellipsoid.d.ts +47 -43
- package/types/ellipsoid/wgs84.d.ts +3 -2
- package/types/entity/BaseBillboard.d.ts +41 -34
- package/types/entity/Billboard.d.ts +7 -7
- package/types/entity/BillboardHandler.d.ts +4 -0
- package/types/entity/Entity.d.ts +101 -83
- package/types/entity/EntityCollection.d.ts +57 -43
- package/types/entity/GeoObject.d.ts +111 -0
- package/types/entity/GeoObjectHandler.d.ts +77 -0
- package/types/entity/Geometry.d.ts +9 -7
- package/types/entity/GeometryHandler.d.ts +2 -2
- package/types/entity/Label.d.ts +24 -29
- package/types/entity/LabelHandler.d.ts +9 -2
- package/types/entity/LabelWorker.d.ts +9 -0
- package/types/entity/PointCloud.d.ts +8 -8
- package/types/entity/PointCloudHandler.d.ts +3 -3
- package/types/entity/Polyline.d.ts +58 -55
- package/types/entity/Ray.d.ts +19 -18
- package/types/entity/Strip.d.ts +8 -7
- package/types/entity/StripHandler.d.ts +3 -3
- package/types/entity/index.d.ts +7 -7
- package/types/input/KeyboardHandler.d.ts +10 -0
- package/types/input/MouseHandler.d.ts +5 -0
- package/types/input/TouchHandler.d.ts +5 -0
- package/types/layer/BaseGeoImage.d.ts +23 -35
- package/types/layer/CanvasTiles.d.ts +15 -22
- package/types/layer/GeoImage.d.ts +5 -18
- package/types/layer/GeoVideo.d.ts +5 -30
- package/types/layer/KML.d.ts +20 -15
- package/types/layer/Layer.d.ts +326 -0
- package/types/layer/Material.d.ts +45 -0
- package/types/layer/Vector.d.ts +208 -0
- package/types/layer/WMS.d.ts +4 -7
- package/types/layer/XYZ.d.ts +19 -25
- package/types/light/LightSource.d.ts +54 -53
- package/types/math/Line2.d.ts +11 -0
- package/types/math/Line3.d.ts +10 -0
- package/types/math/Mat3.d.ts +30 -18
- package/types/math/Mat4.d.ts +71 -52
- package/types/math/Plane.d.ts +5 -4
- package/types/math/Quat.d.ts +379 -0
- package/types/math/Ray.d.ts +82 -0
- package/types/math/Vec2.d.ts +102 -101
- package/types/math/Vec3.d.ts +143 -142
- package/types/math/Vec4.d.ts +40 -39
- package/types/math/coder.d.ts +12 -11
- package/types/math.d.ts +8 -8
- package/types/mercator.d.ts +3 -3
- package/types/proj/EPSG3857.d.ts +3 -2
- package/types/proj/EPSG4326.d.ts +3 -2
- package/types/proj/Proj.d.ts +42 -0
- package/types/quadTree/EntityCollectionNode.d.ts +34 -0
- package/types/quadTree/Node.d.ts +61 -0
- package/types/renderer/Renderer.d.ts +300 -0
- package/types/renderer/RendererEvents.d.ts +10 -7
- package/types/scene/BaseNode.d.ts +9 -9
- package/types/scene/Planet.d.ts +131 -126
- package/types/scene/RenderNode.d.ts +22 -23
- package/types/segment/Segment.d.ts +279 -0
- package/types/segment/SegmentLonLat.d.ts +16 -0
- package/types/shaders/geoObject.d.ts +3 -0
- package/types/shapes/BaseShape.d.ts +43 -40
- package/types/shapes/Sphere.d.ts +7 -7
- package/types/terrain/BilTerrain.d.ts +0 -1
- package/types/terrain/EmptyTerrain.d.ts +4 -4
- package/types/terrain/GlobusTerrain.d.ts +17 -54
- package/types/terrain/MapboxTerrain.d.ts +0 -1
- package/types/utils/GeoImageCreator.d.ts +3 -2
- package/types/utils/TextureAtlas.d.ts +8 -8
- package/types/utils/shared.d.ts +25 -24
- package/types/webgl/Framebuffer.d.ts +5 -5
- package/types/webgl/Handler.d.ts +68 -43
- package/types/webgl/Multisample.d.ts +5 -5
- package/types/webgl/Program.d.ts +8 -2
- package/types/webgl/ProgramController.d.ts +18 -13
- package/src/og/inherits.js +0 -8
- package/src/og/utils/polylabel.js +0 -176
- package/types/inherits.d.ts +0 -4
package/src/og/entity/Label.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
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
10
|
|
|
11
11
|
const ALIGN = {
|
|
12
12
|
RIGHT: 0,
|
|
@@ -28,13 +28,13 @@ const STR2ALIGN = {
|
|
|
28
28
|
/**
|
|
29
29
|
* Billboard text label.
|
|
30
30
|
* @class
|
|
31
|
-
* @extends {
|
|
31
|
+
* @extends {BaseBillboard}
|
|
32
32
|
* @param {Object} [options] - Label options:
|
|
33
|
-
* @param {
|
|
33
|
+
* @param {Vec3|Array.<number>} [options.position] - Billboard spatial position.
|
|
34
34
|
* @param {number} [options.rotation] - Screen angle rotaion.
|
|
35
|
-
* @param {
|
|
36
|
-
* @param {
|
|
37
|
-
* @param {
|
|
35
|
+
* @param {Vec4|string|Array.<number>} [options.color] - Billboard color.
|
|
36
|
+
* @param {Vec3|Array.<number>} [options.alignedAxis] - Billboard aligned vector.
|
|
37
|
+
* @param {Vec3|Array.<number>} [options.offset] - Billboard center screen offset.
|
|
38
38
|
* @param {boolean} [options.visibility] - Visibility.
|
|
39
39
|
* @param {string} [options.text] - Text string.
|
|
40
40
|
* @param {string} [options.face] - HTML5 font face.
|
|
@@ -42,8 +42,8 @@ const STR2ALIGN = {
|
|
|
42
42
|
* @param {string} [options.style] - HTML5 font style. Example 'normal', 'italic'.
|
|
43
43
|
* @param {string} [options.weight] - HTML5 font weight. Example 'normal', 'bold'.
|
|
44
44
|
* @param {number} [options.outline] - Text outline size. 0 - no outline, 1 - maximum outline. Default 0.58.
|
|
45
|
-
* @param {
|
|
46
|
-
* @param {
|
|
45
|
+
* @param {Vec4|string|Array.<number>} [options.outlineColor] - Outline color.
|
|
46
|
+
* @param {Label.ALIGN} [options.align] - Text horizontal align: "left", "right" and "center".
|
|
47
47
|
*/
|
|
48
48
|
class Label extends BaseBillboard {
|
|
49
49
|
constructor(options) {
|
|
@@ -82,16 +82,21 @@ class Label extends BaseBillboard {
|
|
|
82
82
|
/**
|
|
83
83
|
* Label outline color.
|
|
84
84
|
* @private
|
|
85
|
-
* @type {
|
|
85
|
+
* @type {Vec4}
|
|
86
86
|
*/
|
|
87
|
-
this._outlineColor = utils.createColorRGBA(
|
|
87
|
+
this._outlineColor = utils.createColorRGBA(
|
|
88
|
+
options.outlineColor,
|
|
89
|
+
new Vec4(0.0, 0.0, 0.0, 1.0)
|
|
90
|
+
);
|
|
88
91
|
|
|
89
92
|
/**
|
|
90
93
|
* Text horizontal align: "left", "right" and "center".
|
|
91
94
|
* @private
|
|
92
|
-
* @type {
|
|
95
|
+
* @type {Label.ALIGN}
|
|
93
96
|
*/
|
|
94
|
-
this._align = options.align
|
|
97
|
+
this._align = options.align
|
|
98
|
+
? STR2ALIGN[options.align.trim().toLowerCase()] || ALIGN.RIGHT
|
|
99
|
+
: ALIGN.RIGHT;
|
|
95
100
|
|
|
96
101
|
/**
|
|
97
102
|
* Label font atlas index.
|
|
@@ -103,7 +108,7 @@ class Label extends BaseBillboard {
|
|
|
103
108
|
/**
|
|
104
109
|
* Font atlas pointer.
|
|
105
110
|
* @private
|
|
106
|
-
* @type {
|
|
111
|
+
* @type {utils.FontAtlas}
|
|
107
112
|
*/
|
|
108
113
|
this._fontAtlas = null;
|
|
109
114
|
}
|
|
@@ -111,12 +116,14 @@ class Label extends BaseBillboard {
|
|
|
111
116
|
/**
|
|
112
117
|
* Sets lablel text.
|
|
113
118
|
* @public
|
|
114
|
-
* @param {string} text - Text string.
|
|
119
|
+
* @param {string} text - Text string.
|
|
115
120
|
* It can't be bigger than maximum labelHandler _maxLetters value.
|
|
116
121
|
*/
|
|
117
122
|
setText(text) {
|
|
118
123
|
this._text = text.toString();
|
|
119
|
-
|
|
124
|
+
if (this._isReady) {
|
|
125
|
+
this._handler.setText(this._handlerIndex, text, this._fontIndex, this._align);
|
|
126
|
+
}
|
|
120
127
|
}
|
|
121
128
|
|
|
122
129
|
/**
|
|
@@ -131,17 +138,21 @@ class Label extends BaseBillboard {
|
|
|
131
138
|
/**
|
|
132
139
|
* Sets label text align. Could be center, left or right. Left is default.
|
|
133
140
|
* @public
|
|
134
|
-
* @param {
|
|
141
|
+
* @param {Label.ALIGN} align - Text align.
|
|
135
142
|
*/
|
|
136
143
|
setAlign(align) {
|
|
137
144
|
this._align = STR2ALIGN[align.trim().toLowerCase()];
|
|
138
|
-
|
|
139
|
-
|
|
145
|
+
if (this._isReady) {
|
|
146
|
+
this._handler.setText(this._handlerIndex, this._text, this._fontIndex, this._align);
|
|
147
|
+
} else if (this._lockId !== -1) {
|
|
148
|
+
this._lockId = -2;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
140
151
|
|
|
141
152
|
/**
|
|
142
153
|
* Gets label text current alignment.
|
|
143
154
|
* @public
|
|
144
|
-
* @returns {
|
|
155
|
+
* @returns {Label.ALIGN}
|
|
145
156
|
*/
|
|
146
157
|
getAlign() {
|
|
147
158
|
return this._align;
|
|
@@ -173,7 +184,11 @@ class Label extends BaseBillboard {
|
|
|
173
184
|
*/
|
|
174
185
|
setSize(size) {
|
|
175
186
|
this._size = size;
|
|
176
|
-
|
|
187
|
+
if (this._isReady) {
|
|
188
|
+
this._handler.setSizeArr(this._handlerIndex, size);
|
|
189
|
+
} else if (this._lockId !== -1) {
|
|
190
|
+
this._lockId = -2;
|
|
191
|
+
}
|
|
177
192
|
}
|
|
178
193
|
|
|
179
194
|
/**
|
|
@@ -192,7 +207,11 @@ class Label extends BaseBillboard {
|
|
|
192
207
|
*/
|
|
193
208
|
setOutline(outline) {
|
|
194
209
|
this._outline = outline;
|
|
195
|
-
|
|
210
|
+
if (this._isReady) {
|
|
211
|
+
this._handler.setOutlineArr(this._handlerIndex, outline);
|
|
212
|
+
} else if (this._lockId !== -1) {
|
|
213
|
+
this._lockId = -2;
|
|
214
|
+
}
|
|
196
215
|
}
|
|
197
216
|
|
|
198
217
|
/**
|
|
@@ -229,20 +248,28 @@ class Label extends BaseBillboard {
|
|
|
229
248
|
this._outlineColor.y = g;
|
|
230
249
|
this._outlineColor.z = b;
|
|
231
250
|
this._outlineColor.w = a;
|
|
232
|
-
|
|
251
|
+
if (this._isReady) {
|
|
252
|
+
this._handler.setOutlineColorArr(this._handlerIndex, this._outlineColor);
|
|
253
|
+
} else if (this._lockId !== -1) {
|
|
254
|
+
this._lockId = -2;
|
|
255
|
+
}
|
|
233
256
|
}
|
|
234
257
|
|
|
235
258
|
/**
|
|
236
259
|
* Sets text outline color.
|
|
237
260
|
* @public
|
|
238
|
-
* @param {
|
|
261
|
+
* @param {Vec4} rgba - Color vector.
|
|
239
262
|
*/
|
|
240
263
|
setOutlineColor4v(rgba) {
|
|
241
264
|
this._outlineColor.x = rgba.x;
|
|
242
265
|
this._outlineColor.y = rgba.y;
|
|
243
266
|
this._outlineColor.z = rgba.z;
|
|
244
267
|
this._outlineColor.w = rgba.w;
|
|
245
|
-
|
|
268
|
+
if (this._isReady) {
|
|
269
|
+
this._handler.setOutlineColorArr(this._handlerIndex, rgba);
|
|
270
|
+
} else if (this._lockId !== -1) {
|
|
271
|
+
this._lockId = -2;
|
|
272
|
+
}
|
|
246
273
|
}
|
|
247
274
|
|
|
248
275
|
/**
|
|
@@ -252,12 +279,12 @@ class Label extends BaseBillboard {
|
|
|
252
279
|
*/
|
|
253
280
|
setOutlineColorHTML(color) {
|
|
254
281
|
this.setOutlineColor4v(utils.htmlColorToRgba(color));
|
|
255
|
-
}
|
|
282
|
+
}
|
|
256
283
|
|
|
257
284
|
/**
|
|
258
285
|
* Gets outline color vector.
|
|
259
286
|
* @public
|
|
260
|
-
* @returns {
|
|
287
|
+
* @returns {Vec4}
|
|
261
288
|
*/
|
|
262
289
|
getOutlineColor() {
|
|
263
290
|
return this._outlineColor;
|
|
@@ -270,7 +297,11 @@ class Label extends BaseBillboard {
|
|
|
270
297
|
*/
|
|
271
298
|
setOutlineOpacity(opacity) {
|
|
272
299
|
this._outlineColor.w = opacity;
|
|
273
|
-
|
|
300
|
+
if (this._isReady) {
|
|
301
|
+
this._handler.setOutlineColorArr(this._handlerIndex, this._outlineColor);
|
|
302
|
+
} else if (this._lockId !== -1) {
|
|
303
|
+
this._lockId = -2;
|
|
304
|
+
}
|
|
274
305
|
}
|
|
275
306
|
|
|
276
307
|
/**
|
|
@@ -286,31 +317,34 @@ class Label extends BaseBillboard {
|
|
|
286
317
|
* Updates label parameters.
|
|
287
318
|
* @public
|
|
288
319
|
*/
|
|
289
|
-
update() {
|
|
320
|
+
async update() {
|
|
290
321
|
if (this._fontAtlas) {
|
|
291
|
-
this._fontAtlas.getFontIndex(this._face)
|
|
292
|
-
|
|
293
|
-
});
|
|
322
|
+
const fontIndex = await this._fontAtlas.getFontIndex(this._face);
|
|
323
|
+
this._applyFontIndex(fontIndex);
|
|
294
324
|
}
|
|
295
325
|
}
|
|
296
326
|
|
|
297
327
|
_applyFontIndex(fontIndex) {
|
|
298
328
|
this._fontIndex = fontIndex;
|
|
299
|
-
if (this.
|
|
329
|
+
if (this._isReady) {
|
|
300
330
|
this._handler.setFontIndexArr(this._handlerIndex, this._fontIndex);
|
|
301
331
|
this._handler.setText(this._handlerIndex, this._text, this._fontIndex, this._align);
|
|
332
|
+
} else if (this._lockId !== -1) {
|
|
333
|
+
this._lockId = -2;
|
|
302
334
|
}
|
|
303
335
|
}
|
|
304
336
|
|
|
305
337
|
/**
|
|
306
338
|
* Assigns font atlas and update.
|
|
307
339
|
* @public
|
|
308
|
-
* @param {
|
|
340
|
+
* @param {utils.FontAtlas} fontAtlas - Font atlas.
|
|
309
341
|
*/
|
|
310
342
|
assignFontAtlas(fontAtlas) {
|
|
311
|
-
|
|
343
|
+
if (!this._fontAtlas) {
|
|
344
|
+
this._fontAtlas = fontAtlas;
|
|
345
|
+
}
|
|
312
346
|
this.update();
|
|
313
|
-
}
|
|
314
|
-
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
315
349
|
|
|
316
|
-
export { Label, ALIGN };
|
|
350
|
+
export { Label, ALIGN };
|
|
@@ -30,6 +30,11 @@ window.dZ = 1.1;
|
|
|
30
30
|
*
|
|
31
31
|
*/
|
|
32
32
|
class LabelHandler extends BillboardHandler {
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @param {*} entityCollection
|
|
36
|
+
* @param {*} maxLetters
|
|
37
|
+
*/
|
|
33
38
|
constructor(entityCollection, maxLetters = 21) {
|
|
34
39
|
super(entityCollection);
|
|
35
40
|
|
|
@@ -71,19 +76,52 @@ class LabelHandler extends BillboardHandler {
|
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
add(label) {
|
|
74
|
-
if (label.
|
|
79
|
+
if (!label._handler) {
|
|
75
80
|
label._handler = this;
|
|
76
|
-
label._handlerIndex = this._billboards.length;
|
|
77
|
-
this._billboards.push(label);
|
|
78
|
-
this._addBillboardToArrays(label);
|
|
79
|
-
this.refresh();
|
|
80
81
|
this.assignFontAtlas(label);
|
|
82
|
+
this.refresh();
|
|
81
83
|
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
_addLabelToArrays(label) {
|
|
87
|
+
this._renderer.labelWorker.make(this, label);
|
|
88
|
+
}
|
|
89
|
+
|
|
84
90
|
assignFontAtlas(label) {
|
|
85
91
|
if (this._entityCollection && this._renderer) {
|
|
86
92
|
label.assignFontAtlas(this._renderer.fontAtlas);
|
|
93
|
+
this._addLabelToArrays(label);
|
|
94
|
+
} else {
|
|
95
|
+
this._billboards.push(label);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
workerCallback(data, label) {
|
|
100
|
+
if (label._lockId !== -1) {
|
|
101
|
+
label._isReady = true;
|
|
102
|
+
label._lockId = -1;
|
|
103
|
+
label._handlerIndex = this._billboards.length;
|
|
104
|
+
this._billboards.push(label);
|
|
105
|
+
|
|
106
|
+
this._vertexArr = concatTypedArrays(this._vertexArr, data.vertexArr);
|
|
107
|
+
this._texCoordArr = concatTypedArrays(this._texCoordArr, data.texCoordArr);
|
|
108
|
+
this._gliphParamArr = concatTypedArrays(this._gliphParamArr, data.gliphParamArr);
|
|
109
|
+
this._positionHighArr = concatTypedArrays(this._positionHighArr, data.positionHighArr);
|
|
110
|
+
this._positionLowArr = concatTypedArrays(this._positionLowArr, data.positionLowArr);
|
|
111
|
+
this._sizeArr = concatTypedArrays(this._sizeArr, data.sizeArr);
|
|
112
|
+
this._offsetArr = concatTypedArrays(this._offsetArr, data.offsetArr);
|
|
113
|
+
this._rgbaArr = concatTypedArrays(this._rgbaArr, data.rgbaArr);
|
|
114
|
+
this._rotationArr = concatTypedArrays(this._rotationArr, data.rotationArr);
|
|
115
|
+
this._alignedAxisArr = concatTypedArrays(this._alignedAxisArr, data.alignedAxisArr);
|
|
116
|
+
this._fontIndexArr = concatTypedArrays(this._fontIndexArr, data.fontIndexArr);
|
|
117
|
+
this._outlineArr = concatTypedArrays(this._outlineArr, data.outlineArr);
|
|
118
|
+
this._noOutlineArr = concatTypedArrays(this._noOutlineArr, data.noOutlineArr);
|
|
119
|
+
this._outlineColorArr = concatTypedArrays(this._outlineColorArr, data.outlineColorArr);
|
|
120
|
+
this._pickingColorArr = concatTypedArrays(this._pickingColorArr, data.pickingColorArr);
|
|
121
|
+
|
|
122
|
+
label.update();
|
|
123
|
+
|
|
124
|
+
this.refresh();
|
|
87
125
|
}
|
|
88
126
|
}
|
|
89
127
|
|
|
@@ -163,236 +201,6 @@ class LabelHandler extends BillboardHandler {
|
|
|
163
201
|
}
|
|
164
202
|
}
|
|
165
203
|
|
|
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
204
|
_displayPASS() {
|
|
397
205
|
var r = this._renderer;
|
|
398
206
|
var h = r.handler;
|
|
@@ -660,7 +468,8 @@ class LabelHandler extends BillboardHandler {
|
|
|
660
468
|
this.refresh();
|
|
661
469
|
|
|
662
470
|
label._handlerIndex = -1;
|
|
663
|
-
label._handler = null;
|
|
471
|
+
label._handler = null;
|
|
472
|
+
label._isReady = false;
|
|
664
473
|
}
|
|
665
474
|
|
|
666
475
|
setText(index, text, fontIndex, align) {
|
|
@@ -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
|
|