@pirireis/webglobeplugins 0.9.11 → 0.9.12

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 (166) hide show
  1. package/Math/angle-calculation.js +8 -8
  2. package/Math/arc.js +18 -18
  3. package/Math/bounds/line-bbox.js +78 -80
  4. package/Math/constants.js +3 -3
  5. package/Math/juction/arc-plane.js +23 -23
  6. package/Math/juction/line-sphere.js +11 -11
  7. package/Math/juction/plane-plane.js +11 -11
  8. package/Math/line.js +14 -16
  9. package/Math/methods.js +65 -70
  10. package/Math/plane.js +16 -18
  11. package/Math/quaternion.js +45 -49
  12. package/Math/utils.js +2 -2
  13. package/Math/vec3.js +42 -45
  14. package/algorithms/search-binary.js +4 -4
  15. package/altitude-locator/draw-subset-obj.js +7 -8
  16. package/altitude-locator/plugin.js +98 -114
  17. package/arrowfield/adaptor.js +3 -4
  18. package/arrowfield/index.js +2 -2
  19. package/arrowfield/plugin.js +62 -65
  20. package/bearing-line/index.js +1 -1
  21. package/bearing-line/plugin.js +200 -226
  22. package/circle-line-chain/chain-list-map.js +82 -88
  23. package/circle-line-chain/plugin.js +134 -165
  24. package/circle-line-chain/util.js +1 -1
  25. package/compass-rose/compass-rose-padding-flat.js +108 -133
  26. package/compass-rose/compass-text-writer.js +62 -70
  27. package/compass-rose/index.js +2 -2
  28. package/compassrose/compassrose.js +46 -50
  29. package/compassrose/index.js +1 -1
  30. package/heatwave/index.js +2 -2
  31. package/heatwave/isobar/objectarraylabels.js +44 -48
  32. package/heatwave/isobar/plugin.js +104 -123
  33. package/heatwave/isobar/quadtreecontours.js +76 -92
  34. package/heatwave/plugins/heatwaveglobeshell.js +69 -87
  35. package/index.js +11 -11
  36. package/package.json +1 -1
  37. package/partialrings/buffer-manager.js +32 -64
  38. package/partialrings/index.js +1 -1
  39. package/partialrings/plugin.js +48 -84
  40. package/partialrings/program.js +136 -47
  41. package/pin/pin-object-array.js +83 -86
  42. package/pin/pin-point-totem.js +21 -22
  43. package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +10 -10
  44. package/point-heat-map/plugin-webworker.js +40 -45
  45. package/point-heat-map/point-to-heat-map-flow.js +40 -42
  46. package/point-tracks/key-methods.js +1 -1
  47. package/point-tracks/plugin.js +137 -162
  48. package/programs/arrowfield/index.js +1 -1
  49. package/programs/arrowfield/logic.js +170 -62
  50. package/programs/arrowfield/object.js +33 -35
  51. package/programs/data2legend/density-to-legend.js +45 -21
  52. package/programs/data2legend/point-to-density-texture.js +52 -27
  53. package/programs/float2legendwithratio/index.js +1 -1
  54. package/programs/float2legendwithratio/logic.js +88 -42
  55. package/programs/float2legendwithratio/object.js +43 -46
  56. package/programs/globe-util/is-globe-moved.js +10 -11
  57. package/programs/globeshell/index.js +1 -1
  58. package/programs/globeshell/wiggle/index.js +1 -1
  59. package/programs/globeshell/wiggle/logic.js +191 -98
  60. package/programs/globeshell/wiggle/object.js +33 -35
  61. package/programs/helpers/blender/program.js +36 -19
  62. package/programs/helpers/fadeaway/index.js +1 -1
  63. package/programs/helpers/fadeaway/logic.js +35 -13
  64. package/programs/helpers/fadeaway/object.js +9 -10
  65. package/programs/helpers/index.js +1 -1
  66. package/programs/index.js +8 -8
  67. package/programs/line-on-globe/angled-line.js +91 -32
  68. package/programs/line-on-globe/circle-accurate-3d.js +82 -32
  69. package/programs/line-on-globe/circle-accurate-flat.js +108 -50
  70. package/programs/line-on-globe/circle-accurate.js +103 -33
  71. package/programs/line-on-globe/circle.js +97 -32
  72. package/programs/line-on-globe/degree-padding-around-circle-3d.js +83 -33
  73. package/programs/line-on-globe/lines-color-instanced-flat.js +79 -34
  74. package/programs/line-on-globe/linestrip.js +111 -45
  75. package/programs/line-on-globe/naive-accurate-flexible.js +120 -50
  76. package/programs/line-on-globe/to-the-surface.js +58 -29
  77. package/programs/line-on-globe/util.js +1 -1
  78. package/programs/picking/pickable-renderer.js +117 -33
  79. package/programs/point-on-globe/element-globe-surface-glow.js +78 -38
  80. package/programs/point-on-globe/element-point-glow.js +103 -35
  81. package/programs/point-on-globe/square-pixel-point.js +76 -27
  82. package/programs/programcache.js +13 -13
  83. package/programs/rings/distancering/circleflatprogram.js +63 -21
  84. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +156 -145
  85. package/programs/rings/distancering/circlepaddysharedbuffer.js +121 -197
  86. package/programs/rings/distancering/index.js +4 -4
  87. package/programs/rings/distancering/paddyflatprogram.js +73 -20
  88. package/programs/rings/distancering/paddyflatprogram2d.js +75 -22
  89. package/programs/rings/distancering/paddyflatprogram3d.js +73 -20
  90. package/programs/rings/partial-ring/piece-of-pie.js +137 -35
  91. package/programs/totems/camerauniformblock.js +64 -51
  92. package/programs/totems/canvas-webglobe-info.js +48 -40
  93. package/programs/totems/gpu-selection-uniform-block.js +44 -40
  94. package/programs/totems/index.js +1 -1
  95. package/programs/two-d/pixel-padding-for-compass.js +90 -29
  96. package/programs/util.js +6 -7
  97. package/programs/vectorfields/index.js +1 -1
  98. package/programs/vectorfields/logics/drawrectangleparticles.js +70 -29
  99. package/programs/vectorfields/logics/index.js +3 -3
  100. package/programs/vectorfields/logics/pixelbased.js +91 -35
  101. package/programs/vectorfields/logics/ubo.js +31 -25
  102. package/programs/vectorfields/pingpongbuffermanager.js +30 -34
  103. package/rangerings/index.js +4 -4
  104. package/rangerings/plugin.js +202 -258
  105. package/rangerings/rangeringangletext.js +108 -120
  106. package/rangerings/ring-account.js +52 -69
  107. package/shaders/fragment-toy/firework.js +55 -1
  108. package/shaders/fragment-toy/singularity.js +55 -1
  109. package/timetracks/adaptors-line-strip.js +26 -37
  110. package/timetracks/adaptors.js +47 -61
  111. package/timetracks/index.js +4 -4
  112. package/timetracks/plugin-line-strip.js +63 -71
  113. package/timetracks/plugin.js +69 -77
  114. package/timetracks/program-line-strip.js +296 -103
  115. package/timetracks/program.js +419 -113
  116. package/timetracks/programpoint-line-strip.js +97 -44
  117. package/timetracks/programpoint.js +90 -44
  118. package/util/account/bufferoffsetmanager.js +72 -95
  119. package/util/account/index.js +1 -1
  120. package/util/account/single-attribute-buffer-management/buffer-manager.js +44 -44
  121. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +68 -94
  122. package/util/account/single-attribute-buffer-management/index.js +3 -3
  123. package/util/account/single-attribute-buffer-management/object-store.js +29 -30
  124. package/util/account/util.js +2 -4
  125. package/util/algorithms/search-binary.js +4 -4
  126. package/util/check/get.js +5 -5
  127. package/util/check/typecheck.js +13 -15
  128. package/util/geometry/index.js +9 -11
  129. package/util/gl-util/buffer/attribute-loader.js +8 -20
  130. package/util/gl-util/buffer/index.js +1 -1
  131. package/util/gl-util/draw-options/methods.js +8 -9
  132. package/util/gl-util/uniform-block/manager.js +67 -67
  133. package/util/heatwavedatamanager/datamanager.js +56 -116
  134. package/util/heatwavedatamanager/index.js +2 -2
  135. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +37 -40
  136. package/util/heatwavedatamanager/pointcoordsmeta.js +9 -10
  137. package/util/index.js +6 -6
  138. package/util/interpolation/timetrack/index.js +1 -1
  139. package/util/interpolation/timetrack/timetrack-interpolator.js +27 -29
  140. package/util/interpolation/timetrack/web-worker-str.js +179 -1
  141. package/util/interpolation/timetrack/web-worker.js +4 -4
  142. package/util/jshelpers/data-filler.js +7 -7
  143. package/util/jshelpers/timefilters.js +7 -7
  144. package/util/picking/fence.js +7 -7
  145. package/util/picking/picker-displayer.js +46 -52
  146. package/util/programs/draw-texture-on-canvas.js +39 -21
  147. package/util/programs/shapesonglobe.js +104 -64
  148. package/util/programs/supersampletotextures.js +45 -39
  149. package/util/programs/texturetoglobe.js +98 -48
  150. package/util/shaderfunctions/geometrytransformations.js +322 -27
  151. package/util/shaderfunctions/nodata.js +7 -1
  152. package/util/shaderfunctions/noisefunctions.js +39 -9
  153. package/util/surface-line-data/arcs-to-cuts.js +20 -23
  154. package/util/webglobe/rasteroverlay.js +35 -37
  155. package/util/webglobjectbuilders.js +55 -60
  156. package/util/webglobjectbuilders1.js +48 -49
  157. package/waveparticles/adaptor.js +6 -7
  158. package/waveparticles/index.js +2 -2
  159. package/waveparticles/plugin.js +79 -84
  160. package/wind/imagetovectorfieldandmagnitude.js +15 -15
  161. package/wind/index.js +4 -4
  162. package/wind/plugin.js +453 -251
  163. package/wind/vectorfieldimage.js +5 -5
  164. package/write-text/attached-text-writer.js +46 -48
  165. package/write-text/context-text.js +51 -58
  166. package/write-text/context-text3.js +69 -74
