@antv/l7-layers 2.15.5 → 2.16.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/Geometry/index.js +31 -9
- package/es/Geometry/models/billboard.js +89 -51
- package/es/Geometry/models/plane.js +143 -81
- package/es/Geometry/models/sprite.js +118 -60
- package/es/canvas/index.js +33 -10
- package/es/canvas/models/canvas.js +97 -41
- package/es/citybuliding/building.js +27 -8
- package/es/citybuliding/models/build.js +82 -57
- package/es/core/BaseLayer.js +486 -321
- package/es/core/BaseModel.js +126 -97
- package/es/core/LayerPickService.js +32 -21
- package/es/core/TextureService.js +13 -0
- package/es/core/interface.js +24 -17
- package/es/core/shape/Path.js +20 -13
- package/es/core/shape/extrude.js +31 -10
- package/es/core/triangulation.js +114 -54
- package/es/earth/index.js +33 -9
- package/es/earth/models/atmosphere.js +54 -30
- package/es/earth/models/base.js +85 -47
- package/es/earth/models/bloomsphere.js +54 -30
- package/es/earth/utils.js +13 -9
- package/es/heatmap/index.js +40 -10
- package/es/heatmap/models/grid.js +52 -28
- package/es/heatmap/models/grid3d.js +52 -28
- package/es/heatmap/models/heatmap.js +146 -91
- package/es/heatmap/models/hexagon.js +52 -28
- package/es/heatmap/triangulation.js +4 -0
- package/es/image/index.js +28 -9
- package/es/image/models/image.js +100 -66
- package/es/index.js +17 -9
- package/es/line/index.js +34 -9
- package/es/line/models/arc.js +118 -66
- package/es/line/models/arc_3d.js +108 -60
- package/es/line/models/earthArc_3d.js +111 -63
- package/es/line/models/great_circle.js +100 -56
- package/es/line/models/half.js +77 -46
- package/es/line/models/line.js +148 -94
- package/es/line/models/linearline.js +80 -45
- package/es/line/models/simpleLine.js +74 -41
- package/es/line/models/wall.js +92 -52
- package/es/mask/index.js +28 -9
- package/es/mask/models/fill.js +54 -29
- package/es/plugins/DataMappingPlugin.js +117 -80
- package/es/plugins/DataSourcePlugin.js +68 -45
- package/es/plugins/FeatureScalePlugin.js +122 -67
- package/es/plugins/LayerAnimateStylePlugin.js +5 -0
- package/es/plugins/LayerMaskPlugin.js +11 -3
- package/es/plugins/LayerModelPlugin.js +104 -67
- package/es/plugins/LayerStylePlugin.js +9 -3
- package/es/plugins/LightingPlugin.js +18 -12
- package/es/plugins/MultiPassRendererPlugin.js +16 -11
- package/es/plugins/PixelPickingPlugin.js +21 -12
- package/es/plugins/RegisterStyleAttributePlugin.js +12 -5
- package/es/plugins/ShaderUniformPlugin.js +27 -13
- package/es/plugins/UpdateModelPlugin.js +5 -0
- package/es/plugins/UpdateStyleAttributePlugin.js +11 -5
- package/es/point/index.js +77 -26
- package/es/point/models/earthExtrude.js +102 -61
- package/es/point/models/earthFill.js +87 -57
- package/es/point/models/extrude.js +101 -60
- package/es/point/models/fill.js +100 -70
- package/es/point/models/fillmage.js +107 -63
- package/es/point/models/image.js +88 -48
- package/es/point/models/index.js +2 -2
- package/es/point/models/normal.js +54 -30
- package/es/point/models/radar.js +64 -40
- package/es/point/models/simplePoint.js +69 -41
- package/es/point/models/text.d.ts +2 -1
- package/es/point/models/text.js +305 -201
- package/es/point/shape/extrude.js +13 -4
- package/es/polygon/index.js +40 -11
- package/es/polygon/models/extrude.js +92 -48
- package/es/polygon/models/fill.js +88 -54
- package/es/polygon/models/index.js +2 -3
- package/es/polygon/models/ocean.js +76 -42
- package/es/polygon/models/water.js +71 -37
- package/es/raster/buffers/triangulation.js +4 -2
- package/es/raster/index.js +32 -9
- package/es/raster/models/raster.js +116 -80
- package/es/raster/models/rasterRgb.js +127 -84
- package/es/raster/models/rasterTerrainRgb.js +84 -56
- package/es/tile/interaction/getRasterData.js +20 -14
- package/es/tile/interaction/utils.js +9 -7
- package/es/tile/manager/base.js +96 -63
- package/es/tile/service/TileLayerService.js +55 -33
- package/es/tile/service/TilePickService.js +40 -26
- package/es/tile/service/TileSourceService.js +7 -3
- package/es/tile/tileFactory/DebugTile.js +46 -29
- package/es/tile/tileFactory/ImageTile.js +38 -20
- package/es/tile/tileFactory/MaskTile.js +43 -22
- package/es/tile/tileFactory/RasterRGBTile.js +42 -22
- package/es/tile/tileFactory/RasterTerrainRGBTile.js +38 -20
- package/es/tile/tileFactory/RasterTile.js +53 -30
- package/es/tile/tileFactory/Tile.js +97 -63
- package/es/tile/tileFactory/VectorTile.js +68 -41
- package/es/tile/tileFactory/index.js +11 -0
- package/es/tile/tileFactory/layers/TileDebugLayer.js +27 -6
- package/es/tile/tileFactory/util.js +3 -0
- package/es/tile/tileLayer/BaseLayer.js +146 -105
- package/es/tile/utils.js +1 -1
- package/es/utils/blend.js +2 -0
- package/es/utils/collision-index.js +16 -9
- package/es/utils/dataMappingStyle.js +18 -8
- package/es/utils/extrude_polyline.js +149 -101
- package/es/utils/grid-index.js +27 -2
- package/es/utils/identityScale.js +8 -0
- package/es/utils/layerData.js +44 -30
- package/es/utils/multiPassRender.js +13 -11
- package/es/utils/polylineNormal.js +37 -31
- package/es/utils/simpleLine.js +16 -2
- package/es/utils/stencil.js +3 -2
- package/es/utils/symbol-layout.js +53 -27
- package/es/wind/index.js +29 -9
- package/es/wind/models/utils.js +51 -26
- package/es/wind/models/wind.js +147 -101
- package/es/wind/models/windRender.js +66 -53
- package/lib/Geometry/index.js +38 -9
- package/lib/Geometry/models/billboard.js +97 -51
- package/lib/Geometry/models/index.js +5 -0
- package/lib/Geometry/models/plane.js +151 -79
- package/lib/Geometry/models/sprite.js +127 -60
- package/lib/canvas/index.js +40 -10
- package/lib/canvas/models/canvas.js +101 -41
- package/lib/canvas/models/index.js +3 -0
- package/lib/citybuliding/building.js +35 -8
- package/lib/citybuliding/models/build.js +92 -57
- package/lib/core/BaseLayer.js +480 -321
- package/lib/core/BaseModel.js +139 -97
- package/lib/core/LayerPickService.js +37 -21
- package/lib/core/TextureService.js +16 -0
- package/lib/core/interface.js +31 -21
- package/lib/core/schema.js +1 -0
- package/lib/core/shape/Path.js +31 -14
- package/lib/core/shape/extrude.js +54 -10
- package/lib/core/triangulation.js +153 -53
- package/lib/earth/index.js +43 -9
- package/lib/earth/models/atmosphere.js +63 -30
- package/lib/earth/models/base.js +90 -47
- package/lib/earth/models/bloomsphere.js +63 -30
- package/lib/earth/utils.js +31 -7
- package/lib/heatmap/index.js +48 -10
- package/lib/heatmap/models/grid.js +60 -28
- package/lib/heatmap/models/grid3d.js +60 -28
- package/lib/heatmap/models/heatmap.js +162 -91
- package/lib/heatmap/models/hexagon.js +60 -28
- package/lib/heatmap/models/index.js +6 -0
- package/lib/heatmap/triangulation.js +5 -0
- package/lib/image/index.js +36 -9
- package/lib/image/models/image.js +109 -66
- package/lib/image/models/index.js +3 -0
- package/lib/index.js +61 -7
- package/lib/line/index.js +40 -9
- package/lib/line/models/arc.js +128 -64
- package/lib/line/models/arc_3d.js +119 -58
- package/lib/line/models/earthArc_3d.js +122 -61
- package/lib/line/models/great_circle.js +111 -56
- package/lib/line/models/half.js +87 -46
- package/lib/line/models/index.js +11 -0
- package/lib/line/models/line.js +156 -92
- package/lib/line/models/linearline.js +92 -45
- package/lib/line/models/simpleLine.js +84 -41
- package/lib/line/models/wall.js +103 -52
- package/lib/mask/index.js +36 -9
- package/lib/mask/models/fill.js +63 -29
- package/lib/mask/models/index.js +3 -0
- package/lib/plugins/DataMappingPlugin.js +128 -80
- package/lib/plugins/DataSourcePlugin.js +76 -45
- package/lib/plugins/FeatureScalePlugin.js +138 -67
- package/lib/plugins/LayerAnimateStylePlugin.js +10 -0
- package/lib/plugins/LayerMaskPlugin.js +17 -4
- package/lib/plugins/LayerModelPlugin.js +113 -68
- package/lib/plugins/LayerStylePlugin.js +14 -4
- package/lib/plugins/LightingPlugin.js +25 -12
- package/lib/plugins/MultiPassRendererPlugin.js +22 -11
- package/lib/plugins/PixelPickingPlugin.js +27 -12
- package/lib/plugins/RegisterStyleAttributePlugin.js +19 -5
- package/lib/plugins/ShaderUniformPlugin.js +34 -13
- package/lib/plugins/UpdateModelPlugin.js +10 -1
- package/lib/plugins/UpdateStyleAttributePlugin.js +16 -5
- package/lib/point/index.js +83 -26
- package/lib/point/models/earthExtrude.js +113 -61
- package/lib/point/models/earthFill.js +117 -57
- package/lib/point/models/extrude.js +111 -60
- package/lib/point/models/fill.js +109 -68
- package/lib/point/models/fillmage.js +115 -61
- package/lib/point/models/image.js +98 -48
- package/lib/point/models/index.js +12 -1
- package/lib/point/models/normal.js +64 -30
- package/lib/point/models/radar.js +74 -40
- package/lib/point/models/simplePoint.js +79 -41
- package/lib/point/models/text.js +314 -202
- package/lib/point/shape/extrude.js +20 -4
- package/lib/polygon/index.js +48 -11
- package/lib/polygon/models/extrude.js +103 -48
- package/lib/polygon/models/fill.js +98 -54
- package/lib/polygon/models/index.js +14 -2
- package/lib/polygon/models/ocean.js +88 -42
- package/lib/polygon/models/water.js +82 -37
- package/lib/raster/buffers/triangulation.js +7 -3
- package/lib/raster/index.js +40 -9
- package/lib/raster/models/index.js +5 -0
- package/lib/raster/models/raster.js +125 -80
- package/lib/raster/models/rasterRgb.js +139 -84
- package/lib/raster/models/rasterTerrainRgb.js +93 -56
- package/lib/tile/interaction/getRasterData.js +25 -14
- package/lib/tile/interaction/utils.js +19 -7
- package/lib/tile/manager/base.js +104 -63
- package/lib/tile/service/TileLayerService.js +60 -33
- package/lib/tile/service/TilePickService.js +48 -26
- package/lib/tile/service/TileSourceService.js +16 -2
- package/lib/tile/style/utils.js +3 -0
- package/lib/tile/tileFactory/DebugTile.js +54 -29
- package/lib/tile/tileFactory/ImageTile.js +46 -20
- package/lib/tile/tileFactory/MaskTile.js +51 -22
- package/lib/tile/tileFactory/RasterRGBTile.js +50 -22
- package/lib/tile/tileFactory/RasterTerrainRGBTile.js +46 -20
- package/lib/tile/tileFactory/RasterTile.js +63 -30
- package/lib/tile/tileFactory/Tile.js +102 -63
- package/lib/tile/tileFactory/VectorTile.js +76 -41
- package/lib/tile/tileFactory/index.js +25 -0
- package/lib/tile/tileFactory/layers/TileDebugLayer.js +32 -6
- package/lib/tile/tileFactory/util.js +9 -0
- package/lib/tile/tileLayer/BaseLayer.js +153 -105
- package/lib/tile/utils.js +5 -1
- package/lib/utils/blend.js +5 -0
- package/lib/utils/collision-index.js +25 -9
- package/lib/utils/dataMappingStyle.js +19 -8
- package/lib/utils/extrude_polyline.js +181 -101
- package/lib/utils/grid-index.js +28 -2
- package/lib/utils/identityScale.js +9 -0
- package/lib/utils/layerData.js +49 -30
- package/lib/utils/multiPassRender.js +16 -11
- package/lib/utils/polylineNormal.js +66 -31
- package/lib/utils/simpleLine.js +21 -2
- package/lib/utils/stencil.js +4 -0
- package/lib/utils/symbol-layout.js +55 -27
- package/lib/wind/index.js +37 -9
- package/lib/wind/models/index.js +3 -0
- package/lib/wind/models/utils.js +62 -26
- package/lib/wind/models/wind.js +157 -101
- package/lib/wind/models/windRender.js +71 -53
- package/lib/wind/models/windShader.js +1 -0
- package/package.json +7 -7
|
@@ -9,79 +9,105 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConst
|
|
|
9
9
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
10
10
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
11
11
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
12
|
+
|
|
12
13
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
14
|
+
|
|
13
15
|
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; } }
|
|
16
|
+
|
|
14
17
|
import { gl } from '@antv/l7-core';
|
|
15
18
|
import { Version } from '@antv/l7-maps';
|
|
16
19
|
import BaseModel from "../../core/BaseModel";
|
|
20
|
+
|
|
17
21
|
/* babel-plugin-inline-import '../shaders/sprite_frag.glsl' */
|
|
18
22
|
var spriteFrag = "\nuniform sampler2D u_texture;\nuniform float u_mapFlag;\nuniform float u_opacity;\n\nvarying vec3 v_Color;\nvarying float v_d;\n\nvoid main() {\n\n if(v_d < 0.0) {\n discard;\n }\n\n if(u_mapFlag > 0.0) {\n gl_FragColor = texture2D(u_texture, gl_PointCoord);\n gl_FragColor.a *= u_opacity;\n } else {\n gl_FragColor = vec4(v_Color, u_opacity);\n }\n}\n";
|
|
23
|
+
|
|
19
24
|
/* babel-plugin-inline-import '../shaders/sprite_vert.glsl' */
|
|
20
25
|
var spriteVert = "precision highp float;\n\nattribute vec3 a_Position;\nattribute vec3 a_Color;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_opacity;\nuniform float u_Scale;\nvarying vec3 v_Color;\nvarying float v_d;\n\n#pragma include \"projection\"\nvoid main() {\n v_Color = a_Color;\n \n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n v_d = a_Position.z;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy, a_Position.z, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, a_Position.z, 1.0));\n }\n\n gl_PointSize = pow((u_Zoom - 1.0), 2.0) * u_Scale;\n}\n";
|
|
21
|
-
var SPRITE_ANIMATE_DIR
|
|
26
|
+
var SPRITE_ANIMATE_DIR;
|
|
27
|
+
|
|
28
|
+
(function (SPRITE_ANIMATE_DIR) {
|
|
22
29
|
SPRITE_ANIMATE_DIR["UP"] = "up";
|
|
23
30
|
SPRITE_ANIMATE_DIR["DOWN"] = "down";
|
|
24
|
-
|
|
25
|
-
|
|
31
|
+
})(SPRITE_ANIMATE_DIR || (SPRITE_ANIMATE_DIR = {}));
|
|
32
|
+
|
|
26
33
|
var SpriteModel = /*#__PURE__*/function (_BaseModel) {
|
|
27
34
|
_inherits(SpriteModel, _BaseModel);
|
|
35
|
+
|
|
28
36
|
var _super = _createSuper(SpriteModel);
|
|
37
|
+
|
|
29
38
|
function SpriteModel() {
|
|
30
39
|
var _this;
|
|
40
|
+
|
|
31
41
|
_classCallCheck(this, SpriteModel);
|
|
42
|
+
|
|
32
43
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
33
44
|
args[_key] = arguments[_key];
|
|
34
45
|
}
|
|
46
|
+
|
|
35
47
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
48
|
+
|
|
36
49
|
_defineProperty(_assertThisInitialized(_this), "planeGeometryUpdateTriangulation", function () {
|
|
37
50
|
var _ref = _this.layer.getLayerConfig(),
|
|
38
|
-
|
|
39
|
-
|
|
51
|
+
_ref$spriteBottom = _ref.spriteBottom,
|
|
52
|
+
spriteBottom = _ref$spriteBottom === void 0 ? -100000 : _ref$spriteBottom;
|
|
53
|
+
|
|
40
54
|
var updateZ = _this.spriteUpdate;
|
|
41
55
|
var bottomZ = spriteBottom;
|
|
42
56
|
var topZ = _this.spriteTop;
|
|
57
|
+
|
|
43
58
|
for (var i = 0; i < _this.positions.length; i += 5) {
|
|
44
59
|
if (_this.spriteAnimate === SPRITE_ANIMATE_DIR.UP) {
|
|
45
60
|
_this.positions[i + 2] += updateZ;
|
|
61
|
+
|
|
46
62
|
if (_this.positions[i + 2] > topZ) {
|
|
47
63
|
_this.positions[i + 2] = bottomZ;
|
|
48
64
|
}
|
|
49
65
|
} else {
|
|
50
66
|
_this.positions[i + 2] -= updateZ;
|
|
67
|
+
|
|
51
68
|
if (_this.positions[i + 2] < bottomZ) {
|
|
52
69
|
_this.positions[i + 2] = topZ;
|
|
53
70
|
}
|
|
54
71
|
}
|
|
55
72
|
}
|
|
73
|
+
|
|
56
74
|
return {
|
|
57
75
|
vertices: _this.positions,
|
|
58
76
|
indices: _this.indices,
|
|
59
77
|
size: 5
|
|
60
78
|
};
|
|
61
79
|
});
|
|
80
|
+
|
|
62
81
|
_defineProperty(_assertThisInitialized(_this), "updateModel", function () {
|
|
63
82
|
// @ts-ignore
|
|
64
83
|
var attributes = _this.layer.createAttributes({
|
|
65
84
|
triangulation: _this.planeGeometryUpdateTriangulation
|
|
66
85
|
});
|
|
86
|
+
|
|
67
87
|
_this.layer.models.map(function (m) {
|
|
68
88
|
m.updateAttributes(attributes);
|
|
69
89
|
});
|
|
90
|
+
|
|
70
91
|
_this.layerService.throttleRenderLayers();
|
|
92
|
+
|
|
71
93
|
_this.timer = requestAnimationFrame(_this.updateModel);
|
|
72
94
|
});
|
|
95
|
+
|
|
73
96
|
_defineProperty(_assertThisInitialized(_this), "planeGeometryTriangulation", function () {
|
|
74
97
|
var _this2;
|
|
98
|
+
|
|
75
99
|
var _ref2 = _this.layer.getLayerConfig(),
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
100
|
+
_ref2$center = _ref2.center,
|
|
101
|
+
center = _ref2$center === void 0 ? [120, 30] : _ref2$center,
|
|
102
|
+
_ref2$spriteCount = _ref2.spriteCount,
|
|
103
|
+
spriteCount = _ref2$spriteCount === void 0 ? 100 : _ref2$spriteCount,
|
|
104
|
+
_ref2$spriteRadius = _ref2.spriteRadius,
|
|
105
|
+
spriteRadius = _ref2$spriteRadius === void 0 ? 10 : _ref2$spriteRadius;
|
|
106
|
+
|
|
82
107
|
var _this$initSprite = (_this2 = _this).initSprite.apply(_this2, [spriteRadius, spriteCount].concat(_toConsumableArray(center))),
|
|
83
|
-
|
|
84
|
-
|
|
108
|
+
indices = _this$initSprite.indices,
|
|
109
|
+
positions = _this$initSprite.positions;
|
|
110
|
+
|
|
85
111
|
_this.positions = positions;
|
|
86
112
|
_this.indices = indices;
|
|
87
113
|
return {
|
|
@@ -90,8 +116,10 @@ var SpriteModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
90
116
|
size: 5
|
|
91
117
|
};
|
|
92
118
|
});
|
|
119
|
+
|
|
93
120
|
return _this;
|
|
94
121
|
}
|
|
122
|
+
|
|
95
123
|
_createClass(SpriteModel, [{
|
|
96
124
|
key: "initSprite",
|
|
97
125
|
value: function initSprite() {
|
|
@@ -103,29 +131,35 @@ var SpriteModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
103
131
|
var positions = [];
|
|
104
132
|
var mapService = this.mapService;
|
|
105
133
|
var heightLimit = this.spriteAnimate === SPRITE_ANIMATE_DIR.UP ? -this.spriteTop : this.spriteTop;
|
|
134
|
+
|
|
106
135
|
for (var i = 0; i < spriteCount; i++) {
|
|
107
136
|
var height = Math.random() * heightLimit;
|
|
108
137
|
positions.push.apply(positions, _toConsumableArray(getPos(height)));
|
|
109
138
|
}
|
|
139
|
+
|
|
110
140
|
for (var _i = 0; _i < spriteCount; _i++) {
|
|
111
141
|
indices.push(_i);
|
|
112
142
|
}
|
|
143
|
+
|
|
113
144
|
function getPos(z) {
|
|
114
145
|
var randomX = radius * Math.random();
|
|
115
146
|
var randomY = radius * Math.random();
|
|
116
147
|
var x = -radius / 2 + randomX;
|
|
117
148
|
var y = -radius / 2 + randomY;
|
|
149
|
+
|
|
118
150
|
if (mapService.version === Version['GAODE2.x']) {
|
|
119
151
|
// @ts-ignore
|
|
120
152
|
var _ref3 = mapService.lngLatToCoord([x + lng, -y + lat]),
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
153
|
+
_ref4 = _slicedToArray(_ref3, 2),
|
|
154
|
+
a = _ref4[0],
|
|
155
|
+
b = _ref4[1];
|
|
156
|
+
|
|
124
157
|
return [a, b, z, 0, 0];
|
|
125
158
|
} else {
|
|
126
159
|
return [x + lng, -y + lat, z, 0, 0];
|
|
127
160
|
}
|
|
128
161
|
}
|
|
162
|
+
|
|
129
163
|
return {
|
|
130
164
|
indices: indices,
|
|
131
165
|
positions: positions
|
|
@@ -135,16 +169,19 @@ var SpriteModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
135
169
|
key: "getUninforms",
|
|
136
170
|
value: function getUninforms() {
|
|
137
171
|
var _ref5 = this.layer.getLayerConfig(),
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
172
|
+
opacity = _ref5.opacity,
|
|
173
|
+
mapTexture = _ref5.mapTexture,
|
|
174
|
+
_ref5$spriteScale = _ref5.spriteScale,
|
|
175
|
+
spriteScale = _ref5$spriteScale === void 0 ? 1 : _ref5$spriteScale;
|
|
176
|
+
|
|
142
177
|
if (this.mapTexture !== mapTexture) {
|
|
143
178
|
var _this$texture;
|
|
179
|
+
|
|
144
180
|
this.mapTexture = mapTexture;
|
|
145
181
|
(_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
|
|
146
182
|
this.updateTexture(mapTexture);
|
|
147
183
|
}
|
|
184
|
+
|
|
148
185
|
return {
|
|
149
186
|
u_opacity: opacity || 1,
|
|
150
187
|
u_mapFlag: mapTexture ? 1 : 0,
|
|
@@ -156,6 +193,7 @@ var SpriteModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
156
193
|
key: "clearModels",
|
|
157
194
|
value: function clearModels() {
|
|
158
195
|
var _this$texture2;
|
|
196
|
+
|
|
159
197
|
cancelAnimationFrame(this.timer);
|
|
160
198
|
(_this$texture2 = this.texture) === null || _this$texture2 === void 0 ? void 0 : _this$texture2.destroy();
|
|
161
199
|
}
|
|
@@ -164,48 +202,56 @@ var SpriteModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
164
202
|
value: function () {
|
|
165
203
|
var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
166
204
|
var _this3 = this;
|
|
205
|
+
|
|
167
206
|
var _ref6, mapTexture, _ref6$spriteTop, spriteTop, _ref6$spriteUpdate, spriteUpdate, _ref6$spriteAnimate, spriteAnimate, createTexture2D, model;
|
|
207
|
+
|
|
168
208
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
169
|
-
while (1)
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
209
|
+
while (1) {
|
|
210
|
+
switch (_context.prev = _context.next) {
|
|
211
|
+
case 0:
|
|
212
|
+
_ref6 = this.layer.getLayerConfig(), mapTexture = _ref6.mapTexture, _ref6$spriteTop = _ref6.spriteTop, spriteTop = _ref6$spriteTop === void 0 ? 5000000 : _ref6$spriteTop, _ref6$spriteUpdate = _ref6.spriteUpdate, spriteUpdate = _ref6$spriteUpdate === void 0 ? 10000 : _ref6$spriteUpdate, _ref6$spriteAnimate = _ref6.spriteAnimate, spriteAnimate = _ref6$spriteAnimate === void 0 ? SPRITE_ANIMATE_DIR.DOWN : _ref6$spriteAnimate;
|
|
213
|
+
this.mapTexture = mapTexture;
|
|
214
|
+
this.spriteTop = spriteTop;
|
|
215
|
+
this.spriteUpdate = spriteUpdate;
|
|
216
|
+
spriteAnimate === 'up' ? this.spriteAnimate = SPRITE_ANIMATE_DIR.UP : this.spriteAnimate = SPRITE_ANIMATE_DIR.DOWN;
|
|
217
|
+
createTexture2D = this.rendererService.createTexture2D;
|
|
218
|
+
this.texture = createTexture2D({
|
|
219
|
+
height: 0,
|
|
220
|
+
width: 0
|
|
221
|
+
});
|
|
222
|
+
this.updateTexture(mapTexture);
|
|
223
|
+
setTimeout(function () {
|
|
224
|
+
_this3.updateModel();
|
|
225
|
+
}, 100);
|
|
226
|
+
_context.next = 11;
|
|
227
|
+
return this.layer.buildLayerModel({
|
|
228
|
+
moduleName: 'geometrySprite',
|
|
229
|
+
vertexShader: spriteVert,
|
|
230
|
+
fragmentShader: spriteFrag,
|
|
231
|
+
triangulation: this.planeGeometryTriangulation,
|
|
232
|
+
primitive: gl.POINTS,
|
|
233
|
+
depth: {
|
|
234
|
+
enable: false
|
|
235
|
+
},
|
|
236
|
+
blend: this.getBlend()
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
case 11:
|
|
240
|
+
model = _context.sent;
|
|
241
|
+
return _context.abrupt("return", [model]);
|
|
242
|
+
|
|
243
|
+
case 13:
|
|
244
|
+
case "end":
|
|
245
|
+
return _context.stop();
|
|
246
|
+
}
|
|
203
247
|
}
|
|
204
248
|
}, _callee, this);
|
|
205
249
|
}));
|
|
250
|
+
|
|
206
251
|
function initModels() {
|
|
207
252
|
return _initModels.apply(this, arguments);
|
|
208
253
|
}
|
|
254
|
+
|
|
209
255
|
return initModels;
|
|
210
256
|
}()
|
|
211
257
|
}, {
|
|
@@ -213,28 +259,36 @@ var SpriteModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
213
259
|
value: function () {
|
|
214
260
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
215
261
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
216
|
-
while (1)
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
262
|
+
while (1) {
|
|
263
|
+
switch (_context2.prev = _context2.next) {
|
|
264
|
+
case 0:
|
|
265
|
+
return _context2.abrupt("return", this.initModels());
|
|
266
|
+
|
|
267
|
+
case 1:
|
|
268
|
+
case "end":
|
|
269
|
+
return _context2.stop();
|
|
270
|
+
}
|
|
222
271
|
}
|
|
223
272
|
}, _callee2, this);
|
|
224
273
|
}));
|
|
274
|
+
|
|
225
275
|
function buildModels() {
|
|
226
276
|
return _buildModels.apply(this, arguments);
|
|
227
277
|
}
|
|
278
|
+
|
|
228
279
|
return buildModels;
|
|
229
280
|
}()
|
|
230
281
|
}, {
|
|
231
282
|
key: "updateTexture",
|
|
232
283
|
value: function updateTexture(mapTexture) {
|
|
233
284
|
var _this4 = this;
|
|
285
|
+
|
|
234
286
|
var createTexture2D = this.rendererService.createTexture2D;
|
|
287
|
+
|
|
235
288
|
if (mapTexture) {
|
|
236
289
|
var img = new Image();
|
|
237
290
|
img.crossOrigin = 'anonymous';
|
|
291
|
+
|
|
238
292
|
img.onload = function () {
|
|
239
293
|
_this4.texture = createTexture2D({
|
|
240
294
|
data: img,
|
|
@@ -243,8 +297,10 @@ var SpriteModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
243
297
|
wrapS: gl.CLAMP_TO_EDGE,
|
|
244
298
|
wrapT: gl.CLAMP_TO_EDGE
|
|
245
299
|
});
|
|
300
|
+
|
|
246
301
|
_this4.layerService.reRender();
|
|
247
302
|
};
|
|
303
|
+
|
|
248
304
|
img.src = mapTexture;
|
|
249
305
|
} else {
|
|
250
306
|
this.texture = createTexture2D({
|
|
@@ -259,6 +315,8 @@ var SpriteModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
259
315
|
return '';
|
|
260
316
|
}
|
|
261
317
|
}]);
|
|
318
|
+
|
|
262
319
|
return SpriteModel;
|
|
263
320
|
}(BaseModel);
|
|
321
|
+
|
|
264
322
|
export { SpriteModel as default };
|
package/es/canvas/index.js
CHANGED
|
@@ -7,45 +7,63 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConst
|
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
9
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
10
|
+
|
|
10
11
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
|
+
|
|
11
13
|
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; } }
|
|
14
|
+
|
|
12
15
|
import BaseLayer from "../core/BaseLayer";
|
|
13
16
|
import CanvasModels from "./models/index";
|
|
17
|
+
|
|
14
18
|
var CanvasLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
15
19
|
_inherits(CanvasLayer, _BaseLayer);
|
|
20
|
+
|
|
16
21
|
var _super = _createSuper(CanvasLayer);
|
|
22
|
+
|
|
17
23
|
function CanvasLayer() {
|
|
18
24
|
var _this;
|
|
25
|
+
|
|
19
26
|
_classCallCheck(this, CanvasLayer);
|
|
27
|
+
|
|
20
28
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
21
29
|
args[_key] = arguments[_key];
|
|
22
30
|
}
|
|
31
|
+
|
|
23
32
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
33
|
+
|
|
24
34
|
_defineProperty(_assertThisInitialized(_this), "type", 'CanvasLayer');
|
|
35
|
+
|
|
25
36
|
_defineProperty(_assertThisInitialized(_this), "forceRender", true);
|
|
37
|
+
|
|
26
38
|
return _this;
|
|
27
39
|
}
|
|
40
|
+
|
|
28
41
|
_createClass(CanvasLayer, [{
|
|
29
42
|
key: "buildModels",
|
|
30
43
|
value: function () {
|
|
31
44
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
32
45
|
var modelType;
|
|
33
46
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
34
|
-
while (1)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
while (1) {
|
|
48
|
+
switch (_context.prev = _context.next) {
|
|
49
|
+
case 0:
|
|
50
|
+
modelType = this.getModelType();
|
|
51
|
+
this.layerModel = new CanvasModels[modelType](this);
|
|
52
|
+
_context.next = 4;
|
|
53
|
+
return this.initLayerModels();
|
|
54
|
+
|
|
55
|
+
case 4:
|
|
56
|
+
case "end":
|
|
57
|
+
return _context.stop();
|
|
58
|
+
}
|
|
43
59
|
}
|
|
44
60
|
}, _callee, this);
|
|
45
61
|
}));
|
|
62
|
+
|
|
46
63
|
function buildModels() {
|
|
47
64
|
return _buildModels.apply(this, arguments);
|
|
48
65
|
}
|
|
66
|
+
|
|
49
67
|
return buildModels;
|
|
50
68
|
}()
|
|
51
69
|
}, {
|
|
@@ -55,6 +73,7 @@ var CanvasLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
|
55
73
|
if (this.layerModel.clearCanvas) {
|
|
56
74
|
this.layerModel.clearCanvas();
|
|
57
75
|
}
|
|
76
|
+
|
|
58
77
|
this.updateLayerConfig({
|
|
59
78
|
visible: false
|
|
60
79
|
});
|
|
@@ -65,10 +84,12 @@ var CanvasLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
|
65
84
|
key: "renderModels",
|
|
66
85
|
value: function renderModels() {
|
|
67
86
|
var _this$layerModel,
|
|
68
|
-
|
|
87
|
+
_this2 = this;
|
|
88
|
+
|
|
69
89
|
if (this !== null && this !== void 0 && (_this$layerModel = this.layerModel) !== null && _this$layerModel !== void 0 && _this$layerModel.renderUpdate) {
|
|
70
90
|
this.layerModel.renderUpdate();
|
|
71
91
|
}
|
|
92
|
+
|
|
72
93
|
this.models.forEach(function (model) {
|
|
73
94
|
model.draw({
|
|
74
95
|
uniforms: _this2.layerModel.getUninforms()
|
|
@@ -91,6 +112,8 @@ var CanvasLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
|
91
112
|
return 'canvas';
|
|
92
113
|
}
|
|
93
114
|
}]);
|
|
115
|
+
|
|
94
116
|
return CanvasLayer;
|
|
95
117
|
}(BaseLayer);
|
|
118
|
+
|
|
96
119
|
export { CanvasLayer as default };
|