@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,358 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }) : function(o, v) {
31
+ o["default"] = v;
32
+ });
33
+ var __importStar = (this && this.__importStar) || (function () {
34
+ var ownKeys = function(o) {
35
+ ownKeys = Object.getOwnPropertyNames || function (o) {
36
+ var ar = [];
37
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
38
+ return ar;
39
+ };
40
+ return ownKeys(o);
41
+ };
42
+ return function (mod) {
43
+ if (mod && mod.__esModule) return mod;
44
+ var result = {};
45
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
46
+ __setModuleDefault(result, mod);
47
+ return result;
48
+ };
49
+ })();
50
+ Object.defineProperty(exports, "__esModule", { value: true });
51
+ exports.BufferManager = exports.PaddingFreeAngleCache = void 0;
52
+ var util_1 = require("../../../util");
53
+ var account_1 = require("../../../util/account");
54
+ var camerauniformblock_1 = __importStar(require("../../totems/camerauniformblock"));
55
+ var programcache_1 = require("../../programcache");
56
+ var vertexShader = "#version 300 es " +
57
+ util_1.shaderfunctions.PI +
58
+ util_1.shaderfunctions.R +
59
+ util_1.shaderfunctions.POLE +
60
+ camerauniformblock_1.CameraUniformBlockString +
61
+ util_1.shaderfunctions.mercatorXYToGLPosition +
62
+ util_1.shaderfunctions.longLatRadToMercator +
63
+ util_1.shaderfunctions.longLatRadToCartesian3D +
64
+ util_1.shaderfunctions.circleLimpFromLongLatRadCenterCartesian3D +
65
+ util_1.shaderfunctions.circleLimpFromLongLatRadCenterMercatorCompass +
66
+ util_1.shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistance + "\n\nin vec2 center;\nin float radius;\nin float pad_range;\nin vec4 color;\nin float flag;\nin float pad_angle;\n\nuniform int compass;\n\nuniform float opacity;\n\nout vec2 v_limp;\nout vec4 v_color;\n\n\nvoid main() { \n if( flag == 1.0 || radius == 0.0 ) return; // 1.0 is hide \n v_color = vec4(color.rgb, color.a * opacity);\n\n if ( pad_angle == 0.0 ) v_color.rgb -= 0.2;\n gl_PointSize = 2.0;\n\n float odd = mod(float(gl_VertexID), 2.0);\n float index = (float(gl_VertexID)- odd ) / 2.0;\n float angle = pad_angle - 1.5707963267948966192313216916398;\n float radius_ = radius - (pad_range * odd);\n\n if (is3D){ \n gl_Position = projection * view * vec4(\n circleLimpFromLongLatRadCenterCartesian3D( center, radius_, angle) - translate, 1.0);\n v_limp = vec2(0.0, 0.0);\n return;\n }\n vec2 limp;\n if ( compass == 1 ){\n limp = circleLimpFromLongLatRadCenterMercatorCompass(center , radius_, angle);\n } else {\n limp = circleLimpFromLongLatRadCenterMercatorRealDistance(center, radius_, angle);\n }\n v_limp = limp;\n gl_Position = mercatorXYToGLPosition(limp);\n}";
67
+ var fragmentShader = "#version 300 es\nprecision highp float; " +
68
+ util_1.shaderfunctions.POLE + "\nin vec4 v_color;\nin vec2 v_limp;\nout vec4 outColor;\nvoid main() {\n if ( v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE ){ discard; }\n outColor = v_color;\n}";
69
+ var Logic = /** @class */ (function () {
70
+ function Logic(globe) {
71
+ this.globe = globe;
72
+ this.gl = globe.gl;
73
+ this.program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
74
+ {
75
+ var gl = this.gl;
76
+ // assign attribute locations
77
+ gl.bindAttribLocation(this.program, 0, "center");
78
+ gl.bindAttribLocation(this.program, 1, "radius");
79
+ gl.bindAttribLocation(this.program, 2, "pad_range");
80
+ gl.bindAttribLocation(this.program, 3, "color");
81
+ gl.bindAttribLocation(this.program, 4, "flag");
82
+ gl.bindAttribLocation(this.program, 5, "pad_angle");
83
+ }
84
+ this.cameraBlockBindingPoint = 0;
85
+ var cameraBlockIndex = this.gl.getUniformBlockIndex(this.program, "CameraUniformBlock");
86
+ this.gl.uniformBlockBinding(this.program, cameraBlockIndex, this.cameraBlockBindingPoint);
87
+ this.cameraBlockTotem = programcache_1.globeProgramCache.getProgram(globe, camerauniformblock_1.default);
88
+ this._compassLocation = this.gl.getUniformLocation(this.program, "compass");
89
+ this._opacityLocation = this.gl.getUniformLocation(this.program, "opacity");
90
+ this._opacity = 1.0;
91
+ {
92
+ var currentProgram = this.gl.getParameter(this.gl.CURRENT_PROGRAM);
93
+ this.gl.useProgram(this.program);
94
+ this.gl.uniform1i(this._compassLocation, 1);
95
+ this.gl.uniform1f(this._opacityLocation, 1.0);
96
+ this._lastCompass = 1;
97
+ this.gl.useProgram(currentProgram);
98
+ }
99
+ }
100
+ Logic.prototype.draw = function (attrBufferManager, compass, opacity) {
101
+ var _a = this, gl = _a.gl, program = _a.program, cameraBlockBindingPoint = _a.cameraBlockBindingPoint, cameraBlockTotem = _a.cameraBlockTotem, _compassLocation = _a._compassLocation;
102
+ gl.useProgram(program);
103
+ attrBufferManager.bindPaddingVAO();
104
+ cameraBlockTotem.bind(cameraBlockBindingPoint);
105
+ if (compass !== this._lastCompass) {
106
+ gl.uniform1i(_compassLocation, compass);
107
+ this._lastCompass = compass;
108
+ }
109
+ if (opacity !== this._opacity) {
110
+ gl.uniform1f(this._opacityLocation, opacity);
111
+ this._opacity = opacity;
112
+ }
113
+ gl.disable(gl.DEPTH_TEST);
114
+ gl.drawArraysInstanced(gl.LINES, 0, 2, attrBufferManager.length);
115
+ cameraBlockTotem.unbind(cameraBlockBindingPoint);
116
+ gl.enable(gl.DEPTH_TEST);
117
+ gl.bindVertexArray(null);
118
+ };
119
+ Logic.prototype.createBuffer = function (_a) {
120
+ var _b = _a === void 0 ? {} : _a, _c = _b.bufferType, bufferType = _c === void 0 ? "DYNAMIC_DRAW" : _c, _d = _b.initialRingCapacity, initialRingCapacity = _d === void 0 ? 10 : _d;
121
+ return new BufferManager(this.gl, bufferType, initialRingCapacity);
122
+ };
123
+ return Logic;
124
+ }());
125
+ exports.PaddingFreeAngleCache = Object.freeze({
126
+ getProgram: function (globe) { return programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic); },
127
+ releaseProgram: function (globe) { return programcache_1.globeProgramCache.releaseProgram(globe, Logic); }
128
+ });
129
+ var BufferManager = /** @class */ (function (_super) {
130
+ __extends(BufferManager, _super);
131
+ function BufferManager(gl, bufferType, initialRingCapacity) {
132
+ if (initialRingCapacity === void 0) { initialRingCapacity = 10; }
133
+ var _this = _super.call(this, 10, { capacity: initialRingCapacity, bufferType: bufferType }) || this;
134
+ _this.gl = gl;
135
+ _this.bufferType = bufferType;
136
+ _this.buffer = gl.createBuffer();
137
+ gl.bindBuffer(gl.ARRAY_BUFFER, _this.buffer);
138
+ gl.bufferData(gl.ARRAY_BUFFER, _this.capacity * _this.itemSize * 4, gl[bufferType]);
139
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
140
+ _this._centerMaps = new Map();
141
+ _this.vao = gl.createVertexArray();
142
+ {
143
+ gl.bindVertexArray(_this.vao);
144
+ gl.bindBuffer(gl.ARRAY_BUFFER, _this.buffer);
145
+ gl.enableVertexAttribArray(0);
146
+ gl.enableVertexAttribArray(1);
147
+ gl.enableVertexAttribArray(2);
148
+ gl.enableVertexAttribArray(3);
149
+ gl.enableVertexAttribArray(4);
150
+ gl.enableVertexAttribArray(5);
151
+ gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 40, 0);
152
+ gl.vertexAttribPointer(1, 1, gl.FLOAT, false, 40, 8);
153
+ gl.vertexAttribPointer(2, 1, gl.FLOAT, false, 40, 12);
154
+ gl.vertexAttribPointer(3, 4, gl.FLOAT, false, 40, 16);
155
+ gl.vertexAttribPointer(4, 1, gl.FLOAT, false, 40, 32);
156
+ gl.vertexAttribPointer(5, 1, gl.FLOAT, false, 40, 36);
157
+ // divisor
158
+ gl.vertexAttribDivisor(0, 1);
159
+ gl.vertexAttribDivisor(1, 1);
160
+ gl.vertexAttribDivisor(2, 1);
161
+ gl.vertexAttribDivisor(3, 1);
162
+ gl.vertexAttribDivisor(4, 1);
163
+ gl.vertexAttribDivisor(5, 1);
164
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
165
+ gl.bindVertexArray(null);
166
+ }
167
+ return _this;
168
+ }
169
+ BufferManager.prototype.__centerMapMethod = function (rings, paddingAngles) {
170
+ return new Map([
171
+ ["rings", rings],
172
+ ["paddingAngles", paddingAngles]
173
+ ]);
174
+ };
175
+ BufferManager.prototype.bindPaddingVAO = function () {
176
+ this.gl.bindVertexArray(this.vao);
177
+ };
178
+ //TODO: implement this
179
+ // insertBulk is gone. no update feature
180
+ // addBulk is added.
181
+ // deletes old centers given
182
+ BufferManager.prototype.insertBulk = function (data) {
183
+ var _a = this, gl = _a.gl, buffer = _a.buffer;
184
+ var deleteCentersList = [];
185
+ for (var _i = 0, data_1 = data; _i < data_1.length; _i++) {
186
+ var centerID = data_1[_i].centerID;
187
+ if (this._centerMaps.has(centerID)) {
188
+ deleteCentersList.push(centerID);
189
+ }
190
+ }
191
+ if (deleteCentersList.length > 0) {
192
+ this.removeCenters(deleteCentersList);
193
+ }
194
+ var requiredSpace = this.__requiredSpaceForBulk(data);
195
+ var spaceLeft = this.spaceLeft;
196
+ // console.log("space left:", spaceLeft, "required space:", requiredSpace);
197
+ if (requiredSpace > spaceLeft) {
198
+ // console.log("new capacity:", this.capacity + requiredSpace - spaceLeft)
199
+ this.extendBuffer(this.capacity + requiredSpace - spaceLeft);
200
+ }
201
+ var items = [];
202
+ for (var _b = 0, data_2 = data; _b < data_2.length; _b++) {
203
+ var _c = data_2[_b], centerID = _c.centerID, x = _c.x, y = _c.y, rgba = _c.rgba, paddingAngles = _c.paddingAngles, _d = _c.hide, hide = _d === void 0 ? 0 : _d, rings = _c.rings;
204
+ this._centerMaps.set(centerID, this.__centerMapMethod(rings, paddingAngles)); // x,y, rgba, hide prograbably not needed
205
+ for (var _e = 0, rings_1 = rings; _e < rings_1.length; _e++) {
206
+ var _f = rings_1[_e], ringID = _f.ringID, radius = _f.radius, padding = _f.padding;
207
+ for (var _g = 0, paddingAngles_1 = paddingAngles; _g < paddingAngles_1.length; _g++) {
208
+ var paddingAngle = paddingAngles_1[_g];
209
+ var _offsetMapKey = "".concat(centerID, "_").concat(ringID, "_").concat(paddingAngle);
210
+ var offset = this.getOffset(_offsetMapKey) | this.nextOffset();
211
+ items.push({
212
+ offset: offset,
213
+ payload: new Float32Array([x, y, radius, padding, rgba[0], rgba[1], rgba[2], rgba[3], hide, paddingAngle])
214
+ });
215
+ this.offSetMap.set(_offsetMapKey, offset);
216
+ }
217
+ }
218
+ }
219
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
220
+ for (var _h = 0, items_1 = items; _h < items_1.length; _h++) {
221
+ var _j = items_1[_h], offset = _j.offset, payload = _j.payload;
222
+ gl.bufferSubData(gl.ARRAY_BUFFER, offset, payload);
223
+ }
224
+ };
225
+ BufferManager.prototype.updateCentersXY = function (data) {
226
+ var _a = this, gl = _a.gl, buffer = _a.buffer;
227
+ var items = [];
228
+ for (var _i = 0, data_3 = data; _i < data_3.length; _i++) {
229
+ var _b = data_3[_i], centerID = _b.centerID, x = _b.x, y = _b.y;
230
+ var center = this._centerMaps.get(centerID);
231
+ var payload = new Float32Array([x, y]);
232
+ var paddingAngles = center.get("paddingAngles");
233
+ var rings = center.get("rings");
234
+ for (var _c = 0, rings_2 = rings; _c < rings_2.length; _c++) {
235
+ var ringID = rings_2[_c].ringID;
236
+ for (var _d = 0, paddingAngles_2 = paddingAngles; _d < paddingAngles_2.length; _d++) {
237
+ var paddingAngle = paddingAngles_2[_d];
238
+ var offsetKey = offsetMapKey(centerID, ringID, paddingAngle);
239
+ items.push({ offset: this.getOffset(offsetKey), payload: payload });
240
+ }
241
+ }
242
+ }
243
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
244
+ for (var _e = 0, items_2 = items; _e < items_2.length; _e++) {
245
+ var _f = items_2[_e], offset = _f.offset, payload = _f.payload;
246
+ gl.bufferSubData(gl.ARRAY_BUFFER, offset, payload);
247
+ }
248
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
249
+ };
250
+ //TODO: test
251
+ BufferManager.prototype.updateCentersHide = function (data) {
252
+ var _a = this, gl = _a.gl, buffer = _a.buffer;
253
+ var items = [];
254
+ for (var _i = 0, data_4 = data; _i < data_4.length; _i++) {
255
+ var _b = data_4[_i], centerID = _b.centerID, _c = _b.hide, hide = _c === void 0 ? null : _c;
256
+ if (hide === null)
257
+ continue;
258
+ var block = new Float32Array([hide]);
259
+ var center = this._centerMaps.get(centerID);
260
+ if (!center)
261
+ continue;
262
+ var paddingAngles = center.get("paddingAngles");
263
+ var rings = center.get("rings");
264
+ for (var _d = 0, rings_3 = rings; _d < rings_3.length; _d++) {
265
+ var ringID = rings_3[_d].ringID;
266
+ for (var _e = 0, paddingAngles_3 = paddingAngles; _e < paddingAngles_3.length; _e++) {
267
+ var paddingAngle = paddingAngles_3[_e];
268
+ var offsetKey = offsetMapKey(centerID, ringID, paddingAngle);
269
+ items.push({ key: offsetKey, payload: block });
270
+ }
271
+ }
272
+ }
273
+ this._updatePartial(items, 8, gl, buffer);
274
+ };
275
+ BufferManager.prototype.updateCentersColor = function (data) {
276
+ var _a = this, gl = _a.gl, buffer = _a.buffer;
277
+ var items = [];
278
+ for (var _i = 0, data_5 = data; _i < data_5.length; _i++) {
279
+ var _b = data_5[_i], centerID = _b.centerID, rgba = _b.rgba;
280
+ var center = this._centerMaps.get(centerID);
281
+ if (!center)
282
+ continue;
283
+ center.set("rgba", rgba);
284
+ var paddingAngles = center.get("paddingAngles");
285
+ var rings = center.get("rings");
286
+ var payload = new Float32Array(rgba);
287
+ for (var _c = 0, rings_4 = rings; _c < rings_4.length; _c++) {
288
+ var ringID = rings_4[_c].ringID;
289
+ for (var _d = 0, paddingAngles_4 = paddingAngles; _d < paddingAngles_4.length; _d++) {
290
+ var paddingAngle = paddingAngles_4[_d];
291
+ var offsetKey = offsetMapKey(centerID, ringID, paddingAngle);
292
+ items.push({ key: offsetKey, payload: payload });
293
+ }
294
+ }
295
+ }
296
+ this._updatePartial(items, 4, gl, buffer);
297
+ };
298
+ BufferManager.prototype.__requiredSpaceForBulk = function (data) {
299
+ var space = 0;
300
+ for (var _i = 0, data_6 = data; _i < data_6.length; _i++) {
301
+ var _a = data_6[_i], paddingAngles = _a.paddingAngles, rings = _a.rings;
302
+ space += paddingAngles.length * rings.length;
303
+ }
304
+ return space;
305
+ };
306
+ // TODO: TEST IT WITH INSERT
307
+ BufferManager.prototype.removeCenters = function (centerIDs) {
308
+ var keys = [];
309
+ for (var _i = 0, centerIDs_1 = centerIDs; _i < centerIDs_1.length; _i++) {
310
+ var centerID = centerIDs_1[_i];
311
+ var center = this._centerMaps.get(centerID);
312
+ if (!center)
313
+ continue;
314
+ var rings = center.get("rings");
315
+ var paddingAngles = center.get("paddingAngles");
316
+ for (var _a = 0, rings_5 = rings; _a < rings_5.length; _a++) {
317
+ var ringID = rings_5[_a].ringID;
318
+ for (var _b = 0, paddingAngles_5 = paddingAngles; _b < paddingAngles_5.length; _b++) {
319
+ var paddingAngle = paddingAngles_5[_b];
320
+ keys.push(offsetMapKey(centerID, ringID, paddingAngle));
321
+ }
322
+ }
323
+ this._centerMaps.delete(centerID);
324
+ }
325
+ this._removeFromBuffer(keys);
326
+ };
327
+ return BufferManager;
328
+ }(account_1.BufferOffsetManager));
329
+ exports.BufferManager = BufferManager;
330
+ var offsetMapKey = function (centerID, ringID, paddingAngle) { return "".concat(centerID, "_").concat(ringID, "_").concat(paddingAngle); };
331
+ /**
332
+ * {center has x,y, color, paddingAngles, rings} key: centerID
333
+ * {ring has ranges, paddings} key: ringKey
334
+ * _offSetMap => | key: centerID_ringKey_paddingAngle | value: offset |
335
+ *
336
+ * insertCenter
337
+ *
338
+ * insertRing
339
+ *
340
+ * updateCenter ---> updatesRings ---> updatesPaddings
341
+ * centerMap ringMap
342
+ * keeps keeps
343
+ * list of Rings list of Paddings
344
+ *
345
+ *
346
+ * needs an adaptor to convert currently implemented data into this format.
347
+ * current format:
348
+ * center = {
349
+ * centerID,
350
+ * x,
351
+ * y,
352
+ * rings: [
353
+ * radius,
354
+ * paddingRadius,
355
+ * rgba,
356
+ * ]
357
+ * }
358
+ */