@@ -1,19 +1,81 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PixelPaddingForFlatCompassCache = void 0;
4
- var util_1 = require("../../util");
5
- var totems_1 = require("../totems");
6
- var programcache_1 = require("../programcache");
7
- var vertexCount = 720;
8
- var vertexShaderSource = "#version 300 es\n".concat(totems_1.CameraUniformBlockString, "\n\nin vec2 screen_coordinate;\nin float pixel_radius_small_ratio;\nin float pixel_radius_big_ratio;\nin vec4 rgba;\nout vec4 v_rgba;\nuniform float plugin_opacity;\n\nvec3 coord_opacity(){\n float radius;\n float angle;\n float gap = (pixel_radius_big_ratio - pixel_radius_small_ratio);\n if( gl_VertexID % 2 == 0){\n // if( gl_VertexID % 180 == 0){\n // radius = pixel_radius_small_ratio ;\n // } else\n if ( gl_VertexID % 60 == 0){\n radius = pixel_radius_small_ratio; \n } else if( gl_VertexID % 10 == 0) {\n radius = pixel_radius_small_ratio + gap * 0.5;\n } else {\n radius = pixel_radius_small_ratio + gap* 0.75;\n }\n angle = (float(gl_VertexID) / (").concat(vertexCount, ".0));\n } else {\n if ( gl_VertexID % 180 == 1){\n radius = pixel_radius_big_ratio + gap * 0.1;\n\n } else {\n radius = pixel_radius_big_ratio;\n }\n angle = (float(gl_VertexID - 1) / (").concat(vertexCount, ".0));\n }\n float opacity = fract(angle + 0.2475) / 1.5 + 0.33;\n angle = angle * ").concat(Math.PI * 2.0, " + world_north_angle;\n radius = radius * min(screenWH.x, screenWH.y) / 2.0;;\n return vec3( screen_coordinate + vec2( cos(angle), sin(angle)) * radius, opacity);\n}\n\nvec2 adjust_pos(vec2 pos) {\n return vec2(\n (pos.x / screenWH.x - 0.5) * 2.0,\n (0.5 - pos.y / screenWH.y) * 2.0\n );\n}\n\nvoid main(){\n vec3 c = coord_opacity();\n gl_Position = vec4( adjust_pos(c.xy), 0.0, 1.0);\n v_rgba = rgba;\n v_rgba.a *= plugin_opacity;\n gl_PointSize = 10.0;\n}\n");
9
- var fragmentShaderSource = "#version 300 es\nprecision highp float;\nin vec4 v_rgba;\nout vec4 color;\nvoid main(){\n color = v_rgba;\n}\n";
10
- var Logic = /** @class */ (function () {
11
- function Logic(globe) {
4
+ const util_1 = require("../../util");
5
+ const totems_1 = require("../totems");
6
+ const programcache_1 = require("../programcache");
7
+ const vertexCount = 720;
8
+ const vertexShaderSource = `#version 300 es
9
+ ${totems_1.CameraUniformBlockString}
10
+
11
+ in vec2 screen_coordinate;
12
+ in float pixel_radius_small_ratio;
13
+ in float pixel_radius_big_ratio;
14
+ in vec4 rgba;
15
+ out vec4 v_rgba;
16
+ uniform float plugin_opacity;
17
+
18
+ vec3 coord_opacity(){
19
+ float radius;
20
+ float angle;
21
+ float gap = (pixel_radius_big_ratio - pixel_radius_small_ratio);
22
+ if( gl_VertexID % 2 == 0){
23
+ // if( gl_VertexID % 180 == 0){
24
+ // radius = pixel_radius_small_ratio ;
25
+ // } else
26
+ if ( gl_VertexID % 60 == 0){
27
+ radius = pixel_radius_small_ratio;
28
+ } else if( gl_VertexID % 10 == 0) {
29
+ radius = pixel_radius_small_ratio + gap * 0.5;
30
+ } else {
31
+ radius = pixel_radius_small_ratio + gap* 0.75;
32
+ }
33
+ angle = (float(gl_VertexID) / (${vertexCount}.0));
34
+ } else {
35
+ if ( gl_VertexID % 180 == 1){
36
+ radius = pixel_radius_big_ratio + gap * 0.1;
37
+
38
+ } else {
39
+ radius = pixel_radius_big_ratio;
40
+ }
41
+ angle = (float(gl_VertexID - 1) / (${vertexCount}.0));
42
+ }
43
+ float opacity = fract(angle + 0.2475) / 1.5 + 0.33;
44
+ angle = angle * ${Math.PI * 2.0} + world_north_angle;
45
+ radius = radius * min(screenWH.x, screenWH.y) / 2.0;;
46
+ return vec3( screen_coordinate + vec2( cos(angle), sin(angle)) * radius, opacity);
47
+ }
48
+
49
+ vec2 adjust_pos(vec2 pos) {
50
+ return vec2(
51
+ (pos.x / screenWH.x - 0.5) * 2.0,
52
+ (0.5 - pos.y / screenWH.y) * 2.0
53
+ );
54
+ }
55
+
56
+ void main(){
57
+ vec3 c = coord_opacity();
58
+ gl_Position = vec4( adjust_pos(c.xy), 0.0, 1.0);
59
+ v_rgba = rgba;
60
+ v_rgba.a *= plugin_opacity;
61
+ gl_PointSize = 10.0;
62
+ }
63
+ `;
64
+ const fragmentShaderSource = `#version 300 es
65
+ precision highp float;
66
+ in vec4 v_rgba;
67
+ out vec4 color;
68
+ void main(){
69
+ color = v_rgba;
70
+ }
71
+ `;
72
+ class Logic {
73
+ constructor(globe) {
12
74
  this.globe = globe;
13
75
  this.gl = globe.gl;
14
76
  this._lastOpacity = 1;
15
77
  this.program = (0, util_1.createProgram)(this.gl, vertexShaderSource, fragmentShaderSource);
16
- var _a = this, gl = _a.gl, program = _a.program;
78
+ const { gl, program } = this;
17
79
  { // assign attribute locations
18
80
  // in vec2 screen_coordinate;
19
81
  // in float pixel_radius_small_ratio;
@@ -26,20 +88,20 @@ var Logic = /** @class */ (function () {
26
88
  }
27
89
  {
28
90
  this._opacityLocation = gl.getUniformLocation(program, "plugin_opacity");
29
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
91
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
30
92
  gl.useProgram(program);
31
93
  gl.uniform1f(this._opacityLocation, this._lastOpacity);
32
94
  gl.useProgram(currentProgram);
33
95
  }
34
96
  {
35
97
  this.cameraBlockBindingPoint = 0;
36
- var cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
98
+ const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
37
99
  this.cameraBlockTotem = totems_1.CameraUniformBlockTotemCache.get(globe);
38
100
  gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
39
101
  }
40
102
  }
41
- Logic.prototype.draw = function (vao, length, opacity) {
42
- var _a = this, globe = _a.globe, gl = _a.gl, program = _a.program, cameraBlockTotem = _a.cameraBlockTotem, cameraBlockBindingPoint = _a.cameraBlockBindingPoint, _opacityLocation = _a._opacityLocation;
103
+ draw(vao, length, opacity) {
104
+ const { globe, gl, program, cameraBlockTotem, cameraBlockBindingPoint, _opacityLocation } = this;
43
105
  if (globe.api_GetCurrentGeometry() === 0)
44
106
  return;
45
107
  gl.useProgram(program);
@@ -52,34 +114,34 @@ var Logic = /** @class */ (function () {
52
114
  gl.drawArraysInstanced(gl.LINES, 0, vertexCount, length);
53
115
  gl.bindVertexArray(null);
54
116
  cameraBlockTotem.unbind(cameraBlockBindingPoint);
55
- };
56
- Logic.prototype.createVAO = function (screenCoordsBufferObj, pixelRadiusRatioSmallBufferObj, pixelRadiusRatioBigBufferObj, rgbaBufferObj) {
57
- var gl = this.gl;
58
- var vao = gl.createVertexArray();
117
+ }
118
+ createVAO(screenCoordsBufferObj, pixelRadiusRatioSmallBufferObj, pixelRadiusRatioBigBufferObj, rgbaBufferObj) {
119
+ const { gl } = this;
120
+ const vao = gl.createVertexArray();
59
121
  gl.bindVertexArray(vao);
60
122
  {
61
- var buffer = screenCoordsBufferObj.buffer, _a = screenCoordsBufferObj.stride, stride = _a === void 0 ? 0 : _a, _b = screenCoordsBufferObj.offset, offset = _b === void 0 ? 0 : _b;
123
+ const { buffer, stride = 0, offset = 0 } = screenCoordsBufferObj;
62
124
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
63
125
  gl.enableVertexAttribArray(0);
64
126
  gl.vertexAttribPointer(0, 2, gl.FLOAT, false, stride, offset);
65
127
  gl.vertexAttribDivisor(0, 1);
66
128
  }
67
129
  {
68
- var buffer = pixelRadiusRatioSmallBufferObj.buffer, _c = pixelRadiusRatioSmallBufferObj.stride, stride = _c === void 0 ? 0 : _c, _d = pixelRadiusRatioSmallBufferObj.offset, offset = _d === void 0 ? 0 : _d;
130
+ const { buffer, stride = 0, offset = 0 } = pixelRadiusRatioSmallBufferObj;
69
131
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
70
132
  gl.enableVertexAttribArray(1);
71
133
  gl.vertexAttribPointer(1, 1, gl.FLOAT, false, stride, offset);
72
134
  gl.vertexAttribDivisor(1, 1);
73
135
  }
74
136
  {
75
- var buffer = pixelRadiusRatioBigBufferObj.buffer, _e = pixelRadiusRatioBigBufferObj.stride, stride = _e === void 0 ? 0 : _e, _f = pixelRadiusRatioBigBufferObj.offset, offset = _f === void 0 ? 0 : _f;
137
+ const { buffer, stride = 0, offset = 0 } = pixelRadiusRatioBigBufferObj;
76
138
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
77
139
  gl.enableVertexAttribArray(2);
78
140
  gl.vertexAttribPointer(2, 1, gl.FLOAT, false, stride, offset);
79
141
  gl.vertexAttribDivisor(2, 1);
80
142
  }
81
143
  {
82
- var buffer = rgbaBufferObj.buffer, _g = rgbaBufferObj.stride, stride = _g === void 0 ? 0 : _g, _h = rgbaBufferObj.offset, offset = _h === void 0 ? 0 : _h;
144
+ const { buffer, stride = 0, offset = 0 } = rgbaBufferObj;
83
145
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
84
146
  gl.enableVertexAttribArray(3);
85
147
  gl.vertexAttribPointer(3, 4, gl.FLOAT, false, stride, offset);
@@ -88,14 +150,13 @@ var Logic = /** @class */ (function () {
88
150
  gl.bindVertexArray(null);
89
151
  gl.bindBuffer(gl.ARRAY_BUFFER, null);
90
152
  return vao;
91
- };
92
- Logic.prototype.free = function () {
93
- var globe = this.globe;
153
+ }
154
+ free() {
155
+ const { globe } = this;
94
156
  totems_1.CameraUniformBlockTotemCache.release(globe);
95
- };
96
- return Logic;
97
- }());
157
+ }
158
+ }
98
159
  exports.PixelPaddingForFlatCompassCache = Object.freeze({
99
- get: function (globe) { return programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic); },
100
- release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic); }
160
+ get: (globe) => programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic),
161
+ release: (globe) => programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
101
162
  });
package/programs/util.js CHANGED
@@ -1,15 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.longlatbbox2normalbbox = longlatbbox2normalbbox;
4
- function longlatbbox2normalbbox(_a) {
5
- var _b = _a === void 0 ? {} : _a, _c = _b.minLon, minLon = _c === void 0 ? -180 : _c, _d = _b.maxLon, maxLon = _d === void 0 ? 180 : _d, _e = _b.minLat, minLat = _e === void 0 ? -90 : _e, _f = _b.maxLat, maxLat = _f === void 0 ? 90 : _f;
4
+ function longlatbbox2normalbbox({ minLon = -180, maxLon = 180, minLat = -90, maxLat = 90 } = {}) {
6
5
  // x
7
- var horOffset = (minLon) * Math.PI / 180;
8
- var horSize = (maxLon - minLon) * Math.PI / 180;
6
+ const horOffset = (minLon) * Math.PI / 180;
7
+ const horSize = (maxLon - minLon) * Math.PI / 180;
9
8
  // y
10
- var vertOffset = (90 - maxLat) * Math.PI / 180;
11
- var vertSize = (maxLat - minLat) * Math.PI / 180;
12
- var result = {
9
+ const vertOffset = (90 - maxLat) * Math.PI / 180;
10
+ const vertSize = (maxLat - minLat) * Math.PI / 180;
11
+ const result = {
13
12
  bboxOffsetRad: new Float32Array([horOffset, vertOffset]),
14
13
  bboxSizeRad: new Float32Array([horSize, vertSize])
15
14
  };
@@ -18,6 +18,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.PingPongBufferManager = void 0;
21
- var pingpongbuffermanager_1 = __importDefault(require("./pingpongbuffermanager"));
21
+ const pingpongbuffermanager_1 = __importDefault(require("./pingpongbuffermanager"));
22
22
  exports.PingPongBufferManager = pingpongbuffermanager_1.default;
23
23
  __exportStar(require("./logics"), exports);
@@ -1,35 +1,78 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var util_1 = require("../../../util");
4
- var ubo_js_1 = require("./ubo.js");
5
- var programcache_1 = require("../../programcache");
3
+ const util_1 = require("../../../util");
4
+ const ubo_js_1 = require("./ubo.js");
5
+ const programcache_1 = require("../../programcache");
6
6
  /**
7
7
  * [+] ubo
8
8
  */
9
- var vertexShaderSource = "#version 300 es\nprecision highp float;\n" + ubo_js_1.shaderUboSource + "\nuniform sampler2D u_vector_field;\nin vec2 in_position;\nout vec3 base_color;\nvec2 lookup_wind(const vec2 uv) { // gerek kalmayabilir. sampler linear methodu ayni isi yapiyor \n // return texture(u_vector_field, uv).rg; // lower-res hardware filtering\n vec2 res = vec2(textureSize(u_vector_field, 0));\n vec2 px = 1.0 / res;\n vec2 vc = (floor(uv * res)) * px;\n vec2 f = fract(uv * res);\n vec2 tl = texture(u_vector_field, vc).rg;\n vec2 tr = texture(u_vector_field, vc + vec2(px.x, 0)).rg;\n vec2 bl = texture(u_vector_field, vc + vec2(0, px.y)).rg;\n vec2 br = texture(u_vector_field, vc + px).rg;\n return mix(mix(tl, tr, f.x), mix(bl, br, f.x), f.y);\n}\n\n\nvoid main(){\n vec2 direction_vector = lookup_wind(in_position);\n if (direction_vector.r == 0.0 && direction_vector.g == 0.0){ return;}\n\n vec2 limp;\n if ( 0 == gl_VertexID) { limp = -tail_wing_base_limp; }\n else if ( 1 == gl_VertexID) { limp = vec2( tail_wing_base_limp.x, -tail_wing_base_limp.y); }\n else if ( 2 == gl_VertexID) { limp = tail_wing_base_limp; }\n else { limp = vec2(-tail_wing_base_limp.x, tail_wing_base_limp.y); } // if ( 3 == gl_VertexID)\n\n limp = (limp * mat2( \n direction_vector.x, -direction_vector.y,\n direction_vector.y, direction_vector.x)) / draw_texture_size;\n\n vec2 pos = in_position * 2.0 - 1.0;\n gl_Position = vec4(pos + limp, 0.0, 1.0);\n base_color = color;\n}";
10
- var fragmentShaderSource = "#version 300 es\nprecision highp float;\nout vec4 outColor;\nin vec3 base_color;\nvoid main(){\n outColor = vec4(base_color, 1.0);\n}";
11
- var Logic = /** @class */ (function () {
12
- function Logic(gl) {
13
- var _a;
9
+ const vertexShaderSource = `#version 300 es
10
+ precision highp float;
11
+ ` + ubo_js_1.shaderUboSource + `
12
+ uniform sampler2D u_vector_field;
13
+ in vec2 in_position;
14
+ out vec3 base_color;
15
+ vec2 lookup_wind(const vec2 uv) { // gerek kalmayabilir. sampler linear methodu ayni isi yapiyor
16
+ // return texture(u_vector_field, uv).rg; // lower-res hardware filtering
17
+ vec2 res = vec2(textureSize(u_vector_field, 0));
18
+ vec2 px = 1.0 / res;
19
+ vec2 vc = (floor(uv * res)) * px;
20
+ vec2 f = fract(uv * res);
21
+ vec2 tl = texture(u_vector_field, vc).rg;
22
+ vec2 tr = texture(u_vector_field, vc + vec2(px.x, 0)).rg;
23
+ vec2 bl = texture(u_vector_field, vc + vec2(0, px.y)).rg;
24
+ vec2 br = texture(u_vector_field, vc + px).rg;
25
+ return mix(mix(tl, tr, f.x), mix(bl, br, f.x), f.y);
26
+ }
27
+
28
+
29
+ void main(){
30
+ vec2 direction_vector = lookup_wind(in_position);
31
+ if (direction_vector.r == 0.0 && direction_vector.g == 0.0){ return;}
32
+
33
+ vec2 limp;
34
+ if ( 0 == gl_VertexID) { limp = -tail_wing_base_limp; }
35
+ else if ( 1 == gl_VertexID) { limp = vec2( tail_wing_base_limp.x, -tail_wing_base_limp.y); }
36
+ else if ( 2 == gl_VertexID) { limp = tail_wing_base_limp; }
37
+ else { limp = vec2(-tail_wing_base_limp.x, tail_wing_base_limp.y); } // if ( 3 == gl_VertexID)
38
+
39
+ limp = (limp * mat2(
40
+ direction_vector.x, -direction_vector.y,
41
+ direction_vector.y, direction_vector.x)) / draw_texture_size;
42
+
43
+ vec2 pos = in_position * 2.0 - 1.0;
44
+ gl_Position = vec4(pos + limp, 0.0, 1.0);
45
+ base_color = color;
46
+ }`;
47
+ const fragmentShaderSource = `#version 300 es
48
+ precision highp float;
49
+ out vec4 outColor;
50
+ in vec3 base_color;
51
+ void main(){
52
+ outColor = vec4(base_color, 1.0);
53
+ }`;
54
+ class Logic {
55
+ constructor(gl) {
14
56
  this.gl = gl;
15
- _a = this._createProgram(), this.program = _a[0], this._vector_field_location = _a[1];
57
+ [this.program,
58
+ this._vector_field_location] = this._createProgram();
16
59
  // this.decoyBuffer = new DecoyBufferManager(gl);
17
60
  }
18
- Logic.prototype._createProgram = function () {
19
- var gl = this.gl;
20
- var program = (0, util_1.createProgram)(gl, vertexShaderSource, fragmentShaderSource);
61
+ _createProgram() {
62
+ const gl = this.gl;
63
+ const program = (0, util_1.createProgram)(gl, vertexShaderSource, fragmentShaderSource);
21
64
  // ubo point
22
- var ubo_location = gl.getUniformBlockIndex(program, 'UBO');
65
+ const ubo_location = gl.getUniformBlockIndex(program, 'UBO');
23
66
  gl.uniformBlockBinding(program, ubo_location, ubo_js_1.UBO_BINDING_POINT);
24
67
  return [program, gl.getUniformLocation(program, 'u_vector_field')];
25
- };
68
+ }
26
69
  /**
27
70
  * @param {*} bufferManager | PingPongBufferManager
28
71
  * @param {*} vectorTexture | RG32F texture R: x, G: y
29
72
  * @param {*} uboManager | WaveParticalUboManager under ubo.js
30
73
  */
31
- Logic.prototype.draw = function (bufferManager, vectorTexture, uboManager) {
32
- var _a = this, gl = _a.gl, program = _a.program;
74
+ draw(bufferManager, vectorTexture, uboManager) {
75
+ const { gl, program } = this;
33
76
  gl.useProgram(program);
34
77
  gl.bindVertexArray(bufferManager.getSourceVao());
35
78
  // gl.bindVertexArray(this.decoyBuffer.getSourceVao());
@@ -41,26 +84,24 @@ var Logic = /** @class */ (function () {
41
84
  gl.drawArraysInstanced(gl.POINTS, 0, 4, bufferManager.length);
42
85
  gl.bindVertexArray(null);
43
86
  uboManager.unbind();
44
- };
45
- Logic.prototype.free = function () {
87
+ }
88
+ free() {
46
89
  this.gl.deleteProgram(this.program);
47
90
  this.program = null;
48
- };
49
- return Logic;
50
- }());
51
- var default_1 = /** @class */ (function () {
52
- function default_1(gl) {
91
+ }
92
+ }
93
+ class default_1 {
94
+ constructor(gl) {
53
95
  this.gl = gl;
54
96
  this.logic = programcache_1.glProgramCache.getProgram(gl, Logic);
55
97
  }
56
- default_1.prototype.draw = function (bufferManager, vectorTexture, uboManager) {
98
+ draw(bufferManager, vectorTexture, uboManager) {
57
99
  this.logic.draw(bufferManager, vectorTexture, uboManager);
58
- };
59
- default_1.prototype.free = function () {
100
+ }
101
+ free() {
60
102
  programcache_1.glProgramCache.releaseProgram(this.gl, Logic);
61
103
  this.logic = null;
62
104
  this.gl = null;
63
- };
64
- return default_1;
65
- }());
105
+ }
106
+ }
66
107
  exports.default = default_1;
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.WaveParticalUboManager = exports.DrawRectangleParticles = exports.PixelBasedMove = void 0;
7
- var pixelbased_1 = __importDefault(require("./pixelbased"));
7
+ const pixelbased_1 = __importDefault(require("./pixelbased"));
8
8
  exports.PixelBasedMove = pixelbased_1.default;
9
- var drawrectangleparticles_1 = __importDefault(require("./drawrectangleparticles"));
9
+ const drawrectangleparticles_1 = __importDefault(require("./drawrectangleparticles"));
10
10
  exports.DrawRectangleParticles = drawrectangleparticles_1.default;
11
- var ubo_1 = require("./ubo");
11
+ const ubo_1 = require("./ubo");
12
12
  Object.defineProperty(exports, "WaveParticalUboManager", { enumerable: true, get: function () { return ubo_1.WaveParticalUboManager; } });
@@ -1,27 +1,85 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var util_1 = require("../../../util");
4
- var ubo_js_1 = require("./ubo.js");
5
- var programcache_1 = require("../../programcache");
3
+ const util_1 = require("../../../util");
4
+ const ubo_js_1 = require("./ubo.js");
5
+ const programcache_1 = require("../../programcache");
6
6
  // program output is buffer
7
7
  // TODO: Mechanism for randomness
8
8
  // drop out mechanism
9
9
  // random particle position mechanism
10
- var vertexShaderSource = "#version 300 es\n" + ubo_js_1.shaderUboSource + "\n\nuniform sampler2D vector_field;\nin vec2 in_position;\nout vec2 out_position;\n\n// float random(vec2 st){\n// float t = dot(st, vec2(12.9898,78.233));\n// return fract(sin(t) * (t+43758.5453123));\n// }\n\n\nconst vec3 rand_constants = vec3(12.9898, 78.233, 4375.85453);\nfloat random(const vec2 co) {\n float t = dot(rand_constants.xy, co);\n return fract(sin(t) * (rand_constants.z + t));\n}\n\nvec2 lookup_wind(const vec2 uv) { // gerek kalmayabilir. sampler linear methodu ayni isi yapiyor\n // return texture(vector_field, uv).rg; // lower-res hardware filtering\n vec2 res = vec2(textureSize(vector_field, 0));\n if (res.x == 0.0 || res.y == 0.0){ return vec2(0.0);}\n vec2 px = 1.0 / res;\n vec2 vc = (floor(uv * res)) * px;\n vec2 f = fract(uv * res);\n vec2 tl = texture(vector_field, vc).rg;\n vec2 tr = texture(vector_field, vc + vec2(px.x, 0)).rg;\n vec2 bl = texture(vector_field, vc + vec2(0, px.y)).rg;\n vec2 br = texture(vector_field, vc + px).rg;\n if (tl.x == 0.0 && tl.y == 0.0){ return vec2(0.0);}\n if (tr.x == 0.0 && tr.y == 0.0){ return vec2(0.0);}\n if (bl.x == 0.0 && bl.y == 0.0){ return vec2(0.0);}\n if (br.x == 0.0 && br.y == 0.0){ return vec2(0.0);}\n return mix(mix(tl, tr, f.x), mix(bl, br, f.x), f.y);\n}\n\n\nvec2 random_position(vec2 st){\n return vec2(random(st), random(st + 1.0));\n}\n\n\nvoid main(){\n vec2 vec = lookup_wind(in_position).xy;\n if (vec.x == 0.0 && vec.y == 0.0){\n out_position = random_position(in_position);\n return;\n }\n float random_value = random(in_position + random_seed);\n if (random_value < drop_rate){ //TODO: more sophisticated drop out mechanism mi\n out_position = random_position(in_position);\n return;\n }\n out_position = in_position - (vec / draw_texture_size) * range; //*0.0014\n}\n";
11
- var fragmentShaderSource = "#version 300 es\nprecision highp float;\nvoid main(){\n}";
12
- var Logic = /** @class */ (function () {
13
- function Logic(gl) {
14
- var _a;
10
+ const vertexShaderSource = `#version 300 es
11
+ ` + ubo_js_1.shaderUboSource + `
12
+
13
+ uniform sampler2D vector_field;
14
+ in vec2 in_position;
15
+ out vec2 out_position;
16
+
17
+ // float random(vec2 st){
18
+ // float t = dot(st, vec2(12.9898,78.233));
19
+ // return fract(sin(t) * (t+43758.5453123));
20
+ // }
21
+
22
+
23
+ const vec3 rand_constants = vec3(12.9898, 78.233, 4375.85453);
24
+ float random(const vec2 co) {
25
+ float t = dot(rand_constants.xy, co);
26
+ return fract(sin(t) * (rand_constants.z + t));
27
+ }
28
+
29
+ vec2 lookup_wind(const vec2 uv) { // gerek kalmayabilir. sampler linear methodu ayni isi yapiyor
30
+ // return texture(vector_field, uv).rg; // lower-res hardware filtering
31
+ vec2 res = vec2(textureSize(vector_field, 0));
32
+ if (res.x == 0.0 || res.y == 0.0){ return vec2(0.0);}
33
+ vec2 px = 1.0 / res;
34
+ vec2 vc = (floor(uv * res)) * px;
35
+ vec2 f = fract(uv * res);
36
+ vec2 tl = texture(vector_field, vc).rg;
37
+ vec2 tr = texture(vector_field, vc + vec2(px.x, 0)).rg;
38
+ vec2 bl = texture(vector_field, vc + vec2(0, px.y)).rg;
39
+ vec2 br = texture(vector_field, vc + px).rg;
40
+ if (tl.x == 0.0 && tl.y == 0.0){ return vec2(0.0);}
41
+ if (tr.x == 0.0 && tr.y == 0.0){ return vec2(0.0);}
42
+ if (bl.x == 0.0 && bl.y == 0.0){ return vec2(0.0);}
43
+ if (br.x == 0.0 && br.y == 0.0){ return vec2(0.0);}
44
+ return mix(mix(tl, tr, f.x), mix(bl, br, f.x), f.y);
45
+ }
46
+
47
+
48
+ vec2 random_position(vec2 st){
49
+ return vec2(random(st), random(st + 1.0));
50
+ }
51
+
52
+
53
+ void main(){
54
+ vec2 vec = lookup_wind(in_position).xy;
55
+ if (vec.x == 0.0 && vec.y == 0.0){
56
+ out_position = random_position(in_position);
57
+ return;
58
+ }
59
+ float random_value = random(in_position + random_seed);
60
+ if (random_value < drop_rate){ //TODO: more sophisticated drop out mechanism mi
61
+ out_position = random_position(in_position);
62
+ return;
63
+ }
64
+ out_position = in_position - (vec / draw_texture_size) * range; //*0.0014
65
+ }
66
+ `;
67
+ const fragmentShaderSource = `#version 300 es
68
+ precision highp float;
69
+ void main(){
70
+ }`;
71
+ class Logic {
72
+ constructor(gl) {
15
73
  this.gl = gl;
16
- _a = this._createProgram(), this.program = _a[0], this._vector_field_location = _a[1];
74
+ [this.program, this._vector_field_location] = this._createProgram();
17
75
  }
18
76
  /**
19
77
  * @param {*} bufferManager | PingPongBufferManager
20
78
  * @param {*} vectorTexture RG32F texture R: x, G: y
21
79
  * @param {*} uboManager | WaveParticalUboManager under ubo.js
22
80
  */
23
- Logic.prototype.move = function (bufferManager, vectorTexture, uboManager) {
24
- var _a = this, gl = _a.gl, program = _a.program, _vector_field_location = _a._vector_field_location;
81
+ move(bufferManager, vectorTexture, uboManager) {
82
+ const { gl, program, _vector_field_location } = this;
25
83
  gl.useProgram(program);
26
84
  gl.enable(gl.RASTERIZER_DISCARD);
27
85
  gl.bindVertexArray(bufferManager.getSourceVao());
@@ -37,13 +95,13 @@ var Logic = /** @class */ (function () {
37
95
  gl.bindVertexArray(null);
38
96
  uboManager.unbind();
39
97
  gl.disable(gl.RASTERIZER_DISCARD);
40
- };
98
+ }
41
99
  // -- private methods
42
- Logic.prototype._createProgram = function () {
43
- var gl = this.gl;
44
- var vertexShader = (0, util_1.createShader)(gl, gl.VERTEX_SHADER, vertexShaderSource);
45
- var fragmentShader = (0, util_1.createShader)(gl, gl.FRAGMENT_SHADER, fragmentShaderSource);
46
- var program = gl.createProgram();
100
+ _createProgram() {
101
+ const gl = this.gl;
102
+ const vertexShader = (0, util_1.createShader)(gl, gl.VERTEX_SHADER, vertexShaderSource);
103
+ const fragmentShader = (0, util_1.createShader)(gl, gl.FRAGMENT_SHADER, fragmentShaderSource);
104
+ const program = gl.createProgram();
47
105
  gl.attachShader(program, vertexShader);
48
106
  gl.attachShader(program, fragmentShader);
49
107
  gl.transformFeedbackVaryings(program, ["out_position"], gl.SEPARATE_ATTRIBS);
@@ -51,36 +109,34 @@ var Logic = /** @class */ (function () {
51
109
  if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
52
110
  throw new Error(gl.getProgramParameter(program));
53
111
  }
54
- var ubo_location = gl.getUniformBlockIndex(program, 'UBO');
112
+ const ubo_location = gl.getUniformBlockIndex(program, 'UBO');
55
113
  gl.uniformBlockBinding(program, ubo_location, ubo_js_1.UBO_BINDING_POINT);
56
114
  return [program, gl.getUniformLocation(program, 'vector_field')];
57
115
  ;
58
- };
59
- Logic.prototype.free = function () {
116
+ }
117
+ free() {
60
118
  this.gl.deleteProgram(this.program);
61
119
  this.program = null;
62
- };
63
- Logic.prototype.getInPositionLocation = function () {
120
+ }
121
+ getInPositionLocation() {
64
122
  return this.gl.getAttribLocation(this.program, 'in_position');
65
- };
66
- return Logic;
67
- }());
68
- var default_1 = /** @class */ (function () {
69
- function default_1(gl) {
123
+ }
124
+ }
125
+ class default_1 {
126
+ constructor(gl) {
70
127
  this.gl = gl;
71
128
  this.logic = programcache_1.glProgramCache.getProgram(gl, Logic);
72
129
  }
73
- default_1.prototype.move = function (bufferManager, vectorTexture, uboManager) {
130
+ move(bufferManager, vectorTexture, uboManager) {
74
131
  this.logic.move(bufferManager, vectorTexture, uboManager);
75
- };
76
- default_1.prototype.free = function () {
132
+ }
133
+ free() {
77
134
  programcache_1.glProgramCache.releaseProgram(this.gl, Logic);
78
135
  this.program = null;
79
136
  this.gl = null;
80
- };
81
- default_1.prototype.getInPositionLocation = function () {
137
+ }
138
+ getInPositionLocation() {
82
139
  return this.logic.getInPositionLocation();
83
- };
84
- return default_1;
85
- }());
140
+ }
141
+ }
86
142
  exports.default = default_1;
@@ -1,22 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.shaderUboSource = exports.UBO_BINDING_POINT = exports.UBO_SIZE = exports.WaveParticalUboManager = void 0;
4
- var UBO_BINDING_POINT = 0;
4
+ const UBO_BINDING_POINT = 0;
5
5
  exports.UBO_BINDING_POINT = UBO_BINDING_POINT;
6
- var INITIAL_UBO_DATA = new Float32Array([93.17, 0.2, 1.0, 7.0, 1.0, 1.0, 1.0, 0.05, 2000, 2000]);
7
- var shaderUboSource = "\nlayout(std140) uniform UBO {\n float random_seed;\n float range;\n vec2 tail_wing_base_limp;\n vec3 color;\n float drop_rate;\n vec2 draw_texture_size;\n};";
6
+ const INITIAL_UBO_DATA = new Float32Array([93.17, 0.2, 1.0, 7.0, 1.0, 1.0, 1.0, 0.05, 2000, 2000]);
7
+ const shaderUboSource = `
8
+ layout(std140) uniform UBO {
9
+ float random_seed;
10
+ float range;
11
+ vec2 tail_wing_base_limp;
12
+ vec3 color;
13
+ float drop_rate;
14
+ vec2 draw_texture_size;
15
+ };`;
8
16
  exports.shaderUboSource = shaderUboSource;
9
- var UBO_SIZE = 40;
17
+ const UBO_SIZE = 40;
10
18
  exports.UBO_SIZE = UBO_SIZE;
11
- var WaveParticalUboManager = /** @class */ (function () {
12
- function WaveParticalUboManager(gl) {
19
+ class WaveParticalUboManager {
20
+ constructor(gl) {
13
21
  this.gl = gl;
14
22
  this.ubo = this._createBuffer();
15
23
  this._data = null;
16
24
  }
17
- WaveParticalUboManager.prototype.update = function (_a) {
18
- var range = _a.range, random_seed = _a.random_seed, tail_wing_base_limp = _a.tail_wing_base_limp, draw_texture_size = _a.draw_texture_size, drop_rate = _a.drop_rate, color = _a.color;
19
- var _b = this, gl = _b.gl, ubo = _b.ubo;
25
+ update({ range, random_seed, tail_wing_base_limp, draw_texture_size, drop_rate, color }) {
26
+ const { gl, ubo } = this;
20
27
  gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
21
28
  if (random_seed !== undefined)
22
29
  gl.bufferSubData(gl.UNIFORM_BUFFER, 0, new Float32Array([random_seed]));
@@ -31,27 +38,26 @@ var WaveParticalUboManager = /** @class */ (function () {
31
38
  if (draw_texture_size !== undefined)
32
39
  gl.bufferSubData(gl.UNIFORM_BUFFER, 32, new Float32Array(draw_texture_size));
33
40
  gl.bindBuffer(gl.UNIFORM_BUFFER, null);
34
- };
35
- WaveParticalUboManager.prototype._createBuffer = function () {
36
- var gl = this.gl;
37
- var buffer = gl.createBuffer();
41
+ }
42
+ _createBuffer() {
43
+ const gl = this.gl;
44
+ const buffer = gl.createBuffer();
38
45
  gl.bindBuffer(gl.UNIFORM_BUFFER, buffer);
39
46
  gl.bufferData(gl.UNIFORM_BUFFER, INITIAL_UBO_DATA, gl.STATIC_DRAW);
40
47
  gl.bindBuffer(gl.UNIFORM_BUFFER, null);
41
48
  return buffer;
42
- };
43
- WaveParticalUboManager.prototype.bind = function () {
44
- var _a = this, gl = _a.gl, ubo = _a.ubo;
49
+ }
50
+ bind() {
51
+ const { gl, ubo } = this;
45
52
  gl.bindBufferBase(gl.UNIFORM_BUFFER, UBO_BINDING_POINT, ubo);
46
- };
47
- WaveParticalUboManager.prototype.unbind = function () {
48
- var gl = this.gl;
53
+ }
54
+ unbind() {
55
+ const gl = this.gl;
49
56
  gl.bindBufferBase(gl.UNIFORM_BUFFER, UBO_BINDING_POINT, null);
50
- };
51
- WaveParticalUboManager.prototype.free = function () {
52
- var _a = this, gl = _a.gl, _buffer = _a._buffer;
57
+ }
58
+ free() {
59
+ const { gl, _buffer } = this;
53
60
  gl.deleteBuffer(_buffer);
54
- };
55
- return WaveParticalUboManager;
56
- }());
61
+ }
62
+ }
57
63
  exports.WaveParticalUboManager = WaveParticalUboManager;