@antv/l7-layers 2.8.33 → 2.8.34

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.
@@ -0,0 +1,283 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
+
16
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
+
18
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
+
20
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
+
22
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
+
24
+ var _isNumber2 = _interopRequireDefault(require("lodash/isNumber"));
25
+
26
+ var _l7Core = require("@antv/l7-core");
27
+
28
+ var _l7Utils = require("@antv/l7-utils");
29
+
30
+ var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
31
+
32
+ var _triangulation = require("../../core/triangulation");
33
+
34
+ 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); }; }
35
+
36
+ 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; } }
37
+
38
+ var linear_line_frag = "uniform float u_opacity : 1.0;\nuniform sampler2D u_texture;\n\n#pragma include \"picking\"\n\nvarying mat4 styleMappingMat;\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float d_distance_ratio = styleMappingMat[3].r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n\n gl_FragColor = texture2D(u_texture, vec2(d_distance_ratio, 0.5));\n\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
39
+ var linear_line_vert = "\nattribute float a_Miter;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\n// dash line\nattribute float a_Total_Distance;\nattribute vec2 a_DistanceAndIndex;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nuniform float u_heightfixed: 0.0;\nuniform float u_vertexScale: 1.0;\nuniform float u_raisingHeight: 0.0;\n\nuniform float u_opacity: 1.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // distance_ratio/distance/pixelLen/texV\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n \n vec2 offset = project_pixel(size.xy);\n\n float lineDistance = a_DistanceAndIndex.x;\n float currentLinePointRatio = lineDistance / a_Total_Distance;\n \n\n float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\uFF08\u5411\u4E24\u4FA7\u504F\u79FB\u7684\u548C\uFF09\n float linePixelSize = project_pixel(a_Size.x) * 2.0; // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB \u5355\u4FA7 * 2\n float texV = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n styleMappingMat[3][0] = currentLinePointRatio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5 vertex height\n float lineHeight = a_Size.y; // size \u7B2C\u4E8C\u4E2A\u53C2\u6570\u4EE3\u8868\u7684\u9AD8\u5EA6 [linewidth, lineheight]\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n lineHeight *= 0.2; // \u4FDD\u6301\u548C amap/mapbox \u4E00\u81F4\u7684\u6548\u679C\n h *= 0.2;\n if(u_heightfixed < 1.0) {\n lineHeight = project_pixel(a_Size.y);\n }\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight + h + u_raisingHeight, 1.0));\n } else {\n // mapbox - amap\n \n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // mapbox\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n h *= mapboxZoomScale;\n h += u_raisingHeight * mapboxZoomScale;\n if(u_heightfixed > 0.0) {\n lineHeight *= mapboxZoomScale;\n }\n \n } else {\n // amap\n h += u_raisingHeight;\n // lineHeight \u9876\u70B9\u504F\u79FB\u9AD8\u5EA6\n if(u_heightfixed < 1.0) {\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
40
+
41
+ var LinearLineModel = function (_BaseModel) {
42
+ (0, _inherits2.default)(LinearLineModel, _BaseModel);
43
+
44
+ var _super = _createSuper(LinearLineModel);
45
+
46
+ function LinearLineModel() {
47
+ var _this;
48
+
49
+ (0, _classCallCheck2.default)(this, LinearLineModel);
50
+
51
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
52
+ args[_key] = arguments[_key];
53
+ }
54
+
55
+ _this = _super.call.apply(_super, [this].concat(args));
56
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "colorTexture", void 0);
57
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateTexture", function () {
58
+ var createTexture2D = _this.rendererService.createTexture2D;
59
+
60
+ if (_this.colorTexture) {
61
+ _this.colorTexture.destroy();
62
+ }
63
+
64
+ var _ref = _this.layer.getLayerConfig(),
65
+ rampColors = _ref.rampColors;
66
+
67
+ var imageData = (0, _l7Utils.generateColorRamp)(rampColors);
68
+ _this.colorTexture = createTexture2D({
69
+ data: new Uint8Array(imageData.data),
70
+ width: imageData.width,
71
+ height: imageData.height,
72
+ wrapS: _l7Core.gl.CLAMP_TO_EDGE,
73
+ wrapT: _l7Core.gl.CLAMP_TO_EDGE,
74
+ min: _l7Core.gl.NEAREST,
75
+ mag: _l7Core.gl.NEAREST,
76
+ flipY: false
77
+ });
78
+ });
79
+ return _this;
80
+ }
81
+
82
+ (0, _createClass2.default)(LinearLineModel, [{
83
+ key: "getUninforms",
84
+ value: function getUninforms() {
85
+ var _ref2 = this.layer.getLayerConfig(),
86
+ opacity = _ref2.opacity,
87
+ _ref2$vertexHeightSca = _ref2.vertexHeightScale,
88
+ vertexHeightScale = _ref2$vertexHeightSca === void 0 ? 20.0 : _ref2$vertexHeightSca,
89
+ _ref2$raisingHeight = _ref2.raisingHeight,
90
+ raisingHeight = _ref2$raisingHeight === void 0 ? 0 : _ref2$raisingHeight,
91
+ _ref2$heightfixed = _ref2.heightfixed,
92
+ heightfixed = _ref2$heightfixed === void 0 ? false : _ref2$heightfixed;
93
+
94
+ if (this.rendererService.getDirty()) {
95
+ this.colorTexture.bind();
96
+ }
97
+
98
+ if (this.dataTextureTest && this.dataTextureNeedUpdate({
99
+ opacity: opacity
100
+ })) {
101
+ this.judgeStyleAttributes({
102
+ opacity: opacity
103
+ });
104
+ var encodeData = this.layer.getEncodedData();
105
+
106
+ var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
107
+ data = _this$calDataFrame.data,
108
+ width = _this$calDataFrame.width,
109
+ height = _this$calDataFrame.height;
110
+
111
+ this.rowCount = height;
112
+ this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
113
+ flipY: true,
114
+ data: data,
115
+ format: _l7Core.gl.LUMINANCE,
116
+ type: _l7Core.gl.FLOAT,
117
+ width: width,
118
+ height: height
119
+ }) : this.createTexture2D({
120
+ flipY: true,
121
+ data: [1],
122
+ format: _l7Core.gl.LUMINANCE,
123
+ type: _l7Core.gl.FLOAT,
124
+ width: 1,
125
+ height: 1
126
+ });
127
+ }
128
+
129
+ return {
130
+ u_dataTexture: this.dataTexture,
131
+ u_cellTypeLayout: this.getCellTypeLayout(),
132
+ u_opacity: (0, _isNumber2.default)(opacity) ? opacity : 1.0,
133
+ u_texture: this.colorTexture,
134
+ u_heightfixed: Number(heightfixed),
135
+ u_vertexScale: vertexHeightScale,
136
+ u_raisingHeight: Number(raisingHeight)
137
+ };
138
+ }
139
+ }, {
140
+ key: "initModels",
141
+ value: function initModels() {
142
+ this.updateTexture();
143
+ return this.buildModels();
144
+ }
145
+ }, {
146
+ key: "clearModels",
147
+ value: function clearModels() {
148
+ var _this$colorTexture, _this$dataTexture;
149
+
150
+ (_this$colorTexture = this.colorTexture) === null || _this$colorTexture === void 0 ? void 0 : _this$colorTexture.destroy();
151
+ (_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
152
+ }
153
+ }, {
154
+ key: "buildModels",
155
+ value: function buildModels() {
156
+ var _ref3 = this.layer.getLayerConfig(),
157
+ _ref3$mask = _ref3.mask,
158
+ mask = _ref3$mask === void 0 ? false : _ref3$mask,
159
+ _ref3$maskInside = _ref3.maskInside,
160
+ maskInside = _ref3$maskInside === void 0 ? true : _ref3$maskInside,
161
+ _ref3$depth = _ref3.depth,
162
+ depth = _ref3$depth === void 0 ? false : _ref3$depth;
163
+
164
+ var _this$getShaders = this.getShaders(),
165
+ frag = _this$getShaders.frag,
166
+ vert = _this$getShaders.vert,
167
+ type = _this$getShaders.type;
168
+
169
+ this.layer.triangulation = _triangulation.LineTriangulation;
170
+ return [this.layer.buildLayerModel({
171
+ moduleName: 'line_' + type,
172
+ vertexShader: vert,
173
+ fragmentShader: frag,
174
+ triangulation: _triangulation.LineTriangulation,
175
+ primitive: _l7Core.gl.TRIANGLES,
176
+ blend: this.getBlend(),
177
+ depth: {
178
+ enable: depth
179
+ },
180
+ stencil: (0, _l7Utils.getMask)(mask, maskInside)
181
+ })];
182
+ }
183
+ }, {
184
+ key: "getShaders",
185
+ value: function getShaders() {
186
+ return {
187
+ frag: linear_line_frag,
188
+ vert: linear_line_vert,
189
+ type: 'linear_rampColors'
190
+ };
191
+ }
192
+ }, {
193
+ key: "registerBuiltinAttributes",
194
+ value: function registerBuiltinAttributes() {
195
+ this.styleAttributeService.registerStyleAttribute({
196
+ name: 'distanceAndIndex',
197
+ type: _l7Core.AttributeType.Attribute,
198
+ descriptor: {
199
+ name: 'a_DistanceAndIndex',
200
+ buffer: {
201
+ usage: _l7Core.gl.STATIC_DRAW,
202
+ data: [],
203
+ type: _l7Core.gl.FLOAT
204
+ },
205
+ size: 2,
206
+ update: function update(feature, featureIdx, vertex, attributeIdx, normal, vertexIndex) {
207
+ return vertexIndex === undefined ? [vertex[3], 10] : [vertex[3], vertexIndex];
208
+ }
209
+ }
210
+ });
211
+ this.styleAttributeService.registerStyleAttribute({
212
+ name: 'total_distance',
213
+ type: _l7Core.AttributeType.Attribute,
214
+ descriptor: {
215
+ name: 'a_Total_Distance',
216
+ buffer: {
217
+ usage: _l7Core.gl.STATIC_DRAW,
218
+ data: [],
219
+ type: _l7Core.gl.FLOAT
220
+ },
221
+ size: 1,
222
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
223
+ return [vertex[5]];
224
+ }
225
+ }
226
+ });
227
+ this.styleAttributeService.registerStyleAttribute({
228
+ name: 'size',
229
+ type: _l7Core.AttributeType.Attribute,
230
+ descriptor: {
231
+ name: 'a_Size',
232
+ buffer: {
233
+ usage: _l7Core.gl.DYNAMIC_DRAW,
234
+ data: [],
235
+ type: _l7Core.gl.FLOAT
236
+ },
237
+ size: 2,
238
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
239
+ var _feature$size = feature.size,
240
+ size = _feature$size === void 0 ? 1 : _feature$size;
241
+ return Array.isArray(size) ? [size[0], size[1]] : [size, 0];
242
+ }
243
+ }
244
+ });
245
+ this.styleAttributeService.registerStyleAttribute({
246
+ name: 'normal',
247
+ type: _l7Core.AttributeType.Attribute,
248
+ descriptor: {
249
+ name: 'a_Normal',
250
+ buffer: {
251
+ usage: _l7Core.gl.STATIC_DRAW,
252
+ data: [],
253
+ type: _l7Core.gl.FLOAT
254
+ },
255
+ size: 3,
256
+ update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
257
+ return normal;
258
+ }
259
+ }
260
+ });
261
+ this.styleAttributeService.registerStyleAttribute({
262
+ name: 'miter',
263
+ type: _l7Core.AttributeType.Attribute,
264
+ descriptor: {
265
+ name: 'a_Miter',
266
+ buffer: {
267
+ usage: _l7Core.gl.STATIC_DRAW,
268
+ data: [],
269
+ type: _l7Core.gl.FLOAT
270
+ },
271
+ size: 1,
272
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
273
+ return [vertex[4]];
274
+ }
275
+ }
276
+ });
277
+ }
278
+ }]);
279
+ return LinearLineModel;
280
+ }(_BaseModel2.default);
281
+
282
+ exports.default = LinearLineModel;
283
+ //# sourceMappingURL=linearline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/line/models/linearline.ts"],"names":["LinearLineModel","createTexture2D","rendererService","colorTexture","destroy","layer","getLayerConfig","rampColors","imageData","data","Uint8Array","width","height","wrapS","gl","CLAMP_TO_EDGE","wrapT","min","NEAREST","mag","flipY","opacity","vertexHeightScale","raisingHeight","heightfixed","getDirty","bind","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","length","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_texture","u_heightfixed","Number","u_vertexScale","u_raisingHeight","updateTexture","buildModels","mask","maskInside","depth","getShaders","frag","vert","triangulation","LineTriangulation","buildLayerModel","moduleName","vertexShader","fragmentShader","primitive","TRIANGLES","blend","getBlend","enable","stencil","linear_line_frag","linear_line_vert","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","normal","vertexIndex","undefined","DYNAMIC_DRAW","Array","isArray","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;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A,MAAP;AACD;AAlBS;AAHoC,OAAlD;AAyBA,WAAKf,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,OAD0C;AAEhDnC,QAAAA,IAAI,EAAEoC,sBAAcC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,SADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAElE,WAAGmE,WAFJ;AAGNxE,YAAAA,IAAI,EAAE,EAHA;AAIN+B,YAAAA,IAAI,EAAE1B,WAAG2B;AAJH,WAFE;AAQVyC,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,mBAAO,CAACD,MAAM,CAAC,CAAD,CAAP,CAAP;AACD;AAhBS;AAHoC,OAAlD;AAsBD;;;EAlO0CQ,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n IImage,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\n\nimport { generateColorRamp, getMask, IColorRamp } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions } from '../../core/interface';\nimport { LineTriangulation } from '../../core/triangulation';\nimport linear_line_frag from '../shaders/linearLine/line_linear_frag.glsl';\nimport linear_line_vert from '../shaders/linearLine/line_linear_vert.glsl';\n\nexport default class LinearLineModel extends BaseModel {\n protected colorTexture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity,\n vertexHeightScale = 20.0,\n raisingHeight = 0,\n heightfixed = false,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (this.rendererService.getDirty()) {\n this.colorTexture.bind();\n }\n\n if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {\n this.judgeStyleAttributes({ opacity });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n // 纹理支持参数\n u_texture: this.colorTexture, // 贴图\n\n // 是否固定高度\n u_heightfixed: Number(heightfixed),\n\n // 顶点高度 scale\n u_vertexScale: vertexHeightScale,\n u_raisingHeight: Number(raisingHeight),\n };\n }\n\n public initModels(): IModel[] {\n this.updateTexture();\n return this.buildModels();\n }\n\n public clearModels() {\n this.colorTexture?.destroy();\n this.dataTexture?.destroy();\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n depth = false,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n const { frag, vert, type } = this.getShaders();\n this.layer.triangulation = LineTriangulation;\n return [\n this.layer.buildLayerModel({\n moduleName: 'line_' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: LineTriangulation,\n primitive: gl.TRIANGLES,\n blend: this.getBlend(),\n depth: { enable: depth },\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n /**\n * 根据参数获取不同的 shader 代码\n * @returns\n */\n public getShaders(): { frag: string; vert: string; type: string } {\n return {\n frag: linear_line_frag,\n vert: linear_line_vert,\n type: 'linear_rampColors',\n };\n }\n\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'distanceAndIndex',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_DistanceAndIndex',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n vertexIndex?: number,\n ) => {\n return vertexIndex === undefined\n ? [vertex[3], 10]\n : [vertex[3], vertexIndex];\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'total_distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Total_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[5]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n // @ts-ignore\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'miter',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Miter',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[4]];\n },\n },\n });\n }\n\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.colorTexture) {\n this.colorTexture.destroy();\n }\n const {\n rampColors,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n const imageData = generateColorRamp(rampColors as IColorRamp);\n this.colorTexture = createTexture2D({\n data: new Uint8Array(imageData.data),\n width: imageData.width,\n height: imageData.height,\n wrapS: gl.CLAMP_TO_EDGE,\n wrapT: gl.CLAMP_TO_EDGE,\n min: gl.NEAREST,\n mag: gl.NEAREST,\n flipY: false,\n });\n };\n}\n"],"file":"linearline.js"}
@@ -124,6 +124,7 @@ var NormalModel = function (_BaseModel) {
124
124
  _ref2$maskInside = _ref2.maskInside,
125
125
  maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
126
126
 
127
+ this.layer.triangulation = PointTriangulation;
127
128
  return [this.layer.buildLayerModel({
128
129
  moduleName: 'normalpoint',
129
130
  vertexShader: normalVert,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/point/models/normal.ts"],"names":["PointTriangulation","feature","coordinates","vertices","indices","size","length","NormalModel","blend","layer","getLayerConfig","opacity","offsets","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_offsets","isOffsetStatic","buildModels","mask","maskInside","buildLayerModel","moduleName","vertexShader","normalVert","fragmentShader","normalFrag","triangulation","depth","enable","primitive","POINTS","getBlend","stencil","destroy","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","update","featureIdx","vertex","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D,kBAJU;AAKzBiD,QAAAA,KAAK,EAAE;AAAEC,UAAAA,MAAM,EAAE;AAAV,SALkB;AAMzBC,QAAAA,SAAS,EAAEtB,WAAGuB,MANW;AAOzB5C,QAAAA,KAAK,EAAE,KAAK6C,QAAL,EAPkB;AAQzBC,QAAAA,OAAO,EAAE,sBAAQd,IAAR,EAAcC,UAAd;AARgB,OAA3B,CADK,CAAP;AAYD;;;WAED,uBAAqB;AAAA;;AACnB,gCAAKhB,WAAL,wEAAkB8B,OAAlB;AACD;;;WAED,qCAAsC;AAEpC,WAAKC,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,MAD0C;AAEhD3B,QAAAA,IAAI,EAAE4B,sBAAcC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,QADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAElC,WAAGmC,YAFJ;AAGN3C,YAAAA,IAAI,EAAE,EAHA;AAINU,YAAAA,IAAI,EAAEF,WAAGG;AAJH,WAFE;AAQV3B,UAAAA,IAAI,EAAE,CARI;AASV4D,UAAAA,MAAM,EAAE,gBACNhE,OADM,EAENiE,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gCAAqBnE,OAArB,CAAQI,IAAR;AAAA,gBAAQA,IAAR,8BAAe,CAAf;AACA,mBAAOgE,KAAK,CAACC,OAAN,CAAcjE,IAAd,IAAsB,CAACA,IAAI,CAAC,CAAD,CAAL,CAAtB,GAAkC,CAACA,IAAD,CAAzC;AACD;AAjBS;AAHoC,OAAlD;AAuBD;;;WAED,+BAAgE;AAC9D,aAAO;AACLG,QAAAA,KAAK,EAAE+D,kBAAUC;AADZ,OAAP;AAGD;;;EAvHsCC,mB","sourcesContent":["import {\n AttributeType,\n BlendType,\n gl,\n IEncodeFeature,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport { getMask } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport normalFrag from '../shaders/normal_frag.glsl';\nimport normalVert from '../shaders/normal_vert.glsl';\n\nexport function PointTriangulation(feature: IEncodeFeature) {\n const coordinates = feature.coordinates as number[];\n return {\n vertices: [...coordinates],\n indices: [0],\n size: coordinates.length,\n };\n}\n\nexport default class NormalModel extends BaseModel {\n public getDefaultStyle(): Partial<IPointLayerStyleOptions> {\n return {\n blend: 'additive',\n };\n }\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n offsets = [0, 0],\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n offsets,\n });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n };\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n return [\n this.layer.buildLayerModel({\n moduleName: 'normalpoint',\n vertexShader: normalVert,\n fragmentShader: normalFrag,\n triangulation: PointTriangulation,\n depth: { enable: false },\n primitive: gl.POINTS,\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n protected registerBuiltinAttributes() {\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n }\n\n private defaultStyleOptions(): Partial<IPointLayerStyleOptions> {\n return {\n blend: BlendType.additive,\n };\n }\n}\n"],"file":"normal.js"}
1
+ {"version":3,"sources":["../../../src/point/models/normal.ts"],"names":["PointTriangulation","feature","coordinates","vertices","indices","size","length","NormalModel","blend","layer","getLayerConfig","opacity","offsets","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_offsets","isOffsetStatic","buildModels","mask","maskInside","triangulation","buildLayerModel","moduleName","vertexShader","normalVert","fragmentShader","normalFrag","depth","enable","primitive","POINTS","getBlend","stencil","destroy","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","update","featureIdx","vertex","attributeIdx","Array","isArray","BlendType","additive","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAQA;;AAEA;;;;;;;;;AAKO,SAASA,kBAAT,CAA4BC,OAA5B,EA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AAAA,SAAS,EAAEtB,WAAGuB,MANW;AAOzB5C,QAAAA,KAAK,EAAE,KAAK6C,QAAL,EAPkB;AAQzBC,QAAAA,OAAO,EAAE,sBAAQd,IAAR,EAAcC,UAAd;AARgB,OAA3B,CADK,CAAP;AAYD;;;WAED,uBAAqB;AAAA;;AACnB,gCAAKhB,WAAL,wEAAkB8B,OAAlB;AACD;;;WAED,qCAAsC;AAEpC,WAAKC,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,MAD0C;AAEhD3B,QAAAA,IAAI,EAAE4B,sBAAcC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,QADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAElC,WAAGmC,YAFJ;AAGN3C,YAAAA,IAAI,EAAE,EAHA;AAINU,YAAAA,IAAI,EAAEF,WAAGG;AAJH,WAFE;AAQV3B,UAAAA,IAAI,EAAE,CARI;AASV4D,UAAAA,MAAM,EAAE,gBACNhE,OADM,EAENiE,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gCAAqBnE,OAArB,CAAQI,IAAR;AAAA,gBAAQA,IAAR,8BAAe,CAAf;AACA,mBAAOgE,KAAK,CAACC,OAAN,CAAcjE,IAAd,IAAsB,CAACA,IAAI,CAAC,CAAD,CAAL,CAAtB,GAAkC,CAACA,IAAD,CAAzC;AACD;AAjBS;AAHoC,OAAlD;AAuBD;;;WAED,+BAAgE;AAC9D,aAAO;AACLG,QAAAA,KAAK,EAAE+D,kBAAUC;AADZ,OAAP;AAGD;;;EAxHsCC,mB","sourcesContent":["import {\n AttributeType,\n BlendType,\n gl,\n IEncodeFeature,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport { getMask } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport normalFrag from '../shaders/normal_frag.glsl';\nimport normalVert from '../shaders/normal_vert.glsl';\n\nexport function PointTriangulation(feature: IEncodeFeature) {\n const coordinates = feature.coordinates as number[];\n return {\n vertices: [...coordinates],\n indices: [0],\n size: coordinates.length,\n };\n}\n\nexport default class NormalModel extends BaseModel {\n public getDefaultStyle(): Partial<IPointLayerStyleOptions> {\n return {\n blend: 'additive',\n };\n }\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n offsets = [0, 0],\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n offsets,\n });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n };\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n this.layer.triangulation = PointTriangulation;\n return [\n this.layer.buildLayerModel({\n moduleName: 'normalpoint',\n vertexShader: normalVert,\n fragmentShader: normalFrag,\n triangulation: PointTriangulation,\n depth: { enable: false },\n primitive: gl.POINTS,\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n protected registerBuiltinAttributes() {\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n }\n\n private defaultStyleOptions(): Partial<IPointLayerStyleOptions> {\n return {\n blend: BlendType.additive,\n };\n }\n}\n"],"file":"normal.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-layers",
3
- "version": "2.8.33",
3
+ "version": "2.8.34",
4
4
  "description": "L7's collection of built-in layers",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -24,9 +24,9 @@
24
24
  "license": "ISC",
25
25
  "dependencies": {
26
26
  "@antv/geo-coord": "^1.0.8",
27
- "@antv/l7-core": "^2.8.33",
28
- "@antv/l7-source": "^2.8.33",
29
- "@antv/l7-utils": "^2.8.33",
27
+ "@antv/l7-core": "^2.8.34",
28
+ "@antv/l7-source": "^2.8.34",
29
+ "@antv/l7-utils": "^2.8.34",
30
30
  "@babel/runtime": "^7.7.7",
31
31
  "@mapbox/martini": "^0.2.0",
32
32
  "@turf/meta": "^6.0.2",
@@ -52,7 +52,7 @@
52
52
  "@types/gl-matrix": "^2.4.5",
53
53
  "@types/lodash": "^4.14.138"
54
54
  },
55
- "gitHead": "e8e54bdbb77872096e49b733f3ef818ee3f9b88d",
55
+ "gitHead": "103b07c19d4a191d8af2d4bb58b2979d51102841",
56
56
  "publishConfig": {
57
57
  "access": "public"
58
58
  }