@openglobus/og 0.12.4 → 0.13.0

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 +800 -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 +596 -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 +4 -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
@@ -259,7 +259,7 @@ class Segment {
259
259
  }
260
260
 
261
261
  isEntityInside(e) {
262
- return this._extent.isInside(e._lonlatMerc);
262
+ return this._extentLonLat.isInside(e._lonlat);
263
263
  }
264
264
 
265
265
  /**
@@ -1479,7 +1479,9 @@ class Segment {
1479
1479
  (li.minZoom <= p.maxCurrZoom || li.maxZoom <= p.maxCurrZoom)))
1480
1480
  ) {
1481
1481
  notEmpty = true;
1482
+
1482
1483
  var m = pm[li._id];
1484
+
1483
1485
  if (!m) {
1484
1486
  m = pm[li._id] = li.createMaterial(this);
1485
1487
  }
@@ -40,6 +40,7 @@ class SegmentLonLat extends Segment {
40
40
  // this._isNorth = false;
41
41
 
42
42
  this._projection = EPSG4326;
43
+
43
44
  this._extentMerc = new Extent(
44
45
  extent.southWest.forwardMercatorEPS01(),
45
46
  extent.northEast.forwardMercatorEPS01()
@@ -249,10 +250,6 @@ class SegmentLonLat extends Segment {
249
250
  }
250
251
  }
251
252
 
252
- isEntityInside(e) {
253
- return this._extent.isInside(e._lonlat);
254
- }
255
-
256
253
  _getLayerExtentOffset(layer) {
257
254
  var v0s = layer._extent;
258
255
  var v0t = this._extent;
@@ -1,205 +1,221 @@
1
- /**
2
- * @module og/shaders/billboard
3
- */
4
-
5
- 'use strict';
6
-
7
- import { Program } from '../webgl/Program.js';
8
-
9
- export function billboardPicking() {
10
- return new Program("billboardPicking", {
11
- uniforms: {
12
- projectionMatrix: "mat4",
13
- viewMatrix: "mat4",
14
- //uCamPos: "vec3",
15
- eyePositionHigh: "vec3",
16
- eyePositionLow: "vec3",
17
- uFloatParams: "vec2",
18
- uScaleByDistance: "vec3",
19
- uOpacity: "float",
20
- pickingScale: "float"
21
- },
22
- attributes: {
23
- a_vertices: "vec2",
24
- a_positionsHigh: "vec3",
25
- a_positionsLow: "vec3",
26
- a_size: "vec2",
27
- a_offset: "vec3",
28
- a_pickingColor: "vec3",
29
- a_rotation: "float",
30
- a_alignedAxis: "vec3"
31
- },
32
- vertexShader:
33
- `precision highp float;
34
- attribute vec2 a_vertices;
35
- attribute vec2 a_texCoord;
36
- attribute vec3 a_positionsHigh;
37
- attribute vec3 a_positionsLow;
38
- attribute vec3 a_offset;
39
- attribute vec2 a_size;
40
- attribute float a_rotation;
41
- attribute vec3 a_alignedAxis;
42
- attribute vec3 a_pickingColor;
43
-
44
- uniform mat4 viewMatrix;
45
- uniform mat4 projectionMatrix;
46
- uniform vec3 eyePositionHigh;
47
- uniform vec3 eyePositionLow;
48
- uniform vec2 uFloatParams;
49
- uniform vec3 uScaleByDistance;
50
- uniform float uOpacity;
51
- uniform float pickingScale;
52
-
53
- varying vec4 v_color;
54
-
55
- const vec3 ZERO3 = vec3(0.0);
56
-
57
- void main() {
58
-
59
- v_color = vec4(a_pickingColor, 1.0);
60
-
61
- vec3 a_positions = a_positionsHigh + a_positionsLow;
62
- vec3 uCamPos = eyePositionHigh + eyePositionLow;
63
-
64
- vec3 look = a_positions - uCamPos;
65
- float lookLength = length(look);
66
- if(uOpacity * step(lookLength, sqrt(dot(uCamPos,uCamPos) - uFloatParams[0]) + sqrt(dot(a_positions,a_positions) - uFloatParams[0])) == 0.0){
67
- return;
68
- }
69
- vec3 right, up;
70
- if(a_alignedAxis == ZERO3){
71
- up = vec3( viewMatrix[0][1], viewMatrix[1][1], viewMatrix[2][1] );
72
- right = vec3( viewMatrix[0][0], viewMatrix[1][0], viewMatrix[2][0] );
73
- }else{
74
- up = normalize(a_alignedAxis);
75
- right = normalize(cross(look,up));
76
- look = cross(up,right);
77
- }
78
- float dist = dot(uCamPos - a_positions, vec3(viewMatrix[0][2], viewMatrix[1][2], viewMatrix[2][2]));
79
- float focalSize = 2.0 * dist * uFloatParams[1];
80
- vec2 offset = a_offset.xy * focalSize;
81
- float scd = (1.0 - smoothstep(uScaleByDistance[0], uScaleByDistance[1], lookLength)) * (1.0 - step(uScaleByDistance[2], lookLength));
82
- vec2 scale = a_size * focalSize * scd * pickingScale;
83
- float cosRot = cos(a_rotation);
84
- float sinRot = sin(a_rotation);
85
- vec3 rr = (right * cosRot - up * sinRot) * (scale.x * a_vertices.x + scd * offset.x) + (right * sinRot + up * cosRot) * (scale.y * a_vertices.y + scd * offset.y);
86
-
87
- vec3 highDiff = a_positionsHigh - eyePositionHigh;
88
- vec3 lowDiff = a_positionsLow + rr - eyePositionLow;
89
-
90
- mat4 viewMatrixRTE = viewMatrix;
91
- viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
92
-
93
- gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
94
- gl_Position.z += a_offset.z;
95
- }`,
96
- fragmentShader:
97
- `precision highp float;
98
- varying vec4 v_color;
99
- void main () {
100
- gl_FragColor = v_color;
101
- }`
102
- });
103
- }
104
-
105
- export function billboard_screen() {
106
- return new Program("billboard", {
107
- uniforms: {
108
- u_texture: "sampler2d",
109
- projectionMatrix: "mat4",
110
- viewMatrix: "mat4",
111
- eyePositionHigh: "vec3",
112
- eyePositionLow: "vec3",
113
- uFloatParams: "vec2",
114
- uScaleByDistance: "vec3",
115
- uOpacity: "float"
116
- },
117
- attributes: {
118
- a_vertices: "vec2",
119
- a_texCoord: "vec2",
120
- a_positionsHigh: "vec3",
121
- a_positionsLow: "vec3",
122
- a_offset: "vec3",
123
- a_size: "vec2",
124
- a_rotation: "float",
125
- a_rgba: "vec4",
126
- a_alignedAxis: "vec3"
127
- },
128
- vertexShader:
129
- `precision highp float;
130
- attribute vec2 a_vertices;
131
- attribute vec2 a_texCoord;
132
- attribute vec3 a_positionsHigh;
133
- attribute vec3 a_positionsLow;
134
- attribute vec3 a_offset;
135
- attribute vec2 a_size;
136
- attribute float a_rotation;
137
- attribute vec4 a_rgba;
138
- attribute vec3 a_alignedAxis;
139
-
140
- varying vec2 v_texCoords;
141
- varying vec4 v_rgba;
142
-
143
- uniform mat4 viewMatrix;
144
- uniform mat4 projectionMatrix;
145
- uniform vec3 eyePositionHigh;
146
- uniform vec3 eyePositionLow;
147
- uniform vec2 uFloatParams;
148
- uniform vec3 uScaleByDistance;
149
- uniform float uOpacity;
150
-
151
- const vec3 ZERO3 = vec3(0.0);
152
-
153
- void main() {
154
-
155
- vec3 a_positions = a_positionsHigh + a_positionsLow;
156
- vec3 uCamPos = eyePositionHigh + eyePositionLow;
157
-
158
- v_texCoords = a_texCoord;
159
- vec3 look = a_positions - uCamPos;
160
- float lookLength = length(look);
161
- v_rgba = a_rgba;
162
- /*v_rgba.a *= uOpacity * step(lookLength, sqrt(dot(uCamPos,uCamPos) - uFloatParams[0]) + sqrt(dot(a_positions,a_positions) - uFloatParams[0]));*/
163
- if(uOpacity * step(lookLength, sqrt(dot(uCamPos,uCamPos) - uFloatParams[0]) + sqrt(dot(a_positions,a_positions) - uFloatParams[0])) == 0.0){
164
- return;
165
- }
166
- vec3 right, up;
167
- if(a_alignedAxis == ZERO3){
168
- up = vec3( viewMatrix[0][1], viewMatrix[1][1], viewMatrix[2][1] );
169
- right = vec3( viewMatrix[0][0], viewMatrix[1][0], viewMatrix[2][0] );
170
- }else{
171
- up = normalize(a_alignedAxis);
172
- right = normalize(cross(look,up));
173
- look = cross(up,right);
174
- }
175
- float dist = dot(uCamPos - a_positions, vec3(viewMatrix[0][2], viewMatrix[1][2], viewMatrix[2][2]));
176
- float focalSize = 2.0 * dist * uFloatParams[1];
177
- vec2 offset = a_offset.xy * focalSize;
178
- float scd = (1.0 - smoothstep(uScaleByDistance[0], uScaleByDistance[1], lookLength)) * (1.0 - step(uScaleByDistance[2], lookLength));
179
- vec2 scale = a_size * focalSize * scd;
180
- float cosRot = cos(a_rotation);
181
- float sinRot = sin(a_rotation);
182
- vec3 rr = (right * cosRot - up * sinRot) * (scale.x * a_vertices.x + scd * offset.x) + (right * sinRot + up * cosRot) * (scale.y * a_vertices.y + scd * offset.y);
183
-
184
- vec3 highDiff = a_positionsHigh - eyePositionHigh;
185
- vec3 lowDiff = a_positionsLow + rr - eyePositionLow;
186
-
187
- mat4 viewMatrixRTE = viewMatrix;
188
- viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
189
-
190
- gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
191
- gl_Position.z += a_offset.z;
192
- }`,
193
- fragmentShader:
194
- `precision highp float;
195
- uniform sampler2D u_texture;
196
- varying vec2 v_texCoords;
197
- varying vec4 v_rgba;
198
- void main () {
199
- vec4 color = texture2D(u_texture, v_texCoords);
200
- if(color.a < 0.1)
201
- discard;
202
- gl_FragColor = color * v_rgba;
203
- }`
204
- });
1
+ /**
2
+ * @module og/shaders/billboard
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 billboardPicking() {
20
+ return new Program("billboardPicking", {
21
+ uniforms: {
22
+ viewport: "vec2",
23
+ projectionMatrix: "mat4",
24
+ viewMatrix: "mat4",
25
+ eyePositionHigh: "vec3",
26
+ eyePositionLow: "vec3",
27
+ planetRadius: "float",
28
+ uScaleByDistance: "vec3",
29
+ opacity: "float",
30
+ depthOffset: "float"
31
+ },
32
+ attributes: {
33
+ a_vertices: "vec2",
34
+ a_positionsHigh: "vec3",
35
+ a_positionsLow: "vec3",
36
+ a_offset: "vec3",
37
+ a_size: "vec2",
38
+ a_rotation: "float",
39
+ a_rgba: "vec4"
40
+ },
41
+ vertexShader:
42
+ `precision highp float;
43
+ attribute vec2 a_vertices;
44
+ attribute vec3 a_positionsHigh;
45
+ attribute vec3 a_positionsLow;
46
+ attribute vec3 a_offset;
47
+ attribute vec2 a_size;
48
+ attribute float a_rotation;
49
+ attribute vec4 a_rgba;
50
+
51
+ varying vec3 v_rgb;
52
+
53
+ uniform mat4 viewMatrix;
54
+ uniform mat4 projectionMatrix;
55
+ uniform vec3 eyePositionHigh;
56
+ uniform vec3 eyePositionLow;
57
+ uniform vec3 uScaleByDistance;
58
+ uniform float opacity;
59
+ uniform float planetRadius;
60
+ uniform vec2 viewport;
61
+ uniform float depthOffset;
62
+
63
+ const vec3 ZERO3 = vec3(0.0);
64
+
65
+ ${PROJECT}
66
+
67
+ ${ROTATE2D}
68
+
69
+ void main() {
70
+
71
+ vec3 a_positions = a_positionsHigh + a_positionsLow;
72
+ vec3 cameraPos = eyePositionHigh + eyePositionLow;
73
+
74
+ vec3 look = a_positions - cameraPos;
75
+ float lookDist = length(look);
76
+ v_rgb = a_rgba.rgb;
77
+
78
+ if(opacity * step(lookDist, sqrt(dot(cameraPos,cameraPos) - planetRadius) + sqrt(dot(a_positions,a_positions) - planetRadius)) == 0.0){
79
+ return;
80
+ }
81
+
82
+ vec3 up = vec3( viewMatrix[0][1], viewMatrix[1][1], viewMatrix[2][1] );
83
+ vec3 right = vec3( viewMatrix[0][0], viewMatrix[1][0], viewMatrix[2][0] );
84
+
85
+ float scd = (1.0 - smoothstep(uScaleByDistance[0], uScaleByDistance[1], lookDist)) * (1.0 - step(uScaleByDistance[2], lookDist));
86
+
87
+ mat4 viewMatrixRTE = viewMatrix;
88
+ viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
89
+
90
+ vec3 highDiff = a_positionsHigh - eyePositionHigh;
91
+ vec3 lowDiff = a_positionsLow - eyePositionLow;
92
+ vec4 posRTE = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
93
+ vec4 projPos = projectionMatrix * posRTE;
94
+
95
+ projPos.z += depthOffset + a_offset.z;
96
+
97
+ vec2 screenPos = project(projPos);
98
+
99
+ vec2 v = screenPos + rotate2d(a_rotation) * (a_vertices * a_size * scd + a_offset.xy);
100
+
101
+ gl_Position = vec4((2.0 * v / viewport - 1.0) * projPos.w, projPos.z, projPos.w);
102
+ }`,
103
+ fragmentShader:
104
+ `precision highp float;
105
+ varying vec3 v_rgb;
106
+ void main () {
107
+ gl_FragColor = vec4(v_rgb, 1.0);
108
+ }`
109
+ });
110
+ }
111
+
112
+ export function billboard_screen() {
113
+ return new Program("billboard", {
114
+ uniforms: {
115
+ viewport: "vec2",
116
+ u_texture: "sampler2d",
117
+ projectionMatrix: "mat4",
118
+ viewMatrix: "mat4",
119
+ eyePositionHigh: "vec3",
120
+ eyePositionLow: "vec3",
121
+ planetRadius: "float",
122
+ uScaleByDistance: "vec3",
123
+ opacity: "float",
124
+ depthOffset: "float"
125
+ },
126
+ attributes: {
127
+ a_vertices: "vec2",
128
+ a_texCoord: "vec2",
129
+ a_positionsHigh: "vec3",
130
+ a_positionsLow: "vec3",
131
+ a_offset: "vec3",
132
+ a_size: "vec2",
133
+ a_rotation: "float",
134
+ a_rgba: "vec4",
135
+ },
136
+ vertexShader:
137
+ `precision highp float;
138
+ attribute vec2 a_vertices;
139
+ attribute vec2 a_texCoord;
140
+ attribute vec3 a_positionsHigh;
141
+ attribute vec3 a_positionsLow;
142
+ attribute vec3 a_offset;
143
+ attribute vec2 a_size;
144
+ attribute float a_rotation;
145
+ attribute vec4 a_rgba;
146
+
147
+ varying vec2 v_texCoords;
148
+ varying vec4 v_rgba;
149
+
150
+ uniform mat4 viewMatrix;
151
+ uniform mat4 projectionMatrix;
152
+ uniform vec3 eyePositionHigh;
153
+ uniform vec3 eyePositionLow;
154
+ uniform vec3 uScaleByDistance;
155
+ uniform float opacity;
156
+ uniform float planetRadius;
157
+ uniform vec2 viewport;
158
+ uniform float depthOffset;
159
+
160
+ const vec3 ZERO3 = vec3(0.0);
161
+
162
+ ${PROJECT}
163
+
164
+ ${ROTATE2D}
165
+
166
+ void main() {
167
+
168
+ vec3 a_positions = a_positionsHigh + a_positionsLow;
169
+ vec3 cameraPos = eyePositionHigh + eyePositionLow;
170
+
171
+ v_texCoords = a_texCoord;
172
+ vec3 look = a_positions - cameraPos;
173
+ float lookDist = length(look);
174
+ v_rgba = a_rgba;
175
+
176
+ if(opacity * step(lookDist, sqrt(dot(cameraPos,cameraPos) - planetRadius) + sqrt(dot(a_positions,a_positions) - planetRadius)) == 0.0){
177
+ return;
178
+ }
179
+
180
+ vec3 up = vec3( viewMatrix[0][1], viewMatrix[1][1], viewMatrix[2][1] );
181
+ vec3 right = vec3( viewMatrix[0][0], viewMatrix[1][0], viewMatrix[2][0] );
182
+
183
+ float scd = (1.0 - smoothstep(uScaleByDistance[0], uScaleByDistance[1], lookDist)) * (1.0 - step(uScaleByDistance[2], lookDist));
184
+
185
+ mat4 viewMatrixRTE = viewMatrix;
186
+ viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
187
+
188
+ vec3 highDiff = a_positionsHigh - eyePositionHigh;
189
+ vec3 lowDiff = a_positionsLow - eyePositionLow;
190
+ vec4 posRTE = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
191
+ vec4 projPos = projectionMatrix * posRTE;
192
+
193
+ float camSlope = dot(vec3(viewMatrix[0][2], viewMatrix[1][2], viewMatrix[2][2]), normalize(cameraPos));
194
+ if(camSlope > 0.5) {
195
+ float dist = dot(look, normalize(cameraPos));
196
+ projPos.z += dist * 0.02;
197
+ }else{
198
+ projPos.z += -(abs(projPos.z)) * 0.002;
199
+ }
200
+
201
+ projPos.z += depthOffset + a_offset.z;
202
+
203
+ vec2 screenPos = project(projPos);
204
+
205
+ vec2 v = screenPos + rotate2d(a_rotation) * (a_vertices * a_size * scd + a_offset.xy);
206
+
207
+ gl_Position = vec4((2.0 * v / viewport - 1.0) * projPos.w, projPos.z, projPos.w);
208
+ }`,
209
+ fragmentShader:
210
+ `precision highp float;
211
+ uniform sampler2D u_texture;
212
+ varying vec2 v_texCoords;
213
+ varying vec4 v_rgba;
214
+ void main () {
215
+ vec4 color = texture2D(u_texture, v_texCoords);
216
+ if(color.a < 0.1)
217
+ discard;
218
+ gl_FragColor = color * v_rgba;
219
+ }`
220
+ });
205
221
  }