@pirireis/webglobeplugins 0.9.9 → 0.9.10
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 +15 -0
- package/Math/arc.js +65 -0
- package/Math/bounds/line-bbox.js +188 -0
- package/Math/constants.js +9 -0
- package/Math/frustum/camera.js +24 -0
- package/Math/frustum/from-globeinfo.js +48 -0
- package/Math/frustum/types.js +2 -0
- package/Math/globe-util/horizon-plane.js +112 -0
- package/Math/index.js +1 -0
- package/Math/juction/arc-plane.js +83 -0
- package/Math/juction/line-sphere.js +25 -0
- package/Math/juction/plane-plane.js +58 -0
- package/Math/line.js +56 -0
- package/Math/matrix4.js +1 -0
- package/Math/methods.js +201 -0
- package/Math/plane.js +60 -0
- package/Math/quaternion.js +104 -0
- package/Math/types.js +2 -0
- package/Math/utils.js +4 -0
- package/Math/vec3.js +126 -0
- package/algorithms/search-binary.js +19 -0
- package/altitude-locator/adaptors.js +1 -0
- package/altitude-locator/draw-subset-obj.js +18 -0
- package/altitude-locator/keymethod.js +1 -0
- package/altitude-locator/plugin.js +341 -0
- package/altitude-locator/types.js +23 -0
- package/arrowfield/adaptor.js +14 -0
- package/arrowfield/index.js +10 -0
- package/arrowfield/plugin.js +86 -0
- package/bearing-line/index.js +8 -0
- package/bearing-line/plugin.js +449 -0
- package/circle-line-chain/chain-list-map.js +205 -0
- package/circle-line-chain/init.js +1 -0
- package/circle-line-chain/plugin.js +424 -0
- package/circle-line-chain/util.js +5 -0
- package/compass-rose/compass-rose-padding-flat.js +225 -0
- package/compass-rose/compass-text-writer.js +153 -0
- package/compass-rose/index.js +7 -0
- package/compassrose/compassrose.js +296 -0
- package/compassrose/index.js +8 -0
- package/globe-types.js +1 -0
- package/heatwave/index.js +10 -0
- package/heatwave/isobar/objectarraylabels.js +202 -0
- package/heatwave/isobar/plugin.js +343 -0
- package/heatwave/isobar/quadtreecontours.js +300 -0
- package/heatwave/plugins/heatwaveglobeshell.js +206 -0
- package/jest.config.js +7 -0
- package/package.json +4 -4
- package/partialrings/buffer-manager.js +81 -0
- package/partialrings/index.js +41 -0
- package/partialrings/plugin.js +135 -0
- package/partialrings/program.js +286 -0
- package/pin/pin-object-array.js +305 -0
- package/pin/pin-point-totem.js +60 -0
- package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +66 -0
- package/point-heat-map/index.js +1 -0
- package/point-heat-map/plugin-webworker.js +126 -0
- package/point-heat-map/point-to-heat-map-flow.js +127 -0
- package/point-tracks/key-methods.js +5 -0
- package/point-tracks/plugin.js +338 -0
- package/programs/arrowfield/index.js +7 -0
- package/programs/arrowfield/logic.js +257 -0
- package/programs/arrowfield/object.js +66 -0
- package/programs/data2legend/density-to-legend.js +101 -0
- package/programs/data2legend/point-to-density-texture.js +100 -0
- package/programs/float2legendwithratio/index.js +8 -0
- package/programs/float2legendwithratio/logic.js +171 -0
- package/programs/float2legendwithratio/object.js +110 -0
- package/programs/globe-util/is-globe-moved.js +21 -0
- package/programs/globeshell/index.js +8 -0
- package/programs/globeshell/noise/noises.js +1 -0
- package/programs/globeshell/wiggle/index.js +8 -0
- package/programs/globeshell/wiggle/logic.js +345 -0
- package/programs/globeshell/wiggle/object.js +72 -0
- package/programs/helpers/blender/index.js +1 -0
- package/programs/helpers/blender/program.js +79 -0
- package/programs/helpers/fadeaway/index.js +7 -0
- package/programs/helpers/fadeaway/logic.js +72 -0
- package/programs/helpers/fadeaway/object.js +20 -0
- package/programs/helpers/index.js +8 -0
- package/programs/index.js +58 -0
- package/programs/interface.js +1 -0
- package/programs/line-on-globe/angled-line.js +176 -0
- package/programs/line-on-globe/circle-accurate-3d.js +141 -0
- package/programs/line-on-globe/circle-accurate-flat.js +216 -0
- package/programs/line-on-globe/circle-accurate.js +178 -0
- package/programs/line-on-globe/circle.js +167 -0
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +159 -0
- package/programs/line-on-globe/index.js +1 -0
- package/programs/line-on-globe/lines-color-instanced-flat.js +136 -0
- package/programs/line-on-globe/linestrip.js +171 -0
- package/programs/line-on-globe/naive-accurate-flexible.js +195 -0
- package/programs/line-on-globe/to-the-surface.js +111 -0
- package/programs/line-on-globe/util.js +8 -0
- package/programs/picking/pickable-renderer.js +188 -0
- package/programs/point-on-globe/element-globe-surface-glow.js +142 -0
- package/programs/point-on-globe/element-point-glow.js +153 -0
- package/programs/point-on-globe/square-pixel-point.js +174 -0
- package/programs/programcache.js +131 -0
- package/programs/rings/distancering/circleflatprogram.js +156 -0
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +369 -0
- package/programs/rings/distancering/circlepaddysharedbuffer.js +357 -0
- package/programs/rings/distancering/index.js +14 -0
- package/programs/rings/distancering/paddyflatprogram.js +172 -0
- package/programs/rings/distancering/paddyflatprogram2d.js +174 -0
- package/programs/rings/distancering/paddyflatprogram3d.js +172 -0
- package/programs/rings/distancering/shader.js +1 -0
- package/programs/rings/index.js +17 -0
- package/programs/rings/partial-ring/piece-of-pie.js +275 -0
- package/programs/totems/camerauniformblock.js +160 -0
- package/programs/totems/canvas-webglobe-info.js +110 -0
- package/programs/totems/gpu-selection-uniform-block.js +108 -0
- package/programs/totems/index.js +40 -0
- package/programs/two-d/pixel-circle.js +1 -0
- package/programs/two-d/pixel-padding-for-compass.js +162 -0
- package/programs/util.js +17 -0
- package/programs/vectorfields/index.js +23 -0
- package/programs/vectorfields/logics/drawrectangleparticles.js +107 -0
- package/programs/vectorfields/logics/index.js +12 -0
- package/programs/vectorfields/logics/pixelbased.js +142 -0
- package/programs/vectorfields/logics/ubo.js +63 -0
- package/programs/vectorfields/pingpongbuffermanager.js +76 -0
- package/rangerings/enum.js +5 -0
- package/rangerings/index.js +15 -0
- package/rangerings/plugin.js +560 -0
- package/rangerings/rangeringangletext.js +329 -0
- package/rangerings/ring-account.js +117 -0
- package/shaders/fragment-toy/firework.js +58 -0
- package/shaders/fragment-toy/singularity.js +59 -0
- package/shape-on-terrain/arc/naive/plugin.js +252 -0
- package/timetracks/adaptors-line-strip.js +71 -0
- package/timetracks/adaptors.js +122 -0
- package/timetracks/index.js +19 -0
- package/timetracks/plugin-line-strip.js +250 -0
- package/timetracks/plugin.js +258 -0
- package/timetracks/program-line-strip.js +611 -0
- package/timetracks/program.js +772 -0
- package/timetracks/programpoint-line-strip.js +154 -0
- package/timetracks/programpoint.js +147 -0
- package/types.js +15 -0
- package/util/account/bufferoffsetmanager.js +179 -0
- package/util/account/index.js +23 -0
- package/util/account/single-attribute-buffer-management/buffer-manager.js +108 -0
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +150 -0
- package/util/account/single-attribute-buffer-management/index.js +9 -0
- package/util/account/single-attribute-buffer-management/object-store.js +51 -0
- package/util/account/single-attribute-buffer-management/types.js +2 -0
- package/util/account/util.js +22 -0
- package/util/algorithms/index.js +1 -0
- package/util/algorithms/search-binary.js +28 -0
- package/util/check/get.js +18 -0
- package/util/check/index.js +1 -0
- package/util/check/typecheck.js +49 -0
- package/util/geometry/index.js +51 -0
- package/util/gl-util/buffer/attribute-loader.js +69 -0
- package/util/gl-util/buffer/index.js +6 -0
- package/util/gl-util/buffer/types.js +1 -0
- package/util/gl-util/draw-options/methods.js +38 -0
- package/util/gl-util/draw-options/types.js +15 -0
- package/util/gl-util/uniform-block/manager.js +156 -0
- package/util/gl-util/uniform-block/shader.js +1 -0
- package/util/gl-util/uniform-block/types.js +8 -0
- package/util/heatwavedatamanager/datamanager.js +152 -0
- package/util/heatwavedatamanager/index.js +10 -0
- package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +122 -0
- package/util/heatwavedatamanager/pointcoordsmeta.js +20 -0
- package/util/index.js +57 -0
- package/util/interpolation/index.js +1 -0
- package/util/interpolation/timetrack/index.js +5 -0
- package/util/interpolation/timetrack/timetrack-interpolator.js +79 -0
- package/util/interpolation/timetrack/web-worker-str.js +183 -0
- package/util/interpolation/timetrack/web-worker.js +48 -0
- package/util/jshelpers/data-filler.js +20 -0
- package/util/jshelpers/equality.js +20 -0
- package/util/jshelpers/index.js +37 -0
- package/util/jshelpers/timefilters.js +32 -0
- package/util/picking/fence.js +46 -0
- package/util/picking/picker-displayer.js +139 -0
- package/util/programs/draw-texture-on-canvas.js +89 -0
- package/util/programs/index.js +17 -0
- package/util/programs/shapesonglobe.js +214 -0
- package/util/programs/supersampletotextures.js +113 -0
- package/util/programs/texturetoglobe.js +182 -0
- package/util/shaderfunctions/geometrytransformations.js +340 -0
- package/util/shaderfunctions/index.js +18 -0
- package/util/shaderfunctions/nodata.js +11 -0
- package/util/shaderfunctions/noisefunctions.js +43 -0
- package/util/surface-line-data/arc-bboxes.js +25 -0
- package/util/surface-line-data/arcs-to-cuts.js +50 -0
- package/util/surface-line-data/cut-arc.js +1 -0
- package/util/surface-line-data/flow.js +28 -0
- package/util/surface-line-data/rbush-manager.js +1 -0
- package/util/surface-line-data/types.js +1 -0
- package/util/surface-line-data/web-worker.js +1 -0
- package/util/webglobe/gldefaultstates.js +7 -0
- package/util/webglobe/index.js +18 -0
- package/util/webglobe/rasteroverlay.js +78 -0
- package/util/webglobjectbuilders.js +388 -0
- package/util/webglobjectbuilders1.js +237 -0
- package/waveparticles/adaptor.js +17 -0
- package/waveparticles/index.js +10 -0
- package/waveparticles/plugin.js +266 -0
- package/wind/imagetovectorfieldandmagnitude.js +35 -0
- package/wind/index.js +14 -0
- package/wind/plugin.js +926 -0
- package/wind/vectorfieldimage.js +25 -0
- package/write-text/attached-text-writer.js +91 -0
- package/write-text/context-text.js +98 -0
- package/write-text/context-text3.js +155 -0
- package/write-text/index.js +5 -0
- package/write-text/writer-plugin.js +8 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function getVectorField(u, v, width, height, vMin, vMax, uMin, uMax, flip) {
|
|
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
|
+
if (u[k] === null || v[k] === null || isNaN(u[k]) || !isFinite(u[k]) || isNaN(v[k]) || !isFinite(v[k])) {
|
|
10
|
+
data[idx] = 0; // R
|
|
11
|
+
data[idx + 1] = 0; // G
|
|
12
|
+
data[idx + 2] = 0; // B
|
|
13
|
+
data[idx + 3] = 0; // A
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
data[idx] = Math.floor(255 * (u[k] - uMin) / (uMax - uMin)); // R
|
|
17
|
+
data[idx + 1] = Math.floor(255 * (v[k] - vMin) / (vMax - vMin)); // G
|
|
18
|
+
data[idx + 2] = 0; // B
|
|
19
|
+
data[idx + 3] = 255; // A
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return data;
|
|
24
|
+
}
|
|
25
|
+
exports.default = getVectorField;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AttachedTextWriter = void 0;
|
|
4
|
+
const webglobe_1 = require("@pirireis/webglobe");
|
|
5
|
+
const typecheck_1 = require("../util/check/typecheck");
|
|
6
|
+
/**
|
|
7
|
+
* Light wight version of context text writer.
|
|
8
|
+
* The parameters by text are calculated on user side and inserted as items. (ContextTextWriter3 constructs text data from items)
|
|
9
|
+
*
|
|
10
|
+
* Good side of ContextTextWriters pattern is that there is only one way to create text.
|
|
11
|
+
* The glue is inside the plugin.
|
|
12
|
+
* This makes the code more readable and maintainable.
|
|
13
|
+
*
|
|
14
|
+
* With AttachedTextWriter the glue is created by user.
|
|
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
|
+
*/
|
|
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
|
+
}, } = {}) {
|
|
36
|
+
this.globe = globe;
|
|
37
|
+
this._itemMap = new Map();
|
|
38
|
+
this.doDraw = doDraw;
|
|
39
|
+
this.angleOnSphere = angleOnSphere;
|
|
40
|
+
this.zoomLevelAdaptor = zoomLevelAdaptor;
|
|
41
|
+
this.setStyle(style);
|
|
42
|
+
}
|
|
43
|
+
setOpacity(opacity) {
|
|
44
|
+
(0, typecheck_1.opacityCheck)(opacity);
|
|
45
|
+
this._style.opacity = opacity;
|
|
46
|
+
this.globe.DrawRender();
|
|
47
|
+
}
|
|
48
|
+
setStyle(style) {
|
|
49
|
+
(0, typecheck_1.isTextFont)(style.textFont);
|
|
50
|
+
this._style = style;
|
|
51
|
+
this.globe.DrawRender();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @param {{text, long, lat, z = 0, xOffset = 0, yOffset = 0, isAngleOn = false, Angle = 0 }} item
|
|
56
|
+
* @returns
|
|
57
|
+
*/
|
|
58
|
+
insertItem(item) {
|
|
59
|
+
const key = this.keyAdaptor ? this.keyAdaptor(item) : item;
|
|
60
|
+
this._itemMap.set(key, item);
|
|
61
|
+
this.globe.DrawRender();
|
|
62
|
+
}
|
|
63
|
+
// TODO: use item style
|
|
64
|
+
draw() {
|
|
65
|
+
if (!this.doDraw) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
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);
|
|
83
|
+
textFont.size = sizeMultiplier * theSize;
|
|
84
|
+
if (x !== null && y !== null) {
|
|
85
|
+
globe.api_DrawContextText(text, textFont, opacityMultiplier * opacity, { x: x + xOffset, y: y - yOffset }, (isAngleOn && angleIsOn), angle);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
textFont.size = theSize;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.AttachedTextWriter = AttachedTextWriter;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContextTextWriter = void 0;
|
|
4
|
+
const webglobe_1 = require("@pirireis/webglobe");
|
|
5
|
+
const defaultStyle = {
|
|
6
|
+
textFont: {
|
|
7
|
+
name: 'Arial',
|
|
8
|
+
textColor: '#FFFFFF', // beyaz
|
|
9
|
+
hollowColor: '#000000', // siyah
|
|
10
|
+
size: 12, // piksel
|
|
11
|
+
hollow: true,
|
|
12
|
+
bold: true,
|
|
13
|
+
italic: false,
|
|
14
|
+
},
|
|
15
|
+
opacity: 1.0,
|
|
16
|
+
zMode: webglobe_1.CSZMode.Z_GROUND_PERVERTEX,
|
|
17
|
+
};
|
|
18
|
+
class ContextTextWriter {
|
|
19
|
+
constructor(globe, { style = null, doDraw = true } = {}) {
|
|
20
|
+
this.globe = globe;
|
|
21
|
+
this.itemMap = new Map();
|
|
22
|
+
this.style = style || defaultStyle;
|
|
23
|
+
this.doDraw = doDraw;
|
|
24
|
+
}
|
|
25
|
+
setDoDraw(bool) {
|
|
26
|
+
this.doDraw = bool;
|
|
27
|
+
}
|
|
28
|
+
setStyle(style) {
|
|
29
|
+
this.style = style;
|
|
30
|
+
}
|
|
31
|
+
setOpacity(opacity) {
|
|
32
|
+
this.style.opacity = opacity;
|
|
33
|
+
}
|
|
34
|
+
// Clean this ask Front dev
|
|
35
|
+
doDraw(boolean) {
|
|
36
|
+
this.doDraw = boolean;
|
|
37
|
+
}
|
|
38
|
+
draw() {
|
|
39
|
+
if (!this.doDraw)
|
|
40
|
+
return;
|
|
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({
|
|
45
|
+
long: long,
|
|
46
|
+
lat: lat,
|
|
47
|
+
z: 0,
|
|
48
|
+
}, style.zMode === webglobe_1.CSZMode.Z_MSL);
|
|
49
|
+
const o = opacity === null ? opacity_ : opacity * opacity_;
|
|
50
|
+
if (x !== null && y !== null)
|
|
51
|
+
globe.api_DrawContextTextMultiLine(text, textFont, o, { x, y });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
insertText(key, lat, long, text) {
|
|
55
|
+
this.itemMap.set(key, { lat, long, text });
|
|
56
|
+
}
|
|
57
|
+
updateOpacityOfItem(key, opacity) {
|
|
58
|
+
this.itemMap.get(key).opacity = opacity;
|
|
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);
|
|
65
|
+
data.opacity = opacity;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
updateText(key, text) {
|
|
69
|
+
const item = this.itemMap.get(key);
|
|
70
|
+
item.text = text;
|
|
71
|
+
}
|
|
72
|
+
updateCoords(key, lat, long) {
|
|
73
|
+
const item = this.itemMap.get(key);
|
|
74
|
+
item.lat = lat;
|
|
75
|
+
item.long = long;
|
|
76
|
+
}
|
|
77
|
+
insertTextBulk(items) {
|
|
78
|
+
for (const item of items) {
|
|
79
|
+
this.itemMap.set(item.key, item);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
updateTextCoordsBulk(items) {
|
|
83
|
+
for (const { key, lat, long } of items) {
|
|
84
|
+
const item = this.itemMap.get(key);
|
|
85
|
+
item.lat = lat;
|
|
86
|
+
item.long = long;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
deleteTextBulk(keys) {
|
|
90
|
+
for (const key of keys) {
|
|
91
|
+
this.itemMap.delete(key);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
clear() {
|
|
95
|
+
this.itemMap.clear();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.ContextTextWriter = ContextTextWriter;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContextTextWriter3 = void 0;
|
|
4
|
+
const webglobe_1 = require("@pirireis/webglobe");
|
|
5
|
+
const typecheck_1 = require("../util/check/typecheck");
|
|
6
|
+
/**
|
|
7
|
+
* TODOs:
|
|
8
|
+
* 1) update all if initials change (propably need a context and a callback to iterate over zPayload)
|
|
9
|
+
* 2) expose a mechanic to update text on zoom change
|
|
10
|
+
* 3) extend the mechanic on 2 to other events
|
|
11
|
+
*
|
|
12
|
+
* TODO: key check and raise error if doesnt exist
|
|
13
|
+
*/
|
|
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
|
+
} } = {}) {
|
|
33
|
+
this.globe = globe;
|
|
34
|
+
this.itemMap = new Map();
|
|
35
|
+
this.setStyle(style);
|
|
36
|
+
this.doDraw = doDraw;
|
|
37
|
+
this._checkParameterTypes(textAdaptor, coordinatesAdaptor, keyAdaptor, opacityAdaptor, angleAdaptor, xOffset, yOffset);
|
|
38
|
+
this.textAdaptor = textAdaptor;
|
|
39
|
+
this.coordinatesAdaptor = coordinatesAdaptor;
|
|
40
|
+
this.keyAdaptor = keyAdaptor;
|
|
41
|
+
this.zoomLevelAdaptor = zoomLevelAdaptor;
|
|
42
|
+
this.positionAdaptor = positionAdaptor;
|
|
43
|
+
this.opacityAdaptor = opacityAdaptor ? opacityAdaptor : () => 1;
|
|
44
|
+
this.angleOnSphere = angleOnSphere;
|
|
45
|
+
if (angleAdaptor) {
|
|
46
|
+
this.angleAdaptor = angleAdaptor;
|
|
47
|
+
this.angleAdaptorIsOn = true;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this.angleAdaptor = () => null;
|
|
51
|
+
this.angleAdaptorIsOn = false;
|
|
52
|
+
}
|
|
53
|
+
this.xOffset = xOffset;
|
|
54
|
+
this.yOffset = yOffset;
|
|
55
|
+
}
|
|
56
|
+
_checkParameterTypes(textAdaptor, coordinatesAdaptor, keyAdaptor, opacityAdaptor, angleAdaptor, xOffset, yOffset) {
|
|
57
|
+
if (textAdaptor !== null)
|
|
58
|
+
if (!(textAdaptor instanceof Function))
|
|
59
|
+
throw new Error("textAdaptor is not an instance of a Function");
|
|
60
|
+
if (coordinatesAdaptor !== null)
|
|
61
|
+
if (!(coordinatesAdaptor instanceof Function))
|
|
62
|
+
throw new Error("coordinatesAdaptor is not an instance of a Function");
|
|
63
|
+
if (keyAdaptor !== null)
|
|
64
|
+
if (!(keyAdaptor instanceof Function))
|
|
65
|
+
throw new Error("keyAdaptor is not an instance of a Function");
|
|
66
|
+
if (opacityAdaptor !== null)
|
|
67
|
+
if (!(opacityAdaptor instanceof Function))
|
|
68
|
+
throw new Error("opacityAdaptor is not an instance of a Function");
|
|
69
|
+
if (angleAdaptor !== null)
|
|
70
|
+
if (!(angleAdaptor instanceof Function))
|
|
71
|
+
throw new Error("angleAdaptor is not an instance of a Function");
|
|
72
|
+
if (typeof xOffset !== "number")
|
|
73
|
+
throw new Error("xOffset type is not a number");
|
|
74
|
+
if (typeof yOffset !== "number")
|
|
75
|
+
throw new Error("yOffset type is not a number");
|
|
76
|
+
}
|
|
77
|
+
setKeyAdaptor(adaptor) {
|
|
78
|
+
this.keyAdaptor = adaptor;
|
|
79
|
+
}
|
|
80
|
+
setDoDraw(bool) {
|
|
81
|
+
this.doDraw = bool;
|
|
82
|
+
this.globe.DrawRender();
|
|
83
|
+
}
|
|
84
|
+
setStyle(style) {
|
|
85
|
+
(0, typecheck_1.isTextFont)(style.textFont);
|
|
86
|
+
(0, typecheck_1.opacityCheck)(style.opacity); //TODO: use shallow copy
|
|
87
|
+
this.style = style;
|
|
88
|
+
this.globe.DrawRender();
|
|
89
|
+
}
|
|
90
|
+
setOpacity(opacity) {
|
|
91
|
+
this.style.opacity = opacity;
|
|
92
|
+
this.globe.DrawRender();
|
|
93
|
+
}
|
|
94
|
+
draw() {
|
|
95
|
+
if (!this.doDraw)
|
|
96
|
+
return;
|
|
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({
|
|
107
|
+
long: long,
|
|
108
|
+
lat: lat,
|
|
109
|
+
z: 0,
|
|
110
|
+
}, style.zMode === webglobe_1.CSZMode.Z_MSL);
|
|
111
|
+
const { opacityMultiplier, sizeMultiplier } = zoomAdaptor(zPayload);
|
|
112
|
+
const o = (opacity === null ? opacity_ : opacity * opacity_) * opacityMultiplier;
|
|
113
|
+
textFont.size = sizeMultiplier * textSize;
|
|
114
|
+
textFont.position = position;
|
|
115
|
+
if (x !== null && y !== null)
|
|
116
|
+
globe.api_DrawContextTextMultiLine(text, textFont, o, { x: x + xOffset, y: y - yOffset }, angleIsOn, angle);
|
|
117
|
+
}
|
|
118
|
+
textFont.size = textSize;
|
|
119
|
+
}
|
|
120
|
+
insertTextBulk(container, properties) {
|
|
121
|
+
container.forEach((v, i, c) => {
|
|
122
|
+
this.insertText(v, i, c, properties);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
deleteTextBulk(keys) {
|
|
126
|
+
for (const key of keys) {
|
|
127
|
+
this.itemMap.delete(key);
|
|
128
|
+
}
|
|
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);
|
|
133
|
+
if (coords == null) {
|
|
134
|
+
this.itemMap.delete(key);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const text = this.textAdaptor(item, id, container, properties);
|
|
138
|
+
if (text == null) {
|
|
139
|
+
this.itemMap.delete(key);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
;
|
|
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() {
|
|
149
|
+
this.itemMap.clear();
|
|
150
|
+
}
|
|
151
|
+
free() {
|
|
152
|
+
this.itemMap = null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.ContextTextWriter3 = ContextTextWriter3;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContextTextWriter = void 0;
|
|
4
|
+
var context_text_1 = require("./context-text");
|
|
5
|
+
Object.defineProperty(exports, "ContextTextWriter", { enumerable: true, get: function () { return context_text_1.ContextTextWriter; } });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* registerMap(id, aMap, textFont)
|
|
4
|
+
* aMap key, object map.
|
|
5
|
+
* aMap is a specifical tem for a use case.
|
|
6
|
+
* The object has { text, long, lat, opacity, angle, zPayload, achor, xOffset, yOffset, ...extraPropertiesForZoomLevelAdaptor } properties.
|
|
7
|
+
* the plugin runs over items in aMap and draw text on the globe.
|
|
8
|
+
*/
|