@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,18 +1,66 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PointOnGlobeProgramCache = void 0;
4
- var util_1 = require("../../util");
5
- var totems_1 = require("../totems");
6
- var geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
7
- var programcache_1 = require("../programcache");
8
- var vs = "#version 300 es\n".concat(totems_1.CameraUniformBlockString, "\n").concat(geometrytransformations_1.mercatorXYToGLPosition, "\n").concat(geometrytransformations_1.cartesian3DToGLPosition, "\nprecision highp float;\nprecision highp int;\n\nuniform int hovered_vertexID; // can be removed\n\nin vec3 pos3D;\nin vec2 pos2D;\nin vec4 rgba;\n\nuniform float pointSize;\nuniform float hoveredPointSize;\n\nflat out highp int vVertexID;\n\n\nout vec4 v_rgba;\n\nvoid main() {\n\n if(is3D){\n gl_Position = cartesian3DToGLPosition(pos3D);\n }\n else{\n gl_Position = mercatorXYToGLPosition(pos2D);\n }\n if (hovered_vertexID == gl_VertexID) {\n gl_PointSize = hoveredPointSize;\n } else {\n gl_PointSize = pointSize;\n }\n v_rgba = rgba;\n vVertexID = gl_VertexID;\n}");
9
- var fs = "#version 300 es\nprecision highp float;\n\nuniform float opacity;\n\nflat in highp int vVertexID;\nin vec4 v_rgba;\n\nlayout(location = 0) out vec4 fragColor;\nlayout(location = 1) out int vertexID;\n\nvoid main() {\n vertexID = vVertexID; \n fragColor = v_rgba;\n fragColor.a *= opacity;\n}";
10
- var PointOnGlobeProgram = /** @class */ (function () {
11
- function PointOnGlobeProgram(globe) {
1
+ import { createProgram } from "../../util";
2
+ import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems";
3
+ import { mercatorXYToGLPosition, cartesian3DToGLPosition } from "../../util/shaderfunctions/geometrytransformations";
4
+ import { noRegisterGlobeProgramCache } from "../programcache";
5
+ const vs = `#version 300 es
6
+ ${CameraUniformBlockString}
7
+ ${mercatorXYToGLPosition}
8
+ ${cartesian3DToGLPosition}
9
+ precision highp float;
10
+ precision highp int;
11
+
12
+ uniform int hovered_vertexID; // can be removed
13
+
14
+ in vec3 pos3D;
15
+ in vec2 pos2D;
16
+ in vec4 rgba;
17
+
18
+ uniform float pointSize;
19
+ uniform float hoveredPointSize;
20
+
21
+ flat out highp int vVertexID;
22
+
23
+
24
+ out vec4 v_rgba;
25
+
26
+ void main() {
27
+
28
+ if(is3D){
29
+ gl_Position = cartesian3DToGLPosition(pos3D);
30
+ }
31
+ else{
32
+ gl_Position = mercatorXYToGLPosition(pos2D);
33
+ }
34
+ if (hovered_vertexID == gl_VertexID) {
35
+ gl_PointSize = hoveredPointSize;
36
+ } else {
37
+ gl_PointSize = pointSize;
38
+ }
39
+ v_rgba = rgba;
40
+ vVertexID = gl_VertexID;
41
+ }`;
42
+ const fs = `#version 300 es
43
+ precision highp float;
44
+
45
+ uniform float opacity;
46
+
47
+ flat in highp int vVertexID;
48
+ in vec4 v_rgba;
49
+
50
+ layout(location = 0) out vec4 fragColor;
51
+ layout(location = 1) out int vertexID;
52
+
53
+ void main() {
54
+ vertexID = vVertexID;
55
+ fragColor = v_rgba;
56
+ fragColor.a *= opacity;
57
+ }`;
58
+ class PointOnGlobeProgram {
59
+ constructor(globe) {
12
60
  this.globe = globe;
13
61
  this.gl = globe.gl;
14
- this.program = (0, util_1.createProgram)(this.gl, vs, fs);
15
- var _a = this, gl = _a.gl, program = _a.program;
62
+ this.program = createProgram(this.gl, vs, fs);
63
+ const { gl, program } = this;
16
64
  this.uniforms = {
17
65
  opacity: gl.getUniformLocation(program, "opacity"),
18
66
  hovered_vertexID: gl.getUniformLocation(program, "hovered_vertexID"),
@@ -25,7 +73,7 @@ var PointOnGlobeProgram = /** @class */ (function () {
25
73
  this._lastPointSize = 2.0;
26
74
  this._lastHoveredPointSize = 4.0;
27
75
  this._lastHoveredID = -1;
28
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
76
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
29
77
  gl.useProgram(program);
30
78
  gl.uniform1f(this.uniforms.opacity, this._lastOpacity);
31
79
  gl.uniform1f(this.uniforms.pointSize, this._lastPointSize);
@@ -42,14 +90,14 @@ var PointOnGlobeProgram = /** @class */ (function () {
42
90
  // eslint-disable-next-line
43
91
  { // arrange camera uniform block
44
92
  this.cameraBlockBingingPoint = 0;
45
- this.cameraBlockTotem = totems_1.CameraUniformBlockTotemCache.get(globe);
46
- var cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
93
+ this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
94
+ const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
47
95
  gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBingingPoint);
48
96
  }
49
97
  }
50
- PointOnGlobeProgram.prototype.createVAO = function (pos3DBuffer, pos2DBuffer, rgbaBuffer) {
51
- var gl = this.gl;
52
- var vao = gl.createVertexArray();
98
+ createVAO(pos3DBuffer, pos2DBuffer, rgbaBuffer) {
99
+ const { gl } = this;
100
+ const vao = gl.createVertexArray();
53
101
  gl.bindVertexArray(vao);
54
102
  // eslint-disable-next-line
55
103
  {
@@ -72,12 +120,11 @@ var PointOnGlobeProgram = /** @class */ (function () {
72
120
  gl.bindVertexArray(null);
73
121
  gl.bindBuffer(gl.ARRAY_BUFFER, null);
74
122
  return vao;
75
- };
76
- PointOnGlobeProgram.prototype.draw = function (vao, length, _a) {
77
- var _b = _a === void 0 ? {} : _a, _c = _b.opacity, opacity = _c === void 0 ? 1.0 : _c, _d = _b.hoveredID, hoveredID = _d === void 0 ? -1 : _d, _e = _b.pointSize, pointSize = _e === void 0 ? 2.0 : _e, _f = _b.hoveredPointSize, hoveredPointSize = _f === void 0 ? 4.0 : _f, _g = _b.elementBuffer, elementBuffer = _g === void 0 ? null : _g;
123
+ }
124
+ draw(vao, length, { opacity = 1.0, hoveredID = -1, pointSize = 2.0, hoveredPointSize = 4.0, elementBuffer = null } = {}) {
78
125
  if (length === 0 || opacity === 0)
79
126
  return;
80
- var _h = this, gl = _h.gl, program = _h.program, uniforms = _h.uniforms;
127
+ const { gl, program, uniforms } = this;
81
128
  gl.useProgram(program);
82
129
  if (this._lastOpacity !== opacity) {
83
130
  gl.uniform1f(uniforms.opacity, opacity);
@@ -107,19 +154,18 @@ var PointOnGlobeProgram = /** @class */ (function () {
107
154
  }
108
155
  this.cameraBlockTotem.unbind(this.cameraBlockBingingPoint);
109
156
  gl.bindVertexArray(null);
110
- };
111
- PointOnGlobeProgram.prototype.free = function () {
157
+ }
158
+ free() {
112
159
  if (this._isFreed)
113
160
  return;
114
- var _a = this, gl = _a.gl, globe = _a.globe;
115
- totems_1.CameraUniformBlockTotemCache.release(globe);
161
+ const { gl, globe } = this;
162
+ CameraUniformBlockTotemCache.release(globe);
116
163
  gl.deleteProgram(this.program);
117
164
  this._isFreed = true;
118
- };
119
- return PointOnGlobeProgram;
120
- }());
121
- var PointOnGlobeProgramCache = Object.freeze({
122
- get: function (globe) { return programcache_1.noRegisterGlobeProgramCache.getProgram(globe, PointOnGlobeProgram); },
123
- release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, PointOnGlobeProgram); }
165
+ }
166
+ }
167
+ const PointOnGlobeProgramCache = Object.freeze({
168
+ get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, PointOnGlobeProgram),
169
+ release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, PointOnGlobeProgram)
124
170
  });
125
- exports.PointOnGlobeProgramCache = PointOnGlobeProgramCache;
171
+ export { PointOnGlobeProgramCache };
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * @module programcache
4
3
  * @description This module provides a cache for programs. It is used to avoid creating the same program multiple times.
@@ -12,10 +11,8 @@
12
11
  * The programs created by are lightweight absraction of program logic with `constructer(gl)`.
13
12
  * These programs are generally wrapped by another class with more functionality.
14
13
  */
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.noRegisterGlobeProgramCache = exports.glProgramCache = exports.globeProgramCache = void 0;
17
- var globeProgramCache = (function () {
18
- var cache = new Map();
14
+ const globeProgramCache = (function () {
15
+ const cache = new Map();
19
16
  function getProgram(globe, ProgramClass) {
20
17
  if (!cache.has(globe)) {
21
18
  cache.set(globe, new Map());
@@ -26,7 +23,7 @@ var globeProgramCache = (function () {
26
23
  program: new ProgramClass(),
27
24
  count: 1
28
25
  });
29
- var firstObject = globe.DrawOrder.GetObj(0);
26
+ const firstObject = globe.DrawOrder.GetObj(0);
30
27
  globe.api_RegisterPlugin(cache.get(globe).get(ProgramClass).program, firstObject);
31
28
  }
32
29
  else {
@@ -49,13 +46,12 @@ var globeProgramCache = (function () {
49
46
  }
50
47
  ;
51
48
  return Object.freeze({
52
- getProgram: getProgram,
53
- releaseProgram: releaseProgram
49
+ getProgram,
50
+ releaseProgram
54
51
  });
55
52
  })();
56
- exports.globeProgramCache = globeProgramCache;
57
- var glProgramCache = (function () {
58
- var cache = new Map();
53
+ const glProgramCache = (function () {
54
+ const cache = new Map();
59
55
  function getProgram(gl, ProgramClass) {
60
56
  if (!cache.has(gl)) {
61
57
  cache.set(gl, new Map());
@@ -87,13 +83,12 @@ var glProgramCache = (function () {
87
83
  }
88
84
  ;
89
85
  return Object.freeze({
90
- getProgram: getProgram,
91
- releaseProgram: releaseProgram
86
+ getProgram,
87
+ releaseProgram
92
88
  });
93
89
  })();
94
- exports.glProgramCache = glProgramCache;
95
- var noRegisterGlobeProgramCache = (function () {
96
- var cache = new Map();
90
+ const noRegisterGlobeProgramCache = (function () {
91
+ const cache = new Map();
97
92
  function getProgram(globe, ProgramClass) {
98
93
  if (!cache.has(globe)) {
99
94
  cache.set(globe, new Map());
@@ -124,8 +119,8 @@ var noRegisterGlobeProgramCache = (function () {
124
119
  }
125
120
  }
126
121
  return Object.freeze({
127
- getProgram: getProgram,
128
- releaseProgram: releaseProgram
122
+ getProgram,
123
+ releaseProgram
129
124
  });
130
125
  })();
131
- exports.noRegisterGlobeProgramCache = noRegisterGlobeProgramCache;
126
+ export { globeProgramCache, glProgramCache, noRegisterGlobeProgramCache };
@@ -1,61 +1,68 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.programCache = void 0;
37
- var util_1 = require("../../../util");
38
- var camerauniformblock_1 = __importStar(require("../../totems/camerauniformblock"));
39
- var programcache_1 = require("../../programcache");
40
- var CIRCLE_EDGE_COUNT = 360;
41
- var vertexShader = "#version 300 es " +
42
- util_1.shaderfunctions.PI +
43
- util_1.shaderfunctions.R +
44
- util_1.shaderfunctions.POLE +
45
- camerauniformblock_1.CameraUniformBlockString +
46
- util_1.shaderfunctions.mercatorXYToGLPosition +
47
- util_1.shaderfunctions.longLatRadToMercator +
48
- util_1.shaderfunctions.longLatRadToCartesian3D +
49
- util_1.shaderfunctions.circleLimpFromLongLatRadCenterCartesian3D +
50
- util_1.shaderfunctions.circleLimpFromLongLatRadCenterMercatorCompass +
51
- util_1.shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistance + "\n\nuniform int compass;\nuniform float circle_edge_count;\n\nuniform float opacity;\n\nin vec2 center;\nin float radius;\nin vec4 color;\nin float flag;\nout vec4 v_color;\nout vec2 v_limp;\n\nvoid main() {\n if( flag == 1.0 || radius == 0.0) return; // flag 1.0 is hide\n v_color = vec4(color.rgb, color.a * opacity);\n if ( gl_VertexID == 270 ) v_color.rgb += 0.2;\n float angle = 3.1415926535897932384626433832795 * 2.0 * (float(gl_VertexID) / circle_edge_count);\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 \n}";
52
- var fragmentShader = "#version 300 es\nprecision highp float;" +
53
- util_1.shaderfunctions.POLE + "\n\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}";
54
- var Logic = /** @class */ (function () {
55
- function Logic(globe) {
1
+ import { createProgram, shaderfunctions } from "../../../util";
2
+ import CameraUniformBlockTotem, { CameraUniformBlockString } from "../../totems/camerauniformblock";
3
+ import { noRegisterGlobeProgramCache, globeProgramCache } from "../../programcache";
4
+ const CIRCLE_EDGE_COUNT = 360;
5
+ const vertexShader = `#version 300 es ` +
6
+ shaderfunctions.PI +
7
+ shaderfunctions.R +
8
+ shaderfunctions.POLE +
9
+ CameraUniformBlockString +
10
+ shaderfunctions.mercatorXYToGLPosition +
11
+ shaderfunctions.longLatRadToMercator +
12
+ shaderfunctions.longLatRadToCartesian3D +
13
+ shaderfunctions.circleLimpFromLongLatRadCenterCartesian3D +
14
+ shaderfunctions.circleLimpFromLongLatRadCenterMercatorCompass +
15
+ shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistance + `
16
+
17
+ uniform int compass;
18
+ uniform float circle_edge_count;
19
+
20
+ uniform float opacity;
21
+
22
+ in vec2 center;
23
+ in float radius;
24
+ in vec4 color;
25
+ in float flag;
26
+ out vec4 v_color;
27
+ out vec2 v_limp;
28
+
29
+ void main() {
30
+ if( flag == 1.0 || radius == 0.0) return; // flag 1.0 is hide
31
+ v_color = vec4(color.rgb, color.a * opacity);
32
+ if ( gl_VertexID == 270 ) v_color.rgb += 0.2;
33
+ float angle = 3.1415926535897932384626433832795 * 2.0 * (float(gl_VertexID) / circle_edge_count);
34
+ if ( is3D ){
35
+ gl_Position = projection * view * vec4(
36
+ circleLimpFromLongLatRadCenterCartesian3D( center, radius, angle) - translate, 1.0);
37
+ v_limp = vec2(0.0, 0.0);
38
+ return;
39
+ }
40
+ vec2 limp;
41
+ if ( compass == 1 ){
42
+ limp = circleLimpFromLongLatRadCenterMercatorCompass(center, radius, angle);
43
+ } else {
44
+ limp = circleLimpFromLongLatRadCenterMercatorRealDistance(center, radius, angle);
45
+ }
46
+ v_limp = limp;
47
+ gl_Position = mercatorXYToGLPosition(limp);
48
+
49
+ }`;
50
+ const fragmentShader = `#version 300 es
51
+ precision highp float;` +
52
+ shaderfunctions.POLE + `
53
+
54
+ in vec4 v_color;
55
+ in vec2 v_limp;
56
+ out vec4 outColor;
57
+ void main() {
58
+ if ( v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE ){ discard; }
59
+ outColor = v_color;
60
+ }`;
61
+ class Logic {
62
+ constructor(globe) {
56
63
  this.globe = globe;
57
64
  this.gl = globe.gl;
58
- this.program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
65
+ this.program = createProgram(this.gl, vertexShader, fragmentShader);
59
66
  { // bind positions so bufferManager can use them
60
67
  this.gl.bindAttribLocation(this.program, 0, "center");
61
68
  this.gl.bindAttribLocation(this.program, 1, "radius");
@@ -63,8 +70,8 @@ var Logic = /** @class */ (function () {
63
70
  this.gl.bindAttribLocation(this.program, 3, "flag");
64
71
  }
65
72
  this.cameraBlockBindingPoint = 0;
66
- this.cameraBlockTotem = programcache_1.globeProgramCache.getProgram(globe, camerauniformblock_1.default);
67
- var cameraBlockIndex = this.gl.getUniformBlockIndex(this.program, "CameraUniformBlock");
73
+ this.cameraBlockTotem = globeProgramCache.getProgram(globe, CameraUniformBlockTotem);
74
+ const cameraBlockIndex = this.gl.getUniformBlockIndex(this.program, "CameraUniformBlock");
68
75
  this.gl.uniformBlockBinding(this.program, cameraBlockIndex, this.cameraBlockBindingPoint);
69
76
  this._opacityLocation = this.gl.getUniformLocation(this.program, "opacity");
70
77
  this._compassLocation = this.gl.getUniformLocation(this.program, "compass");
@@ -73,7 +80,7 @@ var Logic = /** @class */ (function () {
73
80
  this._compassmode = 1;
74
81
  this._opacity = 1.0;
75
82
  {
76
- var currentProgram = this.gl.getParameter(this.gl.CURRENT_PROGRAM);
83
+ const currentProgram = this.gl.getParameter(this.gl.CURRENT_PROGRAM);
77
84
  this.gl.useProgram(this.program);
78
85
  this.gl.uniform1i(this._compassLocation, 1);
79
86
  this.gl.uniform1f(this._circleEdgeCountLocation, CIRCLE_EDGE_COUNT);
@@ -81,8 +88,8 @@ var Logic = /** @class */ (function () {
81
88
  this.gl.useProgram(currentProgram);
82
89
  }
83
90
  }
84
- Logic.prototype.draw = function (attrBufferManager, compass, circleEdgeCount, opacity) {
85
- var _a = this, gl = _a.gl, program = _a.program, cameraBlockTotem = _a.cameraBlockTotem, cameraBlockBindingPoint = _a.cameraBlockBindingPoint;
91
+ draw(attrBufferManager, compass, circleEdgeCount, opacity) {
92
+ const { gl, program, cameraBlockTotem, cameraBlockBindingPoint } = this;
86
93
  gl.useProgram(program);
87
94
  cameraBlockTotem.bind(cameraBlockBindingPoint);
88
95
  attrBufferManager.bindCircleVAO();
@@ -101,14 +108,13 @@ var Logic = /** @class */ (function () {
101
108
  gl.drawArraysInstanced(gl.LINE_LOOP, 0, circleEdgeCount, attrBufferManager.length);
102
109
  gl.bindVertexArray(null);
103
110
  cameraBlockTotem.unbind(cameraBlockBindingPoint);
104
- };
105
- Logic.prototype.free = function () {
111
+ }
112
+ free() {
106
113
  this.gl.deleteProgram(this.program);
107
- programcache_1.globeProgramCache.releaseProgram(this.globe, camerauniformblock_1.default);
108
- };
109
- return Logic;
110
- }());
111
- exports.programCache = Object.freeze({
112
- getProgram: function (globe) { return programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic); },
113
- releaseProgram: function (globe) { programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic); }
114
+ globeProgramCache.releaseProgram(this.globe, CameraUniformBlockTotem);
115
+ }
116
+ }
117
+ export const programCache = Object.freeze({
118
+ getProgram: (globe) => { return noRegisterGlobeProgramCache.getProgram(globe, Logic); },
119
+ releaseProgram: (globe) => { noRegisterGlobeProgramCache.releaseProgram(globe, Logic); }
114
120
  });