@pirireis/webglobeplugins 0.9.10 → 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 (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 +80 -78
  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 +16 -14
  9. package/Math/methods.js +72 -67
  10. package/Math/plane.js +18 -16
  11. package/Math/quaternion.js +49 -45
  12. package/Math/utils.js +2 -2
  13. package/Math/vec3.js +45 -42
  14. package/algorithms/search-binary.js +4 -4
  15. package/altitude-locator/draw-subset-obj.js +8 -7
  16. package/altitude-locator/plugin.js +113 -97
  17. package/arrowfield/adaptor.js +4 -3
  18. package/arrowfield/index.js +2 -2
  19. package/arrowfield/plugin.js +65 -62
  20. package/bearing-line/index.js +1 -1
  21. package/bearing-line/plugin.js +225 -200
  22. package/circle-line-chain/chain-list-map.js +88 -82
  23. package/circle-line-chain/plugin.js +154 -129
  24. package/circle-line-chain/util.js +1 -1
  25. package/compass-rose/compass-rose-padding-flat.js +126 -104
  26. package/compass-rose/compass-text-writer.js +70 -62
  27. package/compass-rose/index.js +2 -2
  28. package/compassrose/compassrose.js +50 -46
  29. package/compassrose/index.js +1 -1
  30. package/heatwave/index.js +2 -2
  31. package/heatwave/isobar/objectarraylabels.js +48 -44
  32. package/heatwave/isobar/plugin.js +123 -104
  33. package/heatwave/isobar/quadtreecontours.js +92 -76
  34. package/heatwave/plugins/heatwaveglobeshell.js +87 -69
  35. package/index.js +11 -11
  36. package/package.json +1 -1
  37. package/partialrings/buffer-manager.js +64 -32
  38. package/partialrings/index.js +1 -1
  39. package/partialrings/plugin.js +84 -48
  40. package/partialrings/program.js +47 -136
  41. package/pin/pin-object-array.js +86 -83
  42. package/pin/pin-point-totem.js +22 -21
  43. package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +10 -10
  44. package/point-heat-map/plugin-webworker.js +45 -40
  45. package/point-heat-map/point-to-heat-map-flow.js +42 -40
  46. package/point-tracks/key-methods.js +1 -1
  47. package/point-tracks/plugin.js +142 -127
  48. package/programs/arrowfield/index.js +1 -1
  49. package/programs/arrowfield/logic.js +62 -170
  50. package/programs/arrowfield/object.js +35 -33
  51. package/programs/data2legend/density-to-legend.js +21 -45
  52. package/programs/data2legend/point-to-density-texture.js +27 -52
  53. package/programs/float2legendwithratio/index.js +1 -1
  54. package/programs/float2legendwithratio/logic.js +42 -88
  55. package/programs/float2legendwithratio/object.js +46 -43
  56. package/programs/globe-util/is-globe-moved.js +11 -10
  57. package/programs/globeshell/index.js +1 -1
  58. package/programs/globeshell/wiggle/index.js +1 -1
  59. package/programs/globeshell/wiggle/logic.js +98 -191
  60. package/programs/globeshell/wiggle/object.js +35 -33
  61. package/programs/helpers/blender/program.js +19 -36
  62. package/programs/helpers/fadeaway/index.js +1 -1
  63. package/programs/helpers/fadeaway/logic.js +13 -35
  64. package/programs/helpers/fadeaway/object.js +10 -9
  65. package/programs/helpers/index.js +1 -1
  66. package/programs/index.js +8 -8
  67. package/programs/line-on-globe/angled-line.js +32 -91
  68. package/programs/line-on-globe/circle-accurate-3d.js +32 -82
  69. package/programs/line-on-globe/circle-accurate-flat.js +50 -108
  70. package/programs/line-on-globe/circle-accurate.js +33 -103
  71. package/programs/line-on-globe/circle.js +32 -97
  72. package/programs/line-on-globe/degree-padding-around-circle-3d.js +33 -83
  73. package/programs/line-on-globe/lines-color-instanced-flat.js +34 -79
  74. package/programs/line-on-globe/linestrip.js +39 -100
  75. package/programs/line-on-globe/naive-accurate-flexible.js +48 -118
  76. package/programs/line-on-globe/to-the-surface.js +29 -58
  77. package/programs/line-on-globe/util.js +1 -1
  78. package/programs/picking/pickable-renderer.js +33 -117
  79. package/programs/point-on-globe/element-globe-surface-glow.js +38 -78
  80. package/programs/point-on-globe/element-point-glow.js +35 -103
  81. package/programs/point-on-globe/square-pixel-point.js +27 -76
  82. package/programs/programcache.js +13 -13
  83. package/programs/rings/distancering/circleflatprogram.js +21 -63
  84. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +145 -156
  85. package/programs/rings/distancering/circlepaddysharedbuffer.js +197 -121
  86. package/programs/rings/distancering/index.js +4 -4
  87. package/programs/rings/distancering/paddyflatprogram.js +20 -73
  88. package/programs/rings/distancering/paddyflatprogram2d.js +22 -75
  89. package/programs/rings/distancering/paddyflatprogram3d.js +20 -73
  90. package/programs/rings/partial-ring/piece-of-pie.js +35 -137
  91. package/programs/totems/camerauniformblock.js +51 -64
  92. package/programs/totems/canvas-webglobe-info.js +40 -48
  93. package/programs/totems/gpu-selection-uniform-block.js +40 -44
  94. package/programs/totems/index.js +1 -1
  95. package/programs/two-d/pixel-padding-for-compass.js +29 -90
  96. package/programs/util.js +7 -6
  97. package/programs/vectorfields/index.js +1 -1
  98. package/programs/vectorfields/logics/drawrectangleparticles.js +29 -70
  99. package/programs/vectorfields/logics/index.js +3 -3
  100. package/programs/vectorfields/logics/pixelbased.js +35 -91
  101. package/programs/vectorfields/logics/ubo.js +25 -31
  102. package/programs/vectorfields/pingpongbuffermanager.js +34 -30
  103. package/rangerings/index.js +4 -4
  104. package/rangerings/plugin.js +252 -202
  105. package/rangerings/rangeringangletext.js +120 -108
  106. package/rangerings/ring-account.js +69 -52
  107. package/shaders/fragment-toy/firework.js +1 -55
  108. package/shaders/fragment-toy/singularity.js +1 -55
  109. package/timetracks/adaptors-line-strip.js +37 -26
  110. package/timetracks/adaptors.js +61 -47
  111. package/timetracks/index.js +4 -4
  112. package/timetracks/plugin-line-strip.js +63 -59
  113. package/timetracks/plugin.js +69 -65
  114. package/timetracks/program-line-strip.js +103 -296
  115. package/timetracks/program.js +113 -419
  116. package/timetracks/programpoint-line-strip.js +44 -97
  117. package/timetracks/programpoint.js +44 -90
  118. package/util/account/bufferoffsetmanager.js +95 -72
  119. package/util/account/index.js +1 -1
  120. package/util/account/single-attribute-buffer-management/buffer-manager.js +43 -39
  121. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +94 -64
  122. package/util/account/single-attribute-buffer-management/index.js +3 -3
  123. package/util/account/single-attribute-buffer-management/object-store.js +30 -28
  124. package/util/account/util.js +4 -2
  125. package/util/algorithms/search-binary.js +4 -4
  126. package/util/check/get.js +5 -5
  127. package/util/check/typecheck.js +15 -13
  128. package/util/geometry/index.js +11 -9
  129. package/util/gl-util/buffer/attribute-loader.js +20 -8
  130. package/util/gl-util/buffer/index.js +1 -1
  131. package/util/gl-util/draw-options/methods.js +7 -7
  132. package/util/gl-util/uniform-block/manager.js +67 -55
  133. package/util/heatwavedatamanager/datamanager.js +116 -56
  134. package/util/heatwavedatamanager/index.js +2 -2
  135. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +40 -37
  136. package/util/heatwavedatamanager/pointcoordsmeta.js +10 -9
  137. package/util/index.js +6 -6
  138. package/util/interpolation/timetrack/index.js +1 -1
  139. package/util/interpolation/timetrack/timetrack-interpolator.js +29 -27
  140. package/util/interpolation/timetrack/web-worker-str.js +1 -179
  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 +52 -46
  146. package/util/programs/draw-texture-on-canvas.js +21 -39
  147. package/util/programs/shapesonglobe.js +64 -104
  148. package/util/programs/supersampletotextures.js +39 -45
  149. package/util/programs/texturetoglobe.js +48 -98
  150. package/util/shaderfunctions/geometrytransformations.js +27 -322
  151. package/util/shaderfunctions/nodata.js +1 -7
  152. package/util/shaderfunctions/noisefunctions.js +9 -39
  153. package/util/surface-line-data/arcs-to-cuts.js +23 -20
  154. package/util/webglobe/rasteroverlay.js +37 -35
  155. package/util/webglobjectbuilders.js +60 -55
  156. package/util/webglobjectbuilders1.js +49 -48
  157. package/waveparticles/adaptor.js +7 -6
  158. package/waveparticles/index.js +2 -2
  159. package/waveparticles/plugin.js +84 -79
  160. package/wind/imagetovectorfieldandmagnitude.js +15 -15
  161. package/wind/index.js +4 -4
  162. package/wind/plugin.js +251 -453
  163. package/wind/vectorfieldimage.js +5 -5
  164. package/write-text/attached-text-writer.js +48 -46
  165. package/write-text/context-text.js +58 -51
  166. package/write-text/context-text3.js +74 -69
@@ -1,81 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PixelPaddingForFlatCompassCache = void 0;
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) {
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) {
74
12
  this.globe = globe;
75
13
  this.gl = globe.gl;
76
14
  this._lastOpacity = 1;
77
15
  this.program = (0, util_1.createProgram)(this.gl, vertexShaderSource, fragmentShaderSource);
78
- const { gl, program } = this;
16
+ var _a = this, gl = _a.gl, program = _a.program;
79
17
  { // assign attribute locations
80
18
  // in vec2 screen_coordinate;
81
19
  // in float pixel_radius_small_ratio;
@@ -88,20 +26,20 @@ class Logic {
88
26
  }
89
27
  {
90
28
  this._opacityLocation = gl.getUniformLocation(program, "plugin_opacity");
91
- const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
29
+ var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
92
30
  gl.useProgram(program);
93
31
  gl.uniform1f(this._opacityLocation, this._lastOpacity);
94
32
  gl.useProgram(currentProgram);
95
33
  }
96
34
  {
97
35
  this.cameraBlockBindingPoint = 0;
98
- const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
36
+ var cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
99
37
  this.cameraBlockTotem = totems_1.CameraUniformBlockTotemCache.get(globe);
100
38
  gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
101
39
  }
102
40
  }
103
- draw(vao, length, opacity) {
104
- const { globe, gl, program, cameraBlockTotem, cameraBlockBindingPoint, _opacityLocation } = this;
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;
105
43
  if (globe.api_GetCurrentGeometry() === 0)
106
44
  return;
107
45
  gl.useProgram(program);
@@ -114,34 +52,34 @@ class Logic {
114
52
  gl.drawArraysInstanced(gl.LINES, 0, vertexCount, length);
115
53
  gl.bindVertexArray(null);
116
54
  cameraBlockTotem.unbind(cameraBlockBindingPoint);
117
- }
118
- createVAO(screenCoordsBufferObj, pixelRadiusRatioSmallBufferObj, pixelRadiusRatioBigBufferObj, rgbaBufferObj) {
119
- const { gl } = this;
120
- const vao = gl.createVertexArray();
55
+ };
56
+ Logic.prototype.createVAO = function (screenCoordsBufferObj, pixelRadiusRatioSmallBufferObj, pixelRadiusRatioBigBufferObj, rgbaBufferObj) {
57
+ var gl = this.gl;
58
+ var vao = gl.createVertexArray();
121
59
  gl.bindVertexArray(vao);
122
60
  {
123
- const { buffer, stride = 0, offset = 0 } = screenCoordsBufferObj;
61
+ var buffer = screenCoordsBufferObj.buffer, _a = screenCoordsBufferObj.stride, stride = _a === void 0 ? 0 : _a, _b = screenCoordsBufferObj.offset, offset = _b === void 0 ? 0 : _b;
124
62
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
125
63
  gl.enableVertexAttribArray(0);
126
64
  gl.vertexAttribPointer(0, 2, gl.FLOAT, false, stride, offset);
127
65
  gl.vertexAttribDivisor(0, 1);
128
66
  }
129
67
  {
130
- const { buffer, stride = 0, offset = 0 } = pixelRadiusRatioSmallBufferObj;
68
+ var buffer = pixelRadiusRatioSmallBufferObj.buffer, _c = pixelRadiusRatioSmallBufferObj.stride, stride = _c === void 0 ? 0 : _c, _d = pixelRadiusRatioSmallBufferObj.offset, offset = _d === void 0 ? 0 : _d;
131
69
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
132
70
  gl.enableVertexAttribArray(1);
133
71
  gl.vertexAttribPointer(1, 1, gl.FLOAT, false, stride, offset);
134
72
  gl.vertexAttribDivisor(1, 1);
135
73
  }
136
74
  {
137
- const { buffer, stride = 0, offset = 0 } = pixelRadiusRatioBigBufferObj;
75
+ var buffer = pixelRadiusRatioBigBufferObj.buffer, _e = pixelRadiusRatioBigBufferObj.stride, stride = _e === void 0 ? 0 : _e, _f = pixelRadiusRatioBigBufferObj.offset, offset = _f === void 0 ? 0 : _f;
138
76
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
139
77
  gl.enableVertexAttribArray(2);
140
78
  gl.vertexAttribPointer(2, 1, gl.FLOAT, false, stride, offset);
141
79
  gl.vertexAttribDivisor(2, 1);
142
80
  }
143
81
  {
144
- const { buffer, stride = 0, offset = 0 } = rgbaBufferObj;
82
+ var buffer = rgbaBufferObj.buffer, _g = rgbaBufferObj.stride, stride = _g === void 0 ? 0 : _g, _h = rgbaBufferObj.offset, offset = _h === void 0 ? 0 : _h;
145
83
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
146
84
  gl.enableVertexAttribArray(3);
147
85
  gl.vertexAttribPointer(3, 4, gl.FLOAT, false, stride, offset);
@@ -150,13 +88,14 @@ class Logic {
150
88
  gl.bindVertexArray(null);
151
89
  gl.bindBuffer(gl.ARRAY_BUFFER, null);
152
90
  return vao;
153
- }
154
- free() {
155
- const { globe } = this;
91
+ };
92
+ Logic.prototype.free = function () {
93
+ var globe = this.globe;
156
94
  totems_1.CameraUniformBlockTotemCache.release(globe);
157
- }
158
- }
95
+ };
96
+ return Logic;
97
+ }());
159
98
  exports.PixelPaddingForFlatCompassCache = Object.freeze({
160
- get: (globe) => programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic),
161
- release: (globe) => programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
99
+ get: function (globe) { return programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic); },
100
+ release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic); }
162
101
  });
