@antv/l7-layers 2.6.30 → 2.6.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/citybuliding/models/build.js +3 -2
- package/es/citybuliding/models/build.js.map +1 -1
- package/es/core/BaseLayer.d.ts +1 -1
- package/es/core/BaseLayer.js +6 -10
- package/es/core/BaseLayer.js.map +1 -1
- package/es/core/BaseModel.d.ts +1 -1
- package/es/core/BaseModel.js +4 -8
- package/es/core/BaseModel.js.map +1 -1
- package/es/core/interface.d.ts +2 -0
- package/es/core/interface.js.map +1 -1
- package/es/core/triangulation.d.ts +6 -0
- package/es/core/triangulation.js +47 -0
- package/es/core/triangulation.js.map +1 -1
- package/es/heatmap/models/heatmap.js +2 -2
- package/es/line/index.d.ts +1 -1
- package/es/line/index.js +2 -0
- package/es/line/index.js.map +1 -1
- package/es/line/models/index.d.ts +1 -1
- package/es/line/models/index.js +5 -1
- package/es/line/models/index.js.map +1 -1
- package/es/line/models/line.d.ts +0 -1
- package/es/line/models/line.js +5 -32
- package/es/line/models/line.js.map +1 -1
- package/es/line/models/simpleLine.d.ts +10 -0
- package/es/line/models/simpleLine.js +221 -0
- package/es/line/models/simpleLine.js.map +1 -0
- package/es/line/models/wall.d.ts +12 -0
- package/es/line/models/wall.js +311 -0
- package/es/line/models/wall.js.map +1 -0
- package/es/plugins/DataMappingPlugin.js +2 -2
- package/es/plugins/LayerAnimateStylePlugin.js +2 -2
- package/es/plugins/LightingPlugin.js +2 -2
- package/es/plugins/PixelPickingPlugin.js +24 -7
- package/es/plugins/PixelPickingPlugin.js.map +1 -1
- package/es/point/models/fill.js +4 -0
- package/es/point/models/fill.js.map +1 -1
- package/es/point/models/icon-font.js +1 -1
- package/es/point/models/image.js +8 -4
- package/es/point/models/image.js.map +1 -1
- package/es/raster/raster.js +2 -2
- package/es/utils/extrude_polyline.d.ts +13 -0
- package/es/utils/extrude_polyline.js +105 -3
- package/es/utils/extrude_polyline.js.map +1 -1
- package/lib/citybuliding/models/build.js +3 -2
- package/lib/citybuliding/models/build.js.map +1 -1
- package/lib/core/BaseLayer.js +6 -10
- package/lib/core/BaseLayer.js.map +1 -1
- package/lib/core/BaseModel.js +4 -8
- package/lib/core/BaseModel.js.map +1 -1
- package/lib/core/interface.js.map +1 -1
- package/lib/core/triangulation.js +49 -0
- package/lib/core/triangulation.js.map +1 -1
- package/lib/heatmap/models/heatmap.js +2 -2
- package/lib/line/index.js +2 -0
- package/lib/line/index.js.map +1 -1
- package/lib/line/models/index.js +7 -1
- package/lib/line/models/index.js.map +1 -1
- package/lib/line/models/line.js +5 -32
- package/lib/line/models/line.js.map +1 -1
- package/lib/line/models/simpleLine.js +237 -0
- package/lib/line/models/simpleLine.js.map +1 -0
- package/lib/line/models/wall.js +327 -0
- package/lib/line/models/wall.js.map +1 -0
- package/lib/plugins/DataMappingPlugin.js +2 -2
- package/lib/plugins/LayerAnimateStylePlugin.js +2 -2
- package/lib/plugins/LightingPlugin.js +2 -2
- package/lib/plugins/PixelPickingPlugin.js +24 -7
- package/lib/plugins/PixelPickingPlugin.js.map +1 -1
- package/lib/point/models/fill.js +4 -0
- package/lib/point/models/fill.js.map +1 -1
- package/lib/point/models/icon-font.js +1 -1
- package/lib/point/models/image.js +8 -4
- package/lib/point/models/image.js.map +1 -1
- package/lib/raster/raster.js +2 -2
- package/lib/utils/extrude_polyline.js +105 -3
- package/lib/utils/extrude_polyline.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
|
+
|
|
16
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
17
|
+
|
|
18
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
|
+
|
|
20
|
+
var _isNumber2 = _interopRequireDefault(require("lodash/isNumber"));
|
|
21
|
+
|
|
22
|
+
var _l7Core = require("@antv/l7-core");
|
|
23
|
+
|
|
24
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
25
|
+
|
|
26
|
+
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
27
|
+
|
|
28
|
+
var _triangulation = require("../../core/triangulation");
|
|
29
|
+
|
|
30
|
+
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); }; }
|
|
31
|
+
|
|
32
|
+
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; } }
|
|
33
|
+
|
|
34
|
+
var line_frag = "\nuniform float u_blur : 0.99;\nuniform float u_line_type: 0.0;\nuniform float u_opacity : 1.0;\n\nuniform float u_borderWidth: 0.0;\nuniform vec4 u_borderColor;\nvarying vec4 v_color;\n\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n\nvarying mat4 styleMappingMat;\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 if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, d_distance_ratio);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n // anti-alias\n // float blur = 1.0 - smoothstep(u_blur, 1., length(v_normal.xy));\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n}\n";
|
|
35
|
+
var line_vert = "\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Position;\n\n\n// dash line\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nuniform float u_vertexScale: 1.0;\n\n#pragma include \"projection\"\n\nvarying vec4 v_color;\n\nuniform float u_linearColor: 0;\n\nuniform float u_opacity: 1.0;\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 float d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n v_color = a_Color;\n\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n styleMappingMat[3][0] = d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n styleMappingMat[3][1] = a_Distance; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n \n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 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\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy, project_pixel(a_Size.y) + h * 0.2, 1.0));\n } else {\n float lineHeight = a_Size.y;\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 // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n h *= 2.0/pow(2.0, 20.0 - u_Zoom);\n }\n\n // #define COORDINATE_SYSTEM_P20 5.0\n // #define COORDINATE_SYSTEM_P20_OFFSET 6.0\n // amap1.x\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, lineHeight + h, 1.0));\n }\n}\n";
|
|
36
|
+
|
|
37
|
+
var SimpleLineModel = function (_BaseModel) {
|
|
38
|
+
(0, _inherits2.default)(SimpleLineModel, _BaseModel);
|
|
39
|
+
|
|
40
|
+
var _super = _createSuper(SimpleLineModel);
|
|
41
|
+
|
|
42
|
+
function SimpleLineModel() {
|
|
43
|
+
(0, _classCallCheck2.default)(this, SimpleLineModel);
|
|
44
|
+
return _super.apply(this, arguments);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
(0, _createClass2.default)(SimpleLineModel, [{
|
|
48
|
+
key: "getUninforms",
|
|
49
|
+
value: function getUninforms() {
|
|
50
|
+
var _ref = this.layer.getLayerConfig(),
|
|
51
|
+
opacity = _ref.opacity,
|
|
52
|
+
sourceColor = _ref.sourceColor,
|
|
53
|
+
targetColor = _ref.targetColor,
|
|
54
|
+
_ref$vertexHeightScal = _ref.vertexHeightScale,
|
|
55
|
+
vertexHeightScale = _ref$vertexHeightScal === void 0 ? 20.0 : _ref$vertexHeightScal;
|
|
56
|
+
|
|
57
|
+
var useLinearColor = 0;
|
|
58
|
+
var sourceColorArr = [0, 0, 0, 0];
|
|
59
|
+
var targetColorArr = [0, 0, 0, 0];
|
|
60
|
+
|
|
61
|
+
if (sourceColor && targetColor) {
|
|
62
|
+
sourceColorArr = (0, _l7Utils.rgb2arr)(sourceColor);
|
|
63
|
+
targetColorArr = (0, _l7Utils.rgb2arr)(targetColor);
|
|
64
|
+
useLinearColor = 1;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
68
|
+
opacity: opacity
|
|
69
|
+
})) {
|
|
70
|
+
this.judgeStyleAttributes({
|
|
71
|
+
opacity: opacity
|
|
72
|
+
});
|
|
73
|
+
var encodeData = this.layer.getEncodedData();
|
|
74
|
+
|
|
75
|
+
var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
|
|
76
|
+
data = _this$calDataFrame.data,
|
|
77
|
+
width = _this$calDataFrame.width,
|
|
78
|
+
height = _this$calDataFrame.height;
|
|
79
|
+
|
|
80
|
+
this.rowCount = height;
|
|
81
|
+
this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
|
|
82
|
+
flipY: true,
|
|
83
|
+
data: data,
|
|
84
|
+
format: _l7Core.gl.LUMINANCE,
|
|
85
|
+
type: _l7Core.gl.FLOAT,
|
|
86
|
+
width: width,
|
|
87
|
+
height: height
|
|
88
|
+
}) : this.createTexture2D({
|
|
89
|
+
flipY: true,
|
|
90
|
+
data: [1],
|
|
91
|
+
format: _l7Core.gl.LUMINANCE,
|
|
92
|
+
type: _l7Core.gl.FLOAT,
|
|
93
|
+
width: 1,
|
|
94
|
+
height: 1
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
u_dataTexture: this.dataTexture,
|
|
100
|
+
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
101
|
+
u_opacity: (0, _isNumber2.default)(opacity) ? opacity : 1.0,
|
|
102
|
+
u_linearColor: useLinearColor,
|
|
103
|
+
u_sourceColor: sourceColorArr,
|
|
104
|
+
u_targetColor: targetColorArr,
|
|
105
|
+
u_vertexScale: vertexHeightScale
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}, {
|
|
109
|
+
key: "getAnimateUniforms",
|
|
110
|
+
value: function getAnimateUniforms() {
|
|
111
|
+
var _ref2 = this.layer.getLayerConfig(),
|
|
112
|
+
animateOption = _ref2.animateOption;
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
u_aimate: this.animateOption2Array(animateOption),
|
|
116
|
+
u_time: this.layer.getLayerAnimateTime()
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}, {
|
|
120
|
+
key: "initModels",
|
|
121
|
+
value: function initModels() {
|
|
122
|
+
return this.buildModels();
|
|
123
|
+
}
|
|
124
|
+
}, {
|
|
125
|
+
key: "clearModels",
|
|
126
|
+
value: function clearModels() {
|
|
127
|
+
var _this$dataTexture;
|
|
128
|
+
|
|
129
|
+
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
|
|
130
|
+
}
|
|
131
|
+
}, {
|
|
132
|
+
key: "buildModels",
|
|
133
|
+
value: function buildModels() {
|
|
134
|
+
return [this.layer.buildLayerModel({
|
|
135
|
+
moduleName: 'line',
|
|
136
|
+
vertexShader: line_vert,
|
|
137
|
+
fragmentShader: line_frag,
|
|
138
|
+
triangulation: _triangulation.SimpleLineTriangulation,
|
|
139
|
+
primitive: _l7Core.gl.LINES,
|
|
140
|
+
blend: this.getBlend(),
|
|
141
|
+
depth: {
|
|
142
|
+
enable: false
|
|
143
|
+
}
|
|
144
|
+
})];
|
|
145
|
+
}
|
|
146
|
+
}, {
|
|
147
|
+
key: "registerBuiltinAttributes",
|
|
148
|
+
value: function registerBuiltinAttributes() {
|
|
149
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
150
|
+
name: 'distance',
|
|
151
|
+
type: _l7Core.AttributeType.Attribute,
|
|
152
|
+
descriptor: {
|
|
153
|
+
name: 'a_Distance',
|
|
154
|
+
buffer: {
|
|
155
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
156
|
+
data: [],
|
|
157
|
+
type: _l7Core.gl.FLOAT
|
|
158
|
+
},
|
|
159
|
+
size: 1,
|
|
160
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
161
|
+
return [vertex[3]];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
166
|
+
name: 'total_distance',
|
|
167
|
+
type: _l7Core.AttributeType.Attribute,
|
|
168
|
+
descriptor: {
|
|
169
|
+
name: 'a_Total_Distance',
|
|
170
|
+
buffer: {
|
|
171
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
172
|
+
data: [],
|
|
173
|
+
type: _l7Core.gl.FLOAT
|
|
174
|
+
},
|
|
175
|
+
size: 1,
|
|
176
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
177
|
+
return [vertex[5]];
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
182
|
+
name: 'size',
|
|
183
|
+
type: _l7Core.AttributeType.Attribute,
|
|
184
|
+
descriptor: {
|
|
185
|
+
name: 'a_Size',
|
|
186
|
+
buffer: {
|
|
187
|
+
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
188
|
+
data: [],
|
|
189
|
+
type: _l7Core.gl.FLOAT
|
|
190
|
+
},
|
|
191
|
+
size: 2,
|
|
192
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
193
|
+
var _feature$size = feature.size,
|
|
194
|
+
size = _feature$size === void 0 ? 1 : _feature$size;
|
|
195
|
+
return Array.isArray(size) ? [size[0], size[1]] : [size, 0];
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
200
|
+
name: 'normal',
|
|
201
|
+
type: _l7Core.AttributeType.Attribute,
|
|
202
|
+
descriptor: {
|
|
203
|
+
name: 'a_Normal',
|
|
204
|
+
buffer: {
|
|
205
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
206
|
+
data: [],
|
|
207
|
+
type: _l7Core.gl.FLOAT
|
|
208
|
+
},
|
|
209
|
+
size: 3,
|
|
210
|
+
update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
|
|
211
|
+
return normal;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
216
|
+
name: 'miter',
|
|
217
|
+
type: _l7Core.AttributeType.Attribute,
|
|
218
|
+
descriptor: {
|
|
219
|
+
name: 'a_Miter',
|
|
220
|
+
buffer: {
|
|
221
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
222
|
+
data: [],
|
|
223
|
+
type: _l7Core.gl.FLOAT
|
|
224
|
+
},
|
|
225
|
+
size: 1,
|
|
226
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
227
|
+
return [vertex[4]];
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}]);
|
|
233
|
+
return SimpleLineModel;
|
|
234
|
+
}(_BaseModel2.default);
|
|
235
|
+
|
|
236
|
+
exports.default = SimpleLineModel;
|
|
237
|
+
//# sourceMappingURL=simpleLine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/line/models/simpleLine.ts"],"names":["SimpleLineModel","layer","getLayerConfig","opacity","sourceColor","targetColor","vertexHeightScale","useLinearColor","sourceColorArr","targetColorArr","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_linearColor","u_sourceColor","u_targetColor","u_vertexScale","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","buildModels","destroy","buildLayerModel","moduleName","vertexShader","line_vert","fragmentShader","line_frag","triangulation","SimpleLineTriangulation","primitive","LINES","blend","getBlend","depth","enable","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","DYNAMIC_DRAW","Array","isArray","normal","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AAUA;;AAEA;;AAEA;;;;;;;;;IAGqBA,e;;;;;;;;;;;;WACnB,wBAAqC;AACnC,iBAKI,KAAKC,KAAL,CAAWC,cAAX,EALJ;AAAA,UACEC,OADF,QACEA,OADF;AAAA,UAEEC,WAFF,QAEEA,WAFF;AAAA,UAGEC,WAHF,QAGEA,WAHF;AAAA,uCAIEC,iBAJF;AAAA,UAIEA,iBAJF,sCAIsB,IAJtB;;AAQA,UAAIC,cAAc,GAAG,CAArB;AACA,UAAIC,cAAc,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAArB;AACA,UAAIC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,YAAAA,IAAI,EAAE,EAHA;AAINW,YAAAA,IAAI,EAAEF,WAAGG;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;;;EAlN0CM,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\n\nimport { rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions } from '../../core/interface';\nimport { SimpleLineTriangulation } from '../../core/triangulation';\nimport line_frag from '../shaders/simpleline_frag.glsl';\nimport line_vert from '../shaders/simpleline_vert.glsl';\nexport default class SimpleLineModel extends BaseModel {\n public getUninforms(): IModelUniform {\n const {\n opacity,\n sourceColor,\n targetColor,\n vertexHeightScale = 20.0,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\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.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\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n\n // 顶点高度 scale\n u_vertexScale: vertexHeightScale,\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption as IAnimateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n public buildModels(): IModel[] {\n return [\n this.layer.buildLayerModel({\n moduleName: 'line',\n vertexShader: line_vert,\n fragmentShader: line_frag,\n triangulation: SimpleLineTriangulation,\n primitive: gl.LINES, // gl.LINES gl.TRIANGLES\n blend: this.getBlend(),\n depth: { enable: false },\n }),\n ];\n }\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_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[3]];\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"],"file":"simpleLine.js"}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
+
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
+
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
+
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
+
|
|
22
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
+
|
|
24
|
+
var _isNumber2 = _interopRequireDefault(require("lodash/isNumber"));
|
|
25
|
+
|
|
26
|
+
var _l7Core = require("@antv/l7-core");
|
|
27
|
+
|
|
28
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
29
|
+
|
|
30
|
+
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
31
|
+
|
|
32
|
+
var _triangulation = require("../../core/triangulation");
|
|
33
|
+
|
|
34
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
35
|
+
|
|
36
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
37
|
+
|
|
38
|
+
var line_frag = "#define LineTypeSolid 0.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform float u_opacity : 1.0;\nuniform float u_textureBlend;\nuniform float u_iconStepCount;\n\nvarying vec4 v_color;\n\n// line texture\nuniform float u_line_texture;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\n\n// dash\nuniform float u_dash_offset : 0.0;\nuniform float u_dash_ratio : 0.1;\n\nvarying vec2 v_iconMapUV;\nvarying float v_blur;\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n\nvarying mat4 styleMappingMat;\n// [animate, duration, interval, trailLength],\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = styleMappingMat[3].r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n float v = styleMappingMat[3].a;\n\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, v);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n if(u_aimate.x == Animate) {\n animateSpeed = u_time / u_aimate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + animateSpeed);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n }\n\n if(u_line_texture == LineTexture) { // while load texture\n float aDistance = styleMappingMat[3].g; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n float d_texPixelLen = styleMappingMat[3].b; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n float u = fract(mod(aDistance, d_texPixelLen)/d_texPixelLen - animateSpeed);\n float v = styleMappingMat[3].a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // \u8BA1\u7B97\u7EB9\u7406\u95F4\u9694 start\n float flag = 0.0;\n if(u > 1.0/u_iconStepCount) {\n flag = 1.0;\n }\n u = fract(u*u_iconStepCount);\n // \u8BA1\u7B97\u7EB9\u7406\u95F4\u9694 end\n\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture2D(u_texture, uv);\n\n // Tip: \u5224\u65AD\u7EB9\u7406\u95F4\u9694\n if(flag > 0.0) {\n pattern = vec4(0.0);\n }\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor = filterColor(gl_FragColor + pattern);\n } else { // replace\n pattern.a *= opacity;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = filterColor(pattern);\n }\n }\n \n\n // blur - AA\n if(v < v_blur) {\n gl_FragColor.a = mix(0.0, gl_FragColor.a, v/v_blur);\n } else if(v > 1.0 - v_blur) {\n gl_FragColor.a = mix(gl_FragColor.a, 0.0, (v - (1.0 - v_blur))/v_blur);\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n\n \n \n \n}\n";
|
|
39
|
+
var line_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nuniform float u_icon_step: 100;\nuniform float u_heightfixed;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\nvarying float v_blur;\n\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nvarying vec2 v_iconMapUV;\n\n\nuniform float u_linearColor: 0;\n\nuniform float u_opacity: 1.0;\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 \"light\"\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 float d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n float d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n\n v_iconMapUV = a_iconMapUV;\n if(u_heightfixed < 1.0) { // \u9AD8\u5EA6\u968F zoom \u8C03\u6574\n d_texPixelLen = project_pixel(u_icon_step);\n } else {\n d_texPixelLen = u_icon_step;\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n d_texPixelLen *= 10.0;\n }\n\n if(u_aimate.x == Animate || u_linearColor == 1.0) {\n d_distance_ratio = a_Distance / a_Total_Distance;\n }\n\n float miter = (a_Miter + 1.0)/2.0;\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n styleMappingMat[3][0] = d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n styleMappingMat[3][1] = a_Distance; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n styleMappingMat[3][2] = d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n styleMappingMat[3][3] = miter; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C 0 - 1\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n float originSize = a_Size.x; // \u56FA\u5B9A\u9AD8\u5EA6\n if(u_heightfixed < 1.0) { // \u9AD8\u5EA6\u968F zoom \u8C03\u6574\n originSize = project_float_pixel(a_Size.x);\n }\n\n float wallHeight = originSize * miter;\n float lightWeight = calc_lighting(vec4(project_pos.xy, wallHeight, 1.0));\n\n v_blur = min(project_float_pixel(2.0) / originSize, 0.05);\n\n // v_lightWeight = lightWeight;\n v_color = vec4(a_Color.rgb * lightWeight, a_Color.w);\n // v_color = a_Color;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy, wallHeight, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, wallHeight, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
40
|
+
|
|
41
|
+
var LineWallModel = function (_BaseModel) {
|
|
42
|
+
(0, _inherits2.default)(LineWallModel, _BaseModel);
|
|
43
|
+
|
|
44
|
+
var _super = _createSuper(LineWallModel);
|
|
45
|
+
|
|
46
|
+
function LineWallModel() {
|
|
47
|
+
var _this;
|
|
48
|
+
|
|
49
|
+
(0, _classCallCheck2.default)(this, LineWallModel);
|
|
50
|
+
|
|
51
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
52
|
+
args[_key] = arguments[_key];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
56
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "texture", void 0);
|
|
57
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateTexture", function () {
|
|
58
|
+
var createTexture2D = _this.rendererService.createTexture2D;
|
|
59
|
+
|
|
60
|
+
if (_this.texture) {
|
|
61
|
+
_this.texture.update({
|
|
62
|
+
data: _this.iconService.getCanvas()
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
_this.layer.render();
|
|
66
|
+
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
_this.texture = createTexture2D({
|
|
71
|
+
data: _this.iconService.getCanvas(),
|
|
72
|
+
mag: _l7Core.gl.NEAREST,
|
|
73
|
+
min: _l7Core.gl.NEAREST,
|
|
74
|
+
premultiplyAlpha: false,
|
|
75
|
+
width: 1024,
|
|
76
|
+
height: _this.iconService.canvasHeight || 128
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
return _this;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
(0, _createClass2.default)(LineWallModel, [{
|
|
83
|
+
key: "getUninforms",
|
|
84
|
+
value: function getUninforms() {
|
|
85
|
+
var _ref = this.layer.getLayerConfig(),
|
|
86
|
+
opacity = _ref.opacity,
|
|
87
|
+
sourceColor = _ref.sourceColor,
|
|
88
|
+
targetColor = _ref.targetColor,
|
|
89
|
+
_ref$textureBlend = _ref.textureBlend,
|
|
90
|
+
textureBlend = _ref$textureBlend === void 0 ? 'normal' : _ref$textureBlend,
|
|
91
|
+
_ref$heightfixed = _ref.heightfixed,
|
|
92
|
+
heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed,
|
|
93
|
+
_ref$lineTexture = _ref.lineTexture,
|
|
94
|
+
lineTexture = _ref$lineTexture === void 0 ? false : _ref$lineTexture,
|
|
95
|
+
_ref$iconStep = _ref.iconStep,
|
|
96
|
+
iconStep = _ref$iconStep === void 0 ? 100 : _ref$iconStep,
|
|
97
|
+
_ref$iconStepCount = _ref.iconStepCount,
|
|
98
|
+
iconStepCount = _ref$iconStepCount === void 0 ? 1 : _ref$iconStepCount;
|
|
99
|
+
|
|
100
|
+
if (this.rendererService.getDirty()) {
|
|
101
|
+
this.texture.bind();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
var useLinearColor = 0;
|
|
105
|
+
var sourceColorArr = [0, 0, 0, 0];
|
|
106
|
+
var targetColorArr = [0, 0, 0, 0];
|
|
107
|
+
|
|
108
|
+
if (sourceColor && targetColor) {
|
|
109
|
+
sourceColorArr = (0, _l7Utils.rgb2arr)(sourceColor);
|
|
110
|
+
targetColorArr = (0, _l7Utils.rgb2arr)(targetColor);
|
|
111
|
+
useLinearColor = 1;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
115
|
+
opacity: opacity
|
|
116
|
+
})) {
|
|
117
|
+
this.judgeStyleAttributes({
|
|
118
|
+
opacity: opacity
|
|
119
|
+
});
|
|
120
|
+
var encodeData = this.layer.getEncodedData();
|
|
121
|
+
|
|
122
|
+
var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
|
|
123
|
+
data = _this$calDataFrame.data,
|
|
124
|
+
width = _this$calDataFrame.width,
|
|
125
|
+
height = _this$calDataFrame.height;
|
|
126
|
+
|
|
127
|
+
this.rowCount = height;
|
|
128
|
+
this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
|
|
129
|
+
flipY: true,
|
|
130
|
+
data: data,
|
|
131
|
+
format: _l7Core.gl.LUMINANCE,
|
|
132
|
+
type: _l7Core.gl.FLOAT,
|
|
133
|
+
width: width,
|
|
134
|
+
height: height
|
|
135
|
+
}) : this.createTexture2D({
|
|
136
|
+
flipY: true,
|
|
137
|
+
data: [1],
|
|
138
|
+
format: _l7Core.gl.LUMINANCE,
|
|
139
|
+
type: _l7Core.gl.FLOAT,
|
|
140
|
+
width: 1,
|
|
141
|
+
height: 1
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return {
|
|
146
|
+
u_heightfixed: Number(heightfixed),
|
|
147
|
+
u_dataTexture: this.dataTexture,
|
|
148
|
+
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
149
|
+
u_opacity: (0, _isNumber2.default)(opacity) ? opacity : 1.0,
|
|
150
|
+
u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,
|
|
151
|
+
u_texture: this.texture,
|
|
152
|
+
u_line_texture: lineTexture ? 1.0 : 0.0,
|
|
153
|
+
u_iconStepCount: iconStepCount,
|
|
154
|
+
u_icon_step: iconStep,
|
|
155
|
+
u_textSize: [1024, this.iconService.canvasHeight || 128],
|
|
156
|
+
u_linearColor: useLinearColor,
|
|
157
|
+
u_sourceColor: sourceColorArr,
|
|
158
|
+
u_targetColor: targetColorArr
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}, {
|
|
162
|
+
key: "getAnimateUniforms",
|
|
163
|
+
value: function getAnimateUniforms() {
|
|
164
|
+
var _ref2 = this.layer.getLayerConfig(),
|
|
165
|
+
animateOption = _ref2.animateOption;
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
u_aimate: this.animateOption2Array(animateOption),
|
|
169
|
+
u_time: this.layer.getLayerAnimateTime()
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}, {
|
|
173
|
+
key: "initModels",
|
|
174
|
+
value: function initModels() {
|
|
175
|
+
this.updateTexture();
|
|
176
|
+
this.iconService.on('imageUpdate', this.updateTexture);
|
|
177
|
+
return this.buildModels();
|
|
178
|
+
}
|
|
179
|
+
}, {
|
|
180
|
+
key: "clearModels",
|
|
181
|
+
value: function clearModels() {
|
|
182
|
+
var _this$texture, _this$dataTexture;
|
|
183
|
+
|
|
184
|
+
(_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
|
|
185
|
+
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
|
|
186
|
+
this.iconService.off('imageUpdate', this.updateTexture);
|
|
187
|
+
}
|
|
188
|
+
}, {
|
|
189
|
+
key: "buildModels",
|
|
190
|
+
value: function buildModels() {
|
|
191
|
+
return [this.layer.buildLayerModel({
|
|
192
|
+
moduleName: 'linewall',
|
|
193
|
+
vertexShader: line_vert,
|
|
194
|
+
fragmentShader: line_frag,
|
|
195
|
+
triangulation: _triangulation.LineTriangulation,
|
|
196
|
+
primitive: _l7Core.gl.TRIANGLES,
|
|
197
|
+
blend: this.getBlend(),
|
|
198
|
+
depth: {
|
|
199
|
+
enable: false
|
|
200
|
+
}
|
|
201
|
+
})];
|
|
202
|
+
}
|
|
203
|
+
}, {
|
|
204
|
+
key: "registerBuiltinAttributes",
|
|
205
|
+
value: function registerBuiltinAttributes() {
|
|
206
|
+
var _this2 = this;
|
|
207
|
+
|
|
208
|
+
var _ref3 = this.layer.getLayerConfig(),
|
|
209
|
+
_ref3$lineType = _ref3.lineType,
|
|
210
|
+
lineType = _ref3$lineType === void 0 ? 'solid' : _ref3$lineType;
|
|
211
|
+
|
|
212
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
213
|
+
name: 'distance',
|
|
214
|
+
type: _l7Core.AttributeType.Attribute,
|
|
215
|
+
descriptor: {
|
|
216
|
+
name: 'a_Distance',
|
|
217
|
+
buffer: {
|
|
218
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
219
|
+
data: [],
|
|
220
|
+
type: _l7Core.gl.FLOAT
|
|
221
|
+
},
|
|
222
|
+
size: 1,
|
|
223
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
224
|
+
return [vertex[3]];
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
229
|
+
name: 'total_distance',
|
|
230
|
+
type: _l7Core.AttributeType.Attribute,
|
|
231
|
+
descriptor: {
|
|
232
|
+
name: 'a_Total_Distance',
|
|
233
|
+
buffer: {
|
|
234
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
235
|
+
data: [],
|
|
236
|
+
type: _l7Core.gl.FLOAT
|
|
237
|
+
},
|
|
238
|
+
size: 1,
|
|
239
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
240
|
+
return [vertex[5]];
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
245
|
+
name: 'size',
|
|
246
|
+
type: _l7Core.AttributeType.Attribute,
|
|
247
|
+
descriptor: {
|
|
248
|
+
name: 'a_Size',
|
|
249
|
+
buffer: {
|
|
250
|
+
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
251
|
+
data: [],
|
|
252
|
+
type: _l7Core.gl.FLOAT
|
|
253
|
+
},
|
|
254
|
+
size: 2,
|
|
255
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
256
|
+
var _feature$size = feature.size,
|
|
257
|
+
size = _feature$size === void 0 ? 1 : _feature$size;
|
|
258
|
+
return Array.isArray(size) ? [size[0], size[1]] : [size, 0];
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
263
|
+
name: 'normal',
|
|
264
|
+
type: _l7Core.AttributeType.Attribute,
|
|
265
|
+
descriptor: {
|
|
266
|
+
name: 'a_Normal',
|
|
267
|
+
buffer: {
|
|
268
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
269
|
+
data: [],
|
|
270
|
+
type: _l7Core.gl.FLOAT
|
|
271
|
+
},
|
|
272
|
+
size: 3,
|
|
273
|
+
update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
|
|
274
|
+
return normal;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
279
|
+
name: 'miter',
|
|
280
|
+
type: _l7Core.AttributeType.Attribute,
|
|
281
|
+
descriptor: {
|
|
282
|
+
name: 'a_Miter',
|
|
283
|
+
buffer: {
|
|
284
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
285
|
+
data: [],
|
|
286
|
+
type: _l7Core.gl.FLOAT
|
|
287
|
+
},
|
|
288
|
+
size: 1,
|
|
289
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
290
|
+
return [vertex[4]];
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
295
|
+
name: 'uv',
|
|
296
|
+
type: _l7Core.AttributeType.Attribute,
|
|
297
|
+
descriptor: {
|
|
298
|
+
name: 'a_iconMapUV',
|
|
299
|
+
buffer: {
|
|
300
|
+
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
301
|
+
data: [],
|
|
302
|
+
type: _l7Core.gl.FLOAT
|
|
303
|
+
},
|
|
304
|
+
size: 2,
|
|
305
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
306
|
+
var iconMap = _this2.iconService.getIconMap();
|
|
307
|
+
|
|
308
|
+
var texture = feature.texture;
|
|
309
|
+
|
|
310
|
+
var _ref4 = iconMap[texture] || {
|
|
311
|
+
x: 0,
|
|
312
|
+
y: 0
|
|
313
|
+
},
|
|
314
|
+
x = _ref4.x,
|
|
315
|
+
y = _ref4.y;
|
|
316
|
+
|
|
317
|
+
return [x, y];
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
}]);
|
|
323
|
+
return LineWallModel;
|
|
324
|
+
}(_BaseModel2.default);
|
|
325
|
+
|
|
326
|
+
exports.default = LineWallModel;
|
|
327
|
+
//# sourceMappingURL=wall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/line/models/wall.ts"],"names":["LineWallModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","layer","render","mag","gl","NEAREST","min","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","sourceColor","targetColor","textureBlend","heightfixed","lineTexture","iconStep","iconStepCount","getDirty","bind","useLinearColor","sourceColorArr","targetColorArr","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","length","flipY","format","LUMINANCE","type","FLOAT","u_heightfixed","Number","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_textureBlend","u_texture","u_line_texture","u_iconStepCount","u_icon_step","u_textSize","u_linearColor","u_sourceColor","u_targetColor","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","updateTexture","on","buildModels","destroy","off","buildLayerModel","moduleName","vertexShader","line_vert","fragmentShader","line_frag","triangulation","LineTriangulation","primitive","TRIANGLES","blend","getBlend","depth","enable","lineType","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","DYNAMIC_DRAW","Array","isArray","normal","iconMap","getIconMap","x","y","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAYA;;AAEA;;AAEA;;;;;;;;;IAIqBA,a;;;;;;;;;;;;;;;;gGAwQK,YAAM;AAC5B,UAAQC,eAAR,GAA4B,MAAKC,eAAjC,CAAQD,eAAR;;AACA,UAAI,MAAKE,OAAT,EAAkB;AAChB,cAAKA,OAAL,CAAaC,MAAb,CAAoB;AAClBC,UAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB;AADY,SAApB;;AAGA,cAAKC,KAAL,CAAWC,MAAX;;AACA;AACD;;AACD,YAAKN,OAAL,GAAeF,eAAe,CAAC;AAC7BI,QAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB,EADuB;AAE7BG,QAAAA,GAAG,EAAEC,WAAGC,OAFqB;AAG7BC,QAAAA,GAAG,EAAEF,WAAGC,OAHqB;AAI7BE,QAA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C,cAAAA,CAAC,EAAE;AAAX,aAA/C;AAAA,gBAAQD,CAAR,SAAQA,CAAR;AAAA,gBAAWC,CAAX,SAAWA,CAAX;;AACA,mBAAO,CAACD,CAAD,EAAIC,CAAJ,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;EAvQwCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n IImage,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\n\nimport { rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions, lineStyleType } from '../../core/interface';\nimport { LineTriangulation } from '../../core/triangulation';\nimport line_frag from '../shaders/wall_frag.glsl';\nimport line_vert from '../shaders/wall_vert.glsl';\n\nexport default class LineWallModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity,\n sourceColor,\n targetColor,\n textureBlend = 'normal',\n heightfixed = false,\n lineTexture = false,\n iconStep = 100,\n iconStepCount = 1,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (this.rendererService.getDirty()) {\n this.texture.bind();\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.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\n return {\n u_heightfixed: Number(heightfixed),\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity === undefined ? 1 : opacity,\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,\n\n // 纹理支持参数\n u_texture: this.texture, // 贴图\n u_line_texture: lineTexture ? 1.0 : 0.0, // 传入线的标识\n u_iconStepCount: iconStepCount,\n u_icon_step: iconStep,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption as IAnimateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public initModels(): IModel[] {\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n\n return this.buildModels();\n }\n\n public clearModels() {\n this.texture?.destroy();\n this.dataTexture?.destroy();\n this.iconService.off('imageUpdate', this.updateTexture);\n }\n\n public buildModels(): IModel[] {\n return [\n this.layer.buildLayerModel({\n moduleName: 'linewall',\n vertexShader: line_vert,\n fragmentShader: line_frag,\n triangulation: LineTriangulation,\n primitive: gl.TRIANGLES,\n blend: this.getBlend(),\n depth: { enable: false },\n }),\n ];\n }\n protected registerBuiltinAttributes() {\n // const lineType = this\n // point layer size;\n const {\n lineType = 'solid',\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n // if (lineType === 'dash') {\n this.styleAttributeService.registerStyleAttribute({\n name: 'distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_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[3]];\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 this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_iconMapUV',\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 iconMap = this.iconService.getIconMap();\n const { texture } = feature;\n const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };\n return [x, y];\n },\n },\n });\n }\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.update({\n data: this.iconService.getCanvas(),\n });\n this.layer.render();\n return;\n }\n this.texture = createTexture2D({\n data: this.iconService.getCanvas(),\n mag: gl.NEAREST,\n min: gl.NEAREST,\n premultiplyAlpha: false,\n width: 1024,\n height: this.iconService.canvasHeight || 128,\n });\n };\n}\n"],"file":"wall.js"}
|