@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
package/es/core/BaseLayer.d.ts
CHANGED
|
@@ -87,6 +87,8 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
|
|
|
87
87
|
private currentPickId;
|
|
88
88
|
protected rawConfig: Partial<ILayerConfig & ChildLayerStyleOptions>;
|
|
89
89
|
private needUpdateConfig;
|
|
90
|
+
encodeStyleAttribute: Record<string, any>;
|
|
91
|
+
enableEncodeStyles: string[];
|
|
90
92
|
/**
|
|
91
93
|
* 待更新样式属性,在初始化阶段完成注册
|
|
92
94
|
*/
|
|
@@ -141,6 +143,7 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
|
|
|
141
143
|
source(data: any, options?: ISourceCFG): ILayer;
|
|
142
144
|
setData(data: any, options?: ISourceCFG): this;
|
|
143
145
|
style(options: Partial<ChildLayerStyleOptions> & Partial<ILayerConfig>): ILayer;
|
|
146
|
+
private encodeStyle;
|
|
144
147
|
scale(field: string | number | IScaleOptions, cfg?: IScale): this;
|
|
145
148
|
/**
|
|
146
149
|
* 渲染所有的图层
|
package/es/core/BaseLayer.js
CHANGED
|
@@ -12,7 +12,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
12
12
|
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
|
|
13
13
|
import _initializerWarningHelper from "@babel/runtime/helpers/esm/initializerWarningHelper";
|
|
14
14
|
var _excluded = ["passes"],
|
|
15
|
-
_excluded2 = ["moduleName", "vertexShader", "fragmentShader", "
|
|
15
|
+
_excluded2 = ["moduleName", "vertexShader", "fragmentShader", "inject", "triangulation", "segmentNumber"];
|
|
16
16
|
var _dec, _class, _descriptor;
|
|
17
17
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
18
18
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
@@ -24,11 +24,10 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
24
24
|
import { AsyncSeriesBailHook, AsyncWaterfallHook, SyncBailHook, SyncHook } from '@antv/async-hook';
|
|
25
25
|
import { BlendType, IDebugLog, ILayerStage, lazyInject, TYPES } from '@antv/l7-core';
|
|
26
26
|
import Source from '@antv/l7-source';
|
|
27
|
-
import { encodePickingColor
|
|
27
|
+
import { encodePickingColor } from '@antv/l7-utils';
|
|
28
28
|
import { EventEmitter } from 'eventemitter3';
|
|
29
|
-
import { isEqual, isFunction, isObject, isUndefined } from 'lodash';
|
|
29
|
+
import { isEqual, isFunction, isObject, isPlainObject, isUndefined } from 'lodash';
|
|
30
30
|
import { BlendTypes } from "../utils/blend";
|
|
31
|
-
import { styleDataMapping } from "../utils/dataMappingStyle";
|
|
32
31
|
import { calculateData } from "../utils/layerData";
|
|
33
32
|
import { createMultiPassRenderer, normalizePasses } from "../utils/multiPassRender";
|
|
34
33
|
import LayerPickService from "./LayerPickService";
|
|
@@ -107,6 +106,8 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
107
106
|
enable: false
|
|
108
107
|
});
|
|
109
108
|
_defineProperty(_assertThisInitialized(_this), "currentPickId", null);
|
|
109
|
+
_defineProperty(_assertThisInitialized(_this), "encodeStyleAttribute", {});
|
|
110
|
+
_defineProperty(_assertThisInitialized(_this), "enableEncodeStyles", []);
|
|
110
111
|
_defineProperty(_assertThisInitialized(_this), "pendingStyleAttributes", []);
|
|
111
112
|
_defineProperty(_assertThisInitialized(_this), "scaleOptions", {});
|
|
112
113
|
_defineProperty(_assertThisInitialized(_this), "animateStatus", false);
|
|
@@ -126,7 +127,6 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
126
127
|
_this.name = config.name || _this.id;
|
|
127
128
|
_this.zIndex = config.zIndex || 0;
|
|
128
129
|
_this.rawConfig = config;
|
|
129
|
-
// this.parent = this;
|
|
130
130
|
return _this;
|
|
131
131
|
}
|
|
132
132
|
_createClass(BaseLayer, [{
|
|
@@ -199,7 +199,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
199
199
|
} else {
|
|
200
200
|
var sceneId = this.container.get(TYPES.SceneID);
|
|
201
201
|
// @ts-ignore
|
|
202
|
-
styleDataMapping(configToUpdate, this); // 处理 style 中进行数据映射的属性字段
|
|
202
|
+
// styleDataMapping(configToUpdate, this); // 处理 style 中进行数据映射的属性字段
|
|
203
203
|
this.configService.setLayerConfig(sceneId, this.id, _objectSpread(_objectSpread(_objectSpread({}, this.configService.getLayerConfig(this.id)), this.needUpdateConfig), configToUpdate));
|
|
204
204
|
this.needUpdateConfig = {};
|
|
205
205
|
}
|
|
@@ -422,7 +422,9 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
422
422
|
}, {
|
|
423
423
|
key: "prepareBuildModel",
|
|
424
424
|
value: function prepareBuildModel() {
|
|
425
|
-
this.
|
|
425
|
+
if (Object.keys(this.needUpdateConfig || {}).length !== 0) {
|
|
426
|
+
this.updateLayerConfig({});
|
|
427
|
+
}
|
|
426
428
|
|
|
427
429
|
// 启动动画
|
|
428
430
|
var _this$getLayerConfig2 = this.getLayerConfig(),
|
|
@@ -559,21 +561,32 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
559
561
|
}
|
|
560
562
|
});
|
|
561
563
|
}
|
|
562
|
-
this.
|
|
563
|
-
|
|
564
|
-
this.updateLayerConfig(this.rawConfig);
|
|
565
|
-
this.styleNeedUpdate = true;
|
|
566
|
-
}
|
|
567
|
-
// TODO style model 更新
|
|
568
|
-
// @ts-ignore
|
|
569
|
-
// if (lastConfig && lastConfig.mask === true && options.mask === false) {
|
|
570
|
-
// this.clearModels();
|
|
571
|
-
// this.layerModel.buildModels((models) => {
|
|
572
|
-
// this.models = models;
|
|
573
|
-
// });
|
|
574
|
-
// }
|
|
564
|
+
this.encodeStyle(rest);
|
|
565
|
+
this.updateLayerConfig(rest);
|
|
575
566
|
return this;
|
|
576
567
|
}
|
|
568
|
+
|
|
569
|
+
// 参与数据映射的字段 encodeing
|
|
570
|
+
}, {
|
|
571
|
+
key: "encodeStyle",
|
|
572
|
+
value: function encodeStyle(options) {
|
|
573
|
+
var _this6 = this;
|
|
574
|
+
Object.keys(options).forEach(function (key) {
|
|
575
|
+
if (
|
|
576
|
+
// 需要数据映射
|
|
577
|
+
_this6.enableEncodeStyles.includes(key) && isPlainObject(options[key]) && (options[key].field || options[key].values) && !isEqual(_this6.encodeStyleAttribute[key], options[key]) // 防止计算属性重复计算
|
|
578
|
+
) {
|
|
579
|
+
_this6.encodeStyleAttribute[key] = options[key];
|
|
580
|
+
_this6.updateStyleAttribute(key, options[key].field, options[key].values);
|
|
581
|
+
_this6.styleNeedUpdate = true;
|
|
582
|
+
} else {
|
|
583
|
+
// 不需要数据映射
|
|
584
|
+
if (_this6.encodeStyleAttribute[key]) {
|
|
585
|
+
delete _this6.encodeStyleAttribute[key]; // 删除已经存在的属性
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
}
|
|
577
590
|
}, {
|
|
578
591
|
key: "scale",
|
|
579
592
|
value: function scale(field, cfg) {
|
|
@@ -683,7 +696,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
683
696
|
}, {
|
|
684
697
|
key: "setActive",
|
|
685
698
|
value: function setActive(id, options) {
|
|
686
|
-
var
|
|
699
|
+
var _this7 = this;
|
|
687
700
|
if (isObject(id)) {
|
|
688
701
|
var _id$x = id.x,
|
|
689
702
|
x = _id$x === void 0 ? 0 : _id$x,
|
|
@@ -707,7 +720,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
707
720
|
// @ts-ignore
|
|
708
721
|
.then(function () {
|
|
709
722
|
setTimeout(function () {
|
|
710
|
-
|
|
723
|
+
_this7.reRender();
|
|
711
724
|
}, 1);
|
|
712
725
|
});
|
|
713
726
|
}
|
|
@@ -734,7 +747,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
734
747
|
}, {
|
|
735
748
|
key: "setSelect",
|
|
736
749
|
value: function setSelect(id, options) {
|
|
737
|
-
var
|
|
750
|
+
var _this8 = this;
|
|
738
751
|
if (isObject(id)) {
|
|
739
752
|
var _id$x2 = id.x,
|
|
740
753
|
x = _id$x2 === void 0 ? 0 : _id$x2,
|
|
@@ -758,7 +771,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
758
771
|
// @ts-ignore
|
|
759
772
|
.then(function () {
|
|
760
773
|
setTimeout(function () {
|
|
761
|
-
|
|
774
|
+
_this8.reRender();
|
|
762
775
|
}, 1);
|
|
763
776
|
});
|
|
764
777
|
}
|
|
@@ -1009,7 +1022,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
1009
1022
|
}, {
|
|
1010
1023
|
key: "setSource",
|
|
1011
1024
|
value: function setSource(source) {
|
|
1012
|
-
var
|
|
1025
|
+
var _this9 = this;
|
|
1013
1026
|
// 解除原 sources 事件
|
|
1014
1027
|
if (this.layerSource) {
|
|
1015
1028
|
this.layerSource.off('update', this.sourceEvent);
|
|
@@ -1028,22 +1041,22 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
1028
1041
|
// this.layerSource.inited 为 true update 事件不会再触发
|
|
1029
1042
|
this.layerSource.on('update', function (_ref4) {
|
|
1030
1043
|
var type = _ref4.type;
|
|
1031
|
-
if (
|
|
1032
|
-
var
|
|
1033
|
-
var layerCenter =
|
|
1034
|
-
|
|
1035
|
-
if ((
|
|
1036
|
-
|
|
1044
|
+
if (_this9.coordCenter === undefined) {
|
|
1045
|
+
var _this9$mapService;
|
|
1046
|
+
var layerCenter = _this9.layerSource.center;
|
|
1047
|
+
_this9.coordCenter = layerCenter;
|
|
1048
|
+
if ((_this9$mapService = _this9.mapService) !== null && _this9$mapService !== void 0 && _this9$mapService.setCoordCenter) {
|
|
1049
|
+
_this9.mapService.setCoordCenter(layerCenter);
|
|
1037
1050
|
}
|
|
1038
1051
|
}
|
|
1039
1052
|
if (type === 'update') {
|
|
1040
|
-
if (
|
|
1053
|
+
if (_this9.tileLayer) {
|
|
1041
1054
|
// 瓦片图层独立更新
|
|
1042
|
-
|
|
1055
|
+
_this9.tileLayer.reload();
|
|
1043
1056
|
return;
|
|
1044
1057
|
}
|
|
1045
1058
|
// source 初始化不需要处理
|
|
1046
|
-
|
|
1059
|
+
_this9.sourceEvent();
|
|
1047
1060
|
}
|
|
1048
1061
|
});
|
|
1049
1062
|
}
|
|
@@ -1141,56 +1154,38 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
1141
1154
|
key: "buildLayerModel",
|
|
1142
1155
|
value: function () {
|
|
1143
1156
|
var _buildLayerModel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(options) {
|
|
1144
|
-
var
|
|
1145
|
-
var moduleName, vertexShader, fragmentShader, triangulation, segmentNumber,
|
|
1157
|
+
var _this10 = this;
|
|
1158
|
+
var moduleName, vertexShader, fragmentShader, inject, triangulation, segmentNumber, rest, _this$shaderModuleSer, vs, fs, uniforms, createModel;
|
|
1146
1159
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
1147
1160
|
while (1) switch (_context3.prev = _context3.next) {
|
|
1148
1161
|
case 0:
|
|
1149
|
-
moduleName = options.moduleName, vertexShader = options.vertexShader, fragmentShader = options.fragmentShader,
|
|
1162
|
+
moduleName = options.moduleName, vertexShader = options.vertexShader, fragmentShader = options.fragmentShader, inject = options.inject, triangulation = options.triangulation, segmentNumber = options.segmentNumber, rest = _objectWithoutProperties(options, _excluded2);
|
|
1150
1163
|
this.shaderModuleService.registerModule(moduleName, {
|
|
1151
1164
|
vs: vertexShader,
|
|
1152
|
-
fs: fragmentShader
|
|
1165
|
+
fs: fragmentShader,
|
|
1166
|
+
inject: inject
|
|
1153
1167
|
});
|
|
1154
1168
|
_this$shaderModuleSer = this.shaderModuleService.getModule(moduleName), vs = _this$shaderModuleSer.vs, fs = _this$shaderModuleSer.fs, uniforms = _this$shaderModuleSer.uniforms;
|
|
1155
1169
|
createModel = this.rendererService.createModel;
|
|
1156
|
-
return _context3.abrupt("return", new Promise(function (resolve
|
|
1157
|
-
//
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
return reject(err);
|
|
1173
|
-
});
|
|
1174
|
-
} else {
|
|
1175
|
-
// console.log(this.encodedData)
|
|
1176
|
-
var _this9$styleAttribute = _this9.styleAttributeService.createAttributesAndIndices(_this9.encodedData, triangulation, segmentNumber),
|
|
1177
|
-
attributes = _this9$styleAttribute.attributes,
|
|
1178
|
-
elements = _this9$styleAttribute.elements,
|
|
1179
|
-
count = _this9$styleAttribute.count;
|
|
1180
|
-
var modelOptions = _objectSpread({
|
|
1181
|
-
attributes: attributes,
|
|
1182
|
-
uniforms: uniforms,
|
|
1183
|
-
fs: fs,
|
|
1184
|
-
vs: vs,
|
|
1185
|
-
elements: elements,
|
|
1186
|
-
blend: BlendTypes[BlendType.normal]
|
|
1187
|
-
}, rest);
|
|
1188
|
-
if (count) {
|
|
1189
|
-
modelOptions.count = count;
|
|
1190
|
-
}
|
|
1191
|
-
var m = createModel(modelOptions);
|
|
1192
|
-
resolve(m);
|
|
1170
|
+
return _context3.abrupt("return", new Promise(function (resolve) {
|
|
1171
|
+
// console.log(this.encodedData)
|
|
1172
|
+
var _this10$styleAttribut = _this10.styleAttributeService.createAttributesAndIndices(_this10.encodedData, triangulation, segmentNumber),
|
|
1173
|
+
attributes = _this10$styleAttribut.attributes,
|
|
1174
|
+
elements = _this10$styleAttribut.elements,
|
|
1175
|
+
count = _this10$styleAttribut.count;
|
|
1176
|
+
var modelOptions = _objectSpread({
|
|
1177
|
+
attributes: attributes,
|
|
1178
|
+
uniforms: uniforms,
|
|
1179
|
+
fs: fs,
|
|
1180
|
+
vs: vs,
|
|
1181
|
+
elements: elements,
|
|
1182
|
+
blend: BlendTypes[BlendType.normal]
|
|
1183
|
+
}, rest);
|
|
1184
|
+
if (count) {
|
|
1185
|
+
modelOptions.count = count;
|
|
1193
1186
|
}
|
|
1187
|
+
var m = createModel(modelOptions);
|
|
1188
|
+
resolve(m);
|
|
1194
1189
|
}));
|
|
1195
1190
|
case 5:
|
|
1196
1191
|
case "end":
|
|
@@ -1320,7 +1315,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
1320
1315
|
}, {
|
|
1321
1316
|
key: "renderModels",
|
|
1322
1317
|
value: function renderModels() {
|
|
1323
|
-
var
|
|
1318
|
+
var _this11 = this;
|
|
1324
1319
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1325
1320
|
// TODO: this.getEncodedData().length > 0 这个判断是为了解决在 2.5.x 引入数据纹理后产生的 空数据渲染导致 texture 超出上限问题
|
|
1326
1321
|
if (this.encodeDataLength <= 0 && !this.forceRender) {
|
|
@@ -1331,9 +1326,9 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
1331
1326
|
this.hooks.beforeRender.call();
|
|
1332
1327
|
this.models.forEach(function (model) {
|
|
1333
1328
|
model.draw({
|
|
1334
|
-
uniforms:
|
|
1335
|
-
blend:
|
|
1336
|
-
stencil:
|
|
1329
|
+
uniforms: _this11.layerModel.getUninforms(),
|
|
1330
|
+
blend: _this11.layerModel.getBlend(),
|
|
1331
|
+
stencil: _this11.layerModel.getStencil(options)
|
|
1337
1332
|
}, (options === null || options === void 0 ? void 0 : options.ispick) || false);
|
|
1338
1333
|
});
|
|
1339
1334
|
this.hooks.afterRender.call();
|
|
@@ -1349,10 +1344,11 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
1349
1344
|
field: field,
|
|
1350
1345
|
values: values
|
|
1351
1346
|
})) {
|
|
1347
|
+
// 检测是否发生更新
|
|
1352
1348
|
return false;
|
|
1353
1349
|
}
|
|
1354
1350
|
|
|
1355
|
-
// 存储 Attribute
|
|
1351
|
+
// 存储 Attribute 瓦片图层使用
|
|
1356
1352
|
if (['color', 'size', 'texture', 'rotate', 'filter', 'label', 'shape'].indexOf(type) !== -1) {
|
|
1357
1353
|
this.configService.setAttributeConfig(this.id, _defineProperty({}, type, {
|
|
1358
1354
|
field: field,
|
package/es/core/BaseModel.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IAnimateOption, IAttribute, IBlendOptions, ICameraService, IElements,
|
|
1
|
+
import { IAnimateOption, IAttribute, IBlendOptions, ICameraService, IElements, IFontService, IGlobalConfigService, IIconService, IInject, ILayer, ILayerModel, ILayerService, IMapService, IModel, IModelUniform, IPickingService, IRendererService, IRenderOptions, IShaderModuleService, IStencilOptions, IStyleAttributeService, ITexture2D, ITexture2DInitializationOptions, Triangulation } from '@antv/l7-core';
|
|
2
2
|
export type styleSingle = number | string | [string, (single: any) => number] | [string, [number, number]];
|
|
3
3
|
export type styleOffset = string | [number, number] | [string, (single: any) => number];
|
|
4
4
|
export type styleColor = string | [string, (single: any) => string] | [string, [string, string]];
|
|
@@ -14,6 +14,8 @@ export interface ICellProperty {
|
|
|
14
14
|
export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerModel {
|
|
15
15
|
triangulation: Triangulation;
|
|
16
16
|
createTexture2D: (options: ITexture2DInitializationOptions) => ITexture2D;
|
|
17
|
+
preStyleAttribute: Record<string, any>;
|
|
18
|
+
protected encodeStyleAttribute: Record<string, boolean>;
|
|
17
19
|
protected layer: ILayer;
|
|
18
20
|
protected dataTexture: ITexture2D;
|
|
19
21
|
protected DATA_TEXTURE_WIDTH: number;
|
|
@@ -49,76 +51,6 @@ export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerMod
|
|
|
49
51
|
protected layerService: ILayerService;
|
|
50
52
|
protected pickingService: IPickingService;
|
|
51
53
|
constructor(layer: ILayer);
|
|
52
|
-
/**
|
|
53
|
-
* 清除上一次的计算结果 - 全量清除
|
|
54
|
-
*/
|
|
55
|
-
clearLastCalRes(): void;
|
|
56
|
-
getCellTypeLayout(): number[];
|
|
57
|
-
/**
|
|
58
|
-
* 判断数据纹理是否需要重新计算 - 根据传入的值进行判断
|
|
59
|
-
* @param options
|
|
60
|
-
* @returns
|
|
61
|
-
*/
|
|
62
|
-
dataTextureNeedUpdate(options: {
|
|
63
|
-
thetaOffset?: styleSingle;
|
|
64
|
-
opacity?: styleSingle;
|
|
65
|
-
strokeOpacity?: styleSingle;
|
|
66
|
-
strokeWidth?: styleSingle;
|
|
67
|
-
stroke?: styleColor;
|
|
68
|
-
offsets?: styleOffset;
|
|
69
|
-
textOffset?: styleOffset;
|
|
70
|
-
}): boolean;
|
|
71
|
-
/**
|
|
72
|
-
* 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量
|
|
73
|
-
* @param options
|
|
74
|
-
*/
|
|
75
|
-
judgeStyleAttributes(options: {
|
|
76
|
-
thetaOffset?: styleSingle;
|
|
77
|
-
opacity?: styleSingle;
|
|
78
|
-
strokeOpacity?: styleSingle;
|
|
79
|
-
strokeWidth?: styleSingle;
|
|
80
|
-
stroke?: styleColor;
|
|
81
|
-
offsets?: styleOffset;
|
|
82
|
-
}): void;
|
|
83
|
-
/**
|
|
84
|
-
* 判断变量 stroke 是否是常量值
|
|
85
|
-
* @param stroke
|
|
86
|
-
* @returns
|
|
87
|
-
*/
|
|
88
|
-
isStaticColor(stroke: styleColor): boolean;
|
|
89
|
-
/**
|
|
90
|
-
* 获取 stroke 颜色并做兼容处理
|
|
91
|
-
* @param stroke
|
|
92
|
-
* @returns
|
|
93
|
-
*/
|
|
94
|
-
getStrokeColor(stroke: styleColor): number[];
|
|
95
|
-
/**
|
|
96
|
-
* 判断 offsets 是否是常量
|
|
97
|
-
* @param offsets
|
|
98
|
-
* @returns
|
|
99
|
-
*/
|
|
100
|
-
isOffsetStatic(offsets: styleOffset): boolean;
|
|
101
|
-
/**
|
|
102
|
-
* 补空位
|
|
103
|
-
* @param d
|
|
104
|
-
* @param count
|
|
105
|
-
*/
|
|
106
|
-
patchMod(d: number[], count: number): void;
|
|
107
|
-
/**
|
|
108
|
-
* 根据映射的数据字段往推入数据
|
|
109
|
-
* @param d
|
|
110
|
-
* @param cellData
|
|
111
|
-
* @param cellPropertiesLayouts
|
|
112
|
-
*/
|
|
113
|
-
patchData(d: number[], cellData: IEncodeFeature, cellPropertiesLayouts: ICellProperty[]): void;
|
|
114
|
-
/**
|
|
115
|
-
* 计算推入数据纹理的数据
|
|
116
|
-
* @param cellLength
|
|
117
|
-
* @param encodeData
|
|
118
|
-
* @param cellPropertiesLayouts
|
|
119
|
-
* @returns
|
|
120
|
-
*/
|
|
121
|
-
calDataFrame(cellLength: number, encodeData: IEncodeFeature[], cellPropertiesLayouts: ICellProperty[]): IDataTextureFrame;
|
|
122
54
|
getBlend(): IBlendOptions;
|
|
123
55
|
getStencil(option: Partial<IRenderOptions>): Partial<IStencilOptions>;
|
|
124
56
|
getDefaultStyle(): unknown;
|
|
@@ -138,4 +70,10 @@ export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerMod
|
|
|
138
70
|
protected registerBuiltinAttributes(): void;
|
|
139
71
|
protected animateOption2Array(option: IAnimateOption): number[];
|
|
140
72
|
protected startModelAnimate(): void;
|
|
73
|
+
protected getInject(): IInject;
|
|
74
|
+
protected getStyleAttribute(): {
|
|
75
|
+
[key: string]: any;
|
|
76
|
+
};
|
|
77
|
+
protected registerStyleAttribute(): void;
|
|
78
|
+
updateEncodeAttribute(type: string, flag: boolean): void;
|
|
141
79
|
}
|