@openglobus/og 0.12.3 → 0.13.1

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 (93) hide show
  1. package/README.md +0 -2
  2. package/dist/@openglobus/og.esm.js +2 -2
  3. package/dist/@openglobus/og.esm.js.map +1 -1
  4. package/dist/@openglobus/og.umd.js +2 -2
  5. package/dist/@openglobus/og.umd.js.map +1 -1
  6. package/package.json +7 -7
  7. package/src/og/Extent.js +3 -3
  8. package/src/og/Globe.js +277 -275
  9. package/src/og/ImageCanvas.js +3 -3
  10. package/src/og/LonLat.js +9 -9
  11. package/src/og/QueueArray.js +2 -2
  12. package/src/og/Rectangle.js +5 -5
  13. package/src/og/bv/Box.js +1 -1
  14. package/src/og/bv/Sphere.js +2 -2
  15. package/src/og/camera/Camera.js +1 -1
  16. package/src/og/camera/PlanetCamera.js +649 -646
  17. package/src/og/control/LayerSwitcher.js +1 -1
  18. package/src/og/control/MouseNavigation.js +22 -13
  19. package/src/og/control/MouseWheelZoomControl.js +2 -2
  20. package/src/og/control/ScaleControl.js +1 -1
  21. package/src/og/control/TouchNavigation.js +319 -319
  22. package/src/og/control/ZoomControl.js +132 -132
  23. package/src/og/control/visibleExtent/Segment.js +12 -12
  24. package/src/og/ellipsoid/Ellipsoid.js +577 -567
  25. package/src/og/entity/BillboardHandler.js +878 -1051
  26. package/src/og/entity/Entity.js +1 -1
  27. package/src/og/entity/EntityCollection.js +847 -857
  28. package/src/og/entity/GeoObjectHandler.js +2 -2
  29. package/src/og/entity/LabelHandler.js +888 -1040
  30. package/src/og/entity/LabelWorker.js +0 -6
  31. package/src/og/entity/PointCloud.js +495 -495
  32. package/src/og/entity/Polyline.js +2218 -2222
  33. package/src/og/entity/RayHandler.js +1 -1
  34. package/src/og/layer/CanvasTiles.js +6 -3
  35. package/src/og/layer/GeoImage.js +1 -1
  36. package/src/og/layer/KML.js +5 -5
  37. package/src/og/layer/Layer.js +804 -752
  38. package/src/og/layer/Vector.js +997 -1010
  39. package/src/og/layer/XYZ.js +359 -357
  40. package/src/og/math/Line2.js +4 -4
  41. package/src/og/math/Quat.js +2 -2
  42. package/src/og/math/Ray.js +2 -2
  43. package/src/og/math/Vec2.js +524 -524
  44. package/src/og/math/Vec3.js +900 -900
  45. package/src/og/math/Vec4.js +261 -261
  46. package/src/og/math.js +397 -398
  47. package/src/og/quadTree/EntityCollectionNode.js +389 -387
  48. package/src/og/renderer/Renderer.js +14 -20
  49. package/src/og/renderer/RendererEvents.js +1034 -1045
  50. package/src/og/scene/Planet.js +12 -9
  51. package/src/og/scene/RenderNode.js +347 -354
  52. package/src/og/segment/Segment.js +3 -1
  53. package/src/og/segment/SegmentLonLat.js +1 -4
  54. package/src/og/shaders/billboard.js +220 -204
  55. package/src/og/shaders/drawnode.js +603 -603
  56. package/src/og/shaders/label.js +595 -456
  57. package/src/og/shaders/polyline.js +365 -361
  58. package/src/og/terrain/MapboxTerrain.js +1 -1
  59. package/src/og/utils/FontAtlas.js +209 -200
  60. package/src/og/utils/GeoImageCreator.js +4 -5
  61. package/src/og/utils/TextureAtlas.js +4 -4
  62. package/src/og/utils/VectorTileCreator.js +414 -414
  63. package/src/og/utils/shared.js +1 -1
  64. package/src/og/webgl/Handler.js +28 -60
  65. package/src/og/webgl/Multisample.js +260 -260
  66. package/src/og/webgl/Program.js +411 -396
  67. package/types/bv/Box.d.ts +1 -1
  68. package/types/bv/Sphere.d.ts +1 -1
  69. package/types/camera/PlanetCamera.d.ts +3 -3
  70. package/types/control/LayerSwitcher.d.ts +1 -1
  71. package/types/ellipsoid/Ellipsoid.d.ts +9 -2
  72. package/types/entity/BillboardHandler.d.ts +0 -4
  73. package/types/entity/EntityCollection.d.ts +0 -8
  74. package/types/entity/LabelHandler.d.ts +0 -2
  75. package/types/entity/Polyline.d.ts +1 -1
  76. package/types/layer/KML.d.ts +11 -11
  77. package/types/layer/Layer.d.ts +5 -0
  78. package/types/layer/Vector.d.ts +1 -8
  79. package/types/math/Line2.d.ts +4 -4
  80. package/types/math/Ray.d.ts +2 -2
  81. package/types/math/Vec2.d.ts +1 -1
  82. package/types/math/Vec3.d.ts +1 -1
  83. package/types/math/Vec4.d.ts +2 -2
  84. package/types/math.d.ts +1 -1
  85. package/types/renderer/Renderer.d.ts +1 -1
  86. package/types/renderer/RendererEvents.d.ts +1 -1
  87. package/types/shaders/label.d.ts +1 -1
  88. package/types/utils/FontAtlas.d.ts +3 -2
  89. package/types/utils/TextureAtlas.d.ts +3 -3
  90. package/types/utils/VectorTileCreator.d.ts +4 -4
  91. package/types/utils/shared.d.ts +1 -1
  92. package/types/webgl/Handler.d.ts +6 -31
  93. package/types/webgl/Program.d.ts +2 -0
