@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.
- package/Math/angle-calculation.js +8 -8
- package/Math/arc.js +18 -18
- package/Math/bounds/line-bbox.js +78 -80
- package/Math/constants.js +3 -3
- package/Math/juction/arc-plane.js +23 -23
- package/Math/juction/line-sphere.js +11 -11
- package/Math/juction/plane-plane.js +11 -11
- package/Math/line.js +14 -16
- package/Math/methods.js +65 -70
- package/Math/plane.js +16 -18
- package/Math/quaternion.js +45 -49
- package/Math/utils.js +2 -2
- package/Math/vec3.js +42 -45
- package/algorithms/search-binary.js +4 -4
- package/altitude-locator/draw-subset-obj.js +7 -8
- package/altitude-locator/plugin.js +98 -114
- package/arrowfield/adaptor.js +3 -4
- package/arrowfield/index.js +2 -2
- package/arrowfield/plugin.js +62 -65
- package/bearing-line/index.js +1 -1
- package/bearing-line/plugin.js +200 -226
- package/circle-line-chain/chain-list-map.js +82 -88
- package/circle-line-chain/plugin.js +134 -165
- package/circle-line-chain/util.js +1 -1
- package/compass-rose/compass-rose-padding-flat.js +108 -133
- package/compass-rose/compass-text-writer.js +62 -70
- package/compass-rose/index.js +2 -2
- package/compassrose/compassrose.js +46 -50
- package/compassrose/index.js +1 -1
- package/heatwave/index.js +2 -2
- package/heatwave/isobar/objectarraylabels.js +44 -48
- package/heatwave/isobar/plugin.js +104 -123
- package/heatwave/isobar/quadtreecontours.js +76 -92
- package/heatwave/plugins/heatwaveglobeshell.js +69 -87
- package/index.js +11 -11
- package/package.json +1 -1
- package/partialrings/buffer-manager.js +32 -64
- package/partialrings/index.js +1 -1
- package/partialrings/plugin.js +48 -84
- package/partialrings/program.js +136 -47
- package/pin/pin-object-array.js +83 -86
- package/pin/pin-point-totem.js +21 -22
- package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +10 -10
- package/point-heat-map/plugin-webworker.js +40 -45
- package/point-heat-map/point-to-heat-map-flow.js +40 -42
- package/point-tracks/key-methods.js +1 -1
- package/point-tracks/plugin.js +137 -162
- package/programs/arrowfield/index.js +1 -1
- package/programs/arrowfield/logic.js +170 -62
- package/programs/arrowfield/object.js +33 -35
- package/programs/data2legend/density-to-legend.js +45 -21
- package/programs/data2legend/point-to-density-texture.js +52 -27
- package/programs/float2legendwithratio/index.js +1 -1
- package/programs/float2legendwithratio/logic.js +88 -42
- package/programs/float2legendwithratio/object.js +43 -46
- package/programs/globe-util/is-globe-moved.js +10 -11
- package/programs/globeshell/index.js +1 -1
- package/programs/globeshell/wiggle/index.js +1 -1
- package/programs/globeshell/wiggle/logic.js +191 -98
- package/programs/globeshell/wiggle/object.js +33 -35
- package/programs/helpers/blender/program.js +36 -19
- package/programs/helpers/fadeaway/index.js +1 -1
- package/programs/helpers/fadeaway/logic.js +35 -13
- package/programs/helpers/fadeaway/object.js +9 -10
- package/programs/helpers/index.js +1 -1
- package/programs/index.js +8 -8
- package/programs/line-on-globe/angled-line.js +91 -32
- package/programs/line-on-globe/circle-accurate-3d.js +82 -32
- package/programs/line-on-globe/circle-accurate-flat.js +108 -50
- package/programs/line-on-globe/circle-accurate.js +103 -33
- package/programs/line-on-globe/circle.js +97 -32
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +83 -33
- package/programs/line-on-globe/lines-color-instanced-flat.js +79 -34
- package/programs/line-on-globe/linestrip.js +111 -45
- package/programs/line-on-globe/naive-accurate-flexible.js +120 -50
- package/programs/line-on-globe/to-the-surface.js +58 -29
- package/programs/line-on-globe/util.js +1 -1
- package/programs/picking/pickable-renderer.js +117 -33
- package/programs/point-on-globe/element-globe-surface-glow.js +78 -38
- package/programs/point-on-globe/element-point-glow.js +103 -35
- package/programs/point-on-globe/square-pixel-point.js +76 -27
- package/programs/programcache.js +13 -13
- package/programs/rings/distancering/circleflatprogram.js +63 -21
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +156 -145
- package/programs/rings/distancering/circlepaddysharedbuffer.js +121 -197
- package/programs/rings/distancering/index.js +4 -4
- package/programs/rings/distancering/paddyflatprogram.js +73 -20
- package/programs/rings/distancering/paddyflatprogram2d.js +75 -22
- package/programs/rings/distancering/paddyflatprogram3d.js +73 -20
- package/programs/rings/partial-ring/piece-of-pie.js +137 -35
- package/programs/totems/camerauniformblock.js +64 -51
- package/programs/totems/canvas-webglobe-info.js +48 -40
- package/programs/totems/gpu-selection-uniform-block.js +44 -40
- package/programs/totems/index.js +1 -1
- package/programs/two-d/pixel-padding-for-compass.js +90 -29
- package/programs/util.js +6 -7
- package/programs/vectorfields/index.js +1 -1
- package/programs/vectorfields/logics/drawrectangleparticles.js +70 -29
- package/programs/vectorfields/logics/index.js +3 -3
- package/programs/vectorfields/logics/pixelbased.js +91 -35
- package/programs/vectorfields/logics/ubo.js +31 -25
- package/programs/vectorfields/pingpongbuffermanager.js +30 -34
- package/rangerings/index.js +4 -4
- package/rangerings/plugin.js +202 -258
- package/rangerings/rangeringangletext.js +108 -120
- package/rangerings/ring-account.js +52 -69
- package/shaders/fragment-toy/firework.js +55 -1
- package/shaders/fragment-toy/singularity.js +55 -1
- package/timetracks/adaptors-line-strip.js +26 -37
- package/timetracks/adaptors.js +47 -61
- package/timetracks/index.js +4 -4
- package/timetracks/plugin-line-strip.js +63 -71
- package/timetracks/plugin.js +69 -77
- package/timetracks/program-line-strip.js +296 -103
- package/timetracks/program.js +419 -113
- package/timetracks/programpoint-line-strip.js +97 -44
- package/timetracks/programpoint.js +90 -44
- package/util/account/bufferoffsetmanager.js +72 -95
- package/util/account/index.js +1 -1
- package/util/account/single-attribute-buffer-management/buffer-manager.js +44 -44
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +68 -94
- package/util/account/single-attribute-buffer-management/index.js +3 -3
- package/util/account/single-attribute-buffer-management/object-store.js +29 -30
- package/util/account/util.js +2 -4
- package/util/algorithms/search-binary.js +4 -4
- package/util/check/get.js +5 -5
- package/util/check/typecheck.js +13 -15
- package/util/geometry/index.js +9 -11
- package/util/gl-util/buffer/attribute-loader.js +8 -20
- package/util/gl-util/buffer/index.js +1 -1
- package/util/gl-util/draw-options/methods.js +8 -9
- package/util/gl-util/uniform-block/manager.js +67 -67
- package/util/heatwavedatamanager/datamanager.js +56 -116
- package/util/heatwavedatamanager/index.js +2 -2
- package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +37 -40
- package/util/heatwavedatamanager/pointcoordsmeta.js +9 -10
- package/util/index.js +6 -6
- package/util/interpolation/timetrack/index.js +1 -1
- package/util/interpolation/timetrack/timetrack-interpolator.js +27 -29
- package/util/interpolation/timetrack/web-worker-str.js +179 -1
- package/util/interpolation/timetrack/web-worker.js +4 -4
- package/util/jshelpers/data-filler.js +7 -7
- package/util/jshelpers/timefilters.js +7 -7
- package/util/picking/fence.js +7 -7
- package/util/picking/picker-displayer.js +46 -52
- package/util/programs/draw-texture-on-canvas.js +39 -21
- package/util/programs/shapesonglobe.js +104 -64
- package/util/programs/supersampletotextures.js +45 -39
- package/util/programs/texturetoglobe.js +98 -48
- package/util/shaderfunctions/geometrytransformations.js +322 -27
- package/util/shaderfunctions/nodata.js +7 -1
- package/util/shaderfunctions/noisefunctions.js +39 -9
- package/util/surface-line-data/arcs-to-cuts.js +20 -23
- package/util/webglobe/rasteroverlay.js +35 -37
- package/util/webglobjectbuilders.js +55 -60
- package/util/webglobjectbuilders1.js +48 -49
- package/waveparticles/adaptor.js +6 -7
- package/waveparticles/index.js +2 -2
- package/waveparticles/plugin.js +79 -84
- package/wind/imagetovectorfieldandmagnitude.js +15 -15
- package/wind/index.js +4 -4
- package/wind/plugin.js +453 -251
- package/wind/vectorfieldimage.js +5 -5
- package/write-text/attached-text-writer.js +46 -48
- package/write-text/context-text.js +51 -58
- 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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
42
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
117
|
+
}
|
|
118
|
+
createVAO(screenCoordsBufferObj, pixelRadiusRatioSmallBufferObj, pixelRadiusRatioBigBufferObj, rgbaBufferObj) {
|
|
119
|
+
const { gl } = this;
|
|
120
|
+
const vao = gl.createVertexArray();
|
|
59
121
|
gl.bindVertexArray(vao);
|
|
60
122
|
{
|
|
61
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
93
|
-
|
|
153
|
+
}
|
|
154
|
+
free() {
|
|
155
|
+
const { globe } = this;
|
|
94
156
|
totems_1.CameraUniformBlockTotemCache.release(globe);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
}());
|
|
157
|
+
}
|
|
158
|
+
}
|
|
98
159
|
exports.PixelPaddingForFlatCompassCache = Object.freeze({
|
|
99
|
-
get:
|
|
100
|
-
release:
|
|
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(
|
|
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
|
-
|
|
8
|
-
|
|
6
|
+
const horOffset = (minLon) * Math.PI / 180;
|
|
7
|
+
const horSize = (maxLon - minLon) * Math.PI / 180;
|
|
9
8
|
// y
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
57
|
+
[this.program,
|
|
58
|
+
this._vector_field_location] = this._createProgram();
|
|
16
59
|
// this.decoyBuffer = new DecoyBufferManager(gl);
|
|
17
60
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
61
|
+
_createProgram() {
|
|
62
|
+
const gl = this.gl;
|
|
63
|
+
const program = (0, util_1.createProgram)(gl, vertexShaderSource, fragmentShaderSource);
|
|
21
64
|
// ubo point
|
|
22
|
-
|
|
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
|
-
|
|
32
|
-
|
|
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
|
-
|
|
87
|
+
}
|
|
88
|
+
free() {
|
|
46
89
|
this.gl.deleteProgram(this.program);
|
|
47
90
|
this.program = null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
98
|
+
draw(bufferManager, vectorTexture, uboManager) {
|
|
57
99
|
this.logic.draw(bufferManager, vectorTexture, uboManager);
|
|
58
|
-
}
|
|
59
|
-
|
|
100
|
+
}
|
|
101
|
+
free() {
|
|
60
102
|
programcache_1.glProgramCache.releaseProgram(this.gl, Logic);
|
|
61
103
|
this.logic = null;
|
|
62
104
|
this.gl = null;
|
|
63
|
-
}
|
|
64
|
-
|
|
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
|
-
|
|
7
|
+
const pixelbased_1 = __importDefault(require("./pixelbased"));
|
|
8
8
|
exports.PixelBasedMove = pixelbased_1.default;
|
|
9
|
-
|
|
9
|
+
const drawrectangleparticles_1 = __importDefault(require("./drawrectangleparticles"));
|
|
10
10
|
exports.DrawRectangleParticles = drawrectangleparticles_1.default;
|
|
11
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
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
|
-
|
|
24
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
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
|
-
|
|
116
|
+
}
|
|
117
|
+
free() {
|
|
60
118
|
this.gl.deleteProgram(this.program);
|
|
61
119
|
this.program = null;
|
|
62
|
-
}
|
|
63
|
-
|
|
120
|
+
}
|
|
121
|
+
getInPositionLocation() {
|
|
64
122
|
return this.gl.getAttribLocation(this.program, 'in_position');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
130
|
+
move(bufferManager, vectorTexture, uboManager) {
|
|
74
131
|
this.logic.move(bufferManager, vectorTexture, uboManager);
|
|
75
|
-
}
|
|
76
|
-
|
|
132
|
+
}
|
|
133
|
+
free() {
|
|
77
134
|
programcache_1.glProgramCache.releaseProgram(this.gl, Logic);
|
|
78
135
|
this.program = null;
|
|
79
136
|
this.gl = null;
|
|
80
|
-
}
|
|
81
|
-
|
|
137
|
+
}
|
|
138
|
+
getInPositionLocation() {
|
|
82
139
|
return this.logic.getInPositionLocation();
|
|
83
|
-
}
|
|
84
|
-
|
|
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
|
-
|
|
4
|
+
const UBO_BINDING_POINT = 0;
|
|
5
5
|
exports.UBO_BINDING_POINT = UBO_BINDING_POINT;
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
17
|
+
const UBO_SIZE = 40;
|
|
10
18
|
exports.UBO_SIZE = UBO_SIZE;
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
18
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
44
|
-
|
|
49
|
+
}
|
|
50
|
+
bind() {
|
|
51
|
+
const { gl, ubo } = this;
|
|
45
52
|
gl.bindBufferBase(gl.UNIFORM_BUFFER, UBO_BINDING_POINT, ubo);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
53
|
+
}
|
|
54
|
+
unbind() {
|
|
55
|
+
const gl = this.gl;
|
|
49
56
|
gl.bindBufferBase(gl.UNIFORM_BUFFER, UBO_BINDING_POINT, null);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
57
|
+
}
|
|
58
|
+
free() {
|
|
59
|
+
const { gl, _buffer } = this;
|
|
53
60
|
gl.deleteBuffer(_buffer);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
}());
|
|
61
|
+
}
|
|
62
|
+
}
|
|
57
63
|
exports.WaveParticalUboManager = WaveParticalUboManager;
|