@pirireis/webglobeplugins 0.17.1 → 1.0.3

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 (67) hide show
  1. package/Math/haversine.js +22 -0
  2. package/Math/methods.js +15 -2
  3. package/Math/tessellation/methods.js +4 -1
  4. package/Math/tessellation/nearest-value-padding.js +112 -0
  5. package/Math/tessellation/spherical-triangle-area.js +99 -0
  6. package/Math/tessellation/tile-merger.js +346 -215
  7. package/Math/tessellation/triangle-tessellation.js +381 -9
  8. package/Math/vec3.js +4 -0
  9. package/Math/xyz-tile.js +18 -0
  10. package/altitude-locator/plugin.js +1 -2
  11. package/investigation-tools/draw/tiles/adapters.js +2 -2
  12. package/investigation-tools/draw/tiles/tiles.js +2 -2
  13. package/package.json +1 -1
  14. package/programs/helpers/fadeaway.js +6 -1
  15. package/programs/point-on-globe/square-pixel-point.js +1 -0
  16. package/programs/polygon-on-globe/texture-dem-triangles.js +94 -116
  17. package/programs/totems/camera-totem-attactment-interface.js +1 -0
  18. package/programs/totems/camerauniformblock.js +33 -22
  19. package/programs/totems/dem-textures-manager.js +265 -0
  20. package/programs/vectorfields/logics/drawrectangleparticles.js +51 -18
  21. package/programs/vectorfields/logics/{ubo-new.js → particle-ubo.js} +5 -14
  22. package/programs/vectorfields/logics/pixelbased.js +42 -36
  23. package/programs/vectorfields/pingpongbuffermanager.js +34 -8
  24. package/semiplugins/shape-on-terrain/terrain-polygon/adapters.js +55 -0
  25. package/semiplugins/shape-on-terrain/terrain-polygon/data/cache.js +102 -0
  26. package/semiplugins/shape-on-terrain/terrain-polygon/data/index-polygon-map.js +45 -0
  27. package/semiplugins/shape-on-terrain/terrain-polygon/data/manager.js +4 -0
  28. package/semiplugins/shape-on-terrain/terrain-polygon/data/master-worker.js +177 -0
  29. package/semiplugins/shape-on-terrain/terrain-polygon/data/polygon-to-triangles.js +100 -0
  30. package/semiplugins/shape-on-terrain/terrain-polygon/data/random.js +121 -0
  31. package/semiplugins/shape-on-terrain/terrain-polygon/data/types.js +1 -0
  32. package/semiplugins/shape-on-terrain/terrain-polygon/data/worker-contact.js +63 -0
  33. package/semiplugins/shape-on-terrain/terrain-polygon/data/worker.js +125 -0
  34. package/semiplugins/shape-on-terrain/terrain-polygon/terrain-polygon.js +219 -0
  35. package/semiplugins/shape-on-terrain/terrain-polygon/types.js +8 -0
  36. package/semiplugins/shell/bbox-renderer/logic.js +18 -58
  37. package/semiplugins/shell/bbox-renderer/object.js +19 -9
  38. package/tracks/point-heat-map/point-to-heat-map-flow.js +1 -1
  39. package/tracks/point-tracks/plugin.js +13 -6
  40. package/tracks/timetracks/program-line-strip.js +1 -1
  41. package/util/account/single-attribute-buffer-management/buffer-manager.js +5 -3
  42. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +2 -2
  43. package/util/gl-util/uniform-block/manager.js +20 -10
  44. package/util/helper-methods.js +8 -0
  45. package/util/picking/fence.js +4 -2
  46. package/util/picking/picker-displayer.js +51 -9
  47. package/util/programs/draw-texture-on-canvas.js +18 -15
  48. package/util/shaderfunctions/geometrytransformations.js +67 -1
  49. package/vectorfield/waveparticles/plugin.js +241 -116
  50. package/vectorfield/wind/adapters/image-to-fields.js +61 -0
  51. package/vectorfield/wind/adapters/types.js +1 -0
  52. package/vectorfield/wind/imagetovectorfieldandmagnitude.js +6 -9
  53. package/vectorfield/wind/plugin-persistant copy.js +364 -0
  54. package/vectorfield/wind/plugin-persistant.js +375 -0
  55. package/vectorfield/wind/plugin.js +1 -1
  56. package/Math/tessellation/earcut/adapters.js +0 -37
  57. package/Math/tessellation/hybrid-triangle-tessellation-meta.js +0 -123
  58. package/Math/tessellation/shred-input.js +0 -18
  59. package/Math/tessellation/tiler.js +0 -50
  60. package/Math/tessellation/triangle-tessellation-meta.js +0 -523
  61. package/programs/polygon-on-globe/texture-dem-triangle-test-plugin-triangle.js +0 -328
  62. package/programs/vectorfields/logics/drawrectangleparticles1.js +0 -112
  63. package/semiplugins/shape-on-terrain/terrain-cover/texture-dem-cover.js +0 -1
  64. package/util/gl-util/uniform-block/types.js +0 -1
  65. package/util/webglobe/index.js +0 -2
  66. /package/Math/tessellation/{zoom-catch.js → constants.js} +0 -0
  67. /package/util/{webglobe/gldefaultstates.js → globe-default-gl-states.js} +0 -0
