@pirireis/webglobeplugins 0.12.0-alpha → 0.13.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/circle-cdf-points.js +0 -2
- package/package.json +1 -1
- package/programs/line-on-globe/circle-accurate.js +176 -175
- package/programs/line-on-globe/circle.js +166 -164
- package/programs/line-on-globe/linestrip/data.js +4 -0
- package/programs/line-on-globe/{linestrip.js → linestrip/linestrip.js} +34 -34
- package/programs/line-on-globe/to-the-surface.js +111 -109
- package/programs/rings/distancering/circleflatprogram.js +116 -120
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +1 -1
- package/programs/rings/distancering/circlepaddysharedbuffer.js +368 -354
- package/programs/rings/distancering/index.js +6 -5
- package/programs/rings/distancering/paddyflatprogram.js +127 -136
- package/programs/rings/distancering/paddyflatprogram2d.js +129 -138
- package/programs/rings/distancering/paddyflatprogram3d.js +128 -136
- package/programs/vectorfields/logics/pixelbased.js +5 -21
- package/shape-on-terrain/arc/naive/plugin.js +111 -66
- package/shape-on-terrain/circle/plugin.js +94 -62
- package/shape-on-terrain/type.js +1 -0
- package/util/account/index.js +2 -2
- package/util/account/single-attribute-buffer-management/buffer-manager.js +2 -3
- package/util/build-strategy/static-dynamic.js +1 -1
- package/programs/rings/distancering/shader.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LineStripProgramCache } from "../../programs/line-on-globe/linestrip";
|
|
1
|
+
import { LineStripProgramCache } from "../../programs/line-on-globe/linestrip/linestrip";
|
|
2
2
|
import { BufferManager, BufferOrchestrator } from "../../util/account/single-attribute-buffer-management/index";
|
|
3
3
|
import { CameraUniformBlockTotemCache } from "../../programs/totems/camerauniformblock";
|
|
4
4
|
import { createBufferAndReadInfo } from '../../util/gl-util/buffer/attribute-loader';
|
|
@@ -50,6 +50,7 @@ const defineStregthLevel = (lod, radiusMeters) => {
|
|
|
50
50
|
return Math.min(level, ATTRACTION_LEVELS - 1);
|
|
51
51
|
};
|
|
52
52
|
const AnglesStash = CircleCDF.createCummulativeTemplateStash(ATTRACTION_LEVELS, CIRCLE_POINTS_COUNT_HALF, DENSE_PART_SAMPLE_RATIO, STRENGTH_FACTOR);
|
|
53
|
+
const _colorArray = new Float32Array(4); // Used to store the color for each circle
|
|
53
54
|
export class CircleOnTerrainPlugin {
|
|
54
55
|
id;
|
|
55
56
|
globe = null;
|
|
@@ -65,14 +66,91 @@ export class CircleOnTerrainPlugin {
|
|
|
65
66
|
_vao = null;
|
|
66
67
|
_dobuild = true; // This is used to trigger the build of circles when the camera position changes.
|
|
67
68
|
_staticDynamicStrategy = null;
|
|
68
|
-
|
|
69
|
+
_styleOptions = {
|
|
70
|
+
variativeColorsOn: false,
|
|
71
|
+
defaultColor: [0.1, 0.1, 1, 1], // Default color in RGBA format
|
|
72
|
+
defaultHeightFromGroundIn3D: 30.0
|
|
73
|
+
};
|
|
74
|
+
constructor(id, styleOptions = {
|
|
75
|
+
variativeColorsOn: false, defaultColor: [0.1, 0.1, 1, 1]
|
|
76
|
+
}) {
|
|
69
77
|
this.id = id;
|
|
78
|
+
this._styleOptions = styleOptions;
|
|
79
|
+
this._styleOptions.defaultColor = new Float32Array(this._styleOptions.defaultColor);
|
|
70
80
|
}
|
|
81
|
+
init(globe, gl) {
|
|
82
|
+
this.globe = globe;
|
|
83
|
+
this.gl = gl;
|
|
84
|
+
// Initialize the program cache for line strip rendering.
|
|
85
|
+
this._staticDynamicStrategy = new StaticDynamicStrategy(globe, 8);
|
|
86
|
+
this.lineProgram = LineStripProgramCache.get(globe);
|
|
87
|
+
// const g3D = globe3Dcoordinates(globe, 30);
|
|
88
|
+
const g2D = globe2Dcoordinates(globe);
|
|
89
|
+
// Initialize with a reasonable initial capacity to prevent buffer size issues
|
|
90
|
+
const initialCapacity = 100; // Start with capacity for 100 circles
|
|
91
|
+
this.bufferManagerMap.set("position3d", {
|
|
92
|
+
bufferManager: new BufferManager(gl, (CIRCLE_POINTS_COUNT + 1) * 3, { initialCapacity }), // plus 1 is for butting linestrips
|
|
93
|
+
adaptor: (item) => {
|
|
94
|
+
const { longLatArr, height = this._styleOptions.defaultHeightFromGroundIn3D } = item;
|
|
95
|
+
const result = globe3Dcoordinates(globe, height)(longLatArr, { paddingCount: 1, paddingValue: NaN });
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
this.bufferManagerMap.set("position2d", {
|
|
100
|
+
bufferManager: new BufferManager(gl, (CIRCLE_POINTS_COUNT + 1) * 2, { initialCapacity }),
|
|
101
|
+
adaptor: (item) => {
|
|
102
|
+
const { longLatArr } = item;
|
|
103
|
+
const result = g2D(longLatArr, { paddingCount: 1, paddingValue: NaN });
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
if (this._styleOptions.variativeColorsOn) {
|
|
108
|
+
this.bufferManagerMap.set("color", {
|
|
109
|
+
bufferManager: new BufferManager(gl, 4, { initialCapacity }),
|
|
110
|
+
adaptor: (item) => {
|
|
111
|
+
const { radius } = item;
|
|
112
|
+
// Calculate color based on radius
|
|
113
|
+
if (item.color) {
|
|
114
|
+
_colorArray.set(item.color);
|
|
115
|
+
return _colorArray;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
return this._styleOptions.defaultColor;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
this._vao = this.lineProgram.createVAO(createBufferAndReadInfo(this.bufferManagerMap.get("position3d")?.bufferManager.buffer), createBufferAndReadInfo(this.bufferManagerMap.get("position2d")?.bufferManager.buffer), this._styleOptions.variativeColorsOn ?
|
|
124
|
+
createBufferAndReadInfo(this.bufferManagerMap.get("color")?.bufferManager.buffer) : null);
|
|
125
|
+
this._circleUBOHandler = this.lineProgram.createUBO();
|
|
126
|
+
this._cameraUniformBlock = CameraUniformBlockTotemCache.get(globe);
|
|
127
|
+
}
|
|
128
|
+
insertCircle(key, longitude, latitude, radius, height = null) {
|
|
129
|
+
const circle = {
|
|
130
|
+
center: [longitude, latitude],
|
|
131
|
+
radius: radius
|
|
132
|
+
};
|
|
133
|
+
const circleForAzimuthCalc = CircleMethods.createCircleClosestAzimuthAngleProperties(circle);
|
|
134
|
+
this.circleMap.set(key, [circle, circleForAzimuthCalc, height]);
|
|
135
|
+
// @ts-ignore
|
|
136
|
+
if (this._staticDynamicStrategy.getState() !== StaticDynamicState.DYNAMIC) {
|
|
137
|
+
this.__buildStaticCircles([key]);
|
|
138
|
+
}
|
|
139
|
+
this.globe?.DrawRender();
|
|
140
|
+
}
|
|
141
|
+
deleteCircle(keys) {
|
|
142
|
+
for (const key of keys) {
|
|
143
|
+
if (this.circleMap.has(key)) {
|
|
144
|
+
this.circleMap.delete(key);
|
|
145
|
+
this.globe?.DrawRender();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
this._dobuild = true;
|
|
149
|
+
this.globe?.DrawRender();
|
|
150
|
+
}
|
|
151
|
+
// IMPLICIT METHODS
|
|
71
152
|
_buildCircles() {
|
|
72
|
-
//
|
|
73
153
|
// @ts-ignore
|
|
74
|
-
this.__buildCircles();
|
|
75
|
-
return;
|
|
76
154
|
this._staticDynamicStrategy?.updateState();
|
|
77
155
|
const state = this._staticDynamicStrategy?.getState();
|
|
78
156
|
if (state === StaticDynamicState.TO_STATIC)
|
|
@@ -94,7 +172,8 @@ export class CircleOnTerrainPlugin {
|
|
|
94
172
|
// Prepare the data for the buffers
|
|
95
173
|
const data = [{
|
|
96
174
|
key: "",
|
|
97
|
-
longLatArr: []
|
|
175
|
+
longLatArr: [],
|
|
176
|
+
height: null
|
|
98
177
|
}];
|
|
99
178
|
const lookAtPosition = _cameraUniformBlock.getLookAtVector();
|
|
100
179
|
const cameraPosition = _cameraUniformBlock.getNormalizedCameraVector();
|
|
@@ -102,10 +181,9 @@ export class CircleOnTerrainPlugin {
|
|
|
102
181
|
vec3.add(cameraPosition, cameraPosition, lookAtPosition);
|
|
103
182
|
vec3.normalize(cameraPosition, cameraPosition);
|
|
104
183
|
const currentLOD = globe.api_GetCurrentLODWithDecimal();
|
|
105
|
-
// const currentGeom = globe.api_GetCurrentGeometry();
|
|
106
184
|
const circlePointsLongLat = new Float64Array((CIRCLE_POINTS_COUNT) * 2);
|
|
107
185
|
for (const [key, circle] of this.circleMap.entries()) {
|
|
108
|
-
const [{ radius, center }, circleForAzimuthCalc] = circle;
|
|
186
|
+
const [{ radius, center }, circleForAzimuthCalc, height] = circle;
|
|
109
187
|
const closestAzimuthAngle = CircleMethods.closestAzimuthAngle(circleForAzimuthCalc, cameraPosition);
|
|
110
188
|
const stregthLevel = defineStregthLevel(currentLOD, radius);
|
|
111
189
|
// console.log('DrawStregthLevel', stregthLevel, currentLOD, radius);
|
|
@@ -117,6 +195,7 @@ export class CircleOnTerrainPlugin {
|
|
|
117
195
|
CircleCDF.globeFindPointByPolarHalfCircle(circlePointsLongLat, globe, center[0], center[1], radius, closestAzimuthAngle, templateAngles);
|
|
118
196
|
data[0].key = key;
|
|
119
197
|
data[0].longLatArr = circlePointsLongLat;
|
|
198
|
+
data[0].height = height;
|
|
120
199
|
// Add to buffer orchestrator
|
|
121
200
|
this.bufferOrchestrator.insertBulk(data, bufferManagerMap);
|
|
122
201
|
}
|
|
@@ -130,7 +209,8 @@ export class CircleOnTerrainPlugin {
|
|
|
130
209
|
throw new Error("Plugin not initialized properly");
|
|
131
210
|
const data = [{
|
|
132
211
|
key: "",
|
|
133
|
-
longLatArr: []
|
|
212
|
+
longLatArr: [],
|
|
213
|
+
height: null
|
|
134
214
|
}];
|
|
135
215
|
// ensure buffer orchestrotrator have enough capacity
|
|
136
216
|
// all circles are build with even sampling, AttractionLevel = 0
|
|
@@ -140,10 +220,11 @@ export class CircleOnTerrainPlugin {
|
|
|
140
220
|
const circlePointsLongLat = new Float64Array((CIRCLE_POINTS_COUNT) * 2);
|
|
141
221
|
bufferOrchestrator.resetWithCapacity(bufferManagerMap, circleMap.size);
|
|
142
222
|
for (const [key, circle] of this.circleMap.entries()) {
|
|
143
|
-
const [{ radius, center }, _] = circle;
|
|
223
|
+
const [{ radius, center }, _, height] = circle;
|
|
144
224
|
CircleCDF.globeFindPointByPolarHalfCircle(circlePointsLongLat, globe, center[0], center[1], radius, zeroRotation, templateAngles);
|
|
145
225
|
data[0].key = key;
|
|
146
226
|
data[0].longLatArr = circlePointsLongLat;
|
|
227
|
+
data[0].height = height;
|
|
147
228
|
this.bufferOrchestrator.insertBulk(data, bufferManagerMap);
|
|
148
229
|
}
|
|
149
230
|
}
|
|
@@ -157,66 +238,17 @@ export class CircleOnTerrainPlugin {
|
|
|
157
238
|
console.warn(`CircleOnTerrainPlugin: Circle ${key} not found in circleMap.`);
|
|
158
239
|
continue;
|
|
159
240
|
}
|
|
160
|
-
const [{ radius, center }, _] = this.circleMap.get(key);
|
|
241
|
+
const [{ radius, center }, _, height] = this.circleMap.get(key);
|
|
161
242
|
const circlePointsLongLat = new Float64Array((CIRCLE_POINTS_COUNT) * 2);
|
|
162
243
|
CircleCDF.globeFindPointByPolarHalfCircle(circlePointsLongLat, globe, center[0], center[1], radius, zeroRotation, templateAngles);
|
|
163
244
|
data[0].key = key;
|
|
164
245
|
data[0].longLatArr = circlePointsLongLat;
|
|
246
|
+
data[0].height = height;
|
|
165
247
|
this.bufferOrchestrator.insertBulk(data, bufferManagerMap);
|
|
166
248
|
}
|
|
167
249
|
}
|
|
168
250
|
}
|
|
169
|
-
|
|
170
|
-
this.globe = globe;
|
|
171
|
-
this.gl = gl;
|
|
172
|
-
// Initialize the program cache for line strip rendering.
|
|
173
|
-
this._staticDynamicStrategy = new StaticDynamicStrategy(globe, 8);
|
|
174
|
-
this.lineProgram = LineStripProgramCache.get(globe);
|
|
175
|
-
const g3D = globe3Dcoordinates(globe, 30);
|
|
176
|
-
const g2D = globe2Dcoordinates(globe);
|
|
177
|
-
this.bufferManagerMap.set("position3d", {
|
|
178
|
-
bufferManager: new BufferManager(gl, (CIRCLE_POINTS_COUNT + 1) * 3), // plus 1 is for butting linestrips
|
|
179
|
-
adaptor: (item) => {
|
|
180
|
-
const { longLatArr } = item;
|
|
181
|
-
const result = g3D(longLatArr, { paddingCount: 1, paddingValue: NaN });
|
|
182
|
-
return result;
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
this.bufferManagerMap.set("position2d", {
|
|
186
|
-
bufferManager: new BufferManager(gl, (CIRCLE_POINTS_COUNT + 1) * 2),
|
|
187
|
-
adaptor: (item) => {
|
|
188
|
-
const { longLatArr } = item;
|
|
189
|
-
const result = g2D(longLatArr, { paddingCount: 1, paddingValue: NaN });
|
|
190
|
-
return result;
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
this._vao = this.lineProgram.createVAO(createBufferAndReadInfo(this.bufferManagerMap.get("position3d")?.bufferManager.buffer), createBufferAndReadInfo(this.bufferManagerMap.get("position2d")?.bufferManager.buffer), null, null, null);
|
|
194
|
-
this._circleUBOHandler = this.lineProgram.createUBO();
|
|
195
|
-
this._cameraUniformBlock = CameraUniformBlockTotemCache.get(globe);
|
|
196
|
-
}
|
|
197
|
-
insertCircle(key, longitude, latitude, radius) {
|
|
198
|
-
const circle = {
|
|
199
|
-
center: [longitude, latitude],
|
|
200
|
-
radius: radius
|
|
201
|
-
};
|
|
202
|
-
const circleForAzimuthCalc = CircleMethods.createCircleClosestAzimuthAngleProperties(circle);
|
|
203
|
-
this.circleMap.set(key, [circle, circleForAzimuthCalc]);
|
|
204
|
-
// @ts-ignore
|
|
205
|
-
if (this._staticDynamicStrategy.getState() === StaticDynamicState.STATIC) {
|
|
206
|
-
this.__buildStaticCircles([key]);
|
|
207
|
-
}
|
|
208
|
-
this.globe?.DrawRender();
|
|
209
|
-
}
|
|
210
|
-
deleteCircle(keys) {
|
|
211
|
-
for (const key of keys) {
|
|
212
|
-
if (this.circleMap.has(key)) {
|
|
213
|
-
this.circleMap.delete(key);
|
|
214
|
-
this.globe?.DrawRender();
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
this._dobuild = true;
|
|
218
|
-
this.globe?.DrawRender();
|
|
219
|
-
}
|
|
251
|
+
// GLOBE API INTERFACE
|
|
220
252
|
draw3D() {
|
|
221
253
|
const { _isFree, globe, gl, lineProgram, bufferOrchestrator, bufferManagerMap, _vao, _circleUBOHandler } = this;
|
|
222
254
|
if (_isFree || !globe || !gl || !lineProgram || !bufferOrchestrator ||
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/util/account/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import BufferOffsetManager from './bufferoffsetmanager';
|
|
2
|
-
export { BufferOffsetManager };
|
|
1
|
+
// import BufferOffsetManager from './bufferoffsetmanager';
|
|
2
|
+
// export { BufferOffsetManager };
|
|
3
3
|
export * from './single-attribute-buffer-management/index';
|
|
@@ -22,13 +22,12 @@ export class BufferManager {
|
|
|
22
22
|
itemSize;
|
|
23
23
|
bufferType;
|
|
24
24
|
isFreed = false;
|
|
25
|
-
constructor(gl, itemSize, { bufferType = "STATIC_DRAW", buffer = null, initialCapacity =
|
|
25
|
+
constructor(gl, itemSize, { bufferType = "STATIC_DRAW", buffer = null, initialCapacity = 10 } = {}) {
|
|
26
26
|
this.gl = gl;
|
|
27
27
|
this.itemSize = itemSize;
|
|
28
28
|
this.bufferType = bufferType;
|
|
29
29
|
this.buffer = buffer === null ? gl.createBuffer() : buffer;
|
|
30
|
-
|
|
31
|
-
this.resetWithCapacity(initialCapacity);
|
|
30
|
+
this.resetWithCapacity(initialCapacity);
|
|
32
31
|
}
|
|
33
32
|
resetWithCapacity(capacity) {
|
|
34
33
|
const { gl, buffer, bufferType, itemSize } = this;
|
|
@@ -17,7 +17,7 @@ export class StaticDynamicStrategy {
|
|
|
17
17
|
updateState() {
|
|
18
18
|
const currentLOD = this.globe.api_GetCurrentLODWithDecimal();
|
|
19
19
|
const state = currentLOD < this._transitionLevel ? StaticDynamicState.STATIC : StaticDynamicState.DYNAMIC;
|
|
20
|
-
if (this._lastStaticDynamicState === StaticDynamicState.
|
|
20
|
+
if (this._lastStaticDynamicState === StaticDynamicState.DYNAMIC && state === StaticDynamicState.STATIC) {
|
|
21
21
|
this._staticDynamicState = StaticDynamicState.TO_STATIC;
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|