@antv/l7-core
Advanced tools
Comparing version 2.0.27-alpha.0 to 2.0.28-alpha.0
@@ -0,3 +1,3 @@ | ||
import { SyncBailHook, SyncHook, SyncWaterfallHook } from '@antv/async-hook'; | ||
import { Container } from 'inversify'; | ||
import { SyncBailHook, SyncHook, SyncWaterfallHook } from 'tapable'; | ||
import Clock from '../../utils/clock'; | ||
@@ -70,15 +70,15 @@ import { ISceneConfig } from '../config/IConfigService'; | ||
hooks: { | ||
init: SyncBailHook<void, boolean | void>; | ||
afterInit: SyncBailHook<void, boolean | void>; | ||
beforeRenderData: SyncWaterfallHook<boolean | void>; | ||
beforeRender: SyncBailHook<void, boolean | void>; | ||
afterRender: SyncHook<void>; | ||
beforePickingEncode: SyncHook<void>; | ||
afterPickingEncode: SyncHook<void>; | ||
beforeHighlight: SyncHook<[number[]]>; | ||
beforeSelect: SyncHook<[number[]]>; | ||
afterSelect: SyncHook<void>; | ||
afterHighlight: SyncHook<void>; | ||
beforeDestroy: SyncHook<void>; | ||
afterDestroy: SyncHook<void>; | ||
init: SyncBailHook; | ||
afterInit: SyncBailHook; | ||
beforeRenderData: SyncWaterfallHook; | ||
beforeRender: SyncBailHook; | ||
afterRender: SyncHook; | ||
beforePickingEncode: SyncHook; | ||
afterPickingEncode: SyncHook; | ||
beforeHighlight: SyncHook; | ||
beforeSelect: SyncHook; | ||
afterSelect: SyncHook; | ||
afterHighlight: SyncHook; | ||
beforeDestroy: SyncHook; | ||
afterDestroy: SyncHook; | ||
}; | ||
@@ -85,0 +85,0 @@ models: IModel[]; |
@@ -99,3 +99,3 @@ import _initializerDefineProperty from "@babel/runtime/helpers/initializerDefineProperty"; | ||
}).forEach(function (layer) { | ||
layer.hooks.beforeRenderData.call(true); | ||
layer.hooks.beforeRenderData.call(); | ||
layer.hooks.beforeRender.call(); | ||
@@ -102,0 +102,0 @@ layer.render(); |
@@ -15,2 +15,3 @@ import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
import { AsyncParallelHook } from '@antv/async-hook'; | ||
import { DOM } from '@antv/l7-utils'; | ||
@@ -20,3 +21,2 @@ import elementResizeEvent, { unbind } from 'element-resize-event'; | ||
import { inject, injectable } from 'inversify'; | ||
import { AsyncParallelHook } from 'tapable'; | ||
import { TYPES } from '../../types'; | ||
@@ -108,3 +108,3 @@ import { createRendererContainer } from '../../utils/dom'; | ||
_this.hooks = { | ||
init: new AsyncParallelHook(['config']) | ||
init: new AsyncParallelHook() | ||
}; | ||
@@ -111,0 +111,0 @@ return _this; |
@@ -15,10 +15,10 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
var common = "#define PI 3.14159265359"; | ||
var decode = "#define SHIFT_RIGHT17 1.0 / 131072.0\n#define SHIFT_RIGHT18 1.0 / 262144.0\n#define SHIFT_RIGHT19 1.0 / 524288.0\n#define SHIFT_RIGHT20 1.0 / 1048576.0\n#define SHIFT_RIGHT21 1.0 / 2097152.0\n#define SHIFT_RIGHT22 1.0 / 4194304.0\n#define SHIFT_RIGHT23 1.0 / 8388608.0\n#define SHIFT_RIGHT24 1.0 / 16777216.0\n\n#define SHIFT_LEFT17 131072.0\n#define SHIFT_LEFT18 262144.0\n#define SHIFT_LEFT19 524288.0\n#define SHIFT_LEFT20 1048576.0\n#define SHIFT_LEFT21 2097152.0\n#define SHIFT_LEFT22 4194304.0\n#define SHIFT_LEFT23 8388608.0\n#define SHIFT_LEFT24 16777216.0\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\n\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}"; | ||
var decode = "#define SHIFT_RIGHT17 1.0 / 131072.0\n#define SHIFT_RIGHT18 1.0 / 262144.0\n#define SHIFT_RIGHT19 1.0 / 524288.0\n#define SHIFT_RIGHT20 1.0 / 1048576.0\n#define SHIFT_RIGHT21 1.0 / 2097152.0\n#define SHIFT_RIGHT22 1.0 / 4194304.0\n#define SHIFT_RIGHT23 1.0 / 8388608.0\n#define SHIFT_RIGHT24 1.0 / 16777216.0\n\n#define SHIFT_LEFT17 131072.0\n#define SHIFT_LEFT18 262144.0\n#define SHIFT_LEFT19 524288.0\n#define SHIFT_LEFT20 1048576.0\n#define SHIFT_LEFT21 2097152.0\n#define SHIFT_LEFT22 4194304.0\n#define SHIFT_LEFT23 8388608.0\n#define SHIFT_LEFT24 16777216.0\n\nvec2 unpack_float(float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\n\nvec4 decode_color(vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\n"; | ||
var light = "#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\n\nfloat calc_lighting(vec4 pos) {\n\n vec3 worldPos = vec3(pos * u_ModelMatrix);\n\n vec3 worldNormal = a_Normal;\n // //cal light weight\n vec3 viewDir = normalize(u_CameraPosition - worldPos);\n\n vec3 lightDir = normalize(reverse_offset_normal(vec3(1, 10.5, 12)));\n\n vec3 halfDir = normalize(viewDir+lightDir);\n // //lambert\n float lambert = dot(worldNormal, lightDir);\n //specular\n float specular = pow(max(0.0, dot(worldNormal, halfDir)), 32.0);\n //sum to light weight\n float lightWeight = ambientRatio + diffuseRatio * lambert + specularRatio * specular;\n\n return lightWeight;\n}\n"; | ||
var lighting = "// Blinn-Phong model\n// apply lighting in vertex shader instead of fragment shader\n// @see https://learnopengl.com/Advanced-Lighting/Advanced-Lighting\nuniform float u_Ambient : 1.0;\nuniform float u_Diffuse : 1.0;\nuniform float u_Specular : 1.0;\nuniform int u_NumOfDirectionalLights : 1;\nuniform int u_NumOfSpotLights : 0;\n\n#define SHININESS 32.0\n#define MAX_NUM_OF_DIRECTIONAL_LIGHTS 3\n#define MAX_NUM_OF_SPOT_LIGHTS 3\n\nstruct DirectionalLight {\n vec3 direction;\n vec3 ambient;\n vec3 diffuse;\n vec3 specular;\n};\n\nstruct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 ambient;\n vec3 diffuse;\n vec3 specular;\n float constant;\n float linear;\n float quadratic;\n float angle;\n float blur;\n float exponent;\n};\n\nuniform DirectionalLight u_DirectionalLights[MAX_NUM_OF_DIRECTIONAL_LIGHTS];\nuniform SpotLight u_SpotLights[MAX_NUM_OF_SPOT_LIGHTS];\n\nvec3 calc_directional_light(DirectionalLight light, vec3 normal, vec3 viewDir) {\n vec3 lightDir = normalize(light.direction);\n // diffuse shading\n float diff = max(dot(normal, lightDir), 0.0);\n // Blinn-Phong specular shading\n vec3 halfwayDir = normalize(lightDir + viewDir);\n float spec = pow(max(dot(normal, halfwayDir), 0.0), SHININESS);\n\n vec3 ambient = light.ambient * u_Ambient;\n vec3 diffuse = light.diffuse * diff * u_Diffuse;\n vec3 specular = light.specular * spec * u_Specular;\n\n return ambient + diffuse + specular;\n}\n\n// vec3 calc_spot_light(SpotLight light, vec3 normal, vec3 fragPos, vec3 viewDir) {\n// vec3 lightDir = normalize(light.position - fragPos);\n// // diffuse shading\n// float diff = max(dot(normal, lightDir), 0.0);\n// // specular shading\n// vec3 reflectDir = reflect(-lightDir, normal);\n// float spec = pow(max(dot(viewDir, reflectDir), 0.0), SHININESS);\n// // attenuation\n// float distance = length(light.position - fragPos);\n// float attenuation = 1.0 / (light.constant + light.linear * distance + \n// light.quadratic * (distance * distance)); \n\n// vec3 ambient = light.ambient * u_Ambient;\n// vec3 diffuse = light.diffuse * diff * u_Diffuse;\n// vec3 specular = light.specular * spec * u_Specular;\n\n// float spotEffect = dot(normalize(light.direction), -lightDir);\n// float spotCosCutoff = cos(light.angle / 180.0 * PI);\n// float spotCosOuterCutoff = cos((light.angle + light.blur) / 180.0 * PI);\n// float spotCosInnerCutoff = cos((light.angle - light.blur) / 180.0 * PI);\n// if (spotEffect > spotCosCutoff) {\n// spotEffect = pow(smoothstep(spotCosOuterCutoff, spotCosInnerCutoff, spotEffect), light.exponent);\n// } else {\n// spotEffect = 0.0;\n// }\n\n// return ambient + attenuation * (spotEffect * diffuse + specular);\n// }\n\nvec3 calc_lighting(vec3 position, vec3 normal, vec3 viewDir) {\n vec3 weight = vec3(0.0);\n for (int i = 0; i < MAX_NUM_OF_DIRECTIONAL_LIGHTS; i++) {\n if (i >= u_NumOfDirectionalLights) {\n break;\n }\n weight += calc_directional_light(u_DirectionalLights[i], normal, viewDir);\n }\n // for (int i = 0; i < MAX_NUM_OF_SPOT_LIGHTS; i++) {\n // if (i >= u_NumOfSpotLights) {\n // break;\n // }\n // weight += calc_spot_light(u_SpotLights[i], normal, position, viewDir);\n // }\n return weight;\n}"; | ||
var lighting = "// Blinn-Phong model\n// apply lighting in vertex shader instead of fragment shader\n// @see https://learnopengl.com/Advanced-Lighting/Advanced-Lighting\nuniform float u_Ambient : 1.0;\nuniform float u_Diffuse : 1.0;\nuniform float u_Specular : 1.0;\nuniform int u_NumOfDirectionalLights : 1;\nuniform int u_NumOfSpotLights : 0;\n\n#define SHININESS 32.0\n#define MAX_NUM_OF_DIRECTIONAL_LIGHTS 3\n#define MAX_NUM_OF_SPOT_LIGHTS 3\n\nstruct DirectionalLight {\n vec3 direction;\n vec3 ambient;\n vec3 diffuse;\n vec3 specular;\n};\n\nstruct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 ambient;\n vec3 diffuse;\n vec3 specular;\n float constant;\n float linear;\n float quadratic;\n float angle;\n float blur;\n float exponent;\n};\n\nuniform DirectionalLight u_DirectionalLights[MAX_NUM_OF_DIRECTIONAL_LIGHTS];\nuniform SpotLight u_SpotLights[MAX_NUM_OF_SPOT_LIGHTS];\n\nvec3 calc_directional_light(DirectionalLight light, vec3 normal, vec3 viewDir) {\n vec3 lightDir = normalize(light.direction);\n // diffuse shading\n float diff = max(dot(normal, lightDir), 0.0);\n // Blinn-Phong specular shading\n vec3 halfwayDir = normalize(lightDir + viewDir);\n float spec = pow(max(dot(normal, halfwayDir), 0.0), SHININESS);\n\n vec3 ambient = light.ambient * u_Ambient;\n vec3 diffuse = light.diffuse * diff * u_Diffuse;\n vec3 specular = light.specular * spec * u_Specular;\n\n return ambient + diffuse + specular;\n}\n\n// vec3 calc_spot_light(SpotLight light, vec3 normal, vec3 fragPos, vec3 viewDir) {\n// vec3 lightDir = normalize(light.position - fragPos);\n// // diffuse shading\n// float diff = max(dot(normal, lightDir), 0.0);\n// // specular shading\n// vec3 reflectDir = reflect(-lightDir, normal);\n// float spec = pow(max(dot(viewDir, reflectDir), 0.0), SHININESS);\n// // attenuation\n// float distance = length(light.position - fragPos);\n// float attenuation = 1.0 / (light.constant + light.linear * distance +\n// light.quadratic * (distance * distance));\n\n// vec3 ambient = light.ambient * u_Ambient;\n// vec3 diffuse = light.diffuse * diff * u_Diffuse;\n// vec3 specular = light.specular * spec * u_Specular;\n\n// float spotEffect = dot(normalize(light.direction), -lightDir);\n// float spotCosCutoff = cos(light.angle / 180.0 * PI);\n// float spotCosOuterCutoff = cos((light.angle + light.blur) / 180.0 * PI);\n// float spotCosInnerCutoff = cos((light.angle - light.blur) / 180.0 * PI);\n// if (spotEffect > spotCosCutoff) {\n// spotEffect = pow(smoothstep(spotCosOuterCutoff, spotCosInnerCutoff, spotEffect), light.exponent);\n// } else {\n// spotEffect = 0.0;\n// }\n\n// return ambient + attenuation * (spotEffect * diffuse + specular);\n// }\n\nvec3 calc_lighting(vec3 position, vec3 normal, vec3 viewDir) {\n vec3 weight = vec3(0.0);\n for (int i = 0; i < MAX_NUM_OF_DIRECTIONAL_LIGHTS; i++) {\n if (i >= u_NumOfDirectionalLights) {\n break;\n }\n weight += calc_directional_light(u_DirectionalLights[i], normal, viewDir);\n }\n // for (int i = 0; i < MAX_NUM_OF_SPOT_LIGHTS; i++) {\n // if (i >= u_NumOfSpotLights) {\n // break;\n // }\n // weight += calc_spot_light(u_SpotLights[i], normal, position, viewDir);\n // }\n return weight;\n}\n"; | ||
var pickingFrag = "varying vec4 v_PickingResult;\nuniform vec4 u_HighlightColor : [0, 0, 0, 0];\nuniform float u_PickingStage : 0.0;\n\n#define PICKING_NONE 0.0\n#define PICKING_ENCODE 1.0\n#define PICKING_HIGHLIGHT 2.0\n#define COLOR_SCALE 1. / 255.\n\n/*\n * Returns highlight color if this item is selected.\n */\nvec4 filterHighlightColor(vec4 color) {\n bool selected = bool(v_PickingResult.a);\n\n if (selected) {\n vec4 highLightColor = u_HighlightColor * COLOR_SCALE;\n\n float highLightAlpha = highLightColor.a;\n float highLightRatio = highLightAlpha / (highLightAlpha + color.a * (1.0 - highLightAlpha));\n\n vec3 resultRGB = mix(color.rgb, highLightColor.rgb, highLightRatio);\n return vec4(resultRGB, color.a);\n } else {\n return color;\n }\n}\n\n/*\n * Returns picking color if picking enabled else unmodified argument.\n */\nvec4 filterPickingColor(vec4 color) {\n vec3 pickingColor = v_PickingResult.rgb;\n if (u_PickingStage == PICKING_ENCODE && length(pickingColor) < 0.001) {\n discard;\n }\n return u_PickingStage == PICKING_ENCODE ? vec4(pickingColor, 1.0) : color;\n}\n\n/*\n * Returns picking color if picking is enabled if not\n * highlight color if this item is selected, otherwise unmodified argument.\n */\nvec4 filterColor(vec4 color) {\n return filterPickingColor(filterHighlightColor(color));\n}\n"; | ||
var pickingVert = "attribute vec3 a_PickingColor;\nvarying vec4 v_PickingResult;\n\nuniform vec3 u_PickingColor : [0, 0, 0];\nuniform vec4 u_HighlightColor : [0, 0, 0, 0];\nuniform float u_PickingStage : 0.0;\nuniform float u_PickingThreshold : 1.0;\n\n#define PICKING_NONE 0.0\n#define PICKING_ENCODE 1.0\n#define PICKING_HIGHLIGHT 2.0\n#define COLOR_SCALE 1. / 255.\n\nbool isVertexPicked(vec3 vertexColor) {\n return\n abs(vertexColor.r - u_PickingColor.r) < u_PickingThreshold &&\n abs(vertexColor.g - u_PickingColor.g) < u_PickingThreshold &&\n abs(vertexColor.b - u_PickingColor.b) < u_PickingThreshold;\n}\n\nvoid setPickingColor(vec3 pickingColor) {\n // compares only in highlight stage\n v_PickingResult.a = float((u_PickingStage == PICKING_HIGHLIGHT) && isVertexPicked(pickingColor));\n\n // Stores the picking color so that the fragment shader can render it during picking\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n"; | ||
var 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\nfloat pixelDistance(vec2 from, vec2 to) {\n vec2 a1 = ProjectFlat(from);\n vec2 b1 = ProjectFlat(to);\n return distance(a1, b1);\n}\n"; | ||
var 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}\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 || 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 || 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 * -1.;\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"; | ||
var 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}"; | ||
var 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 + 0.01 && u_CoordinateSystem >COORDINATE_SYSTEM_LNGLAT - 0.01\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 float a = COORDINATE_SYSTEM_LNGLAT_OFFSET;\n float b = COORDINATE_SYSTEM_P20_OFFSET;\n float c = COORDINATE_SYSTEM_LNGLAT;\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 if (u_CoordinateSystem < COORDINATE_SYSTEM_LNGLAT + 0.01 && u_CoordinateSystem >COORDINATE_SYSTEM_LNGLAT - 0.01) {\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 return position;\n\n // TODO: \u74E6\u7247\u5750\u6807\u7CFB & \u5E38\u89C4\u4E16\u754C\u5750\u6807\u7CFB\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 || 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 || 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 * -1.;\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\n\nbool isEqual( float a, float b) {\n return a< b + 0.001 && a > b - 0.001;\n}\n\n"; | ||
var 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 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 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 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 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 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}\n"; | ||
var precisionRegExp = /precision\s+(high|low|medium)p\s+float/; | ||
@@ -25,0 +25,0 @@ var globalDefaultprecision = '#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n #else\n precision mediump float;\n#endif\n'; |
@@ -112,3 +112,3 @@ "use strict"; | ||
}).forEach(function (layer) { | ||
layer.hooks.beforeRenderData.call(true); | ||
layer.hooks.beforeRenderData.call(); | ||
layer.hooks.beforeRender.call(); | ||
@@ -115,0 +115,0 @@ layer.render(); |
@@ -34,2 +34,4 @@ "use strict"; | ||
var _asyncHook = require("@antv/async-hook"); | ||
var _l7Utils = require("@antv/l7-utils"); | ||
@@ -43,4 +45,2 @@ | ||
var _tapable = require("tapable"); | ||
var _types = require("../../types"); | ||
@@ -119,3 +119,3 @@ | ||
_this.hooks = { | ||
init: new _tapable.AsyncParallelHook(['config']) | ||
init: new _asyncHook.AsyncParallelHook() | ||
}; | ||
@@ -122,0 +122,0 @@ return _this; |
@@ -29,10 +29,10 @@ "use strict"; | ||
var common = "#define PI 3.14159265359"; | ||
var decode = "#define SHIFT_RIGHT17 1.0 / 131072.0\n#define SHIFT_RIGHT18 1.0 / 262144.0\n#define SHIFT_RIGHT19 1.0 / 524288.0\n#define SHIFT_RIGHT20 1.0 / 1048576.0\n#define SHIFT_RIGHT21 1.0 / 2097152.0\n#define SHIFT_RIGHT22 1.0 / 4194304.0\n#define SHIFT_RIGHT23 1.0 / 8388608.0\n#define SHIFT_RIGHT24 1.0 / 16777216.0\n\n#define SHIFT_LEFT17 131072.0\n#define SHIFT_LEFT18 262144.0\n#define SHIFT_LEFT19 524288.0\n#define SHIFT_LEFT20 1048576.0\n#define SHIFT_LEFT21 2097152.0\n#define SHIFT_LEFT22 4194304.0\n#define SHIFT_LEFT23 8388608.0\n#define SHIFT_LEFT24 16777216.0\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\n\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}"; | ||
var decode = "#define SHIFT_RIGHT17 1.0 / 131072.0\n#define SHIFT_RIGHT18 1.0 / 262144.0\n#define SHIFT_RIGHT19 1.0 / 524288.0\n#define SHIFT_RIGHT20 1.0 / 1048576.0\n#define SHIFT_RIGHT21 1.0 / 2097152.0\n#define SHIFT_RIGHT22 1.0 / 4194304.0\n#define SHIFT_RIGHT23 1.0 / 8388608.0\n#define SHIFT_RIGHT24 1.0 / 16777216.0\n\n#define SHIFT_LEFT17 131072.0\n#define SHIFT_LEFT18 262144.0\n#define SHIFT_LEFT19 524288.0\n#define SHIFT_LEFT20 1048576.0\n#define SHIFT_LEFT21 2097152.0\n#define SHIFT_LEFT22 4194304.0\n#define SHIFT_LEFT23 8388608.0\n#define SHIFT_LEFT24 16777216.0\n\nvec2 unpack_float(float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\n\nvec4 decode_color(vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\n"; | ||
var light = "#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\n\nfloat calc_lighting(vec4 pos) {\n\n vec3 worldPos = vec3(pos * u_ModelMatrix);\n\n vec3 worldNormal = a_Normal;\n // //cal light weight\n vec3 viewDir = normalize(u_CameraPosition - worldPos);\n\n vec3 lightDir = normalize(reverse_offset_normal(vec3(1, 10.5, 12)));\n\n vec3 halfDir = normalize(viewDir+lightDir);\n // //lambert\n float lambert = dot(worldNormal, lightDir);\n //specular\n float specular = pow(max(0.0, dot(worldNormal, halfDir)), 32.0);\n //sum to light weight\n float lightWeight = ambientRatio + diffuseRatio * lambert + specularRatio * specular;\n\n return lightWeight;\n}\n"; | ||
var lighting = "// Blinn-Phong model\n// apply lighting in vertex shader instead of fragment shader\n// @see https://learnopengl.com/Advanced-Lighting/Advanced-Lighting\nuniform float u_Ambient : 1.0;\nuniform float u_Diffuse : 1.0;\nuniform float u_Specular : 1.0;\nuniform int u_NumOfDirectionalLights : 1;\nuniform int u_NumOfSpotLights : 0;\n\n#define SHININESS 32.0\n#define MAX_NUM_OF_DIRECTIONAL_LIGHTS 3\n#define MAX_NUM_OF_SPOT_LIGHTS 3\n\nstruct DirectionalLight {\n vec3 direction;\n vec3 ambient;\n vec3 diffuse;\n vec3 specular;\n};\n\nstruct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 ambient;\n vec3 diffuse;\n vec3 specular;\n float constant;\n float linear;\n float quadratic;\n float angle;\n float blur;\n float exponent;\n};\n\nuniform DirectionalLight u_DirectionalLights[MAX_NUM_OF_DIRECTIONAL_LIGHTS];\nuniform SpotLight u_SpotLights[MAX_NUM_OF_SPOT_LIGHTS];\n\nvec3 calc_directional_light(DirectionalLight light, vec3 normal, vec3 viewDir) {\n vec3 lightDir = normalize(light.direction);\n // diffuse shading\n float diff = max(dot(normal, lightDir), 0.0);\n // Blinn-Phong specular shading\n vec3 halfwayDir = normalize(lightDir + viewDir);\n float spec = pow(max(dot(normal, halfwayDir), 0.0), SHININESS);\n\n vec3 ambient = light.ambient * u_Ambient;\n vec3 diffuse = light.diffuse * diff * u_Diffuse;\n vec3 specular = light.specular * spec * u_Specular;\n\n return ambient + diffuse + specular;\n}\n\n// vec3 calc_spot_light(SpotLight light, vec3 normal, vec3 fragPos, vec3 viewDir) {\n// vec3 lightDir = normalize(light.position - fragPos);\n// // diffuse shading\n// float diff = max(dot(normal, lightDir), 0.0);\n// // specular shading\n// vec3 reflectDir = reflect(-lightDir, normal);\n// float spec = pow(max(dot(viewDir, reflectDir), 0.0), SHININESS);\n// // attenuation\n// float distance = length(light.position - fragPos);\n// float attenuation = 1.0 / (light.constant + light.linear * distance + \n// light.quadratic * (distance * distance)); \n\n// vec3 ambient = light.ambient * u_Ambient;\n// vec3 diffuse = light.diffuse * diff * u_Diffuse;\n// vec3 specular = light.specular * spec * u_Specular;\n\n// float spotEffect = dot(normalize(light.direction), -lightDir);\n// float spotCosCutoff = cos(light.angle / 180.0 * PI);\n// float spotCosOuterCutoff = cos((light.angle + light.blur) / 180.0 * PI);\n// float spotCosInnerCutoff = cos((light.angle - light.blur) / 180.0 * PI);\n// if (spotEffect > spotCosCutoff) {\n// spotEffect = pow(smoothstep(spotCosOuterCutoff, spotCosInnerCutoff, spotEffect), light.exponent);\n// } else {\n// spotEffect = 0.0;\n// }\n\n// return ambient + attenuation * (spotEffect * diffuse + specular);\n// }\n\nvec3 calc_lighting(vec3 position, vec3 normal, vec3 viewDir) {\n vec3 weight = vec3(0.0);\n for (int i = 0; i < MAX_NUM_OF_DIRECTIONAL_LIGHTS; i++) {\n if (i >= u_NumOfDirectionalLights) {\n break;\n }\n weight += calc_directional_light(u_DirectionalLights[i], normal, viewDir);\n }\n // for (int i = 0; i < MAX_NUM_OF_SPOT_LIGHTS; i++) {\n // if (i >= u_NumOfSpotLights) {\n // break;\n // }\n // weight += calc_spot_light(u_SpotLights[i], normal, position, viewDir);\n // }\n return weight;\n}"; | ||
var lighting = "// Blinn-Phong model\n// apply lighting in vertex shader instead of fragment shader\n// @see https://learnopengl.com/Advanced-Lighting/Advanced-Lighting\nuniform float u_Ambient : 1.0;\nuniform float u_Diffuse : 1.0;\nuniform float u_Specular : 1.0;\nuniform int u_NumOfDirectionalLights : 1;\nuniform int u_NumOfSpotLights : 0;\n\n#define SHININESS 32.0\n#define MAX_NUM_OF_DIRECTIONAL_LIGHTS 3\n#define MAX_NUM_OF_SPOT_LIGHTS 3\n\nstruct DirectionalLight {\n vec3 direction;\n vec3 ambient;\n vec3 diffuse;\n vec3 specular;\n};\n\nstruct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 ambient;\n vec3 diffuse;\n vec3 specular;\n float constant;\n float linear;\n float quadratic;\n float angle;\n float blur;\n float exponent;\n};\n\nuniform DirectionalLight u_DirectionalLights[MAX_NUM_OF_DIRECTIONAL_LIGHTS];\nuniform SpotLight u_SpotLights[MAX_NUM_OF_SPOT_LIGHTS];\n\nvec3 calc_directional_light(DirectionalLight light, vec3 normal, vec3 viewDir) {\n vec3 lightDir = normalize(light.direction);\n // diffuse shading\n float diff = max(dot(normal, lightDir), 0.0);\n // Blinn-Phong specular shading\n vec3 halfwayDir = normalize(lightDir + viewDir);\n float spec = pow(max(dot(normal, halfwayDir), 0.0), SHININESS);\n\n vec3 ambient = light.ambient * u_Ambient;\n vec3 diffuse = light.diffuse * diff * u_Diffuse;\n vec3 specular = light.specular * spec * u_Specular;\n\n return ambient + diffuse + specular;\n}\n\n// vec3 calc_spot_light(SpotLight light, vec3 normal, vec3 fragPos, vec3 viewDir) {\n// vec3 lightDir = normalize(light.position - fragPos);\n// // diffuse shading\n// float diff = max(dot(normal, lightDir), 0.0);\n// // specular shading\n// vec3 reflectDir = reflect(-lightDir, normal);\n// float spec = pow(max(dot(viewDir, reflectDir), 0.0), SHININESS);\n// // attenuation\n// float distance = length(light.position - fragPos);\n// float attenuation = 1.0 / (light.constant + light.linear * distance +\n// light.quadratic * (distance * distance));\n\n// vec3 ambient = light.ambient * u_Ambient;\n// vec3 diffuse = light.diffuse * diff * u_Diffuse;\n// vec3 specular = light.specular * spec * u_Specular;\n\n// float spotEffect = dot(normalize(light.direction), -lightDir);\n// float spotCosCutoff = cos(light.angle / 180.0 * PI);\n// float spotCosOuterCutoff = cos((light.angle + light.blur) / 180.0 * PI);\n// float spotCosInnerCutoff = cos((light.angle - light.blur) / 180.0 * PI);\n// if (spotEffect > spotCosCutoff) {\n// spotEffect = pow(smoothstep(spotCosOuterCutoff, spotCosInnerCutoff, spotEffect), light.exponent);\n// } else {\n// spotEffect = 0.0;\n// }\n\n// return ambient + attenuation * (spotEffect * diffuse + specular);\n// }\n\nvec3 calc_lighting(vec3 position, vec3 normal, vec3 viewDir) {\n vec3 weight = vec3(0.0);\n for (int i = 0; i < MAX_NUM_OF_DIRECTIONAL_LIGHTS; i++) {\n if (i >= u_NumOfDirectionalLights) {\n break;\n }\n weight += calc_directional_light(u_DirectionalLights[i], normal, viewDir);\n }\n // for (int i = 0; i < MAX_NUM_OF_SPOT_LIGHTS; i++) {\n // if (i >= u_NumOfSpotLights) {\n // break;\n // }\n // weight += calc_spot_light(u_SpotLights[i], normal, position, viewDir);\n // }\n return weight;\n}\n"; | ||
var pickingFrag = "varying vec4 v_PickingResult;\nuniform vec4 u_HighlightColor : [0, 0, 0, 0];\nuniform float u_PickingStage : 0.0;\n\n#define PICKING_NONE 0.0\n#define PICKING_ENCODE 1.0\n#define PICKING_HIGHLIGHT 2.0\n#define COLOR_SCALE 1. / 255.\n\n/*\n * Returns highlight color if this item is selected.\n */\nvec4 filterHighlightColor(vec4 color) {\n bool selected = bool(v_PickingResult.a);\n\n if (selected) {\n vec4 highLightColor = u_HighlightColor * COLOR_SCALE;\n\n float highLightAlpha = highLightColor.a;\n float highLightRatio = highLightAlpha / (highLightAlpha + color.a * (1.0 - highLightAlpha));\n\n vec3 resultRGB = mix(color.rgb, highLightColor.rgb, highLightRatio);\n return vec4(resultRGB, color.a);\n } else {\n return color;\n }\n}\n\n/*\n * Returns picking color if picking enabled else unmodified argument.\n */\nvec4 filterPickingColor(vec4 color) {\n vec3 pickingColor = v_PickingResult.rgb;\n if (u_PickingStage == PICKING_ENCODE && length(pickingColor) < 0.001) {\n discard;\n }\n return u_PickingStage == PICKING_ENCODE ? vec4(pickingColor, 1.0) : color;\n}\n\n/*\n * Returns picking color if picking is enabled if not\n * highlight color if this item is selected, otherwise unmodified argument.\n */\nvec4 filterColor(vec4 color) {\n return filterPickingColor(filterHighlightColor(color));\n}\n"; | ||
var pickingVert = "attribute vec3 a_PickingColor;\nvarying vec4 v_PickingResult;\n\nuniform vec3 u_PickingColor : [0, 0, 0];\nuniform vec4 u_HighlightColor : [0, 0, 0, 0];\nuniform float u_PickingStage : 0.0;\nuniform float u_PickingThreshold : 1.0;\n\n#define PICKING_NONE 0.0\n#define PICKING_ENCODE 1.0\n#define PICKING_HIGHLIGHT 2.0\n#define COLOR_SCALE 1. / 255.\n\nbool isVertexPicked(vec3 vertexColor) {\n return\n abs(vertexColor.r - u_PickingColor.r) < u_PickingThreshold &&\n abs(vertexColor.g - u_PickingColor.g) < u_PickingThreshold &&\n abs(vertexColor.b - u_PickingColor.b) < u_PickingThreshold;\n}\n\nvoid setPickingColor(vec3 pickingColor) {\n // compares only in highlight stage\n v_PickingResult.a = float((u_PickingStage == PICKING_HIGHLIGHT) && isVertexPicked(pickingColor));\n\n // Stores the picking color so that the fragment shader can render it during picking\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n"; | ||
var 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\nfloat pixelDistance(vec2 from, vec2 to) {\n vec2 a1 = ProjectFlat(from);\n vec2 b1 = ProjectFlat(to);\n return distance(a1, b1);\n}\n"; | ||
var 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}\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 || 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 || 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 * -1.;\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"; | ||
var 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}"; | ||
var 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 + 0.01 && u_CoordinateSystem >COORDINATE_SYSTEM_LNGLAT - 0.01\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 float a = COORDINATE_SYSTEM_LNGLAT_OFFSET;\n float b = COORDINATE_SYSTEM_P20_OFFSET;\n float c = COORDINATE_SYSTEM_LNGLAT;\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 if (u_CoordinateSystem < COORDINATE_SYSTEM_LNGLAT + 0.01 && u_CoordinateSystem >COORDINATE_SYSTEM_LNGLAT - 0.01) {\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 return position;\n\n // TODO: \u74E6\u7247\u5750\u6807\u7CFB & \u5E38\u89C4\u4E16\u754C\u5750\u6807\u7CFB\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 || 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 || 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 * -1.;\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\n\nbool isEqual( float a, float b) {\n return a< b + 0.001 && a > b - 0.001;\n}\n\n"; | ||
var 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 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 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 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 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 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}\n"; | ||
var precisionRegExp = /precision\s+(high|low|medium)p\s+float/; | ||
@@ -39,0 +39,0 @@ var globalDefaultprecision = '#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n #else\n precision mediump float;\n#endif\n'; |
{ | ||
"name": "@antv/l7-core", | ||
"version": "2.0.27-alpha.0", | ||
"version": "2.0.28-alpha.0", | ||
"description": "", | ||
@@ -25,3 +25,4 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@antv/l7-utils": "^2.0.27-alpha.0", | ||
"@antv/async-hook": "^2.0.28-alpha.0", | ||
"@antv/l7-utils": "^2.0.28-alpha.0", | ||
"@babel/runtime": "^7.7.7", | ||
@@ -40,3 +41,2 @@ "@mapbox/tiny-sdf": "^1.1.1", | ||
"reflect-metadata": "^0.1.13", | ||
"tapable": "^2.0.0-beta.8", | ||
"viewport-mercator-project": "^6.2.1" | ||
@@ -51,3 +51,3 @@ }, | ||
}, | ||
"gitHead": "0855cc365bf2bb049fa002812b22b92a496f8308", | ||
"gitHead": "cd522461057292b176046449e3e5929c7fa307ce", | ||
"publishConfig": { | ||
@@ -54,0 +54,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
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
1355173
14765
+ Added@antv/async-hook@2.2.9(transitive)
+ Addedasync@3.2.6(transitive)
- Removedtapable@^2.0.0-beta.8
- Removedtapable@2.2.1(transitive)