@antv/l7-layers 2.19.11 → 2.20.0
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/canvas/models/canvas.js +2 -2
- package/es/core/BaseLayer.d.ts +1 -1
- package/es/core/BaseLayer.js +18 -11
- package/es/core/BaseModel.d.ts +3 -1
- package/es/core/BaseModel.js +28 -4
- package/es/core/CommonStyleAttribute.d.ts +15 -0
- package/es/core/CommonStyleAttribute.js +21 -0
- package/es/core/TextureService.js +2 -2
- package/es/earth/index.js +1 -1
- package/es/geometry/index.js +1 -1
- package/es/geometry/models/billboard.js +1 -1
- package/es/geometry/models/plane.js +2 -2
- package/es/geometry/models/sprite.js +2 -2
- package/es/heatmap/index.js +1 -1
- package/es/heatmap/models/heatmap.js +4 -4
- package/es/image/models/image.js +1 -1
- package/es/line/index.js +1 -1
- package/es/line/models/arc.js +1 -1
- package/es/line/models/arc_3d.js +1 -1
- package/es/line/models/earthArc_3d.js +1 -1
- package/es/line/models/great_circle.js +1 -1
- package/es/line/models/line.js +1 -1
- package/es/line/models/linearline.js +1 -1
- package/es/line/models/wall.js +1 -1
- package/es/plugins/DataMappingPlugin.js +1 -1
- package/es/plugins/PixelPickingPlugin.d.ts +4 -1
- package/es/plugins/PixelPickingPlugin.js +91 -22
- package/es/plugins/RegisterStyleAttributePlugin.d.ts +0 -1
- package/es/plugins/RegisterStyleAttributePlugin.js +4 -22
- package/es/plugins/ShaderUniformPlugin.d.ts +2 -0
- package/es/plugins/ShaderUniformPlugin.js +74 -6
- package/es/point/index.js +1 -1
- package/es/point/models/fill.js +31 -7
- package/es/point/models/fillmage.js +1 -1
- package/es/point/models/image.js +1 -1
- package/es/point/models/normal.js +30 -12
- package/es/point/models/text.js +1 -1
- package/es/point/shaders/fill_frag.glsl +20 -14
- package/es/point/shaders/fill_vert.glsl +19 -18
- package/es/point/shaders/normal_frag.glsl +4 -3
- package/es/point/shaders/normal_vert.glsl +12 -11
- package/es/polygon/index.js +1 -1
- package/es/polygon/models/extrude.js +1 -1
- package/es/polygon/models/extrusion.js +1 -1
- package/es/polygon/models/ocean.js +3 -3
- package/es/polygon/models/water.js +1 -1
- package/es/raster/models/raster.js +2 -2
- package/es/raster/models/rasterRgb.js +1 -1
- package/es/raster/models/rasterTerrainRgb.js +1 -1
- package/es/tile/core/BaseLayer.js +4 -4
- package/es/tile/interaction/getRasterData.js +4 -4
- package/es/tile/service/TileLayerService.js +4 -4
- package/es/tile/service/TilePickService.js +3 -3
- package/es/tile/tile/Tile.d.ts +3 -0
- package/es/tile/tile/Tile.js +2 -2
- package/es/wind/models/wind.js +5 -6
- package/lib/canvas/index.js +2 -3
- package/lib/canvas/models/canvas.js +4 -5
- package/lib/canvas/models/index.js +1 -2
- package/lib/citybuliding/building.js +2 -3
- package/lib/citybuliding/models/build.js +2 -3
- package/lib/core/BaseLayer.js +19 -13
- package/lib/core/BaseModel.js +30 -7
- package/lib/core/CommonStyleAttribute.js +22 -0
- package/lib/core/LayerPickService.js +2 -3
- package/lib/core/TextureService.js +4 -5
- package/lib/core/constant.js +3 -5
- package/lib/core/interface.js +6 -11
- package/lib/core/schema.js +2 -3
- package/lib/core/shape/Path.js +3 -6
- package/lib/core/triangulation.js +2 -2
- package/lib/earth/index.js +3 -4
- package/lib/earth/models/atmosphere.js +2 -3
- package/lib/earth/models/base.js +2 -3
- package/lib/earth/models/bloomsphere.js +2 -3
- package/lib/earth/utils.js +3 -6
- package/lib/geometry/index.js +3 -4
- package/lib/geometry/models/billboard.js +3 -4
- package/lib/geometry/models/index.js +1 -2
- package/lib/geometry/models/plane.js +4 -5
- package/lib/geometry/models/sprite.js +4 -5
- package/lib/heatmap/index.js +3 -4
- package/lib/heatmap/models/grid.js +2 -3
- package/lib/heatmap/models/grid3d.js +2 -3
- package/lib/heatmap/models/heatmap.js +6 -7
- package/lib/heatmap/models/hexagon.js +2 -3
- package/lib/heatmap/models/index.js +1 -2
- package/lib/image/index.js +2 -3
- package/lib/image/models/image.js +3 -4
- package/lib/image/models/index.js +1 -2
- package/lib/line/index.js +3 -4
- package/lib/line/models/arc.js +3 -4
- package/lib/line/models/arc_3d.js +3 -4
- package/lib/line/models/earthArc_3d.js +3 -4
- package/lib/line/models/flow.js +2 -3
- package/lib/line/models/great_circle.js +3 -4
- package/lib/line/models/index.js +1 -2
- package/lib/line/models/line.js +3 -4
- package/lib/line/models/linearline.js +3 -4
- package/lib/line/models/simpleLine.js +2 -3
- package/lib/line/models/wall.js +3 -4
- package/lib/mask/index.js +2 -3
- package/lib/mask/models/fill.js +2 -3
- package/lib/mask/models/index.js +1 -2
- package/lib/plugins/DataMappingPlugin.js +3 -4
- package/lib/plugins/DataSourcePlugin.js +2 -3
- package/lib/plugins/FeatureScalePlugin.js +4 -5
- package/lib/plugins/LayerAnimateStylePlugin.js +2 -3
- package/lib/plugins/LayerMaskPlugin.js +2 -3
- package/lib/plugins/LayerModelPlugin.js +2 -3
- package/lib/plugins/LayerStylePlugin.js +2 -3
- package/lib/plugins/LightingPlugin.js +2 -3
- package/lib/plugins/MultiPassRendererPlugin.js +2 -3
- package/lib/plugins/PixelPickingPlugin.js +93 -25
- package/lib/plugins/RegisterStyleAttributePlugin.js +6 -25
- package/lib/plugins/ShaderUniformPlugin.js +75 -8
- package/lib/plugins/UpdateModelPlugin.js +2 -3
- package/lib/plugins/UpdateStyleAttributePlugin.js +2 -3
- package/lib/point/index.js +3 -4
- package/lib/point/models/billboard_point.js +2 -3
- package/lib/point/models/earthExtrude.js +2 -3
- package/lib/point/models/earthFill.js +2 -3
- package/lib/point/models/extrude.js +2 -3
- package/lib/point/models/fill.js +33 -10
- package/lib/point/models/fillmage.js +3 -4
- package/lib/point/models/image.js +3 -4
- package/lib/point/models/index.js +1 -2
- package/lib/point/models/normal.js +32 -15
- package/lib/point/models/radar.js +2 -3
- package/lib/point/models/text.js +3 -4
- package/lib/point/shaders/fill_frag.glsl +20 -14
- package/lib/point/shaders/fill_vert.glsl +19 -18
- package/lib/point/shaders/normal_frag.glsl +4 -3
- package/lib/point/shaders/normal_vert.glsl +12 -11
- package/lib/polygon/index.js +3 -4
- package/lib/polygon/models/extrude.js +3 -4
- package/lib/polygon/models/extrusion.js +3 -4
- package/lib/polygon/models/fill.js +2 -3
- package/lib/polygon/models/index.js +1 -2
- package/lib/polygon/models/ocean.js +5 -6
- package/lib/polygon/models/water.js +3 -4
- package/lib/raster/index.js +2 -3
- package/lib/raster/models/index.js +1 -2
- package/lib/raster/models/raster.js +4 -5
- package/lib/raster/models/rasterRgb.js +3 -4
- package/lib/raster/models/rasterTerrainRgb.js +3 -4
- package/lib/tile/core/BaseLayer.js +6 -7
- package/lib/tile/core/TileDebugLayer.js +2 -3
- package/lib/tile/interaction/getRasterData.js +4 -4
- package/lib/tile/service/TileLayerService.js +6 -7
- package/lib/tile/service/TilePickService.js +5 -6
- package/lib/tile/service/TileSourceService.js +4 -5
- package/lib/tile/tile/DebugTile.js +2 -3
- package/lib/tile/tile/ImageTile.js +2 -3
- package/lib/tile/tile/MaskTile.js +2 -3
- package/lib/tile/tile/RasterRGBTile.js +2 -3
- package/lib/tile/tile/RasterTerrainRGBTile.js +2 -3
- package/lib/tile/tile/RasterTile.js +2 -3
- package/lib/tile/tile/Tile.js +4 -5
- package/lib/tile/tile/VectorTile.js +2 -3
- package/lib/tile/utils/constants.js +2 -3
- package/lib/tile/utils/utils.js +1 -2
- package/lib/utils/blend.js +2 -3
- package/lib/utils/collision-index.js +2 -3
- package/lib/utils/extrude_polyline.js +2 -3
- package/lib/utils/grid-index.js +1 -2
- package/lib/utils/simpleLine.js +2 -3
- package/lib/wind/index.js +2 -3
- package/lib/wind/models/index.js +1 -2
- package/lib/wind/models/wind.js +7 -9
- package/lib/wind/models/windRender.js +4 -5
- package/lib/wind/models/windShader.js +6 -12
- package/package.json +7 -7
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
4
|
var _dec, _class;
|
|
4
5
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
5
6
|
import { decodePickingColor, encodePickingColor, rgb2arr } from '@antv/l7-utils';
|
|
6
7
|
import { injectable } from 'inversify';
|
|
7
8
|
import 'reflect-metadata';
|
|
9
|
+
import { ShaderLocation } from "../core/CommonStyleAttribute";
|
|
8
10
|
var PickingStage = {
|
|
9
11
|
NONE: 0.0,
|
|
10
12
|
ENCODE: 1.0,
|
|
@@ -13,11 +15,66 @@ var PickingStage = {
|
|
|
13
15
|
var PixelPickingPlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function () {
|
|
14
16
|
function PixelPickingPlugin() {
|
|
15
17
|
_classCallCheck(this, PixelPickingPlugin);
|
|
18
|
+
_defineProperty(this, "PickOption", {
|
|
19
|
+
u_HighlightColor: [1, 0, 0, 1],
|
|
20
|
+
u_SelectColor: [1, 0, 0, 1],
|
|
21
|
+
u_PickingColor: [0, 0, 0],
|
|
22
|
+
u_PickingStage: 0,
|
|
23
|
+
u_CurrentSelectedId: [0, 0, 0],
|
|
24
|
+
u_PickingThreshold: 10,
|
|
25
|
+
u_PickingBuffer: 0,
|
|
26
|
+
// TODO: 更新机制
|
|
27
|
+
u_shaderPick: 0,
|
|
28
|
+
u_EnableSelect: 0,
|
|
29
|
+
u_activeMix: 0
|
|
30
|
+
});
|
|
16
31
|
}
|
|
17
32
|
_createClass(PixelPickingPlugin, [{
|
|
33
|
+
key: "pickOption2Array",
|
|
34
|
+
value: function pickOption2Array() {
|
|
35
|
+
return Object.values(this.PickOption).flat();
|
|
36
|
+
}
|
|
37
|
+
}, {
|
|
38
|
+
key: "updatePickOption",
|
|
39
|
+
value: function updatePickOption(option, rendererService) {
|
|
40
|
+
var _this = this;
|
|
41
|
+
Object.keys(option).forEach(function (key) {
|
|
42
|
+
_this.PickOption[key] = option[key];
|
|
43
|
+
});
|
|
44
|
+
rendererService.uniformBuffers[1].subData({
|
|
45
|
+
offset: 0,
|
|
46
|
+
data: new Uint8Array(new Float32Array(this.pickOption2Array()))
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
18
50
|
key: "apply",
|
|
19
51
|
value: function apply(layer, _ref) {
|
|
20
|
-
var
|
|
52
|
+
var _this2 = this;
|
|
53
|
+
var rendererService = _ref.rendererService,
|
|
54
|
+
styleAttributeService = _ref.styleAttributeService;
|
|
55
|
+
if (!rendererService.uniformBuffers[1]) {
|
|
56
|
+
// Create a Uniform Buffer Object(UBO).
|
|
57
|
+
var uniformBuffer = rendererService.createBuffer({
|
|
58
|
+
// vec4 u_HighlightColor;
|
|
59
|
+
// vec4 u_SelectColor;
|
|
60
|
+
// vec3 u_PickingColor;
|
|
61
|
+
// float u_PickingStage;
|
|
62
|
+
// vec3 u_CurrentSelectedId;
|
|
63
|
+
// float u_PickingThreshold;
|
|
64
|
+
// float u_PickingBuffer;
|
|
65
|
+
// float u_shaderPick;
|
|
66
|
+
// float u_EnableSelect;
|
|
67
|
+
// float u_activeMix;
|
|
68
|
+
data: new Float32Array(this.pickOption2Array().length),
|
|
69
|
+
isUBO: true
|
|
70
|
+
});
|
|
71
|
+
rendererService.uniformBuffers[1] = uniformBuffer;
|
|
72
|
+
this.updatePickOption({}, rendererService);
|
|
73
|
+
}
|
|
74
|
+
// u_PickingBuffer: layer.getLayerConfig().pickingBuffer || 0,
|
|
75
|
+
// // Tip: 当前地图是否在拖动
|
|
76
|
+
// u_shaderPick: Number(layer.getShaderPickStat()),
|
|
77
|
+
|
|
21
78
|
// TODO: 由于 Shader 目前无法根据是否开启拾取进行内容修改,因此即使不开启也需要生成 a_PickingColor
|
|
22
79
|
layer.hooks.init.tapPromise('PixelPickingPlugin', function () {
|
|
23
80
|
var _layer$getLayerConfig = layer.getLayerConfig(),
|
|
@@ -27,6 +84,7 @@ var PixelPickingPlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
|
|
|
27
84
|
type: AttributeType.Attribute,
|
|
28
85
|
descriptor: {
|
|
29
86
|
name: 'a_PickingColor',
|
|
87
|
+
shaderLocation: ShaderLocation.PICKING_COLOR,
|
|
30
88
|
buffer: {
|
|
31
89
|
data: [],
|
|
32
90
|
type: gl.FLOAT
|
|
@@ -46,6 +104,9 @@ var PixelPickingPlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
|
|
|
46
104
|
var _layer$getLayerConfig2 = layer.getLayerConfig(),
|
|
47
105
|
enablePicking = _layer$getLayerConfig2.enablePicking;
|
|
48
106
|
if (enablePicking && layer.isVisible()) {
|
|
107
|
+
_this2.updatePickOption({
|
|
108
|
+
u_PickingStage: PickingStage.ENCODE
|
|
109
|
+
}, rendererService);
|
|
49
110
|
layer.models.forEach(function (model) {
|
|
50
111
|
return model.addUniforms({
|
|
51
112
|
u_PickingStage: PickingStage.ENCODE
|
|
@@ -58,6 +119,9 @@ var PixelPickingPlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
|
|
|
58
119
|
enablePicking = _layer$getLayerConfig3.enablePicking;
|
|
59
120
|
// 区分选中高亮 和滑过高亮
|
|
60
121
|
if (enablePicking && layer.isVisible()) {
|
|
122
|
+
_this2.updatePickOption({
|
|
123
|
+
u_PickingStage: PickingStage.HIGHLIGHT
|
|
124
|
+
}, rendererService);
|
|
61
125
|
layer.models.forEach(function (model) {
|
|
62
126
|
return model.addUniforms({
|
|
63
127
|
u_PickingStage: PickingStage.HIGHLIGHT
|
|
@@ -74,15 +138,17 @@ var PixelPickingPlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
|
|
|
74
138
|
layer.updateLayerConfig({
|
|
75
139
|
pickedFeatureID: decodePickingColor(new Uint8Array(pickedColor))
|
|
76
140
|
});
|
|
141
|
+
var option = {
|
|
142
|
+
u_PickingStage: PickingStage.HIGHLIGHT,
|
|
143
|
+
u_PickingColor: pickedColor,
|
|
144
|
+
u_HighlightColor: highlightColorInArray.map(function (c) {
|
|
145
|
+
return c * 255;
|
|
146
|
+
}),
|
|
147
|
+
u_activeMix: activeMix
|
|
148
|
+
};
|
|
149
|
+
_this2.updatePickOption(option, rendererService);
|
|
77
150
|
layer.models.forEach(function (model) {
|
|
78
|
-
return model.addUniforms(
|
|
79
|
-
u_PickingStage: PickingStage.HIGHLIGHT,
|
|
80
|
-
u_PickingColor: pickedColor,
|
|
81
|
-
u_HighlightColor: highlightColorInArray.map(function (c) {
|
|
82
|
-
return c * 255;
|
|
83
|
-
}),
|
|
84
|
-
u_activeMix: activeMix
|
|
85
|
-
});
|
|
151
|
+
return model.addUniforms(option);
|
|
86
152
|
});
|
|
87
153
|
});
|
|
88
154
|
layer.hooks.beforeSelect.tap('PixelPickingPlugin', function (pickedColor) {
|
|
@@ -94,20 +160,23 @@ var PixelPickingPlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
|
|
|
94
160
|
layer.updateLayerConfig({
|
|
95
161
|
pickedFeatureID: decodePickingColor(new Uint8Array(pickedColor))
|
|
96
162
|
});
|
|
163
|
+
var option = {
|
|
164
|
+
u_PickingStage: PickingStage.HIGHLIGHT,
|
|
165
|
+
u_PickingColor: pickedColor,
|
|
166
|
+
u_HighlightColor: highlightColorInArray.map(function (c) {
|
|
167
|
+
return c * 255;
|
|
168
|
+
}),
|
|
169
|
+
u_activeMix: selectMix,
|
|
170
|
+
u_CurrentSelectedId: pickedColor,
|
|
171
|
+
u_SelectColor: highlightColorInArray.map(function (c) {
|
|
172
|
+
return c * 255;
|
|
173
|
+
}),
|
|
174
|
+
u_EnableSelect: 1
|
|
175
|
+
};
|
|
176
|
+
console.log(option);
|
|
177
|
+
_this2.updatePickOption(option, rendererService);
|
|
97
178
|
layer.models.forEach(function (model) {
|
|
98
|
-
return model.addUniforms(
|
|
99
|
-
u_PickingStage: PickingStage.HIGHLIGHT,
|
|
100
|
-
u_PickingColor: pickedColor,
|
|
101
|
-
u_HighlightColor: highlightColorInArray.map(function (c) {
|
|
102
|
-
return c * 255;
|
|
103
|
-
}),
|
|
104
|
-
u_activeMix: selectMix,
|
|
105
|
-
u_CurrentSelectedId: pickedColor,
|
|
106
|
-
u_SelectColor: highlightColorInArray.map(function (c) {
|
|
107
|
-
return c * 255;
|
|
108
|
-
}),
|
|
109
|
-
u_EnableSelect: 1
|
|
110
|
-
});
|
|
179
|
+
return model.addUniforms(option);
|
|
111
180
|
});
|
|
112
181
|
});
|
|
113
182
|
}
|
|
@@ -9,7 +9,6 @@ export default class RegisterStyleAttributePlugin implements ILayerPlugin {
|
|
|
9
9
|
}): void;
|
|
10
10
|
private registerBuiltinAttributes;
|
|
11
11
|
private registerPositionAttribute;
|
|
12
|
-
private registerFilterAttribute;
|
|
13
12
|
private registerColorAttribute;
|
|
14
13
|
private registerVertexIdAttribute;
|
|
15
14
|
}
|
|
@@ -4,6 +4,7 @@ var _dec, _class;
|
|
|
4
4
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
5
5
|
import { injectable } from 'inversify';
|
|
6
6
|
import 'reflect-metadata';
|
|
7
|
+
import { ShaderLocation } from "../core/CommonStyleAttribute";
|
|
7
8
|
import { isTileGroup } from "../tile/utils/utils";
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -48,6 +49,7 @@ var RegisterStyleAttributePlugin = (_dec = injectable(), _dec(_class = /*#__PURE
|
|
|
48
49
|
type: AttributeType.Attribute,
|
|
49
50
|
descriptor: {
|
|
50
51
|
name: 'a_Position',
|
|
52
|
+
shaderLocation: ShaderLocation.POSITION,
|
|
51
53
|
buffer: {
|
|
52
54
|
data: [],
|
|
53
55
|
type: gl.FLOAT
|
|
@@ -59,28 +61,6 @@ var RegisterStyleAttributePlugin = (_dec = injectable(), _dec(_class = /*#__PURE
|
|
|
59
61
|
}
|
|
60
62
|
});
|
|
61
63
|
}
|
|
62
|
-
}, {
|
|
63
|
-
key: "registerFilterAttribute",
|
|
64
|
-
value: function registerFilterAttribute(styleAttributeService) {
|
|
65
|
-
styleAttributeService.registerStyleAttribute({
|
|
66
|
-
name: 'filter',
|
|
67
|
-
type: AttributeType.Attribute,
|
|
68
|
-
descriptor: {
|
|
69
|
-
name: 'filter',
|
|
70
|
-
buffer: {
|
|
71
|
-
// give the WebGL driver a hint that this buffer may change
|
|
72
|
-
usage: gl.DYNAMIC_DRAW,
|
|
73
|
-
data: [],
|
|
74
|
-
type: gl.FLOAT
|
|
75
|
-
},
|
|
76
|
-
size: 1,
|
|
77
|
-
update: function update(feature) {
|
|
78
|
-
var filter = feature.filter;
|
|
79
|
-
return filter ? [1] : [0];
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
64
|
}, {
|
|
85
65
|
key: "registerColorAttribute",
|
|
86
66
|
value: function registerColorAttribute(styleAttributeService) {
|
|
@@ -89,6 +69,7 @@ var RegisterStyleAttributePlugin = (_dec = injectable(), _dec(_class = /*#__PURE
|
|
|
89
69
|
type: AttributeType.Attribute,
|
|
90
70
|
descriptor: {
|
|
91
71
|
name: 'a_Color',
|
|
72
|
+
shaderLocation: ShaderLocation.COLOR,
|
|
92
73
|
buffer: {
|
|
93
74
|
// give the WebGL driver a hint that this buffer may change
|
|
94
75
|
usage: gl.DYNAMIC_DRAW,
|
|
@@ -112,6 +93,7 @@ var RegisterStyleAttributePlugin = (_dec = injectable(), _dec(_class = /*#__PURE
|
|
|
112
93
|
type: AttributeType.Attribute,
|
|
113
94
|
descriptor: {
|
|
114
95
|
name: 'a_vertexId',
|
|
96
|
+
shaderLocation: ShaderLocation.VERTEX_ID,
|
|
115
97
|
buffer: {
|
|
116
98
|
// give the WebGL driver a hint that this buffer may change
|
|
117
99
|
usage: gl.DYNAMIC_DRAW,
|
|
@@ -12,10 +12,12 @@ export default class ShaderUniformPlugin implements ILayerPlugin {
|
|
|
12
12
|
private readonly coordinateSystemService;
|
|
13
13
|
private readonly rendererService;
|
|
14
14
|
private readonly mapService;
|
|
15
|
+
private readonly layerService;
|
|
15
16
|
apply(layer: ILayer): void;
|
|
16
17
|
/**
|
|
17
18
|
* 对于每个 layer 都有不同的几何中心点,因此在绘制每个 layer 的时候都需要重新设置
|
|
18
19
|
* @param layer
|
|
19
20
|
*/
|
|
20
21
|
private setLayerCenter;
|
|
22
|
+
private generateUBO;
|
|
21
23
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
1
3
|
import _initializerDefineProperty from "@babel/runtime/helpers/esm/initializerDefineProperty";
|
|
2
4
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
5
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
6
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
5
7
|
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
|
|
6
8
|
import _initializerWarningHelper from "@babel/runtime/helpers/esm/initializerWarningHelper";
|
|
7
|
-
var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;
|
|
9
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5;
|
|
8
10
|
import { CameraUniform, CoordinateUniform, TYPES } from '@antv/l7-core';
|
|
9
11
|
import { inject, injectable } from 'inversify';
|
|
10
12
|
import 'reflect-metadata';
|
|
@@ -16,13 +18,14 @@ import 'reflect-metadata';
|
|
|
16
18
|
* @see https://yuque.antfin-inc.com/yuqi.pyq/fgetpa/doml91
|
|
17
19
|
* 3. 当前 Layer 本身的样式属性
|
|
18
20
|
*/
|
|
19
|
-
var ShaderUniformPlugin = (_dec = injectable(), _dec2 = inject(TYPES.ICameraService), _dec3 = inject(TYPES.ICoordinateSystemService), _dec4 = inject(TYPES.IRendererService), _dec5 = inject(TYPES.IMapService), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
21
|
+
var ShaderUniformPlugin = (_dec = injectable(), _dec2 = inject(TYPES.ICameraService), _dec3 = inject(TYPES.ICoordinateSystemService), _dec4 = inject(TYPES.IRendererService), _dec5 = inject(TYPES.IMapService), _dec6 = inject(TYPES.ILayerService), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
20
22
|
function ShaderUniformPlugin() {
|
|
21
23
|
_classCallCheck(this, ShaderUniformPlugin);
|
|
22
24
|
_initializerDefineProperty(this, "cameraService", _descriptor, this);
|
|
23
25
|
_initializerDefineProperty(this, "coordinateSystemService", _descriptor2, this);
|
|
24
26
|
_initializerDefineProperty(this, "rendererService", _descriptor3, this);
|
|
25
27
|
_initializerDefineProperty(this, "mapService", _descriptor4, this);
|
|
28
|
+
_initializerDefineProperty(this, "layerService", _descriptor5, this);
|
|
26
29
|
}
|
|
27
30
|
_createClass(ShaderUniformPlugin, [{
|
|
28
31
|
key: "apply",
|
|
@@ -31,6 +34,15 @@ var ShaderUniformPlugin = (_dec = injectable(), _dec2 = inject(TYPES.ICameraServ
|
|
|
31
34
|
var version = this.mapService.version;
|
|
32
35
|
var mvp = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; // default matrix (for gaode2.x)
|
|
33
36
|
var sceneCenterMercator = [0, 0];
|
|
37
|
+
var uniformBuffer;
|
|
38
|
+
if (!this.rendererService.uniformBuffers[0]) {
|
|
39
|
+
// Create a Uniform Buffer Object(UBO).
|
|
40
|
+
uniformBuffer = this.rendererService.createBuffer({
|
|
41
|
+
data: new Float32Array(16 * 5 + 4 * 6 + 4),
|
|
42
|
+
isUBO: true
|
|
43
|
+
});
|
|
44
|
+
this.rendererService.uniformBuffers[0] = uniformBuffer;
|
|
45
|
+
}
|
|
34
46
|
layer.hooks.beforeRender.tap('ShaderUniformPlugin', function () {
|
|
35
47
|
// @ts-ignore
|
|
36
48
|
var offset = layer.getLayerConfig().tileOrigin;
|
|
@@ -47,12 +59,25 @@ var ShaderUniformPlugin = (_dec = injectable(), _dec2 = inject(TYPES.ICameraServ
|
|
|
47
59
|
var _this$rendererService = _this.rendererService.getViewportSize(),
|
|
48
60
|
width = _this$rendererService.width,
|
|
49
61
|
height = _this$rendererService.height;
|
|
62
|
+
var _this$generateUBO = _this.generateUBO(mvp, sceneCenterMercator, width, height),
|
|
63
|
+
data = _this$generateUBO.data,
|
|
64
|
+
uniforms = _this$generateUBO.uniforms;
|
|
65
|
+
if (_this.layerService.alreadyInRendering && uniformBuffer) {
|
|
66
|
+
// Update only once since all models can share one UBO.
|
|
67
|
+
uniformBuffer.subData({
|
|
68
|
+
offset: 0,
|
|
69
|
+
data: data
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
// For WebGL1. regl
|
|
50
73
|
layer.models.forEach(function (model) {
|
|
51
|
-
|
|
52
|
-
|
|
74
|
+
model.addUniforms(_objectSpread(_objectSpread({}, uniforms), {}, {
|
|
75
|
+
// TODO: move these 2 uniforms to PixelPickingPlugin
|
|
76
|
+
u_PickingBuffer: layer.getLayerConfig().pickingBuffer || 0,
|
|
77
|
+
// Tip: 当前地图是否在拖动
|
|
78
|
+
u_shaderPick: Number(layer.getShaderPickStat())
|
|
79
|
+
}));
|
|
53
80
|
});
|
|
54
|
-
|
|
55
|
-
// TODO:脏检查,决定是否需要渲染
|
|
56
81
|
});
|
|
57
82
|
}
|
|
58
83
|
|
|
@@ -70,6 +95,44 @@ var ShaderUniformPlugin = (_dec = injectable(), _dec2 = inject(TYPES.ICameraServ
|
|
|
70
95
|
this.mapService.setCoordCenter(layer.coordCenter);
|
|
71
96
|
}
|
|
72
97
|
}
|
|
98
|
+
}, {
|
|
99
|
+
key: "generateUBO",
|
|
100
|
+
value: function generateUBO(u_Mvp, sceneCenterMercator, width, height) {
|
|
101
|
+
var _uniforms;
|
|
102
|
+
var u_ProjectionMatrix = this.cameraService.getProjectionMatrix();
|
|
103
|
+
var u_ViewMatrix = this.cameraService.getViewMatrix();
|
|
104
|
+
var u_ViewProjectionMatrix = this.cameraService.getViewProjectionMatrix();
|
|
105
|
+
var u_ModelMatrix = this.cameraService.getModelMatrix();
|
|
106
|
+
var u_ViewportCenterProjection = this.coordinateSystemService.getViewportCenterProjection();
|
|
107
|
+
var u_PixelsPerDegree = this.coordinateSystemService.getPixelsPerDegree();
|
|
108
|
+
var u_Zoom = this.cameraService.getZoom();
|
|
109
|
+
var u_PixelsPerDegree2 = this.coordinateSystemService.getPixelsPerDegree2();
|
|
110
|
+
var u_ZoomScale = this.cameraService.getZoomScale();
|
|
111
|
+
var u_PixelsPerMeter = this.coordinateSystemService.getPixelsPerMeter();
|
|
112
|
+
var u_CoordinateSystem = this.coordinateSystemService.getCoordinateSystem();
|
|
113
|
+
var u_CameraPosition = this.cameraService.getCameraPosition();
|
|
114
|
+
var u_DevicePixelRatio = window.devicePixelRatio;
|
|
115
|
+
var u_ViewportCenter = this.coordinateSystemService.getViewportCenter();
|
|
116
|
+
var u_ViewportSize = [width, height];
|
|
117
|
+
var u_FocalDistance = this.cameraService.getFocalDistance();
|
|
118
|
+
var data = [].concat(_toConsumableArray(u_ViewMatrix), _toConsumableArray(u_ProjectionMatrix), _toConsumableArray(u_ViewProjectionMatrix), _toConsumableArray(u_ModelMatrix), _toConsumableArray(u_Mvp), _toConsumableArray(u_ViewportCenterProjection), _toConsumableArray(u_PixelsPerDegree), [
|
|
119
|
+
// 4
|
|
120
|
+
u_Zoom], _toConsumableArray(u_PixelsPerDegree2), [
|
|
121
|
+
// 4
|
|
122
|
+
u_ZoomScale], _toConsumableArray(u_PixelsPerMeter), [
|
|
123
|
+
// 4
|
|
124
|
+
u_CoordinateSystem], _toConsumableArray(u_CameraPosition), [
|
|
125
|
+
// 4
|
|
126
|
+
u_DevicePixelRatio], _toConsumableArray(u_ViewportCenter), u_ViewportSize, _toConsumableArray(sceneCenterMercator), [
|
|
127
|
+
// 2
|
|
128
|
+
u_FocalDistance,
|
|
129
|
+
// 1
|
|
130
|
+
0]);
|
|
131
|
+
return {
|
|
132
|
+
data: data,
|
|
133
|
+
uniforms: (_uniforms = {}, _defineProperty(_uniforms, CameraUniform.ProjectionMatrix, u_ProjectionMatrix), _defineProperty(_uniforms, CameraUniform.ViewMatrix, u_ViewMatrix), _defineProperty(_uniforms, CameraUniform.ViewProjectionMatrix, u_ViewProjectionMatrix), _defineProperty(_uniforms, CameraUniform.Zoom, u_Zoom), _defineProperty(_uniforms, CameraUniform.ZoomScale, u_ZoomScale), _defineProperty(_uniforms, CameraUniform.FocalDistance, u_FocalDistance), _defineProperty(_uniforms, CameraUniform.CameraPosition, u_CameraPosition), _defineProperty(_uniforms, CoordinateUniform.CoordinateSystem, u_CoordinateSystem), _defineProperty(_uniforms, CoordinateUniform.ViewportCenter, u_ViewportCenter), _defineProperty(_uniforms, CoordinateUniform.ViewportCenterProjection, u_ViewportCenterProjection), _defineProperty(_uniforms, CoordinateUniform.PixelsPerDegree, u_PixelsPerDegree), _defineProperty(_uniforms, CoordinateUniform.PixelsPerDegree2, u_PixelsPerDegree2), _defineProperty(_uniforms, CoordinateUniform.PixelsPerMeter, u_PixelsPerMeter), _defineProperty(_uniforms, CoordinateUniform.Mvp, u_Mvp), _defineProperty(_uniforms, "u_sceneCenterMercator", sceneCenterMercator), _defineProperty(_uniforms, "u_ViewportSize", u_ViewportSize), _defineProperty(_uniforms, "u_ModelMatrix", u_ModelMatrix), _defineProperty(_uniforms, "u_DevicePixelRatio", u_DevicePixelRatio), _uniforms)
|
|
134
|
+
};
|
|
135
|
+
}
|
|
73
136
|
}]);
|
|
74
137
|
return ShaderUniformPlugin;
|
|
75
138
|
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "cameraService", [_dec2], {
|
|
@@ -92,5 +155,10 @@ var ShaderUniformPlugin = (_dec = injectable(), _dec2 = inject(TYPES.ICameraServ
|
|
|
92
155
|
enumerable: true,
|
|
93
156
|
writable: true,
|
|
94
157
|
initializer: null
|
|
158
|
+
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "layerService", [_dec6], {
|
|
159
|
+
configurable: true,
|
|
160
|
+
enumerable: true,
|
|
161
|
+
writable: true,
|
|
162
|
+
initializer: null
|
|
95
163
|
})), _class2)) || _class);
|
|
96
164
|
export { ShaderUniformPlugin as default };
|
package/es/point/index.js
CHANGED
|
@@ -25,7 +25,7 @@ var PointLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
|
25
25
|
}
|
|
26
26
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
27
27
|
_defineProperty(_assertThisInitialized(_this), "type", 'PointLayer');
|
|
28
|
-
_defineProperty(_assertThisInitialized(_this), "enableShaderEncodeStyles", ['
|
|
28
|
+
_defineProperty(_assertThisInitialized(_this), "enableShaderEncodeStyles", ['stroke', 'offsets', 'opacity', 'rotation']);
|
|
29
29
|
_defineProperty(_assertThisInitialized(_this), "enableDataEncodeStyles", ['textOffset', 'textAnchor']);
|
|
30
30
|
_defineProperty(_assertThisInitialized(_this), "defaultSourceConfig", {
|
|
31
31
|
data: [],
|
package/es/point/models/fill.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
3
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
4
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
5
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
@@ -11,14 +12,15 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
11
12
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
12
13
|
import { PointFillTriangulation } from '@antv/l7-utils';
|
|
13
14
|
import BaseModel from "../../core/BaseModel";
|
|
15
|
+
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
14
16
|
import { SizeUnitType } from "../../core/interface";
|
|
15
17
|
// animate pointLayer shader - support animate
|
|
16
18
|
/* babel-plugin-inline-import '../shaders/animate/wave_frag.glsl' */
|
|
17
19
|
var waveFillFrag = "\nuniform float u_additive;\n\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nvoid main() {\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n \n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n\n\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n float color_t = smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n float PI = 3.14159;\n float N_RINGS = 3.0;\n float FREQ = 1.0;\n\n gl_FragColor = v_color;\n\n float d = length(v_data.xy);\n if(d > 0.5) {\n discard;\n }\n float intensity = clamp(cos(d * PI), 0.0, 1.0) * clamp(cos(2.0 * PI * (d * 2.0 * u_animate.z - u_animate.y * u_time)), 0.0, 1.0);\n \n // \u6839\u636E\u53E0\u52A0\u6A21\u5F0F\u9009\u62E9\u6548\u679C\n if(u_additive > 0.0) {\n gl_FragColor *= intensity;\n // \u4F18\u5316\u6C34\u6CE2\u70B9 blend additive \u6A21\u5F0F\u4E0B\u6709\u7684\u62FE\u53D6\u6548\u679C \n gl_FragColor = filterColorAlpha(gl_FragColor, gl_FragColor.a);\n } else {\n gl_FragColor = vec4(gl_FragColor.xyz, gl_FragColor.a * intensity);\n gl_FragColor = filterColor(gl_FragColor);\n }\n}\n"; // static pointLayer shader - not support animate
|
|
18
20
|
/* babel-plugin-inline-import '../shaders/fill_frag.glsl' */
|
|
19
|
-
var pointFillFrag = "uniform float u_additive;\
|
|
21
|
+
var pointFillFrag = "\nlayout(std140) uniform commonUniforms {\n vec3 u_blur_height_fixed;\n float u_stroke_width;\n float u_additive;\n float u_stroke_opacity;\n float u_size_unit;\n};\n\nin vec4 v_color;\nin vec4 v_stroke;\nin vec4 v_data;\nin float v_radius;\n\n#pragma include \"scene_uniforms\"\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nout vec4 outputColor;\n\nvoid main() {\n int shape = int(floor(v_data.w + 0.5));\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius + u_stroke_width);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n if (shape == 0) {\n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n } else if (shape == 1) {\n outer_df = sdEquilateralTriangle(1.1 * v_data.xy);\n inner_df = sdEquilateralTriangle(1.1 / r * v_data.xy);\n } else if (shape == 2) {\n outer_df = sdBox(v_data.xy, vec2(1.));\n inner_df = sdBox(v_data.xy, vec2(r));\n } else if (shape == 3) {\n outer_df = sdPentagon(v_data.xy, 0.8);\n inner_df = sdPentagon(v_data.xy, r * 0.8);\n } else if (shape == 4) {\n outer_df = sdHexagon(v_data.xy, 0.8);\n inner_df = sdHexagon(v_data.xy, r * 0.8);\n } else if (shape == 5) {\n outer_df = sdOctogon(v_data.xy, 1.0);\n inner_df = sdOctogon(v_data.xy, r);\n } else if (shape == 6) {\n outer_df = sdHexagram(v_data.xy, 0.52);\n inner_df = sdHexagram(v_data.xy, r * 0.52);\n } else if (shape == 7) {\n outer_df = sdRhombus(v_data.xy, vec2(1.0));\n inner_df = sdRhombus(v_data.xy, vec2(r));\n } else if (shape == 8) {\n outer_df = sdVesica(v_data.xy, 1.1, 0.8);\n inner_df = sdVesica(v_data.xy, r * 1.1, r * 0.8);\n }\n\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n float color_t = u_stroke_width < 0.01 ? 0.0 : smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n\n if(u_stroke_width < 0.01) {\n outputColor = v_color;\n } else {\n outputColor = mix(v_color, v_stroke * u_stroke_opacity, color_t);\n }\n\n if(u_additive > 0.0) {\n outputColor *= opacity_t;\n outputColor = filterColorAlpha(outputColor, outputColor.a);\n } else {\n outputColor.a *= opacity_t;\n outputColor = filterColor(outputColor);\n }\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if(outputColor.a < 0.01) {\n discard;\n } \n}\n";
|
|
20
22
|
/* babel-plugin-inline-import '../shaders/fill_vert.glsl' */
|
|
21
|
-
var pointFillVert = "
|
|
23
|
+
var pointFillVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 11) in vec3 a_Extrude;\nlayout(location = 10) in float a_Shape;\n\nlayout(std140) uniform commonUniforms {\n vec3 u_blur_height_fixed;\n float u_stroke_width;\n float u_additive;\n float u_stroke_opacity;\n float u_size_unit;\n};\n\nout vec4 v_color;\nout vec4 v_stroke;\nout vec4 v_data;\nout float v_radius;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n // \u900F\u660E\u5EA6\u8BA1\u7B97\n v_stroke = stroke; \n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n /*\n * setPickingSize \u8BBE\u7F6E\u62FE\u53D6\u5927\u5C0F\n * u_meter2coord \u5728\u7B49\u9762\u79EF\u5927\u5C0F\u7684\u65F6\u5019\u8BBE\u7F6E\u5355\u4F4D\n */\n float newSize = setPickingSize(a_Size);\n // float newSize = setPickingSize(a_Size) * 0.00001038445708445579;\n\n\n\n // unpack color(vec2)\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n\n if(u_size_unit == 1.0) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n\n v_radius = newSize;\n\n // anti-alias\n // float antialiased_blur = -max(u_blur, antialiasblur);\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, u_blur_height_fixed.x);\n\n vec2 offset = (extrude.xy * (newSize + u_stroke_width) + u_offsets);\n vec3 aPosition = a_Position;\n\n offset = project_pixel(offset);\n offset = rotate_matrix(offset,rotation);\n \n // TODP: /abs(extrude.x) \u662F\u4E3A\u4E86\u517C\u5BB9\u5730\u7403\u6A21\u5F0F\n v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);\n\n\n // vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n float raisingHeight = u_blur_height_fixed.y;\n\n if(u_blur_height_fixed.z < 1.0) { // false\n raisingHeight = project_pixel(u_blur_height_fixed.y);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_blur_height_fixed.y * mapboxZoomScale;\n }\n }\n \n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
22
24
|
var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
23
25
|
_inherits(FillModel, _BaseModel);
|
|
24
26
|
var _super = _createSuper(FillModel);
|
|
@@ -43,13 +45,23 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
43
45
|
heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed,
|
|
44
46
|
_ref$unit = _ref.unit,
|
|
45
47
|
unit = _ref$unit === void 0 ? 'pixel' : _ref$unit;
|
|
46
|
-
|
|
48
|
+
var commonIniform = _objectSpread({
|
|
47
49
|
u_blur_height_fixed: [blur, Number(raisingHeight), Number(heightfixed)],
|
|
48
50
|
u_additive: blend === 'additive' ? 1.0 : 0.0,
|
|
49
51
|
u_stroke_opacity: strokeOpacity,
|
|
50
52
|
u_stroke_width: strokeWidth,
|
|
51
53
|
u_size_unit: SizeUnitType[unit]
|
|
52
54
|
}, this.getStyleAttribute());
|
|
55
|
+
var attributes = this.getStyleAttribute();
|
|
56
|
+
this.uniformBuffers[0].subData({
|
|
57
|
+
offset: 0,
|
|
58
|
+
data: new Uint8Array(new Float32Array([].concat(_toConsumableArray(attributes.u_stroke), _toConsumableArray(attributes.u_offsets), [attributes.u_opacity, attributes.u_rotation])).buffer)
|
|
59
|
+
});
|
|
60
|
+
this.uniformBuffers[1].subData({
|
|
61
|
+
offset: 0,
|
|
62
|
+
data: new Uint8Array(new Float32Array([].concat(_toConsumableArray(commonIniform.u_blur_height_fixed), [commonIniform.u_stroke_width, commonIniform.u_stroke_opacity, commonIniform.u_additive, commonIniform.u_size_unit])).buffer)
|
|
63
|
+
});
|
|
64
|
+
return commonIniform;
|
|
53
65
|
}
|
|
54
66
|
}, {
|
|
55
67
|
key: "getAnimateUniforms",
|
|
@@ -92,7 +104,7 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
92
104
|
key: "buildModels",
|
|
93
105
|
value: function () {
|
|
94
106
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
95
|
-
var _ref3, _ref3$animateOption, animateOption, _this$getShaders, frag, vert, type, model;
|
|
107
|
+
var _ref3, _ref3$animateOption, animateOption, _this$getShaders, frag, vert, type, attributeUniformBuffer, commonUniforms, model;
|
|
96
108
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
97
109
|
while (1) switch (_context2.prev = _context2.next) {
|
|
98
110
|
case 0:
|
|
@@ -101,7 +113,16 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
101
113
|
} : _ref3$animateOption;
|
|
102
114
|
_this$getShaders = this.getShaders(animateOption), frag = _this$getShaders.frag, vert = _this$getShaders.vert, type = _this$getShaders.type;
|
|
103
115
|
this.layer.triangulation = PointFillTriangulation;
|
|
104
|
-
|
|
116
|
+
attributeUniformBuffer = this.rendererService.createBuffer({
|
|
117
|
+
data: new Float32Array(4 + 2 + 1 + 1),
|
|
118
|
+
isUBO: true
|
|
119
|
+
});
|
|
120
|
+
commonUniforms = this.rendererService.createBuffer({
|
|
121
|
+
data: new Float32Array(8),
|
|
122
|
+
isUBO: true
|
|
123
|
+
});
|
|
124
|
+
this.uniformBuffers.push(attributeUniformBuffer, commonUniforms);
|
|
125
|
+
_context2.next = 8;
|
|
105
126
|
return this.layer.buildLayerModel({
|
|
106
127
|
moduleName: type,
|
|
107
128
|
vertexShader: vert,
|
|
@@ -112,10 +133,10 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
112
133
|
enable: false
|
|
113
134
|
}
|
|
114
135
|
});
|
|
115
|
-
case
|
|
136
|
+
case 8:
|
|
116
137
|
model = _context2.sent;
|
|
117
138
|
return _context2.abrupt("return", [model]);
|
|
118
|
-
case
|
|
139
|
+
case 10:
|
|
119
140
|
case "end":
|
|
120
141
|
return _context2.stop();
|
|
121
142
|
}
|
|
@@ -173,6 +194,7 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
173
194
|
type: AttributeType.Attribute,
|
|
174
195
|
descriptor: {
|
|
175
196
|
name: 'a_Extrude',
|
|
197
|
+
shaderLocation: ShaderLocation.EXTRUDE,
|
|
176
198
|
buffer: {
|
|
177
199
|
// give the WebGL driver a hint that this buffer may change
|
|
178
200
|
usage: gl.DYNAMIC_DRAW,
|
|
@@ -194,6 +216,7 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
194
216
|
type: AttributeType.Attribute,
|
|
195
217
|
descriptor: {
|
|
196
218
|
name: 'a_Size',
|
|
219
|
+
shaderLocation: ShaderLocation.SIZE,
|
|
197
220
|
buffer: {
|
|
198
221
|
// give the WebGL driver a hint that this buffer may change
|
|
199
222
|
usage: gl.DYNAMIC_DRAW,
|
|
@@ -215,6 +238,7 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
215
238
|
type: AttributeType.Attribute,
|
|
216
239
|
descriptor: {
|
|
217
240
|
name: 'a_Shape',
|
|
241
|
+
shaderLocation: ShaderLocation.SHAPE,
|
|
218
242
|
buffer: {
|
|
219
243
|
// give the WebGL driver a hint that this buffer may change
|
|
220
244
|
usage: gl.DYNAMIC_DRAW,
|
|
@@ -157,7 +157,7 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
157
157
|
value: function clearModels() {
|
|
158
158
|
var _this$texture;
|
|
159
159
|
this.iconService.off('imageUpdate', this.updateTexture);
|
|
160
|
-
(_this$texture = this.texture) === null || _this$texture === void 0
|
|
160
|
+
(_this$texture = this.texture) === null || _this$texture === void 0 || _this$texture.destroy();
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
// overwrite baseModel func
|
package/es/point/models/image.js
CHANGED
|
@@ -105,7 +105,7 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
105
105
|
key: "clearModels",
|
|
106
106
|
value: function clearModels() {
|
|
107
107
|
var _this$texture;
|
|
108
|
-
(_this$texture = this.texture) === null || _this$texture === void 0
|
|
108
|
+
(_this$texture = this.texture) === null || _this$texture === void 0 || _this$texture.destroy();
|
|
109
109
|
this.iconService.off('imageUpdate', this.updateTexture);
|
|
110
110
|
}
|
|
111
111
|
}, {
|
|
@@ -10,13 +10,12 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
10
10
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
11
|
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; } }
|
|
12
12
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
13
|
-
import { lodashUtil } from '@antv/l7-utils';
|
|
14
13
|
import BaseModel from "../../core/BaseModel";
|
|
14
|
+
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
15
15
|
/* babel-plugin-inline-import '../shaders/normal_frag.glsl' */
|
|
16
|
-
var normalFrag = "
|
|
16
|
+
var normalFrag = "in vec4 v_color;\nout vec4 outputColor;\nvoid main() {\n outputColor = v_color;\n}";
|
|
17
17
|
/* babel-plugin-inline-import '../shaders/normal_vert.glsl' */
|
|
18
|
-
var normalVert = "
|
|
19
|
-
var isNumber = lodashUtil.isNumber;
|
|
18
|
+
var normalVert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\n\nlayout(std140) uniform u_Common {\n float u_size_scale;\n};\n\nout vec4 v_color;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n\nvoid main() {\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(a_Position, 1.0);\n } else {\n vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2., -a_Size /2., 0., 0.);\n gl_Position = project_common_position_to_clipspace(project_pos);\n }\n\n gl_PointSize = a_Size * u_size_scale * 2.0 * u_DevicePixelRatio;\n}\n";
|
|
20
19
|
export function PointTriangulation(feature) {
|
|
21
20
|
var coordinates = feature.coordinates;
|
|
22
21
|
return {
|
|
@@ -42,10 +41,19 @@ var NormalModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
42
41
|
}, {
|
|
43
42
|
key: "getUninforms",
|
|
44
43
|
value: function getUninforms() {
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
var attributes = this.getStyleAttribute();
|
|
45
|
+
// FIXME: No need to update each frame
|
|
46
|
+
this.uniformBuffers[0].subData({
|
|
47
|
+
offset: 0,
|
|
48
|
+
data: new Uint8Array(new Float32Array([].concat(_toConsumableArray(attributes.u_stroke), _toConsumableArray(attributes.u_offsets), [attributes.u_opacity, attributes.u_rotation])).buffer)
|
|
49
|
+
});
|
|
50
|
+
this.uniformBuffers[1].subData({
|
|
51
|
+
offset: 0,
|
|
52
|
+
data: new Uint8Array(new Float32Array([0.5]).buffer)
|
|
53
|
+
});
|
|
54
|
+
return _objectSpread({
|
|
55
|
+
u_size_scale: 0.5
|
|
56
|
+
}, attributes);
|
|
49
57
|
}
|
|
50
58
|
}, {
|
|
51
59
|
key: "initModels",
|
|
@@ -70,12 +78,21 @@ var NormalModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
70
78
|
key: "buildModels",
|
|
71
79
|
value: function () {
|
|
72
80
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
73
|
-
var model;
|
|
81
|
+
var uniformBuffer, commonBuffer, model;
|
|
74
82
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
75
83
|
while (1) switch (_context2.prev = _context2.next) {
|
|
76
84
|
case 0:
|
|
77
85
|
this.layer.triangulation = PointTriangulation;
|
|
78
|
-
|
|
86
|
+
uniformBuffer = this.rendererService.createBuffer({
|
|
87
|
+
data: new Float32Array(4 + 2 + 1 + 1),
|
|
88
|
+
isUBO: true
|
|
89
|
+
});
|
|
90
|
+
commonBuffer = this.rendererService.createBuffer({
|
|
91
|
+
data: new Float32Array(4),
|
|
92
|
+
isUBO: true
|
|
93
|
+
});
|
|
94
|
+
this.uniformBuffers.push(uniformBuffer, commonBuffer);
|
|
95
|
+
_context2.next = 6;
|
|
79
96
|
return this.layer.buildLayerModel({
|
|
80
97
|
moduleName: 'pointNormal',
|
|
81
98
|
vertexShader: normalVert,
|
|
@@ -88,10 +105,10 @@ var NormalModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
88
105
|
primitive: gl.POINTS,
|
|
89
106
|
pick: false
|
|
90
107
|
});
|
|
91
|
-
case
|
|
108
|
+
case 6:
|
|
92
109
|
model = _context2.sent;
|
|
93
110
|
return _context2.abrupt("return", [model]);
|
|
94
|
-
case
|
|
111
|
+
case 8:
|
|
95
112
|
case "end":
|
|
96
113
|
return _context2.stop();
|
|
97
114
|
}
|
|
@@ -115,6 +132,7 @@ var NormalModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
115
132
|
type: AttributeType.Attribute,
|
|
116
133
|
descriptor: {
|
|
117
134
|
name: 'a_Size',
|
|
135
|
+
shaderLocation: ShaderLocation.SIZE,
|
|
118
136
|
buffer: {
|
|
119
137
|
usage: gl.DYNAMIC_DRAW,
|
|
120
138
|
data: [],
|
package/es/point/models/text.js
CHANGED
|
@@ -234,7 +234,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
234
234
|
key: "clearModels",
|
|
235
235
|
value: function clearModels() {
|
|
236
236
|
var _this$texture;
|
|
237
|
-
(_this$texture = this.texture) === null || _this$texture === void 0
|
|
237
|
+
(_this$texture = this.texture) === null || _this$texture === void 0 || _this$texture.destroy();
|
|
238
238
|
// TODO this.mapping
|
|
239
239
|
this.layer.off('remapping', this.mapping);
|
|
240
240
|
}
|