@pirireis/webglobeplugins 0.16.7 → 0.17.1

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 (159) hide show
  1. package/Math/angle-calculation.js +1 -0
  2. package/Math/contour/quadtreecontours.js +300 -0
  3. package/Math/finite-line-2d.js +58 -0
  4. package/Math/methods.js +6 -0
  5. package/Math/tessellation/hybrid-triangle-tessellation-meta.js +123 -0
  6. package/Math/tessellation/tile-merger.js +298 -0
  7. package/Math/tessellation/triangle-tessellation-meta.js +195 -42
  8. package/Math/tessellation/triangle-tessellation.js +5 -1
  9. package/compass-rose/compass-text-writer.js +39 -33
  10. package/constants.js +3 -0
  11. package/{util/heatwavedatamanager → heatwave}/datamanager.js +1 -1
  12. package/heatwave/{plugins/heatwaveglobeshell.js → heatwave.js} +8 -6
  13. package/heatwave/index.js +5 -3
  14. package/heatwave/{isobar/plugin.js → isobar.js} +6 -5
  15. package/{util/heatwavedatamanager → heatwave}/texture-point-sampler.js +24 -3
  16. package/investigation-tools/draw/tiles/adapters.js +67 -0
  17. package/investigation-tools/draw/tiles/tiles.js +128 -0
  18. package/package.json +4 -2
  19. package/programs/arrowfield/{object.js → arrow-field.js} +1 -1
  20. package/programs/arrowfield/logic.js +1 -1
  21. package/programs/data2legend/density-to-legend.js +24 -29
  22. package/programs/data2legend/point-to-density-texture.js +14 -17
  23. package/programs/float2legendwithratio/logic.js +2 -2
  24. package/programs/float2legendwithratio/object.js +1 -1
  25. package/programs/helpers/{blender/program.js → blender.js} +1 -1
  26. package/programs/helpers/{fadeaway/logic.js → fadeaway.js} +11 -2
  27. package/programs/index.js +20 -9
  28. package/programs/line-on-globe/circle-accurate-3d.js +12 -14
  29. package/programs/line-on-globe/circle-accurate-flat.js +0 -1
  30. package/programs/line-on-globe/degree-padding-around-circle-3d.js +13 -15
  31. package/programs/line-on-globe/lines-color-instanced-flat.js +15 -18
  32. package/programs/line-on-globe/naive-accurate-flexible.js +0 -1
  33. package/programs/picking/pickable-polygon-renderer.js +1 -1
  34. package/programs/picking/pickable-renderer.js +2 -2
  35. package/programs/point-on-globe/element-globe-surface-glow.js +2 -2
  36. package/programs/point-on-globe/element-point-glow.js +1 -1
  37. package/programs/point-on-globe/square-pixel-point.js +1 -1
  38. package/programs/polygon-on-globe/texture-dem-triangle-test-plugin-triangle.js +180 -30
  39. package/programs/polygon-on-globe/texture-dem-triangles.js +93 -34
  40. package/programs/rings/partial-ring/piece-of-pie.js +26 -29
  41. package/programs/totems/camerauniformblock.js +31 -42
  42. package/programs/two-d/pixel-padding-for-compass.js +14 -24
  43. package/programs/vectorfields/logics/drawrectangleparticles.js +9 -8
  44. package/programs/vectorfields/logics/drawrectangleparticles1.js +112 -0
  45. package/programs/vectorfields/logics/pixelbased.js +1 -2
  46. package/programs/vectorfields/pingpongbuffermanager.js +1 -1
  47. package/range-tools-on-terrain/bearing-line/adapters.js +1 -1
  48. package/range-tools-on-terrain/circle-line-chain/adapters.js +0 -5
  49. package/range-tools-on-terrain/circle-line-chain/plugin.js +1 -1
  50. package/range-tools-on-terrain/range-ring/plugin.js +4 -6
  51. package/semiplugins/lightweight/line-plugin.js +0 -1
  52. package/semiplugins/shape-on-terrain/arc-plugin.js +9 -2
  53. package/semiplugins/shape-on-terrain/circle-plugin.js +2 -2
  54. package/semiplugins/shape-on-terrain/padding-1-degree.js +1 -1
  55. package/semiplugins/shell/bbox-renderer/index.js +2 -0
  56. package/{programs/globeshell/wiggle → semiplugins/shell/bbox-renderer}/logic.js +101 -102
  57. package/{programs/globeshell/wiggle → semiplugins/shell/bbox-renderer}/object.js +6 -7
  58. package/semiplugins/utility/container-plugin.js +94 -0
  59. package/semiplugins/utility/object-pass-container-plugin.js +80 -0
  60. package/{point-heat-map → tracks/point-heat-map}/adaptors/timetracksplugin-format-to-this.js +1 -1
  61. package/{point-heat-map → tracks/point-heat-map}/plugin-webworker.js +3 -3
  62. package/{point-heat-map → tracks/point-heat-map}/point-to-heat-map-flow.js +11 -14
  63. package/{point-tracks → tracks/point-tracks}/plugin.js +6 -5
  64. package/{timetracks → tracks/timetracks}/adaptors-line-strip.js +1 -1
  65. package/{timetracks → tracks/timetracks}/program-line-strip.js +49 -49
  66. package/{timetracks → tracks/timetracks}/programpoint-line-strip.js +16 -13
  67. package/types.js +6 -0
  68. package/util/account/bufferoffsetmanager.js +1 -1
  69. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +9 -95
  70. package/util/gl-util/uniform-block/manager.js +0 -1
  71. package/util/gl-util/uniform-block/types.js +0 -7
  72. package/util/index.js +10 -13
  73. package/util/picking/fence.js +16 -18
  74. package/util/picking/picker-displayer.js +6 -8
  75. package/util/programs/{shapesonglobe.js → draw-from-pixel-coords.js} +4 -7
  76. package/util/programs/draw-texture-on-canvas.js +1 -1
  77. package/util/programs/texturetoglobe.js +3 -3
  78. package/util/shaderfunctions/geometrytransformations.js +1 -1
  79. package/vectorfield/arrowfield/index.js +3 -0
  80. package/{arrowfield → vectorfield/arrowfield}/plugin.js +2 -2
  81. package/{waveparticles → vectorfield/waveparticles}/plugin.js +12 -12
  82. package/{wind → vectorfield/wind}/index.js +1 -1
  83. package/{wind → vectorfield/wind}/plugin.js +65 -51
  84. package/write-text/context-text3.js +0 -1
  85. package/write-text/context-text4.js +2 -1
  86. package/write-text/objectarraylabels/index.js +2 -0
  87. package/Math/tessellation/tessellation-algorithm.js +0 -67
  88. package/arrowfield/index.js +0 -3
  89. package/bearing-line/index.js +0 -2
  90. package/bearing-line/plugin.js +0 -444
  91. package/circle-line-chain/chain-list-map.js +0 -201
  92. package/circle-line-chain/init.js +0 -1
  93. package/circle-line-chain/plugin.js +0 -411
  94. package/circle-line-chain/util.js +0 -1
  95. package/compassrose/compassrose.js +0 -293
  96. package/compassrose/index.js +0 -2
  97. package/index.js +0 -12
  98. package/partialrings/buffer-manager.js +0 -75
  99. package/partialrings/index.js +0 -2
  100. package/partialrings/plugin.js +0 -128
  101. package/partialrings/program.js +0 -279
  102. package/programs/arrowfield/index.js +0 -2
  103. package/programs/globe-util/is-globe-moved.js +0 -19
  104. package/programs/globeshell/index.js +0 -2
  105. package/programs/globeshell/wiggle/index.js +0 -2
  106. package/programs/helpers/blender/index.js +0 -1
  107. package/programs/helpers/fadeaway/index.js +0 -2
  108. package/programs/helpers/fadeaway/object.js +0 -14
  109. package/programs/helpers/index.js +0 -2
  110. package/programs/polygon-on-globe/texture-dem-triangle-test-plugin.js +0 -118
  111. package/programs/rings/distancering/circleflatprogram.js +0 -116
  112. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +0 -326
  113. package/programs/rings/distancering/circlepaddysharedbuffer.js +0 -368
  114. package/programs/rings/distancering/index.js +0 -6
  115. package/programs/rings/distancering/paddyflatprogram.js +0 -127
  116. package/programs/rings/distancering/paddyflatprogram2d.js +0 -129
  117. package/programs/rings/distancering/paddyflatprogram3d.js +0 -128
  118. package/programs/two-d/pixel-circle.js +0 -1
  119. package/programs/vectorfields/index.js +0 -3
  120. package/rangerings/enum.js +0 -2
  121. package/rangerings/index.js +0 -5
  122. package/rangerings/plugin.js +0 -543
  123. package/rangerings/rangeringangletext.js +0 -326
  124. package/rangerings/ring-account.js +0 -112
  125. package/timetracks/index.js +0 -1
  126. package/util/build-strategy/general-strategy.js +0 -62
  127. package/util/gl-util/uniform-block/shader.js +0 -1
  128. package/util/heatwavedatamanager/index.js +0 -2
  129. package/util/heatwavedatamanager/pointcoordsmeta.js +0 -22
  130. package/util/jshelpers/data-filler.js +0 -17
  131. package/util/jshelpers/equality.js +0 -18
  132. package/util/jshelpers/index.js +0 -2
  133. package/util/jshelpers/timefilters.js +0 -30
  134. package/util/programs/index.js +0 -1
  135. package/util/surface-line-data/arc-bboxes.js +0 -25
  136. package/util/surface-line-data/arcs-to-cuts.js +0 -50
  137. package/util/surface-line-data/cut-arc.js +0 -1
  138. package/util/surface-line-data/flow.js +0 -28
  139. package/util/surface-line-data/rbush-manager.js +0 -1
  140. package/util/surface-line-data/types.js +0 -1
  141. package/util/surface-line-data/web-worker.js +0 -1
  142. package/util/webglobe/rasteroverlay.js +0 -75
  143. package/write-text/attached-text-writer.js +0 -87
  144. package/write-text/context-text3old.js +0 -152
  145. package/write-text/index.js +0 -1
  146. package/write-text/writer-plugin.js +0 -8
  147. /package/{heatwave/isobar/quadtreecontours.js → Math/contour/quadtreecontours1.js} +0 -0
  148. /package/pin/{pin-object-array.js → pin-object-array1.js} +0 -0
  149. /package/pin/{pin-point-totem.js → pin-point-totem1.js} +0 -0
  150. /package/{point-heat-map → tracks/point-heat-map}/index.js +0 -0
  151. /package/{point-tracks → tracks/point-tracks}/key-methods.js +0 -0
  152. /package/{timetracks → tracks/timetracks}/plugin-line-strip.js +0 -0
  153. /package/{arrowfield → vectorfield/arrowfield}/adaptor.js +0 -0
  154. /package/{waveparticles → vectorfield/waveparticles}/adaptor.js +0 -0
  155. /package/{waveparticles → vectorfield/waveparticles}/index.js +0 -0
  156. /package/{wind → vectorfield/wind}/imagetovectorfieldandmagnitude.js +0 -0
  157. /package/{wind → vectorfield/wind}/vectorfieldimage.js +0 -0
  158. /package/write-text/{context-text.js → context-textDELETE.js} +0 -0
  159. /package/{heatwave/isobar → write-text/objectarraylabels}/objectarraylabels.js +0 -0
