@openglobus/og 0.11.6 → 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 +11 -11
- package/src/og/Globe.js +8 -5
- package/src/og/Popup.js +3 -2
- package/src/og/camera/PlanetCamera.js +9 -4
- package/src/og/control/Lighting.js +33 -2
- package/src/og/ellipsoid/Ellipsoid.js +1 -1
- package/src/og/entity/BaseBillboard.js +67 -76
- package/src/og/entity/BillboardHandler.js +15 -8
- package/src/og/entity/Label.js +44 -47
- package/src/og/entity/LabelHandler.js +25 -25
- package/src/og/entity/LabelWorker.js +21 -16
- package/src/og/layer/Layer.js +28 -15
- package/src/og/layer/Material.js +1 -1
- package/src/og/quadTree/Node.js +16 -30
- package/src/og/renderer/Renderer.js +19 -29
- package/src/og/renderer/RendererEvents.js +41 -21
- package/src/og/scene/Planet.js +11 -28
- package/src/og/shaders/drawnode.js +135 -142
- package/src/og/shaders/toneMapping.js +1 -0
- package/src/og/shapes/BaseShape.js +1 -1
- package/src/og/utils/FontAtlas.js +6 -2
- package/src/og/utils/TextureAtlas.js +2 -2
- package/src/og/utils/VectorTileCreator.js +1 -3
- package/src/og/utils/shared.js +1 -1
- package/src/og/webgl/Handler.js +152 -118
- package/types/Clock.d.ts +0 -94
- package/types/Deferred.d.ts +0 -6
- package/types/Events.d.ts +0 -77
- package/types/Extent.d.ts +0 -166
- package/types/Globe.d.ts +0 -82
- package/types/ImageCanvas.d.ts +0 -123
- package/types/Lock.d.ts +0 -12
- package/types/LonLat.d.ts +0 -108
- package/types/Popup.d.ts +0 -42
- package/types/QueueArray.d.ts +0 -19
- package/types/Rectangle.d.ts +0 -80
- package/types/Stack.d.ts +0 -19
- package/types/ajax.d.ts +0 -24
- package/types/arial.d.ts +0 -48
- package/types/astro/astro.d.ts +0 -38
- package/types/astro/earth.d.ts +0 -7
- package/types/astro/jd.d.ts +0 -254
- package/types/bv/Box.d.ts +0 -30
- package/types/bv/Sphere.d.ts +0 -38
- package/types/bv/index.d.ts +0 -3
- package/types/camera/Camera.d.ts +0 -312
- package/types/camera/Frustum.d.ts +0 -133
- package/types/camera/PlanetCamera.d.ts +0 -218
- package/types/camera/index.d.ts +0 -3
- package/types/cons.d.ts +0 -40
- package/types/control/CompassButton.d.ts +0 -17
- package/types/control/Control.d.ts +0 -104
- package/types/control/DebugInfo.d.ts +0 -15
- package/types/control/EarthCoordinates.d.ts +0 -47
- package/types/control/EarthNavigation.d.ts +0 -42
- package/types/control/GeoImageDragControl.d.ts +0 -6
- package/types/control/KeyboardNavigation.d.ts +0 -21
- package/types/control/LayerSwitcher.d.ts +0 -21
- package/types/control/Lighting.d.ts +0 -16
- package/types/control/MouseNavigation.d.ts +0 -47
- package/types/control/ScaleControl.d.ts +0 -22
- package/types/control/ShowFps.d.ts +0 -11
- package/types/control/SimpleNavigation.d.ts +0 -25
- package/types/control/Sun.d.ts +0 -50
- package/types/control/ToggleWireframe.d.ts +0 -12
- package/types/control/TouchNavigation.d.ts +0 -48
- package/types/control/ZoomControl.d.ts +0 -27
- package/types/control/index.d.ts +0 -17
- package/types/ellipsoid/Ellipsoid.d.ts +0 -146
- package/types/ellipsoid/index.d.ts +0 -3
- package/types/ellipsoid/wgs84.d.ts +0 -6
- package/types/entity/BaseBillboard.d.ts +0 -215
- package/types/entity/Billboard.d.ts +0 -94
- package/types/entity/BillboardHandler.d.ts +0 -78
- package/types/entity/Entity.d.ts +0 -348
- package/types/entity/EntityCollection.d.ts +0 -317
- package/types/entity/GeoObject.d.ts +0 -111
- package/types/entity/GeoObjectHandler.d.ts +0 -77
- package/types/entity/Geometry.d.ts +0 -74
- package/types/entity/GeometryHandler.d.ts +0 -76
- package/types/entity/Label.d.ts +0 -189
- package/types/entity/LabelHandler.d.ts +0 -31
- package/types/entity/LabelWorker.d.ts +0 -9
- package/types/entity/PointCloud.d.ts +0 -174
- package/types/entity/PointCloudHandler.d.ts +0 -38
- package/types/entity/Polyline.d.ts +0 -306
- package/types/entity/PolylineHandler.d.ts +0 -18
- package/types/entity/Ray.d.ts +0 -124
- package/types/entity/RayHandler.d.ts +0 -67
- package/types/entity/ShapeHandler.d.ts +0 -22
- package/types/entity/Strip.d.ts +0 -119
- package/types/entity/StripHandler.d.ts +0 -38
- package/types/entity/index.d.ts +0 -8
- package/types/index.core.d.ts +0 -65
- package/types/index.d.ts +0 -45
- package/types/index.webgl.d.ts +0 -7
- package/types/input/KeyboardHandler.d.ts +0 -10
- package/types/input/MouseHandler.d.ts +0 -5
- package/types/input/TouchHandler.d.ts +0 -5
- package/types/input/input.d.ts +0 -34
- package/types/layer/BaseGeoImage.d.ts +0 -94
- package/types/layer/CanvasTiles.d.ts +0 -68
- package/types/layer/GeoImage.d.ts +0 -52
- package/types/layer/GeoTexture2d.d.ts +0 -8
- package/types/layer/GeoVideo.d.ts +0 -55
- package/types/layer/KML.d.ts +0 -63
- package/types/layer/Layer.d.ts +0 -326
- package/types/layer/Material.d.ts +0 -45
- package/types/layer/Vector.d.ts +0 -208
- package/types/layer/WMS.d.ts +0 -63
- package/types/layer/XYZ.d.ts +0 -120
- package/types/layer/index.d.ts +0 -10
- package/types/light/LightSource.d.ts +0 -178
- package/types/math/Line2.d.ts +0 -11
- package/types/math/Line3.d.ts +0 -10
- package/types/math/Mat3.d.ts +0 -65
- package/types/math/Mat4.d.ts +0 -176
- package/types/math/Plane.d.ts +0 -18
- package/types/math/Quat.d.ts +0 -379
- package/types/math/Ray.d.ts +0 -82
- package/types/math/Vec2.d.ts +0 -309
- package/types/math/Vec3.d.ts +0 -460
- package/types/math/Vec4.d.ts +0 -162
- package/types/math/coder.d.ts +0 -43
- package/types/math/index.d.ts +0 -11
- package/types/math.d.ts +0 -261
- package/types/mercator.d.ts +0 -92
- package/types/proj/EPSG3857.d.ts +0 -6
- package/types/proj/EPSG4326.d.ts +0 -6
- package/types/proj/Proj.d.ts +0 -42
- package/types/quadTree/EntityCollectionNode.d.ts +0 -34
- package/types/quadTree/Node.d.ts +0 -61
- package/types/quadTree/quadTree.d.ts +0 -40
- package/types/renderer/Renderer.d.ts +0 -300
- package/types/renderer/RendererEvents.d.ts +0 -233
- package/types/res/images.d.ts +0 -3
- package/types/scene/Axes.d.ts +0 -11
- package/types/scene/BaseNode.d.ts +0 -60
- package/types/scene/Planet.d.ts +0 -577
- package/types/scene/RenderNode.d.ts +0 -142
- package/types/scene/SkyBox.d.ts +0 -10
- package/types/scene/index.d.ts +0 -4
- package/types/segment/Segment.d.ts +0 -279
- package/types/segment/SegmentLonLat.d.ts +0 -16
- package/types/segment/segmentHelper.d.ts +0 -13
- package/types/shaders/billboard.d.ts +0 -3
- package/types/shaders/depth.d.ts +0 -2
- package/types/shaders/drawnode.d.ts +0 -7
- package/types/shaders/geoObject.d.ts +0 -3
- package/types/shaders/label.d.ts +0 -4
- package/types/shaders/pointCloud.d.ts +0 -2
- package/types/shaders/polyline.d.ts +0 -3
- package/types/shaders/ray.d.ts +0 -2
- package/types/shaders/screenFrame.d.ts +0 -2
- package/types/shaders/shape.d.ts +0 -4
- package/types/shaders/skybox.d.ts +0 -2
- package/types/shaders/toneMapping.d.ts +0 -2
- package/types/shapes/BaseShape.d.ts +0 -250
- package/types/shapes/Sphere.d.ts +0 -41
- package/types/terrain/BilTerrain.d.ts +0 -7
- package/types/terrain/EmptyTerrain.d.ts +0 -72
- package/types/terrain/Geoid.d.ts +0 -26
- package/types/terrain/GlobusTerrain.d.ts +0 -116
- package/types/terrain/MapboxTerrain.d.ts +0 -7
- package/types/terrain/index.d.ts +0 -5
- package/types/utils/FontAtlas.d.ts +0 -14
- package/types/utils/GeoImageCreator.d.ts +0 -30
- package/types/utils/ImagesCacheManager.d.ts +0 -10
- package/types/utils/Loader.d.ts +0 -25
- package/types/utils/NormalMapCreator.d.ts +0 -39
- package/types/utils/PlainSegmentWorker.d.ts +0 -10
- package/types/utils/TerrainWorker.d.ts +0 -9
- package/types/utils/TextureAtlas.d.ts +0 -111
- package/types/utils/VectorTileCreator.d.ts +0 -16
- package/types/utils/colorTable.d.ts +0 -143
- package/types/utils/earcut.d.ts +0 -6
- package/types/utils/shared.d.ts +0 -231
- package/types/webgl/Framebuffer.d.ts +0 -135
- package/types/webgl/Handler.d.ts +0 -397
- package/types/webgl/Multisample.d.ts +0 -89
- package/types/webgl/Program.d.ts +0 -161
- package/types/webgl/ProgramController.d.ts +0 -89
- package/types/webgl/callbacks.d.ts +0 -1
- package/types/webgl/index.d.ts +0 -6
- package/types/webgl/types.d.ts +0 -2
package/src/og/entity/Label.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import * as utils from "../utils/shared.js";
|
|
8
8
|
import { BaseBillboard } from "./BaseBillboard.js";
|
|
9
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,
|
|
@@ -121,8 +122,8 @@ class Label extends BaseBillboard {
|
|
|
121
122
|
*/
|
|
122
123
|
setText(text) {
|
|
123
124
|
this._text = text.toString();
|
|
124
|
-
if (this._isReady) {
|
|
125
|
-
this._handler.setText(this._handlerIndex, text, this._fontIndex, this._align);
|
|
125
|
+
if (this._isReady) {
|
|
126
|
+
this._handler.setText(this._handlerIndex, text, this._fontIndex, this._align);
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
|
|
@@ -142,10 +143,10 @@ class Label extends BaseBillboard {
|
|
|
142
143
|
*/
|
|
143
144
|
setAlign(align) {
|
|
144
145
|
this._align = STR2ALIGN[align.trim().toLowerCase()];
|
|
145
|
-
if (this._isReady) {
|
|
146
|
-
this._handler.setText(this._handlerIndex, this._text, this._fontIndex, this._align);
|
|
147
|
-
} else if (this._lockId !==
|
|
148
|
-
this._lockId =
|
|
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;
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
152
|
|
|
@@ -183,11 +184,13 @@ class Label extends BaseBillboard {
|
|
|
183
184
|
* @param {number} size - Label size in pixels.
|
|
184
185
|
*/
|
|
185
186
|
setSize(size) {
|
|
186
|
-
this._size
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
this._lockId
|
|
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
|
+
}
|
|
191
194
|
}
|
|
192
195
|
}
|
|
193
196
|
|
|
@@ -207,10 +210,10 @@ class Label extends BaseBillboard {
|
|
|
207
210
|
*/
|
|
208
211
|
setOutline(outline) {
|
|
209
212
|
this._outline = outline;
|
|
210
|
-
if (this._isReady) {
|
|
211
|
-
this._handler.setOutlineArr(this._handlerIndex, outline);
|
|
212
|
-
} else if (this._lockId !==
|
|
213
|
-
this._lockId =
|
|
213
|
+
if (this._isReady) {
|
|
214
|
+
this._handler.setOutlineArr(this._handlerIndex, outline);
|
|
215
|
+
} else if (this._lockId !== LOCK_FREE) {
|
|
216
|
+
this._lockId = LOCK_UPDATE;
|
|
214
217
|
}
|
|
215
218
|
}
|
|
216
219
|
|
|
@@ -229,10 +232,8 @@ class Label extends BaseBillboard {
|
|
|
229
232
|
* @param {number} a - Label opacity.
|
|
230
233
|
*/
|
|
231
234
|
setOpacity(a) {
|
|
232
|
-
|
|
233
|
-
this.
|
|
234
|
-
this._outlineColor.w = a;
|
|
235
|
-
this.setOutlineColor4v(this._outlineColor);
|
|
235
|
+
super.setOpacity(a);
|
|
236
|
+
this.setOutlineOpacity(a);
|
|
236
237
|
}
|
|
237
238
|
|
|
238
239
|
/**
|
|
@@ -244,14 +245,16 @@ class Label extends BaseBillboard {
|
|
|
244
245
|
* @param {number} a - Alpha.
|
|
245
246
|
*/
|
|
246
247
|
setOutlineColor(r, g, b, a) {
|
|
247
|
-
this._outlineColor.x
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
this._lockId
|
|
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
|
+
}
|
|
255
258
|
}
|
|
256
259
|
}
|
|
257
260
|
|
|
@@ -261,15 +264,7 @@ class Label extends BaseBillboard {
|
|
|
261
264
|
* @param {Vec4} rgba - Color vector.
|
|
262
265
|
*/
|
|
263
266
|
setOutlineColor4v(rgba) {
|
|
264
|
-
this.
|
|
265
|
-
this._outlineColor.y = rgba.y;
|
|
266
|
-
this._outlineColor.z = rgba.z;
|
|
267
|
-
this._outlineColor.w = rgba.w;
|
|
268
|
-
if (this._isReady) {
|
|
269
|
-
this._handler.setOutlineColorArr(this._handlerIndex, rgba);
|
|
270
|
-
} else if (this._lockId !== -1) {
|
|
271
|
-
this._lockId = -2;
|
|
272
|
-
}
|
|
267
|
+
this.setOutlineColor(rgba.x, rgba.y, rgba.z, rgba.w);
|
|
273
268
|
}
|
|
274
269
|
|
|
275
270
|
/**
|
|
@@ -296,11 +291,13 @@ class Label extends BaseBillboard {
|
|
|
296
291
|
* @param {number} opacity - Outline opacity.
|
|
297
292
|
*/
|
|
298
293
|
setOutlineOpacity(opacity) {
|
|
299
|
-
this._outlineColor.w
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
this._lockId
|
|
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
|
+
}
|
|
304
301
|
}
|
|
305
302
|
}
|
|
306
303
|
|
|
@@ -329,8 +326,8 @@ class Label extends BaseBillboard {
|
|
|
329
326
|
if (this._isReady) {
|
|
330
327
|
this._handler.setFontIndexArr(this._handlerIndex, this._fontIndex);
|
|
331
328
|
this._handler.setText(this._handlerIndex, this._text, this._fontIndex, this._align);
|
|
332
|
-
} else if (this._lockId !==
|
|
333
|
-
this._lockId =
|
|
329
|
+
} else if (this._lockId !== LOCK_FREE) {
|
|
330
|
+
this._lockId = LOCK_UPDATE;
|
|
334
331
|
}
|
|
335
332
|
}
|
|
336
333
|
|
|
@@ -340,11 +337,11 @@ class Label extends BaseBillboard {
|
|
|
340
337
|
* @param {utils.FontAtlas} fontAtlas - Font atlas.
|
|
341
338
|
*/
|
|
342
339
|
assignFontAtlas(fontAtlas) {
|
|
343
|
-
if (!this._fontAtlas) {
|
|
344
|
-
this._fontAtlas = fontAtlas;
|
|
340
|
+
if (!this._fontAtlas) {
|
|
341
|
+
this._fontAtlas = fontAtlas;
|
|
345
342
|
}
|
|
346
343
|
this.update();
|
|
347
|
-
}
|
|
344
|
+
}
|
|
348
345
|
}
|
|
349
346
|
|
|
350
|
-
export { Label, ALIGN };
|
|
347
|
+
export { Label, ALIGN };
|
|
@@ -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;
|
|
@@ -81,28 +82,28 @@ class LabelHandler extends BillboardHandler {
|
|
|
81
82
|
this.assignFontAtlas(label);
|
|
82
83
|
this.refresh();
|
|
83
84
|
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
_addLabelToArrays(label) {
|
|
87
|
-
this._renderer.labelWorker.make(this, label);
|
|
88
|
-
}
|
|
89
|
-
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
_addLabelToArrays(label) {
|
|
88
|
+
this._renderer.labelWorker.make(this, label);
|
|
89
|
+
}
|
|
90
|
+
|
|
90
91
|
assignFontAtlas(label) {
|
|
91
92
|
if (this._entityCollection && this._renderer) {
|
|
92
93
|
label.assignFontAtlas(this._renderer.fontAtlas);
|
|
93
94
|
this._addLabelToArrays(label);
|
|
94
|
-
} else {
|
|
95
|
-
this._billboards.push(label);
|
|
95
|
+
} else {
|
|
96
|
+
this._billboards.push(label);
|
|
96
97
|
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
workerCallback(data, label) {
|
|
100
|
-
if (label._lockId !==
|
|
101
|
-
label._isReady = true;
|
|
102
|
-
label._lockId =
|
|
103
|
-
label._handlerIndex = this._billboards.length;
|
|
104
|
-
this._billboards.push(label);
|
|
105
|
-
|
|
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
|
+
|
|
106
107
|
this._vertexArr = concatTypedArrays(this._vertexArr, data.vertexArr);
|
|
107
108
|
this._texCoordArr = concatTypedArrays(this._texCoordArr, data.texCoordArr);
|
|
108
109
|
this._gliphParamArr = concatTypedArrays(this._gliphParamArr, data.gliphParamArr);
|
|
@@ -117,11 +118,11 @@ class LabelHandler extends BillboardHandler {
|
|
|
117
118
|
this._outlineArr = concatTypedArrays(this._outlineArr, data.outlineArr);
|
|
118
119
|
this._noOutlineArr = concatTypedArrays(this._noOutlineArr, data.noOutlineArr);
|
|
119
120
|
this._outlineColorArr = concatTypedArrays(this._outlineColorArr, data.outlineColorArr);
|
|
120
|
-
this._pickingColorArr = concatTypedArrays(this._pickingColorArr, data.pickingColorArr);
|
|
121
|
-
|
|
122
|
-
label.update();
|
|
123
|
-
|
|
124
|
-
this.refresh();
|
|
121
|
+
this._pickingColorArr = concatTypedArrays(this._pickingColorArr, data.pickingColorArr);
|
|
122
|
+
|
|
123
|
+
label.update();
|
|
124
|
+
|
|
125
|
+
this.refresh();
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
128
|
|
|
@@ -468,8 +469,7 @@ class LabelHandler extends BillboardHandler {
|
|
|
468
469
|
this.refresh();
|
|
469
470
|
|
|
470
471
|
label._handlerIndex = -1;
|
|
471
|
-
label._handler = null;
|
|
472
|
-
label._isReady = false;
|
|
472
|
+
label._handler = null;
|
|
473
473
|
}
|
|
474
474
|
|
|
475
475
|
setText(index, text, fontIndex, align) {
|
|
@@ -1038,4 +1038,4 @@ class LabelHandler extends BillboardHandler {
|
|
|
1038
1038
|
}
|
|
1039
1039
|
}
|
|
1040
1040
|
|
|
1041
|
-
export { LabelHandler };
|
|
1041
|
+
export { LabelHandler };
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
// import { QueueArray } from '../QueueArray.js';
|
|
4
4
|
|
|
5
|
+
export const LOCK_UPDATE = -2;
|
|
6
|
+
export const LOCK_FREE = -1;
|
|
7
|
+
|
|
5
8
|
class LabelWorker {
|
|
6
9
|
constructor(numWorkers = 4) {
|
|
7
10
|
this._id = 0;
|
|
@@ -18,7 +21,7 @@ class LabelWorker {
|
|
|
18
21
|
|
|
19
22
|
let s = that._source[e.data.id];
|
|
20
23
|
|
|
21
|
-
if (s.label._lockId ===
|
|
24
|
+
if (s.label._lockId === LOCK_UPDATE) {
|
|
22
25
|
that.make(s.handler, s.label);
|
|
23
26
|
} else {
|
|
24
27
|
s.handler.workerCallback(e.data, s.label);
|
|
@@ -46,14 +49,15 @@ class LabelWorker {
|
|
|
46
49
|
|
|
47
50
|
make(handler, label) {
|
|
48
51
|
|
|
49
|
-
|
|
52
|
+
if (handler._entityCollection) {
|
|
53
|
+
let source = { handler: handler, label: label };
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
if (this._freeWorkerQueue.length) {
|
|
56
|
+
var w = this._freeWorkerQueue.pop();
|
|
53
57
|
|
|
54
|
-
|
|
58
|
+
this._source[this._id] = source;
|
|
55
59
|
|
|
56
|
-
|
|
60
|
+
let labelData = new Float32Array([
|
|
57
61
|
/*0*/this._id++,
|
|
58
62
|
/*1*/handler._maxLetters,
|
|
59
63
|
/*2*/label.getVisibility() ? 1 : 0,
|
|
@@ -68,17 +72,18 @@ class LabelWorker {
|
|
|
68
72
|
/*22*/label._outline,
|
|
69
73
|
/*23, 24, 25, 26*/label._outlineColor.x, label._outlineColor.y, label._outlineColor.z, label._outlineColor.w,
|
|
70
74
|
/*27, 28, 29*/label._entity._pickingColor.x, label._entity._pickingColor.y, label._entity._pickingColor.z
|
|
71
|
-
|
|
75
|
+
]);
|
|
72
76
|
|
|
73
|
-
|
|
77
|
+
label._lockId = this._id;
|
|
74
78
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
w.postMessage({
|
|
80
|
+
labelData: labelData
|
|
81
|
+
}, [
|
|
82
|
+
labelData.buffer,
|
|
83
|
+
]);
|
|
84
|
+
} else {
|
|
85
|
+
this._pendingQueue.push(source);
|
|
86
|
+
}
|
|
82
87
|
}
|
|
83
88
|
}
|
|
84
89
|
}
|
|
@@ -210,4 +215,4 @@ const _programm = `'use strict';
|
|
|
210
215
|
]);
|
|
211
216
|
}`;
|
|
212
217
|
|
|
213
|
-
export { LabelWorker };
|
|
218
|
+
export { LabelWorker };
|
package/src/og/layer/Layer.js
CHANGED
|
@@ -11,7 +11,6 @@ import { Extent } from "../Extent.js";
|
|
|
11
11
|
import { LonLat } from "../LonLat.js";
|
|
12
12
|
import { Material } from "./Material.js";
|
|
13
13
|
import { Vec3 } from "../math/Vec3.js";
|
|
14
|
-
import { createTexture } from "../webgl/Handler.js";
|
|
15
14
|
|
|
16
15
|
export const FADING_FACTOR = 0.29;
|
|
17
16
|
|
|
@@ -29,9 +28,10 @@ export const FADING_FACTOR = 0.29;
|
|
|
29
28
|
* @param {string} [options.attribution] - Layer attribution that displayed in the attribution area on the screen.
|
|
30
29
|
* @param {boolean} [options.isBaseLayer=false] - This is a base layer.
|
|
31
30
|
* @param {boolean} [options.visibility=true] - Layer visibility.
|
|
31
|
+
* @param {boolean} [options.isSRGB=false] - Layer image webgl nternal format.
|
|
32
32
|
* @param {Extent} [options.extent=[[-180.0, -90.0], [180.0, 90.0]]] - Visible extent.
|
|
33
|
-
* @param {Vec3} [options.ambient=[0.1, 0.1, 0.
|
|
34
|
-
* @param {Vec3} [options.diffuse=[
|
|
33
|
+
* @param {Vec3} [options.ambient=[0.1, 0.1, 0.1]] - Ambient RGB color.
|
|
34
|
+
* @param {Vec3} [options.diffuse=[0.9, 0.9, 0.9]] - Diffuse RGB color.
|
|
35
35
|
* @param {Vec3} [options.specular=[0.00025, 0.00015, 0.0001]] - Specular RGB color.
|
|
36
36
|
* @param {string} [options.textureFilter="anisotropic"] - Image texture filter. Available values: "nearest", "linear", "mipmap" and "anisotropic".
|
|
37
37
|
* @param {Number} [options.shininess=100] - Shininess.
|
|
@@ -112,9 +112,9 @@ class Layer {
|
|
|
112
112
|
* @public
|
|
113
113
|
* @type {Object}
|
|
114
114
|
*/
|
|
115
|
-
this.ambient = utils.createColorRGB(options.ambient, new Vec3(0.
|
|
116
|
-
this.diffuse = utils.createColorRGB(options.diffuse, new Vec3(0.
|
|
117
|
-
this.specular = utils.createColorRGB(options.specular, new Vec3(0.0003, 0.
|
|
115
|
+
this.ambient = utils.createColorRGB(options.ambient, new Vec3(0.2, 0.2, 0.2));
|
|
116
|
+
this.diffuse = utils.createColorRGB(options.diffuse, new Vec3(0.8, 0.8, 0.8));
|
|
117
|
+
this.specular = utils.createColorRGB(options.specular, new Vec3(0.0003, 0.0003, 0.0003));
|
|
118
118
|
this.shininess = options.shininess || 20.0;
|
|
119
119
|
|
|
120
120
|
/**
|
|
@@ -185,13 +185,13 @@ class Layer {
|
|
|
185
185
|
*/
|
|
186
186
|
this._extent = null;
|
|
187
187
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
188
|
+
this.createTexture = null;
|
|
189
|
+
|
|
190
|
+
this._textureFilter = options.textureFilter ? options.textureFilter.trim().toUpperCase() : "MIPMAP";
|
|
191
|
+
|
|
192
|
+
this._isSRGB = options.isSRGB != undefined ? options.isSRGB : false;
|
|
193
|
+
|
|
194
|
+
this._internalFormat = null;
|
|
195
195
|
|
|
196
196
|
/**
|
|
197
197
|
* Visible mercator extent.
|
|
@@ -333,7 +333,16 @@ class Layer {
|
|
|
333
333
|
* @virtual
|
|
334
334
|
* @param {Planet} planet - Planet render node.
|
|
335
335
|
*/
|
|
336
|
-
_assignPlanet(planet) {
|
|
336
|
+
_assignPlanet(planet) {
|
|
337
|
+
// TODO: webgl1
|
|
338
|
+
if (this._isSRGB) {
|
|
339
|
+
this._internalFormat = planet.renderer.handler.gl.SRGB8_ALPHA8;
|
|
340
|
+
} else {
|
|
341
|
+
this._internalFormat = planet.renderer.handler.gl.RGBA8;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
this.createTexture = planet.renderer.handler.createTexture[this._textureFilter];
|
|
345
|
+
|
|
337
346
|
planet.layers.push(this);
|
|
338
347
|
this._planet = planet;
|
|
339
348
|
this.events.on("visibilitychange", planet._onLayerVisibilityChanged, planet);
|
|
@@ -396,7 +405,11 @@ class Layer {
|
|
|
396
405
|
* @virtual
|
|
397
406
|
*/
|
|
398
407
|
clear() {
|
|
399
|
-
|
|
408
|
+
if (this._planet) {
|
|
409
|
+
this._planet._clearLayerMaterial(this);
|
|
410
|
+
this._internalFormat = null;
|
|
411
|
+
this.createTexture = null;
|
|
412
|
+
}
|
|
400
413
|
}
|
|
401
414
|
|
|
402
415
|
/**
|
package/src/og/layer/Material.js
CHANGED
package/src/og/quadTree/Node.js
CHANGED
|
@@ -64,6 +64,7 @@ let BOUNDS = {
|
|
|
64
64
|
* @param {Extent} extent - Planet segment extent.
|
|
65
65
|
*/
|
|
66
66
|
class Node {
|
|
67
|
+
|
|
67
68
|
constructor(SegmentPrototype, planet, partId, parent, id, tileZoom, extent) {
|
|
68
69
|
this.SegmentPrototype = SegmentPrototype;
|
|
69
70
|
this.planet = planet;
|
|
@@ -283,7 +284,7 @@ class Node {
|
|
|
283
284
|
|
|
284
285
|
let altVis =
|
|
285
286
|
cam.eye.distance(seg.bsphere.center) - seg.bsphere.radius <
|
|
286
|
-
|
|
287
|
+
VISIBLE_DISTANCE * Math.sqrt(h) ||
|
|
287
288
|
(seg.tileZoom < 4 && !seg.terrainReady) ||
|
|
288
289
|
seg.tileZoom < 2;
|
|
289
290
|
|
|
@@ -293,27 +294,15 @@ class Node {
|
|
|
293
294
|
|
|
294
295
|
if (seg.tileZoom < 2 && seg.normalMapReady) {
|
|
295
296
|
this.traverseNodes(cam, maxZoom, terrainReadySegment, stopLoading);
|
|
296
|
-
} else if ((!maxZoom && seg.acceptForRendering(cam)) || seg.tileZoom === maxZoom) {
|
|
297
|
-
this.prepareForRendering(
|
|
298
|
-
cam,
|
|
299
|
-
altVis,
|
|
300
|
-
this.inFrustum,
|
|
301
|
-
terrainReadySegment,
|
|
302
|
-
stopLoading
|
|
303
|
-
);
|
|
297
|
+
} else if ((!maxZoom && seg.acceptForRendering(cam)) || seg.tileZoom === maxZoom || !altVis && maxZoom) {
|
|
298
|
+
this.prepareForRendering(cam, altVis, this.inFrustum, terrainReadySegment, stopLoading);
|
|
304
299
|
} else if (seg.tileZoom < planet.terrain._maxNodeZoom && seg.terrainReady) {
|
|
305
300
|
// Deleting terrainReady here, you have to remove
|
|
306
301
|
// this.appliedTerrainNodeId !== pn.nodeId in whileTerrainLoading,
|
|
307
302
|
// also have to fix createBoundsByParent(*)
|
|
308
303
|
this.traverseNodes(cam, maxZoom, seg, stopLoading);
|
|
309
304
|
} else {
|
|
310
|
-
this.prepareForRendering(
|
|
311
|
-
cam,
|
|
312
|
-
altVis,
|
|
313
|
-
this.inFrustum,
|
|
314
|
-
terrainReadySegment,
|
|
315
|
-
stopLoading
|
|
316
|
-
);
|
|
305
|
+
this.prepareForRendering(cam, altVis, this.inFrustum, terrainReadySegment, stopLoading);
|
|
317
306
|
}
|
|
318
307
|
} else {
|
|
319
308
|
this.state = NOTRENDERING;
|
|
@@ -333,7 +322,13 @@ class Node {
|
|
|
333
322
|
n[3].renderTree(cam, maxZoom, terrainReadySegment, stopLoading);
|
|
334
323
|
}
|
|
335
324
|
|
|
336
|
-
prepareForRendering(
|
|
325
|
+
prepareForRendering(
|
|
326
|
+
cam,
|
|
327
|
+
altVis,
|
|
328
|
+
inFrustum,
|
|
329
|
+
terrainReadySegment,
|
|
330
|
+
stopLoading
|
|
331
|
+
) {
|
|
337
332
|
let seg = this.segment;
|
|
338
333
|
|
|
339
334
|
if (cam._lonLat.height < VISIBLE_HEIGHT) {
|
|
@@ -381,7 +376,7 @@ class Node {
|
|
|
381
376
|
}
|
|
382
377
|
|
|
383
378
|
// Create normal map texture
|
|
384
|
-
if (seg.planet.lightEnabled && !seg.normalMapReady
|
|
379
|
+
if (seg.planet.lightEnabled && !seg.normalMapReady && !seg.parentNormalMapReady) {
|
|
385
380
|
this.whileNormalMapCreating();
|
|
386
381
|
}
|
|
387
382
|
|
|
@@ -774,16 +769,8 @@ class Node {
|
|
|
774
769
|
let v_lt = new Vec3(bigOne[0], bigOne[1], bigOne[2]),
|
|
775
770
|
v_rb = new Vec3(bigOne[9], bigOne[10], bigOne[11]);
|
|
776
771
|
|
|
777
|
-
let vn = new Vec3(
|
|
778
|
-
|
|
779
|
-
bigOne[4] - bigOne[1],
|
|
780
|
-
bigOne[5] - bigOne[2]
|
|
781
|
-
),
|
|
782
|
-
vw = new Vec3(
|
|
783
|
-
bigOne[6] - bigOne[0],
|
|
784
|
-
bigOne[7] - bigOne[1],
|
|
785
|
-
bigOne[8] - bigOne[2]
|
|
786
|
-
),
|
|
772
|
+
let vn = new Vec3(bigOne[3] - bigOne[0], bigOne[4] - bigOne[1], bigOne[5] - bigOne[2]),
|
|
773
|
+
vw = new Vec3(bigOne[6] - bigOne[0], bigOne[7] - bigOne[1], bigOne[8] - bigOne[2]),
|
|
787
774
|
ve = new Vec3(
|
|
788
775
|
bigOne[3] - bigOne[9],
|
|
789
776
|
bigOne[4] - bigOne[10],
|
|
@@ -996,8 +983,7 @@ class Node {
|
|
|
996
983
|
offset = 0;
|
|
997
984
|
|
|
998
985
|
while (pNode.segment.tileZoom > neighbourZoom) {
|
|
999
|
-
offset +=
|
|
1000
|
-
PARTOFFSET[pNode.partId][side] / (1 << (pNode.segment.tileZoom - neighbourZoom));
|
|
986
|
+
offset += PARTOFFSET[pNode.partId][side] / (1 << (pNode.segment.tileZoom - neighbourZoom));
|
|
1001
987
|
pNode = pNode.parentNode;
|
|
1002
988
|
}
|
|
1003
989
|
|
|
@@ -73,9 +73,9 @@ class Renderer {
|
|
|
73
73
|
*/
|
|
74
74
|
this.handler = handler;
|
|
75
75
|
|
|
76
|
-
this.exposure =
|
|
76
|
+
this.exposure = 3.01;
|
|
77
77
|
|
|
78
|
-
this.gamma = 0.
|
|
78
|
+
this.gamma = 0.47;
|
|
79
79
|
|
|
80
80
|
this.whitepoint = 1.0;
|
|
81
81
|
|
|
@@ -159,13 +159,11 @@ class Renderer {
|
|
|
159
159
|
|
|
160
160
|
this.depthFramebuffer = null;
|
|
161
161
|
|
|
162
|
-
this._msaa = params.msaa ||
|
|
162
|
+
this._msaa = params.msaa || 4;
|
|
163
163
|
this._internalFormat = "RGBA16F";
|
|
164
164
|
this._format = "RGBA";
|
|
165
165
|
this._type = "FLOAT";
|
|
166
166
|
|
|
167
|
-
this._screenScale = params.screenScale || 1.0;
|
|
168
|
-
|
|
169
167
|
this.sceneFramebuffer = null;
|
|
170
168
|
|
|
171
169
|
this.blitFramebuffer = null;
|
|
@@ -224,11 +222,6 @@ class Renderer {
|
|
|
224
222
|
this.events.active = activity;
|
|
225
223
|
}
|
|
226
224
|
|
|
227
|
-
setScreenScale(scale) {
|
|
228
|
-
this._screenScale = scale;
|
|
229
|
-
this._resize();
|
|
230
|
-
}
|
|
231
|
-
|
|
232
225
|
addDepthCallback(sender, callback) {
|
|
233
226
|
var id = __depthCallbackCounter__++;
|
|
234
227
|
this._depthCallbacks.push({
|
|
@@ -333,7 +326,7 @@ class Renderer {
|
|
|
333
326
|
* @returns {number} -
|
|
334
327
|
*/
|
|
335
328
|
getWidth() {
|
|
336
|
-
return this.handler.canvas.
|
|
329
|
+
return this.handler.canvas.clientWidth;
|
|
337
330
|
}
|
|
338
331
|
|
|
339
332
|
/**
|
|
@@ -342,7 +335,7 @@ class Renderer {
|
|
|
342
335
|
* @returns {number} -
|
|
343
336
|
*/
|
|
344
337
|
getHeight() {
|
|
345
|
-
return this.handler.canvas.
|
|
338
|
+
return this.handler.canvas.clientHeight;
|
|
346
339
|
}
|
|
347
340
|
|
|
348
341
|
/**
|
|
@@ -352,7 +345,7 @@ class Renderer {
|
|
|
352
345
|
*/
|
|
353
346
|
getCenter() {
|
|
354
347
|
var cnv = this.handler.canvas;
|
|
355
|
-
return new Vec2(Math.round(cnv.
|
|
348
|
+
return new Vec2(Math.round(cnv.clientWidth * 0.5), Math.round(cnv.clientHeight * 0.5));
|
|
356
349
|
}
|
|
357
350
|
|
|
358
351
|
/**
|
|
@@ -479,7 +472,7 @@ class Renderer {
|
|
|
479
472
|
internalFormat: this._internalFormat,
|
|
480
473
|
format: this._format,
|
|
481
474
|
type: this._type,
|
|
482
|
-
filter: "
|
|
475
|
+
filter: "NEAREST"
|
|
483
476
|
}).init();
|
|
484
477
|
|
|
485
478
|
this.toneMappingFramebuffer = new Framebuffer(this.handler, {
|
|
@@ -526,24 +519,21 @@ class Renderer {
|
|
|
526
519
|
}
|
|
527
520
|
|
|
528
521
|
_resize() {
|
|
529
|
-
let
|
|
530
|
-
this.activeCamera.setAspectRatio(
|
|
531
|
-
this.sceneFramebuffer.setSize(
|
|
532
|
-
|
|
533
|
-
obj.clientHeight * this._screenScale
|
|
534
|
-
);
|
|
522
|
+
let c = this.handler.canvas;
|
|
523
|
+
this.activeCamera.setAspectRatio(c.width / c.height);
|
|
524
|
+
this.sceneFramebuffer.setSize(c.width, c.height);
|
|
525
|
+
|
|
535
526
|
this.blitFramebuffer &&
|
|
536
|
-
this.blitFramebuffer.setSize(
|
|
537
|
-
|
|
538
|
-
obj.clientHeight * this._screenScale,
|
|
539
|
-
true
|
|
540
|
-
);
|
|
527
|
+
this.blitFramebuffer.setSize(c.width, c.height, true);
|
|
528
|
+
|
|
541
529
|
this.toneMappingFramebuffer &&
|
|
542
|
-
this.toneMappingFramebuffer.setSize(
|
|
530
|
+
this.toneMappingFramebuffer.setSize(c.width, c.height, true);
|
|
531
|
+
|
|
543
532
|
this.depthFramebuffer &&
|
|
544
|
-
this.depthFramebuffer.setSize(
|
|
533
|
+
this.depthFramebuffer.setSize(c.width, c.height, true);
|
|
534
|
+
|
|
545
535
|
this.screenDepthFramebuffer &&
|
|
546
|
-
this.screenDepthFramebuffer.setSize(
|
|
536
|
+
this.screenDepthFramebuffer.setSize(c.width, c.height, true);
|
|
547
537
|
|
|
548
538
|
if (this.handler.gl.type === "webgl") {
|
|
549
539
|
this.screenTexture.screen = this.sceneFramebuffer.textures[0];
|
|
@@ -865,7 +855,7 @@ class Renderer {
|
|
|
865
855
|
getPickingObject(x, y) {
|
|
866
856
|
let cnv = this.renderer.handler.canvas,
|
|
867
857
|
c = new Uint8Array(3);
|
|
868
|
-
this.readPixels(c, x / cnv.
|
|
858
|
+
this.readPixels(c, x / cnv.clientWidth, (cnv.clientHeight - y) / cnv.clientHeight, 1);
|
|
869
859
|
return this.colorObjects[c[0] + "_" + c[1] + "_" + c[2]];
|
|
870
860
|
}
|
|
871
861
|
|