@pirireis/webglobeplugins 0.9.9 → 0.9.11

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 (212) hide show
  1. package/Math/angle-calculation.js +15 -0
  2. package/Math/arc.js +65 -0
  3. package/Math/bounds/line-bbox.js +190 -0
  4. package/Math/constants.js +9 -0
  5. package/Math/frustum/camera.js +24 -0
  6. package/Math/frustum/from-globeinfo.js +48 -0
  7. package/Math/frustum/types.js +2 -0
  8. package/Math/globe-util/horizon-plane.js +112 -0
  9. package/Math/index.js +1 -0
  10. package/Math/juction/arc-plane.js +83 -0
  11. package/Math/juction/line-sphere.js +25 -0
  12. package/Math/juction/plane-plane.js +58 -0
  13. package/Math/line.js +58 -0
  14. package/Math/matrix4.js +1 -0
  15. package/Math/methods.js +206 -0
  16. package/Math/plane.js +62 -0
  17. package/Math/quaternion.js +108 -0
  18. package/Math/types.js +2 -0
  19. package/Math/utils.js +4 -0
  20. package/Math/vec3.js +129 -0
  21. package/algorithms/search-binary.js +19 -0
  22. package/altitude-locator/adaptors.js +1 -0
  23. package/altitude-locator/draw-subset-obj.js +19 -0
  24. package/altitude-locator/keymethod.js +1 -0
  25. package/altitude-locator/plugin.js +357 -0
  26. package/altitude-locator/types.js +23 -0
  27. package/arrowfield/adaptor.js +15 -0
  28. package/arrowfield/index.js +10 -0
  29. package/arrowfield/plugin.js +89 -0
  30. package/bearing-line/index.js +8 -0
  31. package/bearing-line/plugin.js +474 -0
  32. package/circle-line-chain/chain-list-map.js +211 -0
  33. package/circle-line-chain/init.js +1 -0
  34. package/circle-line-chain/plugin.js +449 -0
  35. package/circle-line-chain/util.js +5 -0
  36. package/compass-rose/compass-rose-padding-flat.js +247 -0
  37. package/compass-rose/compass-text-writer.js +161 -0
  38. package/compass-rose/index.js +7 -0
  39. package/compassrose/compassrose.js +300 -0
  40. package/compassrose/index.js +8 -0
  41. package/globe-types.js +1 -0
  42. package/heatwave/index.js +10 -0
  43. package/heatwave/isobar/objectarraylabels.js +206 -0
  44. package/heatwave/isobar/plugin.js +362 -0
  45. package/heatwave/isobar/quadtreecontours.js +316 -0
  46. package/heatwave/plugins/heatwaveglobeshell.js +224 -0
  47. package/index.js +11 -11
  48. package/jest.config.js +7 -0
  49. package/package.json +4 -4
  50. package/partialrings/buffer-manager.js +113 -0
  51. package/partialrings/index.js +41 -0
  52. package/partialrings/plugin.js +171 -0
  53. package/partialrings/program.js +197 -0
  54. package/pin/pin-object-array.js +308 -0
  55. package/pin/pin-point-totem.js +61 -0
  56. package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +66 -0
  57. package/point-heat-map/index.js +1 -0
  58. package/point-heat-map/plugin-webworker.js +131 -0
  59. package/point-heat-map/point-to-heat-map-flow.js +129 -0
  60. package/point-tracks/key-methods.js +5 -0
  61. package/point-tracks/plugin.js +353 -0
  62. package/programs/arrowfield/index.js +7 -0
  63. package/programs/arrowfield/logic.js +149 -0
  64. package/programs/arrowfield/object.js +68 -0
  65. package/programs/data2legend/density-to-legend.js +77 -0
  66. package/programs/data2legend/point-to-density-texture.js +75 -0
  67. package/programs/float2legendwithratio/index.js +8 -0
  68. package/programs/float2legendwithratio/logic.js +125 -0
  69. package/programs/float2legendwithratio/object.js +113 -0
  70. package/programs/globe-util/is-globe-moved.js +22 -0
  71. package/programs/globeshell/index.js +8 -0
  72. package/programs/globeshell/noise/noises.js +1 -0
  73. package/programs/globeshell/wiggle/index.js +8 -0
  74. package/programs/globeshell/wiggle/logic.js +252 -0
  75. package/programs/globeshell/wiggle/object.js +74 -0
  76. package/programs/helpers/blender/index.js +1 -0
  77. package/programs/helpers/blender/program.js +62 -0
  78. package/programs/helpers/fadeaway/index.js +7 -0
  79. package/programs/helpers/fadeaway/logic.js +50 -0
  80. package/programs/helpers/fadeaway/object.js +21 -0
  81. package/programs/helpers/index.js +8 -0
  82. package/programs/index.js +58 -0
  83. package/programs/interface.js +1 -0
  84. package/programs/line-on-globe/angled-line.js +117 -0
  85. package/programs/line-on-globe/circle-accurate-3d.js +91 -0
  86. package/programs/line-on-globe/circle-accurate-flat.js +158 -0
  87. package/programs/line-on-globe/circle-accurate.js +108 -0
  88. package/programs/line-on-globe/circle.js +102 -0
  89. package/programs/line-on-globe/degree-padding-around-circle-3d.js +109 -0
  90. package/programs/line-on-globe/index.js +1 -0
  91. package/programs/line-on-globe/lines-color-instanced-flat.js +91 -0
  92. package/programs/line-on-globe/linestrip.js +110 -0
  93. package/programs/line-on-globe/naive-accurate-flexible.js +125 -0
  94. package/programs/line-on-globe/to-the-surface.js +82 -0
  95. package/programs/line-on-globe/util.js +8 -0
  96. package/programs/picking/pickable-renderer.js +104 -0
  97. package/programs/point-on-globe/element-globe-surface-glow.js +102 -0
  98. package/programs/point-on-globe/element-point-glow.js +85 -0
  99. package/programs/point-on-globe/square-pixel-point.js +125 -0
  100. package/programs/programcache.js +131 -0
  101. package/programs/rings/distancering/circleflatprogram.js +114 -0
  102. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +358 -0
  103. package/programs/rings/distancering/circlepaddysharedbuffer.js +433 -0
  104. package/programs/rings/distancering/index.js +14 -0
  105. package/programs/rings/distancering/paddyflatprogram.js +119 -0
  106. package/programs/rings/distancering/paddyflatprogram2d.js +121 -0
  107. package/programs/rings/distancering/paddyflatprogram3d.js +119 -0
  108. package/programs/rings/distancering/shader.js +1 -0
  109. package/programs/rings/index.js +17 -0
  110. package/programs/rings/partial-ring/piece-of-pie.js +173 -0
  111. package/programs/totems/camerauniformblock.js +147 -0
  112. package/programs/totems/canvas-webglobe-info.js +102 -0
  113. package/programs/totems/gpu-selection-uniform-block.js +104 -0
  114. package/programs/totems/index.js +40 -0
  115. package/programs/two-d/pixel-circle.js +1 -0
  116. package/programs/two-d/pixel-padding-for-compass.js +101 -0
  117. package/programs/util.js +18 -0
  118. package/programs/vectorfields/index.js +23 -0
  119. package/programs/vectorfields/logics/drawrectangleparticles.js +66 -0
  120. package/programs/vectorfields/logics/index.js +12 -0
  121. package/programs/vectorfields/logics/pixelbased.js +86 -0
  122. package/programs/vectorfields/logics/ubo.js +57 -0
  123. package/programs/vectorfields/pingpongbuffermanager.js +80 -0
  124. package/rangerings/enum.js +5 -0
  125. package/rangerings/index.js +15 -0
  126. package/rangerings/plugin.js +610 -0
  127. package/rangerings/rangeringangletext.js +341 -0
  128. package/rangerings/ring-account.js +134 -0
  129. package/shaders/fragment-toy/firework.js +4 -0
  130. package/shaders/fragment-toy/singularity.js +5 -0
  131. package/shape-on-terrain/arc/naive/plugin.js +252 -0
  132. package/timetracks/adaptors-line-strip.js +82 -0
  133. package/timetracks/adaptors.js +136 -0
  134. package/timetracks/index.js +19 -0
  135. package/timetracks/plugin-line-strip.js +254 -0
  136. package/timetracks/plugin.js +262 -0
  137. package/timetracks/program-line-strip.js +418 -0
  138. package/timetracks/program.js +466 -0
  139. package/timetracks/programpoint-line-strip.js +101 -0
  140. package/timetracks/programpoint.js +101 -0
  141. package/types.js +15 -0
  142. package/util/account/bufferoffsetmanager.js +202 -0
  143. package/util/account/index.js +23 -0
  144. package/util/account/single-attribute-buffer-management/buffer-manager.js +112 -0
  145. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +180 -0
  146. package/util/account/single-attribute-buffer-management/index.js +9 -0
  147. package/util/account/single-attribute-buffer-management/object-store.js +53 -0
  148. package/util/account/single-attribute-buffer-management/types.js +2 -0
  149. package/util/account/util.js +24 -0
  150. package/util/algorithms/index.js +1 -0
  151. package/util/algorithms/search-binary.js +28 -0
  152. package/util/check/get.js +18 -0
  153. package/util/check/index.js +1 -0
  154. package/util/check/typecheck.js +51 -0
  155. package/util/geometry/index.js +53 -0
  156. package/util/gl-util/buffer/attribute-loader.js +81 -0
  157. package/util/gl-util/buffer/index.js +6 -0
  158. package/util/gl-util/buffer/types.js +1 -0
  159. package/util/gl-util/draw-options/methods.js +38 -0
  160. package/util/gl-util/draw-options/types.js +15 -0
  161. package/util/gl-util/uniform-block/manager.js +168 -0
  162. package/util/gl-util/uniform-block/shader.js +1 -0
  163. package/util/gl-util/uniform-block/types.js +8 -0
  164. package/util/heatwavedatamanager/datamanager.js +212 -0
  165. package/util/heatwavedatamanager/index.js +10 -0
  166. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +125 -0
  167. package/util/heatwavedatamanager/pointcoordsmeta.js +21 -0
  168. package/util/index.js +57 -0
  169. package/util/interpolation/index.js +1 -0
  170. package/util/interpolation/timetrack/index.js +5 -0
  171. package/util/interpolation/timetrack/timetrack-interpolator.js +81 -0
  172. package/util/interpolation/timetrack/web-worker-str.js +5 -0
  173. package/util/interpolation/timetrack/web-worker.js +48 -0
  174. package/util/jshelpers/data-filler.js +20 -0
  175. package/util/jshelpers/equality.js +20 -0
  176. package/util/jshelpers/index.js +37 -0
  177. package/util/jshelpers/timefilters.js +32 -0
  178. package/util/picking/fence.js +46 -0
  179. package/util/picking/picker-displayer.js +145 -0
  180. package/util/programs/draw-texture-on-canvas.js +71 -0
  181. package/util/programs/index.js +17 -0
  182. package/util/programs/shapesonglobe.js +174 -0
  183. package/util/programs/supersampletotextures.js +107 -0
  184. package/util/programs/texturetoglobe.js +132 -0
  185. package/util/shaderfunctions/geometrytransformations.js +45 -0
  186. package/util/shaderfunctions/index.js +18 -0
  187. package/util/shaderfunctions/nodata.js +5 -0
  188. package/util/shaderfunctions/noisefunctions.js +13 -0
  189. package/util/surface-line-data/arc-bboxes.js +25 -0
  190. package/util/surface-line-data/arcs-to-cuts.js +53 -0
  191. package/util/surface-line-data/cut-arc.js +1 -0
  192. package/util/surface-line-data/flow.js +28 -0
  193. package/util/surface-line-data/rbush-manager.js +1 -0
  194. package/util/surface-line-data/types.js +1 -0
  195. package/util/surface-line-data/web-worker.js +1 -0
  196. package/util/webglobe/gldefaultstates.js +7 -0
  197. package/util/webglobe/index.js +18 -0
  198. package/util/webglobe/rasteroverlay.js +80 -0
  199. package/util/webglobjectbuilders.js +393 -0
  200. package/util/webglobjectbuilders1.js +238 -0
  201. package/waveparticles/adaptor.js +18 -0
  202. package/waveparticles/index.js +10 -0
  203. package/waveparticles/plugin.js +271 -0
  204. package/wind/imagetovectorfieldandmagnitude.js +35 -0
  205. package/wind/index.js +14 -0
  206. package/wind/plugin.js +724 -0
  207. package/wind/vectorfieldimage.js +25 -0
  208. package/write-text/attached-text-writer.js +93 -0
  209. package/write-text/context-text.js +105 -0
  210. package/write-text/context-text3.js +160 -0
  211. package/write-text/index.js +5 -0
  212. package/write-text/writer-plugin.js +8 -0