package/programs/util.js CHANGED
@@ -1,14 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.longlatbbox2normalbbox = longlatbbox2normalbbox;
4
- function longlatbbox2normalbbox({ minLon = -180, maxLon = 180, minLat = -90, maxLat = 90 } = {}) {
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;
5
6
  // x
6
- const horOffset = (minLon) * Math.PI / 180;
7
- const horSize = (maxLon - minLon) * Math.PI / 180;
7
+ var horOffset = (minLon) * Math.PI / 180;
8
+ var horSize = (maxLon - minLon) * Math.PI / 180;
8
9
  // y
9
- const vertOffset = (90 - maxLat) * Math.PI / 180;
10
- const vertSize = (maxLat - minLat) * Math.PI / 180;
11
- const result = {
10
+ var vertOffset = (90 - maxLat) * Math.PI / 180;
11
+ var vertSize = (maxLat - minLat) * Math.PI / 180;
12
+ var result = {
12
13
  bboxOffsetRad: new Float32Array([horOffset, vertOffset]),
13
14
  bboxSizeRad: new Float32Array([horSize, vertSize])
14
15
  };
@@ -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
- const pingpongbuffermanager_1 = __importDefault(require("./pingpongbuffermanager"));
21
+ var pingpongbuffermanager_1 = __importDefault(require("./pingpongbuffermanager"));
22
22
  exports.PingPongBufferManager = pingpongbuffermanager_1.default;
23
23
  __exportStar(require("./logics"), exports);
@@ -1,78 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const util_1 = require("../../../util");
4
- const ubo_js_1 = require("./ubo.js");
5
- const programcache_1 = require("../../programcache");
3
+ var util_1 = require("../../../util");
4
+ var ubo_js_1 = require("./ubo.js");
5
+ var programcache_1 = require("../../programcache");
6
6
  /**
7
7
  * [+] ubo
8
8
  */
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) {
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;
56
14
  this.gl = gl;
57
- [this.program,
58
- this._vector_field_location] = this._createProgram();
15
+ _a = this._createProgram(), this.program = _a[0], this._vector_field_location = _a[1];
59
16
  // this.decoyBuffer = new DecoyBufferManager(gl);
60
17
  }
61
- _createProgram() {
62
- const gl = this.gl;
63
- const program = (0, util_1.createProgram)(gl, vertexShaderSource, fragmentShaderSource);
18
+ Logic.prototype._createProgram = function () {
19
+ var gl = this.gl;
20
+ var program = (0, util_1.createProgram)(gl, vertexShaderSource, fragmentShaderSource);
64
21
  // ubo point
65
- const ubo_location = gl.getUniformBlockIndex(program, 'UBO');
22
+ var ubo_location = gl.getUniformBlockIndex(program, 'UBO');
66
23
  gl.uniformBlockBinding(program, ubo_location, ubo_js_1.UBO_BINDING_POINT);
67
24
  return [program, gl.getUniformLocation(program, 'u_vector_field')];
68
- }
25
+ };
69
26
  /**
70
27
  * @param {*} bufferManager | PingPongBufferManager
71
28
  * @param {*} vectorTexture | RG32F texture R: x, G: y
72
29
  * @param {*} uboManager | WaveParticalUboManager under ubo.js
73
30
  */
74
- draw(bufferManager, vectorTexture, uboManager) {
75
- const { gl, program } = this;
31
+ Logic.prototype.draw = function (bufferManager, vectorTexture, uboManager) {
32
+ var _a = this, gl = _a.gl, program = _a.program;
76
33
  gl.useProgram(program);
77
34
  gl.bindVertexArray(bufferManager.getSourceVao());
78
35
  // gl.bindVertexArray(this.decoyBuffer.getSourceVao());
@@ -84,24 +41,26 @@ class Logic {
84
41
  gl.drawArraysInstanced(gl.POINTS, 0, 4, bufferManager.length);
85
42
  gl.bindVertexArray(null);
86
43
  uboManager.unbind();
87
- }
88
- free() {
44
+ };
45
+ Logic.prototype.free = function () {
89
46
  this.gl.deleteProgram(this.program);
90
47
  this.program = null;
91
- }
92
- }
93
- class default_1 {
94
- constructor(gl) {
48
+ };
49
+ return Logic;
50
+ }());
51
+ var default_1 = /** @class */ (function () {
52
+ function default_1(gl) {
95
53
  this.gl = gl;
96
54
  this.logic = programcache_1.glProgramCache.getProgram(gl, Logic);
97
55
  }
98
- draw(bufferManager, vectorTexture, uboManager) {
56
+ default_1.prototype.draw = function (bufferManager, vectorTexture, uboManager) {
99
57
  this.logic.draw(bufferManager, vectorTexture, uboManager);
100
- }
101
- free() {
58
+ };
59
+ default_1.prototype.free = function () {
102
60
  programcache_1.glProgramCache.releaseProgram(this.gl, Logic);
103
61
  this.logic = null;
104
62
  this.gl = null;
105
- }
106
- }
63
+ };
64
+ return default_1;
65
+ }());
107
66
  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
