@pirireis/webglobeplugins 0.6.11 → 0.6.14

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.
@@ -174,8 +174,8 @@ export class ChainListMap {
174
174
  */
175
175
  textUpdate(chainKey, textWriterObjs, dataPreAdaptor) {
176
176
  const chain = this._chainMap.get(chainKey);
177
- const data = (dataPreAdaptor) ? chain.map(dataPreAdaptor) : chain;
178
177
  if (!chain) return;
178
+ const data = (dataPreAdaptor) ? chain.map(dataPreAdaptor) : chain;
179
179
  const properties = this._chainSideProperties.get(chainKey);
180
180
  textWriterObjs.forEach((writer) => {
181
181
  writer.insertTextBulk(data, properties);
@@ -1,5 +1,6 @@
1
1
  import { LineOnGlobeCache } from '../programs/line-on-globe/naive';
2
2
  import { CircleCache } from '../programs/line-on-globe/circle';
3
+ import { LineToTheOriginCache } from "../programs/line-on-globe/to-the-origin"
3
4
  import { BufferOrchestrator, BufferManager } from "../util/account";
4
5
  import { ChainListMap } from "./chain-list-map";
5
6
  import { mapGetOrThrow } from "../util/check/get";
@@ -76,6 +77,7 @@ export class CircleLineChainPlugin {
76
77
  const { gl, globe } = this;
77
78
  this.lineProgram = LineOnGlobeCache.get(globe);
78
79
  this.circleProgram = CircleCache.get(globe);
80
+ this.lineToTheOriginProgram = LineToTheOriginCache.get(globe);
79
81
  {
80
82
  // createBuffers
81
83
  const bufferType = "DYNAMIC_DRAW";
@@ -134,14 +136,14 @@ export class CircleLineChainPlugin {
134
136
  ...['centerCoords', 'targetCoords', 'dashRatio', 'dashOpacity', 'rgba'].map(key => obj(this.bufferManagersCompMap.get(key))));
135
137
  this.circleVao = this.circleProgram.createVAO(
136
138
  ...["centerCoords", "bigRadius", "rgbaCircle", "circleDashAngle", "dashOpacity"].map(key => obj(this.bufferManagersCompMap.get(key))));
139
+ this.toOriginVao = this.lineToTheOriginProgram.createVAO(
140
+ ...["targetCoords", "rgba"].map(key => obj(this.bufferManagersCompMap.get(key))));
137
141
  }
138
142
 
139
143
  }
140
144
 
141
145
 
142
146
  // API
143
-
144
-
145
147
  setDrawCircleOn(bool) {
146
148
  if (typeof bool !== 'boolean') throw new Error("setDrawCircleOn parameter must be a boolean");
147
149
  this._drawCircleOn = bool;
@@ -377,12 +379,13 @@ export class CircleLineChainPlugin {
377
379
  }
378
380
 
379
381
  draw3D() {
380
- const { gl } = this;
382
+ const { gl, globe } = this;
381
383
  gl.disable(gl.DEPTH_TEST);
382
384
  this.lineProgram.draw(this.lineVao, this.bufferOrchestrator.length, this._opacity);
383
385
  if (this._drawCircleOn) this.circleProgram.draw(this.circleVao, this.bufferOrchestrator.length, this._opacity);
384
386
  this._textContextWriterInjectionMap.forEach((writer) => writer.draw());
385
387
  gl.enable(gl.DEPTH_TEST);
388
+ this.lineToTheOriginProgram.draw(this.toOriginVao, this.bufferOrchestrator.length, this._opacity);
386
389
  }
387
390
  }
388
391
 
@@ -57,14 +57,27 @@ export class PixelPaddingCompassPlugin {
57
57
  this._initOrchestrations()
58
58
  }
59
59
 
60
+
61
+ /**
62
+ * @param {string} key
63
+ * @param {number} long
64
+ * @param {number} lat
65
+ * @typedef properties
66
+ * @property {number} pixelRadiusBig
67
+ * @property {number} pixelRadiusSmall
68
+ * @property {[4 numbers between 0-1]} rgba
69
+ */
60
70
  insert(key, long, lat, properties = null) {
61
71
  this.__insertText(key, null, null, { properties, update: true });
62
72
  this.compassMap.insert(key, long, lat, properties);
63
73
  this.globe.DrawRender();
64
-
65
74
  }
66
75
 
67
76
 
77
+ /**
78
+ *
79
+ * @param {string} key
80
+ */
68
81
  delete(key) {
69
82
  this.compassMap.delete(key);
70
83
  this.globe.DrawRender();
@@ -140,8 +140,6 @@ export default class Plugin {
140
140
  }
141
141
 
142
142
 
143
-
144
-
145
143
  _updateData(ratio, textureData0 = null, textureData1 = null) {
146
144
  if (!textureData0 || !textureData1) {
147
145
  this.isAble = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.6.11",
3
+ "version": "0.6.14",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
@@ -1,9 +1,30 @@
1
+
2
+ /**
3
+ * IconData;
4
+ * iconMap, iconCoords for objectArray
5
+ *
6
+ * Pin data:
7
+ * long, lat, payload
8
+ *
9
+ * methods insertPin pin and its data
10
+ * methods deletePin
11
+ *
12
+ * Behaviur injection:
13
+ * hover
14
+ * move
15
+ * pick drop
16
+ * mouseclicks
17
+ * keyboard clicks
18
+ * mouse curser changes ( this can be implemented inside above methods)
19
+ */
20
+
1
21
  import {
2
22
  CSGlobe,
3
23
  CSIconTypes,
4
24
  CSObjectTypes,
5
25
  CSObjectArrayUpdateTypes,
6
26
  } from "@pirireis/webglobe";
27
+ import AlarmTimeLineFadeInFadeOut from "../../plugins/alarms/alarmFadeInFadeOutPlugin/AlarmTimeLineFadeInFadeOutPlugin";
7
28
 
8
29
  /**
9
30
  * @typedef {Object} IconPayload
@@ -30,6 +51,118 @@ import {
30
51
  * @property {PointPayload[]} attribs
31
52
  */
32
53
 
54
+ function addIconMap(globe, mapName = "IconMapName", ICON_MAP_URL, ICON_MAP_JSON_URL) {
55
+ globe.api_AddIconMap('IconMapName', ICON_MAP_URL, ICON_MAP_JSON_URL);
56
+ }
57
+
58
+ class ObjectArray {
59
+ constructor(symbolSet, style) {
60
+ this.symbolSet = symbolSet;
61
+ this.style = style;
62
+ }
63
+
64
+ setSymbolSet(symbolSet) {
65
+ this.symbolSet = symbolSet;
66
+ }
67
+
68
+
69
+ }
70
+
71
+
72
+ class PinPointObjectArray {
73
+ constructor(id,
74
+ globe,
75
+ symbolSet, // iconMapName
76
+ style,
77
+ callBacks = {
78
+ mouseDown: (pinItem, event) => { },
79
+ mouseMove: (pinItem, event) => { },
80
+ mouseUp: (pinItem, event) => { },
81
+ mouseClick: (pinItem, event) => { },
82
+ mouseDblClick: (pinItem, event) => { },
83
+
84
+ } = {}) {
85
+ this.id = id
86
+ this.globe = globe;
87
+ this.symbolSet = symbolSet;
88
+ this.style = style;
89
+ this.iconMapName = iconMapName;
90
+ this.callBacks = callBacks;
91
+
92
+ // this item will be used
93
+
94
+ this.currentItem = null
95
+ }
96
+
97
+
98
+ insertPins(pins) {
99
+
100
+ }
101
+
102
+ deletePins(pinsIDs) {
103
+ const deleteBucket = {
104
+ coords: [],
105
+ coordsZ: [],
106
+ attribs: []
107
+ }
108
+ }
109
+
110
+
111
+ _queryByScreenFindFirst() {
112
+ const { clientX, clientY } = this.globe.api_GetMousePos();
113
+ const allObjects = this.globe.queryByScreen(clientX, clientY);
114
+ for (let i = 0; i < allObjects.length; i++) {
115
+ const { obj, owner } = allObjects[i];
116
+ if (owner === this.objectArray) {
117
+ return obj;
118
+ }
119
+ }
120
+ }
121
+
122
+ // mouseDown(x, y, event) {
123
+ // return false
124
+ // }
125
+
126
+
127
+ // // mouse'a basılıp hareket ettirildiğinde, mouseDown'dan true dönmüşse çağrılır
128
+ // mouseMove(x, y, event) {
129
+
130
+ // }
131
+
132
+ // // mouse bırakıldığında çağrılır
133
+ // mouseUp(x, y, event) {
134
+
135
+ // }
136
+
137
+ // // harita üzerinde tıklandığında çağrılır
138
+ // mouseClick() {
139
+ // return false
140
+ // }
141
+
142
+ // // harita üzerinde çift tıklandığında çağrılır
143
+ // mouseDblClick() {
144
+ // return false
145
+ // }
146
+
147
+
148
+ free() {
149
+ this.globe.api_ClearMouseEvents() // TODO
150
+ }
151
+
152
+ _setMouseEvent() {
153
+ const { globe } = this;
154
+ globe.api_SetMouseEvents()
155
+ }
156
+
157
+ _getIdForGlobe() {
158
+ const { globe, objectArray } = this;
159
+ const callback = () => {
160
+ const allObjects = globe.api_queryByScreen()
161
+ }
162
+ return `${this.id}_pinObjectArrayMouseEvent`;
163
+ }
164
+ }
165
+
33
166
  class ObjectArrayLabels {
34
167
  /**
35
168
  * @param {number | string} id
@@ -244,4 +377,5 @@ class ObjectArrayLabels {
244
377
  }
245
378
  }
246
379
 
247
- export default ObjectArrayLabels;
380
+ export default ObjectArrayLabels;
381
+
@@ -55,7 +55,7 @@ void main() {
55
55
  v_limp = vec2(0.0, 0.0);
56
56
  } else {
57
57
  vec2 position;
58
- if (radius < 1200.0) {
58
+ if (radius < 1400.0) {
59
59
  position = circleLimpFromLongLatRadCenterMercatorCompass( center_position, radius/ cos(center_position.y), angle);
60
60
  } else {
61
61
  position = circleLimpFromLongLatRadCenterMercatorRealDistance( center_position, radius, angle);
@@ -4,7 +4,7 @@ import { createProgram } from "../../util";
4
4
  import { noRegisterGlobeProgramCache, globeProgramCache } from "../programcache";
5
5
  import BufferOffsetManger from "../../util/account/bufferoffsetmanager";
6
6
  import { programCache } from "../rings/distancering/circleflatprogram";
7
- const Radian = Math.PI / 180.0;
7
+
8
8
  const GLOBE_MIDPOINT_COUNT = 100;
9
9
  const ITEM_SIZE = 9;
10
10
 
@@ -0,0 +1,165 @@
1
+ import { createProgram } from "../../util";
2
+ import { longLatRadToCartesian3DWithR, cartesian3DToGLPosition, R_3D } from "../../util/shaderfunctions/geometrytransformations";
3
+ import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totems";
4
+ import { noRegisterGlobeProgramCache } from "../programcache";
5
+
6
+ /**
7
+ * Creates beams from long, lat, radian coordinates to origin on global view.
8
+ * Ojects with hight, float over terrain and does not propose information of their actual coordinates.
9
+ * You start drawing after zoom level 9-10
10
+ * Does not work on mercator.
11
+ */
12
+
13
+
14
+ const vertexShaderSource = `#version 300 es
15
+ precision highp float;
16
+ ${CameraUniformBlockString}
17
+ ${R_3D}
18
+ ${longLatRadToCartesian3DWithR}
19
+ ${cartesian3DToGLPosition}
20
+
21
+ in vec2 position2d;
22
+ in vec4 rgba;
23
+ uniform float origin_r;
24
+ flat out vec4 v_rgba;
25
+ out float interpolation_value;
26
+
27
+ void main() {
28
+ if (!is3D) {return;}
29
+ vec3 cartesian;
30
+ if(gl_VertexID == 0) {
31
+ cartesian = longLatRadToCartesian3DWithR(position2d, R_3D);
32
+ interpolation_value = 1.0;
33
+ } else {
34
+ cartesian = longLatRadToCartesian3DWithR(position2d, origin_r);
35
+ interpolation_value = 0.0;
36
+ }
37
+ gl_Position = cartesian3DToGLPosition(cartesian);
38
+ v_rgba = rgba;
39
+ gl_PointSize = 10.0; // for testing
40
+ }
41
+ `;
42
+
43
+ const fragmentShaderSource = `#version 300 es
44
+ precision highp float;
45
+
46
+ uniform float plugin_opacity;
47
+ in float interpolation_value;
48
+ flat in vec4 v_rgba;
49
+ out vec4 color;
50
+ void main(){
51
+ if ( fract( interpolation_value * 100.0) < 0.5) {discard;}
52
+ color = vec4(
53
+ v_rgba.rgb,
54
+ v_rgba.a * plugin_opacity * interpolation_value * 0.9
55
+ );
56
+ }`;
57
+
58
+
59
+ class Logic {
60
+ constructor(globe) {
61
+ this.globe = globe;
62
+ this.gl = globe.gl;
63
+ this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
64
+ this._lastOpacity = 1.0;
65
+ this._lastOriginR = 6378.137 - 1;
66
+ const { gl, program } = this;
67
+ {
68
+ gl.bindAttribLocation(program, 0, "position2d");
69
+ gl.bindAttribLocation(program, 1, "rgba");
70
+
71
+ }
72
+ {
73
+ this._opacityLocation = gl.getUniformLocation(program, "plugin_opacity");
74
+ this._originRLocation = gl.getUniformLocation(program, "origin_r")
75
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
76
+ gl.useProgram(program);
77
+ gl.uniform1f(this._opacityLocation, this._lastOpacity);
78
+ gl.uniform1f(this._originRLocation, this._lastOriginR);
79
+ gl.useProgram(currentProgram);
80
+ }
81
+ {
82
+ this.cameraBlockBindingPoint = 0;
83
+ const cameraBlockIndex = this.gl.getUniformBlockIndex(this.program, "CameraUniformBlock");
84
+ this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
85
+ gl.uniformBlockBinding(this.program, cameraBlockIndex, this.cameraBlockBindingPoint);
86
+ }
87
+ }
88
+
89
+ draw(vao, length, opacity, originR = null) {
90
+ const { gl, program, globe, cameraBlockTotem, cameraBlockBindingPoint } = this;
91
+ const is3D = globe.api_GetCurrentGeometry() == 0;
92
+ if (!is3D) return;
93
+ const lod = globe.api_GetCurrentLODWithDecimal()
94
+ if (lod < 12) return;
95
+ gl.useProgram(program);
96
+ cameraBlockTotem.bind(cameraBlockBindingPoint);
97
+ gl.bindVertexArray(vao);
98
+ if (opacity !== this._lastOpacity) {
99
+ gl.uniform1f(this._opacityLocation, opacity);
100
+ this._checkOpacity(opacity);
101
+ this._lastOpacity = opacity;
102
+ }
103
+ if (originR !== null && originR !== this._lastOriginR) {
104
+ this._checkOriginR(originR);
105
+ gl.uniform1f(this._originRLocation, originR);
106
+ this._lastOriginR = originR;
107
+ }
108
+
109
+ // gl.disable(gl.DEPTH_TEST);
110
+ gl.drawArraysInstanced(gl.LINE_STRIP, 0, 2, length);
111
+ gl.bindVertexArray(null);
112
+ cameraBlockTotem.unbind(cameraBlockBindingPoint);
113
+ // gl.enable(gl.DEPTH_TEST);
114
+ }
115
+
116
+ _checkOpacity(opacity) {
117
+ if (opacity < 0.0 || opacity > 1) throw RangeError("Opacity should be between 0 and 1");
118
+
119
+ }
120
+
121
+ _checkOriginR(r) {
122
+ if (r < 0.0 || r > 6378.137 - 0.3) throw RangeError("r should be between 0 and 6378.137 - 0.3");
123
+ }
124
+
125
+ createVAO(potisionBufferObj, colorBufferObj) {
126
+ const { gl } = this;
127
+ const vao = gl.createVertexArray();
128
+ gl.bindVertexArray(vao);
129
+ {
130
+ const { buffer, stride = 0, offset = 0 } = potisionBufferObj;
131
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
132
+ gl.enableVertexAttribArray(0);
133
+ gl.vertexAttribPointer(0, 2, gl.FLOAT, false, stride, offset);
134
+ gl.vertexAttribDivisor(0, 1);
135
+ }
136
+ {
137
+ const { buffer, stride = 0, offset = 0 } = colorBufferObj;
138
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
139
+ gl.enableVertexAttribArray(1);
140
+ gl.vertexAttribPointer(1, 4, gl.FLOAT, false, stride, offset);
141
+ gl.vertexAttribDivisor(1, 1);
142
+ }
143
+
144
+ gl.bindVertexArray(null);
145
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
146
+ return vao;
147
+
148
+ }
149
+
150
+
151
+ free() {
152
+ if (this.isFreed) return;
153
+ CameraUniformBlockTotemCache.release(this.globe);
154
+ this.isFreed = true;
155
+ }
156
+ }
157
+
158
+ const LineToTheOriginCache = Object.freeze({
159
+ get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
160
+ release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
161
+ })
162
+
163
+ export {
164
+ LineToTheOriginCache
165
+ }
@@ -18,6 +18,7 @@ export const R = `
18
18
  export const PI = `
19
19
  #ifndef PI
20
20
  #define PI 3.141592653589793
21
+
21
22
  #endif
22
23
  `;
23
24
 
@@ -77,6 +78,7 @@ export const longLatRadToMercator = R + PI + `
77
78
  vec2 longLatRadToMercator( vec2 longLatRad) {
78
79
  float x = R * longLatRad.x;
79
80
  float y = R * log( tan( PI / 4.0 + longLatRad.y / 2.0 ) );
81
+ y -= mix(-60.0, 60.0, abs(longLatRad.y + PI / 8.0) / (PI / 4.0));
80
82
  return vec2(x, y);
81
83
  }
82
84
  `;
@@ -91,6 +93,14 @@ vec3 longLatRadToCartesian3D( vec2 longLat) {
91
93
  }
92
94
  `;
93
95
 
96
+ export const longLatRadToCartesian3DWithR = `
97
+ vec3 longLatRadToCartesian3DWithR( vec2 longLat, float radius) {
98
+ float x = radius * cos(longLat.y) * cos(longLat.x);
99
+ float y = radius * cos(longLat.y) * sin(longLat.x);
100
+ float z = radius * sin(longLat.y);
101
+ return vec3(x, y, z);
102
+ }
103
+ `;
94
104
 
95
105
  // TODO: Make it precise. It doesnt use haversine formula. If this changes, change the formmula which calculates text position.
96
106
  export const circleLimpFromLongLatRadCenterCartesian3D = R + `
@@ -110,7 +120,7 @@ vec3 circleLimpFromLongLatRadCenterCartesian3D( vec2 center, float radius, float
110
120
 
111
121
  // TODO: Make it precise. Y axis is not correct.
112
122
 
113
- export const circleLimpFromLongLatRadCenterMercatorRealDistance = PI + `
123
+ export const circleLimpFromLongLatRadCenterMercatorRealDistanceNew = PI + `
114
124
  vec2 circleLimpFromLongLatRadCenterMercatorRealDistance(vec2 center, float radius, float angle) {
115
125
  float ang = angle + PI / 2.0; // Shift angle to align with +x axis
116
126
  float r = radius / R;
@@ -130,7 +140,7 @@ vec2 circleLimpFromLongLatRadCenterMercatorRealDistance(vec2 center, float radiu
130
140
  }`;
131
141
 
132
142
 
133
- export const circleLimpFromLongLatRadCenterMercatorRealDistanceOLD = PI + `
143
+ export const circleLimpFromLongLatRadCenterMercatorRealDistance = PI + `
134
144
  vec2 circleLimpFromLongLatRadCenterMercatorRealDistance(vec2 center, float radius, float angle){
135
145
  float ang = angle + PI / 2.0; // this is there because the other methods are implemented in, angle 0 is +x axis orientatation
136
146
  float r = radius / R;
@@ -1,4 +0,0 @@
1
- import HeatWavePlugin from './plugins/heatwaveglobeshell';
2
- import { IsobarRasterToVector } from './isobar/plugin';
3
- export { HeatWavePlugin, IsobarRasterToVector };
4
-