@@ -0,0 +1,254 @@
1
+ "use strict";
2
+ /**
3
+ * Author: Toprak Nihat Deniz Ozturk
4
+ */
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ var program_line_strip_1 = __importDefault(require("./program-line-strip"));
10
+ var programpoint_line_strip_1 = __importDefault(require("./programpoint-line-strip"));
11
+ /**
12
+ * @typedef {Float32Array} TimeTrackMultiColorData | A linestring is representation, let A{a1, a2, a3}, B{b1, b2} be the points of the line.
13
+ * TimeTrackMultiColorData is [
14
+ * a1x, a1y, a1z, a1time, a1r, a1g, a1b, a1time, a3time,
15
+ * a2x, a2y, a2z, a2time, a2r, a2g, a2b, a1time, a3time,
16
+ * a3x, a3y, a3z, a3time, a3r, a3g, a3b, a1time, a3time,
17
+ * NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN,
18
+ * b1x, b1y, b1z, b1time, b1r, b1g, b1b, b1time, b2time,
19
+ * b2x, b2y, b2z, b2time, b2r, b2g, b2b, BstartTime, BendTime
20
+ * ]
21
+ * there is a cutting point between A and B
22
+ *
23
+ * x, y is xy coordinates are in between 0, +1 for -180 to +180 longitude and -90 to +90 latitude
24
+ * z is height in meters
25
+ */
26
+ /**
27
+ * Access following methods through `plugin.program.` :
28
+ * * setGamma
29
+ * * setExposure
30
+ * * setAlphaThreshold
31
+ * * setWeights
32
+ * * setHeadPercentage
33
+ * * setRouteAlpha
34
+ * * setFinalAlphaRatio
35
+
36
+ uses float32array in a * {@link TimeTrackMultiColorData} format
37
+
38
+ */
39
+ var TimeTrackMultiColorPlugin = /** @class */ (function () {
40
+ /**
41
+ * @param {String} id
42
+ * @param {Object} options
43
+ * @param {TimeTrackMultiColorData} options.data {@link TimeTrackMultiColorData}
44
+ * @param {number} options.headPercentage 0 ~ 1
45
+ * @param {number} options.routeAlpha 0 ~ 1
46
+ * @param {Array.<Number>} options.weights [w1, w2, w3, w4, w5]
47
+ * @param {number} options.alphaThreshold 0 ~ 1
48
+ * @param {number} options.exposure 0 ~ inf
49
+ * @param {number} options.gamma 0 ~ inf
50
+ * @param {number} options.finalAlphaRatio 0 ~ 1
51
+ * @param {number} pointOptions.opacity 0 ~ 1
52
+ * @param {number} pointOptions.pointSize 0 ~ inf
53
+ * @param {boolean} pointOptions.isOn true | false
54
+ */
55
+ function TimeTrackMultiColorPlugin(id, options, _a) {
56
+ if (options === void 0) { options = {}; }
57
+ var _b = _a === void 0 ? {} : _a, _c = _b.opacity, opacity = _c === void 0 ? 1.0 : _c, _d = _b.pointSize, pointSize = _d === void 0 ? 1 : _d, _e = _b.isOn, isOn = _e === void 0 ? false : _e;
58
+ this.id = id;
59
+ this.globe = null;
60
+ this.gl = null;
61
+ this.program = null;
62
+ this._headTime = 0;
63
+ this._tailTime = 0;
64
+ this._data = options.data || null;
65
+ this._options = options;
66
+ this._pointOptions = { opacity: opacity, pointSize: pointSize, isOn: isOn };
67
+ this.program = null;
68
+ this._transporArr = new Float32Array(3);
69
+ this._ready = false;
70
+ this.pointProgram = null;
71
+ this._attrBuffer = null;
72
+ }
73
+ // ----------------------------------
74
+ // --- user methods ---
75
+ // ----------------------------------
76
+ TimeTrackMultiColorPlugin.prototype.setHeadAndTailTime = function (headTime, tailTime) {
77
+ var _a;
78
+ this._headTime = headTime;
79
+ this._tailTime = tailTime;
80
+ // console.log("setHeadAndTailTime", headTime, tailTime);
81
+ (_a = this.pointProgram) === null || _a === void 0 ? void 0 : _a.setHeadTime(headTime);
82
+ this.globe.DrawRender();
83
+ };
84
+ TimeTrackMultiColorPlugin.prototype.setBlurWeights = function (weights) {
85
+ this.program.setBlurWeights(weights);
86
+ this.globe.DrawRender();
87
+ };
88
+ TimeTrackMultiColorPlugin.prototype.setHeadPercentage = function (headPercentage) {
89
+ this.program.setHeadPercentage(headPercentage);
90
+ this.globe.DrawRender();
91
+ };
92
+ TimeTrackMultiColorPlugin.prototype.setRouteAlpha = function (routeAlpha) {
93
+ this.program.setRouteAlpha(routeAlpha);
94
+ this.globe.DrawRender();
95
+ };
96
+ TimeTrackMultiColorPlugin.prototype.setFinalAlphaRatio = function (finalAlphaRatio) {
97
+ this.program.setFinalAlphaRatio(finalAlphaRatio);
98
+ this.globe.DrawRender();
99
+ };
100
+ TimeTrackMultiColorPlugin.prototype.setGamma = function (gamma) {
101
+ this.program.setGamma(gamma);
102
+ this.globe.DrawRender();
103
+ };
104
+ TimeTrackMultiColorPlugin.prototype.setExposure = function (exposure) {
105
+ this.program.setExposure(exposure);
106
+ this.globe.DrawRender();
107
+ };
108
+ TimeTrackMultiColorPlugin.prototype.setBlurRepetition = function (repetition) {
109
+ this.program.setBlurRepetition(repetition);
110
+ this.globe.DrawRender();
111
+ };
112
+ // ---------------point program setters-------------------
113
+ TimeTrackMultiColorPlugin.prototype.setPointOpacity = function (opacity) {
114
+ this._pointOptions.opacity = opacity;
115
+ if (this.pointProgram) {
116
+ this.pointProgram.setOpacity(opacity);
117
+ this.globe.DrawRender();
118
+ }
119
+ };
120
+ TimeTrackMultiColorPlugin.prototype.setPointSize = function (size) {
121
+ this._pointOptions.pointSize = size;
122
+ if (this.pointProgram) {
123
+ this.pointProgram.setPointSize(size);
124
+ this.globe.DrawRender();
125
+ }
126
+ };
127
+ TimeTrackMultiColorPlugin.prototype.pointSwitch = function (isOn) {
128
+ if (isOn && !this.pointProgram) {
129
+ this.pointProgram = this._createPointProgram();
130
+ }
131
+ else {
132
+ this._deletePointProgram();
133
+ }
134
+ };
135
+ // ------------------------------------------------------------
136
+ TimeTrackMultiColorPlugin.prototype._createPointProgram = function () {
137
+ var gl = this.gl;
138
+ var program = new programpoint_line_strip_1.default(gl, this.globe, this._attrBuffer, this._pointOptions);
139
+ program.setDrawCount(this._totalSize);
140
+ return program;
141
+ };
142
+ TimeTrackMultiColorPlugin.prototype._deletePointProgram = function () {
143
+ if (this.pointProgram)
144
+ this.pointProgram.free();
145
+ this.pointProgram = null;
146
+ };
147
+ // -------------------------------------------------------------
148
+ TimeTrackMultiColorPlugin.prototype.isReady = function () {
149
+ return this._ready;
150
+ };
151
+ /**
152
+ * @param {TimeTrackMultiColorData} data {@link TimeTrackMultiColorData}
153
+ * Check Class constructor
154
+ */
155
+ TimeTrackMultiColorPlugin.prototype.setData = function (data) {
156
+ if (this.gl) {
157
+ this._ready = false;
158
+ this.setDataAsFloat32Array(data);
159
+ this._ready = true;
160
+ }
161
+ else {
162
+ this._data = data;
163
+ this._ready = false;
164
+ }
165
+ };
166
+ /**
167
+ * @param {TimeTrackMultiColorData} data {@link TimeTrackMultiColorData}
168
+ * @param {number} totalSize | if not provided, it is calculated from float32Array.length / 9. Use if you want to draw first n points.
169
+ */
170
+ TimeTrackMultiColorPlugin.prototype.setDataAsFloat32Array = function (data, totalSize) {
171
+ var _a;
172
+ if (totalSize === void 0) { totalSize = null; }
173
+ var _b = this, gl = _b.gl, _attrBuffer = _b._attrBuffer;
174
+ gl.bindBuffer(gl.ARRAY_BUFFER, _attrBuffer);
175
+ gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
176
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
177
+ // this.program.setInBuffer(data);
178
+ // this.pointProgram.setData(data);
179
+ if (totalSize) {
180
+ this._totalSize = totalSize;
181
+ }
182
+ else {
183
+ this._totalSize = data.length / 9;
184
+ }
185
+ this.program.setTotalLength(this._totalSize);
186
+ (_a = this.pointProgram) === null || _a === void 0 ? void 0 : _a.setDrawCount(this._totalSize / 2);
187
+ this._ready = true;
188
+ };
189
+ // ------------------------------
190
+ // --- globe Methods ---
191
+ // ------------------------------
192
+ TimeTrackMultiColorPlugin.prototype.draw3D = function (projMatrix, modelviewMatrix, transPos) {
193
+ var _a;
194
+ if (!this._ready)
195
+ return;
196
+ var _b = this, _headTime = _b._headTime, _tailTime = _b._tailTime, program = _b.program, _transporArr = _b._transporArr, globe = _b.globe;
197
+ (_a = this.pointProgram) === null || _a === void 0 ? void 0 : _a.draw();
198
+ _transporArr.set([transPos.x, transPos.y, transPos.z], 0);
199
+ var geomType = globe.api_GetCurrentGeometry();
200
+ if (geomType === 0) {
201
+ program.draw(_headTime, _tailTime, projMatrix, modelviewMatrix, _transporArr);
202
+ }
203
+ else if (geomType === 1) {
204
+ var _c = globe.api_GetCurrentWorldWH(), width = _c.width, height = _c.height;
205
+ program.draw(_headTime, _tailTime, projMatrix, modelviewMatrix, _transporArr, [width, height]);
206
+ }
207
+ else {
208
+ console.error("Unknown geometry type", geomType);
209
+ }
210
+ };
211
+ TimeTrackMultiColorPlugin.prototype.resize = function (width, height) {
212
+ var _a = this, program = _a.program, globe = _a.globe;
213
+ width = width || globe.api_ScrW();
214
+ height = height || globe.api_ScrH();
215
+ program.resize(width, height);
216
+ };
217
+ TimeTrackMultiColorPlugin.prototype.init = function (globe, gl) {
218
+ var _a;
219
+ this.globe = globe;
220
+ this.gl = gl;
221
+ this._attrBuffer = gl.createBuffer();
222
+ this.program = new program_line_strip_1.default(gl, this._attrBuffer, globe.api_ScrW(), globe.api_ScrH(), this._options);
223
+ if ((_a = this._pointOptions) === null || _a === void 0 ? void 0 : _a.isOn)
224
+ this.pointProgram = new programpoint_line_strip_1.default(gl, globe, this._attrBuffer);
225
+ // this.pointProgram.setAttrBuffer(_attrBuffer);
226
+ this.setGeometry();
227
+ if (this._data) {
228
+ this._ready = true;
229
+ this.setDataAsFloat32Array(this._data);
230
+ this._data = null;
231
+ }
232
+ this.resize();
233
+ };
234
+ TimeTrackMultiColorPlugin.prototype.free = function () {
235
+ var _a = this, gl = _a.gl, _attrBuffer = _a._attrBuffer;
236
+ this.program.free();
237
+ gl.deleteBuffer(_attrBuffer);
238
+ };
239
+ TimeTrackMultiColorPlugin.prototype.setGeometry = function () {
240
+ var _a = this, globe = _a.globe, program = _a.program;
241
+ program.setIs3D(globe.api_GetCurrentGeometry() === 0);
242
+ };
243
+ // ----------------------------------
244
+ // --- implicit methods ---
245
+ // ----------------------------------
246
+ TimeTrackMultiColorPlugin.prototype._latLongToPixelXY = function (latitude, longitude) {
247
+ return {
248
+ x: (longitude + 180) / 360,
249
+ y: (90 - latitude) / 180
250
+ };
251
+ };
252
+ return TimeTrackMultiColorPlugin;
253
+ }());
254
+ exports.default = TimeTrackMultiColorPlugin;
@@ -0,0 +1,262 @@
1
+ "use strict";
2
+ /**
3
+ * Author: Toprak Nihat Deniz Ozturk
4
+ */
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ var program_1 = __importDefault(require("./program"));
10
+ var programpoint_1 = __importDefault(require("./programpoint"));
11
+ /**
12
+ * @typedef {Float32Array} TimeTrackMultiColorData | A linestring is representation, let A{a1, a2, a3}, B{b1, b2} be the points of the line.
13
+ * TimeTrackMultiColorData is [
14
+ * a1x, a1y, a1z, a1time, a1r, a1g, a1b, a1time, a3time, a2x, a2y, a2z, a2time, a2r, a2g, a2b, a1time, a3time,
15
+ * a2x, a2y, a2z, a2time, a2r, a2g, a2b, a1time, a3time, a3x, a3y, a3z, a3time, a3r, a3g, a3b, a1time, a3time,
16
+ * b1x, b1y, b1z, b1time, b1r, b1g, b1b, b1time, b2time, b2x, b2y, b2z, b2time, b2r, b2g, b2b, BstartTime, BendTime
17
+ * ]
18
+ * As you can see, the middle points of a line is repeated.
19
+ * Start Time is the first time of the line, End Time is the last time of the line.
20
+ * startTime of A = a1time, endTime time of A = a3time
21
+ * Check Adaptor to create TimeTrackMultiColorData. import {Adaptor} from '.';
22
+ */
23
+ /**
24
+ * Access following methods through `plugin.program.` :
25
+ * * setGamma
26
+ * * setExposure
27
+ * * setAlphaThreshold
28
+ * * setWeights
29
+ * * setHeadPercentage
30
+ * * setRouteAlpha
31
+ * * setFinalAlphaRatio
32
+
33
+ uses float32array in a * {@link TimeTrackMultiColorData} format
34
+
35
+ */
36
+ var TimeTrackMultiColorPlugin = /** @class */ (function () {
37
+ /**
38
+ * @param {String} id
39
+ * @param {Object} options
40
+ * @param {TimeTrackMultiColorData} options.data {@link TimeTrackMultiColorData}
41
+ * @param {number} options.headPercentage 0 ~ 1
42
+ * @param {number} options.routeAlpha 0 ~ 1
43
+ * @param {Array.<Number>} options.weights [w1, w2, w3, w4, w5]
44
+ * @param {number} options.alphaThreshold 0 ~ 1
45
+ * @param {number} options.exposure 0 ~ inf
46
+ * @param {number} options.gamma 0 ~ inf
47
+ * @param {number} options.finalAlphaRatio 0 ~ 1
48
+ * @param {number} pointOptions.opacity 0 ~ 1
49
+ * @param {number} pointOptions.pointSize 0 ~ inf
50
+ * @param {boolean} pointOptions.isOn true | false
51
+ */
52
+ function TimeTrackMultiColorPlugin(id, options, _a) {
53
+ if (options === void 0) { options = {}; }
54
+ var _b = _a === void 0 ? {} : _a, _c = _b.opacity, opacity = _c === void 0 ? 1.0 : _c, _d = _b.pointSize, pointSize = _d === void 0 ? 1 : _d, _e = _b.isOn, isOn = _e === void 0 ? false : _e;
55
+ this.id = id;
56
+ this.globe = null;
57
+ this.gl = null;
58
+ this.program = null;
59
+ this._headTime = 0;
60
+ this._tailTime = 0;
61
+ this._data = options.data || null;
62
+ this._options = options;
63
+ this._pointOptions = { opacity: opacity, pointSize: pointSize, isOn: isOn };
64
+ this.program = null;
65
+ this._transporArr = new Float32Array(3);
66
+ this._ready = false;
67
+ this.pointProgram = null;
68
+ this._attrBuffer = null;
69
+ }
70
+ // ----------------------------------
71
+ // --- user methods ---
72
+ // ----------------------------------
73
+ TimeTrackMultiColorPlugin.prototype.setHeadAndTailTime = function (headTime, tailTime) {
74
+ var _a;
75
+ this._headTime = headTime;
76
+ this._tailTime = tailTime;
77
+ (_a = this.pointProgram) === null || _a === void 0 ? void 0 : _a.setHeadTime(headTime);
78
+ this.globe.DrawRender();
79
+ };
80
+ TimeTrackMultiColorPlugin.prototype.setGlow = function (isGlow) {
81
+ this.program.setGlow(isGlow);
82
+ this.globe.DrawRender();
83
+ };
84
+ TimeTrackMultiColorPlugin.prototype.setPremultipliedAlpha = function (isPremultiplied) {
85
+ this.program.setPremultipliedAlpha(isPremultiplied);
86
+ this.globe.DrawRender();
87
+ };
88
+ TimeTrackMultiColorPlugin.prototype.setBlurWeights = function (weights) {
89
+ this.program.setBlurWeights(weights);
90
+ this.globe.DrawRender();
91
+ };
92
+ TimeTrackMultiColorPlugin.prototype.setHeadPercentage = function (headPercentage) {
93
+ this.program.setHeadPercentage(headPercentage);
94
+ this.globe.DrawRender();
95
+ };
96
+ TimeTrackMultiColorPlugin.prototype.setRouteAlpha = function (routeAlpha) {
97
+ this.program.setRouteAlpha(routeAlpha);
98
+ this.globe.DrawRender();
99
+ };
100
+ TimeTrackMultiColorPlugin.prototype.setFinalAlphaRatio = function (finalAlphaRatio) {
101
+ this.program.setFinalAlphaRatio(finalAlphaRatio);
102
+ this.globe.DrawRender();
103
+ };
104
+ TimeTrackMultiColorPlugin.prototype.setGamma = function (gamma) {
105
+ this.program.setGamma(gamma);
106
+ this.globe.DrawRender();
107
+ };
108
+ TimeTrackMultiColorPlugin.prototype.setExposure = function (exposure) {
109
+ this.program.setExposure(exposure);
110
+ this.globe.DrawRender();
111
+ };
112
+ TimeTrackMultiColorPlugin.prototype.setBlurRepetition = function (repetition) {
113
+ this.program.setBlurRepetition(repetition);
114
+ this.globe.DrawRender();
115
+ };
116
+ TimeTrackMultiColorPlugin.prototype.setAlphaThreshold = function (alphaThreshold) {
117
+ this.program.setAlphaThreshold(alphaThreshold);
118
+ this.globe.DrawRender();
119
+ };
120
+ // ---------------point program setters-------------------
121
+ TimeTrackMultiColorPlugin.prototype.setPointOpacity = function (opacity) {
122
+ this._pointOptions.opacity = opacity;
123
+ if (this.pointProgram) {
124
+ this.pointProgram.setOpacity(opacity);
125
+ this.globe.DrawRender();
126
+ }
127
+ };
128
+ TimeTrackMultiColorPlugin.prototype.setPointSize = function (size) {
129
+ this._pointOptions.pointSize = size;
130
+ if (this.pointProgram) {
131
+ this.pointProgram.setPointSize(size);
132
+ this.globe.DrawRender();
133
+ }
134
+ };
135
+ TimeTrackMultiColorPlugin.prototype.pointSwitch = function (isOn) {
136
+ if (isOn && !this.pointProgram) {
137
+ this.pointProgram = this._createPointProgram();
138
+ }
139
+ else {
140
+ this._deletePointProgram();
141
+ }
142
+ };
143
+ // ------------------------------------------------------------
144
+ TimeTrackMultiColorPlugin.prototype._createPointProgram = function () {
145
+ var gl = this.gl;
146
+ var program = new programpoint_1.default(gl, this.globe, this._attrBuffer, this._pointOptions);
147
+ program.setDrawCount(this._totalSize / 2);
148
+ return program;
149
+ };
150
+ TimeTrackMultiColorPlugin.prototype._deletePointProgram = function () {
151
+ if (this.pointProgram)
152
+ this.pointProgram.free();
153
+ this.pointProgram = null;
154
+ };
155
+ // -------------------------------------------------------------
156
+ TimeTrackMultiColorPlugin.prototype.isReady = function () {
157
+ return this._ready;
158
+ };
159
+ /**
160
+ * @param {TimeTrackMultiColorData} data {@link TimeTrackMultiColorData}
161
+ * Check Class constructor
162
+ */
163
+ TimeTrackMultiColorPlugin.prototype.setData = function (data) {
164
+ if (this.gl) {
165
+ this._ready = false;
166
+ this.setDataAsFloat32Array(data);
167
+ this._ready = true;
168
+ }
169
+ else {
170
+ this._data = data;
171
+ this._ready = false;
172
+ }
173
+ };
174
+ /**
175
+ * @param {TimeTrackMultiColorData} data {@link TimeTrackMultiColorData}
176
+ * @param {number} totalSize | if not provided, it is calculated from float32Array.length / 9. Use if you want to draw first n points.
177
+ */
178
+ TimeTrackMultiColorPlugin.prototype.setDataAsFloat32Array = function (data, totalSize) {
179
+ var _a;
180
+ if (totalSize === void 0) { totalSize = null; }
181
+ var _b = this, gl = _b.gl, _attrBuffer = _b._attrBuffer;
182
+ gl.bindBuffer(gl.ARRAY_BUFFER, _attrBuffer);
183
+ gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
184
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
185
+ // this.program.setInBuffer(data);
186
+ // this.pointProgram.setData(data);
187
+ if (totalSize) {
188
+ this._totalSize = totalSize;
189
+ }
190
+ else {
191
+ this._totalSize = data.length / 9;
192
+ }
193
+ this.program.setTotalLength(this._totalSize);
194
+ (_a = this.pointProgram) === null || _a === void 0 ? void 0 : _a.setDrawCount(this._totalSize / 2);
195
+ this._ready = true;
196
+ };
197
+ // ------------------------------
198
+ // --- globe Methods ---
199
+ // ------------------------------
200
+ TimeTrackMultiColorPlugin.prototype.draw3D = function (projMatrix, modelviewMatrix, transPos) {
201
+ var _a;
202
+ if (!this._ready)
203
+ return;
204
+ var _b = this, _headTime = _b._headTime, _tailTime = _b._tailTime, program = _b.program, _transporArr = _b._transporArr, globe = _b.globe;
205
+ (_a = this.pointProgram) === null || _a === void 0 ? void 0 : _a.draw();
206
+ _transporArr.set([transPos.x, transPos.y, transPos.z], 0);
207
+ var geomType = globe.api_GetCurrentGeometry();
208
+ if (geomType === 0) {
209
+ program.draw(_headTime, _tailTime, projMatrix, modelviewMatrix, _transporArr);
210
+ }
211
+ else if (geomType === 1) {
212
+ var _c = globe.api_GetCurrentWorldWH(), width = _c.width, height = _c.height;
213
+ program.draw(_headTime, _tailTime, projMatrix, modelviewMatrix, _transporArr, [width, height]);
214
+ }
215
+ else {
216
+ console.error("Unknown geometry type", geomType);
217
+ }
218
+ };
219
+ TimeTrackMultiColorPlugin.prototype.resize = function (width, height) {
220
+ var _a = this, program = _a.program, globe = _a.globe;
221
+ width = width || globe.api_ScrW();
222
+ height = height || globe.api_ScrH();
223
+ program.resize(width, height);
224
+ };
225
+ TimeTrackMultiColorPlugin.prototype.init = function (globe, gl) {
226
+ var _a;
227
+ this.globe = globe;
228
+ this.gl = gl;
229
+ this._attrBuffer = gl.createBuffer();
230
+ this.program = new program_1.default(gl, this._attrBuffer, globe.api_ScrW(), globe.api_ScrH(), this._options);
231
+ if ((_a = this._pointOptions) === null || _a === void 0 ? void 0 : _a.isOn)
232
+ this.pointProgram = new programpoint_1.default(gl, globe, this._attrBuffer);
233
+ // this.pointProgram.setAttrBuffer(_attrBuffer);
234
+ this.setGeometry();
235
+ if (this._data) {
236
+ this._ready = true;
237
+ this.setDataAsFloat32Array(this._data);
238
+ this._data = null;
239
+ }
240
+ this.resize();
241
+ };
242
+ TimeTrackMultiColorPlugin.prototype.free = function () {
243
+ var _a = this, gl = _a.gl, _attrBuffer = _a._attrBuffer;
244
+ this.program.free();
245
+ gl.deleteBuffer(_attrBuffer);
246
+ };
247
+ TimeTrackMultiColorPlugin.prototype.setGeometry = function () {
248
+ var _a = this, globe = _a.globe, program = _a.program;
249
+ program.setIs3D(globe.api_GetCurrentGeometry() === 0);
250
+ };
251
+ // ----------------------------------
252
+ // --- implicit methods ---
253
+ // ----------------------------------
254
+ TimeTrackMultiColorPlugin.prototype._latLongToPixelXY = function (latitude, longitude) {
255
+ return {
256
+ x: (longitude + 180) / 360,
257
+ y: (90 - latitude) / 180
258
+ };
259
+ };
260
+ return TimeTrackMultiColorPlugin;
261
+ }());
262
+ exports.default = TimeTrackMultiColorPlugin;