@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.
- package/es/core/BaseLayer.js.map +1 -1
- package/es/core/interface.d.ts +1 -0
- package/es/core/interface.js.map +1 -1
- package/es/heatmap/index.d.ts +2 -0
- package/es/heatmap/index.js +9 -0
- package/es/heatmap/index.js.map +1 -1
- package/es/heatmap/models/heatmap.js +1 -0
- package/es/heatmap/models/heatmap.js.map +1 -1
- package/es/line/index.d.ts +1 -1
- package/es/line/index.js +1 -0
- package/es/line/index.js.map +1 -1
- 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/line/models/linearline.d.ts +20 -0
- package/es/line/models/linearline.js +267 -0
- package/es/line/models/linearline.js.map +1 -0
- package/es/point/models/normal.js +1 -0
- package/es/point/models/normal.js.map +1 -1
- package/lib/core/BaseLayer.js.map +1 -1
- package/lib/core/interface.js.map +1 -1
- package/lib/heatmap/index.js +9 -0
- package/lib/heatmap/index.js.map +1 -1
- package/lib/heatmap/models/heatmap.js +1 -0
- package/lib/heatmap/models/heatmap.js.map +1 -1
- package/lib/line/index.js +1 -0
- package/lib/line/index.js.map +1 -1
- package/lib/line/models/index.js +4 -1
- package/lib/line/models/index.js.map +1 -1
- package/lib/line/models/linearline.js +283 -0
- package/lib/line/models/linearline.js.map +1 -0
- package/lib/point/models/normal.js +1 -0
- package/lib/point/models/normal.js.map +1 -1
- package/package.json +5 -5
package/es/line/models/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import Arc3DModel from './arc_3d';
|
|
|
3
3
|
import ArcMiniModel from './arcmini';
|
|
4
4
|
import GreatCircleModel from './great_circle';
|
|
5
5
|
import LineModel from './line';
|
|
6
|
+
import LinearLine from './linearline';
|
|
6
7
|
import SimpleLineModel from './simpleLine';
|
|
7
8
|
import LineWallModel from './wall';
|
|
8
9
|
var LineModels = {
|
|
@@ -12,7 +13,8 @@ var LineModels = {
|
|
|
12
13
|
greatcircle: GreatCircleModel,
|
|
13
14
|
wall: LineWallModel,
|
|
14
15
|
line: LineModel,
|
|
15
|
-
simple: SimpleLineModel
|
|
16
|
+
simple: SimpleLineModel,
|
|
17
|
+
linearline: LinearLine
|
|
16
18
|
};
|
|
17
19
|
export default LineModels;
|
|
18
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/line/models/index.ts"],"names":["ArcModel","Arc3DModel","ArcMiniModel","GreatCircleModel","LineModel","SimpleLineModel","LineWallModel","LineModels","arc","arcmini","arc3d","greatcircle","wall","line","simple"],"mappings":"AAAA,OAAOA,QAAP,MAAqB,OAArB;AACA,OAAOC,UAAP,MAAuB,UAAvB;AACA,OAAOC,YAAP,MAAyB,WAAzB;AACA,OAAOC,gBAAP,MAA6B,gBAA7B;AACA,OAAOC,SAAP,MAAsB,QAAtB;AACA,OAAOC,eAAP,MAA4B,cAA5B;AACA,OAAOC,aAAP,MAA0B,QAA1B;
|
|
1
|
+
{"version":3,"sources":["../../../src/line/models/index.ts"],"names":["ArcModel","Arc3DModel","ArcMiniModel","GreatCircleModel","LineModel","LinearLine","SimpleLineModel","LineWallModel","LineModels","arc","arcmini","arc3d","greatcircle","wall","line","simple","linearline"],"mappings":"AAAA,OAAOA,QAAP,MAAqB,OAArB;AACA,OAAOC,UAAP,MAAuB,UAAvB;AACA,OAAOC,YAAP,MAAyB,WAAzB;AACA,OAAOC,gBAAP,MAA6B,gBAA7B;AACA,OAAOC,SAAP,MAAsB,QAAtB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,eAAP,MAA4B,cAA5B;AACA,OAAOC,aAAP,MAA0B,QAA1B;AAYA,IAAMC,UAA2C,GAAG;AAClDC,EAAAA,GAAG,EAAET,QAD6C;AAElDU,EAAAA,OAAO,EAAER,YAFyC;AAGlDS,EAAAA,KAAK,EAAEV,UAH2C;AAIlDW,EAAAA,WAAW,EAAET,gBAJqC;AAKlDU,EAAAA,IAAI,EAAEN,aAL4C;AAMlDO,EAAAA,IAAI,EAAEV,SAN4C;AAOlDW,EAAAA,MAAM,EAAET,eAP0C;AAQlDU,EAAAA,UAAU,EAAEX;AARsC,CAApD;AAWA,eAAeG,UAAf","sourcesContent":["import ArcModel from './arc';\nimport Arc3DModel from './arc_3d';\nimport ArcMiniModel from './arcmini';\nimport GreatCircleModel from './great_circle';\nimport LineModel from './line';\nimport LinearLine from './linearline';\nimport SimpleLineModel from './simpleLine';\nimport LineWallModel from './wall';\n\nexport type LineModelType =\n | 'arc'\n | 'arcmini'\n | 'arc3d'\n | 'greatcircle'\n | 'wall'\n | 'simple'\n | 'line'\n | 'linearline';\n\nconst LineModels: { [key in LineModelType]: any } = {\n arc: ArcModel,\n arcmini: ArcMiniModel,\n arc3d: Arc3DModel,\n greatcircle: GreatCircleModel,\n wall: LineWallModel,\n line: LineModel,\n simple: SimpleLineModel,\n linearline: LinearLine,\n};\n\nexport default LineModels;\n"],"file":"index.js"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { IModel, IModelUniform, ITexture2D } from '@antv/l7-core';
|
|
2
|
+
import BaseModel from '../../core/BaseModel';
|
|
3
|
+
export default class LinearLineModel extends BaseModel {
|
|
4
|
+
protected colorTexture: ITexture2D;
|
|
5
|
+
getUninforms(): IModelUniform;
|
|
6
|
+
initModels(): IModel[];
|
|
7
|
+
clearModels(): void;
|
|
8
|
+
buildModels(): IModel[];
|
|
9
|
+
/**
|
|
10
|
+
* 根据参数获取不同的 shader 代码
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
getShaders(): {
|
|
14
|
+
frag: string;
|
|
15
|
+
vert: string;
|
|
16
|
+
type: string;
|
|
17
|
+
};
|
|
18
|
+
protected registerBuiltinAttributes(): void;
|
|
19
|
+
private updateTexture;
|
|
20
|
+
}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
import _isNumber from "lodash/isNumber";
|
|
9
|
+
|
|
10
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
|
+
|
|
12
|
+
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; } }
|
|
13
|
+
|
|
14
|
+
import { AttributeType, gl } from '@antv/l7-core';
|
|
15
|
+
import { generateColorRamp, getMask } from '@antv/l7-utils';
|
|
16
|
+
import BaseModel from '../../core/BaseModel';
|
|
17
|
+
import { LineTriangulation } from '../../core/triangulation';
|
|
18
|
+
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";
|
|
19
|
+
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";
|
|
20
|
+
|
|
21
|
+
var LinearLineModel = function (_BaseModel) {
|
|
22
|
+
_inherits(LinearLineModel, _BaseModel);
|
|
23
|
+
|
|
24
|
+
var _super = _createSuper(LinearLineModel);
|
|
25
|
+
|
|
26
|
+
function LinearLineModel() {
|
|
27
|
+
var _this;
|
|
28
|
+
|
|
29
|
+
_classCallCheck(this, LinearLineModel);
|
|
30
|
+
|
|
31
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
32
|
+
args[_key] = arguments[_key];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
36
|
+
|
|
37
|
+
_defineProperty(_assertThisInitialized(_this), "colorTexture", void 0);
|
|
38
|
+
|
|
39
|
+
_defineProperty(_assertThisInitialized(_this), "updateTexture", function () {
|
|
40
|
+
var createTexture2D = _this.rendererService.createTexture2D;
|
|
41
|
+
|
|
42
|
+
if (_this.colorTexture) {
|
|
43
|
+
_this.colorTexture.destroy();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
var _ref = _this.layer.getLayerConfig(),
|
|
47
|
+
rampColors = _ref.rampColors;
|
|
48
|
+
|
|
49
|
+
var imageData = generateColorRamp(rampColors);
|
|
50
|
+
_this.colorTexture = createTexture2D({
|
|
51
|
+
data: new Uint8Array(imageData.data),
|
|
52
|
+
width: imageData.width,
|
|
53
|
+
height: imageData.height,
|
|
54
|
+
wrapS: gl.CLAMP_TO_EDGE,
|
|
55
|
+
wrapT: gl.CLAMP_TO_EDGE,
|
|
56
|
+
min: gl.NEAREST,
|
|
57
|
+
mag: gl.NEAREST,
|
|
58
|
+
flipY: false
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return _this;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
_createClass(LinearLineModel, [{
|
|
66
|
+
key: "getUninforms",
|
|
67
|
+
value: function getUninforms() {
|
|
68
|
+
var _ref2 = this.layer.getLayerConfig(),
|
|
69
|
+
opacity = _ref2.opacity,
|
|
70
|
+
_ref2$vertexHeightSca = _ref2.vertexHeightScale,
|
|
71
|
+
vertexHeightScale = _ref2$vertexHeightSca === void 0 ? 20.0 : _ref2$vertexHeightSca,
|
|
72
|
+
_ref2$raisingHeight = _ref2.raisingHeight,
|
|
73
|
+
raisingHeight = _ref2$raisingHeight === void 0 ? 0 : _ref2$raisingHeight,
|
|
74
|
+
_ref2$heightfixed = _ref2.heightfixed,
|
|
75
|
+
heightfixed = _ref2$heightfixed === void 0 ? false : _ref2$heightfixed;
|
|
76
|
+
|
|
77
|
+
if (this.rendererService.getDirty()) {
|
|
78
|
+
this.colorTexture.bind();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
82
|
+
opacity: opacity
|
|
83
|
+
})) {
|
|
84
|
+
this.judgeStyleAttributes({
|
|
85
|
+
opacity: opacity
|
|
86
|
+
});
|
|
87
|
+
var encodeData = this.layer.getEncodedData();
|
|
88
|
+
|
|
89
|
+
var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
|
|
90
|
+
data = _this$calDataFrame.data,
|
|
91
|
+
width = _this$calDataFrame.width,
|
|
92
|
+
height = _this$calDataFrame.height;
|
|
93
|
+
|
|
94
|
+
this.rowCount = height;
|
|
95
|
+
this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
|
|
96
|
+
flipY: true,
|
|
97
|
+
data: data,
|
|
98
|
+
format: gl.LUMINANCE,
|
|
99
|
+
type: gl.FLOAT,
|
|
100
|
+
width: width,
|
|
101
|
+
height: height
|
|
102
|
+
}) : this.createTexture2D({
|
|
103
|
+
flipY: true,
|
|
104
|
+
data: [1],
|
|
105
|
+
format: gl.LUMINANCE,
|
|
106
|
+
type: gl.FLOAT,
|
|
107
|
+
width: 1,
|
|
108
|
+
height: 1
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
u_dataTexture: this.dataTexture,
|
|
114
|
+
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
115
|
+
u_opacity: _isNumber(opacity) ? opacity : 1.0,
|
|
116
|
+
u_texture: this.colorTexture,
|
|
117
|
+
u_heightfixed: Number(heightfixed),
|
|
118
|
+
u_vertexScale: vertexHeightScale,
|
|
119
|
+
u_raisingHeight: Number(raisingHeight)
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}, {
|
|
123
|
+
key: "initModels",
|
|
124
|
+
value: function initModels() {
|
|
125
|
+
this.updateTexture();
|
|
126
|
+
return this.buildModels();
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
key: "clearModels",
|
|
130
|
+
value: function clearModels() {
|
|
131
|
+
var _this$colorTexture, _this$dataTexture;
|
|
132
|
+
|
|
133
|
+
(_this$colorTexture = this.colorTexture) === null || _this$colorTexture === void 0 ? void 0 : _this$colorTexture.destroy();
|
|
134
|
+
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
|
|
135
|
+
}
|
|
136
|
+
}, {
|
|
137
|
+
key: "buildModels",
|
|
138
|
+
value: function buildModels() {
|
|
139
|
+
var _ref3 = this.layer.getLayerConfig(),
|
|
140
|
+
_ref3$mask = _ref3.mask,
|
|
141
|
+
mask = _ref3$mask === void 0 ? false : _ref3$mask,
|
|
142
|
+
_ref3$maskInside = _ref3.maskInside,
|
|
143
|
+
maskInside = _ref3$maskInside === void 0 ? true : _ref3$maskInside,
|
|
144
|
+
_ref3$depth = _ref3.depth,
|
|
145
|
+
depth = _ref3$depth === void 0 ? false : _ref3$depth;
|
|
146
|
+
|
|
147
|
+
var _this$getShaders = this.getShaders(),
|
|
148
|
+
frag = _this$getShaders.frag,
|
|
149
|
+
vert = _this$getShaders.vert,
|
|
150
|
+
type = _this$getShaders.type;
|
|
151
|
+
|
|
152
|
+
this.layer.triangulation = LineTriangulation;
|
|
153
|
+
return [this.layer.buildLayerModel({
|
|
154
|
+
moduleName: 'line_' + type,
|
|
155
|
+
vertexShader: vert,
|
|
156
|
+
fragmentShader: frag,
|
|
157
|
+
triangulation: LineTriangulation,
|
|
158
|
+
primitive: gl.TRIANGLES,
|
|
159
|
+
blend: this.getBlend(),
|
|
160
|
+
depth: {
|
|
161
|
+
enable: depth
|
|
162
|
+
},
|
|
163
|
+
stencil: getMask(mask, maskInside)
|
|
164
|
+
})];
|
|
165
|
+
}
|
|
166
|
+
}, {
|
|
167
|
+
key: "getShaders",
|
|
168
|
+
value: function getShaders() {
|
|
169
|
+
return {
|
|
170
|
+
frag: linear_line_frag,
|
|
171
|
+
vert: linear_line_vert,
|
|
172
|
+
type: 'linear_rampColors'
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
}, {
|
|
176
|
+
key: "registerBuiltinAttributes",
|
|
177
|
+
value: function registerBuiltinAttributes() {
|
|
178
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
179
|
+
name: 'distanceAndIndex',
|
|
180
|
+
type: AttributeType.Attribute,
|
|
181
|
+
descriptor: {
|
|
182
|
+
name: 'a_DistanceAndIndex',
|
|
183
|
+
buffer: {
|
|
184
|
+
usage: gl.STATIC_DRAW,
|
|
185
|
+
data: [],
|
|
186
|
+
type: gl.FLOAT
|
|
187
|
+
},
|
|
188
|
+
size: 2,
|
|
189
|
+
update: function update(feature, featureIdx, vertex, attributeIdx, normal, vertexIndex) {
|
|
190
|
+
return vertexIndex === undefined ? [vertex[3], 10] : [vertex[3], vertexIndex];
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
195
|
+
name: 'total_distance',
|
|
196
|
+
type: AttributeType.Attribute,
|
|
197
|
+
descriptor: {
|
|
198
|
+
name: 'a_Total_Distance',
|
|
199
|
+
buffer: {
|
|
200
|
+
usage: gl.STATIC_DRAW,
|
|
201
|
+
data: [],
|
|
202
|
+
type: gl.FLOAT
|
|
203
|
+
},
|
|
204
|
+
size: 1,
|
|
205
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
206
|
+
return [vertex[5]];
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
211
|
+
name: 'size',
|
|
212
|
+
type: AttributeType.Attribute,
|
|
213
|
+
descriptor: {
|
|
214
|
+
name: 'a_Size',
|
|
215
|
+
buffer: {
|
|
216
|
+
usage: gl.DYNAMIC_DRAW,
|
|
217
|
+
data: [],
|
|
218
|
+
type: gl.FLOAT
|
|
219
|
+
},
|
|
220
|
+
size: 2,
|
|
221
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
222
|
+
var _feature$size = feature.size,
|
|
223
|
+
size = _feature$size === void 0 ? 1 : _feature$size;
|
|
224
|
+
return Array.isArray(size) ? [size[0], size[1]] : [size, 0];
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
229
|
+
name: 'normal',
|
|
230
|
+
type: AttributeType.Attribute,
|
|
231
|
+
descriptor: {
|
|
232
|
+
name: 'a_Normal',
|
|
233
|
+
buffer: {
|
|
234
|
+
usage: gl.STATIC_DRAW,
|
|
235
|
+
data: [],
|
|
236
|
+
type: gl.FLOAT
|
|
237
|
+
},
|
|
238
|
+
size: 3,
|
|
239
|
+
update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
|
|
240
|
+
return normal;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
245
|
+
name: 'miter',
|
|
246
|
+
type: AttributeType.Attribute,
|
|
247
|
+
descriptor: {
|
|
248
|
+
name: 'a_Miter',
|
|
249
|
+
buffer: {
|
|
250
|
+
usage: gl.STATIC_DRAW,
|
|
251
|
+
data: [],
|
|
252
|
+
type: gl.FLOAT
|
|
253
|
+
},
|
|
254
|
+
size: 1,
|
|
255
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
256
|
+
return [vertex[4]];
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}]);
|
|
262
|
+
|
|
263
|
+
return LinearLineModel;
|
|
264
|
+
}(BaseModel);
|
|
265
|
+
|
|
266
|
+
export { LinearLineModel as default };
|
|
267
|
+
//# sourceMappingURL=linearline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/line/models/linearline.ts"],"names":["AttributeType","gl","generateColorRamp","getMask","BaseModel","LineTriangulation","LinearLineModel","createTexture2D","rendererService","colorTexture","destroy","layer","getLayerConfig","rampColors","imageData","data","Uint8Array","width","height","wrapS","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","buildLayerModel","moduleName","vertexShader","fragmentShader","primitive","TRIANGLES","blend","getBlend","enable","stencil","linear_line_frag","linear_line_vert","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","normal","vertexIndex","undefined","DYNAMIC_DRAW","Array","isArray"],"mappings":";;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAUO,eAVP;AAYA,S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,IAAI,EAAE,EAHA;AAIN8B,YAAAA,IAAI,EAAE5C,EAAE,CAAC6C;AAJH,WAFE;AAQVuC,UAAAA,IAAI,EAAE,CARI;AAUVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKNC,MALM,EAMH;AACH,mBAAOA,MAAP;AACD;AAlBS;AAHoC,OAAlD;AAyBA,WAAKd,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,OAD0C;AAEhDlC,QAAAA,IAAI,EAAE7C,aAAa,CAACgF,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVF,UAAAA,IAAI,EAAE,SADI;AAEVG,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAElF,EAAE,CAACmF,WAFJ;AAGNrE,YAAAA,IAAI,EAAE,EAHA;AAIN8B,YAAAA,IAAI,EAAE5C,EAAE,CAAC6C;AAJH,WAFE;AAQVuC,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;;;;EAlO0CrF,S;;SAAxBE,e","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"}
|
|
@@ -105,6 +105,7 @@ var NormalModel = function (_BaseModel) {
|
|
|
105
105
|
_ref2$maskInside = _ref2.maskInside,
|
|
106
106
|
maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
|
|
107
107
|
|
|
108
|
+
this.layer.triangulation = PointTriangulation;
|
|
108
109
|
return [this.layer.buildLayerModel({
|
|
109
110
|
moduleName: 'normalpoint',
|
|
110
111
|
vertexShader: normalVert,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/point/models/normal.ts"],"names":["AttributeType","BlendType","gl","getMask","BaseModel","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","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_offsets","isOffsetStatic","buildModels","mask","maskInside","buildLayerModel","moduleName","vertexShader","normalVert","fragmentShader","normalFrag","
|
|
1
|
+
{"version":3,"sources":["../../../src/point/models/normal.ts"],"names":["AttributeType","BlendType","gl","getMask","BaseModel","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","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","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","update","featureIdx","vertex","attributeIdx","Array","isArray","additive"],"mappings":";;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,SAFF,EAGEC,EAHF,QAOO,eAPP;AAQA,SAASC,OAAT,QAAwB,gBAAxB;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;;;AAKA,OAAO,SAASC,kBAAT,CAA4BC,OAA5B,EAAqD;AAC1D,MAAMC,WAAW,GAAGD,OAAO,CAACC,WAA5B;AACA,SAAO;AACLC,IAAAA,QAAQ,qBAAMD,WAAN,CADH;AAELE,IAAAA,OAAO,EAAE,CAAC,CAAD,CAFJ;AAGLC,IAAAA,IAAI,EAAEH,WAAW,CAACI;AAHb,GAAP;AAKD;;IAEoBC,W;;;;;;;;;;;;;WACnB,2BAA2D;AACzD,aAAO;AACLC,QAAAA,KAAK,EAAE;AADF,OAAP;AAGD;;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KC,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,MAD0C;AAEhD3B,QAAAA,IAAI,EAAEnC,aAAa,CAAC+D,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVF,UAAAA,IAAI,EAAE,QADI;AAEVG,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAEhE,EAAE,CAACiE,YAFJ;AAGNzC,YAAAA,IAAI,EAAE,EAHA;AAINS,YAAAA,IAAI,EAAEjC,EAAE,CAACkC;AAJH,WAFE;AAQV1B,UAAAA,IAAI,EAAE,CARI;AASV0D,UAAAA,MAAM,EAAE,gBACN9D,OADM,EAEN+D,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gCAAqBjE,OAArB,CAAQI,IAAR;AAAA,gBAAQA,IAAR,8BAAe,CAAf;AACA,mBAAO8D,KAAK,CAACC,OAAN,CAAc/D,IAAd,IAAsB,CAACA,IAAI,CAAC,CAAD,CAAL,CAAtB,GAAkC,CAACA,IAAD,CAAzC;AACD;AAjBS;AAHoC,OAAlD;AAuBD;;;WAED,+BAAgE;AAC9D,aAAO;AACLG,QAAAA,KAAK,EAAEZ,SAAS,CAACyE;AADZ,OAAP;AAGD;;;;EAxHsCtE,S;;SAApBQ,W","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"}
|