@antv/l7-layers 2.16.0 → 2.16.2
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.d.ts +3 -0
- package/es/core/BaseLayer.js +76 -80
- package/es/core/BaseModel.d.ts +9 -71
- package/es/core/BaseModel.js +75 -357
- package/es/core/CommonStyleAttribute.d.ts +2 -0
- package/es/core/CommonStyleAttribute.js +66 -0
- package/es/core/interface.d.ts +13 -3
- package/es/core/shape/extrude.js +18 -6
- package/es/core/triangulation.d.ts +12 -0
- package/es/core/triangulation.js +70 -0
- package/es/heatmap/models/grid.js +1 -1
- package/es/heatmap/models/grid3d.js +1 -1
- package/es/heatmap/models/heatmap.d.ts +1 -0
- package/es/heatmap/models/heatmap.js +17 -13
- package/es/heatmap/models/hexagon.js +1 -1
- package/es/heatmap/shaders/grid_vert.glsl +2 -2
- package/es/heatmap/shaders/hexagon_3d_vert.glsl +2 -2
- package/es/heatmap/shaders/hexagon_vert.glsl +2 -2
- package/es/line/index.d.ts +1 -0
- package/es/line/index.js +3 -2
- package/es/line/models/arc.js +9 -45
- package/es/line/models/arc_3d.js +12 -45
- package/es/line/models/earthArc_3d.js +6 -40
- package/es/line/models/{half.d.ts → flow.d.ts} +1 -11
- package/es/line/models/flow.js +167 -0
- package/es/line/models/great_circle.js +4 -38
- package/es/line/models/index.d.ts +1 -1
- package/es/line/models/index.js +3 -3
- package/es/line/models/line.js +7 -41
- package/es/line/models/linearline.js +4 -38
- package/es/line/models/simpleLine.d.ts +0 -1
- package/es/line/models/simpleLine.js +4 -43
- package/es/line/shaders/dash/arc_dash_frag.glsl +3 -6
- package/es/line/shaders/dash/arc_dash_vert.glsl +6 -46
- package/es/line/shaders/dash/line_dash_frag.glsl +4 -7
- package/es/line/shaders/dash/line_dash_vert.glsl +3 -33
- package/es/line/shaders/flow/flow_line_frag.glsl +13 -0
- package/es/line/shaders/flow/flow_line_vert.glsl +83 -0
- package/es/line/shaders/line_arc_3d_frag.glsl +6 -6
- package/es/line/shaders/line_arc_3d_vert.glsl +4 -34
- package/es/line/shaders/line_arc_frag.glsl +7 -11
- package/es/line/shaders/line_arc_great_circle_frag.glsl +5 -6
- package/es/line/shaders/line_arc_great_circle_vert.glsl +4 -32
- package/es/line/shaders/line_arc_vert.glsl +9 -45
- package/es/line/shaders/line_frag.glsl +15 -17
- package/es/line/shaders/line_vert.glsl +3 -34
- package/es/line/shaders/linear/arc3d_linear_frag.glsl +5 -19
- package/es/line/shaders/linear/arc3d_linear_vert.glsl +9 -48
- package/es/line/shaders/linear/arc_linear_frag.glsl +2 -30
- package/es/line/shaders/linear/arc_linear_vert.glsl +9 -45
- package/es/line/shaders/linear/line_linear_frag.glsl +5 -6
- package/es/line/shaders/linearLine/line_linear_frag.glsl +2 -14
- package/es/line/shaders/linearLine/line_linear_vert.glsl +14 -32
- package/es/line/shaders/simple/simpleline_frag.glsl +1 -5
- package/es/line/shaders/simple/simpleline_linear_frag.glsl +2 -6
- package/es/line/shaders/simple/simpleline_vert.glsl +7 -33
- package/es/plugins/DataMappingPlugin.js +20 -34
- package/es/plugins/LayerModelPlugin.js +13 -1
- package/es/plugins/ShaderUniformPlugin.js +3 -3
- package/es/point/index.d.ts +1 -0
- package/es/point/index.js +1 -0
- package/es/point/models/earthExtrude.d.ts +0 -3
- package/es/point/models/earthExtrude.js +2 -40
- package/es/point/models/earthFill.d.ts +0 -1
- package/es/point/models/earthFill.js +9 -60
- package/es/point/models/extrude.d.ts +0 -3
- package/es/point/models/extrude.js +3 -42
- package/es/point/models/fill.d.ts +0 -1
- package/es/point/models/fill.js +15 -76
- package/es/point/models/fillmage.js +6 -43
- package/es/point/models/image.js +7 -41
- package/es/point/models/normal.js +2 -2
- package/es/point/models/radar.d.ts +0 -1
- package/es/point/models/radar.js +4 -13
- package/es/point/models/simplePoint.d.ts +0 -1
- package/es/point/models/simplePoint.js +8 -49
- package/es/point/models/text.js +17 -47
- package/es/point/shaders/animate/wave_frag.glsl +1 -11
- package/es/point/shaders/earth/extrude_frag.glsl +5 -17
- package/es/point/shaders/earth/extrude_vert.glsl +14 -29
- package/es/point/shaders/earth/fill_frag.glsl +5 -14
- package/es/point/shaders/earth/fill_vert.glsl +1 -75
- package/es/point/shaders/extrude/extrude_frag.glsl +3 -29
- package/es/point/shaders/extrude/extrude_vert.glsl +27 -35
- package/es/point/shaders/fill_frag.glsl +9 -20
- package/es/point/shaders/fill_vert.glsl +16 -101
- package/es/point/shaders/image/fillImage_frag.glsl +2 -5
- package/es/point/shaders/image/fillImage_vert.glsl +4 -47
- package/es/point/shaders/image_frag.glsl +1 -5
- package/es/point/shaders/image_vert.glsl +1 -44
- package/es/point/shaders/normal_frag.glsl +0 -2
- package/es/point/shaders/normal_vert.glsl +2 -1
- package/es/point/shaders/radar/radar_vert.glsl +2 -2
- package/es/point/shaders/simplePoint_frag.glsl +0 -7
- package/es/point/shaders/simplePoint_vert.glsl +3 -45
- package/es/point/shaders/text_frag.glsl +6 -19
- package/es/point/shaders/text_vert.glsl +5 -66
- package/es/polygon/index.d.ts +1 -0
- package/es/polygon/index.js +1 -0
- package/es/polygon/models/extrude.d.ts +0 -3
- package/es/polygon/models/extrude.js +86 -82
- package/es/polygon/models/fill.d.ts +0 -4
- package/es/polygon/models/fill.js +8 -47
- package/es/polygon/shaders/extrude/polygon_extrude_frag.glsl +2 -23
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +7 -5
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +7 -32
- package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +33 -38
- package/es/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +12 -9
- package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +16 -44
- package/es/polygon/shaders/polygon_frag.glsl +0 -5
- package/es/polygon/shaders/polygon_linear_frag.glsl +0 -8
- package/es/polygon/shaders/polygon_linear_vert.glsl +0 -32
- package/es/polygon/shaders/polygon_vert.glsl +1 -27
- package/es/utils/layerData.js +2 -2
- package/lib/core/BaseLayer.js +74 -78
- package/lib/core/BaseModel.js +74 -356
- package/lib/core/CommonStyleAttribute.js +72 -0
- package/lib/core/shape/extrude.js +18 -6
- package/lib/core/triangulation.js +72 -0
- package/lib/heatmap/models/grid.js +1 -1
- package/lib/heatmap/models/grid3d.js +1 -1
- package/lib/heatmap/models/heatmap.js +17 -13
- package/lib/heatmap/models/hexagon.js +1 -1
- package/lib/heatmap/shaders/grid_vert.glsl +2 -2
- package/lib/heatmap/shaders/hexagon_3d_vert.glsl +2 -2
- package/lib/heatmap/shaders/hexagon_vert.glsl +2 -2
- package/lib/line/index.js +3 -2
- package/lib/line/models/arc.js +9 -45
- package/lib/line/models/arc_3d.js +12 -45
- package/lib/line/models/earthArc_3d.js +6 -40
- package/lib/line/models/flow.js +174 -0
- package/lib/line/models/great_circle.js +4 -38
- package/lib/line/models/index.js +3 -3
- package/lib/line/models/line.js +7 -41
- package/lib/line/models/linearline.js +4 -38
- package/lib/line/models/simpleLine.js +4 -43
- package/lib/line/shaders/dash/arc_dash_frag.glsl +3 -6
- package/lib/line/shaders/dash/arc_dash_vert.glsl +6 -46
- package/lib/line/shaders/dash/line_dash_frag.glsl +4 -7
- package/lib/line/shaders/dash/line_dash_vert.glsl +3 -33
- package/lib/line/shaders/flow/flow_line_frag.glsl +13 -0
- package/lib/line/shaders/flow/flow_line_vert.glsl +83 -0
- package/lib/line/shaders/line_arc_3d_frag.glsl +6 -6
- package/lib/line/shaders/line_arc_3d_vert.glsl +4 -34
- package/lib/line/shaders/line_arc_frag.glsl +7 -11
- package/lib/line/shaders/line_arc_great_circle_frag.glsl +5 -6
- package/lib/line/shaders/line_arc_great_circle_vert.glsl +4 -32
- package/lib/line/shaders/line_arc_vert.glsl +9 -45
- package/lib/line/shaders/line_frag.glsl +15 -17
- package/lib/line/shaders/line_vert.glsl +3 -34
- package/lib/line/shaders/linear/arc3d_linear_frag.glsl +5 -19
- package/lib/line/shaders/linear/arc3d_linear_vert.glsl +9 -48
- package/lib/line/shaders/linear/arc_linear_frag.glsl +2 -30
- package/lib/line/shaders/linear/arc_linear_vert.glsl +9 -45
- package/lib/line/shaders/linear/line_linear_frag.glsl +5 -6
- package/lib/line/shaders/linearLine/line_linear_frag.glsl +2 -14
- package/lib/line/shaders/linearLine/line_linear_vert.glsl +14 -32
- package/lib/line/shaders/simple/simpleline_frag.glsl +1 -5
- package/lib/line/shaders/simple/simpleline_linear_frag.glsl +2 -6
- package/lib/line/shaders/simple/simpleline_vert.glsl +7 -33
- package/lib/plugins/DataMappingPlugin.js +20 -34
- package/lib/plugins/LayerModelPlugin.js +13 -1
- package/lib/plugins/ShaderUniformPlugin.js +3 -3
- package/lib/point/index.js +1 -0
- package/lib/point/models/earthExtrude.js +2 -40
- package/lib/point/models/earthFill.js +9 -60
- package/lib/point/models/extrude.js +3 -42
- package/lib/point/models/fill.js +15 -76
- package/lib/point/models/fillmage.js +6 -43
- package/lib/point/models/image.js +7 -41
- package/lib/point/models/normal.js +2 -2
- package/lib/point/models/radar.js +4 -13
- package/lib/point/models/simplePoint.js +8 -49
- package/lib/point/models/text.js +15 -45
- package/lib/point/shaders/animate/wave_frag.glsl +1 -11
- package/lib/point/shaders/earth/extrude_frag.glsl +5 -17
- package/lib/point/shaders/earth/extrude_vert.glsl +14 -29
- package/lib/point/shaders/earth/fill_frag.glsl +5 -14
- package/lib/point/shaders/earth/fill_vert.glsl +1 -75
- package/lib/point/shaders/extrude/extrude_frag.glsl +3 -29
- package/lib/point/shaders/extrude/extrude_vert.glsl +27 -35
- package/lib/point/shaders/fill_frag.glsl +9 -20
- package/lib/point/shaders/fill_vert.glsl +16 -101
- package/lib/point/shaders/image/fillImage_frag.glsl +2 -5
- package/lib/point/shaders/image/fillImage_vert.glsl +4 -47
- package/lib/point/shaders/image_frag.glsl +1 -5
- package/lib/point/shaders/image_vert.glsl +1 -44
- package/lib/point/shaders/normal_frag.glsl +0 -2
- package/lib/point/shaders/normal_vert.glsl +2 -1
- package/lib/point/shaders/radar/radar_vert.glsl +2 -2
- package/lib/point/shaders/simplePoint_frag.glsl +0 -7
- package/lib/point/shaders/simplePoint_vert.glsl +3 -45
- package/lib/point/shaders/text_frag.glsl +6 -19
- package/lib/point/shaders/text_vert.glsl +5 -66
- package/lib/polygon/index.js +1 -0
- package/lib/polygon/models/extrude.js +86 -82
- package/lib/polygon/models/fill.js +8 -47
- package/lib/polygon/shaders/extrude/polygon_extrude_frag.glsl +2 -23
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +7 -5
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +7 -32
- package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +33 -38
- package/lib/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +12 -9
- package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +16 -44
- package/lib/polygon/shaders/polygon_frag.glsl +0 -5
- package/lib/polygon/shaders/polygon_linear_frag.glsl +0 -8
- package/lib/polygon/shaders/polygon_linear_vert.glsl +0 -32
- package/lib/polygon/shaders/polygon_vert.glsl +1 -27
- package/lib/utils/layerData.js +2 -2
- package/package.json +7 -7
- package/es/line/models/half.js +0 -267
- package/es/line/shaders/half/line_half_frag.glsl +0 -53
- package/es/line/shaders/half/line_half_vert.glsl +0 -169
- package/es/utils/dataMappingStyle.d.ts +0 -31
- package/es/utils/dataMappingStyle.js +0 -137
- package/lib/line/models/half.js +0 -274
- package/lib/line/shaders/half/line_half_frag.glsl +0 -53
- package/lib/line/shaders/half/line_half_vert.glsl +0 -169
- package/lib/utils/dataMappingStyle.js +0 -140
|
@@ -31,7 +31,7 @@ var ShaderUniformPlugin = (_dec = injectable(), _dec2 = inject(TYPES.ICameraServ
|
|
|
31
31
|
var _this = this;
|
|
32
32
|
var version = this.mapService.version;
|
|
33
33
|
var mvp = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; // default matrix (for gaode2.x)
|
|
34
|
-
var
|
|
34
|
+
var sceneCenterMercator = [0, 0];
|
|
35
35
|
layer.hooks.beforeRender.tap('ShaderUniformPlugin', function () {
|
|
36
36
|
// @ts-ignore
|
|
37
37
|
var offset = layer.getLayerConfig().tileOrigin;
|
|
@@ -43,14 +43,14 @@ var ShaderUniformPlugin = (_dec = injectable(), _dec2 = inject(TYPES.ICameraServ
|
|
|
43
43
|
mvp = _this.mapService.map.customCoords.getMVPMatrix();
|
|
44
44
|
// mvp = amapCustomCoords.getMVPMatrix()
|
|
45
45
|
// @ts-ignore
|
|
46
|
-
|
|
46
|
+
sceneCenterMercator = _this.mapService.getCustomCoordCenter();
|
|
47
47
|
}
|
|
48
48
|
var _this$rendererService = _this.rendererService.getViewportSize(),
|
|
49
49
|
width = _this$rendererService.width,
|
|
50
50
|
height = _this$rendererService.height;
|
|
51
51
|
layer.models.forEach(function (model) {
|
|
52
52
|
var _model$addUniforms;
|
|
53
|
-
model.addUniforms((_model$addUniforms = {}, _defineProperty(_model$addUniforms, CameraUniform.ProjectionMatrix, _this.cameraService.getProjectionMatrix()), _defineProperty(_model$addUniforms, CameraUniform.ViewMatrix, _this.cameraService.getViewMatrix()), _defineProperty(_model$addUniforms, CameraUniform.ViewProjectionMatrix, _this.cameraService.getViewProjectionMatrix()), _defineProperty(_model$addUniforms, CameraUniform.Zoom, _this.cameraService.getZoom()), _defineProperty(_model$addUniforms, CameraUniform.ZoomScale, _this.cameraService.getZoomScale()), _defineProperty(_model$addUniforms, CameraUniform.FocalDistance, _this.cameraService.getFocalDistance()), _defineProperty(_model$addUniforms, CameraUniform.CameraPosition, _this.cameraService.getCameraPosition()), _defineProperty(_model$addUniforms, CoordinateUniform.CoordinateSystem, _this.coordinateSystemService.getCoordinateSystem()), _defineProperty(_model$addUniforms, CoordinateUniform.ViewportCenter, _this.coordinateSystemService.getViewportCenter()), _defineProperty(_model$addUniforms, CoordinateUniform.ViewportCenterProjection, _this.coordinateSystemService.getViewportCenterProjection()), _defineProperty(_model$addUniforms, CoordinateUniform.PixelsPerDegree, _this.coordinateSystemService.getPixelsPerDegree()), _defineProperty(_model$addUniforms, CoordinateUniform.PixelsPerDegree2, _this.coordinateSystemService.getPixelsPerDegree2()), _defineProperty(_model$addUniforms, CoordinateUniform.PixelsPerMeter, _this.coordinateSystemService.getPixelsPerMeter()), _defineProperty(_model$addUniforms, CoordinateUniform.Mvp, mvp), _defineProperty(_model$addUniforms, "
|
|
53
|
+
model.addUniforms((_model$addUniforms = {}, _defineProperty(_model$addUniforms, CameraUniform.ProjectionMatrix, _this.cameraService.getProjectionMatrix()), _defineProperty(_model$addUniforms, CameraUniform.ViewMatrix, _this.cameraService.getViewMatrix()), _defineProperty(_model$addUniforms, CameraUniform.ViewProjectionMatrix, _this.cameraService.getViewProjectionMatrix()), _defineProperty(_model$addUniforms, CameraUniform.Zoom, _this.cameraService.getZoom()), _defineProperty(_model$addUniforms, CameraUniform.ZoomScale, _this.cameraService.getZoomScale()), _defineProperty(_model$addUniforms, CameraUniform.FocalDistance, _this.cameraService.getFocalDistance()), _defineProperty(_model$addUniforms, CameraUniform.CameraPosition, _this.cameraService.getCameraPosition()), _defineProperty(_model$addUniforms, CoordinateUniform.CoordinateSystem, _this.coordinateSystemService.getCoordinateSystem()), _defineProperty(_model$addUniforms, CoordinateUniform.ViewportCenter, _this.coordinateSystemService.getViewportCenter()), _defineProperty(_model$addUniforms, CoordinateUniform.ViewportCenterProjection, _this.coordinateSystemService.getViewportCenterProjection()), _defineProperty(_model$addUniforms, CoordinateUniform.PixelsPerDegree, _this.coordinateSystemService.getPixelsPerDegree()), _defineProperty(_model$addUniforms, CoordinateUniform.PixelsPerDegree2, _this.coordinateSystemService.getPixelsPerDegree2()), _defineProperty(_model$addUniforms, CoordinateUniform.PixelsPerMeter, _this.coordinateSystemService.getPixelsPerMeter()), _defineProperty(_model$addUniforms, CoordinateUniform.Mvp, mvp), _defineProperty(_model$addUniforms, "u_sceneCenterMercator", sceneCenterMercator), _defineProperty(_model$addUniforms, "u_ViewportSize", [width, height]), _defineProperty(_model$addUniforms, "u_ModelMatrix", _this.cameraService.getModelMatrix()), _defineProperty(_model$addUniforms, "u_DevicePixelRatio", $window.devicePixelRatio), _defineProperty(_model$addUniforms, "u_PickingBuffer", layer.getLayerConfig().pickingBuffer || 0), _defineProperty(_model$addUniforms, "u_shaderPick", Number(layer.getShaderPickStat())), _model$addUniforms));
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
// TODO:脏检查,决定是否需要渲染
|
package/es/point/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { IPointLayerStyleOptions } from '../core/interface';
|
|
|
3
3
|
import { PointType } from './models/index';
|
|
4
4
|
export default class PointLayer extends BaseLayer<IPointLayerStyleOptions> {
|
|
5
5
|
type: string;
|
|
6
|
+
enableEncodeStyles: string[];
|
|
6
7
|
defaultSourceConfig: {
|
|
7
8
|
data: never[];
|
|
8
9
|
options: {
|
package/es/point/index.js
CHANGED
|
@@ -25,6 +25,7 @@ var PointLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
|
25
25
|
}
|
|
26
26
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
27
27
|
_defineProperty(_assertThisInitialized(_this), "type", 'PointLayer');
|
|
28
|
+
_defineProperty(_assertThisInitialized(_this), "enableEncodeStyles", ['opacity', 'offsets', 'stroke']);
|
|
28
29
|
_defineProperty(_assertThisInitialized(_this), "defaultSourceConfig", {
|
|
29
30
|
data: [],
|
|
30
31
|
options: {
|
|
@@ -7,8 +7,6 @@ export default class ExtrudeModel extends BaseModel {
|
|
|
7
7
|
u_pickLight: number;
|
|
8
8
|
u_heightfixed: number;
|
|
9
9
|
u_r: number;
|
|
10
|
-
u_dataTexture: import("@antv/l7-core").ITexture2D;
|
|
11
|
-
u_cellTypeLayout: number[];
|
|
12
10
|
u_opacity: number;
|
|
13
11
|
u_linearColor: number;
|
|
14
12
|
u_sourceColor: number[];
|
|
@@ -19,6 +17,5 @@ export default class ExtrudeModel extends BaseModel {
|
|
|
19
17
|
};
|
|
20
18
|
initModels(): Promise<IModel[]>;
|
|
21
19
|
buildModels(): Promise<IModel[]>;
|
|
22
|
-
clearModels(): void;
|
|
23
20
|
protected registerBuiltinAttributes(): void;
|
|
24
21
|
}
|
|
@@ -16,9 +16,9 @@ import BaseModel from "../../core/BaseModel";
|
|
|
16
16
|
import { PointExtrudeTriangulation } from "../../core/triangulation";
|
|
17
17
|
import { lglt2xyz } from "../../earth/utils";
|
|
18
18
|
/* babel-plugin-inline-import '../shaders/earth/extrude_frag.glsl' */
|
|
19
|
-
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\
|
|
19
|
+
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";
|
|
20
20
|
/* babel-plugin-inline-import '../shaders/earth/extrude_vert.glsl' */
|
|
21
|
-
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;\
|
|
21
|
+
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";
|
|
22
22
|
var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
23
23
|
_inherits(ExtrudeModel, _BaseModel);
|
|
24
24
|
var _super = _createSuper(ExtrudeModel);
|
|
@@ -58,35 +58,6 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
58
58
|
} : _ref$opacityLinear,
|
|
59
59
|
_ref$lightEnable = _ref.lightEnable,
|
|
60
60
|
lightEnable = _ref$lightEnable === void 0 ? true : _ref$lightEnable;
|
|
61
|
-
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
62
|
-
opacity: opacity
|
|
63
|
-
})) {
|
|
64
|
-
this.judgeStyleAttributes({
|
|
65
|
-
opacity: opacity
|
|
66
|
-
});
|
|
67
|
-
var encodeData = this.layer.getEncodedData();
|
|
68
|
-
var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
|
|
69
|
-
data = _this$calDataFrame.data,
|
|
70
|
-
width = _this$calDataFrame.width,
|
|
71
|
-
height = _this$calDataFrame.height;
|
|
72
|
-
this.rowCount = height; // 当前数据纹理有多少行
|
|
73
|
-
|
|
74
|
-
this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
|
|
75
|
-
flipY: true,
|
|
76
|
-
data: data,
|
|
77
|
-
format: gl.LUMINANCE,
|
|
78
|
-
type: gl.FLOAT,
|
|
79
|
-
width: width,
|
|
80
|
-
height: height
|
|
81
|
-
}) : this.createTexture2D({
|
|
82
|
-
flipY: true,
|
|
83
|
-
data: [1],
|
|
84
|
-
format: gl.LUMINANCE,
|
|
85
|
-
type: gl.FLOAT,
|
|
86
|
-
width: 1,
|
|
87
|
-
height: 1
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
61
|
|
|
91
62
|
// 转化渐变色
|
|
92
63
|
var useLinearColor = 0; // 默认不生效
|
|
@@ -118,9 +89,6 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
118
89
|
// 圆柱体是否固定高度
|
|
119
90
|
u_heightfixed: Number(heightfixed),
|
|
120
91
|
u_r: animateOption.enable && this.raiseRepeat > 0 ? this.raiseCount : 1.0,
|
|
121
|
-
u_dataTexture: this.dataTexture,
|
|
122
|
-
// 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
|
|
123
|
-
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
124
92
|
u_opacity: isNumber(opacity) ? opacity : 1.0,
|
|
125
93
|
// 渐变色支持参数
|
|
126
94
|
u_linearColor: useLinearColor,
|
|
@@ -192,12 +160,6 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
192
160
|
}
|
|
193
161
|
return buildModels;
|
|
194
162
|
}()
|
|
195
|
-
}, {
|
|
196
|
-
key: "clearModels",
|
|
197
|
-
value: function clearModels() {
|
|
198
|
-
var _this$dataTexture;
|
|
199
|
-
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
|
|
200
|
-
}
|
|
201
163
|
}, {
|
|
202
164
|
key: "registerBuiltinAttributes",
|
|
203
165
|
value: function registerBuiltinAttributes() {
|
|
@@ -5,7 +5,6 @@ export default class FillModel extends BaseModel {
|
|
|
5
5
|
getAnimateUniforms(): IModelUniform;
|
|
6
6
|
initModels(): Promise<IModel[]>;
|
|
7
7
|
buildModels(): Promise<IModel[]>;
|
|
8
|
-
clearModels(): void;
|
|
9
8
|
protected animateOption2Array(option: Partial<IAnimateOption>): number[];
|
|
10
9
|
protected registerBuiltinAttributes(): void;
|
|
11
10
|
}
|
|
@@ -10,13 +10,13 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
10
10
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
11
|
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; } }
|
|
12
12
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
13
|
-
import { isNumber } from 'lodash';
|
|
14
13
|
import BaseModel from "../../core/BaseModel";
|
|
15
14
|
import { GlobelPointFillTriangulation } from "../../core/triangulation";
|
|
16
15
|
/* babel-plugin-inline-import '../shaders/earth/fill_frag.glsl' */
|
|
17
|
-
var pointFillFrag = "uniform float u_additive;\
|
|
16
|
+
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";
|
|
18
17
|
/* babel-plugin-inline-import '../shaders/earth/fill_vert.glsl' */
|
|
19
|
-
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute float a_Shape;\
|
|
18
|
+
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;\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";
|
|
19
|
+
import { rgb2arr } from '@antv/l7-utils';
|
|
20
20
|
import { mat4, vec3 } from 'gl-matrix';
|
|
21
21
|
var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
22
22
|
_inherits(FillModel, _BaseModel);
|
|
@@ -37,60 +37,17 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
37
37
|
strokeWidth = _ref$strokeWidth === void 0 ? 0 : _ref$strokeWidth,
|
|
38
38
|
_ref$stroke = _ref.stroke,
|
|
39
39
|
stroke = _ref$stroke === void 0 ? 'rgba(0,0,0,0)' : _ref$stroke,
|
|
40
|
-
_ref$offsets = _ref.offsets,
|
|
41
|
-
offsets = _ref$offsets === void 0 ? [0, 0] : _ref$offsets,
|
|
42
40
|
blend = _ref.blend,
|
|
43
41
|
_ref$blur = _ref.blur,
|
|
44
42
|
blur = _ref$blur === void 0 ? 0 : _ref$blur;
|
|
45
|
-
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
46
|
-
opacity: opacity,
|
|
47
|
-
strokeOpacity: strokeOpacity,
|
|
48
|
-
strokeWidth: strokeWidth,
|
|
49
|
-
stroke: stroke,
|
|
50
|
-
offsets: offsets
|
|
51
|
-
})) {
|
|
52
|
-
// 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量
|
|
53
|
-
this.judgeStyleAttributes({
|
|
54
|
-
opacity: opacity,
|
|
55
|
-
strokeOpacity: strokeOpacity,
|
|
56
|
-
strokeWidth: strokeWidth,
|
|
57
|
-
stroke: stroke,
|
|
58
|
-
offsets: offsets
|
|
59
|
-
});
|
|
60
|
-
var encodeData = this.layer.getEncodedData();
|
|
61
|
-
var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
|
|
62
|
-
data = _this$calDataFrame.data,
|
|
63
|
-
width = _this$calDataFrame.width,
|
|
64
|
-
height = _this$calDataFrame.height;
|
|
65
|
-
this.rowCount = height; // 当前数据纹理有多少行
|
|
66
|
-
|
|
67
|
-
this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
|
|
68
|
-
flipY: true,
|
|
69
|
-
data: data,
|
|
70
|
-
format: gl.LUMINANCE,
|
|
71
|
-
type: gl.FLOAT,
|
|
72
|
-
width: width,
|
|
73
|
-
height: height
|
|
74
|
-
}) : this.createTexture2D({
|
|
75
|
-
flipY: true,
|
|
76
|
-
data: [1],
|
|
77
|
-
format: gl.LUMINANCE,
|
|
78
|
-
type: gl.FLOAT,
|
|
79
|
-
width: 1,
|
|
80
|
-
height: 1
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
43
|
return {
|
|
84
44
|
u_blur: blur,
|
|
85
45
|
u_additive: blend === 'additive' ? 1.0 : 0.0,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 1.0,
|
|
92
|
-
u_stroke_color: this.getStrokeColor(stroke),
|
|
93
|
-
u_offsets: this.isOffsetStatic(offsets) ? offsets : [0, 0]
|
|
46
|
+
u_opacity: opacity,
|
|
47
|
+
u_stroke_opacity: strokeOpacity,
|
|
48
|
+
u_stroke_width: strokeWidth,
|
|
49
|
+
u_stroke_color: rgb2arr(stroke)
|
|
50
|
+
// u_offsets: offsets,
|
|
94
51
|
};
|
|
95
52
|
}
|
|
96
53
|
}, {
|
|
@@ -158,15 +115,7 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
158
115
|
return _buildModels.apply(this, arguments);
|
|
159
116
|
}
|
|
160
117
|
return buildModels;
|
|
161
|
-
}()
|
|
162
|
-
}, {
|
|
163
|
-
key: "clearModels",
|
|
164
|
-
value: function clearModels() {
|
|
165
|
-
var _this$dataTexture;
|
|
166
|
-
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// overwrite baseModel func
|
|
118
|
+
}() // overwrite baseModel func
|
|
170
119
|
}, {
|
|
171
120
|
key: "animateOption2Array",
|
|
172
121
|
value: function animateOption2Array(option) {
|
|
@@ -7,8 +7,6 @@ export default class ExtrudeModel extends BaseModel {
|
|
|
7
7
|
u_pickLight: number;
|
|
8
8
|
u_heightfixed: number;
|
|
9
9
|
u_r: number;
|
|
10
|
-
u_dataTexture: import("@antv/l7-core").ITexture2D;
|
|
11
|
-
u_cellTypeLayout: number[];
|
|
12
10
|
u_opacity: number;
|
|
13
11
|
u_linearColor: number;
|
|
14
12
|
u_sourceColor: number[];
|
|
@@ -19,6 +17,5 @@ export default class ExtrudeModel extends BaseModel {
|
|
|
19
17
|
};
|
|
20
18
|
initModels(): Promise<IModel[]>;
|
|
21
19
|
buildModels(): Promise<IModel[]>;
|
|
22
|
-
clearModels(): void;
|
|
23
20
|
protected registerBuiltinAttributes(): void;
|
|
24
21
|
}
|
|
@@ -11,13 +11,12 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
11
11
|
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; } }
|
|
12
12
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
13
13
|
import { calculateCentroid, getCullFace, rgb2arr } from '@antv/l7-utils';
|
|
14
|
-
import { isNumber } from 'lodash';
|
|
15
14
|
import BaseModel from "../../core/BaseModel";
|
|
16
15
|
import { PointExtrudeTriangulation } from "../../core/triangulation";
|
|
17
16
|
/* babel-plugin-inline-import '../shaders/extrude/extrude_frag.glsl' */
|
|
18
|
-
var pointExtrudeFrag = "varying vec4 v_color;\
|
|
17
|
+
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";
|
|
19
18
|
/* babel-plugin-inline-import '../shaders/extrude/extrude_vert.glsl' */
|
|
20
|
-
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;\nuniform mat4 u_Mvp;\nvarying vec4 v_color;\n\nuniform float u_opacity : 1;\nuniform float u_lightEnable: 1;\
|
|
19
|
+
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;\nuniform mat4 u_Mvp;\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 if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * pos;\n } else {\n gl_Position = project_common_position_to_clipspace(pos);\n }\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
21
20
|
var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
22
21
|
_inherits(ExtrudeModel, _BaseModel);
|
|
23
22
|
var _super = _createSuper(ExtrudeModel);
|
|
@@ -57,35 +56,6 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
57
56
|
} : _ref$opacityLinear,
|
|
58
57
|
_ref$lightEnable = _ref.lightEnable,
|
|
59
58
|
lightEnable = _ref$lightEnable === void 0 ? true : _ref$lightEnable;
|
|
60
|
-
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
61
|
-
opacity: opacity
|
|
62
|
-
})) {
|
|
63
|
-
this.judgeStyleAttributes({
|
|
64
|
-
opacity: opacity
|
|
65
|
-
});
|
|
66
|
-
var encodeData = this.layer.getEncodedData();
|
|
67
|
-
var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
|
|
68
|
-
data = _this$calDataFrame.data,
|
|
69
|
-
width = _this$calDataFrame.width,
|
|
70
|
-
height = _this$calDataFrame.height;
|
|
71
|
-
this.rowCount = height; // 当前数据纹理有多少行
|
|
72
|
-
|
|
73
|
-
this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
|
|
74
|
-
flipY: true,
|
|
75
|
-
data: data,
|
|
76
|
-
format: gl.LUMINANCE,
|
|
77
|
-
type: gl.FLOAT,
|
|
78
|
-
width: width,
|
|
79
|
-
height: height
|
|
80
|
-
}) : this.createTexture2D({
|
|
81
|
-
flipY: true,
|
|
82
|
-
data: [1],
|
|
83
|
-
format: gl.LUMINANCE,
|
|
84
|
-
type: gl.FLOAT,
|
|
85
|
-
width: 1,
|
|
86
|
-
height: 1
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
59
|
|
|
90
60
|
// 转化渐变色
|
|
91
61
|
var useLinearColor = 0; // 默认不生效
|
|
@@ -117,10 +87,7 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
117
87
|
// 圆柱体是否固定高度
|
|
118
88
|
u_heightfixed: Number(heightfixed),
|
|
119
89
|
u_r: animateOption.enable && this.raiseRepeat > 0 ? this.raiseCount : 1.0,
|
|
120
|
-
|
|
121
|
-
// 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
|
|
122
|
-
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
123
|
-
u_opacity: isNumber(opacity) ? opacity : 1.0,
|
|
90
|
+
u_opacity: opacity,
|
|
124
91
|
// 渐变色支持参数
|
|
125
92
|
u_linearColor: useLinearColor,
|
|
126
93
|
u_sourceColor: sourceColorArr,
|
|
@@ -190,12 +157,6 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
190
157
|
}
|
|
191
158
|
return buildModels;
|
|
192
159
|
}()
|
|
193
|
-
}, {
|
|
194
|
-
key: "clearModels",
|
|
195
|
-
value: function clearModels() {
|
|
196
|
-
var _this$dataTexture;
|
|
197
|
-
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
|
|
198
|
-
}
|
|
199
160
|
}, {
|
|
200
161
|
key: "registerBuiltinAttributes",
|
|
201
162
|
value: function registerBuiltinAttributes() {
|