@antv/l7-layers 2.19.10 → 2.20.0
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/canvas/models/canvas.js +2 -2
- package/es/core/BaseLayer.d.ts +1 -1
- package/es/core/BaseLayer.js +22 -15
- package/es/core/BaseModel.d.ts +3 -1
- package/es/core/BaseModel.js +28 -4
- package/es/core/CommonStyleAttribute.d.ts +15 -0
- package/es/core/CommonStyleAttribute.js +21 -0
- package/es/core/TextureService.js +2 -2
- package/es/core/interface.d.ts +13 -9
- package/es/core/line_trangluation.d.ts +19 -0
- package/es/core/line_trangluation.js +91 -0
- package/es/core/shape/arrow.d.ts +25 -0
- package/es/core/shape/arrow.js +160 -0
- package/es/core/triangulation.d.ts +2 -8
- package/es/core/triangulation.js +6 -34
- package/es/earth/index.js +1 -1
- package/es/geometry/index.js +1 -1
- package/es/geometry/models/billboard.js +1 -1
- package/es/geometry/models/plane.js +2 -2
- package/es/geometry/models/sprite.js +2 -2
- package/es/heatmap/index.js +1 -1
- package/es/heatmap/models/heatmap.js +4 -4
- package/es/image/models/image.js +1 -1
- package/es/line/index.js +3 -2
- package/es/line/models/arc.js +6 -4
- package/es/line/models/arc_3d.js +4 -2
- package/es/line/models/earthArc_3d.js +4 -2
- package/es/line/models/flow.js +4 -5
- package/es/line/models/great_circle.js +1 -1
- package/es/line/models/line.js +3 -15
- package/es/line/models/linearline.js +1 -1
- package/es/line/models/wall.js +1 -1
- package/es/line/shaders/dash/arc_dash_vert.glsl +2 -5
- package/es/line/shaders/flow/flow_line_vert.glsl +36 -6
- package/es/line/shaders/linear/arc_linear_vert.glsl +2 -3
- package/es/plugins/DataMappingPlugin.js +3 -20
- package/es/plugins/PixelPickingPlugin.d.ts +4 -1
- package/es/plugins/PixelPickingPlugin.js +91 -22
- package/es/plugins/RegisterStyleAttributePlugin.d.ts +0 -1
- package/es/plugins/RegisterStyleAttributePlugin.js +4 -22
- package/es/plugins/ShaderUniformPlugin.d.ts +2 -0
- package/es/plugins/ShaderUniformPlugin.js +74 -6
- package/es/point/index.js +1 -1
- package/es/point/models/fill.js +31 -7
- package/es/point/models/fillmage.js +1 -1
- package/es/point/models/image.js +1 -1
- package/es/point/models/normal.js +30 -12
- package/es/point/models/text.js +1 -1
- package/es/point/shaders/fill_frag.glsl +20 -14
- package/es/point/shaders/fill_vert.glsl +19 -18
- package/es/point/shaders/normal_frag.glsl +4 -3
- package/es/point/shaders/normal_vert.glsl +12 -11
- package/es/polygon/index.js +1 -1
- package/es/polygon/models/extrude.js +1 -1
- package/es/polygon/models/extrusion.js +1 -1
- package/es/polygon/models/ocean.js +3 -3
- package/es/polygon/models/water.js +1 -1
- package/es/raster/models/raster.js +2 -2
- package/es/raster/models/rasterRgb.js +1 -1
- package/es/raster/models/rasterTerrainRgb.js +1 -1
- package/es/tile/core/BaseLayer.js +4 -4
- package/es/tile/interaction/getRasterData.js +4 -4
- package/es/tile/service/TileLayerService.js +4 -4
- package/es/tile/service/TilePickService.js +3 -3
- package/es/tile/tile/Tile.d.ts +3 -1
- package/es/tile/tile/Tile.js +2 -2
- package/es/wind/models/wind.js +5 -6
- package/lib/canvas/index.js +2 -3
- package/lib/canvas/models/canvas.js +4 -5
- package/lib/canvas/models/index.js +1 -2
- package/lib/citybuliding/building.js +2 -3
- package/lib/citybuliding/models/build.js +2 -3
- package/lib/core/BaseLayer.js +23 -17
- package/lib/core/BaseModel.js +30 -7
- package/lib/core/CommonStyleAttribute.js +22 -0
- package/lib/core/LayerPickService.js +2 -3
- package/lib/core/TextureService.js +4 -5
- package/lib/core/constant.js +3 -5
- package/lib/core/interface.js +6 -11
- package/lib/core/line_trangluation.js +99 -0
- package/lib/core/schema.js +2 -3
- package/lib/core/shape/Path.js +3 -6
- package/lib/core/shape/arrow.js +174 -0
- package/lib/core/triangulation.js +8 -37
- package/lib/earth/index.js +3 -4
- package/lib/earth/models/atmosphere.js +2 -3
- package/lib/earth/models/base.js +2 -3
- package/lib/earth/models/bloomsphere.js +2 -3
- package/lib/earth/utils.js +3 -6
- package/lib/geometry/index.js +3 -4
- package/lib/geometry/models/billboard.js +3 -4
- package/lib/geometry/models/index.js +1 -2
- package/lib/geometry/models/plane.js +4 -5
- package/lib/geometry/models/sprite.js +4 -5
- package/lib/heatmap/index.js +3 -4
- package/lib/heatmap/models/grid.js +2 -3
- package/lib/heatmap/models/grid3d.js +2 -3
- package/lib/heatmap/models/heatmap.js +6 -7
- package/lib/heatmap/models/hexagon.js +2 -3
- package/lib/heatmap/models/index.js +1 -2
- package/lib/image/index.js +2 -3
- package/lib/image/models/image.js +3 -4
- package/lib/image/models/index.js +1 -2
- package/lib/line/index.js +5 -5
- package/lib/line/models/arc.js +8 -7
- package/lib/line/models/arc_3d.js +6 -5
- package/lib/line/models/earthArc_3d.js +6 -5
- package/lib/line/models/flow.js +6 -8
- package/lib/line/models/great_circle.js +3 -4
- package/lib/line/models/index.js +1 -2
- package/lib/line/models/line.js +5 -18
- package/lib/line/models/linearline.js +3 -4
- package/lib/line/models/simpleLine.js +2 -3
- package/lib/line/models/wall.js +3 -4
- package/lib/line/shaders/dash/arc_dash_vert.glsl +2 -5
- package/lib/line/shaders/flow/flow_line_vert.glsl +36 -6
- package/lib/line/shaders/linear/arc_linear_vert.glsl +2 -3
- package/lib/mask/index.js +2 -3
- package/lib/mask/models/fill.js +2 -3
- package/lib/mask/models/index.js +1 -2
- package/lib/plugins/DataMappingPlugin.js +5 -23
- package/lib/plugins/DataSourcePlugin.js +2 -3
- package/lib/plugins/FeatureScalePlugin.js +4 -5
- package/lib/plugins/LayerAnimateStylePlugin.js +2 -3
- package/lib/plugins/LayerMaskPlugin.js +2 -3
- package/lib/plugins/LayerModelPlugin.js +2 -3
- package/lib/plugins/LayerStylePlugin.js +2 -3
- package/lib/plugins/LightingPlugin.js +2 -3
- package/lib/plugins/MultiPassRendererPlugin.js +2 -3
- package/lib/plugins/PixelPickingPlugin.js +93 -25
- package/lib/plugins/RegisterStyleAttributePlugin.js +6 -25
- package/lib/plugins/ShaderUniformPlugin.js +75 -8
- package/lib/plugins/UpdateModelPlugin.js +2 -3
- package/lib/plugins/UpdateStyleAttributePlugin.js +2 -3
- package/lib/point/index.js +3 -4
- package/lib/point/models/billboard_point.js +2 -3
- package/lib/point/models/earthExtrude.js +2 -3
- package/lib/point/models/earthFill.js +2 -3
- package/lib/point/models/extrude.js +2 -3
- package/lib/point/models/fill.js +33 -10
- package/lib/point/models/fillmage.js +3 -4
- package/lib/point/models/image.js +3 -4
- package/lib/point/models/index.js +1 -2
- package/lib/point/models/normal.js +32 -15
- package/lib/point/models/radar.js +2 -3
- package/lib/point/models/text.js +3 -4
- package/lib/point/shaders/fill_frag.glsl +20 -14
- package/lib/point/shaders/fill_vert.glsl +19 -18
- package/lib/point/shaders/normal_frag.glsl +4 -3
- package/lib/point/shaders/normal_vert.glsl +12 -11
- package/lib/polygon/index.js +3 -4
- package/lib/polygon/models/extrude.js +3 -4
- package/lib/polygon/models/extrusion.js +3 -4
- package/lib/polygon/models/fill.js +2 -3
- package/lib/polygon/models/index.js +1 -2
- package/lib/polygon/models/ocean.js +5 -6
- package/lib/polygon/models/water.js +3 -4
- package/lib/raster/index.js +2 -3
- package/lib/raster/models/index.js +1 -2
- package/lib/raster/models/raster.js +4 -5
- package/lib/raster/models/rasterRgb.js +3 -4
- package/lib/raster/models/rasterTerrainRgb.js +3 -4
- package/lib/tile/core/BaseLayer.js +6 -7
- package/lib/tile/core/TileDebugLayer.js +2 -3
- package/lib/tile/interaction/getRasterData.js +4 -4
- package/lib/tile/service/TileLayerService.js +6 -7
- package/lib/tile/service/TilePickService.js +5 -6
- package/lib/tile/service/TileSourceService.js +4 -5
- package/lib/tile/tile/DebugTile.js +2 -3
- package/lib/tile/tile/ImageTile.js +2 -3
- package/lib/tile/tile/MaskTile.js +2 -3
- package/lib/tile/tile/RasterRGBTile.js +2 -3
- package/lib/tile/tile/RasterTerrainRGBTile.js +2 -3
- package/lib/tile/tile/RasterTile.js +2 -3
- package/lib/tile/tile/Tile.js +4 -5
- package/lib/tile/tile/VectorTile.js +2 -3
- package/lib/tile/utils/constants.js +2 -3
- package/lib/tile/utils/utils.js +1 -2
- package/lib/utils/blend.js +2 -3
- package/lib/utils/collision-index.js +2 -3
- package/lib/utils/extrude_polyline.js +2 -3
- package/lib/utils/grid-index.js +1 -2
- package/lib/utils/simpleLine.js +2 -3
- package/lib/wind/index.js +2 -3
- package/lib/wind/models/index.js +1 -2
- package/lib/wind/models/wind.js +7 -9
- package/lib/wind/models/windRender.js +4 -5
- package/lib/wind/models/windShader.js +6 -12
- package/package.json +7 -7
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
8
10
|
var _initializerDefineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/initializerDefineProperty"));
|
|
9
11
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
12
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -14,7 +16,7 @@ var _initializerWarningHelper2 = _interopRequireDefault(require("@babel/runtime/
|
|
|
14
16
|
var _l7Core = require("@antv/l7-core");
|
|
15
17
|
var _inversify = require("inversify");
|
|
16
18
|
require("reflect-metadata");
|
|
17
|
-
var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;
|
|
19
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5;
|
|
18
20
|
/**
|
|
19
21
|
* 在渲染之前需要获取当前 Shader 所需 Uniform,例如:
|
|
20
22
|
* 1. 从相机服务中获取 View & ProjectionMatrix,当前缩放等级等等
|
|
@@ -22,13 +24,14 @@ var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2
|
|
|
22
24
|
* @see https://yuque.antfin-inc.com/yuqi.pyq/fgetpa/doml91
|
|
23
25
|
* 3. 当前 Layer 本身的样式属性
|
|
24
26
|
*/
|
|
25
|
-
var ShaderUniformPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inversify.inject)(_l7Core.TYPES.ICameraService), _dec3 = (0, _inversify.inject)(_l7Core.TYPES.ICoordinateSystemService), _dec4 = (0, _inversify.inject)(_l7Core.TYPES.IRendererService), _dec5 = (0, _inversify.inject)(_l7Core.TYPES.IMapService), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
27
|
+
var ShaderUniformPlugin = exports.default = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inversify.inject)(_l7Core.TYPES.ICameraService), _dec3 = (0, _inversify.inject)(_l7Core.TYPES.ICoordinateSystemService), _dec4 = (0, _inversify.inject)(_l7Core.TYPES.IRendererService), _dec5 = (0, _inversify.inject)(_l7Core.TYPES.IMapService), _dec6 = (0, _inversify.inject)(_l7Core.TYPES.ILayerService), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
26
28
|
function ShaderUniformPlugin() {
|
|
27
29
|
(0, _classCallCheck2.default)(this, ShaderUniformPlugin);
|
|
28
30
|
(0, _initializerDefineProperty2.default)(this, "cameraService", _descriptor, this);
|
|
29
31
|
(0, _initializerDefineProperty2.default)(this, "coordinateSystemService", _descriptor2, this);
|
|
30
32
|
(0, _initializerDefineProperty2.default)(this, "rendererService", _descriptor3, this);
|
|
31
33
|
(0, _initializerDefineProperty2.default)(this, "mapService", _descriptor4, this);
|
|
34
|
+
(0, _initializerDefineProperty2.default)(this, "layerService", _descriptor5, this);
|
|
32
35
|
}
|
|
33
36
|
(0, _createClass2.default)(ShaderUniformPlugin, [{
|
|
34
37
|
key: "apply",
|
|
@@ -37,6 +40,15 @@ var ShaderUniformPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inv
|
|
|
37
40
|
var version = this.mapService.version;
|
|
38
41
|
var mvp = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; // default matrix (for gaode2.x)
|
|
39
42
|
var sceneCenterMercator = [0, 0];
|
|
43
|
+
var uniformBuffer;
|
|
44
|
+
if (!this.rendererService.uniformBuffers[0]) {
|
|
45
|
+
// Create a Uniform Buffer Object(UBO).
|
|
46
|
+
uniformBuffer = this.rendererService.createBuffer({
|
|
47
|
+
data: new Float32Array(16 * 5 + 4 * 6 + 4),
|
|
48
|
+
isUBO: true
|
|
49
|
+
});
|
|
50
|
+
this.rendererService.uniformBuffers[0] = uniformBuffer;
|
|
51
|
+
}
|
|
40
52
|
layer.hooks.beforeRender.tap('ShaderUniformPlugin', function () {
|
|
41
53
|
// @ts-ignore
|
|
42
54
|
var offset = layer.getLayerConfig().tileOrigin;
|
|
@@ -53,12 +65,25 @@ var ShaderUniformPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inv
|
|
|
53
65
|
var _this$rendererService = _this.rendererService.getViewportSize(),
|
|
54
66
|
width = _this$rendererService.width,
|
|
55
67
|
height = _this$rendererService.height;
|
|
68
|
+
var _this$generateUBO = _this.generateUBO(mvp, sceneCenterMercator, width, height),
|
|
69
|
+
data = _this$generateUBO.data,
|
|
70
|
+
uniforms = _this$generateUBO.uniforms;
|
|
71
|
+
if (_this.layerService.alreadyInRendering && uniformBuffer) {
|
|
72
|
+
// Update only once since all models can share one UBO.
|
|
73
|
+
uniformBuffer.subData({
|
|
74
|
+
offset: 0,
|
|
75
|
+
data: data
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
// For WebGL1. regl
|
|
56
79
|
layer.models.forEach(function (model) {
|
|
57
|
-
|
|
58
|
-
|
|
80
|
+
model.addUniforms((0, _objectSpread2.default)((0, _objectSpread2.default)({}, uniforms), {}, {
|
|
81
|
+
// TODO: move these 2 uniforms to PixelPickingPlugin
|
|
82
|
+
u_PickingBuffer: layer.getLayerConfig().pickingBuffer || 0,
|
|
83
|
+
// Tip: 当前地图是否在拖动
|
|
84
|
+
u_shaderPick: Number(layer.getShaderPickStat())
|
|
85
|
+
}));
|
|
59
86
|
});
|
|
60
|
-
|
|
61
|
-
// TODO:脏检查,决定是否需要渲染
|
|
62
87
|
});
|
|
63
88
|
}
|
|
64
89
|
|
|
@@ -76,6 +101,44 @@ var ShaderUniformPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inv
|
|
|
76
101
|
this.mapService.setCoordCenter(layer.coordCenter);
|
|
77
102
|
}
|
|
78
103
|
}
|
|
104
|
+
}, {
|
|
105
|
+
key: "generateUBO",
|
|
106
|
+
value: function generateUBO(u_Mvp, sceneCenterMercator, width, height) {
|
|
107
|
+
var _uniforms;
|
|
108
|
+
var u_ProjectionMatrix = this.cameraService.getProjectionMatrix();
|
|
109
|
+
var u_ViewMatrix = this.cameraService.getViewMatrix();
|
|
110
|
+
var u_ViewProjectionMatrix = this.cameraService.getViewProjectionMatrix();
|
|
111
|
+
var u_ModelMatrix = this.cameraService.getModelMatrix();
|
|
112
|
+
var u_ViewportCenterProjection = this.coordinateSystemService.getViewportCenterProjection();
|
|
113
|
+
var u_PixelsPerDegree = this.coordinateSystemService.getPixelsPerDegree();
|
|
114
|
+
var u_Zoom = this.cameraService.getZoom();
|
|
115
|
+
var u_PixelsPerDegree2 = this.coordinateSystemService.getPixelsPerDegree2();
|
|
116
|
+
var u_ZoomScale = this.cameraService.getZoomScale();
|
|
117
|
+
var u_PixelsPerMeter = this.coordinateSystemService.getPixelsPerMeter();
|
|
118
|
+
var u_CoordinateSystem = this.coordinateSystemService.getCoordinateSystem();
|
|
119
|
+
var u_CameraPosition = this.cameraService.getCameraPosition();
|
|
120
|
+
var u_DevicePixelRatio = window.devicePixelRatio;
|
|
121
|
+
var u_ViewportCenter = this.coordinateSystemService.getViewportCenter();
|
|
122
|
+
var u_ViewportSize = [width, height];
|
|
123
|
+
var u_FocalDistance = this.cameraService.getFocalDistance();
|
|
124
|
+
var data = [].concat((0, _toConsumableArray2.default)(u_ViewMatrix), (0, _toConsumableArray2.default)(u_ProjectionMatrix), (0, _toConsumableArray2.default)(u_ViewProjectionMatrix), (0, _toConsumableArray2.default)(u_ModelMatrix), (0, _toConsumableArray2.default)(u_Mvp), (0, _toConsumableArray2.default)(u_ViewportCenterProjection), (0, _toConsumableArray2.default)(u_PixelsPerDegree), [
|
|
125
|
+
// 4
|
|
126
|
+
u_Zoom], (0, _toConsumableArray2.default)(u_PixelsPerDegree2), [
|
|
127
|
+
// 4
|
|
128
|
+
u_ZoomScale], (0, _toConsumableArray2.default)(u_PixelsPerMeter), [
|
|
129
|
+
// 4
|
|
130
|
+
u_CoordinateSystem], (0, _toConsumableArray2.default)(u_CameraPosition), [
|
|
131
|
+
// 4
|
|
132
|
+
u_DevicePixelRatio], (0, _toConsumableArray2.default)(u_ViewportCenter), u_ViewportSize, (0, _toConsumableArray2.default)(sceneCenterMercator), [
|
|
133
|
+
// 2
|
|
134
|
+
u_FocalDistance,
|
|
135
|
+
// 1
|
|
136
|
+
0]);
|
|
137
|
+
return {
|
|
138
|
+
data: data,
|
|
139
|
+
uniforms: (_uniforms = {}, (0, _defineProperty2.default)(_uniforms, _l7Core.CameraUniform.ProjectionMatrix, u_ProjectionMatrix), (0, _defineProperty2.default)(_uniforms, _l7Core.CameraUniform.ViewMatrix, u_ViewMatrix), (0, _defineProperty2.default)(_uniforms, _l7Core.CameraUniform.ViewProjectionMatrix, u_ViewProjectionMatrix), (0, _defineProperty2.default)(_uniforms, _l7Core.CameraUniform.Zoom, u_Zoom), (0, _defineProperty2.default)(_uniforms, _l7Core.CameraUniform.ZoomScale, u_ZoomScale), (0, _defineProperty2.default)(_uniforms, _l7Core.CameraUniform.FocalDistance, u_FocalDistance), (0, _defineProperty2.default)(_uniforms, _l7Core.CameraUniform.CameraPosition, u_CameraPosition), (0, _defineProperty2.default)(_uniforms, _l7Core.CoordinateUniform.CoordinateSystem, u_CoordinateSystem), (0, _defineProperty2.default)(_uniforms, _l7Core.CoordinateUniform.ViewportCenter, u_ViewportCenter), (0, _defineProperty2.default)(_uniforms, _l7Core.CoordinateUniform.ViewportCenterProjection, u_ViewportCenterProjection), (0, _defineProperty2.default)(_uniforms, _l7Core.CoordinateUniform.PixelsPerDegree, u_PixelsPerDegree), (0, _defineProperty2.default)(_uniforms, _l7Core.CoordinateUniform.PixelsPerDegree2, u_PixelsPerDegree2), (0, _defineProperty2.default)(_uniforms, _l7Core.CoordinateUniform.PixelsPerMeter, u_PixelsPerMeter), (0, _defineProperty2.default)(_uniforms, _l7Core.CoordinateUniform.Mvp, u_Mvp), (0, _defineProperty2.default)(_uniforms, "u_sceneCenterMercator", sceneCenterMercator), (0, _defineProperty2.default)(_uniforms, "u_ViewportSize", u_ViewportSize), (0, _defineProperty2.default)(_uniforms, "u_ModelMatrix", u_ModelMatrix), (0, _defineProperty2.default)(_uniforms, "u_DevicePixelRatio", u_DevicePixelRatio), _uniforms)
|
|
140
|
+
};
|
|
141
|
+
}
|
|
79
142
|
}]);
|
|
80
143
|
return ShaderUniformPlugin;
|
|
81
144
|
}(), (_descriptor = (0, _applyDecoratedDescriptor2.default)(_class2.prototype, "cameraService", [_dec2], {
|
|
@@ -98,5 +161,9 @@ var ShaderUniformPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inv
|
|
|
98
161
|
enumerable: true,
|
|
99
162
|
writable: true,
|
|
100
163
|
initializer: null
|
|
101
|
-
})
|
|
102
|
-
|
|
164
|
+
}), _descriptor5 = (0, _applyDecoratedDescriptor2.default)(_class2.prototype, "layerService", [_dec6], {
|
|
165
|
+
configurable: true,
|
|
166
|
+
enumerable: true,
|
|
167
|
+
writable: true,
|
|
168
|
+
initializer: null
|
|
169
|
+
})), _class2)) || _class);
|
|
@@ -13,7 +13,7 @@ var _dec, _class;
|
|
|
13
13
|
/**
|
|
14
14
|
* Model 更新
|
|
15
15
|
*/
|
|
16
|
-
var UpdateModelPlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
|
|
16
|
+
var UpdateModelPlugin = exports.default = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
|
|
17
17
|
function UpdateModelPlugin() {
|
|
18
18
|
(0, _classCallCheck2.default)(this, UpdateModelPlugin);
|
|
19
19
|
}
|
|
@@ -36,5 +36,4 @@ var UpdateModelPlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#_
|
|
|
36
36
|
}
|
|
37
37
|
}]);
|
|
38
38
|
return UpdateModelPlugin;
|
|
39
|
-
}()) || _class);
|
|
40
|
-
exports.default = UpdateModelPlugin;
|
|
39
|
+
}()) || _class);
|
|
@@ -13,7 +13,7 @@ var _dec, _class;
|
|
|
13
13
|
/**
|
|
14
14
|
* 在初始化阶段完成属性的注册,以及首次根据 Layer 指定的三角化方法完成 indices 和 attribute 的创建
|
|
15
15
|
*/
|
|
16
|
-
var UpdateStyleAttributePlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
|
|
16
|
+
var UpdateStyleAttributePlugin = exports.default = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
|
|
17
17
|
function UpdateStyleAttributePlugin() {
|
|
18
18
|
(0, _classCallCheck2.default)(this, UpdateStyleAttributePlugin);
|
|
19
19
|
}
|
|
@@ -78,5 +78,4 @@ var UpdateStyleAttributePlugin = (_dec = (0, _inversify.injectable)(), _dec(_cla
|
|
|
78
78
|
}
|
|
79
79
|
}]);
|
|
80
80
|
return UpdateStyleAttributePlugin;
|
|
81
|
-
}()) || _class);
|
|
82
|
-
exports.default = UpdateStyleAttributePlugin;
|
|
81
|
+
}()) || _class);
|
package/lib/point/index.js
CHANGED
|
@@ -21,7 +21,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
21
21
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
22
22
|
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); }; }
|
|
23
23
|
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
|
-
var PointLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
24
|
+
var PointLayer = exports.default = /*#__PURE__*/function (_BaseLayer) {
|
|
25
25
|
(0, _inherits2.default)(PointLayer, _BaseLayer);
|
|
26
26
|
var _super = _createSuper(PointLayer);
|
|
27
27
|
function PointLayer() {
|
|
@@ -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", ['
|
|
35
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "enableShaderEncodeStyles", ['stroke', 'offsets', 'opacity', '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: [],
|
|
@@ -209,5 +209,4 @@ var PointLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
|
209
209
|
}
|
|
210
210
|
}]);
|
|
211
211
|
return PointLayer;
|
|
212
|
-
}(_BaseLayer2.default);
|
|
213
|
-
exports.default = PointLayer;
|
|
212
|
+
}(_BaseLayer2.default);
|
|
@@ -31,7 +31,7 @@ function PointTriangulation(feature) {
|
|
|
31
31
|
size: coordinates.length
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
var SimplePointModel = /*#__PURE__*/function (_BaseModel) {
|
|
34
|
+
var SimplePointModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
35
35
|
(0, _inherits2.default)(SimplePointModel, _BaseModel);
|
|
36
36
|
var _super = _createSuper(SimplePointModel);
|
|
37
37
|
function SimplePointModel() {
|
|
@@ -146,5 +146,4 @@ var SimplePointModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
146
146
|
}
|
|
147
147
|
}]);
|
|
148
148
|
return SimplePointModel;
|
|
149
|
-
}(_BaseModel2.default);
|
|
150
|
-
exports.default = SimplePointModel;
|
|
149
|
+
}(_BaseModel2.default);
|
|
@@ -26,7 +26,7 @@ var pointExtrudeFrag = "varying vec4 v_color;\nuniform float u_opacity: 1.0;\n\n
|
|
|
26
26
|
/* babel-plugin-inline-import '../shaders/earth/extrude_vert.glsl' */
|
|
27
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;\n\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
28
|
var isNumber = _l7Utils.lodashUtil.isNumber;
|
|
29
|
-
var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
29
|
+
var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
30
30
|
(0, _inherits2.default)(ExtrudeModel, _BaseModel);
|
|
31
31
|
var _super = _createSuper(ExtrudeModel);
|
|
32
32
|
function ExtrudeModel() {
|
|
@@ -237,5 +237,4 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
237
237
|
}
|
|
238
238
|
}]);
|
|
239
239
|
return ExtrudeModel;
|
|
240
|
-
}(_BaseModel2.default);
|
|
241
|
-
exports.default = ExtrudeModel;
|
|
240
|
+
}(_BaseModel2.default);
|
|
@@ -25,7 +25,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
25
25
|
var pointFillFrag = "uniform float u_additive;\nuniform float u_opacity : 1;\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;\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\n vec4 strokeColor = textrueStroke == vec4(0) ? v_color : textrueStroke;\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius + strokeWidth);\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 if(outer_df > antialiasblur + 0.018) discard;\n\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n float color_t = strokeWidth < 0.01 ? 0.0 : smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n\n if(strokeWidth < 0.01) {\n gl_FragColor = vec4(v_color.rgb, v_color.a * u_opacity);\n } else {\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), u_stroke_color * 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}\n";
|
|
26
26
|
/* babel-plugin-inline-import '../shaders/earth/fill_vert.glsl' */
|
|
27
27
|
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;\n\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\n\nuniform float u_opacity : 1;\nuniform float u_stroke_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\nuniform vec2 u_offsets;\n\nuniform float u_blur : 0.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\n\nvoid main() {\n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n /*\n * setPickingSize \u8BBE\u7F6E\u62FE\u53D6\u5927\u5C0F\n */\n float newSize = setPickingSize(a_Size);\n // float newSize = setPickingSize(a_Size) * 0.00001038445708445579;\n\n // unpack color(vec2)\n v_color = a_Color;\n\n // radius(16-bit)\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);\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 gl_Position = u_ViewProjectionMatrix * vec4(a_Position + extrude * newSize * 0.1 + u_offsets, 1.0);\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
28
|
-
var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
28
|
+
var FillModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
29
29
|
(0, _inherits2.default)(FillModel, _BaseModel);
|
|
30
30
|
var _super = _createSuper(FillModel);
|
|
31
31
|
function FillModel() {
|
|
@@ -221,5 +221,4 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
221
221
|
}
|
|
222
222
|
}]);
|
|
223
223
|
return FillModel;
|
|
224
|
-
}(_BaseModel2.default);
|
|
225
|
-
exports.default = FillModel;
|
|
224
|
+
}(_BaseModel2.default);
|
|
@@ -24,7 +24,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
24
24
|
var pointExtrudeFrag = "varying vec4 v_color;\nvarying float v_lightWeight;\nuniform float u_pickLight: 0.0;\n\n#pragma include \"picking\"\n\n\nvoid main() {\n\n gl_FragColor = v_color;\n // \u5F00\u542F\u900F\u660E\u5EA6\u6E10\u53D8\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";
|
|
25
25
|
/* babel-plugin-inline-import '../shaders/extrude/extrude_vert.glsl' */
|
|
26
26
|
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_r;\nuniform mat4 u_ModelMatrix;\n\nvarying vec4 v_color;\nvarying float v_lightWeight;\nvarying float v_barLinearZ;\n\nuniform float u_opacity : 1;\nuniform float u_lightEnable: 1;\nuniform float u_opacitylinear: 0.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_opacitylinear_dir: 1.0;\nuniform float u_linearColor: 0.0;\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 vec3 size = a_Size * a_Position;\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\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\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\n v_lightWeight = lightWeight;\n\n v_color = a_Color;\n\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, a_Position.z);\n v_color.a = v_color.a * u_opacity;\n } else {\n v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * u_opacity);\n }\n\n if(u_opacitylinear > 0.0) {\n v_color.a *= u_opacitylinear_dir > 0.0 ? (1.0 - a_Position.z): a_Position.z;\n }\n\n\n // gl_Position = project_common_position_to_clipspace(pos);\n\n gl_Position = project_common_position_to_clipspace_v2(pos);\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
27
|
-
var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
27
|
+
var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
28
28
|
(0, _inherits2.default)(ExtrudeModel, _BaseModel);
|
|
29
29
|
var _super = _createSuper(ExtrudeModel);
|
|
30
30
|
function ExtrudeModel() {
|
|
@@ -236,5 +236,4 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
236
236
|
}
|
|
237
237
|
}]);
|
|
238
238
|
return ExtrudeModel;
|
|
239
|
-
}(_BaseModel2.default);
|
|
240
|
-
exports.default = ExtrudeModel;
|
|
239
|
+
}(_BaseModel2.default);
|
package/lib/point/models/fill.js
CHANGED
|
@@ -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 _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
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"));
|
|
@@ -16,6 +17,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
|
|
|
16
17
|
var _l7Core = require("@antv/l7-core");
|
|
17
18
|
var _l7Utils = require("@antv/l7-utils");
|
|
18
19
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
20
|
+
var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
19
21
|
var _interface = require("../../core/interface");
|
|
20
22
|
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
23
|
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; } }
|
|
@@ -23,10 +25,10 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
23
25
|
// animate pointLayer shader - support animate
|
|
24
26
|
var waveFillFrag = "\nuniform float u_additive;\n\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nvoid main() {\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n \n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n\n\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n float color_t = smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n float PI = 3.14159;\n float N_RINGS = 3.0;\n float FREQ = 1.0;\n\n gl_FragColor = v_color;\n\n float d = length(v_data.xy);\n if(d > 0.5) {\n discard;\n }\n float intensity = clamp(cos(d * PI), 0.0, 1.0) * clamp(cos(2.0 * PI * (d * 2.0 * u_animate.z - u_animate.y * u_time)), 0.0, 1.0);\n \n // \u6839\u636E\u53E0\u52A0\u6A21\u5F0F\u9009\u62E9\u6548\u679C\n if(u_additive > 0.0) {\n gl_FragColor *= intensity;\n // \u4F18\u5316\u6C34\u6CE2\u70B9 blend additive \u6A21\u5F0F\u4E0B\u6709\u7684\u62FE\u53D6\u6548\u679C \n gl_FragColor = filterColorAlpha(gl_FragColor, gl_FragColor.a);\n } else {\n gl_FragColor = vec4(gl_FragColor.xyz, gl_FragColor.a * intensity);\n gl_FragColor = filterColor(gl_FragColor);\n }\n}\n"; // static pointLayer shader - not support animate
|
|
25
27
|
/* babel-plugin-inline-import '../shaders/fill_frag.glsl' */
|
|
26
|
-
var pointFillFrag = "uniform float u_additive;\
|
|
28
|
+
var pointFillFrag = "\nlayout(std140) uniform commonUniforms {\n vec3 u_blur_height_fixed;\n float u_stroke_width;\n float u_additive;\n float u_stroke_opacity;\n float u_size_unit;\n};\n\nin vec4 v_color;\nin vec4 v_stroke;\nin vec4 v_data;\nin float v_radius;\n\n#pragma include \"scene_uniforms\"\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nout vec4 outputColor;\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 outputColor = v_color;\n } else {\n outputColor = mix(v_color, v_stroke * u_stroke_opacity, color_t);\n }\n\n if(u_additive > 0.0) {\n outputColor *= opacity_t;\n outputColor = filterColorAlpha(outputColor, outputColor.a);\n } else {\n outputColor.a *= opacity_t;\n outputColor = filterColor(outputColor);\n }\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if(outputColor.a < 0.01) {\n discard;\n } \n}\n";
|
|
27
29
|
/* babel-plugin-inline-import '../shaders/fill_vert.glsl' */
|
|
28
|
-
var pointFillVert = "
|
|
29
|
-
var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
30
|
+
var pointFillVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 11) in vec3 a_Extrude;\nlayout(location = 10) in float a_Shape;\n\nlayout(std140) uniform commonUniforms {\n vec3 u_blur_height_fixed;\n float u_stroke_width;\n float u_additive;\n float u_stroke_opacity;\n float u_size_unit;\n};\n\nout vec4 v_color;\nout vec4 v_stroke;\nout vec4 v_data;\nout float v_radius;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\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.0) {\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 gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
31
|
+
var FillModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
30
32
|
(0, _inherits2.default)(FillModel, _BaseModel);
|
|
31
33
|
var _super = _createSuper(FillModel);
|
|
32
34
|
function FillModel() {
|
|
@@ -50,13 +52,23 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
50
52
|
heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed,
|
|
51
53
|
_ref$unit = _ref.unit,
|
|
52
54
|
unit = _ref$unit === void 0 ? 'pixel' : _ref$unit;
|
|
53
|
-
|
|
55
|
+
var commonIniform = (0, _objectSpread2.default)({
|
|
54
56
|
u_blur_height_fixed: [blur, Number(raisingHeight), Number(heightfixed)],
|
|
55
57
|
u_additive: blend === 'additive' ? 1.0 : 0.0,
|
|
56
58
|
u_stroke_opacity: strokeOpacity,
|
|
57
59
|
u_stroke_width: strokeWidth,
|
|
58
60
|
u_size_unit: _interface.SizeUnitType[unit]
|
|
59
61
|
}, this.getStyleAttribute());
|
|
62
|
+
var attributes = this.getStyleAttribute();
|
|
63
|
+
this.uniformBuffers[0].subData({
|
|
64
|
+
offset: 0,
|
|
65
|
+
data: new Uint8Array(new Float32Array([].concat((0, _toConsumableArray2.default)(attributes.u_stroke), (0, _toConsumableArray2.default)(attributes.u_offsets), [attributes.u_opacity, attributes.u_rotation])).buffer)
|
|
66
|
+
});
|
|
67
|
+
this.uniformBuffers[1].subData({
|
|
68
|
+
offset: 0,
|
|
69
|
+
data: new Uint8Array(new Float32Array([].concat((0, _toConsumableArray2.default)(commonIniform.u_blur_height_fixed), [commonIniform.u_stroke_width, commonIniform.u_stroke_opacity, commonIniform.u_additive, commonIniform.u_size_unit])).buffer)
|
|
70
|
+
});
|
|
71
|
+
return commonIniform;
|
|
60
72
|
}
|
|
61
73
|
}, {
|
|
62
74
|
key: "getAnimateUniforms",
|
|
@@ -99,7 +111,7 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
99
111
|
key: "buildModels",
|
|
100
112
|
value: function () {
|
|
101
113
|
var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
102
|
-
var _ref3, _ref3$animateOption, animateOption, _this$getShaders, frag, vert, type, model;
|
|
114
|
+
var _ref3, _ref3$animateOption, animateOption, _this$getShaders, frag, vert, type, attributeUniformBuffer, commonUniforms, model;
|
|
103
115
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
104
116
|
while (1) switch (_context2.prev = _context2.next) {
|
|
105
117
|
case 0:
|
|
@@ -108,7 +120,16 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
108
120
|
} : _ref3$animateOption;
|
|
109
121
|
_this$getShaders = this.getShaders(animateOption), frag = _this$getShaders.frag, vert = _this$getShaders.vert, type = _this$getShaders.type;
|
|
110
122
|
this.layer.triangulation = _l7Utils.PointFillTriangulation;
|
|
111
|
-
|
|
123
|
+
attributeUniformBuffer = this.rendererService.createBuffer({
|
|
124
|
+
data: new Float32Array(4 + 2 + 1 + 1),
|
|
125
|
+
isUBO: true
|
|
126
|
+
});
|
|
127
|
+
commonUniforms = this.rendererService.createBuffer({
|
|
128
|
+
data: new Float32Array(8),
|
|
129
|
+
isUBO: true
|
|
130
|
+
});
|
|
131
|
+
this.uniformBuffers.push(attributeUniformBuffer, commonUniforms);
|
|
132
|
+
_context2.next = 8;
|
|
112
133
|
return this.layer.buildLayerModel({
|
|
113
134
|
moduleName: type,
|
|
114
135
|
vertexShader: vert,
|
|
@@ -119,10 +140,10 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
119
140
|
enable: false
|
|
120
141
|
}
|
|
121
142
|
});
|
|
122
|
-
case
|
|
143
|
+
case 8:
|
|
123
144
|
model = _context2.sent;
|
|
124
145
|
return _context2.abrupt("return", [model]);
|
|
125
|
-
case
|
|
146
|
+
case 10:
|
|
126
147
|
case "end":
|
|
127
148
|
return _context2.stop();
|
|
128
149
|
}
|
|
@@ -180,6 +201,7 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
180
201
|
type: _l7Core.AttributeType.Attribute,
|
|
181
202
|
descriptor: {
|
|
182
203
|
name: 'a_Extrude',
|
|
204
|
+
shaderLocation: _CommonStyleAttribute.ShaderLocation.EXTRUDE,
|
|
183
205
|
buffer: {
|
|
184
206
|
// give the WebGL driver a hint that this buffer may change
|
|
185
207
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
@@ -201,6 +223,7 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
201
223
|
type: _l7Core.AttributeType.Attribute,
|
|
202
224
|
descriptor: {
|
|
203
225
|
name: 'a_Size',
|
|
226
|
+
shaderLocation: _CommonStyleAttribute.ShaderLocation.SIZE,
|
|
204
227
|
buffer: {
|
|
205
228
|
// give the WebGL driver a hint that this buffer may change
|
|
206
229
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
@@ -222,6 +245,7 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
222
245
|
type: _l7Core.AttributeType.Attribute,
|
|
223
246
|
descriptor: {
|
|
224
247
|
name: 'a_Shape',
|
|
248
|
+
shaderLocation: _CommonStyleAttribute.ShaderLocation.SHAPE,
|
|
225
249
|
buffer: {
|
|
226
250
|
// give the WebGL driver a hint that this buffer may change
|
|
227
251
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
@@ -240,5 +264,4 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
240
264
|
}
|
|
241
265
|
}]);
|
|
242
266
|
return FillModel;
|
|
243
|
-
}(_BaseModel2.default);
|
|
244
|
-
exports.default = FillModel;
|
|
267
|
+
}(_BaseModel2.default);
|
|
@@ -27,7 +27,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
27
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";
|
|
28
28
|
/* babel-plugin-inline-import '../shaders/image/fillImage_vert.glsl' */
|
|
29
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;\n\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 gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
30
|
-
var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
30
|
+
var FillImageModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
31
31
|
(0, _inherits2.default)(FillImageModel, _BaseModel);
|
|
32
32
|
var _super = _createSuper(FillImageModel);
|
|
33
33
|
function FillImageModel() {
|
|
@@ -164,7 +164,7 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
164
164
|
value: function clearModels() {
|
|
165
165
|
var _this$texture;
|
|
166
166
|
this.iconService.off('imageUpdate', this.updateTexture);
|
|
167
|
-
(_this$texture = this.texture) === null || _this$texture === void 0
|
|
167
|
+
(_this$texture = this.texture) === null || _this$texture === void 0 || _this$texture.destroy();
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
// overwrite baseModel func
|
|
@@ -240,5 +240,4 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
240
240
|
}
|
|
241
241
|
}]);
|
|
242
242
|
return FillImageModel;
|
|
243
|
-
}(_BaseModel2.default);
|
|
244
|
-
exports.default = FillImageModel;
|
|
243
|
+
}(_BaseModel2.default);
|
|
@@ -24,7 +24,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
24
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";
|
|
25
25
|
/* babel-plugin-inline-import '../shaders/image_vert.glsl' */
|
|
26
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;\n\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\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
|
|
27
|
-
var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
27
|
+
var ImageModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
28
28
|
(0, _inherits2.default)(ImageModel, _BaseModel);
|
|
29
29
|
var _super = _createSuper(ImageModel);
|
|
30
30
|
function ImageModel() {
|
|
@@ -112,7 +112,7 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
112
112
|
key: "clearModels",
|
|
113
113
|
value: function clearModels() {
|
|
114
114
|
var _this$texture;
|
|
115
|
-
(_this$texture = this.texture) === null || _this$texture === void 0
|
|
115
|
+
(_this$texture = this.texture) === null || _this$texture === void 0 || _this$texture.destroy();
|
|
116
116
|
this.iconService.off('imageUpdate', this.updateTexture);
|
|
117
117
|
}
|
|
118
118
|
}, {
|
|
@@ -203,5 +203,4 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
203
203
|
}
|
|
204
204
|
}]);
|
|
205
205
|
return ImageModel;
|
|
206
|
-
}(_BaseModel2.default);
|
|
207
|
-
exports.default = ImageModel;
|
|
206
|
+
}(_BaseModel2.default);
|
|
@@ -16,15 +16,14 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
16
16
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
17
17
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
18
18
|
var _l7Core = require("@antv/l7-core");
|
|
19
|
-
var _l7Utils = require("@antv/l7-utils");
|
|
20
19
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
20
|
+
var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
21
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); }; }
|
|
22
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; } }
|
|
23
23
|
/* babel-plugin-inline-import '../shaders/normal_frag.glsl' */
|
|
24
|
-
var normalFrag = "
|
|
24
|
+
var normalFrag = "in vec4 v_color;\nout vec4 outputColor;\nvoid main() {\n outputColor = v_color;\n}";
|
|
25
25
|
/* babel-plugin-inline-import '../shaders/normal_vert.glsl' */
|
|
26
|
-
var normalVert = "
|
|
27
|
-
var isNumber = _l7Utils.lodashUtil.isNumber;
|
|
26
|
+
var normalVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\n\nlayout(std140) uniform u_Common {\n float u_size_scale;\n};\n\nout 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, 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(project_pos);\n }\n\n gl_PointSize = a_Size * u_size_scale * 2.0 * u_DevicePixelRatio;\n}\n";
|
|
28
27
|
function PointTriangulation(feature) {
|
|
29
28
|
var coordinates = feature.coordinates;
|
|
30
29
|
return {
|
|
@@ -33,7 +32,7 @@ function PointTriangulation(feature) {
|
|
|
33
32
|
size: coordinates.length
|
|
34
33
|
};
|
|
35
34
|
}
|
|
36
|
-
var NormalModel = /*#__PURE__*/function (_BaseModel) {
|
|
35
|
+
var NormalModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
37
36
|
(0, _inherits2.default)(NormalModel, _BaseModel);
|
|
38
37
|
var _super = _createSuper(NormalModel);
|
|
39
38
|
function NormalModel() {
|
|
@@ -50,10 +49,19 @@ var NormalModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
50
49
|
}, {
|
|
51
50
|
key: "getUninforms",
|
|
52
51
|
value: function getUninforms() {
|
|
53
|
-
var
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
var attributes = this.getStyleAttribute();
|
|
53
|
+
// FIXME: No need to update each frame
|
|
54
|
+
this.uniformBuffers[0].subData({
|
|
55
|
+
offset: 0,
|
|
56
|
+
data: new Uint8Array(new Float32Array([].concat((0, _toConsumableArray2.default)(attributes.u_stroke), (0, _toConsumableArray2.default)(attributes.u_offsets), [attributes.u_opacity, attributes.u_rotation])).buffer)
|
|
57
|
+
});
|
|
58
|
+
this.uniformBuffers[1].subData({
|
|
59
|
+
offset: 0,
|
|
60
|
+
data: new Uint8Array(new Float32Array([0.5]).buffer)
|
|
61
|
+
});
|
|
62
|
+
return (0, _objectSpread2.default)({
|
|
63
|
+
u_size_scale: 0.5
|
|
64
|
+
}, attributes);
|
|
57
65
|
}
|
|
58
66
|
}, {
|
|
59
67
|
key: "initModels",
|
|
@@ -78,12 +86,21 @@ var NormalModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
78
86
|
key: "buildModels",
|
|
79
87
|
value: function () {
|
|
80
88
|
var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
81
|
-
var model;
|
|
89
|
+
var uniformBuffer, commonBuffer, model;
|
|
82
90
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
83
91
|
while (1) switch (_context2.prev = _context2.next) {
|
|
84
92
|
case 0:
|
|
85
93
|
this.layer.triangulation = PointTriangulation;
|
|
86
|
-
|
|
94
|
+
uniformBuffer = this.rendererService.createBuffer({
|
|
95
|
+
data: new Float32Array(4 + 2 + 1 + 1),
|
|
96
|
+
isUBO: true
|
|
97
|
+
});
|
|
98
|
+
commonBuffer = this.rendererService.createBuffer({
|
|
99
|
+
data: new Float32Array(4),
|
|
100
|
+
isUBO: true
|
|
101
|
+
});
|
|
102
|
+
this.uniformBuffers.push(uniformBuffer, commonBuffer);
|
|
103
|
+
_context2.next = 6;
|
|
87
104
|
return this.layer.buildLayerModel({
|
|
88
105
|
moduleName: 'pointNormal',
|
|
89
106
|
vertexShader: normalVert,
|
|
@@ -96,10 +113,10 @@ var NormalModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
96
113
|
primitive: _l7Core.gl.POINTS,
|
|
97
114
|
pick: false
|
|
98
115
|
});
|
|
99
|
-
case
|
|
116
|
+
case 6:
|
|
100
117
|
model = _context2.sent;
|
|
101
118
|
return _context2.abrupt("return", [model]);
|
|
102
|
-
case
|
|
119
|
+
case 8:
|
|
103
120
|
case "end":
|
|
104
121
|
return _context2.stop();
|
|
105
122
|
}
|
|
@@ -123,6 +140,7 @@ var NormalModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
123
140
|
type: _l7Core.AttributeType.Attribute,
|
|
124
141
|
descriptor: {
|
|
125
142
|
name: 'a_Size',
|
|
143
|
+
shaderLocation: _CommonStyleAttribute.ShaderLocation.SIZE,
|
|
126
144
|
buffer: {
|
|
127
145
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
128
146
|
data: [],
|
|
@@ -139,5 +157,4 @@ var NormalModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
139
157
|
}
|
|
140
158
|
}]);
|
|
141
159
|
return NormalModel;
|
|
142
|
-
}(_BaseModel2.default);
|
|
143
|
-
exports.default = NormalModel;
|
|
160
|
+
}(_BaseModel2.default);
|