@pirireis/webglobeplugins 0.15.2-3.alpha → 0.15.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-generate-points copy.js +366 -0
- package/Math/arc.js +2 -1
- package/Math/circle-cdf-points.js +170 -1
- package/Math/circle.js +25 -0
- package/Math/globe-util/horizon-plane.js +112 -0
- package/Math/methods.js +2 -2
- package/Math/vec3.js +2 -6
- package/altitude-locator/draw-subset-obj.js +16 -0
- package/altitude-locator/plugin.js +1 -1
- package/bearing-line/plugin.js +2 -3
- package/package.json +1 -1
- package/point-tracks/plugin.js +22 -82
- package/programs/line-on-globe/lines-color-instanced-flat.js +1 -0
- package/programs/line-on-globe/linestrip/linestrip.js +28 -2
- package/programs/line-on-globe/paddings/paddings.js +1 -0
- package/programs/point-on-globe/element-globe-surface-glow.js +1 -0
- package/programs/rings/partial-ring/piece-of-pie copy.js +286 -0
- package/programs/totems/camerauniformblock.js +0 -7
- package/programs/totems/canvas-webglobe-info.js +9 -9
- package/range-tools-on-terrain/bearing-line/adapters.js +5 -8
- package/range-tools-on-terrain/bearing-line/plugin.js +20 -95
- package/range-tools-on-terrain/circle-line-chain/adapters.js +8 -15
- package/range-tools-on-terrain/circle-line-chain/chain-list-map.js +12 -16
- package/range-tools-on-terrain/circle-line-chain/plugin.js +11 -67
- package/range-tools-on-terrain/range-ring/adapters.js +6 -74
- package/range-tools-on-terrain/range-ring/plugin.js +7 -222
- package/range-tools-on-terrain/range-ring/types.js +1 -9
- package/semiplugins/lightweight/line-plugin.js +47 -65
- package/semiplugins/lightweight/piece-of-pie-plugin.js +18 -44
- package/semiplugins/shape-on-terrain/arc-plugin.js +100 -197
- package/semiplugins/shape-on-terrain/circle-plugin.js +90 -209
- package/semiplugins/shape-on-terrain/derived/padding-plugin.js +101 -0
- package/semiplugins/shape-on-terrain/one-degree-padding.js +85 -0
- package/util/account/single-attribute-buffer-management/buffer-manager.js +0 -10
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +8 -145
- package/util/account/single-attribute-buffer-management/object-store.js +0 -7
- package/util/build-strategy/static-dynamic.js +1 -11
- package/util/check/typecheck.js +0 -12
- package/util/geometry/index.js +1 -2
- package/programs/totems/globe-changes.js +0 -59
- package/semiplugins/interface.js +0 -1
- package/semiplugins/shape-on-terrain/padding-1-degree.js +0 -538
- package/util/account/single-attribute-buffer-management/buffer-orchestrator1.js +0 -159
- package/util/frame-counter-trigger.js +0 -84
- package/write-text/context-text4.js +0 -140
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { LineOnGlobeCache } from "../../programs/line-on-globe/naive-accurate-flexible";
|
|
2
|
-
import {
|
|
3
|
-
import { BufferManager } from "../../util/account/single-attribute-buffer-management/buffer-manager";
|
|
2
|
+
import { BufferMapOrchestrator } from "../../util/account/create-buffermap-orchastration";
|
|
4
3
|
import { sphereCoord } from "../../util/geometry/index";
|
|
5
4
|
import { constraintFloat } from "../../util/check/typecheck";
|
|
6
5
|
export class LinePlugin {
|
|
@@ -11,36 +10,33 @@ export class LinePlugin {
|
|
|
11
10
|
vao = null;
|
|
12
11
|
_options;
|
|
13
12
|
_uboHandler = null;
|
|
14
|
-
|
|
15
|
-
bufferManagersMap = new Map();
|
|
13
|
+
_bufferOrchestrator = null;
|
|
16
14
|
_freed = false;
|
|
17
|
-
constructor(id, { flatViewOn = true, globeViewOn = true, variativeColorsOn = false, defaultColor = [1, 1, 1, 1], dashedLineOpacityVariativeOn = false, dashedLineRatioVariativeOn = false, bufferType = "DYNAMIC_DRAW", opacity = 1.0
|
|
15
|
+
constructor(id, { flatViewOn = true, globeViewOn = true, variativeColorsOn = false, defaultColor = [1, 1, 1, 1], dashedLineOpacityVariativeOn = false, dashedLineRatioVariativeOn = false, bufferType = "DYNAMIC_DRAW", opacity = 1.0 } = {}) {
|
|
18
16
|
this.id = id;
|
|
19
17
|
this._options = {
|
|
20
|
-
flatViewOn
|
|
21
|
-
globeViewOn
|
|
22
|
-
variativeColorsOn
|
|
23
|
-
defaultColor
|
|
24
|
-
dashedLineOpacityVariativeOn
|
|
25
|
-
dashedLineRatioVariativeOn
|
|
26
|
-
bufferType
|
|
27
|
-
opacity
|
|
28
|
-
initialCapacity: initialCapacity ?? 10
|
|
18
|
+
flatViewOn,
|
|
19
|
+
globeViewOn,
|
|
20
|
+
variativeColorsOn,
|
|
21
|
+
defaultColor,
|
|
22
|
+
dashedLineOpacityVariativeOn,
|
|
23
|
+
dashedLineRatioVariativeOn,
|
|
24
|
+
bufferType,
|
|
25
|
+
opacity
|
|
29
26
|
};
|
|
30
|
-
this.bufferOrchestrator = new BufferOrchestrator({ capacity: initialCapacity ?? 10 });
|
|
31
27
|
}
|
|
32
28
|
init(globe, gl) {
|
|
33
29
|
this.globe = globe;
|
|
34
30
|
this.gl = gl;
|
|
35
31
|
this.program = LineOnGlobeCache.get(globe);
|
|
36
32
|
this._uboHandler = this.program.createUBO();
|
|
37
|
-
this.
|
|
38
|
-
|
|
33
|
+
this._bufferOrchestrator = new BufferMapOrchestrator(gl, this._createBufferDetailsMap(), 10 // initial capacity
|
|
34
|
+
);
|
|
39
35
|
this.vao = this.program.createVAO(...this._createSelectBufferNames().map((key) => {
|
|
40
36
|
if (key === null) {
|
|
41
37
|
return null;
|
|
42
38
|
}
|
|
43
|
-
const bufferManagerComp = this.bufferManagersMap.get(key);
|
|
39
|
+
const bufferManagerComp = this._bufferOrchestrator?.bufferManagersMap.get(key);
|
|
44
40
|
if (bufferManagerComp === undefined) {
|
|
45
41
|
throw new Error(`Buffer key ${key} does not exist in bufferManagersMap`);
|
|
46
42
|
}
|
|
@@ -53,43 +49,26 @@ export class LinePlugin {
|
|
|
53
49
|
}));
|
|
54
50
|
}
|
|
55
51
|
// PLUGIN INTERFACE METHODS
|
|
56
|
-
increaseSpace(amount) {
|
|
57
|
-
if (this._freed) {
|
|
58
|
-
console.warn("Plugin is freed, cannot increase space");
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (this.globe === null) {
|
|
62
|
-
console.warn("Globe is not initialized.");
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (typeof amount !== "number" || amount <= 0) {
|
|
66
|
-
console.warn("Invalid amount, must be a positive number");
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
this.bufferOrchestrator.ensureSpace(amount, this.bufferManagersMap);
|
|
70
|
-
}
|
|
71
52
|
insertBulk(items) {
|
|
72
|
-
const {
|
|
73
|
-
if (!
|
|
53
|
+
const { _bufferOrchestrator, globe } = this;
|
|
54
|
+
if (!_bufferOrchestrator || !globe) {
|
|
74
55
|
throw new Error("Buffer orchestrator or globe is not initialized.");
|
|
75
56
|
}
|
|
76
|
-
|
|
57
|
+
_bufferOrchestrator.insertBulk(items);
|
|
77
58
|
this.globe?.DrawRender();
|
|
78
59
|
}
|
|
79
60
|
deleteBulk(keys) {
|
|
80
|
-
const {
|
|
81
|
-
if (!
|
|
61
|
+
const { _bufferOrchestrator, globe } = this;
|
|
62
|
+
if (!_bufferOrchestrator || !globe) {
|
|
82
63
|
throw new Error("Buffer orchestrator or globe is not initialized.");
|
|
83
64
|
}
|
|
84
|
-
|
|
65
|
+
_bufferOrchestrator.deleteBulk(keys);
|
|
85
66
|
this.globe?.DrawRender();
|
|
86
67
|
}
|
|
87
|
-
setPluginOpacity(opacity
|
|
68
|
+
setPluginOpacity(opacity) {
|
|
88
69
|
constraintFloat(opacity, 0, 1);
|
|
89
70
|
this._options.opacity = opacity;
|
|
90
|
-
|
|
91
|
-
this.globe?.DrawRender();
|
|
92
|
-
}
|
|
71
|
+
this.globe?.DrawRender();
|
|
93
72
|
}
|
|
94
73
|
setPluginDashedLineRatio(ratio) {
|
|
95
74
|
constraintFloat(ratio, 0, 1);
|
|
@@ -102,19 +81,14 @@ export class LinePlugin {
|
|
|
102
81
|
this._options.defaultColor[3] = opacity; // Update the default color's alpha channel
|
|
103
82
|
this.globe?.DrawRender();
|
|
104
83
|
}
|
|
105
|
-
setDefaultColor(color
|
|
84
|
+
setDefaultColor(color) {
|
|
106
85
|
if (!this.globe || !this.gl) {
|
|
107
86
|
console.warn("Globe or WebGL context is not initialized.");
|
|
108
87
|
return;
|
|
109
88
|
}
|
|
110
89
|
this._options.defaultColor = color;
|
|
111
90
|
this._uboHandler?.updateSingle("u_color", new Float32Array(color));
|
|
112
|
-
|
|
113
|
-
this.globe.DrawRender();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
updateCoordinates(items) {
|
|
117
|
-
throw new Error("Method not implemented.");
|
|
91
|
+
this.globe?.DrawRender();
|
|
118
92
|
}
|
|
119
93
|
// GLOBE INTERACTION METHODS
|
|
120
94
|
draw3D() {
|
|
@@ -125,10 +99,11 @@ export class LinePlugin {
|
|
|
125
99
|
if (!this.globe || !this.gl || !this.program || !this.vao) {
|
|
126
100
|
throw new Error("Globe, GL context or program is not initialized.");
|
|
127
101
|
}
|
|
128
|
-
const {
|
|
129
|
-
if (!
|
|
102
|
+
const { _bufferOrchestrator, _options, _uboHandler, vao } = this;
|
|
103
|
+
if (!_bufferOrchestrator || !_bufferOrchestrator || !_uboHandler) {
|
|
130
104
|
throw new Error("Buffer orchestrator is not initialized.");
|
|
131
105
|
}
|
|
106
|
+
const { bufferOrchestrator } = _bufferOrchestrator;
|
|
132
107
|
const { flatViewOn, globeViewOn, opacity } = _options;
|
|
133
108
|
const drawOptions = {
|
|
134
109
|
drawRange: {
|
|
@@ -152,60 +127,67 @@ export class LinePlugin {
|
|
|
152
127
|
if (this._freed)
|
|
153
128
|
return;
|
|
154
129
|
// TODO: FILL
|
|
155
|
-
this.
|
|
156
|
-
manager.bufferManager.free();
|
|
157
|
-
});
|
|
130
|
+
this._bufferOrchestrator?.free();
|
|
158
131
|
this._uboHandler?.free();
|
|
159
132
|
LineOnGlobeCache.release(this.globe);
|
|
160
133
|
this._freed = true;
|
|
161
134
|
}
|
|
162
135
|
// IMPLICIT INTERFACE METHODS
|
|
163
|
-
|
|
136
|
+
_createBufferDetailsMap() {
|
|
164
137
|
const globe = this.globe;
|
|
165
138
|
const { flatViewOn, globeViewOn, variativeColorsOn, dashedLineOpacityVariativeOn, dashedLineRatioVariativeOn, bufferType = "DYNAMIC_DRAW" } = this._options;
|
|
166
|
-
const m =
|
|
167
|
-
const initialCapacity = this._options.initialCapacity;
|
|
139
|
+
const m = new Map();
|
|
168
140
|
if (flatViewOn) {
|
|
169
141
|
m.set("start_position", {
|
|
170
|
-
|
|
142
|
+
itemSize: 2,
|
|
143
|
+
bufferType: bufferType, // TODO: Ask User?
|
|
144
|
+
buffer: null,
|
|
171
145
|
adaptor: (item) => {
|
|
172
146
|
const result = new Float32Array(globe.api_GetMercator2DPoint(item.start[0], item.start[1]));
|
|
173
147
|
return result;
|
|
174
148
|
}
|
|
175
149
|
});
|
|
176
150
|
m.set("end_position", {
|
|
177
|
-
|
|
151
|
+
itemSize: 2,
|
|
152
|
+
bufferType: bufferType,
|
|
153
|
+
buffer: null,
|
|
178
154
|
adaptor: (item) => new Float32Array(globe.api_GetMercator2DPoint(item.end[0], item.end[1]))
|
|
179
155
|
});
|
|
180
156
|
}
|
|
181
157
|
if (globeViewOn) {
|
|
182
158
|
m.set("start_position_3d", {
|
|
183
|
-
|
|
159
|
+
itemSize: 3,
|
|
160
|
+
bufferType: bufferType,
|
|
184
161
|
adaptor: (item) => sphereCoord(item.start[0], item.start[1], globe, item.start_altitude || 0)
|
|
185
162
|
});
|
|
186
163
|
m.set("end_position_3d", {
|
|
187
|
-
|
|
164
|
+
itemSize: 3,
|
|
165
|
+
bufferType: bufferType,
|
|
188
166
|
adaptor: (item) => sphereCoord(item.end[0], item.end[1], globe, item.end_altitude || 0)
|
|
189
167
|
});
|
|
190
168
|
}
|
|
191
169
|
if (variativeColorsOn) {
|
|
192
170
|
m.set("color", {
|
|
193
|
-
|
|
171
|
+
itemSize: 4,
|
|
172
|
+
bufferType: bufferType,
|
|
194
173
|
adaptor: (item) => new Float32Array(item.color !== undefined ? item.color : [-1, -1, -1, -1])
|
|
195
174
|
});
|
|
196
175
|
}
|
|
197
176
|
if (dashedLineOpacityVariativeOn) {
|
|
198
177
|
m.set("dashed_line_opacity", {
|
|
199
|
-
|
|
178
|
+
itemSize: 1,
|
|
179
|
+
bufferType: bufferType,
|
|
200
180
|
adaptor: (item) => new Float32Array(item.dashed_line_opacity !== undefined ? [item.dashed_line_opacity] : [-1])
|
|
201
181
|
});
|
|
202
182
|
}
|
|
203
183
|
if (dashedLineRatioVariativeOn) {
|
|
204
184
|
m.set("dashed_line_ratio", {
|
|
205
|
-
|
|
185
|
+
itemSize: 1,
|
|
186
|
+
bufferType: bufferType,
|
|
206
187
|
adaptor: (item) => new Float32Array(item.dashed_line_ratio !== undefined ? [item.dashed_line_ratio] : [-1])
|
|
207
188
|
});
|
|
208
189
|
}
|
|
190
|
+
return m;
|
|
209
191
|
}
|
|
210
192
|
_createSelectBufferNames() {
|
|
211
193
|
const { flatViewOn, globeViewOn, variativeColorsOn, dashedLineOpacityVariativeOn, dashedLineRatioVariativeOn } = this._options;
|
|
@@ -19,19 +19,13 @@ export class PieceOfPiePlugin {
|
|
|
19
19
|
_pluginOptions = {
|
|
20
20
|
bufferType: "STATIC_DRAW",
|
|
21
21
|
initialCapacity: INITIAL_CAPACITY,
|
|
22
|
-
|
|
23
|
-
defaultHeightFromGroundIn3D: 0, // Default altitude is ground level
|
|
24
|
-
defaultColor: [1, 1, 1, 1], // Default color is white with full opacity
|
|
25
|
-
variativeColorsOn: false, // Default is to not use variative colors
|
|
22
|
+
defaultAltitude: 0, // Default altitude is ground level
|
|
26
23
|
};
|
|
27
|
-
constructor(id, options =
|
|
24
|
+
constructor(id, options = {}) {
|
|
28
25
|
this.id = id;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
...options
|
|
33
|
-
};
|
|
34
|
-
}
|
|
26
|
+
options.bufferType && (this._pluginOptions.bufferType = options.bufferType);
|
|
27
|
+
options.initialCapacity && (this._pluginOptions.initialCapacity = options.initialCapacity);
|
|
28
|
+
options.defaultAltitude && (this._pluginOptions.defaultAltitude = options.defaultAltitude);
|
|
35
29
|
}
|
|
36
30
|
insertBulk(items) {
|
|
37
31
|
this.bufferOrchestrator.insertBulk(items, this.bufferManagersMap);
|
|
@@ -41,12 +35,10 @@ export class PieceOfPiePlugin {
|
|
|
41
35
|
this.bufferOrchestrator.deleteBulk(keys, this.bufferManagersMap);
|
|
42
36
|
this.globe?.DrawRender();
|
|
43
37
|
}
|
|
44
|
-
setPluginOpacity(opacity
|
|
38
|
+
setPluginOpacity(opacity) {
|
|
45
39
|
opacityCheck(opacity);
|
|
46
40
|
this._uboHandler?.updateSingle("u_opacity", new Float32Array([opacity]));
|
|
47
|
-
|
|
48
|
-
this.globe?.DrawRender();
|
|
49
|
-
}
|
|
41
|
+
this.globe?.DrawRender();
|
|
50
42
|
}
|
|
51
43
|
setDrawMode(drawMode) {
|
|
52
44
|
if (drawMode !== "TRIANGLE_FAN" && drawMode !== "LINE_STRIP" && drawMode !== "BOTH") {
|
|
@@ -55,17 +47,6 @@ export class PieceOfPiePlugin {
|
|
|
55
47
|
this.drawMode = drawMode;
|
|
56
48
|
this.globe?.DrawRender();
|
|
57
49
|
}
|
|
58
|
-
setDefaultColor(color) {
|
|
59
|
-
if (this._isFreed) {
|
|
60
|
-
console.warn("PieceOfPiePlugin is freed, cannot set default color.");
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
if (!Array.isArray(color) || color.length !== 4) {
|
|
64
|
-
throw new Error("Color must be an array of 4 numbers [R, G, B, A].");
|
|
65
|
-
}
|
|
66
|
-
this._uboHandler?.updateSingle("u_color", new Float32Array(color));
|
|
67
|
-
this.globe?.DrawRender();
|
|
68
|
-
}
|
|
69
50
|
_createBufferManagersMap() {
|
|
70
51
|
const { gl, globe, _pluginOptions } = this;
|
|
71
52
|
const { bufferType, initialCapacity } = _pluginOptions;
|
|
@@ -79,7 +60,7 @@ export class PieceOfPiePlugin {
|
|
|
79
60
|
}],
|
|
80
61
|
["centerCoords3d", {
|
|
81
62
|
bufferManager: new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
82
|
-
adaptor: (item) => sphereCoord(item.center[0], item.center[1], globe, (item.altitude ?? this._pluginOptions.
|
|
63
|
+
adaptor: (item) => sphereCoord(item.center[0], item.center[1], globe, (item.altitude ?? this._pluginOptions.defaultAltitude) / 1000)
|
|
83
64
|
}],
|
|
84
65
|
["startAngle2d", {
|
|
85
66
|
bufferManager: new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
@@ -121,22 +102,21 @@ export class PieceOfPiePlugin {
|
|
|
121
102
|
bufferManager: new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
122
103
|
adaptor: (item) => new Float32Array([item.fillingMode ?? 0])
|
|
123
104
|
}],
|
|
105
|
+
["rgba", {
|
|
106
|
+
bufferManager: new BufferManager(gl, 4, { bufferType, initialCapacity }),
|
|
107
|
+
adaptor: (item) => {
|
|
108
|
+
if (!item.color || item.color.length === 0) {
|
|
109
|
+
return new Float32Array([1, 1, 1, 1]); // Default color if none provided
|
|
110
|
+
}
|
|
111
|
+
return new Float32Array(item.color);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
],
|
|
124
115
|
["radius", {
|
|
125
116
|
bufferManager: new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
126
117
|
adaptor: (item) => new Float32Array([item.radius])
|
|
127
118
|
}],
|
|
128
119
|
]);
|
|
129
|
-
if (this._pluginOptions.variativeColorsOn) {
|
|
130
|
-
bufferManagersMap.set("rgba", {
|
|
131
|
-
bufferManager: new BufferManager(gl, 4, { bufferType, initialCapacity }),
|
|
132
|
-
adaptor: (item) => {
|
|
133
|
-
if (!item.color || item.color.length === 0) {
|
|
134
|
-
return new Float32Array([1, 1, 1, 1]); // Default color if none provided
|
|
135
|
-
}
|
|
136
|
-
return new Float32Array(item.color);
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
120
|
this.bufferManagersMap = bufferManagersMap;
|
|
141
121
|
}
|
|
142
122
|
init(globe, gl) {
|
|
@@ -155,9 +135,6 @@ export class PieceOfPiePlugin {
|
|
|
155
135
|
'rgba',
|
|
156
136
|
'radius',
|
|
157
137
|
'fillingMode'].map((name) => {
|
|
158
|
-
if (!this.bufferManagersMap?.has(name)) {
|
|
159
|
-
return null; // this make vao with default attribute value with no buffer bound to it
|
|
160
|
-
}
|
|
161
138
|
const buffer = this.bufferManagersMap?.get(name)?.bufferManager.buffer;
|
|
162
139
|
return {
|
|
163
140
|
buffer: buffer,
|
|
@@ -165,9 +142,6 @@ export class PieceOfPiePlugin {
|
|
|
165
142
|
offset: 0,
|
|
166
143
|
};
|
|
167
144
|
}));
|
|
168
|
-
this._uboHandler = this.program.createUBO();
|
|
169
|
-
this._uboHandler.updateSingle("u_color", new Float32Array(this._pluginOptions.defaultColor));
|
|
170
|
-
this._uboHandler.updateSingle("u_opacity", new Float32Array([this._pluginOptions.opacity ?? 1.0])); // Default opacity is 1.0
|
|
171
145
|
}
|
|
172
146
|
draw3D() {
|
|
173
147
|
if (!this.gl || !this.program || !this.vao || !this.globe) {
|