@openglobus/og 0.11.5 → 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 +5 -7
- package/src/og/Clock.js +6 -10
- package/src/og/Events.js +5 -7
- package/src/og/Extent.js +73 -32
- package/src/og/ImageCanvas.js +18 -15
- package/src/og/LonLat.js +13 -10
- package/src/og/Popup.js +18 -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/Frustum.js +19 -12
- package/src/og/camera/PlanetCamera.js +0 -1
- package/src/og/control/CompassButton.js +1 -2
- package/src/og/control/Control.js +7 -9
- package/src/og/control/DebugInfo.js +0 -1
- package/src/og/control/KeyboardNavigation.js +9 -9
- package/src/og/control/LayerSwitcher.js +21 -20
- 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 +22 -12
- 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/ellipsoid/Ellipsoid.js +148 -56
- package/src/og/ellipsoid/wgs84.js +3 -3
- package/src/og/entity/BaseBillboard.js +65 -14
- package/src/og/entity/Billboard.js +9 -5
- package/src/og/entity/BillboardHandler.js +310 -64
- package/src/og/entity/Entity.js +39 -1
- package/src/og/entity/EntityCollection.js +47 -24
- package/src/og/entity/GeoObject.js +228 -0
- package/src/og/entity/GeoObjectHandler.js +910 -0
- package/src/og/entity/GeometryHandler.js +595 -123
- package/src/og/entity/Label.js +53 -18
- package/src/og/entity/LabelHandler.js +42 -244
- package/src/og/entity/LabelWorker.js +213 -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 -16
- package/src/og/layer/GeoImage.js +6 -6
- package/src/og/layer/KML.js +55 -33
- package/src/og/layer/Layer.js +3 -3
- package/src/og/layer/Vector.js +94 -48
- package/src/og/layer/WMS.js +33 -16
- 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 +60 -30
- 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 +31 -17
- package/src/og/renderer/Renderer.js +23 -6
- package/src/og/renderer/RendererEvents.js +1 -1
- package/src/og/scene/BaseNode.js +2 -3
- package/src/og/scene/Planet.js +2 -2
- package/src/og/scene/RenderNode.js +15 -8
- 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/shapes/BaseShape.js +107 -35
- package/src/og/shapes/Icosphere.js +25 -10
- package/src/og/shapes/Sphere.js +8 -11
- package/src/og/utils/TextureAtlas.js +16 -18
- package/src/og/utils/shared.js +1 -1
- package/src/og/webgl/Handler.js +68 -49
- 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/Deferred.d.ts +1 -1
- package/types/Events.d.ts +2 -2
- package/types/Extent.d.ts +1 -1
- package/types/Rectangle.d.ts +1 -1
- package/types/ajax.d.ts +1 -1
- package/types/bv/Box.d.ts +1 -1
- package/types/bv/Sphere.d.ts +1 -1
- package/types/camera/Camera.d.ts +5 -5
- package/types/camera/Frustum.d.ts +6 -6
- package/types/camera/PlanetCamera.d.ts +8 -8
- package/types/control/Control.d.ts +1 -1
- package/types/control/EarthCoordinates.d.ts +1 -1
- package/types/control/Sun.d.ts +1 -1
- package/types/entity/BaseBillboard.d.ts +15 -8
- package/types/entity/Entity.d.ts +24 -9
- package/types/entity/EntityCollection.d.ts +15 -9
- package/types/entity/GeoObject.d.ts +111 -0
- package/types/entity/GeoObjectHandler.d.ts +77 -0
- package/types/entity/Geometry.d.ts +1 -1
- package/types/entity/GeometryHandler.d.ts +1 -1
- package/types/entity/Label.d.ts +3 -3
- package/types/entity/LabelHandler.d.ts +2 -0
- package/types/entity/LabelWorker.d.ts +9 -0
- package/types/entity/PointCloud.d.ts +1 -1
- package/types/entity/Polyline.d.ts +5 -5
- package/types/entity/Ray.d.ts +1 -1
- package/types/entity/Strip.d.ts +1 -1
- package/types/layer/BaseGeoImage.d.ts +3 -3
- package/types/layer/CanvasTiles.d.ts +5 -5
- package/types/layer/GeoImage.d.ts +1 -1
- package/types/layer/GeoVideo.d.ts +1 -1
- package/types/layer/Layer.d.ts +5 -5
- package/types/layer/Vector.d.ts +9 -9
- package/types/layer/XYZ.d.ts +3 -3
- package/types/light/LightSource.d.ts +7 -7
- package/types/math/Plane.d.ts +1 -1
- package/types/math/Ray.d.ts +1 -1
- package/types/math/Vec2.d.ts +34 -34
- package/types/math/Vec3.d.ts +1 -1
- package/types/math/Vec4.d.ts +1 -1
- package/types/math/coder.d.ts +1 -1
- package/types/math.d.ts +1 -1
- package/types/proj/Proj.d.ts +2 -2
- package/types/quadTree/Node.d.ts +1 -1
- package/types/renderer/Renderer.d.ts +12 -10
- package/types/renderer/RendererEvents.d.ts +1 -1
- package/types/scene/BaseNode.d.ts +4 -4
- package/types/scene/Planet.d.ts +40 -40
- package/types/scene/RenderNode.d.ts +9 -9
- package/types/segment/Segment.d.ts +9 -9
- package/types/shaders/geoObject.d.ts +3 -0
- package/types/shapes/BaseShape.d.ts +5 -5
- package/types/terrain/EmptyTerrain.d.ts +2 -2
- package/types/terrain/GlobusTerrain.d.ts +4 -4
- package/types/utils/TextureAtlas.d.ts +4 -4
- package/types/utils/shared.d.ts +9 -9
- package/types/webgl/Framebuffer.d.ts +1 -1
- package/types/webgl/Handler.d.ts +16 -7
- package/types/webgl/Multisample.d.ts +2 -2
- package/types/webgl/Program.d.ts +6 -0
- package/types/webgl/ProgramController.d.ts +1 -1
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,
|
|
@@ -84,14 +84,19 @@ class Label extends BaseBillboard {
|
|
|
84
84
|
* @private
|
|
85
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
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.
|
|
@@ -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
|
/**
|
|
@@ -135,7 +142,11 @@ class Label extends BaseBillboard {
|
|
|
135
142
|
*/
|
|
136
143
|
setAlign(align) {
|
|
137
144
|
this._align = STR2ALIGN[align.trim().toLowerCase()];
|
|
138
|
-
|
|
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
|
+
}
|
|
139
150
|
}
|
|
140
151
|
|
|
141
152
|
/**
|
|
@@ -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,7 +248,11 @@ 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
|
/**
|
|
@@ -242,7 +265,11 @@ class Label extends BaseBillboard {
|
|
|
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
|
/**
|
|
@@ -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
|
/**
|
|
@@ -295,9 +326,11 @@ class Label extends BaseBillboard {
|
|
|
295
326
|
|
|
296
327
|
_applyFontIndex(fontIndex) {
|
|
297
328
|
this._fontIndex = fontIndex;
|
|
298
|
-
if (this.
|
|
329
|
+
if (this._isReady) {
|
|
299
330
|
this._handler.setFontIndexArr(this._handlerIndex, this._fontIndex);
|
|
300
331
|
this._handler.setText(this._handlerIndex, this._text, this._fontIndex, this._align);
|
|
332
|
+
} else if (this._lockId !== -1) {
|
|
333
|
+
this._lockId = -2;
|
|
301
334
|
}
|
|
302
335
|
}
|
|
303
336
|
|
|
@@ -307,9 +340,11 @@ class Label extends BaseBillboard {
|
|
|
307
340
|
* @param {utils.FontAtlas} fontAtlas - Font atlas.
|
|
308
341
|
*/
|
|
309
342
|
assignFontAtlas(fontAtlas) {
|
|
310
|
-
|
|
343
|
+
if (!this._fontAtlas) {
|
|
344
|
+
this._fontAtlas = fontAtlas;
|
|
345
|
+
}
|
|
311
346
|
this.update();
|
|
312
|
-
}
|
|
347
|
+
}
|
|
313
348
|
}
|
|
314
349
|
|
|
315
|
-
export { Label, ALIGN };
|
|
350
|
+
export { Label, ALIGN };
|
|
@@ -76,19 +76,52 @@ class LabelHandler extends BillboardHandler {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
add(label) {
|
|
79
|
-
if (label.
|
|
79
|
+
if (!label._handler) {
|
|
80
80
|
label._handler = this;
|
|
81
|
-
label._handlerIndex = this._billboards.length;
|
|
82
|
-
this._billboards.push(label);
|
|
83
|
-
this._addBillboardToArrays(label);
|
|
84
|
-
this.refresh();
|
|
85
81
|
this.assignFontAtlas(label);
|
|
82
|
+
this.refresh();
|
|
86
83
|
}
|
|
87
|
-
}
|
|
88
|
-
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
_addLabelToArrays(label) {
|
|
87
|
+
this._renderer.labelWorker.make(this, label);
|
|
88
|
+
}
|
|
89
|
+
|
|
89
90
|
assignFontAtlas(label) {
|
|
90
91
|
if (this._entityCollection && this._renderer) {
|
|
91
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();
|
|
92
125
|
}
|
|
93
126
|
}
|
|
94
127
|
|
|
@@ -168,236 +201,6 @@ class LabelHandler extends BillboardHandler {
|
|
|
168
201
|
}
|
|
169
202
|
}
|
|
170
203
|
|
|
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
204
|
_displayPASS() {
|
|
402
205
|
var r = this._renderer;
|
|
403
206
|
var h = r.handler;
|
|
@@ -665,7 +468,8 @@ class LabelHandler extends BillboardHandler {
|
|
|
665
468
|
this.refresh();
|
|
666
469
|
|
|
667
470
|
label._handlerIndex = -1;
|
|
668
|
-
label._handler = null;
|
|
471
|
+
label._handler = null;
|
|
472
|
+
label._isReady = false;
|
|
669
473
|
}
|
|
670
474
|
|
|
671
475
|
setText(index, text, fontIndex, align) {
|
|
@@ -692,12 +496,6 @@ class LabelHandler extends BillboardHandler {
|
|
|
692
496
|
|
|
693
497
|
let m = n.metrics;
|
|
694
498
|
|
|
695
|
-
//m.nWidth;
|
|
696
|
-
//m.nHeight;
|
|
697
|
-
//m.nAdvance;
|
|
698
|
-
//m.nXOffset;
|
|
699
|
-
//m.nYOffset;
|
|
700
|
-
|
|
701
499
|
a[j] = tc[0];
|
|
702
500
|
a[j + 1] = tc[1];
|
|
703
501
|
a[j + 2] = offset;
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// import { QueueArray } from '../QueueArray.js';
|
|
4
|
+
|
|
5
|
+
class LabelWorker {
|
|
6
|
+
constructor(numWorkers = 4) {
|
|
7
|
+
this._id = 0;
|
|
8
|
+
this._source = {};
|
|
9
|
+
|
|
10
|
+
this._freeWorkerQueue = []; //new QueueArray(numWorkers);
|
|
11
|
+
var labelProgramm = new Blob([_programm], { type: "application/javascript" });
|
|
12
|
+
|
|
13
|
+
var that = this;
|
|
14
|
+
|
|
15
|
+
for (let i = 0; i < numWorkers; i++) {
|
|
16
|
+
var w = new Worker(URL.createObjectURL(labelProgramm));
|
|
17
|
+
w.onmessage = function (e) {
|
|
18
|
+
|
|
19
|
+
let s = that._source[e.data.id];
|
|
20
|
+
|
|
21
|
+
if (s.label._lockId === -2) {
|
|
22
|
+
that.make(s.handler, s.label);
|
|
23
|
+
} else {
|
|
24
|
+
s.handler.workerCallback(e.data, s.label);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
that._source[e.data.id] = null;
|
|
28
|
+
delete that._source[e.data.id];
|
|
29
|
+
that._freeWorkerQueue.unshift(this);
|
|
30
|
+
|
|
31
|
+
that.check();
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
this._freeWorkerQueue.push(w);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
this._pendingQueue = []; //new QueueArray(512);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
check() {
|
|
41
|
+
if (this._pendingQueue.length) {
|
|
42
|
+
var p = this._pendingQueue.pop();
|
|
43
|
+
this.make(p.handler, p.label);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
make(handler, label) {
|
|
48
|
+
|
|
49
|
+
let source = { handler: handler, label: label };
|
|
50
|
+
|
|
51
|
+
if (this._freeWorkerQueue.length) {
|
|
52
|
+
var w = this._freeWorkerQueue.pop();
|
|
53
|
+
|
|
54
|
+
this._source[this._id] = source;
|
|
55
|
+
|
|
56
|
+
let labelData = new Float32Array([
|
|
57
|
+
/*0*/this._id++,
|
|
58
|
+
/*1*/handler._maxLetters,
|
|
59
|
+
/*2*/label.getVisibility() ? 1 : 0,
|
|
60
|
+
/*3, 4, 5*/label._positionHigh.x, label._positionHigh.y, label._positionHigh.z,
|
|
61
|
+
/*6, 7, 8*/label._positionLow.x, label._positionLow.y, label._positionLow.z,
|
|
62
|
+
/*9*/label._size,
|
|
63
|
+
/*10, 11, 12*/label._offset.x, label._offset.y, label._offset.z,
|
|
64
|
+
/*13, 14, 15, 16*/label._color.x, label._color.y, label._color.z, label._color.w,
|
|
65
|
+
/*17*/label._rotation,
|
|
66
|
+
/*18, 19, 20*/label._alignedAxis.x, label._alignedAxis.y, label._alignedAxis.z,
|
|
67
|
+
/*21*/label._fontIndex,
|
|
68
|
+
/*22*/label._outline,
|
|
69
|
+
/*23, 24, 25, 26*/label._outlineColor.x, label._outlineColor.y, label._outlineColor.z, label._outlineColor.w,
|
|
70
|
+
/*27, 28, 29*/label._entity._pickingColor.x, label._entity._pickingColor.y, label._entity._pickingColor.z
|
|
71
|
+
]);
|
|
72
|
+
|
|
73
|
+
label._lockId = this._id;
|
|
74
|
+
|
|
75
|
+
w.postMessage({
|
|
76
|
+
labelData: labelData
|
|
77
|
+
}, [
|
|
78
|
+
labelData.buffer,
|
|
79
|
+
]);
|
|
80
|
+
} else {
|
|
81
|
+
this._pendingQueue.push(source);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const _programm = `'use strict';
|
|
87
|
+
|
|
88
|
+
function concatTypedArrays(dest, index, source) {
|
|
89
|
+
let len = source.length,
|
|
90
|
+
offset = index * len;
|
|
91
|
+
for(let i = 0; i < len; i++) {
|
|
92
|
+
dest[offset + i] = source[i];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
self.onmessage = function (e) {
|
|
97
|
+
var labelData = e.data.labelData,
|
|
98
|
+
id = labelData[0],
|
|
99
|
+
maxLetters = labelData[1],
|
|
100
|
+
isVisible = labelData[2],
|
|
101
|
+
/*3, 4, 5*/_positionHigh_x = labelData[3], _positionHigh_y = labelData[4], _positionHigh_z = labelData[5],
|
|
102
|
+
/*6, 7, 8*/_positionLow_x = labelData[6], _positionLow_y = labelData[7], _positionLow_z = labelData[8],
|
|
103
|
+
/*9*/_size = labelData[9],
|
|
104
|
+
/*10, 11, 12*/_offset_x = labelData[10], _offset_y = labelData[11], _offset_z = labelData[12],
|
|
105
|
+
/*13, 14, 15, 16*/_color_x = labelData[13], _color_y = labelData[14], _color_z = labelData[15], _color_w = labelData[16],
|
|
106
|
+
/*17*/_rotation = labelData[17],
|
|
107
|
+
/*18, 19, 20*/_alignedAxis_x = labelData[18], _alignedAxis_y = labelData[19], _alignedAxis_z = labelData[20],
|
|
108
|
+
/*21*/_fontIndex = labelData[21],
|
|
109
|
+
/*22*/_outline = labelData[22],
|
|
110
|
+
/*23, 24, 25, 26*/_outlineColor_x = labelData[23], _outlineColor_y = labelData[24], _outlineColor_z = labelData[25], _outlineColor_w = labelData[26],
|
|
111
|
+
/*27, 28, 29*/_pickingColor_x = labelData[27], _pickingColor_y = labelData[28], _pickingColor_z = labelData[29]
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
let _vertexArr = new Float32Array(maxLetters * 12),
|
|
115
|
+
_texCoordArr = new Float32Array(maxLetters * 24),
|
|
116
|
+
_gliphParamArr = new Float32Array(maxLetters * 24),
|
|
117
|
+
_positionHighArr = new Float32Array(maxLetters * 18),
|
|
118
|
+
_positionLowArr = new Float32Array(maxLetters * 18),
|
|
119
|
+
_sizeArr = new Float32Array(maxLetters * 6),
|
|
120
|
+
_offsetArr = new Float32Array(maxLetters * 18),
|
|
121
|
+
_rgbaArr = new Float32Array(maxLetters * 24),
|
|
122
|
+
_rotationArr = new Float32Array(maxLetters * 6),
|
|
123
|
+
_alignedAxisArr = new Float32Array(maxLetters * 18),
|
|
124
|
+
_fontIndexArr = new Float32Array(maxLetters * 6),
|
|
125
|
+
_outlineArr = new Float32Array(maxLetters * 6),
|
|
126
|
+
_noOutlineArr = new Float32Array(maxLetters * 6),
|
|
127
|
+
_outlineColorArr = new Float32Array(maxLetters * 24),
|
|
128
|
+
_pickingColorArr = new Float32Array(maxLetters * 18);
|
|
129
|
+
|
|
130
|
+
for (var i = 0; i < maxLetters; i++) {
|
|
131
|
+
if (isVisible !== 0) {
|
|
132
|
+
concatTypedArrays(_vertexArr, i, [0, 0, 0, -1, 1, -1, 1, -1, 1, 0, 0, 0]);
|
|
133
|
+
} else {
|
|
134
|
+
concatTypedArrays(_vertexArr, i, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
concatTypedArrays(_texCoordArr, i, [0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, 0]);
|
|
138
|
+
concatTypedArrays(_gliphParamArr, i, [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]);
|
|
139
|
+
|
|
140
|
+
var x = _positionHigh_x, y = _positionHigh_y, z = _positionHigh_z, w;
|
|
141
|
+
concatTypedArrays(_positionHighArr, i, [x, y, z, x, y, z, x, y, z, x, y, z, x, y, z, x, y, z]);
|
|
142
|
+
|
|
143
|
+
x = _positionLow_x; y = _positionLow_y; z = _positionLow_z;
|
|
144
|
+
concatTypedArrays(_positionLowArr, i, [x, y, z, x, y, z, x, y, z, x, y, z, x, y, z, x, y, z]);
|
|
145
|
+
|
|
146
|
+
x = _size;
|
|
147
|
+
concatTypedArrays(_sizeArr, i, [x, x, x, x, x, x]);
|
|
148
|
+
|
|
149
|
+
x = _offset_x; y = _offset_y; z = _offset_z;
|
|
150
|
+
concatTypedArrays(_offsetArr, i, [x, y, z, x, y, z, x, y, z, x, y, z, x, y, z, x, y, z]);
|
|
151
|
+
|
|
152
|
+
x = _color_x; y = _color_y; z = _color_z; w = _color_w;
|
|
153
|
+
concatTypedArrays(_rgbaArr, i, [x, y, z, w, x, y, z, w, x, y, z, w, x, y, z, w, x, y, z, w, x, y, z, w]);
|
|
154
|
+
|
|
155
|
+
x = _rotation;
|
|
156
|
+
concatTypedArrays(_rotationArr, i, [x, x, x, x, x, x]);
|
|
157
|
+
|
|
158
|
+
x = _alignedAxis_x; y = _alignedAxis_y; z = _alignedAxis_z;
|
|
159
|
+
concatTypedArrays(_alignedAxisArr, i, [x, y, z, x, y, z, x, y, z, x, y, z, x, y, z, x, y, z]);
|
|
160
|
+
|
|
161
|
+
x = _fontIndex;
|
|
162
|
+
concatTypedArrays(_fontIndexArr, i, [x, x, x, x, x, x]);
|
|
163
|
+
|
|
164
|
+
x = _outline;
|
|
165
|
+
concatTypedArrays(_outlineArr, i, [x, x, x, x, x, x]);
|
|
166
|
+
|
|
167
|
+
w = 0.001;
|
|
168
|
+
concatTypedArrays(_noOutlineArr, i, [w, w, w, w, w, w]);
|
|
169
|
+
|
|
170
|
+
x = _outlineColor_x; y = _outlineColor_y; z = _outlineColor_z; w = _outlineColor_w;
|
|
171
|
+
concatTypedArrays(_outlineColorArr, i, [x, y, z, w, x, y, z, w, x, y, z, w, x, y, z, w, x, y, z, w, x, y, z, w]);
|
|
172
|
+
|
|
173
|
+
x = _pickingColor_x / 255; y = _pickingColor_y / 255; z = _pickingColor_z / 255;
|
|
174
|
+
concatTypedArrays(_pickingColorArr, i, [x, y, z, x, y, z, x, y, z, x, y, z, x, y, z, x, y, z]);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
self.postMessage({
|
|
178
|
+
id: id,
|
|
179
|
+
vertexArr: _vertexArr,
|
|
180
|
+
texCoordArr: _texCoordArr,
|
|
181
|
+
gliphParamArr: _gliphParamArr,
|
|
182
|
+
positionHighArr: _positionHighArr,
|
|
183
|
+
positionLowArr: _positionLowArr,
|
|
184
|
+
sizeArr: _sizeArr,
|
|
185
|
+
offsetArr: _offsetArr,
|
|
186
|
+
rgbaArr: _rgbaArr,
|
|
187
|
+
rotationArr: _rotationArr,
|
|
188
|
+
alignedAxisArr: _alignedAxisArr,
|
|
189
|
+
fontIndexArr: _fontIndexArr,
|
|
190
|
+
outlineArr: _outlineArr,
|
|
191
|
+
noOutlineArr: _noOutlineArr,
|
|
192
|
+
outlineColorArr: _outlineColorArr,
|
|
193
|
+
pickingColorArr: _pickingColorArr
|
|
194
|
+
}, [
|
|
195
|
+
_vertexArr.buffer,
|
|
196
|
+
_texCoordArr.buffer,
|
|
197
|
+
_gliphParamArr.buffer,
|
|
198
|
+
_positionHighArr.buffer,
|
|
199
|
+
_positionLowArr.buffer,
|
|
200
|
+
_sizeArr.buffer,
|
|
201
|
+
_offsetArr.buffer,
|
|
202
|
+
_rgbaArr.buffer,
|
|
203
|
+
_rotationArr.buffer,
|
|
204
|
+
_alignedAxisArr.buffer,
|
|
205
|
+
_fontIndexArr.buffer,
|
|
206
|
+
_outlineArr.buffer,
|
|
207
|
+
_noOutlineArr.buffer,
|
|
208
|
+
_outlineColorArr.buffer,
|
|
209
|
+
_pickingColorArr.buffer
|
|
210
|
+
]);
|
|
211
|
+
}`;
|
|
212
|
+
|
|
213
|
+
export { LabelWorker };
|