@openglobus/og 0.13.1 → 0.13.4
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.
- package/dist/@openglobus/og.esm.js +2 -2
- package/dist/@openglobus/og.esm.js.map +1 -1
- package/dist/@openglobus/og.umd.js +2 -2
- package/dist/@openglobus/og.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/og/control/TouchNavigation.js +340 -319
- package/src/og/entity/GeoObject.js +4 -0
- package/src/og/entity/GeoObjectHandler.js +22 -33
- package/src/og/entity/LabelHandler.js +1 -2
- package/src/og/renderer/RendererEvents.js +1051 -1051
- package/src/og/shaders/billboard.js +8 -0
- package/src/og/shaders/drawnode.js +17 -13
- package/src/og/shaders/label.js +27 -46
- package/types/entity/GeoObject.d.ts +1 -0
|
@@ -92,6 +92,14 @@ export function billboardPicking() {
|
|
|
92
92
|
vec4 posRTE = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
|
|
93
93
|
vec4 projPos = projectionMatrix * posRTE;
|
|
94
94
|
|
|
95
|
+
float camSlope = dot(vec3(viewMatrix[0][2], viewMatrix[1][2], viewMatrix[2][2]), normalize(cameraPos));
|
|
96
|
+
if(camSlope > 0.5) {
|
|
97
|
+
float dist = dot(look, normalize(cameraPos));
|
|
98
|
+
projPos.z += dist * 0.02;
|
|
99
|
+
}else{
|
|
100
|
+
projPos.z += -(abs(projPos.z)) * 0.002;
|
|
101
|
+
}
|
|
102
|
+
|
|
95
103
|
projPos.z += depthOffset + a_offset.z;
|
|
96
104
|
|
|
97
105
|
vec2 screenPos = project(projPos);
|
|
@@ -158,7 +158,7 @@ export function drawnode_screen_wl() {
|
|
|
158
158
|
varying vec4 vTextureCoord;
|
|
159
159
|
varying vec2 vGlobalTextureCoord;
|
|
160
160
|
varying vec4 v_vertex;
|
|
161
|
-
varying float v_height;
|
|
161
|
+
varying float v_height;
|
|
162
162
|
|
|
163
163
|
void main(void) {
|
|
164
164
|
|
|
@@ -209,27 +209,31 @@ export function drawnode_screen_wl() {
|
|
|
209
209
|
|
|
210
210
|
${DEF_BLEND_WEBGL1}
|
|
211
211
|
|
|
212
|
+
float shininess;
|
|
213
|
+
float reflection;
|
|
214
|
+
float diffuseLightWeighting;
|
|
215
|
+
vec3 night;
|
|
212
216
|
|
|
213
217
|
void main(void) {
|
|
214
|
-
|
|
218
|
+
|
|
215
219
|
float overGround = 1.0 - step(0.1, v_height);
|
|
216
220
|
vec3 normal = normalize(normalMatrix * ((texture2D(uNormalMap, vTextureCoord.zw).rgb - 0.5) * 2.0));
|
|
217
221
|
vec3 lightDirection = normalize(lightsPositions[0].xyz - v_vertex.xyz * lightsPositions[0].w);
|
|
218
222
|
vec3 eyeDirection = normalize(-v_vertex.xyz);
|
|
219
223
|
vec3 reflectionDirection = reflect(-lightDirection, normal);
|
|
220
224
|
vec4 nightImageColor = texture2D( nightTexture, vGlobalTextureCoord.st );
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
+
shininess = texture2D( specularTexture, vGlobalTextureCoord.st ).r * 255.0 * overGround;
|
|
226
|
+
reflection = max( dot(reflectionDirection, eyeDirection), 0.0);
|
|
227
|
+
diffuseLightWeighting = max(dot(normal, lightDirection), 0.0);
|
|
228
|
+
night = nightStep * (.18 - diffuseLightWeighting * 3.0) * nightImageColor.rgb;
|
|
225
229
|
night *= overGround * step(0.0, night);
|
|
226
230
|
|
|
227
231
|
vec3 spec = specular.rgb * pow( reflection, specular.w) * shininess;
|
|
228
|
-
|
|
232
|
+
vec4 lightWeighting = vec4(ambient + diffuse * diffuseLightWeighting + spec + night, 1.0);
|
|
229
233
|
|
|
230
234
|
gl_FragColor = texture2D( defaultTexture, vTextureCoord.xy );
|
|
231
235
|
if( samplerCount == 0 ) {
|
|
232
|
-
gl_FragColor *=
|
|
236
|
+
gl_FragColor *= lightWeighting;
|
|
233
237
|
return;
|
|
234
238
|
}
|
|
235
239
|
|
|
@@ -237,30 +241,30 @@ export function drawnode_screen_wl() {
|
|
|
237
241
|
|
|
238
242
|
blend(gl_FragColor, samplerArr[0], tileOffsetArr[0], layerOpacityArr[0]);
|
|
239
243
|
if( samplerCount == 1 ) {
|
|
240
|
-
gl_FragColor *=
|
|
244
|
+
gl_FragColor *= lightWeighting;
|
|
241
245
|
return;
|
|
242
246
|
}
|
|
243
247
|
|
|
244
248
|
blend(gl_FragColor, samplerArr[1], tileOffsetArr[1], layerOpacityArr[1]);
|
|
245
249
|
if( samplerCount == 2 ) {
|
|
246
|
-
gl_FragColor *=
|
|
250
|
+
gl_FragColor *= lightWeighting;
|
|
247
251
|
return;
|
|
248
252
|
}
|
|
249
253
|
|
|
250
254
|
blend(gl_FragColor, samplerArr[2], tileOffsetArr[2], layerOpacityArr[2]);
|
|
251
255
|
if( samplerCount == 3 ) {
|
|
252
|
-
gl_FragColor *=
|
|
256
|
+
gl_FragColor *= lightWeighting;
|
|
253
257
|
return;
|
|
254
258
|
}
|
|
255
259
|
|
|
256
260
|
blend(gl_FragColor, samplerArr[3], tileOffsetArr[3], layerOpacityArr[3]);
|
|
257
261
|
if( samplerCount == 4 ) {
|
|
258
|
-
gl_FragColor *=
|
|
262
|
+
gl_FragColor *= lightWeighting;
|
|
259
263
|
return;
|
|
260
264
|
}
|
|
261
265
|
|
|
262
266
|
blend(gl_FragColor, samplerArr[4], tileOffsetArr[4], layerOpacityArr[4]);
|
|
263
|
-
gl_FragColor *=
|
|
267
|
+
gl_FragColor *= lightWeighting;
|
|
264
268
|
}`
|
|
265
269
|
});
|
|
266
270
|
}
|
package/src/og/shaders/label.js
CHANGED
|
@@ -65,7 +65,6 @@ export function label_webgl2() {
|
|
|
65
65
|
flat out int v_fontIndex;
|
|
66
66
|
out vec4 v_outlineColor;
|
|
67
67
|
flat out float v_outline;
|
|
68
|
-
flat out int v_isOutlinePass;
|
|
69
68
|
|
|
70
69
|
uniform vec2 viewport;
|
|
71
70
|
uniform mat4 viewMatrix;
|
|
@@ -75,7 +74,6 @@ export function label_webgl2() {
|
|
|
75
74
|
uniform float planetRadius;
|
|
76
75
|
uniform vec3 scaleByDistance;
|
|
77
76
|
uniform float opacity;
|
|
78
|
-
uniform int isOutlinePass;
|
|
79
77
|
uniform float depthOffset;
|
|
80
78
|
|
|
81
79
|
const vec3 ZERO3 = vec3(0.0);
|
|
@@ -95,7 +93,6 @@ export function label_webgl2() {
|
|
|
95
93
|
vec3 cameraPos = eyePositionHigh + eyePositionLow;
|
|
96
94
|
|
|
97
95
|
v_outline = a_outline;
|
|
98
|
-
v_isOutlinePass = isOutlinePass;
|
|
99
96
|
|
|
100
97
|
v_fontIndex = int(a_fontIndex);
|
|
101
98
|
v_uv = vec2(a_texCoord.xy);
|
|
@@ -138,6 +135,8 @@ export function label_webgl2() {
|
|
|
138
135
|
fragmentShader:
|
|
139
136
|
`#version 300 es
|
|
140
137
|
|
|
138
|
+
uniform int isOutlinePass;
|
|
139
|
+
|
|
141
140
|
precision highp float;
|
|
142
141
|
precision highp int;
|
|
143
142
|
|
|
@@ -150,7 +149,6 @@ export function label_webgl2() {
|
|
|
150
149
|
|
|
151
150
|
uniform sampler2D fontTextureArr[MAX_SIZE];
|
|
152
151
|
uniform vec4 sdfParamsArr[MAX_SIZE];
|
|
153
|
-
flat in int v_isOutlinePass;
|
|
154
152
|
|
|
155
153
|
flat in int v_fontIndex;
|
|
156
154
|
in vec2 v_uv;
|
|
@@ -219,42 +217,25 @@ export function label_webgl2() {
|
|
|
219
217
|
return sdfParamsArr[10];
|
|
220
218
|
}
|
|
221
219
|
}
|
|
222
|
-
|
|
223
|
-
// void main () {
|
|
224
|
-
//
|
|
225
|
-
// float sd = getDistance();
|
|
226
|
-
//
|
|
227
|
-
// vec4 sdfParams = getSDFParams();
|
|
228
|
-
//
|
|
229
|
-
// vec2 dxdy = fwidth(v_uv) * sdfParams.xy;
|
|
230
|
-
// float dist = sd + min(0.001, 0.5 - 1.0 / sdfParams.w) - 0.5;
|
|
231
|
-
// float opacity = clamp(dist * sdfParams.w / length(dxdy) + 0.5, 0.0, 1.0);
|
|
232
|
-
//
|
|
233
|
-
// float strokeDist = sd + min(v_outline, 0.5 - 1.0 / sdfParams.w) - 0.5;
|
|
234
|
-
// float strokeAlpha = v_rgba.a * clamp(strokeDist * sdfParams.w / length(dxdy) + 0.5, 0.0, 1.0);
|
|
235
|
-
//
|
|
236
|
-
// if (strokeAlpha < 0.01) {
|
|
237
|
-
// discard;
|
|
238
|
-
// }
|
|
239
|
-
//
|
|
240
|
-
// outScreen = v_rgba * opacity * v_rgba.a + v_outlineColor * v_outlineColor.a * strokeAlpha * (1.0 - opacity);
|
|
241
|
-
// }
|
|
242
|
-
|
|
220
|
+
|
|
243
221
|
void main () {
|
|
244
222
|
|
|
245
223
|
vec4 sdfParams = getSDFParams();
|
|
246
|
-
|
|
224
|
+
float sd = getDistance();
|
|
247
225
|
vec2 dxdy = fwidth(v_uv) * sdfParams.xy;
|
|
248
|
-
float dist =
|
|
226
|
+
float dist = sd + min(0.001, 0.5 - 1.0 / sdfParams.w) - 0.5;
|
|
249
227
|
float opacity = clamp(dist * sdfParams.w / length(dxdy) + 0.5, 0.0, 1.0);
|
|
250
228
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
229
|
+
if(isOutlinePass == 0){
|
|
230
|
+
outScreen = vec4(v_rgba.rgb, opacity * v_rgba.a);
|
|
231
|
+
} else {
|
|
232
|
+
float strokeDist = sd + min(v_outline, 0.5 - 1.0 / sdfParams.w) - 0.5;
|
|
233
|
+
float strokeAlpha = v_rgba.a * clamp(strokeDist * sdfParams.w / length(dxdy) + 0.5, 0.0, 1.0);
|
|
234
|
+
if(strokeAlpha < 0.1){
|
|
235
|
+
discard;
|
|
236
|
+
}
|
|
237
|
+
outScreen = v_rgba * strokeAlpha * (0.5 - opacity) * 2.0;
|
|
238
|
+
}
|
|
258
239
|
}`
|
|
259
240
|
});
|
|
260
241
|
}
|
|
@@ -303,7 +284,6 @@ export function label_screen() {
|
|
|
303
284
|
attribute float a_fontIndex;
|
|
304
285
|
|
|
305
286
|
varying float v_outline;
|
|
306
|
-
varying float v_isOutlinePass;
|
|
307
287
|
varying vec2 v_uv;
|
|
308
288
|
varying vec4 v_rgba;
|
|
309
289
|
varying float v_fontIndex;
|
|
@@ -316,7 +296,6 @@ export function label_screen() {
|
|
|
316
296
|
uniform float planetRadius;
|
|
317
297
|
uniform vec3 scaleByDistance;
|
|
318
298
|
uniform float opacity;
|
|
319
|
-
uniform int isOutlinePass;
|
|
320
299
|
uniform float depthOffset;
|
|
321
300
|
|
|
322
301
|
const vec3 ZERO3 = vec3(0.0);
|
|
@@ -336,7 +315,6 @@ export function label_screen() {
|
|
|
336
315
|
vec3 cameraPos = eyePositionHigh + eyePositionLow;
|
|
337
316
|
|
|
338
317
|
v_outline = a_outline;
|
|
339
|
-
v_isOutlinePass = float(isOutlinePass);
|
|
340
318
|
v_uv = vec2(a_texCoord.xy);
|
|
341
319
|
v_rgba = a_rgba;
|
|
342
320
|
v_fontIndex = a_fontIndex;
|
|
@@ -391,9 +369,9 @@ export function label_screen() {
|
|
|
391
369
|
|
|
392
370
|
uniform sampler2D fontTextureArr[MAX_SIZE];
|
|
393
371
|
uniform vec4 sdfParamsArr[MAX_SIZE];
|
|
372
|
+
uniform int isOutlinePass;
|
|
394
373
|
|
|
395
374
|
varying float v_outline;
|
|
396
|
-
varying float v_isOutlinePass;
|
|
397
375
|
varying vec2 v_uv;
|
|
398
376
|
varying vec4 v_rgba;
|
|
399
377
|
varying float v_fontIndex;
|
|
@@ -464,18 +442,21 @@ export function label_screen() {
|
|
|
464
442
|
fontIndex = v_fontIndex + 0.1;
|
|
465
443
|
|
|
466
444
|
vec4 sdfParams = getSDFParams();
|
|
467
|
-
|
|
445
|
+
float sd = getDistance();
|
|
468
446
|
vec2 dxdy = fwidth(v_uv) * sdfParams.xy;
|
|
469
|
-
float dist =
|
|
447
|
+
float dist = sd + min(0.001, 0.5 - 1.0 / sdfParams.w) - 0.5;
|
|
470
448
|
float opacity = clamp(dist * sdfParams.w / length(dxdy) + 0.5, 0.0, 1.0);
|
|
471
449
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
450
|
+
if(isOutlinePass == 0){
|
|
451
|
+
gl_FragColor = vec4(v_rgba.rgb, opacity * v_rgba.a);
|
|
452
|
+
} else {
|
|
453
|
+
float strokeDist = sd + min(v_outline, 0.5 - 1.0 / sdfParams.w) - 0.5;
|
|
454
|
+
float strokeAlpha = v_rgba.a * clamp(strokeDist * sdfParams.w / length(dxdy) + 0.5, 0.0, 1.0);
|
|
455
|
+
if(strokeAlpha < 0.1){
|
|
456
|
+
discard;
|
|
457
|
+
}
|
|
458
|
+
gl_FragColor = v_rgba * strokeAlpha * (0.5 - opacity) * 2.0;
|
|
476
459
|
}
|
|
477
|
-
|
|
478
|
-
gl_FragColor = vec4(v_rgba.rgb, opacity * v_rgba.a);
|
|
479
460
|
}`
|
|
480
461
|
});
|
|
481
462
|
}
|