@@ -27,70 +27,55 @@ const float PI_05 = M_PI * 0.5;
27
27
const float PI_15 = M_PI * 1.5 ;
28
28
const float PI_20 = M_PI * 2.0 ;
29
29
30
- mat3 rotation3dY(float angle) {
31
- float s = sin (angle);
32
- float c = cos (angle);
33
- return mat3 (
34
- c, 0.0 , - s,
35
- 0.0 , 1.0 , 0.0 ,
36
- s, 0.0 , c
37
- );
38
- }
39
- vec3 rotateY(vec3 v, float angle) {
40
- return rotation3dY(angle) * v;
41
- }
42
- vec3 rotateY(vec2 v, float angle) {
43
- return rotation3dY(angle) * vec3 (v, 0.0 );
44
- }
45
30
46
31
47
- void main(void ){
48
- if (mod (a_position.x, 2.0 ) == 1.0 ){
32
+ void main(void ) {
33
+ if (mod (a_position.x, 2.0 ) == 1.0 ) {
49
34
50
35
vec2 position = floor (a_position.xy / 2.0 ) * EXTENT_SCALE;
51
36
52
37
vec2 rotLowHi = mod (a_texcoord, 32.0 );
53
- float rotation = rotLowHi.y * 32.0 + rotLowHi.x;
38
+ float rotationZ = rotLowHi.y * 32.0 + rotLowHi.x;
54
39
// texture coodrinates bit6->bit16
55
40
v_texcoord = floor (a_texcoord / 32.0 ) * u_atlasScale;
56
41
57
42
vec2 labelOffset = vec2 (toPixel(u_offset.xy, u_scale), toPixel(u_offset.zw, u_scale));
58
43
59
44
labelOffset *= DEVICE_PIXEL_RATIO;
60
45
61
- rotation = rotation / 1024.0 * PI_20;// 9bit -> 2PI;
46
+ rotationZ = rotationZ / 1024.0 * PI_20;// 9bit -> 2PI;
62
47
63
- float z = a_position.z * SCALE_UINT16_Z + toPixel(u_offsetZ, u_scale)/ u_zMeterToPixel/ u_scale;
48
+ float z = a_position.z * SCALE_UINT16_Z + toPixel(u_offsetZ, u_scale) / u_zMeterToPixel / u_scale;
64
49
65
- if (u_alignMap){
66
- float absRotation = mod (u_rotate + rotation, PI_20);
50
+ if (u_alignMap) {
51
+ float absRotation = mod (u_rotate + rotationZ, PI_20);
52
+ float rotationY = a_point.z / 32767.0 * PI_20;
67
53
68
- if (absRotation > PI_05 && absRotation < PI_15){
69
- rotation += M_PI;
54
+ if (absRotation > PI_05 && absRotation < PI_15) {
55
+ rotationZ += M_PI;
70
56
labelOffset *= - 1.0 ;
57
+ rotationY *= - 1.0 ;
71
58
}
72
59
73
- vec2 _p = a_point.xy * OFFSET_SCALE + labelOffset;
74
- vec3 p = rotateY(vec3 (_p, 1.0 ), a_point.z/ 32767.0 * PI_20);
75
- p.xy = rotateZ(_p, rotation);
76
- p = p / u_scale / DEVICE_PIXEL_RATIO;
77
-
78
- vec3 posWorld = vec3 (u_topLeft + position, p.z - z);
60
+ vec3 offset = vec3 (a_point.xy * OFFSET_SCALE + labelOffset, 0.0 ) / u_scale / DEVICE_PIXEL_RATIO;
61
+ offset = rotateY(offset, rotationY);
62
+ offset.xy = rotateZ(offset.xy, rotationZ);
79
63
80
- if (! u_scaleByAltitude){
64
+ vec3 posWorld = vec3 (u_topLeft + position, - z);
65
+ if (! u_scaleByAltitude) {
81
66
float scaleDZ = 1.0 + posWorld.z * u_matrix[2 ][3 ] / (u_matrix[0 ][3 ] * posWorld.x + u_matrix[1 ][3 ] * posWorld.y + u_matrix[3 ][3 ]);
82
- p .xy *= scaleDZ;
67
+ offset .xy *= scaleDZ;
83
68
}
69
+ gl_Position = u_matrix * vec4 (posWorld + offset, 1.0 );
84
70
85
- gl_Position = u_matrix * vec4 (posWorld.xy + p.xy, posWorld.z + p.z, 1.0 );
86
71
} else {
87
72
vec4 cpos = u_matrix * vec4 ((u_topLeft + position), - z, 1.0 );
88
- vec2 offset = rotateZ(a_point.xy * OFFSET_SCALE + labelOffset, rotation );
73
+ vec2 offset = rotateZ(a_point.xy * OFFSET_SCALE + labelOffset, rotationZ );
89
74
// posOffset = rotateY(vec3(posOffset, 0), a_point.z).xy;
90
75
gl_Position = vec4 (cpos.xy / cpos.w + vec2 (1 , - 1 ) * offset / DEVICE_PIXEL_RATIO / u_resolution * 2.0 , cpos.z / cpos.w, 1.0 );
91
76
}
92
77
93
- if (u_fixedView){
78
+ if (u_fixedView) {
94
79
// round/snap to pixelgrid if mapview is static -> crisp
95
80
gl_Position = snapToScreenPixel(gl_Position , u_resolution);
96
81
}
0 commit comments