@pirireis/webglobeplugins 0.6.25-a → 0.6.27-a
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.
|
@@ -13,8 +13,8 @@ export class PixelPaddingCompassPlugin {
|
|
|
13
13
|
|
|
14
14
|
defaultProperties = {
|
|
15
15
|
rgba: [1, 1, 1, 1],
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
pixelRadiusRatioBig: 0.8,
|
|
17
|
+
pixelRadiusRatioSmall: 0.6,
|
|
18
18
|
},
|
|
19
19
|
font = {
|
|
20
20
|
name: 'Arial',
|
|
@@ -50,6 +50,7 @@ export class PixelPaddingCompassPlugin {
|
|
|
50
50
|
|
|
51
51
|
init(globe, gl) {
|
|
52
52
|
this.globe = globe;
|
|
53
|
+
this.resize();
|
|
53
54
|
this.gl = gl;
|
|
54
55
|
if (this.textAngleOn) {
|
|
55
56
|
this._createTextWriter();
|
|
@@ -63,8 +64,8 @@ export class PixelPaddingCompassPlugin {
|
|
|
63
64
|
* @param {number} long
|
|
64
65
|
* @param {number} lat
|
|
65
66
|
* @typedef properties
|
|
66
|
-
* @property {number}
|
|
67
|
-
* @property {number}
|
|
67
|
+
* @property {number} pixelRadiusRatioBig
|
|
68
|
+
* @property {number} pixelRadiusRatioSmall
|
|
68
69
|
* @property {[4 numbers between 0-1]} rgba
|
|
69
70
|
*/
|
|
70
71
|
insert(key, long, lat, properties = null) {
|
|
@@ -115,13 +116,13 @@ export class PixelPaddingCompassPlugin {
|
|
|
115
116
|
'bufferManager': new BufferManager(gl, 2, { bufferType, initialCapacity }),
|
|
116
117
|
'adaptor': (item) => new Float32Array([item.x, item.y])
|
|
117
118
|
}],
|
|
118
|
-
["
|
|
119
|
+
["pixelRadiusRatioSmall", {
|
|
119
120
|
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
120
|
-
'adaptor': (item) => new Float32Array([item.properties.
|
|
121
|
+
'adaptor': (item) => new Float32Array([item.properties.pixelRadiusRatioSmall])
|
|
121
122
|
}],
|
|
122
|
-
["
|
|
123
|
+
["pixelRadiusRatioBig", {
|
|
123
124
|
'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
124
|
-
'adaptor': (item) => new Float32Array([item.properties.
|
|
125
|
+
'adaptor': (item) => new Float32Array([item.properties.pixelRadiusRatioBig])
|
|
125
126
|
}],
|
|
126
127
|
["rgba", {
|
|
127
128
|
'bufferManager': new BufferManager(gl, 4, { bufferType, initialCapacity }),
|
|
@@ -134,7 +135,7 @@ export class PixelPaddingCompassPlugin {
|
|
|
134
135
|
return { 'buffer': bufferManagerComp.bufferManager.buffer, 'stride': 0, 'offset': 0 }
|
|
135
136
|
};
|
|
136
137
|
this.paddingVao = this.paddingProgram.createVAO(
|
|
137
|
-
...['screenCoordinates', '
|
|
138
|
+
...['screenCoordinates', 'pixelRadiusRatioSmall', 'pixelRadiusRatioBig', 'rgba'].map(key => obj(this.bufferManagersCompMap.get(key))));
|
|
138
139
|
}
|
|
139
140
|
}
|
|
140
141
|
|
|
@@ -143,15 +144,19 @@ export class PixelPaddingCompassPlugin {
|
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
|
|
147
|
+
resize() {
|
|
148
|
+
this.writer?.resize();
|
|
149
|
+
}
|
|
150
|
+
|
|
146
151
|
|
|
147
152
|
__insertText(key, x, y, { properties, update = false } = {}) {
|
|
148
153
|
if (!this.writer) return;
|
|
149
154
|
if (update) {
|
|
150
155
|
let radius;
|
|
151
|
-
if (properties != null && properties.
|
|
152
|
-
radius = properties.
|
|
156
|
+
if (properties != null && properties.pixelRadiusRatioBig) {
|
|
157
|
+
radius = properties.pixelRadiusRatioBig * this.radiusMultiplier;
|
|
153
158
|
} else {
|
|
154
|
-
radius = this.defaultProperties.
|
|
159
|
+
radius = this.defaultProperties.pixelRadiusRatioBig * this.radiusMultiplier;
|
|
155
160
|
}
|
|
156
161
|
this.writer.insertTextItem(key, x, y, radius + textGapFit);
|
|
157
162
|
} else {
|
|
@@ -185,6 +190,23 @@ export class PixelPaddingCompassPlugin {
|
|
|
185
190
|
})
|
|
186
191
|
|
|
187
192
|
}
|
|
193
|
+
|
|
194
|
+
resize() {
|
|
195
|
+
this.radiusMultiplier = this._shorterDimension() * 0.5;
|
|
196
|
+
this._reinsertAllText();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
_reinsertAllText() {
|
|
201
|
+
this.compassMap.query(this.globe, this.writer).forEach((v) => {
|
|
202
|
+
this.__insertText(v.key, v.x, v.y, { properties: v.properties, update: true });
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
_shorterDimension() {
|
|
207
|
+
const globe = this.globe;
|
|
208
|
+
return Math.min(globe.api_ScrW(), globe.api_ScrH());
|
|
209
|
+
}
|
|
188
210
|
}
|
|
189
211
|
|
|
190
212
|
|
package/package.json
CHANGED
|
@@ -6,8 +6,8 @@ const vertexShaderSource = `#version 300 es
|
|
|
6
6
|
${CameraUniformBlockString}
|
|
7
7
|
|
|
8
8
|
in vec2 screen_coordinate;
|
|
9
|
-
in float
|
|
10
|
-
in float
|
|
9
|
+
in float pixel_radius_small_ratio;
|
|
10
|
+
in float pixel_radius_big_ratio;
|
|
11
11
|
in vec4 rgba;
|
|
12
12
|
out vec4 v_rgba;
|
|
13
13
|
uniform float plugin_opacity;
|
|
@@ -15,31 +15,31 @@ uniform float plugin_opacity;
|
|
|
15
15
|
vec3 coord_opacity(){
|
|
16
16
|
float radius;
|
|
17
17
|
float angle;
|
|
18
|
-
float gap = (
|
|
18
|
+
float gap = (pixel_radius_big_ratio - pixel_radius_small_ratio);
|
|
19
19
|
if( gl_VertexID % 2 == 0){
|
|
20
20
|
// if( gl_VertexID % 180 == 0){
|
|
21
|
-
// radius =
|
|
21
|
+
// radius = pixel_radius_small_ratio ;
|
|
22
22
|
// } else
|
|
23
23
|
if ( gl_VertexID % 60 == 0){
|
|
24
|
-
radius =
|
|
24
|
+
radius = pixel_radius_small_ratio;
|
|
25
25
|
} else if( gl_VertexID % 10 == 0) {
|
|
26
|
-
radius =
|
|
26
|
+
radius = pixel_radius_small_ratio + gap * 0.5;
|
|
27
27
|
} else {
|
|
28
|
-
radius =
|
|
28
|
+
radius = pixel_radius_small_ratio + gap* 0.75;
|
|
29
29
|
}
|
|
30
30
|
angle = (float(gl_VertexID) / (${vertexCount}.0));
|
|
31
31
|
} else {
|
|
32
32
|
if ( gl_VertexID % 180 == 1){
|
|
33
|
-
radius =
|
|
33
|
+
radius = pixel_radius_big_ratio + gap * 0.1;
|
|
34
34
|
|
|
35
35
|
} else {
|
|
36
|
-
radius =
|
|
36
|
+
radius = pixel_radius_big_ratio;
|
|
37
37
|
}
|
|
38
38
|
angle = (float(gl_VertexID - 1) / (${vertexCount}.0));
|
|
39
39
|
}
|
|
40
40
|
float opacity = fract(angle + 0.2475) / 1.5 + 0.33;
|
|
41
41
|
angle = angle * ${Math.PI * 2.0} + world_north_angle;
|
|
42
|
-
|
|
42
|
+
radius = radius * min(screenWH.x, screenWH.y) / 2.0;;
|
|
43
43
|
return vec3( screen_coordinate + vec2( cos(angle), sin(angle)) * radius, opacity);
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -78,13 +78,13 @@ class Logic {
|
|
|
78
78
|
const { gl, program } = this;
|
|
79
79
|
{ // assign attribute locations
|
|
80
80
|
// in vec2 screen_coordinate;
|
|
81
|
-
// in float
|
|
82
|
-
// in float
|
|
81
|
+
// in float pixel_radius_small_ratio;
|
|
82
|
+
// in float pixel_radius_big_ratio;
|
|
83
83
|
// in vec4 rgba;
|
|
84
84
|
|
|
85
85
|
gl.bindAttribLocation(program, 0, "screen_coordinate");
|
|
86
|
-
gl.bindAttribLocation(program, 1, "
|
|
87
|
-
gl.bindAttribLocation(program, 2, "
|
|
86
|
+
gl.bindAttribLocation(program, 1, "pixel_radius_small_ratio");
|
|
87
|
+
gl.bindAttribLocation(program, 2, "pixel_radius_big_ratio");
|
|
88
88
|
gl.bindAttribLocation(program, 3, "rgba");
|
|
89
89
|
}
|
|
90
90
|
{
|
|
@@ -118,7 +118,7 @@ class Logic {
|
|
|
118
118
|
cameraBlockTotem.unbind(cameraBlockBindingPoint);
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
createVAO(screenCoordsBufferObj,
|
|
121
|
+
createVAO(screenCoordsBufferObj, pixelRadiusRatioSmallBufferObj, pixelRadiusRatioBigBufferObj, rgbaBufferObj) {
|
|
122
122
|
const { gl } = this;
|
|
123
123
|
const vao = gl.createVertexArray();
|
|
124
124
|
gl.bindVertexArray(vao);
|
|
@@ -130,14 +130,14 @@ class Logic {
|
|
|
130
130
|
gl.vertexAttribDivisor(0, 1);
|
|
131
131
|
}
|
|
132
132
|
{
|
|
133
|
-
const { buffer, stride = 0, offset = 0 } =
|
|
133
|
+
const { buffer, stride = 0, offset = 0 } = pixelRadiusRatioSmallBufferObj;
|
|
134
134
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
135
135
|
gl.enableVertexAttribArray(1);
|
|
136
136
|
gl.vertexAttribPointer(1, 1, gl.FLOAT, false, stride, offset);
|
|
137
137
|
gl.vertexAttribDivisor(1, 1);
|
|
138
138
|
}
|
|
139
139
|
{
|
|
140
|
-
const { buffer, stride = 0, offset = 0 } =
|
|
140
|
+
const { buffer, stride = 0, offset = 0 } = pixelRadiusRatioBigBufferObj;
|
|
141
141
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
142
142
|
gl.enableVertexAttribArray(2);
|
|
143
143
|
gl.vertexAttribPointer(2, 1, gl.FLOAT, false, stride, offset);
|
|
@@ -22,6 +22,8 @@ export class ContextTextWriter3 {
|
|
|
22
22
|
opacity: 1.0,
|
|
23
23
|
zMode: CSZMode.Z_GROUND_PERVERTEX,
|
|
24
24
|
},
|
|
25
|
+
xOffset = 0,
|
|
26
|
+
yOffset = 0,
|
|
25
27
|
doDraw = true,
|
|
26
28
|
textAdaptor = null,
|
|
27
29
|
coordinatesAdaptor = null,
|
|
@@ -29,8 +31,7 @@ export class ContextTextWriter3 {
|
|
|
29
31
|
opacityAdaptor = null,
|
|
30
32
|
angleAdaptor = null,
|
|
31
33
|
angleOnSphere = false,
|
|
32
|
-
|
|
33
|
-
yOffset = 0,
|
|
34
|
+
positionAdaptor = (item, i, container, properties) => "left",
|
|
34
35
|
zoomLevelAdaptor = (zoomLevel) => (item) => {
|
|
35
36
|
return {
|
|
36
37
|
opacityMultiplier: 1,
|
|
@@ -49,7 +50,7 @@ export class ContextTextWriter3 {
|
|
|
49
50
|
this.keyAdaptor = keyAdaptor;
|
|
50
51
|
|
|
51
52
|
this.zoomLevelAdaptor = zoomLevelAdaptor;
|
|
52
|
-
|
|
53
|
+
this.positionAdaptor = positionAdaptor;
|
|
53
54
|
this.opacityAdaptor = opacityAdaptor ? opacityAdaptor : () => 1;
|
|
54
55
|
this.angleOnSphere = angleOnSphere;
|
|
55
56
|
if (angleAdaptor) {
|
|
@@ -104,7 +105,7 @@ export class ContextTextWriter3 {
|
|
|
104
105
|
const zoomLevel = globe.api_GetCurrentLODWithDecimal();
|
|
105
106
|
const zoomAdaptor = this.zoomLevelAdaptor(zoomLevel);
|
|
106
107
|
for (const [key, item] of itemMap) {
|
|
107
|
-
const { lat, long, text, opacity = null, angle = null, payload } = item;
|
|
108
|
+
const { lat, long, text, opacity = null, angle = null, payload, position } = item;
|
|
108
109
|
const { x, y } = globe.api_GetScreenPointFromGeo(
|
|
109
110
|
{
|
|
110
111
|
long: long,
|
|
@@ -116,7 +117,7 @@ export class ContextTextWriter3 {
|
|
|
116
117
|
const { opacityMultiplier, sizeMultiplier } = zoomAdaptor(payload);
|
|
117
118
|
const o = (opacity === null ? opacity_ : opacity * opacity_) * opacityMultiplier;
|
|
118
119
|
textFont.size = sizeMultiplier * textSize;
|
|
119
|
-
|
|
120
|
+
textFont.position = position;
|
|
120
121
|
if (x !== null && y !== null) globe.api_DrawContextTextMultiLine(text, textFont, o, { x: x + xOffset, y: y - yOffset }, angleIsOn, angle);
|
|
121
122
|
}
|
|
122
123
|
textFont.size = textSize;
|
|
@@ -154,7 +155,8 @@ export class ContextTextWriter3 {
|
|
|
154
155
|
};
|
|
155
156
|
const opacity = this.opacityAdaptor(item, id, container, properties);
|
|
156
157
|
const angle = this.angleAdaptor(item, id, container, properties);
|
|
157
|
-
|
|
158
|
+
const position = this.positionAdaptor(item, id, container, properties);
|
|
159
|
+
this.itemMap.set(key, { long: coords.long, lat: coords.lat, text, opacity, angle, payload: item, position });
|
|
158
160
|
}
|
|
159
161
|
|
|
160
162
|
clear() {
|