@antv/l7-layers 2.17.12 → 2.18.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/core/BaseLayer.js +7 -2
- package/es/core/BaseModel.d.ts +0 -20
- package/es/core/BaseModel.js +4 -2
- package/es/core/CommonStyleAttribute.js +20 -0
- package/es/core/interface.d.ts +1 -0
- package/es/earth/models/atmosphere.js +2 -1
- package/es/earth/models/bloomsphere.js +2 -1
- package/es/heatmap/models/heatmap.js +2 -2
- package/es/image/models/image.js +6 -29
- package/es/line/models/arc.js +2 -2
- package/es/line/models/linearline.js +2 -2
- package/es/line/models/simpleLine.js +2 -2
- package/es/line/models/wall.js +2 -2
- package/es/mask/models/fill.js +2 -2
- package/es/plugins/DataMappingPlugin.js +2 -2
- package/es/plugins/FeatureScalePlugin.js +6 -2
- package/es/plugins/ShaderUniformPlugin.js +1 -2
- package/es/point/index.js +5 -3
- package/es/point/models/{simplePoint.js → billboard_point.js} +2 -2
- package/es/point/models/earthExtrude.js +2 -2
- package/es/point/models/fill.js +1 -1
- package/es/point/models/fillmage.js +8 -37
- package/es/point/models/image.js +7 -7
- package/es/point/models/index.js +1 -1
- package/es/point/models/normal.js +6 -5
- package/es/point/models/text.js +3 -21
- package/es/point/shaders/fill_vert.glsl +3 -4
- package/es/point/shaders/image/fillImage_frag.glsl +2 -1
- package/es/point/shaders/image/fillImage_vert.glsl +9 -11
- package/es/point/shaders/image_frag.glsl +2 -4
- package/es/point/shaders/image_vert.glsl +3 -4
- package/es/point/shaders/normal_vert.glsl +1 -2
- package/es/point/shaders/text_vert.glsl +4 -6
- package/es/polygon/models/ocean.js +2 -2
- package/es/polygon/models/water.js +2 -1
- package/es/tile/tileFactory/Tile.d.ts +0 -1
- package/es/tile/tileLayer/BaseLayer.js +2 -1
- package/es/utils/layerData.js +2 -2
- package/lib/core/BaseLayer.js +30 -25
- package/lib/core/BaseModel.js +4 -2
- package/lib/core/CommonStyleAttribute.js +20 -0
- package/lib/earth/models/atmosphere.js +3 -2
- package/lib/earth/models/bloomsphere.js +3 -2
- package/lib/heatmap/models/heatmap.js +2 -2
- package/lib/image/models/image.js +6 -29
- package/lib/line/models/arc.js +2 -2
- package/lib/line/models/linearline.js +2 -2
- package/lib/line/models/simpleLine.js +2 -2
- package/lib/line/models/wall.js +2 -2
- package/lib/mask/models/fill.js +2 -2
- package/lib/plugins/DataMappingPlugin.js +2 -2
- package/lib/plugins/FeatureScalePlugin.js +10 -6
- package/lib/plugins/ShaderUniformPlugin.js +1 -2
- package/lib/point/index.js +5 -3
- package/lib/point/models/{simplePoint.js → billboard_point.js} +2 -2
- package/lib/point/models/earthExtrude.js +2 -2
- package/lib/point/models/fill.js +1 -1
- package/lib/point/models/fillmage.js +8 -37
- package/lib/point/models/image.js +7 -7
- package/lib/point/models/index.js +2 -2
- package/lib/point/models/normal.js +6 -5
- package/lib/point/models/text.js +3 -21
- package/lib/point/shaders/fill_vert.glsl +3 -4
- package/lib/point/shaders/image/fillImage_frag.glsl +2 -1
- package/lib/point/shaders/image/fillImage_vert.glsl +9 -11
- package/lib/point/shaders/image_frag.glsl +2 -4
- package/lib/point/shaders/image_vert.glsl +3 -4
- package/lib/point/shaders/normal_vert.glsl +1 -2
- package/lib/point/shaders/text_vert.glsl +4 -6
- package/lib/polygon/models/ocean.js +2 -2
- package/lib/polygon/models/water.js +3 -2
- package/lib/tile/tileLayer/BaseLayer.js +3 -2
- package/lib/utils/layerData.js +3 -3
- package/package.json +7 -8
- /package/es/point/models/{simplePoint.d.ts → billboard_point.d.ts} +0 -0
- /package/es/point/shaders/{simplePoint_frag.glsl → billboard_point_frag.glsl} +0 -0
- /package/es/point/shaders/{simplePoint_vert.glsl → billboard_point_vert.glsl} +0 -0
- /package/lib/point/shaders/{simplePoint_frag.glsl → billboard_point_frag.glsl} +0 -0
- /package/lib/point/shaders/{simplePoint_vert.glsl → billboard_point_vert.glsl} +0 -0
|
@@ -12,7 +12,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
12
12
|
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime/helpers/applyDecoratedDescriptor"));
|
|
13
13
|
var _initializerWarningHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/initializerWarningHelper"));
|
|
14
14
|
var _l7Core = require("@antv/l7-core");
|
|
15
|
-
var _l7Utils = require("@antv/l7-utils");
|
|
16
15
|
var _inversify = require("inversify");
|
|
17
16
|
require("reflect-metadata");
|
|
18
17
|
var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;
|
|
@@ -56,7 +55,7 @@ var ShaderUniformPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inv
|
|
|
56
55
|
height = _this$rendererService.height;
|
|
57
56
|
layer.models.forEach(function (model) {
|
|
58
57
|
var _model$addUniforms;
|
|
59
|
-
model.addUniforms((_model$addUniforms = {}, (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.ProjectionMatrix, _this.cameraService.getProjectionMatrix()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.ViewMatrix, _this.cameraService.getViewMatrix()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.ViewProjectionMatrix, _this.cameraService.getViewProjectionMatrix()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.Zoom, _this.cameraService.getZoom()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.ZoomScale, _this.cameraService.getZoomScale()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.FocalDistance, _this.cameraService.getFocalDistance()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.CameraPosition, _this.cameraService.getCameraPosition()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.CoordinateSystem, _this.coordinateSystemService.getCoordinateSystem()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.ViewportCenter, _this.coordinateSystemService.getViewportCenter()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.ViewportCenterProjection, _this.coordinateSystemService.getViewportCenterProjection()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.PixelsPerDegree, _this.coordinateSystemService.getPixelsPerDegree()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.PixelsPerDegree2, _this.coordinateSystemService.getPixelsPerDegree2()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.PixelsPerMeter, _this.coordinateSystemService.getPixelsPerMeter()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.Mvp, mvp), (0, _defineProperty2.default)(_model$addUniforms, "u_sceneCenterMercator", sceneCenterMercator), (0, _defineProperty2.default)(_model$addUniforms, "u_ViewportSize", [width, height]), (0, _defineProperty2.default)(_model$addUniforms, "u_ModelMatrix", _this.cameraService.getModelMatrix()), (0, _defineProperty2.default)(_model$addUniforms, "u_DevicePixelRatio",
|
|
58
|
+
model.addUniforms((_model$addUniforms = {}, (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.ProjectionMatrix, _this.cameraService.getProjectionMatrix()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.ViewMatrix, _this.cameraService.getViewMatrix()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.ViewProjectionMatrix, _this.cameraService.getViewProjectionMatrix()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.Zoom, _this.cameraService.getZoom()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.ZoomScale, _this.cameraService.getZoomScale()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.FocalDistance, _this.cameraService.getFocalDistance()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.CameraPosition, _this.cameraService.getCameraPosition()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.CoordinateSystem, _this.coordinateSystemService.getCoordinateSystem()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.ViewportCenter, _this.coordinateSystemService.getViewportCenter()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.ViewportCenterProjection, _this.coordinateSystemService.getViewportCenterProjection()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.PixelsPerDegree, _this.coordinateSystemService.getPixelsPerDegree()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.PixelsPerDegree2, _this.coordinateSystemService.getPixelsPerDegree2()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.PixelsPerMeter, _this.coordinateSystemService.getPixelsPerMeter()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.Mvp, mvp), (0, _defineProperty2.default)(_model$addUniforms, "u_sceneCenterMercator", sceneCenterMercator), (0, _defineProperty2.default)(_model$addUniforms, "u_ViewportSize", [width, height]), (0, _defineProperty2.default)(_model$addUniforms, "u_ModelMatrix", _this.cameraService.getModelMatrix()), (0, _defineProperty2.default)(_model$addUniforms, "u_DevicePixelRatio", window.devicePixelRatio), (0, _defineProperty2.default)(_model$addUniforms, "u_PickingBuffer", layer.getLayerConfig().pickingBuffer || 0), (0, _defineProperty2.default)(_model$addUniforms, "u_shaderPick", Number(layer.getShaderPickStat())), _model$addUniforms));
|
|
60
59
|
});
|
|
61
60
|
|
|
62
61
|
// TODO:脏检查,决定是否需要渲染
|
package/lib/point/index.js
CHANGED
|
@@ -32,7 +32,7 @@ var PointLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
|
32
32
|
}
|
|
33
33
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
34
34
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "type", 'PointLayer');
|
|
35
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "enableShaderEncodeStyles", ['opacity', 'offsets', 'stroke']);
|
|
35
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "enableShaderEncodeStyles", ['opacity', 'offsets', 'stroke', 'rotation']);
|
|
36
36
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "enableDataEncodeStyles", ['textOffset', 'textAnchor']);
|
|
37
37
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "defaultSourceConfig", {
|
|
38
38
|
data: [],
|
|
@@ -164,7 +164,9 @@ var PointLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
|
164
164
|
var layerData = this.getEncodedData();
|
|
165
165
|
var _this$getLayerConfig2 = this.getLayerConfig(),
|
|
166
166
|
shape2d = _this$getLayerConfig2.shape2d,
|
|
167
|
-
shape3d = _this$getLayerConfig2.shape3d
|
|
167
|
+
shape3d = _this$getLayerConfig2.shape3d,
|
|
168
|
+
_this$getLayerConfig3 = _this$getLayerConfig2.billboard,
|
|
169
|
+
billboard = _this$getLayerConfig3 === void 0 ? true : _this$getLayerConfig3;
|
|
168
170
|
var iconMap = this.iconService.getIconMap();
|
|
169
171
|
var item = layerData.find(function (fe) {
|
|
170
172
|
return fe.hasOwnProperty('shape');
|
|
@@ -182,7 +184,7 @@ var PointLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
|
182
184
|
if (shape === 'radar') {
|
|
183
185
|
return 'radar';
|
|
184
186
|
}
|
|
185
|
-
if (this.layerType === 'fillImage') {
|
|
187
|
+
if (this.layerType === 'fillImage' || billboard === false) {
|
|
186
188
|
return 'fillImage';
|
|
187
189
|
}
|
|
188
190
|
if ((shape2d === null || shape2d === void 0 ? void 0 : shape2d.indexOf(shape)) !== -1) {
|
|
@@ -19,9 +19,9 @@ var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
|
19
19
|
var _l7Utils = require("@antv/l7-utils");
|
|
20
20
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
21
21
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
22
|
-
/* babel-plugin-inline-import '../shaders/
|
|
22
|
+
/* babel-plugin-inline-import '../shaders/billboard_point_frag.glsl' */
|
|
23
23
|
var simplePointFrag = "\nuniform float u_additive;\nuniform float u_stroke_opacity : 1;\n\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\nvarying vec4 v_color;\nvarying float v_blur;\nvarying float v_innerRadius;\n\n#pragma include \"picking\"\nvoid main() {\n vec2 center = vec2(0.5);\n\n // Tip: \u7247\u5143\u5230\u4E2D\u5FC3\u70B9\u7684\u8DDD\u79BB 0 - 1\n float fragmengTocenter = distance(center, gl_PointCoord) * 2.0;\n // Tip: \u7247\u5143\u7684\u526A\u5207\u6210\u5706\u5F62\n float circleClipOpacity = 1.0 - smoothstep(v_blur, 1.0, fragmengTocenter);\n\n\n if(v_innerRadius < 0.99) {\n // \u5F53\u5B58\u5728 stroke \u4E14 stroke > 0.01\n float blurWidth = (1.0 - v_blur)/2.0;\n vec4 stroke = vec4(u_stroke_color.rgb, u_stroke_opacity);\n if(fragmengTocenter > v_innerRadius + blurWidth) {\n gl_FragColor = stroke;\n } else if(fragmengTocenter > v_innerRadius - blurWidth){\n float mixR = (fragmengTocenter - (v_innerRadius - blurWidth)) / (blurWidth * 2.0);\n gl_FragColor = mix(v_color, stroke, mixR);\n } else {\n gl_FragColor = v_color;\n }\n } else {\n // \u5F53\u4E0D\u5B58\u5728 stroke \u6216 stroke <= 0.01\n gl_FragColor = v_color;\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n \n if(u_additive > 0.0) {\n gl_FragColor *= circleClipOpacity;\n } else {\n gl_FragColor.a *= circleClipOpacity;\n }\n\n}\n";
|
|
24
|
-
/* babel-plugin-inline-import '../shaders/
|
|
24
|
+
/* babel-plugin-inline-import '../shaders/billboard_point_vert.glsl' */
|
|
25
25
|
var simplePointVert = "\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nattribute float a_Size;\nattribute vec4 a_Color;\nvarying vec4 v_color;\n\nuniform float u_opacity : 1;\nuniform vec2 u_offsets;\nuniform float u_stroke_width;\n\nvarying float v_blur;\nvarying float v_innerRadius;\n\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"project\"\nvoid main() {\n v_color = vec4(a_Color.xyz, a_Color.w * u_opacity);\n v_blur = 1.0 - max(2.0/a_Size, 0.05);\n v_innerRadius = max((a_Size - u_stroke_width) / a_Size, 0.0);\n \n vec2 offset = project_pixel(u_offsets);\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(a_Position.xy + offset, a_Position.z, 1.0);\n } else { // else\n vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);\n gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));\n }\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
|
|
26
26
|
function PointTriangulation(feature) {
|
|
27
27
|
var coordinates = feature.coordinates;
|
|
@@ -16,7 +16,6 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
|
|
|
16
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
17
|
var _l7Core = require("@antv/l7-core");
|
|
18
18
|
var _l7Utils = require("@antv/l7-utils");
|
|
19
|
-
var _lodash = require("lodash");
|
|
20
19
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
21
20
|
var _triangulation = require("../../core/triangulation");
|
|
22
21
|
var _utils = require("../../earth/utils");
|
|
@@ -26,6 +25,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
26
25
|
var pointExtrudeFrag = "varying vec4 v_color;\nuniform float u_opacity: 1.0;\n\nuniform float u_pickLight: 0.0;\n\n#pragma include \"picking\"\n\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\nuniform float u_opacitylinear: 0.0;\nuniform float u_opacitylinear_dir: 1.0;\nvarying float v_lightWeight;\nvarying float v_barLinearZ;\nvoid main() {\n\n gl_FragColor = v_color;\n\n // \u5F00\u542F\u900F\u660E\u5EA6\u6E10\u53D8\n if(u_opacitylinear > 0.0) {\n gl_FragColor.a *= u_opacitylinear_dir > 0.0 ? (1.0 - v_barLinearZ): v_barLinearZ;\n }\n\n // picking\n if(u_pickLight > 0.0) {\n gl_FragColor = filterColorAlpha(gl_FragColor, v_lightWeight);\n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n}\n";
|
|
27
26
|
/* babel-plugin-inline-import '../shaders/earth/extrude_vert.glsl' */
|
|
28
27
|
var pointExtrudeVert = "precision highp float;\n\n#define pi 3.1415926535\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec3 a_Position;\nattribute vec3 a_Pos;\nattribute vec4 a_Color;\nattribute vec3 a_Size;\nattribute vec3 a_Normal;\n\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_globel;\nuniform float u_r;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nvarying vec4 v_color;\n\nuniform float u_opacity : 1;\nuniform float u_lightEnable: 1;\nvarying float v_lightWeight;\nvarying float v_barLinearZ;\n// \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nfloat getYRadian(float x, float z) {\n if(x > 0.0 && z > 0.0) {\n return atan(x/z);\n } else if(x > 0.0 && z <= 0.0){\n return atan(-z/x) + pi/2.0;\n } else if(x <= 0.0 && z <= 0.0) {\n return pi + atan(x/z); //atan(x/z) + \n } else {\n return atan(z/-x) + pi*3.0/2.0;\n }\n}\n\nfloat getXRadian(float y, float r) {\n return atan(y/r);\n}\n\nvoid main() {\n\n \n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n vec3 size = a_Size * a_Position;\n\n // a_Position.z \u662F\u5728\u6784\u5EFA\u7F51\u683C\u7684\u65F6\u5019\u4F20\u5165\u7684\u6807\u51C6\u503C 0 - 1\uFF0C\u5728\u63D2\u503C\u5668\u63D2\u503C\u53EF\u4EE5\u83B7\u53D6 0\uFF5E1 \u7EBF\u6027\u6E10\u53D8\u7684\u503C\n v_barLinearZ = a_Position.z;\n\n vec3 offset = size; // \u63A7\u5236\u5706\u67F1\u4F53\u7684\u5927\u5C0F - \u4ECE\u6807\u51C6\u5355\u4F4D\u5706\u67F1\u4F53\u8FDB\u884C\u504F\u79FB\n if(u_heightfixed < 1.0) { // \u5706\u67F1\u4F53\u4E0D\u56FA\u5B9A\u9AD8\u5EA6\n \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 offset = offset * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n offset = offset * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n } else {// \u5706\u67F1\u4F53\u56FA\u5B9A\u9AD8\u5EA6 \uFF08 \u5904\u7406 mapbox \uFF09\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n offset *= 4.0/pow(2.0, 21.0 - u_Zoom);\n }\n }\n\n\n vec4 project_pos = project_position(vec4(a_Pos.xy, 0., 1.0));\n\n // u_r \u63A7\u5236\u5706\u67F1\u7684\u751F\u957F\n vec4 pos = vec4(project_pos.xy + offset.xy, offset.z * u_r, 1.0);\n\n // \u5706\u67F1\u5149\u7167\u6548\u679C\n float lightWeight = 1.0;\n if(u_lightEnable > 0.0) { // \u53D6\u6D88\u4E09\u5143\u8868\u8FBE\u5F0F\uFF0C\u589E\u5F3A\u5065\u58EE\u6027\n lightWeight = calc_lighting(pos);\n }\n v_lightWeight = lightWeight;\n // \u8BBE\u7F6E\u5706\u67F1\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n v_color = mix(u_sourceColor, u_targetColor, barLinearZ);\n v_color.rgb *= lightWeight;\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n v_color = a_Color;\n }\n v_color.a *= u_opacity;\n\n \n // \u5728\u5730\u7403\u6A21\u5F0F\u4E0B\uFF0C\u5C06\u539F\u672C\u5782\u76F4\u4E8E xy \u5E73\u9762\u7684\u5706\u67F1\u8C03\u6574\u59FF\u6001\u5230\u9002\u5E94\u5706\u7684\u89D2\u5EA6\n //\u65CB\u8F6C\u77E9\u9635mx\uFF0C\u521B\u5EFA\u7ED5x\u8F74\u65CB\u8F6C\u77E9\u9635\n float r = sqrt(a_Pos.z*a_Pos.z + a_Pos.x*a_Pos.x);\n float xRadian = getXRadian(a_Pos.y, r);\n float xcos = cos(xRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u4F59\u5F26\u503C\n float xsin = sin(xRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u6B63\u5F26\u503C\n mat4 mx = mat4(\n 1,0,0,0, \n 0,xcos,-xsin,0, \n 0,xsin,xcos,0, \n 0,0,0,1);\n\n //\u65CB\u8F6C\u77E9\u9635my\uFF0C\u521B\u5EFA\u7ED5y\u8F74\u65CB\u8F6C\u77E9\u9635\n float yRadian = getYRadian(a_Pos.x, a_Pos.z);\n float ycos = cos(yRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u4F59\u5F26\u503C\n float ysin = sin(yRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u6B63\u5F26\u503C\n mat4 my = mat4(\n ycos,0,-ysin,0, \n 0,1,0,0, \n ysin,0,ycos,0, \n 0,0,0,1);\n\n gl_Position = u_ViewProjectionMatrix * vec4(( my * mx * vec4(a_Position * a_Size, 1.0)).xyz + a_Pos, 1.0);\n \n\n setPickingColor(a_PickingColor);\n}\n";
|
|
28
|
+
var isNumber = _l7Utils.lodashUtil.isNumber;
|
|
29
29
|
var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
30
30
|
(0, _inherits2.default)(ExtrudeModel, _BaseModel);
|
|
31
31
|
var _super = _createSuper(ExtrudeModel);
|
|
@@ -96,7 +96,7 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
96
96
|
// 圆柱体是否固定高度
|
|
97
97
|
u_heightfixed: Number(heightfixed),
|
|
98
98
|
u_r: animateOption.enable && this.raiseRepeat > 0 ? this.raiseCount : 1.0,
|
|
99
|
-
u_opacity:
|
|
99
|
+
u_opacity: isNumber(opacity) ? opacity : 1.0,
|
|
100
100
|
// 渐变色支持参数
|
|
101
101
|
u_linearColor: useLinearColor,
|
|
102
102
|
u_sourceColor: sourceColorArr,
|
package/lib/point/models/fill.js
CHANGED
|
@@ -25,7 +25,7 @@ var waveFillFrag = "\nuniform float u_additive;\n\n\nvarying vec4 v_data;\nvaryi
|
|
|
25
25
|
/* babel-plugin-inline-import '../shaders/fill_frag.glsl' */
|
|
26
26
|
var pointFillFrag = "uniform float u_additive;\nuniform float u_stroke_opacity : 1;\nuniform float u_stroke_width : 2;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nvarying vec4 v_stroke;\n\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\n\nvoid main() {\n int shape = int(floor(v_data.w + 0.5));\n lowp float antialiasblur = v_data.z;\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, antialiasblur, outer_df);\n\n float color_t = u_stroke_width < 0.01 ? 0.0 : smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n\n if(u_stroke_width < 0.01) {\n gl_FragColor = v_color;\n } else {\n gl_FragColor = mix(v_color, v_stroke * u_stroke_opacity, color_t);\n }\n\n if(u_additive > 0.0) {\n gl_FragColor *= opacity_t;\n gl_FragColor = filterColorAlpha(gl_FragColor, gl_FragColor.a);\n } else {\n gl_FragColor.a *= opacity_t;\n gl_FragColor = filterColor(gl_FragColor);\n }\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if(gl_FragColor.a < 0.01) {\n discard;\n } \n}\n";
|
|
27
27
|
/* babel-plugin-inline-import '../shaders/fill_vert.glsl' */
|
|
28
|
-
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute float a_Shape;\
|
|
28
|
+
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute float a_Shape;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform int u_size_unit;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nvarying vec4 v_stroke;\nuniform float u_stroke_width: 2;\nuniform vec3 u_blur_height_fixed: [0, 0, 0];\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\n\nvoid main() {\n // \u900F\u660E\u5EA6\u8BA1\u7B97\n v_stroke = stroke; \n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n /*\n * setPickingSize \u8BBE\u7F6E\u62FE\u53D6\u5927\u5C0F\n * u_meter2coord \u5728\u7B49\u9762\u79EF\u5927\u5C0F\u7684\u65F6\u5019\u8BBE\u7F6E\u5355\u4F4D\n */\n float newSize = setPickingSize(a_Size);\n // float newSize = setPickingSize(a_Size) * 0.00001038445708445579;\n\n\n\n // unpack color(vec2)\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n\n if(u_size_unit == 1) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n\n v_radius = newSize;\n\n // anti-alias\n // float antialiased_blur = -max(u_blur, antialiasblur);\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, u_blur_height_fixed.x);\n\n vec2 offset = (extrude.xy * (newSize + u_stroke_width) + u_offsets);\n vec3 aPosition = a_Position;\n\n offset = project_pixel(offset);\n offset = rotate_matrix(offset,rotation);\n \n // TODP: /abs(extrude.x) \u662F\u4E3A\u4E86\u517C\u5BB9\u5730\u7403\u6A21\u5F0F\n v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);\n\n\n // vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n float raisingHeight = u_blur_height_fixed.y;\n\n if(u_blur_height_fixed.z < 1.0) { // false\n raisingHeight = project_pixel(u_blur_height_fixed.y);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_blur_height_fixed.y * mapboxZoomScale;\n }\n }\n \n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
29
29
|
var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
30
30
|
(0, _inherits2.default)(FillModel, _BaseModel);
|
|
31
31
|
var _super = _createSuper(FillModel);
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
11
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
12
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
13
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
@@ -23,9 +24,9 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
23
24
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
24
25
|
/* babel-plugin-inline-import '../shaders/image/fillImage_frag.glsl' */
|
|
25
26
|
// static pointLayer shader - not support animate
|
|
26
|
-
var pointFillFrag = "uniform sampler2D u_texture;\nuniform vec2 u_textSize;\nuniform float u_opacity : 1;\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\nvarying vec2 v_uv; // \u672C\u8EAB\u7684 uv \u5750\u6807\nvarying vec2 v_Iconuv;\n\nvoid main() {\n\n vec2 pos = v_Iconuv / u_textSize + v_uv / u_textSize * 64.;\n gl_FragColor = texture2D(u_texture, pos);\n gl_FragColor.a *=
|
|
27
|
+
var pointFillFrag = "uniform sampler2D u_texture;\nuniform vec2 u_textSize;\nuniform float u_opacity : 1;\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\nvarying vec2 v_uv; // \u672C\u8EAB\u7684 uv \u5750\u6807\nvarying vec2 v_Iconuv;\nvarying float v_opacity;\n\nvoid main() {\n\n vec2 pos = v_Iconuv / u_textSize + v_uv / u_textSize * 64.;\n gl_FragColor = texture2D(u_texture, pos);\n gl_FragColor.a *= v_opacity;\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
27
28
|
/* babel-plugin-inline-import '../shaders/image/fillImage_vert.glsl' */
|
|
28
|
-
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute vec2 a_Uv;\
|
|
29
|
+
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute vec2 a_Uv;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform mat2 u_RotateMatrix;\nuniform int u_size_unit;\n\nvarying vec2 v_uv; // \u672C\u8EAB\u7684 uv \u5750\u6807\nvarying vec2 v_Iconuv; // icon \u8D34\u56FE\u7684 uv \u5750\u6807\n\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\nvarying float v_opacity;\n// uniform vec2 u_offsets; // shader \u6CE8\u5165\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n vec3 extrude = a_Extrude;\n v_uv = (a_Extrude.xy + 1.0)/2.0;\n v_uv.y = 1.0 - v_uv.y;\n v_Iconuv = a_Uv;\n v_opacity = opacity;\n float newSize = a_Size;\n if(u_size_unit == 1) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n \n // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);\n vec2 offset = (extrude.xy * (newSize) + offsets);\n\n offset = rotate_matrix(offset,rotation);\n\n vec3 aPosition = a_Position;\n\n offset = project_pixel(offset);\n\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n float raisingHeight = u_raisingHeight;\n if(u_heightfixed < 1.0) { // height fixed\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp *vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
29
30
|
var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
30
31
|
(0, _inherits2.default)(FillImageModel, _BaseModel);
|
|
31
32
|
var _super = _createSuper(FillImageModel);
|
|
@@ -70,11 +71,6 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
70
71
|
// 旋转的弧度
|
|
71
72
|
function getUninforms() {
|
|
72
73
|
var _ref = this.layer.getLayerConfig(),
|
|
73
|
-
_ref$opacity = _ref.opacity,
|
|
74
|
-
opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
|
|
75
|
-
_ref$offsets = _ref.offsets,
|
|
76
|
-
offsets = _ref$offsets === void 0 ? [0, 0] : _ref$offsets,
|
|
77
|
-
rotation = _ref.rotation,
|
|
78
74
|
_ref$raisingHeight = _ref.raisingHeight,
|
|
79
75
|
raisingHeight = _ref$raisingHeight === void 0 ? 0.0 : _ref$raisingHeight,
|
|
80
76
|
_ref$heightfixed = _ref.heightfixed,
|
|
@@ -91,22 +87,14 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
91
87
|
* GAODE2.x -1
|
|
92
88
|
* GAODE1.x -1
|
|
93
89
|
*/
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
rotateFlag = -1;
|
|
97
|
-
}
|
|
98
|
-
// 控制图标的旋转角度(绕 Z 轴旋转)
|
|
99
|
-
this.radian = rotation !== undefined ? rotateFlag * Math.PI * rotation / 180 : rotateFlag * Math.PI * (this.mapService.getRotation() % 360) / 180;
|
|
100
|
-
return {
|
|
90
|
+
|
|
91
|
+
return (0, _objectSpread2.default)({
|
|
101
92
|
u_raisingHeight: Number(raisingHeight),
|
|
102
93
|
u_heightfixed: Number(heightfixed),
|
|
103
94
|
u_size_unit: _interface.SizeUnitType[unit],
|
|
104
|
-
u_RotateMatrix: new Float32Array([Math.cos(this.radian), Math.sin(this.radian), -Math.sin(this.radian), Math.cos(this.radian)]),
|
|
105
95
|
u_texture: this.texture,
|
|
106
|
-
u_textSize: [1024, this.iconService.canvasHeight || 128]
|
|
107
|
-
|
|
108
|
-
u_offsets: offsets
|
|
109
|
-
};
|
|
96
|
+
u_textSize: [1024, this.iconService.canvasHeight || 128]
|
|
97
|
+
}, this.getStyleAttribute());
|
|
110
98
|
}
|
|
111
99
|
}, {
|
|
112
100
|
key: "getAttribute",
|
|
@@ -151,6 +139,7 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
151
139
|
depth: {
|
|
152
140
|
enable: false
|
|
153
141
|
},
|
|
142
|
+
inject: this.getInject(),
|
|
154
143
|
cull: {
|
|
155
144
|
enable: true,
|
|
156
145
|
face: (0, _l7Utils.getCullFace)(this.mapService.version)
|
|
@@ -183,24 +172,6 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
183
172
|
key: "registerBuiltinAttributes",
|
|
184
173
|
value: function registerBuiltinAttributes() {
|
|
185
174
|
var _this2 = this;
|
|
186
|
-
this.styleAttributeService.registerStyleAttribute({
|
|
187
|
-
name: 'rotate',
|
|
188
|
-
type: _l7Core.AttributeType.Attribute,
|
|
189
|
-
descriptor: {
|
|
190
|
-
name: 'a_Rotate',
|
|
191
|
-
buffer: {
|
|
192
|
-
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
193
|
-
data: [],
|
|
194
|
-
type: _l7Core.gl.FLOAT
|
|
195
|
-
},
|
|
196
|
-
size: 1,
|
|
197
|
-
update: function update(feature) {
|
|
198
|
-
var _feature$rotate = feature.rotate,
|
|
199
|
-
rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
|
|
200
|
-
return Array.isArray(rotate) ? [rotate[0]] : [rotate];
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
175
|
this.styleAttributeService.registerStyleAttribute({
|
|
205
176
|
name: 'uv',
|
|
206
177
|
type: _l7Core.AttributeType.Attribute,
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
11
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
12
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
13
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
@@ -20,9 +21,9 @@ var _triangulation = require("../../core/triangulation");
|
|
|
20
21
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
21
22
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
22
23
|
/* babel-plugin-inline-import '../shaders/image_frag.glsl' */
|
|
23
|
-
var pointImageFrag = "\nuniform sampler2D u_texture;\nvarying vec4 v_color;\nvarying vec2 v_uv;\
|
|
24
|
+
var pointImageFrag = "\nuniform sampler2D u_texture;\nvarying vec4 v_color;\nvarying vec2 v_uv;\nvarying float v_opacity;\nuniform vec2 u_textSize;\n\n#pragma include \"picking\"\n\nvoid main(){\n vec2 pos = v_uv / u_textSize + gl_PointCoord / u_textSize * 64.;\n vec4 textureColor;\n\n // Y = 0.299R + 0.587G + 0.114B // \u4EAE\u5EA6\u63D0\u53D6\n \n textureColor = texture2D(u_texture, pos);\n\n // Tip: \u53BB\u9664\u8FB9\u7F18\u90E8\u5206 mipmap \u5BFC\u81F4\u7684\u6DF7\u5408\u53D8\u6697\n float fragmengTocenter = distance(vec2(0.5), gl_PointCoord);\n if(fragmengTocenter >= 0.5) {\n float luma = 0.299 * textureColor.r + 0.587 * textureColor.g + 0.114 * textureColor.b;\n textureColor.a *= luma;\n }\n \n \n\n if(all(lessThan(v_color, vec4(1.0+0.00001))) && all(greaterThan(v_color, vec4(1.0-0.00001))) || v_color==vec4(1.0)){\n gl_FragColor= textureColor;\n }else {\n gl_FragColor= step(0.01, textureColor.z) * v_color;\n }\n gl_FragColor.a *= v_opacity;\n if (gl_FragColor.a < 0.01) {\n discard;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
24
25
|
/* babel-plugin-inline-import '../shaders/image_vert.glsl' */
|
|
25
|
-
var pointImageVert = "precision highp float;\nattribute vec3 a_Position;\nattribute vec4 a_Color;\nattribute vec2 a_Uv;\nattribute float a_Size;\nvarying vec4 v_color;\nvarying vec2 v_uv;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\
|
|
26
|
+
var pointImageVert = "precision highp float;\nattribute vec3 a_Position;\nattribute vec4 a_Color;\nattribute vec2 a_Uv;\nattribute float a_Size;\nvarying vec4 v_color;\nvarying vec2 v_uv;\nvarying float v_opacity;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n v_color = a_Color;\n v_opacity = opacity;\n v_uv = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n \n vec2 offset = project_pixel(offsets);\n\n float raisingHeight = u_raisingHeight;\n if(u_heightfixed < 1.0) { // false\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
|
|
26
27
|
var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
27
28
|
(0, _inherits2.default)(ImageModel, _BaseModel);
|
|
28
29
|
var _super = _createSuper(ImageModel);
|
|
@@ -79,14 +80,12 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
79
80
|
if (this.rendererService.getDirty()) {
|
|
80
81
|
this.texture.bind();
|
|
81
82
|
}
|
|
82
|
-
return {
|
|
83
|
+
return (0, _objectSpread2.default)({
|
|
83
84
|
u_raisingHeight: Number(raisingHeight),
|
|
84
85
|
u_heightfixed: Number(heightfixed),
|
|
85
86
|
u_texture: this.texture,
|
|
86
|
-
u_textSize: [1024, this.iconService.canvasHeight || 128]
|
|
87
|
-
|
|
88
|
-
u_offsets: offsets
|
|
89
|
-
};
|
|
87
|
+
u_textSize: [1024, this.iconService.canvasHeight || 128]
|
|
88
|
+
}, this.getStyleAttribute());
|
|
90
89
|
}
|
|
91
90
|
}, {
|
|
92
91
|
key: "initModels",
|
|
@@ -130,6 +129,7 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
130
129
|
vertexShader: pointImageVert,
|
|
131
130
|
fragmentShader: pointImageFrag,
|
|
132
131
|
triangulation: _triangulation.PointImageTriangulation,
|
|
132
|
+
inject: this.getInject(),
|
|
133
133
|
depth: {
|
|
134
134
|
enable: false
|
|
135
135
|
},
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _billboard_point = _interopRequireDefault(require("./billboard_point"));
|
|
8
9
|
var _earthExtrude = _interopRequireDefault(require("./earthExtrude"));
|
|
9
10
|
var _earthFill = _interopRequireDefault(require("./earthFill"));
|
|
10
11
|
var _extrude = _interopRequireDefault(require("./extrude"));
|
|
@@ -13,7 +14,6 @@ var _fillmage = _interopRequireDefault(require("./fillmage"));
|
|
|
13
14
|
var _image = _interopRequireDefault(require("./image"));
|
|
14
15
|
var _normal = _interopRequireDefault(require("./normal"));
|
|
15
16
|
var _radar = _interopRequireDefault(require("./radar"));
|
|
16
|
-
var _simplePoint = _interopRequireDefault(require("./simplePoint"));
|
|
17
17
|
var _text = _interopRequireDefault(require("./text"));
|
|
18
18
|
// earth
|
|
19
19
|
|
|
@@ -23,7 +23,7 @@ var PointModels = {
|
|
|
23
23
|
radar: _radar.default,
|
|
24
24
|
image: _image.default,
|
|
25
25
|
normal: _normal.default,
|
|
26
|
-
simplePoint:
|
|
26
|
+
simplePoint: _billboard_point.default,
|
|
27
27
|
extrude: _extrude.default,
|
|
28
28
|
text: _text.default,
|
|
29
29
|
earthFill: _earthFill.default,
|
|
@@ -8,6 +8,7 @@ exports.PointTriangulation = PointTriangulation;
|
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
13
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
14
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
@@ -15,14 +16,15 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
15
16
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
16
17
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
17
18
|
var _l7Core = require("@antv/l7-core");
|
|
18
|
-
var
|
|
19
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
19
20
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
20
21
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
21
22
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
22
23
|
/* babel-plugin-inline-import '../shaders/normal_frag.glsl' */
|
|
23
24
|
var normalFrag = "varying vec4 v_color;\nvoid main() {\n gl_FragColor = v_color;\n}\n";
|
|
24
25
|
/* babel-plugin-inline-import '../shaders/normal_vert.glsl' */
|
|
25
|
-
var normalVert = "\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform
|
|
26
|
+
var normalVert = "\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nattribute float a_Size;\nattribute vec4 a_Color;\n\nvarying vec4 v_color;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n\nvoid main() {\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(a_Position.xy, a_Position.z, 1.0);\n } else {\n vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);\n gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy),project_pos.z,project_pos.w));\n }\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n}\n";
|
|
27
|
+
var isNumber = _l7Utils.lodashUtil.isNumber;
|
|
26
28
|
function PointTriangulation(feature) {
|
|
27
29
|
var coordinates = feature.coordinates;
|
|
28
30
|
return {
|
|
@@ -51,9 +53,7 @@ var NormalModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
51
53
|
var _ref = this.layer.getLayerConfig(),
|
|
52
54
|
_ref$opacity = _ref.opacity,
|
|
53
55
|
opacity = _ref$opacity === void 0 ? 1 : _ref$opacity;
|
|
54
|
-
return {
|
|
55
|
-
u_opacity: (0, _lodash.isNumber)(opacity) ? opacity : 1.0
|
|
56
|
-
};
|
|
56
|
+
return (0, _objectSpread2.default)({}, this.getStyleAttribute());
|
|
57
57
|
}
|
|
58
58
|
}, {
|
|
59
59
|
key: "initModels",
|
|
@@ -89,6 +89,7 @@ var NormalModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
89
89
|
vertexShader: normalVert,
|
|
90
90
|
fragmentShader: normalFrag,
|
|
91
91
|
triangulation: PointTriangulation,
|
|
92
|
+
inject: this.getInject(),
|
|
92
93
|
depth: {
|
|
93
94
|
enable: false
|
|
94
95
|
},
|
package/lib/point/models/text.js
CHANGED
|
@@ -19,7 +19,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
19
19
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
20
20
|
var _l7Core = require("@antv/l7-core");
|
|
21
21
|
var _l7Utils = require("@antv/l7-utils");
|
|
22
|
-
var _lodash = require("lodash");
|
|
23
22
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
24
23
|
var _collisionIndex = _interopRequireDefault(require("../../utils/collision-index"));
|
|
25
24
|
var _symbolLayout = require("../../utils/symbol-layout");
|
|
@@ -31,7 +30,8 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
31
30
|
/* babel-plugin-inline-import '../shaders/text_frag.glsl' */
|
|
32
31
|
var textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\nuniform sampler2D u_sdf_map;\nuniform float u_gamma_scale : 0.5;\nuniform float u_stroke_width : 2.0;\nuniform float u_halo_blur : 0.5;\nuniform float u_DevicePixelRatio;\n\nvarying vec4 v_color;\nvarying vec4 v_stroke_color;\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying float v_fontScale;\n\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n\n // get sdf from atlas\n float dist = texture2D(u_sdf_map, v_uv).a;\n\n lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;\n highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;\n\n highp float gamma_scaled = gamma * v_gamma_scale;\n\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n gl_FragColor = mix(v_color, v_stroke_color, smoothstep(0., 0.5, 1.- dist));\n\n gl_FragColor.a *= alpha;\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if (gl_FragColor.a < 0.01) {\n discard;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
33
32
|
/* babel-plugin-inline-import '../shaders/text_vert.glsl' */
|
|
34
|
-
var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\nattribute vec3 a_Position;\nattribute vec2 a_tex;\nattribute vec2 a_textOffsets;\nattribute vec4 a_Color;\nattribute float a_Size;\
|
|
33
|
+
var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\nattribute vec3 a_Position;\nattribute vec2 a_tex;\nattribute vec2 a_textOffsets;\nattribute vec4 a_Color;\nattribute float a_Size;\n\nuniform vec2 u_sdf_map_size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying vec4 v_color;\nvarying vec4 v_stroke_color;\nvarying float v_fontScale;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n \n v_uv = a_tex / u_sdf_map_size;\n\n\n\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n v_stroke_color = vec4(u_stroke_color.xyz, u_stroke_color.w * opacity);\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n vec2 offset = rotate_matrix(a_textOffsets,rotation);\n \n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n float raiseHeight = u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n vec4 projected_position;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n projected_position = u_Mvp *(vec4(a_Position.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n } else { // else\n projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n }\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + offset * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
|
|
34
|
+
var isEqual = _l7Utils.lodashUtil.isEqual;
|
|
35
35
|
function TextTrianglation(feature) {
|
|
36
36
|
// @ts-ignore
|
|
37
37
|
var that = this;
|
|
@@ -198,7 +198,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
198
198
|
while (1) switch (_context4.prev = _context4.next) {
|
|
199
199
|
case 0:
|
|
200
200
|
_ref4 = this.getTextStyle(), _ref4$textAllowOverla = _ref4.textAllowOverlap, textAllowOverlap = _ref4$textAllowOverla === void 0 ? false : _ref4$textAllowOverla, _ref4$textAnchor = _ref4.textAnchor, textAnchor = _ref4$textAnchor === void 0 ? 'center' : _ref4$textAnchor, textOffset = _ref4.textOffset, padding = _ref4.padding, fontFamily = _ref4.fontFamily, fontWeight = _ref4.fontWeight;
|
|
201
|
-
if (!(!
|
|
201
|
+
if (!(!isEqual(padding, this.preTextStyle.padding) || !isEqual(textOffset, this.preTextStyle.textOffset) || !isEqual(textAnchor, this.preTextStyle.textAnchor) || !isEqual(fontFamily, this.preTextStyle.fontFamily) || !isEqual(fontWeight, this.preTextStyle.fontWeight))) {
|
|
202
202
|
_context4.next = 5;
|
|
203
203
|
break;
|
|
204
204
|
}
|
|
@@ -249,24 +249,6 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
249
249
|
}, {
|
|
250
250
|
key: "registerBuiltinAttributes",
|
|
251
251
|
value: function registerBuiltinAttributes() {
|
|
252
|
-
this.styleAttributeService.registerStyleAttribute({
|
|
253
|
-
name: 'rotate',
|
|
254
|
-
type: _l7Core.AttributeType.Attribute,
|
|
255
|
-
descriptor: {
|
|
256
|
-
name: 'a_Rotate',
|
|
257
|
-
buffer: {
|
|
258
|
-
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
259
|
-
data: [],
|
|
260
|
-
type: _l7Core.gl.FLOAT
|
|
261
|
-
},
|
|
262
|
-
size: 1,
|
|
263
|
-
update: function update(feature) {
|
|
264
|
-
var _feature$rotate = feature.rotate,
|
|
265
|
-
rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
|
|
266
|
-
return Array.isArray(rotate) ? [rotate[0]] : [rotate];
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
252
|
this.styleAttributeService.registerStyleAttribute({
|
|
271
253
|
name: 'textOffsets',
|
|
272
254
|
type: _l7Core.AttributeType.Attribute,
|
|
@@ -3,7 +3,6 @@ attribute vec3 a_Position;
|
|
|
3
3
|
attribute vec3 a_Extrude;
|
|
4
4
|
attribute float a_Size;
|
|
5
5
|
attribute float a_Shape;
|
|
6
|
-
|
|
7
6
|
uniform mat4 u_ModelMatrix;
|
|
8
7
|
uniform mat4 u_Mvp;
|
|
9
8
|
uniform int u_size_unit;
|
|
@@ -12,19 +11,18 @@ varying vec4 v_data;
|
|
|
12
11
|
varying vec4 v_color;
|
|
13
12
|
varying float v_radius;
|
|
14
13
|
varying vec4 v_stroke;
|
|
15
|
-
|
|
16
|
-
// uniform float u_opacity : 1;
|
|
17
14
|
uniform float u_stroke_width: 2;
|
|
18
15
|
uniform vec3 u_blur_height_fixed: [0, 0, 0];
|
|
19
16
|
|
|
20
17
|
|
|
21
18
|
#pragma include "projection"
|
|
22
19
|
#pragma include "picking"
|
|
20
|
+
#pragma include "rotation_2d"
|
|
23
21
|
|
|
24
22
|
|
|
25
23
|
void main() {
|
|
26
24
|
// 透明度计算
|
|
27
|
-
|
|
25
|
+
v_stroke = stroke;
|
|
28
26
|
vec3 extrude = a_Extrude;
|
|
29
27
|
float shape_type = a_Shape;
|
|
30
28
|
/*
|
|
@@ -53,6 +51,7 @@ void main() {
|
|
|
53
51
|
vec3 aPosition = a_Position;
|
|
54
52
|
|
|
55
53
|
offset = project_pixel(offset);
|
|
54
|
+
offset = rotate_matrix(offset,rotation);
|
|
56
55
|
|
|
57
56
|
// TODP: /abs(extrude.x) 是为了兼容地球模式
|
|
58
57
|
v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);
|
|
@@ -6,12 +6,13 @@ uniform float u_opacity : 1;
|
|
|
6
6
|
#pragma include "picking"
|
|
7
7
|
varying vec2 v_uv; // 本身的 uv 坐标
|
|
8
8
|
varying vec2 v_Iconuv;
|
|
9
|
+
varying float v_opacity;
|
|
9
10
|
|
|
10
11
|
void main() {
|
|
11
12
|
|
|
12
13
|
vec2 pos = v_Iconuv / u_textSize + v_uv / u_textSize * 64.;
|
|
13
14
|
gl_FragColor = texture2D(u_texture, pos);
|
|
14
|
-
gl_FragColor.a *=
|
|
15
|
+
gl_FragColor.a *= v_opacity;
|
|
15
16
|
|
|
16
17
|
gl_FragColor = filterColor(gl_FragColor);
|
|
17
18
|
}
|
|
@@ -3,7 +3,6 @@ attribute vec3 a_Position;
|
|
|
3
3
|
attribute vec3 a_Extrude;
|
|
4
4
|
attribute float a_Size;
|
|
5
5
|
attribute vec2 a_Uv;
|
|
6
|
-
attribute float a_Rotate;
|
|
7
6
|
|
|
8
7
|
uniform mat4 u_ModelMatrix;
|
|
9
8
|
uniform mat4 u_Mvp;
|
|
@@ -15,31 +14,30 @@ varying vec2 v_Iconuv; // icon 贴图的 uv 坐标
|
|
|
15
14
|
|
|
16
15
|
uniform float u_raisingHeight: 0.0;
|
|
17
16
|
uniform float u_heightfixed: 0.0;
|
|
18
|
-
|
|
19
|
-
uniform vec2 u_offsets;
|
|
20
|
-
|
|
17
|
+
varying float v_opacity;
|
|
18
|
+
// uniform vec2 u_offsets; // shader 注入
|
|
21
19
|
|
|
22
20
|
|
|
23
21
|
#pragma include "projection"
|
|
24
22
|
#pragma include "picking"
|
|
23
|
+
#pragma include "rotation_2d"
|
|
25
24
|
|
|
26
25
|
void main() {
|
|
27
26
|
vec3 extrude = a_Extrude;
|
|
28
27
|
v_uv = (a_Extrude.xy + 1.0)/2.0;
|
|
29
28
|
v_uv.y = 1.0 - v_uv.y;
|
|
30
29
|
v_Iconuv = a_Uv;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
highp float angle_sin = sin(a_Rotate);
|
|
34
|
-
highp float angle_cos = cos(a_Rotate);
|
|
35
|
-
mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);
|
|
30
|
+
v_opacity = opacity;
|
|
36
31
|
float newSize = a_Size;
|
|
37
32
|
if(u_size_unit == 1) {
|
|
38
33
|
newSize = newSize * u_PixelsPerMeter.z;
|
|
39
34
|
}
|
|
40
|
-
|
|
35
|
+
|
|
41
36
|
// vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);
|
|
42
|
-
vec2 offset = (
|
|
37
|
+
vec2 offset = (extrude.xy * (newSize) + offsets);
|
|
38
|
+
|
|
39
|
+
offset = rotate_matrix(offset,rotation);
|
|
40
|
+
|
|
43
41
|
vec3 aPosition = a_Position;
|
|
44
42
|
|
|
45
43
|
offset = project_pixel(offset);
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
uniform sampler2D u_texture;
|
|
3
3
|
varying vec4 v_color;
|
|
4
4
|
varying vec2 v_uv;
|
|
5
|
+
varying float v_opacity;
|
|
5
6
|
uniform vec2 u_textSize;
|
|
6
|
-
uniform float u_opacity : 1;
|
|
7
7
|
|
|
8
8
|
#pragma include "picking"
|
|
9
9
|
|
|
@@ -29,9 +29,7 @@ void main(){
|
|
|
29
29
|
}else {
|
|
30
30
|
gl_FragColor= step(0.01, textureColor.z) * v_color;
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
gl_FragColor.a = gl_FragColor.a * u_opacity;
|
|
34
|
-
|
|
32
|
+
gl_FragColor.a *= v_opacity;
|
|
35
33
|
if (gl_FragColor.a < 0.01) {
|
|
36
34
|
discard;
|
|
37
35
|
}
|
|
@@ -5,15 +5,13 @@ attribute vec2 a_Uv;
|
|
|
5
5
|
attribute float a_Size;
|
|
6
6
|
varying vec4 v_color;
|
|
7
7
|
varying vec2 v_uv;
|
|
8
|
+
varying float v_opacity;
|
|
8
9
|
uniform mat4 u_ModelMatrix;
|
|
9
10
|
uniform mat4 u_Mvp;
|
|
10
|
-
uniform vec2 u_offsets;
|
|
11
11
|
|
|
12
|
-
uniform float u_opacity : 1;
|
|
13
12
|
uniform float u_raisingHeight: 0.0;
|
|
14
13
|
uniform float u_heightfixed: 0.0;
|
|
15
14
|
|
|
16
|
-
|
|
17
15
|
#pragma include "projection"
|
|
18
16
|
#pragma include "picking"
|
|
19
17
|
|
|
@@ -21,10 +19,11 @@ void main() {
|
|
|
21
19
|
|
|
22
20
|
// cal style mapping - 数据纹理映射部分的计算
|
|
23
21
|
v_color = a_Color;
|
|
22
|
+
v_opacity = opacity;
|
|
24
23
|
v_uv = a_Uv;
|
|
25
24
|
vec4 project_pos = project_position(vec4(a_Position, 1.0));
|
|
26
25
|
|
|
27
|
-
vec2 offset = project_pixel(
|
|
26
|
+
vec2 offset = project_pixel(offsets);
|
|
28
27
|
|
|
29
28
|
float raisingHeight = u_raisingHeight;
|
|
30
29
|
if(u_heightfixed < 1.0) { // false
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
attribute vec3 a_Position;
|
|
3
3
|
uniform mat4 u_ModelMatrix;
|
|
4
|
-
uniform float u_opacity : 1;
|
|
5
4
|
uniform mat4 u_Mvp;
|
|
6
5
|
attribute float a_Size;
|
|
7
6
|
attribute vec4 a_Color;
|
|
@@ -12,7 +11,7 @@ varying vec4 v_color;
|
|
|
12
11
|
#pragma include "project"
|
|
13
12
|
|
|
14
13
|
void main() {
|
|
15
|
-
v_color = vec4(a_Color.xyz, a_Color.w *
|
|
14
|
+
v_color = vec4(a_Color.xyz, a_Color.w * opacity);
|
|
16
15
|
|
|
17
16
|
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
18
17
|
gl_Position = u_Mvp * vec4(a_Position.xy, a_Position.z, 1.0);
|