@pirireis/webglobeplugins 0.13.0-alpha → 0.14.0-alpha
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/arc-cdf-points.js +20 -0
- package/Math/arc-generate-points copy.js +1 -0
- package/Math/arc.js +21 -8
- package/Math/circle.js +35 -16
- package/Math/templete-shapes/grid-visually-equal.js +66 -0
- package/altitude-locator/plugin.js +3 -2
- package/bearing-line/plugin.js +1 -2
- package/circle-line-chain/plugin.js +4 -7
- package/compass-rose/compass-rose-padding-flat.js +12 -0
- package/package.json +1 -1
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +1 -1
- package/programs/line-on-globe/linestrip/linestrip.js +5 -3
- package/programs/line-on-globe/naive-accurate-flexible.js +23 -16
- package/programs/picking/pickable-renderer.js +1 -2
- package/programs/rings/partial-ring/piece-of-pie copy.js +286 -0
- package/programs/rings/partial-ring/piece-of-pie.js +26 -13
- package/programs/totems/camerauniformblock.js +1 -1
- package/programs/totems/index.js +1 -1
- package/range-tools-on-terrain/bearing-line/adapters.js +111 -0
- package/range-tools-on-terrain/bearing-line/plugin.js +360 -0
- package/range-tools-on-terrain/circle-line-chain/adapters.js +83 -0
- package/range-tools-on-terrain/circle-line-chain/chain-list-map.js +351 -0
- package/range-tools-on-terrain/circle-line-chain/plugin.js +389 -0
- package/range-tools-on-terrain/circle-line-chain/types.js +1 -0
- package/range-tools-on-terrain/range-ring/adapters.js +25 -0
- package/range-tools-on-terrain/range-ring/plugin.js +31 -0
- package/range-tools-on-terrain/range-ring/types.js +1 -0
- package/rangerings/plugin.js +7 -11
- package/semiplugins/lightweight/line-plugin.js +195 -0
- package/semiplugins/lightweight/piece-of-pie-plugin.js +175 -0
- package/semiplugins/shape-on-terrain/arc-plugin.js +368 -0
- package/{shape-on-terrain/circle/plugin.js → semiplugins/shape-on-terrain/circle-plugin.js} +67 -38
- package/semiplugins/shape-on-terrain/derived/padding-plugin.js +96 -0
- package/semiplugins/type.js +1 -0
- package/types.js +0 -11
- package/util/account/create-buffermap-orchastration.js +39 -0
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +14 -3
- package/util/check/typecheck.js +15 -1
- package/util/geometry/index.js +3 -2
- package/util/gl-util/buffer/attribute-loader.js +2 -5
- package/util/gl-util/draw-options/methods.js +4 -5
- package/util/webglobjectbuilders.js +4 -9
- package/write-text/context-text3.js +17 -0
- package/write-text/context-text3old.js +152 -0
- package/programs/line-on-globe/circle-accurate.js +0 -176
- package/programs/line-on-globe/circle.js +0 -166
- package/programs/line-on-globe/to-the-surface.js +0 -111
- package/programs/totems/canvas-webglobe-info1.js +0 -106
- package/shape-on-terrain/arc/naive/plugin.js +0 -250
- package/util/check/get.js +0 -14
- package/util/gl-util/buffer/types.js +0 -1
- package/util/gl-util/draw-options/types.js +0 -15
- package/util/webglobjectbuilders1.js +0 -219
- /package/{shape-on-terrain/type.js → range-tools-on-terrain/bearing-line/types.js} +0 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { createProgram } from "../../../util/webglobjectbuilders";
|
|
2
|
+
import { CameraUniformBlockTotem, CameraUniformBlockString } from "../../totems/index";
|
|
3
|
+
import { noRegisterGlobeProgramCache, globeProgramCache } from "../../programcache";
|
|
4
|
+
import { POLE, PI, longLatRadToMercator, mercatorXYToGLPosition, longLatRadToCartesian3D, circleLimpFromLongLatRadCenterCartesian3D_accurate, circleLimpFromLongLatRadCenterMercatorCompass_accurate,
|
|
5
|
+
//circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate,
|
|
6
|
+
cartesian3DToGLPosition } from "../../../util/shaderfunctions/geometrytransformations";
|
|
7
|
+
/**
|
|
8
|
+
* TODO:
|
|
9
|
+
* 1. Triangle face looks at screen. if rotation angle is positive the last vertex must be the faintest.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
const drawModeMap = Object.freeze({
|
|
13
|
+
LINE_STRIP: 0,
|
|
14
|
+
TRIANGLE_FAN: 1,
|
|
15
|
+
});
|
|
16
|
+
//${ circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate }
|
|
17
|
+
const vertexShaderSource = `#version 300 es
|
|
18
|
+
|
|
19
|
+
${CameraUniformBlockString}
|
|
20
|
+
${PI}
|
|
21
|
+
${longLatRadToMercator}
|
|
22
|
+
${mercatorXYToGLPosition}
|
|
23
|
+
${longLatRadToCartesian3D}
|
|
24
|
+
${circleLimpFromLongLatRadCenterCartesian3D_accurate}
|
|
25
|
+
${circleLimpFromLongLatRadCenterMercatorCompass_accurate}
|
|
26
|
+
${cartesian3DToGLPosition}
|
|
27
|
+
|
|
28
|
+
uniform float edge_count;
|
|
29
|
+
uniform int draw_mode; // %2 => 0: LINE_STRIP, 1: TRIANGLE_FAN
|
|
30
|
+
uniform float plugin_alpha_multiplier;
|
|
31
|
+
//, lat, startAngle, tailAngle, ...rgba, radius, rgbaMode
|
|
32
|
+
// in vec2 center; // long, lat in radian
|
|
33
|
+
in vec2 center2d;
|
|
34
|
+
in vec3 center3d;
|
|
35
|
+
in float start_angle2d;
|
|
36
|
+
in float tail_angle2d;
|
|
37
|
+
|
|
38
|
+
in float start_angle3d;
|
|
39
|
+
in float tail_angle3d;
|
|
40
|
+
|
|
41
|
+
in vec4 color;
|
|
42
|
+
in float radius; // in meter
|
|
43
|
+
in float filling_mode; // 0.0: constant, 1.0: fading, 2.0: hide
|
|
44
|
+
// flat out int vid;
|
|
45
|
+
// flat out float v_phase;
|
|
46
|
+
out vec2 v_pos;
|
|
47
|
+
out vec4 v_color;
|
|
48
|
+
// flat out float v_angle;
|
|
49
|
+
|
|
50
|
+
void main() {
|
|
51
|
+
// vid = gl_VertexID;
|
|
52
|
+
if (filling_mode == 2.0 || radius == 0.0) { return; }
|
|
53
|
+
float start_angle, tail_angle;
|
|
54
|
+
if (is3D) {
|
|
55
|
+
start_angle = start_angle3d;
|
|
56
|
+
tail_angle = tail_angle3d;
|
|
57
|
+
} else {
|
|
58
|
+
start_angle = start_angle2d;
|
|
59
|
+
tail_angle = tail_angle2d;
|
|
60
|
+
}
|
|
61
|
+
float filling_mode_ = filling_mode;
|
|
62
|
+
if ( draw_mode == 0 && filling_mode == 1.0) {filling_mode_ = 0.0;}
|
|
63
|
+
float vertexID = float(gl_VertexID);
|
|
64
|
+
float radius_ = radius;
|
|
65
|
+
float alpha = plugin_alpha_multiplier;
|
|
66
|
+
if (draw_mode == 1) { // TRIANGLE_FAN
|
|
67
|
+
if (gl_VertexID == 0) {
|
|
68
|
+
radius_ = 0.0;
|
|
69
|
+
if ( filling_mode == 1.0 ) { alpha = 0.0; }
|
|
70
|
+
}
|
|
71
|
+
vertexID -= 1.0;
|
|
72
|
+
}
|
|
73
|
+
float phase = ( vertexID / (edge_count - 1.0) );
|
|
74
|
+
// v_angle = tail_angle;
|
|
75
|
+
|
|
76
|
+
if ( filling_mode_ == 1.0 ) {
|
|
77
|
+
if ( tail_angle < 0.0 ) {
|
|
78
|
+
v_color = vec4( color.rgb , color.a * ( 1.0 - phase ) * alpha );
|
|
79
|
+
} else {
|
|
80
|
+
v_color = vec4( color.rgb , color.a * phase * alpha );
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
v_color = vec4( color.rgb , color.a * alpha );
|
|
84
|
+
}
|
|
85
|
+
if ( filling_mode == 0.0 && draw_mode == 1 ) {
|
|
86
|
+
v_color.a /= 2.0;
|
|
87
|
+
}
|
|
88
|
+
float angle;
|
|
89
|
+
if ( tail_angle > 0.0 ) {
|
|
90
|
+
angle = tail_angle * (-phase + 1.0) + start_angle;
|
|
91
|
+
} else {
|
|
92
|
+
angle = tail_angle * phase + start_angle;
|
|
93
|
+
}
|
|
94
|
+
if (is3D) {
|
|
95
|
+
vec3 pos = circleLimpFromLongLatRadCenterCartesian3D_accurate(center3d, radius_, angle);
|
|
96
|
+
v_pos = vec2(0.0, 0.0);
|
|
97
|
+
gl_Position = cartesian3DToGLPosition(pos);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
vec2 pos2 = circleLimpFromLongLatRadCenterMercatorCompass_accurate(center2d, radius_, angle);
|
|
101
|
+
v_pos = pos2;
|
|
102
|
+
gl_Position = mercatorXYToGLPosition(pos2);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
gl_PointSize = 10.0;
|
|
106
|
+
}`;
|
|
107
|
+
const fragmentShaderSource = `#version 300 es` + POLE + PI + `
|
|
108
|
+
precision highp float;
|
|
109
|
+
// flat in int vid;
|
|
110
|
+
in vec4 v_color;
|
|
111
|
+
in vec2 v_pos;
|
|
112
|
+
// flat in float v_phase;
|
|
113
|
+
// in float v_angle;
|
|
114
|
+
out vec4 outColor;
|
|
115
|
+
void main() {
|
|
116
|
+
// if( vid % 2 == 0 ) { discard; }
|
|
117
|
+
// if ( mod(v_angle, PI / 36.0 ) < (PI / 72.0)) { discard; }
|
|
118
|
+
// if ( mod(v_angle * v_phase, PI / 90.0 ) < (PI / 180.0)) { discard; }
|
|
119
|
+
if ( v_pos.x < -POLE || v_pos.x > POLE || v_pos.y < -POLE || v_pos.y > POLE ) { discard; }
|
|
120
|
+
outColor = v_color;
|
|
121
|
+
}`;
|
|
122
|
+
export const ITEM_SIZE = 10;
|
|
123
|
+
export class Logic {
|
|
124
|
+
globe;
|
|
125
|
+
gl;
|
|
126
|
+
_lastMode;
|
|
127
|
+
_lastEdgeCount;
|
|
128
|
+
_lastAlphaMultiplier;
|
|
129
|
+
program;
|
|
130
|
+
_edgeCountLocation;
|
|
131
|
+
_draw_modeLocation;
|
|
132
|
+
_plugin_alpha_multiplierLocation;
|
|
133
|
+
cameraBlockBindingPoint;
|
|
134
|
+
cameraBlockTotem; // Type this based on your CameraUniformBlockTotem implementation
|
|
135
|
+
constructor(globe) {
|
|
136
|
+
this.globe = globe;
|
|
137
|
+
this.gl = globe.gl;
|
|
138
|
+
this._lastMode = 0;
|
|
139
|
+
this._lastEdgeCount = 64;
|
|
140
|
+
this._lastAlphaMultiplier = 1.0;
|
|
141
|
+
this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
|
|
142
|
+
const { gl, program } = this;
|
|
143
|
+
{ // set attributes locations
|
|
144
|
+
gl.bindAttribLocation(program, 0, 'center2d');
|
|
145
|
+
gl.bindAttribLocation(program, 1, 'center3d');
|
|
146
|
+
gl.bindAttribLocation(program, 2, 'start_angle2d');
|
|
147
|
+
gl.bindAttribLocation(program, 3, 'tail_angle2d');
|
|
148
|
+
gl.bindAttribLocation(program, 4, 'start_angle3d');
|
|
149
|
+
gl.bindAttribLocation(program, 5, 'tail_angle3d');
|
|
150
|
+
gl.bindAttribLocation(program, 6, 'color');
|
|
151
|
+
gl.bindAttribLocation(program, 7, 'radius');
|
|
152
|
+
gl.bindAttribLocation(program, 8, 'filling_mode');
|
|
153
|
+
// vao
|
|
154
|
+
// instanced draw read 1
|
|
155
|
+
}
|
|
156
|
+
{ // Uniforms
|
|
157
|
+
this._edgeCountLocation = gl.getUniformLocation(program, 'edge_count');
|
|
158
|
+
this._draw_modeLocation = gl.getUniformLocation(program, 'draw_mode');
|
|
159
|
+
this._plugin_alpha_multiplierLocation = gl.getUniformLocation(program, 'plugin_alpha_multiplier');
|
|
160
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
161
|
+
gl.useProgram(program);
|
|
162
|
+
gl.uniform1i(this._draw_modeLocation, this._lastMode);
|
|
163
|
+
gl.uniform1f(this._edgeCountLocation, this._lastEdgeCount);
|
|
164
|
+
gl.uniform1f(this._plugin_alpha_multiplierLocation, 1.0);
|
|
165
|
+
this.cameraBlockBindingPoint = 0;
|
|
166
|
+
this.cameraBlockTotem = globeProgramCache.getProgram(globe, CameraUniformBlockTotem);
|
|
167
|
+
const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
|
|
168
|
+
gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
|
|
169
|
+
gl.useProgram(currentProgram);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
draw(length, vao, edgeCount, alphaMultiplier, drawMode) {
|
|
173
|
+
const { gl, program, cameraBlockTotem, cameraBlockBindingPoint } = this;
|
|
174
|
+
// gl.disable(gl.DEPTH_TEST);
|
|
175
|
+
gl.useProgram(program);
|
|
176
|
+
if (drawModeMap[drawMode] !== this._lastMode) {
|
|
177
|
+
gl.uniform1i(this._draw_modeLocation, drawModeMap[drawMode]);
|
|
178
|
+
this._lastMode = drawModeMap[drawMode];
|
|
179
|
+
}
|
|
180
|
+
if (edgeCount !== this._lastEdgeCount) {
|
|
181
|
+
gl.uniform1f(this._edgeCountLocation, edgeCount);
|
|
182
|
+
this._lastEdgeCount = edgeCount;
|
|
183
|
+
}
|
|
184
|
+
if (alphaMultiplier !== this._lastAlphaMultiplier) {
|
|
185
|
+
gl.uniform1f(this._plugin_alpha_multiplierLocation, alphaMultiplier);
|
|
186
|
+
this._lastAlphaMultiplier = alphaMultiplier;
|
|
187
|
+
}
|
|
188
|
+
const overdraw = drawModeMap[drawMode];
|
|
189
|
+
cameraBlockTotem.bind(cameraBlockBindingPoint);
|
|
190
|
+
gl.bindVertexArray(vao);
|
|
191
|
+
gl.drawArraysInstanced(gl[drawMode], 0, edgeCount + overdraw, length);
|
|
192
|
+
cameraBlockTotem.unbind(cameraBlockBindingPoint);
|
|
193
|
+
gl.bindVertexArray(null);
|
|
194
|
+
// gl.enable(gl.DEPTH_TEST);
|
|
195
|
+
}
|
|
196
|
+
free() {
|
|
197
|
+
noRegisterGlobeProgramCache.releaseProgram(this.globe, CameraUniformBlockTotem);
|
|
198
|
+
this.gl.deleteProgram(this.program);
|
|
199
|
+
this.program = null;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* in vec2 center; // long, lat in radian
|
|
203
|
+
in float start_angle; // the start of partial circle from bearing point
|
|
204
|
+
in float tail_angle; // the rotation of the partial circle
|
|
205
|
+
in vec4 color;
|
|
206
|
+
in float radius; // in meter
|
|
207
|
+
in float filling_mode; // 0.0: constant, 1.0: fading, 2.0: hide
|
|
208
|
+
*/
|
|
209
|
+
createVAO(center2dObj, center3dObj, startAngle2DObj, tailAngle2DObj, startAngle3DObj, tailAngle3DObj, colorObj, radiusObj, colorModeObj) {
|
|
210
|
+
const { gl } = this;
|
|
211
|
+
const vao = gl.createVertexArray();
|
|
212
|
+
gl.bindVertexArray(vao);
|
|
213
|
+
{
|
|
214
|
+
const { buffer, stride, offset } = center2dObj;
|
|
215
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
216
|
+
gl.enableVertexAttribArray(0);
|
|
217
|
+
gl.vertexAttribPointer(0, 2, gl.FLOAT, false, stride, offset);
|
|
218
|
+
gl.vertexAttribDivisor(0, 1);
|
|
219
|
+
}
|
|
220
|
+
{
|
|
221
|
+
const { buffer, stride, offset } = center3dObj;
|
|
222
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
223
|
+
gl.enableVertexAttribArray(1);
|
|
224
|
+
gl.vertexAttribPointer(1, 3, gl.FLOAT, false, stride, offset);
|
|
225
|
+
gl.vertexAttribDivisor(1, 1);
|
|
226
|
+
}
|
|
227
|
+
{
|
|
228
|
+
const { buffer, stride, offset } = startAngle2DObj;
|
|
229
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
230
|
+
gl.enableVertexAttribArray(2);
|
|
231
|
+
gl.vertexAttribPointer(2, 1, gl.FLOAT, false, stride, offset);
|
|
232
|
+
gl.vertexAttribDivisor(2, 1);
|
|
233
|
+
}
|
|
234
|
+
{
|
|
235
|
+
const { buffer, stride, offset } = tailAngle2DObj;
|
|
236
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
237
|
+
gl.enableVertexAttribArray(3);
|
|
238
|
+
gl.vertexAttribPointer(3, 1, gl.FLOAT, false, stride, offset);
|
|
239
|
+
gl.vertexAttribDivisor(3, 1);
|
|
240
|
+
}
|
|
241
|
+
{
|
|
242
|
+
const { buffer, stride, offset } = startAngle3DObj;
|
|
243
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
244
|
+
gl.enableVertexAttribArray(4);
|
|
245
|
+
gl.vertexAttribPointer(4, 1, gl.FLOAT, false, stride, offset);
|
|
246
|
+
gl.vertexAttribDivisor(4, 1);
|
|
247
|
+
}
|
|
248
|
+
{
|
|
249
|
+
const { buffer, stride, offset } = tailAngle3DObj;
|
|
250
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
251
|
+
gl.enableVertexAttribArray(5);
|
|
252
|
+
gl.vertexAttribPointer(5, 1, gl.FLOAT, false, stride, offset);
|
|
253
|
+
gl.vertexAttribDivisor(5, 1);
|
|
254
|
+
}
|
|
255
|
+
{
|
|
256
|
+
const { buffer, stride, offset } = colorObj;
|
|
257
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
258
|
+
gl.enableVertexAttribArray(6);
|
|
259
|
+
gl.vertexAttribPointer(6, 4, gl.FLOAT, false, stride, offset);
|
|
260
|
+
gl.vertexAttribDivisor(6, 1);
|
|
261
|
+
}
|
|
262
|
+
{
|
|
263
|
+
const { buffer, stride, offset } = radiusObj;
|
|
264
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
265
|
+
gl.enableVertexAttribArray(7);
|
|
266
|
+
gl.vertexAttribPointer(7, 1, gl.FLOAT, false, stride, offset);
|
|
267
|
+
gl.vertexAttribDivisor(7, 1);
|
|
268
|
+
}
|
|
269
|
+
{
|
|
270
|
+
const { buffer, stride, offset } = colorModeObj;
|
|
271
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
272
|
+
gl.enableVertexAttribArray(8);
|
|
273
|
+
gl.vertexAttribPointer(8, 1, gl.FLOAT, false, stride, offset);
|
|
274
|
+
gl.vertexAttribDivisor(8, 1);
|
|
275
|
+
}
|
|
276
|
+
gl.bindVertexArray(null);
|
|
277
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
278
|
+
return vao;
|
|
279
|
+
}
|
|
280
|
+
createUBO() {
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
export const PieceOfPieProgramCache = Object.freeze({
|
|
284
|
+
get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
|
|
285
|
+
release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
|
|
286
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createProgram
|
|
2
|
-
import { CameraUniformBlockTotem, CameraUniformBlockString } from "../../totems";
|
|
1
|
+
import { createProgram } from "../../../util/webglobjectbuilders";
|
|
2
|
+
import { CameraUniformBlockTotem, CameraUniformBlockString } from "../../totems/index";
|
|
3
3
|
import { noRegisterGlobeProgramCache, globeProgramCache } from "../../programcache";
|
|
4
4
|
import { POLE, PI, longLatRadToMercator, mercatorXYToGLPosition, longLatRadToCartesian3D, circleLimpFromLongLatRadCenterCartesian3D_accurate, circleLimpFromLongLatRadCenterMercatorCompass_accurate,
|
|
5
5
|
//circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate,
|
|
@@ -40,7 +40,7 @@ in float tail_angle3d;
|
|
|
40
40
|
|
|
41
41
|
in vec4 color;
|
|
42
42
|
in float radius; // in meter
|
|
43
|
-
in float
|
|
43
|
+
in float filling_mode; // 0.0: constant, 1.0: fading, 2.0: hide
|
|
44
44
|
// flat out int vid;
|
|
45
45
|
// flat out float v_phase;
|
|
46
46
|
out vec2 v_pos;
|
|
@@ -49,7 +49,7 @@ out vec4 v_color;
|
|
|
49
49
|
|
|
50
50
|
void main() {
|
|
51
51
|
// vid = gl_VertexID;
|
|
52
|
-
if (
|
|
52
|
+
if (filling_mode == 2.0 || radius == 0.0) { return; }
|
|
53
53
|
float start_angle, tail_angle;
|
|
54
54
|
if (is3D) {
|
|
55
55
|
start_angle = start_angle3d;
|
|
@@ -58,22 +58,22 @@ void main() {
|
|
|
58
58
|
start_angle = start_angle2d;
|
|
59
59
|
tail_angle = tail_angle2d;
|
|
60
60
|
}
|
|
61
|
-
float
|
|
62
|
-
if ( draw_mode == 0 &&
|
|
61
|
+
float filling_mode_ = filling_mode;
|
|
62
|
+
if ( draw_mode == 0 && filling_mode == 1.0) {filling_mode_ = 0.0;}
|
|
63
63
|
float vertexID = float(gl_VertexID);
|
|
64
64
|
float radius_ = radius;
|
|
65
65
|
float alpha = plugin_alpha_multiplier;
|
|
66
66
|
if (draw_mode == 1) { // TRIANGLE_FAN
|
|
67
67
|
if (gl_VertexID == 0) {
|
|
68
68
|
radius_ = 0.0;
|
|
69
|
-
if (
|
|
69
|
+
if ( filling_mode == 1.0 ) { alpha = 0.0; }
|
|
70
70
|
}
|
|
71
71
|
vertexID -= 1.0;
|
|
72
72
|
}
|
|
73
73
|
float phase = ( vertexID / (edge_count - 1.0) );
|
|
74
74
|
// v_angle = tail_angle;
|
|
75
75
|
|
|
76
|
-
if (
|
|
76
|
+
if ( filling_mode_ == 1.0 ) {
|
|
77
77
|
if ( tail_angle < 0.0 ) {
|
|
78
78
|
v_color = vec4( color.rgb , color.a * ( 1.0 - phase ) * alpha );
|
|
79
79
|
} else {
|
|
@@ -82,7 +82,7 @@ void main() {
|
|
|
82
82
|
} else {
|
|
83
83
|
v_color = vec4( color.rgb , color.a * alpha );
|
|
84
84
|
}
|
|
85
|
-
if (
|
|
85
|
+
if ( filling_mode == 0.0 && draw_mode == 1 ) {
|
|
86
86
|
v_color.a /= 2.0;
|
|
87
87
|
}
|
|
88
88
|
float angle;
|
|
@@ -121,6 +121,17 @@ void main() {
|
|
|
121
121
|
}`;
|
|
122
122
|
export const ITEM_SIZE = 10;
|
|
123
123
|
export class Logic {
|
|
124
|
+
globe;
|
|
125
|
+
gl;
|
|
126
|
+
_lastMode;
|
|
127
|
+
_lastEdgeCount;
|
|
128
|
+
_lastAlphaMultiplier;
|
|
129
|
+
program;
|
|
130
|
+
_edgeCountLocation;
|
|
131
|
+
_draw_modeLocation;
|
|
132
|
+
_plugin_alpha_multiplierLocation;
|
|
133
|
+
cameraBlockBindingPoint;
|
|
134
|
+
cameraBlockTotem; // Type this based on your CameraUniformBlockTotem implementation
|
|
124
135
|
constructor(globe) {
|
|
125
136
|
this.globe = globe;
|
|
126
137
|
this.gl = globe.gl;
|
|
@@ -138,7 +149,7 @@ export class Logic {
|
|
|
138
149
|
gl.bindAttribLocation(program, 5, 'tail_angle3d');
|
|
139
150
|
gl.bindAttribLocation(program, 6, 'color');
|
|
140
151
|
gl.bindAttribLocation(program, 7, 'radius');
|
|
141
|
-
gl.bindAttribLocation(program, 8, '
|
|
152
|
+
gl.bindAttribLocation(program, 8, 'filling_mode');
|
|
142
153
|
// vao
|
|
143
154
|
// instanced draw read 1
|
|
144
155
|
}
|
|
@@ -162,9 +173,9 @@ export class Logic {
|
|
|
162
173
|
const { gl, program, cameraBlockTotem, cameraBlockBindingPoint } = this;
|
|
163
174
|
// gl.disable(gl.DEPTH_TEST);
|
|
164
175
|
gl.useProgram(program);
|
|
165
|
-
if (drawMode !== this._lastMode) {
|
|
176
|
+
if (drawModeMap[drawMode] !== this._lastMode) {
|
|
166
177
|
gl.uniform1i(this._draw_modeLocation, drawModeMap[drawMode]);
|
|
167
|
-
this._lastMode = drawMode;
|
|
178
|
+
this._lastMode = drawModeMap[drawMode];
|
|
168
179
|
}
|
|
169
180
|
if (edgeCount !== this._lastEdgeCount) {
|
|
170
181
|
gl.uniform1f(this._edgeCountLocation, edgeCount);
|
|
@@ -193,7 +204,7 @@ export class Logic {
|
|
|
193
204
|
in float tail_angle; // the rotation of the partial circle
|
|
194
205
|
in vec4 color;
|
|
195
206
|
in float radius; // in meter
|
|
196
|
-
in float
|
|
207
|
+
in float filling_mode; // 0.0: constant, 1.0: fading, 2.0: hide
|
|
197
208
|
*/
|
|
198
209
|
createVAO(center2dObj, center3dObj, startAngle2DObj, tailAngle2DObj, startAngle3DObj, tailAngle3DObj, colorObj, radiusObj, colorModeObj) {
|
|
199
210
|
const { gl } = this;
|
|
@@ -266,6 +277,8 @@ export class Logic {
|
|
|
266
277
|
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
267
278
|
return vao;
|
|
268
279
|
}
|
|
280
|
+
createUBO() {
|
|
281
|
+
}
|
|
269
282
|
}
|
|
270
283
|
export const PieceOfPieProgramCache = Object.freeze({
|
|
271
284
|
get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
|
package/programs/totems/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import CameraUniformBlockTotem,
|
|
1
|
+
import { CameraUniformBlockTotem, CameraUniformBlockString, CameraUniformBlockTotemCache } from "./camerauniformblock";
|
|
2
2
|
export { CameraUniformBlockTotem, CameraUniformBlockString, CameraUniformBlockTotemCache };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
const radian = (degree) => degree * Math.PI / 180;
|
|
2
|
+
const calculateStartAngle = (long, lat, endLong, endLat) => {
|
|
3
|
+
const dLat = (integralSec(endLat) - integralSec(lat)); // Because lines are strectes toward poles.
|
|
4
|
+
const dLong = endLong - long;
|
|
5
|
+
let angle = -Math.atan2(dLat, dLong);
|
|
6
|
+
return angle;
|
|
7
|
+
};
|
|
8
|
+
const integralSec = (angle) => {
|
|
9
|
+
return Math.log(Math.tan(angle / 2 + Math.PI / 4));
|
|
10
|
+
};
|
|
11
|
+
export const flatLinesInputAdapter = (bearingLine) => {
|
|
12
|
+
const { long, lat, endLong, endLat, rgba } = bearingLine;
|
|
13
|
+
return {
|
|
14
|
+
key: bearingLine.key,
|
|
15
|
+
start: [long, lat],
|
|
16
|
+
end: [endLong, endLat],
|
|
17
|
+
color: rgba,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export const flatLinesBearingInputAdapter = (bearingLine) => {
|
|
21
|
+
const { long, lat, rgba, key, bearingLat = 0, bearingLong = 0 } = bearingLine;
|
|
22
|
+
return {
|
|
23
|
+
key: key,
|
|
24
|
+
start: [long, lat],
|
|
25
|
+
end: [bearingLong, bearingLat],
|
|
26
|
+
color: rgba,
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export const bearingLineToCircleInputAdapter = (globe) => (bearingLine) => {
|
|
30
|
+
const { long, lat, endLong, endLat, rgba, altitude = 0 } = bearingLine;
|
|
31
|
+
if (bearingLine.radius === undefined || bearingLine.radius === null) {
|
|
32
|
+
const radius = globe.Math.GetDist2D(long, lat, endLong, endLat);
|
|
33
|
+
bearingLine.radius = radius;
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
key: bearingLine.key,
|
|
37
|
+
center: [long, lat],
|
|
38
|
+
radius: bearingLine.radius,
|
|
39
|
+
height: altitude,
|
|
40
|
+
color: rgba,
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export const bearingLineToArcInputAdapter = (bearingLine) => {
|
|
44
|
+
const { long, lat, endLong, endLat, rgba, altitude = 0 } = bearingLine;
|
|
45
|
+
return {
|
|
46
|
+
key: bearingLine.key,
|
|
47
|
+
start: [long, lat],
|
|
48
|
+
end: [endLong, endLat],
|
|
49
|
+
height: altitude,
|
|
50
|
+
color: rgba,
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
export const bearingLineToBearingArcInputAdapter = (globe, bearingLine) => {
|
|
54
|
+
const { long, lat, bearingAngle, rgba, altitude = 0, key } = bearingLine;
|
|
55
|
+
if (bearingLine.radius === undefined || bearingLine.radius === null) {
|
|
56
|
+
throw new Error("Bearing line radius is not defined. Please calculate it before converting to ArcInput.");
|
|
57
|
+
}
|
|
58
|
+
const { long: endLong, lat: endLat } = globe.Math.FindPointByPolar(long, lat, bearingLine.radius, bearingAngle);
|
|
59
|
+
bearingLine.bearingLong = endLong;
|
|
60
|
+
bearingLine.bearingLat = endLat;
|
|
61
|
+
return {
|
|
62
|
+
key: key,
|
|
63
|
+
start: [long, lat],
|
|
64
|
+
end: [endLong, endLat],
|
|
65
|
+
height: altitude,
|
|
66
|
+
color: rgba,
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export const bearingLineToPieceOfPieInputAdapter = (globe, item) => {
|
|
70
|
+
const lat = radian(item.lat);
|
|
71
|
+
const long = radian(item.long);
|
|
72
|
+
const endLat = radian(item.endLat);
|
|
73
|
+
const endLong = radian(item.endLong);
|
|
74
|
+
const altitude = (item.altitude ?? 0) / 1000;
|
|
75
|
+
const radius = item.radius ? item.radius * 0.2 : 10;
|
|
76
|
+
// @ts-ignore
|
|
77
|
+
const { long: bearingLong, lat: bearingLat } = globe.Math.FindPointByPolar(item.long, item.lat, item.radius, item.bearingAngle);
|
|
78
|
+
const startAngle2d = calculateStartAngle(long, lat, endLong, endLat);
|
|
79
|
+
const bearingAngle2d = calculateStartAngle(long, lat, radian(bearingLong), radian(bearingLat));
|
|
80
|
+
let tailAngle2d = bearingAngle2d - startAngle2d;
|
|
81
|
+
if (tailAngle2d > 0) {
|
|
82
|
+
tailAngle2d -= Math.PI * 2;
|
|
83
|
+
}
|
|
84
|
+
const bearingAngle = radian(item.bearingAngle - 90);
|
|
85
|
+
const startAngleReal = globe.Math.GetAzimuthAngle(item.long, item.lat, item.endLong, item.endLat); //startAngle2d * 180 / Math.PI;
|
|
86
|
+
const startAngle3d = radian(startAngleReal - 90);
|
|
87
|
+
let tailAngle3d = bearingAngle - startAngle3d;
|
|
88
|
+
if (tailAngle3d > 0) {
|
|
89
|
+
tailAngle3d -= Math.PI * 2;
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
key: item.key,
|
|
93
|
+
center: [item.long, item.lat],
|
|
94
|
+
radius: radius,
|
|
95
|
+
altitude: altitude + 230,
|
|
96
|
+
color: item.rgba,
|
|
97
|
+
startAngle2D: startAngle2d * 180 / Math.PI,
|
|
98
|
+
coverAngle2D: tailAngle2d * 180 / Math.PI,
|
|
99
|
+
startAngle3D: startAngle3d * 180 / Math.PI,
|
|
100
|
+
coverAngle3D: tailAngle3d * 180 / Math.PI,
|
|
101
|
+
fillingMode: item.pieFillingMode ?? 1,
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
export const pieceOfPieOpacityAdaptor = (lod, tiltAngle) => {
|
|
105
|
+
const lodThreshold = 7.5;
|
|
106
|
+
const lodFactor = Math.exp(-Math.max(0, lod - lodThreshold));
|
|
107
|
+
tiltAngle += 5;
|
|
108
|
+
const tiltFactor = Math.min(1, 1 / Math.tan(radian(tiltAngle)));
|
|
109
|
+
const opacity = Math.max(Math.min(lodFactor * tiltFactor, 1), 0);
|
|
110
|
+
return opacity < 0.1 ? 0 : opacity; // Ensure opacity is not less than 0.1
|
|
111
|
+
};
|