@pirireis/webglobeplugins 0.15.20-alpha → 0.15.22-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/vec3.js +1 -1
- package/altitude-locator/plugin.js +1 -1
- package/package.json +1 -1
- package/point-tracks/plugin.js +1 -2
- package/programs/line-on-globe/lines-color-instanced-flat.js +0 -1
- package/programs/point-on-globe/element-globe-surface-glow.js +0 -1
- package/programs/totems/camerauniformblock.js +7 -0
- package/range-tools-on-terrain/bearing-line/plugin.js +0 -1
- package/range-tools-on-terrain/circle-line-chain/chain-list-map.js +4 -9
- package/range-tools-on-terrain/circle-line-chain/plugin.js +5 -3
- package/semiplugins/lightweight/line-plugin.js +35 -40
- package/semiplugins/shape-on-terrain/padding-1-degree.js +94 -44
- package/util/account/single-attribute-buffer-management/buffer-manager.js +1 -1
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +121 -70
- package/util/account/single-attribute-buffer-management/buffer-orchestrator1.js +159 -0
- package/util/account/single-attribute-buffer-management/object-store.js +1 -1
- 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/semiplugins/shape-on-terrain/derived/padding-plugin.js +0 -101
- package/util/account/single-attribute-buffer-management/buffer-orchestrator copy.js +0 -161
- package/util/account/single-attribute-buffer-management/chunked-buffer-manager.js +0 -75
- package/util/account/single-attribute-buffer-management/chunked-buffer-orchestrator.js +0 -195
package/Math/arc.js
CHANGED
|
@@ -143,8 +143,7 @@ function _populatePointsWithClosestPointInsideArc(out, arc, count, closestPoint)
|
|
|
143
143
|
* @param {Vec3} cameraPosition - The position of the camera.
|
|
144
144
|
* @param {number} quaternionReuseCount - The number of times to apply the same rotation before recalculating. Higher is faster but less accurate.
|
|
145
145
|
*/
|
|
146
|
-
function _distanceSampling(out, count, inArc, cameraPosition = vec3create(0, 0, 0),
|
|
147
|
-
quaternionReuseCount = 1) {
|
|
146
|
+
function _distanceSampling(out, count, inArc, cameraPosition = vec3create(0, 0, 0), quaternionReuseCount = 1) {
|
|
148
147
|
if (count === 0) {
|
|
149
148
|
return;
|
|
150
149
|
}
|
|
@@ -1,168 +1,4 @@
|
|
|
1
1
|
import { RADIANS } from "./methods";
|
|
2
|
-
function createTemplate(intervalCount, strength = 1.0) {
|
|
3
|
-
const out = new Array(intervalCount);
|
|
4
|
-
const TOTAL = 1;
|
|
5
|
-
let cummulative = 0;
|
|
6
|
-
if (strength <= 0) {
|
|
7
|
-
// If strength is 0, distribute evenly.
|
|
8
|
-
const step = TOTAL / (intervalCount - 1);
|
|
9
|
-
for (let i = 0; i < intervalCount; i++) {
|
|
10
|
-
out[i] = cummulative;
|
|
11
|
-
cummulative += step;
|
|
12
|
-
}
|
|
13
|
-
out[intervalCount - 1] = TOTAL; // Ensure the last value is exactly TOTAL
|
|
14
|
-
return out;
|
|
15
|
-
}
|
|
16
|
-
// If strength is greater than 0, bias towards the start.
|
|
17
|
-
const weights = new Array(intervalCount);
|
|
18
|
-
let currentStep = 1;
|
|
19
|
-
let totalWeight = 0;
|
|
20
|
-
// Calculate weights for each interval, decreasing for later intervals.
|
|
21
|
-
for (let i = 0; i < intervalCount; i++) {
|
|
22
|
-
// Using (i + 1) in the denominator gives earlier intervals the highest weight.
|
|
23
|
-
totalWeight += currentStep;
|
|
24
|
-
weights[i] = totalWeight;
|
|
25
|
-
currentStep += strength;
|
|
26
|
-
}
|
|
27
|
-
// Distribute the total angle based on the weights.
|
|
28
|
-
for (let i = 0; i < intervalCount; i++) {
|
|
29
|
-
// Round to the nearest whole number for this interval.
|
|
30
|
-
out[i] = (weights[i] / totalWeight) * TOTAL;
|
|
31
|
-
}
|
|
32
|
-
if (out[intervalCount - 1] !== TOTAL) {
|
|
33
|
-
out[intervalCount - 1] = TOTAL;
|
|
34
|
-
}
|
|
35
|
-
// console.log("createTemplate", "strength", strength, "intervalCount", intervalCount, "out", out);
|
|
36
|
-
return out;
|
|
37
|
-
}
|
|
38
|
-
function interpolation(a, b, t) {
|
|
39
|
-
return a + (b - a) * t;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Populates the `out` array with values from the `template` array,
|
|
43
|
-
* distributing the surplus length as interpolated values between the template samples.
|
|
44
|
-
*
|
|
45
|
-
* @param out The destination array to be filled. Its length must be >= template.length.
|
|
46
|
-
* @param template An ordered array of numbers to be placed in the `out` array.
|
|
47
|
-
* @param strength A parameter controlling the distribution bias of surplus samples.
|
|
48
|
-
* - strength = 0: Surplus samples are distributed evenly.
|
|
49
|
-
* - strength > 0: Surplus samples are biased towards the start of the template.
|
|
50
|
-
* - Higher values create a stronger bias.
|
|
51
|
-
*/
|
|
52
|
-
function increasePopulation(// TODO: THERE IS A BUG
|
|
53
|
-
out, template, strength = 1.0) {
|
|
54
|
-
const sourceLength = template.length;
|
|
55
|
-
const destinationLength = out.length;
|
|
56
|
-
const outLengthAtStart = out.length;
|
|
57
|
-
// --- Handle Edge Cases ---
|
|
58
|
-
// If the template is empty, there is nothing to interpolate from.
|
|
59
|
-
if (sourceLength === 0) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
// If the template has only one value, fill the output array with that value.
|
|
63
|
-
if (sourceLength === 1) {
|
|
64
|
-
out.fill(template[0]);
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
// If the destination is not larger than the source, just copy the template values.
|
|
68
|
-
if (destinationLength <= sourceLength) {
|
|
69
|
-
for (let i = 0; i < destinationLength; i++) {
|
|
70
|
-
out[i] = template[i];
|
|
71
|
-
}
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
// --- Main Logic ---
|
|
75
|
-
const surplus = destinationLength - sourceLength;
|
|
76
|
-
const numGaps = sourceLength - 1;
|
|
77
|
-
// This array will hold the number of extra samples to add in each gap.
|
|
78
|
-
const surplusPerGap = new Array(numGaps).fill(0);
|
|
79
|
-
if (surplus > 0) {
|
|
80
|
-
// --- Step 1: Determine the distribution of surplus items ---
|
|
81
|
-
// If strength is 0, distribute surplus items as evenly as possible.
|
|
82
|
-
if (strength <= 0) {
|
|
83
|
-
const baseToAdd = Math.floor(surplus / numGaps);
|
|
84
|
-
const remainder = surplus % numGaps;
|
|
85
|
-
for (let i = 0; i < numGaps; i++) {
|
|
86
|
-
// Distribute the remainder one by one to the first gaps.
|
|
87
|
-
surplusPerGap[i] = baseToAdd + (i < remainder ? 1 : 0);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
// Biased Distribution: more items in earlier gaps.
|
|
92
|
-
const weights = new Array(numGaps);
|
|
93
|
-
let totalWeight = 0;
|
|
94
|
-
// A. Calculate a weight for each gap. The weight decreases for later gaps.
|
|
95
|
-
// The `strength` parameter makes this decay steeper.
|
|
96
|
-
for (let i = 0; i < numGaps; i++) {
|
|
97
|
-
// Using (i + 1) in the denominator gives earlier gaps (i=0) the highest weight.
|
|
98
|
-
const weight = Math.pow(1 / (i + 1), strength);
|
|
99
|
-
weights[i] = weight;
|
|
100
|
-
totalWeight += weight;
|
|
101
|
-
}
|
|
102
|
-
// B. Distribute the surplus based on the calculated weights.
|
|
103
|
-
// This method ensures the total distributed count equals the surplus.
|
|
104
|
-
let distributedCount = 0;
|
|
105
|
-
for (let i = 0; i < numGaps - 1; i++) {
|
|
106
|
-
const idealCount = (weights[i] / totalWeight) * surplus;
|
|
107
|
-
// Round to the nearest whole number for this gap.
|
|
108
|
-
const countForThisGap = Math.ceil(idealCount);
|
|
109
|
-
surplusPerGap[i] = countForThisGap;
|
|
110
|
-
distributedCount += countForThisGap;
|
|
111
|
-
}
|
|
112
|
-
// Assign the remainder to the last gap to guarantee the sum is correct.
|
|
113
|
-
//surplusPerGap[numGaps - 1] = surplus - distributedCount;
|
|
114
|
-
// add to first
|
|
115
|
-
const leftover = surplus - distributedCount;
|
|
116
|
-
if (leftover > 0) {
|
|
117
|
-
surplusPerGap[0] += leftover; // Add any leftover to the first gap.
|
|
118
|
-
}
|
|
119
|
-
console.log("leftover", leftover, "distributedCount", distributedCount, "surplus", surplus);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
// --- Step 2: Populate the `out` array ---
|
|
123
|
-
let outIndex = 0;
|
|
124
|
-
for (let i = 0; i < surplusPerGap.length; i++) {
|
|
125
|
-
if (typeof surplusPerGap[i] !== "number" || isNaN(surplusPerGap[i]) || !isFinite(surplusPerGap[i])) {
|
|
126
|
-
console.warn("increasePopulation: Invalid surplusPerGap value at index", i, ":", surplusPerGap[i]);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
for (let i = 0; i < sourceLength; i++) {
|
|
130
|
-
// A. Add the original template item.
|
|
131
|
-
out[outIndex++] = template[i];
|
|
132
|
-
// B. If this is not the last template item, fill the gap after it.
|
|
133
|
-
if (i < numGaps) {
|
|
134
|
-
const numToAdd = surplusPerGap[i];
|
|
135
|
-
if (numToAdd <= 0)
|
|
136
|
-
continue;
|
|
137
|
-
const startVal = template[i];
|
|
138
|
-
const endVal = template[i + 1];
|
|
139
|
-
// C. Add the interpolated ("surplus") items for this gap.
|
|
140
|
-
// The total number of intervals in this gap is numToAdd + 1.
|
|
141
|
-
const totalIntervals = numToAdd + 1;
|
|
142
|
-
for (let j = 1; j <= numToAdd; j++) {
|
|
143
|
-
const t = j / totalIntervals; // The interpolation factor (0 < t < 1)
|
|
144
|
-
// Linear interpolation: out = start * (1 - t) + end * t
|
|
145
|
-
const interpolatedValue = startVal * (1 - t) + endVal * t;
|
|
146
|
-
out[outIndex++] = interpolatedValue;
|
|
147
|
-
if (outIndex >= out.length) {
|
|
148
|
-
console.warn("increasePopulation: Output array overflow. Stopping early.");
|
|
149
|
-
console.warn("processeed item ratio:", i, "/", sourceLength);
|
|
150
|
-
let count = numToAdd - j;
|
|
151
|
-
console.log("count", count);
|
|
152
|
-
for (let _i = i; _i < sourceLength; _i++) {
|
|
153
|
-
count += surplusPerGap[_i];
|
|
154
|
-
}
|
|
155
|
-
console.warn("increasePopulation: Not enough space to add", count, "more items.");
|
|
156
|
-
return; // Prevent overflow if the output array is not large enough.
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
// --- Step 3: Ensure the output length is correct ---
|
|
162
|
-
if (outLengthAtStart !== out.length) {
|
|
163
|
-
console.warn("increasePopulation: Output length mismatch. Expected", outLengthAtStart, "but got", out.length);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
2
|
function createCummulativeTemplate(numberOfPoints, strength, denseRatio = 0.5 // Ratio of points to be densely packed at the start.
|
|
167
3
|
) {
|
|
168
4
|
// Handle edge cases for the number of points.
|
|
@@ -239,9 +75,4 @@ function globeFindPointByPolarHalfCircle(out, globe, centerLong, centerLat, radi
|
|
|
239
75
|
offset -= 2;
|
|
240
76
|
}
|
|
241
77
|
}
|
|
242
|
-
export {
|
|
243
|
-
// createTemplate,
|
|
244
|
-
// increasePopulation,
|
|
245
|
-
// interpolation,
|
|
246
|
-
// createCummulativeTemplate,
|
|
247
|
-
createCummulativeTemplateStash, globeFindPointByPolar, globeFindPointByPolarHalfCircle };
|
|
78
|
+
export { createCummulativeTemplateStash, globeFindPointByPolar, globeFindPointByPolarHalfCircle };
|
package/Math/circle.js
CHANGED
|
@@ -29,30 +29,5 @@ function createCircleClosestAzimuthAngleProperties(circle) {
|
|
|
29
29
|
normal: normal,
|
|
30
30
|
northPointProjectedToOriginPlaneNormalized: N,
|
|
31
31
|
};
|
|
32
|
-
// const distance = normal[2]; //dot(normal, [0, 0, 1] as Vec3)
|
|
33
|
-
// const N: Vec3 = [0, 0, 0];
|
|
34
|
-
// if (Math.abs(distance) < 1e-6) {
|
|
35
|
-
// N[0] = -1;
|
|
36
|
-
// N[1] = 0;
|
|
37
|
-
// N[2] = 0;
|
|
38
|
-
// } else {
|
|
39
|
-
// // TODO: add cases for 8 parts of the sphere
|
|
40
|
-
// copy(N, normal);
|
|
41
|
-
// multiplyScalar(N, N, distance);
|
|
42
|
-
// if (N[2] >= 0) {
|
|
43
|
-
// N[0] = -N[0];
|
|
44
|
-
// N[1] = -N[1];
|
|
45
|
-
// N[2] = 1 - N[2];
|
|
46
|
-
// } else {
|
|
47
|
-
// N[2] = -N[2];
|
|
48
|
-
// N[0] = -N[0];
|
|
49
|
-
// N[1] = -N[1];
|
|
50
|
-
// }
|
|
51
|
-
// }
|
|
52
|
-
// normalize(N, N);
|
|
53
|
-
// return {
|
|
54
|
-
// normal: normal,
|
|
55
|
-
// northPointProjectedToOriginPlaneNormalized: N,
|
|
56
|
-
// }
|
|
57
32
|
}
|
|
58
33
|
export { closestAzimuthAngle, createCircleClosestAzimuthAngleProperties };
|
package/Math/vec3.js
CHANGED
|
@@ -85,7 +85,7 @@ function equals(a, b) {
|
|
|
85
85
|
Math.abs(a[2] - b[2]) < EPSILON);
|
|
86
86
|
}
|
|
87
87
|
function fromUnitVectorToLongLat(out, a) {
|
|
88
|
-
const len = length(a);
|
|
88
|
+
const len = length(a);
|
|
89
89
|
if (len === 0) {
|
|
90
90
|
throw new Error('Cannot convert a zero vector to unit vector');
|
|
91
91
|
}
|
|
@@ -335,7 +335,7 @@ class PointGlowLineToEarthPlugin {
|
|
|
335
335
|
});
|
|
336
336
|
}
|
|
337
337
|
_doesChanged() {
|
|
338
|
-
return this.
|
|
338
|
+
return this.globe.api_IsScreenMoving();
|
|
339
339
|
}
|
|
340
340
|
_changed() {
|
|
341
341
|
this._parametersChanged = true;
|
package/package.json
CHANGED
package/point-tracks/plugin.js
CHANGED
|
@@ -144,7 +144,7 @@ class PointTracksPlugin {
|
|
|
144
144
|
* @returns
|
|
145
145
|
*/
|
|
146
146
|
insertBulk(tracks) {
|
|
147
|
-
this._fillTracksToPointsMap(tracks);
|
|
147
|
+
this._fillTracksToPointsMap(tracks);
|
|
148
148
|
const flattenedPoints = tracks.map(trackToFlatPoints, this._objectStoreExtraParametersFiltered).flat();
|
|
149
149
|
const currentLoad = this._bufferOrchestrator.length;
|
|
150
150
|
if (currentLoad + flattenedPoints.length >= 2147483647) {
|
|
@@ -224,7 +224,6 @@ class PointTracksPlugin {
|
|
|
224
224
|
return;
|
|
225
225
|
this._isFreed = true;
|
|
226
226
|
this._pickerDisplayer.free();
|
|
227
|
-
this._tracksToPointMap.clear();
|
|
228
227
|
PointOnGlobeProgramCache.release(this.globe);
|
|
229
228
|
this.gl.deleteBuffer(this._focusParams.elementBuffer);
|
|
230
229
|
this._bufferManagersMap.forEach(({ bufferManager, adaptor }) => bufferManager.free());
|
|
@@ -8,7 +8,6 @@ import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
|
|
|
8
8
|
* This program draws line between points provided from the first and second buffer.
|
|
9
9
|
* draw method gl.drawArraysInstanced( gl.POINTS, 0,2, lineCount);
|
|
10
10
|
* */
|
|
11
|
-
// TODO: find better way to eleminate edge case distance(posA, posB) > 37000000.0
|
|
12
11
|
const vertexShaderSource = `#version 300 es
|
|
13
12
|
precision highp float;
|
|
14
13
|
${CameraUniformBlockString}
|
|
@@ -100,7 +100,6 @@ class Logic {
|
|
|
100
100
|
const vao = gl.createVertexArray();
|
|
101
101
|
const divisor = 1;
|
|
102
102
|
gl.bindVertexArray(vao);
|
|
103
|
-
// TODO constants to escape values
|
|
104
103
|
attributeLoader(gl, pos3DObj, 0, 3, { divisor });
|
|
105
104
|
attributeLoader(gl, radiusObj, 1, 1, { divisor, escapeValues: [-1] });
|
|
106
105
|
attributeLoader(gl, colorObj, 2, 4, { divisor, escapeValues: [-1, -1, -1, -1] });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { globeProgramCache } from "../programcache";
|
|
2
2
|
import { fromLongLatToUnitVector } from "../../Math/vec3";
|
|
3
3
|
import { RADIANS } from "../../Math/methods";
|
|
4
|
+
import { GlobeChangeObserver } from "./globe-changes";
|
|
4
5
|
export const CameraUniformBlockString = `
|
|
5
6
|
layout(std140) uniform CameraUniformBlock {
|
|
6
7
|
mat4 view; // 64 bytes 0
|
|
@@ -29,6 +30,7 @@ export class CameraUniformBlockTotem {
|
|
|
29
30
|
_isMovedParams;
|
|
30
31
|
_normalizedCameraVector = [0, 0, 0]; // Normalized camera vector
|
|
31
32
|
// _frustumPlanes: any; // Uncomment and type if used
|
|
33
|
+
_globeChangeObserver = null;
|
|
32
34
|
constructor() {
|
|
33
35
|
this.id = "CameraUniformBlockTotem";
|
|
34
36
|
this.description =
|
|
@@ -51,6 +53,7 @@ export class CameraUniformBlockTotem {
|
|
|
51
53
|
this.ubo = this._createUBO();
|
|
52
54
|
this.traslateFloat32 = new Float32Array(3);
|
|
53
55
|
this.mapWHFloat32 = new Float32Array(2);
|
|
56
|
+
this._globeChangeObserver = new GlobeChangeObserver(globe);
|
|
54
57
|
this.setGeometry();
|
|
55
58
|
this.resize();
|
|
56
59
|
}
|
|
@@ -86,6 +89,7 @@ export class CameraUniformBlockTotem {
|
|
|
86
89
|
const ubo = this.ubo;
|
|
87
90
|
const mapWHFloat32 = this.mapWHFloat32;
|
|
88
91
|
const globe = this.globe;
|
|
92
|
+
this._globeChangeObserver?.checkChanges();
|
|
89
93
|
gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
|
|
90
94
|
{
|
|
91
95
|
// view, projection, translate
|
|
@@ -196,6 +200,9 @@ export class CameraUniformBlockTotem {
|
|
|
196
200
|
fromLongLatToUnitVector(result, [CenterLong * RADIANS, CenterLat * RADIANS]);
|
|
197
201
|
return result;
|
|
198
202
|
}
|
|
203
|
+
getGlobeChanges() {
|
|
204
|
+
return this._globeChangeObserver?.getChanges();
|
|
205
|
+
}
|
|
199
206
|
free() {
|
|
200
207
|
const gl = this.gl;
|
|
201
208
|
const ubo = this.ubo;
|
|
@@ -216,7 +216,6 @@ export class BearingLinePlugin {
|
|
|
216
216
|
this.drawOptions.drawAngleRing = drawAngleRing;
|
|
217
217
|
this.globe.DrawRender();
|
|
218
218
|
}
|
|
219
|
-
// TODO:
|
|
220
219
|
updatePartial(items, { textWriterIDs } = {}) {
|
|
221
220
|
if (this._freed) {
|
|
222
221
|
throw new Error("Plugin has been freed, cannot update item.");
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* set and get node data
|
|
3
|
-
* node indexes;
|
|
4
|
-
*/
|
|
5
1
|
export class ChainListMap {
|
|
6
2
|
_chainMap;
|
|
7
3
|
_chainSideProperties;
|
|
@@ -98,7 +94,7 @@ export class ChainListMap {
|
|
|
98
94
|
});
|
|
99
95
|
}
|
|
100
96
|
this._chainMap.delete(chainKey);
|
|
101
|
-
this._chainSideProperties.delete(chainKey);
|
|
97
|
+
this._chainSideProperties.delete(chainKey);
|
|
102
98
|
for (const key of keys)
|
|
103
99
|
this._indexMap.delete(key);
|
|
104
100
|
return keys;
|
|
@@ -177,10 +173,9 @@ export class ChainListMap {
|
|
|
177
173
|
memoryProperties[key] = value;
|
|
178
174
|
});
|
|
179
175
|
}
|
|
180
|
-
//
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
176
|
+
// getNodeProperties(chainKey: string): ChainProperties | undefined {
|
|
177
|
+
// return this._chainSideProperties.get(chainKey);
|
|
178
|
+
// }
|
|
184
179
|
getChainProperties(chainKey) {
|
|
185
180
|
return this._chainSideProperties.get(chainKey);
|
|
186
181
|
}
|
|
@@ -47,7 +47,7 @@ export class CircleLineChainPlugin {
|
|
|
47
47
|
dashedLineOpacityVariativeOn: false,
|
|
48
48
|
dashedLineRatioVariativeOn: false,
|
|
49
49
|
bufferType: "DYNAMIC_DRAW",
|
|
50
|
-
opacity: 1.0
|
|
50
|
+
opacity: 1.0,
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
53
|
constructor(id, { drawCircleOn, textWritersMap, textDataPreAdaptor, opacities, lineAdaptor, arcAdaptor, circleAdaptor, arcOnTerrainOptions, circleOnTerrainOptions, lineOptions } = {}) {
|
|
@@ -158,12 +158,14 @@ export class CircleLineChainPlugin {
|
|
|
158
158
|
this.globe?.DrawRender();
|
|
159
159
|
}
|
|
160
160
|
setOpacities(opacities) {
|
|
161
|
-
|
|
161
|
+
if (this._freed) {
|
|
162
|
+
console.warn("CircleLineChainPlugin is freed, cannot set opacities.");
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
162
165
|
this._opacities = {
|
|
163
166
|
...this._opacities,
|
|
164
167
|
...opacities
|
|
165
168
|
};
|
|
166
|
-
// set Opacities of plugins
|
|
167
169
|
this.globe?.DrawRender();
|
|
168
170
|
}
|
|
169
171
|
setElevationMode(mode) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LineOnGlobeCache } from "../../programs/line-on-globe/naive-accurate-flexible";
|
|
2
|
-
import {
|
|
2
|
+
import { BufferOrchestrator } from "../../util/account/single-attribute-buffer-management/buffer-orchestrator";
|
|
3
|
+
import { BufferManager } from "../../util/account/single-attribute-buffer-management/buffer-manager";
|
|
3
4
|
import { sphereCoord } from "../../util/geometry/index";
|
|
4
5
|
import { constraintFloat } from "../../util/check/typecheck";
|
|
5
6
|
export class LinePlugin {
|
|
@@ -10,20 +11,23 @@ export class LinePlugin {
|
|
|
10
11
|
vao = null;
|
|
11
12
|
_options;
|
|
12
13
|
_uboHandler = null;
|
|
13
|
-
_bufferOrchestrator
|
|
14
|
+
_bufferOrchestrator;
|
|
15
|
+
_bufferManagersMap = new Map();
|
|
14
16
|
_freed = false;
|
|
15
|
-
constructor(id, { flatViewOn = true, globeViewOn = true, variativeColorsOn = false, defaultColor = [1, 1, 1, 1], dashedLineOpacityVariativeOn = false, dashedLineRatioVariativeOn = false, bufferType = "DYNAMIC_DRAW", opacity = 1.0 } = {}) {
|
|
17
|
+
constructor(id, { flatViewOn = true, globeViewOn = true, variativeColorsOn = false, defaultColor = [1, 1, 1, 1], dashedLineOpacityVariativeOn = false, dashedLineRatioVariativeOn = false, bufferType = "DYNAMIC_DRAW", opacity = 1.0, initialCapacity = 10 } = {}) {
|
|
16
18
|
this.id = id;
|
|
17
19
|
this._options = {
|
|
18
|
-
flatViewOn,
|
|
19
|
-
globeViewOn,
|
|
20
|
-
variativeColorsOn,
|
|
21
|
-
defaultColor,
|
|
22
|
-
dashedLineOpacityVariativeOn,
|
|
23
|
-
dashedLineRatioVariativeOn,
|
|
24
|
-
bufferType,
|
|
25
|
-
opacity
|
|
20
|
+
flatViewOn: flatViewOn ?? true,
|
|
21
|
+
globeViewOn: globeViewOn ?? true,
|
|
22
|
+
variativeColorsOn: variativeColorsOn ?? false,
|
|
23
|
+
defaultColor: defaultColor ?? [1, 1, 1, 1],
|
|
24
|
+
dashedLineOpacityVariativeOn: dashedLineOpacityVariativeOn ?? false,
|
|
25
|
+
dashedLineRatioVariativeOn: dashedLineRatioVariativeOn ?? false,
|
|
26
|
+
bufferType: bufferType ?? "DYNAMIC_DRAW",
|
|
27
|
+
opacity: opacity ?? 1.0,
|
|
28
|
+
initialCapacity: initialCapacity ?? 10
|
|
26
29
|
};
|
|
30
|
+
this._bufferOrchestrator = new BufferOrchestrator({ capacity: initialCapacity ?? 10 });
|
|
27
31
|
}
|
|
28
32
|
init(globe, gl) {
|
|
29
33
|
this.globe = globe;
|
|
@@ -31,13 +35,12 @@ export class LinePlugin {
|
|
|
31
35
|
this.program = LineOnGlobeCache.get(globe);
|
|
32
36
|
this._uboHandler = this.program.createUBO();
|
|
33
37
|
this.setDefaultColor(this._options.defaultColor);
|
|
34
|
-
this.
|
|
35
|
-
);
|
|
38
|
+
this._fillManagerMap();
|
|
36
39
|
this.vao = this.program.createVAO(...this._createSelectBufferNames().map((key) => {
|
|
37
40
|
if (key === null) {
|
|
38
41
|
return null;
|
|
39
42
|
}
|
|
40
|
-
const bufferManagerComp = this.
|
|
43
|
+
const bufferManagerComp = this._bufferManagersMap.get(key);
|
|
41
44
|
if (bufferManagerComp === undefined) {
|
|
42
45
|
throw new Error(`Buffer key ${key} does not exist in bufferManagersMap`);
|
|
43
46
|
}
|
|
@@ -51,19 +54,19 @@ export class LinePlugin {
|
|
|
51
54
|
}
|
|
52
55
|
// PLUGIN INTERFACE METHODS
|
|
53
56
|
insertBulk(items) {
|
|
54
|
-
const { _bufferOrchestrator, globe } = this;
|
|
57
|
+
const { _bufferOrchestrator, _bufferManagersMap, globe } = this;
|
|
55
58
|
if (!_bufferOrchestrator || !globe) {
|
|
56
59
|
throw new Error("Buffer orchestrator or globe is not initialized.");
|
|
57
60
|
}
|
|
58
|
-
_bufferOrchestrator.insertBulk(items);
|
|
61
|
+
_bufferOrchestrator.insertBulk(items, _bufferManagersMap);
|
|
59
62
|
this.globe?.DrawRender();
|
|
60
63
|
}
|
|
61
64
|
deleteBulk(keys) {
|
|
62
|
-
const { _bufferOrchestrator, globe } = this;
|
|
65
|
+
const { _bufferOrchestrator, _bufferManagersMap, globe } = this;
|
|
63
66
|
if (!_bufferOrchestrator || !globe) {
|
|
64
67
|
throw new Error("Buffer orchestrator or globe is not initialized.");
|
|
65
68
|
}
|
|
66
|
-
_bufferOrchestrator.deleteBulk(keys);
|
|
69
|
+
_bufferOrchestrator.deleteBulk(keys, _bufferManagersMap);
|
|
67
70
|
this.globe?.DrawRender();
|
|
68
71
|
}
|
|
69
72
|
setPluginOpacity(opacity, drawRender = false) {
|
|
@@ -108,12 +111,11 @@ export class LinePlugin {
|
|
|
108
111
|
if (!_bufferOrchestrator || !_bufferOrchestrator || !_uboHandler) {
|
|
109
112
|
throw new Error("Buffer orchestrator is not initialized.");
|
|
110
113
|
}
|
|
111
|
-
const { bufferOrchestrator } = _bufferOrchestrator;
|
|
112
114
|
const { flatViewOn, globeViewOn, opacity } = _options;
|
|
113
115
|
const drawOptions = {
|
|
114
116
|
drawRange: {
|
|
115
117
|
first: 0,
|
|
116
|
-
count:
|
|
118
|
+
count: _bufferOrchestrator.length
|
|
117
119
|
}
|
|
118
120
|
};
|
|
119
121
|
this.gl.disable(this.gl.DEPTH_TEST); // Disable depth test for lines
|
|
@@ -132,67 +134,60 @@ export class LinePlugin {
|
|
|
132
134
|
if (this._freed)
|
|
133
135
|
return;
|
|
134
136
|
// TODO: FILL
|
|
135
|
-
this.
|
|
137
|
+
this._bufferManagersMap.forEach((manager) => {
|
|
138
|
+
manager.bufferManager.free();
|
|
139
|
+
});
|
|
136
140
|
this._uboHandler?.free();
|
|
137
141
|
LineOnGlobeCache.release(this.globe);
|
|
138
142
|
this._freed = true;
|
|
139
143
|
}
|
|
140
144
|
// IMPLICIT INTERFACE METHODS
|
|
141
|
-
|
|
145
|
+
_fillManagerMap() {
|
|
142
146
|
const globe = this.globe;
|
|
143
147
|
const { flatViewOn, globeViewOn, variativeColorsOn, dashedLineOpacityVariativeOn, dashedLineRatioVariativeOn, bufferType = "DYNAMIC_DRAW" } = this._options;
|
|
144
|
-
const m =
|
|
148
|
+
const m = this._bufferManagersMap;
|
|
149
|
+
const initialCapacity = this._options.initialCapacity;
|
|
145
150
|
if (flatViewOn) {
|
|
146
151
|
m.set("start_position", {
|
|
147
|
-
|
|
148
|
-
bufferType: bufferType, // TODO: Ask User?
|
|
149
|
-
buffer: null,
|
|
152
|
+
bufferManager: new BufferManager(globe.gl, 2, { bufferType, initialCapacity: this._options.initialCapacity }),
|
|
150
153
|
adaptor: (item) => {
|
|
151
154
|
const result = new Float32Array(globe.api_GetMercator2DPoint(item.start[0], item.start[1]));
|
|
152
155
|
return result;
|
|
153
156
|
}
|
|
154
157
|
});
|
|
155
158
|
m.set("end_position", {
|
|
156
|
-
|
|
157
|
-
bufferType: bufferType,
|
|
158
|
-
buffer: null,
|
|
159
|
+
bufferManager: new BufferManager(globe.gl, 2, { bufferType, initialCapacity: this._options.initialCapacity }),
|
|
159
160
|
adaptor: (item) => new Float32Array(globe.api_GetMercator2DPoint(item.end[0], item.end[1]))
|
|
160
161
|
});
|
|
161
162
|
}
|
|
162
163
|
if (globeViewOn) {
|
|
163
164
|
m.set("start_position_3d", {
|
|
164
|
-
|
|
165
|
-
bufferType: bufferType,
|
|
165
|
+
bufferManager: new BufferManager(globe.gl, 3, { bufferType, initialCapacity: this._options.initialCapacity }),
|
|
166
166
|
adaptor: (item) => sphereCoord(item.start[0], item.start[1], globe, item.start_altitude || 0)
|
|
167
167
|
});
|
|
168
168
|
m.set("end_position_3d", {
|
|
169
|
-
|
|
170
|
-
bufferType: bufferType,
|
|
169
|
+
bufferManager: new BufferManager(globe.gl, 3, { bufferType, initialCapacity: this._options.initialCapacity }),
|
|
171
170
|
adaptor: (item) => sphereCoord(item.end[0], item.end[1], globe, item.end_altitude || 0)
|
|
172
171
|
});
|
|
173
172
|
}
|
|
174
173
|
if (variativeColorsOn) {
|
|
175
174
|
m.set("color", {
|
|
176
|
-
|
|
177
|
-
bufferType: bufferType,
|
|
175
|
+
bufferManager: new BufferManager(globe.gl, 4, { bufferType, initialCapacity: this._options.initialCapacity }),
|
|
178
176
|
adaptor: (item) => new Float32Array(item.color !== undefined ? item.color : [-1, -1, -1, -1])
|
|
179
177
|
});
|
|
180
178
|
}
|
|
181
179
|
if (dashedLineOpacityVariativeOn) {
|
|
182
180
|
m.set("dashed_line_opacity", {
|
|
183
|
-
|
|
184
|
-
bufferType: bufferType,
|
|
181
|
+
bufferManager: new BufferManager(globe.gl, 1, { bufferType, initialCapacity: this._options.initialCapacity }),
|
|
185
182
|
adaptor: (item) => new Float32Array(item.dashed_line_opacity !== undefined ? [item.dashed_line_opacity] : [-1])
|
|
186
183
|
});
|
|
187
184
|
}
|
|
188
185
|
if (dashedLineRatioVariativeOn) {
|
|
189
186
|
m.set("dashed_line_ratio", {
|
|
190
|
-
|
|
191
|
-
bufferType: bufferType,
|
|
187
|
+
bufferManager: new BufferManager(globe.gl, 1, { bufferType, initialCapacity: this._options.initialCapacity }),
|
|
192
188
|
adaptor: (item) => new Float32Array(item.dashed_line_ratio !== undefined ? [item.dashed_line_ratio] : [-1])
|
|
193
189
|
});
|
|
194
190
|
}
|
|
195
|
-
return m;
|
|
196
191
|
}
|
|
197
192
|
_createSelectBufferNames() {
|
|
198
193
|
const { flatViewOn, globeViewOn, variativeColorsOn, dashedLineOpacityVariativeOn, dashedLineRatioVariativeOn } = this._options;
|