@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
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.PickerDisplayer = void 0;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
const draw_texture_on_canvas_1 = require("../programs/draw-texture-on-canvas");
|
|
9
|
+
const fence_1 = require("./fence");
|
|
10
|
+
const ESCAPE_VALUE = -1;
|
|
11
|
+
class PickerDisplayer {
|
|
12
|
+
constructor(globe) {
|
|
13
13
|
this.globe = globe;
|
|
14
14
|
this.gl = globe.gl;
|
|
15
|
-
|
|
15
|
+
const gl = this.gl;
|
|
16
16
|
this.colorTexture = gl.createTexture(); // bind to color attachment 0
|
|
17
17
|
this.indexTexture = gl.createTexture(); // bind to color attachment 1
|
|
18
18
|
this.fbo = gl.createFramebuffer();
|
|
@@ -21,39 +21,37 @@ var PickerDisplayer = /** @class */ (function () {
|
|
|
21
21
|
this.resize();
|
|
22
22
|
this.displayer = draw_texture_on_canvas_1.textureOnCanvasProgramCache.get(this.gl);
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
if (width === void 0) { width = null; }
|
|
26
|
-
if (height === void 0) { height = null; }
|
|
24
|
+
resize(width = null, height = null) {
|
|
27
25
|
if (width === null || height === null) {
|
|
28
26
|
width = this.globe.api_ScrW();
|
|
29
27
|
height = this.globe.api_ScrH();
|
|
30
28
|
}
|
|
31
|
-
|
|
29
|
+
const { gl, colorTexture, indexTexture } = this;
|
|
32
30
|
gl.deleteTexture(colorTexture);
|
|
33
31
|
gl.deleteTexture(indexTexture);
|
|
34
|
-
|
|
32
|
+
const colorTextureNew = gl.createTexture();
|
|
35
33
|
gl.bindTexture(gl.TEXTURE_2D, colorTextureNew);
|
|
36
34
|
gl.texStorage2D(gl.TEXTURE_2D, 1, gl.RGBA8, width, height);
|
|
37
|
-
|
|
35
|
+
const indexTextureNew = gl.createTexture();
|
|
38
36
|
gl.bindTexture(gl.TEXTURE_2D, indexTextureNew);
|
|
39
37
|
// gl.texStorage2D(gl.TEXTURE_2D, 1, gl.R16I, width, height);
|
|
40
38
|
gl.texStorage2D(gl.TEXTURE_2D, 1, gl.R32I, width, height);
|
|
41
39
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
42
40
|
this.colorTexture = colorTextureNew;
|
|
43
41
|
this.indexTexture = indexTextureNew;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
}
|
|
43
|
+
clearTextures() {
|
|
44
|
+
const { gl, colorTexture, indexTexture } = this;
|
|
47
45
|
gl.activeTexture(gl.TEXTURE1);
|
|
48
46
|
gl.bindTexture(gl.TEXTURE_2D, indexTexture);
|
|
49
47
|
gl.clearBufferiv(gl.COLOR, 1, new Int32Array([-1, -1, -1, -1]));
|
|
50
48
|
gl.activeTexture(gl.TEXTURE0);
|
|
51
49
|
gl.bindTexture(gl.TEXTURE_2D, colorTexture);
|
|
52
50
|
gl.clearBufferfv(gl.COLOR, 0, new Float32Array([0, 0, 0, 0]));
|
|
53
|
-
}
|
|
51
|
+
}
|
|
54
52
|
// call before drawing the scene with gl picker shader
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
bindFBO() {
|
|
54
|
+
const { gl, colorTexture, indexTexture, fbo } = this;
|
|
57
55
|
gl.activeTexture(gl.TEXTURE1);
|
|
58
56
|
gl.bindTexture(gl.TEXTURE_2D, indexTexture);
|
|
59
57
|
gl.activeTexture(gl.TEXTURE0);
|
|
@@ -64,30 +62,27 @@ var PickerDisplayer = /** @class */ (function () {
|
|
|
64
62
|
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT1, gl.TEXTURE_2D, this.indexTexture, 0);
|
|
65
63
|
gl.drawBuffers([gl.COLOR_ATTACHMENT0, gl.COLOR_ATTACHMENT1]);
|
|
66
64
|
}
|
|
67
|
-
}
|
|
65
|
+
}
|
|
68
66
|
// call after drawing the scene with gl picker shader
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
drawColorTexture() {
|
|
68
|
+
const { colorTexture } = this;
|
|
71
69
|
this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, null);
|
|
72
70
|
this.displayer.draw(colorTexture);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (callback === void 0) { callback = function () { }; }
|
|
77
|
-
var size = Math.pow(1 + 2 * selectionPointFilling, 2);
|
|
71
|
+
}
|
|
72
|
+
pickXY(x, y, selectionPointFilling = 1, callback = () => { }) {
|
|
73
|
+
const size = Math.pow(1 + 2 * selectionPointFilling, 2);
|
|
78
74
|
this._pick(size, x - selectionPointFilling, y - selectionPointFilling, 1 + 2 * selectionPointFilling, 1 + 2 * selectionPointFilling, callback);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
}
|
|
76
|
+
pickBbox(left, top, right, bottom, callback) {
|
|
77
|
+
const size = (right - left) * (bottom - top) * 4;
|
|
82
78
|
this._pick(size, left, top, right - left, bottom - top, callback);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
var _this = this;
|
|
79
|
+
}
|
|
80
|
+
_pick(size, startX, startY, lengthX, lengthY, callback) {
|
|
86
81
|
if (this._inProgress)
|
|
87
82
|
return false;
|
|
88
83
|
this._inProgress = true;
|
|
89
84
|
this._initHoldBuffer(size * 4);
|
|
90
|
-
|
|
85
|
+
const { gl, _pbo } = this;
|
|
91
86
|
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, _pbo);
|
|
92
87
|
this.bindFBO();
|
|
93
88
|
gl.readBuffer(gl.COLOR_ATTACHMENT1); // This is the attachment we want to read
|
|
@@ -95,35 +90,35 @@ var PickerDisplayer = /** @class */ (function () {
|
|
|
95
90
|
startX, startY, lengthX, lengthY, gl.RED_INTEGER, gl.INT, 0);
|
|
96
91
|
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
97
92
|
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
|
|
98
|
-
(0, fence_1.fence)(this.gl).then(
|
|
93
|
+
(0, fence_1.fence)(this.gl).then(() => {
|
|
99
94
|
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, _pbo);
|
|
100
95
|
// const data = new Int16Array(size);
|
|
101
|
-
|
|
96
|
+
const data = new Int32Array(size);
|
|
102
97
|
gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, data);
|
|
103
98
|
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
|
|
104
|
-
|
|
99
|
+
const result = this._pickFromBuffer(data, size);
|
|
105
100
|
callback(result);
|
|
106
101
|
// gl.deleteBuffer(pbo);
|
|
107
|
-
|
|
102
|
+
this._inProgress = false;
|
|
108
103
|
});
|
|
109
104
|
return true;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
for (
|
|
114
|
-
|
|
105
|
+
}
|
|
106
|
+
_pickFromBuffer(array, size) {
|
|
107
|
+
const selectedObjects = new Set();
|
|
108
|
+
for (let i = 0; i < size; i += 1) {
|
|
109
|
+
const id = array[i];
|
|
115
110
|
if (id !== ESCAPE_VALUE) {
|
|
116
111
|
selectedObjects.add(id);
|
|
117
112
|
}
|
|
118
113
|
}
|
|
119
114
|
return selectedObjects;
|
|
120
|
-
}
|
|
121
|
-
|
|
115
|
+
}
|
|
116
|
+
_initHoldBuffer(size) {
|
|
122
117
|
if (this._pbo && this._pboSize >= size) {
|
|
123
118
|
return;
|
|
124
119
|
}
|
|
125
|
-
|
|
126
|
-
|
|
120
|
+
const { gl } = this;
|
|
121
|
+
const pbo = gl.createBuffer();
|
|
127
122
|
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, pbo);
|
|
128
123
|
gl.bufferData(gl.PIXEL_PACK_BUFFER, size, gl.STREAM_READ);
|
|
129
124
|
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
|
|
@@ -132,14 +127,13 @@ var PickerDisplayer = /** @class */ (function () {
|
|
|
132
127
|
gl.deleteBuffer(this._pbo);
|
|
133
128
|
}
|
|
134
129
|
this._pbo = pbo;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
130
|
+
}
|
|
131
|
+
free() {
|
|
132
|
+
const { gl, colorTexture, indexTexture, fbo } = this;
|
|
138
133
|
gl.deleteTexture(colorTexture);
|
|
139
134
|
gl.deleteTexture(indexTexture);
|
|
140
135
|
gl.deleteFramebuffer(fbo);
|
|
141
136
|
draw_texture_on_canvas_1.textureOnCanvasProgramCache.release(this.gl);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
}());
|
|
137
|
+
}
|
|
138
|
+
}
|
|
145
139
|
exports.PickerDisplayer = PickerDisplayer;
|
|
@@ -1,13 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.textureOnCanvasProgramCache = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const webglobjectbuilders_1 = require("../webglobjectbuilders");
|
|
5
|
+
const programs_1 = require("../../programs");
|
|
6
6
|
// import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../../programs/totems";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const vs = `#version 300 es
|
|
8
|
+
precision highp float;
|
|
9
|
+
|
|
10
|
+
in vec2 a_position;
|
|
11
|
+
out vec2 v_texcoord;
|
|
12
|
+
|
|
13
|
+
void main() {
|
|
14
|
+
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
15
|
+
v_texcoord = a_position * 0.5 + 0.5;
|
|
16
|
+
}`;
|
|
17
|
+
const fs = `#version 300 es
|
|
18
|
+
precision highp float;
|
|
19
|
+
|
|
20
|
+
uniform sampler2D u_texture;
|
|
21
|
+
uniform float u_opacity;
|
|
22
|
+
in vec2 v_texcoord;
|
|
23
|
+
out vec4 fragColor;
|
|
24
|
+
|
|
25
|
+
void main() {
|
|
26
|
+
fragColor = texture(u_texture, v_texcoord);
|
|
27
|
+
fragColor.a *= u_opacity;
|
|
28
|
+
}`;
|
|
29
|
+
class TextureOnCanvasProgram {
|
|
30
|
+
constructor(gl) {
|
|
11
31
|
this.gl = gl;
|
|
12
32
|
this.vao = this.gl.createVertexArray();
|
|
13
33
|
this.buffer = this.gl.createBuffer();
|
|
@@ -25,23 +45,22 @@ var TextureOnCanvasProgram = /** @class */ (function () {
|
|
|
25
45
|
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, null);
|
|
26
46
|
this.program = (0, webglobjectbuilders_1.createProgram)(this.gl, vs, fs);
|
|
27
47
|
{
|
|
28
|
-
|
|
48
|
+
const { gl, program } = this;
|
|
29
49
|
this.uniforms = {
|
|
30
|
-
texture:
|
|
31
|
-
opacity:
|
|
50
|
+
texture: gl.getUniformLocation(program, "u_texture"),
|
|
51
|
+
opacity: gl.getUniformLocation(program, "u_opacity"),
|
|
32
52
|
};
|
|
33
53
|
}
|
|
34
54
|
{
|
|
35
55
|
this._lastOpacity = 1.0;
|
|
36
|
-
|
|
56
|
+
const currentProgram = this.gl.getParameter(this.gl.CURRENT_PROGRAM);
|
|
37
57
|
this.gl.useProgram(this.program);
|
|
38
58
|
this.gl.uniform1f(this.uniforms.opacity, this._lastOpacity);
|
|
39
59
|
this.gl.useProgram(currentProgram);
|
|
40
60
|
}
|
|
41
61
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
var _d = this, gl = _d.gl, program = _d.program, uniforms = _d.uniforms, vao = _d.vao;
|
|
62
|
+
draw(texture, { opacity = 1.0 } = {}) {
|
|
63
|
+
const { gl, program, uniforms, vao } = this;
|
|
45
64
|
gl.useProgram(program);
|
|
46
65
|
gl.bindVertexArray(vao);
|
|
47
66
|
gl.activeTexture(gl.TEXTURE0);
|
|
@@ -53,19 +72,18 @@ var TextureOnCanvasProgram = /** @class */ (function () {
|
|
|
53
72
|
}
|
|
54
73
|
gl.drawArrays(gl.TRIANGLE_FAN, 0, 4);
|
|
55
74
|
gl.bindVertexArray(null);
|
|
56
|
-
}
|
|
57
|
-
|
|
75
|
+
}
|
|
76
|
+
free() {
|
|
58
77
|
if (this._isFreed)
|
|
59
78
|
return;
|
|
60
79
|
this.gl.deleteVertexArray(this.vao);
|
|
61
80
|
this.gl.deleteBuffer(this.buffer);
|
|
62
81
|
this.gl.deleteProgram(this.program);
|
|
63
82
|
this._isFreed = true;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
release: function (gl) { return programs_1.glProgramCache.releaseProgram(gl, TextureOnCanvasProgram); }
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const textureOnCanvasProgramCache = Object.freeze({
|
|
86
|
+
get: (gl) => programs_1.glProgramCache.getProgram(gl, TextureOnCanvasProgram),
|
|
87
|
+
release: (gl) => programs_1.glProgramCache.releaseProgram(gl, TextureOnCanvasProgram)
|
|
70
88
|
});
|
|
71
89
|
exports.textureOnCanvasProgramCache = textureOnCanvasProgramCache;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ShapesOnGlobeProgram = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const webglobjectbuilders_1 = require("../webglobjectbuilders");
|
|
5
|
+
const camerauniformblock_1 = require("../../programs/totems/camerauniformblock");
|
|
6
|
+
const __1 = require("..");
|
|
7
7
|
/** TODO:
|
|
8
8
|
* 3d icin calistir
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
|
-
return
|
|
10
|
+
const drawModeFunc = (gl) => {
|
|
11
|
+
return (mode) => {
|
|
12
12
|
return {
|
|
13
13
|
"point": gl.POINTS,
|
|
14
14
|
"line": gl.LINES,
|
|
@@ -20,9 +20,8 @@ var drawModeFunc = function (gl) {
|
|
|
20
20
|
}[mode];
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (drawMode === void 0) { drawMode = 'point'; }
|
|
23
|
+
class ShapesOnGlobeProgram {
|
|
24
|
+
constructor(gl, globe, drawMode = 'point') {
|
|
26
25
|
this.globe = globe;
|
|
27
26
|
this.gl = gl;
|
|
28
27
|
this._getDraw = drawModeFunc(gl);
|
|
@@ -33,9 +32,9 @@ var ShapesOnGlobeProgram = /** @class */ (function () {
|
|
|
33
32
|
this._initUniforms();
|
|
34
33
|
this.setScreenWH();
|
|
35
34
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
_initUniforms() {
|
|
36
|
+
const { gl, _programWrapper } = this;
|
|
37
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
39
38
|
this._getDrawMode = drawModeFunc(gl);
|
|
40
39
|
gl.useProgram(_programWrapper.program);
|
|
41
40
|
gl.uniform1f(_programWrapper.u_opacity, 1.0);
|
|
@@ -43,16 +42,59 @@ var ShapesOnGlobeProgram = /** @class */ (function () {
|
|
|
43
42
|
gl.uniform1f(_programWrapper.height, 0.0);
|
|
44
43
|
gl.uniform1f(_programWrapper.u_point_size, 1.0);
|
|
45
44
|
gl.useProgram(currentProgram);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
}
|
|
46
|
+
_createProgramWrapper() {
|
|
47
|
+
const { gl, globe } = this;
|
|
48
|
+
const vertexSource = `#version 300 es
|
|
49
|
+
precision highp float;
|
|
50
|
+
${camerauniformblock_1.CameraUniformBlockString}
|
|
51
|
+
|
|
52
|
+
in vec2 a_position;
|
|
53
|
+
in vec4 a_color;
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
uniform bool u_is3D;
|
|
57
|
+
uniform float height;
|
|
58
|
+
|
|
59
|
+
uniform float u_point_size;
|
|
60
|
+
|
|
61
|
+
out vec4 v_color;
|
|
62
|
+
|
|
63
|
+
` + __1.shaderfunctions.pixelXYToCartesian3DPoint + `
|
|
64
|
+
` + __1.shaderfunctions.pixelXYToCartesian2DPoint + `
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
void main() {
|
|
68
|
+
vec3 pos = vec3(a_position, height);
|
|
69
|
+
if(is3D){
|
|
70
|
+
pos = pixelXYToCartesian3DPoint(pos);
|
|
71
|
+
gl_Position = projection * view * vec4(pos - translate, 1.0);
|
|
72
|
+
} else {
|
|
73
|
+
vec2 xy = pixelXYToCartesian2DPoint(pos.xy, translate.xy, mapWH, screenWH);
|
|
74
|
+
gl_Position = projection * vec4(xy.x, xy.y, 0.0, 1.0);
|
|
75
|
+
}
|
|
76
|
+
gl_PointSize = u_point_size;
|
|
77
|
+
v_color = a_color;
|
|
78
|
+
}
|
|
79
|
+
`;
|
|
80
|
+
const fragmentSource = `#version 300 es
|
|
81
|
+
precision highp float;
|
|
82
|
+
|
|
83
|
+
uniform float u_opacity;
|
|
84
|
+
|
|
85
|
+
in vec4 v_color;
|
|
86
|
+
out vec4 outColor;
|
|
87
|
+
|
|
88
|
+
void main() {
|
|
89
|
+
outColor = v_color;
|
|
90
|
+
outColor.a = u_opacity;
|
|
91
|
+
}
|
|
92
|
+
`;
|
|
93
|
+
const program = (0, webglobjectbuilders_1.createProgram)(gl, vertexSource, fragmentSource);
|
|
94
|
+
const a_position = gl.getAttribLocation(program, 'a_position');
|
|
95
|
+
const a_color = gl.getAttribLocation(program, 'a_color');
|
|
54
96
|
// vao and buffer.
|
|
55
|
-
|
|
97
|
+
const vao = gl.createVertexArray();
|
|
56
98
|
gl.bindVertexArray(vao);
|
|
57
99
|
gl.bindBuffer(gl.ARRAY_BUFFER, this._inBuffer);
|
|
58
100
|
gl.enableVertexAttribArray(a_position);
|
|
@@ -60,22 +102,22 @@ var ShapesOnGlobeProgram = /** @class */ (function () {
|
|
|
60
102
|
gl.enableVertexAttribArray(a_color);
|
|
61
103
|
gl.vertexAttribPointer(a_color, 4, gl.FLOAT, false, 6 * 4, 2 * 4);
|
|
62
104
|
gl.bindVertexArray(null);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
105
|
+
const cm = camerauniformblock_1.CameraUniformBlockTotemCache.get(globe);
|
|
106
|
+
const bindingPoint = 0;
|
|
107
|
+
const cmIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
|
|
66
108
|
gl.uniformBlockBinding(program, cmIndex, bindingPoint);
|
|
67
109
|
return {
|
|
68
110
|
program: program,
|
|
69
111
|
vao: vao,
|
|
70
112
|
u_point_size: gl.getUniformLocation(program, 'u_point_size'),
|
|
71
113
|
u_opacity: gl.getUniformLocation(program, 'u_opacity'),
|
|
72
|
-
bindCamera:
|
|
73
|
-
unbindCamera:
|
|
114
|
+
bindCamera: () => cm.bind(bindingPoint),
|
|
115
|
+
unbindCamera: () => cm.unbind(bindingPoint)
|
|
74
116
|
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
117
|
+
}
|
|
118
|
+
draw(uProjectionMatrix, uModelViewMatrix, uTranslate, drawRanges) {
|
|
119
|
+
const { gl, _programWrapper, _is3D } = this;
|
|
120
|
+
const deepTest = gl.isEnabled(gl.DEPTH_TEST);
|
|
79
121
|
gl.disable(gl.DEPTH_TEST);
|
|
80
122
|
gl.useProgram(_programWrapper.program);
|
|
81
123
|
gl.bindVertexArray(_programWrapper.vao);
|
|
@@ -85,11 +127,10 @@ var ShapesOnGlobeProgram = /** @class */ (function () {
|
|
|
85
127
|
gl.bindVertexArray(_programWrapper.vao);
|
|
86
128
|
_programWrapper.bindCamera();
|
|
87
129
|
if (!_is3D) {
|
|
88
|
-
|
|
130
|
+
const mapWH = this.globe.api_GetCurrentWorldWH();
|
|
89
131
|
gl.uniform2f(_programWrapper.u_mapWH, mapWH.width, mapWH.height);
|
|
90
132
|
}
|
|
91
|
-
for (
|
|
92
|
-
var drawRange = drawRanges_1[_i];
|
|
133
|
+
for (const drawRange of drawRanges) {
|
|
93
134
|
gl.drawArrays(this._drawMode, drawRange[0], drawRange[1]);
|
|
94
135
|
// gl.drawArrays(gl.POINTS, drawRange[0], 1);
|
|
95
136
|
}
|
|
@@ -98,77 +139,76 @@ var ShapesOnGlobeProgram = /** @class */ (function () {
|
|
|
98
139
|
if (deepTest) {
|
|
99
140
|
gl.enable(gl.DEPTH_TEST);
|
|
100
141
|
}
|
|
101
|
-
}
|
|
102
|
-
|
|
142
|
+
}
|
|
143
|
+
setOpacity(opacity) {
|
|
103
144
|
if (opacity < 0 || opacity > 1) {
|
|
104
145
|
throw new Error('Invalid opacity value');
|
|
105
146
|
}
|
|
106
147
|
;
|
|
107
|
-
|
|
108
|
-
|
|
148
|
+
const { gl, _programWrapper } = this;
|
|
149
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
109
150
|
gl.useProgram(_programWrapper.program);
|
|
110
151
|
gl.uniform1f(_programWrapper.u_opacity, opacity);
|
|
111
152
|
gl.useProgram(currentProgram);
|
|
112
153
|
this.globe.DrawRender();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
154
|
+
}
|
|
155
|
+
setPointSize(size) {
|
|
156
|
+
const { gl, _programWrapper } = this;
|
|
157
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
117
158
|
gl.useProgram(_programWrapper.program);
|
|
118
159
|
gl.uniform1f(_programWrapper.u_point_size, size);
|
|
119
160
|
gl.useProgram(currentProgram);
|
|
120
161
|
this.globe.DrawRender();
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
162
|
+
}
|
|
163
|
+
setDrawMode(mode) {
|
|
164
|
+
const modegl = this._getDraw(mode);
|
|
124
165
|
if (modegl) {
|
|
125
166
|
this._drawMode = modegl;
|
|
126
167
|
}
|
|
127
168
|
else {
|
|
128
169
|
throw new Error('Invalid draw mode ' + mode);
|
|
129
170
|
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
171
|
+
}
|
|
172
|
+
setScreenWH() {
|
|
173
|
+
const { gl, _programWrapper, globe } = this;
|
|
174
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
134
175
|
gl.useProgram(_programWrapper.program);
|
|
135
176
|
gl.uniform2f(_programWrapper.u_scrWH, globe.api_ScrW(), globe.api_ScrH());
|
|
136
177
|
gl.useProgram(currentProgram);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
178
|
+
}
|
|
179
|
+
resize(width, height) {
|
|
180
|
+
const { gl, _programWrapper, globe } = this;
|
|
140
181
|
width = width || globe.api_ScrW();
|
|
141
182
|
height = height || globe.api_ScrH();
|
|
142
|
-
|
|
183
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
143
184
|
gl.useProgram(_programWrapper.program);
|
|
144
185
|
gl.uniform2f(_programWrapper.u_scrWH, width, height);
|
|
145
186
|
gl.useProgram(currentProgram);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
187
|
+
}
|
|
188
|
+
setGeometry() {
|
|
189
|
+
const { gl, globe, _programWrapper } = this;
|
|
149
190
|
this._is3D = globe.api_GetCurrentGeometry() === 0;
|
|
150
|
-
|
|
191
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
151
192
|
gl.useProgram(_programWrapper.program);
|
|
152
193
|
gl.uniform1f(_programWrapper.u_is3D, this._is3D ? 1.0 : 0.0);
|
|
153
194
|
gl.useProgram(currentProgram);
|
|
154
195
|
this.resize();
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
196
|
+
}
|
|
197
|
+
free() {
|
|
198
|
+
const { gl, _programWrapper } = this;
|
|
158
199
|
gl.deleteProgram(_programWrapper.program);
|
|
159
200
|
gl.deleteVertexArray(_programWrapper.vao);
|
|
160
201
|
gl.deleteBuffer(this._inBuffer);
|
|
161
|
-
}
|
|
202
|
+
}
|
|
162
203
|
/**
|
|
163
204
|
*
|
|
164
205
|
* @param {Float32Array} data
|
|
165
206
|
* @format [x, y, r, g, b, a, x, y, r, g, b, a, x, y, r, g, b, a, x, y, r, g, b, a]
|
|
166
207
|
*/
|
|
167
|
-
|
|
168
|
-
|
|
208
|
+
setBufferData(data) {
|
|
209
|
+
const { gl } = this;
|
|
169
210
|
gl.bindBuffer(gl.ARRAY_BUFFER, this._inBuffer);
|
|
170
211
|
gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
}());
|
|
212
|
+
}
|
|
213
|
+
}
|
|
174
214
|
exports.ShapesOnGlobeProgram = ShapesOnGlobeProgram;
|