@pirireis/webglobeplugins 0.6.18 → 0.6.20
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/bearing-line/plugin-flat-old.js +500 -0
- package/bearing-line/plugin.js +99 -25
- package/circle-line-chain/plugin.js +58 -8
- package/circle-line-chain/plugin_newer_old.js +406 -0
- package/package.json +1 -1
- package/programs/line-on-globe/circle-accurate-3d.js +184 -0
- package/programs/line-on-globe/circle-accurate-flat.js +200 -0
- package/programs/line-on-globe/circle-accurate.js +2 -0
- package/programs/rings/partial-ring/piece-of-pie.js +3 -3
- package/rangerings/rangerings copy.js +219 -0
- package/rangerings-2/plugin.js +3 -0
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +5 -76
- package/util/jshelpers/data-filler.js +19 -0
- package/util/shaderfunctions/geometrytransformations.js +8 -3
- package/write-text/context-text3.js +4 -0
- package/circle-line-chain/chain-api.md +0 -336
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { createProgram } from "../../util/webglobjectbuilders";
|
|
2
|
+
import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totems/camerauniformblock";
|
|
3
|
+
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
4
|
+
import { vaoAttributeLoader } from "../../util/account/util";
|
|
5
|
+
import {
|
|
6
|
+
mercatorXYToGLPosition, POLE
|
|
7
|
+
} from "../../util/shaderfunctions/geometrytransformations";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Warning:
|
|
11
|
+
* Insert the points from the second index and skip 1 point as you placed 361 points
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const EDGE_COUNT = 62; // 1 for returning to the start point. 1 for cutting the circle into pieces.
|
|
15
|
+
|
|
16
|
+
const vertexShaderSource = `#version 300 es
|
|
17
|
+
precision highp float;
|
|
18
|
+
${CameraUniformBlockString}
|
|
19
|
+
${mercatorXYToGLPosition}
|
|
20
|
+
|
|
21
|
+
uniform float edge_count;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
in vec2 position2d;
|
|
25
|
+
in vec4 color;
|
|
26
|
+
in float dash_ratio;
|
|
27
|
+
in float dash_opacity;
|
|
28
|
+
|
|
29
|
+
out float interpolation;
|
|
30
|
+
out vec4 v_color;
|
|
31
|
+
out float v_dash_ratio;
|
|
32
|
+
out float v_dash_opacity;
|
|
33
|
+
out vec2 v_limp;
|
|
34
|
+
void main() {
|
|
35
|
+
interpolation = float( gl_VertexID % 62 ) / ${EDGE_COUNT}.0;
|
|
36
|
+
if ( gl_VertexID % 62 == 0 ) { return; } // cut on the first point.
|
|
37
|
+
if ( is3D ) {
|
|
38
|
+
return;
|
|
39
|
+
v_limp = vec2(0.0, 0.0);
|
|
40
|
+
} else {
|
|
41
|
+
v_limp = position2d;
|
|
42
|
+
gl_Position = mercatorXYToGLPosition( position2d);
|
|
43
|
+
}
|
|
44
|
+
v_dash_ratio = dash_ratio;
|
|
45
|
+
v_dash_opacity = dash_opacity;
|
|
46
|
+
v_color = color;
|
|
47
|
+
gl_PointSize = 15.0;
|
|
48
|
+
|
|
49
|
+
}`
|
|
50
|
+
|
|
51
|
+
const fragmentShaderSource = `#version 300 es
|
|
52
|
+
${POLE}
|
|
53
|
+
precision highp float;
|
|
54
|
+
uniform float opacity;
|
|
55
|
+
in vec4 v_color;
|
|
56
|
+
in float v_dash_ratio;
|
|
57
|
+
in float v_dash_opacity;
|
|
58
|
+
in float interpolation;
|
|
59
|
+
in vec2 v_limp;
|
|
60
|
+
out vec4 color;
|
|
61
|
+
void main() {
|
|
62
|
+
if ( v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE ){ color = vec4(0.0,0.0,0.0,0.0); return; }
|
|
63
|
+
color = v_color;
|
|
64
|
+
color.a *= opacity;
|
|
65
|
+
if ( v_dash_ratio == 1.0 || v_dash_ratio == 0.0 ) return;
|
|
66
|
+
if (fract(interpolation / (2.0 * v_dash_ratio)) < 0.5 ) {
|
|
67
|
+
color.a *= v_dash_opacity;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class Logic {
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
constructor(globe) {
|
|
78
|
+
this.globe = globe;
|
|
79
|
+
this.gl = globe.gl;
|
|
80
|
+
this._lastOpacity = 1.0;
|
|
81
|
+
this._lastMercatorMode = 0;
|
|
82
|
+
this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
|
|
83
|
+
|
|
84
|
+
const { gl, program } = this;
|
|
85
|
+
this.program.uniforms = {
|
|
86
|
+
opacity: gl.getUniformLocation(program, "opacity"),
|
|
87
|
+
mercator_calculation_mode: gl.getUniformLocation(program, "mercator_calculation_mode")
|
|
88
|
+
};
|
|
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.uniform1i(program.uniforms.mercator_calculation_mode, 0);
|
|
95
|
+
gl.useProgram(currentProgram);
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
{ // assign attribute locations
|
|
101
|
+
gl.bindAttribLocation(program, 0, "position2d");
|
|
102
|
+
gl.bindAttribLocation(program, 1, "color");
|
|
103
|
+
gl.bindAttribLocation(program, 2, "dash_ratio");
|
|
104
|
+
gl.bindAttribLocation(program, 3, "dash_opacity");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
this.cameraBindingPoint = 0;
|
|
108
|
+
this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
|
|
109
|
+
const cameraBlockLocation = gl.getUniformBlockIndex(program, "CameraUniformBlock");
|
|
110
|
+
gl.uniformBlockBinding(program, cameraBlockLocation, this.cameraBindingPoint);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
createVAO(centerObj, colorObj, dashRatioObj, dashOpacityObj) {
|
|
115
|
+
const { gl } = this;
|
|
116
|
+
const vao = gl.createVertexArray();
|
|
117
|
+
gl.bindVertexArray(vao);
|
|
118
|
+
{ // make this a function end import from account module.
|
|
119
|
+
const { buffer, stride = 0, offset = 0, divisor = 1 } = centerObj;
|
|
120
|
+
vaoAttributeLoader(gl, buffer, 0, 2, stride, offset, null);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
{
|
|
124
|
+
const { buffer, stride = 0, offset = 0, divisor = 1 } = colorObj;
|
|
125
|
+
vaoAttributeLoader(gl, buffer, 1, 4, stride, offset, null);
|
|
126
|
+
}
|
|
127
|
+
{
|
|
128
|
+
const { buffer, stride = 0, offset = 0, divisor = 1 } = dashRatioObj;
|
|
129
|
+
vaoAttributeLoader(gl, buffer, 2, 1, stride, offset, null);
|
|
130
|
+
}
|
|
131
|
+
{
|
|
132
|
+
const { buffer, stride = 0, offset = 0, divisor = 1 } = dashOpacityObj;
|
|
133
|
+
vaoAttributeLoader(gl, buffer, 3, 1, stride, offset, null);
|
|
134
|
+
}
|
|
135
|
+
gl.bindVertexArray(null);
|
|
136
|
+
gl.bindVertexArray(null);
|
|
137
|
+
return vao;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
draw(vao, length, opacity) {
|
|
142
|
+
const { gl, program, cameraBlockTotem, cameraBindingPoint } = this;
|
|
143
|
+
gl.useProgram(program);
|
|
144
|
+
if (this._lastOpacity !== opacity) {
|
|
145
|
+
gl.uniform1f(program.uniforms.opacity, opacity);
|
|
146
|
+
this._lastOpacity = opacity;
|
|
147
|
+
}
|
|
148
|
+
gl.bindVertexArray(vao);
|
|
149
|
+
cameraBlockTotem.bind(cameraBindingPoint);
|
|
150
|
+
gl.drawArrays(gl.LINE_STRIP, 0, length * EDGE_COUNT)
|
|
151
|
+
// gl.drawArrays(gl.POINTS, 0, length * EDGE_COUNT)
|
|
152
|
+
cameraBlockTotem.unbind(cameraBindingPoint);
|
|
153
|
+
gl.bindVertexArray(null);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
free() {
|
|
158
|
+
if (this.isFreed) return;
|
|
159
|
+
CameraUniformBlockTotemCache.release(this.globe);
|
|
160
|
+
this.gl.deleteProgram(this.program);
|
|
161
|
+
this.isFreed = true;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
const CircleCache = Object.freeze({
|
|
168
|
+
get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
|
|
169
|
+
release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
function centerCoords2dflatDataCreator(globe, centerLong, centerLat, targetLong, targetLat, { startAngleOfCircle = null } = {}) {
|
|
174
|
+
const centerCoords2dflat = new Float32Array(EDGE_COUNT * 2);
|
|
175
|
+
const radius2d = globe.Math.GetDist2D(centerLong, centerLat, targetLong, targetLat);
|
|
176
|
+
let angle;
|
|
177
|
+
if (startAngleOfCircle === null) {
|
|
178
|
+
angle = globe.Math.GetAzimuthAngle(centerLong, centerLat, targetLong, targetLat);
|
|
179
|
+
} else {
|
|
180
|
+
angle = startAngleOfCircle;
|
|
181
|
+
}
|
|
182
|
+
const pointsLongLat = globe.Math.GetEllipseGeo(
|
|
183
|
+
centerLong,
|
|
184
|
+
centerLat,
|
|
185
|
+
radius2d,
|
|
186
|
+
radius2d,
|
|
187
|
+
angle,
|
|
188
|
+
360 / (EDGE_COUNT - 2), // 1 for return to start point, 1 for cutting circles
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
for (let i = 1; i < EDGE_COUNT; i++) {
|
|
192
|
+
const { long: lg, lat: lt } = pointsLongLat[i - 1];
|
|
193
|
+
centerCoords2dflat.set(globe.api_GetMercator2DPoint(lg, lt), i * 2);
|
|
194
|
+
}
|
|
195
|
+
return centerCoords2dflat;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export {
|
|
199
|
+
CircleCache, EDGE_COUNT, centerCoords2dflatDataCreator
|
|
200
|
+
}
|
|
@@ -71,6 +71,7 @@ void main() {
|
|
|
71
71
|
v_dash_ratio = dash_ratio;
|
|
72
72
|
v_dash_opacity = dash_opacity;
|
|
73
73
|
v_color = color;
|
|
74
|
+
gl_PointSize = 3.0;
|
|
74
75
|
|
|
75
76
|
}`
|
|
76
77
|
|
|
@@ -178,6 +179,7 @@ class Logic {
|
|
|
178
179
|
gl.bindVertexArray(vao);
|
|
179
180
|
cameraBlockTotem.bind(cameraBindingPoint);
|
|
180
181
|
gl.drawArraysInstanced(gl.LINE_STRIP, 0, EDGE_COUNT_ON_SPHERE + 1, length);
|
|
182
|
+
gl.drawArraysInstanced(gl.POINTS, 0, EDGE_COUNT_ON_SPHERE + 1, length);
|
|
181
183
|
cameraBlockTotem.unbind(cameraBindingPoint);
|
|
182
184
|
gl.bindVertexArray(null);
|
|
183
185
|
}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
longLatRadToCartesian3D,
|
|
10
10
|
circleLimpFromLongLatRadCenterCartesian3D_accurate,
|
|
11
11
|
circleLimpFromLongLatRadCenterMercatorCompass_accurate,
|
|
12
|
-
circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate,
|
|
12
|
+
//circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate,
|
|
13
13
|
cartesian3DToGLPosition
|
|
14
14
|
|
|
15
15
|
|
|
@@ -28,6 +28,7 @@ const drawModeMap = Object.freeze({
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
|
|
31
|
+
//${ circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate }
|
|
31
32
|
|
|
32
33
|
const vertexShaderSource = `#version 300 es
|
|
33
34
|
|
|
@@ -38,7 +39,6 @@ ${mercatorXYToGLPosition}
|
|
|
38
39
|
${longLatRadToCartesian3D}
|
|
39
40
|
${circleLimpFromLongLatRadCenterCartesian3D_accurate}
|
|
40
41
|
${circleLimpFromLongLatRadCenterMercatorCompass_accurate}
|
|
41
|
-
${circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate}
|
|
42
42
|
${cartesian3DToGLPosition}
|
|
43
43
|
|
|
44
44
|
uniform float edge_count;
|
|
@@ -113,7 +113,7 @@ void main() {
|
|
|
113
113
|
gl_Position = cartesian3DToGLPosition(pos);
|
|
114
114
|
}
|
|
115
115
|
else {
|
|
116
|
-
vec2 pos2 =
|
|
116
|
+
vec2 pos2 = circleLimpFromLongLatRadCenterMercatorCompass_accurate(center2d, radius_, angle);
|
|
117
117
|
v_pos = pos2;
|
|
118
118
|
gl_Position = mercatorXYToGLPosition(pos2);
|
|
119
119
|
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { rings } from "../programs";
|
|
2
|
+
import { COMPASS_MODES } from "./enum";
|
|
3
|
+
import { PaddingFreeAngleCache } from "../programs/rings/distancering";
|
|
4
|
+
|
|
5
|
+
import RangeRingAngleText from "./rangeringangletext";
|
|
6
|
+
const { circleProgramCache, PaddingProgramCache, CirclePaddySharedBuffer } = rings;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @typedef RangeRingData
|
|
10
|
+
* @property {number} centerX
|
|
11
|
+
* @property {number} centerY
|
|
12
|
+
* @property {Array<Ring>} rings
|
|
13
|
+
*
|
|
14
|
+
* @typedef Ring
|
|
15
|
+
* @property {number} radius
|
|
16
|
+
* @property {number} padding
|
|
17
|
+
* @property {[number, number, number]} color
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
export default class {
|
|
24
|
+
|
|
25
|
+
constructor(id, { oneDegreePadding = true, compass = COMPASS_MODES.REAL, showNumbers = true, numbersStyle = null, opacity = 1 } = {}) {
|
|
26
|
+
this.id = id;
|
|
27
|
+
this.compass = compass;
|
|
28
|
+
this._showNumbers = showNumbers;
|
|
29
|
+
this._numbersStyle = numbersStyle;
|
|
30
|
+
this._opacity = opacity;
|
|
31
|
+
this.circleEdgeCount = 360;
|
|
32
|
+
this._onedegreepaddingOn = oneDegreePadding;
|
|
33
|
+
this.bufferManager = null;
|
|
34
|
+
|
|
35
|
+
this._deleteCounter = 0;
|
|
36
|
+
this._deleteThreshold = 10;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
setOneDegreePaddingOn(oneDegreePadding) {
|
|
41
|
+
this._onedegreepaddingOn = oneDegreePadding;
|
|
42
|
+
this.globe.DrawRender();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
init(globe, gl) {
|
|
46
|
+
this.gl = gl;
|
|
47
|
+
this.globe = globe;
|
|
48
|
+
this.circleFlatProgram = circleProgramCache.getProgram(globe);
|
|
49
|
+
this.paddyFlatProgram = PaddingProgramCache.getProgram(globe);
|
|
50
|
+
this.paddingFreeAngleProgram = PaddingFreeAngleCache.getProgram(globe);
|
|
51
|
+
if (this._showNumbers) {
|
|
52
|
+
this.textPlugin = new RangeRingAngleText(globe, this.id + "text", { flatCompassMode: this.compass, style: this._numbersStyle, opacity: this._opacity });
|
|
53
|
+
delete this._numbersStyle;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// TODO: Add text free
|
|
58
|
+
free() {
|
|
59
|
+
|
|
60
|
+
this.circleProgramCache?.releaseProgram(this.globe);
|
|
61
|
+
this.PaddingProgramCache?.releaseProgram(this.globe);
|
|
62
|
+
this.PaddingFreeAngleCache?.releaseProgram(this.globe);
|
|
63
|
+
this.gl.deleteVertexArray(this.bufferManager?.vao);
|
|
64
|
+
this.gl.deleteVertexArray(this.paddingBufferManager?.vao);
|
|
65
|
+
this.paddingBufferManager?.free();
|
|
66
|
+
this.bufferManager?.free();
|
|
67
|
+
this.textPlugin?.free();
|
|
68
|
+
this.circleFlatProgram = null;
|
|
69
|
+
this.paddyFlatProgram = null;
|
|
70
|
+
this.bufferManager = null;
|
|
71
|
+
this.paddingBufferManager = null;
|
|
72
|
+
this.textPlugin = null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
setOpacity(opacity) {
|
|
77
|
+
this._opacity = opacity;
|
|
78
|
+
this.textPlugin?.setOpacity(opacity); // TODO impolement this
|
|
79
|
+
this.globe.DrawRender();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
setGeometry() {
|
|
83
|
+
this.textPlugin?.setGeometry();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
draw3D() {
|
|
88
|
+
const { circleFlatProgram, paddyFlatProgram, paddingFreeAngleProgram, bufferManager, compass, gl, circleEdgeCount, paddingBufferManager, _opacity } = this;
|
|
89
|
+
if (this.bufferManager !== null && bufferManager.length > 0) {
|
|
90
|
+
gl.disable(gl.DEPTH_TEST);
|
|
91
|
+
circleFlatProgram.draw(bufferManager, compass, circleEdgeCount, _opacity);
|
|
92
|
+
if (this._onedegreepaddingOn) paddyFlatProgram.draw(bufferManager, 360, compass, _opacity);
|
|
93
|
+
paddingFreeAngleProgram.draw(paddingBufferManager, compass, _opacity);
|
|
94
|
+
gl.enable(gl.DEPTH_TEST);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @param {RangeRingData} rangeRingData
|
|
102
|
+
* 0 compass limps
|
|
103
|
+
* other real distance limp
|
|
104
|
+
*/
|
|
105
|
+
setCampass(compass) {
|
|
106
|
+
this.compass = compass;
|
|
107
|
+
this.textPlugin?.setCompass(compass);
|
|
108
|
+
this.globe.DrawRender();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
initilizeBufferManager(initialRingCapacity, bufferDrawType) {
|
|
112
|
+
const { gl, globe } = this
|
|
113
|
+
this.bufferDrawType = bufferDrawType;
|
|
114
|
+
this.bufferManager = new CirclePaddySharedBuffer(gl, globe, { bufferType: bufferDrawType, initialRingCapacity: initialRingCapacity });
|
|
115
|
+
this.paddingBufferManager = this.paddingFreeAngleProgram.createBuffer({ bufferType: bufferDrawType, initialRingCapacity });
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @typedef {Array<{ringID, radius, paddingRange}>} rings
|
|
121
|
+
* @param {Array<centerID:string, x:number, y:number, stepAngle:number, rgba:[4 numbers], rings:rings} items
|
|
122
|
+
*/
|
|
123
|
+
insertBulk(items) {
|
|
124
|
+
const insertData = ringItemsToCircleBufferInsertDataAdaptor(items);
|
|
125
|
+
|
|
126
|
+
this.bufferManager.insertBulk(insertData);
|
|
127
|
+
for (const item of items) {
|
|
128
|
+
item.paddingAngles = angleToPaddingAngles(item.stepAngle, 0);
|
|
129
|
+
}
|
|
130
|
+
this.paddingBufferManager.insertBulk(items);
|
|
131
|
+
this.textPlugin?.insertBulk(items);
|
|
132
|
+
this.globe.DrawRender();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
*
|
|
138
|
+
* @param {Array<{centerID, x, y}>} items
|
|
139
|
+
*/
|
|
140
|
+
updateCentersXY(items) {
|
|
141
|
+
this.bufferManager.updateCentersXY(items);
|
|
142
|
+
this.paddingBufferManager.updateCentersXY(items);
|
|
143
|
+
this.textPlugin?.updateCentersXY(items);
|
|
144
|
+
this.globe.DrawRender();
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @param {Array<{centerID, rgba:[4 numbers]}>} centerColors
|
|
150
|
+
*/
|
|
151
|
+
updateCentersColor(centerColors) {
|
|
152
|
+
this.bufferManager.updateCentersColor(centerColors);
|
|
153
|
+
this.paddingBufferManager.updateCentersColor(centerColors);
|
|
154
|
+
this.globe.DrawRender();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @param {Array<{centerID}>} centerIds
|
|
160
|
+
*/
|
|
161
|
+
removeCenters(centerIds) {
|
|
162
|
+
this.bufferManager.removeCenters(centerIds);
|
|
163
|
+
this.paddingBufferManager.removeCenters(centerIds);
|
|
164
|
+
this.textPlugin?.removeCenters(centerIds);
|
|
165
|
+
this._deleteCounter += centerIds.length;
|
|
166
|
+
if (this._deleteCounter > this._deleteThreshold) {
|
|
167
|
+
// this is naive since we are not checking the actual deletion
|
|
168
|
+
// but it works
|
|
169
|
+
this._deleteCounter = 0;
|
|
170
|
+
this.bufferManager.defrag();
|
|
171
|
+
this.paddingBufferManager.defrag();
|
|
172
|
+
}
|
|
173
|
+
this.globe.DrawRender();
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
*
|
|
179
|
+
* @param {Array<{centerID, hide, textHide}>} centerHides
|
|
180
|
+
*/
|
|
181
|
+
updateCentersHide(centerHides) {
|
|
182
|
+
this.bufferManager.updateCentersHide(centerHides);
|
|
183
|
+
this.paddingBufferManager.updateCentersHide(centerHides);
|
|
184
|
+
this.textPlugin?.updateCentersHide(centerHides);
|
|
185
|
+
this.globe.DrawRender();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
const ringItemsToCircleBufferInsertDataAdaptor = (ringItems) => {
|
|
193
|
+
|
|
194
|
+
const result = [];
|
|
195
|
+
for (const { centerID, x, y, rgba, rings, hide = 0, textHide = 0 } of ringItems) {
|
|
196
|
+
const resultRings = [];
|
|
197
|
+
for (const { ringID, radius, padding } of rings) {
|
|
198
|
+
resultRings.push({
|
|
199
|
+
ringID,
|
|
200
|
+
radius,
|
|
201
|
+
padding: padding / 5,
|
|
202
|
+
rgba,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
result.push({
|
|
207
|
+
centerID,
|
|
208
|
+
x,
|
|
209
|
+
y,
|
|
210
|
+
rings: resultRings,
|
|
211
|
+
hide,
|
|
212
|
+
textHide
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
return result;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
const angleToPaddingAngles = (gapDegree, offsetDegree = 0) => Array.from({ length: Math.ceil(360 / gapDegree) }, (_, i) => (i * gapDegree + offsetDegree) * Math.PI / 180);
|
|
219
|
+
|
|
@@ -29,79 +29,6 @@
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
/**
|
|
33
|
-
* Scratchpad
|
|
34
|
-
*
|
|
35
|
-
* plugin insertBulk(items){
|
|
36
|
-
* this.offsetManager.autoExtendBuffers(items.length);
|
|
37
|
-
* this.offsetManager.assignOffsets(items); // read item.keys and assign offsets to them.
|
|
38
|
-
* this.attrib1BufferManager.insertBulk(items.map(item => this.attrib1Block(item)), );
|
|
39
|
-
* this.attrib2BufferManager.insertBulk();
|
|
40
|
-
* if (this.attrib3isInNeed) this.attrib3BufferManager.insertBulk(items);
|
|
41
|
-
* this.globe.DrawRender();
|
|
42
|
-
* }
|
|
43
|
-
*
|
|
44
|
-
* useTheCaseThatRequiresAttrib3(){
|
|
45
|
-
* // generate items from other buffers if possible.
|
|
46
|
-
* }
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* assignOffsets(items){
|
|
50
|
-
* for (const item of items){
|
|
51
|
-
* const offset = this.offsetManager.getOffset(item.key) || this.offsetManager.nextOffset();
|
|
52
|
-
* item.__offset__ = offset;
|
|
53
|
-
*
|
|
54
|
-
* allBuffers = [attrib1BufferManager, attrib2BufferManager, attrib3BufferManager]
|
|
55
|
-
* // // not single responsibility ..
|
|
56
|
-
* defrag(allBuffers){
|
|
57
|
-
* for (const bufferManager of allBuffers){
|
|
58
|
-
* bufferManager.defrag(this.offsetManager.offsetMap);
|
|
59
|
-
* }
|
|
60
|
-
* this.offsetManager._defrag();
|
|
61
|
-
* }
|
|
62
|
-
*
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
*
|
|
68
|
-
* attrib1BufferManager.insertBulk( items) {
|
|
69
|
-
* gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
70
|
-
* for (const item of items) {
|
|
71
|
-
* const block = this.itemToBlock(item); // this changes based on inserted data structure and expected block structure.
|
|
72
|
-
* gl.bufferSubData(gl.ARRAY_BUFFER, item.__offset__, block);
|
|
73
|
-
* }
|
|
74
|
-
* gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
75
|
-
* }
|
|
76
|
-
*
|
|
77
|
-
* deleteBulk(offsets){
|
|
78
|
-
* gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
79
|
-
* for (const offset of offsets) {
|
|
80
|
-
* gl.bufferSubData(gl.ARRAY_BUFFER, offset, emptyBlock);
|
|
81
|
-
* }
|
|
82
|
-
* gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
83
|
-
* }
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* //
|
|
87
|
-
* defrag(offsetMap){
|
|
88
|
-
* const newArray = new Float32Array(itemCount * itemSize);
|
|
89
|
-
* const bufferData = this._getBufferData();
|
|
90
|
-
* let newOffSet = 0;
|
|
91
|
-
* for (const [key, offSet] of offsetMap) {
|
|
92
|
-
* const bufferOffset = offset;
|
|
93
|
-
* newArray.set(bufferData.slice(bufferOffset, bufferOffset + itemSize), newOffSet);
|
|
94
|
-
newOffset += itemSize * 4;
|
|
95
|
-
}
|
|
96
|
-
*
|
|
97
|
-
* gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
98
|
-
*
|
|
99
|
-
* }
|
|
100
|
-
*
|
|
101
|
-
* ----------------
|
|
102
|
-
|
|
103
|
-
*/
|
|
104
|
-
|
|
105
32
|
const EXTRA_SIZE = 10;
|
|
106
33
|
|
|
107
34
|
export class BufferOrchestrator {
|
|
@@ -137,7 +64,6 @@ export class BufferOrchestrator {
|
|
|
137
64
|
for (const [key, { bufferManager, adaptor }] of bufferManagersMap) {
|
|
138
65
|
bufferManager.insertBulk(items.map(adaptor), offsets);
|
|
139
66
|
}
|
|
140
|
-
|
|
141
67
|
}
|
|
142
68
|
|
|
143
69
|
|
|
@@ -155,7 +81,9 @@ export class BufferOrchestrator {
|
|
|
155
81
|
}
|
|
156
82
|
if (bufferKeys) {
|
|
157
83
|
for (const key of bufferKeys) {
|
|
158
|
-
const
|
|
84
|
+
const bufferManagerComp = bufferManagersMap.get(key);
|
|
85
|
+
if (bufferManagerComp === undefined) throw new Error("updateBulk bufferKey does not exist");
|
|
86
|
+
const { bufferManager, adaptor } = bufferManagerComp;
|
|
159
87
|
bufferManager.insertBulk(items.map(adaptor), offsets);
|
|
160
88
|
}
|
|
161
89
|
} else {
|
|
@@ -228,7 +156,8 @@ export class BufferOrchestrator {
|
|
|
228
156
|
}
|
|
229
157
|
}
|
|
230
158
|
this._defrag();
|
|
231
|
-
this._length =
|
|
159
|
+
this._length = offsetMap.size;
|
|
160
|
+
this._capacity = newCapacity;
|
|
232
161
|
this.tombstoneOffsets = [];
|
|
233
162
|
}
|
|
234
163
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const populateFloat32Array = Object.freeze({
|
|
2
|
+
fillFloat32Array: (length, data) => {
|
|
3
|
+
const result = new Float32Array(length);
|
|
4
|
+
result.fill(data);
|
|
5
|
+
return result;
|
|
6
|
+
},
|
|
7
|
+
|
|
8
|
+
fillWithListData: (length, listdata) => {
|
|
9
|
+
const result = new Float32Array(length * listdata.length);
|
|
10
|
+
let offset = 0;
|
|
11
|
+
for (let i = 0; i < length; i++) {
|
|
12
|
+
result.set(listdata, offset);
|
|
13
|
+
offset += listdata.length;
|
|
14
|
+
}
|
|
15
|
+
return result
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export { populateFloat32Array };
|
|
@@ -344,11 +344,16 @@ vec2 circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate(vec2 mercato
|
|
|
344
344
|
|
|
345
345
|
float delta_long = atan(sin(ang) * sin_r * cos(center.y), cos_r - sin(center.y) * sin_lat);
|
|
346
346
|
float longi = center.x + delta_long;
|
|
347
|
-
float y = mix(-80.5, 80.5, abs(
|
|
348
|
-
|
|
347
|
+
// float y = mix(-80.5, 80.5, abs(center.y + PI / 2.0));
|
|
348
|
+
vec2 limp = vec2(
|
|
349
349
|
R * longi,
|
|
350
|
-
R * log(tan(PI / 4.0 + lat / 2.0))
|
|
350
|
+
R * log(tan(PI / 4.0 + lat / 2.0))
|
|
351
|
+
);
|
|
352
|
+
vec2 center_mercator = vec2(
|
|
353
|
+
R * center.x,
|
|
354
|
+
R * log(tan(PI/4.0+ center.y / 2.0))
|
|
351
355
|
);
|
|
356
|
+
return mercator_center - center_mercator + limp;
|
|
352
357
|
}`;
|
|
353
358
|
|
|
354
359
|
export {
|