@pirireis/webglobeplugins 0.8.8 → 0.8.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bearing-line/plugin.js +8 -4
- package/circle-line-chain/plugin.js +17 -13
- package/package.json +1 -1
- package/point-heat-map/point-to-heat-map-flow.js +1 -1
- package/programs/line-on-globe/circle-accurate-3d.js +14 -21
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +11 -18
- package/programs/line-on-globe/naive-accurate-flexible.js +4 -4
- package/rangerings/plugin.js +45 -31
- package/util/geometry/index.js +17 -1
- package/util/shaderfunctions/geometrytransformations.js +64 -5
package/bearing-line/plugin.js
CHANGED
|
@@ -7,7 +7,7 @@ import { mapGetOrThrow } from "../util/check/get";
|
|
|
7
7
|
import { populateFloat32Array } from "../util/jshelpers/data-filler";
|
|
8
8
|
import { ContextTextWriter3 } from '../write-text/context-text3'
|
|
9
9
|
import { constraintFloat, isBoolean } from '../util/check/typecheck';
|
|
10
|
-
|
|
10
|
+
import { normalize } from '../util/geometry';
|
|
11
11
|
import { createBufferAndReadInfo } from '../util/gl-util/buffer/integrate-buffer';
|
|
12
12
|
|
|
13
13
|
export const RINGPARTIAL_DRAW_MODE = Object.freeze({
|
|
@@ -322,6 +322,9 @@ export default class BearingLinePlugin {
|
|
|
322
322
|
this.circle3DProgram = Circle3DCache.get(globe);
|
|
323
323
|
const circleFlatEdgeCount = this.circleFlatEdgeCount
|
|
324
324
|
{
|
|
325
|
+
const sphereCoord = (long, lat) => {
|
|
326
|
+
return normalize(globe.api_GetCartesian3DPoint(long, lat, 0, 0), 6378.137);
|
|
327
|
+
}
|
|
325
328
|
// createBuffers
|
|
326
329
|
const bufferType = "DYNAMIC_DRAW";
|
|
327
330
|
const initialCapacity = this.bufferOrchestrator.capacity;
|
|
@@ -337,7 +340,7 @@ export default class BearingLinePlugin {
|
|
|
337
340
|
}],
|
|
338
341
|
["centerCoords3d", {
|
|
339
342
|
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
340
|
-
'adaptor': (item) =>
|
|
343
|
+
'adaptor': (item) => sphereCoord(item.long, item.lat, 0, 0),
|
|
341
344
|
}],
|
|
342
345
|
["targetCoords2d", {
|
|
343
346
|
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
@@ -345,7 +348,8 @@ export default class BearingLinePlugin {
|
|
|
345
348
|
}],
|
|
346
349
|
["targetCoords3d", {
|
|
347
350
|
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
348
|
-
'adaptor': (item) => new Float32Array(
|
|
351
|
+
'adaptor': (item) => new Float32Array(
|
|
352
|
+
globe.api_GetCartesian3DPoint(item.endLong, item.endLat, 0, 0))
|
|
349
353
|
}],
|
|
350
354
|
["bearingTargetCoords2d", {
|
|
351
355
|
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
@@ -442,7 +446,7 @@ export default class BearingLinePlugin {
|
|
|
442
446
|
...["centerCoords2dflat", "rgbaMercator", "circleDashAngleMercator", "dashOpacityMercator"
|
|
443
447
|
].map(key => vaoOBJ(key)));
|
|
444
448
|
this.circle3DVao = this.circle3DProgram.createVAO(
|
|
445
|
-
...["centerCoords3d", "
|
|
449
|
+
...["centerCoords3d", "targetCoords3d", "rgba", "circleDashAngle", "dashOpacity"
|
|
446
450
|
].map(key => vaoOBJ(key)));
|
|
447
451
|
}
|
|
448
452
|
|
|
@@ -9,7 +9,7 @@ import { populateFloat32Array } from "../util/jshelpers/data-filler";
|
|
|
9
9
|
import { ContextTextWriter3 } from '../write-text/context-text3';
|
|
10
10
|
import { isBoolean, constraintFloat, opacityCheck } from '../util/check/typecheck';
|
|
11
11
|
import { createBufferAndReadInfo } from '../util/gl-util/buffer/integrate-buffer';
|
|
12
|
-
|
|
12
|
+
import { normalize } from '../util/geometry/index';
|
|
13
13
|
/**
|
|
14
14
|
* Insert info to chain list map (nodes and properties)
|
|
15
15
|
*
|
|
@@ -264,6 +264,10 @@ export class CircleLineChainPlugin {
|
|
|
264
264
|
|
|
265
265
|
const _circleFlatEdgeCount = this._circleFlatEdgeCount;
|
|
266
266
|
{
|
|
267
|
+
const sphereCoord = (long, lat) => {
|
|
268
|
+
return normalize(globe.api_GetCartesian3DPoint(long, lat, 0, 0), 6378.137);
|
|
269
|
+
}
|
|
270
|
+
|
|
267
271
|
// createBuffers
|
|
268
272
|
const bufferType = "DYNAMIC_DRAW";
|
|
269
273
|
const initialCapacity = this.bufferOrchestrator.capacity;
|
|
@@ -275,7 +279,7 @@ export class CircleLineChainPlugin {
|
|
|
275
279
|
}],
|
|
276
280
|
["centerCoords3d", {
|
|
277
281
|
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
278
|
-
'adaptor': (item) => new
|
|
282
|
+
'adaptor': (item) => new sphereCoord(item.long, item.lat, 0, 0),
|
|
279
283
|
}],
|
|
280
284
|
["targetCoords2d", {
|
|
281
285
|
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
@@ -283,7 +287,7 @@ export class CircleLineChainPlugin {
|
|
|
283
287
|
}],
|
|
284
288
|
["targetCoords3d", {
|
|
285
289
|
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
286
|
-
'adaptor': (item) =>
|
|
290
|
+
'adaptor': (item) => sphereCoord(item.long, item.lat, 0, 0),
|
|
287
291
|
}],
|
|
288
292
|
["rgba", {
|
|
289
293
|
'bufferManager': new BufferManager(gl, 4, { bufferType, initialCapacity }),
|
|
@@ -292,10 +296,10 @@ export class CircleLineChainPlugin {
|
|
|
292
296
|
return new Float32Array(item.chainProperties.rgba);
|
|
293
297
|
}
|
|
294
298
|
}],
|
|
295
|
-
["bigRadius", {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}],
|
|
299
|
+
// ["bigRadius", {
|
|
300
|
+
// 'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
301
|
+
// 'adaptor': (item) => new Float32Array([item.bigRadius])
|
|
302
|
+
// }],
|
|
299
303
|
["dashRatio", {
|
|
300
304
|
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
301
305
|
'adaptor': (item) => new Float32Array([item.chainProperties.dashRatio])
|
|
@@ -354,7 +358,7 @@ export class CircleLineChainPlugin {
|
|
|
354
358
|
].map(key => obj(key)));
|
|
355
359
|
|
|
356
360
|
this.circle3DVao = this.circle3DProgram.createVAO(
|
|
357
|
-
...["centerCoords3d", "
|
|
361
|
+
...["centerCoords3d", "targetCoords3d", "rgbaCircle", "circleDashAngle", "dashOpacity"
|
|
358
362
|
].map(key => obj(key))
|
|
359
363
|
);
|
|
360
364
|
|
|
@@ -376,7 +380,7 @@ export class CircleLineChainPlugin {
|
|
|
376
380
|
_reconstructChains(chainKeys) {
|
|
377
381
|
const { globe } = this;
|
|
378
382
|
|
|
379
|
-
const radiusM = radiusMethod(globe);
|
|
383
|
+
// const radiusM = radiusMethod(globe);
|
|
380
384
|
const callback = (v, i, array, chainProperties) => {
|
|
381
385
|
if (i === array.length - 1) return null;
|
|
382
386
|
|
|
@@ -384,7 +388,7 @@ export class CircleLineChainPlugin {
|
|
|
384
388
|
|
|
385
389
|
return {
|
|
386
390
|
chainProperties: chainProperties,
|
|
387
|
-
bigRadius: radiusM(v, i, array),
|
|
391
|
+
// bigRadius: radiusM(v, i, array),
|
|
388
392
|
targetLong: array[i + 1].long,
|
|
389
393
|
targetLat: array[i + 1].lat,
|
|
390
394
|
long: v.long,
|
|
@@ -458,7 +462,7 @@ export class CircleLineChainPlugin {
|
|
|
458
462
|
|
|
459
463
|
|
|
460
464
|
|
|
461
|
-
const radiusMethod = (globe) => (v, i, array) => {
|
|
462
|
-
|
|
463
|
-
}
|
|
465
|
+
// const radiusMethod = (globe) => (v, i, array) => {
|
|
466
|
+
// return globe.Math.GetDist3D(v.long, v.lat, array[i + 1].long, array[i + 1].lat)
|
|
467
|
+
// }
|
|
464
468
|
|
package/package.json
CHANGED
|
@@ -67,7 +67,7 @@ class PointHeatmapFlow {
|
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* @param {Float32Array} data
|
|
70
|
-
* @format [x, y, z, height] x,y,z is normalized 3d cartesian coordinates. Height in kilometers. Set
|
|
70
|
+
* @format [x, y, z, height] x,y,z is normalized 3d cartesian coordinates. Height in kilometers. Set 6378.137 for ground level.
|
|
71
71
|
*/
|
|
72
72
|
setData(data) {
|
|
73
73
|
const { gl, buffer } = this;
|
|
@@ -4,11 +4,11 @@ import { noRegisterGlobeProgramCache } from "../programcache";
|
|
|
4
4
|
// import { vaoAttributeLoader } from "../../util/account/util";
|
|
5
5
|
import { attributeLoader } from "../../util/gl-util/buffer/integrate-buffer";
|
|
6
6
|
import {
|
|
7
|
-
|
|
7
|
+
cartesian3DToGLPosition,
|
|
8
8
|
circleLimpFromLongLatRadCenterCartesian3D_accurate,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
circleOnSphere,
|
|
10
|
+
POLE,
|
|
11
|
+
PI
|
|
12
12
|
} from "../../util/shaderfunctions/geometrytransformations";
|
|
13
13
|
|
|
14
14
|
|
|
@@ -21,27 +21,22 @@ import {
|
|
|
21
21
|
* center_position is too small or doenst loaded as expected.
|
|
22
22
|
*/
|
|
23
23
|
const EDGE_COUNT_ON_SPHERE = 360;
|
|
24
|
-
|
|
24
|
+
//${circleLimpFromLongLatRadCenterCartesian3D_accurate}
|
|
25
25
|
const vertexShaderSource = `#version 300 es
|
|
26
26
|
precision highp float;
|
|
27
|
+
${PI}
|
|
27
28
|
${CameraUniformBlockString}
|
|
28
|
-
${longLatRadToMercator}
|
|
29
|
-
${longLatRadToCartesian3D}
|
|
30
29
|
${cartesian3DToGLPosition}
|
|
31
|
-
${
|
|
32
|
-
${realDistanceOnSphereR1}
|
|
33
|
-
${circleLimpFromLongLatRadCenterCartesian3D_accurate}
|
|
34
|
-
${circleLimpFromLongLatRadCenterMercatorCompass_accurate}
|
|
35
|
-
${circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate}
|
|
30
|
+
${circleOnSphere}
|
|
36
31
|
|
|
37
32
|
uniform float edge_count;
|
|
38
33
|
|
|
39
34
|
in vec3 center_position3d;
|
|
40
|
-
in
|
|
35
|
+
in vec3 target_position3d;
|
|
36
|
+
// in float radius;
|
|
41
37
|
in vec4 color;
|
|
42
38
|
in float dash_ratio;
|
|
43
39
|
in float dash_opacity;
|
|
44
|
-
in float initial_angle;
|
|
45
40
|
|
|
46
41
|
out float interpolation;
|
|
47
42
|
out vec4 v_color;
|
|
@@ -51,7 +46,7 @@ void main() {
|
|
|
51
46
|
interpolation = float( gl_VertexID ) / ${EDGE_COUNT_ON_SPHERE}.0;
|
|
52
47
|
if ( is3D ) {
|
|
53
48
|
float angle = PI * 2.0 * interpolation;
|
|
54
|
-
vec3 position =
|
|
49
|
+
vec3 position = circleOnSphere(center_position3d, target_position3d, angle);
|
|
55
50
|
gl_Position = cartesian3DToGLPosition(position);
|
|
56
51
|
} else {
|
|
57
52
|
return;
|
|
@@ -107,11 +102,10 @@ class Logic {
|
|
|
107
102
|
|
|
108
103
|
{ // assign attribute locations
|
|
109
104
|
gl.bindAttribLocation(program, 0, "center_position3d");
|
|
110
|
-
gl.bindAttribLocation(program, 1, "
|
|
105
|
+
gl.bindAttribLocation(program, 1, "target_position3d");
|
|
111
106
|
gl.bindAttribLocation(program, 2, "color");
|
|
112
107
|
gl.bindAttribLocation(program, 3, "dash_ratio");
|
|
113
108
|
gl.bindAttribLocation(program, 4, "dash_opacity");
|
|
114
|
-
gl.bindAttribLocation(program, 5, "initial_angle");
|
|
115
109
|
}
|
|
116
110
|
|
|
117
111
|
this.cameraBindingPoint = 0;
|
|
@@ -120,7 +114,7 @@ class Logic {
|
|
|
120
114
|
gl.uniformBlockBinding(program, cameraBlockLocation, this.cameraBindingPoint);
|
|
121
115
|
}
|
|
122
116
|
|
|
123
|
-
createVAO(center3dObj,
|
|
117
|
+
createVAO(center3dObj, target3dObj, colorObj, dashRatioObj, dashOpacityObj) {
|
|
124
118
|
const { gl } = this;
|
|
125
119
|
const vao = gl.createVertexArray();
|
|
126
120
|
const divisor = 1;
|
|
@@ -128,12 +122,11 @@ class Logic {
|
|
|
128
122
|
gl.bindVertexArray(vao);
|
|
129
123
|
|
|
130
124
|
attributeLoader(gl, center3dObj, 0, 3, { divisor });
|
|
131
|
-
attributeLoader(gl,
|
|
125
|
+
attributeLoader(gl, target3dObj, 1, 3, { divisor });
|
|
126
|
+
// attributeLoader(gl, radiusObj, 1, 1, { divisor });
|
|
132
127
|
attributeLoader(gl, colorObj, 2, 4, { divisor });
|
|
133
128
|
attributeLoader(gl, dashRatioObj, 3, 1, { divisor });
|
|
134
129
|
attributeLoader(gl, dashOpacityObj, 4, 1, { divisor });
|
|
135
|
-
attributeLoader(gl, initialAngleObj, 5, 1, { divisor, escapeValues: [0] });
|
|
136
|
-
|
|
137
130
|
|
|
138
131
|
gl.bindVertexArray(null);
|
|
139
132
|
gl.bindVertexArray(null);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createProgram } from "../../util/webglobjectbuilders";
|
|
2
2
|
import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totems/camerauniformblock";
|
|
3
3
|
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
4
|
-
import { vaoAttributeLoader } from "../../util/account/util";
|
|
4
|
+
// import { vaoAttributeLoader } from "../../util/account/util";
|
|
5
|
+
import { attributeLoader } from "../../util/gl-util/buffer/integrate-buffer";
|
|
5
6
|
import { Z_ALPHA_MODE } from "./util";
|
|
6
7
|
import {
|
|
7
8
|
cartesian3DToGLPosition,
|
|
@@ -127,24 +128,16 @@ class Logic {
|
|
|
127
128
|
const vao = gl.createVertexArray();
|
|
128
129
|
const divisor = 1;
|
|
129
130
|
gl.bindVertexArray(vao);
|
|
130
|
-
{ // make this a function end import from account module.
|
|
131
|
-
const { buffer, stride = 0, offset = 0 } = center3dObj;
|
|
132
|
-
vaoAttributeLoader(gl, buffer, 0, 3, stride, offset, divisor);
|
|
133
|
-
}
|
|
134
|
-
{
|
|
135
|
-
const { buffer, stride = 0, offset = 0 } = bigRadiusObj;
|
|
136
|
-
vaoAttributeLoader(gl, buffer, 1, 1, stride, offset, divisor);
|
|
137
|
-
}
|
|
138
|
-
{
|
|
139
|
-
const { buffer, stride = 0, offset = 0 } = smallRadiusObj;
|
|
140
|
-
vaoAttributeLoader(gl, buffer, 2, 1, stride, offset, divisor);
|
|
141
|
-
}
|
|
142
|
-
{
|
|
143
|
-
const { buffer, stride = 0, offset = 0 } = colorObj;
|
|
144
|
-
vaoAttributeLoader(gl, buffer, 3, 4, stride, offset, divisor);
|
|
145
|
-
}
|
|
146
131
|
|
|
147
|
-
|
|
132
|
+
|
|
133
|
+
attributeLoader(gl, center3dObj, 0, 3, { divisor });
|
|
134
|
+
|
|
135
|
+
attributeLoader(gl, bigRadiusObj, 1, 1, { divisor });
|
|
136
|
+
|
|
137
|
+
attributeLoader(gl, smallRadiusObj, 2, 1, { divisor });
|
|
138
|
+
|
|
139
|
+
attributeLoader(gl, colorObj, 3, 4, { divisor });
|
|
140
|
+
|
|
148
141
|
gl.bindVertexArray(null);
|
|
149
142
|
return vao;
|
|
150
143
|
}
|
|
@@ -193,8 +193,8 @@ class Logic {
|
|
|
193
193
|
|
|
194
194
|
|
|
195
195
|
createVAO(
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
startPotision2DBufferObj, startPotision3DBufferObj,
|
|
197
|
+
endPosition2DBufferObj, endPosition3DBufferObj,
|
|
198
198
|
dashRatioBufferObj,
|
|
199
199
|
dashOpacityBufferObj,
|
|
200
200
|
colorBufferObj) {
|
|
@@ -205,9 +205,9 @@ class Logic {
|
|
|
205
205
|
|
|
206
206
|
const divisor = 1;
|
|
207
207
|
|
|
208
|
-
attributeLoader(gl,
|
|
208
|
+
attributeLoader(gl, startPotision2DBufferObj, 0, 2, { divisor });
|
|
209
209
|
attributeLoader(gl, startPotision3DBufferObj, 1, 3, { divisor });
|
|
210
|
-
attributeLoader(gl,
|
|
210
|
+
attributeLoader(gl, endPosition2DBufferObj, 2, 2, { divisor });
|
|
211
211
|
attributeLoader(gl, endPosition3DBufferObj, 3, 3, { divisor });
|
|
212
212
|
attributeLoader(gl, dashRatioBufferObj, 4, 1, { divisor, escapeValues: [escapeValue] });
|
|
213
213
|
attributeLoader(gl, dashOpacityBufferObj, 5, 1, { divisor, escapeValues: [escapeValue] });
|
package/rangerings/plugin.js
CHANGED
|
@@ -57,11 +57,14 @@ import RangeRingAngleText from "./rangeringangletext";
|
|
|
57
57
|
import { Z_ALPHA_MODE } from "../programs/line-on-globe/util";
|
|
58
58
|
import { ENUM_HIDE } from "./enum";
|
|
59
59
|
import { opacityCheck, constraintFloat } from "../util/check/typecheck";
|
|
60
|
+
import { normalize } from "../util/geometry"
|
|
60
61
|
const CIRCLE_FLAT_EDGE_COUNT = 362; // 360 + 2 for closing the circle and a cutting point
|
|
61
62
|
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
const coordOnSphere = (long, lat, globe) => {
|
|
65
|
+
const coord = globe.api_GetCartesian3DPoint(long, lat, 0, 0);
|
|
66
|
+
return normalize(coord, 6378.137);
|
|
67
|
+
}
|
|
65
68
|
|
|
66
69
|
class RangeRings {
|
|
67
70
|
constructor(id,
|
|
@@ -106,9 +109,9 @@ class RangeRings {
|
|
|
106
109
|
} = this;
|
|
107
110
|
for (const { centerID } of items) {
|
|
108
111
|
const datas = this.__reconstructCentralRings(centerID);
|
|
109
|
-
bufferOrchestrator.updateBulk(datas, bufferManagersCompMap, ["centerCoords3d", "centerCoords2dflat", "centerCoords2dflatForPadding"]);
|
|
112
|
+
bufferOrchestrator.updateBulk(datas, bufferManagersCompMap, ["centerCoords3d", "centerCoords2dflat", "targetCoords3d", "centerCoords2dflatForPadding"]);
|
|
110
113
|
const paddingDatas = this.__reconstructCentralRingsBigPaddings(centerID);
|
|
111
|
-
paddingBufferOrchestrator.updateBulk(paddingDatas, bufferManagersCompMapPadding, ["
|
|
114
|
+
paddingBufferOrchestrator.updateBulk(paddingDatas, bufferManagersCompMapPadding, ["circlePoint2d", "paddingPoint2d", "circlePoint3d", "paddingPoint3d"]);
|
|
112
115
|
}
|
|
113
116
|
this.paddingTextPlugin?.updateCentersXY(items);
|
|
114
117
|
|
|
@@ -144,7 +147,7 @@ class RangeRings {
|
|
|
144
147
|
for (const item of items) {
|
|
145
148
|
_ringAccount.insertCenter(item);
|
|
146
149
|
const datas = this.__reconstructCentralRings(item.centerID);
|
|
147
|
-
bufferOrchestrator.insertBulk(datas, bufferManagersCompMap
|
|
150
|
+
bufferOrchestrator.insertBulk(datas, bufferManagersCompMap);
|
|
148
151
|
const paddingDatas = this.__reconstructCentralRingsBigPaddings(item.centerID);
|
|
149
152
|
paddingBufferOrchestrator.insertBulk(paddingDatas, bufferManagersCompMapPadding);
|
|
150
153
|
}
|
|
@@ -309,7 +312,7 @@ class RangeRings {
|
|
|
309
312
|
this._circleProgram3D = CircleCache3D.get(globe);
|
|
310
313
|
this._padding2dProgram = LinesColorInstancedFlatCache.get(globe);
|
|
311
314
|
this._padding3dProgram = CirclePadding3DCache.get(globe);
|
|
312
|
-
this.
|
|
315
|
+
this._lineOnGlobe_bigPadding = LineOnGlobeCache.get(globe);
|
|
313
316
|
|
|
314
317
|
}
|
|
315
318
|
|
|
@@ -329,6 +332,11 @@ class RangeRings {
|
|
|
329
332
|
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
330
333
|
'adaptor': (item) => new Float32Array(item.centerCoords3d),
|
|
331
334
|
}],
|
|
335
|
+
["targetCoords3d", {
|
|
336
|
+
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
337
|
+
'adaptor': (item) => new Float32Array(item.targetCoords3d),
|
|
338
|
+
}],
|
|
339
|
+
|
|
332
340
|
["rgba", {
|
|
333
341
|
'bufferManager': new BufferManager(gl, 4, { bufferType, initialCapacity }),
|
|
334
342
|
'adaptor': (item) => new Float32Array(item.hide === ENUM_HIDE.HIDE ? [0, 0, 0, 0] : item.rgba)
|
|
@@ -385,8 +393,9 @@ class RangeRings {
|
|
|
385
393
|
this._circle2DVao = this._circleProgram2D.createVAO(
|
|
386
394
|
...["centerCoords2dflat", "rgbaMercator", "circleDashAngleMercator", "dashOpacityMercator"].map(key => obj(this.bufferManagersCompMap.get(key)))
|
|
387
395
|
);
|
|
396
|
+
|
|
388
397
|
this._circle3DVao = this._circleProgram3D.createVAO(
|
|
389
|
-
...["centerCoords3d", "
|
|
398
|
+
...["centerCoords3d", "targetCoords3d", "rgba", "circleDashAngle", "dashOpacity"].map(key => obj(this.bufferManagersCompMap.get(key)))
|
|
390
399
|
);
|
|
391
400
|
|
|
392
401
|
this._oneDegree2DPaddingVao = this._padding2dProgram.createVAO(
|
|
@@ -400,13 +409,13 @@ class RangeRings {
|
|
|
400
409
|
this.paddingBufferOrchestrator = new BufferOrchestrator({ capacity: initialCapacity });
|
|
401
410
|
this.bufferManagersCompMapPadding = new Map(
|
|
402
411
|
[
|
|
403
|
-
["
|
|
412
|
+
["circlePoint2d", {
|
|
404
413
|
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
405
|
-
'adaptor': (item) => item.
|
|
414
|
+
'adaptor': (item) => item.circlePoint2d,
|
|
406
415
|
}],
|
|
407
|
-
["
|
|
416
|
+
["paddingPoint2d", {
|
|
408
417
|
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
409
|
-
'adaptor': (item) => item.
|
|
418
|
+
'adaptor': (item) => item.paddingPoint2d,
|
|
410
419
|
}],
|
|
411
420
|
["circlePoint3d", {
|
|
412
421
|
'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
@@ -421,19 +430,19 @@ class RangeRings {
|
|
|
421
430
|
'adaptor': (item) => new Float32Array(item.rgba)
|
|
422
431
|
}],
|
|
423
432
|
|
|
424
|
-
["dashOpacity", {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
}],
|
|
428
|
-
["dashRatio", {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
}],
|
|
433
|
+
// ["dashOpacity", {
|
|
434
|
+
// 'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
435
|
+
// 'adaptor': (item) => new Float32Array([1]),
|
|
436
|
+
// }],
|
|
437
|
+
// ["dashRatio", {
|
|
438
|
+
// 'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
439
|
+
// 'adaptor': (item) => new Float32Array([1]),
|
|
440
|
+
// }],
|
|
432
441
|
]
|
|
433
442
|
);
|
|
434
443
|
|
|
435
|
-
this._bigPadding3dFlatVAO = this.
|
|
436
|
-
...["
|
|
444
|
+
this._bigPadding3dFlatVAO = this._lineOnGlobe_bigPadding.createVAO(//"dashRatio", "dashOpacity"
|
|
445
|
+
...["circlePoint2d", "circlePoint3d", "paddingPoint2d", "paddingPoint3d", null, null, "rgba",].map(key =>
|
|
437
446
|
(key === null) ? null : obj(this.bufferManagersCompMapPadding.get(key)))
|
|
438
447
|
);
|
|
439
448
|
|
|
@@ -441,8 +450,11 @@ class RangeRings {
|
|
|
441
450
|
...["centerCoords3d", "radius3d", "radius3dsmall", "rgba"].map(key => obj(this.bufferManagersCompMap.get(key)))
|
|
442
451
|
);
|
|
443
452
|
|
|
453
|
+
|
|
454
|
+
|
|
444
455
|
}
|
|
445
456
|
|
|
457
|
+
// IMPLICIT METHODS
|
|
446
458
|
|
|
447
459
|
__reconstructCentralRingsBigPaddings(centerID) {
|
|
448
460
|
const { globe } = this;
|
|
@@ -458,10 +470,10 @@ class RangeRings {
|
|
|
458
470
|
const paddingPoint = globe.Math.FindPointByPolar(long, lat, radius - padding, azimuthAngle); // long lat
|
|
459
471
|
result.push({
|
|
460
472
|
key: ringBigPaddingKeyMethod(centerID, ringID, azimuthAngle),
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
circlePoint3d:
|
|
464
|
-
paddingPoint3d:
|
|
473
|
+
circlePoint2d: new Float32Array(globe.api_GetMercator2DPoint(circlePoint.long, circlePoint.lat)),
|
|
474
|
+
paddingPoint2d: new Float32Array(globe.api_GetMercator2DPoint(paddingPoint.long, paddingPoint.lat)),
|
|
475
|
+
circlePoint3d: coordOnSphere(circlePoint.long, circlePoint.lat, globe),
|
|
476
|
+
paddingPoint3d: coordOnSphere(paddingPoint.long, paddingPoint.lat, globe),
|
|
465
477
|
rgba: color,
|
|
466
478
|
hide,
|
|
467
479
|
textHide
|
|
@@ -473,7 +485,6 @@ class RangeRings {
|
|
|
473
485
|
return result;
|
|
474
486
|
}
|
|
475
487
|
|
|
476
|
-
// IMPLICIT METHODS
|
|
477
488
|
|
|
478
489
|
__reconstructCentralRings(centerID) {
|
|
479
490
|
const { globe } = this;
|
|
@@ -481,7 +492,7 @@ class RangeRings {
|
|
|
481
492
|
if (centerItem === undefined) throw new Error("Center not found");
|
|
482
493
|
|
|
483
494
|
const { long, lat, rgba, rings, hide = 0, textHide = 0 } = centerItem;
|
|
484
|
-
const centerCoords3d =
|
|
495
|
+
const centerCoords3d = coordOnSphere(long, lat, globe);
|
|
485
496
|
|
|
486
497
|
const result = [];
|
|
487
498
|
|
|
@@ -489,10 +500,13 @@ class RangeRings {
|
|
|
489
500
|
const key = __identity__;
|
|
490
501
|
const centerCoords2dflat = centerCoords2dflatDataCreatorWithRadius(globe, long, lat, radius, { edgeCount: CIRCLE_FLAT_EDGE_COUNT });
|
|
491
502
|
const radiusPadding = hide === ENUM_HIDE.HIDE_1_DEGREE_PADDINGS ? radius : radius - padding / 3;
|
|
503
|
+
const targetPoint = globe.Math.FindPointByPolar(long, lat, radius, 0); // long lat
|
|
504
|
+
const targetCoords3d = coordOnSphere(targetPoint.long, targetPoint.lat, globe);
|
|
492
505
|
const centerCoords2dflatForPadding = centerCoords2dflatDataCreatorWithRadius(globe, long, lat, radiusPadding, { edgeCount: CIRCLE_FLAT_EDGE_COUNT });
|
|
493
506
|
result.push({
|
|
494
507
|
key,
|
|
495
508
|
centerCoords3d,
|
|
509
|
+
targetCoords3d,
|
|
496
510
|
centerCoords2dflat,
|
|
497
511
|
radius,
|
|
498
512
|
padding,
|
|
@@ -562,7 +576,7 @@ class RangeRings {
|
|
|
562
576
|
draw3D() {
|
|
563
577
|
const {
|
|
564
578
|
globe, gl,
|
|
565
|
-
_circleProgram2D, _circleProgram3D, _padding2dProgram, _padding3dProgram,
|
|
579
|
+
_circleProgram2D, _circleProgram3D, _padding2dProgram, _padding3dProgram, _lineOnGlobe_bigPadding,
|
|
566
580
|
_circle2DVao, _circle3DVao, _oneDegree2DPaddingVao, _padding3dOneDegreeVao, _bigPadding3dFlatVAO,
|
|
567
581
|
bufferOrchestrator, paddingBufferOrchestrator,
|
|
568
582
|
_opacity, _oneDegreePadding, _zAlphaOnDegreePadding } = this;
|
|
@@ -577,8 +591,8 @@ class RangeRings {
|
|
|
577
591
|
// _padding2dProgram.draw(bigPaddingVAO, paddingBufferOrchestrator.length, _opacity);
|
|
578
592
|
if (_oneDegreePadding) _padding2dProgram.draw(_oneDegree2DPaddingVao, bufferOrchestrator.length * CIRCLE_FLAT_EDGE_COUNT, _opacity, _zAlphaOnDegreePadding);
|
|
579
593
|
}
|
|
580
|
-
const drawOptions = { drawRange: { first: 0, count:
|
|
581
|
-
|
|
594
|
+
const drawOptions = { drawRange: { first: 0, count: paddingBufferOrchestrator.length } };
|
|
595
|
+
_lineOnGlobe_bigPadding.draw(_bigPadding3dFlatVAO, drawOptions, _opacity);
|
|
582
596
|
this._textWritersMap.forEach((textWriter) => textWriter.draw());
|
|
583
597
|
gl.enable(gl.DEPTH_TEST);
|
|
584
598
|
}
|
|
@@ -604,7 +618,7 @@ class RangeRings {
|
|
|
604
618
|
this._circleProgram3D = null;
|
|
605
619
|
this._padding2dProgram = null;
|
|
606
620
|
this._padding3dProgram = null;
|
|
607
|
-
this.
|
|
621
|
+
this._lineOnGlobe_bigPadding = null;
|
|
608
622
|
this.paddingTextPlugin?.free();
|
|
609
623
|
this._isFreed = true;
|
|
610
624
|
}
|
package/util/geometry/index.js
CHANGED
|
@@ -26,4 +26,20 @@ export function latLongBboxtoPixelXYBbox(minX, minY, maxX, maxY) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param {Float32List} array
|
|
32
|
+
* @returns {Float32Array}
|
|
33
|
+
*/
|
|
34
|
+
export function normalize(array, newLength = 1) {
|
|
35
|
+
let total = 0;
|
|
36
|
+
for (let i = 0; i < array.length; i++) {
|
|
37
|
+
total += array[i] * array[i];
|
|
38
|
+
}
|
|
39
|
+
const len = newLength / Math.sqrt(total);
|
|
40
|
+
const result = new Float32Array(array.length);
|
|
41
|
+
for (let i = 0; i < array.length; i++) {
|
|
42
|
+
result[i] = array[i] * len;
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
@@ -245,10 +245,10 @@ vec3 pointsOnSphereBetween(vec3 a, vec3 b, float ratio) {
|
|
|
245
245
|
b = normalize(b);
|
|
246
246
|
|
|
247
247
|
// Compute the dot product and clamp it to avoid numerical issues
|
|
248
|
-
float dotProduct = clamp(dot(a, b), -1.0, 1.0);
|
|
248
|
+
// float dotProduct = clamp(dot(a, b), -1.0, 1.0);
|
|
249
249
|
|
|
250
250
|
// Compute the angle between the points
|
|
251
|
-
float theta = acos(
|
|
251
|
+
float theta = acos(dot(a, b));
|
|
252
252
|
|
|
253
253
|
// Handle the edge case where the points are nearly identical
|
|
254
254
|
if (theta < 0.0001) {
|
|
@@ -284,7 +284,66 @@ vec3 circleLimpFromLongLatRadCenterCartesian3D_accurate( vec3 geoW, float radius
|
|
|
284
284
|
tangent1 = cos(angle) * tangent1 - sin(angle) * cross(normal, tangent1);
|
|
285
285
|
float radius_in_angle = radius/R;
|
|
286
286
|
float projected_radius = sin(radius_in_angle) * R / 1000.0;
|
|
287
|
-
return (geoW * cos(radius_in_angle))+ tangent1 * projected_radius;
|
|
287
|
+
return (geoW * cos(radius_in_angle)) + tangent1 * projected_radius;
|
|
288
|
+
}`;
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
const circleOnSphere = `
|
|
292
|
+
vec3 rotateVectorAroundAxis(vec3 v, vec3 axis, float angle) {
|
|
293
|
+
float c = cos(angle);
|
|
294
|
+
float s = sin(angle);
|
|
295
|
+
float t = 1.0 - c;
|
|
296
|
+
vec3 normalizedAxis = normalize(axis); // Ensure axis is unit length
|
|
297
|
+
|
|
298
|
+
return vec3(
|
|
299
|
+
(t * normalizedAxis.x * normalizedAxis.x + c) * v.x +
|
|
300
|
+
(t * normalizedAxis.x * normalizedAxis.y - s * normalizedAxis.z) * v.y +
|
|
301
|
+
(t * normalizedAxis.x * normalizedAxis.z + s * normalizedAxis.y) * v.z,
|
|
302
|
+
|
|
303
|
+
(t * normalizedAxis.x * normalizedAxis.y + s * normalizedAxis.z) * v.x +
|
|
304
|
+
(t * normalizedAxis.y * normalizedAxis.y + c) * v.y +
|
|
305
|
+
(t * normalizedAxis.y * normalizedAxis.z - s * normalizedAxis.x) * v.z,
|
|
306
|
+
|
|
307
|
+
(t * normalizedAxis.x * normalizedAxis.z - s * normalizedAxis.y) * v.x +
|
|
308
|
+
(t * normalizedAxis.y * normalizedAxis.z + s * normalizedAxis.x) * v.y +
|
|
309
|
+
(t * normalizedAxis.z * normalizedAxis.z + c) * v.z
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
// Alternative, more compact way using cross and dot products:
|
|
313
|
+
// vec3 crossProd = cross(normalizedAxis, v);
|
|
314
|
+
// float dotProd = dot(normalizedAxis, v);
|
|
315
|
+
// return v * c + crossProd * s + normalizedAxis * dotProd * t;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* @brief Calculates a point on a circle drawn on the surface of a sphere.
|
|
320
|
+
* The sphere is assumed to be centered at the origin (0,0,0).
|
|
321
|
+
* The circle's center on the sphere surface is M, and H is a starting point on the circle.
|
|
322
|
+
* The function returns the point obtained by rotating H around the axis defined by M by angle A.
|
|
323
|
+
*
|
|
324
|
+
* @param M The center point of the circle on the sphere's surface. The vector from the origin to M defines the rotation axis.
|
|
325
|
+
* @param H A starting point on the circle (also on the sphere's surface).
|
|
326
|
+
* @param A The angle of rotation in radians. Use radians(degrees) if your input is in degrees.
|
|
327
|
+
* @return A vec3 representing the calculated point on the sphere's surface.
|
|
328
|
+
*/
|
|
329
|
+
vec3 circleOnSphere(vec3 M, vec3 H, float A) {
|
|
330
|
+
// The rotation axis is the vector from the origin to the circle's center point M on the sphere.
|
|
331
|
+
// This axis vector needs to be normalized for the rotation formula.
|
|
332
|
+
vec3 rotationAxis = normalize(M);
|
|
333
|
+
|
|
334
|
+
// Rotate the starting point H around the rotation axis by angle A.
|
|
335
|
+
vec3 rotatedPoint = rotateVectorAroundAxis(H, rotationAxis, A);
|
|
336
|
+
|
|
337
|
+
// Optional but recommended: Re-normalize the result to ensure it stays exactly on the sphere's surface,
|
|
338
|
+
// counteracting potential floating-point inaccuracies, especially if the original sphere radius was 1.
|
|
339
|
+
// If the sphere has a different radius R, you might want to normalize and multiply by R:
|
|
340
|
+
// float radius = length(M); // Assuming M is exactly on the surface
|
|
341
|
+
// return normalize(rotatedPoint) * radius;
|
|
342
|
+
// If it's a unit sphere:
|
|
343
|
+
// return normalize(rotatedPoint);
|
|
344
|
+
|
|
345
|
+
// For simplicity, returning the direct result of rotation. Assume M and H were perfectly on the sphere.
|
|
346
|
+
return rotatedPoint;
|
|
288
347
|
}`;
|
|
289
348
|
|
|
290
349
|
const circleLimpFromLongLatRadCenterMercatorCompass_accurate = `
|
|
@@ -324,6 +383,6 @@ export {
|
|
|
324
383
|
slerp,
|
|
325
384
|
circleLimpFromLongLatRadCenterCartesian3D_accurate,
|
|
326
385
|
circleLimpFromLongLatRadCenterMercatorCompass_accurate,
|
|
327
|
-
circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate
|
|
328
|
-
|
|
386
|
+
circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate,
|
|
387
|
+
circleOnSphere,
|
|
329
388
|
}
|