@antv/l7-layers 2.9.13 → 2.9.14
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 +0 -1
- package/es/core/BaseLayer.js +24 -29
- package/es/core/BaseLayer.js.map +1 -1
- package/es/line/index.d.ts +1 -1
- package/es/line/index.js +6 -1
- package/es/line/index.js.map +1 -1
- package/es/line/models/earthArc_3d.d.ts +17 -0
- package/es/line/models/earthArc_3d.js +311 -0
- package/es/line/models/earthArc_3d.js.map +1 -0
- package/es/line/models/index.d.ts +1 -1
- package/es/line/models/index.js +3 -1
- package/es/line/models/index.js.map +1 -1
- package/es/point/index.d.ts +1 -1
- package/es/point/index.js +4 -2
- package/es/point/index.js.map +1 -1
- package/es/point/models/earthExtrude.d.ts +24 -0
- package/es/point/models/earthExtrude.js +259 -0
- package/es/point/models/earthExtrude.js.map +1 -0
- package/es/point/models/earthFill.d.ts +20 -0
- package/es/point/models/earthFill.js +255 -0
- package/es/point/models/earthFill.js.map +1 -0
- package/es/point/models/extrude.d.ts +0 -1
- package/es/point/models/extrude.js +2 -10
- package/es/point/models/extrude.js.map +1 -1
- package/es/point/models/fill.js +7 -43
- package/es/point/models/fill.js.map +1 -1
- package/es/point/models/index.d.ts +1 -1
- package/es/point/models/index.js +5 -1
- package/es/point/models/index.js.map +1 -1
- package/lib/core/BaseLayer.js +24 -29
- package/lib/core/BaseLayer.js.map +1 -1
- package/lib/line/index.js +6 -1
- package/lib/line/index.js.map +1 -1
- package/lib/line/models/earthArc_3d.js +328 -0
- package/lib/line/models/earthArc_3d.js.map +1 -0
- package/lib/line/models/index.js +4 -1
- package/lib/line/models/index.js.map +1 -1
- package/lib/point/index.js +4 -2
- package/lib/point/index.js.map +1 -1
- package/lib/point/models/earthExtrude.js +277 -0
- package/lib/point/models/earthExtrude.js.map +1 -0
- package/lib/point/models/earthFill.js +291 -0
- package/lib/point/models/earthFill.js.map +1 -0
- package/lib/point/models/extrude.js +2 -11
- package/lib/point/models/extrude.js.map +1 -1
- package/lib/point/models/fill.js +6 -62
- package/lib/point/models/fill.js.map +1 -1
- package/lib/point/models/index.js +7 -1
- package/lib/point/models/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -31,8 +31,6 @@ var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
|
31
31
|
|
|
32
32
|
var _triangulation = require("../../core/triangulation");
|
|
33
33
|
|
|
34
|
-
var _utils = require("../../earth/utils");
|
|
35
|
-
|
|
36
34
|
var _geo = require("../../utils/geo");
|
|
37
35
|
|
|
38
36
|
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); }; }
|
|
@@ -40,7 +38,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
40
38
|
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; } }
|
|
41
39
|
|
|
42
40
|
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\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\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;\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float lightWeight = styleMappingMat[1][3];\n float barLinearZ = styleMappingMat[2][3];\n\n // \u8BBE\u7F6E\u5706\u67F1\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, barLinearZ);\n gl_FragColor.rgb *= lightWeight;\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n // \u5E94\u7528\u900F\u660E\u5EA6\n gl_FragColor.a *= opacity;\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 - barLinearZ): barLinearZ;\n }\n\n // picking\n if(u_pickLight > 0.0) {\n gl_FragColor = filterColorAlpha(gl_FragColor, lightWeight);\n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n}\n";
|
|
43
|
-
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
|
|
41
|
+
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;\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\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 // 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 - lightWeight\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1] - linearZ(\u5782\u76F4\u65B9\u5411 0 - 1 \u7684\u503C)\n 0.0, 0.0, 0.0, 0.0\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 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 styleMappingMat[2][3] = 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 styleMappingMat[1][3] = lightWeight;\n\n v_color =vec4(a_Color.rgb * lightWeight, a_Color.w);\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";
|
|
44
42
|
|
|
45
43
|
var ExtrudeModel = function (_BaseModel) {
|
|
46
44
|
(0, _inherits2.default)(ExtrudeModel, _BaseModel);
|
|
@@ -152,7 +150,6 @@ var ExtrudeModel = function (_BaseModel) {
|
|
|
152
150
|
u_pickLight: Number(pickLight),
|
|
153
151
|
u_heightfixed: Number(heightfixed),
|
|
154
152
|
u_r: animateOption.enable && this.raiserepeat > 0 ? this.raiseCount : 1.0,
|
|
155
|
-
u_globel: this.mapService.version === 'GLOBEL' ? 1 : 0,
|
|
156
153
|
u_dataTexture: this.dataTexture,
|
|
157
154
|
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
158
155
|
u_opacity: (0, _isNumber2.default)(opacity) ? opacity : 1.0,
|
|
@@ -204,7 +201,6 @@ var ExtrudeModel = function (_BaseModel) {
|
|
|
204
201
|
}, {
|
|
205
202
|
key: "registerBuiltinAttributes",
|
|
206
203
|
value: function registerBuiltinAttributes() {
|
|
207
|
-
var isGlobel = this.mapService.version === 'GLOBEL';
|
|
208
204
|
this.styleAttributeService.registerStyleAttribute({
|
|
209
205
|
name: 'size',
|
|
210
206
|
type: _l7Core.AttributeType.Attribute,
|
|
@@ -266,12 +262,7 @@ var ExtrudeModel = function (_BaseModel) {
|
|
|
266
262
|
size: 3,
|
|
267
263
|
update: function update(feature, featureIdx) {
|
|
268
264
|
var coordinates = (0, _geo.calculateCentroid)(feature.coordinates);
|
|
269
|
-
|
|
270
|
-
if (isGlobel) {
|
|
271
|
-
return (0, _utils.lglt2xyz)([coordinates[0], coordinates[1]]);
|
|
272
|
-
} else {
|
|
273
|
-
return [coordinates[0], coordinates[1], 0];
|
|
274
|
-
}
|
|
265
|
+
return [coordinates[0], coordinates[1], 0];
|
|
275
266
|
}
|
|
276
267
|
}
|
|
277
268
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/point/models/extrude.ts"],"names":["ExtrudeModel","layer","getLayerConfig","animateOption","enable","speed","repeat","opacity","sourceColor","targetColor","pickLight","heightfixed","opacityLinear","dir","lightEnable","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","useLinearColor","sourceColorArr","targetColorArr","raiseCount","raiserepeat","u_pickLight","Number","u_heightfixed","u_r","u_globel","mapService","version","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_linearColor","u_sourceColor","u_targetColor","u_opacitylinear","u_opacitylinear_dir","u_lightEnable","buildModels","depth","buildLayerModel","moduleName","vertexShader","pointExtrudeVert","fragmentShader","pointExtrudeFrag","triangulation","PointExtrudeTriangulation","blend","getBlend","cull","face","destroy","isGlobel","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","buffersize","Array","isArray","STATIC_DRAW","normal","coordinates","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAOA;;AAEA;;AAEA;;AACA;;AACA;;;;;;;;;IAIqBA,Y;;;;;;;;;;;;;;;6FACU,C;8FACC,C;;;;;;WAC9B,wBAAsB;AACpB,iBAoBI,KAAKC,KAAL,CAAWC,cAAX,EApBJ;AAAA,oCACEC,aADF;AAAA,UACEA,aADF,mCACkB;AACdC,QAAAA,MAAM,EAAE,KADM;AAEdC,QAAAA,KAAK,EAAE,IAFO;AAGdC,QAAAA,MAAM,EAAE;AAHM,OADlB;AAAA,8BAMEC,OANF;AAAA,UAMEA,OANF,6BAMY,CANZ;AAAA,UAQEC,WARF,QAQEA,WARF;AAAA,UASEC,WATF,QASEA,WATF;AAAA,gCAWEC,SAXF;AAAA,UAWEA,SAXF,+BAWc,KAXd;AAAA,kCAYEC,WAZF;AAAA,UAYEA,WAZF,iCAYgB,KAZhB;AAAA,oCAcEC,aAdF;AAAA,UAcEA,aAdF,mCAckB;AACdR,QAAAA,MAAM,EAAE,KADM;AAEdS,QAAAA,GAAG,EAAE;AAFS,OAdlB;AAAA,kCAmBEC,WAnBF;AAAA,UAmBEA,WAnBF,iCAmBgB,IAnBhB;;AAuBA,UACE,KAAKC,eAAL,IACA,KAAKC,qBAAL,CAA2B;AACzBT,QAAAA,OAAO,EAAPA;AADyB,O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AAE;AAENC,YAAAA,KAAK,EAAEjD,WAAG4D,WAFJ;AAGNrE,YAAAA,IAAI,EAAE,EAHA;AAINW,YAAAA,IAAI,EAAEF,WAAGG;AAJH,WAFE;AAQVgD,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKNK,MALM,EAMH;AACH,mBAAOA,MAAP;AACD;AAjBS;AAHoC,OAAlD;AAuBA,WAAKnB,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,KAD0C;AAEhD1C,QAAAA,IAAI,EAAE2C,sBAAcC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,OADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAEjD,WAAGkD,YAFJ;AAGN3D,YAAAA,IAAI,EAAE,EAHA;AAINW,YAAAA,IAAI,EAAEF,WAAGG;AAJH,WAFE;AAQVgD,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBAACC,OAAD,EAA0BC,UAA1B,EAAiD;AACvD,gBAAMQ,WAAW,GAAG,4BAAkBT,OAAO,CAACS,WAA1B,CAApB;;AACA,gBAAIrB,QAAJ,EAAc;AAEZ,qBAAO,qBAAS,CAACqB,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,CAAT,CAAP;AAKD,aAPD,MAOO;AACL,qBAAO,CAACA,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,EAAiC,CAAjC,CAAP;AACD;AACF;AArBS;AAHoC,OAAlD;AA2BD;;;EA/OuCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n} from '@antv/l7-core';\nimport { getCullFace, rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport { PointExtrudeTriangulation } from '../../core/triangulation';\nimport { lglt2xyz } from '../../earth/utils';\nimport { calculateCentroid } from '../../utils/geo';\nimport pointExtrudeFrag from '../shaders/extrude/extrude_frag.glsl';\nimport pointExtrudeVert from '../shaders/extrude/extrude_vert.glsl';\n\nexport default class ExtrudeModel extends BaseModel {\n private raiseCount: number = 0;\n private raiserepeat: number = 0;\n public getUninforms() {\n const {\n animateOption = {\n enable: false,\n speed: 0.01,\n repeat: false,\n },\n opacity = 1,\n\n sourceColor,\n targetColor,\n\n pickLight = false,\n heightfixed = false,\n\n opacityLinear = {\n enable: false,\n dir: 'up',\n },\n\n lightEnable = true,\n } = this.layer.getLayerConfig() as Partial<\n ILayerConfig & IPointLayerStyleOptions\n >;\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n })\n ) {\n this.judgeStyleAttributes({\n opacity,\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\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n if (this.raiseCount < 1 && this.raiserepeat > 0) {\n if (animateOption.enable) {\n const { speed = 0.01, repeat = false } = animateOption;\n this.raiseCount += speed;\n if (this.raiseCount >= 1) {\n if (this.raiserepeat > 1) {\n this.raiseCount = 0;\n this.raiserepeat--;\n } else {\n this.raiseCount = 1;\n }\n }\n }\n }\n\n return {\n // 圆柱体的拾取高亮是否要计算光照\n u_pickLight: Number(pickLight),\n // 圆柱体是否固定高度\n u_heightfixed: Number(heightfixed),\n\n u_r: animateOption.enable && this.raiserepeat > 0 ? this.raiseCount : 1.0,\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n u_globel: this.mapService.version === 'GLOBEL' ? 1 : 0,\n\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n\n // 透明度渐变\n u_opacitylinear: Number(opacityLinear.enable),\n u_opacitylinear_dir: opacityLinear.dir === 'up' ? 1.0 : 0.0,\n\n // 光照计算开关\n u_lightEnable: Number(lightEnable),\n };\n }\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n // GAODE1.x GAODE2.x MAPBOX\n const {\n depth = true,\n animateOption: { repeat = 1 },\n } = this.layer.getLayerConfig() as ILayerConfig;\n this.raiserepeat = repeat;\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointExtrude2',\n vertexShader: pointExtrudeVert,\n fragmentShader: pointExtrudeFrag,\n triangulation: PointExtrudeTriangulation,\n blend: this.getBlend(),\n cull: {\n enable: true,\n face: getCullFace(this.mapService.version),\n },\n depth: {\n enable: depth,\n },\n }),\n ];\n }\n public clearModels() {\n this.dataTexture?.destroy();\n }\n protected registerBuiltinAttributes() {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\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: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size } = feature;\n if (size) {\n let buffersize: number[] = [];\n if (Array.isArray(size)) {\n buffersize =\n size.length === 2 ? [size[0], size[0], size[1]] : size;\n }\n if (!Array.isArray(size)) {\n buffersize = [size, size, size];\n }\n return buffersize;\n } else {\n return [2, 2, 2];\n }\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 update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'pos',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Pos',\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: 3,\n update: (feature: IEncodeFeature, featureIdx: number) => {\n const coordinates = calculateCentroid(feature.coordinates);\n if (isGlobel) {\n // TODO: 在地球模式下需要将传入 shader 的经纬度转化成对应的 xyz 坐标\n return lglt2xyz([coordinates[0], coordinates[1]]) as [\n number,\n number,\n number,\n ];\n } else {\n return [coordinates[0], coordinates[1], 0];\n }\n },\n },\n });\n }\n}\n"],"file":"extrude.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/point/models/extrude.ts"],"names":["ExtrudeModel","layer","getLayerConfig","animateOption","enable","speed","repeat","opacity","sourceColor","targetColor","pickLight","heightfixed","opacityLinear","dir","lightEnable","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","useLinearColor","sourceColorArr","targetColorArr","raiseCount","raiserepeat","u_pickLight","Number","u_heightfixed","u_r","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_linearColor","u_sourceColor","u_targetColor","u_opacitylinear","u_opacitylinear_dir","u_lightEnable","buildModels","depth","buildLayerModel","moduleName","vertexShader","pointExtrudeVert","fragmentShader","pointExtrudeFrag","triangulation","PointExtrudeTriangulation","blend","getBlend","cull","face","mapService","version","destroy","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","buffersize","Array","isArray","STATIC_DRAW","normal","coordinates","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAOA;;AAEA;;AAEA;;AACA;;;;;;;;;IAIqBA,Y;;;;;;;;;;;;;;;6FACU,C;8FACC,C;;;;;;WAC9B,wBAAsB;AACpB,iBAoBI,KAAKC,KAAL,CAAWC,cAAX,EApBJ;AAAA,oCACEC,aADF;AAAA,UACEA,aADF,mCACkB;AACdC,QAAAA,MAAM,EAAE,KADM;AAEdC,QAAAA,KAAK,EAAE,IAFO;AAGdC,QAAAA,MAAM,EAAE;AAHM,OADlB;AAAA,8BAMEC,OANF;AAAA,UAMEA,OANF,6BAMY,CANZ;AAAA,UAQEC,WARF,QAQEA,WARF;AAAA,UASEC,WATF,QASEA,WATF;AAAA,gCAWEC,SAXF;AAAA,UAWEA,SAXF,+BAWc,KAXd;AAAA,kCAYEC,WAZF;AAAA,UAYEA,WAZF,iCAYgB,KAZhB;AAAA,oCAcEC,aAdF;AAAA,UAcEA,aAdF,mCAckB;AACdR,QAAAA,MAAM,EAAE,KADM;AAEdS,QAAAA,GAAG,EAAE;AAFS,OAdlB;AAAA,kCAmBEC,WAnBF;AAAA,UAmBEA,WAnB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AHA;AAINW,YAAAA,IAAI,EAAEF,WAAGG;AAJH,WAFE;AAQV8C,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKNK,MALM,EAMH;AACH,mBAAOA,MAAP;AACD;AAjBS;AAHoC,OAAlD;AAuBA,WAAKnB,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,KAD0C;AAEhDxC,QAAAA,IAAI,EAAEyC,sBAAcC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,OADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAE/C,WAAGgD,YAFJ;AAGNzD,YAAAA,IAAI,EAAE,EAHA;AAINW,YAAAA,IAAI,EAAEF,WAAGG;AAJH,WAFE;AAQV8C,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBAACC,OAAD,EAA0BC,UAA1B,EAAiD;AACvD,gBAAMQ,WAAW,GAAG,4BAAkBT,OAAO,CAACS,WAA1B,CAApB;AACA,mBAAO,CAACA,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,EAAiC,CAAjC,CAAP;AACD;AAZS;AAHoC,OAAlD;AAkBD;;;EAjOuCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n} from '@antv/l7-core';\nimport { getCullFace, rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport { PointExtrudeTriangulation } from '../../core/triangulation';\nimport { calculateCentroid } from '../../utils/geo';\nimport pointExtrudeFrag from '../shaders/extrude/extrude_frag.glsl';\nimport pointExtrudeVert from '../shaders/extrude/extrude_vert.glsl';\n\nexport default class ExtrudeModel extends BaseModel {\n private raiseCount: number = 0;\n private raiserepeat: number = 0;\n public getUninforms() {\n const {\n animateOption = {\n enable: false,\n speed: 0.01,\n repeat: false,\n },\n opacity = 1,\n\n sourceColor,\n targetColor,\n\n pickLight = false,\n heightfixed = false,\n\n opacityLinear = {\n enable: false,\n dir: 'up',\n },\n\n lightEnable = true,\n } = this.layer.getLayerConfig() as Partial<\n ILayerConfig & IPointLayerStyleOptions\n >;\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n })\n ) {\n this.judgeStyleAttributes({\n opacity,\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\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n if (this.raiseCount < 1 && this.raiserepeat > 0) {\n if (animateOption.enable) {\n const { speed = 0.01, repeat = false } = animateOption;\n this.raiseCount += speed;\n if (this.raiseCount >= 1) {\n if (this.raiserepeat > 1) {\n this.raiseCount = 0;\n this.raiserepeat--;\n } else {\n this.raiseCount = 1;\n }\n }\n }\n }\n return {\n // 圆柱体的拾取高亮是否要计算光照\n u_pickLight: Number(pickLight),\n // 圆柱体是否固定高度\n u_heightfixed: Number(heightfixed),\n\n u_r: animateOption.enable && this.raiserepeat > 0 ? this.raiseCount : 1.0,\n\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n\n // 透明度渐变\n u_opacitylinear: Number(opacityLinear.enable),\n u_opacitylinear_dir: opacityLinear.dir === 'up' ? 1.0 : 0.0,\n\n // 光照计算开关\n u_lightEnable: Number(lightEnable),\n };\n }\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n // GAODE1.x GAODE2.x MAPBOX\n const {\n depth = true,\n animateOption: { repeat = 1 },\n } = this.layer.getLayerConfig() as ILayerConfig;\n this.raiserepeat = repeat;\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointExtrude2',\n vertexShader: pointExtrudeVert,\n fragmentShader: pointExtrudeFrag,\n triangulation: PointExtrudeTriangulation,\n blend: this.getBlend(),\n cull: {\n enable: true,\n face: getCullFace(this.mapService.version),\n },\n depth: {\n enable: depth,\n },\n }),\n ];\n }\n public clearModels() {\n this.dataTexture?.destroy();\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: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size } = feature;\n if (size) {\n let buffersize: number[] = [];\n if (Array.isArray(size)) {\n buffersize =\n size.length === 2 ? [size[0], size[0], size[1]] : size;\n }\n if (!Array.isArray(size)) {\n buffersize = [size, size, size];\n }\n return buffersize;\n } else {\n return [2, 2, 2];\n }\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 update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'pos',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Pos',\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: 3,\n update: (feature: IEncodeFeature, featureIdx: number) => {\n const coordinates = calculateCentroid(feature.coordinates);\n return [coordinates[0], coordinates[1], 0];\n },\n },\n });\n }\n}\n"],"file":"extrude.js"}
|
package/lib/point/models/fill.js
CHANGED
|
@@ -7,8 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
|
|
10
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
11
|
|
|
14
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
@@ -37,15 +35,13 @@ var _triangulation = require("../../core/triangulation");
|
|
|
37
35
|
|
|
38
36
|
var _l7Maps = require("@antv/l7-maps");
|
|
39
37
|
|
|
40
|
-
var _glMatrix = require("gl-matrix");
|
|
41
|
-
|
|
42
38
|
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); }; }
|
|
43
39
|
|
|
44
40
|
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; } }
|
|
45
41
|
|
|
46
42
|
var waveFillFrag = "\nuniform float u_additive;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nvoid main() {\n\n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n float opacity = styleMappingMat[0][0];\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n \n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n\n\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n float color_t = smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n float PI = 3.14159;\n float N_RINGS = 3.0;\n float FREQ = 1.0;\n\n gl_FragColor = vec4(v_color.rgb, v_color.a * opacity);\n\n float d = length(v_data.xy);\n if(d > 0.5) {\n discard;\n }\n float intensity = clamp(cos(d * PI), 0.0, 1.0) * clamp(cos(2.0 * PI * (d * 2.0 * u_aimate.z - u_aimate.y * u_time)), 0.0, 1.0);\n \n // TODO: \u6839\u636E\u53E0\u52A0\u6A21\u5F0F\u9009\u62E9\u6548\u679C\n if(u_additive > 0.0) {\n gl_FragColor *= intensity;\n // TODO: \u4F18\u5316\u6C34\u6CE2\u70B9 blend additive \u6A21\u5F0F\u4E0B\u6709\u7684\u62FE\u53D6\u6548\u679C \n gl_FragColor = filterColorAlpha(gl_FragColor, gl_FragColor.a);\n } else {\n gl_FragColor = vec4(gl_FragColor.xyz, gl_FragColor.a * intensity);\n gl_FragColor = filterColor(gl_FragColor);\n }\n}\n";
|
|
47
|
-
var pointFillFrag = "
|
|
48
|
-
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute float a_Shape;\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\nuniform
|
|
43
|
+
var pointFillFrag = "uniform float u_additive;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\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 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n float opacity = styleMappingMat[0][0];\n float stroke_opacity = styleMappingMat[0][1];\n float strokeWidth = styleMappingMat[0][2];\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 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 * opacity);\n } else {\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), strokeColor * 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";
|
|
44
|
+
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute float a_Shape;\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\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_meter2coord;\nuniform float u_meteryScale;\nuniform float u_isMeter;\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;\nuniform float u_raisingHeight: 0.0;\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\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 * u_meter2coord \u5728\u7B49\u9762\u79EF\u5927\u5C0F\u7684\u65F6\u5019\u8BBE\u7F6E\u5355\u4F4D\n */\n float newSize = setPickingSize(a_Size) * u_meter2coord;\n // float newSize = setPickingSize(a_Size) * 0.00001038445708445579;\n\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\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\n vec2 strokeOpacityAndOffset = calStrokeOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][1] = strokeOpacityAndOffset.r;\n textureOffset = strokeOpacityAndOffset.g;\n\n vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][2] = strokeWidthAndOffset.r;\n textureOffset = strokeWidthAndOffset.g;\n\n vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);\n if(hasStroke()) {\n vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R\n textureOffset += 1.0;\n\n vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G\n textureOffset += 1.0;\n\n vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B\n textureOffset += 1.0;\n\n vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A\n textureOffset += 1.0;\n } else {\n if(u_stroke_color == vec4(0.0)) {\n styleMappingMat[1][0] = v_color.r;\n styleMappingMat[1][1] = v_color.g;\n styleMappingMat[1][2] = v_color.b;\n styleMappingMat[1][3] = v_color.a;\n } else {\n styleMappingMat[1][0] = u_stroke_color.r;\n styleMappingMat[1][1] = u_stroke_color.g;\n styleMappingMat[1][2] = u_stroke_color.b;\n styleMappingMat[1][3] = u_stroke_color.a;\n }\n }\n\n vec2 textrueOffsets = vec2(0.0, 0.0);\n if(hasOffsets()) {\n vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n\n vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n } else {\n textrueOffsets = u_offsets;\n }\n\n // cal style mapping\n\n // unpack color(vec2)\n v_color = a_Color;\n\n // radius(16-bit)\n v_radius = newSize;\n\n // TODO: billboard\n // anti-alias\n // float antialiased_blur = -max(u_blur, antialiasblur);\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, u_blur);\n\n vec2 offset = (extrude.xy * (newSize + u_stroke_width) + textrueOffsets);\n vec3 aPosition = a_Position;\n if(u_isMeter < 1.0) {\n // \u4E0D\u4EE5\u7C73\u4E3A\u5B9E\u9645\u5355\u4F4D\n offset = project_pixel(offset);\n } else {\n // \u4EE5\u7C73\u4E3A\u5B9E\u9645\u5355\u4F4D\n if(newSize * pow(2.0, u_Zoom) < 48.0) {\n antialiasblur = max(antialiasblur, -0.05);\n } else if(newSize * pow(2.0, u_Zoom) < 128.0) {\n antialiasblur = max(antialiasblur, -0.6/pow(u_Zoom, 2.0));\n } else {\n antialiasblur = max(antialiasblur, -0.8/pow(u_Zoom, 2.0));\n }\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n aPosition.x += offset.x / u_meteryScale;\n aPosition.y += offset.y;\n offset = vec2(0.0);\n }\n }\n\n // TODP: /abs(extrude.x) \u662F\u4E3A\u4E86\u517C\u5BB9\u5730\u7403\u6A21\u5F0F\n v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);\n\n\n // vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n float raiseHeight = u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, raiseHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, u_raisingHeight, 1.0));\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
49
45
|
|
|
50
46
|
var FillModel = function (_BaseModel) {
|
|
51
47
|
(0, _inherits2.default)(FillModel, _BaseModel);
|
|
@@ -139,7 +135,6 @@ var FillModel = function (_BaseModel) {
|
|
|
139
135
|
u_isMeter: Number(this.isMeter),
|
|
140
136
|
u_blur: blur,
|
|
141
137
|
u_additive: blend === 'additive' ? 1.0 : 0.0,
|
|
142
|
-
u_globel: this.mapService.version === _l7Maps.Version.GLOBEL ? 1 : 0,
|
|
143
138
|
u_dataTexture: this.dataTexture,
|
|
144
139
|
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
145
140
|
u_opacity: (0, _isNumber2.default)(opacity) ? opacity : 1.0,
|
|
@@ -228,15 +223,14 @@ var FillModel = function (_BaseModel) {
|
|
|
228
223
|
vert = _this$getShaders.vert,
|
|
229
224
|
type = _this$getShaders.type;
|
|
230
225
|
|
|
231
|
-
|
|
232
|
-
this.layer.triangulation = isGlobel ? _triangulation.GlobelPointFillTriangulation : _triangulation.PointFillTriangulation;
|
|
226
|
+
this.layer.triangulation = _triangulation.PointFillTriangulation;
|
|
233
227
|
return [this.layer.buildLayerModel({
|
|
234
228
|
moduleName: 'pointfill_' + type,
|
|
235
229
|
vertexShader: vert,
|
|
236
230
|
fragmentShader: frag,
|
|
237
|
-
triangulation:
|
|
231
|
+
triangulation: _triangulation.PointFillTriangulation,
|
|
238
232
|
depth: {
|
|
239
|
-
enable:
|
|
233
|
+
enable: false
|
|
240
234
|
},
|
|
241
235
|
blend: this.getBlend(),
|
|
242
236
|
stencil: (0, _l7Utils.getMask)(mask, maskInside)
|
|
@@ -286,7 +280,6 @@ var FillModel = function (_BaseModel) {
|
|
|
286
280
|
value: function registerBuiltinAttributes() {
|
|
287
281
|
var _this2 = this;
|
|
288
282
|
|
|
289
|
-
var isGlobel = this.mapService.version === 'GLOBEL';
|
|
290
283
|
this.styleAttributeService.registerStyleAttribute({
|
|
291
284
|
name: 'extrude',
|
|
292
285
|
type: _l7Core.AttributeType.Attribute,
|
|
@@ -299,56 +292,7 @@ var FillModel = function (_BaseModel) {
|
|
|
299
292
|
},
|
|
300
293
|
size: 3,
|
|
301
294
|
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
302
|
-
var extrude;
|
|
303
|
-
|
|
304
|
-
if (isGlobel) {
|
|
305
|
-
var _vertex = (0, _slicedToArray2.default)(vertex, 3),
|
|
306
|
-
x = _vertex[0],
|
|
307
|
-
y = _vertex[1],
|
|
308
|
-
z = _vertex[2];
|
|
309
|
-
|
|
310
|
-
var n1 = _glMatrix.vec3.fromValues(0, 0, 1);
|
|
311
|
-
|
|
312
|
-
var n2 = _glMatrix.vec3.fromValues(x, 0, z);
|
|
313
|
-
|
|
314
|
-
var xzReg = x >= 0 ? _glMatrix.vec3.angle(n1, n2) : Math.PI * 2 - _glMatrix.vec3.angle(n1, n2);
|
|
315
|
-
var yReg = Math.PI * 2 - Math.asin(y / 100);
|
|
316
|
-
|
|
317
|
-
var m = _glMatrix.mat4.create();
|
|
318
|
-
|
|
319
|
-
_glMatrix.mat4.rotateY(m, m, xzReg);
|
|
320
|
-
|
|
321
|
-
_glMatrix.mat4.rotateX(m, m, yReg);
|
|
322
|
-
|
|
323
|
-
var v1 = _glMatrix.vec3.fromValues(1, 1, 0);
|
|
324
|
-
|
|
325
|
-
_glMatrix.vec3.transformMat4(v1, v1, m);
|
|
326
|
-
|
|
327
|
-
_glMatrix.vec3.normalize(v1, v1);
|
|
328
|
-
|
|
329
|
-
var v2 = _glMatrix.vec3.fromValues(-1, 1, 0);
|
|
330
|
-
|
|
331
|
-
_glMatrix.vec3.transformMat4(v2, v2, m);
|
|
332
|
-
|
|
333
|
-
_glMatrix.vec3.normalize(v2, v2);
|
|
334
|
-
|
|
335
|
-
var v3 = _glMatrix.vec3.fromValues(-1, -1, 0);
|
|
336
|
-
|
|
337
|
-
_glMatrix.vec3.transformMat4(v3, v3, m);
|
|
338
|
-
|
|
339
|
-
_glMatrix.vec3.normalize(v3, v3);
|
|
340
|
-
|
|
341
|
-
var v4 = _glMatrix.vec3.fromValues(1, -1, 0);
|
|
342
|
-
|
|
343
|
-
_glMatrix.vec3.transformMat4(v4, v4, m);
|
|
344
|
-
|
|
345
|
-
_glMatrix.vec3.normalize(v4, v4);
|
|
346
|
-
|
|
347
|
-
extrude = [].concat((0, _toConsumableArray2.default)(v1), (0, _toConsumableArray2.default)(v2), (0, _toConsumableArray2.default)(v3), (0, _toConsumableArray2.default)(v4));
|
|
348
|
-
} else {
|
|
349
|
-
extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];
|
|
350
|
-
}
|
|
351
|
-
|
|
295
|
+
var extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];
|
|
352
296
|
var extrudeIndex = attributeIdx % 4 * 3;
|
|
353
297
|
return [extrude[extrudeIndex], extrude[extrudeIndex + 1], extrude[extrudeIndex + 2]];
|
|
354
298
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/point/models/fill.ts"],"names":["FillModel","layer","getLayerConfig","opacity","strokeOpacity","strokeWidth","stroke","offsets","blend","blur","raisingHeight","unit","updateUnit","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_raisingHeight","Number","u_meter2coord","meter2coord","u_meteryScale","meteryScale","u_isMeter","isMeter","u_blur","u_additive","u_globel","mapService","version","Version","GLOBEL","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_stroke_opacity","u_stroke_width","u_stroke_color","getStrokeColor","u_offsets","isOffsetStatic","animateOption","enable","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","styleAttributeService","createAttributesAndIndices","PointFillTriangulation","buildModels","getSource","extent","minLng","minLat","maxLng","maxLat","center","mapboxContext","$window","mapboxgl","MAPBOX","MercatorCoordinate","coord","fromLngLat","lng","lat","offsetInMercatorCoordinateUnits","meterInMercatorCoordinateUnits","westCoord","x","y","z","westLnglat","toLngLat","southCoord","southLnglat","m1","meterToCoord","m2","Boolean","mask","maskInside","getShaders","frag","vert","isGlobel","triangulation","GlobelPointFillTriangulation","buildLayerModel","moduleName","vertexShader","fragmentShader","depth","getBlend","stencil","waveFillFrag","pointFillVert","pointFillFrag","destroy","option","speed","rings","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","extrude","n1","vec3","fromValues","n2","xzReg","angle","Math","PI","yReg","asin","m","mat4","create","rotateY","rotateX","v1","transformMat4","normalize","v2","v3","v4","extrudeIndex","Array","isArray","shape","shape2d","shapeIndex","indexOf","L7MAP","calMeter2Coord","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAWA;;AAEA;;AAEA;;AAUA;;AACA;;;;;;;;;;IACqBA,S;;;;;;;;;;;;;;;8FACW,C;8FACA,C;0FACH,K;uFAEJ,Q;;;;;;WACvB,wBAAqC;AACnC,iBAUI,KAAKC,KAAL,CAAWC,cAAX,EAVJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,oCAEEC,aAFF;AAAA,UAEEA,aAFF,mCAEkB,CAFlB;AAAA,kCAGEC,WAHF;AAAA,UAGEA,WAHF,iCAGgB,CAHhB;AAAA,6BAIEC,MAJF;AAAA,UAIEA,MAJF,4BAIW,eAJX;AAAA,8BAKEC,OALF;AAAA,UAKEA,OALF,6BAKY,CAAC,CAAD,EAAI,CAAJ,CALZ;AAAA,UAMEC,KANF,QAMEA,KANF;AAAA,2BAOEC,IAPF;AAAA,UAOEA,IAPF,0BAOS,CAPT;AAAA,oCAQEC,aARF;AAAA,UAQEA,aARF,mCAQkB,CARlB;AAAA,2BASEC,IATF;AAAA,UASEA,IATF,0BASS,QATT;;AAWA,WAAKC,UAAL,CAAgBD,IAAhB;;AAEA,UACE,KAAKE,eAAL,IAC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AACA,eAAKJ,WAAL,GAAmB,CAAnB;AACD;;AACD,aAAK1B,IAAL,GAAYA,IAAZ;AACD;AACF;;;EA7XoC2J,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IAttribute,\n IElements,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport { $window, getCullFace, getMask } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport {\n GlobelPointFillTriangulation,\n PointFillTriangulation,\n} from '../../core/triangulation';\n// animate pointLayer shader - support animate\nimport waveFillFrag from '../shaders/animate/wave_frag.glsl';\n// static pointLayer shader - not support animate\nimport pointFillFrag from '../shaders/fill_frag.glsl';\nimport pointFillVert from '../shaders/fill_vert.glsl';\n\nimport { Version } from '@antv/l7-maps';\nimport { mat4, vec3 } from 'gl-matrix';\nexport default class FillModel extends BaseModel {\n private meter2coord: number = 1;\n private meteryScale: number = 1; // 兼容 mapbox\n private isMeter: boolean = false;\n\n private unit: string = 'l7size';\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = 'rgba(0,0,0,0)',\n offsets = [0, 0],\n blend,\n blur = 0,\n raisingHeight = 0,\n unit = 'l7size',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n this.updateUnit(unit);\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n });\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_raisingHeight: Number(raisingHeight),\n\n u_meter2coord: this.meter2coord,\n u_meteryScale: this.meteryScale,\n u_isMeter: Number(this.isMeter),\n u_blur: blur,\n\n u_additive: blend === 'additive' ? 1.0 : 0.0,\n u_globel: this.mapService.version === Version.GLOBEL ? 1 : 0,\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_stroke_opacity: isNumber(strokeOpacity) ? strokeOpacity : 1.0,\n u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 1.0,\n u_stroke_color: this.getStrokeColor(stroke),\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const {\n animateOption = { enable: false },\n } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n return this.styleAttributeService.createAttributesAndIndices(\n this.layer.getEncodedData(),\n PointFillTriangulation,\n );\n }\n\n public initModels(): IModel[] {\n this.updateUnit('l7size');\n\n return this.buildModels();\n }\n\n /**\n * 计算等面积点图层(unit meter)笛卡尔坐标标度与世界坐标标度的比例\n * @returns\n */\n public calMeter2Coord() {\n const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;\n const center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];\n\n const { version } = this.mapService;\n const mapboxContext = $window?.mapboxgl;\n if (version === Version.MAPBOX && mapboxContext?.MercatorCoordinate) {\n // 参考:\n // https://docs.mapbox.com/mapbox-gl-js/api/geography/#mercatorcoordinate#meterinmercatorcoordinateunits\n const coord = mapboxContext.MercatorCoordinate.fromLngLat(\n { lng: center[0], lat: center[1] },\n 0,\n );\n const offsetInMercatorCoordinateUnits = coord.meterInMercatorCoordinateUnits();\n const westCoord = new mapboxContext.MercatorCoordinate(\n coord.x - offsetInMercatorCoordinateUnits,\n coord.y,\n coord.z,\n );\n const westLnglat = westCoord.toLngLat();\n\n const southCoord = new mapboxContext.MercatorCoordinate(\n coord.x,\n coord.y - offsetInMercatorCoordinateUnits,\n coord.z,\n );\n const southLnglat = southCoord.toLngLat();\n\n this.meter2coord = center[0] - westLnglat.lng;\n\n this.meteryScale = (southLnglat.lat - center[1]) / this.meter2coord;\n return;\n }\n\n const m1 = this.mapService.meterToCoord(center, [minLng, minLat]);\n const m2 = this.mapService.meterToCoord(center, [\n maxLng === minLng ? maxLng + 0.1 : maxLng,\n maxLat === minLat ? minLat + 0.1 : maxLat,\n ]);\n this.meter2coord = (m1 + m2) / 2;\n if (!Boolean(this.meter2coord)) {\n // Tip: 兼容单个数据导致的 m1、m2 为 NaN\n this.meter2coord = 7.70681090738883;\n }\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n animateOption = { enable: false },\n } = this.layer.getLayerConfig() as Partial<\n ILayerConfig & IPointLayerStyleOptions\n >;\n const { frag, vert, type } = this.getShaders(animateOption);\n\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n this.layer.triangulation = isGlobel\n ? GlobelPointFillTriangulation\n : PointFillTriangulation;\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointfill_' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: isGlobel\n ? GlobelPointFillTriangulation\n : PointFillTriangulation,\n depth: { enable: isGlobel },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n /**\n * 根据 animateOption 的值返回对应的 shader 代码\n * @returns\n */\n public getShaders(\n animateOption: Partial<IAnimateOption>,\n ): { frag: string; vert: string; type: string } {\n if (animateOption.enable) {\n switch (animateOption.type) {\n case 'wave':\n return {\n frag: waveFillFrag,\n vert: pointFillVert,\n type: 'wave',\n };\n default:\n return {\n frag: waveFillFrag,\n vert: pointFillVert,\n type: 'wave',\n };\n }\n } else {\n return {\n frag: pointFillFrag,\n vert: pointFillVert,\n type: 'normal',\n };\n }\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n // overwrite baseModel func\n protected animateOption2Array(option: Partial<IAnimateOption>): number[] {\n return [option.enable ? 0 : 1.0, option.speed || 1, option.rings || 3, 0];\n }\n protected registerBuiltinAttributes() {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'extrude',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Extrude',\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: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n let extrude;\n // 地球模式\n if (isGlobel) {\n const [x, y, z] = vertex;\n const n1 = vec3.fromValues(0, 0, 1);\n const n2 = vec3.fromValues(x, 0, z);\n\n const xzReg =\n x >= 0 ? vec3.angle(n1, n2) : Math.PI * 2 - vec3.angle(n1, n2);\n\n const yReg = Math.PI * 2 - Math.asin(y / 100);\n\n const m = mat4.create();\n mat4.rotateY(m, m, xzReg);\n mat4.rotateX(m, m, yReg);\n\n const v1 = vec3.fromValues(1, 1, 0);\n vec3.transformMat4(v1, v1, m);\n vec3.normalize(v1, v1);\n\n const v2 = vec3.fromValues(-1, 1, 0);\n vec3.transformMat4(v2, v2, m);\n vec3.normalize(v2, v2);\n\n const v3 = vec3.fromValues(-1, -1, 0);\n vec3.transformMat4(v3, v3, m);\n vec3.normalize(v3, v3);\n\n const v4 = vec3.fromValues(1, -1, 0);\n vec3.transformMat4(v4, v4, m);\n vec3.normalize(v4, v4);\n\n extrude = [...v1, ...v2, ...v3, ...v4];\n } else {\n // 平面模式\n extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];\n }\n\n const extrudeIndex = (attributeIdx % 4) * 3;\n return [\n extrude[extrudeIndex],\n extrude[extrudeIndex + 1],\n extrude[extrudeIndex + 2],\n ];\n },\n },\n });\n\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 = 5 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'shape',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Shape',\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 { shape = 2 } = feature;\n const shape2d = this.layer.getLayerConfig().shape2d as string[];\n const shapeIndex = shape2d.indexOf(shape as string);\n return [shapeIndex];\n },\n },\n });\n }\n\n /**\n * 判断是否更新点图层的计量单位\n * @param unit\n */\n private updateUnit(unit: string) {\n const { version } = this.mapService;\n if (this.unit !== unit) {\n // l7size => meter\n if (\n this.unit !== 'meter' &&\n unit === 'meter' &&\n version !== Version.L7MAP &&\n version !== Version.GLOBEL\n ) {\n this.isMeter = true;\n this.calMeter2Coord();\n // meter => l7size\n } else if (this.unit === 'meter' && unit !== 'meter') {\n this.isMeter = false;\n this.meter2coord = 1;\n }\n this.unit = unit;\n }\n }\n}\n"],"file":"fill.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/point/models/fill.ts"],"names":["FillModel","layer","getLayerConfig","opacity","strokeOpacity","strokeWidth","stroke","offsets","blend","blur","raisingHeight","unit","updateUnit","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_raisingHeight","Number","u_meter2coord","meter2coord","u_meteryScale","meteryScale","u_isMeter","isMeter","u_blur","u_additive","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_stroke_opacity","u_stroke_width","u_stroke_color","getStrokeColor","u_offsets","isOffsetStatic","animateOption","enable","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","styleAttributeService","createAttributesAndIndices","PointFillTriangulation","buildModels","getSource","extent","minLng","minLat","maxLng","maxLat","center","version","mapService","mapboxContext","$window","mapboxgl","Version","MAPBOX","MercatorCoordinate","coord","fromLngLat","lng","lat","offsetInMercatorCoordinateUnits","meterInMercatorCoordinateUnits","westCoord","x","y","z","westLnglat","toLngLat","southCoord","southLnglat","m1","meterToCoord","m2","Boolean","mask","maskInside","getShaders","frag","vert","triangulation","buildLayerModel","moduleName","vertexShader","fragmentShader","depth","getBlend","stencil","waveFillFrag","pointFillVert","pointFillFrag","destroy","option","speed","rings","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","extrude","extrudeIndex","Array","isArray","shape","shape2d","shapeIndex","indexOf","L7MAP","GLOBEL","calMeter2Coord","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAWA;;AAEA;;AAE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AACVH,UAAAA,IAAI,EAAE,SADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAE7F,WAAG8F,YAFJ;AAGNvG,YAAAA,IAAI,EAAE,EAHA;AAINW,YAAAA,IAAI,EAAEF,WAAGG;AAJH,WAFE;AAQV4F,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,iCAAsBH,OAAtB,CAAQQ,KAAR;AAAA,gBAAQA,KAAR,+BAAgB,CAAhB;;AACA,gBAAMC,OAAO,GAAG,MAAI,CAACvI,KAAL,CAAWC,cAAX,GAA4BsI,OAA5C;;AACA,gBAAMC,UAAU,GAAGD,OAAO,CAACE,OAAR,CAAgBH,KAAhB,CAAnB;AACA,mBAAO,CAACE,UAAD,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;WAMD,oBAAmB9H,IAAnB,EAAiC;AAC/B,UAAQ4D,OAAR,GAAoB,KAAKC,UAAzB,CAAQD,OAAR;;AACA,UAAI,KAAK5D,IAAL,KAAcA,IAAlB,EAAwB;AAEtB,YACE,KAAKA,IAAL,KAAc,OAAd,IACAA,IAAI,KAAK,OADT,IAEA4D,OAAO,KAAKK,gBAAQ+D,KAFpB,IAGApE,OAAO,KAAKK,gBAAQgE,MAJtB,EAKE;AACA,eAAKnG,OAAL,GAAe,IAAf;AACA,eAAKoG,cAAL;AAED,SATD,MASO,IAAI,KAAKlI,IAAL,KAAc,OAAd,IAAyBA,IAAI,KAAK,OAAtC,EAA+C;AACpD,eAAK8B,OAAL,GAAe,KAAf;AACA,eAAKJ,WAAL,GAAmB,CAAnB;AACD;;AACD,aAAK1B,IAAL,GAAYA,IAAZ;AACD;AACF;;;EA9UoCmI,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IAttribute,\n IElements,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport { $window, getMask } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport { PointFillTriangulation } from '../../core/triangulation';\n// animate pointLayer shader - support animate\nimport waveFillFrag from '../shaders/animate/wave_frag.glsl';\n// static pointLayer shader - not support animate\nimport pointFillFrag from '../shaders/fill_frag.glsl';\nimport pointFillVert from '../shaders/fill_vert.glsl';\n\nimport { Version } from '@antv/l7-maps';\nexport default class FillModel extends BaseModel {\n private meter2coord: number = 1;\n private meteryScale: number = 1; // 兼容 mapbox\n private isMeter: boolean = false;\n\n private unit: string = 'l7size';\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = 'rgba(0,0,0,0)',\n offsets = [0, 0],\n blend,\n blur = 0,\n raisingHeight = 0,\n unit = 'l7size',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n this.updateUnit(unit);\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n });\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_raisingHeight: Number(raisingHeight),\n\n u_meter2coord: this.meter2coord,\n u_meteryScale: this.meteryScale,\n u_isMeter: Number(this.isMeter),\n u_blur: blur,\n\n u_additive: blend === 'additive' ? 1.0 : 0.0,\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_stroke_opacity: isNumber(strokeOpacity) ? strokeOpacity : 1.0,\n u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 1.0,\n u_stroke_color: this.getStrokeColor(stroke),\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const {\n animateOption = { enable: false },\n } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n return this.styleAttributeService.createAttributesAndIndices(\n this.layer.getEncodedData(),\n PointFillTriangulation,\n );\n }\n\n public initModels(): IModel[] {\n this.updateUnit('l7size');\n\n return this.buildModels();\n }\n\n /**\n * 计算等面积点图层(unit meter)笛卡尔坐标标度与世界坐标标度的比例\n * @returns\n */\n public calMeter2Coord() {\n const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;\n const center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];\n\n const { version } = this.mapService;\n const mapboxContext = $window?.mapboxgl;\n if (version === Version.MAPBOX && mapboxContext?.MercatorCoordinate) {\n // 参考:\n // https://docs.mapbox.com/mapbox-gl-js/api/geography/#mercatorcoordinate#meterinmercatorcoordinateunits\n const coord = mapboxContext.MercatorCoordinate.fromLngLat(\n { lng: center[0], lat: center[1] },\n 0,\n );\n const offsetInMercatorCoordinateUnits = coord.meterInMercatorCoordinateUnits();\n const westCoord = new mapboxContext.MercatorCoordinate(\n coord.x - offsetInMercatorCoordinateUnits,\n coord.y,\n coord.z,\n );\n const westLnglat = westCoord.toLngLat();\n\n const southCoord = new mapboxContext.MercatorCoordinate(\n coord.x,\n coord.y - offsetInMercatorCoordinateUnits,\n coord.z,\n );\n const southLnglat = southCoord.toLngLat();\n\n this.meter2coord = center[0] - westLnglat.lng;\n\n this.meteryScale = (southLnglat.lat - center[1]) / this.meter2coord;\n return;\n }\n\n const m1 = this.mapService.meterToCoord(center, [minLng, minLat]);\n const m2 = this.mapService.meterToCoord(center, [\n maxLng === minLng ? maxLng + 0.1 : maxLng,\n maxLat === minLat ? minLat + 0.1 : maxLat,\n ]);\n this.meter2coord = (m1 + m2) / 2;\n if (!Boolean(this.meter2coord)) {\n // Tip: 兼容单个数据导致的 m1、m2 为 NaN\n this.meter2coord = 7.70681090738883;\n }\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n animateOption = { enable: false },\n } = this.layer.getLayerConfig() as Partial<\n ILayerConfig & IPointLayerStyleOptions\n >;\n const { frag, vert, type } = this.getShaders(animateOption);\n\n this.layer.triangulation = PointFillTriangulation;\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointfill_' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: PointFillTriangulation,\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n /**\n * 根据 animateOption 的值返回对应的 shader 代码\n * @returns\n */\n public getShaders(\n animateOption: Partial<IAnimateOption>,\n ): { frag: string; vert: string; type: string } {\n if (animateOption.enable) {\n switch (animateOption.type) {\n case 'wave':\n return {\n frag: waveFillFrag,\n vert: pointFillVert,\n type: 'wave',\n };\n default:\n return {\n frag: waveFillFrag,\n vert: pointFillVert,\n type: 'wave',\n };\n }\n } else {\n return {\n frag: pointFillFrag,\n vert: pointFillVert,\n type: 'normal',\n };\n }\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n // overwrite baseModel func\n protected animateOption2Array(option: Partial<IAnimateOption>): number[] {\n return [option.enable ? 0 : 1.0, option.speed || 1, option.rings || 3, 0];\n }\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'extrude',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Extrude',\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: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];\n const extrudeIndex = (attributeIdx % 4) * 3;\n return [\n extrude[extrudeIndex],\n extrude[extrudeIndex + 1],\n extrude[extrudeIndex + 2],\n ];\n },\n },\n });\n\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 = 5 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'shape',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Shape',\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 { shape = 2 } = feature;\n const shape2d = this.layer.getLayerConfig().shape2d as string[];\n const shapeIndex = shape2d.indexOf(shape as string);\n return [shapeIndex];\n },\n },\n });\n }\n\n /**\n * 判断是否更新点图层的计量单位\n * @param unit\n */\n private updateUnit(unit: string) {\n const { version } = this.mapService;\n if (this.unit !== unit) {\n // l7size => meter\n if (\n this.unit !== 'meter' &&\n unit === 'meter' &&\n version !== Version.L7MAP &&\n version !== Version.GLOBEL\n ) {\n this.isMeter = true;\n this.calMeter2Coord();\n // meter => l7size\n } else if (this.unit === 'meter' && unit !== 'meter') {\n this.isMeter = false;\n this.meter2coord = 1;\n }\n this.unit = unit;\n }\n }\n}\n"],"file":"fill.js"}
|
|
@@ -9,6 +9,10 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _tileModel = _interopRequireDefault(require("../../tile/models/tileModel"));
|
|
11
11
|
|
|
12
|
+
var _earthExtrude = _interopRequireDefault(require("./earthExtrude"));
|
|
13
|
+
|
|
14
|
+
var _earthFill = _interopRequireDefault(require("./earthFill"));
|
|
15
|
+
|
|
12
16
|
var _extrude = _interopRequireDefault(require("./extrude"));
|
|
13
17
|
|
|
14
18
|
var _fill = _interopRequireDefault(require("./fill"));
|
|
@@ -40,7 +44,9 @@ var PointModels = {
|
|
|
40
44
|
text: _text.default,
|
|
41
45
|
icon: _iconFont.default,
|
|
42
46
|
vectorpoint: _tileModel.default,
|
|
43
|
-
tile: _tile.default
|
|
47
|
+
tile: _tile.default,
|
|
48
|
+
earthFill: _earthFill.default,
|
|
49
|
+
earthExtrude: _earthExtrude.default
|
|
44
50
|
};
|
|
45
51
|
var _default = PointModels;
|
|
46
52
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/point/models/index.ts"],"names":["PointModels","fillImage","FillImageModel","fill","FillModel","radar","Radar","image","IMageModel","normal","NormalModel","simplePoint","SimplePopint","extrude","ExtrudeModel","text","TextModel","icon","IconModel","vectorpoint","PointTileModel","tile","TileFillModel"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["../../../src/point/models/index.ts"],"names":["PointModels","fillImage","FillImageModel","fill","FillModel","radar","Radar","image","IMageModel","normal","NormalModel","simplePoint","SimplePopint","extrude","ExtrudeModel","text","TextModel","icon","IconModel","vectorpoint","PointTileModel","tile","TileFillModel","earthFill","EarthFillModel","earthExtrude","EarthExtrudeModel"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAiBA,IAAMA,WAAwC,GAAG;AAC/CC,EAAAA,SAAS,EAAEC,iBADoC;AAE/CC,EAAAA,IAAI,EAAEC,aAFyC;AAG/CC,EAAAA,KAAK,EAAEC,cAHwC;AAI/CC,EAAAA,KAAK,EAAEC,cAJwC;AAK/CC,EAAAA,MAAM,EAAEC,eALuC;AAM/CC,EAAAA,WAAW,EAAEC,oBANkC;AAO/CC,EAAAA,OAAO,EAAEC,gBAPsC;AAQ/CC,EAAAA,IAAI,EAAEC,aARyC;AAS/CC,EAAAA,IAAI,EAAEC,iBATyC;AAU/CC,EAAAA,WAAW,EAAEC,kBAVkC;AAW/CC,EAAAA,IAAI,EAAEC,aAXyC;AAY/CC,EAAAA,SAAS,EAAEC,kBAZoC;AAa/CC,EAAAA,YAAY,EAAEC;AAbiC,CAAjD;eAgBe1B,W","sourcesContent":["import PointTileModel from '../../tile/models/tileModel';\nimport EarthExtrudeModel from './earthExtrude';\n// earth\nimport EarthFillModel from './earthFill';\nimport ExtrudeModel from './extrude';\nimport FillModel from './fill';\nimport FillImageModel from './fillmage';\nimport IconModel from './icon-font';\nimport IMageModel from './image';\nimport NormalModel from './normal';\nimport Radar from './radar';\nimport SimplePopint from './simplePoint';\nimport TextModel from './text';\nimport TileFillModel from './tile';\n\nexport type PointType =\n | 'fillImage'\n | 'fill'\n | 'radar'\n | 'image'\n | 'normal'\n | 'simplePoint'\n | 'extrude'\n | 'text'\n | 'icon'\n | 'vectorpoint'\n | 'tile'\n | 'earthFill'\n | 'earthExtrude';\n\nconst PointModels: { [key in PointType]: any } = {\n fillImage: FillImageModel,\n fill: FillModel,\n radar: Radar,\n image: IMageModel,\n normal: NormalModel,\n simplePoint: SimplePopint,\n extrude: ExtrudeModel,\n text: TextModel,\n icon: IconModel,\n vectorpoint: PointTileModel,\n tile: TileFillModel,\n earthFill: EarthFillModel,\n earthExtrude: EarthExtrudeModel,\n};\n\nexport default PointModels;\n"],"file":"index.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-layers",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.14",
|
|
4
4
|
"description": "L7's collection of built-in layers",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"author": "xiaoiver",
|
|
26
26
|
"license": "ISC",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@antv/l7-core": "2.9.
|
|
29
|
-
"@antv/l7-source": "2.9.
|
|
30
|
-
"@antv/l7-utils": "2.9.
|
|
28
|
+
"@antv/l7-core": "2.9.14",
|
|
29
|
+
"@antv/l7-source": "2.9.14",
|
|
30
|
+
"@antv/l7-utils": "2.9.14",
|
|
31
31
|
"@babel/runtime": "^7.7.7",
|
|
32
32
|
"@mapbox/martini": "^0.2.0",
|
|
33
33
|
"@turf/helpers": "^6.1.4",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@types/gl-matrix": "^2.4.5",
|
|
58
58
|
"@types/lodash": "^4.14.138"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "8a3f9f5f4eeb19e3a260fccb239ce743a40f4f41",
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"access": "public"
|
|
63
63
|
}
|