@antv/l7-layers 2.9.25-alpha.0 → 2.9.25

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.
Files changed (125) hide show
  1. package/es/heatmap/models/heatmap.js +1 -1
  2. package/es/tile/utils.js +1 -1
  3. package/lib/Geometry/index.js +114 -77
  4. package/lib/Geometry/models/billboard.js +232 -181
  5. package/lib/Geometry/models/index.js +18 -34
  6. package/lib/Geometry/models/plane.js +407 -278
  7. package/lib/Geometry/models/sprite.js +291 -189
  8. package/lib/canvas/index.js +101 -66
  9. package/lib/canvas/models/canvas.js +207 -140
  10. package/lib/canvas/models/index.js +12 -30
  11. package/lib/citybuliding/building.js +98 -63
  12. package/lib/citybuliding/models/build.js +192 -146
  13. package/lib/core/BaseLayer.js +1331 -814
  14. package/lib/core/BaseModel.js +457 -279
  15. package/lib/core/interface.js +40 -53
  16. package/lib/core/schema.js +21 -39
  17. package/lib/core/shape/Path.js +67 -79
  18. package/lib/core/shape/extrude.js +132 -91
  19. package/lib/core/triangulation.js +378 -196
  20. package/lib/earth/index.js +100 -62
  21. package/lib/earth/models/atmosphere.js +146 -112
  22. package/lib/earth/models/base.js +210 -150
  23. package/lib/earth/models/bloomsphere.js +146 -112
  24. package/lib/earth/utils.js +111 -91
  25. package/lib/heatmap/index.js +149 -92
  26. package/lib/heatmap/models/grid.js +118 -91
  27. package/lib/heatmap/models/grid3d.js +155 -123
  28. package/lib/heatmap/models/heatmap.js +475 -338
  29. package/lib/heatmap/models/hexagon.js +121 -92
  30. package/lib/heatmap/models/index.js +22 -37
  31. package/lib/heatmap/triangulation.js +31 -47
  32. package/lib/image/index.js +111 -74
  33. package/lib/image/models/dataImage.js +232 -174
  34. package/lib/image/models/image.js +175 -128
  35. package/lib/image/models/index.js +15 -32
  36. package/lib/index.js +263 -97
  37. package/lib/line/index.js +131 -85
  38. package/lib/line/models/arc.js +352 -237
  39. package/lib/line/models/arc_3d.js +334 -228
  40. package/lib/line/models/earthArc_3d.js +336 -228
  41. package/lib/line/models/great_circle.js +291 -200
  42. package/lib/line/models/half.js +286 -201
  43. package/lib/line/models/index.js +42 -50
  44. package/lib/line/models/line.js +428 -299
  45. package/lib/line/models/linearline.js +277 -203
  46. package/lib/line/models/simpleLine.js +239 -175
  47. package/lib/line/models/tile.js +348 -237
  48. package/lib/line/models/wall.js +327 -235
  49. package/lib/mask/index.js +92 -59
  50. package/lib/mask/models/fill.js +134 -82
  51. package/lib/mask/models/index.js +12 -30
  52. package/lib/plugins/DataMappingPlugin.js +342 -224
  53. package/lib/plugins/DataSourcePlugin.js +102 -87
  54. package/lib/plugins/FeatureScalePlugin.js +330 -240
  55. package/lib/plugins/LayerAnimateStylePlugin.js +61 -55
  56. package/lib/plugins/LayerModelPlugin.js +80 -73
  57. package/lib/plugins/LayerStylePlugin.js +48 -51
  58. package/lib/plugins/LightingPlugin.js +80 -68
  59. package/lib/plugins/MultiPassRendererPlugin.js +91 -65
  60. package/lib/plugins/PixelPickingPlugin.js +150 -109
  61. package/lib/plugins/RegisterStyleAttributePlugin.js +110 -110
  62. package/lib/plugins/ShaderUniformPlugin.js +118 -99
  63. package/lib/plugins/UpdateModelPlugin.js +40 -47
  64. package/lib/plugins/UpdateStyleAttributePlugin.js +93 -75
  65. package/lib/point/index.js +226 -150
  66. package/lib/point/models/earthExtrude.js +279 -201
  67. package/lib/point/models/earthFill.js +287 -202
  68. package/lib/point/models/extrude.js +299 -203
  69. package/lib/point/models/fill.js +406 -275
  70. package/lib/point/models/fillmage.js +365 -256
  71. package/lib/point/models/image.js +241 -168
  72. package/lib/point/models/index.js +46 -52
  73. package/lib/point/models/normal.js +183 -134
  74. package/lib/point/models/radar.js +304 -211
  75. package/lib/point/models/simplePoint.js +194 -142
  76. package/lib/point/models/text.js +608 -385
  77. package/lib/point/models/tile.js +314 -223
  78. package/lib/point/shape/extrude.js +56 -52
  79. package/lib/polygon/index.js +154 -102
  80. package/lib/polygon/models/extrude.js +311 -223
  81. package/lib/polygon/models/fill.js +215 -153
  82. package/lib/polygon/models/index.js +46 -52
  83. package/lib/polygon/models/ocean.js +244 -173
  84. package/lib/polygon/models/tile.js +144 -100
  85. package/lib/polygon/models/water.js +222 -153
  86. package/lib/raster/buffers/triangulation.js +27 -40
  87. package/lib/raster/index.js +115 -75
  88. package/lib/raster/models/index.js +16 -33
  89. package/lib/raster/models/raster.js +178 -135
  90. package/lib/raster/raster.js +187 -132
  91. package/lib/tile/interface.js +4 -16
  92. package/lib/tile/manager/tileConfigManager.js +125 -86
  93. package/lib/tile/manager/tileLayerManager.js +313 -229
  94. package/lib/tile/manager/tilePickerManager.js +192 -123
  95. package/lib/tile/models/tileModel.js +71 -52
  96. package/lib/tile/tileFactory/base.js +432 -309
  97. package/lib/tile/tileFactory/index.js +51 -49
  98. package/lib/tile/tileFactory/line.js +65 -50
  99. package/lib/tile/tileFactory/point.js +65 -50
  100. package/lib/tile/tileFactory/polygon.js +65 -50
  101. package/lib/tile/tileFactory/raster.js +66 -54
  102. package/lib/tile/tileFactory/rasterData.js +88 -76
  103. package/lib/tile/tileFactory/rasterDataLayer.js +97 -62
  104. package/lib/tile/tileFactory/vectorLayer.js +168 -109
  105. package/lib/tile/tileLayer/baseTileLayer.js +420 -221
  106. package/lib/tile/tmsTileLayer.js +110 -67
  107. package/lib/tile/utils.js +110 -92
  108. package/lib/utils/blend.js +59 -79
  109. package/lib/utils/collision-index.js +107 -64
  110. package/lib/utils/dataMappingStyle.js +105 -60
  111. package/lib/utils/extrude_polyline.js +600 -398
  112. package/lib/utils/grid-index.js +163 -111
  113. package/lib/utils/layerData.js +130 -99
  114. package/lib/utils/multiPassRender.js +49 -41
  115. package/lib/utils/polylineNormal.js +148 -96
  116. package/lib/utils/simpleLine.js +100 -85
  117. package/lib/utils/symbol-layout.js +219 -116
  118. package/lib/utils/updateShape.js +15 -41
  119. package/lib/wind/index.js +109 -71
  120. package/lib/wind/models/index.js +12 -30
  121. package/lib/wind/models/utils.js +144 -105
  122. package/lib/wind/models/wind.js +333 -224
  123. package/lib/wind/models/windRender.js +329 -218
  124. package/lib/wind/models/windShader.js +23 -181
  125. package/package.json +6 -6