@@ -0,0 +1,364 @@
1
+ "use strict";
2
+ /**
3
+ * Author: Toprak Nihat Deniz Ozturk
4
+ */
5
+ // import { Globe } from "../../types";
6
+ // import { imageToFields } from "./adapters/image-to-fields.js";
7
+ // import ParticlePlugin from "../waveparticles/plugin";
8
+ // import { createImageFromBase64 } from "../../util/webglobjectbuilders";
9
+ // import { TexturePointSampler } from "../../heatwave/texture-point-sampler";
10
+ // import imageToMagnitude, { imageToRadianAngle } from "./imagetovectorfieldandmagnitude.js";
11
+ // import { WindData, LegendData } from "./adapters/types.js";
12
+ // /**
13
+ // * Shader Dökümanı:
14
+ // * * Vektör alan haritasında kaçış değeri
15
+ // * texture2D(u_wind, pos).rg == vec2(0.0, 0.0) değerini kaçış için kullandım.
16
+ // * Deniz rüzgarları gibi haritalarda kara için rg değerleri 0.0 oluyor.
17
+ // * Gerçek bir partikülün rg == vec2(0.0, 0.0) değerinde olma olasılığı düşük.
18
+ // * Hem yatay ve hem dikey boyutta en düşük değere sahip olmalı.
19
+ // *
20
+ // */
21
+ // type LegendData = {
22
+ // thresholds: number[];
23
+ // values: string[];
24
+ // };
25
+ // type WindData = {
26
+ // image: HTMLImageElement;
27
+ // uMin: number;
28
+ // vMin: number;
29
+ // uMax: number;
30
+ // vMax: number;
31
+ // };
32
+ // /*
33
+ // * @param { Object } windData
34
+ // * @param { HTMLImageElement } windData.image - image element
35
+ // * @param { number } windData.uMin - minimum u value
36
+ // * @param { number } windData.vMin - minimum v value
37
+ // * @param { number } windData.uMax - maximum u value
38
+ // * @param { number } windData.vMax - maximum v value
39
+ // *
40
+ // */
41
+ // type WindDataMeta = {
42
+ // width: number;
43
+ // height: number;
44
+ // bbox: number[]; // [minLon, minLat, maxLon, maxLat]
45
+ // flipY?: boolean;
46
+ // };
47
+ // type WindPluginOptions = {
48
+ // fadeOpacity?: number;
49
+ // speedFactor?: number;
50
+ // dropRate?: number;
51
+ // dropRateBump?: number;
52
+ // baseOpacity?: number;
53
+ // pointSize?: number;
54
+ // minSpeedThreshold?: number;
55
+ // maxSpeedThreshold?: number;
56
+ // height?: number;
57
+ // legendData?: LegendData;
58
+ // };
59
+ // const defaultRampColors = [
60
+ // [0.0, '#5e4fa2'],
61
+ // [0.08, '#3288bd'],
62
+ // [0.2, '#66c2a5'],
63
+ // [0.3, '#abdda4'],
64
+ // [0.4, '#e6f598'],
65
+ // [0.5, '#fee08b'],
66
+ // [0.6, '#fdae61'],
67
+ // [0.7, '#f46d43'],
68
+ // [1.0, '#d53e4f']
69
+ // ];
70
+ // const windyLegendData = {
71
+ // "thresholds": [0, 3, 3, 5, 5, 7, 10, 10, 13, 15, 15, 17, 20, 20, 25, 25, 30],
72
+ // // 0 5 10 20 30 40 60
73
+ // // "thresholds": [0, 5, 5, 10, 10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 40, 60],
74
+ // "values": [
75
+ // "#6271B8",
76
+ // "#6271B8",
77
+ // "#6271B8",
78
+ // "#6271B8",
79
+ // "#3D6EA3",
80
+ // "#4A94AA",
81
+ // "#4A9294",
82
+ // "#4D8E7C",
83
+ // "#4CA44C",
84
+ // "#67A436",
85
+ // "#A28740",
86
+ // "#A26D5C",
87
+ // "#8D3F5C",
88
+ // "#974B91",
89
+ // "#5F64A0",
90
+ // "#5B88A1",
91
+ // "#5B88A1"
92
+ // ]
93
+ // };
94
+ // export default class WindPlugin {
95
+ // public id: string;
96
+ // public globe!: Globe;
97
+ // private gl: WebGLRenderingContext | null = null;
98
+ // private particalPlugin!: ParticalPlugin
99
+ // private windMetadata: WindDataMeta;
100
+ // private legendData: LegendData;
101
+ // private options: WindPluginOptions;
102
+ // private windData: WindData | null;
103
+ // /**
104
+ // * @param {String} id
105
+ // * @param {Object} windDataMeta
106
+ // * @param {number} windDataMeta.width - image width
107
+ // * @param {number} windDataMeta.height - image height
108
+ // * @param {Array} windDataMeta.bbox - bounding box [minLon, minLat, maxLon, maxLat]
109
+ // * @param {Object} options
110
+ // * @param {number} options.fadeOpacity - how fast the particle trails fade on each frame | between 0 - 1 | default 0.746
111
+ // * @param {number} options.speedFactor - how fast the particles move | between 0 - 1 | default 0.6
112
+ // * @param {number} options.dropRate - how often the particles move to a random place | between 0 - 1 | default 0.007
113
+ // * @param {number} options.dropRateBump - drop rate increase relative to individual particle speed
114
+ // * @param {number} options.baseOpacity - opacity of drawn particle trails | between 0 - 1 | default 1.0
115
+ // * @param {number} options.pointSize - draw size of each particle | positive number | default 2.0
116
+ // * @param {number} options.minSpeedThreshold - minimum speed value | positive number | default 0.0
117
+ // * @param {number} options.maxSpeedThreshold - maximum speed value | positive number | default 1000.0
118
+ // * @param {number} options.height - height of the particles | number | default 0.0
119
+ // * @param {number} numParticles - number of particles | positive integer
120
+ // * @param {LegendData} options.legendData - legend data
121
+ // */
122
+ // constructor(id: string,
123
+ // windDataMeta: WindDataMeta,
124
+ // legendData: LegendData,
125
+ // options: WindPluginOptions = {}) {
126
+ // this.id = id;
127
+ // this.legendData = legendData;
128
+ // this.windDataMeta = windDataMeta;
129
+ // this.options = {
130
+ // ...{
131
+ // fadeOpacity: 0.746,
132
+ // speedFactor: 0.6,
133
+ // dropRate: 0.007,
134
+ // dropRateBump: 0.001,
135
+ // baseOpacity: 1.0,
136
+ // pointSize: 2.0,
137
+ // minSpeed: 0.0,
138
+ // maxSpeed: 1000.0,
139
+ // height: 0.0,
140
+ // numParticles: 40000,
141
+ // legendData: windyLegendData
142
+ // }, ...options
143
+ // }
144
+ // this.windData = null;
145
+ // }
146
+ // // globe plugin init methodu
147
+ // init(globe: Globe, gl: WebGL2RenderingContext) {
148
+ // this.globe = globe;
149
+ // this.gl = gl;
150
+ // const particalPluginOptions = {
151
+ // fadeOpacity: this.options.fadeOpacity,
152
+ // speedFactor: this.options.speedFactor,
153
+ // dropRate: this.options.dropRate,
154
+ // dropRateBump: this.options.dropRateBump,
155
+ // baseOpacity: this.options.baseOpacity,
156
+ // pointSize: this.options.pointSize,
157
+ // minSpeed: this.options.minSpeedThreshold,
158
+ // maxSpeed: this.options.maxSpeedThreshold,
159
+ // dataHeight: this.options.height,
160
+ // numParticles: this.options.numParticles,
161
+ // dataHeight: this.options.height,
162
+ // } as ParticalPluginOptions;
163
+ // this.particalPlugin = new ParticalPlugin("wind-partical-plugin",
164
+ // particalPluginOptions);
165
+ // this.particalPlugin.init(globe, gl);
166
+ // }
167
+ // // Uniforms are loaded once, on initiation and when they are changed.
168
+ // set height(value) {
169
+ // this._height = value;
170
+ // this._loadHeight();
171
+ // }
172
+ // set minSpeed(value) {
173
+ // this._minSpeed = value;
174
+ // this._loadMinMaxSpeed();
175
+ // }
176
+ // set maxSpeed(value) {
177
+ // this._maxSpeed = value;
178
+ // this._loadMinMaxSpeed();
179
+ // }
180
+ // set fadeOpacity(value) {
181
+ // this._fadeOpacity = value;
182
+ // this._loadFadeOpacity();
183
+ // }
184
+ // set speedFactor(value) {
185
+ // this._speedFactor = value;
186
+ // this._loadSpeedFactor()
187
+ // }
188
+ // set dropRate(value) {
189
+ // this._dropRate = value;
190
+ // this._loadDropRate();
191
+ // }
192
+ // set dropRateBump(value) {
193
+ // this._dropRateBump = value;
194
+ // this._loadDropRateBump();
195
+ // }
196
+ // set baseOpacity(value) {
197
+ // this._baseOpacity = value;
198
+ // this._loadBaseOpacity();
199
+ // }
200
+ // set pointSize(value) {
201
+ // this._pointSize = value;
202
+ // this._loadPointSize();
203
+ // }
204
+ // // Color ramp methods.
205
+ // // Color ramp is used to colorize the particles according to their speed.
206
+ // // Legend max value is used to normalize the speed values.
207
+ // setColorRamp(colors) {
208
+ // // lookup texture for colorizing the particles according to their speed
209
+ // if (this.gl == null) {
210
+ // return;
211
+ // }
212
+ // this.colorRampTexture = createTexture(this.gl, this.gl.LINEAR, getColorRamp(colors), 16, 16);
213
+ // }
214
+ // setColorRampDefault() {
215
+ // const { uMax, uMin, vMax, vMin } = this.windData;
216
+ // const maxSpeed = Math.sqrt(
217
+ // uMax * uMax + vMax * vMax
218
+ // )
219
+ // const minSpeed = Math.sqrt(
220
+ // uMin * uMin + vMin * vMin
221
+ // )
222
+ // // console.log("maxSpeed", maxSpeed, "minSpeed", minSpeed);
223
+ // this._rampMax = maxSpeed > minSpeed ? maxSpeed : minSpeed;
224
+ // this._loadRampMax();
225
+ // this.setColorRamp(defaultRampColors);
226
+ // }
227
+ // /**
228
+ // *
229
+ // * @param {*} legendData
230
+ // * @param {Array} legendData.thresholds - list of integers
231
+ // * @param {Array} legendData.values - list of colors in hex format like #ff0000 (alpha is not included)
232
+ // *
233
+ // */
234
+ // setLegend(legendData) {
235
+ // const { gl } = this;
236
+ // if (gl === null) {
237
+ // throw new Error("wind plugin. setColorRampFromService is called before plugin is registered.");
238
+ // }
239
+ // const { thresholds, values } = legendData;
240
+ // if (thresholds.length === 0 || values.length === 0) {
241
+ // return;
242
+ // }
243
+ // thresholds.push(thresholds[thresholds.length - 1]);
244
+ // values.push(values[values.length - 1]);
245
+ // const maxVelocity = thresholds[thresholds.length - 1];
246
+ // const colors = [];
247
+ // for (let i = 0; i < thresholds.length; i++) {
248
+ // colors.push([
249
+ // thresholds[i] / maxVelocity,
250
+ // values[i]
251
+ // ]);
252
+ // }
253
+ // const colorRamp = getColorRamp(colors);
254
+ // this.colorRampTexture = createTexture(gl, gl.LINEAR, colorRamp, 16, 16);
255
+ // this._rampMax = maxVelocity;
256
+ // this._loadRampMax();
257
+ // }
258
+ // // particle coordinates are encoded into RGBA texture
259
+ // set numParticles(numParticles) {
260
+ // const gl = this.gl;
261
+ // // we create a square texture where each pixel will hold a particle position encoded as RGBA
262
+ // const particleRes = this.particleStateResolution = Math.ceil(Math.sqrt(numParticles));
263
+ // this._numParticles = particleRes * particleRes;
264
+ // const particleState = new Uint8Array(this._numParticles * 4);
265
+ // for (let i = 0; i < particleState.length; i++) {
266
+ // particleState[i] = Math.floor(Math.random() * 256); // randomize the initial particle positions
267
+ // }
268
+ // // textures to hold the particle state for the current and the next frame
269
+ // this.particleStateTexture0 = createTexture(gl, gl.NEAREST, particleState, particleRes, particleRes);
270
+ // this.particleStateTexture1 = createTexture(gl, gl.NEAREST, particleState, particleRes, particleRes);
271
+ // const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
272
+ // gl.useProgram(this.updateProgram.program);
273
+ // gl.uniform1f(this.updateProgram.u_wind_res, this.particleStateResolution);
274
+ // gl.useProgram(this.drawSphereProgram.program);
275
+ // gl.uniform1f(this.drawSphereProgram.u_particles_res, this.particleStateResolution);
276
+ // gl.useProgram(this.drawFlatProgram.program);
277
+ // gl.uniform1f(this.drawFlatProgram.u_particles_res, this.particleStateResolution);
278
+ // gl.useProgram(currentProgram);
279
+ // // console.log("numParticles", this._numParticles);
280
+ // const particleIndices = new Float32Array(this._numParticles);
281
+ // for (let i = 0; i < this._numParticles; i++) particleIndices[i] = i;
282
+ // this.particleIndexBuffer = createBuffer(gl, particleIndices);
283
+ // }
284
+ // get numParticles() {
285
+ // return this._numParticles;
286
+ // }
287
+ // // Vector field texture is used to calculate the particle movement.
288
+ // /**
289
+ // * @param {Object} windData
290
+ // * @param {HTMLImageElement} windData.image - image element
291
+ // * @param {number} windData.uMin - minimum u value
292
+ // * @param {number} windData.vMin - minimum v value
293
+ // * @param {number} windData.uMax - maximum u value
294
+ // * @param {number} windData.vMax - maximum v value
295
+ // */
296
+ // setWind(windData) {
297
+ // if (windData === null) {
298
+ // return;
299
+ // }
300
+ // const windDataMeta = this._windDataMeta;
301
+ // const gl = this.gl;
302
+ // this.windData = windData;
303
+ // this.windTexture = createTexture(gl, gl.LINEAR, windData.image);
304
+ // const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
305
+ // gl.useProgram(this.updateProgram.program);
306
+ // gl.uniform2f(this.updateProgram.u_wind_res, windDataMeta.width, windDataMeta.height);
307
+ // gl.uniform2f(this.updateProgram.u_wind_min, this.windData.uMin, this.windData.vMin);
308
+ // gl.uniform2f(this.updateProgram.u_wind_max, this.windData.uMax, this.windData.vMax);
309
+ // this.setGeometry();
310
+ // console.log("windData bbox", windData.bbox);
311
+ // const minXY = this._latLongToPixelXY(windDataMeta.bbox[1], windDataMeta.bbox[0]);
312
+ // const maxXY = this._latLongToPixelXY(windDataMeta.bbox[3], windDataMeta.bbox[2]);
313
+ // this._loadBoundingBoxData(minXY.x, minXY.y, maxXY.x, maxXY.y);
314
+ // gl.useProgram(currentProgram);
315
+ // this._setCoorcinatesDataCalculatorData();
316
+ // this.resize();
317
+ // }
318
+ // // Vector field texture is used to calculate the particle movement.
319
+ // /**
320
+ // * @param {Object} windData
321
+ // * @param {BaseInt64} windData.image - image element
322
+ // * @param {number} windData.width - image width
323
+ // * @param {number} windData.height - image height
324
+ // * @param {number} windData.uMin - minimum u value
325
+ // * @param {number} windData.vMin - minimum v value
326
+ // * @param {number} windData.uMax - maximum u value
327
+ // * @param {number} windData.vMax - maximum v value
328
+ // * @param {Array} windData.bbox - bounding box [minLon, minLat, maxLon, maxLat]
329
+ // */
330
+ // setWindDataWithImageBase64(windData) {
331
+ // const image = createImageFromBase64(windData.image)
332
+ // image.onload = () => {
333
+ // windData.image = image;
334
+ // this.setWind(windData);
335
+ // }
336
+ // }
337
+ // /**
338
+ // * @param
339
+ // * @returns
340
+ // */
341
+ // getTexturePointSampler(type: 'magnitude' | 'angle' = 'magnitude') {
342
+ // // if (type === `magnitude`) {
343
+ // // if (!this.texturePointSampler) {
344
+ // // this._createTexturePointSampler();
345
+ // // this._setCoorcinatesDataCalculatorData();
346
+ // // }
347
+ // // return this.texturePointSampler;
348
+ // // } else if (type === `angle`) {
349
+ // // if (!this.texturePointSamplerAngle) {
350
+ // // this._createTexturePointSamplerAngle();
351
+ // // this._setCoorcinatesDataCalculatorData();
352
+ // // }
353
+ // // return this.texturePointSamplerAngle;
354
+ // // } else {
355
+ // // throw new Error(`WindPlugin.getTexturePointSampler: type must be either 'magnitude' or 'angle'.`);
356
+ // // }
357
+ // }
358
+ // // globe calls `draw3D` method on each frame
359
+ // draw3D() {
360
+ // }
361
+ // // globe calls this `free` on plugin object unregistration
362
+ // free() {
363
+ // }
364
+ // }