- const pixelbased_1 = __importDefault(require("./pixelbased"));
7
+ var pixelbased_1 = __importDefault(require("./pixelbased"));
8
8
  exports.PixelBasedMove = pixelbased_1.default;
9
- const drawrectangleparticles_1 = __importDefault(require("./drawrectangleparticles"));
9
+ var drawrectangleparticles_1 = __importDefault(require("./drawrectangleparticles"));
10
10
  exports.DrawRectangleParticles = drawrectangleparticles_1.default;
11
- const ubo_1 = require("./ubo");
11
+ var ubo_1 = require("./ubo");
12
12
  Object.defineProperty(exports, "WaveParticalUboManager", { enumerable: true, get: function () { return ubo_1.WaveParticalUboManager; } });
@@ -1,85 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const util_1 = require("../../../util");
4
- const ubo_js_1 = require("./ubo.js");
5
- const programcache_1 = require("../../programcache");
3
+ var util_1 = require("../../../util");
4
+ var ubo_js_1 = require("./ubo.js");
5
+ var 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
- 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) {
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;
73
15
  this.gl = gl;
74
- [this.program, this._vector_field_location] = this._createProgram();
16
+ _a = this._createProgram(), this.program = _a[0], this._vector_field_location = _a[1];
75
17
  }
76
18
  /**
77
19
  * @param {*} bufferManager | PingPongBufferManager
78
20
  * @param {*} vectorTexture RG32F texture R: x, G: y
79
21
  * @param {*} uboManager | WaveParticalUboManager under ubo.js
80
22
  */