@@ -1,162 +1,222 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
-
22
- // src/earth/models/base.ts
23
- var base_exports = {};
24
- __export(base_exports, {
25
- default: () => BaseEarthModel
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
26
7
  });
27
- module.exports = __toCommonJS(base_exports);
28
- var import_l7_core = require("@antv/l7-core");
29
- var import_BaseModel = __toESM(require("../../core/BaseModel"));
30
- var import_triangulation = require("../../core/triangulation");
31
- var import_base_frag = __toESM(require("../shaders/base_frag.glsl"));
32
- var import_base_vert = __toESM(require("../shaders/base_vert.glsl"));
33
- var BaseEarthModel = class extends import_BaseModel.default {
34
- constructor() {
35
- super(...arguments);
36
- this.earthTime = 3.4;
37
- this.sunX = 1e3;
38
- this.sunY = 1e3;
39
- this.sunZ = 1e3;
40
- this.sunRadius = Math.sqrt(this.sunX * this.sunX + this.sunY * this.sunY + this.sunZ * this.sunZ);
8
+ exports.default = void 0;
9
+
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
+
16
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
+
18
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
+
20
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
+
22
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
+
24
+ var _l7Core = require("@antv/l7-core");
25
+
26
+ var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
27
+
28
+ var _triangulation = require("../../core/triangulation");
29
+
30
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
31
+
32
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
33
+
34
+ /* babel-plugin-inline-import '../shaders/base_frag.glsl' */
35
+ var baseFrag = "\nuniform sampler2D u_texture;\n\nvarying vec2 v_texCoord;\nvarying float v_lightWeight;\n\n\nvoid main() {\n\n vec4 color = texture2D(u_texture,vec2(v_texCoord.x,v_texCoord.y));\n color.xyz = color.xyz * v_lightWeight;\n gl_FragColor = color;\n}\n";
36
+
37
+ /* babel-plugin-inline-import '../shaders/base_vert.glsl' */
38
+ var baseVert = "// attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute vec2 a_Uv;\nvarying vec2 v_texCoord;\n\n// attribute vec2 a_Extrude;\n// attribute float a_Size;\n// attribute float a_Shape;\n\nuniform vec3 u_CameraPosition;\nuniform mat4 u_ViewProjectionMatrix;\nuniform mat4 u_ModelMatrix;\nuniform float u_ambientRatio : 0.5;\nuniform float u_diffuseRatio : 0.3;\nuniform float u_specularRatio : 0.2;\nuniform vec3 u_sunLight: [1.0, -10.5, 12.0];\n\n\n\nfloat calc_lighting(vec4 pos) {\n\n vec3 worldPos = vec3(pos * u_ModelMatrix);\n\n vec3 worldNormal = a_Normal;\n\n // cal light weight\n vec3 viewDir = normalize(u_CameraPosition - worldPos);\n\n vec3 lightDir = normalize(u_sunLight);\n\n vec3 halfDir = normalize(viewDir+lightDir);\n // lambert\n float lambert = dot(worldNormal, lightDir);\n // specular\n float specular = pow(max(0.0, dot(worldNormal, halfDir)), 32.0);\n //sum to light weight\n float lightWeight = u_ambientRatio + u_diffuseRatio * lambert + u_specularRatio * specular;\n\n return lightWeight;\n}\n\nvarying float v_lightWeight;\nvoid main() {\n\n v_texCoord = a_Uv;\n\n float lightWeight = calc_lighting(vec4(a_Position, 1.0));\n v_lightWeight = lightWeight;\n\n gl_Position = u_ViewProjectionMatrix * u_ModelMatrix * vec4(a_Position, 1.0);\n}\n";
39
+
40
+ var BaseEarthModel = /*#__PURE__*/function (_BaseModel) {
41
+ (0, _inherits2.default)(BaseEarthModel, _BaseModel);
42
+
43
+ var _super = _createSuper(BaseEarthModel);
44
+
45
+ function BaseEarthModel() {
46
+ var _this;
47
+
48
+ (0, _classCallCheck2.default)(this, BaseEarthModel);
49
+
50
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
51
+ args[_key] = arguments[_key];
52
+ }
53
+
54
+ _this = _super.call.apply(_super, [this].concat(args));
55
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "earthTime", 3.4);
56
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "sunX", 1000);
57
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "sunY", 1000);
58
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "sunZ", 1000);
59
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "sunRadius", Math.sqrt(_this.sunX * _this.sunX + _this.sunY * _this.sunY + _this.sunZ * _this.sunZ));
60
+ return _this;
41
61
  }
