@pirireis/webglobeplugins 0.12.0-alpha → 0.14.0-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/Math/arc-cdf-points.js +20 -0
  2. package/Math/arc-generate-points copy.js +1 -0
  3. package/Math/arc.js +21 -8
  4. package/Math/circle-cdf-points.js +0 -2
  5. package/Math/circle.js +35 -16
  6. package/Math/templete-shapes/grid-visually-equal.js +66 -0
  7. package/altitude-locator/plugin.js +3 -2
  8. package/bearing-line/plugin.js +1 -2
  9. package/circle-line-chain/plugin.js +4 -7
  10. package/compass-rose/compass-rose-padding-flat.js +12 -0
  11. package/package.json +1 -1
  12. package/programs/line-on-globe/degree-padding-around-circle-3d.js +1 -1
  13. package/programs/line-on-globe/linestrip/data.js +4 -0
  14. package/programs/line-on-globe/{linestrip.js → linestrip/linestrip.js} +37 -35
  15. package/programs/line-on-globe/naive-accurate-flexible.js +23 -16
  16. package/programs/picking/pickable-renderer.js +1 -2
  17. package/programs/rings/distancering/circleflatprogram.js +116 -120
  18. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +1 -1
  19. package/programs/rings/distancering/circlepaddysharedbuffer.js +368 -354
  20. package/programs/rings/distancering/index.js +6 -5
  21. package/programs/rings/distancering/paddyflatprogram.js +127 -136
  22. package/programs/rings/distancering/paddyflatprogram2d.js +129 -138
  23. package/programs/rings/distancering/paddyflatprogram3d.js +128 -136
  24. package/programs/rings/partial-ring/piece-of-pie copy.js +286 -0
  25. package/programs/rings/partial-ring/piece-of-pie.js +26 -13
  26. package/programs/totems/camerauniformblock.js +1 -1
  27. package/programs/totems/index.js +1 -1
  28. package/programs/vectorfields/logics/pixelbased.js +5 -21
  29. package/range-tools-on-terrain/bearing-line/adapters.js +111 -0
  30. package/range-tools-on-terrain/bearing-line/plugin.js +360 -0
  31. package/range-tools-on-terrain/bearing-line/types.js +1 -0
  32. package/range-tools-on-terrain/circle-line-chain/adapters.js +83 -0
  33. package/range-tools-on-terrain/circle-line-chain/chain-list-map.js +351 -0
  34. package/range-tools-on-terrain/circle-line-chain/plugin.js +389 -0
  35. package/range-tools-on-terrain/circle-line-chain/types.js +1 -0
  36. package/range-tools-on-terrain/range-ring/adapters.js +25 -0
  37. package/range-tools-on-terrain/range-ring/plugin.js +31 -0
  38. package/range-tools-on-terrain/range-ring/types.js +1 -0
  39. package/rangerings/plugin.js +7 -11
  40. package/semiplugins/lightweight/line-plugin.js +195 -0
  41. package/semiplugins/lightweight/piece-of-pie-plugin.js +175 -0
  42. package/semiplugins/shape-on-terrain/arc-plugin.js +368 -0
  43. package/{shape-on-terrain/circle/plugin.js → semiplugins/shape-on-terrain/circle-plugin.js} +129 -68
  44. package/semiplugins/shape-on-terrain/derived/padding-plugin.js +96 -0
  45. package/semiplugins/type.js +1 -0
  46. package/types.js +0 -11
  47. package/util/account/create-buffermap-orchastration.js +39 -0
  48. package/util/account/index.js +2 -2
  49. package/util/account/single-attribute-buffer-management/buffer-manager.js +2 -3
  50. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +14 -3
  51. package/util/build-strategy/static-dynamic.js +1 -1
  52. package/util/check/typecheck.js +15 -1
  53. package/util/geometry/index.js +3 -2
  54. package/util/gl-util/buffer/attribute-loader.js +2 -5
  55. package/util/gl-util/draw-options/methods.js +4 -5
  56. package/util/webglobjectbuilders.js +4 -9
  57. package/write-text/context-text3.js +17 -0
  58. package/write-text/context-text3old.js +152 -0
  59. package/programs/line-on-globe/circle-accurate.js +0 -175
  60. package/programs/line-on-globe/circle.js +0 -164
  61. package/programs/line-on-globe/to-the-surface.js +0 -109
  62. package/programs/rings/distancering/shader.js +0 -1
  63. package/programs/totems/canvas-webglobe-info1.js +0 -106
  64. package/shape-on-terrain/arc/naive/plugin.js +0 -205
  65. package/util/check/get.js +0 -14
  66. package/util/gl-util/buffer/types.js +0 -1
  67. package/util/gl-util/draw-options/types.js +0 -15
  68. package/util/webglobjectbuilders1.js +0 -219