81
- move(bufferManager, vectorTexture, uboManager) {
82
- const { gl, program, _vector_field_location } = this;
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;
83
25
  gl.useProgram(program);
84
26
  gl.enable(gl.RASTERIZER_DISCARD);
85
27
  gl.bindVertexArray(bufferManager.getSourceVao());
@@ -95,13 +37,13 @@ class Logic {
95
37
  gl.bindVertexArray(null);
96
38
  uboManager.unbind();
97
39
  gl.disable(gl.RASTERIZER_DISCARD);
98
- }
40
+ };
99
41
  // -- private methods
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();
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();
105
47
  gl.attachShader(program, vertexShader);
106
48
  gl.attachShader(program, fragmentShader);
107
49
  gl.transformFeedbackVaryings(program, ["out_position"], gl.SEPARATE_ATTRIBS);
@@ -109,34 +51,36 @@ class Logic {
109
51
  if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
110
52
  throw new Error(gl.getProgramParameter(program));
111
53
  }
112
- const ubo_location = gl.getUniformBlockIndex(program, 'UBO');
54
+ var ubo_location = gl.getUniformBlockIndex(program, 'UBO');
113
55
  gl.uniformBlockBinding(program, ubo_location, ubo_js_1.UBO_BINDING_POINT);
114
56
  return [program, gl.getUniformLocation(program, 'vector_field')];