42
- getUninforms() {
43
- const { animateOption, globelOtions } = this.layer.getLayerConfig();
44
- if (animateOption == null ? void 0 : animateOption.enable) {
45
- this.mapService.rotateY({
46
- reg: 2e-3
47
- });
48
- this.earthTime += 0.02;
62
+
63
+ (0, _createClass2.default)(BaseEarthModel, [{
64
+ key: "getUninforms",
65
+ value: function getUninforms() {
66
+ var _this$layer$getLayerC = this.layer.getLayerConfig(),
67
+ animateOption = _this$layer$getLayerC.animateOption,
68
+ globelOtions = _this$layer$getLayerC.globelOtions;
69
+
70
+ if (animateOption !== null && animateOption !== void 0 && animateOption.enable) {
71
+ // @ts-ignore
72
+ // T: rotateY 方法只有在地球模式下存在
73
+ this.mapService.rotateY({
74
+ reg: 0.002
75
+ });
76
+ this.earthTime += 0.02;
77
+ this.sunY = 10;
78
+ this.sunX = Math.cos(this.earthTime) * (this.sunRadius - this.sunY);
79
+ this.sunZ = Math.sin(this.earthTime) * (this.sunRadius - this.sunY);
80
+ }
81
+
82
+ return {
83
+ u_ambientRatio: (globelOtions === null || globelOtions === void 0 ? void 0 : globelOtions.ambientRatio) || 0.6,
84
+ // 环境光
85
+ u_diffuseRatio: (globelOtions === null || globelOtions === void 0 ? void 0 : globelOtions.diffuseRatio) || 0.4,
86
+ // 漫反射
87
+ u_specularRatio: (globelOtions === null || globelOtions === void 0 ? void 0 : globelOtions.specularRatio) || 0.1,
88
+ // 高光反射
89
+ // u_sunLight: [120, 120, 120],
90
+ u_sunLight: [this.sunX, this.sunY, this.sunZ],
91
+ u_texture: this.texture
92
+ };
93
+ }
94
+ }, {
95
+ key: "setEarthTime",
96
+ value: function setEarthTime(time) {
97
+ this.earthTime = time;
49
98
  this.sunY = 10;
50
99
  this.sunX = Math.cos(this.earthTime) * (this.sunRadius - this.sunY);
51
100
  this.sunZ = Math.sin(this.earthTime) * (this.sunRadius - this.sunY);
101
+ this.layerService.renderLayers();
52
102
  }
53
- return {
54
- u_ambientRatio: (globelOtions == null ? void 0 : globelOtions.ambientRatio) || 0.6,
55
- u_diffuseRatio: (globelOtions == null ? void 0 : globelOtions.diffuseRatio) || 0.4,
56
- u_specularRatio: (globelOtions == null ? void 0 : globelOtions.specularRatio) || 0.1,
57
- u_sunLight: [this.sunX, this.sunY, this.sunZ],
58
- u_texture: this.texture
59
- };
60
- }
61
- setEarthTime(time) {
62
- this.earthTime = time;
63
- this.sunY = 10;
64
- this.sunX = Math.cos(this.earthTime) * (this.sunRadius - this.sunY);
65
- this.sunZ = Math.sin(this.earthTime) * (this.sunRadius - this.sunY);
66
- this.layerService.renderLayers();
67
- }
68
- initModels(callbackModel) {
69
- const { globelOtions } = this.layer.getLayerConfig();
70
- if ((globelOtions == null ? void 0 : globelOtions.earthTime) !== void 0) {
71
- this.setEarthTime(globelOtions.earthTime);
72
- }
73
- const source = this.layer.getSource();
74
- const { createTexture2D } = this.rendererService;
75
- this.texture = createTexture2D({
76
- height: 0,
77
- width: 0
78
- });
79
- source.data.images.then((imageData) => {
103
+ }, {
104
+ key: "initModels",
105
+ value: function initModels(callbackModel) {
106
+ var _this2 = this;
107
+
108
+ var _this$layer$getLayerC2 = this.layer.getLayerConfig(),
109
+ globelOtions = _this$layer$getLayerC2.globelOtions;
110
+
111
+ if ((globelOtions === null || globelOtions === void 0 ? void 0 : globelOtions.earthTime) !== undefined) {
112
+ this.setEarthTime(globelOtions.earthTime);
113
+ }
114
+
115
+ var source = this.layer.getSource();
116
+ var createTexture2D = this.rendererService.createTexture2D;
80
117
  this.texture = createTexture2D({
81
- data: imageData[0],
82
- width: imageData[0].width,
83
- height: imageData[0].height
118
+ height: 0,
119
+ width: 0
84
120
  });
85
- this.layerService.updateLayerRenderList();
86
- this.layerService.renderLayers();
87
- });
88
- this.buildModels(callbackModel);
89
- }
90
- clearModels() {
91
- return "";
92
- }
93
- buildModels(callbackModel) {
94
- this.layer.zIndex = -998;
95
- this.layer.buildLayerModel({
96
- moduleName: "earthBase",
97
- vertexShader: import_base_vert.default,
98
- fragmentShader: import_base_frag.default,
99
- triangulation: import_triangulation.earthTriangulation,
100
- depth: { enable: true },
101
- blend: this.getBlend()
102
- }).then((model) => {
103
- callbackModel([model]);
104
- }).catch((err) => {
105
- console.warn(err);
106
- callbackModel([]);
107
- });
108
- }
109
- registerBuiltinAttributes() {
110
- this.styleAttributeService.registerStyleAttribute({
111
- name: "size",
112
- type: import_l7_core.AttributeType.Attribute,
113
- descriptor: {
114
- name: "a_Size",
115
- buffer: {
116
- usage: import_l7_core.gl.DYNAMIC_DRAW,
117
- data: [],
118
- type: import_l7_core.gl.FLOAT
121
+ source.data.images.then(function (imageData) {
122
+ _this2.texture = createTexture2D({
123
+ data: imageData[0],
124
+ width: imageData[0].width,
125
+ height: imageData[0].height
126
+ });
127
+
128
+ _this2.layerService.updateLayerRenderList();
129
+
130
+ _this2.layerService.renderLayers();
131
+ });
132
+ this.buildModels(callbackModel);
133
+ }
134
+ }, {
135
+ key: "clearModels",
136
+ value: function clearModels() {
137
+ return '';
138
+ }
139
+ }, {
140
+ key: "buildModels",
141
+ value: function buildModels(callbackModel) {
142
+ // TODO: 调整图层的绘制顺序 地球大气层
143
+ this.layer.zIndex = -998;
144
+ this.layer.buildLayerModel({
145
+ moduleName: 'earthBase',
146
+ vertexShader: baseVert,
147
+ fragmentShader: baseFrag,
148
+ triangulation: _triangulation.earthTriangulation,
149
+ depth: {
150
+ enable: true
119
151
  },
120
- size: 1,
121
- update: (feature, featureIdx, vertex, attributeIdx) => {
122
- const { size = 1 } = feature;
123
- return Array.isArray(size) ? [size[0]] : [size];
152
+ blend: this.getBlend()
153
+ }).then(function (model) {
154
+ callbackModel([model]);
155
+ }).catch(function (err) {
156
+ console.warn(err);
157
+ callbackModel([]);
158
+ });
159
+ }
160
+ }, {
161
+ key: "registerBuiltinAttributes",
162
+ value: function registerBuiltinAttributes() {
163
+ // point layer size;
164
+ this.styleAttributeService.registerStyleAttribute({
165
+ name: 'size',
166
+ type: _l7Core.AttributeType.Attribute,
167
+ descriptor: {
168
+ name: 'a_Size',
169
+ buffer: {
170
+ // give the WebGL driver a hint that this buffer may change
171
+ usage: _l7Core.gl.DYNAMIC_DRAW,
172
+ data: [],
173
+ type: _l7Core.gl.FLOAT
174
+ },
175
+ size: 1,
176
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
177
+ var _feature$size = feature.size,
178
+ size = _feature$size === void 0 ? 1 : _feature$size;
179
+ return Array.isArray(size) ? [size[0]] : [size];
180
+ }
124
181
  }
125
- }
126
- });
127
- this.styleAttributeService.registerStyleAttribute({
128
- name: "normal",
129
- type: import_l7_core.AttributeType.Attribute,
130
- descriptor: {
131
- name: "a_Normal",
132
- buffer: {
133
- usage: import_l7_core.gl.STATIC_DRAW,
134
- data: [],
135
- type: import_l7_core.gl.FLOAT
136
- },
137
- size: 3,
138
- update: (feature, featureIdx, vertex, attributeIdx, normal) => {
139
- return normal;
182
+ });
183
+ this.styleAttributeService.registerStyleAttribute({
184
+ name: 'normal',
185
+ type: _l7Core.AttributeType.Attribute,
186
+ descriptor: {
187
+ name: 'a_Normal',
188
+ buffer: {
189
+ // give the WebGL driver a hint that this buffer may change
190
+ usage: _l7Core.gl.STATIC_DRAW,
191
+ data: [],
192
+ type: _l7Core.gl.FLOAT
193
+ },
194
+ size: 3,
195
+ update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
196
+ return normal;
197
+ }
140
198
  }
141
- }
142
- });
143
- this.styleAttributeService.registerStyleAttribute({
144
- name: "uv",
145
- type: import_l7_core.AttributeType.Attribute,
146
- descriptor: {
147
- name: "a_Uv",
148
- buffer: {
149
- usage: import_l7_core.gl.DYNAMIC_DRAW,
150
- data: [],
151
- type: import_l7_core.gl.FLOAT
152
- },
153
- size: 2,
154
- update: (feature, featureIdx, vertex, attributeIdx) => {
155
- return [vertex[3], vertex[4]];
199
+ });
200
+ this.styleAttributeService.registerStyleAttribute({
201
+ name: 'uv',
202
+ type: _l7Core.AttributeType.Attribute,
203
+ descriptor: {
204
+ name: 'a_Uv',
205
+ buffer: {
206
+ // give the WebGL driver a hint that this buffer may change
207
+ usage: _l7Core.gl.DYNAMIC_DRAW,
208
+ data: [],
209
+ type: _l7Core.gl.FLOAT
210
+ },
211
+ size: 2,
212
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
213
+ return [vertex[3], vertex[4]];
214
+ }
156
215
  }
157
- }
158
- });
159
- }
160
- };
161
- // Annotate the CommonJS export names for ESM import in node:
162
- 0 && (module.exports = {});
216
+ });
217
+ }
218
+ }]);
219
+ return BaseEarthModel;
220
+ }(_BaseModel2.default);
221
+
222
+ exports.default = BaseEarthModel;
@@ -1,118 +1,152 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
-
22
- // src/earth/models/bloomsphere.ts
23
- var bloomsphere_exports = {};
24
- __export(bloomsphere_exports, {
25
- default: () => EarthBloomSphereModel
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
26
7
  });
