@antv/l7-core
Advanced tools
Comparing version 2.0.0-beta.13 to 2.0.0-beta.15
@@ -6,2 +6,13 @@ # Change Log | ||
# [2.0.0-beta.15](https://github.com/antvis/L7/compare/v2.0.0-beta.14...v2.0.0-beta.15) (2019-11-29) | ||
### Bug Fixes | ||
* **map:** temporarily closed amap offset coordinate ([9a20f64](https://github.com/antvis/L7/commit/9a20f6480321c9297ff27fe4cfe6af9032fcb969)) | ||
# [2.0.0-beta.13](https://github.com/antvis/L7/compare/v2.0.0-beta.12...v2.0.0-beta.13) (2019-11-28) | ||
@@ -8,0 +19,0 @@ |
@@ -14,3 +14,3 @@ import _uniq from "lodash/uniq"; | ||
const project = "\n#define E 2.718281828459045\nvec2 ProjectFlat(vec2 lnglat){\n float maxs=85.0511287798;\n float lat=max(min(maxs,lnglat.y),-maxs);\n float scale= 268435456.;\n float d=PI/180.;\n float x=lnglat.x*d;\n float y=lat*d;\n y=log(tan((PI/4.)+(y/2.)));\n \n float a=.5/PI,\n b=.5,\n c=-.5/PI;\n d=.5;\n x=scale*(a*x+b);\n y=scale*(c*y+d);\n return vec2(x,y);\n}\n\nvec2 unProjectFlat(vec2 px){\n float a=.5/PI;\n float b=.5;\n float c=-.5/PI;\n float d=.5;\n float scale = 268435456.;\n float x=(px.x/scale-b)/a;\n float y=(px.y/scale-d)/c;\n y=(atan(pow(E,y))-(PI/4.))*2.;\n d=PI/180.;\n float lat=y/d;\n float lng=x/d;\n return vec2(lng,lat);\n}\n"; | ||
const projection = "#define TILE_SIZE 512.0\n#define PI 3.1415926536\n#define WORLD_SCALE TILE_SIZE / (PI * 2.0)\n\n#define COORDINATE_SYSTEM_LNGLAT 1.0\n#define COORDINATE_SYSTEM_LNGLAT_OFFSET 2.0\n#define COORDINATE_SYSTEM_VECTOR_TILE 3.0\n#define COORDINATE_SYSTEM_IDENTITY 4.0\n#define COORDINATE_SYSTEM_P20 5.0\n#define COORDINATE_SYSTEM_P20_OFFSET 6.0\n#define COORDINATE_SYSTEM_METER_OFFSET 7.0\n\nuniform mat4 u_ViewMatrix;\nuniform mat4 u_ProjectionMatrix;\nuniform mat4 u_ViewProjectionMatrix;\nuniform float u_Zoom : 1;\nuniform float u_ZoomScale : 1;\n\nuniform float u_CoordinateSystem;\nuniform vec2 u_ViewportCenter;\nuniform vec4 u_ViewportCenterProjection;\nuniform vec3 u_PixelsPerDegree;\nuniform vec3 u_PixelsPerDegree2;\nuniform vec3 u_PixelsPerMeter;\n\nuniform vec2 u_ViewportSize;\nuniform float u_DevicePixelRatio;\nuniform float u_FocalDistance;\nuniform vec3 u_CameraPosition;\n\n// web mercator coords -> world coords\nvec2 project_mercator(vec2 lnglat) {\n float x = lnglat.x;\n return vec2(\n radians(x) + PI,\n PI - log(tan(PI * 0.25 + radians(lnglat.y) * 0.5))\n );\n}\n\nfloat project_scale(float meters) {\n return meters * u_PixelsPerMeter.z;\n}\n\n\n// offset coords -> world coords\nvec4 project_offset(vec4 offset) {\n float dy = offset.y;\n dy = clamp(dy, -1., 1.);\n vec3 pixels_per_unit = u_PixelsPerDegree + u_PixelsPerDegree2 * dy;\n return vec4(offset.xyz * pixels_per_unit, offset.w);\n}\n\nvec3 project_normal(vec3 normal) {\n vec4 normal_modelspace = u_ModelMatrix * vec4(normal, 0.0);\n return normalize(normal_modelspace.xyz * u_PixelsPerMeter);\n}\n\nvec3 project_offset_normal(vec3 vector) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT\n || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // normals generated by the polygon tesselator are in lnglat offsets instead of meters\n return normalize(vector * u_PixelsPerDegree);\n }\n return project_normal(vector);\n}\n\n// reverse Y\nvec3 reverse_offset_normal(vec3 vector) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) {\n return vector * vec3(1.0, -1.0, 1.0);\n }\n return vector;\n}\n\nvec4 project_position(vec4 position) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n float X = position.x - u_ViewportCenter.x;\n float Y = position.y - u_ViewportCenter.y;\n return project_offset(vec4(X, Y, position.z, position.w));\n }\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n return vec4(\n project_mercator(position.xy) * WORLD_SCALE * u_ZoomScale,\n project_scale(position.z),\n position.w\n );\n }\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) {\n return vec4(\n (project_mercator(position.xy) * WORLD_SCALE * u_ZoomScale - vec2(215440491., 106744817.)) * vec2(1., -1.),\n project_scale(position.z),\n position.w\n );\n }\n\n // TODO: \u74E6\u7247\u5750\u6807\u7CFB & \u5E38\u89C4\u4E16\u754C\u5750\u6807\u7CFB\n}\n\nvec2 project_pixel_size_to_clipspace(vec2 pixels) {\n vec2 offset = pixels / u_ViewportSize * u_DevicePixelRatio * 2.0;\n return offset * u_FocalDistance;\n}\n\nfloat project_pixel(float pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20\n || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n return pixel;\n}\nvec2 project_pixel(vec2 pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n return pixel;\n}\n\nvec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // Needs to be divided with project_uCommonUnitsPerMeter\n position.w *= u_PixelsPerMeter.z;\n }\n return viewProjectionMatrix * position + center;\n}\n\n// Projects from common space coordinates to clip space\nvec4 project_common_position_to_clipspace(vec4 position) {\n return project_common_position_to_clipspace(\n position,\n u_ViewProjectionMatrix,\n u_ViewportCenterProjection\n );\n}\n\nvec4 unproject_clipspace_to_position(vec4 clipspacePos, mat4 u_InverseViewProjectionMatrix) {\n vec4 pos = u_InverseViewProjectionMatrix * (clipspacePos - u_ViewportCenterProjection);\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // Needs to be divided with project_uCommonUnitsPerMeter\n pos.w = pos.w / u_PixelsPerMeter.z;\n }\n return pos;\n}\n"; | ||
const projection = "#define TILE_SIZE 512.0\n#define PI 3.1415926536\n#define WORLD_SCALE TILE_SIZE / (PI * 2.0)\n\n#define COORDINATE_SYSTEM_LNGLAT 1.0\n#define COORDINATE_SYSTEM_LNGLAT_OFFSET 2.0\n#define COORDINATE_SYSTEM_VECTOR_TILE 3.0\n#define COORDINATE_SYSTEM_IDENTITY 4.0\n#define COORDINATE_SYSTEM_P20 5.0\n#define COORDINATE_SYSTEM_P20_OFFSET 6.0\n#define COORDINATE_SYSTEM_METER_OFFSET 7.0\n\nuniform mat4 u_ViewMatrix;\nuniform mat4 u_ProjectionMatrix;\nuniform mat4 u_ViewProjectionMatrix;\nuniform float u_Zoom : 1;\nuniform float u_ZoomScale : 1;\n\nuniform float u_CoordinateSystem;\nuniform vec2 u_ViewportCenter;\nuniform vec4 u_ViewportCenterProjection;\nuniform vec3 u_PixelsPerDegree;\nuniform vec3 u_PixelsPerDegree2;\nuniform vec3 u_PixelsPerMeter;\n\nuniform vec2 u_ViewportSize;\nuniform float u_DevicePixelRatio;\nuniform float u_FocalDistance;\nuniform vec3 u_CameraPosition;\n\n// web mercator coords -> world coords\nvec2 project_mercator(vec2 lnglat) {\n float x = lnglat.x;\n return vec2(\n radians(x) + PI,\n PI - log(tan(PI * 0.25 + radians(lnglat.y) * 0.5))\n );\n}\n\nfloat project_scale(float meters) {\n return meters * u_PixelsPerMeter.z;\n}\n\n\n// offset coords -> world coords\nvec4 project_offset(vec4 offset) {\n float dy = offset.y;\n dy = clamp(dy, -1., 1.);\n vec3 pixels_per_unit = u_PixelsPerDegree + u_PixelsPerDegree2 * dy;\n return vec4(offset.xyz * pixels_per_unit, offset.w);\n}\n\nvec3 project_normal(vec3 normal) {\n vec4 normal_modelspace = u_ModelMatrix * vec4(normal, 0.0);\n return normalize(normal_modelspace.xyz * u_PixelsPerMeter);\n}\n\nvec3 project_offset_normal(vec3 vector) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT\n || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // normals generated by the polygon tesselator are in lnglat offsets instead of meters\n return normalize(vector * u_PixelsPerDegree);\n }\n return project_normal(vector);\n}\n\n// reverse Y\nvec3 reverse_offset_normal(vec3 vector) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) {\n return vector * vec3(1.0, -1.0, 1.0);\n }\n return vector;\n}\n\nvec4 project_position(vec4 position) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n float X = position.x - u_ViewportCenter.x;\n float Y = position.y - u_ViewportCenter.y;\n return project_offset(vec4(X, Y, position.z, position.w));\n }\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n return vec4(\n project_mercator(position.xy) * WORLD_SCALE * u_ZoomScale,\n project_scale(position.z),\n position.w\n );\n }\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) {\n return vec4(\n (project_mercator(position.xy) * WORLD_SCALE * u_ZoomScale - vec2(215440491., 106744817.)) * vec2(1., -1.),\n project_scale(position.z),\n position.w\n );\n }\n\n // TODO: \u74E6\u7247\u5750\u6807\u7CFB & \u5E38\u89C4\u4E16\u754C\u5750\u6807\u7CFB\n}\n\nvec2 project_pixel_size_to_clipspace(vec2 pixels) {\n vec2 offset = pixels / u_ViewportSize * u_DevicePixelRatio * 2.0;\n return offset * u_FocalDistance;\n}\n\nfloat project_pixel(float pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n return pixel;\n}\nvec2 project_pixel(vec2 pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n return pixel;\n}\n\nvec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // Needs to be divided with project_uCommonUnitsPerMeter\n position.w *= u_PixelsPerMeter.z;\n }\n return viewProjectionMatrix * position + center;\n}\n\n// Projects from common space coordinates to clip space\nvec4 project_common_position_to_clipspace(vec4 position) {\n return project_common_position_to_clipspace(\n position,\n u_ViewProjectionMatrix,\n u_ViewportCenterProjection\n );\n}\n\nvec4 unproject_clipspace_to_position(vec4 clipspacePos, mat4 u_InverseViewProjectionMatrix) {\n vec4 pos = u_InverseViewProjectionMatrix * (clipspacePos - u_ViewportCenterProjection);\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // Needs to be divided with project_uCommonUnitsPerMeter\n pos.w = pos.w / u_PixelsPerMeter.z;\n }\n return pos;\n}\n"; | ||
const sdf2d = "/**\n * 2D signed distance field functions\n * @see http://www.iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm\n */\n\nfloat ndot(vec2 a, vec2 b ) { return a.x*b.x - a.y*b.y; }\n\nfloat sdCircle(vec2 p, float r) {\n return length(p) - r;\n}\n\nfloat sdEquilateralTriangle(vec2 p) {\n const float k = sqrt(3.0);\n p.x = abs(p.x) - 1.0;\n p.y = p.y + 1.0/k;\n if( p.x + k*p.y > 0.0 ) p = vec2(p.x-k*p.y,-k*p.x-p.y)/2.0;\n p.x -= clamp( p.x, -2.0, 0.0 );\n return -length(p)*sign(p.y);\n}\n\nfloat sdBox(vec2 p, vec2 b) {\n vec2 d = abs(p)-b;\n return length(max(d,vec2(0))) + min(max(d.x,d.y),0.0);\n}\n\nfloat sdPentagon(vec2 p, float r) {\n const vec3 k = vec3(0.809016994,0.587785252,0.726542528);\n p.x = abs(p.x);\n p -= 2.0*min(dot(vec2(-k.x,k.y),p),0.0)*vec2(-k.x,k.y);\n p -= 2.0*min(dot(vec2( k.x,k.y),p),0.0)*vec2( k.x,k.y);\n p -= vec2(clamp(p.x,-r*k.z,r*k.z),r); \n return length(p)*sign(p.y);\n}\n\nfloat sdHexagon(vec2 p, float r) {\n const vec3 k = vec3(-0.866025404,0.5,0.577350269);\n p = abs(p);\n p -= 2.0*min(dot(k.xy,p),0.0)*k.xy;\n p -= vec2(clamp(p.x, -k.z*r, k.z*r), r);\n return length(p)*sign(p.y);\n}\n\nfloat sdOctogon(vec2 p, float r) {\n const vec3 k = vec3(-0.9238795325, 0.3826834323, 0.4142135623 );\n p = abs(p);\n p -= 2.0*min(dot(vec2( k.x,k.y),p),0.0)*vec2( k.x,k.y);\n p -= 2.0*min(dot(vec2(-k.x,k.y),p),0.0)*vec2(-k.x,k.y);\n p -= vec2(clamp(p.x, -k.z*r, k.z*r), r);\n return length(p)*sign(p.y);\n}\n\nfloat sdHexagram(vec2 p, float r) {\n const vec4 k=vec4(-0.5,0.8660254038,0.5773502692,1.7320508076);\n p = abs(p);\n p -= 2.0*min(dot(k.xy,p),0.0)*k.xy;\n p -= 2.0*min(dot(k.yx,p),0.0)*k.yx;\n p -= vec2(clamp(p.x,r*k.z,r*k.w),r);\n return length(p)*sign(p.y);\n}\n\nfloat sdRhombus(vec2 p, vec2 b) {\n vec2 q = abs(p);\n float h = clamp((-2.0*ndot(q,b)+ndot(b,b))/dot(b,b),-1.0,1.0);\n float d = length( q - 0.5*b*vec2(1.0-h,1.0+h) );\n return d * sign( q.x*b.y + q.y*b.x - b.x*b.y );\n}\n\nfloat sdVesica(vec2 p, float r, float d) {\n p = abs(p);\n float b = sqrt(r*r-d*d); // can delay this sqrt\n return ((p.y-b)*d>p.x*b) \n ? length(p-vec2(0.0,b))\n : length(p-vec2(-d,0.0))-r;\n}"; | ||
@@ -17,0 +17,0 @@ const precisionRegExp = /precision\s+(high|low|medium)p\s+float/; |
@@ -25,3 +25,3 @@ "use strict"; | ||
const project = "\n#define E 2.718281828459045\nvec2 ProjectFlat(vec2 lnglat){\n float maxs=85.0511287798;\n float lat=max(min(maxs,lnglat.y),-maxs);\n float scale= 268435456.;\n float d=PI/180.;\n float x=lnglat.x*d;\n float y=lat*d;\n y=log(tan((PI/4.)+(y/2.)));\n \n float a=.5/PI,\n b=.5,\n c=-.5/PI;\n d=.5;\n x=scale*(a*x+b);\n y=scale*(c*y+d);\n return vec2(x,y);\n}\n\nvec2 unProjectFlat(vec2 px){\n float a=.5/PI;\n float b=.5;\n float c=-.5/PI;\n float d=.5;\n float scale = 268435456.;\n float x=(px.x/scale-b)/a;\n float y=(px.y/scale-d)/c;\n y=(atan(pow(E,y))-(PI/4.))*2.;\n d=PI/180.;\n float lat=y/d;\n float lng=x/d;\n return vec2(lng,lat);\n}\n"; | ||
const projection = "#define TILE_SIZE 512.0\n#define PI 3.1415926536\n#define WORLD_SCALE TILE_SIZE / (PI * 2.0)\n\n#define COORDINATE_SYSTEM_LNGLAT 1.0\n#define COORDINATE_SYSTEM_LNGLAT_OFFSET 2.0\n#define COORDINATE_SYSTEM_VECTOR_TILE 3.0\n#define COORDINATE_SYSTEM_IDENTITY 4.0\n#define COORDINATE_SYSTEM_P20 5.0\n#define COORDINATE_SYSTEM_P20_OFFSET 6.0\n#define COORDINATE_SYSTEM_METER_OFFSET 7.0\n\nuniform mat4 u_ViewMatrix;\nuniform mat4 u_ProjectionMatrix;\nuniform mat4 u_ViewProjectionMatrix;\nuniform float u_Zoom : 1;\nuniform float u_ZoomScale : 1;\n\nuniform float u_CoordinateSystem;\nuniform vec2 u_ViewportCenter;\nuniform vec4 u_ViewportCenterProjection;\nuniform vec3 u_PixelsPerDegree;\nuniform vec3 u_PixelsPerDegree2;\nuniform vec3 u_PixelsPerMeter;\n\nuniform vec2 u_ViewportSize;\nuniform float u_DevicePixelRatio;\nuniform float u_FocalDistance;\nuniform vec3 u_CameraPosition;\n\n// web mercator coords -> world coords\nvec2 project_mercator(vec2 lnglat) {\n float x = lnglat.x;\n return vec2(\n radians(x) + PI,\n PI - log(tan(PI * 0.25 + radians(lnglat.y) * 0.5))\n );\n}\n\nfloat project_scale(float meters) {\n return meters * u_PixelsPerMeter.z;\n}\n\n\n// offset coords -> world coords\nvec4 project_offset(vec4 offset) {\n float dy = offset.y;\n dy = clamp(dy, -1., 1.);\n vec3 pixels_per_unit = u_PixelsPerDegree + u_PixelsPerDegree2 * dy;\n return vec4(offset.xyz * pixels_per_unit, offset.w);\n}\n\nvec3 project_normal(vec3 normal) {\n vec4 normal_modelspace = u_ModelMatrix * vec4(normal, 0.0);\n return normalize(normal_modelspace.xyz * u_PixelsPerMeter);\n}\n\nvec3 project_offset_normal(vec3 vector) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT\n || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // normals generated by the polygon tesselator are in lnglat offsets instead of meters\n return normalize(vector * u_PixelsPerDegree);\n }\n return project_normal(vector);\n}\n\n// reverse Y\nvec3 reverse_offset_normal(vec3 vector) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) {\n return vector * vec3(1.0, -1.0, 1.0);\n }\n return vector;\n}\n\nvec4 project_position(vec4 position) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n float X = position.x - u_ViewportCenter.x;\n float Y = position.y - u_ViewportCenter.y;\n return project_offset(vec4(X, Y, position.z, position.w));\n }\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n return vec4(\n project_mercator(position.xy) * WORLD_SCALE * u_ZoomScale,\n project_scale(position.z),\n position.w\n );\n }\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) {\n return vec4(\n (project_mercator(position.xy) * WORLD_SCALE * u_ZoomScale - vec2(215440491., 106744817.)) * vec2(1., -1.),\n project_scale(position.z),\n position.w\n );\n }\n\n // TODO: \u74E6\u7247\u5750\u6807\u7CFB & \u5E38\u89C4\u4E16\u754C\u5750\u6807\u7CFB\n}\n\nvec2 project_pixel_size_to_clipspace(vec2 pixels) {\n vec2 offset = pixels / u_ViewportSize * u_DevicePixelRatio * 2.0;\n return offset * u_FocalDistance;\n}\n\nfloat project_pixel(float pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20\n || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n return pixel;\n}\nvec2 project_pixel(vec2 pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n return pixel;\n}\n\nvec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // Needs to be divided with project_uCommonUnitsPerMeter\n position.w *= u_PixelsPerMeter.z;\n }\n return viewProjectionMatrix * position + center;\n}\n\n// Projects from common space coordinates to clip space\nvec4 project_common_position_to_clipspace(vec4 position) {\n return project_common_position_to_clipspace(\n position,\n u_ViewProjectionMatrix,\n u_ViewportCenterProjection\n );\n}\n\nvec4 unproject_clipspace_to_position(vec4 clipspacePos, mat4 u_InverseViewProjectionMatrix) {\n vec4 pos = u_InverseViewProjectionMatrix * (clipspacePos - u_ViewportCenterProjection);\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // Needs to be divided with project_uCommonUnitsPerMeter\n pos.w = pos.w / u_PixelsPerMeter.z;\n }\n return pos;\n}\n"; | ||
const projection = "#define TILE_SIZE 512.0\n#define PI 3.1415926536\n#define WORLD_SCALE TILE_SIZE / (PI * 2.0)\n\n#define COORDINATE_SYSTEM_LNGLAT 1.0\n#define COORDINATE_SYSTEM_LNGLAT_OFFSET 2.0\n#define COORDINATE_SYSTEM_VECTOR_TILE 3.0\n#define COORDINATE_SYSTEM_IDENTITY 4.0\n#define COORDINATE_SYSTEM_P20 5.0\n#define COORDINATE_SYSTEM_P20_OFFSET 6.0\n#define COORDINATE_SYSTEM_METER_OFFSET 7.0\n\nuniform mat4 u_ViewMatrix;\nuniform mat4 u_ProjectionMatrix;\nuniform mat4 u_ViewProjectionMatrix;\nuniform float u_Zoom : 1;\nuniform float u_ZoomScale : 1;\n\nuniform float u_CoordinateSystem;\nuniform vec2 u_ViewportCenter;\nuniform vec4 u_ViewportCenterProjection;\nuniform vec3 u_PixelsPerDegree;\nuniform vec3 u_PixelsPerDegree2;\nuniform vec3 u_PixelsPerMeter;\n\nuniform vec2 u_ViewportSize;\nuniform float u_DevicePixelRatio;\nuniform float u_FocalDistance;\nuniform vec3 u_CameraPosition;\n\n// web mercator coords -> world coords\nvec2 project_mercator(vec2 lnglat) {\n float x = lnglat.x;\n return vec2(\n radians(x) + PI,\n PI - log(tan(PI * 0.25 + radians(lnglat.y) * 0.5))\n );\n}\n\nfloat project_scale(float meters) {\n return meters * u_PixelsPerMeter.z;\n}\n\n\n// offset coords -> world coords\nvec4 project_offset(vec4 offset) {\n float dy = offset.y;\n dy = clamp(dy, -1., 1.);\n vec3 pixels_per_unit = u_PixelsPerDegree + u_PixelsPerDegree2 * dy;\n return vec4(offset.xyz * pixels_per_unit, offset.w);\n}\n\nvec3 project_normal(vec3 normal) {\n vec4 normal_modelspace = u_ModelMatrix * vec4(normal, 0.0);\n return normalize(normal_modelspace.xyz * u_PixelsPerMeter);\n}\n\nvec3 project_offset_normal(vec3 vector) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT\n || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // normals generated by the polygon tesselator are in lnglat offsets instead of meters\n return normalize(vector * u_PixelsPerDegree);\n }\n return project_normal(vector);\n}\n\n// reverse Y\nvec3 reverse_offset_normal(vec3 vector) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) {\n return vector * vec3(1.0, -1.0, 1.0);\n }\n return vector;\n}\n\nvec4 project_position(vec4 position) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET\n || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n float X = position.x - u_ViewportCenter.x;\n float Y = position.y - u_ViewportCenter.y;\n return project_offset(vec4(X, Y, position.z, position.w));\n }\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n return vec4(\n project_mercator(position.xy) * WORLD_SCALE * u_ZoomScale,\n project_scale(position.z),\n position.w\n );\n }\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) {\n return vec4(\n (project_mercator(position.xy) * WORLD_SCALE * u_ZoomScale - vec2(215440491., 106744817.)) * vec2(1., -1.),\n project_scale(position.z),\n position.w\n );\n }\n\n // TODO: \u74E6\u7247\u5750\u6807\u7CFB & \u5E38\u89C4\u4E16\u754C\u5750\u6807\u7CFB\n}\n\nvec2 project_pixel_size_to_clipspace(vec2 pixels) {\n vec2 offset = pixels / u_ViewportSize * u_DevicePixelRatio * 2.0;\n return offset * u_FocalDistance;\n}\n\nfloat project_pixel(float pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n return pixel;\n}\nvec2 project_pixel(vec2 pixel) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n return pixel * pow(2.0, (19.0 - u_Zoom));\n }\n return pixel;\n}\n\nvec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {\n if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // Needs to be divided with project_uCommonUnitsPerMeter\n position.w *= u_PixelsPerMeter.z;\n }\n return viewProjectionMatrix * position + center;\n}\n\n// Projects from common space coordinates to clip space\nvec4 project_common_position_to_clipspace(vec4 position) {\n return project_common_position_to_clipspace(\n position,\n u_ViewProjectionMatrix,\n u_ViewportCenterProjection\n );\n}\n\nvec4 unproject_clipspace_to_position(vec4 clipspacePos, mat4 u_InverseViewProjectionMatrix) {\n vec4 pos = u_InverseViewProjectionMatrix * (clipspacePos - u_ViewportCenterProjection);\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET ||\n u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // Needs to be divided with project_uCommonUnitsPerMeter\n pos.w = pos.w / u_PixelsPerMeter.z;\n }\n return pos;\n}\n"; | ||
const sdf2d = "/**\n * 2D signed distance field functions\n * @see http://www.iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm\n */\n\nfloat ndot(vec2 a, vec2 b ) { return a.x*b.x - a.y*b.y; }\n\nfloat sdCircle(vec2 p, float r) {\n return length(p) - r;\n}\n\nfloat sdEquilateralTriangle(vec2 p) {\n const float k = sqrt(3.0);\n p.x = abs(p.x) - 1.0;\n p.y = p.y + 1.0/k;\n if( p.x + k*p.y > 0.0 ) p = vec2(p.x-k*p.y,-k*p.x-p.y)/2.0;\n p.x -= clamp( p.x, -2.0, 0.0 );\n return -length(p)*sign(p.y);\n}\n\nfloat sdBox(vec2 p, vec2 b) {\n vec2 d = abs(p)-b;\n return length(max(d,vec2(0))) + min(max(d.x,d.y),0.0);\n}\n\nfloat sdPentagon(vec2 p, float r) {\n const vec3 k = vec3(0.809016994,0.587785252,0.726542528);\n p.x = abs(p.x);\n p -= 2.0*min(dot(vec2(-k.x,k.y),p),0.0)*vec2(-k.x,k.y);\n p -= 2.0*min(dot(vec2( k.x,k.y),p),0.0)*vec2( k.x,k.y);\n p -= vec2(clamp(p.x,-r*k.z,r*k.z),r); \n return length(p)*sign(p.y);\n}\n\nfloat sdHexagon(vec2 p, float r) {\n const vec3 k = vec3(-0.866025404,0.5,0.577350269);\n p = abs(p);\n p -= 2.0*min(dot(k.xy,p),0.0)*k.xy;\n p -= vec2(clamp(p.x, -k.z*r, k.z*r), r);\n return length(p)*sign(p.y);\n}\n\nfloat sdOctogon(vec2 p, float r) {\n const vec3 k = vec3(-0.9238795325, 0.3826834323, 0.4142135623 );\n p = abs(p);\n p -= 2.0*min(dot(vec2( k.x,k.y),p),0.0)*vec2( k.x,k.y);\n p -= 2.0*min(dot(vec2(-k.x,k.y),p),0.0)*vec2(-k.x,k.y);\n p -= vec2(clamp(p.x, -k.z*r, k.z*r), r);\n return length(p)*sign(p.y);\n}\n\nfloat sdHexagram(vec2 p, float r) {\n const vec4 k=vec4(-0.5,0.8660254038,0.5773502692,1.7320508076);\n p = abs(p);\n p -= 2.0*min(dot(k.xy,p),0.0)*k.xy;\n p -= 2.0*min(dot(k.yx,p),0.0)*k.yx;\n p -= vec2(clamp(p.x,r*k.z,r*k.w),r);\n return length(p)*sign(p.y);\n}\n\nfloat sdRhombus(vec2 p, vec2 b) {\n vec2 q = abs(p);\n float h = clamp((-2.0*ndot(q,b)+ndot(b,b))/dot(b,b),-1.0,1.0);\n float d = length( q - 0.5*b*vec2(1.0-h,1.0+h) );\n return d * sign( q.x*b.y + q.y*b.x - b.x*b.y );\n}\n\nfloat sdVesica(vec2 p, float r, float d) {\n p = abs(p);\n float b = sqrt(r*r-d*d); // can delay this sqrt\n return ((p.y-b)*d>p.x*b) \n ? length(p-vec2(0.0,b))\n : length(p-vec2(-d,0.0))-r;\n}"; | ||
@@ -28,0 +28,0 @@ const precisionRegExp = /precision\s+(high|low|medium)p\s+float/; |
{ | ||
"name": "@antv/l7-core", | ||
"version": "2.0.0-beta.13", | ||
"version": "2.0.0-beta.15", | ||
"description": "", | ||
@@ -46,3 +46,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "bc2f1c9cb66d00d33145c3ca3ee8031b41d2002c", | ||
"gitHead": "a21759211ce52abb20383981a9f2dcec58e9672d", | ||
"publishConfig": { | ||
@@ -49,0 +49,0 @@ "access": "public" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
1085034
0
11326