@pirireis/webglobeplugins 0.6.30-c → 0.6.32-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.
@@ -63,12 +63,12 @@ export default class TrackGlowLineProgram {
63
63
  gl.useProgram(_blurProgram.program);
64
64
  gl.uniform1fv(_blurProgram.u_weight, options.weights || [1, 0.45045946, 0.2216216, 0.154054, 0.056216]);
65
65
  gl.uniform1f(_blurProgram.u_alpha_threshold, options.alphaThreshold || 0.0);
66
+ gl.uniform1i(_blurProgram.u_glow, 1);
66
67
 
67
68
  gl.useProgram(_combineProgram.program);
68
69
  gl.uniform1f(_combineProgram.u_exposure, options.exposure || 1.0);
69
70
  gl.uniform1f(_combineProgram.u_gamma, options.gamma || 1.0);
70
71
  gl.uniform1f(_combineProgram.u_final_alpha_ratio, options.finalAlphaRatio || 1.0);
71
- gl.uniform1i(_blurProgram.u_glow, 1);
72
72
  gl.useProgram(currentProgram);
73
73
  }
74
74
 
@@ -302,130 +302,130 @@ export default class TrackGlowLineProgram {
302
302
  const gl = this.gl;
303
303
 
304
304
  const vertexShader = `#version 300 es
305
- precision highp float;
305
+ precision highp float;
306
306
 
307
- in vec2 a_position;
308
- out vec2 v_texcoord;
307
+ in vec2 a_position;
308
+ out vec2 v_texcoord;
309
309
 
310
- void main() {
311
- gl_Position = vec4(a_position, 0.0, 1.0);
312
- v_texcoord = a_position.xy * 0.5 + 0.5;
313
- }
314
- `;
310
+ void main() {
311
+ gl_Position = vec4(a_position, 0.0, 1.0);
312
+ v_texcoord = a_position.xy * 0.5 + 0.5;
313
+ }
314
+ `;
315
315
  const fragmentShader = `#version 300 es
316
- precision highp float;
317
-
318
- in vec2 v_texcoord;
319
-
320
- uniform sampler2D u_texture;
321
- uniform bool u_horizontal;
322
- uniform float u_weight[5];
323
- uniform float u_alpha_threshold;
324
- uniform bool u_glow;
325
- out vec4 outColor;
316
+ precision highp float;
317
+
318
+ in vec2 v_texcoord;
319
+
320
+ uniform sampler2D u_texture;
321
+ uniform bool u_horizontal;
322
+ uniform float u_weight[5];
323
+ uniform float u_alpha_threshold;
324
+ uniform bool u_glow;
325
+ out vec4 outColor;
326
+
327
+ void main()
328
+ {
329
+ vec2 tex_offset = vec2(
330
+ 1.0 / float(textureSize(u_texture, 0).x),
331
+ 1.0 / float(textureSize(u_texture, 0).y) ); // gets size of single texel
332
+ vec3 color = vec3(0.0);
333
+ float total_alpha = texture(u_texture, v_texcoord).a * u_weight[0];
334
+ if (total_alpha > 0.0){
335
+ color = texture(u_texture, v_texcoord).rgb;
336
+ }
337
+ vec2 offset = vec2(0.0);
338
+ float alpha;
339
+ float color_count = 0.0;
340
+ if (!u_glow){
341
+ if(u_horizontal){
342
+ for(int i = 1; i < 5; ++i)
343
+ {
344
+ offset = vec2(tex_offset.x * float(i), 0.0);
345
+ alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
346
+
347
+ if (alpha > u_alpha_threshold){
348
+ // color = max( color, texture(u_texture, v_texcoord + offset).rgb);
349
+ color += texture(u_texture, v_texcoord + offset).rgb;
350
+ total_alpha += alpha;
351
+ color_count += 1.0;
352
+ }
353
+ alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
354
+ if (alpha > u_alpha_threshold){
355
+ // color = max( color, texture(u_texture, v_texcoord - offset).rgb);
356
+ color += texture(u_texture, v_texcoord - offset).rgb ;
357
+ total_alpha += alpha;
358
+ color_count += 1.0;
326
359
 
327
- void main()
328
- {
329
- vec2 tex_offset = vec2(
330
- 1.0 / float(textureSize(u_texture, 0).x),
331
- 1.0 / float(textureSize(u_texture, 0).y) ); // gets size of single texel
332
- vec3 color = vec3(0.0);
333
- float total_alpha = texture(u_texture, v_texcoord).a * u_weight[0];
334
- if (total_alpha > 0.0){
335
- color = texture(u_texture, v_texcoord).rgb;
360
+ }
361
+ }
362
+ } else {
363
+ for(int i = 1; i < 5; ++i)
364
+ {
365
+ offset = vec2(0.0, tex_offset.y * float(i));
366
+ alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
367
+ if (alpha > u_alpha_threshold){
368
+ // color = max( color , texture(u_texture, v_texcoord + offset).rgb);
369
+ color += texture(u_texture, v_texcoord + offset).rgb;
370
+ total_alpha += alpha;
371
+ color_count += 1.0;
372
+
373
+ }
374
+ alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
375
+ if (alpha > u_alpha_threshold){
376
+ // color = max( color, texture(u_texture, v_texcoord - offset).rgb );
377
+ color += texture(u_texture, v_texcoord - offset).rgb ;
378
+ total_alpha += alpha;
379
+ color_count += 1.0;
380
+
381
+ }
382
+ }
383
+
384
+ }
385
+ if (color_count > 0.0){
386
+ color /= color_count;
336
387
  }
337
- vec2 offset = vec2(0.0);
338
- float alpha;
339
- float color_count = 0.0;
340
- if (!u_glow){
341
- if(u_horizontal){
342
- for(int i = 1; i < 5; ++i)
343
- {
344
- offset = vec2(tex_offset.x * float(i), 0.0);
345
- alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
346
-
347
- if (alpha > u_alpha_threshold){
348
- // color = max( color, texture(u_texture, v_texcoord + offset).rgb);
349
- color += texture(u_texture, v_texcoord + offset).rgb;
350
- total_alpha += alpha;
351
- color_count += 1.0;
352
- }
353
- alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
354
- if (alpha > u_alpha_threshold){
355
- // color = max( color, texture(u_texture, v_texcoord - offset).rgb);
356
- color += texture(u_texture, v_texcoord - offset).rgb ;
357
- total_alpha += alpha;
358
- color_count += 1.0;
359
-
360
- }
361
- }
362
388
  } else {
363
- for(int i = 1; i < 5; ++i)
364
- {
365
- offset = vec2(0.0, tex_offset.y * float(i));
366
- alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
367
- if (alpha > u_alpha_threshold){
368
- // color = max( color , texture(u_texture, v_texcoord + offset).rgb);
369
- color += texture(u_texture, v_texcoord + offset).rgb;
370
- total_alpha += alpha;
371
- color_count += 1.0;
372
-
373
- }
374
- alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
375
- if (alpha > u_alpha_threshold){
376
- // color = max( color, texture(u_texture, v_texcoord - offset).rgb );
377
- color += texture(u_texture, v_texcoord - offset).rgb ;
378
- total_alpha += alpha;
379
- color_count += 1.0;
380
-
381
- }
382
- }
383
-
389
+ if(u_horizontal)
390
+ {
391
+ for(int i = 1; i < 5; ++i)
392
+ {
393
+ offset = vec2(tex_offset.x * float(i), 0.0);
394
+ alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
395
+
396
+ if (alpha > u_alpha_threshold){
397
+ color = max( color, texture(u_texture, v_texcoord + offset).rgb);
398
+ total_alpha += alpha;
384
399
  }
385
- if (color_count > 0.0){
386
- color /= color_count;
387
- }
388
- } else {
389
- if(u_horizontal)
390
- {
391
- for(int i = 1; i < 5; ++i)
392
- {
393
- offset = vec2(tex_offset.x * float(i), 0.0);
394
- alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
395
-
396
- if (alpha > u_alpha_threshold){
397
- color = max( color, texture(u_texture, v_texcoord + offset).rgb);
398
- total_alpha += alpha;
399
- }
400
- alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
401
- if (alpha > u_alpha_threshold){
402
- color = max( color, texture(u_texture, v_texcoord - offset).rgb);
403
-
404
- total_alpha += alpha;
405
- }
406
- }
400
+ alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
401
+ if (alpha > u_alpha_threshold){
402
+ color = max( color, texture(u_texture, v_texcoord - offset).rgb);
403
+
404
+ total_alpha += alpha;
407
405
  }
408
- else
409
- {
410
- for(int i = 1; i < 5; ++i)
411
- {
412
- offset = vec2(0.0, tex_offset.y * float(i));
413
- alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
414
- if (alpha > u_alpha_threshold){
415
- color = max( color, texture(u_texture, v_texcoord + offset).rgb);
416
- total_alpha += alpha;
417
- }
418
- alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
419
- if (alpha > u_alpha_threshold){
420
- color = max( color, texture(u_texture, v_texcoord - offset).rgb );
421
- total_alpha += alpha;
422
- }
423
- }
406
+ }
407
+ }
408
+ else
409
+ {
410
+ for(int i = 1; i < 5; ++i)
411
+ {
412
+ offset = vec2(0.0, tex_offset.y * float(i));
413
+ alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
414
+ if (alpha > u_alpha_threshold){
415
+ color = max( color, texture(u_texture, v_texcoord + offset).rgb);
416
+ total_alpha += alpha;
417
+ }
418
+ alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
419
+ if (alpha > u_alpha_threshold){
420
+ color = max( color, texture(u_texture, v_texcoord - offset).rgb );
421
+ total_alpha += alpha;
424
422
  }
425
423
  }
426
- outColor = vec4(color, total_alpha);
427
424
  }
428
- `;
425
+ }
426
+ outColor = vec4(color, total_alpha);
427
+ }
428
+ `;
429
429
 
430
430
  const program = createProgram(this.gl, vertexShader, fragmentShader);
431
431
 
@@ -463,77 +463,77 @@ export default class TrackGlowLineProgram {
463
463
  const gl = this.gl;
464
464
 
465
465
  const vertexShader = `#version 300 es
466
- precision highp float;
466
+ precision highp float;
467
467
 
468
- in vec2 a_position;
469
- out vec2 v_texcoord;
468
+ in vec2 a_position;
469
+ out vec2 v_texcoord;
470
470
 
471
- void main() {
472
- gl_Position = vec4(a_position, 0.0, 1.0);
473
- v_texcoord = a_position.xy * 0.5 + 0.5;
474
- }
475
- `;
471
+ void main() {
472
+ gl_Position = vec4(a_position, 0.0, 1.0);
473
+ v_texcoord = a_position.xy * 0.5 + 0.5;
474
+ }
475
+ `;
476
476
  const fragmentShader = `#version 300 es
477
- precision highp float;
478
-
479
- in vec2 v_texcoord;
480
-
481
- uniform sampler2D u_texture;
482
- uniform bool u_horizontal;
483
- uniform float u_weight[5];
484
- uniform float u_alpha_threshold;
477
+ precision highp float;
485
478
 
486
- out vec4 outColor;
479
+ in vec2 v_texcoord;
487
480
 
488
- void main()
489
- {
490
- vec2 tex_offset = vec2(1) / vec2(textureSize(u_texture, 0)); // gets size of single texel
491
- vec3 color = vec3(0.0);
492
- float total_alpha = texture(u_texture, v_texcoord).a * u_weight[0];
493
- if (total_alpha > 0.0){
494
- color = texture(u_texture, v_texcoord).rgb;
495
- }
496
- vec2 offset = vec2(0.0);
497
- float alpha;
481
+ uniform sampler2D u_texture;
482
+ uniform bool u_horizontal;
483
+ uniform float u_weight[5];
484
+ uniform float u_alpha_threshold;
498
485
 
499
- if(u_horizontal)
500
- {
501
- for(int i = 1; i < 5; ++i)
502
- {
503
- offset = vec2(tex_offset.x * float(i), 0.0);
504
- alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
505
-
506
- if (alpha > u_alpha_threshold){
507
- color = max( color, texture(u_texture, v_texcoord + offset).rgb);
508
- total_alpha += alpha;
509
- }
510
- alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
511
- if (alpha > u_alpha_threshold){
512
- color = max( color, texture(u_texture, v_texcoord - offset).rgb);
513
- total_alpha += alpha;
514
- }
515
- }
486
+ out vec4 outColor;
487
+
488
+ void main()
489
+ {
490
+ vec2 tex_offset = vec2(1) / vec2(textureSize(u_texture, 0)); // gets size of single texel
491
+ vec3 color = vec3(0.0);
492
+ float total_alpha = texture(u_texture, v_texcoord).a * u_weight[0];
493
+ if (total_alpha > 0.0){
494
+ color = texture(u_texture, v_texcoord).rgb;
495
+ }
496
+ vec2 offset = vec2(0.0);
497
+ float alpha;
498
+
499
+ if(u_horizontal)
500
+ {
501
+ for(int i = 1; i < 5; ++i)
502
+ {
503
+ offset = vec2(tex_offset.x * float(i), 0.0);
504
+ alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
505
+
506
+ if (alpha > u_alpha_threshold){
507
+ color = max( color, texture(u_texture, v_texcoord + offset).rgb);
508
+ total_alpha += alpha;
516
509
  }
517
- else
518
- {
519
- for(int i = 1; i < 5; ++i)
520
- {
521
- offset = vec2(0.0, tex_offset.y * float(i));
522
- alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
523
- if (alpha > u_alpha_threshold){
524
- color = max( color , texture(u_texture, v_texcoord + offset).rgb);
525
- total_alpha += alpha;
526
- }
527
- alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
528
- if (alpha > u_alpha_threshold){
529
- color = max( color, texture(u_texture, v_texcoord - offset).rgb );
530
- total_alpha += alpha;
531
- }
532
- }
510
+ alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
511
+ if (alpha > u_alpha_threshold){
512
+ color = max( color, texture(u_texture, v_texcoord - offset).rgb);
513
+ total_alpha += alpha;
533
514
  }
534
- outColor = vec4(color, total_alpha);
535
515
  }
536
- `;
516
+ }
517
+ else
518
+ {
519
+ for(int i = 1; i < 5; ++i)
520
+ {
521
+ offset = vec2(0.0, tex_offset.y * float(i));
522
+ alpha = texture(u_texture, v_texcoord + offset).a * u_weight[i];
523
+ if (alpha > u_alpha_threshold){
524
+ color = max( color , texture(u_texture, v_texcoord + offset).rgb);
525
+ total_alpha += alpha;
526
+ }
527
+ alpha = texture(u_texture, v_texcoord - offset).a * u_weight[i];
528
+ if (alpha > u_alpha_threshold){
529
+ color = max( color, texture(u_texture, v_texcoord - offset).rgb );
530
+ total_alpha += alpha;
531
+ }
532
+ }
533
+ }
534
+ outColor = vec4(color, total_alpha);
535
+ }
536
+ `;
537
537
 
538
538
  const program = createProgram(this.gl, vertexShader, fragmentShader);
539
539
 
@@ -583,88 +583,88 @@ export default class TrackGlowLineProgram {
583
583
  const gl = this.gl;
584
584
 
585
585
  const vertexShader = `#version 300 es
586
- precision highp float;
587
-
588
- in vec3 a_position;
589
- in float a_time;
590
- in vec3 a_color;
591
- in float a_track_start_time;
592
- in float a_track_end_time;
593
-
594
- uniform mat4 uModelViewMatrix;
595
- uniform mat4 uProjectionMatrix;
596
- uniform vec3 uTranslate;
597
-
598
- uniform bool u_is_3d;
599
- uniform vec2 u_mapWH;
600
- uniform vec2 u_scrWH;
601
-
602
- out float v_time;
603
- out vec3 v_color;
604
- out float v_track_start_time;
605
- out float v_track_end_time;
606
-
607
- ` + shaderfunctions.pixelXYToCartesian3DPoint
608
- + shaderfunctions.pixelXYToCartesian2DPoint + `
609
-
610
- void main() {
611
- v_time = a_time;
612
- v_color = a_color;
613
- v_track_start_time = a_track_start_time;
614
- v_track_end_time = a_track_end_time;
615
- if (u_is_3d){
616
- vec3 pos = pixelXYToCartesian3DPoint(a_position);
617
- gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(pos - uTranslate, 1.0);
618
- } else {
619
- vec2 xy = pixelXYToCartesian2DPoint(a_position.xy, uTranslate.xy, u_mapWH, u_scrWH);
620
- gl_Position = uProjectionMatrix * vec4(xy.x, xy.y, 0.0, 1.0);
621
-
622
- }
623
- gl_PointSize = 1.0;
624
- }
625
- `;
586
+ precision highp float;
587
+
588
+ in vec3 a_position;
589
+ in float a_time;
590
+ in vec3 a_color;
591
+ in float a_track_start_time;
592
+ in float a_track_end_time;
593
+
594
+ uniform mat4 uModelViewMatrix;
595
+ uniform mat4 uProjectionMatrix;
596
+ uniform vec3 uTranslate;
597
+
598
+ uniform bool u_is_3d;
599
+ uniform vec2 u_mapWH;
600
+ uniform vec2 u_scrWH;
601
+
602
+ out float v_time;
603
+ out vec3 v_color;
604
+ out float v_track_start_time;
605
+ out float v_track_end_time;
606
+
607
+ ${shaderfunctions.pixelXYToCartesian3DPoint}
608
+ ${shaderfunctions.pixelXYToCartesian2DPoint}
609
+
610
+ void main() {
611
+ v_time = a_time;
612
+ v_color = a_color;
613
+ v_track_start_time = a_track_start_time;
614
+ v_track_end_time = a_track_end_time;
615
+ if (u_is_3d){
616
+ vec3 pos = pixelXYToCartesian3DPoint(a_position);
617
+ gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(pos - uTranslate, 1.0);
618
+ } else {
619
+ vec2 xy = pixelXYToCartesian2DPoint(a_position.xy, uTranslate.xy, u_mapWH, u_scrWH);
620
+ gl_Position = uProjectionMatrix * vec4(xy.x, xy.y, 0.0, 1.0);
621
+
622
+ }
623
+ gl_PointSize = 1.0;
624
+ }
625
+ `;
626
626
 
627
627
  const fragmentShader = `#version 300 es
628
- precision lowp float;
628
+ precision lowp float;
629
629
 
630
- in float v_time;
631
- in vec3 v_color;
632
- in float v_track_start_time;
633
- in float v_track_end_time;
630
+ in float v_time;
631
+ in vec3 v_color;
632
+ in float v_track_start_time;
633
+ in float v_track_end_time;
634
634
 
635
- uniform float u_head_time;
636
- uniform float u_tail_time;
635
+ uniform float u_head_time;
636
+ uniform float u_tail_time;
637
637
 
638
- uniform float u_head_percentage;
639
- uniform float u_route_alpha;
638
+ uniform float u_head_percentage;
639
+ uniform float u_route_alpha;
640
640
 
641
- layout(location = 0) out vec4 outColor0;
642
- layout(location = 1) out vec4 outColor1;
641
+ layout(location = 0) out vec4 outColor0;
642
+ layout(location = 1) out vec4 outColor1;
643
643
 
644
644
 
645
- void main() {
646
- if ( u_tail_time > v_track_end_time || u_head_time < v_track_start_time) discard;
647
- // if ( v_time < u_tail_time || v_time > u_head_time) discard;
648
-
649
- float gap = u_head_time - u_tail_time;
650
- float head = gap * u_head_percentage;
651
- float dist = u_head_time - v_time;
652
- if ((v_time > u_head_time ) || (v_time < u_tail_time) ){
653
-
654
- outColor0 = vec4(v_color , u_route_alpha);
655
- } else if (dist < head) {
656
- // white head
657
- outColor0 = vec4(1.0, 1.0, 1.0, 0.77 + ( u_route_alpha * 0.23));
658
- outColor1 = vec4(1.0, 1.0, 1.0, 0.77 + ( u_route_alpha * 0.23));
659
- //
660
- } else {
661
- // colored body of lines
662
- float alpha = ((gap - dist) / gap) / 2.0 + 0.5;
663
- outColor0 = vec4(v_color , alpha );
664
- outColor1 = vec4(v_color , alpha );
665
- }
666
- }
667
- `;
645
+ void main() {
646
+ if ( u_tail_time > v_track_end_time || u_head_time < v_track_start_time) discard;
647
+ // if ( v_time < u_tail_time || v_time > u_head_time) discard;
648
+
649
+ float gap = u_head_time - u_tail_time;
650
+ float head = gap * u_head_percentage;
651
+ float dist = u_head_time - v_time;
652
+ if ((v_time > u_head_time ) || (v_time < u_tail_time) ){
653
+
654
+ outColor0 = vec4(v_color , u_route_alpha);
655
+ } else if (dist < head) {
656
+ // white head
657
+ outColor0 = vec4(1.0, 1.0, 1.0, 0.77 + ( u_route_alpha * 0.23));
658
+ outColor1 = vec4(1.0, 1.0, 1.0, 0.77 + ( u_route_alpha * 0.23));
659
+ //
660
+ } else {
661
+ // colored body of lines
662
+ float alpha = ((gap - dist) / gap) / 2.0 + 0.5;
663
+ outColor0 = vec4(v_color , alpha );
664
+ outColor1 = vec4(v_color , alpha );
665
+ }
666
+ }
667
+ `;
668
668
  const program = createProgram(this.gl, vertexShader, fragmentShader);
669
669
  const a_position = gl.getAttribLocation(program, "a_position");
670
670
  const a_time = gl.getAttribLocation(program, "a_time");
@@ -104,7 +104,7 @@ export class ContextTextWriter3 {
104
104
  const angleIsOn = is3D ? (this.angleAdaptorIsOn && this.angleOnSphere) : (this.angleAdaptorIsOn)
105
105
  const zoomLevel = globe.api_GetCurrentLODWithDecimal();
106
106
  const zoomAdaptor = this.zoomLevelAdaptor(zoomLevel);
107
- for (const [key, item] of itemMap) {
107
+ for (const item of itemMap.values()) {
108
108
  const { lat, long, text, opacity = null, angle = null, payload, position } = item;
109
109
  const { x, y } = globe.api_GetScreenPointFromGeo(
110
110
  {
@@ -160,12 +160,6 @@ export class ContextTextWriter3 {
160
160
  }
161
161
 
162
162
 
163
- updateText() {
164
- this.itemMap.forEach((v, k, m) => {
165
- const { payload } = v;
166
- this.insertText(payload, 0, m, payload);
167
- });
168
- }
169
163
 
170
164
  clear() {
171
165
  this.itemMap.clear();