27
- module.exports = __toCommonJS(bloomsphere_exports);
28
- var import_l7_core = require("@antv/l7-core");
29
- var import_lodash = require("lodash");
30
- var import_BaseModel = __toESM(require("../../core/BaseModel"));
31
- var import_triangulation = require("../../core/triangulation");
32
- var import_bloomsphere_frag = __toESM(require("../shaders/bloomsphere_frag.glsl"));
33
- var import_bloomsphere_vert = __toESM(require("../shaders/bloomsphere_vert.glsl"));
34
- var EarthBloomSphereModel = class extends import_BaseModel.default {
35
- getUninforms() {
36
- const {
37
- opacity = 1
38
- } = this.layer.getLayerConfig();
39
- return {
40
- u_opacity: (0, import_lodash.isNumber)(opacity) ? opacity : 1
41
- };
42
- }
43
- initModels(callbackModel) {
44
- this.buildModels(callbackModel);
45
- }
46
- clearModels() {
47
- return "";
48
- }
49
- buildModels(callbackModel) {
50
- this.layer.zIndex = -999;
51
- this.layer.buildLayerModel({
52
- moduleName: "earthBloom",
53
- vertexShader: import_bloomsphere_vert.default,
54
- fragmentShader: import_bloomsphere_frag.default,
55
- triangulation: import_triangulation.earthOuterTriangulation,
56
- depth: { enable: false },
57
- blend: this.getBlend()
58
- }).then((model) => {
59
- callbackModel([model]);
60
- }).catch((err) => {
61
- console.warn(err);
62
- callbackModel([]);
63
- });
8
+ exports.default = void 0;
9
+
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
15
+
16
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
17
+
18
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
19
+
20
+ var _l7Core = require("@antv/l7-core");
21
+
22
+ var _lodash = require("lodash");
23
+
24
+ var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
25
+
26
+ var _triangulation = require("../../core/triangulation");
27
+
28
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
29
+
30
+ 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; } }
31
+
32
+ /* babel-plugin-inline-import '../shaders/bloomsphere_frag.glsl' */
33
+ var bloomSphereFrag = "\nuniform float u_opacity;\nuniform vec3 u_CameraPosition;\nvarying vec3 vVertexNormal;\n\nvarying vec4 v_Color;\nvoid main() {\n\n\n float intensity = - dot(normalize(vVertexNormal), normalize(u_CameraPosition));\n // TODO: \u53BB\u9664\u80CC\u9762\n if(intensity > 1.0) intensity = 0.0;\n\n gl_FragColor = vec4(v_Color.rgb, v_Color.a * intensity * u_opacity);\n}\n";
34
+
35
+ /* babel-plugin-inline-import '../shaders/bloomsphere_vert.glsl' */
36
+ var bloomSphereVert = "\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute vec2 a_Uv;\nattribute vec4 a_Color;\nuniform vec3 u_CameraPosition;\nuniform mat4 u_ViewProjectionMatrix;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_ViewMatrix;\n\nvarying vec3 vVertexNormal;\nvarying vec4 v_Color;\n\nvoid main() {\n v_Color = a_Color;\n\n vVertexNormal = a_Normal;\n\n gl_Position = u_ViewProjectionMatrix * u_ModelMatrix * vec4(a_Position, 1.0);\n}\n";
37
+
38
+ var EarthBloomSphereModel = /*#__PURE__*/function (_BaseModel) {
39
+ (0, _inherits2.default)(EarthBloomSphereModel, _BaseModel);
40
+
41
+ var _super = _createSuper(EarthBloomSphereModel);
42
+
43
+ function EarthBloomSphereModel() {
44
+ (0, _classCallCheck2.default)(this, EarthBloomSphereModel);
45
+ return _super.apply(this, arguments);
64
46
  }
65
- registerBuiltinAttributes() {
66
- this.styleAttributeService.registerStyleAttribute({
67
- name: "size",
68
- type: import_l7_core.AttributeType.Attribute,
69
- descriptor: {
70
- name: "a_Size",
71
- buffer: {
72
- usage: import_l7_core.gl.DYNAMIC_DRAW,
73
- data: [],
74
- type: import_l7_core.gl.FLOAT
47
+
48
+ (0, _createClass2.default)(EarthBloomSphereModel, [{
49
+ key: "getUninforms",
50
+ value: function getUninforms() {
51
+ var _ref = this.layer.getLayerConfig(),
52
+ _ref$opacity = _ref.opacity,
53
+ opacity = _ref$opacity === void 0 ? 1 : _ref$opacity;
54
+
55
+ return {
56
+ u_opacity: (0, _lodash.isNumber)(opacity) ? opacity : 1.0
57
+ };
58
+ }
59
+ }, {
60
+ key: "initModels",
61
+ value: function initModels(callbackModel) {
62
+ this.buildModels(callbackModel);
63
+ }
64
+ }, {
65
+ key: "clearModels",
66
+ value: function clearModels() {
67
+ return '';
68
+ }
69
+ }, {
70
+ key: "buildModels",
71
+ value: function buildModels(callbackModel) {
72
+ // TODO: 调整图层的绘制顺序,让它保持在地球后面(减少锯齿现象)
73
+ this.layer.zIndex = -999;
74
+ this.layer.buildLayerModel({
75
+ moduleName: 'earthBloom',
76
+ vertexShader: bloomSphereVert,
77
+ fragmentShader: bloomSphereFrag,
78
+ triangulation: _triangulation.earthOuterTriangulation,
79
+ depth: {
80
+ enable: false
75
81
  },
76
- size: 1,
77
- update: (feature, featureIdx, vertex, attributeIdx) => {
78
- const { size = 1 } = feature;
79
- return Array.isArray(size) ? [size[0]] : [size];
82
+ blend: this.getBlend()
83
+ }).then(function (model) {
84
+ callbackModel([model]);
85
+ }).catch(function (err) {
86
+ console.warn(err);
87
+ callbackModel([]);
88
+ });
89
+ }
90
+ }, {
91
+ key: "registerBuiltinAttributes",
92
+ value: function registerBuiltinAttributes() {
93
+ // point layer size;
94
+ this.styleAttributeService.registerStyleAttribute({
95
+ name: 'size',
96
+ type: _l7Core.AttributeType.Attribute,
97
+ descriptor: {
98
+ name: 'a_Size',
99
+ buffer: {
100
+ // give the WebGL driver a hint that this buffer may change
101
+ usage: _l7Core.gl.DYNAMIC_DRAW,
102
+ data: [],
103
+ type: _l7Core.gl.FLOAT
104
+ },
105
+ size: 1,
106
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
107
+ var _feature$size = feature.size,
108
+ size = _feature$size === void 0 ? 1 : _feature$size;
109
+ return Array.isArray(size) ? [size[0]] : [size];
110
+ }
80
111
  }
81
- }
82
- });
83
- this.styleAttributeService.registerStyleAttribute({
84
- name: "normal",
85
- type: import_l7_core.AttributeType.Attribute,
86
- descriptor: {
87
- name: "a_Normal",
88
- buffer: {
89
- usage: import_l7_core.gl.STATIC_DRAW,
90
- data: [],
91
- type: import_l7_core.gl.FLOAT
92
- },
93
- size: 3,
94
- update: (feature, featureIdx, vertex, attributeIdx, normal) => {
95
- return normal;
112
+ });
113
+ this.styleAttributeService.registerStyleAttribute({
114
+ name: 'normal',
115
+ type: _l7Core.AttributeType.Attribute,
116
+ descriptor: {
117
+ name: 'a_Normal',
118
+ buffer: {
119
+ // give the WebGL driver a hint that this buffer may change
120
+ usage: _l7Core.gl.STATIC_DRAW,
121
+ data: [],
122
+ type: _l7Core.gl.FLOAT
123
+ },
124
+ size: 3,
125
+ update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
126
+ return normal;
127
+ }
96
128
  }
97
- }
98
- });
99
- this.styleAttributeService.registerStyleAttribute({
100
- name: "uv",
101
- type: import_l7_core.AttributeType.Attribute,
102
- descriptor: {
103
- name: "a_Uv",
104
- buffer: {
105
- usage: import_l7_core.gl.DYNAMIC_DRAW,
106
- data: [],
107
- type: import_l7_core.gl.FLOAT
108
- },
109
- size: 2,
110
- update: (feature, featureIdx, vertex, attributeIdx) => {
111
- return [vertex[3], vertex[4]];
129
+ });
130
+ this.styleAttributeService.registerStyleAttribute({
131
+ name: 'uv',
132
+ type: _l7Core.AttributeType.Attribute,
133
+ descriptor: {
134
+ name: 'a_Uv',
135
+ buffer: {
136
+ // give the WebGL driver a hint that this buffer may change
137
+ usage: _l7Core.gl.DYNAMIC_DRAW,
138
+ data: [],
139
+ type: _l7Core.gl.FLOAT
140
+ },
141
+ size: 2,
142
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
143
+ return [vertex[3], vertex[4]];
144
+ }
112
145
  }
113
- }
114
- });
115
- }
116
- };
117
- // Annotate the CommonJS export names for ESM import in node:
118
- 0 && (module.exports = {});
146
+ });
147
+ }
148
+ }]);
149
+ return EarthBloomSphereModel;
150
+ }(_BaseModel2.default);
151
+
152
+ exports.default = EarthBloomSphereModel;