@openglobus/og 0.13.2 → 0.13.5
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/dist/@openglobus/og.esm.js +2 -2
- package/dist/@openglobus/og.esm.js.map +1 -1
- package/dist/@openglobus/og.umd.js +2 -2
- package/dist/@openglobus/og.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/og/control/TouchNavigation.js +340 -319
- package/src/og/entity/Billboard.js +165 -165
- package/src/og/entity/BillboardHandler.js +1 -1
- package/src/og/entity/GeoObject.js +4 -0
- package/src/og/entity/GeoObjectHandler.js +22 -33
- package/src/og/entity/Geometry.js +319 -319
- package/src/og/entity/Label.js +348 -346
- package/src/og/entity/LabelHandler.js +44 -37
- package/src/og/renderer/RendererEvents.js +1051 -1051
- package/src/og/shaders/billboard.js +8 -0
- package/src/og/shaders/label.js +59 -16
- package/src/og/utils/FontAtlas.js +25 -15
- package/src/og/utils/TextureAtlas.js +291 -280
- package/types/entity/GeoObject.d.ts +1 -0
- package/types/entity/Label.d.ts +1 -0
- package/types/entity/LabelHandler.d.ts +1 -1
- package/types/utils/TextureAtlas.d.ts +2 -0
package/src/og/entity/Label.js
CHANGED
|
@@ -1,347 +1,349 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module og/entity/Label
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
"use strict";
|
|
6
|
-
|
|
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";
|
|
11
|
-
|
|
12
|
-
const ALIGN = {
|
|
13
|
-
RIGHT: 0,
|
|
14
|
-
LEFT: 1,
|
|
15
|
-
CENTER: 2
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Text align options.
|
|
20
|
-
* @readonly
|
|
21
|
-
* @enum {number}
|
|
22
|
-
*/
|
|
23
|
-
const STR2ALIGN = {
|
|
24
|
-
left: ALIGN.LEFT,
|
|
25
|
-
right: ALIGN.RIGHT,
|
|
26
|
-
center: ALIGN.CENTER
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Billboard text label.
|
|
31
|
-
* @class
|
|
32
|
-
* @extends {BaseBillboard}
|
|
33
|
-
* @param {Object} [options] - Label options:
|
|
34
|
-
* @param {Vec3|Array.<number>} [options.position] - Billboard spatial position.
|
|
35
|
-
* @param {number} [options.rotation] - Screen angle rotaion.
|
|
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.
|
|
39
|
-
* @param {boolean} [options.visibility] - Visibility.
|
|
40
|
-
* @param {string} [options.text] - Text string.
|
|
41
|
-
* @param {string} [options.face] - HTML5 font face.
|
|
42
|
-
* @param {number} [options.size] - Font size in pixels.
|
|
43
|
-
* @param {string} [options.style] - HTML5 font style. Example 'normal', 'italic'.
|
|
44
|
-
* @param {string} [options.weight] - HTML5 font weight. Example 'normal', 'bold'.
|
|
45
|
-
* @param {number} [options.outline] - Text outline size. 0 - no outline, 1 - maximum outline. Default 0.58.
|
|
46
|
-
* @param {Vec4|string|Array.<number>} [options.outlineColor] - Outline color.
|
|
47
|
-
* @param {Label.ALIGN} [options.align] - Text horizontal align: "left", "right" and "center".
|
|
48
|
-
*/
|
|
49
|
-
class Label extends BaseBillboard {
|
|
50
|
-
constructor(options) {
|
|
51
|
-
super(options);
|
|
52
|
-
|
|
53
|
-
options = options || {};
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Label text string.
|
|
57
|
-
* @private
|
|
58
|
-
* @type {string}
|
|
59
|
-
*/
|
|
60
|
-
this._text = options.text;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* HTML5 font face.
|
|
64
|
-
* @private
|
|
65
|
-
* @type {string}
|
|
66
|
-
*/
|
|
67
|
-
this._face = utils.defaultString(options.face, "arial");
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Font size in pixels.
|
|
71
|
-
* @private
|
|
72
|
-
* @type {number}
|
|
73
|
-
*/
|
|
74
|
-
this._size = options.size || 24;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Label outline.
|
|
78
|
-
* @private
|
|
79
|
-
* @type {number}
|
|
80
|
-
*/
|
|
81
|
-
this._outline = options.outline != undefined ? options.outline : 0.0;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Label outline color.
|
|
85
|
-
* @private
|
|
86
|
-
* @type {Vec4}
|
|
87
|
-
*/
|
|
88
|
-
this._outlineColor = utils.createColorRGBA(
|
|
89
|
-
options.outlineColor,
|
|
90
|
-
new Vec4(0.0, 0.0, 0.0, 1.0)
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Text horizontal align: "left", "right" and "center".
|
|
95
|
-
* @private
|
|
96
|
-
* @type {Label.ALIGN}
|
|
97
|
-
*/
|
|
98
|
-
this._align = options.align
|
|
99
|
-
? STR2ALIGN[options.align.trim().toLowerCase()] || ALIGN.RIGHT
|
|
100
|
-
: ALIGN.RIGHT;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Label font atlas index.
|
|
104
|
-
* @private
|
|
105
|
-
* @type {number}
|
|
106
|
-
*/
|
|
107
|
-
this._fontIndex = 0;
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Font atlas pointer.
|
|
111
|
-
* @private
|
|
112
|
-
* @type {utils.FontAtlas}
|
|
113
|
-
*/
|
|
114
|
-
this._fontAtlas = null;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
*
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
*
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
this.
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
*
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
*
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
*
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
*
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
this.
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
*
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
*
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
this.
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
*
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
*
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
*
|
|
243
|
-
* @
|
|
244
|
-
* @param {number}
|
|
245
|
-
* @param {number}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
this._outlineColor.
|
|
252
|
-
this._outlineColor.
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
this.
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
*
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
*
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
*
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
*
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
this.
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
*
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
this.
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
*
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module og/entity/Label
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
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";
|
|
11
|
+
|
|
12
|
+
const ALIGN = {
|
|
13
|
+
RIGHT: 0,
|
|
14
|
+
LEFT: 1,
|
|
15
|
+
CENTER: 2
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Text align options.
|
|
20
|
+
* @readonly
|
|
21
|
+
* @enum {number}
|
|
22
|
+
*/
|
|
23
|
+
const STR2ALIGN = {
|
|
24
|
+
left: ALIGN.LEFT,
|
|
25
|
+
right: ALIGN.RIGHT,
|
|
26
|
+
center: ALIGN.CENTER
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Billboard text label.
|
|
31
|
+
* @class
|
|
32
|
+
* @extends {BaseBillboard}
|
|
33
|
+
* @param {Object} [options] - Label options:
|
|
34
|
+
* @param {Vec3|Array.<number>} [options.position] - Billboard spatial position.
|
|
35
|
+
* @param {number} [options.rotation] - Screen angle rotaion.
|
|
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.
|
|
39
|
+
* @param {boolean} [options.visibility] - Visibility.
|
|
40
|
+
* @param {string} [options.text] - Text string.
|
|
41
|
+
* @param {string} [options.face] - HTML5 font face.
|
|
42
|
+
* @param {number} [options.size] - Font size in pixels.
|
|
43
|
+
* @param {string} [options.style] - HTML5 font style. Example 'normal', 'italic'.
|
|
44
|
+
* @param {string} [options.weight] - HTML5 font weight. Example 'normal', 'bold'.
|
|
45
|
+
* @param {number} [options.outline] - Text outline size. 0 - no outline, 1 - maximum outline. Default 0.58.
|
|
46
|
+
* @param {Vec4|string|Array.<number>} [options.outlineColor] - Outline color.
|
|
47
|
+
* @param {Label.ALIGN} [options.align] - Text horizontal align: "left", "right" and "center".
|
|
48
|
+
*/
|
|
49
|
+
class Label extends BaseBillboard {
|
|
50
|
+
constructor(options) {
|
|
51
|
+
super(options);
|
|
52
|
+
|
|
53
|
+
options = options || {};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Label text string.
|
|
57
|
+
* @private
|
|
58
|
+
* @type {string}
|
|
59
|
+
*/
|
|
60
|
+
this._text = options.text;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* HTML5 font face.
|
|
64
|
+
* @private
|
|
65
|
+
* @type {string}
|
|
66
|
+
*/
|
|
67
|
+
this._face = utils.defaultString(options.face, "arial");
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Font size in pixels.
|
|
71
|
+
* @private
|
|
72
|
+
* @type {number}
|
|
73
|
+
*/
|
|
74
|
+
this._size = options.size || 24;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Label outline.
|
|
78
|
+
* @private
|
|
79
|
+
* @type {number}
|
|
80
|
+
*/
|
|
81
|
+
this._outline = options.outline != undefined ? options.outline : 0.0;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Label outline color.
|
|
85
|
+
* @private
|
|
86
|
+
* @type {Vec4}
|
|
87
|
+
*/
|
|
88
|
+
this._outlineColor = utils.createColorRGBA(
|
|
89
|
+
options.outlineColor,
|
|
90
|
+
new Vec4(0.0, 0.0, 0.0, 1.0)
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Text horizontal align: "left", "right" and "center".
|
|
95
|
+
* @private
|
|
96
|
+
* @type {Label.ALIGN}
|
|
97
|
+
*/
|
|
98
|
+
this._align = options.align
|
|
99
|
+
? STR2ALIGN[options.align.trim().toLowerCase()] || ALIGN.RIGHT
|
|
100
|
+
: ALIGN.RIGHT;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Label font atlas index.
|
|
104
|
+
* @private
|
|
105
|
+
* @type {number}
|
|
106
|
+
*/
|
|
107
|
+
this._fontIndex = 0;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Font atlas pointer.
|
|
111
|
+
* @private
|
|
112
|
+
* @type {utils.FontAtlas}
|
|
113
|
+
*/
|
|
114
|
+
this._fontAtlas = null;
|
|
115
|
+
|
|
116
|
+
this._isRTL = options.isRTL || false;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Sets lablel text.
|
|
121
|
+
* @public
|
|
122
|
+
* @param {string} text - Text string.
|
|
123
|
+
* It can't be bigger than maximum labelHandler _maxLetters value.
|
|
124
|
+
*/
|
|
125
|
+
setText(text) {
|
|
126
|
+
this._text = text.toString();
|
|
127
|
+
if (this._isReady && this._handler) {
|
|
128
|
+
this._handler.setText(this._handlerIndex, text, this._fontIndex, this._align, this._isRTL);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Gets current text string.
|
|
134
|
+
* @public
|
|
135
|
+
* @returns {string}
|
|
136
|
+
*/
|
|
137
|
+
getText() {
|
|
138
|
+
return this._text;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Sets label text align. Could be center, left or right. Left is default.
|
|
143
|
+
* @public
|
|
144
|
+
* @param {Label.ALIGN} align - Text align.
|
|
145
|
+
*/
|
|
146
|
+
setAlign(align) {
|
|
147
|
+
this._align = STR2ALIGN[align.trim().toLowerCase()];
|
|
148
|
+
if (this._isReady && this._handler) {
|
|
149
|
+
this._handler.setText(this._handlerIndex, this._text, this._fontIndex, this._align, this._isRTL);
|
|
150
|
+
} else if (this._lockId !== LOCK_FREE) {
|
|
151
|
+
this._lockId = LOCK_UPDATE;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Gets label text current alignment.
|
|
157
|
+
* @public
|
|
158
|
+
* @returns {Label.ALIGN}
|
|
159
|
+
*/
|
|
160
|
+
getAlign() {
|
|
161
|
+
return this._align;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Sets font face family.
|
|
166
|
+
* @public
|
|
167
|
+
* @param {string} face - Font face family.
|
|
168
|
+
*/
|
|
169
|
+
setFace(face) {
|
|
170
|
+
this._face = face.trim().toLowerCase();
|
|
171
|
+
this.update();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Gets current font face.
|
|
176
|
+
* @public
|
|
177
|
+
* @returns {string}
|
|
178
|
+
*/
|
|
179
|
+
getFace() {
|
|
180
|
+
return this._face;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Sets label font size in pixels.
|
|
185
|
+
* @public
|
|
186
|
+
* @param {number} size - Label size in pixels.
|
|
187
|
+
*/
|
|
188
|
+
setSize(size) {
|
|
189
|
+
if (size !== this._size) {
|
|
190
|
+
this._size = size;
|
|
191
|
+
if (this._isReady && this._handler) {
|
|
192
|
+
this._handler.setSizeArr(this._handlerIndex, size);
|
|
193
|
+
} else if (this._lockId !== LOCK_FREE) {
|
|
194
|
+
this._lockId = LOCK_UPDATE;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Gets label size in pixels.
|
|
201
|
+
* @public
|
|
202
|
+
* @returns {number}
|
|
203
|
+
*/
|
|
204
|
+
getSize() {
|
|
205
|
+
return this._size;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Sets text outline border size. Where 0 - is no outline and 1 - is the maximum outline size.
|
|
210
|
+
* @public
|
|
211
|
+
* @param {number} outline - Text outline size.
|
|
212
|
+
*/
|
|
213
|
+
setOutline(outline) {
|
|
214
|
+
this._outline = outline;
|
|
215
|
+
if (this._isReady && this._handler) {
|
|
216
|
+
this._handler.setOutlineArr(this._handlerIndex, outline);
|
|
217
|
+
} else if (this._lockId !== LOCK_FREE) {
|
|
218
|
+
this._lockId = LOCK_UPDATE;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Gets text current outline size.
|
|
224
|
+
* @public
|
|
225
|
+
* @returns {number}
|
|
226
|
+
*/
|
|
227
|
+
getOutline() {
|
|
228
|
+
return this._outline;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Sets label opacity.
|
|
233
|
+
* @public
|
|
234
|
+
* @param {number} a - Label opacity.
|
|
235
|
+
*/
|
|
236
|
+
setOpacity(a) {
|
|
237
|
+
super.setOpacity(a);
|
|
238
|
+
this.setOutlineOpacity(a);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Sets text outline color.
|
|
243
|
+
* @public
|
|
244
|
+
* @param {number} r - Red.
|
|
245
|
+
* @param {number} g - Green.
|
|
246
|
+
* @param {number} b - Blue.
|
|
247
|
+
* @param {number} a - Alpha.
|
|
248
|
+
*/
|
|
249
|
+
setOutlineColor(r, g, b, a) {
|
|
250
|
+
if (a !== this._outlineColor.w || r !== this._outlineColor.x || g !== this._outlineColor.y || b !== this._outlineColor.z) {
|
|
251
|
+
this._outlineColor.x = r;
|
|
252
|
+
this._outlineColor.y = g;
|
|
253
|
+
this._outlineColor.z = b;
|
|
254
|
+
this._outlineColor.w = a;
|
|
255
|
+
if (this._isReady && this._handler) {
|
|
256
|
+
this._handler.setOutlineColorArr(this._handlerIndex, this._outlineColor);
|
|
257
|
+
} else if (this._lockId !== LOCK_FREE) {
|
|
258
|
+
this._lockId = LOCK_UPDATE;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Sets text outline color.
|
|
265
|
+
* @public
|
|
266
|
+
* @param {Vec4} rgba - Color vector.
|
|
267
|
+
*/
|
|
268
|
+
setOutlineColor4v(rgba) {
|
|
269
|
+
this.setOutlineColor(rgba.x, rgba.y, rgba.z, rgba.w);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Sets text outline color HTML string.
|
|
274
|
+
* @public
|
|
275
|
+
* @param {string} color - HTML string color.
|
|
276
|
+
*/
|
|
277
|
+
setOutlineColorHTML(color) {
|
|
278
|
+
this.setOutlineColor4v(utils.htmlColorToRgba(color));
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Gets outline color vector.
|
|
283
|
+
* @public
|
|
284
|
+
* @returns {Vec4}
|
|
285
|
+
*/
|
|
286
|
+
getOutlineColor() {
|
|
287
|
+
return this._outlineColor;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Sets outline opacity. Actually outline color alpha value.
|
|
292
|
+
* @public
|
|
293
|
+
* @param {number} opacity - Outline opacity.
|
|
294
|
+
*/
|
|
295
|
+
setOutlineOpacity(opacity) {
|
|
296
|
+
if (opacity !== this._outlineColor.w) {
|
|
297
|
+
this._outlineColor.w = opacity;
|
|
298
|
+
if (this._isReady && this._handler) {
|
|
299
|
+
this._handler.setOutlineColorArr(this._handlerIndex, this._outlineColor);
|
|
300
|
+
} else if (this._lockId !== LOCK_FREE) {
|
|
301
|
+
this._lockId = LOCK_UPDATE;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Gets outline opacity value.
|
|
308
|
+
* @public
|
|
309
|
+
* @returns {number}
|
|
310
|
+
*/
|
|
311
|
+
getOutlineOpacity() {
|
|
312
|
+
return this._outlineColor.w;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Updates label parameters.
|
|
317
|
+
* @public
|
|
318
|
+
*/
|
|
319
|
+
async update() {
|
|
320
|
+
if (this._fontAtlas) {
|
|
321
|
+
const fontIndex = await this._fontAtlas.getFontIndex(this._face);
|
|
322
|
+
this._applyFontIndex(fontIndex);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
_applyFontIndex(fontIndex) {
|
|
327
|
+
this._fontIndex = fontIndex;
|
|
328
|
+
if (this._isReady && this._handler) {
|
|
329
|
+
this._handler.setFontIndexArr(this._handlerIndex, this._fontIndex);
|
|
330
|
+
this._handler.setText(this._handlerIndex, this._text, this._fontIndex, this._align, this._isRTL);
|
|
331
|
+
} else if (this._lockId !== LOCK_FREE) {
|
|
332
|
+
this._lockId = LOCK_UPDATE;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Assigns font atlas and update.
|
|
338
|
+
* @public
|
|
339
|
+
* @param {utils.FontAtlas} fontAtlas - Font atlas.
|
|
340
|
+
*/
|
|
341
|
+
assignFontAtlas(fontAtlas) {
|
|
342
|
+
if (!this._fontAtlas) {
|
|
343
|
+
this._fontAtlas = fontAtlas;
|
|
344
|
+
}
|
|
345
|
+
this.update();
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
347
349
|
export { Label, ALIGN };
|