@pirireis/webglobeplugins 0.9.9 → 0.9.10
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 +15 -0
- package/Math/arc.js +65 -0
- package/Math/bounds/line-bbox.js +188 -0
- package/Math/constants.js +9 -0
- package/Math/frustum/camera.js +24 -0
- package/Math/frustum/from-globeinfo.js +48 -0
- package/Math/frustum/types.js +2 -0
- package/Math/globe-util/horizon-plane.js +112 -0
- package/Math/index.js +1 -0
- package/Math/juction/arc-plane.js +83 -0
- package/Math/juction/line-sphere.js +25 -0
- package/Math/juction/plane-plane.js +58 -0
- package/Math/line.js +56 -0
- package/Math/matrix4.js +1 -0
- package/Math/methods.js +201 -0
- package/Math/plane.js +60 -0
- package/Math/quaternion.js +104 -0
- package/Math/types.js +2 -0
- package/Math/utils.js +4 -0
- package/Math/vec3.js +126 -0
- package/algorithms/search-binary.js +19 -0
- package/altitude-locator/adaptors.js +1 -0
- package/altitude-locator/draw-subset-obj.js +18 -0
- package/altitude-locator/keymethod.js +1 -0
- package/altitude-locator/plugin.js +341 -0
- package/altitude-locator/types.js +23 -0
- package/arrowfield/adaptor.js +14 -0
- package/arrowfield/index.js +10 -0
- package/arrowfield/plugin.js +86 -0
- package/bearing-line/index.js +8 -0
- package/bearing-line/plugin.js +449 -0
- package/circle-line-chain/chain-list-map.js +205 -0
- package/circle-line-chain/init.js +1 -0
- package/circle-line-chain/plugin.js +424 -0
- package/circle-line-chain/util.js +5 -0
- package/compass-rose/compass-rose-padding-flat.js +225 -0
- package/compass-rose/compass-text-writer.js +153 -0
- package/compass-rose/index.js +7 -0
- package/compassrose/compassrose.js +296 -0
- package/compassrose/index.js +8 -0
- package/globe-types.js +1 -0
- package/heatwave/index.js +10 -0
- package/heatwave/isobar/objectarraylabels.js +202 -0
- package/heatwave/isobar/plugin.js +343 -0
- package/heatwave/isobar/quadtreecontours.js +300 -0
- package/heatwave/plugins/heatwaveglobeshell.js +206 -0
- package/jest.config.js +7 -0
- package/package.json +4 -4
- package/partialrings/buffer-manager.js +81 -0
- package/partialrings/index.js +41 -0
- package/partialrings/plugin.js +135 -0
- package/partialrings/program.js +286 -0
- package/pin/pin-object-array.js +305 -0
- package/pin/pin-point-totem.js +60 -0
- package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +66 -0
- package/point-heat-map/index.js +1 -0
- package/point-heat-map/plugin-webworker.js +126 -0
- package/point-heat-map/point-to-heat-map-flow.js +127 -0
- package/point-tracks/key-methods.js +5 -0
- package/point-tracks/plugin.js +338 -0
- package/programs/arrowfield/index.js +7 -0
- package/programs/arrowfield/logic.js +257 -0
- package/programs/arrowfield/object.js +66 -0
- package/programs/data2legend/density-to-legend.js +101 -0
- package/programs/data2legend/point-to-density-texture.js +100 -0
- package/programs/float2legendwithratio/index.js +8 -0
- package/programs/float2legendwithratio/logic.js +171 -0
- package/programs/float2legendwithratio/object.js +110 -0
- package/programs/globe-util/is-globe-moved.js +21 -0
- package/programs/globeshell/index.js +8 -0
- package/programs/globeshell/noise/noises.js +1 -0
- package/programs/globeshell/wiggle/index.js +8 -0
- package/programs/globeshell/wiggle/logic.js +345 -0
- package/programs/globeshell/wiggle/object.js +72 -0
- package/programs/helpers/blender/index.js +1 -0
- package/programs/helpers/blender/program.js +79 -0
- package/programs/helpers/fadeaway/index.js +7 -0
- package/programs/helpers/fadeaway/logic.js +72 -0
- package/programs/helpers/fadeaway/object.js +20 -0
- package/programs/helpers/index.js +8 -0
- package/programs/index.js +58 -0
- package/programs/interface.js +1 -0
- package/programs/line-on-globe/angled-line.js +176 -0
- package/programs/line-on-globe/circle-accurate-3d.js +141 -0
- package/programs/line-on-globe/circle-accurate-flat.js +216 -0
- package/programs/line-on-globe/circle-accurate.js +178 -0
- package/programs/line-on-globe/circle.js +167 -0
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +159 -0
- package/programs/line-on-globe/index.js +1 -0
- package/programs/line-on-globe/lines-color-instanced-flat.js +136 -0
- package/programs/line-on-globe/linestrip.js +171 -0
- package/programs/line-on-globe/naive-accurate-flexible.js +195 -0
- package/programs/line-on-globe/to-the-surface.js +111 -0
- package/programs/line-on-globe/util.js +8 -0
- package/programs/picking/pickable-renderer.js +188 -0
- package/programs/point-on-globe/element-globe-surface-glow.js +142 -0
- package/programs/point-on-globe/element-point-glow.js +153 -0
- package/programs/point-on-globe/square-pixel-point.js +174 -0
- package/programs/programcache.js +131 -0
- package/programs/rings/distancering/circleflatprogram.js +156 -0
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +369 -0
- package/programs/rings/distancering/circlepaddysharedbuffer.js +357 -0
- package/programs/rings/distancering/index.js +14 -0
- package/programs/rings/distancering/paddyflatprogram.js +172 -0
- package/programs/rings/distancering/paddyflatprogram2d.js +174 -0
- package/programs/rings/distancering/paddyflatprogram3d.js +172 -0
- package/programs/rings/distancering/shader.js +1 -0
- package/programs/rings/index.js +17 -0
- package/programs/rings/partial-ring/piece-of-pie.js +275 -0
- package/programs/totems/camerauniformblock.js +160 -0
- package/programs/totems/canvas-webglobe-info.js +110 -0
- package/programs/totems/gpu-selection-uniform-block.js +108 -0
- package/programs/totems/index.js +40 -0
- package/programs/two-d/pixel-circle.js +1 -0
- package/programs/two-d/pixel-padding-for-compass.js +162 -0
- package/programs/util.js +17 -0
- package/programs/vectorfields/index.js +23 -0
- package/programs/vectorfields/logics/drawrectangleparticles.js +107 -0
- package/programs/vectorfields/logics/index.js +12 -0
- package/programs/vectorfields/logics/pixelbased.js +142 -0
- package/programs/vectorfields/logics/ubo.js +63 -0
- package/programs/vectorfields/pingpongbuffermanager.js +76 -0
- package/rangerings/enum.js +5 -0
- package/rangerings/index.js +15 -0
- package/rangerings/plugin.js +560 -0
- package/rangerings/rangeringangletext.js +329 -0
- package/rangerings/ring-account.js +117 -0
- package/shaders/fragment-toy/firework.js +58 -0
- package/shaders/fragment-toy/singularity.js +59 -0
- package/shape-on-terrain/arc/naive/plugin.js +252 -0
- package/timetracks/adaptors-line-strip.js +71 -0
- package/timetracks/adaptors.js +122 -0
- package/timetracks/index.js +19 -0
- package/timetracks/plugin-line-strip.js +250 -0
- package/timetracks/plugin.js +258 -0
- package/timetracks/program-line-strip.js +611 -0
- package/timetracks/program.js +772 -0
- package/timetracks/programpoint-line-strip.js +154 -0
- package/timetracks/programpoint.js +147 -0
- package/types.js +15 -0
- package/util/account/bufferoffsetmanager.js +179 -0
- package/util/account/index.js +23 -0
- package/util/account/single-attribute-buffer-management/buffer-manager.js +108 -0
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +150 -0
- package/util/account/single-attribute-buffer-management/index.js +9 -0
- package/util/account/single-attribute-buffer-management/object-store.js +51 -0
- package/util/account/single-attribute-buffer-management/types.js +2 -0
- package/util/account/util.js +22 -0
- package/util/algorithms/index.js +1 -0
- package/util/algorithms/search-binary.js +28 -0
- package/util/check/get.js +18 -0
- package/util/check/index.js +1 -0
- package/util/check/typecheck.js +49 -0
- package/util/geometry/index.js +51 -0
- package/util/gl-util/buffer/attribute-loader.js +69 -0
- package/util/gl-util/buffer/index.js +6 -0
- package/util/gl-util/buffer/types.js +1 -0
- package/util/gl-util/draw-options/methods.js +38 -0
- package/util/gl-util/draw-options/types.js +15 -0
- package/util/gl-util/uniform-block/manager.js +156 -0
- package/util/gl-util/uniform-block/shader.js +1 -0
- package/util/gl-util/uniform-block/types.js +8 -0
- package/util/heatwavedatamanager/datamanager.js +152 -0
- package/util/heatwavedatamanager/index.js +10 -0
- package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +122 -0
- package/util/heatwavedatamanager/pointcoordsmeta.js +20 -0
- package/util/index.js +57 -0
- package/util/interpolation/index.js +1 -0
- package/util/interpolation/timetrack/index.js +5 -0
- package/util/interpolation/timetrack/timetrack-interpolator.js +79 -0
- package/util/interpolation/timetrack/web-worker-str.js +183 -0
- package/util/interpolation/timetrack/web-worker.js +48 -0
- package/util/jshelpers/data-filler.js +20 -0
- package/util/jshelpers/equality.js +20 -0
- package/util/jshelpers/index.js +37 -0
- package/util/jshelpers/timefilters.js +32 -0
- package/util/picking/fence.js +46 -0
- package/util/picking/picker-displayer.js +139 -0
- package/util/programs/draw-texture-on-canvas.js +89 -0
- package/util/programs/index.js +17 -0
- package/util/programs/shapesonglobe.js +214 -0
- package/util/programs/supersampletotextures.js +113 -0
- package/util/programs/texturetoglobe.js +182 -0
- package/util/shaderfunctions/geometrytransformations.js +340 -0
- package/util/shaderfunctions/index.js +18 -0
- package/util/shaderfunctions/nodata.js +11 -0
- package/util/shaderfunctions/noisefunctions.js +43 -0
- package/util/surface-line-data/arc-bboxes.js +25 -0
- package/util/surface-line-data/arcs-to-cuts.js +50 -0
- package/util/surface-line-data/cut-arc.js +1 -0
- package/util/surface-line-data/flow.js +28 -0
- package/util/surface-line-data/rbush-manager.js +1 -0
- package/util/surface-line-data/types.js +1 -0
- package/util/surface-line-data/web-worker.js +1 -0
- package/util/webglobe/gldefaultstates.js +7 -0
- package/util/webglobe/index.js +18 -0
- package/util/webglobe/rasteroverlay.js +78 -0
- package/util/webglobjectbuilders.js +388 -0
- package/util/webglobjectbuilders1.js +237 -0
- package/waveparticles/adaptor.js +17 -0
- package/waveparticles/index.js +10 -0
- package/waveparticles/plugin.js +266 -0
- package/wind/imagetovectorfieldandmagnitude.js +35 -0
- package/wind/index.js +14 -0
- package/wind/plugin.js +926 -0
- package/wind/vectorfieldimage.js +25 -0
- package/write-text/attached-text-writer.js +91 -0
- package/write-text/context-text.js +98 -0
- package/write-text/context-text3.js +155 -0
- package/write-text/index.js +5 -0
- package/write-text/writer-plugin.js +8 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CirclePadding3DCache = void 0;
|
|
4
|
+
const webglobjectbuilders_1 = require("../../util/webglobjectbuilders");
|
|
5
|
+
const camerauniformblock_1 = require("../totems/camerauniformblock");
|
|
6
|
+
const programcache_1 = require("../programcache");
|
|
7
|
+
// import { vaoAttributeLoader } from "../../util/account/util";
|
|
8
|
+
const attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
|
|
9
|
+
const util_1 = require("./util");
|
|
10
|
+
const geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
|
|
11
|
+
/**
|
|
12
|
+
* TODO:
|
|
13
|
+
* 1. integrate geometry functions for radius angle and center
|
|
14
|
+
* 2. integrate attributes
|
|
15
|
+
*
|
|
16
|
+
* TODO:
|
|
17
|
+
* center_position is too small or doenst loaded as expected.
|
|
18
|
+
*/
|
|
19
|
+
const INITIAL_EDGE_COUNT = 720;
|
|
20
|
+
const vertexShaderSource = `#version 300 es
|
|
21
|
+
precision highp float;
|
|
22
|
+
${camerauniformblock_1.CameraUniformBlockString}
|
|
23
|
+
${geometrytransformations_1.cartesian3DToGLPosition}
|
|
24
|
+
${geometrytransformations_1.circleLimpFromLongLatRadCenterCartesian3D_accurate}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
in vec3 center_position3d;
|
|
28
|
+
in float big_radius;
|
|
29
|
+
in float small_radius;
|
|
30
|
+
in vec4 color;
|
|
31
|
+
|
|
32
|
+
uniform float edge_count;
|
|
33
|
+
uniform float step_angle;
|
|
34
|
+
uniform int z_alpha_on;
|
|
35
|
+
|
|
36
|
+
out float interpolation;
|
|
37
|
+
out vec4 v_color;
|
|
38
|
+
void main() {
|
|
39
|
+
if( !is3D) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
v_color = color;
|
|
43
|
+
if ( z_alpha_on == 1 ){
|
|
44
|
+
float z_alpha = pow(z_level * 0.75, 3.0) * distance(big_radius, small_radius) / (R * 2.0);
|
|
45
|
+
if ( z_alpha < 0.1 ) { return; }
|
|
46
|
+
v_color.a *= z_alpha;
|
|
47
|
+
}
|
|
48
|
+
int pad_phase = gl_VertexID % 2; // 0 or 1
|
|
49
|
+
interpolation = float( gl_VertexID - pad_phase) / edge_count;
|
|
50
|
+
float angle = float( gl_VertexID - pad_phase) * step_angle;
|
|
51
|
+
vec3 position;
|
|
52
|
+
if ( pad_phase == 0 ) {
|
|
53
|
+
position = circleLimpFromLongLatRadCenterCartesian3D_accurate(center_position3d, big_radius, angle);
|
|
54
|
+
} else {
|
|
55
|
+
position = circleLimpFromLongLatRadCenterCartesian3D_accurate(center_position3d, small_radius, angle);
|
|
56
|
+
}
|
|
57
|
+
gl_Position = cartesian3DToGLPosition(position);
|
|
58
|
+
|
|
59
|
+
gl_PointSize = 5.0;
|
|
60
|
+
}`;
|
|
61
|
+
const fragmentShaderSource = `#version 300 es
|
|
62
|
+
${geometrytransformations_1.POLE}
|
|
63
|
+
precision highp float;
|
|
64
|
+
uniform float opacity;
|
|
65
|
+
in vec4 v_color;
|
|
66
|
+
in float interpolation;
|
|
67
|
+
in vec2 v_limp;
|
|
68
|
+
out vec4 color;
|
|
69
|
+
void main() {
|
|
70
|
+
color = v_color;
|
|
71
|
+
color.a *= opacity;
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
class Logic {
|
|
75
|
+
constructor(globe) {
|
|
76
|
+
this.globe = globe;
|
|
77
|
+
this.gl = globe.gl;
|
|
78
|
+
this._lastOpacity = 1.0;
|
|
79
|
+
this._lastEdgeCount = INITIAL_EDGE_COUNT;
|
|
80
|
+
this._lastStepAngle = 720 / INITIAL_EDGE_COUNT;
|
|
81
|
+
this._lastZAlphaMode = util_1.Z_ALPHA_MODE.ON;
|
|
82
|
+
this.program = (0, webglobjectbuilders_1.createProgram)(this.gl, vertexShaderSource, fragmentShaderSource);
|
|
83
|
+
const { gl, program } = this;
|
|
84
|
+
this.program.uniforms = {
|
|
85
|
+
opacity: gl.getUniformLocation(program, "opacity"),
|
|
86
|
+
edgeCount: gl.getUniformLocation(program, "edge_count"),
|
|
87
|
+
stepAngle: gl.getUniformLocation(program, "step_angle"),
|
|
88
|
+
zAlphaMode: gl.getUniformLocation(program, "z_alpha_on")
|
|
89
|
+
};
|
|
90
|
+
{ // initial uniform values
|
|
91
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
92
|
+
gl.useProgram(program);
|
|
93
|
+
gl.uniform1f(program.uniforms.opacity, 1.0);
|
|
94
|
+
gl.uniform1f(program.uniforms.edgeCount, INITIAL_EDGE_COUNT * 2);
|
|
95
|
+
gl.uniform1f(program.uniforms.stepAngle, this._lastStepAngle * Math.PI / 360);
|
|
96
|
+
gl.uniform1i(program.uniforms.zAlphaMode, util_1.Z_ALPHA_MODE.ON);
|
|
97
|
+
gl.useProgram(currentProgram);
|
|
98
|
+
}
|
|
99
|
+
{ // assign attribute locations
|
|
100
|
+
gl.bindAttribLocation(program, 0, "center_position3d");
|
|
101
|
+
gl.bindAttribLocation(program, 1, "big_radius");
|
|
102
|
+
gl.bindAttribLocation(program, 2, "small_radius");
|
|
103
|
+
gl.bindAttribLocation(program, 3, "color");
|
|
104
|
+
}
|
|
105
|
+
this.cameraBindingPoint = 0;
|
|
106
|
+
this.cameraBlockTotem = camerauniformblock_1.CameraUniformBlockTotemCache.get(globe);
|
|
107
|
+
const cameraBlockLocation = gl.getUniformBlockIndex(program, "CameraUniformBlock");
|
|
108
|
+
gl.uniformBlockBinding(program, cameraBlockLocation, this.cameraBindingPoint);
|
|
109
|
+
}
|
|
110
|
+
createVAO(center3dObj, bigRadiusObj, smallRadiusObj, colorObj) {
|
|
111
|
+
const { gl } = this;
|
|
112
|
+
const vao = gl.createVertexArray();
|
|
113
|
+
const divisor = 1;
|
|
114
|
+
gl.bindVertexArray(vao);
|
|
115
|
+
(0, attribute_loader_1.attributeLoader)(gl, center3dObj, 0, 3, { divisor });
|
|
116
|
+
(0, attribute_loader_1.attributeLoader)(gl, bigRadiusObj, 1, 1, { divisor });
|
|
117
|
+
(0, attribute_loader_1.attributeLoader)(gl, smallRadiusObj, 2, 1, { divisor });
|
|
118
|
+
(0, attribute_loader_1.attributeLoader)(gl, colorObj, 3, 4, { divisor });
|
|
119
|
+
gl.bindVertexArray(null);
|
|
120
|
+
return vao;
|
|
121
|
+
}
|
|
122
|
+
draw(vao, length, edgeCount, stepAngle, opacity, zAlphaMode = util_1.Z_ALPHA_MODE.ON) {
|
|
123
|
+
const { gl, program, cameraBlockTotem, cameraBindingPoint } = this;
|
|
124
|
+
gl.useProgram(program);
|
|
125
|
+
if (this._lastOpacity !== opacity) {
|
|
126
|
+
gl.uniform1f(program.uniforms.opacity, opacity);
|
|
127
|
+
this._lastOpacity = opacity;
|
|
128
|
+
}
|
|
129
|
+
if (this._lastEdgeCount !== edgeCount) {
|
|
130
|
+
gl.uniform1f(program.uniforms.edgeCount, 2 * edgeCount);
|
|
131
|
+
this._lastEdgeCount = edgeCount;
|
|
132
|
+
}
|
|
133
|
+
if (this._lastStepAngle !== stepAngle) {
|
|
134
|
+
gl.uniform1f(program.uniforms.stepAngle, stepAngle * Math.PI / 360);
|
|
135
|
+
this._lastStepAngle = stepAngle;
|
|
136
|
+
}
|
|
137
|
+
if (this._lastZAlphaMode !== zAlphaMode) {
|
|
138
|
+
gl.uniform1i(program.uniforms.zAlphaMode, zAlphaMode);
|
|
139
|
+
this._lastZAlphaMode = zAlphaMode;
|
|
140
|
+
}
|
|
141
|
+
gl.bindVertexArray(vao);
|
|
142
|
+
cameraBlockTotem.bind(cameraBindingPoint);
|
|
143
|
+
gl.drawArraysInstanced(gl.LINES, 0, edgeCount * 2, length);
|
|
144
|
+
// gl.drawArraysInstanced(gl.POINTS, 0, edgeCount, length);
|
|
145
|
+
cameraBlockTotem.unbind(cameraBindingPoint);
|
|
146
|
+
gl.bindVertexArray(null);
|
|
147
|
+
}
|
|
148
|
+
free() {
|
|
149
|
+
if (this.isFreed)
|
|
150
|
+
return;
|
|
151
|
+
camerauniformblock_1.CameraUniformBlockTotemCache.release(this.globe);
|
|
152
|
+
this.gl.deleteProgram(this.program);
|
|
153
|
+
this.isFreed = true;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.CirclePadding3DCache = Object.freeze({
|
|
157
|
+
get: (globe) => programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic),
|
|
158
|
+
release: (globe) => programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
|
|
159
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Z_ALPHA_MODE = exports.LinesColorInstancedFlatCache = void 0;
|
|
4
|
+
const totems_1 = require("../totems");
|
|
5
|
+
const geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
|
|
6
|
+
const programcache_1 = require("../programcache");
|
|
7
|
+
const util_1 = require("../../util");
|
|
8
|
+
const util_2 = require("./util");
|
|
9
|
+
Object.defineProperty(exports, "Z_ALPHA_MODE", { enumerable: true, get: function () { return util_2.Z_ALPHA_MODE; } });
|
|
10
|
+
const attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
|
|
11
|
+
/**
|
|
12
|
+
* This program draws line between points provided from the first and second buffer.
|
|
13
|
+
* draw method gl.drawArraysInstanced( gl.POINTS, 0,2, lineCount);
|
|
14
|
+
* */
|
|
15
|
+
// TODO: find better way to eleminate edge case distance(posA, posB) > 37000000.0
|
|
16
|
+
const vertexShaderSource = `#version 300 es
|
|
17
|
+
precision highp float;
|
|
18
|
+
${totems_1.CameraUniformBlockString}
|
|
19
|
+
${geometrytransformations_1.mercatorXYToGLPosition}
|
|
20
|
+
uniform float opacity;
|
|
21
|
+
uniform int z_alpha_on;
|
|
22
|
+
|
|
23
|
+
in vec2 posA;
|
|
24
|
+
in vec2 posB;
|
|
25
|
+
in vec4 color;
|
|
26
|
+
|
|
27
|
+
out vec2 v_frame;
|
|
28
|
+
out vec4 v_color;
|
|
29
|
+
void main() {
|
|
30
|
+
|
|
31
|
+
if ( is3D ) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
float gap = max( distance(posA.x, posB.x), distance(posA.y,posB.y)); //
|
|
35
|
+
if ( gap > 37000000.0) { return; }
|
|
36
|
+
float z_alpha;
|
|
37
|
+
if ( z_alpha_on == 1 ){
|
|
38
|
+
z_alpha = pow(2.0,z_level+1.0) / ( 10000000.0 / gap);
|
|
39
|
+
z_alpha = smoothstep(0.1,0.9, z_alpha);
|
|
40
|
+
if( z_alpha < 0.01) {return;}
|
|
41
|
+
} else {
|
|
42
|
+
z_alpha = 1.0;
|
|
43
|
+
}
|
|
44
|
+
vec2 pos;
|
|
45
|
+
if ( gl_VertexID == 0 ) {
|
|
46
|
+
pos = posA;
|
|
47
|
+
} else {
|
|
48
|
+
pos = posB;
|
|
49
|
+
}
|
|
50
|
+
v_frame = pos;
|
|
51
|
+
gl_Position = mercatorXYToGLPosition( pos );
|
|
52
|
+
v_color = color;
|
|
53
|
+
v_color.a *= z_alpha * opacity;
|
|
54
|
+
gl_PointSize = 4.0;
|
|
55
|
+
}`;
|
|
56
|
+
const fragmentShaderSource = `#version 300 es
|
|
57
|
+
${geometrytransformations_1.POLE}
|
|
58
|
+
precision highp float;
|
|
59
|
+
in vec4 v_color;
|
|
60
|
+
in vec2 v_frame;
|
|
61
|
+
out vec4 outColor;
|
|
62
|
+
void main() {
|
|
63
|
+
if ( v_frame.x < -POLE || v_frame.x > POLE || v_frame.y < -POLE || v_frame.y > POLE ){ discard; }
|
|
64
|
+
outColor = v_color;
|
|
65
|
+
}`;
|
|
66
|
+
class Logic {
|
|
67
|
+
constructor(globe) {
|
|
68
|
+
this.globe = globe;
|
|
69
|
+
this.gl = globe.gl;
|
|
70
|
+
this.program = (0, util_1.createProgram)(this.gl, vertexShaderSource, fragmentShaderSource);
|
|
71
|
+
this._lastOpicity = 1.0;
|
|
72
|
+
this._lastZAlphaOn = util_2.Z_ALPHA_MODE.OFF;
|
|
73
|
+
const { gl, program } = this;
|
|
74
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
75
|
+
gl.useProgram(program);
|
|
76
|
+
{ // assign attribute locations
|
|
77
|
+
gl.bindAttribLocation(program, 0, 'posA');
|
|
78
|
+
gl.bindAttribLocation(program, 1, 'posB');
|
|
79
|
+
gl.bindAttribLocation(program, 2, 'color');
|
|
80
|
+
}
|
|
81
|
+
{ // uniform locations
|
|
82
|
+
this._opacityLocation = gl.getUniformLocation(program, 'opacity');
|
|
83
|
+
this._zAlphaOnLocation = gl.getUniformLocation(program, 'z_alpha_on');
|
|
84
|
+
gl.uniform1i(this._zAlphaOnLocation, this._lastZAlphaOn);
|
|
85
|
+
gl.uniform1f(this._opacityLocation, this._lastOpicity);
|
|
86
|
+
}
|
|
87
|
+
{ // uniform block
|
|
88
|
+
this._cameraUniformBlock = totems_1.CameraUniformBlockTotemCache.get(globe);
|
|
89
|
+
this._cameraBindingPoint = 0;
|
|
90
|
+
const cameraBlockBindingIndex = gl.getUniformBlockIndex(program, 'CameraUniformBlock');
|
|
91
|
+
gl.uniformBlockBinding(program, cameraBlockBindingIndex, this._cameraBindingPoint);
|
|
92
|
+
}
|
|
93
|
+
gl.useProgram(currentProgram);
|
|
94
|
+
}
|
|
95
|
+
createVAO(posAObj, posBObj, colorObj) {
|
|
96
|
+
const { gl } = this;
|
|
97
|
+
const vao = gl.createVertexArray();
|
|
98
|
+
const divisor = 1;
|
|
99
|
+
gl.bindVertexArray(vao);
|
|
100
|
+
(0, attribute_loader_1.attributeLoader)(gl, posAObj, 0, 2, { divisor });
|
|
101
|
+
(0, attribute_loader_1.attributeLoader)(gl, posBObj, 1, 2, { divisor });
|
|
102
|
+
(0, attribute_loader_1.attributeLoader)(gl, colorObj, 2, 4, { divisor });
|
|
103
|
+
gl.bindVertexArray(null);
|
|
104
|
+
return vao;
|
|
105
|
+
}
|
|
106
|
+
draw(vao, lineCount, opacity = 1.0, zAlphaOn = util_2.Z_ALPHA_MODE.ON) {
|
|
107
|
+
const { gl, program, _cameraBindingPoint, _cameraUniformBlock } = this;
|
|
108
|
+
gl.useProgram(program);
|
|
109
|
+
_cameraUniformBlock.bind(_cameraBindingPoint);
|
|
110
|
+
gl.bindVertexArray(vao);
|
|
111
|
+
if (this._lastOpicity !== opacity) {
|
|
112
|
+
this._lastOpicity = opacity;
|
|
113
|
+
gl.uniform1f(this._opacityLocation, opacity);
|
|
114
|
+
}
|
|
115
|
+
if (this._lastZAlphaOn !== zAlphaOn) {
|
|
116
|
+
this._lastZAlphaOn = zAlphaOn;
|
|
117
|
+
gl.uniform1i(this._zAlphaOnLocation, zAlphaOn);
|
|
118
|
+
}
|
|
119
|
+
gl.drawArraysInstanced(gl.LINES, 0, 2, lineCount);
|
|
120
|
+
_cameraUniformBlock.unbind(_cameraBindingPoint);
|
|
121
|
+
gl.bindVertexArray(null);
|
|
122
|
+
}
|
|
123
|
+
free() {
|
|
124
|
+
if (this.isFreed)
|
|
125
|
+
return;
|
|
126
|
+
const { gl, program, globe } = this;
|
|
127
|
+
totems_1.CameraUniformBlockTotemCache.release(globe);
|
|
128
|
+
gl.deleteProgram(program);
|
|
129
|
+
this.isFreed = true;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const LinesColorInstancedFlatCache = Object.freeze({
|
|
133
|
+
get: (globe) => { return programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic); },
|
|
134
|
+
release: (globe) => { programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic); }
|
|
135
|
+
});
|
|
136
|
+
exports.LinesColorInstancedFlatCache = LinesColorInstancedFlatCache;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LineStripProgramCache = void 0;
|
|
4
|
+
const webglobjectbuilders_1 = require("../../util/webglobjectbuilders");
|
|
5
|
+
require("../interface");
|
|
6
|
+
const totems_1 = require("../totems");
|
|
7
|
+
const geometrytransformations_js_1 = require("../../util/shaderfunctions/geometrytransformations.js");
|
|
8
|
+
const programcache_1 = require("../programcache");
|
|
9
|
+
const attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
|
|
10
|
+
require("../../util/gl-util/buffer/attribute-loader");
|
|
11
|
+
const manager_1 = require("../../util/gl-util/uniform-block/manager");
|
|
12
|
+
require("../../util/gl-util/uniform-block/types");
|
|
13
|
+
const methods_1 = require("../../util/gl-util/draw-options/methods");
|
|
14
|
+
require("../../util/gl-util/draw-options/types");
|
|
15
|
+
const ESCAPE_VALUE = -1;
|
|
16
|
+
const uniformBindingPoints = {
|
|
17
|
+
camera: 0,
|
|
18
|
+
flexible: 1,
|
|
19
|
+
};
|
|
20
|
+
const one = new Float32Array([1]);
|
|
21
|
+
const flexibleBlockManager = new manager_1.UniformBlockManager('FlexibleAttributes', [
|
|
22
|
+
{ name: "u_color", type: "vec4", value: new Float32Array([0.12, 1, 0.1, 1]) },
|
|
23
|
+
{ name: "u_dash_opacity", type: "float", value: one },
|
|
24
|
+
{ name: "u_dash_length", type: "float", value: one },
|
|
25
|
+
], uniformBindingPoints.flexible);
|
|
26
|
+
const vertexShaderSource = `#version 300 es
|
|
27
|
+
precision highp float;
|
|
28
|
+
|
|
29
|
+
${totems_1.CameraUniformBlockString}
|
|
30
|
+
${geometrytransformations_js_1.cartesian3DToGLPosition}
|
|
31
|
+
${geometrytransformations_js_1.mercatorXYToGLPosition}
|
|
32
|
+
|
|
33
|
+
${flexibleBlockManager.glslCode()}
|
|
34
|
+
|
|
35
|
+
in vec3 position3d;
|
|
36
|
+
in vec2 position2d;
|
|
37
|
+
in vec4 color;
|
|
38
|
+
in float dash_length;
|
|
39
|
+
in float dash_opacity;
|
|
40
|
+
|
|
41
|
+
out float v_dash_length;
|
|
42
|
+
out float v_dash_opacity;
|
|
43
|
+
out vec4 v_color;
|
|
44
|
+
|
|
45
|
+
flat out vec3 v_flat_position;
|
|
46
|
+
out vec3 v_position;
|
|
47
|
+
|
|
48
|
+
void main() {
|
|
49
|
+
|
|
50
|
+
v_color = ( color.r == -1.0 ) ? u_color : color;
|
|
51
|
+
v_dash_length = ( dash_length == -1.0 ) ? u_dash_length : dash_length;
|
|
52
|
+
v_dash_opacity = ( dash_opacity == -1.0 ) ? u_dash_opacity : dash_opacity;
|
|
53
|
+
|
|
54
|
+
if ( is3D ) {
|
|
55
|
+
gl_Position = cartesian3DToGLPosition( position3d );
|
|
56
|
+
v_position = position3d;
|
|
57
|
+
v_flat_position = position3d;
|
|
58
|
+
} else {
|
|
59
|
+
gl_Position = mercatorXYToGLPosition( position2d );
|
|
60
|
+
v_position = vec3( position2d, 0.0 );
|
|
61
|
+
v_flat_position = vec3( position2d, 0.0 );
|
|
62
|
+
}
|
|
63
|
+
gl_PointSize = 4.0;
|
|
64
|
+
}`;
|
|
65
|
+
const fragmentShaderSource = `#version 300 es
|
|
66
|
+
precision highp float;
|
|
67
|
+
|
|
68
|
+
uniform float opacity;
|
|
69
|
+
|
|
70
|
+
in vec4 v_color;
|
|
71
|
+
in float v_dash_length;
|
|
72
|
+
in float v_dash_opacity;
|
|
73
|
+
|
|
74
|
+
flat in vec3 v_flat_position;
|
|
75
|
+
in vec3 v_position;
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
out vec4 outColor;
|
|
79
|
+
|
|
80
|
+
void main() {
|
|
81
|
+
outColor = v_color;
|
|
82
|
+
return;
|
|
83
|
+
float dash_length = v_dash_length;
|
|
84
|
+
float dash_opacity = v_dash_opacity;
|
|
85
|
+
|
|
86
|
+
if ( dash_length == 0.0 ) {
|
|
87
|
+
outColor = vec4( v_color.rgb, v_color.a * v_dash_opacity );
|
|
88
|
+
} else {
|
|
89
|
+
float dist = distance( v_flat_position, v_position );
|
|
90
|
+
// float alpha = mod( dist , v_dash_length * 2.0 ) / v_dash_length < 1.0 ? 1.0 : v_dash_opacity;
|
|
91
|
+
outColor = vec4( v_color.rgb, v_color.a * opacity );
|
|
92
|
+
}
|
|
93
|
+
}`;
|
|
94
|
+
console.log("LineStripProgram");
|
|
95
|
+
console.log(vertexShaderSource);
|
|
96
|
+
console.log(fragmentShaderSource);
|
|
97
|
+
class Logic {
|
|
98
|
+
constructor(globe) {
|
|
99
|
+
this._vaosPublished = [];
|
|
100
|
+
this._ubosPublished = [];
|
|
101
|
+
this._opacity = {
|
|
102
|
+
value: 1,
|
|
103
|
+
location: null
|
|
104
|
+
};
|
|
105
|
+
console.log("LineStripProgram globe", globe);
|
|
106
|
+
this.gl = globe.gl;
|
|
107
|
+
this.globe = globe;
|
|
108
|
+
this.program = (0, webglobjectbuilders_1.createProgram)(this.gl, vertexShaderSource, fragmentShaderSource);
|
|
109
|
+
const currentProgram = this.gl.getParameter(this.gl.CURRENT_PROGRAM);
|
|
110
|
+
this.gl.useProgram(this.program);
|
|
111
|
+
this._opacity.location = this.gl.getUniformLocation(this.program, "opacity");
|
|
112
|
+
this.gl.uniform1f(this._opacity.location, this._opacity.value);
|
|
113
|
+
// bind attribute locations
|
|
114
|
+
this.gl.bindAttribLocation(this.program, 0, "position3d");
|
|
115
|
+
this.gl.bindAttribLocation(this.program, 1, "position2d");
|
|
116
|
+
this.gl.bindAttribLocation(this.program, 2, "color");
|
|
117
|
+
this.gl.bindAttribLocation(this.program, 3, "dash_length");
|
|
118
|
+
this.gl.bindAttribLocation(this.program, 4, "dash_opacity");
|
|
119
|
+
this.cameraBlockTotem = totems_1.CameraUniformBlockTotemCache.get(globe);
|
|
120
|
+
this.cameraBlockTotem.assignBindingPoint(this.program, uniformBindingPoints.camera);
|
|
121
|
+
flexibleBlockManager.assignBindingPoint(this.gl, this.program);
|
|
122
|
+
this._defaultFlexibleUBO = flexibleBlockManager.createUBO(this.gl);
|
|
123
|
+
this.gl.useProgram(currentProgram);
|
|
124
|
+
}
|
|
125
|
+
createUBO(bufferReadType = "STATIC_DRAW") {
|
|
126
|
+
const ubo = flexibleBlockManager.createUBO(this.gl, bufferReadType);
|
|
127
|
+
this._ubosPublished.push(ubo);
|
|
128
|
+
return ubo;
|
|
129
|
+
}
|
|
130
|
+
createVAO(position3D, position2D, color, dashLength, dashOpacity) {
|
|
131
|
+
const { gl } = this;
|
|
132
|
+
const vao = gl.createVertexArray();
|
|
133
|
+
gl.bindVertexArray(vao);
|
|
134
|
+
(0, attribute_loader_1.attributeLoader)(gl, position3D, 0, 3);
|
|
135
|
+
(0, attribute_loader_1.attributeLoader)(gl, position2D, 1, 2);
|
|
136
|
+
(0, attribute_loader_1.attributeLoader)(gl, color, 2, 4, { escapeValues: [ESCAPE_VALUE, ESCAPE_VALUE, ESCAPE_VALUE, ESCAPE_VALUE] });
|
|
137
|
+
(0, attribute_loader_1.attributeLoader)(gl, dashLength, 3, 1, { escapeValues: [ESCAPE_VALUE] });
|
|
138
|
+
(0, attribute_loader_1.attributeLoader)(gl, dashOpacity, 4, 1, { escapeValues: [ESCAPE_VALUE] });
|
|
139
|
+
gl.bindVertexArray(null);
|
|
140
|
+
return vao;
|
|
141
|
+
}
|
|
142
|
+
draw(vao, drawOptions, opacity = 1, flexibleUBO = null) {
|
|
143
|
+
const { gl, program, cameraBlockTotem } = this;
|
|
144
|
+
gl.useProgram(program);
|
|
145
|
+
if (opacity !== this._opacity.value) {
|
|
146
|
+
this._opacity.value = opacity;
|
|
147
|
+
this.gl.uniform1f(this._opacity.location, this._opacity.value);
|
|
148
|
+
}
|
|
149
|
+
const ubo = flexibleUBO || this._defaultFlexibleUBO;
|
|
150
|
+
cameraBlockTotem.bind(uniformBindingPoints.camera);
|
|
151
|
+
ubo.bind();
|
|
152
|
+
gl.bindVertexArray(vao);
|
|
153
|
+
(0, methods_1.drawArrays)(gl, gl.POINTS, drawOptions);
|
|
154
|
+
(0, methods_1.drawArrays)(gl, gl.LINE_STRIP, drawOptions);
|
|
155
|
+
gl.bindVertexArray(null);
|
|
156
|
+
ubo.unbind();
|
|
157
|
+
cameraBlockTotem.unbind(uniformBindingPoints.camera);
|
|
158
|
+
}
|
|
159
|
+
free() {
|
|
160
|
+
this._vaosPublished.forEach((vao) => this.gl.deleteVertexArray(vao));
|
|
161
|
+
this._ubosPublished.forEach((ubo) => ubo.free());
|
|
162
|
+
this.gl.deleteProgram(this.program);
|
|
163
|
+
this._defaultFlexibleUBO.free();
|
|
164
|
+
totems_1.CameraUniformBlockTotemCache.release(this.globe);
|
|
165
|
+
this.gl.deleteProgram(this.program);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
exports.LineStripProgramCache = Object.freeze({
|
|
169
|
+
get: (globe) => programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic),
|
|
170
|
+
release: (globe) => programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic),
|
|
171
|
+
});
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LineOnGlobeCache = void 0;
|
|
4
|
+
const totems_1 = require("../totems");
|
|
5
|
+
const geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
|
|
6
|
+
const util_1 = require("../../util");
|
|
7
|
+
const programcache_1 = require("../programcache");
|
|
8
|
+
const attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
|
|
9
|
+
const manager_1 = require("../../util/gl-util/uniform-block/manager");
|
|
10
|
+
require("../../util/gl-util/draw-options/types");
|
|
11
|
+
const methods_1 = require("../../util/gl-util/draw-options/methods");
|
|
12
|
+
const GLOBE_MIDPOINT_COUNT = 30;
|
|
13
|
+
const escapeValue = -1.0;
|
|
14
|
+
const uniformBindingPoints = {
|
|
15
|
+
camera: 0,
|
|
16
|
+
flexible: 1
|
|
17
|
+
};
|
|
18
|
+
const uniformBlockManager = new manager_1.UniformBlockManager('FlexibleAttibutes', [
|
|
19
|
+
{ name: 'u_color', type: 'vec4' },
|
|
20
|
+
{ name: 'u_dash_ratio', type: 'float' },
|
|
21
|
+
{ name: 'u_dash_opacity', type: 'float' }
|
|
22
|
+
], uniformBindingPoints.flexible);
|
|
23
|
+
const vertexShader = `#version 300 es
|
|
24
|
+
precision highp float;
|
|
25
|
+
|
|
26
|
+
${geometrytransformations_1.R_3D}
|
|
27
|
+
${totems_1.CameraUniformBlockString}
|
|
28
|
+
${geometrytransformations_1.slerp}
|
|
29
|
+
${geometrytransformations_1.mercatorXYToGLPosition}
|
|
30
|
+
${geometrytransformations_1.cartesian3DToGLPosition}
|
|
31
|
+
|
|
32
|
+
${uniformBlockManager.glslCode()}
|
|
33
|
+
|
|
34
|
+
in vec2 start_position;
|
|
35
|
+
in vec3 start_position3d;
|
|
36
|
+
in vec2 end_position;
|
|
37
|
+
in vec3 end_position3d;
|
|
38
|
+
|
|
39
|
+
in float dash_ratio;
|
|
40
|
+
in float dash_opacity;
|
|
41
|
+
in vec4 color;
|
|
42
|
+
|
|
43
|
+
out float v_dash_ratio;
|
|
44
|
+
out float v_dash_opacity;
|
|
45
|
+
out vec4 v_color;
|
|
46
|
+
|
|
47
|
+
out vec2 v_limp;
|
|
48
|
+
out float interpolation;
|
|
49
|
+
|
|
50
|
+
void main() {
|
|
51
|
+
vec2 longLat;
|
|
52
|
+
|
|
53
|
+
v_color = (color.r == -1.0) ? u_color: color;
|
|
54
|
+
v_dash_ratio = (dash_ratio == -1.0) ? u_dash_ratio : dash_ratio;
|
|
55
|
+
v_dash_opacity = (dash_opacity == -1.0) ? u_dash_opacity : dash_opacity;
|
|
56
|
+
|
|
57
|
+
if (is3D) {
|
|
58
|
+
interpolation = float(gl_VertexID) / ${GLOBE_MIDPOINT_COUNT - 1}.0;
|
|
59
|
+
vec3 cartesian = slerp(start_position3d, end_position3d, interpolation);
|
|
60
|
+
gl_Position = cartesian3DToGLPosition(cartesian);
|
|
61
|
+
v_limp = vec2(0.0, 0.0);
|
|
62
|
+
} else {
|
|
63
|
+
if ( distance( start_position, end_position) > 30000000.0) { return; }
|
|
64
|
+
interpolation = float(gl_VertexID);
|
|
65
|
+
if (gl_VertexID % 2 == 0) {
|
|
66
|
+
longLat = start_position;
|
|
67
|
+
} else {
|
|
68
|
+
longLat = end_position;
|
|
69
|
+
}
|
|
70
|
+
v_limp = longLat;
|
|
71
|
+
gl_Position = mercatorXYToGLPosition(longLat);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
const fragmentShader = `#version 300 es
|
|
76
|
+
${geometrytransformations_1.POLE}
|
|
77
|
+
precision highp float;
|
|
78
|
+
|
|
79
|
+
uniform float opacity;
|
|
80
|
+
|
|
81
|
+
in float interpolation;
|
|
82
|
+
in vec2 v_limp;
|
|
83
|
+
in vec4 v_color;
|
|
84
|
+
in float v_dash_ratio;
|
|
85
|
+
in float v_dash_opacity;
|
|
86
|
+
|
|
87
|
+
out vec4 color;
|
|
88
|
+
|
|
89
|
+
void main() {
|
|
90
|
+
if (v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE) { discard; }
|
|
91
|
+
color = v_color;
|
|
92
|
+
color.a *= opacity;
|
|
93
|
+
if ( v_dash_ratio >= 1.0 ) { return; }
|
|
94
|
+
if (interpolation > 0.95) { return; }
|
|
95
|
+
if (fract(interpolation / (2.0 * v_dash_ratio)) < 0.5) { color.a *= v_dash_opacity; }
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
`;
|
|
99
|
+
class Logic {
|
|
100
|
+
constructor(globe) {
|
|
101
|
+
this.vaosPublished = [];
|
|
102
|
+
this.isFreed = false;
|
|
103
|
+
this.globe = globe;
|
|
104
|
+
this.gl = globe.gl;
|
|
105
|
+
this.program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
|
|
106
|
+
this._lastOpacity = 1.0;
|
|
107
|
+
const { gl, program } = this;
|
|
108
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
109
|
+
gl.useProgram(program);
|
|
110
|
+
// assign attribute locations
|
|
111
|
+
gl.bindAttribLocation(program, 0, "start_position");
|
|
112
|
+
gl.bindAttribLocation(program, 1, "start_position3d");
|
|
113
|
+
gl.bindAttribLocation(program, 2, "end_position");
|
|
114
|
+
gl.bindAttribLocation(program, 3, "end_position3d");
|
|
115
|
+
gl.bindAttribLocation(program, 4, "dash_ratio");
|
|
116
|
+
gl.bindAttribLocation(program, 5, "dash_opacity");
|
|
117
|
+
gl.bindAttribLocation(program, 6, "color");
|
|
118
|
+
this._opacityLocation = gl.getUniformLocation(program, "opacity");
|
|
119
|
+
gl.uniform1f(this._opacityLocation, this._lastOpacity);
|
|
120
|
+
gl.useProgram(currentProgram);
|
|
121
|
+
this.cameraBlockTotem = totems_1.CameraUniformBlockTotemCache.get(globe);
|
|
122
|
+
this.cameraBlockTotem.assignBindingPoint(program, uniformBindingPoints.camera);
|
|
123
|
+
this._ubosPublished = [];
|
|
124
|
+
uniformBlockManager.assignBindingPoint(this.gl, this.program);
|
|
125
|
+
this._defaultFlexibleUBO = this.createUBO();
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
*
|
|
129
|
+
* @param {*} vao
|
|
130
|
+
* @param {DrawRangeIndexParams} drawOptions
|
|
131
|
+
* @param {number} opacity
|
|
132
|
+
* @param {Object} flexibleOptions
|
|
133
|
+
* @param {Array<number, number, number, number>} flexibleOptions.color // 0-1
|
|
134
|
+
* @param {number} flexibleOptions.dash_opacity
|
|
135
|
+
* @param {number} flexibleOptions.dash_ratio
|
|
136
|
+
*/
|
|
137
|
+
draw(vao, drawOptions, opacity, flexibleUBO = null) {
|
|
138
|
+
const { gl, program, globe, cameraBlockTotem, _defaultFlexibleUBO } = this;
|
|
139
|
+
gl.useProgram(program);
|
|
140
|
+
cameraBlockTotem.bind(uniformBindingPoints.camera);
|
|
141
|
+
gl.bindVertexArray(vao);
|
|
142
|
+
if (opacity !== this._lastOpacity) {
|
|
143
|
+
gl.uniform1f(this._opacityLocation, opacity);
|
|
144
|
+
this._lastOpacity = opacity;
|
|
145
|
+
}
|
|
146
|
+
// this._setFlexibleUniforms(flexibleOptions);
|
|
147
|
+
const vertexCount = globe.api_GetCurrentGeometry() === 0 ? GLOBE_MIDPOINT_COUNT : 2;
|
|
148
|
+
const ubo = flexibleUBO || _defaultFlexibleUBO;
|
|
149
|
+
ubo.bind();
|
|
150
|
+
(0, methods_1.drawInstanced)(gl, gl.LINE_STRIP, drawOptions, vertexCount);
|
|
151
|
+
ubo.unbind();
|
|
152
|
+
gl.bindVertexArray(null);
|
|
153
|
+
cameraBlockTotem.unbind(uniformBindingPoints.camera);
|
|
154
|
+
}
|
|
155
|
+
createUBO(bufferReadType = "STATIC_DRAW") {
|
|
156
|
+
const ubo = uniformBlockManager.createUBO(this.gl, bufferReadType);
|
|
157
|
+
this._ubosPublished.push(ubo);
|
|
158
|
+
ubo.update(new Map([
|
|
159
|
+
["u_color", [1, 1, 1, 1]],
|
|
160
|
+
["u_dash_ratio", [1]],
|
|
161
|
+
["u_dash_opacity", [1]]
|
|
162
|
+
]));
|
|
163
|
+
return ubo;
|
|
164
|
+
}
|
|
165
|
+
createVAO(startPotision2DBufferObj, startPotision3DBufferObj, endPosition2DBufferObj, endPosition3DBufferObj, dashRatioBufferObj, dashOpacityBufferObj, colorBufferObj) {
|
|
166
|
+
const { gl } = this;
|
|
167
|
+
const vao = gl.createVertexArray();
|
|
168
|
+
gl.bindVertexArray(vao);
|
|
169
|
+
const divisor = 1;
|
|
170
|
+
(0, attribute_loader_1.attributeLoader)(gl, startPotision2DBufferObj, 0, 2, { divisor });
|
|
171
|
+
(0, attribute_loader_1.attributeLoader)(gl, startPotision3DBufferObj, 1, 3, { divisor });
|
|
172
|
+
(0, attribute_loader_1.attributeLoader)(gl, endPosition2DBufferObj, 2, 2, { divisor });
|
|
173
|
+
(0, attribute_loader_1.attributeLoader)(gl, endPosition3DBufferObj, 3, 3, { divisor });
|
|
174
|
+
(0, attribute_loader_1.attributeLoader)(gl, dashRatioBufferObj, 4, 1, { divisor, escapeValues: [escapeValue] });
|
|
175
|
+
(0, attribute_loader_1.attributeLoader)(gl, dashOpacityBufferObj, 5, 1, { divisor, escapeValues: [escapeValue] });
|
|
176
|
+
(0, attribute_loader_1.attributeLoader)(gl, colorBufferObj, 6, 4, { divisor, escapeValues: [escapeValue, escapeValue, escapeValue, escapeValue] });
|
|
177
|
+
gl.bindVertexArray(null);
|
|
178
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
179
|
+
this.vaosPublished.push(vao);
|
|
180
|
+
return vao;
|
|
181
|
+
}
|
|
182
|
+
free() {
|
|
183
|
+
if (this.isFreed)
|
|
184
|
+
return;
|
|
185
|
+
totems_1.CameraUniformBlockTotemCache.release(this.globe);
|
|
186
|
+
this.gl.deleteProgram(this.program);
|
|
187
|
+
this.vaosPublished.forEach(vao => this.gl.deleteVertexArray(vao));
|
|
188
|
+
this._ubosPublished.forEach(ubo => ubo.free());
|
|
189
|
+
this.isFreed = true;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
exports.LineOnGlobeCache = Object.freeze({
|
|
193
|
+
get: (globe) => { return programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic); },
|
|
194
|
+
release: (globe) => { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic); }
|
|
195
|
+
});
|