@@ -1,17 +1,5 @@
1
- import { CSZMode, CSMeasureTextPositionTypes } from "@pirireis/webglobe";
2
- // const defaultStyle = {
3
- // textFont: {
4
- // name: 'Arial',
5
- // textColor: '#FFFFFF', // beyaz
6
- // hollowColor: '#000000', // siyah
7
- // size: 12, // piksel
8
- // hollow: true,
9
- // bold: true,
10
- // italic: false,
11
- // },
12
- // opacity: 1.0,
13
- // zMode: CSZMode.Z_GROUND_PERVERTEX,
14
- // }
1
+ // filepath: d:\webglobeplugins\webglobePlugin\src\webglobeplugins\compass-rose\compass-text-writer.ts
2
+ import { CSMeasureTextPositionTypes } from "@pirireis/webglobe";
15
3
  /**
16
4
  * TODOs:
17
5
  * 1) update all if initials change (propably need a context and a callback to iterate over data)
@@ -21,19 +9,32 @@ import { CSZMode, CSMeasureTextPositionTypes } from "@pirireis/webglobe";
21
9
  const yGapFit = -2;
22
10
  const xGapFit = -5;
23
11
  export class PixelPaddingCompassTextWriter {
12
+ globe;
13
+ itemMap;
14
+ font;
15
+ northFont;
16
+ doDraw;
17
+ angle;
18
+ angles;
19
+ texts;
20
+ positions;
21
+ _lastNorthAngle;
22
+ offsets;
23
+ keyAdaptor;
24
+ opacity;
24
25
  constructor(globe, { font = {
25
26
  name: 'Arial',
26
- textColor: '#FFFFFF', // beyaz
27
- hollowColor: '#000000', // siyah
28
- size: 12, // piksel
27
+ textColor: '#FFFFFF',
28
+ hollowColor: '#000000',
29
+ size: 12,
29
30
  hollow: true,
30
31
  bold: true,
31
32
  italic: false,
32
33
  }, northFont = {
33
34
  name: 'Arial',
34
- textColor: '#BB0000', // beyaz
35
- hollowColor: '#000000', // siyah
36
- size: 14, // piksel
35
+ textColor: '#BB0000',
36
+ hollowColor: '#000000',
37
+ size: 14,
37
38
  hollow: true,
38
39
  bold: true,
39
40
  italic: false,
@@ -56,17 +57,16 @@ export class PixelPaddingCompassTextWriter {
56
57
  this.positions.push(null);
57
58
  }
58
59
  this.angles.push(currentAngle);
59
- if (currentAngle == 0) {
60
+ if (currentAngle === 0) {
60
61
  this.texts.push("K");
61
62
  }
62
63
  else {
63
- // to string 3 chars fill left with 0
64
64
  this.texts.push(currentAngle.toString().padStart(3, '0'));
65
65
  }
66
66
  currentAngle += this.angle;
67
67
  }
68
68
  this._lastNorthAngle = globe.api_GetCurrentLookInfo()["NorthAng"] * (Math.PI / 180);
69
- this.offsets = this.__offset(this._lastNorthAngle);
69
+ this.offsets = this.__offset();
70
70
  }
71
71
  setKeyAdaptor(adaptor) {
72
72
  this.keyAdaptor = adaptor;
@@ -86,7 +86,6 @@ export class PixelPaddingCompassTextWriter {
86
86
  _checkSetOffsets() {
87
87
  const { globe } = this;
88
88
  const newAngle = globe.api_GetCurrentLookInfo()["NorthAng"] * (Math.PI / 180);
89
- ;
90
89
  if (newAngle !== this._lastNorthAngle) {
91
90
  this._lastNorthAngle = newAngle;
92
91
  this.offsets = this.__offset();
@@ -96,42 +95,49 @@ export class PixelPaddingCompassTextWriter {
96
95
  if (!this.doDraw)
97
96
  return;
98
97
  const { globe, font, opacity: opacity_, northFont, itemMap, texts, angles, positions } = this;
99
- this._checkSetOffsets(); // zMode: CSZMode.Z_GROUND_PERVERTEX,
98
+ this._checkSetOffsets();
100
99
  const offsets = this.offsets;
101
100
  for (const [key, { center, radius, opacity = null }] of itemMap) {
102
- const o = opacity === null ? opacity_ : opacity * opacity_;
103
- if (center.x !== null && center.y !== null) {
101
+ const o = opacity === null ? (opacity_ ?? 1.0) : opacity * (opacity_ ?? 1.0);
102
+ if (center && radius !== undefined) {
103
+ const { x, y } = center;
104
+ if (x === null || y === null)
105
+ continue;
104
106
  offsets.forEach(({ offsetX, offsetY }, i) => {
105
107
  const text = texts[i];
106
108
  const angle = angles[i];
107
109
  font.position = positions[i];
108
110
  if (angle === 0) {
109
- globe.api_DrawContextTextMultiLine(text, northFont, o, { x: center.x + offsetX * radius + xGapFit, y: center.y + offsetY * radius + yGapFit });
111
+ globe.api_DrawContextTextMultiLine(text, northFont, o, { x: x + offsetX * radius + xGapFit, y: y + offsetY * radius + yGapFit });
110
112
  }
111
113
  else {
112
- globe.api_DrawContextTextMultiLine(text, font, o, { x: center.x + offsetX * radius + xGapFit, y: center.y + offsetY * radius + yGapFit });
114
+ globe.api_DrawContextTextMultiLine(text, font, o, { x: x + offsetX * radius + xGapFit, y: y + offsetY * radius + yGapFit });
113
115
  }
114
116
  });
115
117
  }
116
118
  }
117
119
  }
118
- insertTextItem(key, x, y, radius = undefined) {
120
+ insertTextItem(key, x, y, radius) {
119
121
  const item = this.getItem(key);
120
122
  item.center = { x, y };
121
123
  if (radius === undefined)
122
124
  return;
123
- if (item.radius != undefined && item.radius === radius)
125
+ if (item.radius !== undefined && item.radius === radius)
124
126
  return;
125
127
  item.radius = radius;
126
128
  }
127
129
  getItem(key) {
128
- if (!this.itemMap.has(key))
130
+ if (!this.itemMap.has(key)) {
129
131
  this.itemMap.set(key, {});
132
+ }
130
133
  return this.itemMap.get(key);
131
134
  }
132
135
  __calculateOffset(angle) {
133
136
  const rAngle = (angle - 90) * (Math.PI / 180);
134
- return { offsetX: Math.cos(rAngle + this._lastNorthAngle), offsetY: Math.sin(rAngle + this._lastNorthAngle) };
137
+ return {
138
+ offsetX: Math.cos(rAngle + this._lastNorthAngle),
139
+ offsetY: Math.sin(rAngle + this._lastNorthAngle)
140
+ };
135
141
  }
136
142
  __offset() {
137
143
  const angle = this.angle;
package/constants.js CHANGED
@@ -1,3 +1,6 @@
1
+ export const CSRenderPassPluginKeys = ["supportNormalPass",
2
+ "supportSelectedPass",
3
+ "supportEditingPass"];
1
4
  export const GLOBE_DEFAULT_MIN_LOD = 2;
2
5
  export const GLOBE_DEFAULT_MAX_LOD = 25;
3
6
  export const POLE2 = 12756274.0;
@@ -2,7 +2,7 @@
2
2
  * todo:
3
3
  * data must be processed before being set to the cache
4
4
  */
