@antv/l7-layers 2.20.8 → 2.20.10

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.
@@ -159,6 +159,7 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
159
159
  * 渲染所有的图层
160
160
  */
161
161
  renderLayers(): void;
162
+ prerender(): void;
162
163
  render(options?: Partial<IRenderOptions>): ILayer;
163
164
  /**
164
165
  * renderMultiPass 专门用于渲染支持 multipass 的 layer
@@ -633,6 +633,9 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
633
633
  this.layerService.reRender();
634
634
  this.rendering = false;
635
635
  }
636
+ }, {
637
+ key: "prerender",
638
+ value: function prerender() {}
636
639
  }, {
637
640
  key: "render",
638
641
  value: function render() {
@@ -50,6 +50,7 @@ export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerMod
50
50
  };
51
51
  elements: IElements;
52
52
  };
53
+ prerender(): void;
53
54
  render(renderOptions?: Partial<IRenderOptions>): void;
54
55
  protected registerBuiltinAttributes(): void;
55
56
  protected animateOption2Array(option: IAnimateOption): number[];
@@ -13,9 +13,9 @@ import { BlendType, lazyInject, MaskOperation, StencilType, TYPES } from '@antv/
13
13
  import { rgb2arr } from '@antv/l7-utils';
14
14
  import { BlendTypes } from "../utils/blend";
15
15
  import { getStencil as _getStencil, getStencilMask } from "../utils/stencil";
16
+ import { getCommonStyleAttributeOptions, ShaderLocation } from "./CommonStyleAttribute";
16
17
  import { DefaultUniformStyleType, DefaultUniformStyleValue } from "./constant";
17
18
  import { MultipleOfFourNumber } from "./utils";
18
- import { getCommonStyleAttributeOptions, ShaderLocation } from "./CommonStyleAttribute";
19
19
  var shaderLocationMap = {
20
20
  opacity: ShaderLocation.OPACITY,
21
21
  stroke: ShaderLocation.STROKE,
@@ -204,6 +204,9 @@ var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
204
204
  value: function getAttribute() {
205
205
  throw new Error('Method not implemented.');
206
206
  }
207
+ }, {
208
+ key: "prerender",
209
+ value: function prerender() {}
207
210
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
208
211
  }, {
209
212
  key: "render",
@@ -5,6 +5,7 @@ import type { HeatMapModelType } from './models';
5
5
  export default class HeatMapLayer extends BaseLayer<IHeatMapLayerStyleOptions> {
6
6
  type: string;
7
7
  buildModels(): Promise<void>;
8
+ prerender(): void;
8
9
  renderModels(options?: Partial<IRenderOptions>): this;
9
10
  updateModelData(data: IAttributeAndElements): void;
10
11
  getModelType(): HeatMapModelType;
@@ -47,6 +47,16 @@ var HeatMapLayer = /*#__PURE__*/function (_BaseLayer) {
47
47
  }
48
48
  return buildModels;
49
49
  }()
