@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
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// TODO: REMOVE
|
|
3
|
+
// // import { Vector3D, Quaternion, Plane, Ray, Matrix4 } from 'your-3d-math-library'; // <-- ADAPT THIS IMPORT
|
|
4
|
+
// import { Vector3D } from '../vector3d';
|
|
5
|
+
// import { Plane } from '../plane';
|
|
6
|
+
// import { Line } from '../line';
|
|
7
|
+
// import { Matrix4 } from '../matrix4';
|
|
8
|
+
// import { Quaternion } from '../quaternion';
|
|
9
|
+
// // --- Assume these static helper variables exist within your class ---
|
|
10
|
+
// const _lookFromOrigin = new Vector3D();
|
|
11
|
+
// const _cameraPosition = new Vector3D();
|
|
12
|
+
// const _finalForward = new Vector3D();
|
|
13
|
+
// const _approxUp = new Vector3D();
|
|
14
|
+
// const _finalRight = new Vector3D();
|
|
15
|
+
// const _finalUp = new Vector3D();
|
|
16
|
+
// const _tempVec = new Vector3D(); // General purpose helper
|
|
17
|
+
// const _initialBottomRayDir = new Vector3D();
|
|
18
|
+
// const _qOrient = new Quaternion();
|
|
19
|
+
// const _rollQuaternion = new Quaternion();
|
|
20
|
+
// const _rotationMatrix = new Matrix4();
|
|
21
|
+
// const _fieldOfViewBottomRay = new Line(new Vector3D(), new Vector3D());
|
|
22
|
+
// const _origin3d = new Vector3D(0, 0, 0); // Globe Center
|
|
23
|
+
// // --- Assume these constants exist ---
|
|
24
|
+
// const WORLD_RADIUS_3D = 6371000; // Example: Earth radius
|
|
25
|
+
// const FIELD_OF_VIEW = (25 * Math.PI) / 180; // Example: 25 degrees half-FOV in radians
|
|
26
|
+
// // // --- Assume Plane class has these methods ---
|
|
27
|
+
// // interface Plane {
|
|
28
|
+
// // setFromNormalAndPoint(normal: Vector3D, point: Vector3D): this;
|
|
29
|
+
// // set(normal: Vector3D, constant: number): this;
|
|
30
|
+
// // // ... other plane methods
|
|
31
|
+
// // }
|
|
32
|
+
// // // --- Assume Ray class has these methods ---
|
|
33
|
+
// // interface Ray {
|
|
34
|
+
// // origin: Vector3D;
|
|
35
|
+
// // direction: Vector3D;
|
|
36
|
+
// // intersectionSphere(center: Vector3D, radius: number): Vector3D[] | null; // Or similar
|
|
37
|
+
// // // ... other ray methods
|
|
38
|
+
// // }
|
|
39
|
+
// // // --- Assume Vector3D has setFromLongLat ---
|
|
40
|
+
// // interface Vector3D {
|
|
41
|
+
// // setFromLongLat(lon: number, lat: number): this;
|
|
42
|
+
// // // ... other vector methods
|
|
43
|
+
// // }
|
|
44
|
+
// // // --- END OF ASSUMPTIONS ---
|
|
45
|
+
// /**
|
|
46
|
+
// * Calculates a culling plane representing the bottom edge of the camera's field of view.
|
|
47
|
+
// * @param globe - The globe object, expected to have api_GetCurrentLookInfo and Fp properties.
|
|
48
|
+
// * @param out - The Plane object to store the result.
|
|
49
|
+
// * @param fieldOfView - The vertical half-angle of the field of view in radians.
|
|
50
|
+
// * @returns The calculated Plane.
|
|
51
|
+
// */
|
|
52
|
+
// function calculateHorizonPlane(globe: any, out: Plane, fieldOfView: number = FIELD_OF_VIEW): Plane {
|
|
53
|
+
// const cameraLookInfo = globe.api_GetCurrentLookInfo();
|
|
54
|
+
// cameraLookInfo.CenterLong *= Math.PI / 180;
|
|
55
|
+
// cameraLookInfo.CenterLat *= Math.PI / 180;
|
|
56
|
+
// // cameraLookInfo.Tilt *= Math.PI / 180; // Tilt is now implicitly handled
|
|
57
|
+
// cameraLookInfo.NorthAng *= Math.PI / 180;
|
|
58
|
+
// // Set _lookFromOrigin based on camera target (Lon/Lat)
|
|
59
|
+
// (_lookFromOrigin as any).setFromLongLat(cameraLookInfo.CenterLong, cameraLookInfo.CenterLat); // Cast to any if setFromLongLat is custom
|
|
60
|
+
// // 1. Calculate _cameraPosition and _finalForward (_lookFromCamera)
|
|
61
|
+
// _cameraPosition.set(globe.Fp.x, globe.Fp.y, globe.Fp.z); // Using your X negation
|
|
62
|
+
// _cameraPosition.divideScalar(WORLD_RADIUS_3D); // Scale to unit sphere
|
|
63
|
+
// Vector3D.subVectors(_lookFromOrigin, _cameraPosition, _finalForward).normalize();
|
|
64
|
+
// // 2. Calculate Q_orient (Final Camera Orientation Quaternion)
|
|
65
|
+
// // Use the vector from origin to camera as an initial 'up' reference
|
|
66
|
+
// _approxUp.copy(_cameraPosition).normalize();
|
|
67
|
+
// // Calculate Right vector using cross product
|
|
68
|
+
// Vector3D.crossVectors(_finalForward, _approxUp, _finalRight).normalize();
|
|
69
|
+
// // Handle edge case: If looking straight along (or opposite to) _approxUp
|
|
70
|
+
// if (_finalRight.lengthSq() < 0.0001) {
|
|
71
|
+
// // If vectors are parallel, _approxUp is not good.
|
|
72
|
+
// // Choose a different 'up', e.g., if _approxUp is near Z, use Y.
|
|
73
|
+
// if (Math.abs(_approxUp.z) > 0.9) {
|
|
74
|
+
// _approxUp.set(0, 1, 0);
|
|
75
|
+
// } else {
|
|
76
|
+
// _approxUp.set(0, 0, 1);
|
|
77
|
+
// }
|
|
78
|
+
// Vector3D.crossVectors(_finalForward, _approxUp, _finalRight).normalize();
|
|
79
|
+
// }
|
|
80
|
+
// // Calculate the 'true' Up vector, orthogonal to Right and Forward
|
|
81
|
+
// Vector3D.crossVectors(_finalRight, _finalForward, _finalUp).normalize();
|
|
82
|
+
// // Apply NorthAng (Roll) around the Forward axis
|
|
83
|
+
// _rollQuaternion.setFromAxisAngle(_finalForward, cameraLookInfo.NorthAng);
|
|
84
|
+
// _finalUp.applyQuaternion(_rollQuaternion);
|
|
85
|
+
// _finalRight.applyQuaternion(_rollQuaternion); // Must rotate Right as well!
|
|
86
|
+
// // Create Q_orient from the final basis vectors (Right, Up, -Forward)
|
|
87
|
+
// // This assumes a Matrix4.makeBasis(x, y, z) exists and builds a rotation matrix.
|
|
88
|
+
// // It also assumes local camera looks down -Z, hence negating _finalForward for the Z basis.
|
|
89
|
+
// _tempVec.copy(_finalForward).negate();
|
|
90
|
+
// _rotationMatrix.makeBasis(_finalRight, _finalUp, _tempVec); // <-- ADAPT: Ensure your library has makeBasis or equivalent
|
|
91
|
+
// _qOrient.setFromRotationMatrix(_rotationMatrix); // <-- ADAPT: Ensure this function exists
|
|
92
|
+
// // 3. Calculate Initial Bottom Ray (Local: -Z forward, Y up, X right)
|
|
93
|
+
// // Rotates (0, 0, -1) around (1, 0, 0) by fieldOfView
|
|
94
|
+
// _initialBottomRayDir.set(0, -Math.sin(fieldOfView), -Math.cos(fieldOfView));
|
|
95
|
+
// // 4. Calculate Final Bottom Ray (World)
|
|
96
|
+
// _fieldOfViewBottomRay.direction.copy(_initialBottomRayDir).applyQuaternion(_qOrient).normalize();
|
|
97
|
+
// _fieldOfViewBottomRay.origin.copy(_cameraPosition);
|
|
98
|
+
// // 5. Intersection and Plane
|
|
99
|
+
// const intersection = (_fieldOfViewBottomRay as any).intersectionSphere(_origin3d, 1); // Cast to any if method isn't standard
|
|
100
|
+
// if (intersection && intersection.length > 0) {
|
|
101
|
+
// // If ray intersects, use the closest point for the plane
|
|
102
|
+
// out.setFromNormalAndPoint(_lookFromOrigin, intersection[0]);
|
|
103
|
+
// } else {
|
|
104
|
+
// // If ray does not intersect (FOV covers globe or misses)
|
|
105
|
+
// // WARNING: This sets a plane through the globe's center.
|
|
106
|
+
// // This might not be the desired behavior for culling.
|
|
107
|
+
// // Consider what should happen if the whole globe *is* visible.
|
|
108
|
+
// out.set(_lookFromOrigin, 0.0);
|
|
109
|
+
// }
|
|
110
|
+
// return out;
|
|
111
|
+
// }
|
|
112
|
+
// export { calculateHorizonPlane };
|
package/Math/methods.js
CHANGED
|
@@ -73,13 +73,13 @@ export const pixelXYLenghtToUnitVectorWithHeight = (pixelXYHeight) => {
|
|
|
73
73
|
const radius = WORLD_RADIUS_3D + pixelXYHeight[2];
|
|
74
74
|
return [...radianToCartesian3d([long, lat]), radius];
|
|
75
75
|
};
|
|
76
|
-
export const globe3Dcoordinates = (globe,
|
|
76
|
+
export const globe3Dcoordinates = (globe, height = 0) => (longlats, { paddingCount = 0, paddingValue = NaN }) => {
|
|
77
77
|
const len = longlats.length / 2;
|
|
78
78
|
const result = new Float32Array(len * 3 + paddingCount * 3).fill(paddingValue);
|
|
79
79
|
for (let i = 0; i < len; i++) {
|
|
80
80
|
const long = longlats[i * 2];
|
|
81
81
|
const lat = longlats[i * 2 + 1];
|
|
82
|
-
const xyz = globe.api_GetCartesian3DPoint(long, lat, height,
|
|
82
|
+
const xyz = globe.api_GetCartesian3DPoint(long, lat, height, 0);
|
|
83
83
|
result.set(xyz, i * 3);
|
|
84
84
|
}
|
|
85
85
|
return result;
|
package/Math/vec3.js
CHANGED
|
@@ -60,11 +60,7 @@ function length(a) {
|
|
|
60
60
|
function normalize(outVec, inVec) {
|
|
61
61
|
const len = length(inVec);
|
|
62
62
|
if (len === 0) {
|
|
63
|
-
|
|
64
|
-
outVec[0] = 0;
|
|
65
|
-
outVec[1] = 0;
|
|
66
|
-
outVec[2] = 0;
|
|
67
|
-
return;
|
|
63
|
+
throw new Error('Cannot normalize a zero vector');
|
|
68
64
|
}
|
|
69
65
|
outVec[0] = inVec[0] / len;
|
|
70
66
|
outVec[1] = inVec[1] / len;
|
|
@@ -85,7 +81,7 @@ function equals(a, b) {
|
|
|
85
81
|
Math.abs(a[2] - b[2]) < EPSILON);
|
|
86
82
|
}
|
|
87
83
|
function fromUnitVectorToLongLat(out, a) {
|
|
88
|
-
const len = length(a);
|
|
84
|
+
const len = length(a); // TODO Might drop length check
|
|
89
85
|
if (len === 0) {
|
|
90
86
|
throw new Error('Cannot convert a zero vector to unit vector');
|
|
91
87
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "./types";
|
|
2
|
+
/**
|
|
3
|
+
* @param {DrawSubsetOptions} drawSubsetOptions
|
|
4
|
+
*/
|
|
5
|
+
// TODO: Draw all is an optional property for the target plugin, with this approach.
|
|
6
|
+
class DrawSubsetOptionRegistry {
|
|
7
|
+
constructor() {
|
|
8
|
+
this._drawSubsetOptions = new Map();
|
|
9
|
+
}
|
|
10
|
+
register(key, drawSubsetOptions) {
|
|
11
|
+
this._drawSubsetOptions.set(key, drawSubsetOptions);
|
|
12
|
+
}
|
|
13
|
+
unregister(key) {
|
|
14
|
+
this._drawSubsetOptions.delete(key);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -335,7 +335,7 @@ class PointGlowLineToEarthPlugin {
|
|
|
335
335
|
});
|
|
336
336
|
}
|
|
337
337
|
_doesChanged() {
|
|
338
|
-
return this.
|
|
338
|
+
return this._cameraBlockTotem.isMoved() || this._parametersChanged; // TODO: implement
|
|
339
339
|
}
|
|
340
340
|
_changed() {
|
|
341
341
|
this._parametersChanged = true;
|
package/bearing-line/plugin.js
CHANGED
|
@@ -397,9 +397,8 @@ export default class BearingLinePlugin {
|
|
|
397
397
|
const drawRange = { first: 0, count: this.bufferOrchestrator.length };
|
|
398
398
|
this.lineProgram.draw(this.lineVao, { drawRange }, this._opacity);
|
|
399
399
|
if (this.drawAngleRing) {
|
|
400
|
-
this.pieceOfPieProgram.
|
|
401
|
-
this.pieceOfPieProgram.draw(this.bufferOrchestrator.length, this.ringVao, 360, RINGPARTIAL_DRAW_MODE.
|
|
402
|
-
this.pieceOfPieProgram.draw(this.bufferOrchestrator.length, this.ringVao, 360, RINGPARTIAL_DRAW_MODE.LINE_STRIP);
|
|
400
|
+
this.pieceOfPieProgram.draw(this.bufferOrchestrator.length, this.ringVao, 360, this._opacity * 0.8, RINGPARTIAL_DRAW_MODE.TRIANGLE_FAN);
|
|
401
|
+
this.pieceOfPieProgram.draw(this.bufferOrchestrator.length, this.ringVao, 360, this._opacity * 0.8, RINGPARTIAL_DRAW_MODE.LINE_STRIP);
|
|
403
402
|
}
|
|
404
403
|
if (this.drawBearingLine) {
|
|
405
404
|
// this.lineProgram.draw(this.bearingLineVAO, this.bufferOrchestrator.length, this._opacity );
|
package/package.json
CHANGED
package/point-tracks/plugin.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BufferOrchestrator, BufferManager, ObjectStore } from "../util/account
|
|
1
|
+
import { BufferOrchestrator, BufferManager, ObjectStore } from "../util/account";
|
|
2
2
|
import { PickerDisplayer } from "../util/picking/picker-displayer";
|
|
3
3
|
import { PointOnGlobeProgramCache } from "../programs/point-on-globe/square-pixel-point";
|
|
4
4
|
import { wgs84ToCartesian3d, wgs84ToMercator } from "../Math/methods";
|
|
@@ -14,7 +14,7 @@ const _0vec3 = /* @__PURE__ */ [0, 0, 0];
|
|
|
14
14
|
* @typedef {Array<Point>, rgba, trackID} Track
|
|
15
15
|
*/
|
|
16
16
|
class PointTracksPlugin {
|
|
17
|
-
constructor(id, { pointSize = 2, hoveredPointSize = 4, selectionPointFilling = 4, opacity = 1.0
|
|
17
|
+
constructor(id, { pointSize = 2, hoveredPointSize = 4, selectionPointFilling = 4, opacity = 1.0 } = {}) {
|
|
18
18
|
this.id = id;
|
|
19
19
|
this._isFreed = false;
|
|
20
20
|
this._pointProgram = null;
|
|
@@ -25,20 +25,15 @@ class PointTracksPlugin {
|
|
|
25
25
|
this._selectedID = -1;
|
|
26
26
|
this._selectedObj = null;
|
|
27
27
|
this._tracksToPointsMap = new Map(); // one to many
|
|
28
|
-
this._opacity = opacity
|
|
28
|
+
this._opacity = opacity;
|
|
29
29
|
this.program = null;
|
|
30
30
|
this._lastWH = { w: 0, h: 0 };
|
|
31
31
|
this._focusParams = { on: false, length: 0, elementBuffer: null, trackIDs: [] };
|
|
32
32
|
this.pointSizes = {
|
|
33
|
-
pointSize
|
|
34
|
-
selectionPointFilling
|
|
35
|
-
hoveredPointSize
|
|
33
|
+
pointSize,
|
|
34
|
+
selectionPointFilling,
|
|
35
|
+
hoveredPointSize
|
|
36
36
|
};
|
|
37
|
-
this._objectStoreExtraParameters = objectStoreExtraParameters ? objectStoreExtraParameters : [];
|
|
38
|
-
this._objectStoreExtraParametersFiltered = objectStoreExtraParameters.filter(param => {
|
|
39
|
-
return !["long", "lat", "height", "ID", "trackID"].includes(param);
|
|
40
|
-
});
|
|
41
|
-
this._bufferOrchestrator = new BufferOrchestrator({ capacity: initialCapacity ? initialCapacity : 1000 });
|
|
42
37
|
}
|
|
43
38
|
init(globe, gl) {
|
|
44
39
|
this.globe = globe;
|
|
@@ -50,8 +45,9 @@ class PointTracksPlugin {
|
|
|
50
45
|
}
|
|
51
46
|
_initBufferManagers() {
|
|
52
47
|
const { gl } = this;
|
|
53
|
-
const initialCapacity =
|
|
48
|
+
const initialCapacity = 10;
|
|
54
49
|
const bufferType = "DYNAMIC_DRAW";
|
|
50
|
+
this._bufferOrchestrator = new BufferOrchestrator({ initialCapacity });
|
|
55
51
|
this._bufferManagersMap = new Map([
|
|
56
52
|
["pos3D", {
|
|
57
53
|
bufferManager: new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
@@ -71,17 +67,9 @@ class PointTracksPlugin {
|
|
|
71
67
|
["objectStore", {
|
|
72
68
|
bufferManager: new ObjectStore({ initialCapacity }),
|
|
73
69
|
adaptor: (item) => {
|
|
74
|
-
|
|
75
|
-
trackID: item.trackID,
|
|
76
|
-
pointID: item.pointID,
|
|
70
|
+
return {
|
|
71
|
+
trackID: item.trackID, pointID: item.pointID
|
|
77
72
|
};
|
|
78
|
-
// Add extra parameters specified in _objectStoreExtraParameters
|
|
79
|
-
this._objectStoreExtraParameters.forEach(param => {
|
|
80
|
-
if (item.hasOwnProperty(param)) {
|
|
81
|
-
result[param] = item[param];
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
return result;
|
|
85
73
|
}
|
|
86
74
|
}]
|
|
87
75
|
]);
|
|
@@ -144,8 +132,8 @@ class PointTracksPlugin {
|
|
|
144
132
|
* @returns
|
|
145
133
|
*/
|
|
146
134
|
insertBulk(tracks) {
|
|
147
|
-
this._fillTracksToPointsMap(tracks);
|
|
148
|
-
const flattenedPoints = tracks.map(trackToFlatPoints
|
|
135
|
+
this._fillTracksToPointsMap(tracks); // TODO error should be at the top
|
|
136
|
+
const flattenedPoints = tracks.map(trackToFlatPoints).flat();
|
|
149
137
|
const currentLoad = this._bufferOrchestrator.length;
|
|
150
138
|
if (currentLoad + flattenedPoints.length >= 2147483647) {
|
|
151
139
|
throw new Error("Too many points, Point count cannot exceed 2147483647");
|
|
@@ -167,8 +155,8 @@ class PointTracksPlugin {
|
|
|
167
155
|
* @param {string} trackID
|
|
168
156
|
*/
|
|
169
157
|
deleteTrack(trackID) {
|
|
170
|
-
const
|
|
171
|
-
const points = Array.from(
|
|
158
|
+
const pointSet = this._tracksToPointsMap.get(trackID);
|
|
159
|
+
const points = Array.from(pointSet);
|
|
172
160
|
const { _bufferOrchestrator, _bufferManagersMap } = this;
|
|
173
161
|
_bufferOrchestrator.deleteBulk(points.map((pointID) => keyMethod(trackID, pointID)), _bufferManagersMap);
|
|
174
162
|
this._tracksToPointsMap.delete(trackID);
|
|
@@ -201,23 +189,6 @@ class PointTracksPlugin {
|
|
|
201
189
|
}
|
|
202
190
|
this.globe.DrawRender();
|
|
203
191
|
}
|
|
204
|
-
updateTrackColor(trackID, rgba) {
|
|
205
|
-
if (!this._tracksToPointsMap.has(trackID)) {
|
|
206
|
-
console.warn(`Track with ID ${trackID} does not exist.`);
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
const pointList = this._tracksToPointsMap.get(trackID);
|
|
210
|
-
const points = Array.from(pointList);
|
|
211
|
-
const { _bufferOrchestrator, _bufferManagersMap } = this;
|
|
212
|
-
_bufferOrchestrator.updateBulk(points.map((pointID) => {
|
|
213
|
-
return {
|
|
214
|
-
key: keyMethod(trackID, pointID),
|
|
215
|
-
rgba: new Float32Array(rgba)
|
|
216
|
-
};
|
|
217
|
-
}), _bufferManagersMap, ["rgba"]);
|
|
218
|
-
this._refillFocus();
|
|
219
|
-
this.globe?.DrawRender();
|
|
220
|
-
}
|
|
221
192
|
// GLOBE API METHODS
|
|
222
193
|
free() {
|
|
223
194
|
if (this._isFreed)
|
|
@@ -230,12 +201,6 @@ class PointTracksPlugin {
|
|
|
230
201
|
}
|
|
231
202
|
draw3D() {
|
|
232
203
|
const { gl, _pointProgram, _pickerDisplayer, _bufferOrchestrator, _vao } = this;
|
|
233
|
-
if (!gl) {
|
|
234
|
-
throw new Error("GL is not loaded, PointTracks Plugin");
|
|
235
|
-
}
|
|
236
|
-
if (this._isFreed) {
|
|
237
|
-
throw new Error("Plugin is unregistered, PointTracks Plugin");
|
|
238
|
-
}
|
|
239
204
|
this.resize();
|
|
240
205
|
_pickerDisplayer.bindFBO();
|
|
241
206
|
_pickerDisplayer.clearTextures();
|
|
@@ -281,12 +246,7 @@ class PointTracksPlugin {
|
|
|
281
246
|
const pointSet = this._tracksToPointsMap.get(trackID);
|
|
282
247
|
for (let p = 0; p < points.length; p++) {
|
|
283
248
|
const pointID = points[p].ID;
|
|
284
|
-
|
|
285
|
-
pointSet.add(pointID);
|
|
286
|
-
}
|
|
287
|
-
else {
|
|
288
|
-
console.warn(`Point with ID ${pointID} already exists in track ${trackID}. Skipping duplicate.`);
|
|
289
|
-
}
|
|
249
|
+
pointSet.add(pointID);
|
|
290
250
|
}
|
|
291
251
|
}
|
|
292
252
|
}
|
|
@@ -296,21 +256,9 @@ class PointTracksPlugin {
|
|
|
296
256
|
}
|
|
297
257
|
}
|
|
298
258
|
_deletePointsFromTracksMap(trackID, pointIDs) {
|
|
299
|
-
const
|
|
300
|
-
if (trackIDs === undefined) {
|
|
301
|
-
console.warn(`Track with ID ${trackID} not found.`);
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
259
|
+
const trackSet = this._tracksToPointsMap.get(trackID);
|
|
304
260
|
for (const pointID of pointIDs) {
|
|
305
|
-
|
|
306
|
-
console.warn(`Point with ID ${pointID} not found in track ${trackID}.`);
|
|
307
|
-
}
|
|
308
|
-
else {
|
|
309
|
-
trackIDs.delete(pointID);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
if (trackIDs.size === 0) {
|
|
313
|
-
this._tracksToPointsMap.delete(trackID);
|
|
261
|
+
trackSet.delete(pointID);
|
|
314
262
|
}
|
|
315
263
|
}
|
|
316
264
|
_selfSelect() {
|
|
@@ -334,16 +282,14 @@ class PointTracksPlugin {
|
|
|
334
282
|
const indexes = [];
|
|
335
283
|
const foundTracks = [];
|
|
336
284
|
for (const trackID of trackIDs) {
|
|
337
|
-
const
|
|
338
|
-
if (!
|
|
285
|
+
const pointSet = this._tracksToPointsMap.get(trackID);
|
|
286
|
+
if (!pointSet)
|
|
339
287
|
continue;
|
|
340
288
|
foundTracks.push(trackID);
|
|
341
|
-
|
|
289
|
+
const points = Array.from(pointSet);
|
|
290
|
+
for (const pointID of points) {
|
|
342
291
|
const key = keyMethod(trackID, pointID);
|
|
343
292
|
const index = this._bufferOrchestrator.offsetMap.get(key);
|
|
344
|
-
if (index === undefined) {
|
|
345
|
-
throw new Error;
|
|
346
|
-
}
|
|
347
293
|
indexes.push(index);
|
|
348
294
|
length++;
|
|
349
295
|
}
|
|
@@ -360,7 +306,7 @@ class PointTracksPlugin {
|
|
|
360
306
|
return true;
|
|
361
307
|
}
|
|
362
308
|
}
|
|
363
|
-
const trackToFlatPoints = (track
|
|
309
|
+
const trackToFlatPoints = (track) => {
|
|
364
310
|
const trackID = track.trackID;
|
|
365
311
|
const points = track.points;
|
|
366
312
|
const rgba = new Float32Array(track.rgba);
|
|
@@ -375,12 +321,6 @@ const trackToFlatPoints = (track, extraParameters) => {
|
|
|
375
321
|
rgba,
|
|
376
322
|
trackID
|
|
377
323
|
});
|
|
378
|
-
for (let i = 0; i < extraParameters.length; i++) {
|
|
379
|
-
const param = extraParameters[i];
|
|
380
|
-
if (point.hasOwnProperty(param)) {
|
|
381
|
-
flatPoints[flatPoints.length - 1][param] = point[param];
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
324
|
}
|
|
385
325
|
return flatPoints;
|
|
386
326
|
};
|
|
@@ -8,6 +8,7 @@ import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
|
|
|
8
8
|
* This program draws line between points provided from the first and second buffer.
|
|
9
9
|
* draw method gl.drawArraysInstanced( gl.POINTS, 0,2, lineCount);
|
|
10
10
|
* */
|
|
11
|
+
// TODO: find better way to eleminate edge case distance(posA, posB) > 37000000.0
|
|
11
12
|
const vertexShaderSource = `#version 300 es
|
|
12
13
|
precision highp float;
|
|
13
14
|
${CameraUniformBlockString}
|
|
@@ -3,6 +3,7 @@ import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../../to
|
|
|
3
3
|
import { cartesian3DToGLPosition, mercatorXYToGLPosition, } from "../../../util/shaderfunctions/geometrytransformations";
|
|
4
4
|
import { noRegisterGlobeProgramCache } from "../../programcache";
|
|
5
5
|
import { attributeLoader } from "../../../util/gl-util/buffer/attribute-loader";
|
|
6
|
+
import "../../../util/gl-util/buffer/attribute-loader";
|
|
6
7
|
import { UniformBlockManager } from "../../../util/gl-util/uniform-block/manager";
|
|
7
8
|
import { drawArrays } from "../../../util/gl-util/draw-options/methods";
|
|
8
9
|
const ESCAPE_VALUE = -1;
|
|
@@ -28,14 +29,24 @@ uniform float u_opacity;
|
|
|
28
29
|
in vec3 position3d;
|
|
29
30
|
in vec2 position2d;
|
|
30
31
|
in vec4 color;
|
|
32
|
+
// in float dash_length;
|
|
33
|
+
// in float dash_opacity;
|
|
34
|
+
|
|
35
|
+
// out float v_dash_length;
|
|
36
|
+
// out float v_dash_opacity;
|
|
31
37
|
out vec4 v_color;
|
|
32
38
|
|
|
33
39
|
flat out vec3 v_flat_position;
|
|
34
40
|
out vec3 v_position;
|
|
35
41
|
|
|
36
42
|
void main() {
|
|
43
|
+
|
|
37
44
|
v_color = ( color.r == -1.0 ) ? u_color : color;
|
|
38
45
|
v_color.a *= u_opacity;
|
|
46
|
+
|
|
47
|
+
// v_dash_length = ( dash_length == -1.0 ) ? u_dash_length : dash_length;
|
|
48
|
+
// v_dash_opacity = ( dash_opacity == -1.0 ) ? u_dash_opacity : dash_opacity;
|
|
49
|
+
|
|
39
50
|
if ( is3D ) {
|
|
40
51
|
gl_Position = cartesian3DToGLPosition( position3d );
|
|
41
52
|
v_position = position3d;
|
|
@@ -62,8 +73,18 @@ in vec3 v_position;
|
|
|
62
73
|
out vec4 outColor;
|
|
63
74
|
|
|
64
75
|
void main() {
|
|
65
|
-
outColor =
|
|
76
|
+
outColor = v_color;
|
|
77
|
+
return;
|
|
78
|
+
// float dash_length = v_dash_length;
|
|
79
|
+
// float dash_opacity = v_dash_opacity;
|
|
66
80
|
|
|
81
|
+
// if ( dash_length == 0.0 ) {
|
|
82
|
+
outColor = vec4( v_color.rgb, v_color.a );
|
|
83
|
+
// } else {
|
|
84
|
+
// float dist = distance( v_flat_position, v_position );
|
|
85
|
+
// // float alpha = mod( dist , v_dash_length * 2.0 ) / v_dash_length < 1.0 ? 1.0 : v_dash_opacity;
|
|
86
|
+
// outColor = vec4( 1.0, 1.0, 1.0, v_color.a * opacity *alpha);
|
|
87
|
+
// }
|
|
67
88
|
}`;
|
|
68
89
|
export class LineProgram {
|
|
69
90
|
_vaosPublished = [];
|
|
@@ -89,6 +110,8 @@ export class LineProgram {
|
|
|
89
110
|
this.gl.bindAttribLocation(this.program, 0, "position3d");
|
|
90
111
|
this.gl.bindAttribLocation(this.program, 1, "position2d");
|
|
91
112
|
this.gl.bindAttribLocation(this.program, 2, "color");
|
|
113
|
+
// this.gl.bindAttribLocation(this.program, 3, "dash_length");
|
|
114
|
+
// this.gl.bindAttribLocation(this.program, 4, "dash_opacity");
|
|
92
115
|
this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
|
|
93
116
|
this.cameraBlockTotem.assignBindingPoint(this.program, uniformBindingPoints.camera);
|
|
94
117
|
flexibleBlockManager.assignBindingPoint(this.gl, this.program);
|
|
@@ -100,13 +123,16 @@ export class LineProgram {
|
|
|
100
123
|
this._ubosPublished.push(ubo);
|
|
101
124
|
return ubo;
|
|
102
125
|
}
|
|
103
|
-
createVAO(position3D, position2D, color
|
|
126
|
+
createVAO(position3D, position2D, color //, dashLength: BufferAndReadInfo, dashOpacity: BufferAndReadInfo,
|
|
127
|
+
) {
|
|
104
128
|
const { gl } = this;
|
|
105
129
|
const vao = gl.createVertexArray();
|
|
106
130
|
gl.bindVertexArray(vao);
|
|
107
131
|
attributeLoader(gl, position3D, 0, 3);
|
|
108
132
|
attributeLoader(gl, position2D, 1, 2);
|
|
109
133
|
attributeLoader(gl, color, 2, 4, { escapeValues: [ESCAPE_VALUE, ESCAPE_VALUE, ESCAPE_VALUE, ESCAPE_VALUE] });
|
|
134
|
+
// attributeLoader(gl, dashLength, 3, 1, { escapeValues: [ESCAPE_VALUE] });
|
|
135
|
+
// attributeLoader(gl, dashOpacity, 4, 1, { escapeValues: [ESCAPE_VALUE] });
|
|
110
136
|
gl.bindVertexArray(null);
|
|
111
137
|
return vao;
|
|
112
138
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -100,6 +100,7 @@ class Logic {
|
|
|
100
100
|
const vao = gl.createVertexArray();
|
|
101
101
|
const divisor = 1;
|
|
102
102
|
gl.bindVertexArray(vao);
|
|
103
|
+
// TODO constants to escape values
|
|
103
104
|
attributeLoader(gl, pos3DObj, 0, 3, { divisor });
|
|
104
105
|
attributeLoader(gl, radiusObj, 1, 1, { divisor, escapeValues: [-1] });
|
|
105
106
|
attributeLoader(gl, colorObj, 2, 4, { divisor, escapeValues: [-1, -1, -1, -1] });
|