@antv/l7-layers 2.20.3 → 2.20.5
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 +3 -1
- package/es/core/BaseModel.d.ts +20 -0
- package/es/core/BaseModel.js +71 -0
- package/es/core/CommonStyleAttribute.d.ts +2 -1
- package/es/core/CommonStyleAttribute.js +1 -0
- package/es/core/utils.d.ts +4 -0
- package/es/core/utils.js +15 -0
- package/es/line/models/great_circle.js +11 -7
- package/es/point/models/extrude.d.ts +8 -10
- package/es/point/models/extrude.js +25 -11
- package/es/point/models/image.js +0 -4
- package/es/point/shaders/extrude/extrude_frag.glsl +19 -7
- package/es/point/shaders/extrude/extrude_vert.glsl +23 -27
- package/lib/core/BaseLayer.js +3 -1
- package/lib/core/BaseModel.js +71 -0
- package/lib/core/CommonStyleAttribute.js +1 -0
- package/lib/core/utils.js +22 -0
- package/lib/line/models/great_circle.js +11 -7
- package/lib/point/models/extrude.js +25 -11
- package/lib/point/models/image.js +0 -4
- package/lib/point/shaders/extrude/extrude_frag.glsl +19 -7
- package/lib/point/shaders/extrude/extrude_vert.glsl +23 -27
- package/package.json +7 -7
package/es/core/BaseLayer.js
CHANGED
|
@@ -126,7 +126,9 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
126
126
|
}
|
|
127
127
|
var autoRender = _this.layerSource.getSourceCfg().autoRender;
|
|
128
128
|
if (autoRender) {
|
|
129
|
-
|
|
129
|
+
setTimeout(function () {
|
|
130
|
+
_this.reRender();
|
|
131
|
+
}, 10);
|
|
130
132
|
}
|
|
131
133
|
});
|
|
132
134
|
_this.name = config.name || _this.id;
|
package/es/core/BaseModel.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerMod
|
|
|
32
32
|
protected cameraService: ICameraService;
|
|
33
33
|
protected layerService: ILayerService;
|
|
34
34
|
protected pickingService: IPickingService;
|
|
35
|
+
protected attributeUnifoms: IBuffer;
|
|
36
|
+
protected commonUnifoms: IBuffer;
|
|
35
37
|
constructor(layer: ILayer);
|
|
36
38
|
getBlend(): IBlendOptions;
|
|
37
39
|
getStencil(option: Partial<IRenderOptions>): Partial<IStencilOptions>;
|
|
@@ -58,4 +60,22 @@ export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerMod
|
|
|
58
60
|
};
|
|
59
61
|
protected registerStyleAttribute(): void;
|
|
60
62
|
updateEncodeAttribute(type: string, flag: boolean): void;
|
|
63
|
+
initUniformsBuffer(): void;
|
|
64
|
+
protected getUniformsBufferInfo(uniformsOption: {
|
|
65
|
+
[key: string]: any;
|
|
66
|
+
}): {
|
|
67
|
+
uniformsOption: {
|
|
68
|
+
[key: string]: any;
|
|
69
|
+
};
|
|
70
|
+
uniformsLength: number;
|
|
71
|
+
uniformsArray: number[];
|
|
72
|
+
};
|
|
73
|
+
protected getCommonUniformsInfo(): {
|
|
74
|
+
uniformsArray: number[];
|
|
75
|
+
uniformsLength: number;
|
|
76
|
+
uniformsOption: {
|
|
77
|
+
[key: string]: any;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
updateStyleUnifoms(): void;
|
|
61
81
|
}
|
package/es/core/BaseModel.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
1
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
3
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
4
|
import _initializerDefineProperty from "@babel/runtime/helpers/esm/initializerDefineProperty";
|
|
@@ -13,6 +14,7 @@ import { rgb2arr } from '@antv/l7-utils';
|
|
|
13
14
|
import { BlendTypes } from "../utils/blend";
|
|
14
15
|
import { getStencil as _getStencil, getStencilMask } from "../utils/stencil";
|
|
15
16
|
import { DefaultUniformStyleType, DefaultUniformStyleValue } from "./constant";
|
|
17
|
+
import { MultipleOfFourNumber } from "./utils";
|
|
16
18
|
import { getCommonStyleAttributeOptions, ShaderLocation } from "./CommonStyleAttribute";
|
|
17
19
|
var shaderLocationMap = {
|
|
18
20
|
opacity: ShaderLocation.OPACITY,
|
|
@@ -32,6 +34,9 @@ var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
32
34
|
|
|
33
35
|
// @lazyInject(TYPES.IShaderModuleService)
|
|
34
36
|
|
|
37
|
+
// 支持数据映射的buffer
|
|
38
|
+
// 不支持数据映射的buffer
|
|
39
|
+
|
|
35
40
|
// style texture data mapping
|
|
36
41
|
|
|
37
42
|
function BaseModel(layer) {
|
|
@@ -212,6 +217,8 @@ var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
212
217
|
this.layer.setAnimateStartTime();
|
|
213
218
|
}
|
|
214
219
|
}
|
|
220
|
+
|
|
221
|
+
// 动态注入参与数据映射的uniform
|
|
215
222
|
}, {
|
|
216
223
|
key: "getInject",
|
|
217
224
|
value: function getInject() {
|
|
@@ -286,6 +293,70 @@ var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
286
293
|
value: function updateEncodeAttribute(type, flag) {
|
|
287
294
|
this.encodeStyleAttribute[type] = flag;
|
|
288
295
|
}
|
|
296
|
+
}, {
|
|
297
|
+
key: "initUniformsBuffer",
|
|
298
|
+
value: function initUniformsBuffer() {
|
|
299
|
+
var attrUniforms = this.getUniformsBufferInfo(this.getStyleAttribute());
|
|
300
|
+
var commonUniforms = this.getCommonUniformsInfo();
|
|
301
|
+
this.attributeUnifoms = this.rendererService.createBuffer({
|
|
302
|
+
data: new Float32Array(MultipleOfFourNumber(attrUniforms.uniformsLength)),
|
|
303
|
+
// 长度需要大于等于 4
|
|
304
|
+
isUBO: true
|
|
305
|
+
});
|
|
306
|
+
this.commonUnifoms = this.rendererService.createBuffer({
|
|
307
|
+
data: new Float32Array(MultipleOfFourNumber(commonUniforms.uniformsLength)),
|
|
308
|
+
isUBO: true
|
|
309
|
+
});
|
|
310
|
+
this.uniformBuffers = [this.attributeUnifoms, this.commonUnifoms];
|
|
311
|
+
}
|
|
312
|
+
// 获取数据映射 uniform 信息
|
|
313
|
+
}, {
|
|
314
|
+
key: "getUniformsBufferInfo",
|
|
315
|
+
value: function getUniformsBufferInfo(uniformsOption) {
|
|
316
|
+
var uniformsLength = 0;
|
|
317
|
+
var uniformsArray = [];
|
|
318
|
+
Object.values(uniformsOption).forEach(function (value) {
|
|
319
|
+
if (Array.isArray(value)) {
|
|
320
|
+
uniformsArray.push.apply(uniformsArray, _toConsumableArray(value));
|
|
321
|
+
uniformsLength += value.length;
|
|
322
|
+
} else {
|
|
323
|
+
uniformsArray.push(value);
|
|
324
|
+
uniformsLength += 1;
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
return {
|
|
328
|
+
uniformsOption: uniformsOption,
|
|
329
|
+
uniformsLength: uniformsLength,
|
|
330
|
+
uniformsArray: uniformsArray
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
}, {
|
|
334
|
+
key: "getCommonUniformsInfo",
|
|
335
|
+
value: function getCommonUniformsInfo() {
|
|
336
|
+
return {
|
|
337
|
+
uniformsLength: 0,
|
|
338
|
+
uniformsArray: [],
|
|
339
|
+
uniformsOption: {}
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// 更新支持数据映射的uniform
|
|
344
|
+
}, {
|
|
345
|
+
key: "updateStyleUnifoms",
|
|
346
|
+
value: function updateStyleUnifoms() {
|
|
347
|
+
var _this$getUniformsBuff = this.getUniformsBufferInfo(this.getStyleAttribute()),
|
|
348
|
+
uniformsArray = _this$getUniformsBuff.uniformsArray;
|
|
349
|
+
var _this$getCommonUnifor = this.getCommonUniformsInfo(),
|
|
350
|
+
commonUniformsArray = _this$getCommonUnifor.uniformsArray;
|
|
351
|
+
this.attributeUnifoms.subData({
|
|
352
|
+
offset: 0,
|
|
353
|
+
data: new Uint8Array(new Float32Array(uniformsArray).buffer)
|
|
354
|
+
});
|
|
355
|
+
this.commonUnifoms.subData({
|
|
356
|
+
offset: 0,
|
|
357
|
+
data: new Uint8Array(new Float32Array(commonUniformsArray).buffer)
|
|
358
|
+
});
|
|
359
|
+
}
|
|
289
360
|
}]);
|
|
290
361
|
return BaseModel;
|
|
291
362
|
}(), (_descriptor = _applyDecoratedDescriptor(_class.prototype, "configService", [_dec], {
|
|
@@ -13,6 +13,7 @@ export var ShaderLocation = /*#__PURE__*/function (ShaderLocation) {
|
|
|
13
13
|
ShaderLocation[ShaderLocation["SHAPE"] = 10] = "SHAPE";
|
|
14
14
|
ShaderLocation[ShaderLocation["EXTRUDE"] = 11] = "EXTRUDE";
|
|
15
15
|
ShaderLocation[ShaderLocation["MAX"] = 12] = "MAX";
|
|
16
|
+
ShaderLocation[ShaderLocation["NORMAL"] = 13] = "NORMAL";
|
|
16
17
|
return ShaderLocation;
|
|
17
18
|
}({});
|
|
18
19
|
export function getCommonStyleAttributeOptions(name) {
|
package/es/core/utils.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function formatUniformsOption2Std140(uniformsOption) {
|
|
2
|
+
var std140_str = '';
|
|
3
|
+
Object.keys(uniformsOption).forEach(function (key) {
|
|
4
|
+
var value = uniformsOption[key];
|
|
5
|
+
if (Array.isArray(value)) {
|
|
6
|
+
std140_str += "vec".concat(value.length, " ").concat(key, ";\n");
|
|
7
|
+
} else {
|
|
8
|
+
std140_str += "flot ".concat(key, ";\n");
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
return std140_str;
|
|
12
|
+
}
|
|
13
|
+
export function MultipleOfFourNumber(num) {
|
|
14
|
+
return Math.ceil(num / 4) * 4;
|
|
15
|
+
}
|
|
@@ -146,25 +146,29 @@ var GreatCircleModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
146
146
|
key: "buildModels",
|
|
147
147
|
value: function () {
|
|
148
148
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
149
|
-
var model;
|
|
149
|
+
var _ref3, _ref3$segmentNumber, segmentNumber, model;
|
|
150
150
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
151
151
|
while (1) switch (_context2.prev = _context2.next) {
|
|
152
152
|
case 0:
|
|
153
|
-
|
|
153
|
+
_ref3 = this.layer.getLayerConfig(), _ref3$segmentNumber = _ref3.segmentNumber, segmentNumber = _ref3$segmentNumber === void 0 ? 30 : _ref3$segmentNumber;
|
|
154
|
+
_context2.next = 3;
|
|
154
155
|
return this.layer.buildLayerModel({
|
|
155
156
|
moduleName: 'lineGreatCircle',
|
|
156
157
|
vertexShader: line_arc2d_vert,
|
|
157
158
|
fragmentShader: line_arc_frag,
|
|
158
159
|
triangulation: LineArcTriangulation,
|
|
160
|
+
styleOption: {
|
|
161
|
+
segmentNumber: segmentNumber
|
|
162
|
+
},
|
|
159
163
|
inject: this.getInject(),
|
|
160
164
|
depth: {
|
|
161
165
|
enable: false
|
|
162
166
|
}
|
|
163
167
|
});
|
|
164
|
-
case
|
|
168
|
+
case 3:
|
|
165
169
|
model = _context2.sent;
|
|
166
170
|
return _context2.abrupt("return", [model]);
|
|
167
|
-
case
|
|
171
|
+
case 5:
|
|
168
172
|
case "end":
|
|
169
173
|
return _context2.stop();
|
|
170
174
|
}
|
|
@@ -231,12 +235,12 @@ var GreatCircleModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
231
235
|
var iconMap = _this2.iconService.getIconMap();
|
|
232
236
|
var texture = feature.texture;
|
|
233
237
|
// console.log('icon feature', feature)
|
|
234
|
-
var
|
|
238
|
+
var _ref4 = iconMap[texture] || {
|
|
235
239
|
x: 0,
|
|
236
240
|
y: 0
|
|
237
241
|
},
|
|
238
|
-
x =
|
|
239
|
-
y =
|
|
242
|
+
x = _ref4.x,
|
|
243
|
+
y = _ref4.y;
|
|
240
244
|
return [x, y];
|
|
241
245
|
}
|
|
242
246
|
}
|
|
@@ -4,16 +4,14 @@ export default class ExtrudeModel extends BaseModel {
|
|
|
4
4
|
private raiseCount;
|
|
5
5
|
private raiseRepeat;
|
|
6
6
|
getUninforms(): {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
u_opacitylinear_dir: number;
|
|
16
|
-
u_lightEnable: number;
|
|
7
|
+
[x: string]: any;
|
|
8
|
+
};
|
|
9
|
+
protected getCommonUniformsInfo(): {
|
|
10
|
+
uniformsArray: number[];
|
|
11
|
+
uniformsLength: number;
|
|
12
|
+
uniformsOption: {
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
};
|
|
17
15
|
};
|
|
18
16
|
initModels(): Promise<IModel[]>;
|
|
19
17
|
buildModels(): Promise<IModel[]>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
3
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
4
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
5
|
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
@@ -14,9 +15,10 @@ import { calculateCentroid, getCullFace, rgb2arr } from '@antv/l7-utils';
|
|
|
14
15
|
import BaseModel from "../../core/BaseModel";
|
|
15
16
|
import { PointExtrudeTriangulation } from "../../core/triangulation";
|
|
16
17
|
/* babel-plugin-inline-import '../shaders/extrude/extrude_frag.glsl' */
|
|
17
|
-
var pointExtrudeFrag = "
|
|
18
|
+
var pointExtrudeFrag = "in vec4 v_color;\nin float v_lightWeight;\nout vec4 outputColor;\n\n\nlayout(std140) uniform commonUniforms {\n float u_pickLight;\n float u_heightfixed;\n float u_r;\n float u_linearColor;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_opacitylinear;\n float u_opacitylinear_dir;\n float u_lightEnable;\n};\n\n#pragma include \"picking\"\n\nvoid main() {\n\n outputColor = v_color;\n // \u5F00\u542F\u900F\u660E\u5EA6\u6E10\u53D8\n // picking\n if(u_pickLight > 0.0) {\n outputColor = filterColorAlpha(outputColor, v_lightWeight);\n } else {\n outputColor = filterColor(outputColor);\n }\n}\n";
|
|
18
19
|
/* babel-plugin-inline-import '../shaders/extrude/extrude_vert.glsl' */
|
|
19
|
-
var pointExtrudeVert = "
|
|
20
|
+
var pointExtrudeVert = "#define pi 3.1415926535\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in vec3 a_Size;\nlayout(location = 11) in vec3 a_Extrude;\nlayout(location = 13) in vec3 a_Normal;\n\nlayout(std140) uniform commonUniforms {\n float u_pickLight;\n float u_heightfixed;\n float u_r;\n float u_linearColor;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_opacitylinear;\n float u_opacitylinear_dir;\n float u_lightEnable;\n};\nout vec4 v_color;\nout float v_lightWeight;\nout float v_barLinearZ;\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\n vec3 size = a_Size * a_Position;\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\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_Extrude.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\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\n v_lightWeight = lightWeight;\n\n v_color = a_Color;\n\n // \u8BBE\u7F6E\u5706\u67F1\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n v_color = mix(u_sourceColor, u_targetColor, a_Position.z);\n v_color.a = v_color.a * opacity;\n } else {\n v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);\n }\n\n if(u_opacitylinear > 0.0) {\n v_color.a *= u_opacitylinear_dir > 0.0 ? (1.0 - a_Position.z): a_Position.z;\n }\n\n\n gl_Position = project_common_position_to_clipspace_v2(pos);\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
21
|
+
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
20
22
|
var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
21
23
|
_inherits(ExtrudeModel, _BaseModel);
|
|
22
24
|
var _super = _createSuper(ExtrudeModel);
|
|
@@ -34,6 +36,14 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
34
36
|
_createClass(ExtrudeModel, [{
|
|
35
37
|
key: "getUninforms",
|
|
36
38
|
value: function getUninforms() {
|
|
39
|
+
var commoninfo = this.getCommonUniformsInfo();
|
|
40
|
+
var attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
|
|
41
|
+
this.updateStyleUnifoms();
|
|
42
|
+
return _objectSpread(_objectSpread({}, commoninfo.uniformsOption), attributeInfo.uniformsOption);
|
|
43
|
+
}
|
|
44
|
+
}, {
|
|
45
|
+
key: "getCommonUniformsInfo",
|
|
46
|
+
value: function getCommonUniformsInfo() {
|
|
37
47
|
var _ref = this.layer.getLayerConfig(),
|
|
38
48
|
_ref$animateOption = _ref.animateOption,
|
|
39
49
|
animateOption = _ref$animateOption === void 0 ? {
|
|
@@ -41,8 +51,6 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
41
51
|
speed: 0.01,
|
|
42
52
|
repeat: false
|
|
43
53
|
} : _ref$animateOption,
|
|
44
|
-
_ref$opacity = _ref.opacity,
|
|
45
|
-
opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
|
|
46
54
|
sourceColor = _ref.sourceColor,
|
|
47
55
|
targetColor = _ref.targetColor,
|
|
48
56
|
_ref$pickLight = _ref.pickLight,
|
|
@@ -81,13 +89,12 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
81
89
|
}
|
|
82
90
|
}
|
|
83
91
|
}
|
|
84
|
-
|
|
92
|
+
var commonOptions = {
|
|
85
93
|
// 圆柱体的拾取高亮是否要计算光照
|
|
86
94
|
u_pickLight: Number(pickLight),
|
|
87
95
|
// 圆柱体是否固定高度
|
|
88
96
|
u_heightfixed: Number(heightfixed),
|
|
89
97
|
u_r: animateOption.enable && this.raiseRepeat > 0 ? this.raiseCount : 1.0,
|
|
90
|
-
u_opacity: opacity,
|
|
91
98
|
// 渐变色支持参数
|
|
92
99
|
u_linearColor: useLinearColor,
|
|
93
100
|
u_sourceColor: sourceColorArr,
|
|
@@ -98,6 +105,8 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
98
105
|
// 光照计算开关
|
|
99
106
|
u_lightEnable: Number(lightEnable)
|
|
100
107
|
};
|
|
108
|
+
var commonBufferInfo = this.getUniformsBufferInfo(commonOptions);
|
|
109
|
+
return commonBufferInfo;
|
|
101
110
|
}
|
|
102
111
|
}, {
|
|
103
112
|
key: "initModels",
|
|
@@ -129,12 +138,14 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
129
138
|
// GAODE1.x GAODE2.x MAPBOX
|
|
130
139
|
_ref2 = this.layer.getLayerConfig(), _ref2$depth = _ref2.depth, depth = _ref2$depth === void 0 ? true : _ref2$depth, _ref2$animateOption$r = _ref2.animateOption.repeat, repeat = _ref2$animateOption$r === void 0 ? 1 : _ref2$animateOption$r;
|
|
131
140
|
this.raiseRepeat = repeat;
|
|
132
|
-
|
|
141
|
+
this.initUniformsBuffer();
|
|
142
|
+
_context2.next = 5;
|
|
133
143
|
return this.layer.buildLayerModel({
|
|
134
144
|
moduleName: 'pointExtrude',
|
|
135
145
|
vertexShader: pointExtrudeVert,
|
|
136
146
|
fragmentShader: pointExtrudeFrag,
|
|
137
147
|
triangulation: PointExtrudeTriangulation,
|
|
148
|
+
inject: this.getInject(),
|
|
138
149
|
cull: {
|
|
139
150
|
enable: true,
|
|
140
151
|
face: getCullFace(this.mapService.version)
|
|
@@ -143,10 +154,10 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
143
154
|
enable: depth
|
|
144
155
|
}
|
|
145
156
|
});
|
|
146
|
-
case
|
|
157
|
+
case 5:
|
|
147
158
|
model = _context2.sent;
|
|
148
159
|
return _context2.abrupt("return", [model]);
|
|
149
|
-
case
|
|
160
|
+
case 7:
|
|
150
161
|
case "end":
|
|
151
162
|
return _context2.stop();
|
|
152
163
|
}
|
|
@@ -166,6 +177,7 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
166
177
|
type: AttributeType.Attribute,
|
|
167
178
|
descriptor: {
|
|
168
179
|
name: 'a_Size',
|
|
180
|
+
shaderLocation: ShaderLocation.SIZE,
|
|
169
181
|
buffer: {
|
|
170
182
|
usage: gl.DYNAMIC_DRAW,
|
|
171
183
|
data: [],
|
|
@@ -196,6 +208,7 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
196
208
|
type: AttributeType.Attribute,
|
|
197
209
|
descriptor: {
|
|
198
210
|
name: 'a_Normal',
|
|
211
|
+
shaderLocation: ShaderLocation.NORMAL,
|
|
199
212
|
buffer: {
|
|
200
213
|
// give the WebGL driver a hint that this buffer may change
|
|
201
214
|
usage: gl.STATIC_DRAW,
|
|
@@ -209,10 +222,11 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
209
222
|
}
|
|
210
223
|
});
|
|
211
224
|
this.styleAttributeService.registerStyleAttribute({
|
|
212
|
-
name: '
|
|
225
|
+
name: 'extrude',
|
|
213
226
|
type: AttributeType.Attribute,
|
|
214
227
|
descriptor: {
|
|
215
|
-
name: '
|
|
228
|
+
name: 'a_Extrude',
|
|
229
|
+
shaderLocation: ShaderLocation.EXTRUDE,
|
|
216
230
|
buffer: {
|
|
217
231
|
// give the WebGL driver a hint that this buffer may change
|
|
218
232
|
usage: gl.DYNAMIC_DRAW,
|
package/es/point/models/image.js
CHANGED
|
@@ -60,10 +60,6 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
60
60
|
key: "getUninforms",
|
|
61
61
|
value: function getUninforms() {
|
|
62
62
|
var _ref = this.layer.getLayerConfig(),
|
|
63
|
-
_ref$opacity = _ref.opacity,
|
|
64
|
-
opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
|
|
65
|
-
_ref$offsets = _ref.offsets,
|
|
66
|
-
offsets = _ref$offsets === void 0 ? [0, 0] : _ref$offsets,
|
|
67
63
|
_ref$raisingHeight = _ref.raisingHeight,
|
|
68
64
|
raisingHeight = _ref$raisingHeight === void 0 ? 0 : _ref$raisingHeight,
|
|
69
65
|
_ref$heightfixed = _ref.heightfixed,
|
|
@@ -1,18 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
in vec4 v_color;
|
|
2
|
+
in float v_lightWeight;
|
|
3
|
+
out vec4 outputColor;
|
|
4
4
|
|
|
5
|
-
#pragma include "picking"
|
|
6
5
|
|
|
6
|
+
layout(std140) uniform commonUniforms {
|
|
7
|
+
float u_pickLight;
|
|
8
|
+
float u_heightfixed;
|
|
9
|
+
float u_r;
|
|
10
|
+
float u_linearColor;
|
|
11
|
+
vec4 u_sourceColor;
|
|
12
|
+
vec4 u_targetColor;
|
|
13
|
+
float u_opacitylinear;
|
|
14
|
+
float u_opacitylinear_dir;
|
|
15
|
+
float u_lightEnable;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
#pragma include "picking"
|
|
7
19
|
|
|
8
20
|
void main() {
|
|
9
21
|
|
|
10
|
-
|
|
22
|
+
outputColor = v_color;
|
|
11
23
|
// 开启透明度渐变
|
|
12
24
|
// picking
|
|
13
25
|
if(u_pickLight > 0.0) {
|
|
14
|
-
|
|
26
|
+
outputColor = filterColorAlpha(outputColor, v_lightWeight);
|
|
15
27
|
} else {
|
|
16
|
-
|
|
28
|
+
outputColor = filterColor(outputColor);
|
|
17
29
|
}
|
|
18
30
|
}
|
|
@@ -1,32 +1,28 @@
|
|
|
1
|
-
precision highp float;
|
|
2
|
-
|
|
3
1
|
#define pi 3.1415926535
|
|
4
2
|
#define ambientRatio 0.5
|
|
5
3
|
#define diffuseRatio 0.3
|
|
6
4
|
#define specularRatio 0.2
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
uniform
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
uniform float u_linearColor: 0.0;
|
|
29
|
-
|
|
6
|
+
layout(location = 0) in vec3 a_Position;
|
|
7
|
+
layout(location = 1) in vec4 a_Color;
|
|
8
|
+
layout(location = 9) in vec3 a_Size;
|
|
9
|
+
layout(location = 11) in vec3 a_Extrude;
|
|
10
|
+
layout(location = 13) in vec3 a_Normal;
|
|
11
|
+
|
|
12
|
+
layout(std140) uniform commonUniforms {
|
|
13
|
+
float u_pickLight;
|
|
14
|
+
float u_heightfixed;
|
|
15
|
+
float u_r;
|
|
16
|
+
float u_linearColor;
|
|
17
|
+
vec4 u_sourceColor;
|
|
18
|
+
vec4 u_targetColor;
|
|
19
|
+
float u_opacitylinear;
|
|
20
|
+
float u_opacitylinear_dir;
|
|
21
|
+
float u_lightEnable;
|
|
22
|
+
};
|
|
23
|
+
out vec4 v_color;
|
|
24
|
+
out float v_lightWeight;
|
|
25
|
+
out float v_barLinearZ;
|
|
30
26
|
|
|
31
27
|
#pragma include "projection"
|
|
32
28
|
#pragma include "light"
|
|
@@ -72,7 +68,7 @@ void main() {
|
|
|
72
68
|
}
|
|
73
69
|
|
|
74
70
|
|
|
75
|
-
vec4 project_pos = project_position(vec4(
|
|
71
|
+
vec4 project_pos = project_position(vec4(a_Extrude.xy, 0., 1.0));
|
|
76
72
|
|
|
77
73
|
// u_r 控制圆柱的生长
|
|
78
74
|
vec4 pos = vec4(project_pos.xy + offset.xy, offset.z * u_r, 1.0);
|
|
@@ -91,9 +87,9 @@ void main() {
|
|
|
91
87
|
// 设置圆柱的底色
|
|
92
88
|
if(u_linearColor == 1.0) { // 使用渐变颜色
|
|
93
89
|
v_color = mix(u_sourceColor, u_targetColor, a_Position.z);
|
|
94
|
-
v_color.a = v_color.a *
|
|
90
|
+
v_color.a = v_color.a * opacity;
|
|
95
91
|
} else {
|
|
96
|
-
v_color = vec4(a_Color.rgb * lightWeight, a_Color.w *
|
|
92
|
+
v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);
|
|
97
93
|
}
|
|
98
94
|
|
|
99
95
|
if(u_opacitylinear > 0.0) {
|
package/lib/core/BaseLayer.js
CHANGED
|
@@ -132,7 +132,9 @@ var BaseLayer = exports.default = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.
|
|
|
132
132
|
}
|
|
133
133
|
var autoRender = _this.layerSource.getSourceCfg().autoRender;
|
|
134
134
|
if (autoRender) {
|
|
135
|
-
|
|
135
|
+
setTimeout(function () {
|
|
136
|
+
_this.reRender();
|
|
137
|
+
}, 10);
|
|
136
138
|
}
|
|
137
139
|
});
|
|
138
140
|
_this.name = config.name || _this.id;
|
package/lib/core/BaseModel.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
11
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
12
|
var _initializerDefineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/initializerDefineProperty"));
|
|
@@ -19,6 +20,7 @@ var _l7Utils = require("@antv/l7-utils");
|
|
|
19
20
|
var _blend = require("../utils/blend");
|
|
20
21
|
var _stencil = require("../utils/stencil");
|
|
21
22
|
var _constant = require("./constant");
|
|
23
|
+
var _utils = require("./utils");
|
|
22
24
|
var _CommonStyleAttribute = require("./CommonStyleAttribute");
|
|
23
25
|
var _dec, _class, _descriptor;
|
|
24
26
|
var shaderLocationMap = {
|
|
@@ -39,6 +41,9 @@ var BaseModel = exports.default = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.
|
|
|
39
41
|
|
|
40
42
|
// @lazyInject(TYPES.IShaderModuleService)
|
|
41
43
|
|
|
44
|
+
// 支持数据映射的buffer
|
|
45
|
+
// 不支持数据映射的buffer
|
|
46
|
+
|
|
42
47
|
// style texture data mapping
|
|
43
48
|
|
|
44
49
|
function BaseModel(layer) {
|
|
@@ -219,6 +224,8 @@ var BaseModel = exports.default = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.
|
|
|
219
224
|
this.layer.setAnimateStartTime();
|
|
220
225
|
}
|
|
221
226
|
}
|
|
227
|
+
|
|
228
|
+
// 动态注入参与数据映射的uniform
|
|
222
229
|
}, {
|
|
223
230
|
key: "getInject",
|
|
224
231
|
value: function getInject() {
|
|
@@ -293,6 +300,70 @@ var BaseModel = exports.default = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.
|
|
|
293
300
|
value: function updateEncodeAttribute(type, flag) {
|
|
294
301
|
this.encodeStyleAttribute[type] = flag;
|
|
295
302
|
}
|
|
303
|
+
}, {
|
|
304
|
+
key: "initUniformsBuffer",
|
|
305
|
+
value: function initUniformsBuffer() {
|
|
306
|
+
var attrUniforms = this.getUniformsBufferInfo(this.getStyleAttribute());
|
|
307
|
+
var commonUniforms = this.getCommonUniformsInfo();
|
|
308
|
+
this.attributeUnifoms = this.rendererService.createBuffer({
|
|
309
|
+
data: new Float32Array((0, _utils.MultipleOfFourNumber)(attrUniforms.uniformsLength)),
|
|
310
|
+
// 长度需要大于等于 4
|
|
311
|
+
isUBO: true
|
|
312
|
+
});
|
|
313
|
+
this.commonUnifoms = this.rendererService.createBuffer({
|
|
314
|
+
data: new Float32Array((0, _utils.MultipleOfFourNumber)(commonUniforms.uniformsLength)),
|
|
315
|
+
isUBO: true
|
|
316
|
+
});
|
|
317
|
+
this.uniformBuffers = [this.attributeUnifoms, this.commonUnifoms];
|
|
318
|
+
}
|
|
319
|
+
// 获取数据映射 uniform 信息
|
|
320
|
+
}, {
|
|
321
|
+
key: "getUniformsBufferInfo",
|
|
322
|
+
value: function getUniformsBufferInfo(uniformsOption) {
|
|
323
|
+
var uniformsLength = 0;
|
|
324
|
+
var uniformsArray = [];
|
|
325
|
+
Object.values(uniformsOption).forEach(function (value) {
|
|
326
|
+
if (Array.isArray(value)) {
|
|
327
|
+
uniformsArray.push.apply(uniformsArray, (0, _toConsumableArray2.default)(value));
|
|
328
|
+
uniformsLength += value.length;
|
|
329
|
+
} else {
|
|
330
|
+
uniformsArray.push(value);
|
|
331
|
+
uniformsLength += 1;
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
return {
|
|
335
|
+
uniformsOption: uniformsOption,
|
|
336
|
+
uniformsLength: uniformsLength,
|
|
337
|
+
uniformsArray: uniformsArray
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
}, {
|
|
341
|
+
key: "getCommonUniformsInfo",
|
|
342
|
+
value: function getCommonUniformsInfo() {
|
|
343
|
+
return {
|
|
344
|
+
uniformsLength: 0,
|
|
345
|
+
uniformsArray: [],
|
|
346
|
+
uniformsOption: {}
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// 更新支持数据映射的uniform
|
|
351
|
+
}, {
|
|
352
|
+
key: "updateStyleUnifoms",
|
|
353
|
+
value: function updateStyleUnifoms() {
|
|
354
|
+
var _this$getUniformsBuff = this.getUniformsBufferInfo(this.getStyleAttribute()),
|
|
355
|
+
uniformsArray = _this$getUniformsBuff.uniformsArray;
|
|
356
|
+
var _this$getCommonUnifor = this.getCommonUniformsInfo(),
|
|
357
|
+
commonUniformsArray = _this$getCommonUnifor.uniformsArray;
|
|
358
|
+
this.attributeUnifoms.subData({
|
|
359
|
+
offset: 0,
|
|
360
|
+
data: new Uint8Array(new Float32Array(uniformsArray).buffer)
|
|
361
|
+
});
|
|
362
|
+
this.commonUnifoms.subData({
|
|
363
|
+
offset: 0,
|
|
364
|
+
data: new Uint8Array(new Float32Array(commonUniformsArray).buffer)
|
|
365
|
+
});
|
|
366
|
+
}
|
|
296
367
|
}]);
|
|
297
368
|
return BaseModel;
|
|
298
369
|
}(), (_descriptor = (0, _applyDecoratedDescriptor2.default)(_class.prototype, "configService", [_dec], {
|
|
@@ -20,6 +20,7 @@ var ShaderLocation = exports.ShaderLocation = /*#__PURE__*/function (ShaderLocat
|
|
|
20
20
|
ShaderLocation[ShaderLocation["SHAPE"] = 10] = "SHAPE";
|
|
21
21
|
ShaderLocation[ShaderLocation["EXTRUDE"] = 11] = "EXTRUDE";
|
|
22
22
|
ShaderLocation[ShaderLocation["MAX"] = 12] = "MAX";
|
|
23
|
+
ShaderLocation[ShaderLocation["NORMAL"] = 13] = "NORMAL";
|
|
23
24
|
return ShaderLocation;
|
|
24
25
|
}({});
|
|
25
26
|
function getCommonStyleAttributeOptions(name) {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MultipleOfFourNumber = MultipleOfFourNumber;
|
|
7
|
+
exports.formatUniformsOption2Std140 = formatUniformsOption2Std140;
|
|
8
|
+
function formatUniformsOption2Std140(uniformsOption) {
|
|
9
|
+
var std140_str = '';
|
|
10
|
+
Object.keys(uniformsOption).forEach(function (key) {
|
|
11
|
+
var value = uniformsOption[key];
|
|
12
|
+
if (Array.isArray(value)) {
|
|
13
|
+
std140_str += "vec".concat(value.length, " ").concat(key, ";\n");
|
|
14
|
+
} else {
|
|
15
|
+
std140_str += "flot ".concat(key, ";\n");
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return std140_str;
|
|
19
|
+
}
|
|
20
|
+
function MultipleOfFourNumber(num) {
|
|
21
|
+
return Math.ceil(num / 4) * 4;
|
|
22
|
+
}
|
|
@@ -153,25 +153,29 @@ var GreatCircleModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
153
153
|
key: "buildModels",
|
|
154
154
|
value: function () {
|
|
155
155
|
var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
156
|
-
var model;
|
|
156
|
+
var _ref3, _ref3$segmentNumber, segmentNumber, model;
|
|
157
157
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
158
158
|
while (1) switch (_context2.prev = _context2.next) {
|
|
159
159
|
case 0:
|
|
160
|
-
|
|
160
|
+
_ref3 = this.layer.getLayerConfig(), _ref3$segmentNumber = _ref3.segmentNumber, segmentNumber = _ref3$segmentNumber === void 0 ? 30 : _ref3$segmentNumber;
|
|
161
|
+
_context2.next = 3;
|
|
161
162
|
return this.layer.buildLayerModel({
|
|
162
163
|
moduleName: 'lineGreatCircle',
|
|
163
164
|
vertexShader: line_arc2d_vert,
|
|
164
165
|
fragmentShader: line_arc_frag,
|
|
165
166
|
triangulation: _triangulation.LineArcTriangulation,
|
|
167
|
+
styleOption: {
|
|
168
|
+
segmentNumber: segmentNumber
|
|
169
|
+
},
|
|
166
170
|
inject: this.getInject(),
|
|
167
171
|
depth: {
|
|
168
172
|
enable: false
|
|
169
173
|
}
|
|
170
174
|
});
|
|
171
|
-
case
|
|
175
|
+
case 3:
|
|
172
176
|
model = _context2.sent;
|
|
173
177
|
return _context2.abrupt("return", [model]);
|
|
174
|
-
case
|
|
178
|
+
case 5:
|
|
175
179
|
case "end":
|
|
176
180
|
return _context2.stop();
|
|
177
181
|
}
|
|
@@ -238,12 +242,12 @@ var GreatCircleModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
238
242
|
var iconMap = _this2.iconService.getIconMap();
|
|
239
243
|
var texture = feature.texture;
|
|
240
244
|
// console.log('icon feature', feature)
|
|
241
|
-
var
|
|
245
|
+
var _ref4 = iconMap[texture] || {
|
|
242
246
|
x: 0,
|
|
243
247
|
y: 0
|
|
244
248
|
},
|
|
245
|
-
x =
|
|
246
|
-
y =
|
|
249
|
+
x = _ref4.x,
|
|
250
|
+
y = _ref4.y;
|
|
247
251
|
return [x, y];
|
|
248
252
|
}
|
|
249
253
|
}
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
11
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
12
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
13
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
@@ -18,12 +19,13 @@ var _l7Core = require("@antv/l7-core");
|
|
|
18
19
|
var _l7Utils = require("@antv/l7-utils");
|
|
19
20
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
20
21
|
var _triangulation = require("../../core/triangulation");
|
|
22
|
+
var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
21
23
|
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); }; }
|
|
22
24
|
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; } }
|
|
23
25
|
/* babel-plugin-inline-import '../shaders/extrude/extrude_frag.glsl' */
|
|
24
|
-
var pointExtrudeFrag = "
|
|
26
|
+
var pointExtrudeFrag = "in vec4 v_color;\nin float v_lightWeight;\nout vec4 outputColor;\n\n\nlayout(std140) uniform commonUniforms {\n float u_pickLight;\n float u_heightfixed;\n float u_r;\n float u_linearColor;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_opacitylinear;\n float u_opacitylinear_dir;\n float u_lightEnable;\n};\n\n#pragma include \"picking\"\n\nvoid main() {\n\n outputColor = v_color;\n // \u5F00\u542F\u900F\u660E\u5EA6\u6E10\u53D8\n // picking\n if(u_pickLight > 0.0) {\n outputColor = filterColorAlpha(outputColor, v_lightWeight);\n } else {\n outputColor = filterColor(outputColor);\n }\n}\n";
|
|
25
27
|
/* babel-plugin-inline-import '../shaders/extrude/extrude_vert.glsl' */
|
|
26
|
-
var pointExtrudeVert = "
|
|
28
|
+
var pointExtrudeVert = "#define pi 3.1415926535\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in vec3 a_Size;\nlayout(location = 11) in vec3 a_Extrude;\nlayout(location = 13) in vec3 a_Normal;\n\nlayout(std140) uniform commonUniforms {\n float u_pickLight;\n float u_heightfixed;\n float u_r;\n float u_linearColor;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_opacitylinear;\n float u_opacitylinear_dir;\n float u_lightEnable;\n};\nout vec4 v_color;\nout float v_lightWeight;\nout float v_barLinearZ;\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\n vec3 size = a_Size * a_Position;\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\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_Extrude.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\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\n v_lightWeight = lightWeight;\n\n v_color = a_Color;\n\n // \u8BBE\u7F6E\u5706\u67F1\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n v_color = mix(u_sourceColor, u_targetColor, a_Position.z);\n v_color.a = v_color.a * opacity;\n } else {\n v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);\n }\n\n if(u_opacitylinear > 0.0) {\n v_color.a *= u_opacitylinear_dir > 0.0 ? (1.0 - a_Position.z): a_Position.z;\n }\n\n\n gl_Position = project_common_position_to_clipspace_v2(pos);\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
27
29
|
var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
28
30
|
(0, _inherits2.default)(ExtrudeModel, _BaseModel);
|
|
29
31
|
var _super = _createSuper(ExtrudeModel);
|
|
@@ -41,6 +43,14 @@ var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
41
43
|
(0, _createClass2.default)(ExtrudeModel, [{
|
|
42
44
|
key: "getUninforms",
|
|
43
45
|
value: function getUninforms() {
|
|
46
|
+
var commoninfo = this.getCommonUniformsInfo();
|
|
47
|
+
var attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
|
|
48
|
+
this.updateStyleUnifoms();
|
|
49
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, commoninfo.uniformsOption), attributeInfo.uniformsOption);
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
key: "getCommonUniformsInfo",
|
|
53
|
+
value: function getCommonUniformsInfo() {
|
|
44
54
|
var _ref = this.layer.getLayerConfig(),
|
|
45
55
|
_ref$animateOption = _ref.animateOption,
|
|
46
56
|
animateOption = _ref$animateOption === void 0 ? {
|
|
@@ -48,8 +58,6 @@ var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
48
58
|
speed: 0.01,
|
|
49
59
|
repeat: false
|
|
50
60
|
} : _ref$animateOption,
|
|
51
|
-
_ref$opacity = _ref.opacity,
|
|
52
|
-
opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
|
|
53
61
|
sourceColor = _ref.sourceColor,
|
|
54
62
|
targetColor = _ref.targetColor,
|
|
55
63
|
_ref$pickLight = _ref.pickLight,
|
|
@@ -88,13 +96,12 @@ var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
88
96
|
}
|
|
89
97
|
}
|
|
90
98
|
}
|
|
91
|
-
|
|
99
|
+
var commonOptions = {
|
|
92
100
|
// 圆柱体的拾取高亮是否要计算光照
|
|
93
101
|
u_pickLight: Number(pickLight),
|
|
94
102
|
// 圆柱体是否固定高度
|
|
95
103
|
u_heightfixed: Number(heightfixed),
|
|
96
104
|
u_r: animateOption.enable && this.raiseRepeat > 0 ? this.raiseCount : 1.0,
|
|
97
|
-
u_opacity: opacity,
|
|
98
105
|
// 渐变色支持参数
|
|
99
106
|
u_linearColor: useLinearColor,
|
|
100
107
|
u_sourceColor: sourceColorArr,
|
|
@@ -105,6 +112,8 @@ var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
105
112
|
// 光照计算开关
|
|
106
113
|
u_lightEnable: Number(lightEnable)
|
|
107
114
|
};
|
|
115
|
+
var commonBufferInfo = this.getUniformsBufferInfo(commonOptions);
|
|
116
|
+
return commonBufferInfo;
|
|
108
117
|
}
|
|
109
118
|
}, {
|
|
110
119
|
key: "initModels",
|
|
@@ -136,12 +145,14 @@ var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
136
145
|
// GAODE1.x GAODE2.x MAPBOX
|
|
137
146
|
_ref2 = this.layer.getLayerConfig(), _ref2$depth = _ref2.depth, depth = _ref2$depth === void 0 ? true : _ref2$depth, _ref2$animateOption$r = _ref2.animateOption.repeat, repeat = _ref2$animateOption$r === void 0 ? 1 : _ref2$animateOption$r;
|
|
138
147
|
this.raiseRepeat = repeat;
|
|
139
|
-
|
|
148
|
+
this.initUniformsBuffer();
|
|
149
|
+
_context2.next = 5;
|
|
140
150
|
return this.layer.buildLayerModel({
|
|
141
151
|
moduleName: 'pointExtrude',
|
|
142
152
|
vertexShader: pointExtrudeVert,
|
|
143
153
|
fragmentShader: pointExtrudeFrag,
|
|
144
154
|
triangulation: _triangulation.PointExtrudeTriangulation,
|
|
155
|
+
inject: this.getInject(),
|
|
145
156
|
cull: {
|
|
146
157
|
enable: true,
|
|
147
158
|
face: (0, _l7Utils.getCullFace)(this.mapService.version)
|
|
@@ -150,10 +161,10 @@ var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
150
161
|
enable: depth
|
|
151
162
|
}
|
|
152
163
|
});
|
|
153
|
-
case
|
|
164
|
+
case 5:
|
|
154
165
|
model = _context2.sent;
|
|
155
166
|
return _context2.abrupt("return", [model]);
|
|
156
|
-
case
|
|
167
|
+
case 7:
|
|
157
168
|
case "end":
|
|
158
169
|
return _context2.stop();
|
|
159
170
|
}
|
|
@@ -173,6 +184,7 @@ var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
173
184
|
type: _l7Core.AttributeType.Attribute,
|
|
174
185
|
descriptor: {
|
|
175
186
|
name: 'a_Size',
|
|
187
|
+
shaderLocation: _CommonStyleAttribute.ShaderLocation.SIZE,
|
|
176
188
|
buffer: {
|
|
177
189
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
178
190
|
data: [],
|
|
@@ -203,6 +215,7 @@ var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
203
215
|
type: _l7Core.AttributeType.Attribute,
|
|
204
216
|
descriptor: {
|
|
205
217
|
name: 'a_Normal',
|
|
218
|
+
shaderLocation: _CommonStyleAttribute.ShaderLocation.NORMAL,
|
|
206
219
|
buffer: {
|
|
207
220
|
// give the WebGL driver a hint that this buffer may change
|
|
208
221
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
@@ -216,10 +229,11 @@ var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
216
229
|
}
|
|
217
230
|
});
|
|
218
231
|
this.styleAttributeService.registerStyleAttribute({
|
|
219
|
-
name: '
|
|
232
|
+
name: 'extrude',
|
|
220
233
|
type: _l7Core.AttributeType.Attribute,
|
|
221
234
|
descriptor: {
|
|
222
|
-
name: '
|
|
235
|
+
name: 'a_Extrude',
|
|
236
|
+
shaderLocation: _CommonStyleAttribute.ShaderLocation.EXTRUDE,
|
|
223
237
|
buffer: {
|
|
224
238
|
// give the WebGL driver a hint that this buffer may change
|
|
225
239
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
@@ -67,10 +67,6 @@ var ImageModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
67
67
|
key: "getUninforms",
|
|
68
68
|
value: function getUninforms() {
|
|
69
69
|
var _ref = this.layer.getLayerConfig(),
|
|
70
|
-
_ref$opacity = _ref.opacity,
|
|
71
|
-
opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
|
|
72
|
-
_ref$offsets = _ref.offsets,
|
|
73
|
-
offsets = _ref$offsets === void 0 ? [0, 0] : _ref$offsets,
|
|
74
70
|
_ref$raisingHeight = _ref.raisingHeight,
|
|
75
71
|
raisingHeight = _ref$raisingHeight === void 0 ? 0 : _ref$raisingHeight,
|
|
76
72
|
_ref$heightfixed = _ref.heightfixed,
|
|
@@ -1,18 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
in vec4 v_color;
|
|
2
|
+
in float v_lightWeight;
|
|
3
|
+
out vec4 outputColor;
|
|
4
4
|
|
|
5
|
-
#pragma include "picking"
|
|
6
5
|
|
|
6
|
+
layout(std140) uniform commonUniforms {
|
|
7
|
+
float u_pickLight;
|
|
8
|
+
float u_heightfixed;
|
|
9
|
+
float u_r;
|
|
10
|
+
float u_linearColor;
|
|
11
|
+
vec4 u_sourceColor;
|
|
12
|
+
vec4 u_targetColor;
|
|
13
|
+
float u_opacitylinear;
|
|
14
|
+
float u_opacitylinear_dir;
|
|
15
|
+
float u_lightEnable;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
#pragma include "picking"
|
|
7
19
|
|
|
8
20
|
void main() {
|
|
9
21
|
|
|
10
|
-
|
|
22
|
+
outputColor = v_color;
|
|
11
23
|
// 开启透明度渐变
|
|
12
24
|
// picking
|
|
13
25
|
if(u_pickLight > 0.0) {
|
|
14
|
-
|
|
26
|
+
outputColor = filterColorAlpha(outputColor, v_lightWeight);
|
|
15
27
|
} else {
|
|
16
|
-
|
|
28
|
+
outputColor = filterColor(outputColor);
|
|
17
29
|
}
|
|
18
30
|
}
|
|
@@ -1,32 +1,28 @@
|
|
|
1
|
-
precision highp float;
|
|
2
|
-
|
|
3
1
|
#define pi 3.1415926535
|
|
4
2
|
#define ambientRatio 0.5
|
|
5
3
|
#define diffuseRatio 0.3
|
|
6
4
|
#define specularRatio 0.2
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
uniform
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
uniform float u_linearColor: 0.0;
|
|
29
|
-
|
|
6
|
+
layout(location = 0) in vec3 a_Position;
|
|
7
|
+
layout(location = 1) in vec4 a_Color;
|
|
8
|
+
layout(location = 9) in vec3 a_Size;
|
|
9
|
+
layout(location = 11) in vec3 a_Extrude;
|
|
10
|
+
layout(location = 13) in vec3 a_Normal;
|
|
11
|
+
|
|
12
|
+
layout(std140) uniform commonUniforms {
|
|
13
|
+
float u_pickLight;
|
|
14
|
+
float u_heightfixed;
|
|
15
|
+
float u_r;
|
|
16
|
+
float u_linearColor;
|
|
17
|
+
vec4 u_sourceColor;
|
|
18
|
+
vec4 u_targetColor;
|
|
19
|
+
float u_opacitylinear;
|
|
20
|
+
float u_opacitylinear_dir;
|
|
21
|
+
float u_lightEnable;
|
|
22
|
+
};
|
|
23
|
+
out vec4 v_color;
|
|
24
|
+
out float v_lightWeight;
|
|
25
|
+
out float v_barLinearZ;
|
|
30
26
|
|
|
31
27
|
#pragma include "projection"
|
|
32
28
|
#pragma include "light"
|
|
@@ -72,7 +68,7 @@ void main() {
|
|
|
72
68
|
}
|
|
73
69
|
|
|
74
70
|
|
|
75
|
-
vec4 project_pos = project_position(vec4(
|
|
71
|
+
vec4 project_pos = project_position(vec4(a_Extrude.xy, 0., 1.0));
|
|
76
72
|
|
|
77
73
|
// u_r 控制圆柱的生长
|
|
78
74
|
vec4 pos = vec4(project_pos.xy + offset.xy, offset.z * u_r, 1.0);
|
|
@@ -91,9 +87,9 @@ void main() {
|
|
|
91
87
|
// 设置圆柱的底色
|
|
92
88
|
if(u_linearColor == 1.0) { // 使用渐变颜色
|
|
93
89
|
v_color = mix(u_sourceColor, u_targetColor, a_Position.z);
|
|
94
|
-
v_color.a = v_color.a *
|
|
90
|
+
v_color.a = v_color.a * opacity;
|
|
95
91
|
} else {
|
|
96
|
-
v_color = vec4(a_Color.rgb * lightWeight, a_Color.w *
|
|
92
|
+
v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);
|
|
97
93
|
}
|
|
98
94
|
|
|
99
95
|
if(u_opacitylinear > 0.0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-layers",
|
|
3
|
-
"version": "2.20.
|
|
3
|
+
"version": "2.20.5",
|
|
4
4
|
"description": "L7's collection of built-in layers",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"license": "ISC",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@antv/async-hook": "^2.2.9",
|
|
30
|
-
"@antv/l7-core": "2.20.
|
|
31
|
-
"@antv/l7-maps": "2.20.
|
|
32
|
-
"@antv/l7-source": "2.20.
|
|
33
|
-
"@antv/l7-utils": "2.20.
|
|
30
|
+
"@antv/l7-core": "2.20.5",
|
|
31
|
+
"@antv/l7-maps": "2.20.5",
|
|
32
|
+
"@antv/l7-source": "2.20.5",
|
|
33
|
+
"@antv/l7-utils": "2.20.5",
|
|
34
34
|
"@babel/runtime": "^7.7.7",
|
|
35
35
|
"@mapbox/martini": "^0.2.0",
|
|
36
36
|
"@turf/clone": "^6.5.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"reflect-metadata": "^0.1.13"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@antv/l7-test-utils": "2.20.
|
|
55
|
+
"@antv/l7-test-utils": "2.20.5",
|
|
56
56
|
"@types/d3-array": "^2.0.0",
|
|
57
57
|
"@types/d3-color": "^1.2.2",
|
|
58
58
|
"@types/d3-interpolate": "1.1.6",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@types/gl-matrix": "^2.4.5",
|
|
62
62
|
"@types/lodash": "^4.14.138"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "9c6df5f2ef050d18102f4aa4ccbb598bc1b5ee4d",
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
67
67
|
}
|