115
57
  ;
116
- }
117
- free() {
58
+ };
59
+ Logic.prototype.free = function () {
118
60
  this.gl.deleteProgram(this.program);
119
61
  this.program = null;
120
- }
121
- getInPositionLocation() {
62
+ };
63
+ Logic.prototype.getInPositionLocation = function () {
122
64
  return this.gl.getAttribLocation(this.program, 'in_position');
123
- }
124
- }
125
- class default_1 {
126
- constructor(gl) {
65
+ };
66
+ return Logic;
67
+ }());
68
+ var default_1 = /** @class */ (function () {
69
+ function default_1(gl) {
127
70
  this.gl = gl;
128
71
  this.logic = programcache_1.glProgramCache.getProgram(gl, Logic);
129
72
  }
130
- move(bufferManager, vectorTexture, uboManager) {
73
+ default_1.prototype.move = function (bufferManager, vectorTexture, uboManager) {
131
74
  this.logic.move(bufferManager, vectorTexture, uboManager);
132
- }
133
- free() {
75
+ };
76
+ default_1.prototype.free = function () {
134
77
  programcache_1.glProgramCache.releaseProgram(this.gl, Logic);
135
78
  this.program = null;
136
79
  this.gl = null;
137
- }
138
- getInPositionLocation() {
80
+ };
81
+ default_1.prototype.getInPositionLocation = function () {
139
82
  return this.logic.getInPositionLocation();
140
- }
141
- }
83
+ };
84
+ return default_1;
85
+ }());
142
86
  exports.default = default_1;
