@pirireis/webglobeplugins 0.9.11 → 0.9.13

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.
Files changed (179) hide show
  1. package/Math/angle-calculation.js +9 -11
  2. package/Math/arc.js +38 -41
  3. package/Math/bounds/line-bbox.js +79 -83
  4. package/Math/constants.js +4 -9
  5. package/Math/frustum/types.js +1 -2
  6. package/Math/juction/arc-plane.js +33 -36
  7. package/Math/juction/line-sphere.js +15 -18
  8. package/Math/juction/plane-plane.js +20 -23
  9. package/Math/line.js +42 -47
  10. package/Math/methods.js +69 -92
  11. package/Math/plane.js +33 -38
  12. package/Math/quaternion.js +48 -55
  13. package/Math/types.js +1 -2
  14. package/Math/utils.js +2 -4
  15. package/Math/vec3.js +46 -52
  16. package/algorithms/search-binary.js +5 -8
  17. package/altitude-locator/draw-subset-obj.js +8 -11
  18. package/altitude-locator/plugin.js +114 -133
  19. package/altitude-locator/types.js +1 -3
  20. package/arrowfield/adaptor.js +3 -7
  21. package/arrowfield/index.js +3 -10
  22. package/arrowfield/plugin.js +63 -69
  23. package/bearing-line/index.js +2 -8
  24. package/bearing-line/plugin.js +218 -248
  25. package/circle-line-chain/chain-list-map.js +82 -92
  26. package/circle-line-chain/plugin.js +147 -182
  27. package/circle-line-chain/util.js +1 -5
  28. package/compass-rose/compass-rose-padding-flat.js +111 -140
  29. package/compass-rose/compass-text-writer.js +63 -75
  30. package/compass-rose/index.js +3 -7
  31. package/compassrose/compassrose.js +50 -57
  32. package/compassrose/index.js +2 -8
  33. package/heatwave/index.js +3 -10
  34. package/heatwave/isobar/objectarraylabels.js +50 -56
  35. package/heatwave/isobar/plugin.js +111 -170
  36. package/heatwave/isobar/quadtreecontours.js +78 -96
  37. package/heatwave/plugins/heatwaveglobeshell.js +73 -94
  38. package/index.js +12 -58
  39. package/package.json +1 -1
  40. package/partialrings/buffer-manager.js +32 -70
  41. package/partialrings/index.js +2 -41
  42. package/partialrings/plugin.js +55 -98
  43. package/partialrings/program.js +141 -59
  44. package/pin/pin-object-array.js +89 -97
  45. package/pin/pin-point-totem.js +21 -22
  46. package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +11 -14
  47. package/point-heat-map/plugin-webworker.js +45 -53
  48. package/point-heat-map/point-to-heat-map-flow.js +46 -51
  49. package/point-tracks/key-methods.js +2 -5
  50. package/point-tracks/plugin.js +141 -170
  51. package/programs/arrowfield/index.js +2 -7
  52. package/programs/arrowfield/logic.js +172 -67
  53. package/programs/arrowfield/object.js +35 -43
  54. package/programs/data2legend/density-to-legend.js +47 -26
  55. package/programs/data2legend/point-to-density-texture.js +56 -34
  56. package/programs/float2legendwithratio/index.js +2 -8
  57. package/programs/float2legendwithratio/logic.js +88 -45
  58. package/programs/float2legendwithratio/object.js +45 -54
  59. package/programs/globe-util/is-globe-moved.js +10 -13
  60. package/programs/globeshell/index.js +2 -8
  61. package/programs/globeshell/wiggle/index.js +2 -8
  62. package/programs/globeshell/wiggle/logic.js +191 -101
  63. package/programs/globeshell/wiggle/object.js +35 -43
  64. package/programs/helpers/blender/program.js +36 -22
  65. package/programs/helpers/fadeaway/index.js +2 -7
  66. package/programs/helpers/fadeaway/logic.js +36 -17
  67. package/programs/helpers/fadeaway/object.js +11 -18
  68. package/programs/helpers/index.js +2 -8
  69. package/programs/index.js +9 -58
  70. package/programs/line-on-globe/angled-line.js +95 -39
  71. package/programs/line-on-globe/circle-accurate-3d.js +86 -39
  72. package/programs/line-on-globe/circle-accurate-flat.js +116 -64
  73. package/programs/line-on-globe/circle-accurate.js +113 -46
  74. package/programs/line-on-globe/circle.js +106 -44
  75. package/programs/line-on-globe/degree-padding-around-circle-3d.js +89 -42
  76. package/programs/line-on-globe/lines-color-instanced-flat.js +84 -43
  77. package/programs/line-on-globe/linestrip.js +126 -63
  78. package/programs/line-on-globe/naive-accurate-flexible.js +126 -59
  79. package/programs/line-on-globe/to-the-surface.js +62 -35
  80. package/programs/line-on-globe/util.js +2 -5
  81. package/programs/picking/pickable-renderer.js +127 -46
  82. package/programs/point-on-globe/element-globe-surface-glow.js +83 -46
  83. package/programs/point-on-globe/element-point-glow.js +112 -47
  84. package/programs/point-on-globe/square-pixel-point.js +80 -34
  85. package/programs/programcache.js +14 -19
  86. package/programs/rings/distancering/circleflatprogram.js +76 -70
  87. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +168 -194
  88. package/programs/rings/distancering/circlepaddysharedbuffer.js +121 -200
  89. package/programs/rings/distancering/index.js +5 -14
  90. package/programs/rings/distancering/paddyflatprogram.js +87 -70
  91. package/programs/rings/distancering/paddyflatprogram2d.js +89 -72
  92. package/programs/rings/distancering/paddyflatprogram3d.js +87 -70
  93. package/programs/rings/index.js +1 -17
  94. package/programs/rings/partial-ring/piece-of-pie.js +144 -44
  95. package/programs/totems/camerauniformblock.js +65 -56
  96. package/programs/totems/canvas-webglobe-info.js +49 -45
  97. package/programs/totems/gpu-selection-uniform-block.js +45 -45
  98. package/programs/totems/index.js +2 -40
  99. package/programs/two-d/pixel-padding-for-compass.js +94 -36
  100. package/programs/util.js +7 -10
  101. package/programs/vectorfields/index.js +3 -23
  102. package/programs/vectorfields/logics/drawrectangleparticles.js +73 -35
  103. package/programs/vectorfields/logics/index.js +4 -12
  104. package/programs/vectorfields/logics/pixelbased.js +94 -41
  105. package/programs/vectorfields/logics/ubo.js +32 -32
  106. package/programs/vectorfields/pingpongbuffermanager.js +30 -37
  107. package/rangerings/enum.js +2 -5
  108. package/rangerings/index.js +5 -15
  109. package/rangerings/plugin.js +223 -286
  110. package/rangerings/rangeringangletext.js +122 -137
  111. package/rangerings/ring-account.js +53 -75
  112. package/shaders/fragment-toy/firework.js +55 -4
  113. package/shaders/fragment-toy/singularity.js +56 -5
  114. package/timetracks/adaptors-line-strip.js +27 -44
  115. package/timetracks/adaptors.js +48 -67
  116. package/timetracks/index.js +5 -19
  117. package/timetracks/plugin-line-strip.js +65 -79
  118. package/timetracks/plugin.js +71 -85
  119. package/timetracks/program-line-strip.js +297 -107
  120. package/timetracks/program.js +421 -118
  121. package/timetracks/programpoint-line-strip.js +98 -48
  122. package/timetracks/programpoint.js +91 -48
  123. package/util/account/bufferoffsetmanager.js +72 -98
  124. package/util/account/index.js +3 -23
  125. package/util/account/single-attribute-buffer-management/buffer-manager.js +44 -48
  126. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +68 -98
  127. package/util/account/single-attribute-buffer-management/index.js +4 -9
  128. package/util/account/single-attribute-buffer-management/object-store.js +29 -34
  129. package/util/account/single-attribute-buffer-management/types.js +1 -2
  130. package/util/account/util.js +2 -8
  131. package/util/algorithms/search-binary.js +5 -8
  132. package/util/check/get.js +5 -9
  133. package/util/check/typecheck.js +13 -24
  134. package/util/geometry/index.js +10 -18
  135. package/util/gl-util/buffer/attribute-loader.js +10 -26
  136. package/util/gl-util/buffer/index.js +2 -5
  137. package/util/gl-util/draw-options/methods.js +10 -15
  138. package/util/gl-util/uniform-block/manager.js +69 -72
  139. package/util/heatwavedatamanager/datamanager.js +56 -119
  140. package/util/heatwavedatamanager/index.js +3 -10
  141. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +38 -47
  142. package/util/heatwavedatamanager/pointcoordsmeta.js +9 -13
  143. package/util/index.js +13 -57
  144. package/util/interpolation/timetrack/index.js +2 -5
  145. package/util/interpolation/timetrack/timetrack-interpolator.js +30 -36
  146. package/util/interpolation/timetrack/web-worker-str.js +180 -5
  147. package/util/interpolation/timetrack/web-worker.js +4 -6
  148. package/util/jshelpers/data-filler.js +8 -11
  149. package/util/jshelpers/equality.js +1 -3
  150. package/util/jshelpers/index.js +2 -37
  151. package/util/jshelpers/timefilters.js +8 -10
  152. package/util/picking/fence.js +8 -11
  153. package/util/picking/picker-displayer.js +49 -58
  154. package/util/programs/draw-texture-on-canvas.js +41 -26
  155. package/util/programs/index.js +1 -17
  156. package/util/programs/shapesonglobe.js +104 -68
  157. package/util/programs/supersampletotextures.js +45 -43
  158. package/util/programs/texturetoglobe.js +99 -52
  159. package/util/shaderfunctions/geometrytransformations.js +323 -35
  160. package/util/shaderfunctions/index.js +2 -18
  161. package/util/shaderfunctions/nodata.js +8 -5
  162. package/util/shaderfunctions/noisefunctions.js +40 -12
  163. package/util/surface-line-data/arcs-to-cuts.js +20 -23
  164. package/util/webglobe/gldefaultstates.js +1 -4
  165. package/util/webglobe/index.js +2 -18
  166. package/util/webglobe/rasteroverlay.js +36 -41
  167. package/util/webglobjectbuilders.js +70 -93
  168. package/util/webglobjectbuilders1.js +63 -82
  169. package/waveparticles/adaptor.js +7 -10
  170. package/waveparticles/index.js +3 -10
  171. package/waveparticles/plugin.js +82 -90
  172. package/wind/imagetovectorfieldandmagnitude.js +16 -19
  173. package/wind/index.js +5 -14
  174. package/wind/plugin.js +454 -291
  175. package/wind/vectorfieldimage.js +6 -8
  176. package/write-text/attached-text-writer.js +48 -54
  177. package/write-text/context-text.js +52 -63
  178. package/write-text/context-text3.js +71 -80
  179. package/write-text/index.js +1 -5