5
- export default class DataManager {
5
+ export class DataManager {
6
6
  /**
7
7
  *
8
8
  * @param {Array<number>} timeEpocs | array of time epocs
@@ -1,7 +1,9 @@
1
- import { getColorRampModed, DataManager, } from "../../util/index";
2
- import { TexturePointSampler } from "../../util/heatwavedatamanager/texture-point-sampler";
3
- import { GlobeShellWiggle, Float2LegendWithRatio } from "../../programs";
4
- import { opacityCheck } from "../../util/check/typecheck";
1
+ import { getColorRampModed } from "../util/webglobjectbuilders";
2
+ import { DataManager } from "./datamanager";
3
+ import { TexturePointSampler } from "./texture-point-sampler";
4
+ import { BBOXGlobeShell } from "../semiplugins/shell/bbox-renderer";
5
+ import { Float2LegendWithRatio } from "../programs/float2legendwithratio";
6
+ import { opacityCheck } from "../util/check/typecheck";
5
7
  /**
6
8
  * @param id : string
7
9
  * @param dataManager : DataManager
@@ -9,7 +11,7 @@ import { opacityCheck } from "../../util/check/typecheck";
9
11
  * @param dataWidthHeight : {width: number, height: number}
10
12
  * @param options : {bbox: number[], minMaxEdges: {min: number, max: number}, escapeValue: number, resolution: number[], meshPartition: number[]}
11
13
  */
12
- export default class HeatWaveGlobeShellPlugin {
14
+ export class HeatWavePlugin {
13
15
  constructor(id, dataManager, colorRampData, dataWidthHeight, { bbox = [-180, -90, 180, 90], minMaxEdges = { min: -99999, max: 99999 }, escapeValue = 99999, resolution = [2056, 2056], yFlip = true, } = {}) {
14
16
  this.id = id;
15
17
  this.dataManager = dataManager;
@@ -152,7 +154,7 @@ export default class HeatWaveGlobeShellPlugin {
152
154
  this.setEscapeValue(this._escapeValue);
153
155
  }
154
156
  _init(globe, gl) {
155
- this.globeShell = new GlobeShellWiggle(gl, globe, {
157
+ this.globeShell = new BBOXGlobeShell(gl, globe, {
156
158
  minLon: this._bbox[0],
157
159
  minLat: this._bbox[1],
158
160
  maxLon: this._bbox[2],
package/heatwave/index.js CHANGED
@@ -1,3 +1,5 @@
1
- import HeatWavePlugin from './plugins/heatwaveglobeshell';
2
- import { IsobarRasterToVector } from './isobar/plugin';
3
- export { HeatWavePlugin, IsobarRasterToVector };
1
+ import { DataManager } from "./datamanager.js";
2
+ import { HeatWavePlugin } from "./heatwave.js";
3
+ import { IsobarRasterToVector } from "./isobar.js";
4
+ import { TexturePointSampler } from "./texture-point-sampler";
5
+ export { DataManager, HeatWavePlugin, IsobarRasterToVector, TexturePointSampler };
@@ -1,7 +1,8 @@
1
- import { ShapesOnGlobeProgram, latLongToPixelXY } from "../../util";
2
- import ContourMipmap, { scaleParameters } from "./quadtreecontours";
3
- import ObjectArrayLabels from "./objectarraylabels";
4
- import { isBoolean, opacityCheck } from "../../util/check/typecheck";
1
+ import { DrawFromPixelCoords, } from "../util/programs/draw-from-pixel-coords";
2
+ import { latLongToPixelXY } from "../util/geometry/index";
3
+ import ContourMipmap, { scaleParameters } from "../Math/contour/quadtreecontours";
4
+ import ObjectArrayLabels from "../write-text/objectarraylabels";
5
+ import { isBoolean, opacityCheck } from "../util/check/typecheck";
5
6
  export class IsobarRasterToVector {
6
7
  /**
7
8
  * @typedef {Object} IsobarData
@@ -151,7 +152,7 @@ export class IsobarRasterToVector {
151
152
  init(globe, gl) {
152
153
  this.gl = gl;
153
154
  this.globe = globe;
154
- this.program = new ShapesOnGlobeProgram(gl, globe, 'line_strip');
155
+ this.program = new DrawFromPixelCoords(gl, globe, 'line_strip');
155
156
  if (this._isLabelsOn) {
156
157
  this._createLabelsLayer();
157
158
  this._labelsLayer.addToMap();
@@ -1,4 +1,25 @@
1
- import PointCoordsMeta from "./pointcoordsmeta";
1
+ class PointCoordsMeta {
2
+ _bbox;
3
+ _width;
4
+ _height;
5
+ _xRatio;
6
+ _yRatio;
7
+ constructor(bbox, width, height) {
8
+ this._bbox = bbox;
9
+ this._width = width;
10
+ this._height = height;
11
+ this._xRatio = this._width / (this._bbox[2] - this._bbox[0]);
12
+ this._yRatio = this._height / (this._bbox[3] - this._bbox[1]);
13
+ }
14
+ getFlooredIndex(long, lat) {
15
+ let x = (long - this._bbox[0]) * this._xRatio;
16
+ let y = (this._bbox[3] - lat) * this._yRatio;
17
+ x = x > 0 ? x - 1 : 0;
18
+ y = y > 0 ? y - 1 : 0;
19
+ const index = Math.floor(y) * this._width + Math.floor(x);
20
+ return index;
21
+ }
22
+ }
2
23
  const pointObject = (long, lat, posIndex, callback) => {
3
24
  return { long, lat, posIndex, callback };
4
25
  };
@@ -103,7 +124,7 @@ export class TexturePointSampler {
103
124
  }
104
125
  flush(callEmptyCallback = false) {
105
126
  if (callEmptyCallback) {
106
- for (const [key, { callback }] of this._pointObjects.entries()) {
127
+ for (const [, { callback }] of this._pointObjects.entries()) {
107
128
  callback(null, null, null);
108
129
  }
109
130
  }
@@ -141,7 +162,7 @@ export class TexturePointSampler {
141
162
  }
142
163
  }
143
164
  else {
144
- for (const [key, { callback }] of this._pointObjects.entries()) {
165
+ for (const [, { callback }] of this._pointObjects.entries()) {
145
166
  callback(null, null, null);
146
167
  }
147
168
  }
@@ -0,0 +1,67 @@
1
+ function boilerArcInput(start, end, color, key) {
2
+ return {
3
+ key: key,
4
+ start: start,
5
+ end: end,
6
+ color: color,
7
+ height: null,
8
+ msl: null
9
+ };
10
+ }
11
+ export function tileToArcInputs(tiles, color) {
12
+ if (tiles.length === 0)
13
+ return [];
14
+ const result = [];
15
+ // (alias) type ArcInput = {
16
+ // key: string;
17
+ // start: LongLat;
18
+ // end: LongLat;
19
+ // color: Color;
20
+ // height?: Meter | null;
21
+ // msl?: boolean | null;
22
+ // }
23
+ for (const tile of tiles) {
24
+ const tileKey = `tile_${tile.row}_${tile.column}`;
25
+ const bbox = tile.bbox;
26
+ // left side
27
+ result.push(boilerArcInput([bbox.ll.x, bbox.ll.y], [bbox.ll.x, bbox.ur.y], color, `${tileKey}_left`));
28
+ // top side
29
+ result.push(boilerArcInput([bbox.ll.x, bbox.ur.y], [bbox.ur.x, bbox.ur.y], color, `${tileKey}_top`));
30
+ // bottom side
31
+ result.push(boilerArcInput([bbox.ll.x, bbox.ll.y], [bbox.ur.x, bbox.ll.y], color, `${tileKey}_bottom`));
32
+ // right side
33
+ result.push(boilerArcInput([bbox.ur.x, bbox.ll.y], [bbox.ur.x, bbox.ur.y], color, `${tileKey}_right`));
34
+ }
35
+ return result;
36
+ }
37
+ export function mergedTileToArcInputs(mergedTile, color) {
38
+ const result = [];
39
+ const bbox = mergedTile.bbox;
40
+ // left side
41
+ result.push(boilerArcInput([bbox.ll.x, bbox.ll.y], [bbox.ll.x, bbox.ur.y], color, `${mergedTile.zoom}_left`));
42
+ // right side
43
+ result.push(boilerArcInput([bbox.ur.x, bbox.ll.y], [bbox.ur.x, bbox.ur.y], color, `${mergedTile.zoom}_right`));
44
+ // top side
45
+ result.push(boilerArcInput([bbox.ll.x, bbox.ur.y], [bbox.ur.x, bbox.ur.y], color, `${mergedTile.zoom}_top`));
46
+ // bottom side
47
+ result.push(boilerArcInput([bbox.ll.x, bbox.ll.y], [bbox.ur.x, bbox.ll.y], color, `${mergedTile.zoom}_bottom`));
48
+ return result;
49
+ }
50
+ export function tilesToContextWriter4Inputs(tiles) {
51
+ const result = [];
52
+ for (const tile of tiles) {
53
+ const tileKey = `L_${tile.level}_R${tile.row}_C${tile.column}`;
54
+ const centerLong = (tile.bbox.ll.x + tile.bbox.ur.x) / 2;
55
+ const centerLat = (tile.bbox.ll.y + tile.bbox.ur.y) / 2;
56
+ result.push({
57
+ key: tileKey,
58
+ long: centerLong,
59
+ lat: centerLat,
60
+ text: tileKey,
61
+ opacity: null,
62
+ angle: null,
63
+ position: 'center'
64
+ });
65
+ }
66
+ return result;
67
+ }
@@ -0,0 +1,128 @@
1
+ import { ArcOnTerrainPlugin } from "../../../semiplugins/shape-on-terrain/arc-plugin";
2
+ import { tileToArcInputs, tilesToContextWriter4Inputs, mergedTileToArcInputs } from "./adapters";
3
+ import { ContextTextWriter4 } from "../../../write-text/context-text4";
4
+ import { mergeMeshes } from "../../../Math/tessellation/tile-merger";
5
+ // diverse ColorRamp
6
+ const defaultColorsRamp = [
7
+ [0.0, [0, 0, 255, 255]], // Blue
8
+ // [0.3, [255, 165, 0, 255]], // Orange
9
+ [0.25, [0, 255, 0, 255]], // Green
10
+ // [0.4, [255, 0, 0, 255]], // Red
11
+ [0.5, [128, 0, 128, 255]], // Purple
12
+ // [0.6, [0, 255, 255, 255]], // Cyan
13
+ [0.75, [255, 192, 203, 255]], // Pink
14
+ [1.0, [255, 255, 255, 255]], // White
15
+ // [1.0, [0, 0, 0, 255]] // Black
16
+ ];
17
+ export class TilesRendererPlugin {
18
+ id;
19
+ globe;
20
+ gl;
21
+ arcPlugin;
22
+ contextTextWriter;
23
+ colorsRamp;
24
+ _lastTilesUniqueIdentifier = null;
25
+ constructor(id, colorsRamp = defaultColorsRamp) {
26
+ this.globe = null;
27
+ this.gl = null;
28
+ this.contextTextWriter = null;
29
+ this.id = id;
30
+ this.colorsRamp = colorsRamp;
31
+ this.arcPlugin = new ArcOnTerrainPlugin(id + "_arc_plugin", {
32
+ variativeColorsOn: true,
33
+ defaultHeightFromGroundIn3D: 0,
34
+ });
35
+ }
36
+ init(globe, gl) {
37
+ this.globe = globe;
38
+ this.gl = gl;
39
+ this.contextTextWriter = new ContextTextWriter4(globe, (item) => { return [item]; }, (item) => { return item.key; }, (zoomLevel) => (item) => {
40
+ return {
41
+ opacityMultiplier: 1,
42
+ sizeMultiplier: 1
43
+ };
44
+ });
45
+ this.arcPlugin.init(globe, gl);
46
+ }
47
+ draw3D(projectionMatrix, modelViewMatrix, transPosition) {
48
+ // if (this.globe.api_IsScreenMoving()) {
49
+ this._prepareArcInputs();
50
+ // }
51
+ this.arcPlugin.draw3D();
52
+ this.contextTextWriter.draw();
53
+ }
54
+ free() {
55
+ this.arcPlugin.free();
56
+ }
57
+ _prepareArcInputs() {
58
+ // const drawnTiles = filterTilesInScreen(
59
+ // this.globe.api_GetDrawedTilesInfo(),
60
+ // this.globe
61
+ // );
62
+ const drawnTiles = this.globe.api_GetDrawedTilesInfo();
63
+ let maxLevel = 0;
64
+ let minLevel = Number.MAX_VALUE;
65
+ const tileMap = new Map();
66
+ for (const tile of drawnTiles) {
67
+ if (tile.level > maxLevel) {
68
+ maxLevel = tile.level;
69
+ }
70
+ if (tile.level < minLevel) {
71
+ minLevel = tile.level;
72
+ }
73
+ if (!tileMap.has(tile.level)) {
74
+ tileMap.set(tile.level, []);
75
+ }
76
+ tileMap.get(tile.level).push(tile);
77
+ }
78
+ let tilesUniqueId = "";
79
+ for (let level = minLevel; level <= maxLevel; level++) {
80
+ const tiles = tileMap.get(level);
81
+ if (!tiles)
82
+ continue;
83
+ tilesUniqueId += `L${level}_C${tiles.length}_`;
84
+ }
85
+ if (tilesUniqueId === this._lastTilesUniqueIdentifier)
86
+ return;
87
+ this._lastTilesUniqueIdentifier = tilesUniqueId;
88
+ const levelRange = maxLevel - minLevel;
89
+ const colors = this._interpolateColors(levelRange);
90
+ this.arcPlugin.deleteAll();
91
+ for (let level = maxLevel; level >= minLevel; level--) {
92
+ const tiles = tileMap.get(level);
93
+ if (!tiles)
94
+ continue;
95
+ const colorIndex = level - minLevel;
96
+ const color = colors[colorIndex];
97
+ const arcInputs = tileToArcInputs(tiles, color);
98
+ this.arcPlugin.insertBulk(arcInputs);
99
+ }
100
+ // drawMergedBBoxes:
101
+ const mergedTiles = mergeMeshes(drawnTiles, 12, 5, 4);
102
+ const color = [255, 255, 0, 255]; // Yellow
103
+ const arcMergedInputs = mergedTiles.map(mergedTile => mergedTileToArcInputs(mergedTile, color)).flat();
104
+ this.arcPlugin.insertBulk(arcMergedInputs);
105
+ const contextWriterInputs = tilesToContextWriter4Inputs(drawnTiles);
106
+ this.contextTextWriter.clear();
107
+ this.contextTextWriter.insertTextBulk(contextWriterInputs);
108
+ }
109
+ _interpolateColors(maxValue) {
110
+ let colors = [];
111
+ let colorRampIndex = 0;
112
+ for (let i = 0; i <= maxValue; i++) {
113
+ const t = i / maxValue;
114
+ while (colorRampIndex < this.colorsRamp.length - 1 && t > this.colorsRamp[colorRampIndex + 1][0]) {
115
+ colorRampIndex++;
116
+ }
117
+ const [t0, color0] = this.colorsRamp[colorRampIndex];
118
+ const [t1, color1] = this.colorsRamp[Math.min(colorRampIndex + 1, this.colorsRamp.length - 1)];
119
+ const localT = (t - t0) / (t1 - t0);
120
+ const r = Math.round(color0[0] + (color1[0] - color0[0]) * localT);
121
+ const g = Math.round(color0[1] + (color1[1] - color0[1]) * localT);
122
+ const b = Math.round(color0[2] + (color1[2] - color0[2]) * localT);
123
+ // const a = Math.round(color0[3] + (color1[3] - color0[3]) * localT);
124
+ colors.push([r, g, b, 255]);
125
+ }
126
+ return colors;
127
+ }
128
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.16.7",
3
+ "version": "0.17.1",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT",
@@ -8,9 +8,11 @@
8
8
  "build": "tsc"
9
9
  },
10
10
  "dependencies": {
11
- "@pirireis/webglobe": "^6.2.22",
12
11
  "delaunator": "^5.0.1",
13
12
  "earcut": "^3.0.2",
14
13
  "rbush": "^4.0.1"
14
+ },
15
+ "peerDependencies": {
16
+ "@pirireis/webglobe": "^6.2.22"
15
17
  }
16
18
  }
@@ -4,7 +4,7 @@
4
4
  import Logic from './logic';
5
5
  import { globeProgramCache } from '../programcache';
6
6
  import { longlatbbox2normalbbox } from "../util";
7
- export default class ArrowField {
7
+ export class ArrowField {
8
8
  constructor(gl, globe, { minLon = -180, maxLon = 180, minLat = -90, maxLat = 90, height = 0, opacity = 1, color = [0.04, 0.2, 0.8], targetWidth = 100, targetHeight = 100, dataWidth = null, dataHeight = null, tailLengthRatio = 1, wingLengthRatio = 0.5, noDataValue = null,
9
9
  // maxMagnitude = null
10
10
  } = {}) {
@@ -1,4 +1,4 @@
1
- import { createProgram } from "../../util";
1
+ import { createProgram } from "../../util/webglobjectbuilders";
2
2
  import { globeProgramCache } from "../programcache";
3
3
  import { CameraUniformBlockTotem } from "../totems";
4
4
  const arrowVertexShader = `#version 300 es
@@ -1,4 +1,4 @@
1
- import { createProgram } from "../../util/";
1
+ import { createProgram } from "../../util/webglobjectbuilders";
2
2
  import { noRegisterGlobeProgramCache } from "../programcache";
3
3
  const vs = `#version 300 es
4
4
  precision highp float;
@@ -38,34 +38,29 @@ class DensityToLegendProgram {
38
38
  legendTexture: gl.getUniformLocation(program, "u_legend_texture"),
39
39
  opacity: gl.getUniformLocation(program, "u_opacity"),
40
40
  };
41
- { // assign attribute locations
42
- gl.bindAttribLocation(program, 0, "a_position");
43
- }
44
- {
45
- this.vao = gl.createVertexArray();
46
- const a_positionLocation = gl.getAttribLocation(program, "a_position");
47
- gl.bindVertexArray(this.vao);
48
- const buffer = gl.createBuffer();
49
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
50
- gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
51
- -1, -1,
52
- 1, -1,
53
- 1, 1,
54
- -1, 1,
55
- ]), gl.STATIC_DRAW);
56
- gl.enableVertexAttribArray(a_positionLocation);
57
- gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
58
- gl.bindVertexArray(null);
59
- // gl.bindBuffer(gl.ARRAY_BUFFER, null);
60
- this._buffer = buffer;
61
- }
62
- {
63
- this._lastOpacity = 1;
64
- const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
65
- gl.useProgram(program);
66
- gl.uniform1f(this.uniforms.opacity, this._lastOpacity);
67
- gl.useProgram(currentProgram);
68
- }
41
+ // assign attribute locations
42
+ gl.bindAttribLocation(program, 0, "a_position");
43
+ this.vao = gl.createVertexArray();
44
+ const a_positionLocation = gl.getAttribLocation(program, "a_position");
45
+ gl.bindVertexArray(this.vao);
46
+ const buffer = gl.createBuffer();
47
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
48
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
49
+ -1, -1,
50
+ 1, -1,
51
+ 1, 1,
52
+ -1, 1,
53
+ ]), gl.STATIC_DRAW);
54
+ gl.enableVertexAttribArray(a_positionLocation);
55
+ gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
56
+ gl.bindVertexArray(null);
57
+ // gl.bindBuffer(gl.ARRAY_BUFFER, null);
58
+ this._buffer = buffer;
59
+ this._lastOpacity = 1;
60
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
61
+ gl.useProgram(program);
62
+ gl.uniform1f(this.uniforms.opacity, this._lastOpacity);
63
+ gl.useProgram(currentProgram);
69
64
  }
70
65
  draw(densityTexture, legendTexture, opacity) {
71
66
  const { gl, program, uniforms } = this;
@@ -1,4 +1,4 @@
1
- import { createProgram } from "../../util/";
1
+ import { createProgram } from "../../util/webglobjectbuilders";
2
2
  import { noRegisterGlobeProgramCache } from "../programcache";
3
3
  import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems/camerauniformblock";
4
4
  import { mercatorXYToGLPosition, cartesian3DToGLPosition } from "../../util/shaderfunctions/geometrytransformations";
@@ -41,22 +41,19 @@ class PointHeatmapProgram {
41
41
  this.uniforms = {
42
42
  pointSize: gl.getUniformLocation(this.program, "pointSize"),
43
43
  };
44
- { // assign attribute locations
45
- gl.bindAttribLocation(program, 0, "position");
46
- }
47
- { // arrange camera uniform block
48
- this.cameraBlockBingingPoint = 0;
49
- this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
50
- const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
51
- gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBingingPoint);
52
- }
53
- { // last values
54
- this._lastPointSize = 0;
55
- const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
56
- gl.useProgram(program);
57
- gl.uniform1f(this.uniforms.pointSize, this._lastPointSize);
58
- gl.useProgram(currentProgram);
59
- }
44
+ // assign attribute locations
45
+ gl.bindAttribLocation(program, 0, "position");
46
+ // arrange camera uniform block
47
+ this.cameraBlockBingingPoint = 0;
48
+ this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
49
+ const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
50
+ gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBingingPoint);
51
+ // last values
52
+ this._lastPointSize = 0;
53
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
54
+ gl.useProgram(program);
55
+ gl.uniform1f(this.uniforms.pointSize, this._lastPointSize);
56
+ gl.useProgram(currentProgram);
60
57
  }
61
58
  createVAO(positionBuffer, vectorSize) {
62
59
  const gl = this.gl;
@@ -1,5 +1,5 @@
1
- import { createProgram } from "../../util";
2
- export default class {
1
+ import { createProgram } from "../../util/webglobjectbuilders";
2
+ export class Float2LegentWithRatioProgram {
3
3
  constructor(gl) {
4
4
  this.gl = gl;
5
5
  this._width = 1;
@@ -1,4 +1,4 @@
1
- import Float2LegentWithRatioProgram from './logic';
1
+ import { Float2LegentWithRatioProgram } from './logic';
2
2
  import { glProgramCache } from '../programcache';
3
3
  // Uniform Buffer Objects use this
4
4
  export default class DataObject {
@@ -1,4 +1,4 @@
1
- import { createProgram } from "../util";
1
+ import { createProgram } from "../util/webglobeplugins";
2
2
  /**
3
3
  * Blends two float32textures with given ratio.
4
4
  */