@@ -1,3 +1,5 @@
1
+ import { fromAxisAngle } from './quaternion';
2
+ import { applyQuaternion, clone } from './vec3';
1
3
  // --- Utility Functions for 3D Vector Operations --- (Assumed to be the same as provided)
2
4
  /**
3
5
  * Normalizes a 3D vector to unit length.
@@ -204,6 +206,24 @@ export function generateArcPoints(p0, p1, axisA, attractionPoint, pointCount, at
204
206
  }
205
207
  return sampledPoints;
206
208
  }
209
+ const _rotationQuaternion = /*@__PURE__*/ [0, 0, 0, 1];
210
+ export function evenlySpacedArcPoints(p0, axisA, coverAngle, pointCount) {
211
+ if (pointCount < 1)
212
+ return [];
213
+ if (pointCount === 1)
214
+ return [vec3Normalize(p0)];
215
+ const point = vec3Normalize(p0);
216
+ const stepAngle = coverAngle / (pointCount - 1);
217
+ fromAxisAngle(_rotationQuaternion, axisA, stepAngle);
218
+ const sampledPoints = new Array(pointCount);
219
+ sampledPoints[0] = clone(point);
220
+ // Start from index 1 since we already have the first point
221
+ for (let i = 1; i < pointCount; i++) {
222
+ applyQuaternion(point, point, _rotationQuaternion);
223
+ sampledPoints[i] = clone(point);
224
+ }
225
+ return sampledPoints;
226
+ }
207
227
  // // --- Example Usage (for demonstration and testing) ---
208
228
  // // Example 1: Basic arc, very strong attraction point in the middle
209
229
  // const p0_ex1: Vec3 = [1, 0, 0];
@@ -1,3 +1,4 @@
1
+ // TODO: Delete this file if it is not needed anymore.
1
2
  // import { normilze as vec3Normalize, dot as vec3Dot, cross as vec3Cross, scale as vec3Scale, add as vec3Add, sub as vec3Sub } from './vec3';
2
3
  // --- Utility Functions for 3D Vector Operations ---
3
4
  /**
package/Math/arc.js CHANGED
@@ -13,17 +13,30 @@ const _longLat = /*@__PURE__*/ [0, 0];
13
13
  function create(p0, p1) {
14
14
  const normal = vec3create(0, 0, 0);
15
15
  cross(normal, p0, p1);
16
- const coverPlaneNormal = [p0[0] + p1[0], p0[1] + p1[1], p0[2] + p1[2]];
17
- normalize(coverPlaneNormal, coverPlaneNormal);
18
- const dot_ = dot(coverPlaneNormal, p0);
16
+ normalize(normal, normal);
17
+ const coverPlaneNormal = vec3create(p0[0] + p1[0], p0[1] + p1[1], p0[2] + p1[2]);
18
+ let distance;
19
+ const ls = lengthSquared(coverPlaneNormal);
20
+ if (ls > EPSILON) {
21
+ normalize(coverPlaneNormal, coverPlaneNormal);
22
+ distance = dot(coverPlaneNormal, p0);
23
+ }
24
+ else {
25
+ // Handle opposite points case
26
+ const tempPlane = planeCreate(vec3create(), 0);
27
+ _oppositePointsHandle(p0, p1, normal, tempPlane);
28
+ vec3copy(coverPlaneNormal, tempPlane.normal);
29
+ distance = tempPlane.distance;
30
+ }
19
31
  return {
20
32
  p0: vec3clone(p0),
21
33
  p1: vec3clone(p1),
22
34
  normal: vec3clone(normal),
23
35
  coverPlane: {
24
36
  normal: coverPlaneNormal,
25
- distance: dot_
26
- }
37
+ distance: distance
38
+ },
39
+ coverAngle: Math.acos(dot(p0, p1))
27
40
  };
28
41
  }
