@antv/l7-layers 2.21.10 → 2.21.11-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/citybuliding/models/build.d.ts +16 -0
- package/es/citybuliding/models/build.js +18 -20
- package/es/citybuliding/shaders/build_frag.glsl +6 -6
- package/es/citybuliding/shaders/build_vert.glsl +8 -14
- package/es/core/BaseLayer.d.ts +0 -1
- package/es/core/BaseLayer.js +9 -19
- package/es/core/BaseModel.d.ts +15 -2
- package/es/core/BaseModel.js +98 -64
- package/es/core/CommonStyleAttribute.d.ts +14 -18
- package/es/core/CommonStyleAttribute.js +23 -67
- package/es/core/shape/extrude.js +6 -3
- package/es/core/triangulation.js +22 -50
- package/es/core/utils.d.ts +4 -0
- package/es/core/utils.js +33 -0
- package/es/earth/models/atmosphere.d.ts +15 -0
- package/es/earth/models/atmosphere.js +30 -24
- package/es/earth/models/base.d.ts +15 -0
- package/es/earth/models/base.js +30 -24
- package/es/earth/models/bloomsphere.d.ts +15 -0
- package/es/earth/models/bloomsphere.js +30 -24
- package/es/earth/shaders/atmosphere/atmosphere_vert.glsl +7 -5
- package/es/earth/shaders/base/base_vert.glsl +3 -3
- package/es/earth/shaders/bloomshpere/bloomsphere_vert.glsl +5 -4
- package/es/geometry/models/billboard.d.ts +15 -0
- package/es/geometry/models/billboard.js +14 -8
- package/es/geometry/models/plane.d.ts +14 -0
- package/es/geometry/models/plane.js +10 -10
- package/es/geometry/models/sprite.js +3 -9
- package/es/geometry/shaders/billboard_vert.glsl +28 -25
- package/es/geometry/shaders/plane_vert.glsl +6 -6
- package/es/geometry/shaders/sprite_vert.glsl +7 -9
- package/es/heatmap/models/grid.d.ts +14 -0
- package/es/heatmap/models/grid.js +10 -3
- package/es/heatmap/models/grid3d.d.ts +16 -0
- package/es/heatmap/models/grid3d.js +14 -6
- package/es/heatmap/models/heatmap.d.ts +20 -1
- package/es/heatmap/models/heatmap.js +96 -83
- package/es/heatmap/models/hexagon.d.ts +14 -0
- package/es/heatmap/models/hexagon.js +9 -3
- package/es/heatmap/shaders/grid/grid_vert.glsl +30 -42
- package/es/heatmap/shaders/grid3d/grid_3d_vert.glsl +14 -26
- package/es/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +19 -16
- package/es/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +16 -22
- package/es/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -4
- package/es/heatmap/shaders/hexagon/hexagon_vert.glsl +13 -23
- package/es/image/models/image.d.ts +14 -0
- package/es/image/models/image.js +11 -7
- package/es/image/shaders/image_vert.glsl +7 -6
- package/es/line/models/arc.d.ts +18 -0
- package/es/line/models/arc.js +57 -8
- package/es/line/models/arc_3d.d.ts +18 -0
- package/es/line/models/arc_3d.js +55 -7
- package/es/line/models/flow.d.ts +17 -0
- package/es/line/models/flow.js +35 -7
- package/es/line/models/great_circle.d.ts +17 -0
- package/es/line/models/great_circle.js +34 -6
- package/es/line/models/line.d.ts +17 -0
- package/es/line/models/line.js +17 -8
- package/es/line/models/simple_line.d.ts +14 -0
- package/es/line/models/simple_line.js +12 -47
- package/es/line/models/wall.d.ts +17 -0
- package/es/line/models/wall.js +22 -48
- package/es/line/shaders/arc/line_arc_vert.glsl +44 -52
- package/es/line/shaders/arc3d/line_arc_3d_vert.glsl +15 -20
- package/es/line/shaders/flow/flow_line_vert.glsl +30 -48
- package/es/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +53 -74
- package/es/line/shaders/line/line_vert.glsl +31 -48
- package/es/line/shaders/simple/simpleline_vert.glsl +18 -23
- package/es/line/shaders/wall/wall_vert.glsl +36 -45
- package/es/mask/models/fill.js +2 -1
- package/es/mask/shaders/mask_vert.glsl +2 -7
- package/es/plugins/DataMappingPlugin.d.ts +0 -1
- package/es/plugins/DataMappingPlugin.js +1 -24
- package/es/plugins/PixelPickingPlugin.js +2 -2
- package/es/plugins/RegisterStyleAttributePlugin.d.ts +0 -1
- package/es/plugins/RegisterStyleAttributePlugin.js +3 -25
- package/es/plugins/ShaderUniformPlugin.d.ts +0 -5
- package/es/plugins/ShaderUniformPlugin.js +4 -35
- package/es/point/models/billboard_point.d.ts +14 -0
- package/es/point/models/billboard_point.js +11 -3
- package/es/point/models/earthExtrude.d.ts +16 -0
- package/es/point/models/earthExtrude.js +15 -8
- package/es/point/models/earthFill.d.ts +16 -0
- package/es/point/models/earthFill.js +13 -5
- package/es/point/models/extrude.d.ts +16 -0
- package/es/point/models/extrude.js +19 -12
- package/es/point/models/fill.d.ts +16 -0
- package/es/point/models/fill.js +16 -5
- package/es/point/models/fillImage.d.ts +16 -0
- package/es/point/models/fillImage.js +16 -16
- package/es/point/models/image.d.ts +15 -0
- package/es/point/models/image.js +14 -4
- package/es/point/models/normal.d.ts +14 -0
- package/es/point/models/normal.js +11 -3
- package/es/point/models/radar.d.ts +15 -0
- package/es/point/models/radar.js +13 -4
- package/es/point/models/text.d.ts +16 -0
- package/es/point/models/text.js +18 -11
- package/es/point/shaders/billboard/billboard_point_vert.glsl +10 -13
- package/es/point/shaders/earthExtrude/earthExtrude_vert.glsl +15 -25
- package/es/point/shaders/earthFill/earthFill_vert.glsl +6 -6
- package/es/point/shaders/extrude/extrude_vert.glsl +35 -39
- package/es/point/shaders/fill/fill_vert.glsl +12 -14
- package/es/point/shaders/fillImage/fillImage_vert.glsl +16 -28
- package/es/point/shaders/image/image_vert.glsl +15 -12
- package/es/point/shaders/normal/normal_vert.glsl +7 -10
- package/es/point/shaders/radar/radar_vert.glsl +11 -11
- package/es/point/shaders/text/text_vert.glsl +10 -9
- package/es/polygon/models/extrude.d.ts +16 -0
- package/es/polygon/models/extrude.js +26 -26
- package/es/polygon/models/extrusion.d.ts +16 -0
- package/es/polygon/models/extrusion.js +34 -4
- package/es/polygon/models/fill.d.ts +14 -0
- package/es/polygon/models/fill.js +12 -4
- package/es/polygon/models/ocean.d.ts +14 -0
- package/es/polygon/models/ocean.js +11 -6
- package/es/polygon/models/water.d.ts +14 -0
- package/es/polygon/models/water.js +11 -6
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +17 -15
- package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +22 -20
- package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +17 -17
- package/es/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +8 -8
- package/es/polygon/shaders/fill/fill_linear_vert.glsl +7 -6
- package/es/polygon/shaders/fill/fill_vert.glsl +10 -12
- package/es/polygon/shaders/ocean/ocean_vert.glsl +3 -4
- package/es/polygon/shaders/water/polygon_water_vert.glsl +5 -5
- package/es/raster/index.d.ts +1 -1
- package/es/raster/index.js +1 -1
- package/es/raster/models/raster.d.ts +14 -0
- package/es/raster/models/raster.js +13 -3
- package/es/raster/models/rasterRgb.d.ts +14 -0
- package/es/raster/models/rasterRgb.js +12 -3
- package/es/raster/models/rasterTerrainRgb.d.ts +14 -0
- package/es/raster/models/rasterTerrainRgb.js +11 -3
- package/es/raster/shaders/raster/raster_2d_vert.glsl +6 -6
- package/es/raster/shaders/rgb/raster_rgb_vert.glsl +11 -11
- package/es/raster/shaders/terrain/terrain_rgb_vert.glsl +11 -11
- package/es/tile/core/BaseLayer.js +0 -16
- package/es/utils/extrude_polyline.d.ts +0 -15
- package/es/utils/extrude_polyline.js +0 -217
- package/es/wind/models/wind.d.ts +14 -0
- package/es/wind/models/wind.js +9 -1
- package/es/wind/shaders/wind_vert.glsl +6 -5
- package/lib/citybuliding/models/build.d.ts +16 -0
- package/lib/citybuliding/models/build.js +18 -20
- package/lib/citybuliding/shaders/build_frag.glsl +6 -6
- package/lib/citybuliding/shaders/build_vert.glsl +8 -14
- package/lib/core/BaseLayer.d.ts +0 -1
- package/lib/core/BaseLayer.js +9 -19
- package/lib/core/BaseModel.d.ts +15 -2
- package/lib/core/BaseModel.js +96 -62
- package/lib/core/CommonStyleAttribute.d.ts +14 -18
- package/lib/core/CommonStyleAttribute.js +23 -68
- package/lib/core/shape/extrude.js +6 -3
- package/lib/core/triangulation.js +22 -50
- package/lib/core/utils.d.ts +4 -0
- package/lib/core/utils.js +35 -0
- package/lib/earth/models/atmosphere.d.ts +15 -0
- package/lib/earth/models/atmosphere.js +30 -24
- package/lib/earth/models/base.d.ts +15 -0
- package/lib/earth/models/base.js +30 -24
- package/lib/earth/models/bloomsphere.d.ts +15 -0
- package/lib/earth/models/bloomsphere.js +30 -24
- package/lib/earth/shaders/atmosphere/atmosphere_vert.glsl +7 -5
- package/lib/earth/shaders/base/base_vert.glsl +3 -3
- package/lib/earth/shaders/bloomshpere/bloomsphere_vert.glsl +5 -4
- package/lib/geometry/models/billboard.d.ts +15 -0
- package/lib/geometry/models/billboard.js +14 -8
- package/lib/geometry/models/plane.d.ts +14 -0
- package/lib/geometry/models/plane.js +10 -10
- package/lib/geometry/models/sprite.js +3 -9
- package/lib/geometry/shaders/billboard_vert.glsl +28 -25
- package/lib/geometry/shaders/plane_vert.glsl +6 -6
- package/lib/geometry/shaders/sprite_vert.glsl +7 -9
- package/lib/heatmap/models/grid.d.ts +14 -0
- package/lib/heatmap/models/grid.js +10 -3
- package/lib/heatmap/models/grid3d.d.ts +16 -0
- package/lib/heatmap/models/grid3d.js +14 -6
- package/lib/heatmap/models/heatmap.d.ts +20 -1
- package/lib/heatmap/models/heatmap.js +95 -82
- package/lib/heatmap/models/hexagon.d.ts +14 -0
- package/lib/heatmap/models/hexagon.js +9 -3
- package/lib/heatmap/shaders/grid/grid_vert.glsl +30 -42
- package/lib/heatmap/shaders/grid3d/grid_3d_vert.glsl +14 -26
- package/lib/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +19 -16
- package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +16 -22
- package/lib/heatmap/shaders/heatmap/heatmap_vert.glsl +3 -4
- package/lib/heatmap/shaders/hexagon/hexagon_vert.glsl +13 -23
- package/lib/image/models/image.d.ts +14 -0
- package/lib/image/models/image.js +11 -7
- package/lib/image/shaders/image_vert.glsl +7 -6
- package/lib/line/models/arc.d.ts +18 -0
- package/lib/line/models/arc.js +56 -7
- package/lib/line/models/arc_3d.d.ts +18 -0
- package/lib/line/models/arc_3d.js +55 -7
- package/lib/line/models/flow.d.ts +17 -0
- package/lib/line/models/flow.js +35 -7
- package/lib/line/models/great_circle.d.ts +17 -0
- package/lib/line/models/great_circle.js +33 -5
- package/lib/line/models/line.d.ts +17 -0
- package/lib/line/models/line.js +17 -8
- package/lib/line/models/simple_line.d.ts +14 -0
- package/lib/line/models/simple_line.js +12 -47
- package/lib/line/models/wall.d.ts +17 -0
- package/lib/line/models/wall.js +22 -48
- package/lib/line/shaders/arc/line_arc_vert.glsl +44 -52
- package/lib/line/shaders/arc3d/line_arc_3d_vert.glsl +15 -20
- package/lib/line/shaders/flow/flow_line_vert.glsl +30 -48
- package/lib/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +53 -74
- package/lib/line/shaders/line/line_vert.glsl +31 -48
- package/lib/line/shaders/simple/simpleline_vert.glsl +18 -23
- package/lib/line/shaders/wall/wall_vert.glsl +36 -45
- package/lib/mask/models/fill.js +2 -1
- package/lib/mask/shaders/mask_vert.glsl +2 -7
- package/lib/plugins/DataMappingPlugin.d.ts +0 -1
- package/lib/plugins/DataMappingPlugin.js +0 -23
- package/lib/plugins/PixelPickingPlugin.js +1 -1
- package/lib/plugins/RegisterStyleAttributePlugin.d.ts +0 -1
- package/lib/plugins/RegisterStyleAttributePlugin.js +2 -24
- package/lib/plugins/ShaderUniformPlugin.d.ts +0 -5
- package/lib/plugins/ShaderUniformPlugin.js +4 -35
- package/lib/point/models/billboard_point.d.ts +14 -0
- package/lib/point/models/billboard_point.js +11 -3
- package/lib/point/models/earthExtrude.d.ts +16 -0
- package/lib/point/models/earthExtrude.js +14 -7
- package/lib/point/models/earthFill.d.ts +16 -0
- package/lib/point/models/earthFill.js +13 -5
- package/lib/point/models/extrude.d.ts +16 -0
- package/lib/point/models/extrude.js +18 -11
- package/lib/point/models/fill.d.ts +16 -0
- package/lib/point/models/fill.js +16 -5
- package/lib/point/models/fillImage.d.ts +16 -0
- package/lib/point/models/fillImage.js +16 -16
- package/lib/point/models/image.d.ts +15 -0
- package/lib/point/models/image.js +14 -4
- package/lib/point/models/normal.d.ts +14 -0
- package/lib/point/models/normal.js +11 -3
- package/lib/point/models/radar.d.ts +15 -0
- package/lib/point/models/radar.js +13 -4
- package/lib/point/models/text.d.ts +16 -0
- package/lib/point/models/text.js +18 -11
- package/lib/point/shaders/billboard/billboard_point_vert.glsl +10 -13
- package/lib/point/shaders/earthExtrude/earthExtrude_vert.glsl +15 -25
- package/lib/point/shaders/earthFill/earthFill_vert.glsl +6 -6
- package/lib/point/shaders/extrude/extrude_vert.glsl +35 -39
- package/lib/point/shaders/fill/fill_vert.glsl +12 -14
- package/lib/point/shaders/fillImage/fillImage_vert.glsl +16 -28
- package/lib/point/shaders/image/image_vert.glsl +15 -12
- package/lib/point/shaders/normal/normal_vert.glsl +7 -10
- package/lib/point/shaders/radar/radar_vert.glsl +11 -11
- package/lib/point/shaders/text/text_vert.glsl +10 -9
- package/lib/polygon/models/extrude.d.ts +16 -0
- package/lib/polygon/models/extrude.js +25 -25
- package/lib/polygon/models/extrusion.d.ts +16 -0
- package/lib/polygon/models/extrusion.js +34 -4
- package/lib/polygon/models/fill.d.ts +14 -0
- package/lib/polygon/models/fill.js +12 -4
- package/lib/polygon/models/ocean.d.ts +14 -0
- package/lib/polygon/models/ocean.js +11 -6
- package/lib/polygon/models/water.d.ts +14 -0
- package/lib/polygon/models/water.js +11 -6
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +17 -15
- package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +22 -20
- package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +17 -17
- package/lib/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +8 -8
- package/lib/polygon/shaders/fill/fill_linear_vert.glsl +7 -6
- package/lib/polygon/shaders/fill/fill_vert.glsl +10 -12
- package/lib/polygon/shaders/ocean/ocean_vert.glsl +3 -4
- package/lib/polygon/shaders/water/polygon_water_vert.glsl +5 -5
- package/lib/raster/index.d.ts +1 -1
- package/lib/raster/index.js +2 -2
- package/lib/raster/models/raster.d.ts +14 -0
- package/lib/raster/models/raster.js +13 -3
- package/lib/raster/models/rasterRgb.d.ts +14 -0
- package/lib/raster/models/rasterRgb.js +12 -3
- package/lib/raster/models/rasterTerrainRgb.d.ts +14 -0
- package/lib/raster/models/rasterTerrainRgb.js +11 -3
- package/lib/raster/shaders/raster/raster_2d_vert.glsl +6 -6
- package/lib/raster/shaders/rgb/raster_rgb_vert.glsl +11 -11
- package/lib/raster/shaders/terrain/terrain_rgb_vert.glsl +11 -11
- package/lib/tile/core/BaseLayer.js +0 -16
- package/lib/utils/extrude_polyline.d.ts +0 -15
- package/lib/utils/extrude_polyline.js +0 -217
- package/lib/wind/models/wind.d.ts +14 -0
- package/lib/wind/models/wind.js +9 -1
- package/lib/wind/shaders/wind_vert.glsl +6 -5
- package/package.json +6 -6
package/lib/core/BaseModel.js
CHANGED
|
@@ -15,17 +15,20 @@ var _stencil = require("../utils/stencil");
|
|
|
15
15
|
var _CommonStyleAttribute = require("./CommonStyleAttribute");
|
|
16
16
|
var _constant = require("./constant");
|
|
17
17
|
var _utils = require("./utils");
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
stroke: _CommonStyleAttribute.ShaderLocation.STROKE,
|
|
21
|
-
offsets: _CommonStyleAttribute.ShaderLocation.OFFSETS,
|
|
22
|
-
rotation: _CommonStyleAttribute.ShaderLocation.ROTATION,
|
|
23
|
-
extrusionBase: _CommonStyleAttribute.ShaderLocation.EXTRUSION_BASE,
|
|
24
|
-
thetaOffset: 15
|
|
25
|
-
};
|
|
18
|
+
// 属性索引宏定义前缀,使用命名空间避免 define 名称重复情况
|
|
19
|
+
const DEFINE_ATTRIBUTE_LOCATION_PREFIX = 'ATTRIBUTE_LOCATION_';
|
|
26
20
|
|
|
27
21
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28
22
|
class BaseModel {
|
|
23
|
+
/**
|
|
24
|
+
* Attribute Layout Location in Shader
|
|
25
|
+
*/
|
|
26
|
+
get attributeLocation() {
|
|
27
|
+
return (0, _objectSpread2.default)({}, _CommonStyleAttribute.COMMON_ATTRIBUTE_LOCATION);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// style texture data mapping
|
|
31
|
+
|
|
29
32
|
// 不支持数据映射的buffer
|
|
30
33
|
|
|
31
34
|
// style texture data mapping
|
|
@@ -34,7 +37,6 @@ class BaseModel {
|
|
|
34
37
|
(0, _defineProperty2.default)(this, "triangulation", void 0);
|
|
35
38
|
(0, _defineProperty2.default)(this, "uniformBuffers", []);
|
|
36
39
|
(0, _defineProperty2.default)(this, "textures", []);
|
|
37
|
-
// style texture data mapping
|
|
38
40
|
(0, _defineProperty2.default)(this, "createTexture2D", void 0);
|
|
39
41
|
(0, _defineProperty2.default)(this, "preStyleAttribute", {});
|
|
40
42
|
(0, _defineProperty2.default)(this, "encodeStyleAttribute", {});
|
|
@@ -185,55 +187,18 @@ class BaseModel {
|
|
|
185
187
|
this.layer.setAnimateStartTime();
|
|
186
188
|
}
|
|
187
189
|
}
|
|
188
|
-
|
|
189
|
-
// 动态注入参与数据映射的uniform
|
|
190
190
|
getInject() {
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
//
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
str += `#define USE_ATTRIBUTE_${key.toUpperCase()} 0.0; \n\n`;
|
|
203
|
-
} else {
|
|
204
|
-
uniforms.push(` ${_constant.DefaultUniformStyleType[key]} u_${key};`);
|
|
205
|
-
}
|
|
206
|
-
let location = shaderLocationMap[key];
|
|
207
|
-
if (!location && key === 'THETA_OFFSET') {
|
|
208
|
-
location = 15;
|
|
209
|
-
}
|
|
210
|
-
str += `
|
|
211
|
-
#ifdef USE_ATTRIBUTE_${key.toUpperCase()}
|
|
212
|
-
layout(location = ${shaderLocationMap[key]}) in ${_constant.DefaultUniformStyleType[key]} a_${key.charAt(0).toUpperCase() + key.slice(1)};
|
|
213
|
-
#endif\n
|
|
214
|
-
`;
|
|
215
|
-
});
|
|
216
|
-
const attributeUniforms = uniforms.length ? `
|
|
217
|
-
layout(std140) uniform AttributeUniforms {
|
|
218
|
-
${uniforms.join('\n')}
|
|
219
|
-
};
|
|
220
|
-
` : '';
|
|
221
|
-
str += attributeUniforms;
|
|
222
|
-
let innerStr = '';
|
|
223
|
-
this.layer.enableShaderEncodeStyles.forEach(key => {
|
|
224
|
-
innerStr += `\n
|
|
225
|
-
#ifdef USE_ATTRIBUTE_${key.toUpperCase()}
|
|
226
|
-
${_constant.DefaultUniformStyleType[key]} ${key} = a_${key.charAt(0).toUpperCase() + key.slice(1)};
|
|
227
|
-
#else
|
|
228
|
-
${_constant.DefaultUniformStyleType[key]} ${key} = u_${key};
|
|
229
|
-
#endif\n
|
|
230
|
-
`;
|
|
231
|
-
});
|
|
232
|
-
return {
|
|
233
|
-
'vs:#decl': str,
|
|
234
|
-
'fs:#decl': attributeUniforms,
|
|
235
|
-
'vs:#main-start': innerStr
|
|
236
|
-
};
|
|
191
|
+
const shaderInject = getDynamicStyleInject(this.layer.enableShaderEncodeStyles, this.layer.encodeStyleAttribute);
|
|
192
|
+
return shaderInject;
|
|
193
|
+
}
|
|
194
|
+
getDefines() {
|
|
195
|
+
// define atribute Layout Location
|
|
196
|
+
const atributeLocationDefines = Object.keys(this.attributeLocation).reduce((result, key) => {
|
|
197
|
+
const normalizedKey = DEFINE_ATTRIBUTE_LOCATION_PREFIX + key;
|
|
198
|
+
result[normalizedKey] = this.attributeLocation[key];
|
|
199
|
+
return result;
|
|
200
|
+
}, {});
|
|
201
|
+
return (0, _objectSpread2.default)({}, atributeLocationDefines);
|
|
237
202
|
}
|
|
238
203
|
|
|
239
204
|
// 获取数据映射样式
|
|
@@ -254,14 +219,36 @@ ${uniforms.join('\n')}
|
|
|
254
219
|
});
|
|
255
220
|
return options;
|
|
256
221
|
}
|
|
222
|
+
|
|
257
223
|
// 注册数据映射样式
|
|
258
224
|
registerStyleAttribute() {
|
|
259
225
|
Object.keys(this.layer.encodeStyleAttribute).forEach(key => {
|
|
260
226
|
const options = (0, _CommonStyleAttribute.getCommonStyleAttributeOptions)(key);
|
|
261
227
|
if (options) {
|
|
262
228
|
this.styleAttributeService.registerStyleAttribute(options);
|
|
263
|
-
|
|
264
|
-
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* 注册 Position 属性 64 位地位部分,当经纬度数据开启双精度浮点数使用,
|
|
235
|
+
* 避免大于 20层级以上出现数据偏移
|
|
236
|
+
*/
|
|
237
|
+
registerPosition64LowAttribute(enable64bitPosition = true) {
|
|
238
|
+
// save low part for enabled double precision POSITION attribute
|
|
239
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
240
|
+
name: 'position64Low',
|
|
241
|
+
type: _l7Core.AttributeType.Attribute,
|
|
242
|
+
descriptor: {
|
|
243
|
+
name: 'a_Position64Low',
|
|
244
|
+
shaderLocation: this.attributeLocation.POSITION_64LOW,
|
|
245
|
+
buffer: {
|
|
246
|
+
data: [],
|
|
247
|
+
type: _l7Core.gl.FLOAT
|
|
248
|
+
},
|
|
249
|
+
size: 2,
|
|
250
|
+
update: (feature, featureIdx, vertex) => {
|
|
251
|
+
return enable64bitPosition ? [(0, _l7Utils.fp64LowPart)(vertex[0]), (0, _l7Utils.fp64LowPart)(vertex[1])] : [0, 0];
|
|
265
252
|
}
|
|
266
253
|
}
|
|
267
254
|
});
|
|
@@ -276,14 +263,16 @@ ${uniforms.join('\n')}
|
|
|
276
263
|
this.attributeUnifoms = this.rendererService.createBuffer({
|
|
277
264
|
data: new Float32Array((0, _utils.MultipleOfFourNumber)(attrUniforms.uniformsLength)).fill(0),
|
|
278
265
|
// 长度需要大于等于 4
|
|
279
|
-
isUBO: true
|
|
266
|
+
isUBO: true,
|
|
267
|
+
label: 'layerModelAttributeUnifoms'
|
|
280
268
|
});
|
|
281
269
|
this.uniformBuffers.push(this.attributeUnifoms);
|
|
282
270
|
}
|
|
283
271
|
if (commonUniforms.uniformsLength !== 0) {
|
|
284
272
|
this.commonUnifoms = this.rendererService.createBuffer({
|
|
285
273
|
data: new Float32Array((0, _utils.MultipleOfFourNumber)(commonUniforms.uniformsLength)).fill(0),
|
|
286
|
-
isUBO: true
|
|
274
|
+
isUBO: true,
|
|
275
|
+
label: 'layerModelCommonUnifoms'
|
|
287
276
|
});
|
|
288
277
|
this.uniformBuffers.push(this.commonUnifoms);
|
|
289
278
|
}
|
|
@@ -338,4 +327,49 @@ ${uniforms.join('\n')}
|
|
|
338
327
|
});
|
|
339
328
|
}
|
|
340
329
|
}
|
|
341
|
-
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* 获取动态注入参与数据映射 uniform/attribute
|
|
333
|
+
*/
|
|
334
|
+
exports.default = BaseModel;
|
|
335
|
+
function getDynamicStyleInject(shaderEncodeStyles, styleAttribute) {
|
|
336
|
+
const uniforms = [];
|
|
337
|
+
let vsDeclInjection = '';
|
|
338
|
+
|
|
339
|
+
// 支持数据映射的类型
|
|
340
|
+
shaderEncodeStyles.forEach(key => {
|
|
341
|
+
const upperCaseKey = key.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase();
|
|
342
|
+
const shaderDefineName = DEFINE_ATTRIBUTE_LOCATION_PREFIX + upperCaseKey;
|
|
343
|
+
if (styleAttribute[key]) {
|
|
344
|
+
// 配置了数据映射的类型
|
|
345
|
+
vsDeclInjection += `#define USE_ATTRIBUTE_${upperCaseKey} 0.0 \n`;
|
|
346
|
+
} else {
|
|
347
|
+
uniforms.push(` ${_constant.DefaultUniformStyleType[key]} u_${key};`);
|
|
348
|
+
}
|
|
349
|
+
vsDeclInjection += `
|
|
350
|
+
#ifdef USE_ATTRIBUTE_${upperCaseKey}
|
|
351
|
+
layout(location = ${shaderDefineName}) in ${_constant.DefaultUniformStyleType[key]} a_${key.charAt(0).toUpperCase() + key.slice(1)};
|
|
352
|
+
#endif \n`;
|
|
353
|
+
});
|
|
354
|
+
const fsDeclInjection = uniforms.length ? `
|
|
355
|
+
layout(std140) uniform AttributeUniforms {
|
|
356
|
+
${uniforms.join('\n')}
|
|
357
|
+
};\n` : '';
|
|
358
|
+
vsDeclInjection += fsDeclInjection;
|
|
359
|
+
let vsMainInjection = '';
|
|
360
|
+
shaderEncodeStyles.forEach(key => {
|
|
361
|
+
const upperCaseKey = key.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase();
|
|
362
|
+
vsMainInjection += `
|
|
363
|
+
#ifdef USE_ATTRIBUTE_${upperCaseKey}
|
|
364
|
+
${_constant.DefaultUniformStyleType[key]} ${key} = a_${key.charAt(0).toUpperCase() + key.slice(1)};
|
|
365
|
+
#else
|
|
366
|
+
${_constant.DefaultUniformStyleType[key]} ${key} = u_${key};
|
|
367
|
+
#endif
|
|
368
|
+
`;
|
|
369
|
+
});
|
|
370
|
+
return {
|
|
371
|
+
'vs:#decl': vsDeclInjection,
|
|
372
|
+
'fs:#decl': fsDeclInjection,
|
|
373
|
+
'vs:#main-start': vsMainInjection
|
|
374
|
+
};
|
|
375
|
+
}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import type { IStyleAttribute } from '@antv/l7-core';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
NORMAL = 13,
|
|
17
|
-
UV = 14,
|
|
18
|
-
LINEAR = 15
|
|
19
|
-
}
|
|
2
|
+
/**
|
|
3
|
+
* Attribute Layout Location in Shader
|
|
4
|
+
*/
|
|
5
|
+
export declare const COMMON_ATTRIBUTE_LOCATION: {
|
|
6
|
+
readonly POSITION: 0;
|
|
7
|
+
readonly POSITION_64LOW: 1;
|
|
8
|
+
readonly COLOR: 2;
|
|
9
|
+
readonly PICKING_COLOR: 3;
|
|
10
|
+
readonly STROKE: 4;
|
|
11
|
+
readonly OPACITY: 5;
|
|
12
|
+
readonly OFFSETS: 6;
|
|
13
|
+
readonly ROTATION: 7;
|
|
14
|
+
readonly MAX: 8;
|
|
15
|
+
};
|
|
20
16
|
export declare function getCommonStyleAttributeOptions(name: string): Partial<IStyleAttribute> | undefined;
|
|
@@ -3,28 +3,27 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.COMMON_ATTRIBUTE_LOCATION = void 0;
|
|
7
7
|
exports.getCommonStyleAttributeOptions = getCommonStyleAttributeOptions;
|
|
8
8
|
var _l7Core = require("@antv/l7-core");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}({}); // Polygon Linear
|
|
9
|
+
/**
|
|
10
|
+
* Attribute Layout Location in Shader
|
|
11
|
+
*/
|
|
12
|
+
const COMMON_ATTRIBUTE_LOCATION = exports.COMMON_ATTRIBUTE_LOCATION = {
|
|
13
|
+
// common attribute in RegisterStyleAttributePlugin
|
|
14
|
+
POSITION: 0,
|
|
15
|
+
// low part for double precision POSITION attribute
|
|
16
|
+
POSITION_64LOW: 1,
|
|
17
|
+
COLOR: 2,
|
|
18
|
+
PICKING_COLOR: 3,
|
|
19
|
+
// common style attribute
|
|
20
|
+
STROKE: 4,
|
|
21
|
+
OPACITY: 5,
|
|
22
|
+
OFFSETS: 6,
|
|
23
|
+
ROTATION: 7,
|
|
24
|
+
// last index
|
|
25
|
+
MAX: 8
|
|
26
|
+
};
|
|
28
27
|
function getCommonStyleAttributeOptions(name) {
|
|
29
28
|
switch (name) {
|
|
30
29
|
// // roate
|
|
@@ -34,7 +33,7 @@ function getCommonStyleAttributeOptions(name) {
|
|
|
34
33
|
type: _l7Core.AttributeType.Attribute,
|
|
35
34
|
descriptor: {
|
|
36
35
|
name: 'a_Rotation',
|
|
37
|
-
shaderLocation:
|
|
36
|
+
shaderLocation: COMMON_ATTRIBUTE_LOCATION.ROTATION,
|
|
38
37
|
buffer: {
|
|
39
38
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
40
39
|
data: [],
|
|
@@ -55,7 +54,7 @@ function getCommonStyleAttributeOptions(name) {
|
|
|
55
54
|
type: _l7Core.AttributeType.Attribute,
|
|
56
55
|
descriptor: {
|
|
57
56
|
name: 'a_Stroke',
|
|
58
|
-
shaderLocation:
|
|
57
|
+
shaderLocation: COMMON_ATTRIBUTE_LOCATION.STROKE,
|
|
59
58
|
buffer: {
|
|
60
59
|
// give the WebGL driver a hint that this buffer may change
|
|
61
60
|
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
@@ -77,7 +76,7 @@ function getCommonStyleAttributeOptions(name) {
|
|
|
77
76
|
type: _l7Core.AttributeType.Attribute,
|
|
78
77
|
descriptor: {
|
|
79
78
|
name: 'a_Opacity',
|
|
80
|
-
shaderLocation:
|
|
79
|
+
shaderLocation: COMMON_ATTRIBUTE_LOCATION.OPACITY,
|
|
81
80
|
buffer: {
|
|
82
81
|
// give the WebGL driver a hint that this buffer may change
|
|
83
82
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
@@ -93,35 +92,13 @@ function getCommonStyleAttributeOptions(name) {
|
|
|
93
92
|
}
|
|
94
93
|
}
|
|
95
94
|
};
|
|
96
|
-
case 'extrusionBase':
|
|
97
|
-
return {
|
|
98
|
-
name: 'extrusionBase',
|
|
99
|
-
type: _l7Core.AttributeType.Attribute,
|
|
100
|
-
descriptor: {
|
|
101
|
-
name: 'a_ExtrusionBase',
|
|
102
|
-
shaderLocation: ShaderLocation.EXTRUSION_BASE,
|
|
103
|
-
buffer: {
|
|
104
|
-
// give the WebGL driver a hint that this buffer may change
|
|
105
|
-
usage: _l7Core.gl.STATIC_DRAW,
|
|
106
|
-
data: [],
|
|
107
|
-
type: _l7Core.gl.FLOAT
|
|
108
|
-
},
|
|
109
|
-
size: 1,
|
|
110
|
-
update: feature => {
|
|
111
|
-
const {
|
|
112
|
-
extrusionBase: op = 0
|
|
113
|
-
} = feature;
|
|
114
|
-
return [op];
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
95
|
case 'offsets':
|
|
119
96
|
return {
|
|
120
97
|
name: 'offsets',
|
|
121
98
|
type: _l7Core.AttributeType.Attribute,
|
|
122
99
|
descriptor: {
|
|
123
100
|
name: 'a_Offsets',
|
|
124
|
-
shaderLocation:
|
|
101
|
+
shaderLocation: COMMON_ATTRIBUTE_LOCATION.OFFSETS,
|
|
125
102
|
buffer: {
|
|
126
103
|
// give the WebGL driver a hint that this buffer may change
|
|
127
104
|
usage: _l7Core.gl.STATIC_DRAW,
|
|
@@ -137,28 +114,6 @@ function getCommonStyleAttributeOptions(name) {
|
|
|
137
114
|
}
|
|
138
115
|
}
|
|
139
116
|
};
|
|
140
|
-
case 'thetaOffset':
|
|
141
|
-
return {
|
|
142
|
-
name: 'thetaOffset',
|
|
143
|
-
type: _l7Core.AttributeType.Attribute,
|
|
144
|
-
descriptor: {
|
|
145
|
-
name: 'a_ThetaOffset',
|
|
146
|
-
shaderLocation: 15,
|
|
147
|
-
buffer: {
|
|
148
|
-
// give the WebGL driver a hint that this buffer may change
|
|
149
|
-
usage: _l7Core.gl.STATIC_DRAW,
|
|
150
|
-
data: [],
|
|
151
|
-
type: _l7Core.gl.FLOAT
|
|
152
|
-
},
|
|
153
|
-
size: 1,
|
|
154
|
-
update: feature => {
|
|
155
|
-
const {
|
|
156
|
-
thetaOffset: op = 1
|
|
157
|
-
} = feature;
|
|
158
|
-
return [op];
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
117
|
default:
|
|
163
118
|
return undefined;
|
|
164
119
|
}
|
|
@@ -10,6 +10,7 @@ exports.fillPolygon = fillPolygon;
|
|
|
10
10
|
var _l7Utils = require("@antv/l7-utils");
|
|
11
11
|
var _earcut = _interopRequireDefault(require("earcut"));
|
|
12
12
|
var _glMatrix = require("gl-matrix");
|
|
13
|
+
var _utils = require("../utils");
|
|
13
14
|
/**
|
|
14
15
|
* 拉伸多边形顶点,返回拉伸后的顶点信息
|
|
15
16
|
* @param paths 路径数据组
|
|
@@ -73,7 +74,8 @@ function extrude_PolygonNormal(path, needFlat = false // 是否需要转成平
|
|
|
73
74
|
const flattengeo = _earcut.default.flatten(path);
|
|
74
75
|
const {
|
|
75
76
|
vertices,
|
|
76
|
-
dimensions
|
|
77
|
+
dimensions,
|
|
78
|
+
holes
|
|
77
79
|
} = flattengeo;
|
|
78
80
|
const positions = [];
|
|
79
81
|
const indexArray = [];
|
|
@@ -92,8 +94,9 @@ function extrude_PolygonNormal(path, needFlat = false // 是否需要转成平
|
|
|
92
94
|
);
|
|
93
95
|
normals.push(0, 0, 1);
|
|
94
96
|
}
|
|
95
|
-
const
|
|
96
|
-
indexArray.push(...
|
|
97
|
+
const indices = (0, _utils.getPolygonSurfaceIndices)(vertices, holes, dimensions, needFlat);
|
|
98
|
+
indexArray.push(...indices);
|
|
99
|
+
|
|
97
100
|
// 设置侧面
|
|
98
101
|
for (let i = 0; i < n; i++) {
|
|
99
102
|
const prePoint = flattengeo.vertices.slice(i * dimensions, (i + 1) * dimensions);
|
|
@@ -28,8 +28,9 @@ var _earcut = _interopRequireDefault(require("earcut"));
|
|
|
28
28
|
var _glMatrix = require("gl-matrix");
|
|
29
29
|
var _utils = require("../earth/utils");
|
|
30
30
|
var _extrude_polyline = _interopRequireDefault(require("../utils/extrude_polyline"));
|
|
31
|
-
var _extrude = _interopRequireWildcard(require("./shape/extrude"));
|
|
32
31
|
var _Path = require("./shape/Path");
|
|
32
|
+
var _extrude = _interopRequireWildcard(require("./shape/extrude"));
|
|
33
|
+
var _utils2 = require("./utils");
|
|
33
34
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
34
35
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
35
36
|
// @ts-ignore
|
|
@@ -103,9 +104,7 @@ function PointImageTriangulation(feature) {
|
|
|
103
104
|
*/
|
|
104
105
|
function LineTriangulation(feature) {
|
|
105
106
|
const {
|
|
106
|
-
coordinates
|
|
107
|
-
originCoordinates,
|
|
108
|
-
version
|
|
107
|
+
coordinates
|
|
109
108
|
} = feature;
|
|
110
109
|
// let path = coordinates as number[][][] | number[][];
|
|
111
110
|
// if (!Array.isArray(path[0][0])) {
|
|
@@ -116,32 +115,13 @@ function LineTriangulation(feature) {
|
|
|
116
115
|
dash: true,
|
|
117
116
|
join: 'bevel'
|
|
118
117
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (!Array.isArray(path1[0][0])) {
|
|
123
|
-
path1 = [coordinates];
|
|
124
|
-
}
|
|
125
|
-
let path2 = originCoordinates; // 计算法线
|
|
126
|
-
if (!Array.isArray(path2[0][0])) {
|
|
127
|
-
path2 = [originCoordinates];
|
|
128
|
-
}
|
|
129
|
-
for (let i = 0; i < path1.length; i++) {
|
|
130
|
-
// 高德2.0在计算线时,需要使用经纬度计算发现,使用 customCoords.lnglatToCoords 计算的数据来计算顶点的位置
|
|
131
|
-
const item1 = path1[i];
|
|
132
|
-
const item2 = path2[i];
|
|
133
|
-
line.extrude_gaode2(item1, item2);
|
|
134
|
-
}
|
|
135
|
-
} else {
|
|
136
|
-
// 处理非高德2.0的几何体构建
|
|
137
|
-
let path = coordinates;
|
|
138
|
-
if (path[0] && !Array.isArray(path[0][0])) {
|
|
139
|
-
path = [coordinates];
|
|
140
|
-
}
|
|
141
|
-
path.forEach(item => {
|
|
142
|
-
line.extrude(item);
|
|
143
|
-
});
|
|
118
|
+
let path = coordinates;
|
|
119
|
+
if (path[0] && !Array.isArray(path[0][0])) {
|
|
120
|
+
path = [coordinates];
|
|
144
121
|
}
|
|
122
|
+
path.forEach(item => {
|
|
123
|
+
line.extrude(item);
|
|
124
|
+
});
|
|
145
125
|
const linebuffer = line.complex;
|
|
146
126
|
return {
|
|
147
127
|
vertices: linebuffer.positions,
|
|
@@ -203,8 +183,7 @@ function FlowLineFillTriangulation(feature) {
|
|
|
203
183
|
}
|
|
204
184
|
function SimpleLineTriangulation(feature) {
|
|
205
185
|
const {
|
|
206
|
-
coordinates
|
|
207
|
-
originCoordinates
|
|
186
|
+
coordinates
|
|
208
187
|
} = feature;
|
|
209
188
|
const pos = [];
|
|
210
189
|
if (!Array.isArray(coordinates[0])) {
|
|
@@ -219,7 +198,7 @@ function SimpleLineTriangulation(feature) {
|
|
|
219
198
|
const {
|
|
220
199
|
results,
|
|
221
200
|
totalDistance
|
|
222
|
-
} = getSimpleLineVertices(coordinates
|
|
201
|
+
} = getSimpleLineVertices(coordinates);
|
|
223
202
|
results.map(point => {
|
|
224
203
|
pos.push(point[0], point[1], point[2], point[3], 0, totalDistance);
|
|
225
204
|
});
|
|
@@ -271,15 +250,11 @@ function pushDis(point, n) {
|
|
|
271
250
|
}
|
|
272
251
|
return point;
|
|
273
252
|
}
|
|
274
|
-
function getSimpleLineVertices(coordinates
|
|
253
|
+
function getSimpleLineVertices(coordinates) {
|
|
275
254
|
let points = coordinates;
|
|
276
|
-
//除了amap2.0以外 coordinates就是经纬度数据
|
|
277
|
-
let originPoints = originCoordinates || coordinates;
|
|
278
255
|
if (Array.isArray(points) && Array.isArray(points[0]) && Array.isArray(points[0][0])) {
|
|
279
256
|
// @ts-ignore
|
|
280
|
-
points =
|
|
281
|
-
// @ts-ignore
|
|
282
|
-
originPoints = originCoordinates.flat();
|
|
257
|
+
points = coordinates.flat();
|
|
283
258
|
}
|
|
284
259
|
//修改计算距离的方式,与普通线的计算方式保持一致 edit by huyang 20231214
|
|
285
260
|
let distance = 0;
|
|
@@ -293,13 +268,13 @@ function getSimpleLineVertices(coordinates, originCoordinates) {
|
|
|
293
268
|
const point = pushDis(points[0], distance);
|
|
294
269
|
results.push(point);
|
|
295
270
|
for (let i = 1; i < points.length - 1; i++) {
|
|
296
|
-
const subDistance = lineSegmentDistance((0, _l7Utils.aProjectFlat)(
|
|
271
|
+
const subDistance = lineSegmentDistance((0, _l7Utils.aProjectFlat)(points[i - 1]), (0, _l7Utils.aProjectFlat)(points[i]));
|
|
297
272
|
distance += subDistance;
|
|
298
273
|
const mulPoint = pushDis(points[i], distance);
|
|
299
274
|
results.push(mulPoint);
|
|
300
275
|
results.push(mulPoint);
|
|
301
276
|
}
|
|
302
|
-
const pointDistance = lineSegmentDistance((0, _l7Utils.aProjectFlat)(
|
|
277
|
+
const pointDistance = lineSegmentDistance((0, _l7Utils.aProjectFlat)(points[points.length - 2]), (0, _l7Utils.aProjectFlat)(points[points.length - 1]));
|
|
303
278
|
distance += pointDistance;
|
|
304
279
|
results.push(pushDis(points[points.length - 1], distance));
|
|
305
280
|
return {
|
|
@@ -338,8 +313,9 @@ function polygonTriangulation(feature) {
|
|
|
338
313
|
dimensions,
|
|
339
314
|
holes
|
|
340
315
|
} = flattengeo;
|
|
316
|
+
const indices = (0, _utils2.getPolygonSurfaceIndices)(vertices, holes, dimensions);
|
|
341
317
|
return {
|
|
342
|
-
indices
|
|
318
|
+
indices,
|
|
343
319
|
vertices,
|
|
344
320
|
size: dimensions
|
|
345
321
|
};
|
|
@@ -348,18 +324,14 @@ function polygonTriangulation(feature) {
|
|
|
348
324
|
// 构建几何图形(带有中心点和大小)
|
|
349
325
|
function polygonTriangulationWithCenter(feature) {
|
|
350
326
|
const {
|
|
351
|
-
|
|
352
|
-
} = feature;
|
|
353
|
-
const flattengeo = _earcut.default.flatten(coordinates);
|
|
354
|
-
const {
|
|
327
|
+
indices,
|
|
355
328
|
vertices,
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
} = flattengeo;
|
|
329
|
+
size
|
|
330
|
+
} = polygonTriangulation(feature);
|
|
359
331
|
return {
|
|
360
|
-
indices:
|
|
332
|
+
indices: indices,
|
|
361
333
|
vertices: getVerticesWithCenter(vertices),
|
|
362
|
-
size:
|
|
334
|
+
size: size + 4
|
|
363
335
|
};
|
|
364
336
|
}
|
|
365
337
|
function getVerticesWithCenter(vertices) {
|
package/lib/core/utils.d.ts
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
1
|
export declare function MultipleOfFourNumber(num: number): number;
|
|
2
|
+
/**
|
|
3
|
+
* Get vertex indices for drawing polygon mesh (triangulation)
|
|
4
|
+
*/
|
|
5
|
+
export declare function getPolygonSurfaceIndices(positions: number[], holeIndices: number[], positionSize: number, preproject?: boolean): number[];
|
package/lib/core/utils.js
CHANGED
|
@@ -1,9 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.MultipleOfFourNumber = MultipleOfFourNumber;
|
|
8
|
+
exports.getPolygonSurfaceIndices = getPolygonSurfaceIndices;
|
|
9
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
10
|
+
var _earcut = _interopRequireDefault(require("earcut"));
|
|
7
11
|
function MultipleOfFourNumber(num) {
|
|
8
12
|
return Math.max(Math.ceil(num / 4) * 4, 4);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Get vertex indices for drawing polygon mesh (triangulation)
|
|
17
|
+
*/
|
|
18
|
+
function getPolygonSurfaceIndices(positions, holeIndices, positionSize, preproject = true) {
|
|
19
|
+
const is3d = positionSize === 3;
|
|
20
|
+
if (preproject) {
|
|
21
|
+
positions = positions.slice();
|
|
22
|
+
const p = [];
|
|
23
|
+
for (let i = 0; i < positions.length; i += positionSize) {
|
|
24
|
+
p[0] = positions[i];
|
|
25
|
+
p[1] = positions[i + 1];
|
|
26
|
+
if (is3d) {
|
|
27
|
+
p[2] = positions[i + 2];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// earcut is a 2D triangulation algorithm, and handles 3D data as if it was projected onto the XY plane
|
|
31
|
+
const xy = (0, _l7Utils.lngLatToMeters)(p, true, {
|
|
32
|
+
enable: false,
|
|
33
|
+
decimal: 1
|
|
34
|
+
});
|
|
35
|
+
positions[i] = xy[0];
|
|
36
|
+
positions[i + 1] = xy[1];
|
|
37
|
+
if (is3d) {
|
|
38
|
+
positions[i + 2] = xy[2];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const indices = (0, _earcut.default)(positions, holeIndices, positionSize);
|
|
43
|
+
return indices;
|
|
9
44
|
}
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import type { IModel } from '@antv/l7-core';
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class EarthAtomSphereModel extends BaseModel {
|
|
4
|
+
protected get attributeLocation(): {
|
|
5
|
+
readonly POSITION: 0;
|
|
6
|
+
readonly POSITION_64LOW: 1;
|
|
7
|
+
readonly COLOR: 2;
|
|
8
|
+
readonly PICKING_COLOR: 3;
|
|
9
|
+
readonly STROKE: 4;
|
|
10
|
+
readonly OPACITY: 5;
|
|
11
|
+
readonly OFFSETS: 6;
|
|
12
|
+
readonly ROTATION: 7;
|
|
13
|
+
readonly MAX: 8;
|
|
14
|
+
} & Record<string, number> & {
|
|
15
|
+
MAX: 8;
|
|
16
|
+
NORMAL: number;
|
|
17
|
+
UV: number;
|
|
18
|
+
};
|
|
4
19
|
protected getCommonUniformsInfo(): {
|
|
5
20
|
uniformsArray: number[];
|
|
6
21
|
uniformsLength: number;
|