@antv/l7-layers
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -52,19 +52,2 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
this.styleAttributeService.registerStyleAttribute({ | ||
name: 'size', | ||
type: AttributeType.Attribute, | ||
descriptor: { | ||
name: 'a_Size', | ||
buffer: { | ||
usage: gl.DYNAMIC_DRAW, | ||
data: [], | ||
type: gl.FLOAT | ||
}, | ||
size: 1, | ||
update: function update(feature, featureIdx, vertex, attributeIdx) { | ||
var size = feature.size; | ||
return Array.isArray(size) ? [size[0]] : [size]; | ||
} | ||
} | ||
}); | ||
this.styleAttributeService.registerStyleAttribute({ | ||
name: 'pos', | ||
@@ -71,0 +54,0 @@ type: AttributeType.Attribute, |
@@ -9,3 +9,3 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
import { LineArcTriangulation } from '../../core/triangulation'; | ||
var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nuniform float u_opacity;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\nvarying vec2 v_normal;\nvarying vec2 v_dash_array;\nvarying float v_distance_ratio;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"picking\"\n\nvoid main() {\n gl_FragColor = v_color;\n float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n gl_FragColor.a *= (blur * u_opacity);\n if(u_line_type == LineTypeDash) {\n gl_FragColor.a *= blur * (1.0- step(v_dash_array.x, mod(v_distance_ratio, v_dash_array.x +v_dash_array.y)));\n // gl_FragColor.a =\n }\n\n if(u_aimate.x == Animate) {\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n // gl_FragColor.a = fract(u_time);\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; | ||
var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nuniform float u_opacity;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\nvarying vec2 v_normal;\nvarying vec2 v_dash_array;\nvarying float v_distance_ratio;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"picking\"\n\nvoid main() {\n gl_FragColor = v_color;\n float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n gl_FragColor.a *= (blur * u_opacity);\n if(u_line_type == LineTypeDash) {\n gl_FragColor.a *= blur * (1.0- step(v_dash_array.x, mod(v_distance_ratio, v_dash_array.x +v_dash_array.y)));\n }\n\n if(u_aimate.x == Animate) {\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; | ||
var line_arc_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute vec4 a_Color;\nattribute float a_Size;\n\nuniform mat4 u_ModelMatrix;\nuniform float segmentNumber;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nvarying vec4 v_color;\nvarying vec2 v_normal;\nvarying float v_distance_ratio;\nuniform float u_line_type: 0.0;\nuniform vec2 u_dash_array: [10.0, 5.];\n\nvarying vec2 v_dash_array;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat maps (float value, float start1, float stop1, float start2, float stop2) {\n return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.0));\n}\n\nfloat paraboloid(vec2 source, vec2 target, float ratio) {\n vec2 x = mix(source, target, ratio);\n vec2 center = mix(source, target, 0.5);\n float dSourceCenter = distance(source, center);\n float dXCenter = distance(x, center);\n return (dSourceCenter + dXCenter) * (dSourceCenter - dXCenter);\n}\n\nvec3 getPos(vec2 source, vec2 target, float segmentRatio) {\n float vertex_height = paraboloid(source, target, segmentRatio);\n\n return vec3(\n mix(source, target, segmentRatio),\n sqrt(max(0.0, vertex_height))\n );\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n\n vec2 offset = dir_screenspace * offset_direction * a_Size / 2.0;\n\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nvoid main() {\n v_color = a_Color;\n vec2 source = project_position(vec4(a_Instance.rg, 0, 0)).xy;\n vec2 target = project_position(vec4(a_Instance.ba, 0, 0)).xy;\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n\n if(u_line_type == LineTypeDash) {\n v_distance_ratio = segmentIndex / segmentNumber;\n float total_Distance = pixelDistance(a_Instance.rg, a_Instance.ba) / 2.0 * PI;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / (total_Distance / segmentNumber * segmentIndex);\n }\n if(u_aimate.x == Animate) {\n v_distance_ratio = segmentIndex / segmentNumber;\n }\n\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n vec3 curr = getPos(source, target, segmentRatio);\n vec3 next = getPos(source, target, nextSegmentRatio);\n vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y);\n v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n\n gl_Position = project_common_position_to_clipspace(vec4(curr.xy + project_pixel(offset), curr.z, 1.0));\n setPickingColor(a_PickingColor);\n}\n"; | ||
@@ -12,0 +12,0 @@ var lineStyleObj = { |
@@ -9,3 +9,3 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
import { LineArcTriangulation } from '../../core/triangulation'; | ||
var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nuniform float u_opacity;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\nvarying vec2 v_normal;\nvarying vec2 v_dash_array;\nvarying float v_distance_ratio;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"picking\"\n\nvoid main() {\n gl_FragColor = v_color;\n float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n gl_FragColor.a *= (blur * u_opacity);\n if(u_line_type == LineTypeDash) {\n gl_FragColor.a *= blur * (1.0- step(v_dash_array.x, mod(v_distance_ratio, v_dash_array.x +v_dash_array.y)));\n // gl_FragColor.a =\n }\n\n if(u_aimate.x == Animate) {\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n // gl_FragColor.a = fract(u_time);\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; | ||
var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nuniform float u_opacity;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\nvarying vec2 v_normal;\nvarying vec2 v_dash_array;\nvarying float v_distance_ratio;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"picking\"\n\nvoid main() {\n gl_FragColor = v_color;\n float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n gl_FragColor.a *= (blur * u_opacity);\n if(u_line_type == LineTypeDash) {\n gl_FragColor.a *= blur * (1.0- step(v_dash_array.x, mod(v_distance_ratio, v_dash_array.x +v_dash_array.y)));\n }\n\n if(u_aimate.x == Animate) {\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; | ||
var line_arc2d_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\nuniform float segmentNumber;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nvarying vec4 v_color;\nvarying vec2 v_normal;\n\nvarying float v_distance_ratio;\nuniform float u_line_type: 0.0;\nuniform vec2 u_dash_array: [10.0, 5.];\nvarying vec2 v_dash_array;\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\nvec2 midPoint(vec2 source, vec2 target) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = 0.314;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);\n return mid;\n}\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n}\nvec2 interpolate (vec2 source, vec2 target, float t) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n vec2 mid = midPoint(source, target);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x ,t), bezier3(y,t));\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * a_Size / 2.0;\n return offset * vec2(1.0, -1.0);\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nvoid main() {\n v_color = a_Color;\n vec2 source = a_Instance.rg;\n vec2 target = a_Instance.ba;\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n if(u_line_type == LineTypeDash) {\n v_distance_ratio = segmentIndex / segmentNumber;\n float total_Distance = pixelDistance(a_Instance.rg, a_Instance.ba) / 2.0 * PI;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / (total_Distance / segmentNumber * segmentIndex);\n }\n if(u_aimate.x == Animate) {\n v_distance_ratio = segmentIndex / segmentNumber;\n }\n vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio), 0.0, 1.0));\n vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio), 0.0, 1.0));\n v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n\n gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, 0, 1.0));\n setPickingColor(a_PickingColor);\n}\n"; | ||
@@ -12,0 +12,0 @@ var lineStyleObj = { |
@@ -10,3 +10,3 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
var line_arc2d_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\nuniform float segmentNumber;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nvarying vec4 v_color;\nvarying vec2 v_normal;\n\nvarying float v_distance_ratio;\nuniform float u_line_type: 0.0;\nuniform vec2 u_dash_array: [10.0, 5.];\nvarying vec2 v_dash_array;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat maps (float value, float start1, float stop1, float start2, float stop2) {\n return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n}\n\nfloat paraboloid(vec2 source, vec2 target, float ratio) {\n vec2 x = mix(source, target, ratio);\n vec2 center = mix(source, target, 0.5);\n float dSourceCenter = distance(source, center);\n float dXCenter = distance(x, center);\n return (dSourceCenter + dXCenter) * (dSourceCenter - dXCenter);\n}\n\nvec3 getPos(vec2 source, vec2 target, float segmentRatio) {\n float vertex_height = paraboloid(source, target, segmentRatio);\n\n return vec3(\n mix(source, target, segmentRatio),\n sqrt(max(0.0, vertex_height))\n );\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * a_Size / 2.0;\n return offset * vec2(1.0, -1.0);\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\nfloat getAngularDist (vec2 source, vec2 target) {\n vec2 delta = source - target;\n vec2 sin_half_delta = sin(delta / 2.0);\n float a =\n sin_half_delta.y * sin_half_delta.y +\n cos(source.y) * cos(target.y) *\n sin_half_delta.x * sin_half_delta.x;\n return 2.0 * atan(sqrt(a), sqrt(1.0 - a));\n}\nvec2 interpolate (vec2 source, vec2 target, float angularDist, float t) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n if(abs(angularDist - PI) < 0.001) {\n return (1.0 - t) * source + t * target;\n }\n float a = sin((1.0 - t) * angularDist) / sin(angularDist);\n float b = sin(t * angularDist) / sin(angularDist);\n vec2 sin_source = sin(source);\n vec2 cos_source = cos(source);\n vec2 sin_target = sin(target);\n vec2 cos_target = cos(target);\n float x = a * cos_source.y * cos_source.x + b * cos_target.y * cos_target.x;\n float y = a * cos_source.y * sin_source.x + b * cos_target.y * sin_target.x;\n float z = a * sin_source.y + b * sin_target.y;\n return vec2(atan(y, x), atan(z, sqrt(x * x + y * y)));\n}\n\nvoid main() {\n v_color = a_Color;\n vec2 source = radians(a_Instance.rg);\n vec2 target = radians(a_Instance.ba);\n float angularDist = getAngularDist(source, target);\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n if(u_line_type == LineTypeDash) {\n v_distance_ratio = segmentIndex / segmentNumber;\n float total_Distance = pixelDistance(a_Instance.rg, a_Instance.ba);\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / (total_Distance / segmentNumber * segmentIndex);\n }\n if(u_aimate.x == Animate) {\n v_distance_ratio = segmentIndex / segmentNumber;\n }\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n v_distance_ratio = segmentIndex / segmentNumber;\n vec4 curr = project_position(vec4(degrees(interpolate(source, target, angularDist, segmentRatio)), 0.0, 1.0));\n vec4 next = project_position(vec4(degrees(interpolate(source, target, angularDist, nextSegmentRatio)), 0.0, 1.0));\n v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n // vec4 project_pos = project_position(vec4(curr.xy, 0, 1.0));\n gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, curr.z, 1.0));\n setPickingColor(a_PickingColor);\n}\n\n"; | ||
var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nuniform float u_opacity;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\nvarying vec2 v_normal;\nvarying vec2 v_dash_array;\nvarying float v_distance_ratio;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"picking\"\n\nvoid main() {\n gl_FragColor = v_color;\n float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n gl_FragColor.a *= (blur * u_opacity);\n if(u_line_type == LineTypeDash) {\n gl_FragColor.a *= blur * (1.0- step(v_dash_array.x, mod(v_distance_ratio, v_dash_array.x +v_dash_array.y)));\n // gl_FragColor.a =\n }\n\n if(u_aimate.x == Animate) {\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n // gl_FragColor.a = fract(u_time);\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; | ||
var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nuniform float u_opacity;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\nvarying vec2 v_normal;\nvarying vec2 v_dash_array;\nvarying float v_distance_ratio;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"picking\"\n\nvoid main() {\n gl_FragColor = v_color;\n float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n gl_FragColor.a *= (blur * u_opacity);\n if(u_line_type == LineTypeDash) {\n gl_FragColor.a *= blur * (1.0- step(v_dash_array.x, mod(v_distance_ratio, v_dash_array.x +v_dash_array.y)));\n }\n\n if(u_aimate.x == Animate) {\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; | ||
var lineStyleObj = { | ||
@@ -13,0 +13,0 @@ solid: 0.0, |
@@ -9,3 +9,3 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
import { LineTriangulation } from '../../core/triangulation'; | ||
var line_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\nuniform float u_opacity : 1.0;\nvarying vec4 v_color;\nvarying vec2 v_normal;\n\n\n// dash\nuniform float u_dash_offset : 0.0;\nuniform float u_dash_ratio : 0.1;\nvarying float v_distance_ratio;\nvarying vec2 v_dash_array;\nvarying float v_side;\n\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n// [animate, duration, interval, trailLength],\nvoid main() {\n gl_FragColor = v_color;\n // anti-alias\n float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy)) * u_opacity;\n // gl_FragColor.a *= blur;\n\n if(u_aimate.x == Animate) {\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n // float alpha2 = exp(-abs(v_side));\n gl_FragColor.a *= alpha * blur;\n // gl_FragColor.a = fract(u_time);\n }\n // dash line\n if(u_line_type == LineTypeDash) {\n gl_FragColor.a *= blur * (1.0- step(v_dash_array.x, mod(v_distance_ratio, v_dash_array.x +v_dash_array.y)));\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; | ||
var line_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\nuniform float u_opacity : 1.0;\nvarying vec4 v_color;\nvarying vec2 v_normal;\n\n\n// dash\nuniform float u_dash_offset : 0.0;\nuniform float u_dash_ratio : 0.1;\nvarying float v_distance_ratio;\nvarying vec2 v_dash_array;\nvarying float v_side;\n\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n// [animate, duration, interval, trailLength],\nvoid main() {\n gl_FragColor = v_color;\n // anti-alias\n float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy)) * u_opacity;\n // gl_FragColor.a *= blur;\n\n if(u_aimate.x == Animate) {\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n gl_FragColor.a *= alpha * blur;\n }\n // dash line\n if(u_line_type == LineTypeDash) {\n gl_FragColor.a *= blur * (1.0- step(v_dash_array.x, mod(v_distance_ratio, v_dash_array.x +v_dash_array.y)));\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; | ||
var line_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\n// dash line\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\nuniform float u_line_type: 0.0;\nuniform vec2 u_dash_array: [10.0, 5.];\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\nvarying vec2 v_dash_array;\nvarying vec2 v_normal;\nvarying float v_distance_ratio;\nvarying float v_side;\n\n\nvoid main() {\n\n if(u_line_type == LineTypeDash) {\n v_distance_ratio = a_Distance / a_Total_Distance;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;\n }\n if(u_aimate.x == Animate) {\n v_distance_ratio = a_Distance / a_Total_Distance;\n }\n v_normal = vec2(reverse_offset_normal(a_Normal) * sign(a_Miter));\n v_color = a_Color;\n vec3 size = a_Miter * a_Size.x * reverse_offset_normal(a_Normal); //v_normal * vec3(1., -1., 1.0);\n vec2 offset = project_pixel(size.xy);\n v_side = a_Miter * a_Size.x;\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n"; | ||
@@ -12,0 +12,0 @@ var lineStyleObj = { |
@@ -10,3 +10,3 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
import { PointFillTriangulation } from '../../core/triangulation'; | ||
var pointFillFrag = "#define Animate 0.0\n\nuniform float u_blur : 0;\nuniform float u_opacity : 1;\nuniform float u_stroke_width : 1;\nuniform vec4 u_stroke_color : [0, 0, 0, 0];\nuniform float u_stroke_opacity : 1;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nvoid main() {\n int shape = int(floor(v_data.w + 0.5));\n\n lowp float antialiasblur = v_data.z;\n float antialiased_blur = -max(u_blur, antialiasblur);\n float r = v_radius / (v_radius + u_stroke_width);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n if (shape == 0) {\n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n } else if (shape == 1) {\n outer_df = sdEquilateralTriangle(1.1 * v_data.xy);\n inner_df = sdEquilateralTriangle(1.1 / r * v_data.xy);\n } else if (shape == 2) {\n outer_df = sdBox(v_data.xy, vec2(1.));\n inner_df = sdBox(v_data.xy, vec2(r));\n } else if (shape == 3) {\n outer_df = sdPentagon(v_data.xy, 0.8);\n inner_df = sdPentagon(v_data.xy, r * 0.8);\n } else if (shape == 4) {\n outer_df = sdHexagon(v_data.xy, 0.8);\n inner_df = sdHexagon(v_data.xy, r * 0.8);\n } else if (shape == 5) {\n outer_df = sdOctogon(v_data.xy, 1.0);\n inner_df = sdOctogon(v_data.xy, r);\n } else if (shape == 6) {\n outer_df = sdHexagram(v_data.xy, 0.52);\n inner_df = sdHexagram(v_data.xy, r * 0.52);\n } else if (shape == 7) {\n outer_df = sdRhombus(v_data.xy, vec2(1.0));\n inner_df = sdRhombus(v_data.xy, vec2(r));\n } else if (shape == 8) {\n outer_df = sdVesica(v_data.xy, 1.1, 0.8);\n inner_df = sdVesica(v_data.xy, r * 1.1, r * 0.8);\n }\n\n float opacity_t = smoothstep(0.0, antialiased_blur, outer_df);\n if(u_stroke_width <0.01 ) {\n gl_FragColor = v_color * opacity_t;\n return;\n }\n float color_t = u_stroke_width < 0.01 ? 0.0 : smoothstep(\n antialiased_blur,\n 0.0,\n inner_df\n );\n vec4 strokeColor = u_stroke_color == vec4(0) ? v_color : u_stroke_color;\n float PI = 3.14159;\n float N_RINGS = 3.0;\n float FREQ = 1.0;\n\n\n\n gl_FragColor = opacity_t * mix(vec4(v_color.rgb, v_color.a * u_opacity), strokeColor * u_stroke_opacity, color_t);\n\n if(u_aimate.x == Animate) {\n float d = length(v_data.xy);\n float intensity = clamp(cos(d * PI), 0.0, 1.0) * clamp(cos(2.0 * PI * (d * 2.0 * u_aimate.z - u_aimate.y * u_time)), 0.0, 1.0);\n gl_FragColor = vec4(gl_FragColor.xyz * intensity, intensity);\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; | ||
var pointFillFrag = "#define Animate 0.0\n\nuniform float u_blur : 0;\nuniform float u_opacity : 1;\nuniform float u_stroke_width : 1;\nuniform vec4 u_stroke_color : [0, 0, 0, 0];\nuniform float u_stroke_opacity : 1;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nvoid main() {\n int shape = int(floor(v_data.w + 0.5));\n\n lowp float antialiasblur = v_data.z;\n float antialiased_blur = -max(u_blur, antialiasblur);\n float r = v_radius / (v_radius + u_stroke_width);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n if (shape == 0) {\n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n } else if (shape == 1) {\n outer_df = sdEquilateralTriangle(1.1 * v_data.xy);\n inner_df = sdEquilateralTriangle(1.1 / r * v_data.xy);\n } else if (shape == 2) {\n outer_df = sdBox(v_data.xy, vec2(1.));\n inner_df = sdBox(v_data.xy, vec2(r));\n } else if (shape == 3) {\n outer_df = sdPentagon(v_data.xy, 0.8);\n inner_df = sdPentagon(v_data.xy, r * 0.8);\n } else if (shape == 4) {\n outer_df = sdHexagon(v_data.xy, 0.8);\n inner_df = sdHexagon(v_data.xy, r * 0.8);\n } else if (shape == 5) {\n outer_df = sdOctogon(v_data.xy, 1.0);\n inner_df = sdOctogon(v_data.xy, r);\n } else if (shape == 6) {\n outer_df = sdHexagram(v_data.xy, 0.52);\n inner_df = sdHexagram(v_data.xy, r * 0.52);\n } else if (shape == 7) {\n outer_df = sdRhombus(v_data.xy, vec2(1.0));\n inner_df = sdRhombus(v_data.xy, vec2(r));\n } else if (shape == 8) {\n outer_df = sdVesica(v_data.xy, 1.1, 0.8);\n inner_df = sdVesica(v_data.xy, r * 1.1, r * 0.8);\n }\n\n float opacity_t = smoothstep(0.0, antialiased_blur, outer_df);\n if(u_stroke_width <0.01 ) {\n gl_FragColor = v_color * opacity_t;\n return;\n }\n float color_t = u_stroke_width < 0.01 ? 0.0 : smoothstep(\n antialiased_blur,\n 0.0,\n inner_df\n );\n vec4 strokeColor = u_stroke_color == vec4(0) ? v_color : u_stroke_color;\n float PI = 3.14159;\n float N_RINGS = 3.0;\n float FREQ = 1.0;\n\n // gl_FragColor = v_color * color_t;\n // gl_FragColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), strokeColor * u_stroke_opacity, color_t);\n gl_FragColor = opacity_t * mix(vec4(v_color.rgb, v_color.a * u_opacity), strokeColor * u_stroke_opacity, color_t);\n\n if(u_aimate.x == Animate) {\n float d = length(v_data.xy);\n float intensity = clamp(cos(d * PI), 0.0, 1.0) * clamp(cos(2.0 * PI * (d * 2.0 * u_aimate.z - u_aimate.y * u_time)), 0.0, 1.0);\n gl_FragColor = vec4(gl_FragColor.xyz * intensity, intensity);\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; | ||
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec2 a_Extrude;\nattribute float a_Size;\nattribute float a_Shape;\nuniform mat4 u_ModelMatrix;\n\nuniform float u_stroke_width : 2;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // unpack color(vec2)\n v_color = a_Color;\n vec2 extrude = a_Extrude;\n\n float shape_type = a_Shape;\n\n // radius(16-bit)\n v_radius = a_Size;\n\n vec2 offset = project_pixel(extrude * (a_Size + u_stroke_width));\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n\n // TODO: billboard\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n // anti-alias\n float antialiasblur = 1.0 / (a_Size + u_stroke_width);\n\n // construct point coords\n v_data = vec4(extrude, antialiasblur,shape_type);\n\n setPickingColor(a_PickingColor);\n}\n"; | ||
@@ -13,0 +13,0 @@ |
@@ -60,3 +60,4 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
fontWeight = _ref$fontWeight === void 0 ? 800 : _ref$fontWeight, | ||
fontFamily = _ref.fontFamily, | ||
_ref$fontFamily = _ref.fontFamily, | ||
fontFamily = _ref$fontFamily === void 0 ? 'sans-serif' : _ref$fontFamily, | ||
_ref$stroke = _ref.stroke, | ||
@@ -63,0 +64,0 @@ stroke = _ref$stroke === void 0 ? '#fff' : _ref$stroke, |
@@ -17,2 +17,3 @@ import { IModel, ITexture2D } from '@antv/l7-core'; | ||
protected registerBuiltinAttributes(): void; | ||
private updateColorTexure; | ||
} |
@@ -48,2 +48,3 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
this.updateColorTexure(); | ||
return { | ||
@@ -115,2 +116,18 @@ u_opacity: opacity || 1, | ||
} | ||
}, { | ||
key: "updateColorTexure", | ||
value: function updateColorTexure() { | ||
var createTexture2D = this.rendererService.createTexture2D; | ||
var _ref3 = this.layer.getLayerConfig(), | ||
rampColors = _ref3.rampColors; | ||
var imageData = generateColorRamp(rampColors); | ||
this.colorTexture = createTexture2D({ | ||
data: imageData.data, | ||
width: imageData.width, | ||
height: imageData.height, | ||
flipY: true | ||
}); | ||
} | ||
}]); | ||
@@ -117,0 +134,0 @@ |
@@ -68,19 +68,2 @@ "use strict"; | ||
this.styleAttributeService.registerStyleAttribute({ | ||
name: 'size', | ||
type: _l7Core.AttributeType.Attribute, | ||
descriptor: { | ||
name: 'a_Size', | ||
buffer: { | ||
usage: _l7Core.gl.DYNAMIC_DRAW, | ||
data: [], | ||
type: _l7Core.gl.FLOAT | ||
}, | ||
size: 1, | ||
update: function update(feature, featureIdx, vertex, attributeIdx) { | ||
var size = feature.size; | ||
return Array.isArray(size) ? [size[0]] : [size]; | ||
} | ||
} | ||
}); | ||
this.styleAttributeService.registerStyleAttribute({ | ||
name: 'pos', | ||
@@ -87,0 +70,0 @@ type: _l7Core.AttributeType.Attribute, |
@@ -26,3 +26,3 @@ "use strict"; | ||
var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nuniform float u_opacity;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\nvarying vec2 v_normal;\nvarying vec2 v_dash_array;\nvarying float v_distance_ratio;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"picking\"\n\nvoid main() {\n gl_FragColor = v_color;\n float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n gl_FragColor.a *= (blur * u_opacity);\n if(u_line_type == LineTypeDash) {\n gl_FragColor.a *= blur * (1.0- step(v_dash_array.x, mod(v_distance_ratio, v_dash_array.x +v_dash_array.y)));\n // gl_FragColor.a =\n }\n\n if(u_aimate.x == Animate) {\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n // gl_FragColor.a = fract(u_time);\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; | ||
var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nuniform float u_opacity;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\nvarying vec2 v_normal;\nvarying vec2 v_dash_array;\nvarying float v_distance_ratio;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"picking\"\n\nvoid main() {\n gl_FragColor = v_color;\n float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n gl_FragColor.a *= (blur * u_opacity);\n if(u_line_type == LineTypeDash) {\n gl_FragColor.a *= blur * (1.0- step(v_dash_array.x, mod(v_distance_ratio, v_dash_array.x +v_dash_array.y)));\n }\n\n if(u_aimate.x == Animate) {\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; | ||
var line_arc_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute vec4 a_Color;\nattribute float a_Size;\n\nuniform mat4 u_ModelMatrix;\nuniform float segmentNumber;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nvarying vec4 v_color;\nvarying vec2 v_normal;\nvarying float v_distance_ratio;\nuniform float u_line_type: 0.0;\nuniform vec2 u_dash_array: [10.0, 5.];\n\nvarying vec2 v_dash_array;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat maps (float value, float start1, float stop1, float start2, float stop2) {\n return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.0));\n}\n\nfloat paraboloid(vec2 source, vec2 target, float ratio) {\n vec2 x = mix(source, target, ratio);\n vec2 center = mix(source, target, 0.5);\n float dSourceCenter = distance(source, center);\n float dXCenter = distance(x, center);\n return (dSourceCenter + dXCenter) * (dSourceCenter - dXCenter);\n}\n\nvec3 getPos(vec2 source, vec2 target, float segmentRatio) {\n float vertex_height = paraboloid(source, target, segmentRatio);\n\n return vec3(\n mix(source, target, segmentRatio),\n sqrt(max(0.0, vertex_height))\n );\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n\n vec2 offset = dir_screenspace * offset_direction * a_Size / 2.0;\n\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nvoid main() {\n v_color = a_Color;\n vec2 source = project_position(vec4(a_Instance.rg, 0, 0)).xy;\n vec2 target = project_position(vec4(a_Instance.ba, 0, 0)).xy;\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n\n if(u_line_type == LineTypeDash) {\n v_distance_ratio = segmentIndex / segmentNumber;\n float total_Distance = pixelDistance(a_Instance.rg, a_Instance.ba) / 2.0 * PI;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / (total_Distance / segmentNumber * segmentIndex);\n }\n if(u_aimate.x == Animate) {\n v_distance_ratio = segmentIndex / segmentNumber;\n }\n\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n vec3 curr = getPos(source, target, segmentRatio);\n vec3 next = getPos(source, target, nextSegmentRatio);\n vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y);\n v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n\n gl_Position = project_common_position_to_clipspace(vec4(curr.xy + project_pixel(offset), curr.z, 1.0));\n setPickingColor(a_PickingColor);\n}\n"; | ||
@@ -29,0 +29,0 @@ var lineStyleObj = { |
@@ -26,3 +26,3 @@ "use strict"; | ||
var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nuniform float u_opacity;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\nvarying vec2 v_normal;\nvarying vec2 v_dash_array;\nvarying float v_distance_ratio;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"picking\"\n\nvoid main() {\n gl_FragColor = v_color;\n float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n gl_FragColor.a *= (blur * u_opacity);\n if(u_line_type == LineTypeDash) {\n gl_FragColor.a *= blur * (1.0- step(v_dash_array.x, mod(v_distance_ratio, v_dash_array.x +v_dash_array.y)));\n // gl_FragColor.a =\n }\n\n if(u_aimate.x == Animate) {\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n // gl_FragColor.a = fract(u_time);\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; | ||
var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nuniform float u_opacity;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\nvarying vec2 v_normal;\nvarying vec2 v_dash_array;\nvarying float v_distance_ratio;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"picking\"\n\nvoid main() {\n gl_FragColor = v_color;\n float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n gl_FragColor.a *= (blur * u_opacity);\n if(u_line_type == LineTypeDash) {\n gl_FragColor.a *= blur * (1.0- step(v_dash_array.x, mod(v_distance_ratio, v_dash_array.x +v_dash_array.y)));\n }\n\n if(u_aimate.x == Animate) {\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; | ||
var line_arc2d_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\nuniform float segmentNumber;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nvarying vec4 v_color;\nvarying vec2 v_normal;\n\nvarying float v_distance_ratio;\nuniform float u_line_type: 0.0;\nuniform vec2 u_dash_array: [10.0, 5.];\nvarying vec2 v_dash_array;\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\nvec2 midPoint(vec2 source, vec2 target) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = 0.314;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);\n return mid;\n}\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n}\nvec2 interpolate (vec2 source, vec2 target, float t) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n vec2 mid = midPoint(source, target);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x ,t), bezier3(y,t));\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * a_Size / 2.0;\n return offset * vec2(1.0, -1.0);\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nvoid main() {\n v_color = a_Color;\n vec2 source = a_Instance.rg;\n vec2 target = a_Instance.ba;\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n if(u_line_type == LineTypeDash) {\n v_distance_ratio = segmentIndex / segmentNumber;\n float total_Distance = pixelDistance(a_Instance.rg, a_Instance.ba) / 2.0 * PI;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / (total_Distance / segmentNumber * segmentIndex);\n }\n if(u_aimate.x == Animate) {\n v_distance_ratio = segmentIndex / segmentNumber;\n }\n vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio), 0.0, 1.0));\n vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio), 0.0, 1.0));\n v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n\n gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, 0, 1.0));\n setPickingColor(a_PickingColor);\n}\n"; | ||
@@ -29,0 +29,0 @@ var lineStyleObj = { |
@@ -27,3 +27,3 @@ "use strict"; | ||
var line_arc2d_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\nuniform float segmentNumber;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nvarying vec4 v_color;\nvarying vec2 v_normal;\n\nvarying float v_distance_ratio;\nuniform float u_line_type: 0.0;\nuniform vec2 u_dash_array: [10.0, 5.];\nvarying vec2 v_dash_array;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat maps (float value, float start1, float stop1, float start2, float stop2) {\n return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n}\n\nfloat paraboloid(vec2 source, vec2 target, float ratio) {\n vec2 x = mix(source, target, ratio);\n vec2 center = mix(source, target, 0.5);\n float dSourceCenter = distance(source, center);\n float dXCenter = distance(x, center);\n return (dSourceCenter + dXCenter) * (dSourceCenter - dXCenter);\n}\n\nvec3 getPos(vec2 source, vec2 target, float segmentRatio) {\n float vertex_height = paraboloid(source, target, segmentRatio);\n\n return vec3(\n mix(source, target, segmentRatio),\n sqrt(max(0.0, vertex_height))\n );\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * a_Size / 2.0;\n return offset * vec2(1.0, -1.0);\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\nfloat getAngularDist (vec2 source, vec2 target) {\n vec2 delta = source - target;\n vec2 sin_half_delta = sin(delta / 2.0);\n float a =\n sin_half_delta.y * sin_half_delta.y +\n cos(source.y) * cos(target.y) *\n sin_half_delta.x * sin_half_delta.x;\n return 2.0 * atan(sqrt(a), sqrt(1.0 - a));\n}\nvec2 interpolate (vec2 source, vec2 target, float angularDist, float t) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n if(abs(angularDist - PI) < 0.001) {\n return (1.0 - t) * source + t * target;\n }\n float a = sin((1.0 - t) * angularDist) / sin(angularDist);\n float b = sin(t * angularDist) / sin(angularDist);\n vec2 sin_source = sin(source);\n vec2 cos_source = cos(source);\n vec2 sin_target = sin(target);\n vec2 cos_target = cos(target);\n float x = a * cos_source.y * cos_source.x + b * cos_target.y * cos_target.x;\n float y = a * cos_source.y * sin_source.x + b * cos_target.y * sin_target.x;\n float z = a * sin_source.y + b * sin_target.y;\n return vec2(atan(y, x), atan(z, sqrt(x * x + y * y)));\n}\n\nvoid main() {\n v_color = a_Color;\n vec2 source = radians(a_Instance.rg);\n vec2 target = radians(a_Instance.ba);\n float angularDist = getAngularDist(source, target);\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n if(u_line_type == LineTypeDash) {\n v_distance_ratio = segmentIndex / segmentNumber;\n float total_Distance = pixelDistance(a_Instance.rg, a_Instance.ba);\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / (total_Distance / segmentNumber * segmentIndex);\n }\n if(u_aimate.x == Animate) {\n v_distance_ratio = segmentIndex / segmentNumber;\n }\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n v_distance_ratio = segmentIndex / segmentNumber;\n vec4 curr = project_position(vec4(degrees(interpolate(source, target, angularDist, segmentRatio)), 0.0, 1.0));\n vec4 next = project_position(vec4(degrees(interpolate(source, target, angularDist, nextSegmentRatio)), 0.0, 1.0));\n v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n // vec4 project_pos = project_position(vec4(curr.xy, 0, 1.0));\n gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, curr.z, 1.0));\n setPickingColor(a_PickingColor);\n}\n\n"; | ||
var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nuniform float u_opacity;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\nvarying vec2 v_normal;\nvarying vec2 v_dash_array;\nvarying float v_distance_ratio;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"picking\"\n\nvoid main() {\n gl_FragColor = v_color;\n float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n gl_FragColor.a *= (blur * u_opacity);\n if(u_line_type == LineTypeDash) {\n gl_FragColor.a *= blur * (1.0- step(v_dash_array.x, mod(v_distance_ratio, v_dash_array.x +v_dash_array.y)));\n // gl_FragColor.a =\n }\n\n if(u_aimate.x == Animate) {\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n // gl_FragColor.a = fract(u_time);\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; | ||
var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nuniform float u_opacity;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\nvarying vec2 v_normal;\nvarying vec2 v_dash_array;\nvarying float v_distance_ratio;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"picking\"\n\nvoid main() {\n gl_FragColor = v_color;\n float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n gl_FragColor.a *= (blur * u_opacity);\n if(u_line_type == LineTypeDash) {\n gl_FragColor.a *= blur * (1.0- step(v_dash_array.x, mod(v_distance_ratio, v_dash_array.x +v_dash_array.y)));\n }\n\n if(u_aimate.x == Animate) {\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; | ||
var lineStyleObj = { | ||
@@ -30,0 +30,0 @@ solid: 0.0, |
@@ -26,3 +26,3 @@ "use strict"; | ||
var line_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\nuniform float u_opacity : 1.0;\nvarying vec4 v_color;\nvarying vec2 v_normal;\n\n\n// dash\nuniform float u_dash_offset : 0.0;\nuniform float u_dash_ratio : 0.1;\nvarying float v_distance_ratio;\nvarying vec2 v_dash_array;\nvarying float v_side;\n\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n// [animate, duration, interval, trailLength],\nvoid main() {\n gl_FragColor = v_color;\n // anti-alias\n float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy)) * u_opacity;\n // gl_FragColor.a *= blur;\n\n if(u_aimate.x == Animate) {\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n // float alpha2 = exp(-abs(v_side));\n gl_FragColor.a *= alpha * blur;\n // gl_FragColor.a = fract(u_time);\n }\n // dash line\n if(u_line_type == LineTypeDash) {\n gl_FragColor.a *= blur * (1.0- step(v_dash_array.x, mod(v_distance_ratio, v_dash_array.x +v_dash_array.y)));\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; | ||
var line_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\nuniform float u_opacity : 1.0;\nvarying vec4 v_color;\nvarying vec2 v_normal;\n\n\n// dash\nuniform float u_dash_offset : 0.0;\nuniform float u_dash_ratio : 0.1;\nvarying float v_distance_ratio;\nvarying vec2 v_dash_array;\nvarying float v_side;\n\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n// [animate, duration, interval, trailLength],\nvoid main() {\n gl_FragColor = v_color;\n // anti-alias\n float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy)) * u_opacity;\n // gl_FragColor.a *= blur;\n\n if(u_aimate.x == Animate) {\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n gl_FragColor.a *= alpha * blur;\n }\n // dash line\n if(u_line_type == LineTypeDash) {\n gl_FragColor.a *= blur * (1.0- step(v_dash_array.x, mod(v_distance_ratio, v_dash_array.x +v_dash_array.y)));\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; | ||
var line_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\n// dash line\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\nuniform float u_line_type: 0.0;\nuniform vec2 u_dash_array: [10.0, 5.];\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\nvarying vec2 v_dash_array;\nvarying vec2 v_normal;\nvarying float v_distance_ratio;\nvarying float v_side;\n\n\nvoid main() {\n\n if(u_line_type == LineTypeDash) {\n v_distance_ratio = a_Distance / a_Total_Distance;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;\n }\n if(u_aimate.x == Animate) {\n v_distance_ratio = a_Distance / a_Total_Distance;\n }\n v_normal = vec2(reverse_offset_normal(a_Normal) * sign(a_Miter));\n v_color = a_Color;\n vec3 size = a_Miter * a_Size.x * reverse_offset_normal(a_Normal); //v_normal * vec3(1., -1., 1.0);\n vec2 offset = project_pixel(size.xy);\n v_side = a_Miter * a_Size.x;\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n"; | ||
@@ -29,0 +29,0 @@ var lineStyleObj = { |
@@ -28,3 +28,3 @@ "use strict"; | ||
var pointFillFrag = "#define Animate 0.0\n\nuniform float u_blur : 0;\nuniform float u_opacity : 1;\nuniform float u_stroke_width : 1;\nuniform vec4 u_stroke_color : [0, 0, 0, 0];\nuniform float u_stroke_opacity : 1;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nvoid main() {\n int shape = int(floor(v_data.w + 0.5));\n\n lowp float antialiasblur = v_data.z;\n float antialiased_blur = -max(u_blur, antialiasblur);\n float r = v_radius / (v_radius + u_stroke_width);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n if (shape == 0) {\n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n } else if (shape == 1) {\n outer_df = sdEquilateralTriangle(1.1 * v_data.xy);\n inner_df = sdEquilateralTriangle(1.1 / r * v_data.xy);\n } else if (shape == 2) {\n outer_df = sdBox(v_data.xy, vec2(1.));\n inner_df = sdBox(v_data.xy, vec2(r));\n } else if (shape == 3) {\n outer_df = sdPentagon(v_data.xy, 0.8);\n inner_df = sdPentagon(v_data.xy, r * 0.8);\n } else if (shape == 4) {\n outer_df = sdHexagon(v_data.xy, 0.8);\n inner_df = sdHexagon(v_data.xy, r * 0.8);\n } else if (shape == 5) {\n outer_df = sdOctogon(v_data.xy, 1.0);\n inner_df = sdOctogon(v_data.xy, r);\n } else if (shape == 6) {\n outer_df = sdHexagram(v_data.xy, 0.52);\n inner_df = sdHexagram(v_data.xy, r * 0.52);\n } else if (shape == 7) {\n outer_df = sdRhombus(v_data.xy, vec2(1.0));\n inner_df = sdRhombus(v_data.xy, vec2(r));\n } else if (shape == 8) {\n outer_df = sdVesica(v_data.xy, 1.1, 0.8);\n inner_df = sdVesica(v_data.xy, r * 1.1, r * 0.8);\n }\n\n float opacity_t = smoothstep(0.0, antialiased_blur, outer_df);\n if(u_stroke_width <0.01 ) {\n gl_FragColor = v_color * opacity_t;\n return;\n }\n float color_t = u_stroke_width < 0.01 ? 0.0 : smoothstep(\n antialiased_blur,\n 0.0,\n inner_df\n );\n vec4 strokeColor = u_stroke_color == vec4(0) ? v_color : u_stroke_color;\n float PI = 3.14159;\n float N_RINGS = 3.0;\n float FREQ = 1.0;\n\n\n\n gl_FragColor = opacity_t * mix(vec4(v_color.rgb, v_color.a * u_opacity), strokeColor * u_stroke_opacity, color_t);\n\n if(u_aimate.x == Animate) {\n float d = length(v_data.xy);\n float intensity = clamp(cos(d * PI), 0.0, 1.0) * clamp(cos(2.0 * PI * (d * 2.0 * u_aimate.z - u_aimate.y * u_time)), 0.0, 1.0);\n gl_FragColor = vec4(gl_FragColor.xyz * intensity, intensity);\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; | ||
var pointFillFrag = "#define Animate 0.0\n\nuniform float u_blur : 0;\nuniform float u_opacity : 1;\nuniform float u_stroke_width : 1;\nuniform vec4 u_stroke_color : [0, 0, 0, 0];\nuniform float u_stroke_opacity : 1;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nvoid main() {\n int shape = int(floor(v_data.w + 0.5));\n\n lowp float antialiasblur = v_data.z;\n float antialiased_blur = -max(u_blur, antialiasblur);\n float r = v_radius / (v_radius + u_stroke_width);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n if (shape == 0) {\n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n } else if (shape == 1) {\n outer_df = sdEquilateralTriangle(1.1 * v_data.xy);\n inner_df = sdEquilateralTriangle(1.1 / r * v_data.xy);\n } else if (shape == 2) {\n outer_df = sdBox(v_data.xy, vec2(1.));\n inner_df = sdBox(v_data.xy, vec2(r));\n } else if (shape == 3) {\n outer_df = sdPentagon(v_data.xy, 0.8);\n inner_df = sdPentagon(v_data.xy, r * 0.8);\n } else if (shape == 4) {\n outer_df = sdHexagon(v_data.xy, 0.8);\n inner_df = sdHexagon(v_data.xy, r * 0.8);\n } else if (shape == 5) {\n outer_df = sdOctogon(v_data.xy, 1.0);\n inner_df = sdOctogon(v_data.xy, r);\n } else if (shape == 6) {\n outer_df = sdHexagram(v_data.xy, 0.52);\n inner_df = sdHexagram(v_data.xy, r * 0.52);\n } else if (shape == 7) {\n outer_df = sdRhombus(v_data.xy, vec2(1.0));\n inner_df = sdRhombus(v_data.xy, vec2(r));\n } else if (shape == 8) {\n outer_df = sdVesica(v_data.xy, 1.1, 0.8);\n inner_df = sdVesica(v_data.xy, r * 1.1, r * 0.8);\n }\n\n float opacity_t = smoothstep(0.0, antialiased_blur, outer_df);\n if(u_stroke_width <0.01 ) {\n gl_FragColor = v_color * opacity_t;\n return;\n }\n float color_t = u_stroke_width < 0.01 ? 0.0 : smoothstep(\n antialiased_blur,\n 0.0,\n inner_df\n );\n vec4 strokeColor = u_stroke_color == vec4(0) ? v_color : u_stroke_color;\n float PI = 3.14159;\n float N_RINGS = 3.0;\n float FREQ = 1.0;\n\n // gl_FragColor = v_color * color_t;\n // gl_FragColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), strokeColor * u_stroke_opacity, color_t);\n gl_FragColor = opacity_t * mix(vec4(v_color.rgb, v_color.a * u_opacity), strokeColor * u_stroke_opacity, color_t);\n\n if(u_aimate.x == Animate) {\n float d = length(v_data.xy);\n float intensity = clamp(cos(d * PI), 0.0, 1.0) * clamp(cos(2.0 * PI * (d * 2.0 * u_aimate.z - u_aimate.y * u_time)), 0.0, 1.0);\n gl_FragColor = vec4(gl_FragColor.xyz * intensity, intensity);\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; | ||
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec2 a_Extrude;\nattribute float a_Size;\nattribute float a_Shape;\nuniform mat4 u_ModelMatrix;\n\nuniform float u_stroke_width : 2;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // unpack color(vec2)\n v_color = a_Color;\n vec2 extrude = a_Extrude;\n\n float shape_type = a_Shape;\n\n // radius(16-bit)\n v_radius = a_Size;\n\n vec2 offset = project_pixel(extrude * (a_Size + u_stroke_width));\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n\n // TODO: billboard\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n // anti-alias\n float antialiasblur = 1.0 / (a_Size + u_stroke_width);\n\n // construct point coords\n v_data = vec4(extrude, antialiasblur,shape_type);\n\n setPickingColor(a_PickingColor);\n}\n"; | ||
@@ -31,0 +31,0 @@ |
@@ -83,3 +83,4 @@ "use strict"; | ||
fontWeight = _ref$fontWeight === void 0 ? 800 : _ref$fontWeight, | ||
fontFamily = _ref.fontFamily, | ||
_ref$fontFamily = _ref.fontFamily, | ||
fontFamily = _ref$fontFamily === void 0 ? 'sans-serif' : _ref$fontFamily, | ||
_ref$stroke = _ref.stroke, | ||
@@ -86,0 +87,0 @@ stroke = _ref$stroke === void 0 ? '#fff' : _ref$stroke, |
@@ -66,2 +66,3 @@ "use strict"; | ||
this.updateColorTexure(); | ||
return { | ||
@@ -133,2 +134,18 @@ u_opacity: opacity || 1, | ||
} | ||
}, { | ||
key: "updateColorTexure", | ||
value: function updateColorTexure() { | ||
var createTexture2D = this.rendererService.createTexture2D; | ||
var _ref3 = this.layer.getLayerConfig(), | ||
rampColors = _ref3.rampColors; | ||
var imageData = (0, _l7Utils.generateColorRamp)(rampColors); | ||
this.colorTexture = createTexture2D({ | ||
data: imageData.data, | ||
width: imageData.width, | ||
height: imageData.height, | ||
flipY: true | ||
}); | ||
} | ||
}]); | ||
@@ -135,0 +152,0 @@ return RasterModel; |
{ | ||
"name": "@antv/l7-layers", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "L7's collection of built-in layers", | ||
@@ -25,5 +25,5 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@antv/l7-core": "^2.0.0", | ||
"@antv/l7-source": "^2.0.0", | ||
"@antv/l7-utils": "^2.0.0", | ||
"@antv/l7-core": "^2.0.1", | ||
"@antv/l7-source": "^2.0.1", | ||
"@antv/l7-utils": "^2.0.1", | ||
"@babel/runtime": "^7.7.7", | ||
@@ -53,3 +53,3 @@ "@mapbox/martini": "^0.1.0", | ||
}, | ||
"gitHead": "74cd35b7f6bcec20576a55456d349b9d59919f74", | ||
"gitHead": "5a24eff0bcd2ae3983dac09331689fc712d73abc", | ||
"publishConfig": { | ||
@@ -56,0 +56,0 @@ "access": "public" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
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
14268
19
1428914
Updated@antv/l7-core@^2.0.1
Updated@antv/l7-source@^2.0.1
Updated@antv/l7-utils@^2.0.1