29
42
  function set(out, p0, p1) {
@@ -46,6 +59,7 @@ function copy(out, a) {
46
59
  vec3copy(out.normal, a.normal);
47
60
  out.coverPlane.normal = vec3clone(a.coverPlane.normal);
48
61
  out.coverPlane.distance = a.coverPlane.distance;
62
+ out.coverAngle = a.coverAngle; // Copy coverAngle if it exists
49
63
  }
50
64
  function clone(a) {
51
65
  return {
@@ -55,7 +69,8 @@ function clone(a) {
55
69
  coverPlane: {
56
70
  normal: vec3clone(a.coverPlane.normal),
57
71
  distance: a.coverPlane.distance
58
- }
72
+ },
73
+ coverAngle: a.coverAngle // Clone coverAngle if it exists
59
74
  };
60
75
  }
61
76
  function isPointOn(arc, point) {
@@ -118,8 +133,6 @@ function _populatePointsWithClosestPointInsideArc(out, arc, count, closestPoint)
118
133
  const angleStep2 = angleP1 / pop2;
119
134
  fromAxisAngle(_rotationQuaternion, arc.normal, angleStep1);
120
135
  }
121
- function _populatePointsWithoutClosestPoint(out, arc, count) {
122
- }
123
136
  /**
124
137
  * Samples points along an arc with density biased by the camera's distance,
125
138
  * reusing the rotation quaternion to improve performance.
@@ -206,7 +206,6 @@ function createCummulativeTemplate(numberOfPoints, strength, denseRatio = 0.5 //
206
206
  // Normalize the values to ensure they sum up to 1.
207
207
  distribution[i] = distribution[i] / totalWeight;
208
208
  }
209
- console.log("distribution", distribution, "strength", strength, "numberOfPoints", numberOfPoints);
210
209
  return distribution;
211
210
  }
212
211
  function createCummulativeTemplateStash(levels, numberOfPoints, denseRatio = 0.5, strengthMultiplier = 2.4) {
@@ -239,7 +238,6 @@ function globeFindPointByPolarHalfCircle(out, globe, centerLong, centerLat, radi
239
238
  out[offset - 1] = point.lat;
240
239
  offset -= 2;
241
240
  }
242
- console.log("1");
243
241
  }
244
242
  export {
245
243
  // createTemplate,
package/Math/circle.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RADIANS } from './methods';
2
- import { subtract, normalize, dot, fromLongLatToUnitVector, copy, multiplyScalar } from './vec3';
2
+ import { subtract, normalize, dot, fromLongLatToUnitVector, copy, multiplyScalar, clone } from './vec3';
3
3
  const _0vec3 = [0, 0, 0];
4
4
  function closestAzimuthAngle(circleProperties, point) {
5
5
  const distance = dot(circleProperties.normal, point);
@@ -10,30 +10,49 @@ function closestAzimuthAngle(circleProperties, point) {
10
10
  const N = circleProperties.northPointProjectedToOriginPlaneNormalized;
11
11
  const _dot = dot(_0vec3, N);
12
12
  let angle = Math.acos(_dot);
13
- const z = _0vec3[0] * N[1] - _0vec3[1] * N[0];
13
+ const z = (_0vec3[0] * N[1] - _0vec3[1] * N[0]) * circleProperties.normal[2];
14
14
  return z < 0 ? -angle : angle;
15
15
  }
16
16
  function createCircleClosestAzimuthAngleProperties(circle) {
17
17
  const normal = Array(3);
18
18
  fromLongLatToUnitVector(normal, [circle.center[0] * RADIANS, circle.center[1] * RADIANS]);
19
- const distance = normal[2]; //dot(normal, [0, 0, 1] as Vec3)
20
- const N = [0, 0, 0];
21
- if (Math.abs(distance) < 1e-6) {
22
- N[0] = -1;
23
- N[1] = 0;
24
- N[2] = 0;
25
- }
26
- else {
27
- copy(N, normal);
28
- multiplyScalar(N, N, distance);
29
- N[0] = -N[0];
30
- N[1] = -N[1];
31
- N[2] = 1 - N[2];
32
- }
19
+ const N = clone(normal);
20
+ const distance = dot([0, 0, 1], normal);
21
+ multiplyScalar(N, N, distance);
22
+ // if (N[2] >= 0) {
23
+ subtract(N, [0, 0, 1], N);
24
+ // } else {
25
+ // subtract(N, [0, 0, -1], N);
26
+ // }
33
27
  normalize(N, N);
34
28
  return {
35
29
  normal: normal,
36
30
  northPointProjectedToOriginPlaneNormalized: N,
37
31
  };
32
+ // const distance = normal[2]; //dot(normal, [0, 0, 1] as Vec3)
33
+ // const N: Vec3 = [0, 0, 0];
34
+ // if (Math.abs(distance) < 1e-6) {
35
+ // N[0] = -1;
36
+ // N[1] = 0;
37
+ // N[2] = 0;
38
+ // } else {
39
+ // // TODO: add cases for 8 parts of the sphere
40
+ // copy(N, normal);
41
+ // multiplyScalar(N, N, distance);
42
+ // if (N[2] >= 0) {
43
+ // N[0] = -N[0];
44
+ // N[1] = -N[1];
45
+ // N[2] = 1 - N[2];
46
+ // } else {
47
+ // N[2] = -N[2];
48
+ // N[0] = -N[0];
49
+ // N[1] = -N[1];
50
+ // }
51
+ // }
52
+ // normalize(N, N);
53
+ // return {
54
+ // normal: normal,
55
+ // northPointProjectedToOriginPlaneNormalized: N,
56
+ // }
38
57
  }
39
58
  export { closestAzimuthAngle, createCircleClosestAzimuthAngleProperties };
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Createa a grıd of longitude/latitude points visually equal on the mercator projectıon.
3
+ */
4
+ function mercatorMeterToLongLat(mercatorX, mercatorY) {
5
+ const R = 6378137; // Earth radius in meters
6
+ const lng = (mercatorX / R) * (180 / Math.PI);
7
+ const lat = (2 * Math.atan(Math.exp(mercatorY / R)) - Math.PI / 2) * (180 / Math.PI);
8
+ return [lng, lat];
9
+ }
10
+ function createGrid(sizeX, sizeY) {
11
+ const grid = [];
12
+ for (let y = 0; y < sizeY; y++) {
13
+ const row = new Array(sizeX);
14
+ grid.push(row);
15
+ }
16
+ return grid;
17
+ }
18
+ function moveByAngle(origin, angle, distance) {
19
+ const long = origin[0] + distance * Math.cos(angle);
20
+ const lat = origin[1] + distance * Math.sin(angle);
21
+ return [long, lat];
22
+ }
23
+ export function createfillGrid(globe, origin, startX, startY, rowSize, columnSize, cellSizeX, cellSizeY, rotaionAngle = 0) {
24
+ const originMercator = globe.api_GetMercator2DPoint(origin[0], origin[1]);
25
+ const angleRadians = rotaionAngle * (Math.PI / 180);
26
+ const grid = createGrid(rowSize, columnSize);
27
+ // Set the origin point first
28
+ grid[startY][startX] = originMercator;
29
+ // fill single vertical row from origin - to the right
30
+ let lastPoint = originMercator;
31
+ for (let i = startX + 1; i < rowSize; i++) {
32
+ const [long, lat] = moveByAngle(lastPoint, angleRadians, cellSizeX);
33
+ lastPoint = [long, lat];
34
+ grid[startY][i] = [long, lat];
35
+ }
36
+ // fill single vertical row from origin - to the left
37
+ lastPoint = originMercator;
38
+ for (let i = startX - 1; i >= 0; i--) {
39
+ const [long, lat] = moveByAngle(lastPoint, Math.PI + angleRadians, cellSizeX);
40
+ lastPoint = [long, lat];
41
+ grid[startY][i] = [long, lat];
42
+ }
43
+ // fill single horizontal from origin from startY to 0
44
+ console.log("grid", grid);
45
+ for (let i = startY - 1; i >= 0; i--) {
46
+ for (let j = 0; j < rowSize; j++) {
47
+ const [long, lat] = moveByAngle(grid[i + 1][j], angleRadians - Math.PI / 2, cellSizeY);
48
+ grid[i][j] = [long, lat];
49
+ }
50
+ }
51
+ // fill single horizontal from origin from startY to last row
52
+ for (let i = startY + 1; i < columnSize; i++) {
53
+ for (let j = 0; j < rowSize; j++) {
54
+ const [long, lat] = moveByAngle(grid[i - 1][j], angleRadians + Math.PI / 2, cellSizeY);
55
+ grid[i][j] = [long, lat];
56
+ }
57
+ }
58
+ // Convert from mercator meters to longitude/latitude
59
+ for (let i = 0; i < columnSize; i++) {
60
+ for (let j = 0; j < rowSize; j++) {
61
+ const [long, lat] = mercatorMeterToLongLat(grid[i][j][0], grid[i][j][1]);
62
+ grid[i][j] = [long, lat];
63
+ }
64
+ }
65
+ return grid;
66
+ }
@@ -2,11 +2,12 @@ import './types.js';
2
2
  import { PickableRendererProgramCache } from '../programs/picking/pickable-renderer.js';
3
3
  import { ElementPointGlowProgramCache } from '../programs/point-on-globe/element-point-glow.js';
4
4
  import { ElementGlobeSufaceGlowCache } from '../programs/point-on-globe/element-globe-surface-glow.js';
5
- import { LineOnGlobeCache } from '../programs/line-on-globe/naive-accurate-flexible.js';
5
+ import { LineOnGlobeCache } from '../programs/line-on-globe/naive-accurate-flexible';
6
6
  import { BufferOrchestrator, BufferManager } from "../util/account";
7
+ // @ts-ignore
7
8
  import { PickerDisplayer } from '../util/picking/picker-displayer.js';
8
9
  import { wgs84ToCartesian3d, wgs84ToMercator } from '../Math/methods';
9
- import { constraintFloat, opacityCheck } from '../util/check/typecheck.js';
10
+ import { constraintFloat, opacityCheck } from '../util/check/typecheck';
10
11
  import { createBufferAndReadInfo } from '../util/gl-util/buffer/attribute-loader';
11
12
  import { CameraUniformBlockTotemCache } from '../programs/totems/camerauniformblock';
12
13
  /**
@@ -3,10 +3,9 @@ import { LineOnGlobeCache } from '../programs/line-on-globe/naive-accurate-flexi
3
3
  import { CircleCache as Circle3DCache } from '../programs/line-on-globe/circle-accurate-3d';
4
4
  import { CircleCache, EDGE_COUNT as flatCircleEdgeCount, centerCoords2dflatDataCreator } from '../programs/line-on-globe/circle-accurate-flat';
5
5
  import { BufferOrchestrator, BufferManager } from '../util/account';
6
- import { mapGetOrThrow } from "../util/check/get";
7
6
  import { populateFloat32Array } from "../util/jshelpers/data-filler";
8
7
  import { ContextTextWriter3 } from '../write-text/context-text3';
9
- import { constraintFloat, isBoolean } from '../util/check/typecheck';
8
+ import { constraintFloat, isBoolean, mapGetOrThrow } from '../util/check/typecheck';
10
9
  import { sphereCoord } from '../util/geometry';
11
10
  import { createBufferAndReadInfo } from '../util/gl-util/buffer/attribute-loader';
12
11
  export const RINGPARTIAL_DRAW_MODE = Object.freeze({
@@ -2,12 +2,11 @@ import { LineOnGlobeCache } from '../programs/line-on-globe/naive-accurate-flexi
2
2
  import { CircleCache, EDGE_COUNT as flatCircleEdgeCount, centerCoords2dflatDataCreator } from '../programs/line-on-globe/circle-accurate-flat';
3
3
  import { CircleCache as Circle3DCache } from '../programs/line-on-globe/circle-accurate-3d';
4
4
  import { BufferOrchestrator, BufferManager } from "../util/account";
5
- import { ChainListMap } from "./chain-list-map";
6
- import { mapGetOrThrow } from "../util/check/get";
5
+ import { ChainListMap } from "../range-tools-on-terrain/circle-line-chain/chain-list-map";
7
6
  import { keyMethod } from "./util";
8
7
  import { populateFloat32Array } from "../util/jshelpers/data-filler";
9
8
  import { ContextTextWriter3 } from '../write-text/context-text3';
10
- import { isBoolean, constraintFloat, opacityCheck } from '../util/check/typecheck';
9
+ import { opacityCheck, mapGetOrThrow } from '../util/check/typecheck';
11
10
  import { createBufferAndReadInfo } from '../util/gl-util/buffer/attribute-loader';
12
11
  import { sphereCoord } from '../util/geometry/index';
13
12
  /**
@@ -57,7 +56,7 @@ export class CircleLineChainPlugin {
57
56
  /**
58
57
  *
59
58
  * @param {*} id
60
- * @param {Map<[key, ContextTextWriter3]} textWritersMap //import { ContextTextWriter3 } from "@pirireis/webglobeplugins/write-text/context-text3";
59
+ * @param {Map<key, ContextTextWriter3>} textWritersMap //import { ContextTextWriter3 } from "@pirireis/webglobeplugins/write-text/context-text3";
61
60
  */
62
61
  constructor(id, { drawCircleOn = true, textWritersMap = new Map(), textDataPreAdaptor = null, circleFlatEdgeCount = flatCircleEdgeCount - 2 } = {}) {
63
62
  this.id = id;
@@ -131,8 +130,6 @@ export class CircleLineChainPlugin {
131
130
  }
132
131
  /**
133
132
  *
134
-
135
- /**
136
133
  * @param {Array<string>} textWriterIDs | textWritersMap keys to be used for writing text.
137
134
  * @param {Array<string>} chainKeys | if empty, all texts will be updated
138
135
  */
@@ -181,7 +178,7 @@ export class CircleLineChainPlugin {
181
178
  this.globe.DrawRender();
182
179
  }
183
180
  getChain(chainKey) {
184
- this._chainListMap.getChain(chainKey);
181
+ this._chainListMap.getNodes(chainKey);
185
182
  }
186
183
  /**
187
184
  *
@@ -32,6 +32,7 @@ export class PixelPaddingCompassPlugin {
32
32
  this._font_hold = { font, northFont };
33
33
  this.compassMap = new CompassMap(this);
34
34
  this._opacity = opacity;
35
+ this.isFreed = false;
35
36
  }
36
37
  init(globe, gl) {
37
38
  this.globe = globe;
@@ -135,6 +136,11 @@ export class PixelPaddingCompassPlugin {
135
136
  }
136
137
  // Globe API interface methods
137
138
  draw2D() {
139
+ if (this.isFreed) {
140
+ console.warn("PixelPaddingCompassPlugin is freed, cannot draw.");
141
+ return;
142
+ }
143
+ ;
138
144
  const { gl, globe, paddingProgram, paddingVao, bufferOrchestrator, bufferManagersCompMap } = this;
139
145
  const is3D = globe.api_GetCurrentGeometry() === 0;
140
146
  if (is3D)
@@ -153,6 +159,12 @@ export class PixelPaddingCompassPlugin {
153
159
  this.writer?.draw();
154
160
  }
155
161
  free() {
162
+ if (this.isFreed) {
163
+ console.warn("PixelPaddingCompassPlugin is already freed.");
164
+ return;
165
+ }
166
+ ;
167
+ this.isFreed = true;
156
168
  this.compassMap.free();
157
169
  const { globe, gl, paddingVao } = this;
158
170
  gl.deleteVertexArray(paddingVao);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.12.0-alpha",
3
+ "version": "0.14.0-alpha",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT",
@@ -1,4 +1,4 @@
1
- import { createProgram } from "../../util/webglobjectbuilders";
1
+ import { createProgram } from "../../util/index";
2
2
  import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totems/camerauniformblock";
3
3
  import { noRegisterGlobeProgramCache } from "../programcache";
4
4
  // import { vaoAttributeLoader } from "../../util/account/util";
@@ -0,0 +1,4 @@
1
+ export function createLineStripData(program, globe, gl, DrawStyleOptions) {
2
+ // @ts-ignore
3
+ return;
4
+ }
@@ -1,23 +1,21 @@
1
- import { createProgram } from "../../util/webglobjectbuilders";
2
- import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totems/index";
3
- import { cartesian3DToGLPosition, mercatorXYToGLPosition, } from "../../util/shaderfunctions/geometrytransformations";
4
- import { noRegisterGlobeProgramCache } from "../programcache";
5
- import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
6
- import "../../util/gl-util/buffer/attribute-loader";
7
- import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
8
- import "../../util/gl-util/uniform-block/types";
9
- import { drawArrays } from "../../util/gl-util/draw-options/methods";
10
- import "../../util/gl-util/draw-options/types";
1
+ import { createProgram } from "../../../util/webglobjectbuilders";
2
+ import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../../totems/index";
3
+ import { cartesian3DToGLPosition, mercatorXYToGLPosition, } from "../../../util/shaderfunctions/geometrytransformations";
4
+ import { noRegisterGlobeProgramCache } from "../../programcache";
5
+ import { attributeLoader } from "../../../util/gl-util/buffer/attribute-loader";
6
+ import "../../../util/gl-util/buffer/attribute-loader";
7
+ import { UniformBlockManager } from "../../../util/gl-util/uniform-block/manager";
8
+ import { drawArrays } from "../../../util/gl-util/draw-options/methods";
11
9
  const ESCAPE_VALUE = -1;
12
10
  const uniformBindingPoints = {
13
11
  camera: 0,
14
12
  flexible: 1,
15
13
  };
16
- const one = new Float32Array([1]);
14
+ // const one = new Float32Array([1]);
17
15
  const flexibleBlockManager = new UniformBlockManager('FlexibleAttributes', [
18
16
  { name: "u_color", type: "vec4", value: new Float32Array([0.12, 1, 0.1, 1]) },
19
- { name: "u_dash_opacity", type: "float", value: one },
20
- { name: "u_dash_length", type: "float", value: one },
17
+ // { name: "u_dash_opacity", type: "float", value: one },
18
+ // { name: "u_dash_length", type: "float", value: one },
21
19
  ], uniformBindingPoints.flexible);
22
20
  const vertexShaderSource = `#version 300 es
23
21
  precision highp float;
@@ -28,14 +26,16 @@ ${mercatorXYToGLPosition}
28
26
 
29
27
  ${flexibleBlockManager.glslCode()}
30
28
 
29
+ uniform float u_opacity;
30
+
31
31
  in vec3 position3d;
32
32
  in vec2 position2d;
33
33
  in vec4 color;
34
- in float dash_length;
35
- in float dash_opacity;
34
+ // in float dash_length;
35
+ // in float dash_opacity;
36
36
 
37
- out float v_dash_length;
38
- out float v_dash_opacity;
37
+ // out float v_dash_length;
38
+ // out float v_dash_opacity;
39
39
  out vec4 v_color;
40
40
 
41
41
  flat out vec3 v_flat_position;
@@ -44,8 +44,10 @@ out vec3 v_position;
44
44
  void main() {
45
45
 
46
46
  v_color = ( color.r == -1.0 ) ? u_color : color;
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;
47
+ v_color.a *= u_opacity;
48
+
49
+ // v_dash_length = ( dash_length == -1.0 ) ? u_dash_length : dash_length;
50
+ // v_dash_opacity = ( dash_opacity == -1.0 ) ? u_dash_opacity : dash_opacity;
49
51
 
50
52
  if ( is3D ) {
51
53
  gl_Position = cartesian3DToGLPosition( position3d );
@@ -70,22 +72,21 @@ in float v_dash_opacity;
70
72
  flat in vec3 v_flat_position;
71
73
  in vec3 v_position;
72
74
 
73
-
74
75
  out vec4 outColor;
75
76
 
76
77
  void main() {
77
78
  outColor = v_color;
78
79
  return;
79
- float dash_length = v_dash_length;
80
- float dash_opacity = v_dash_opacity;
80
+ // float dash_length = v_dash_length;
81
+ // float dash_opacity = v_dash_opacity;
81
82
 
82
- if ( dash_length == 0.0 ) {
83
- outColor = vec4( v_color.rgb, v_color.a * v_dash_opacity );
84
- } else {
85
- float dist = distance( v_flat_position, v_position );
86
- // float alpha = mod( dist , v_dash_length * 2.0 ) / v_dash_length < 1.0 ? 1.0 : v_dash_opacity;
87
- outColor = vec4( v_color.rgb, v_color.a * opacity );
88
- }
83
+ // if ( dash_length == 0.0 ) {
84
+ outColor = vec4( v_color.rgb, v_color.a );
85
+ // } else {
86
+ // float dist = distance( v_flat_position, v_position );
87
+ // // float alpha = mod( dist , v_dash_length * 2.0 ) / v_dash_length < 1.0 ? 1.0 : v_dash_opacity;
88
+ // outColor = vec4( 1.0, 1.0, 1.0, v_color.a * opacity *alpha);
89
+ // }
89
90
  }`;
90
91
  export class LineProgram {
91
92
  _vaosPublished = [];
@@ -105,14 +106,14 @@ export class LineProgram {
105
106
  this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
106
107
  const currentProgram = this.gl.getParameter(this.gl.CURRENT_PROGRAM);
107
108
  this.gl.useProgram(this.program);
108
- this._opacity.location = this.gl.getUniformLocation(this.program, "opacity");
109
+ this._opacity.location = this.gl.getUniformLocation(this.program, "u_opacity");
109
110
  this.gl.uniform1f(this._opacity.location, this._opacity.value);
110
111
  // bind attribute locations
111
112
  this.gl.bindAttribLocation(this.program, 0, "position3d");
112
113
  this.gl.bindAttribLocation(this.program, 1, "position2d");
113
114
  this.gl.bindAttribLocation(this.program, 2, "color");
114
- this.gl.bindAttribLocation(this.program, 3, "dash_length");
115
- this.gl.bindAttribLocation(this.program, 4, "dash_opacity");
115
+ // this.gl.bindAttribLocation(this.program, 3, "dash_length");
116
+ // this.gl.bindAttribLocation(this.program, 4, "dash_opacity");
116
117
  this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
117
118
  this.cameraBlockTotem.assignBindingPoint(this.program, uniformBindingPoints.camera);
118
119
  flexibleBlockManager.assignBindingPoint(this.gl, this.program);
@@ -124,15 +125,16 @@ export class LineProgram {
124
125
  this._ubosPublished.push(ubo);
125
126
  return ubo;
126
127
  }
127
- createVAO(position3D, position2D, color, dashLength, dashOpacity) {
128
+ createVAO(position3D, position2D, color //, dashLength: BufferAndReadInfo, dashOpacity: BufferAndReadInfo,
129
+ ) {
128
130
  const { gl } = this;
129
131
  const vao = gl.createVertexArray();
130
132
  gl.bindVertexArray(vao);
131
133
  attributeLoader(gl, position3D, 0, 3);
132
134
  attributeLoader(gl, position2D, 1, 2);
133
135
  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] });
136
+ // attributeLoader(gl, dashLength, 3, 1, { escapeValues: [ESCAPE_VALUE] });
137
+ // attributeLoader(gl, dashOpacity, 4, 1, { escapeValues: [ESCAPE_VALUE] });
136
138
  gl.bindVertexArray(null);
137
139
  return vao;
138
140
  }
@@ -1,10 +1,9 @@
1
- import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totems";
1
+ import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totems/camerauniformblock";
2
2
  import { slerp, POLE, R_3D, mercatorXYToGLPosition, cartesian3DToGLPosition } from "../../util/shaderfunctions/geometrytransformations";
3
- import { createProgram } from "../../util";
3
+ import { createProgram } from "../../util/webglobjectbuilders";
4
4
  import { noRegisterGlobeProgramCache } from "../programcache";
5
5
  import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
6
6
  import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
7
- import "../../util/gl-util/draw-options/types";
8
7
  import { drawInstanced } from "../../util/gl-util/draw-options/methods";
9
8
  const GLOBE_MIDPOINT_COUNT = 30;
10
9
  const escapeValue = -1.0;
@@ -13,9 +12,9 @@ const uniformBindingPoints = {
13
12
  flexible: 1
14
13
  };
15
14
  const uniformBlockManager = new UniformBlockManager('FlexibleAttibutes', [
16
- { name: 'u_color', type: 'vec4' },
17
- { name: 'u_dash_ratio', type: 'float' },
18
- { name: 'u_dash_opacity', type: 'float' }
15
+ { name: 'u_color', type: 'vec4', value: null },
16
+ { name: 'u_dash_ratio', type: 'float', value: null },
17
+ { name: 'u_dash_opacity', type: 'float', value: null }
19
18
  ], uniformBindingPoints.flexible);
20
19
  const vertexShader = `#version 300 es
21
20
  precision highp float;
@@ -96,6 +95,14 @@ void main() {
96
95
  class Logic {
97
96
  vaosPublished = [];
98
97
  isFreed = false;
98
+ globe;
99
+ gl;
100
+ program;
101
+ _lastOpacity;
102
+ _opacityLocation;
103
+ cameraBlockTotem;
104
+ _ubosPublished;
105
+ _defaultFlexibleUBO;
99
106
  constructor(globe) {
100
107
  this.globe = globe;
101
108
  this.gl = globe.gl;
@@ -122,14 +129,11 @@ class Logic {
122
129
  this._defaultFlexibleUBO = this.createUBO();
123
130
  }
124
131
  /**
125
- *
126
- * @param {*} vao
127
- * @param {DrawRangeIndexParams} drawOptions
128
- * @param {number} opacity
129
- * @param {Object} flexibleOptions
130
- * @param {Array<number, number, number, number>} flexibleOptions.color // 0-1
131
- * @param {number} flexibleOptions.dash_opacity
132
- * @param {number} flexibleOptions.dash_ratio
132
+ * Draw method for rendering lines on globe
133
+ * @param vao - WebGL Vertex Array Object
134
+ * @param drawOptions - Draw range index parameters
135
+ * @param opacity - Opacity value (0-1)
136
+ * @param flexibleUBO - Optional flexible uniform buffer object
133
137
  */
134
138
  draw(vao, drawOptions, opacity, flexibleUBO = null) {
135
139
  const { gl, program, globe, cameraBlockTotem, _defaultFlexibleUBO } = this;
@@ -162,6 +166,9 @@ class Logic {
162
166
  createVAO(startPotision2DBufferObj, startPotision3DBufferObj, endPosition2DBufferObj, endPosition3DBufferObj, dashRatioBufferObj, dashOpacityBufferObj, colorBufferObj) {
163
167
  const { gl } = this;
164
168
  const vao = gl.createVertexArray();
169
+ if (!vao) {
170
+ throw new Error("Failed to create vertex array object");
171
+ }
165
172
  gl.bindVertexArray(vao);
166
173
  const divisor = 1;
167
174
  attributeLoader(gl, startPotision2DBufferObj, 0, 2, { divisor });
@@ -181,8 +188,8 @@ class Logic {
181
188
  return;
182
189
  CameraUniformBlockTotemCache.release(this.globe);
183
190
  this.gl.deleteProgram(this.program);
184
- this.vaosPublished.forEach(vao => this.gl.deleteVertexArray(vao));
185
- this._ubosPublished.forEach(ubo => ubo.free());
191
+ this.vaosPublished.forEach((vao) => this.gl.deleteVertexArray(vao));
192
+ this._ubosPublished.forEach((ubo) => ubo.free());
186
193
  this.isFreed = true;
187
194
  }
188
195
  }
@@ -2,8 +2,7 @@ import { createProgram } from "../../util";
2
2
  import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems";
3
3
  import { mercatorXYToGLPosition, cartesian3DToGLPosition, R_3D, R } from "../../util/shaderfunctions/geometrytransformations";
4
4
  import { noRegisterGlobeProgramCache } from "../programcache";
5
- import "../../util/gl-util/draw-options/types";
6
- import { drawArrays } from "../../util/gl-util/draw-options/methods";
5
+ import { drawArrays, DrawRangeIndexParams } from "../../util/gl-util/draw-options/methods";
7
6
  import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
8
7
  import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
9
8
  const uniformBindingPoints = {