@@ -1,29 +1,22 @@
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
- const UBO_BINDING_POINT = 0;
4
+ var UBO_BINDING_POINT = 0;
5
5
  exports.UBO_BINDING_POINT = UBO_BINDING_POINT;
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
- };`;
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};";
16
8
  exports.shaderUboSource = shaderUboSource;
17
- const UBO_SIZE = 40;
9
+ var UBO_SIZE = 40;
18
10
  exports.UBO_SIZE = UBO_SIZE;
19
- class WaveParticalUboManager {
20
- constructor(gl) {
11
+ var WaveParticalUboManager = /** @class */ (function () {
12
+ function WaveParticalUboManager(gl) {
21
13
  this.gl = gl;
22
14
  this.ubo = this._createBuffer();
23
15
  this._data = null;
24
16
  }
25
- update({ range, random_seed, tail_wing_base_limp, draw_texture_size, drop_rate, color }) {
26
- const { gl, ubo } = this;
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;
27
20
  gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
28
21
  if (random_seed !== undefined)
29
22
  gl.bufferSubData(gl.UNIFORM_BUFFER, 0, new Float32Array([random_seed]));
@@ -38,26 +31,27 @@ class WaveParticalUboManager {
38
31
  if (draw_texture_size !== undefined)
39
32
  gl.bufferSubData(gl.UNIFORM_BUFFER, 32, new Float32Array(draw_texture_size));
40
33
  gl.bindBuffer(gl.UNIFORM_BUFFER, null);
41
- }
42
- _createBuffer() {
43
- const gl = this.gl;
44
- const buffer = gl.createBuffer();
34
+ };
35
+ WaveParticalUboManager.prototype._createBuffer = function () {
36
+ var gl = this.gl;
37
+ var buffer = gl.createBuffer();
45
38
  gl.bindBuffer(gl.UNIFORM_BUFFER, buffer);
46
39
  gl.bufferData(gl.UNIFORM_BUFFER, INITIAL_UBO_DATA, gl.STATIC_DRAW);
47
40
  gl.bindBuffer(gl.UNIFORM_BUFFER, null);
48
41
  return buffer;
49
- }
50
- bind() {
51
- const { gl, ubo } = this;
42
+ };
43
+ WaveParticalUboManager.prototype.bind = function () {
44
+ var _a = this, gl = _a.gl, ubo = _a.ubo;
52
45
  gl.bindBufferBase(gl.UNIFORM_BUFFER, UBO_BINDING_POINT, ubo);
53
- }
54
- unbind() {
55
- const gl = this.gl;
46
+ };
47
+ WaveParticalUboManager.prototype.unbind = function () {
48
+ var gl = this.gl;
56
49
  gl.bindBufferBase(gl.UNIFORM_BUFFER, UBO_BINDING_POINT, null);
57
- }
58
- free() {
59
- const { gl, _buffer } = this;
50
+ };
51
+ WaveParticalUboManager.prototype.free = function () {
52
+ var _a = this, gl = _a.gl, _buffer = _a._buffer;
60
53
  gl.deleteBuffer(_buffer);
61
- }
62
- }
54
+ };
55
+ return WaveParticalUboManager;
56
+ }());
63
57
  exports.WaveParticalUboManager = WaveParticalUboManager;