@@ -1,457 +1,596 @@
1
- /**
2
- * @module og/shaders/label
3
- */
4
-
5
- 'use strict';
6
-
7
- import { Program } from '../webgl/Program.js';
8
-
9
- export function label_webgl2() {
10
-
11
- return new Program("label", {
12
- uniforms: {
13
- viewport: "vec2",
14
- fontTextureArr: "sampler2darray",
15
- projectionMatrix: "mat4",
16
- viewMatrix: "mat4",
17
- eyePositionHigh: "vec3",
18
- eyePositionLow: "vec3",
19
- planetRadius: "float",
20
- uZ: "float",
21
- scaleByDistance: "vec3",
22
- opacity: "float"
23
- },
24
- attributes: {
25
- a_outline: "float",
26
- a_gliphParam: "vec4",
27
- a_vertices: "vec2",
28
- a_texCoord: "vec4",
29
- a_positionsHigh: "vec3",
30
- a_positionsLow: "vec3",
31
- a_size: "float",
32
- //a_rotation: "float",
33
- a_rgba: "vec4",
34
- a_offset: "vec3",
35
- //a_alignedAxis: "vec3",
36
- a_fontIndex: "float",
37
- },
38
- vertexShader:
39
- `#version 300 es
40
-
41
- in float a_outline;
42
- in vec4 a_gliphParam;
43
- in vec2 a_vertices;
44
- in vec4 a_texCoord;
45
- in vec3 a_positionsHigh;
46
- in vec3 a_positionsLow;
47
- in vec3 a_offset;
48
- in float a_size;
49
- //in float a_rotation;
50
- in vec4 a_rgba;
51
- //in vec3 a_alignedAxis;
52
- in float a_fontIndex;
53
-
54
- out vec2 v_uv;
55
- out vec4 v_rgba;
56
- flat out float v_weight;
57
- flat out int v_fontIndex;
58
-
59
- uniform vec2 viewport;
60
- uniform mat4 viewMatrix;
61
- uniform mat4 projectionMatrix;
62
- uniform vec3 eyePositionHigh;
63
- uniform vec3 eyePositionLow;
64
- uniform float planetRadius;
65
- uniform float uZ;
66
- uniform vec3 scaleByDistance;
67
- uniform float opacity;
68
-
69
- const vec3 ZERO3 = vec3(0.0);
70
-
71
- vec2 project(vec4 p) {
72
- return (0.5 * p.xyz / p.w + 0.5).xy * viewport;
73
- }
74
-
75
- void main() {
76
-
77
- if(a_texCoord.z == -1.0 || a_outline == 0.0) {
78
- gl_Position = vec4(0.0);
79
- return;
80
- }
81
-
82
- vec3 a_positions = a_positionsHigh + a_positionsLow;
83
- vec3 cameraPos = eyePositionHigh + eyePositionLow;
84
-
85
- v_weight = a_outline;
86
-
87
- v_fontIndex = int(a_fontIndex);
88
- v_uv = vec2(a_texCoord.xy);
89
- float lookDist = length(a_positions - cameraPos);
90
- v_rgba = a_rgba;
91
- if(opacity * step(lookDist, sqrt(dot(cameraPos,cameraPos) - planetRadius) + sqrt(dot(a_positions,a_positions) - planetRadius)) == 0.0){
92
- return;
93
- }
94
-
95
- float scd = (1.0 - smoothstep(scaleByDistance[0], scaleByDistance[1], lookDist)) * (1.0 - step(scaleByDistance[2], lookDist));
96
-
97
- v_rgba.a *= opacity;
98
-
99
- mat4 viewMatrixRTE = viewMatrix;
100
- viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
101
-
102
- vec3 highDiff = a_positionsHigh - eyePositionHigh;
103
- vec3 lowDiff = a_positionsLow - eyePositionLow;
104
- vec4 posRTE = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
105
- vec4 projPos = projectionMatrix * posRTE;
106
- vec2 screenPos = project(projPos);
107
-
108
- vec2 v = screenPos + (a_vertices * a_gliphParam.xy + a_gliphParam.zw + vec2(a_texCoord.z, 0.0) + vec2(a_texCoord.w, 0.0)) * a_size * scd + a_offset.xy;
109
-
110
- gl_Position = vec4((2.0 * v / viewport - 1.0) * projPos.w, projPos.z + a_offset.z + uZ, projPos.w);
111
- }`,
112
- fragmentShader:
113
- `#version 300 es
114
-
115
- precision highp float;
116
-
117
- const int MAX_SIZE = 11;
118
-
119
- uniform sampler2D fontTextureArr[MAX_SIZE];
120
-
121
- flat in float v_weight;
122
- flat in int v_fontIndex;
123
- in vec2 v_uv;
124
- in vec4 v_rgba;
125
-
126
- in vec3 v_pickingColor;
127
-
128
- layout(location = 0) out vec4 outScreen;
129
-
130
- vec4 sdfParams = vec4(512.0, 512.0, 32.0, 8.0);
131
-
132
- float median(float r, float g, float b) {
133
- return max(min(r, g), min(max(r, g), b));
134
- }
135
-
136
- float getDistance() {
137
- vec3 msdf;
138
- if(v_fontIndex == 0) {
139
- msdf = texture(fontTextureArr[0], v_uv).rgb;
140
- } else if(v_fontIndex == 1){
141
- msdf = texture(fontTextureArr[1], v_uv).rgb;
142
- } else if(v_fontIndex == 2){
143
- msdf = texture(fontTextureArr[2], v_uv).rgb;
144
- } else if(v_fontIndex == 3){
145
- msdf = texture(fontTextureArr[3], v_uv).rgb;
146
- } else if(v_fontIndex == 4){
147
- msdf = texture(fontTextureArr[4], v_uv).rgb;
148
- } else if(v_fontIndex == 5){
149
- msdf = texture(fontTextureArr[5], v_uv).rgb;
150
- } else if(v_fontIndex == 6){
151
- msdf = texture(fontTextureArr[6], v_uv).rgb;
152
- } else if(v_fontIndex == 7){
153
- msdf = texture(fontTextureArr[7], v_uv).rgb;
154
- } else if(v_fontIndex == 8){
155
- msdf = texture(fontTextureArr[8], v_uv).rgb;
156
- } else if(v_fontIndex == 9){
157
- msdf = texture(fontTextureArr[9], v_uv).rgb;
158
- } else if(v_fontIndex == 10){
159
- msdf = texture(fontTextureArr[10], v_uv).rgb;
160
- }
161
- return median(msdf.r, msdf.g, msdf.b);
162
- }
163
-
164
- void main () {
165
-
166
- vec2 dxdy = fwidth(v_uv) * sdfParams.xy;
167
- float dist = getDistance() + min(v_weight, 0.5 - 1.0 / sdfParams.w) - 0.5;
168
- float opacity = clamp(dist * sdfParams.w / length(dxdy) + 0.5, 0.0, 1.0);
169
-
170
- vec4 color = v_rgba;
171
- color.a *= opacity;
172
- if (color.a < 0.01) {
173
- discard;
174
- }
175
-
176
- outScreen = vec4(v_rgba.rgb, opacity * v_rgba.a);
177
- }`
178
- });
179
- }
180
-
181
- export function labelPicking() {
182
- return new Program("labelPicking", {
183
- uniforms: {
184
- viewport: "vec2",
185
- projectionMatrix: "mat4",
186
- viewMatrix: "mat4",
187
- eyePositionHigh: "vec3",
188
- eyePositionLow: "vec3",
189
- planetRadius: "float",
190
- scaleByDistance: "vec3",
191
- opacity: "float"
192
- },
193
- attributes: {
194
- a_gliphParam: "vec4",
195
- a_vertices: "vec2",
196
- a_texCoord: "vec4",
197
- a_positionsHigh: "vec3",
198
- a_positionsLow: "vec3",
199
- a_offset: "vec3",
200
- a_size: "float",
201
- //a_rotation: "float",
202
- a_rgba: "vec4",
203
- //a_alignedAxis: "vec3"
204
- },
205
- vertexShader:
206
- `
207
- attribute vec4 a_gliphParam;
208
- attribute vec2 a_vertices;
209
- attribute vec4 a_texCoord;
210
- attribute vec3 a_positionsHigh;
211
- attribute vec3 a_positionsLow;
212
- attribute vec3 a_offset;
213
- attribute float a_size;
214
- //attribute float a_rotation;
215
- attribute vec4 a_rgba;
216
- //attribute vec3 a_alignedAxis;
217
-
218
- varying vec4 v_rgba;
219
-
220
- uniform vec2 viewport;
221
- uniform mat4 viewMatrix;
222
- uniform mat4 projectionMatrix;
223
- uniform vec3 eyePositionHigh;
224
- uniform vec3 eyePositionLow;
225
- uniform float planetRadius;
226
- uniform vec3 scaleByDistance;
227
- uniform float opacity;
228
-
229
- const vec3 ZERO3 = vec3(0.0);
230
-
231
- vec2 project(vec4 p) {
232
- return (0.5 * p.xyz / p.w + 0.5).xy * viewport;
233
- }
234
-
235
- void main() {
236
- vec3 a_positions = a_positionsHigh + a_positionsLow;
237
- vec3 cameraPos = eyePositionHigh + eyePositionLow;
238
-
239
- if(a_texCoord.z == -1.0){
240
- gl_Position = vec4(0.0);
241
- return;
242
- }
243
-
244
- float lookDist = length(a_positions - cameraPos);
245
- v_rgba = a_rgba;
246
- if(opacity * step(lookDist, sqrt(dot(cameraPos,cameraPos) - planetRadius) + sqrt(dot(a_positions,a_positions) - planetRadius)) == 0.0){
247
- return;
248
- }
249
-
250
- float scd = (1.0 - smoothstep(scaleByDistance[0], scaleByDistance[1], lookDist)) * (1.0 - step(scaleByDistance[2], lookDist));
251
-
252
- v_rgba.a *= opacity;
253
-
254
- mat4 viewMatrixRTE = viewMatrix;
255
- viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
256
-
257
- vec3 highDiff = a_positionsHigh - eyePositionHigh;
258
- vec3 lowDiff = a_positionsLow - eyePositionLow;
259
- vec4 posRTE = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
260
- vec4 projPos = projectionMatrix * posRTE;
261
- vec2 screenPos = project(projPos);
262
-
263
- vec2 v = screenPos + (a_vertices * a_gliphParam.xy + a_gliphParam.zw + vec2(a_texCoord.z, 0.0) + vec2(a_texCoord.w, 0.0)) * a_size * scd + a_offset.xy;
264
-
265
- gl_Position = vec4((2.0 * v / viewport - 1.0) * projPos.w, projPos.z + a_offset.z, projPos.w);
266
- }`,
267
- fragmentShader:
268
- `
269
- precision highp float;
270
-
271
- varying vec4 v_rgba;
272
-
273
- varying vec3 v_pickingColor;
274
-
275
- void main () {
276
-
277
- vec4 color = v_rgba;
278
- if (color.a < 0.05) {
279
- discard;
280
- }
281
-
282
- gl_FragColor = vec4(v_rgba.rgb, v_rgba.a);
283
- }`
284
- });
285
- }
286
-
287
- export function label_screen() {
288
- return new Program("label", {
289
- uniforms: {
290
- viewport: "vec2",
291
- fontTextureArr: "sampler2darray",
292
- projectionMatrix: "mat4",
293
- viewMatrix: "mat4",
294
- eyePositionHigh: "vec3",
295
- eyePositionLow: "vec3",
296
- planetRadius: "float",
297
- uZ: "float",
298
- scaleByDistance: "vec3",
299
- opacity: "float"
300
- },
301
- attributes: {
302
- a_outline: "float",
303
- a_gliphParam: "vec4",
304
- a_vertices: "vec2",
305
- a_texCoord: "vec4",
306
- a_positionsHigh: "vec3",
307
- a_positionsLow: "vec3",
308
- a_offset: "vec3",
309
- a_size: "float",
310
- //a_rotation: "float",
311
- a_rgba: "vec4",
312
- //a_alignedAxis: "vec3",
313
- a_fontIndex: "float",
314
- },
315
- vertexShader:
316
- `
317
- attribute float a_outline;
318
- attribute vec4 a_gliphParam;
319
- attribute vec2 a_vertices;
320
- attribute vec4 a_texCoord;
321
- attribute vec3 a_positionsHigh;
322
- attribute vec3 a_positionsLow;
323
- attribute vec3 a_offset;
324
- attribute float a_size;
325
- //attribute float a_rotation;
326
- attribute vec4 a_rgba;
327
- //attribute vec3 a_alignedAxis;
328
- attribute float a_fontIndex;
329
-
330
- varying vec2 v_uv;
331
- varying vec4 v_rgba;
332
- varying float v_weight;
333
- varying float v_fontIndex;
334
-
335
- uniform vec2 viewport;
336
- uniform mat4 viewMatrix;
337
- uniform mat4 projectionMatrix;
338
- uniform vec3 eyePositionHigh;
339
- uniform vec3 eyePositionLow;
340
- uniform float planetRadius;
341
- uniform float uZ;
342
- uniform vec3 scaleByDistance;
343
- uniform float opacity;
344
-
345
- const vec3 ZERO3 = vec3(0.0);
346
-
347
- vec2 project(vec4 p) {
348
- return (0.5 * p.xyz / p.w + 0.5).xy * viewport;
349
- }
350
-
351
- void main() {
352
-
353
- if(a_texCoord.z == -1.0 || a_outline == 0.0) {
354
- gl_Position = vec4(0.0);
355
- return;
356
- }
357
-
358
- v_weight = a_outline;
359
- v_fontIndex = a_fontIndex;
360
- v_uv = vec2(a_texCoord.xy);
361
-
362
- vec3 a_positions = a_positionsHigh + a_positionsLow;
363
- vec3 cameraPos = eyePositionHigh + eyePositionLow;
364
-
365
- float lookDist = length(a_positions - cameraPos);
366
- v_rgba = a_rgba;
367
- if(opacity * step(lookDist, sqrt(dot(cameraPos,cameraPos) - planetRadius) + sqrt(dot(a_positions,a_positions) - planetRadius)) == 0.0){
368
- return;
369
- }
370
-
371
- float scd = (1.0 - smoothstep(scaleByDistance[0], scaleByDistance[1], lookDist)) * (1.0 - step(scaleByDistance[2], lookDist));
372
-
373
- v_rgba.a *= opacity;
374
-
375
- mat4 viewMatrixRTE = viewMatrix;
376
- viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
377
-
378
- vec3 highDiff = a_positionsHigh - eyePositionHigh;
379
- vec3 lowDiff = a_positionsLow - eyePositionLow;
380
- vec4 posRTE = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
381
- vec4 projPos = projectionMatrix * posRTE;
382
- vec2 screenPos = project(projPos);
383
-
384
- vec2 v = screenPos + (a_vertices * a_gliphParam.xy + a_gliphParam.zw + vec2(a_texCoord.z, 0.0) + vec2(a_texCoord.w, 0.0)) * a_size * scd + a_offset.xy;
385
-
386
- gl_Position = vec4((2.0 * v / viewport - 1.0) * projPos.w, projPos.z + a_offset.z + uZ, projPos.w);
387
- }`,
388
- fragmentShader:
389
- `#extension GL_OES_standard_derivatives : enable
390
-
391
- precision highp float;
392
-
393
- const int MAX_SIZE = 11;
394
-
395
- uniform sampler2D fontTextureArr[MAX_SIZE];
396
-
397
- varying float v_fontIndex;
398
- varying float v_weight;
399
- varying vec2 v_uv;
400
- varying vec4 v_rgba;
401
-
402
- varying vec3 v_pickingColor;
403
-
404
- float fontIndex;
405
-
406
- vec4 sdfParams = vec4(512.0, 512.0, 32.0, 8.0);
407
-
408
- float median(float r, float g, float b) {
409
- return max(min(r, g), min(max(r, g), b));
410
- }
411
-
412
- float getDistance() {
413
- vec3 msdf;
414
- if(fontIndex >= 0.0 && fontIndex < 1.0) {
415
- msdf = texture2D(fontTextureArr[0], v_uv).rgb;
416
- } else if(fontIndex >= 1.0 && fontIndex < 2.0){
417
- msdf = texture2D(fontTextureArr[1], v_uv).rgb;
418
- } else if(fontIndex >= 2.0 && fontIndex < 3.0){
419
- msdf = texture2D(fontTextureArr[2], v_uv).rgb;
420
- } else if(fontIndex >= 3.0 && fontIndex < 4.0){
421
- msdf = texture2D(fontTextureArr[3], v_uv).rgb;
422
- } else if(fontIndex >= 4.0 && fontIndex < 5.0){
423
- msdf = texture2D(fontTextureArr[4], v_uv).rgb;
424
- } else if(fontIndex >= 5.0 && fontIndex < 6.0){
425
- msdf = texture2D(fontTextureArr[5], v_uv).rgb;
426
- } else if(fontIndex >= 6.0 && fontIndex < 7.0){
427
- msdf = texture2D(fontTextureArr[6], v_uv).rgb;
428
- } else if(fontIndex >= 7.0 && fontIndex < 8.0){
429
- msdf = texture2D(fontTextureArr[7], v_uv).rgb;
430
- } else if(fontIndex >= 8.0 && fontIndex < 9.0){
431
- msdf = texture2D(fontTextureArr[8], v_uv).rgb;
432
- } else if(fontIndex >= 9.0 && fontIndex < 10.0){
433
- msdf = texture2D(fontTextureArr[9], v_uv).rgb;
434
- } else if(fontIndex >= 10.0 && fontIndex < 11.0){
435
- msdf = texture2D(fontTextureArr[10], v_uv).rgb;
436
- }
437
- return median(msdf.r, msdf.g, msdf.b);
438
- }
439
-
440
- void main () {
441
-
442
- fontIndex = v_fontIndex + 0.1;
443
-
444
- vec2 dxdy = fwidth(v_uv) * sdfParams.xy;
445
- float dist = getDistance() + min(v_weight, 0.5 - 1.0 / sdfParams.w) - 0.5;
446
- float opacity = clamp(dist * sdfParams.w / length(dxdy) + 0.5, 0.0, 1.0);
447
-
448
- vec4 color = v_rgba;
449
- color.a *= opacity;
450
- if (color.a < 0.01) {
451
- discard;
452
- }
453
-
454
- gl_FragColor = vec4(v_rgba.rgb, opacity * v_rgba.a);
455
- }`
456
- });
1
+ /**
2
+ * @module og/shaders/label
3
+ */
4
+
5
+ 'use strict';
6
+
7
+ import { Program } from '../webgl/Program.js';
8
+
9
+ const PROJECT = `vec2 project(vec4 p) {
10
+ return (0.5 * p.xyz / p.w + 0.5).xy * viewport;
11
+ }`;
12
+
13
+ const ROTATE2D =
14
+ `mat2 rotate2d(float angle) {
15
+ return mat2(cos(angle), -sin(angle),
16
+ sin(angle), cos(angle));
17
+ }`;
18
+
19
+ export function label_webgl2() {
20
+ return new Program("label", {
21
+ uniforms: {
22
+ viewport: "vec2",
23
+ fontTextureArr: "sampler2darray",
24
+ sdfParamsArr: "vec4",
25
+ projectionMatrix: "mat4",
26
+ viewMatrix: "mat4",
27
+ eyePositionHigh: "vec3",
28
+ eyePositionLow: "vec3",
29
+ planetRadius: "float",
30
+ scaleByDistance: "vec3",
31
+ opacity: "float",
32
+ isOutlinePass: "int",
33
+ depthOffset: "float"
34
+ },
35
+ attributes: {
36
+ a_outline: "float",
37
+ a_gliphParam: "vec4",
38
+ a_vertices: "vec2",
39
+ a_texCoord: "vec4",
40
+ a_positionsHigh: "vec3",
41
+ a_positionsLow: "vec3",
42
+ a_size: "float",
43
+ a_rotation: "float",
44
+ a_rgba: "vec4",
45
+ a_offset: "vec3",
46
+ a_fontIndex: "float"
47
+ },
48
+ vertexShader:
49
+ `#version 300 es
50
+
51
+ in float a_outline;
52
+ in vec4 a_gliphParam;
53
+ in vec2 a_vertices;
54
+ in vec4 a_texCoord;
55
+ in vec3 a_positionsHigh;
56
+ in vec3 a_positionsLow;
57
+ in vec3 a_offset;
58
+ in float a_size;
59
+ in float a_rotation;
60
+ in vec4 a_rgba;
61
+ in float a_fontIndex;
62
+
63
+ out vec2 v_uv;
64
+ out vec4 v_rgba;
65
+ flat out int v_fontIndex;
66
+ out vec4 v_outlineColor;
67
+ flat out float v_outline;
68
+ flat out int v_isOutlinePass;
69
+
70
+ uniform vec2 viewport;
71
+ uniform mat4 viewMatrix;
72
+ uniform mat4 projectionMatrix;
73
+ uniform vec3 eyePositionHigh;
74
+ uniform vec3 eyePositionLow;
75
+ uniform float planetRadius;
76
+ uniform vec3 scaleByDistance;
77
+ uniform float opacity;
78
+ uniform int isOutlinePass;
79
+ uniform float depthOffset;
80
+
81
+ const vec3 ZERO3 = vec3(0.0);
82
+
83
+ ${PROJECT}
84
+
85
+ ${ROTATE2D}
86
+
87
+ void main() {
88
+
89
+ if(a_texCoord.z == -1.0) {
90
+ gl_Position = vec4(0.0);
91
+ return;
92
+ }
93
+
94
+ vec3 a_positions = a_positionsHigh + a_positionsLow;
95
+ vec3 cameraPos = eyePositionHigh + eyePositionLow;
96
+
97
+ v_outline = a_outline;
98
+ v_isOutlinePass = isOutlinePass;
99
+
100
+ v_fontIndex = int(a_fontIndex);
101
+ v_uv = vec2(a_texCoord.xy);
102
+ vec3 look = a_positions - cameraPos;
103
+ float lookDist = length(look);
104
+ v_rgba = a_rgba;
105
+
106
+ if(opacity * step(lookDist, sqrt(dot(cameraPos,cameraPos) - planetRadius) + sqrt(dot(a_positions,a_positions) - planetRadius)) == 0.0){
107
+ return;
108
+ }
109
+
110
+ float scd = (1.0 - smoothstep(scaleByDistance[0], scaleByDistance[1], lookDist)) * (1.0 - step(scaleByDistance[2], lookDist));
111
+
112
+ v_rgba.a *= opacity;
113
+
114
+ mat4 viewMatrixRTE = viewMatrix;
115
+ viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
116
+
117
+ vec3 highDiff = a_positionsHigh - eyePositionHigh;
118
+ vec3 lowDiff = a_positionsLow - eyePositionLow;
119
+ vec4 posRTE = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
120
+ vec4 projPos = projectionMatrix * posRTE;
121
+
122
+ float camSlope = dot(vec3(viewMatrix[0][2], viewMatrix[1][2], viewMatrix[2][2]), normalize(cameraPos));
123
+ if(camSlope > 0.5) {
124
+ float dist = dot(look, normalize(cameraPos));
125
+ projPos.z += dist * 0.02;
126
+ }else{
127
+ projPos.z += -(abs(projPos.z)) * 0.002;
128
+ }
129
+
130
+ projPos.z += depthOffset + a_offset.z;
131
+
132
+ vec2 screenPos = project(projPos);
133
+
134
+ vec2 v = screenPos + rotate2d(a_rotation) * ((a_vertices * a_gliphParam.xy + a_gliphParam.zw + vec2(a_texCoord.z, 0.0) + vec2(a_texCoord.w, 0.0)) * a_size * scd + a_offset.xy);
135
+
136
+ gl_Position = vec4((2.0 * v / viewport - 1.0) * projPos.w, projPos.z, projPos.w);
137
+ }`,
138
+ fragmentShader:
139
+ `#version 300 es
140
+
141
+ precision highp float;
142
+ precision highp int;
143
+
144
+ const int MAX_SIZE = 11;
145
+
146
+ // x - ATLAS_WIDTH = 512.0;
147
+ // y - ATLAS_HEIGHT = 512.0;
148
+ // z - ATLAS_GLYPH_SIZE = 32.0;
149
+ // w - ATLAS_FIELD_RANGE = 8.0;
150
+
151
+ uniform sampler2D fontTextureArr[MAX_SIZE];
152
+ uniform vec4 sdfParamsArr[MAX_SIZE];
153
+ flat in int v_isOutlinePass;
154
+
155
+ flat in int v_fontIndex;
156
+ in vec2 v_uv;
157
+ in vec4 v_rgba;
158
+
159
+ flat in float v_outline;
160
+
161
+ in vec3 v_pickingColor;
162
+
163
+ layout(location = 0) out vec4 outScreen;
164
+
165
+ float median(float r, float g, float b) {
166
+ return max(min(r, g), min(max(r, g), b));
167
+ }
168
+
169
+ float getDistance() {
170
+ vec3 msdf;
171
+ if(v_fontIndex == 0) {
172
+ msdf = texture(fontTextureArr[0], v_uv).rgb;
173
+ } else if(v_fontIndex == 1){
174
+ msdf = texture(fontTextureArr[1], v_uv).rgb;
175
+ } else if(v_fontIndex == 2){
176
+ msdf = texture(fontTextureArr[2], v_uv).rgb;
177
+ } else if(v_fontIndex == 3){
178
+ msdf = texture(fontTextureArr[3], v_uv).rgb;
179
+ } else if(v_fontIndex == 4){
180
+ msdf = texture(fontTextureArr[4], v_uv).rgb;
181
+ } else if(v_fontIndex == 5){
182
+ msdf = texture(fontTextureArr[5], v_uv).rgb;
183
+ } else if(v_fontIndex == 6){
184
+ msdf = texture(fontTextureArr[6], v_uv).rgb;
185
+ } else if(v_fontIndex == 7){
186
+ msdf = texture(fontTextureArr[7], v_uv).rgb;
187
+ } else if(v_fontIndex == 8){
188
+ msdf = texture(fontTextureArr[8], v_uv).rgb;
189
+ } else if(v_fontIndex == 9){
190
+ msdf = texture(fontTextureArr[9], v_uv).rgb;
191
+ } else if(v_fontIndex == 10){
192
+ msdf = texture(fontTextureArr[10], v_uv).rgb;
193
+ }
194
+ return median(msdf.r, msdf.g, msdf.b);
195
+ }
196
+
197
+ vec4 getSDFParams() {
198
+ if(v_fontIndex == 0) {
199
+ return sdfParamsArr[0];
200
+ } else if(v_fontIndex == 1){
201
+ return sdfParamsArr[1];
202
+ } else if(v_fontIndex == 2){
203
+ return sdfParamsArr[2];
204
+ } else if(v_fontIndex == 3){
205
+ return sdfParamsArr[3];
206
+ } else if(v_fontIndex == 4){
207
+ return sdfParamsArr[4];
208
+ } else if(v_fontIndex == 5){
209
+ return sdfParamsArr[5];
210
+ } else if(v_fontIndex == 6){
211
+ return sdfParamsArr[6];
212
+ } else if(v_fontIndex == 7){
213
+ return sdfParamsArr[7];
214
+ } else if(v_fontIndex == 8){
215
+ return sdfParamsArr[8];
216
+ } else if(v_fontIndex == 9){
217
+ return sdfParamsArr[9];
218
+ } else if(v_fontIndex == 10){
219
+ return sdfParamsArr[10];
220
+ }
221
+ }
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
+
243
+ void main () {
244
+
245
+ vec4 sdfParams = getSDFParams();
246
+
247
+ vec2 dxdy = fwidth(v_uv) * sdfParams.xy;
248
+ float dist = getDistance() + min(v_isOutlinePass == 0 ? 0.001 : v_outline, 0.5 - 1.0 / sdfParams.w) - 0.5;
249
+ float opacity = clamp(dist * sdfParams.w / length(dxdy) + 0.5, 0.0, 1.0);
250
+
251
+ vec4 color = v_rgba;
252
+ color.a *= opacity;
253
+ if (color.a < 0.01) {
254
+ discard;
255
+ }
256
+
257
+ outScreen = vec4(v_rgba.rgb, opacity * v_rgba.a);
258
+ }`
259
+ });
260
+ }
261
+
262
+ export function label_screen() {
263
+ return new Program("label", {
264
+ uniforms: {
265
+ viewport: "vec2",
266
+ fontTextureArr: "sampler2darray",
267
+ sdfParamsArr: "vec4",
268
+ projectionMatrix: "mat4",
269
+ viewMatrix: "mat4",
270
+ eyePositionHigh: "vec3",
271
+ eyePositionLow: "vec3",
272
+ planetRadius: "float",
273
+ scaleByDistance: "vec3",
274
+ opacity: "float",
275
+ isOutlinePass: "int",
276
+ depthOffset: "float"
277
+ },
278
+ attributes: {
279
+ a_outline: "float",
280
+ a_gliphParam: "vec4",
281
+ a_vertices: "vec2",
282
+ a_texCoord: "vec4",
283
+ a_positionsHigh: "vec3",
284
+ a_positionsLow: "vec3",
285
+ a_size: "float",
286
+ a_rotation: "float",
287
+ a_rgba: "vec4",
288
+ a_offset: "vec3",
289
+ a_fontIndex: "float"
290
+ },
291
+ vertexShader:
292
+ `
293
+ attribute float a_outline;
294
+ attribute vec4 a_gliphParam;
295
+ attribute vec2 a_vertices;
296
+ attribute vec4 a_texCoord;
297
+ attribute vec3 a_positionsHigh;
298
+ attribute vec3 a_positionsLow;
299
+ attribute vec3 a_offset;
300
+ attribute float a_size;
301
+ attribute float a_rotation;
302
+ attribute vec4 a_rgba;
303
+ attribute float a_fontIndex;
304
+
305
+ varying float v_outline;
306
+ varying float v_isOutlinePass;
307
+ varying vec2 v_uv;
308
+ varying vec4 v_rgba;
309
+ varying float v_fontIndex;
310
+
311
+ uniform vec2 viewport;
312
+ uniform mat4 viewMatrix;
313
+ uniform mat4 projectionMatrix;
314
+ uniform vec3 eyePositionHigh;
315
+ uniform vec3 eyePositionLow;
316
+ uniform float planetRadius;
317
+ uniform vec3 scaleByDistance;
318
+ uniform float opacity;
319
+ uniform int isOutlinePass;
320
+ uniform float depthOffset;
321
+
322
+ const vec3 ZERO3 = vec3(0.0);
323
+
324
+ ${PROJECT}
325
+
326
+ ${ROTATE2D}
327
+
328
+ void main() {
329
+
330
+ if(a_texCoord.z == -1.0) {
331
+ gl_Position = vec4(0.0);
332
+ return;
333
+ }
334
+
335
+ vec3 a_positions = a_positionsHigh + a_positionsLow;
336
+ vec3 cameraPos = eyePositionHigh + eyePositionLow;
337
+
338
+ v_outline = a_outline;
339
+ v_isOutlinePass = float(isOutlinePass);
340
+ v_uv = vec2(a_texCoord.xy);
341
+ v_rgba = a_rgba;
342
+ v_fontIndex = a_fontIndex;
343
+
344
+ vec3 look = a_positions - cameraPos;
345
+ float lookDist = length(look);
346
+
347
+ if(opacity * step(lookDist, sqrt(dot(cameraPos,cameraPos) - planetRadius) + sqrt(dot(a_positions,a_positions) - planetRadius)) == 0.0){
348
+ return;
349
+ }
350
+
351
+ float scd = (1.0 - smoothstep(scaleByDistance[0], scaleByDistance[1], lookDist)) * (1.0 - step(scaleByDistance[2], lookDist));
352
+
353
+ v_rgba.a *= opacity;
354
+
355
+ mat4 viewMatrixRTE = viewMatrix;
356
+ viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
357
+
358
+ vec3 highDiff = a_positionsHigh - eyePositionHigh;
359
+ vec3 lowDiff = a_positionsLow - eyePositionLow;
360
+ vec4 posRTE = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
361
+ vec4 projPos = projectionMatrix * posRTE;
362
+
363
+ float camSlope = dot(vec3(viewMatrix[0][2], viewMatrix[1][2], viewMatrix[2][2]), normalize(cameraPos));
364
+ if(camSlope > 0.5) {
365
+ float dist = dot(look, normalize(cameraPos));
366
+ projPos.z += dist * 0.02;
367
+ }else{
368
+ projPos.z += -(abs(projPos.z)) * 0.002;
369
+ }
370
+
371
+ projPos.z += depthOffset + a_offset.z;
372
+
373
+ vec2 screenPos = project(projPos);
374
+
375
+ vec2 v = screenPos + rotate2d(a_rotation) * ((a_vertices * a_gliphParam.xy + a_gliphParam.zw + vec2(a_texCoord.z, 0.0) + vec2(a_texCoord.w, 0.0)) * a_size * scd + a_offset.xy);
376
+
377
+ gl_Position = vec4((2.0 * v / viewport - 1.0) * projPos.w, projPos.z, projPos.w);
378
+ }`,
379
+ fragmentShader:
380
+ `#extension GL_OES_standard_derivatives : enable
381
+
382
+ precision highp float;
383
+ precision highp int;
384
+
385
+ const int MAX_SIZE = 11;
386
+
387
+ // x - ATLAS_WIDTH = 512.0;
388
+ // y - ATLAS_HEIGHT = 512.0;
389
+ // z - ATLAS_GLYPH_SIZE = 32.0;
390
+ // w - ATLAS_FIELD_RANGE = 8.0;
391
+
392
+ uniform sampler2D fontTextureArr[MAX_SIZE];
393
+ uniform vec4 sdfParamsArr[MAX_SIZE];
394
+
395
+ varying float v_outline;
396
+ varying float v_isOutlinePass;
397
+ varying vec2 v_uv;
398
+ varying vec4 v_rgba;
399
+ varying float v_fontIndex;
400
+
401
+ float fontIndex;
402
+
403
+ float median(float r, float g, float b) {
404
+ return max(min(r, g), min(max(r, g), b));
405
+ }
406
+
407
+ float getDistance() {
408
+ vec3 msdf;
409
+ if(fontIndex >= 0.0 && fontIndex < 1.0) {
410
+ msdf = texture2D(fontTextureArr[0], v_uv).rgb;
411
+ } else if(fontIndex >= 1.0 && fontIndex < 2.0){
412
+ msdf = texture2D(fontTextureArr[1], v_uv).rgb;
413
+ } else if(fontIndex >= 2.0 && fontIndex < 3.0){
414
+ msdf = texture2D(fontTextureArr[2], v_uv).rgb;
415
+ } else if(fontIndex >= 3.0 && fontIndex < 4.0){
416
+ msdf = texture2D(fontTextureArr[3], v_uv).rgb;
417
+ } else if(fontIndex >= 4.0 && fontIndex < 5.0){
418
+ msdf = texture2D(fontTextureArr[4], v_uv).rgb;
419
+ } else if(fontIndex >= 5.0 && fontIndex < 6.0){
420
+ msdf = texture2D(fontTextureArr[5], v_uv).rgb;
421
+ } else if(fontIndex >= 6.0 && fontIndex < 7.0){
422
+ msdf = texture2D(fontTextureArr[6], v_uv).rgb;
423
+ } else if(fontIndex >= 7.0 && fontIndex < 8.0){
424
+ msdf = texture2D(fontTextureArr[7], v_uv).rgb;
425
+ } else if(fontIndex >= 8.0 && fontIndex < 9.0){
426
+ msdf = texture2D(fontTextureArr[8], v_uv).rgb;
427
+ } else if(fontIndex >= 9.0 && fontIndex < 10.0){
428
+ msdf = texture2D(fontTextureArr[9], v_uv).rgb;
429
+ } else if(fontIndex >= 10.0 && fontIndex < 11.0){
430
+ msdf = texture2D(fontTextureArr[10], v_uv).rgb;
431
+ }
432
+ return median(msdf.r, msdf.g, msdf.b);
433
+ }
434
+
435
+
436
+ vec4 getSDFParams() {
437
+ if(fontIndex >= 0.0 && fontIndex < 1.0) {
438
+ return sdfParamsArr[0];
439
+ } else if(fontIndex >= 1.0 && fontIndex < 2.0){
440
+ return sdfParamsArr[1];
441
+ } else if(fontIndex >= 2.0 && fontIndex < 3.0){
442
+ return sdfParamsArr[2];
443
+ } else if(fontIndex >= 3.0 && fontIndex < 4.0){
444
+ return sdfParamsArr[3];
445
+ } else if(fontIndex >= 4.0 && fontIndex < 5.0){
446
+ return sdfParamsArr[4];
447
+ } else if(fontIndex >= 5.0 && fontIndex < 6.0){
448
+ return sdfParamsArr[5];
449
+ } else if(fontIndex >= 6.0 && fontIndex < 7.0){
450
+ return sdfParamsArr[6];
451
+ } else if(fontIndex >= 7.0 && fontIndex < 8.0){
452
+ return sdfParamsArr[7];
453
+ } else if(fontIndex >= 8.0 && fontIndex < 9.0){
454
+ return sdfParamsArr[8];
455
+ } else if(fontIndex >= 9.0 && fontIndex < 10.0){
456
+ return sdfParamsArr[9];
457
+ } else if(fontIndex >= 10.0 && fontIndex < 11.0){
458
+ return sdfParamsArr[10];
459
+ }
460
+ }
461
+
462
+ void main () {
463
+
464
+ fontIndex = v_fontIndex + 0.1;
465
+
466
+ vec4 sdfParams = getSDFParams();
467
+
468
+ vec2 dxdy = fwidth(v_uv) * sdfParams.xy;
469
+ float dist = getDistance() + min(v_isOutlinePass == 0.0 ? 0.001 : v_outline, 0.5 - 1.0 / sdfParams.w) - 0.5;
470
+ float opacity = clamp(dist * sdfParams.w / length(dxdy) + 0.5, 0.0, 1.0);
471
+
472
+ vec4 color = v_rgba;
473
+ color.a *= opacity;
474
+ if (color.a < 0.01) {
475
+ discard;
476
+ }
477
+
478
+ gl_FragColor = vec4(v_rgba.rgb, opacity * v_rgba.a);
479
+ }`
480
+ });
481
+ }
482
+
483
+ export function labelPicking() {
484
+ return new Program("labelPicking", {
485
+ uniforms: {
486
+ viewport: "vec2",
487
+ projectionMatrix: "mat4",
488
+ viewMatrix: "mat4",
489
+ eyePositionHigh: "vec3",
490
+ eyePositionLow: "vec3",
491
+ planetRadius: "float",
492
+ scaleByDistance: "vec3",
493
+ opacity: "float",
494
+ depthOffset: "float"
495
+ },
496
+ attributes: {
497
+ a_gliphParam: "vec4",
498
+ a_vertices: "vec2",
499
+ a_texCoord: "vec4",
500
+ a_positionsHigh: "vec3",
501
+ a_positionsLow: "vec3",
502
+ a_offset: "vec3",
503
+ a_size: "float",
504
+ a_rotation: "float",
505
+ a_rgba: "vec4"
506
+ },
507
+ vertexShader:
508
+ `
509
+ attribute vec4 a_gliphParam;
510
+ attribute vec2 a_vertices;
511
+ attribute vec4 a_texCoord;
512
+ attribute vec3 a_positionsHigh;
513
+ attribute vec3 a_positionsLow;
514
+ attribute vec3 a_offset;
515
+ attribute float a_size;
516
+ attribute float a_rotation;
517
+ attribute vec4 a_rgba;
518
+
519
+ varying vec4 v_rgba;
520
+
521
+ uniform vec2 viewport;
522
+ uniform mat4 viewMatrix;
523
+ uniform mat4 projectionMatrix;
524
+ uniform vec3 eyePositionHigh;
525
+ uniform vec3 eyePositionLow;
526
+ uniform float planetRadius;
527
+ uniform vec3 scaleByDistance;
528
+ uniform float opacity;
529
+ uniform float depthOffset;
530
+
531
+ const vec3 ZERO3 = vec3(0.0);
532
+
533
+ ${PROJECT}
534
+
535
+ ${ROTATE2D}
536
+
537
+ void main() {
538
+ vec3 a_positions = a_positionsHigh + a_positionsLow;
539
+ vec3 cameraPos = eyePositionHigh + eyePositionLow;
540
+
541
+ if(a_texCoord.z == -1.0){
542
+ gl_Position = vec4(0.0);
543
+ return;
544
+ }
545
+
546
+ vec3 look = a_positions - cameraPos;
547
+ float lookDist = length(look);
548
+ v_rgba = a_rgba;
549
+ if(opacity * step(lookDist, sqrt(dot(cameraPos,cameraPos) - planetRadius) + sqrt(dot(a_positions,a_positions) - planetRadius)) == 0.0){
550
+ return;
551
+ }
552
+
553
+ float scd = (1.0 - smoothstep(scaleByDistance[0], scaleByDistance[1], lookDist)) * (1.0 - step(scaleByDistance[2], lookDist));
554
+
555
+ v_rgba.a *= opacity;
556
+
557
+ mat4 viewMatrixRTE = viewMatrix;
558
+ viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
559
+
560
+ vec3 highDiff = a_positionsHigh - eyePositionHigh;
561
+ vec3 lowDiff = a_positionsLow - eyePositionLow;
562
+ vec4 posRTE = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
563
+ vec4 projPos = projectionMatrix * posRTE;
564
+
565
+ float camSlope = dot(vec3(viewMatrix[0][2], viewMatrix[1][2], viewMatrix[2][2]), normalize(cameraPos));
566
+ if(camSlope > 0.5) {
567
+ float dist = dot(look, normalize(cameraPos));
568
+ projPos.z += dist * 0.02;
569
+ }else{
570
+ projPos.z += -(abs(projPos.z)) * 0.002;
571
+ }
572
+
573
+ projPos.z += depthOffset + a_offset.z;
574
+
575
+ vec2 screenPos = project(projPos);
576
+ vec2 v = screenPos + rotate2d(a_rotation) * ((a_vertices * a_gliphParam.xy + a_gliphParam.zw + vec2(a_texCoord.z, 0.0) + vec2(a_texCoord.w, 0.0)) * a_size * scd + a_offset.xy);
577
+ gl_Position = vec4((2.0 * v / viewport - 1.0) * projPos.w, projPos.z, projPos.w);
578
+ }`,
579
+ fragmentShader:
580
+ `precision highp float;
581
+
582
+ varying vec4 v_rgba;
583
+
584
+ varying vec3 v_pickingColor;
585
+
586
+ void main () {
587
+
588
+ vec4 color = v_rgba;
589
+ if (color.a < 0.05) {
590
+ discard;
591
+ }
592
+
593
+ gl_FragColor = vec4(v_rgba.rgb, v_rgba.a);
594
+ }`
595
+ });
457
596
  }