50
+ }, {
51
+ key: "prerender",
52
+ value: function prerender() {
53
+ var shape = this.getModelType();
54
+ if (shape === 'heatmap') {
55
+ if (this.layerModel) {
56
+ this.layerModel.prerender(); // 独立的渲染流程
57
+ }
58
+ }
59
+ }
50
60
  }, {
51
61
  key: "renderModels",
52
62
  value: function renderModels() {
@@ -12,6 +12,7 @@ export default class HeatMapModel extends BaseModel {
12
12
  private preRampColors;
13
13
  private colorModelUniformBuffer;
14
14
  private heat3DModelUniformBuffer;
15
+ prerender(): void;
15
16
  render(options: Partial<IRenderOptions>): void;
16
17
  getUninforms(): IModelUniform;
17
18
  initModels(): Promise<IModel[]>;
@@ -12,7 +12,7 @@ var _dec, _class;
12
12
  import _regeneratorRuntime from "@babel/runtime/regenerator";
13
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
14
  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; } }
15
- import { AttributeType, gl, TextureUsage } from '@antv/l7-core';
15
+ import { AttributeType, TextureUsage, gl } from '@antv/l7-core';
16
16
  import { generateColorRamp, getCullFace, lodashUtil } from '@antv/l7-utils';
17
17
  import { mat4 } from 'gl-matrix';
18
18
  import { injectable } from 'inversify';
@@ -49,14 +49,12 @@ var HeatMapModel = (_dec = injectable(), _dec(_class = /*#__PURE__*/function (_B
49
49
  return _this;
50
50
  }
51
51
  _createClass(HeatMapModel, [{
52
- key: "render",
53
- value: function render(options) {
52
+ key: "prerender",
53
+ value: function prerender() {
54
54
  var _this2 = this;
55
55
  var _this$rendererService = this.rendererService,
56
56
  clear = _this$rendererService.clear,
57
57
  useFramebuffer = _this$rendererService.useFramebuffer;
58
- var _ref = this.layer.getLayerConfig(),
59
- rampColors = _ref.rampColors;
60
58
  useFramebuffer(this.heatmapFramerBuffer, function () {
61
59
  clear({
62
60
  color: [0, 0, 0, 0],
@@ -66,7 +64,12 @@ var HeatMapModel = (_dec = injectable(), _dec(_class = /*#__PURE__*/function (_B
66
64
  });
67
65
  _this2.drawIntensityMode(); // 密度图
68
66
  });
69
-
67
+ }
68
+ }, {
69
+ key: "render",
70
+ value: function render(options) {
71
+ var _ref = this.layer.getLayerConfig(),
72
+ rampColors = _ref.rampColors;
70
73
  if (!isEqual(this.preRampColors, rampColors)) {
71
74
  this.updateColorTexture();
72
75
  }
@@ -2,8 +2,14 @@ import type { IModel } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  export default class MaskModel extends BaseModel {
4
4
  getUninforms(): {
5
- u_opacity: number;
6
- u_color: number[];
5
+ [x: string]: any;
6
+ };
7
+ protected getCommonUniformsInfo(): {
8
+ uniformsArray: number[];
9
+ uniformsLength: number;
10
+ uniformsOption: {
11
+ [key: string]: any;
12
+ };
7
13
  };
8
14
  initModels(): Promise<IModel[]>;
9
15
  buildModels(): Promise<IModel[]>;
@@ -1,4 +1,5 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
3
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
4
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
5
  import _inherits from "@babel/runtime/helpers/esm/inherits";
@@ -7,14 +8,13 @@ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
7
8
  import _regeneratorRuntime from "@babel/runtime/regenerator";
8
9
  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); }; }
9
10
  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; } }
10
- import { lodashUtil, rgb2arr } from '@antv/l7-utils';
11
+ import { rgb2arr } from '@antv/l7-utils';
11
12
  import BaseModel from "../../core/BaseModel";
12
13
  import { polygonTriangulation } from "../../core/triangulation";
13
14
  /* babel-plugin-inline-import '../../shader/minify_frag.glsl' */
14
- var mask_frag = "uniform float u_opacity : 1.0;\nuniform vec4 u_color;\n\nvoid main() {\n gl_FragColor = u_color;\n gl_FragColor.a *= u_opacity;\n}\n";
15
+ var mask_frag = "layout(std140) uniform commonUniorm {\n vec4 u_color;\n float u_opacity;\n};\n\nout vec4 outputColor;\n\nvoid main() {\n outputColor = u_color;\n outputColor.a *= u_opacity;\n}\n";
15
16
  /* babel-plugin-inline-import '../shaders/mask_vert.glsl' */
16
- var mask_vert = "attribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\n\n\n#pragma include \"projection\"\n\nvoid main() {\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n}\n\n";
17
- var isNumber = lodashUtil.isNumber;
17
+ var mask_vert = "layout(location = 0) in vec3 a_Position;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_color;\n float u_opacity;\n};\n\n#pragma include \"projection\"\n\nvoid main() {\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n}\n\n";
18
18
  var MaskModel = /*#__PURE__*/function (_BaseModel) {
19
19
  _inherits(MaskModel, _BaseModel);
20
20
  var _super = _createSuper(MaskModel);
@@ -25,15 +25,25 @@ var MaskModel = /*#__PURE__*/function (_BaseModel) {
25
25
  _createClass(MaskModel, [{
26
26
  key: "getUninforms",
27
27
  value: function getUninforms() {
28
+ var commoninfo = this.getCommonUniformsInfo();
29
+ var attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
30
+ this.updateStyleUnifoms();
31
+ return _objectSpread(_objectSpread({}, commoninfo.uniformsOption), attributeInfo.uniformsOption);
32
+ }
33
+ }, {
34
+ key: "getCommonUniformsInfo",
35
+ value: function getCommonUniformsInfo() {
28
36
  var _ref = this.layer.getLayerConfig(),
29
37
  _ref$opacity = _ref.opacity,
30
38
  opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
31
39
  _ref$color = _ref.color,
32
40
  color = _ref$color === void 0 ? '#000' : _ref$color;
33
- return {
34
- u_opacity: isNumber(opacity) ? opacity : 0.0,
35
- u_color: rgb2arr(color)
41
+ var commonOptions = {
42
+ u_color: rgb2arr(color),
43
+ u_opacity: opacity || 1
36
44
  };
45
+ var commonBufferInfo = this.getUniformsBufferInfo(commonOptions);
46
+ return commonBufferInfo;
37
47
  }
38
48
  }, {
39
49
  key: "initModels",
@@ -62,7 +72,8 @@ var MaskModel = /*#__PURE__*/function (_BaseModel) {
62
72
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
63
73
  while (1) switch (_context2.prev = _context2.next) {
64
74
  case 0:
65
- _context2.next = 2;
75
+ this.initUniformsBuffer();
76
+ _context2.next = 3;
66
77
  return this.layer.buildLayerModel({
67
78
  moduleName: 'mask',
68
79
  vertexShader: mask_vert,
@@ -73,10 +84,10 @@ var MaskModel = /*#__PURE__*/function (_BaseModel) {
73
84
  },
74
85
  pick: false
75
86
  });
76
- case 2:
87
+ case 3:
77
88
  model = _context2.sent;
78
89
  return _context2.abrupt("return", [model]);
79
- case 4:
90
+ case 5:
80
91
  case "end":
81
92
  return _context2.stop();
82
93
  }
@@ -1,6 +1,9 @@
1
- attribute vec3 a_Position;
2
- uniform mat4 u_ModelMatrix;
1
+ layout(location = 0) in vec3 a_Position;
3
2
 
3
+ layout(std140) uniform commonUniorm {
4
+ vec4 u_color;
5
+ float u_opacity;
6
+ };
4
7
 
5
8
  #pragma include "projection"
6
9
 
@@ -14,7 +14,7 @@ import BaseModel from "../../core/BaseModel";
14
14
  import { ShaderLocation } from "../../core/CommonStyleAttribute";
15
15
  import { RasterImageTriangulation } from "../../core/triangulation";
16
16
  /* babel-plugin-inline-import '../shaders/raster/raster_2d_frag.glsl' */
17
- var rasterFrag = "layout(std140) uniform commonUniforms {\n vec2 u_domain;\n float u_opacity;\n float u_noDataValue;\n bool u_clampLow;\n bool u_clampHigh;\n};\n\nuniform sampler2D u_rasterTexture;\nuniform sampler2D u_colorTexture;\n\nin vec2 v_texCoord;\n\nbool isnan_emu(float x) { return (x > 0.0 || x < 0.0) ? x != x : x != 0.0; }\n\nout vec4 outputColor;\n\nvoid main() {\n // Can use any component here since u_rasterTexture is under luminance format.\n float value = texture(SAMPLER_2D(u_rasterTexture), vec2(v_texCoord.x, v_texCoord.y)).r * 255.0;\n if (value == u_noDataValue || isnan_emu(value)) {\n discard;\n } else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1])) {\n discard;\n } else {\n float normalisedValue =(value - u_domain[0]) / (u_domain[1] - u_domain[0]);\n vec4 color = texture(SAMPLER_2D(u_colorTexture), vec2(normalisedValue, 0));\n \n outputColor = color;\n outputColor.a = outputColor.a * u_opacity ;\n if (outputColor.a < 0.01)\n discard;\n }\n}\n";
17
+ var rasterFrag = "layout(std140) uniform commonUniforms {\n vec2 u_domain;\n float u_opacity;\n float u_noDataValue;\n bool u_clampLow;\n bool u_clampHigh;\n};\n\nuniform sampler2D u_rasterTexture;\nuniform sampler2D u_colorTexture;\n\nin vec2 v_texCoord;\n\nbool isnan_emu(float x) { return (x > 0.0 || x < 0.0) ? x != x : x != 0.0; }\n\nout vec4 outputColor;\n\nvoid main() {\n // Can use any component here since u_rasterTexture is under luminance format.\n float value = texture(SAMPLER_2D(u_rasterTexture), vec2(v_texCoord.x, v_texCoord.y)).r;\n if (value == u_noDataValue || isnan_emu(value)) {\n discard;\n } else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1])) {\n discard;\n } else {\n float normalisedValue =(value - u_domain[0]) / (u_domain[1] - u_domain[0]);\n vec4 color = texture(SAMPLER_2D(u_colorTexture), vec2(normalisedValue, 0));\n \n outputColor = color;\n outputColor.a = outputColor.a * u_opacity ;\n if (outputColor.a < 0.01)\n discard;\n }\n}\n";
18
18
  /* babel-plugin-inline-import '../shaders/raster/raster_2d_vert.glsl' */
19
19
  var rasterVert = "\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 14) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n vec2 u_domain;\n float u_opacity;\n float u_noDataValue;\n bool u_clampLow;\n bool u_clampHigh;\n};\n\nout vec2 v_texCoord;\n\n#pragma include \"projection\"\n\nvoid main() {\n v_texCoord = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy,0., 1.0));\n}\n";
20
20
  var RasterModel = /*#__PURE__*/function (_BaseModel) {
@@ -141,11 +141,11 @@ var RasterModel = /*#__PURE__*/function (_BaseModel) {
141
141
  width = _yield$this$getRaster.width;
142
142
  height = _yield$this$getRaster.height;
143
143
  this.texture = createTexture2D({
144
- data: new Uint8Array(data),
144
+ data: data,
145
145
  width: width,
146
146
  height: height,
147
147
  format: gl.LUMINANCE,
148
- type: gl.UNSIGNED_BYTE,
148
+ type: gl.FLOAT,
149
149
  alignment: 1
150
150
  // aniso: 4,
151
151
  });
@@ -17,7 +17,7 @@ out vec4 outputColor;
17
17
 
18
18
  void main() {
19
19
  // Can use any component here since u_rasterTexture is under luminance format.
20
- float value = texture(SAMPLER_2D(u_rasterTexture), vec2(v_texCoord.x, v_texCoord.y)).r * 255.0;
20
+ float value = texture(SAMPLER_2D(u_rasterTexture), vec2(v_texCoord.x, v_texCoord.y)).r;
21
21
  if (value == u_noDataValue || isnan_emu(value)) {
22
22
  discard;
23
23
  } else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1])) {
@@ -1,7 +1,11 @@
1
- uniform float u_opacity : 1.0;
2
- uniform vec4 u_color;
1
+ layout(std140) uniform commonUniorm {
2
+ vec4 u_color;
3
+ float u_opacity;
4
+ };
5
+
6
+ out vec4 outputColor;
3
7
 
4
8
  void main() {
5
- gl_FragColor = u_color;
6
- gl_FragColor.a *= u_opacity;
9
+ outputColor = u_color;
10
+ outputColor.a *= u_opacity;
7
11
  }
@@ -1,4 +1,4 @@
1
- import { gl, MaskOperation, StencilType } from '@antv/l7-core';
1
+ import { MaskOperation, StencilType, gl } from '@antv/l7-core';
2
2
  // 掩膜配置
3
3
  export function getStencil(mask, maskInside) {
4
4
  return {
@@ -639,6 +639,9 @@ var BaseLayer = exports.default = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.
639
639
  this.layerService.reRender();
640
640
  this.rendering = false;
641
641
  }
642
+ }, {
643
+ key: "prerender",
644
+ value: function prerender() {}
642
645
  }, {
643
646
  key: "render",
644
647
  value: function render() {
@@ -19,9 +19,9 @@ var _l7Core = require("@antv/l7-core");
19
19
  var _l7Utils = require("@antv/l7-utils");
20
20
  var _blend = require("../utils/blend");
21
21
  var _stencil = require("../utils/stencil");
22
+ var _CommonStyleAttribute = require("./CommonStyleAttribute");
22
23
  var _constant = require("./constant");
23
24
  var _utils = require("./utils");
24
- var _CommonStyleAttribute = require("./CommonStyleAttribute");
25
25
  var _dec, _class, _descriptor;
26
26
  var shaderLocationMap = {
27
27
  opacity: _CommonStyleAttribute.ShaderLocation.OPACITY,
@@ -211,6 +211,9 @@ var BaseModel = exports.default = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.
211
211
  value: function getAttribute() {
212
212
  throw new Error('Method not implemented.');
213
213
  }
214
+ }, {
215
+ key: "prerender",
216
+ value: function prerender() {}
214
217
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
215
218
  }, {
216
219
  key: "render",
@@ -54,6 +54,16 @@ var HeatMapLayer = exports.default = /*#__PURE__*/function (_BaseLayer) {
54
54
  }
55
55
  return buildModels;
56
56
  }()
57
+ }, {
58
+ key: "prerender",
59
+ value: function prerender() {
60
+ var shape = this.getModelType();
61
+ if (shape === 'heatmap') {
62
+ if (this.layerModel) {
63
+ this.layerModel.prerender(); // 独立的渲染流程
64
+ }
65
+ }
66
+ }
57
67
  }, {
58
68
  key: "renderModels",
59
69
  value: function renderModels() {
@@ -56,14 +56,12 @@ var HeatMapModel = exports.default = (_dec = (0, _inversify.injectable)(), _dec(
56
56
  return _this;
57
57
  }
58
58
  (0, _createClass2.default)(HeatMapModel, [{
59
- key: "render",
60
- value: function render(options) {
59
+ key: "prerender",
60
+ value: function prerender() {
61
61
  var _this2 = this;
62
62
  var _this$rendererService = this.rendererService,
63
63
  clear = _this$rendererService.clear,
64
64
  useFramebuffer = _this$rendererService.useFramebuffer;
65
- var _ref = this.layer.getLayerConfig(),
66
- rampColors = _ref.rampColors;
67
65
  useFramebuffer(this.heatmapFramerBuffer, function () {
68
66
  clear({
69
67
  color: [0, 0, 0, 0],
@@ -73,7 +71,12 @@ var HeatMapModel = exports.default = (_dec = (0, _inversify.injectable)(), _dec(
73
71
  });
74
72
  _this2.drawIntensityMode(); // 密度图
75
73
  });
76
-
74
+ }
75
+ }, {
76
+ key: "render",
77
+ value: function render(options) {
78
+ var _ref = this.layer.getLayerConfig(),
79
+ rampColors = _ref.rampColors;
77
80
  if (!isEqual(this.preRampColors, rampColors)) {
78
81
  this.updateColorTexture();
79
82
  }
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
11
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
13
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
@@ -18,10 +19,9 @@ var _triangulation = require("../../core/triangulation");
18
19
  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); }; }
19
20
  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; } }
20
21
  /* babel-plugin-inline-import '../../shader/minify_frag.glsl' */
21
- var mask_frag = "uniform float u_opacity : 1.0;\nuniform vec4 u_color;\n\nvoid main() {\n gl_FragColor = u_color;\n gl_FragColor.a *= u_opacity;\n}\n";
22
+ var mask_frag = "layout(std140) uniform commonUniorm {\n vec4 u_color;\n float u_opacity;\n};\n\nout vec4 outputColor;\n\nvoid main() {\n outputColor = u_color;\n outputColor.a *= u_opacity;\n}\n";
22
23
  /* babel-plugin-inline-import '../shaders/mask_vert.glsl' */
23
- var mask_vert = "attribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\n\n\n#pragma include \"projection\"\n\nvoid main() {\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n}\n\n";
24
- var isNumber = _l7Utils.lodashUtil.isNumber;
24
+ var mask_vert = "layout(location = 0) in vec3 a_Position;\n\nlayout(std140) uniform commonUniorm {\n vec4 u_color;\n float u_opacity;\n};\n\n#pragma include \"projection\"\n\nvoid main() {\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n}\n\n";
25
25
  var MaskModel = exports.default = /*#__PURE__*/function (_BaseModel) {
26
26
  (0, _inherits2.default)(MaskModel, _BaseModel);
27
27
  var _super = _createSuper(MaskModel);
@@ -32,15 +32,25 @@ var MaskModel = exports.default = /*#__PURE__*/function (_BaseModel) {
32
32
  (0, _createClass2.default)(MaskModel, [{
33
33
  key: "getUninforms",
34
34
  value: function getUninforms() {
35
+ var commoninfo = this.getCommonUniformsInfo();
36
+ var attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
37
+ this.updateStyleUnifoms();
38
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, commoninfo.uniformsOption), attributeInfo.uniformsOption);
39
+ }
40
+ }, {
41
+ key: "getCommonUniformsInfo",
42
+ value: function getCommonUniformsInfo() {
35
43
  var _ref = this.layer.getLayerConfig(),
36
44
  _ref$opacity = _ref.opacity,
37
45
  opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
38
46
  _ref$color = _ref.color,
39
47
  color = _ref$color === void 0 ? '#000' : _ref$color;
40
- return {
41
- u_opacity: isNumber(opacity) ? opacity : 0.0,
42
- u_color: (0, _l7Utils.rgb2arr)(color)
48
+ var commonOptions = {
49
+ u_color: (0, _l7Utils.rgb2arr)(color),
50
+ u_opacity: opacity || 1
43
51
  };
52
+ var commonBufferInfo = this.getUniformsBufferInfo(commonOptions);
53
+ return commonBufferInfo;
44
54
  }
45
55
  }, {
46
56
  key: "initModels",
@@ -69,7 +79,8 @@ var MaskModel = exports.default = /*#__PURE__*/function (_BaseModel) {
69
79
  return _regenerator.default.wrap(function _callee2$(_context2) {
70
80
  while (1) switch (_context2.prev = _context2.next) {
71
81
  case 0:
72
- _context2.next = 2;
82
+ this.initUniformsBuffer();
83
+ _context2.next = 3;
73
84
  return this.layer.buildLayerModel({
74
85
  moduleName: 'mask',
75
86
  vertexShader: mask_vert,
@@ -80,10 +91,10 @@ var MaskModel = exports.default = /*#__PURE__*/function (_BaseModel) {
80
91
  },
81
92
  pick: false
82
93
  });
83
- case 2:
94
+ case 3:
84
95
  model = _context2.sent;
85
96
  return _context2.abrupt("return", [model]);
86
- case 4:
97
+ case 5:
87
98
  case "end":
88
99
  return _context2.stop();
89
100
  }
@@ -1,6 +1,9 @@
1
- attribute vec3 a_Position;
2
- uniform mat4 u_ModelMatrix;
1
+ layout(location = 0) in vec3 a_Position;
3
2
 
3
+ layout(std140) uniform commonUniorm {
4
+ vec4 u_color;
5
+ float u_opacity;
6
+ };
4
7
 
5
8
  #pragma include "projection"
6
9
 
@@ -21,7 +21,7 @@ var _triangulation = require("../../core/triangulation");
21
21
  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); }; }
22
22
  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; } }
23
23
  /* babel-plugin-inline-import '../shaders/raster/raster_2d_frag.glsl' */
24
- var rasterFrag = "layout(std140) uniform commonUniforms {\n vec2 u_domain;\n float u_opacity;\n float u_noDataValue;\n bool u_clampLow;\n bool u_clampHigh;\n};\n\nuniform sampler2D u_rasterTexture;\nuniform sampler2D u_colorTexture;\n\nin vec2 v_texCoord;\n\nbool isnan_emu(float x) { return (x > 0.0 || x < 0.0) ? x != x : x != 0.0; }\n\nout vec4 outputColor;\n\nvoid main() {\n // Can use any component here since u_rasterTexture is under luminance format.\n float value = texture(SAMPLER_2D(u_rasterTexture), vec2(v_texCoord.x, v_texCoord.y)).r * 255.0;\n if (value == u_noDataValue || isnan_emu(value)) {\n discard;\n } else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1])) {\n discard;\n } else {\n float normalisedValue =(value - u_domain[0]) / (u_domain[1] - u_domain[0]);\n vec4 color = texture(SAMPLER_2D(u_colorTexture), vec2(normalisedValue, 0));\n \n outputColor = color;\n outputColor.a = outputColor.a * u_opacity ;\n if (outputColor.a < 0.01)\n discard;\n }\n}\n";
24
+ var rasterFrag = "layout(std140) uniform commonUniforms {\n vec2 u_domain;\n float u_opacity;\n float u_noDataValue;\n bool u_clampLow;\n bool u_clampHigh;\n};\n\nuniform sampler2D u_rasterTexture;\nuniform sampler2D u_colorTexture;\n\nin vec2 v_texCoord;\n\nbool isnan_emu(float x) { return (x > 0.0 || x < 0.0) ? x != x : x != 0.0; }\n\nout vec4 outputColor;\n\nvoid main() {\n // Can use any component here since u_rasterTexture is under luminance format.\n float value = texture(SAMPLER_2D(u_rasterTexture), vec2(v_texCoord.x, v_texCoord.y)).r;\n if (value == u_noDataValue || isnan_emu(value)) {\n discard;\n } else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1])) {\n discard;\n } else {\n float normalisedValue =(value - u_domain[0]) / (u_domain[1] - u_domain[0]);\n vec4 color = texture(SAMPLER_2D(u_colorTexture), vec2(normalisedValue, 0));\n \n outputColor = color;\n outputColor.a = outputColor.a * u_opacity ;\n if (outputColor.a < 0.01)\n discard;\n }\n}\n";
25
25
  /* babel-plugin-inline-import '../shaders/raster/raster_2d_vert.glsl' */
26
26
  var rasterVert = "\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 14) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n vec2 u_domain;\n float u_opacity;\n float u_noDataValue;\n bool u_clampLow;\n bool u_clampHigh;\n};\n\nout vec2 v_texCoord;\n\n#pragma include \"projection\"\n\nvoid main() {\n v_texCoord = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy,0., 1.0));\n}\n";
27
27
  var RasterModel = exports.default = /*#__PURE__*/function (_BaseModel) {
@@ -148,11 +148,11 @@ var RasterModel = exports.default = /*#__PURE__*/function (_BaseModel) {
148
148
  width = _yield$this$getRaster.width;
149
149
  height = _yield$this$getRaster.height;
150
150
  this.texture = createTexture2D({
151
- data: new Uint8Array(data),
151
+ data: data,
152
152
  width: width,
153
153
  height: height,
154
154
  format: _l7Core.gl.LUMINANCE,
155
- type: _l7Core.gl.UNSIGNED_BYTE,
155
+ type: _l7Core.gl.FLOAT,
156
156
  alignment: 1
157
157
  // aniso: 4,
158
158
  });
@@ -17,7 +17,7 @@ out vec4 outputColor;
17
17
 
18
18
  void main() {
19
19
  // Can use any component here since u_rasterTexture is under luminance format.
20
- float value = texture(SAMPLER_2D(u_rasterTexture), vec2(v_texCoord.x, v_texCoord.y)).r * 255.0;
20
+ float value = texture(SAMPLER_2D(u_rasterTexture), vec2(v_texCoord.x, v_texCoord.y)).r;
21
21
  if (value == u_noDataValue || isnan_emu(value)) {
22
22
  discard;
23
23
  } else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1])) {
@@ -1,7 +1,11 @@
1
- uniform float u_opacity : 1.0;
2
- uniform vec4 u_color;
1
+ layout(std140) uniform commonUniorm {
2
+ vec4 u_color;
3
+ float u_opacity;
4
+ };
5
+
6
+ out vec4 outputColor;
3
7
 
4
8
  void main() {
5
- gl_FragColor = u_color;
6
- gl_FragColor.a *= u_opacity;
9
+ outputColor = u_color;
10
+ outputColor.a *= u_opacity;
7
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-layers",
3
- "version": "2.20.8",
3
+ "version": "2.20.10",
4
4
  "description": "L7's collection of built-in layers",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -27,10 +27,10 @@
27
27
  "license": "ISC",
28
28
  "dependencies": {
29
29
  "@antv/async-hook": "^2.2.9",
30
- "@antv/l7-core": "2.20.8",
31
- "@antv/l7-maps": "2.20.8",
32
- "@antv/l7-source": "2.20.8",
33
- "@antv/l7-utils": "2.20.8",
30
+ "@antv/l7-core": "2.20.10",
31
+ "@antv/l7-maps": "2.20.10",
32
+ "@antv/l7-source": "2.20.10",
33
+ "@antv/l7-utils": "2.20.10",
34
34
  "@babel/runtime": "^7.7.7",
35
35
  "@mapbox/martini": "^0.2.0",
36
36
  "@turf/clone": "^6.5.0",
@@ -52,7 +52,7 @@
52
52
  "reflect-metadata": "^0.1.13"
53
53
  },
54
54
  "devDependencies": {
55
- "@antv/l7-test-utils": "2.20.8",
55
+ "@antv/l7-test-utils": "2.20.10",
56
56
  "@types/d3-array": "^2.0.0",
57
57
  "@types/d3-color": "^1.2.2",
58
58
  "@types/d3-interpolate": "1.1.6",
@@ -61,7 +61,7 @@
61
61
  "@types/gl-matrix": "^2.4.5",
62
62
  "@types/lodash": "^4.14.138"
63
63
  },
64
- "gitHead": "66dd7560d7515a92f7b13666e74c2e58c1a0aeee",
64
+ "gitHead": "228c2056e3c5a7ffb334158dff12c79d55ed4ed7",
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  }