@@ -1,54 +1,39 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.PixelPaddingCompassPlugin = void 0;
15
- var pixel_padding_for_compass_1 = require("../programs/two-d/pixel-padding-for-compass");
16
- var account_1 = require("../util/account");
17
- var compass_text_writer_1 = require("./compass-text-writer");
18
- var PaddingAngle = 30;
19
- var textGapFit = 10;
20
- var PixelPaddingCompassPlugin = /** @class */ (function () {
21
- function PixelPaddingCompassPlugin(id, _a) {
22
- var _b = _a === void 0 ? {} : _a, _c = _b.opacity, opacity = _c === void 0 ? 1 : _c, _d = _b.textAngleOn, textAngleOn = _d === void 0 ? true : _d, _e = _b.defaultProperties, defaultProperties = _e === void 0 ? {
23
- rgba: [1, 1, 1, 1],
24
- pixelRadiusRatioBig: 0.8,
25
- pixelRadiusRatioSmall: 0.6,
26
- } : _e, _f = _b.font, font = _f === void 0 ? {
27
- name: 'Arial',
28
- textColor: '#FFFFFF',
29
- hollowColor: '#000000',
30
- size: 12, // piksel
31
- hollow: true,
32
- bold: true,
33
- italic: false,
34
- } : _f, _g = _b.northFont, northFont = _g === void 0 ? {
35
- name: 'Arial',
36
- textColor: '#BBAA00',
37
- hollowColor: '#000000',
38
- size: 14, // piksel
39
- hollow: true,
40
- bold: true,
41
- italic: false,
42
- } : _g;
1
+ import { PixelPaddingForFlatCompassCache } from "../programs/two-d/pixel-padding-for-compass";
2
+ import { BufferManager, BufferOrchestrator } from "../util/account";
3
+ import { PixelPaddingCompassTextWriter } from "./compass-text-writer";
4
+ const PaddingAngle = 30;
5
+ const textGapFit = 10;
6
+ export class PixelPaddingCompassPlugin {
7
+ constructor(id, { opacity = 1, textAngleOn = true, defaultProperties = {
8
+ rgba: [1, 1, 1, 1],
9
+ pixelRadiusRatioBig: 0.8,
10
+ pixelRadiusRatioSmall: 0.6,
11
+ }, font = {
12
+ name: 'Arial',
13
+ textColor: '#FFFFFF',
14
+ hollowColor: '#000000',
15
+ size: 12, // piksel
16
+ hollow: true,
17
+ bold: true,
18
+ italic: false,
19
+ }, northFont = {
20
+ name: 'Arial',
21
+ textColor: '#BBAA00',
22
+ hollowColor: '#000000',
23
+ size: 14, // piksel
24
+ hollow: true,
25
+ bold: true,
26
+ italic: false,
27
+ } } = {}) {
43
28
  this.id = id;
44
29
  this.textAngleOn = textAngleOn;
45
30
  this.defaultProperties = defaultProperties;
46
- this.bufferOrchestrator = new account_1.BufferOrchestrator({ capacity: 10 });
47
- this._font_hold = { font: font, northFont: northFont };
31
+ this.bufferOrchestrator = new BufferOrchestrator({ capacity: 10 });
32
+ this._font_hold = { font, northFont };
48
33
  this.compassMap = new CompassMap(this);
49
34
  this._opacity = opacity;
50
35
  }
51
- PixelPaddingCompassPlugin.prototype.init = function (globe, gl) {
36
+ init(globe, gl) {
52
37
  this.globe = globe;
53
38
  this.resize();
54
39
  this.gl = gl;
@@ -56,7 +41,7 @@ var PixelPaddingCompassPlugin = /** @class */ (function () {
56
41
  this._createTextWriter();
57
42
  }
58
43
  this._initOrchestrations();
59
- };
44
+ }
60
45
  /**
61
46
  * @param {string} key
62
47
  * @param {number} long
@@ -66,83 +51,76 @@ var PixelPaddingCompassPlugin = /** @class */ (function () {
66
51
  * @property {number} pixelRadiusRatioSmall
67
52
  * @property {[4 numbers between 0-1]} rgba
68
53
  */
69
- PixelPaddingCompassPlugin.prototype.insert = function (key, long, lat, properties) {
70
- if (properties === void 0) { properties = null; }
71
- this.__insertText(key, null, null, { properties: properties, update: true });
54
+ insert(key, long, lat, properties = null) {
55
+ this.__insertText(key, null, null, { properties, update: true });
72
56
  this.compassMap.insert(key, long, lat, properties);
73
57
  this.globe.DrawRender();
74
- };
58
+ }
75
59
  /**
76
60
  *
77
61
  * @param {string} key
78
62
  */
79
- PixelPaddingCompassPlugin.prototype.delete = function (key) {
63
+ delete(key) {
80
64
  this.compassMap.delete(key);
81
65
  this.globe.DrawRender();
82
- };
83
- PixelPaddingCompassPlugin.prototype.setFont = function (_a) {
84
- var _b = _a === void 0 ? {} : _a, _c = _b.textFont, textFont = _c === void 0 ? null : _c, _d = _b.northFont, northFont = _d === void 0 ? null : _d;
66
+ }
67
+ setFont({ textFont = null, northFont = null } = {}) {
85
68
  if (textFont)
86
69
  this.writer.setFont(textFont);
87
70
  if (northFont)
88
71
  this.writer.setNorthFont(northFont);
89
72
  this.globe.DrawRender();
90
- };
91
- PixelPaddingCompassPlugin.prototype.setOpacity = function (opacity) {
92
- var _a;
73
+ }
74
+ setOpacity(opacity) {
93
75
  this._opacity = opacity;
94
- (_a = this.writer) === null || _a === void 0 ? void 0 : _a.setOpacity(opacity);
76
+ this.writer?.setOpacity(opacity);
95
77
  this.globe.DrawRender();
96
- };
97
- PixelPaddingCompassPlugin.prototype.getTextWriter = function () {
78
+ }
79
+ getTextWriter() {
98
80
  return this.writer;
99
- };
100
- PixelPaddingCompassPlugin.prototype._initOrchestrations = function () {
101
- var _a;
102
- var _this = this;
103
- var _b = this, gl = _b.gl, globe = _b.globe;
104
- this.paddingProgram = pixel_padding_for_compass_1.PixelPaddingForFlatCompassCache.get(globe);
81
+ }
82
+ _initOrchestrations() {
83
+ const { gl, globe } = this;
84
+ this.paddingProgram = PixelPaddingForFlatCompassCache.get(globe);
105
85
  {
106
86
  // createBuffers
107
- var bufferType = "DYNAMIC_DRAW";
108
- var initialCapacity = this.bufferOrchestrator.capacity;
87
+ const bufferType = "DYNAMIC_DRAW";
88
+ const initialCapacity = this.bufferOrchestrator.capacity;
109
89
  this.bufferManagersCompMap = new Map([
110
90
  ["screenCoordinates", {
111
- 'bufferManager': new account_1.BufferManager(gl, 2, { bufferType: bufferType, initialCapacity: initialCapacity }),
112
- 'adaptor': function (item) { return new Float32Array([item.x, item.y]); }
91
+ 'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
92
+ 'adaptor': (item) => new Float32Array([item.x, item.y])
113
93
  }],
114
94
  ["pixelRadiusRatioSmall", {
115
- 'bufferManager': new account_1.BufferManager(gl, 1, { bufferType: bufferType, initialCapacity: initialCapacity }),
116
- 'adaptor': function (item) { return new Float32Array([item.properties.pixelRadiusRatioSmall]); }
95
+ 'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
96
+ 'adaptor': (item) => new Float32Array([item.properties.pixelRadiusRatioSmall])
117
97
  }],
118
98
  ["pixelRadiusRatioBig", {
119
- 'bufferManager': new account_1.BufferManager(gl, 1, { bufferType: bufferType, initialCapacity: initialCapacity }),
120
- 'adaptor': function (item) { return new Float32Array([item.properties.pixelRadiusRatioBig]); }
99
+ 'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
100
+ 'adaptor': (item) => new Float32Array([item.properties.pixelRadiusRatioBig])
121
101
  }],
122
102
  ["rgba", {
123
- 'bufferManager': new account_1.BufferManager(gl, 4, { bufferType: bufferType, initialCapacity: initialCapacity }),
124
- 'adaptor': function (item) { return new Float32Array(item.properties.rgba); }
103
+ 'bufferManager': new BufferManager(gl, 4, { bufferType, initialCapacity }),
104
+ 'adaptor': (item) => new Float32Array(item.properties.rgba)
125
105
  }],
126
106
  ]);
127
- var obj_1 = function (bufferManagerComp) {
107
+ const obj = function (bufferManagerComp) {
128
108
  return { 'buffer': bufferManagerComp.bufferManager.buffer, 'stride': 0, 'offset': 0 };
129
109
  };
130
- this.paddingVao = (_a = this.paddingProgram).createVAO.apply(_a, ['screenCoordinates', 'pixelRadiusRatioSmall', 'pixelRadiusRatioBig', 'rgba'].map(function (key) { return obj_1(_this.bufferManagersCompMap.get(key)); }));
110
+ this.paddingVao = this.paddingProgram.createVAO(...['screenCoordinates', 'pixelRadiusRatioSmall', 'pixelRadiusRatioBig', 'rgba'].map(key => obj(this.bufferManagersCompMap.get(key))));
131
111
  }
132
- };
133
- PixelPaddingCompassPlugin.prototype._createTextWriter = function () {
134
- this.writer = new compass_text_writer_1.PixelPaddingCompassTextWriter(this.globe, __assign({ angle: PaddingAngle }, this._font_hold));
135
- };
136
- PixelPaddingCompassPlugin.prototype.resize = function () {
137
- var _a;
138
- (_a = this.writer) === null || _a === void 0 ? void 0 : _a.resize();
139
- };
140
- PixelPaddingCompassPlugin.prototype.__insertText = function (key, x, y, _a) {
141
- var _b = _a === void 0 ? {} : _a, properties = _b.properties, _c = _b.update, update = _c === void 0 ? false : _c;
112
+ }
113
+ _createTextWriter() {
114
+ this.writer = new PixelPaddingCompassTextWriter(this.globe, { angle: PaddingAngle, ...this._font_hold });
115
+ }
116
+ resize() {
117
+ this.writer?.resize();
118
+ }
119
+ __insertText(key, x, y, { properties, update = false } = {}) {
142
120
  if (!this.writer)
143
121
  return;
144
122
  if (update) {
145
- var radius = void 0;
123
+ let radius;
146
124
  if (properties != null && properties.pixelRadiusRatioBig) {
147
125
  radius = properties.pixelRadiusRatioBig * this.radiusMultiplier;
148
126
  }
@@ -154,94 +132,87 @@ var PixelPaddingCompassPlugin = /** @class */ (function () {
154
132
  else {
155
133
  this.writer.insertTextItem(key, x, y);
156
134
  }
157
- };
135
+ }
158
136
  // Globe API interface methods
159
- PixelPaddingCompassPlugin.prototype.draw2D = function () {
160
- var _this = this;
161
- var _a;
162
- var _b = this, gl = _b.gl, globe = _b.globe, paddingProgram = _b.paddingProgram, paddingVao = _b.paddingVao, bufferOrchestrator = _b.bufferOrchestrator, bufferManagersCompMap = _b.bufferManagersCompMap;
163
- var is3D = globe.api_GetCurrentGeometry() === 0;
137
+ draw2D() {
138
+ const { gl, globe, paddingProgram, paddingVao, bufferOrchestrator, bufferManagersCompMap } = this;
139
+ const is3D = globe.api_GetCurrentGeometry() === 0;
164
140
  if (is3D)
165
141
  return;
166
- var items = this.compassMap.query(globe, this.writer);
142
+ const items = this.compassMap.query(globe, this.writer);
167
143
  if (items.length === 0)
168
144
  return;
169
145
  bufferOrchestrator.flush();
170
146
  bufferOrchestrator.insertBulk(items, bufferManagersCompMap);
171
- items.forEach(function (v) {
172
- _this.__insertText(v.key, v.x, v.y);
147
+ items.forEach((v) => {
148
+ this.__insertText(v.key, v.x, v.y);
173
149
  });
174
150
  gl.disable(gl.DEPTH_TEST);
175
151
  paddingProgram.draw(paddingVao, bufferOrchestrator.length, this._opacity);
176
152
  gl.enable(gl.DEPTH_TEST);
177
- (_a = this.writer) === null || _a === void 0 ? void 0 : _a.draw();
178
- };
179
- PixelPaddingCompassPlugin.prototype.free = function () {
153
+ this.writer?.draw();
154
+ }
155
+ free() {
180
156
  this.compassMap.free();
181
- var _a = this, globe = _a.globe, gl = _a.gl, paddingVao = _a.paddingVao;
157
+ const { globe, gl, paddingVao } = this;
182
158
  gl.deleteVertexArray(paddingVao);
183
- pixel_padding_for_compass_1.PixelPaddingForFlatCompassCache.release(globe);
184
- this.bufferManagersCompMap.forEach(function (v) {
159
+ PixelPaddingForFlatCompassCache.release(globe);
160
+ this.bufferManagersCompMap.forEach(v => {
185
161
  v.bufferManager.free();
186
162
  });
187
- };
188
- PixelPaddingCompassPlugin.prototype.resize = function () {
163
+ }
164
+ resize() {
189
165
  this.radiusMultiplier = this._shorterDimension() * 0.5;
190
166
  this._reinsertAllText();
191
- };
192
- PixelPaddingCompassPlugin.prototype._reinsertAllText = function () {
193
- var _this = this;
194
- this.compassMap.query(this.globe, this.writer).forEach(function (v) {
195
- _this.__insertText(v.key, v.x, v.y, { properties: v.properties, update: true });
167
+ }
168
+ _reinsertAllText() {
169
+ this.compassMap.query(this.globe, this.writer).forEach((v) => {
170
+ this.__insertText(v.key, v.x, v.y, { properties: v.properties, update: true });
196
171
  });
197
- };
198
- PixelPaddingCompassPlugin.prototype._shorterDimension = function () {
199
- var globe = this.globe;
172
+ }
173
+ _shorterDimension() {
174
+ const globe = this.globe;
200
175
  return Math.min(globe.api_ScrW(), globe.api_ScrH());
201
- };
202
- return PixelPaddingCompassPlugin;
203
- }());
204
- exports.PixelPaddingCompassPlugin = PixelPaddingCompassPlugin;
205
- var CompassMap = /** @class */ (function () {
206
- function CompassMap(parent) {
176
+ }
177
+ }
178
+ class CompassMap {
179
+ constructor(parent) {
207
180
  this.coordsMemory = new Map();
208
181
  this.propertyMemory = new Map();
209
182
  this.parent = parent;
210
183
  }
211
- CompassMap.prototype.insert = function (key, long, lat, properties) {
212
- if (properties === void 0) { properties = null; }
184
+ insert(key, long, lat, properties = null) {
213
185
  this.coordsMemory.set(key, [long, lat]);
214
186
  if (properties)
215
187
  this.propertyMemory.set(key, properties);
216
- };
217
- CompassMap.prototype.delete = function (key) {
188
+ }
189
+ delete(key) {
218
190
  this.coordsMemory.delete(key);
219
191
  this.propertyMemory.delete(key);
220
- };
221
- CompassMap.prototype.free = function () {
192
+ }
193
+ free() {
222
194
  this.coordsMemory.clear();
223
195
  this.propertyMemory.clear();
224
196
  this.coordsMemory = null;
225
197
  this.propertyMemory = null;
226
- };
227
- CompassMap.prototype.query = function (globe, writer) {
228
- var _a = this, coordsMemory = _a.coordsMemory, propertyMemory = _a.propertyMemory;
229
- var defaultProperties = this.parent.defaultProperties;
230
- var result = [];
231
- coordsMemory.forEach(function (v, k, c) {
232
- var _a = globe.api_GetScreenPointFromGeo({
198
+ }
199
+ query(globe, writer) {
200
+ const { coordsMemory, propertyMemory } = this;
201
+ const defaultProperties = this.parent.defaultProperties;
202
+ const result = [];
203
+ coordsMemory.forEach((v, k, c) => {
204
+ const { x, y } = globe.api_GetScreenPointFromGeo({
233
205
  long: v[0],
234
206
  lat: v[1],
235
207
  z: 0,
236
- }), x = _a.x, y = _a.y;
237
- writer === null || writer === void 0 ? void 0 : writer.insertTextItem(k, x, y);
208
+ });
209
+ writer?.insertTextItem(k, x, y);
238
210
  if (x !== null) {
239
- var properties = __assign(__assign({}, defaultProperties), propertyMemory.get(k));
240
- result.push({ key: k, x: x, y: y, properties: properties });
211
+ const properties = { ...defaultProperties, ...propertyMemory.get(k) };
212
+ result.push({ key: k, x, y, properties });
241
213
  }
242
214
  });
243
215
  return result;
244
- };
245
- return CompassMap;
246
- }());
216
+ }
217
+ }
247
218
  function isOnTheScreen(globe, points) { }
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PixelPaddingCompassTextWriter = void 0;
4
- var webglobe_1 = require("@pirireis/webglobe");
1
+ import { CSZMode, CSMeasureTextPositionTypes } from "@pirireis/webglobe";
5
2
  // const defaultStyle = {
6
3
  // textFont: {
7
4
  // name: 'Arial',
@@ -21,27 +18,26 @@ var webglobe_1 = require("@pirireis/webglobe");
21
18
  * 2) expose a mechanic to update text on zoom change
22
19
  * 3) extend the mechanic on 2 to other events
23
20
  */
24
- var yGapFit = -2;
25
- var xGapFit = -5;
26
- var PixelPaddingCompassTextWriter = /** @class */ (function () {
27
- function PixelPaddingCompassTextWriter(globe, _a) {
28
- var _b = _a === void 0 ? {} : _a, _c = _b.font, font = _c === void 0 ? {
29
- name: 'Arial',
30
- textColor: '#FFFFFF', // beyaz
31
- hollowColor: '#000000', // siyah
32
- size: 12, // piksel
33
- hollow: true,
34
- bold: true,
35
- italic: false,
36
- } : _c, _d = _b.northFont, northFont = _d === void 0 ? {
37
- name: 'Arial',
38
- textColor: '#BB0000', // beyaz
39
- hollowColor: '#000000', // siyah
40
- size: 14, // piksel
41
- hollow: true,
42
- bold: true,
43
- italic: false,
44
- } : _d, _e = _b.doDraw, doDraw = _e === void 0 ? true : _e, _f = _b.angle, angle = _f === void 0 ? 30 : _f;
21
+ const yGapFit = -2;
22
+ const xGapFit = -5;
23
+ export class PixelPaddingCompassTextWriter {
24
+ constructor(globe, { font = {
25
+ name: 'Arial',
26
+ textColor: '#FFFFFF', // beyaz
27
+ hollowColor: '#000000', // siyah
28
+ size: 12, // piksel
29
+ hollow: true,
30
+ bold: true,
31
+ italic: false,
32
+ }, northFont = {
33
+ name: 'Arial',
34
+ textColor: '#BB0000', // beyaz
35
+ hollowColor: '#000000', // siyah
36
+ size: 14, // piksel
37
+ hollow: true,
38
+ bold: true,
39
+ italic: false,
40
+ }, doDraw = true, angle = 30, } = {}) {
45
41
  this.globe = globe;
46
42
  this.itemMap = new Map();
47
43
  this.font = font;
@@ -51,10 +47,10 @@ var PixelPaddingCompassTextWriter = /** @class */ (function () {
51
47
  this.angles = [];
52
48
  this.texts = [];
53
49
  this.positions = [];
54
- var currentAngle = 0;
50
+ let currentAngle = 0;
55
51
  while (currentAngle < 360) {
56
52
  if (currentAngle > 180) {
57
- this.positions.push(webglobe_1.CSMeasureTextPositionTypes.CENTER);
53
+ this.positions.push(CSMeasureTextPositionTypes.CENTER);
58
54
  }
59
55
  else {
60
56
  this.positions.push(null);
@@ -72,43 +68,42 @@ var PixelPaddingCompassTextWriter = /** @class */ (function () {
72
68
  this._lastNorthAngle = globe.api_GetCurrentLookInfo()["NorthAng"] * (Math.PI / 180);
73
69
  this.offsets = this.__offset(this._lastNorthAngle);
74
70
  }
75
- PixelPaddingCompassTextWriter.prototype.setKeyAdaptor = function (adaptor) {
71
+ setKeyAdaptor(adaptor) {
76
72
  this.keyAdaptor = adaptor;
77
- };
78
- PixelPaddingCompassTextWriter.prototype.setDoDraw = function (bool) {
73
+ }
74
+ setDoDraw(bool) {
79
75
  this.doDraw = bool;
80
- };
81
- PixelPaddingCompassTextWriter.prototype.setFont = function (font) {
76
+ }
77
+ setFont(font) {
82
78
  this.font = font;
83
- };
84
- PixelPaddingCompassTextWriter.prototype.setNorthFont = function (font) {
79
+ }
80
+ setNorthFont(font) {
85
81
  this.northFont = font;
86
- };
87
- PixelPaddingCompassTextWriter.prototype.setOpacity = function (opacity) {
82
+ }
83
+ setOpacity(opacity) {
88
84
  this.opacity = opacity;
89
- };
90
- PixelPaddingCompassTextWriter.prototype._checkSetOffsets = function () {
91
- var globe = this.globe;
92
- var newAngle = globe.api_GetCurrentLookInfo()["NorthAng"] * (Math.PI / 180);
85
+ }
86
+ _checkSetOffsets() {
87
+ const { globe } = this;
88
+ const newAngle = globe.api_GetCurrentLookInfo()["NorthAng"] * (Math.PI / 180);
93
89
  ;
94
90
  if (newAngle !== this._lastNorthAngle) {
95
91
  this._lastNorthAngle = newAngle;
96
92
  this.offsets = this.__offset();
97
93
  }
98
- };
99
- PixelPaddingCompassTextWriter.prototype.draw = function () {
94
+ }
95
+ draw() {
100
96
  if (!this.doDraw)
101
97
  return;
102
- var _a = this, globe = _a.globe, font = _a.font, opacity_ = _a.opacity, northFont = _a.northFont, itemMap = _a.itemMap, texts = _a.texts, angles = _a.angles, positions = _a.positions;
98
+ const { globe, font, opacity: opacity_, northFont, itemMap, texts, angles, positions } = this;
103
99
  this._checkSetOffsets(); // zMode: CSZMode.Z_GROUND_PERVERTEX,
104
- var offsets = this.offsets;
105
- var _loop_1 = function (key, center, radius, opacity) {
106
- var o = opacity === null ? opacity_ : opacity * opacity_;
100
+ const offsets = this.offsets;
101
+ for (const [key, { center, radius, opacity = null }] of itemMap) {
102
+ const o = opacity === null ? opacity_ : opacity * opacity_;
107
103
  if (center.x !== null && center.y !== null) {
108
- offsets.forEach(function (_a, i) {
109
- var offsetX = _a.offsetX, offsetY = _a.offsetY;
110
- var text = texts[i];
111
- var angle = angles[i];
104
+ offsets.forEach(({ offsetX, offsetY }, i) => {
105
+ const text = texts[i];
106
+ const angle = angles[i];
112
107
  font.position = positions[i];
113
108
  if (angle === 0) {
114
109
  globe.api_DrawContextTextMultiLine(text, northFont, o, { x: center.x + offsetX * radius + xGapFit, y: center.y + offsetY * radius + yGapFit });
@@ -118,44 +113,37 @@ var PixelPaddingCompassTextWriter = /** @class */ (function () {
118
113
  }
119
114
  });
120
115
  }
121
- };
122
- for (var _i = 0, itemMap_1 = itemMap; _i < itemMap_1.length; _i++) {
123
- var _b = itemMap_1[_i], key = _b[0], _c = _b[1], center = _c.center, radius = _c.radius, _d = _c.opacity, opacity = _d === void 0 ? null : _d;
124
- _loop_1(key, center, radius, opacity);
125
116
  }
126
- };
127
- PixelPaddingCompassTextWriter.prototype.insertTextItem = function (key, x, y, radius) {
128
- if (radius === void 0) { radius = undefined; }
129
- var item = this.getItem(key);
130
- item.center = { x: x, y: y };
117
+ }
118
+ insertTextItem(key, x, y, radius = undefined) {
119
+ const item = this.getItem(key);
120
+ item.center = { x, y };
131
121
  if (radius === undefined)
132
122
  return;
133
123
  if (item.radius != undefined && item.radius === radius)
134
124
  return;
135
125
  item.radius = radius;
136
- };
137
- PixelPaddingCompassTextWriter.prototype.getItem = function (key) {
126
+ }
127
+ getItem(key) {
138
128
  if (!this.itemMap.has(key))
139
129
  this.itemMap.set(key, {});
140
130
  return this.itemMap.get(key);
141
- };
142
- PixelPaddingCompassTextWriter.prototype.__calculateOffset = function (angle) {
143
- var rAngle = (angle - 90) * (Math.PI / 180);
131
+ }
132
+ __calculateOffset(angle) {
133
+ const rAngle = (angle - 90) * (Math.PI / 180);
144
134
  return { offsetX: Math.cos(rAngle + this._lastNorthAngle), offsetY: Math.sin(rAngle + this._lastNorthAngle) };
145
- };
146
- PixelPaddingCompassTextWriter.prototype.__offset = function () {
147
- var angle = this.angle;
148
- var offsets = [];
149
- var currentAngle = 0;
135
+ }
136
+ __offset() {
137
+ const angle = this.angle;
138
+ const offsets = [];
139
+ let currentAngle = 0;
150
140
  while (currentAngle < 360) {
151
141
  offsets.push(this.__calculateOffset(currentAngle));
152
142
  currentAngle += angle;
153
143
  }
154
144
  return offsets;
155
- };
156
- PixelPaddingCompassTextWriter.prototype.clear = function () {
145
+ }
146
+ clear() {
157
147
  this.itemMap.clear();
158
- };
159
- return PixelPaddingCompassTextWriter;
160
- }());
161
- exports.PixelPaddingCompassTextWriter = PixelPaddingCompassTextWriter;
148
+ }
149
+ }
@@ -1,7 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PixelPaddingCompassTextWriter = exports.PixelPaddingCompassPlugin = void 0;
4
- var compass_text_writer_1 = require("./compass-text-writer");
5
- Object.defineProperty(exports, "PixelPaddingCompassTextWriter", { enumerable: true, get: function () { return compass_text_writer_1.PixelPaddingCompassTextWriter; } });
6
- var compass_rose_padding_flat_1 = require("./compass-rose-padding-flat");
7
- Object.defineProperty(exports, "PixelPaddingCompassPlugin", { enumerable: true, get: function () { return compass_rose_padding_flat_1.PixelPaddingCompassPlugin; } });
1
+ import { PixelPaddingCompassTextWriter } from "./compass-text-writer";
2
+ import { PixelPaddingCompassPlugin } from "./compass-rose-padding-flat";
3
+ export { PixelPaddingCompassPlugin, PixelPaddingCompassTextWriter };