@pirireis/webglobeplugins 0.15.1-alpha → 0.15.2-3.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.js +1 -2
- package/Math/circle-cdf-points.js +1 -170
- package/Math/circle.js +0 -25
- package/Math/methods.js +2 -2
- package/Math/vec3.js +6 -2
- package/altitude-locator/plugin.js +1 -1
- package/bearing-line/plugin.js +3 -2
- package/package.json +1 -1
- package/point-tracks/plugin.js +82 -22
- package/programs/line-on-globe/lines-color-instanced-flat.js +0 -1
- package/programs/line-on-globe/linestrip/linestrip.js +2 -30
- package/programs/point-on-globe/element-globe-surface-glow.js +0 -1
- package/programs/rings/partial-ring/piece-of-pie.js +55 -89
- package/programs/totems/camerauniformblock.js +7 -0
- package/programs/totems/canvas-webglobe-info.js +9 -9
- package/programs/totems/globe-changes.js +59 -0
- package/range-tools-on-terrain/bearing-line/adapters.js +8 -5
- package/range-tools-on-terrain/bearing-line/plugin.js +115 -18
- package/range-tools-on-terrain/circle-line-chain/adapters.js +15 -8
- package/range-tools-on-terrain/circle-line-chain/chain-list-map.js +35 -13
- package/range-tools-on-terrain/circle-line-chain/plugin.js +76 -16
- package/range-tools-on-terrain/range-ring/adapters.js +74 -6
- package/range-tools-on-terrain/range-ring/plugin.js +222 -7
- package/range-tools-on-terrain/range-ring/types.js +9 -1
- package/semiplugins/interface.js +1 -0
- package/semiplugins/lightweight/line-plugin.js +65 -47
- package/semiplugins/lightweight/piece-of-pie-plugin.js +50 -25
- package/semiplugins/shape-on-terrain/arc-plugin.js +197 -100
- package/semiplugins/shape-on-terrain/circle-plugin.js +209 -90
- package/semiplugins/shape-on-terrain/padding-1-degree.js +538 -0
- package/util/account/single-attribute-buffer-management/buffer-manager.js +10 -0
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +145 -8
- package/util/account/single-attribute-buffer-management/buffer-orchestrator1.js +159 -0
- package/util/account/single-attribute-buffer-management/object-store.js +7 -0
- package/util/build-strategy/static-dynamic.js +11 -1
- package/util/check/typecheck.js +12 -0
- package/util/frame-counter-trigger.js +84 -0
- package/util/geometry/index.js +2 -1
- package/write-text/context-text4.js +140 -0
- package/Math/arc-generate-points copy.js +0 -366
- package/Math/globe-util/horizon-plane.js +0 -112
- package/altitude-locator/draw-subset-obj.js +0 -16
- package/programs/line-on-globe/paddings/paddings.js +0 -1
- package/programs/rings/partial-ring/piece-of-pie copy.js +0 -286
- package/semiplugins/shape-on-terrain/derived/padding-plugin.js +0 -101
- package/semiplugins/shape-on-terrain/one-degree-padding.js +0 -85
|
@@ -1,286 +0,0 @@
|
|
|
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,101 +0,0 @@
|
|
|
1
|
-
import { ArcOnTerrainPlugin } from "../arc-plugin";
|
|
2
|
-
const EDGE_COUNT = 5;
|
|
3
|
-
const paddingKeys = (padding) => {
|
|
4
|
-
const stepCount = padding.coverAngle / padding.stepAngle;
|
|
5
|
-
const keys = new Array(Math.ceil(stepCount));
|
|
6
|
-
for (let i = 0; i < stepCount; i++) {
|
|
7
|
-
keys[i] = padding.key + i;
|
|
8
|
-
}
|
|
9
|
-
if (keys.length > stepCount) {
|
|
10
|
-
keys[keys.length - 1] = padding.key + stepCount;
|
|
11
|
-
}
|
|
12
|
-
return keys;
|
|
13
|
-
};
|
|
14
|
-
const adapterPadding2Arc = (globe, padding) => {
|
|
15
|
-
const stepCount = padding.coverAngle / padding.stepAngle;
|
|
16
|
-
const result = new Array(Math.ceil(stepCount));
|
|
17
|
-
const fill = (i, angle) => {
|
|
18
|
-
const startPoint = globe.Math.FindPointByPolar(padding.center[0], padding.center[1], padding.outerRadius, angle);
|
|
19
|
-
const endPoint = globe.Math.FindPointByPolar(padding.center[0], padding.center[1], padding.innerRadius, angle);
|
|
20
|
-
result[i] = {
|
|
21
|
-
key: padding.key + i,
|
|
22
|
-
start: [startPoint.long, startPoint.lat],
|
|
23
|
-
end: [endPoint.long, endPoint.lat],
|
|
24
|
-
color: padding.color,
|
|
25
|
-
height: padding.height,
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
for (let i = 0; i < stepCount; i++) {
|
|
29
|
-
const angle = padding.startAngle + i * padding.stepAngle;
|
|
30
|
-
fill(i, angle);
|
|
31
|
-
}
|
|
32
|
-
if (result.length > stepCount) {
|
|
33
|
-
const i = result.length - 1;
|
|
34
|
-
const angle = padding.startAngle + padding.coverAngle;
|
|
35
|
-
fill(i, angle);
|
|
36
|
-
}
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
export const chargerAdaptor = (chargerInput, plugin, padding) => {
|
|
40
|
-
};
|
|
41
|
-
export class PaddingPlugin {
|
|
42
|
-
id;
|
|
43
|
-
arcPlugin;
|
|
44
|
-
globe = null;
|
|
45
|
-
_memory = new Map();
|
|
46
|
-
isFreed = false;
|
|
47
|
-
constructor(id, { variativeColorsOn = true, defaultColor = [1, 1, 1, 1], defaultHeightFromGroundIn3D = 30.0, vertexCount = EDGE_COUNT } = {}) {
|
|
48
|
-
this.id = id;
|
|
49
|
-
this.arcPlugin = new ArcOnTerrainPlugin(id, {
|
|
50
|
-
cameraAttractionIsOn: false,
|
|
51
|
-
vertexCount: vertexCount,
|
|
52
|
-
variativeColorsOn: variativeColorsOn,
|
|
53
|
-
defaultColor: defaultColor,
|
|
54
|
-
defaultHeightFromGroundIn3D: defaultHeightFromGroundIn3D,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
insertBulk(items) {
|
|
58
|
-
for (const padding of items) {
|
|
59
|
-
this.__delete(padding.key);
|
|
60
|
-
this._memory.set(padding.key, padding);
|
|
61
|
-
}
|
|
62
|
-
const arcInputs = items.flatMap(padding => adapterPadding2Arc(this.globe, padding));
|
|
63
|
-
this.arcPlugin.insertBulk(arcInputs);
|
|
64
|
-
}
|
|
65
|
-
deleteBulk(keys) {
|
|
66
|
-
const arcKeys = keys.flatMap(key => paddingKeys({ key, center: [0, 0], outerRadius: 0, innerRadius: 0, startAngle: 0, coverAngle: 0, stepAngle: 0, color: [0, 0, 0, 1] }));
|
|
67
|
-
this.arcPlugin.deleteBulk(arcKeys);
|
|
68
|
-
}
|
|
69
|
-
updateColor(key, color) {
|
|
70
|
-
// TODO: get all padding keys and update all of them
|
|
71
|
-
if (!this._memory.has(key)) {
|
|
72
|
-
console.warn(`Padding with key ${key} does not exist.`);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const keys = paddingKeys(this._memory.get(key));
|
|
76
|
-
for (let i = 0; i < keys.length; i++) {
|
|
77
|
-
this.arcPlugin.updateColor(keys[i], color);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
__delete(key) {
|
|
81
|
-
const padding = this._memory.get(key);
|
|
82
|
-
if (padding) {
|
|
83
|
-
const keys = paddingKeys(padding);
|
|
84
|
-
this.arcPlugin.deleteBulk(keys);
|
|
85
|
-
this._memory.delete(key);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
init(globe, gl) {
|
|
89
|
-
this.globe = globe;
|
|
90
|
-
this.arcPlugin.init(globe, gl);
|
|
91
|
-
}
|
|
92
|
-
draw3D() {
|
|
93
|
-
this.arcPlugin.draw3D();
|
|
94
|
-
}
|
|
95
|
-
free() {
|
|
96
|
-
if (this.isFreed)
|
|
97
|
-
return;
|
|
98
|
-
this.isFreed = true;
|
|
99
|
-
this.arcPlugin.free();
|
|
100
|
-
}
|
|
101
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// // One Degree Padding
|
|
3
|
-
// /**
|
|
4
|
-
// * 2d coordinates are loaded ones
|
|
5
|
-
// * 3d coordinates are calculated on the fly.
|
|
6
|
-
// *
|
|
7
|
-
// * 2d paddings are fixed size
|
|
8
|
-
// * 3d paddings gets shortened as lod increases
|
|
9
|
-
// *
|
|
10
|
-
// * color buffer is shared and does not change on unless insert or delete
|
|
11
|
-
// * changing color can be done by re inserting
|
|
12
|
-
// *
|
|
13
|
-
// *
|
|
14
|
-
// *
|
|
15
|
-
// */
|
|
16
|
-
// import { Globe, LongLat, Meter, Color } from '../../types';
|
|
17
|
-
// import { BufferManagersMap } from '../../util/account/single-attribute-buffer-management/types';
|
|
18
|
-
// import { BufferManager } from '../../util/account/single-attribute-buffer-management/buffer-manager';
|
|
19
|
-
// import { BufferOrchestrator } from '../../util/acconut/single-attribute-buffer-management/buffer-orchestrator';
|
|
20
|
-
// import { LineStripProgramCache, LineProgram } from '../../programs/line-on-globe/linestrip/linestrip';
|
|
21
|
-
// import { ProgramInterface } from '../../types';
|
|
22
|
-
// export type OneDegreePaddingInput = {
|
|
23
|
-
// key: string;
|
|
24
|
-
// center: LongLat;
|
|
25
|
-
// outerRadius: Meter;
|
|
26
|
-
// color: Color;
|
|
27
|
-
// };
|
|
28
|
-
// const _float32Array = new Float32Array(360 * 3 * 2).fill(NaN);
|
|
29
|
-
// export class Paddings1Degree implements ProgramInterface {
|
|
30
|
-
// id: string;
|
|
31
|
-
// private globe: Globe | null = null;
|
|
32
|
-
// private bufferOrchestrator: BufferOrchestrator;
|
|
33
|
-
// private bufferManagersMap: BufferManagersMap;
|
|
34
|
-
// private lineProgram: LineProgram | null = null;
|
|
35
|
-
// private _LODCoeffecientForPaddingScale: number = 1;
|
|
36
|
-
// private _PaddingSizeRatio = 0.1; // 0.1 means 10% of the padding size is used for 3d padding
|
|
37
|
-
// private _finalPaddingSizeRatio = 0.1; // this._LODCoefficientForPaddingScale * this._PaddingSizeRatio; // final padding size ratio is the product of LOD coefficient and padding size ratio
|
|
38
|
-
// constructor(id: string, { capacity = 1000 } = {}) {
|
|
39
|
-
// this.id = id;
|
|
40
|
-
// this.bufferOrchestrator = new BufferOrchestrator({ capacity });
|
|
41
|
-
// this.bufferManagersMap = new Map();
|
|
42
|
-
// this.lineProgram = null;
|
|
43
|
-
// }
|
|
44
|
-
// init(globe: Globe): void {
|
|
45
|
-
// this.globe = globe;
|
|
46
|
-
// this.lineProgram = LineStripProgramCache.get(globe);
|
|
47
|
-
// }
|
|
48
|
-
// __updateLODCoefficientForPaddingScale(): void {
|
|
49
|
-
// // TODO: call this ones when lod changes or each frame // maybe only on 3d geometry
|
|
50
|
-
// }
|
|
51
|
-
// __fillBufferManagersMap() {
|
|
52
|
-
// const globe = this.globe as Globe;
|
|
53
|
-
// const gl = globe.gl as WebGL2RenderingContext;
|
|
54
|
-
// this.bufferManagersMap.set("position2d", {
|
|
55
|
-
// bufferManager: new BufferManager(gl,
|
|
56
|
-
// 360 * (2 + 1), // plus 1 to cut
|
|
57
|
-
// { bufferType: "STATIC_DRAW", initialCapacity: 10 }),
|
|
58
|
-
// adaptor: (PaddingInput: OneDegreePaddingInput) => {
|
|
59
|
-
// for (let i = 0; i < 360; i++) {
|
|
60
|
-
// let { long, lat } = globe.Math.FindPointByPolar(
|
|
61
|
-
// PaddingInput.center[0], // center long
|
|
62
|
-
// PaddingInput.center[1], // center lat
|
|
63
|
-
// PaddingInput.outerRadius, // outer radius
|
|
64
|
-
// i, // angle
|
|
65
|
-
// )
|
|
66
|
-
// let corrds = globe.api_GetMercator2DPoint(long, lat);
|
|
67
|
-
// // fill the second coordinate with 0
|
|
68
|
-
// _float32Array[i * 3] = corrds[0];
|
|
69
|
-
// _float32Array[i * 3 + 1] = corrds[1];
|
|
70
|
-
// ({ long, lat } = globe.Math.FindPointByPolar(
|
|
71
|
-
// PaddingInput.center[0], // center long
|
|
72
|
-
// PaddingInput.center[1], // center lat
|
|
73
|
-
// PaddingInput.outerRadius * this._finalPaddingSizeRatio, // inner radius
|
|
74
|
-
// i, // angle
|
|
75
|
-
// ));
|
|
76
|
-
// let innerCorrds = globe.api_GetMercator2DPoint(long, lat);
|
|
77
|
-
// // fill the second coordinate with 0
|
|
78
|
-
// _float32Array[i * 3 + 2] = innerCorrds[0];
|
|
79
|
-
// _float32Array[i * 3 + 3] = innerCorrds[1];
|
|
80
|
-
// }
|
|
81
|
-
// return _float32Array;
|
|
82
|
-
// }
|
|
83
|
-
// });
|
|
84
|
-
// // Other methods like draw, insertBulk, deleteBulk, etc. would go here
|
|
85
|
-
// }
|