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