@pirireis/webglobeplugins 0.9.11 → 0.9.12
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/Math/angle-calculation.js +8 -8
- package/Math/arc.js +18 -18
- package/Math/bounds/line-bbox.js +78 -80
- package/Math/constants.js +3 -3
- package/Math/juction/arc-plane.js +23 -23
- package/Math/juction/line-sphere.js +11 -11
- package/Math/juction/plane-plane.js +11 -11
- package/Math/line.js +14 -16
- package/Math/methods.js +65 -70
- package/Math/plane.js +16 -18
- package/Math/quaternion.js +45 -49
- package/Math/utils.js +2 -2
- package/Math/vec3.js +42 -45
- package/algorithms/search-binary.js +4 -4
- package/altitude-locator/draw-subset-obj.js +7 -8
- package/altitude-locator/plugin.js +98 -114
- package/arrowfield/adaptor.js +3 -4
- package/arrowfield/index.js +2 -2
- package/arrowfield/plugin.js +62 -65
- package/bearing-line/index.js +1 -1
- package/bearing-line/plugin.js +200 -226
- package/circle-line-chain/chain-list-map.js +82 -88
- package/circle-line-chain/plugin.js +134 -165
- package/circle-line-chain/util.js +1 -1
- package/compass-rose/compass-rose-padding-flat.js +108 -133
- package/compass-rose/compass-text-writer.js +62 -70
- package/compass-rose/index.js +2 -2
- package/compassrose/compassrose.js +46 -50
- package/compassrose/index.js +1 -1
- package/heatwave/index.js +2 -2
- package/heatwave/isobar/objectarraylabels.js +44 -48
- package/heatwave/isobar/plugin.js +104 -123
- package/heatwave/isobar/quadtreecontours.js +76 -92
- package/heatwave/plugins/heatwaveglobeshell.js +69 -87
- package/index.js +11 -11
- package/package.json +1 -1
- package/partialrings/buffer-manager.js +32 -64
- package/partialrings/index.js +1 -1
- package/partialrings/plugin.js +48 -84
- package/partialrings/program.js +136 -47
- package/pin/pin-object-array.js +83 -86
- package/pin/pin-point-totem.js +21 -22
- package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +10 -10
- package/point-heat-map/plugin-webworker.js +40 -45
- package/point-heat-map/point-to-heat-map-flow.js +40 -42
- package/point-tracks/key-methods.js +1 -1
- package/point-tracks/plugin.js +137 -162
- package/programs/arrowfield/index.js +1 -1
- package/programs/arrowfield/logic.js +170 -62
- package/programs/arrowfield/object.js +33 -35
- package/programs/data2legend/density-to-legend.js +45 -21
- package/programs/data2legend/point-to-density-texture.js +52 -27
- package/programs/float2legendwithratio/index.js +1 -1
- package/programs/float2legendwithratio/logic.js +88 -42
- package/programs/float2legendwithratio/object.js +43 -46
- package/programs/globe-util/is-globe-moved.js +10 -11
- package/programs/globeshell/index.js +1 -1
- package/programs/globeshell/wiggle/index.js +1 -1
- package/programs/globeshell/wiggle/logic.js +191 -98
- package/programs/globeshell/wiggle/object.js +33 -35
- package/programs/helpers/blender/program.js +36 -19
- package/programs/helpers/fadeaway/index.js +1 -1
- package/programs/helpers/fadeaway/logic.js +35 -13
- package/programs/helpers/fadeaway/object.js +9 -10
- package/programs/helpers/index.js +1 -1
- package/programs/index.js +8 -8
- package/programs/line-on-globe/angled-line.js +91 -32
- package/programs/line-on-globe/circle-accurate-3d.js +82 -32
- package/programs/line-on-globe/circle-accurate-flat.js +108 -50
- package/programs/line-on-globe/circle-accurate.js +103 -33
- package/programs/line-on-globe/circle.js +97 -32
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +83 -33
- package/programs/line-on-globe/lines-color-instanced-flat.js +79 -34
- package/programs/line-on-globe/linestrip.js +111 -45
- package/programs/line-on-globe/naive-accurate-flexible.js +120 -50
- package/programs/line-on-globe/to-the-surface.js +58 -29
- package/programs/line-on-globe/util.js +1 -1
- package/programs/picking/pickable-renderer.js +117 -33
- package/programs/point-on-globe/element-globe-surface-glow.js +78 -38
- package/programs/point-on-globe/element-point-glow.js +103 -35
- package/programs/point-on-globe/square-pixel-point.js +76 -27
- package/programs/programcache.js +13 -13
- package/programs/rings/distancering/circleflatprogram.js +63 -21
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +156 -145
- package/programs/rings/distancering/circlepaddysharedbuffer.js +121 -197
- package/programs/rings/distancering/index.js +4 -4
- package/programs/rings/distancering/paddyflatprogram.js +73 -20
- package/programs/rings/distancering/paddyflatprogram2d.js +75 -22
- package/programs/rings/distancering/paddyflatprogram3d.js +73 -20
- package/programs/rings/partial-ring/piece-of-pie.js +137 -35
- package/programs/totems/camerauniformblock.js +64 -51
- package/programs/totems/canvas-webglobe-info.js +48 -40
- package/programs/totems/gpu-selection-uniform-block.js +44 -40
- package/programs/totems/index.js +1 -1
- package/programs/two-d/pixel-padding-for-compass.js +90 -29
- package/programs/util.js +6 -7
- package/programs/vectorfields/index.js +1 -1
- package/programs/vectorfields/logics/drawrectangleparticles.js +70 -29
- package/programs/vectorfields/logics/index.js +3 -3
- package/programs/vectorfields/logics/pixelbased.js +91 -35
- package/programs/vectorfields/logics/ubo.js +31 -25
- package/programs/vectorfields/pingpongbuffermanager.js +30 -34
- package/rangerings/index.js +4 -4
- package/rangerings/plugin.js +202 -258
- package/rangerings/rangeringangletext.js +108 -120
- package/rangerings/ring-account.js +52 -69
- package/shaders/fragment-toy/firework.js +55 -1
- package/shaders/fragment-toy/singularity.js +55 -1
- package/timetracks/adaptors-line-strip.js +26 -37
- package/timetracks/adaptors.js +47 -61
- package/timetracks/index.js +4 -4
- package/timetracks/plugin-line-strip.js +63 -71
- package/timetracks/plugin.js +69 -77
- package/timetracks/program-line-strip.js +296 -103
- package/timetracks/program.js +419 -113
- package/timetracks/programpoint-line-strip.js +97 -44
- package/timetracks/programpoint.js +90 -44
- package/util/account/bufferoffsetmanager.js +72 -95
- package/util/account/index.js +1 -1
- package/util/account/single-attribute-buffer-management/buffer-manager.js +44 -44
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +68 -94
- package/util/account/single-attribute-buffer-management/index.js +3 -3
- package/util/account/single-attribute-buffer-management/object-store.js +29 -30
- package/util/account/util.js +2 -4
- package/util/algorithms/search-binary.js +4 -4
- package/util/check/get.js +5 -5
- package/util/check/typecheck.js +13 -15
- package/util/geometry/index.js +9 -11
- package/util/gl-util/buffer/attribute-loader.js +8 -20
- package/util/gl-util/buffer/index.js +1 -1
- package/util/gl-util/draw-options/methods.js +8 -9
- package/util/gl-util/uniform-block/manager.js +67 -67
- package/util/heatwavedatamanager/datamanager.js +56 -116
- package/util/heatwavedatamanager/index.js +2 -2
- package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +37 -40
- package/util/heatwavedatamanager/pointcoordsmeta.js +9 -10
- package/util/index.js +6 -6
- package/util/interpolation/timetrack/index.js +1 -1
- package/util/interpolation/timetrack/timetrack-interpolator.js +27 -29
- package/util/interpolation/timetrack/web-worker-str.js +179 -1
- package/util/interpolation/timetrack/web-worker.js +4 -4
- package/util/jshelpers/data-filler.js +7 -7
- package/util/jshelpers/timefilters.js +7 -7
- package/util/picking/fence.js +7 -7
- package/util/picking/picker-displayer.js +46 -52
- package/util/programs/draw-texture-on-canvas.js +39 -21
- package/util/programs/shapesonglobe.js +104 -64
- package/util/programs/supersampletotextures.js +45 -39
- package/util/programs/texturetoglobe.js +98 -48
- package/util/shaderfunctions/geometrytransformations.js +322 -27
- package/util/shaderfunctions/nodata.js +7 -1
- package/util/shaderfunctions/noisefunctions.js +39 -9
- package/util/surface-line-data/arcs-to-cuts.js +20 -23
- package/util/webglobe/rasteroverlay.js +35 -37
- package/util/webglobjectbuilders.js +55 -60
- package/util/webglobjectbuilders1.js +48 -49
- package/waveparticles/adaptor.js +6 -7
- package/waveparticles/index.js +2 -2
- package/waveparticles/plugin.js +79 -84
- package/wind/imagetovectorfieldandmagnitude.js +15 -15
- package/wind/index.js +4 -4
- package/wind/plugin.js +453 -251
- package/wind/vectorfieldimage.js +5 -5
- package/write-text/attached-text-writer.js +46 -48
- package/write-text/context-text.js +51 -58
- package/write-text/context-text3.js +69 -74
package/wind/vectorfieldimage.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
function getVectorField(u, v, width, height, vMin, vMax, uMin, uMax, flip) {
|
|
4
|
-
|
|
5
|
-
for (
|
|
6
|
-
for (
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const data = new Uint8ClampedArray(width * height * 4);
|
|
5
|
+
for (let row = 0; row < height; row++) {
|
|
6
|
+
for (let col = 0; col < width; col++) {
|
|
7
|
+
let k = flip ? ((height - row - 1) * width + col) : row * width + col;
|
|
8
|
+
let idx = (width * row + col) << 2; // Multiply by 4 for RGBA
|
|
9
9
|
if (u[k] === null || v[k] === null || isNaN(u[k]) || !isFinite(u[k]) || isNaN(v[k]) || !isFinite(v[k])) {
|
|
10
10
|
data[idx] = 0; // R
|
|
11
11
|
data[idx + 1] = 0; // G
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AttachedTextWriter = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const webglobe_1 = require("@pirireis/webglobe");
|
|
5
|
+
const typecheck_1 = require("../util/check/typecheck");
|
|
6
6
|
/**
|
|
7
7
|
* Light wight version of context text writer.
|
|
8
8
|
* The parameters by text are calculated on user side and inserted as items. (ContextTextWriter3 constructs text data from items)
|
|
@@ -14,26 +14,25 @@ var typecheck_1 = require("../util/check/typecheck");
|
|
|
14
14
|
* With AttachedTextWriter the glue is created by user.
|
|
15
15
|
* I observed that the users generally uses a wrapper around the plugin logic anyway. This wrapper can be used as the glue for plugin and attacked writer.
|
|
16
16
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}; } : _f;
|
|
17
|
+
class AttachedTextWriter {
|
|
18
|
+
constructor(globe, { style = {
|
|
19
|
+
textFont: {
|
|
20
|
+
name: 'Arial',
|
|
21
|
+
textColor: '#FFFFFF', // beyaz
|
|
22
|
+
hollowColor: '#000000', // siyah
|
|
23
|
+
size: 12, // piksel
|
|
24
|
+
hollow: true,
|
|
25
|
+
bold: true,
|
|
26
|
+
italic: false,
|
|
27
|
+
},
|
|
28
|
+
opacity: 1.0,
|
|
29
|
+
zMode: webglobe_1.CSZMode.Z_GROUND_PERVERTEX,
|
|
30
|
+
}, doDraw = true, angleOnSphere = false, zoomLevelAdaptor = (zoomLevel) => (item) => {
|
|
31
|
+
return {
|
|
32
|
+
opacityMultiplier: 1,
|
|
33
|
+
sizeMultiplier: 1
|
|
34
|
+
};
|
|
35
|
+
}, } = {}) {
|
|
37
36
|
this.globe = globe;
|
|
38
37
|
this._itemMap = new Map();
|
|
39
38
|
this.doDraw = doDraw;
|
|
@@ -41,53 +40,52 @@ var AttachedTextWriter = /** @class */ (function () {
|
|
|
41
40
|
this.zoomLevelAdaptor = zoomLevelAdaptor;
|
|
42
41
|
this.setStyle(style);
|
|
43
42
|
}
|
|
44
|
-
|
|
43
|
+
setOpacity(opacity) {
|
|
45
44
|
(0, typecheck_1.opacityCheck)(opacity);
|
|
46
45
|
this._style.opacity = opacity;
|
|
47
46
|
this.globe.DrawRender();
|
|
48
|
-
}
|
|
49
|
-
|
|
47
|
+
}
|
|
48
|
+
setStyle(style) {
|
|
50
49
|
(0, typecheck_1.isTextFont)(style.textFont);
|
|
51
50
|
this._style = style;
|
|
52
51
|
this.globe.DrawRender();
|
|
53
|
-
}
|
|
52
|
+
}
|
|
54
53
|
/**
|
|
55
54
|
*
|
|
56
55
|
* @param {{text, long, lat, z = 0, xOffset = 0, yOffset = 0, isAngleOn = false, Angle = 0 }} item
|
|
57
56
|
* @returns
|
|
58
57
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
insertItem(item) {
|
|
59
|
+
const key = this.keyAdaptor ? this.keyAdaptor(item) : item;
|
|
61
60
|
this._itemMap.set(key, item);
|
|
62
61
|
this.globe.DrawRender();
|
|
63
|
-
}
|
|
62
|
+
}
|
|
64
63
|
// TODO: use item style
|
|
65
|
-
|
|
64
|
+
draw() {
|
|
66
65
|
if (!this.doDraw) {
|
|
67
66
|
return;
|
|
68
67
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
_itemMap.forEach(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
long
|
|
80
|
-
lat
|
|
81
|
-
z
|
|
82
|
-
}, zMode)
|
|
83
|
-
|
|
68
|
+
const { globe, _itemMap, _style } = this;
|
|
69
|
+
const { zMode, textFont, opacity } = _style;
|
|
70
|
+
const is3D = globe.api_GetCurrentGeometry() === 0;
|
|
71
|
+
const angleIsOn = is3D ? true : this.angleOnSphere;
|
|
72
|
+
const zoomLevel = globe.api_GetCurrentLODWithDecimal();
|
|
73
|
+
const zoomAdaptor = this.zoomLevelAdaptor(zoomLevel);
|
|
74
|
+
const theSize = textFont.size;
|
|
75
|
+
_itemMap.forEach((item, key) => {
|
|
76
|
+
const { text, long, lat, z = 0, xOffset = 0, yOffset = 0, isAngleOn = false, angle = 0 } = item;
|
|
77
|
+
const { x, y } = globe.api_GetScreenPointFromGeo({
|
|
78
|
+
long,
|
|
79
|
+
lat,
|
|
80
|
+
z
|
|
81
|
+
}, zMode);
|
|
82
|
+
const { opacityMultiplier, sizeMultiplier } = zoomAdaptor(item);
|
|
84
83
|
textFont.size = sizeMultiplier * theSize;
|
|
85
84
|
if (x !== null && y !== null) {
|
|
86
85
|
globe.api_DrawContextText(text, textFont, opacityMultiplier * opacity, { x: x + xOffset, y: y - yOffset }, (isAngleOn && angleIsOn), angle);
|
|
87
86
|
}
|
|
88
87
|
});
|
|
89
88
|
textFont.size = theSize;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
}());
|
|
89
|
+
}
|
|
90
|
+
}
|
|
93
91
|
exports.AttachedTextWriter = AttachedTextWriter;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ContextTextWriter = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const webglobe_1 = require("@pirireis/webglobe");
|
|
5
|
+
const defaultStyle = {
|
|
6
6
|
textFont: {
|
|
7
7
|
name: 'Arial',
|
|
8
8
|
textColor: '#FFFFFF', // beyaz
|
|
@@ -15,91 +15,84 @@ var defaultStyle = {
|
|
|
15
15
|
opacity: 1.0,
|
|
16
16
|
zMode: webglobe_1.CSZMode.Z_GROUND_PERVERTEX,
|
|
17
17
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.style, style = _c === void 0 ? null : _c, _d = _b.doDraw, doDraw = _d === void 0 ? true : _d;
|
|
18
|
+
class ContextTextWriter {
|
|
19
|
+
constructor(globe, { style = null, doDraw = true } = {}) {
|
|
21
20
|
this.globe = globe;
|
|
22
21
|
this.itemMap = new Map();
|
|
23
22
|
this.style = style || defaultStyle;
|
|
24
23
|
this.doDraw = doDraw;
|
|
25
24
|
}
|
|
26
|
-
|
|
25
|
+
setDoDraw(bool) {
|
|
27
26
|
this.doDraw = bool;
|
|
28
|
-
}
|
|
29
|
-
|
|
27
|
+
}
|
|
28
|
+
setStyle(style) {
|
|
30
29
|
this.style = style;
|
|
31
|
-
}
|
|
32
|
-
|
|
30
|
+
}
|
|
31
|
+
setOpacity(opacity) {
|
|
33
32
|
this.style.opacity = opacity;
|
|
34
|
-
}
|
|
33
|
+
}
|
|
35
34
|
// Clean this ask Front dev
|
|
36
|
-
|
|
35
|
+
doDraw(boolean) {
|
|
37
36
|
this.doDraw = boolean;
|
|
38
|
-
}
|
|
39
|
-
|
|
37
|
+
}
|
|
38
|
+
draw() {
|
|
40
39
|
if (!this.doDraw)
|
|
41
40
|
return;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
for (
|
|
45
|
-
|
|
46
|
-
var _e = globe.api_GetScreenPointFromGeo({
|
|
41
|
+
const { globe, style, itemMap } = this;
|
|
42
|
+
const { textFont, opacity: opacity_ } = style;
|
|
43
|
+
for (const [key, { lat, long, text, opacity = null }] of itemMap) {
|
|
44
|
+
const { x, y } = globe.api_GetScreenPointFromGeo({
|
|
47
45
|
long: long,
|
|
48
46
|
lat: lat,
|
|
49
47
|
z: 0,
|
|
50
|
-
}, style.zMode === webglobe_1.CSZMode.Z_MSL)
|
|
51
|
-
|
|
48
|
+
}, style.zMode === webglobe_1.CSZMode.Z_MSL);
|
|
49
|
+
const o = opacity === null ? opacity_ : opacity * opacity_;
|
|
52
50
|
if (x !== null && y !== null)
|
|
53
|
-
globe.api_DrawContextTextMultiLine(text, textFont, o, { x
|
|
51
|
+
globe.api_DrawContextTextMultiLine(text, textFont, o, { x, y });
|
|
54
52
|
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
this.itemMap.set(key, { lat
|
|
58
|
-
}
|
|
59
|
-
|
|
53
|
+
}
|
|
54
|
+
insertText(key, lat, long, text) {
|
|
55
|
+
this.itemMap.set(key, { lat, long, text });
|
|
56
|
+
}
|
|
57
|
+
updateOpacityOfItem(key, opacity) {
|
|
60
58
|
this.itemMap.get(key).opacity = opacity;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
for (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
var data = this.itemMap.get(key);
|
|
59
|
+
}
|
|
60
|
+
updateOpacityBulk(items, keyAdaptor, valueAdaptor) {
|
|
61
|
+
for (const item of items) {
|
|
62
|
+
const key = keyAdaptor(item);
|
|
63
|
+
const opacity = valueAdaptor(item);
|
|
64
|
+
const data = this.itemMap.get(key);
|
|
68
65
|
data.opacity = opacity;
|
|
69
66
|
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
}
|
|
68
|
+
updateText(key, text) {
|
|
69
|
+
const item = this.itemMap.get(key);
|
|
73
70
|
item.text = text;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
}
|
|
72
|
+
updateCoords(key, lat, long) {
|
|
73
|
+
const item = this.itemMap.get(key);
|
|
77
74
|
item.lat = lat;
|
|
78
75
|
item.long = long;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
for (
|
|
82
|
-
var item = items_2[_i];
|
|
76
|
+
}
|
|
77
|
+
insertTextBulk(items) {
|
|
78
|
+
for (const item of items) {
|
|
83
79
|
this.itemMap.set(item.key, item);
|
|
84
80
|
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
for (
|
|
88
|
-
|
|
89
|
-
var item = this.itemMap.get(key);
|
|
81
|
+
}
|
|
82
|
+
updateTextCoordsBulk(items) {
|
|
83
|
+
for (const { key, lat, long } of items) {
|
|
84
|
+
const item = this.itemMap.get(key);
|
|
90
85
|
item.lat = lat;
|
|
91
86
|
item.long = long;
|
|
92
87
|
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
for (
|
|
96
|
-
var key = keys_1[_i];
|
|
88
|
+
}
|
|
89
|
+
deleteTextBulk(keys) {
|
|
90
|
+
for (const key of keys) {
|
|
97
91
|
this.itemMap.delete(key);
|
|
98
92
|
}
|
|
99
|
-
}
|
|
100
|
-
|
|
93
|
+
}
|
|
94
|
+
clear() {
|
|
101
95
|
this.itemMap.clear();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
}());
|
|
96
|
+
}
|
|
97
|
+
}
|
|
105
98
|
exports.ContextTextWriter = ContextTextWriter;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ContextTextWriter3 = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const webglobe_1 = require("@pirireis/webglobe");
|
|
5
|
+
const typecheck_1 = require("../util/check/typecheck");
|
|
6
6
|
/**
|
|
7
7
|
* TODOs:
|
|
8
8
|
* 1) update all if initials change (propably need a context and a callback to iterate over zPayload)
|
|
@@ -11,26 +11,25 @@ var typecheck_1 = require("../util/check/typecheck");
|
|
|
11
11
|
*
|
|
12
12
|
* TODO: key check and raise error if doesnt exist
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}; } : _p;
|
|
14
|
+
class ContextTextWriter3 {
|
|
15
|
+
constructor(globe, { style = {
|
|
16
|
+
textFont: {
|
|
17
|
+
name: 'Arial',
|
|
18
|
+
textColor: '#FFFFFF', // beyaz
|
|
19
|
+
hollowColor: '#000000', // siyah
|
|
20
|
+
size: 12, // piksel
|
|
21
|
+
hollow: true,
|
|
22
|
+
bold: true,
|
|
23
|
+
italic: false,
|
|
24
|
+
},
|
|
25
|
+
opacity: 1.0,
|
|
26
|
+
zMode: webglobe_1.CSZMode.Z_GROUND_PERVERTEX,
|
|
27
|
+
}, xOffset = 0, yOffset = 0, doDraw = true, textAdaptor = null, coordinatesAdaptor = null, keyAdaptor = null, opacityAdaptor = null, angleAdaptor = null, angleOnSphere = false, positionAdaptor = (item, i, container, properties) => "left", zoomLevelAdaptor = (zoomLevel) => (item) => {
|
|
28
|
+
return {
|
|
29
|
+
opacityMultiplier: 1,
|
|
30
|
+
sizeMultiplier: 1
|
|
31
|
+
};
|
|
32
|
+
} } = {}) {
|
|
34
33
|
this.globe = globe;
|
|
35
34
|
this.itemMap = new Map();
|
|
36
35
|
this.setStyle(style);
|
|
@@ -41,20 +40,20 @@ var ContextTextWriter3 = /** @class */ (function () {
|
|
|
41
40
|
this.keyAdaptor = keyAdaptor;
|
|
42
41
|
this.zoomLevelAdaptor = zoomLevelAdaptor;
|
|
43
42
|
this.positionAdaptor = positionAdaptor;
|
|
44
|
-
this.opacityAdaptor = opacityAdaptor ? opacityAdaptor :
|
|
43
|
+
this.opacityAdaptor = opacityAdaptor ? opacityAdaptor : () => 1;
|
|
45
44
|
this.angleOnSphere = angleOnSphere;
|
|
46
45
|
if (angleAdaptor) {
|
|
47
46
|
this.angleAdaptor = angleAdaptor;
|
|
48
47
|
this.angleAdaptorIsOn = true;
|
|
49
48
|
}
|
|
50
49
|
else {
|
|
51
|
-
this.angleAdaptor =
|
|
50
|
+
this.angleAdaptor = () => null;
|
|
52
51
|
this.angleAdaptorIsOn = false;
|
|
53
52
|
}
|
|
54
53
|
this.xOffset = xOffset;
|
|
55
54
|
this.yOffset = yOffset;
|
|
56
55
|
}
|
|
57
|
-
|
|
56
|
+
_checkParameterTypes(textAdaptor, coordinatesAdaptor, keyAdaptor, opacityAdaptor, angleAdaptor, xOffset, yOffset) {
|
|
58
57
|
if (textAdaptor !== null)
|
|
59
58
|
if (!(textAdaptor instanceof Function))
|
|
60
59
|
throw new Error("textAdaptor is not an instance of a Function");
|
|
@@ -74,87 +73,83 @@ var ContextTextWriter3 = /** @class */ (function () {
|
|
|
74
73
|
throw new Error("xOffset type is not a number");
|
|
75
74
|
if (typeof yOffset !== "number")
|
|
76
75
|
throw new Error("yOffset type is not a number");
|
|
77
|
-
}
|
|
78
|
-
|
|
76
|
+
}
|
|
77
|
+
setKeyAdaptor(adaptor) {
|
|
79
78
|
this.keyAdaptor = adaptor;
|
|
80
|
-
}
|
|
81
|
-
|
|
79
|
+
}
|
|
80
|
+
setDoDraw(bool) {
|
|
82
81
|
this.doDraw = bool;
|
|
83
82
|
this.globe.DrawRender();
|
|
84
|
-
}
|
|
85
|
-
|
|
83
|
+
}
|
|
84
|
+
setStyle(style) {
|
|
86
85
|
(0, typecheck_1.isTextFont)(style.textFont);
|
|
87
86
|
(0, typecheck_1.opacityCheck)(style.opacity); //TODO: use shallow copy
|
|
88
87
|
this.style = style;
|
|
89
88
|
this.globe.DrawRender();
|
|
90
|
-
}
|
|
91
|
-
|
|
89
|
+
}
|
|
90
|
+
setOpacity(opacity) {
|
|
92
91
|
this.style.opacity = opacity;
|
|
93
92
|
this.globe.DrawRender();
|
|
94
|
-
}
|
|
95
|
-
|
|
93
|
+
}
|
|
94
|
+
draw() {
|
|
96
95
|
if (!this.doDraw)
|
|
97
96
|
return;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
for (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
var _e = globe.api_GetScreenPointFromGeo({
|
|
97
|
+
const { globe, style, itemMap, xOffset, yOffset } = this;
|
|
98
|
+
const { textFont, opacity: opacity_ } = style;
|
|
99
|
+
const textSize = textFont.size;
|
|
100
|
+
const is3D = globe.api_GetCurrentGeometry() === 0;
|
|
101
|
+
const angleIsOn = is3D ? (this.angleAdaptorIsOn && this.angleOnSphere) : (this.angleAdaptorIsOn);
|
|
102
|
+
const zoomLevel = globe.api_GetCurrentLODWithDecimal();
|
|
103
|
+
const zoomAdaptor = this.zoomLevelAdaptor(zoomLevel);
|
|
104
|
+
for (const item of itemMap.values()) {
|
|
105
|
+
const { lat, long, text, opacity = null, angle = null, zPayload, position } = item;
|
|
106
|
+
const { x, y } = globe.api_GetScreenPointFromGeo({
|
|
109
107
|
long: long,
|
|
110
108
|
lat: lat,
|
|
111
109
|
z: 0,
|
|
112
|
-
}, style.zMode === webglobe_1.CSZMode.Z_MSL)
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
}, style.zMode === webglobe_1.CSZMode.Z_MSL);
|
|
111
|
+
const { opacityMultiplier, sizeMultiplier } = zoomAdaptor(zPayload);
|
|
112
|
+
const o = (opacity === null ? opacity_ : opacity * opacity_) * opacityMultiplier;
|
|
115
113
|
textFont.size = sizeMultiplier * textSize;
|
|
116
114
|
textFont.position = position;
|
|
117
115
|
if (x !== null && y !== null)
|
|
118
116
|
globe.api_DrawContextTextMultiLine(text, textFont, o, { x: x + xOffset, y: y - yOffset }, angleIsOn, angle);
|
|
119
117
|
}
|
|
120
118
|
textFont.size = textSize;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
_this.insertText(v, i, c, properties);
|
|
119
|
+
}
|
|
120
|
+
insertTextBulk(container, properties) {
|
|
121
|
+
container.forEach((v, i, c) => {
|
|
122
|
+
this.insertText(v, i, c, properties);
|
|
126
123
|
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
for (
|
|
130
|
-
var key = keys_1[_i];
|
|
124
|
+
}
|
|
125
|
+
deleteTextBulk(keys) {
|
|
126
|
+
for (const key of keys) {
|
|
131
127
|
this.itemMap.delete(key);
|
|
132
128
|
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
129
|
+
}
|
|
130
|
+
insertText(item, id, container, properties) {
|
|
131
|
+
const key = this.keyAdaptor(item, id, container, properties);
|
|
132
|
+
const coords = this.coordinatesAdaptor(item, id, container, properties);
|
|
137
133
|
if (coords == null) {
|
|
138
134
|
this.itemMap.delete(key);
|
|
139
135
|
return;
|
|
140
136
|
}
|
|
141
|
-
|
|
137
|
+
const text = this.textAdaptor(item, id, container, properties);
|
|
142
138
|
if (text == null) {
|
|
143
139
|
this.itemMap.delete(key);
|
|
144
140
|
return;
|
|
145
141
|
}
|
|
146
142
|
;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
this.itemMap.set(key, { long: coords.long, lat: coords.lat, text
|
|
151
|
-
}
|
|
152
|
-
|
|
143
|
+
const opacity = this.opacityAdaptor(item, id, container, properties);
|
|
144
|
+
const angle = this.angleAdaptor(item, id, container, properties);
|
|
145
|
+
const position = this.positionAdaptor(item, id, container, properties);
|
|
146
|
+
this.itemMap.set(key, { long: coords.long, lat: coords.lat, text, opacity, angle, zPayload: item, position });
|
|
147
|
+
}
|
|
148
|
+
clear() {
|
|
153
149
|
this.itemMap.clear();
|
|
154
|
-
}
|
|
155
|
-
|
|
150
|
+
}
|
|
151
|
+
free() {
|
|
156
152
|
this.itemMap = null;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
}());
|
|
153
|
+
}
|
|
154
|
+
}
|
|
160
155
|
exports.ContextTextWriter3 = ContextTextWriter3;
|