@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,6 +1,8 @@
|
|
|
1
1
|
import { createProgram } from "../../../util/webglobjectbuilders";
|
|
2
2
|
import { CameraUniformBlockTotem, CameraUniformBlockString } from "../../totems/index";
|
|
3
3
|
import { noRegisterGlobeProgramCache, globeProgramCache } from "../../programcache";
|
|
4
|
+
import { attributeLoader } from "../../../util/gl-util/buffer/attribute-loader";
|
|
5
|
+
import { UniformBlockManager } from "../../../util/gl-util/uniform-block/manager";
|
|
4
6
|
import { POLE, PI, longLatRadToMercator, mercatorXYToGLPosition, longLatRadToCartesian3D, circleLimpFromLongLatRadCenterCartesian3D_accurate, circleLimpFromLongLatRadCenterMercatorCompass_accurate,
|
|
5
7
|
//circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate,
|
|
6
8
|
cartesian3DToGLPosition } from "../../../util/shaderfunctions/geometrytransformations";
|
|
@@ -9,6 +11,14 @@ cartesian3DToGLPosition } from "../../../util/shaderfunctions/geometrytransforma
|
|
|
9
11
|
* 1. Triangle face looks at screen. if rotation angle is positive the last vertex must be the faintest.
|
|
10
12
|
*
|
|
11
13
|
*/
|
|
14
|
+
const uniformBindingPoints = {
|
|
15
|
+
camera: 0,
|
|
16
|
+
flexible: 1,
|
|
17
|
+
};
|
|
18
|
+
const flexibleBlockManager = new UniformBlockManager('FlexibleAttributes', [
|
|
19
|
+
{ name: "u_color", type: "vec4", value: new Float32Array([0.12, 1, 0.1, 1]) },
|
|
20
|
+
{ name: "u_opacity", type: "float", value: new Float32Array([1]) },
|
|
21
|
+
], uniformBindingPoints.flexible);
|
|
12
22
|
const drawModeMap = Object.freeze({
|
|
13
23
|
LINE_STRIP: 0,
|
|
14
24
|
TRIANGLE_FAN: 1,
|
|
@@ -25,11 +35,12 @@ ${circleLimpFromLongLatRadCenterCartesian3D_accurate}
|
|
|
25
35
|
${circleLimpFromLongLatRadCenterMercatorCompass_accurate}
|
|
26
36
|
${cartesian3DToGLPosition}
|
|
27
37
|
|
|
38
|
+
${flexibleBlockManager.glslCode()}
|
|
39
|
+
|
|
40
|
+
|
|
28
41
|
uniform float edge_count;
|
|
29
42
|
uniform int draw_mode; // %2 => 0: LINE_STRIP, 1: TRIANGLE_FAN
|
|
30
|
-
|
|
31
|
-
//, lat, startAngle, tailAngle, ...rgba, radius, rgbaMode
|
|
32
|
-
// in vec2 center; // long, lat in radian
|
|
43
|
+
|
|
33
44
|
in vec2 center2d;
|
|
34
45
|
in vec3 center3d;
|
|
35
46
|
in float start_angle2d;
|
|
@@ -41,14 +52,15 @@ in float tail_angle3d;
|
|
|
41
52
|
in vec4 color;
|
|
42
53
|
in float radius; // in meter
|
|
43
54
|
in float filling_mode; // 0.0: constant, 1.0: fading, 2.0: hide
|
|
44
|
-
|
|
45
|
-
// flat out float v_phase;
|
|
55
|
+
|
|
46
56
|
out vec2 v_pos;
|
|
47
57
|
out vec4 v_color;
|
|
48
|
-
|
|
58
|
+
|
|
49
59
|
|
|
50
60
|
void main() {
|
|
51
61
|
// vid = gl_VertexID;
|
|
62
|
+
vec4 _color = (color.r == -1.0) ? u_color : color;
|
|
63
|
+
|
|
52
64
|
if (filling_mode == 2.0 || radius == 0.0) { return; }
|
|
53
65
|
float start_angle, tail_angle;
|
|
54
66
|
if (is3D) {
|
|
@@ -62,7 +74,7 @@ void main() {
|
|
|
62
74
|
if ( draw_mode == 0 && filling_mode == 1.0) {filling_mode_ = 0.0;}
|
|
63
75
|
float vertexID = float(gl_VertexID);
|
|
64
76
|
float radius_ = radius;
|
|
65
|
-
float alpha =
|
|
77
|
+
float alpha = u_opacity;
|
|
66
78
|
if (draw_mode == 1) { // TRIANGLE_FAN
|
|
67
79
|
if (gl_VertexID == 0) {
|
|
68
80
|
radius_ = 0.0;
|
|
@@ -71,16 +83,15 @@ void main() {
|
|
|
71
83
|
vertexID -= 1.0;
|
|
72
84
|
}
|
|
73
85
|
float phase = ( vertexID / (edge_count - 1.0) );
|
|
74
|
-
// v_angle = tail_angle;
|
|
75
86
|
|
|
76
87
|
if ( filling_mode_ == 1.0 ) {
|
|
77
88
|
if ( tail_angle < 0.0 ) {
|
|
78
|
-
v_color = vec4(
|
|
89
|
+
v_color = vec4( _color.rgb , _color.a * ( 1.0 - phase ) * alpha );
|
|
79
90
|
} else {
|
|
80
|
-
v_color = vec4(
|
|
91
|
+
v_color = vec4( _color.rgb , _color.a * phase * alpha );
|
|
81
92
|
}
|
|
82
93
|
} else {
|
|
83
|
-
v_color = vec4(
|
|
94
|
+
v_color = vec4( _color.rgb , _color.a * alpha );
|
|
84
95
|
}
|
|
85
96
|
if ( filling_mode == 0.0 && draw_mode == 1 ) {
|
|
86
97
|
v_color.a /= 2.0;
|
|
@@ -106,16 +117,11 @@ void main() {
|
|
|
106
117
|
}`;
|
|
107
118
|
const fragmentShaderSource = `#version 300 es` + POLE + PI + `
|
|
108
119
|
precision highp float;
|
|
109
|
-
// flat in int vid;
|
|
110
120
|
in vec4 v_color;
|
|
111
121
|
in vec2 v_pos;
|
|
112
|
-
// flat in float v_phase;
|
|
113
|
-
// in float v_angle;
|
|
114
122
|
out vec4 outColor;
|
|
115
123
|
void main() {
|
|
116
|
-
|
|
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; }
|
|
124
|
+
|
|
119
125
|
if ( v_pos.x < -POLE || v_pos.x > POLE || v_pos.y < -POLE || v_pos.y > POLE ) { discard; }
|
|
120
126
|
outColor = v_color;
|
|
121
127
|
}`;
|
|
@@ -129,9 +135,10 @@ export class Logic {
|
|
|
129
135
|
program;
|
|
130
136
|
_edgeCountLocation;
|
|
131
137
|
_draw_modeLocation;
|
|
132
|
-
_plugin_alpha_multiplierLocation;
|
|
133
138
|
cameraBlockBindingPoint;
|
|
134
139
|
cameraBlockTotem; // Type this based on your CameraUniformBlockTotem implementation
|
|
140
|
+
_ubosPublished = [];
|
|
141
|
+
_defaultFlexibleUBO;
|
|
135
142
|
constructor(globe) {
|
|
136
143
|
this.globe = globe;
|
|
137
144
|
this.gl = globe.gl;
|
|
@@ -156,22 +163,21 @@ export class Logic {
|
|
|
156
163
|
{ // Uniforms
|
|
157
164
|
this._edgeCountLocation = gl.getUniformLocation(program, 'edge_count');
|
|
158
165
|
this._draw_modeLocation = gl.getUniformLocation(program, 'draw_mode');
|
|
159
|
-
this._plugin_alpha_multiplierLocation = gl.getUniformLocation(program, 'plugin_alpha_multiplier');
|
|
160
166
|
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
161
167
|
gl.useProgram(program);
|
|
162
168
|
gl.uniform1i(this._draw_modeLocation, this._lastMode);
|
|
163
169
|
gl.uniform1f(this._edgeCountLocation, this._lastEdgeCount);
|
|
164
|
-
gl.uniform1f(this._plugin_alpha_multiplierLocation, 1.0);
|
|
165
170
|
this.cameraBlockBindingPoint = 0;
|
|
166
171
|
this.cameraBlockTotem = globeProgramCache.getProgram(globe, CameraUniformBlockTotem);
|
|
167
172
|
const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
|
|
168
173
|
gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
|
|
174
|
+
flexibleBlockManager.assignBindingPoint(gl, program);
|
|
175
|
+
this._defaultFlexibleUBO = flexibleBlockManager.createUBO(gl);
|
|
169
176
|
gl.useProgram(currentProgram);
|
|
170
177
|
}
|
|
171
178
|
}
|
|
172
|
-
draw(length, vao, edgeCount,
|
|
179
|
+
draw(length, vao, edgeCount, drawMode, ubo = null) {
|
|
173
180
|
const { gl, program, cameraBlockTotem, cameraBlockBindingPoint } = this;
|
|
174
|
-
// gl.disable(gl.DEPTH_TEST);
|
|
175
181
|
gl.useProgram(program);
|
|
176
182
|
if (drawModeMap[drawMode] !== this._lastMode) {
|
|
177
183
|
gl.uniform1i(this._draw_modeLocation, drawModeMap[drawMode]);
|
|
@@ -181,9 +187,11 @@ export class Logic {
|
|
|
181
187
|
gl.uniform1f(this._edgeCountLocation, edgeCount);
|
|
182
188
|
this._lastEdgeCount = edgeCount;
|
|
183
189
|
}
|
|
184
|
-
if (
|
|
185
|
-
|
|
186
|
-
|
|
190
|
+
if (ubo) {
|
|
191
|
+
ubo.bind();
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
this._defaultFlexibleUBO.bind();
|
|
187
195
|
}
|
|
188
196
|
const overdraw = drawModeMap[drawMode];
|
|
189
197
|
cameraBlockTotem.bind(cameraBlockBindingPoint);
|
|
@@ -191,11 +199,18 @@ export class Logic {
|
|
|
191
199
|
gl.drawArraysInstanced(gl[drawMode], 0, edgeCount + overdraw, length);
|
|
192
200
|
cameraBlockTotem.unbind(cameraBlockBindingPoint);
|
|
193
201
|
gl.bindVertexArray(null);
|
|
194
|
-
|
|
202
|
+
if (ubo) {
|
|
203
|
+
ubo.unbind();
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
this._defaultFlexibleUBO.unbind();
|
|
207
|
+
}
|
|
195
208
|
}
|
|
196
209
|
free() {
|
|
197
210
|
noRegisterGlobeProgramCache.releaseProgram(this.globe, CameraUniformBlockTotem);
|
|
198
211
|
this.gl.deleteProgram(this.program);
|
|
212
|
+
this._defaultFlexibleUBO.free();
|
|
213
|
+
this._ubosPublished.forEach(ubo => ubo.free()); // TODO: can be called 2 times. is it a problem?
|
|
199
214
|
this.program = null;
|
|
200
215
|
}
|
|
201
216
|
/**
|
|
@@ -210,74 +225,25 @@ export class Logic {
|
|
|
210
225
|
const { gl } = this;
|
|
211
226
|
const vao = gl.createVertexArray();
|
|
212
227
|
gl.bindVertexArray(vao);
|
|
213
|
-
{
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
{
|
|
221
|
-
|
|
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
|
-
}
|
|
228
|
+
attributeLoader(gl, center2dObj, 0, 2, { divisor: 1 });
|
|
229
|
+
attributeLoader(gl, center3dObj, 1, 3, { divisor: 1 });
|
|
230
|
+
attributeLoader(gl, startAngle2DObj, 2, 1, { divisor: 1 });
|
|
231
|
+
attributeLoader(gl, tailAngle2DObj, 3, 1, { divisor: 1 });
|
|
232
|
+
attributeLoader(gl, startAngle3DObj, 4, 1, { divisor: 1 });
|
|
233
|
+
attributeLoader(gl, tailAngle3DObj, 5, 1, { divisor: 1 });
|
|
234
|
+
attributeLoader(gl, colorObj, 6, 4, { divisor: 1, escapeValues: [-1.0, -1.0, -1.0, -1.0] });
|
|
235
|
+
attributeLoader(gl, radiusObj, 7, 1, { divisor: 1, escapeValues: [-1.0] });
|
|
236
|
+
attributeLoader(gl, colorModeObj, 8, 1, { divisor: 1, escapeValues: [-1.0] });
|
|
276
237
|
gl.bindVertexArray(null);
|
|
277
238
|
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
278
239
|
return vao;
|
|
279
240
|
}
|
|
280
241
|
createUBO() {
|
|
242
|
+
const { gl } = this;
|
|
243
|
+
const bufferReadType = gl.DYNAMIC_DRAW;
|
|
244
|
+
const ubo = flexibleBlockManager.createUBO(gl, "STATIC_DRAW");
|
|
245
|
+
this._ubosPublished.push(ubo);
|
|
246
|
+
return ubo;
|
|
281
247
|
}
|
|
282
248
|
}
|
|
283
249
|
export const PieceOfPieProgramCache = Object.freeze({
|
|
@@ -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;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { globeProgramCache } from "../programcache";
|
|
2
|
-
export const WebGlobeInfoUniformBlockString = `
|
|
3
|
-
layout(std140) uniform WebGlobeInfo {
|
|
4
|
-
vec2 canvas_resolution;
|
|
5
|
-
vec2 mouse_radian_long_lat;
|
|
6
|
-
vec2 mouse_pixel_xy;
|
|
7
|
-
float north_angle;
|
|
8
|
-
float world_tilt;
|
|
9
|
-
float earth_distance;
|
|
10
|
-
};
|
|
2
|
+
export const WebGlobeInfoUniformBlockString = `
|
|
3
|
+
layout(std140) uniform WebGlobeInfo {
|
|
4
|
+
vec2 canvas_resolution;
|
|
5
|
+
vec2 mouse_radian_long_lat;
|
|
6
|
+
vec2 mouse_pixel_xy;
|
|
7
|
+
float north_angle;
|
|
8
|
+
float world_tilt;
|
|
9
|
+
float earth_distance;
|
|
10
|
+
};
|
|
11
11
|
`;
|
|
12
12
|
export default class CanvasWebGlobeInfo {
|
|
13
13
|
id;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export class GlobeChangeObserver {
|
|
2
|
+
globe;
|
|
3
|
+
lastLOD = -1;
|
|
4
|
+
lastGeometry;
|
|
5
|
+
lastWorldWH = { width: 0, height: 0 };
|
|
6
|
+
lastLook = {
|
|
7
|
+
CenterLong: 0,
|
|
8
|
+
CenterLat: 0,
|
|
9
|
+
Distance: 0,
|
|
10
|
+
Tilt: 0,
|
|
11
|
+
NorthAng: 0
|
|
12
|
+
};
|
|
13
|
+
lastElevationCoefficient = NaN;
|
|
14
|
+
changes = {
|
|
15
|
+
geometry: false,
|
|
16
|
+
look: false,
|
|
17
|
+
lod: false,
|
|
18
|
+
lod2DWheel: false,
|
|
19
|
+
elevationScale: false,
|
|
20
|
+
screenMoved: false
|
|
21
|
+
};
|
|
22
|
+
constructor(globe) {
|
|
23
|
+
this.globe = globe;
|
|
24
|
+
this.lastGeometry = globe.api_GetCurrentGeometry();
|
|
25
|
+
this.lastLook = globe.api_GetCurrentLookInfo();
|
|
26
|
+
this.lastLOD = globe.api_GetCurrentLODWithDecimal();
|
|
27
|
+
this.lastWorldWH = globe.api_GetCurrentWorldWH();
|
|
28
|
+
this.lastElevationCoefficient = globe.api_GetZScale();
|
|
29
|
+
}
|
|
30
|
+
checkChanges() {
|
|
31
|
+
const globe = this.globe;
|
|
32
|
+
const currentGeometry = globe.api_GetCurrentGeometry();
|
|
33
|
+
const currentLook = globe.api_GetCurrentLookInfo();
|
|
34
|
+
const currentLOD = globe.api_GetCurrentLODWithDecimal();
|
|
35
|
+
const currentWorldWH = globe.api_GetCurrentWorldWH();
|
|
36
|
+
this.changes.geometry = (this.lastGeometry !== currentGeometry);
|
|
37
|
+
this.changes.look = (this.lastLook.CenterLong !== currentLook.CenterLong ||
|
|
38
|
+
this.lastLook.CenterLat !== currentLook.CenterLat ||
|
|
39
|
+
this.lastLook.Distance !== currentLook.Distance ||
|
|
40
|
+
this.lastLook.Tilt !== currentLook.Tilt ||
|
|
41
|
+
this.lastLook.NorthAng !== currentLook.NorthAng ||
|
|
42
|
+
this.lastWorldWH.width !== currentWorldWH.width ||
|
|
43
|
+
this.lastWorldWH.height !== currentWorldWH.height);
|
|
44
|
+
this.changes.lod = (this.lastLOD !== currentLOD);
|
|
45
|
+
this.changes.lod2DWheel = (!globe.api_IsScreenMoving() && this.changes.lod);
|
|
46
|
+
// Update last known states
|
|
47
|
+
this.lastGeometry = currentGeometry;
|
|
48
|
+
this.lastLook = currentLook;
|
|
49
|
+
this.lastLOD = currentLOD;
|
|
50
|
+
this.lastWorldWH = currentWorldWH;
|
|
51
|
+
this.changes.screenMoved = (this.changes.geometry ||
|
|
52
|
+
this.changes.look ||
|
|
53
|
+
this.changes.lod ||
|
|
54
|
+
this.changes.lod2DWheel);
|
|
55
|
+
}
|
|
56
|
+
getChanges() {
|
|
57
|
+
return this.changes;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -18,7 +18,7 @@ export const flatLinesInputAdapter = (bearingLine) => {
|
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
20
|
export const flatLinesBearingInputAdapter = (bearingLine) => {
|
|
21
|
-
const { long, lat, rgba, key, bearingLat = 0, bearingLong = 0 } = bearingLine;
|
|
21
|
+
const { long, lat, rgba, key, bearingLat = 0, bearingLong = 0, msl } = bearingLine;
|
|
22
22
|
return {
|
|
23
23
|
key: key,
|
|
24
24
|
start: [long, lat],
|
|
@@ -27,7 +27,7 @@ export const flatLinesBearingInputAdapter = (bearingLine) => {
|
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
29
|
export const bearingLineToCircleInputAdapter = (globe) => (bearingLine) => {
|
|
30
|
-
const { long, lat, endLong, endLat, rgba, altitude = 0 } = bearingLine;
|
|
30
|
+
const { long, lat, endLong, endLat, rgba, altitude = 0, msl = null } = bearingLine;
|
|
31
31
|
if (bearingLine.radius === undefined || bearingLine.radius === null) {
|
|
32
32
|
const radius = globe.Math.GetDist2D(long, lat, endLong, endLat);
|
|
33
33
|
bearingLine.radius = radius;
|
|
@@ -38,20 +38,22 @@ export const bearingLineToCircleInputAdapter = (globe) => (bearingLine) => {
|
|
|
38
38
|
radius: bearingLine.radius,
|
|
39
39
|
height: altitude,
|
|
40
40
|
color: rgba,
|
|
41
|
+
msl
|
|
41
42
|
};
|
|
42
43
|
};
|
|
43
44
|
export const bearingLineToArcInputAdapter = (bearingLine) => {
|
|
44
|
-
const { long, lat, endLong, endLat, rgba, altitude = 0 } = bearingLine;
|
|
45
|
+
const { long, lat, endLong, endLat, rgba, altitude = 0, msl } = bearingLine;
|
|
45
46
|
return {
|
|
46
47
|
key: bearingLine.key,
|
|
47
48
|
start: [long, lat],
|
|
48
49
|
end: [endLong, endLat],
|
|
49
50
|
height: altitude,
|
|
50
51
|
color: rgba,
|
|
52
|
+
msl: msl
|
|
51
53
|
};
|
|
52
54
|
};
|
|
53
55
|
export const bearingLineToBearingArcInputAdapter = (globe, bearingLine) => {
|
|
54
|
-
const { long, lat, bearingAngle, rgba, altitude = 0, key } = bearingLine;
|
|
56
|
+
const { long, lat, bearingAngle, rgba, altitude = 0, key, msl } = bearingLine;
|
|
55
57
|
if (bearingLine.radius === undefined || bearingLine.radius === null) {
|
|
56
58
|
throw new Error("Bearing line radius is not defined. Please calculate it before converting to ArcInput.");
|
|
57
59
|
}
|
|
@@ -64,6 +66,7 @@ export const bearingLineToBearingArcInputAdapter = (globe, bearingLine) => {
|
|
|
64
66
|
end: [endLong, endLat],
|
|
65
67
|
height: altitude,
|
|
66
68
|
color: rgba,
|
|
69
|
+
msl,
|
|
67
70
|
};
|
|
68
71
|
};
|
|
69
72
|
export const bearingLineToPieceOfPieInputAdapter = (globe, item) => {
|
|
@@ -71,7 +74,7 @@ export const bearingLineToPieceOfPieInputAdapter = (globe, item) => {
|
|
|
71
74
|
const long = radian(item.long);
|
|
72
75
|
const endLat = radian(item.endLat);
|
|
73
76
|
const endLong = radian(item.endLong);
|
|
74
|
-
const altitude = (item.altitude ?? 0)
|
|
77
|
+
const altitude = (item.altitude ?? 0);
|
|
75
78
|
const radius = item.radius ? item.radius * 0.2 : 10;
|
|
76
79
|
// @ts-ignore
|
|
77
80
|
const { long: bearingLong, lat: bearingLat } = globe.Math.FindPointByPolar(item.long, item.lat, item.radius, item.bearingAngle);
|
|
@@ -32,7 +32,53 @@ export class BearingLinePlugin {
|
|
|
32
32
|
flatStraightLineOn: true // This is a new option to control flat straight line drawing
|
|
33
33
|
};
|
|
34
34
|
_memory = new Map();
|
|
35
|
-
|
|
35
|
+
_semiPluginsOptions = {
|
|
36
|
+
circleOnTerrainOptions: {
|
|
37
|
+
defaultColor: [1, 1, 1, 0.5],
|
|
38
|
+
defaultHeightFromGroundIn3D: 30.0,
|
|
39
|
+
variativeColorsOn: false,
|
|
40
|
+
isMSL: false
|
|
41
|
+
},
|
|
42
|
+
arcOnTerrainOptions: {
|
|
43
|
+
defaultHeightFromGroundIn3D: 30.0,
|
|
44
|
+
variativeColorsOn: false,
|
|
45
|
+
defaultColor: [1, 1, 1, 0.5],
|
|
46
|
+
globeViewOn: true,
|
|
47
|
+
flatViewOn: false,
|
|
48
|
+
isMSL: false
|
|
49
|
+
},
|
|
50
|
+
lineOptions: {
|
|
51
|
+
flatViewOn: true,
|
|
52
|
+
globeViewOn: true,
|
|
53
|
+
variativeColorsOn: false,
|
|
54
|
+
defaultColor: [1, 1, 1, 0.5],
|
|
55
|
+
},
|
|
56
|
+
pieceOfPieOptions: {
|
|
57
|
+
defaultColor: [1, 1, 1, 0.5],
|
|
58
|
+
variativeColorsOn: false,
|
|
59
|
+
defaultHeightFromGroundIn3D: 1000.0,
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
constructor(id, { textWritersMap, textDataPreAdaptor, opacities, drawOptions, circleOnTerrainOptions = {
|
|
63
|
+
defaultColor: [1, 1, 1, 0.5],
|
|
64
|
+
defaultHeightFromGroundIn3D: 30.0,
|
|
65
|
+
variativeColorsOn: false,
|
|
66
|
+
}, arcOnTerrainOptions = {
|
|
67
|
+
globeViewOn: true,
|
|
68
|
+
flatViewOn: false,
|
|
69
|
+
defaultColor: [1, 1, 1, 0.5],
|
|
70
|
+
defaultHeightFromGroundIn3D: 30.0,
|
|
71
|
+
variativeColorsOn: false,
|
|
72
|
+
}, lineOptions = {
|
|
73
|
+
flatViewOn: true,
|
|
74
|
+
globeViewOn: false,
|
|
75
|
+
variativeColorsOn: false,
|
|
76
|
+
defaultColor: [1, 1, 1, 0.5],
|
|
77
|
+
}, pieceOfPieOptions = {
|
|
78
|
+
defaultColor: [1, 1, 1, 0.5],
|
|
79
|
+
variativeColorsOn: false,
|
|
80
|
+
defaultHeightFromGroundIn3D: 1000.0,
|
|
81
|
+
} } = {}) {
|
|
36
82
|
this.id = id;
|
|
37
83
|
if (!(textWritersMap instanceof Map))
|
|
38
84
|
throw new Error("textWritersMap is not an instance of Map");
|
|
@@ -40,28 +86,49 @@ export class BearingLinePlugin {
|
|
|
40
86
|
if (!(v instanceof ContextTextWriter3))
|
|
41
87
|
throw new Error("textWritersMap element is not an instance of ContextTextWriter3");
|
|
42
88
|
});
|
|
89
|
+
if (circleOnTerrainOptions) {
|
|
90
|
+
this._semiPluginsOptions.circleOnTerrainOptions = {
|
|
91
|
+
...this._semiPluginsOptions.circleOnTerrainOptions,
|
|
92
|
+
...circleOnTerrainOptions
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
if (arcOnTerrainOptions) {
|
|
96
|
+
this._semiPluginsOptions.arcOnTerrainOptions = {
|
|
97
|
+
...this._semiPluginsOptions.arcOnTerrainOptions,
|
|
98
|
+
...arcOnTerrainOptions
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (lineOptions) {
|
|
102
|
+
this._semiPluginsOptions.lineOptions = {
|
|
103
|
+
...this._semiPluginsOptions.lineOptions,
|
|
104
|
+
...lineOptions
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
if (pieceOfPieOptions)
|
|
108
|
+
this._semiPluginsOptions.pieceOfPieOptions = {
|
|
109
|
+
...this._semiPluginsOptions.pieceOfPieOptions,
|
|
110
|
+
...pieceOfPieOptions
|
|
111
|
+
};
|
|
43
112
|
this._textWritersMap = textWritersMap || new Map();
|
|
44
113
|
this._textWritersMap.forEach((writer) => writer.setKeyAdaptor((item) => item.key));
|
|
45
114
|
this._textDataPreAdaptor = textDataPreAdaptor || ((item) => item);
|
|
46
|
-
this.circlePlugin = new CircleOnTerrainPlugin(id + "_circle",
|
|
47
|
-
variativeColorsOn: true,
|
|
48
|
-
});
|
|
115
|
+
this.circlePlugin = new CircleOnTerrainPlugin(id + "_circle", this._semiPluginsOptions.circleOnTerrainOptions);
|
|
49
116
|
this.arcPlugin = new ArcOnTerrainPlugin(id + "_arc", {
|
|
50
|
-
|
|
117
|
+
...this._semiPluginsOptions.arcOnTerrainOptions,
|
|
51
118
|
});
|
|
52
119
|
this.arcPluginBL = new ArcOnTerrainPlugin(id + "_arcBL", {
|
|
53
|
-
|
|
120
|
+
...this._semiPluginsOptions.arcOnTerrainOptions,
|
|
54
121
|
});
|
|
55
122
|
this.pieceOfPiePlugin = new PieceOfPiePlugin(id + "_pieceOfPie", {
|
|
56
123
|
bufferType: "DYNAMIC_DRAW",
|
|
124
|
+
...this._semiPluginsOptions.pieceOfPieOptions
|
|
57
125
|
});
|
|
58
126
|
this.linePlugin = new LinePlugin(id + "_line", {
|
|
59
|
-
variativeColorsOn: true,
|
|
60
127
|
bufferType: "DYNAMIC_DRAW",
|
|
128
|
+
...this._semiPluginsOptions.lineOptions
|
|
61
129
|
});
|
|
62
130
|
this.linePluginBL = new LinePlugin(id + "_lineBL", {
|
|
63
|
-
|
|
64
|
-
bufferType: "DYNAMIC_DRAW",
|
|
131
|
+
...this._semiPluginsOptions.lineOptions // flatViewOn: true,
|
|
65
132
|
});
|
|
66
133
|
if (opacities) {
|
|
67
134
|
this._opacities = {
|
|
@@ -76,6 +143,39 @@ export class BearingLinePlugin {
|
|
|
76
143
|
};
|
|
77
144
|
}
|
|
78
145
|
}
|
|
146
|
+
setDefaultSemiPluginColor(semiPluginName, color) {
|
|
147
|
+
if (this._freed) {
|
|
148
|
+
throw new Error("Plugin has been freed, cannot set default semi plugin color.");
|
|
149
|
+
}
|
|
150
|
+
if (!this.globe) {
|
|
151
|
+
throw new Error("Globe is not set, cannot set default semi plugin color.");
|
|
152
|
+
}
|
|
153
|
+
if (semiPluginName === "ALL") {
|
|
154
|
+
this.circlePlugin.setDefaultColor(color);
|
|
155
|
+
this.arcPlugin.setDefaultColor(color);
|
|
156
|
+
this.arcPluginBL.setDefaultColor(color);
|
|
157
|
+
this.linePlugin.setDefaultColor(color);
|
|
158
|
+
this.linePluginBL.setDefaultColor(color);
|
|
159
|
+
this.pieceOfPiePlugin.setDefaultColor(color);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
switch (semiPluginName) {
|
|
163
|
+
case "circleOnTerrain":
|
|
164
|
+
this.circlePlugin.setDefaultColor(color);
|
|
165
|
+
break;
|
|
166
|
+
case "arcOnTerrain":
|
|
167
|
+
this.arcPlugin.setDefaultColor(color);
|
|
168
|
+
break;
|
|
169
|
+
case "line":
|
|
170
|
+
this.linePlugin.setDefaultColor(color);
|
|
171
|
+
break;
|
|
172
|
+
case "pieceOfPie":
|
|
173
|
+
this.pieceOfPiePlugin.setDefaultColor(color);
|
|
174
|
+
break;
|
|
175
|
+
default:
|
|
176
|
+
throw new Error(`Unknown semi plugin name: ${semiPluginName}`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
79
179
|
setDoDrawVRM(drawVRM) {
|
|
80
180
|
if (this._freed) {
|
|
81
181
|
throw new Error("Plugin has been freed, cannot set draw VRM.");
|
|
@@ -116,7 +216,6 @@ export class BearingLinePlugin {
|
|
|
116
216
|
this.drawOptions.drawAngleRing = drawAngleRing;
|
|
117
217
|
this.globe.DrawRender();
|
|
118
218
|
}
|
|
119
|
-
// TODO:
|
|
120
219
|
updatePartial(items, { textWriterIDs } = {}) {
|
|
121
220
|
if (this._freed) {
|
|
122
221
|
throw new Error("Plugin has been freed, cannot update item.");
|
|
@@ -313,11 +412,11 @@ export class BearingLinePlugin {
|
|
|
313
412
|
throw new Error("Circle and Arc plugins are not initialized.");
|
|
314
413
|
}
|
|
315
414
|
if (this.drawOptions.drawVRM) {
|
|
316
|
-
this.circlePlugin.setPluginOpacity(this._opacities.circle ?? this._opacities.general);
|
|
415
|
+
this.circlePlugin.setPluginOpacity(this._opacities.circle ?? this._opacities.general, false);
|
|
317
416
|
this.circlePlugin.draw3D();
|
|
318
417
|
}
|
|
319
418
|
if (this.drawOptions.drawBearingLine) {
|
|
320
|
-
this.arcPluginBL.setPluginOpacity(this._opacities.
|
|
419
|
+
this.arcPluginBL.setPluginOpacity(this._opacities.bearing ?? this._opacities.general, false);
|
|
321
420
|
this.arcPluginBL.draw3D();
|
|
322
421
|
}
|
|
323
422
|
if (this.drawOptions.drawAngleRing) {
|
|
@@ -325,21 +424,19 @@ export class BearingLinePlugin {
|
|
|
325
424
|
const tiltAngle = this.globe.api_GetCurrentLookInfo().Tilt;
|
|
326
425
|
const opacity = pieceOfPieOpacityAdaptor(currentLOD, tiltAngle) * (this._opacities.general ?? 1);
|
|
327
426
|
if (opacity > 0) {
|
|
328
|
-
this.pieceOfPiePlugin.setPluginOpacity(opacity);
|
|
427
|
+
this.pieceOfPiePlugin.setPluginOpacity(opacity, false);
|
|
329
428
|
this.pieceOfPiePlugin.draw3D();
|
|
330
429
|
}
|
|
331
430
|
}
|
|
332
431
|
const currentGeometry = this.globe.api_GetCurrentGeometry();
|
|
333
|
-
this.arcPlugin.setPluginOpacity(this._opacities.arc ?? this._opacities.general);
|
|
432
|
+
this.arcPlugin.setPluginOpacity(this._opacities.arc ?? this._opacities.general, false);
|
|
334
433
|
this.arcPlugin.draw3D();
|
|
335
434
|
if (currentGeometry === 1) {
|
|
336
435
|
this.linePlugin.draw3D();
|
|
337
436
|
this.linePluginBL.draw3D();
|
|
338
437
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
textWriter.draw();
|
|
342
|
-
}
|
|
438
|
+
for (const textWriter of this._textWritersMap.values()) {
|
|
439
|
+
textWriter.draw();
|
|
343
440
|
}
|
|
344
441
|
}
|
|
345
442
|
free() {
|