@antv/l7-layers 2.20.20 → 2.21.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/index.d.ts +13 -8
- package/es/canvas/index.js +63 -36
- package/es/canvas/models/canvas.d.ts +19 -14
- package/es/canvas/models/canvas.js +125 -139
- package/es/canvas/models/constants.d.ts +2 -0
- package/es/canvas/models/constants.js +6 -0
- package/es/canvas/models/index.d.ts +2 -5
- package/es/canvas/models/index.js +2 -5
- package/es/core/BaseLayer.d.ts +17 -19
- package/es/core/BaseLayer.js +88 -62
- package/es/core/BaseModel.js +15 -29
- package/es/core/LayerPickService.js +4 -5
- package/es/core/TextureService.js +1 -2
- package/es/core/interface.d.ts +31 -4
- package/es/core/shape/arrow.js +2 -6
- package/es/heatmap/models/heatmap.d.ts +0 -1
- package/es/heatmap/models/heatmap.js +2 -5
- package/es/index.d.ts +2 -1
- package/es/index.js +2 -89
- package/es/line/models/arc.js +5 -5
- package/es/line/models/arc_3d.js +4 -3
- package/es/line/models/great_circle.js +4 -4
- package/es/line/models/line.js +5 -8
- package/es/line/models/simple_line.js +1 -2
- package/es/line/models/wall.js +4 -3
- package/es/plugins/DataMappingPlugin.d.ts +4 -7
- package/es/plugins/DataMappingPlugin.js +8 -23
- package/es/plugins/DataSourcePlugin.d.ts +0 -1
- package/es/plugins/DataSourcePlugin.js +4 -7
- package/es/plugins/FeatureScalePlugin.d.ts +2 -5
- package/es/plugins/FeatureScalePlugin.js +4 -6
- package/es/plugins/LayerAnimateStylePlugin.d.ts +0 -1
- package/es/plugins/LayerAnimateStylePlugin.js +2 -5
- package/es/plugins/LayerMaskPlugin.d.ts +0 -1
- package/es/plugins/LayerMaskPlugin.js +2 -8
- package/es/plugins/LayerModelPlugin.d.ts +0 -1
- package/es/plugins/LayerModelPlugin.js +13 -18
- package/es/plugins/LayerStylePlugin.d.ts +0 -1
- package/es/plugins/LayerStylePlugin.js +2 -5
- package/es/plugins/LightingPlugin.d.ts +0 -1
- package/es/plugins/LightingPlugin.js +2 -5
- package/es/plugins/MultiPassRendererPlugin.d.ts +0 -1
- package/es/plugins/MultiPassRendererPlugin.js +2 -5
- package/es/plugins/PixelPickingPlugin.d.ts +2 -6
- package/es/plugins/PixelPickingPlugin.js +4 -9
- package/es/plugins/RegisterStyleAttributePlugin.d.ts +2 -5
- package/es/plugins/RegisterStyleAttributePlugin.js +2 -5
- package/es/plugins/ShaderUniformPlugin.d.ts +7 -8
- package/es/plugins/ShaderUniformPlugin.js +16 -42
- package/es/plugins/UpdateModelPlugin.d.ts +0 -1
- package/es/plugins/UpdateModelPlugin.js +2 -5
- package/es/plugins/UpdateStyleAttributePlugin.d.ts +2 -5
- package/es/plugins/UpdateStyleAttributePlugin.js +2 -6
- package/es/plugins/index.d.ts +15 -0
- package/es/plugins/index.js +18 -0
- package/es/point/models/fill.d.ts +1 -1
- package/es/point/models/fill.js +6 -9
- package/es/point/models/fillImage.js +4 -3
- package/es/point/models/image.js +4 -3
- package/es/polygon/models/extrude.js +0 -1
- package/es/polygon/models/ocean.js +1 -2
- package/es/polygon/models/water.js +0 -2
- package/es/tile/core/BaseLayer.js +4 -5
- package/es/tile/interaction/getRasterData.js +0 -2
- package/es/tile/service/TileLayerService.d.ts +0 -1
- package/es/tile/service/TileLayerService.js +0 -1
- package/es/tile/service/TilePickService.d.ts +1 -1
- package/es/tile/service/TilePickService.js +2 -3
- package/es/tile/tile/Tile.js +8 -6
- package/lib/canvas/index.js +63 -37
- package/lib/canvas/models/canvas.js +125 -138
- package/lib/canvas/models/constants.js +12 -0
- package/lib/canvas/models/index.js +22 -7
- package/lib/core/BaseLayer.js +88 -62
- package/lib/core/BaseModel.js +14 -28
- package/lib/core/LayerPickService.js +4 -5
- package/lib/core/TextureService.js +1 -2
- package/lib/core/shape/arrow.js +2 -6
- package/lib/heatmap/models/heatmap.js +2 -5
- package/lib/index.js +9 -90
- package/lib/line/models/arc.js +4 -4
- package/lib/line/models/arc_3d.js +4 -3
- package/lib/line/models/great_circle.js +4 -4
- package/lib/line/models/line.js +5 -8
- package/lib/line/models/simple_line.js +0 -1
- package/lib/line/models/wall.js +4 -3
- package/lib/plugins/DataMappingPlugin.js +7 -22
- package/lib/plugins/DataSourcePlugin.js +3 -6
- package/lib/plugins/FeatureScalePlugin.js +4 -6
- package/lib/plugins/LayerAnimateStylePlugin.js +2 -5
- package/lib/plugins/LayerMaskPlugin.js +2 -8
- package/lib/plugins/LayerModelPlugin.js +13 -18
- package/lib/plugins/LayerStylePlugin.js +2 -5
- package/lib/plugins/LightingPlugin.js +2 -5
- package/lib/plugins/MultiPassRendererPlugin.js +2 -5
- package/lib/plugins/PixelPickingPlugin.js +4 -9
- package/lib/plugins/RegisterStyleAttributePlugin.js +2 -5
- package/lib/plugins/ShaderUniformPlugin.js +15 -41
- package/lib/plugins/UpdateModelPlugin.js +2 -5
- package/lib/plugins/UpdateStyleAttributePlugin.js +2 -5
- package/lib/plugins/index.js +26 -0
- package/lib/point/models/fill.js +6 -9
- package/lib/point/models/fillImage.js +4 -3
- package/lib/point/models/image.js +4 -3
- package/lib/polygon/models/extrude.js +0 -1
- package/lib/polygon/models/ocean.js +0 -1
- package/lib/polygon/models/water.js +0 -2
- package/lib/tile/core/BaseLayer.js +4 -5
- package/lib/tile/interaction/getRasterData.js +0 -2
- package/lib/tile/service/TileLayerService.js +0 -1
- package/lib/tile/service/TilePickService.js +2 -3
- package/lib/tile/tile/Tile.js +8 -6
- package/package.json +18 -20
|
@@ -7,13 +7,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _inversify = require("inversify");
|
|
11
|
-
require("reflect-metadata");
|
|
12
|
-
var _dec, _class;
|
|
13
10
|
/**
|
|
14
11
|
* 在初始化阶段完成属性的注册,以及首次根据 Layer 指定的三角化方法完成 indices 和 attribute 的创建
|
|
15
12
|
*/
|
|
16
|
-
var UpdateStyleAttributePlugin = exports.default =
|
|
13
|
+
var UpdateStyleAttributePlugin = exports.default = /*#__PURE__*/function () {
|
|
17
14
|
function UpdateStyleAttributePlugin() {
|
|
18
15
|
(0, _classCallCheck2.default)(this, UpdateStyleAttributePlugin);
|
|
19
16
|
}
|
|
@@ -78,4 +75,4 @@ var UpdateStyleAttributePlugin = exports.default = (_dec = (0, _inversify.inject
|
|
|
78
75
|
}
|
|
79
76
|
}]);
|
|
80
77
|
return UpdateStyleAttributePlugin;
|
|
81
|
-
}()
|
|
78
|
+
}();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createPlugins = createPlugins;
|
|
8
|
+
var _DataMappingPlugin = _interopRequireDefault(require("./DataMappingPlugin"));
|
|
9
|
+
var _DataSourcePlugin = _interopRequireDefault(require("./DataSourcePlugin"));
|
|
10
|
+
var _FeatureScalePlugin = _interopRequireDefault(require("./FeatureScalePlugin"));
|
|
11
|
+
var _LayerAnimateStylePlugin = _interopRequireDefault(require("./LayerAnimateStylePlugin"));
|
|
12
|
+
var _LayerMaskPlugin = _interopRequireDefault(require("./LayerMaskPlugin"));
|
|
13
|
+
var _LayerModelPlugin = _interopRequireDefault(require("./LayerModelPlugin"));
|
|
14
|
+
var _LayerStylePlugin = _interopRequireDefault(require("./LayerStylePlugin"));
|
|
15
|
+
var _LightingPlugin = _interopRequireDefault(require("./LightingPlugin"));
|
|
16
|
+
var _MultiPassRendererPlugin = _interopRequireDefault(require("./MultiPassRendererPlugin"));
|
|
17
|
+
var _PixelPickingPlugin = _interopRequireDefault(require("./PixelPickingPlugin"));
|
|
18
|
+
var _RegisterStyleAttributePlugin = _interopRequireDefault(require("./RegisterStyleAttributePlugin"));
|
|
19
|
+
var _ShaderUniformPlugin = _interopRequireDefault(require("./ShaderUniformPlugin"));
|
|
20
|
+
var _UpdateModelPlugin = _interopRequireDefault(require("./UpdateModelPlugin"));
|
|
21
|
+
var _UpdateStyleAttributePlugin = _interopRequireDefault(require("./UpdateStyleAttributePlugin"));
|
|
22
|
+
// import ConfigSchemaValidationPlugin from './ConfigSchemaValidationPlugin';
|
|
23
|
+
|
|
24
|
+
function createPlugins() {
|
|
25
|
+
return [new _DataSourcePlugin.default(), new _RegisterStyleAttributePlugin.default(), new _FeatureScalePlugin.default(), new _DataMappingPlugin.default(), new _LayerStylePlugin.default(), new _LayerMaskPlugin.default(), new _UpdateStyleAttributePlugin.default(), new _UpdateModelPlugin.default(), new _MultiPassRendererPlugin.default(), new _ShaderUniformPlugin.default(), new _LayerAnimateStylePlugin.default(), new _LightingPlugin.default(), new _PixelPickingPlugin.default(), new _LayerModelPlugin.default()];
|
|
26
|
+
}
|
package/lib/point/models/fill.js
CHANGED
|
@@ -104,17 +104,14 @@ var FillModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
104
104
|
key: "buildModels",
|
|
105
105
|
value: function () {
|
|
106
106
|
var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
107
|
-
var
|
|
107
|
+
var _this$getShaders, frag, vert, type, model;
|
|
108
108
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
109
109
|
while (1) switch (_context2.prev = _context2.next) {
|
|
110
110
|
case 0:
|
|
111
|
-
|
|
112
|
-
enable: false
|
|
113
|
-
} : _ref3$animateOption;
|
|
114
|
-
_this$getShaders = this.getShaders(animateOption), frag = _this$getShaders.frag, vert = _this$getShaders.vert, type = _this$getShaders.type;
|
|
111
|
+
_this$getShaders = this.getShaders(), frag = _this$getShaders.frag, vert = _this$getShaders.vert, type = _this$getShaders.type;
|
|
115
112
|
this.layer.triangulation = _l7Utils.PointFillTriangulation;
|
|
116
113
|
this.initUniformsBuffer();
|
|
117
|
-
_context2.next =
|
|
114
|
+
_context2.next = 5;
|
|
118
115
|
return this.layer.buildLayerModel({
|
|
119
116
|
moduleName: type,
|
|
120
117
|
vertexShader: vert,
|
|
@@ -125,10 +122,10 @@ var FillModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
125
122
|
enable: false
|
|
126
123
|
}
|
|
127
124
|
});
|
|
128
|
-
case
|
|
125
|
+
case 5:
|
|
129
126
|
model = _context2.sent;
|
|
130
127
|
return _context2.abrupt("return", [model]);
|
|
131
|
-
case
|
|
128
|
+
case 7:
|
|
132
129
|
case "end":
|
|
133
130
|
return _context2.stop();
|
|
134
131
|
}
|
|
@@ -145,7 +142,7 @@ var FillModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
145
142
|
*/
|
|
146
143
|
}, {
|
|
147
144
|
key: "getShaders",
|
|
148
|
-
value: function getShaders(
|
|
145
|
+
value: function getShaders() {
|
|
149
146
|
return {
|
|
150
147
|
frag: pointFillFrag,
|
|
151
148
|
vert: pointFillVert,
|
|
@@ -78,7 +78,8 @@ var FillImageModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
78
78
|
_ref$unit = _ref.unit,
|
|
79
79
|
unit = _ref$unit === void 0 ? 'pixel' : _ref$unit;
|
|
80
80
|
if (this.rendererService.getDirty()) {
|
|
81
|
-
|
|
81
|
+
var _this$texture;
|
|
82
|
+
(_this$texture = this.texture) === null || _this$texture === void 0 || _this$texture.bind();
|
|
82
83
|
}
|
|
83
84
|
/**
|
|
84
85
|
* rotateFlag
|
|
@@ -164,9 +165,9 @@ var FillImageModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
164
165
|
}, {
|
|
165
166
|
key: "clearModels",
|
|
166
167
|
value: function clearModels() {
|
|
167
|
-
var _this$
|
|
168
|
+
var _this$texture2;
|
|
168
169
|
this.iconService.off('imageUpdate', this.updateTexture);
|
|
169
|
-
(_this$
|
|
170
|
+
(_this$texture2 = this.texture) === null || _this$texture2 === void 0 || _this$texture2.destroy();
|
|
170
171
|
}
|
|
171
172
|
|
|
172
173
|
// overwrite baseModel func
|
|
@@ -69,7 +69,8 @@ var ImageModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
69
69
|
value: function getUninforms() {
|
|
70
70
|
// ThreeJS 图层兼容
|
|
71
71
|
if (this.rendererService.getDirty()) {
|
|
72
|
-
|
|
72
|
+
var _this$texture;
|
|
73
|
+
(_this$texture = this.texture) === null || _this$texture === void 0 || _this$texture.bind();
|
|
73
74
|
}
|
|
74
75
|
var commonInfo = this.getCommonUniformsInfo();
|
|
75
76
|
var attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
|
|
@@ -118,8 +119,8 @@ var ImageModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
118
119
|
}, {
|
|
119
120
|
key: "clearModels",
|
|
120
121
|
value: function clearModels() {
|
|
121
|
-
var _this$
|
|
122
|
-
(_this$
|
|
122
|
+
var _this$texture2;
|
|
123
|
+
(_this$texture2 = this.texture) === null || _this$texture2 === void 0 || _this$texture2.destroy();
|
|
123
124
|
this.iconService.off('imageUpdate', this.updateTexture);
|
|
124
125
|
}
|
|
125
126
|
}, {
|
|
@@ -222,7 +222,6 @@ var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
|
222
222
|
update: function update(feature, featureIdx, vertex) {
|
|
223
223
|
var lng = vertex[0];
|
|
224
224
|
var lat = vertex[1];
|
|
225
|
-
// console.log((lng - bounds[0]) / lngLen, (lat - bounds[1]) / latLen, vertex[4])
|
|
226
225
|
// 临时 兼容高德V2
|
|
227
226
|
return [(lng - bounds[0]) / lngLen, (lat - bounds[1]) / latLen, vertex[4]];
|
|
228
227
|
}
|
|
@@ -25,7 +25,6 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
25
25
|
var ocean_frag = "\nlayout(std140) uniform commonUniforms {\n vec4 u_watercolor;\n vec4 u_watercolor2;\n float u_time;\n};\n\nin vec2 v_uv;\nin float v_opacity;\nout vec4 outputColor;\n\nfloat coast2water_fadedepth = 0.10;\nfloat large_waveheight = .750; // change to adjust the \"heavy\" waves\nfloat large_wavesize = 3.4; // factor to adjust the large wave size\nfloat small_waveheight = 0.6; // change to adjust the small random waves\nfloat small_wavesize = 0.5; // factor to ajust the small wave size\nfloat water_softlight_fact = 15.; // range [1..200] (should be << smaller than glossy-fact)\nfloat water_glossylight_fact= 120.; // range [1..200]\nfloat particle_amount = 70.;\n\nvec3 water_specularcolor = vec3(1.3, 1.3, 0.9); // specular Color (RGB) of the water-highlights\n#define light vec3(-0., sin(u_time*0.5)*.5 + .35, 2.8) // position of the sun\n\nuniform sampler2D u_texture1;\nuniform sampler2D u_texture2;\nuniform sampler2D u_texture3;\n\n \n\nfloat hash( float n ) {\n return fract(sin(n)*43758.5453123);\n}\n\n// 2d noise function\nfloat noise1( in vec2 x ) {\n vec2 p = floor(x);\n vec2 f = smoothstep(0.0, 1.0, fract(x));\n float n = p.x + p.y*57.0;\n return mix(mix( hash(n+ 0.0), hash(n+ 1.0),f.x),\n mix( hash(n+ 57.0), hash(n+ 58.0),f.x),f.y);\n}\n\nfloat noise(vec2 p) {\n return texture(SAMPLER_2D(u_texture2),p*vec2(1./256.)).x;\n}\n\nvec4 highness(vec2 p) {\n vec4 t = texture(SAMPLER_2D(u_texture1),fract(p));\n float clipped = -2.0-smoothstep(3.,10.,t.a)*6.9-smoothstep(10.,100.,t.a)*89.9-smoothstep(0.,10000.,t.a)*10000.0;\n return clamp(t, 0.0,3.0)+clamp(t/3.0-1.0, 0.0,1.0)+clamp(t/16.0-1.0, 0.0,1.0);\n}\n\nfloat height_map( vec2 p ) {\n vec4 height=highness(p);\n /*\n height = -0.5+\n 0.5*smoothstep(-100.,0.,-height)+\n 2.75*smoothstep(0.,2.,height)+\n 1.75*smoothstep(2.,4.,height)+\n 2.75*smoothstep(4.,16.,height)+\n 1.5*smoothstep(16.,1000.,height);\n */\n\n mat2 m = mat2( 0.9563*1.4, -0.2924*1.4, 0.2924*1.4, 0.9563*1.4 );\n //p = p*6.;\n float f = 0.6000*noise1( p ); p = m*p*1.1*6.;\n f += 0.2500*noise( p ); p = m*p*1.32;\n f += 0.1666*noise( p ); p = m*p*1.11;\n f += 0.0834*noise( p ); p = m*p*1.12;\n f += 0.0634*noise( p ); p = m*p*1.13;\n f += 0.0444*noise( p ); p = m*p*1.14;\n f += 0.0274*noise( p ); p = m*p*1.15;\n f += 0.0134*noise( p ); p = m*p*1.16;\n f += 0.0104*noise( p ); p = m*p*1.17;\n f += 0.0084*noise( p );\n f = .25*f+dot(height,vec4(-.03125,-.125,.25,.25))*.5;\n const float FLAT_LEVEL = 0.92525;\n //f = f*0.25+height*0.75;\n if (f<FLAT_LEVEL)\n f = f;\n else\n f = pow((f-FLAT_LEVEL)/(1.-FLAT_LEVEL), 2.)*(1.-FLAT_LEVEL)*2.0+FLAT_LEVEL; // makes a smooth coast-increase\n return clamp(f, 0., 10.);\n}\n\nvec3 plasma_quintic( float x ) {\n x = clamp( x, 0.0, 1.0);\n vec4 x1 = vec4( 1.0, x, x * x, x * x * x ); // 1 x x2 x3\n vec4 x2 = x1 * x1.w * x; // x4 x5 x6 x7\n return vec3(\n dot( x1.xyzw, vec4( +0.063861086, +1.992659096, -1.023901152, -0.490832805 ) ) + dot( x2.xy, vec2( +1.308442123, -0.914547012 ) ),\n dot( x1.xyzw, vec4( +0.049718590, -0.791144343, +2.892305078, +0.811726816 ) ) + dot( x2.xy, vec2( -4.686502417, +2.717794514 ) ),\n dot( x1.xyzw, vec4( +0.513275779, +1.580255060, -5.164414457, +4.559573646 ) ) + dot( x2.xy, vec2( -1.916810682, +0.570638854 ) ) );\n}\n\nvec4 color(vec2 p){\n vec4 c1 = vec4(1.7,1.6,.9,1);\n vec4 c2 = vec4(.2,.94,.1,1);\n vec4 c3 = vec4(.3,.2,.0,1);\n vec4 c4 = vec4(.99,.99,1.6,1);\n vec4 v = highness(p);\n float los = smoothstep(0.1,1.1,v.b);\n float his = smoothstep(3.5,6.5,v.b);\n float ces = smoothstep(1.,5.,v.a);\n vec4 lo = mix(c1,c2,los);\n vec4 hi = mix(c3,c4,his);\n vec4 ce = mix(lo,hi,ces);\n\n return vec4(plasma_quintic(ces),1).ragb;\n}\n\nvec3 terrain_map( vec2 p )\n{\n return color(p).rgb*0.75+0.25*vec3(0.7, .55, .4)+texture(SAMPLER_2D(u_texture3), fract(p*5.)).rgb*.5; // test-terrain is simply 'sandstone'\n}\n\nconst mat2 m = mat2( 0.72, -1.60, 1.60, 0.72 );\n\nfloat water_map( vec2 p, float height ) {\n vec2 p2 = p*large_wavesize;\n vec2 shift1 = 0.001*vec2( u_time*160.0*2.0, u_time*120.0*2.0 );\n vec2 shift2 = 0.001*vec2( u_time*190.0*2.0, -u_time*130.0*2.0 );\n\n // coarse crossing 'ocean' waves...\n float f = 0.6000*noise( p );\n f += 0.2500*noise( p*m );\n f += 0.1666*noise( p*m*m );\n float wave = sin(p2.x*0.622+p2.y*0.622+shift2.x*4.269)*large_waveheight*f*height*height ;\n\n p *= small_wavesize;\n f = 0.;\n float amp = 1.0, s = .5;\n for (int i=0; i<9; i++)\n { p = m*p*.947; f -= amp*abs(sin((noise( p+shift1*s )-.5)*2.)); amp = amp*.59; s*=-1.329; }\n \n return wave+f*small_waveheight;\n}\n\nfloat nautic(vec2 p) {\n p *= 18.;\n float f = 0.;\n float amp = 1.0, s = .5;\n for (int i=0; i<3; i++)\n { p = m*p*1.2; f += amp*abs(smoothstep(0., 1., noise( p+u_time*s ))-.5); amp = amp*.5; s*=-1.227; }\n return pow(1.-f, 5.);\n}\n\nfloat particles(vec2 p) {\n p *= 200.;\n float f = 0.;\n float amp = 1.0, s = 1.5;\n for (int i=0; i<3; i++)\n { p = m*p*1.2; f += amp*noise( p+u_time*s ); amp = amp*.5; s*=-1.227; }\n return pow(f*.35, 7.)*particle_amount;\n}\n\nfloat test_shadow( vec2 xy, float height) {\n vec3 r0 = vec3(xy, height);\n vec3 rd = normalize( light - r0 );\n \n float hit = 1.0;\n float t = 0.001;\n for (int j=1; j<25; j++)\n {\n vec3 p = r0 + t*rd;\n float h = height_map( p.xy );\n float height_diff = p.z - h;\n if (height_diff<0.0)\n {\n return 0.0;\n }\n t += 0.01+height_diff*.02;\n hit = min(hit, 2.*height_diff/t); // soft shaddow \n }\n return hit;\n}\n\nvec3 CalcTerrain(vec2 uv, float height) {\n vec3 col = terrain_map( uv );\n vec2 iResolution = vec2(512.);\n float h1 = height_map(uv-vec2(0., 0.5)/ iResolution.xy);\n float h2 = height_map(uv+vec2(0., 0.5)/ iResolution.xy);\n float h3 = height_map(uv-vec2(0.5, 0.)/ iResolution.xy);\n float h4 = height_map(uv+vec2(0.5, 0.)/ iResolution.xy);\n vec3 norm = normalize(vec3(h3-h4, h1-h2, 1.));\n vec3 r0 = vec3(uv, height);\n vec3 rd = normalize( light - r0 );\n float grad = dot(norm, rd);\n col *= grad+pow(grad, 8.);\n float terrainshade = test_shadow( uv, height );\n col = mix(col*.25, col, terrainshade);\n return col;\n}\n\n\nvoid main() {\n vec3 watercolor = u_watercolor.rgb;\n vec3 watercolor2 = u_watercolor2.rgb;\n vec2 uv = v_uv;\n float WATER_LEVEL = 0.84; // Water level (range: 0.0 - 2.0)\n float deepwater_fadedepth = 0.4 + coast2water_fadedepth;\n float height = height_map( uv );\n vec3 col;\n\n float waveheight = clamp(WATER_LEVEL*3.-1.5, 0., 1.);\n float level = WATER_LEVEL + .2*water_map(uv*15. + vec2(u_time*.1), waveheight);\n if (height > level)\n {\n col = CalcTerrain(uv, height);\n }\n if (height <= level)\n {\n vec2 dif = vec2(.0, .01);\n vec2 pos = uv*15. + vec2(u_time*.01);\n float h1 = water_map(pos-dif,waveheight);\n float h2 = water_map(pos+dif,waveheight);\n float h3 = water_map(pos-dif.yx,waveheight);\n float h4 = water_map(pos+dif.yx,waveheight);\n vec3 normwater = normalize(vec3(h3-h4, h1-h2, .125)); // norm-vector of the 'bumpy' water-plane\n uv += normwater.xy*.002*(level-height);\n \n col = CalcTerrain(uv, height);\n\n float coastfade = clamp((level-height)/coast2water_fadedepth, 0., 1.);\n float coastfade2= clamp((level-height)/deepwater_fadedepth, 0., 1.);\n float intensity = col.r*.2126+col.g*.7152+col.b*.0722;\n watercolor = mix(watercolor*intensity, watercolor2, smoothstep(0., 1., coastfade2));\n\n vec3 r0 = vec3(uv, WATER_LEVEL);\n vec3 rd = normalize( light - r0 ); // ray-direction to the light from water-position\n float grad = dot(normwater, rd); // dot-product of norm-vector and light-direction\n float specular = pow(grad, water_softlight_fact); // used for soft highlights \n float specular2= pow(grad, water_glossylight_fact); // used for glossy highlights\n float gradpos = dot(vec3(0., 0., 1.), rd);\n float specular1= smoothstep(0., 1., pow(gradpos, 5.)); // used for diffusity (some darker corona around light's specular reflections...) \n float watershade = test_shadow( uv, level );\n watercolor *= 2.2+watershade;\n watercolor += (.2+.8*watershade) * ((grad-1.0)*.5+specular) * .25;\n watercolor /= (1.+specular1*1.25);\n watercolor += watershade*specular2*water_specularcolor;\n watercolor += watershade*coastfade*(1.-coastfade2)*(vec3(.5, .6, .7)*nautic(uv)+vec3(1., 1., 1.)*particles(uv));\n \n col = mix(col, watercolor, coastfade);\n }\n \n outputColor = vec4(col, v_opacity); \n}\n";
|
|
26
26
|
/* babel-plugin-inline-import '../shaders/ocean/ocean_vert.glsl' */
|
|
27
27
|
var ocean_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 14) in vec2 a_uv;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_watercolor;\n vec4 u_watercolor2;\n float u_time;\n};\n\n\nout vec2 v_uv;\nout float v_opacity;\n\n#pragma include \"projection\"\n\nvoid main() {\n v_uv = a_uv;\n v_opacity = opacity;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n}\n\n";
|
|
28
|
-
var isNumber = _l7Utils.lodashUtil.isNumber;
|
|
29
28
|
var OceanModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
30
29
|
(0, _inherits2.default)(OceanModel, _BaseModel);
|
|
31
30
|
var _super = _createSuper(OceanModel);
|
|
@@ -15,7 +15,6 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
|
|
|
15
15
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
16
16
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
17
17
|
var _l7Core = require("@antv/l7-core");
|
|
18
|
-
var _l7Utils = require("@antv/l7-utils");
|
|
19
18
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
20
19
|
var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
21
20
|
var _triangulation = require("../../core/triangulation");
|
|
@@ -25,7 +24,6 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
25
24
|
var water_frag = "uniform sampler2D u_texture;\nlayout(std140) uniform commonUniforms {\n float u_speed;\n float u_time;\n};\n\nout vec4 outputColor;\n\n\nin vec4 v_Color;\nin vec2 v_uv;\n\nfloat rand(vec2 n) { return 0.5 + 0.5 * fract(sin(dot(n.xy, vec2(12.9898, 78.233)))* 43758.5453); }\n\nfloat water(vec3 p) {\n float t = u_time * u_speed;\n p.z += t * 2.; p.x += t * 2.;\n vec3 c1 = texture(SAMPLER_2D(u_texture), p.xz / 30.).xyz;\n p.z += t * 3.; p.x += t * 0.52;\n vec3 c2 = texture(SAMPLER_2D(u_texture), p.xz / 30.).xyz;\n p.z += t * 4.; p.x += t * 0.8;\n vec3 c3 = texture(SAMPLER_2D(u_texture), p.xz / 30.).xyz;\n c1 += c2 - c3;\n float z = (c1.x + c1.y + c1.z) / 3.;\n return p.y + z / 4.;\n}\n\nfloat map(vec3 p) {\n float d = 100.0;\n d = water(p);\n return d;\n}\n\nfloat intersect(vec3 ro, vec3 rd) {\n float d = 0.0;\n for (int i = 0; i <= 100; i++) {\n float h = map(ro + rd * d);\n if (h < 0.1) return d;\n d += h;\n }\n return 0.0;\n}\n\nvec3 norm(vec3 p) {\n float eps = .1;\n return normalize(vec3(\n map(p + vec3(eps, 0, 0)) - map(p + vec3(-eps, 0, 0)),\n map(p + vec3(0, eps, 0)) - map(p + vec3(0, -eps, 0)),\n map(p + vec3(0, 0, eps)) - map(p + vec3(0, 0, -eps))\n ));\n} \n\nfloat calSpc() {\n vec3 l1 = normalize(vec3(1, 1, 1));\n vec3 ro = vec3(-3, 20, -8);\n vec3 rc = vec3(0, 0, 0);\n vec3 ww = normalize(rc - ro);\n vec3 uu = normalize(cross(vec3(0,1,0), ww));\n vec3 vv = normalize(cross(rc - ro, uu));\n vec3 rd = normalize(uu * v_uv.x + vv * v_uv.y + ww);\n float d = intersect(ro, rd);\n vec3 p = ro + rd * d;\n vec3 n = norm(p);\n float spc = pow(max(0.0, dot(reflect(l1, n), rd)), 30.0);\n return spc;\n}\n\nvoid main() {\n\n outputColor = v_Color;\n float spc = calSpc();\n outputColor += spc * 0.4;\n}\n";
|
|
26
25
|
/* babel-plugin-inline-import '../shaders/water/polygon_water_vert.glsl' */
|
|
27
26
|
var water_vert = "layout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 14) in vec2 a_uv;\nlayout(std140) uniform commonUniforms {\n float u_speed;\n float u_time;\n};\nout vec4 v_Color;\nout vec2 v_uv;\n\n\n#pragma include \"projection\"\n\nvoid main() {\n v_uv = a_uv;\n v_Color = a_Color;\n v_Color.a *= opacity;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz, 1.0));\n}\n\n";
|
|
28
|
-
var isNumber = _l7Utils.lodashUtil.isNumber;
|
|
29
27
|
var WaterModel = exports.default = /*#__PURE__*/function (_BaseModel) {
|
|
30
28
|
(0, _inherits2.default)(WaterModel, _BaseModel);
|
|
31
29
|
var _super = _createSuper(WaterModel);
|
|
@@ -10,7 +10,6 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
10
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
var _l7Core = require("@antv/l7-core");
|
|
14
13
|
var _l7Utils = require("@antv/l7-utils");
|
|
15
14
|
var _TileLayerService = require("../service/TileLayerService");
|
|
16
15
|
var _TilePickService = require("../service/TilePickService");
|
|
@@ -62,10 +61,10 @@ var BaseTileLayer = exports.default = /*#__PURE__*/function () {
|
|
|
62
61
|
(0, _defineProperty2.default)(this, "viewchange", debounce(this.mapchange, 24));
|
|
63
62
|
this.parent = parent;
|
|
64
63
|
var container = this.parent.getContainer();
|
|
65
|
-
this.rendererService = container.
|
|
66
|
-
this.layerService = container.
|
|
67
|
-
this.mapService = container.
|
|
68
|
-
this.pickingService = container.
|
|
64
|
+
this.rendererService = container.rendererService;
|
|
65
|
+
this.layerService = container.layerService;
|
|
66
|
+
this.mapService = container.mapService;
|
|
67
|
+
this.pickingService = container.pickingService;
|
|
69
68
|
|
|
70
69
|
// 初始化瓦片管理服务
|
|
71
70
|
this.tileLayerService = new _TileLayerService.TileLayerService({
|
|
@@ -45,8 +45,6 @@ function readPixel(x, y, rendererService) {
|
|
|
45
45
|
var _getViewportSize = getViewportSize(),
|
|
46
46
|
width = _getViewportSize.width,
|
|
47
47
|
height = _getViewportSize.height;
|
|
48
|
-
width *= _l7Utils.DOM.DPR;
|
|
49
|
-
height *= _l7Utils.DOM.DPR;
|
|
50
48
|
if (xInDevicePixel > width - 1 * _l7Utils.DOM.DPR || xInDevicePixel < 0 || yInDevicePixel > height - 1 * _l7Utils.DOM.DPR || yInDevicePixel < 0) {
|
|
51
49
|
return false;
|
|
52
50
|
}
|
|
@@ -11,7 +11,6 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
11
11
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
12
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
|
-
require("reflect-metadata");
|
|
15
14
|
var TileLayerService = exports.TileLayerService = /*#__PURE__*/function () {
|
|
16
15
|
function TileLayerService(_ref) {
|
|
17
16
|
var rendererService = _ref.rendererService,
|
|
@@ -12,7 +12,6 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
12
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
13
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
14
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
var _l7Core = require("@antv/l7-core");
|
|
16
15
|
var _l7Utils = require("@antv/l7-utils");
|
|
17
16
|
var _TileSourceService = require("./TileSourceService");
|
|
18
17
|
var SELECT = 'select';
|
|
@@ -49,7 +48,7 @@ var TilePickService = exports.TilePickService = /*#__PURE__*/function () {
|
|
|
49
48
|
while (1) switch (_context.prev = _context.next) {
|
|
50
49
|
case 0:
|
|
51
50
|
container = this.parent.getContainer();
|
|
52
|
-
pickingService = container.
|
|
51
|
+
pickingService = container.pickingService;
|
|
53
52
|
if (!(layer.type === 'RasterLayer')) {
|
|
54
53
|
_context.next = 8;
|
|
55
54
|
break;
|
|
@@ -177,7 +176,7 @@ var TilePickService = exports.TilePickService = /*#__PURE__*/function () {
|
|
|
177
176
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
178
177
|
}, {
|
|
179
178
|
key: "pickRasterLayer",
|
|
180
|
-
value: function pickRasterLayer(
|
|
179
|
+
value: function pickRasterLayer() {
|
|
181
180
|
return false;
|
|
182
181
|
}
|
|
183
182
|
}]);
|
package/lib/tile/tile/Tile.js
CHANGED
|
@@ -125,8 +125,8 @@ var Tile = exports.default = /*#__PURE__*/function (_EventEmitter) {
|
|
|
125
125
|
}).shape('fill').color('#0f0').style({
|
|
126
126
|
opacity: 0.5
|
|
127
127
|
});
|
|
128
|
-
container = (0, _l7Core.createLayerContainer)(this.parent.
|
|
129
|
-
mask.setContainer(container
|
|
128
|
+
container = (0, _l7Core.createLayerContainer)(this.parent.container);
|
|
129
|
+
mask.setContainer(container);
|
|
130
130
|
_context.next = 5;
|
|
131
131
|
return mask.init();
|
|
132
132
|
case 5:
|
|
@@ -155,8 +155,8 @@ var Tile = exports.default = /*#__PURE__*/function (_EventEmitter) {
|
|
|
155
155
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
156
156
|
while (1) switch (_context2.prev = _context2.next) {
|
|
157
157
|
case 0:
|
|
158
|
-
container = (0, _l7Core.createLayerContainer)(this.parent.
|
|
159
|
-
mask.setContainer(container
|
|
158
|
+
container = (0, _l7Core.createLayerContainer)(this.parent.container);
|
|
159
|
+
mask.setContainer(container);
|
|
160
160
|
_context2.next = 4;
|
|
161
161
|
return mask.init();
|
|
162
162
|
case 4:
|
|
@@ -183,8 +183,8 @@ var Tile = exports.default = /*#__PURE__*/function (_EventEmitter) {
|
|
|
183
183
|
case 0:
|
|
184
184
|
// set flag
|
|
185
185
|
layer.isTileLayer = true;
|
|
186
|
-
container = (0, _l7Core.createLayerContainer)(this.parent.
|
|
187
|
-
layer.setContainer(container
|
|
186
|
+
container = (0, _l7Core.createLayerContainer)(this.parent.container);
|
|
187
|
+
layer.setContainer(container);
|
|
188
188
|
this.layers.push(layer);
|
|
189
189
|
_context3.next = 6;
|
|
190
190
|
return layer.init();
|
|
@@ -221,6 +221,7 @@ var Tile = exports.default = /*#__PURE__*/function (_EventEmitter) {
|
|
|
221
221
|
value: function getMainLayer() {
|
|
222
222
|
return this.layers[0];
|
|
223
223
|
}
|
|
224
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
224
225
|
}, {
|
|
225
226
|
key: "getFeatures",
|
|
226
227
|
value: function getFeatures(sourceLayer) {
|
|
@@ -232,6 +233,7 @@ var Tile = exports.default = /*#__PURE__*/function (_EventEmitter) {
|
|
|
232
233
|
* @param id
|
|
233
234
|
* @returns
|
|
234
235
|
*/
|
|
236
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
235
237
|
}, {
|
|
236
238
|
key: "getFeatureById",
|
|
237
239
|
value: function getFeatureById(id) {
|
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-layers",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.21.0",
|
|
4
4
|
"description": "L7's collection of built-in layers",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"types": "es/index.d.ts",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "xiaoiver",
|
|
8
7
|
"sideEffects": [
|
|
9
8
|
"./es/index.js"
|
|
10
9
|
],
|
|
10
|
+
"main": "lib/index.js",
|
|
11
|
+
"module": "es/index.js",
|
|
12
|
+
"types": "es/index.d.ts",
|
|
11
13
|
"files": [
|
|
12
14
|
"dist",
|
|
13
15
|
"lib",
|
|
@@ -15,22 +17,20 @@
|
|
|
15
17
|
"README.md"
|
|
16
18
|
],
|
|
17
19
|
"scripts": {
|
|
18
|
-
"tsc": "tsc --project tsconfig.build.json",
|
|
19
|
-
"clean": "rimraf dist; rimraf es; rimraf lib;",
|
|
20
20
|
"build": "father build",
|
|
21
21
|
"build:cjs": "BABEL_ENV=cjs babel src --root-mode upward --out-dir lib --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments",
|
|
22
22
|
"build:esm": "BABEL_ENV=esm babel src --root-mode upward --out-dir es --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments",
|
|
23
|
-
"
|
|
24
|
-
"sync": "tnpm sync"
|
|
23
|
+
"clean": "rimraf dist; rimraf es; rimraf lib;",
|
|
24
|
+
"sync": "tnpm sync",
|
|
25
|
+
"tsc": "tsc --project tsconfig.build.json",
|
|
26
|
+
"watch": "BABEL_ENV=cjs babel src --watch --root-mode upward --out-dir lib --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments"
|
|
25
27
|
},
|
|
26
|
-
"author": "xiaoiver",
|
|
27
|
-
"license": "ISC",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@antv/async-hook": "^2.2.9",
|
|
30
|
-
"@antv/l7-core": "2.
|
|
31
|
-
"@antv/l7-maps": "2.
|
|
32
|
-
"@antv/l7-source": "2.
|
|
33
|
-
"@antv/l7-utils": "2.
|
|
30
|
+
"@antv/l7-core": "2.21.0",
|
|
31
|
+
"@antv/l7-maps": "2.21.0",
|
|
32
|
+
"@antv/l7-source": "2.21.0",
|
|
33
|
+
"@antv/l7-utils": "2.21.0",
|
|
34
34
|
"@babel/runtime": "^7.7.7",
|
|
35
35
|
"@mapbox/martini": "^0.2.0",
|
|
36
36
|
"@turf/clone": "^6.5.0",
|
|
@@ -47,12 +47,10 @@
|
|
|
47
47
|
"extrude-polyline": "^1.0.6",
|
|
48
48
|
"gl-matrix": "^3.1.0",
|
|
49
49
|
"gl-vec2": "^1.3.0",
|
|
50
|
-
"
|
|
51
|
-
"polyline-miter-util": "^1.0.1",
|
|
52
|
-
"reflect-metadata": "^0.1.13"
|
|
50
|
+
"polyline-miter-util": "^1.0.1"
|
|
53
51
|
},
|
|
54
52
|
"devDependencies": {
|
|
55
|
-
"@antv/l7-test-utils": "2.
|
|
53
|
+
"@antv/l7-test-utils": "2.21.0",
|
|
56
54
|
"@types/d3-array": "^2.0.0",
|
|
57
55
|
"@types/d3-color": "^1.2.2",
|
|
58
56
|
"@types/d3-interpolate": "1.1.6",
|
|
@@ -61,8 +59,8 @@
|
|
|
61
59
|
"@types/gl-matrix": "^2.4.5",
|
|
62
60
|
"@types/lodash": "^4.14.138"
|
|
63
61
|
},
|
|
64
|
-
"gitHead": "1966dbadf9efee8d69d22beb4d89947c158da634",
|
|
65
62
|
"publishConfig": {
|
|
66
63
|
"access": "public"
|
|
67
|
-
}
|
|
64
|
+
},
|
|
65
|
+
"gitHead": "7fa1b00b5262c98bb4cceef4eaf87a7b10af7e29"
|
|
68
66
|
}
|