@antv/l7-renderer 2.18.0 → 2.18.2

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.
@@ -1,350 +0,0 @@
1
- import _typeof from "@babel/runtime/helpers/esm/typeof";
2
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
- import _createClass from "@babel/runtime/helpers/esm/createClass";
5
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
6
- import { gl } from '@antv/l7-core';
7
- import { lodashUtil } from '@antv/l7-utils';
8
- import { blendEquationMap, blendFuncMap, cullFaceMap, depthFuncMap, primitiveMap, stencilFuncMap, stencilOpMap } from "./constants";
9
- var isPlainObject = lodashUtil.isPlainObject,
10
- isTypedArray = lodashUtil.isTypedArray;
11
-
12
- /**
13
- * adaptor for regl.DrawCommand
14
- */
15
- var ReglModel = /*#__PURE__*/function () {
16
- function ReglModel(reGl, options) {
17
- _classCallCheck(this, ReglModel);
18
- _defineProperty(this, "destroyed", false);
19
- _defineProperty(this, "uniforms", {});
20
- this.reGl = reGl;
21
- var vs = options.vs,
22
- fs = options.fs,
23
- attributes = options.attributes,
24
- uniforms = options.uniforms,
25
- primitive = options.primitive,
26
- count = options.count,
27
- elements = options.elements,
28
- depth = options.depth,
29
- cull = options.cull,
30
- instances = options.instances;
31
- var reglUniforms = {};
32
- this.options = options;
33
- if (uniforms) {
34
- this.uniforms = this.extractUniforms(uniforms);
35
- Object.keys(uniforms).forEach(function (uniformName) {
36
- // use regl prop API
37
- // @ts-ignore
38
- reglUniforms[uniformName] = reGl.prop(uniformName);
39
- });
40
- }
41
- var reglAttributes = {};
42
- Object.keys(attributes).forEach(function (name) {
43
- reglAttributes[name] = attributes[name].get();
44
- });
45
- var drawParams = {
46
- attributes: reglAttributes,
47
- frag: fs,
48
- uniforms: reglUniforms,
49
- vert: vs,
50
- // @ts-ignore
51
- colorMask: reGl.prop('colorMask'),
52
- lineWidth: 1,
53
- blend: {
54
- // @ts-ignore
55
- enable: reGl.prop('blend.enable'),
56
- // @ts-ignore
57
- func: reGl.prop('blend.func'),
58
- // @ts-ignore
59
- equation: reGl.prop('blend.equation'),
60
- // @ts-ignore
61
- color: reGl.prop('blend.color')
62
- },
63
- stencil: {
64
- // @ts-ignore
65
- enable: reGl.prop('stencil.enable'),
66
- // @ts-ignore
67
- mask: reGl.prop('stencil.mask'),
68
- // @ts-ignore
69
- func: reGl.prop('stencil.func'),
70
- // @ts-ignore
71
- opFront: reGl.prop('stencil.opFront'),
72
- // @ts-ignore
73
- opBack: reGl.prop('stencil.opBack')
74
- },
75
- primitive: primitiveMap[primitive === undefined ? gl.TRIANGLES : primitive]
76
- };
77
- if (instances) {
78
- drawParams.instances = instances;
79
- }
80
-
81
- // Tip:
82
- // elements 中可能包含 count,此时不应传入
83
- // count 和 elements 相比、count 优先
84
- if (count) {
85
- drawParams.count = count;
86
- } else if (elements) {
87
- drawParams.elements = elements.get();
88
- }
89
- this.initDepthDrawParams({
90
- depth: depth
91
- }, drawParams);
92
- // this.initBlendDrawParams({ blend }, drawParams);
93
- // this.initStencilDrawParams({ stencil }, drawParams);
94
- this.initCullDrawParams({
95
- cull: cull
96
- }, drawParams);
97
- this.drawCommand = reGl(drawParams);
98
- this.drawParams = drawParams;
99
- }
100
- _createClass(ReglModel, [{
101
- key: "updateAttributesAndElements",
102
- value: function updateAttributesAndElements(attributes, elements) {
103
- var reglAttributes = {};
104
- Object.keys(attributes).forEach(function (name) {
105
- reglAttributes[name] = attributes[name].get();
106
- });
107
- this.drawParams.attributes = reglAttributes;
108
- this.drawParams.elements = elements.get();
109
- this.drawCommand = this.reGl(this.drawParams);
110
- }
111
- }, {
112
- key: "updateAttributes",
113
- value: function updateAttributes(attributes) {
114
- var reglAttributes = {};
115
- Object.keys(attributes).forEach(function (name) {
116
- reglAttributes[name] = attributes[name].get();
117
- });
118
- this.drawParams.attributes = reglAttributes;
119
- this.drawCommand = this.reGl(this.drawParams);
120
- }
121
- }, {
122
- key: "addUniforms",
123
- value: function addUniforms(uniforms) {
124
- this.uniforms = _objectSpread(_objectSpread({}, this.uniforms), this.extractUniforms(uniforms));
125
- }
126
- }, {
127
- key: "draw",
128
- value: function draw(options, pick) {
129
- if (this.drawParams.attributes && Object.keys(this.drawParams.attributes).length === 0) {
130
- return;
131
- }
132
- var uniforms = _objectSpread(_objectSpread({}, this.uniforms), this.extractUniforms(options.uniforms || {}));
133
- var reglDrawProps = {};
134
- Object.keys(uniforms).forEach(function (uniformName) {
135
- var type = _typeof(uniforms[uniformName]);
136
- if (type === 'boolean' || type === 'number' || Array.isArray(uniforms[uniformName]) ||
137
- // @ts-ignore
138
- uniforms[uniformName].BYTES_PER_ELEMENT) {
139
- reglDrawProps[uniformName] = uniforms[uniformName];
140
- } else {
141
- reglDrawProps[uniformName] = uniforms[uniformName].get();
142
- }
143
- });
144
- // 更新 blend
145
- // @ts-ignore
146
- reglDrawProps.blend = pick // picking 操作不应该使用 blend
147
- ? this.getBlendDrawParams({
148
- blend: {
149
- enable: false
150
- }
151
- }) : this.getBlendDrawParams(options);
152
-
153
- // 更新stentil 配置
154
- // @ts-ignore
155
- reglDrawProps.stencil = this.getStencilDrawParams(options);
156
- // @ts-ignore
157
- reglDrawProps.colorMask = this.getColorMaskDrawParams(options, pick);
158
-
159
- // 在进行拾取操作的绘制中,不应该使用叠加模式 - picking 根据拾取的颜色作为判断的输入,而叠加模式会产生新的,在 id 序列中不存在的颜色
160
- this.drawCommand(reglDrawProps);
161
- }
162
- }, {
163
- key: "destroy",
164
- value: function destroy() {
165
- var _this$drawParams, _this$drawParams$elem;
166
- // @ts-ignore
167
- (_this$drawParams = this.drawParams) === null || _this$drawParams === void 0 ? void 0 : (_this$drawParams$elem = _this$drawParams.elements) === null || _this$drawParams$elem === void 0 ? void 0 : _this$drawParams$elem.destroy();
168
- if (this.options.attributes) {
169
- Object.values(this.options.attributes).forEach(function (attr) {
170
- // @ts-ignore
171
- attr === null || attr === void 0 ? void 0 : attr.destroy();
172
- });
173
- }
174
- this.destroyed = true;
175
- }
176
-
177
- /**
178
- * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#depth-buffer
179
- */
180
- }, {
181
- key: "initDepthDrawParams",
182
- value: function initDepthDrawParams(_ref, drawParams) {
183
- var depth = _ref.depth;
184
- if (depth) {
185
- drawParams.depth = {
186
- enable: depth.enable === undefined ? true : !!depth.enable,
187
- mask: depth.mask === undefined ? true : !!depth.mask,
188
- func: depthFuncMap[depth.func || gl.LESS],
189
- range: depth.range || [0, 1]
190
- };
191
- }
192
- }
193
- }, {
194
- key: "getBlendDrawParams",
195
- value: function getBlendDrawParams(_ref2) {
196
- var blend = _ref2.blend;
197
- var _ref3 = blend || {},
198
- enable = _ref3.enable,
199
- func = _ref3.func,
200
- equation = _ref3.equation,
201
- _ref3$color = _ref3.color,
202
- color = _ref3$color === void 0 ? [0, 0, 0, 0] : _ref3$color;
203
- // @ts-ignore
204
- return {
205
- enable: !!enable,
206
- func: {
207
- srcRGB: blendFuncMap[func && func.srcRGB || gl.SRC_ALPHA],
208
- srcAlpha: blendFuncMap[func && func.srcAlpha || gl.SRC_ALPHA],
209
- dstRGB: blendFuncMap[func && func.dstRGB || gl.ONE_MINUS_SRC_ALPHA],
210
- dstAlpha: blendFuncMap[func && func.dstAlpha || gl.ONE_MINUS_SRC_ALPHA]
211
- },
212
- equation: {
213
- rgb: blendEquationMap[equation && equation.rgb || gl.FUNC_ADD],
214
- alpha: blendEquationMap[equation && equation.alpha || gl.FUNC_ADD]
215
- },
216
- color: color
217
- };
218
- }
219
- /**
220
- * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#stencil
221
- */
222
- }, {
223
- key: "getStencilDrawParams",
224
- value: function getStencilDrawParams(_ref4) {
225
- var stencil = _ref4.stencil;
226
- var _ref5 = stencil || {},
227
- enable = _ref5.enable,
228
- _ref5$mask = _ref5.mask,
229
- mask = _ref5$mask === void 0 ? -1 : _ref5$mask,
230
- _ref5$func = _ref5.func,
231
- func = _ref5$func === void 0 ? {
232
- cmp: gl.ALWAYS,
233
- ref: 0,
234
- mask: -1
235
- } : _ref5$func,
236
- _ref5$opFront = _ref5.opFront,
237
- opFront = _ref5$opFront === void 0 ? {
238
- fail: gl.KEEP,
239
- zfail: gl.KEEP,
240
- zpass: gl.KEEP
241
- } : _ref5$opFront,
242
- _ref5$opBack = _ref5.opBack,
243
- opBack = _ref5$opBack === void 0 ? {
244
- fail: gl.KEEP,
245
- zfail: gl.KEEP,
246
- zpass: gl.KEEP
247
- } : _ref5$opBack;
248
- return {
249
- enable: !!enable,
250
- mask: mask,
251
- func: _objectSpread(_objectSpread({}, func), {}, {
252
- cmp: stencilFuncMap[func.cmp]
253
- }),
254
- opFront: {
255
- fail: stencilOpMap[opFront.fail],
256
- zfail: stencilOpMap[opFront.zfail],
257
- zpass: stencilOpMap[opFront.zpass]
258
- },
259
- opBack: {
260
- fail: stencilOpMap[opBack.fail],
261
- zfail: stencilOpMap[opBack.zfail],
262
- zpass: stencilOpMap[opBack.zpass]
263
- }
264
- };
265
- }
266
- }, {
267
- key: "getColorMaskDrawParams",
268
- value: function getColorMaskDrawParams(_ref6, pick) {
269
- var stencil = _ref6.stencil;
270
- // TODO: 重构相关参数
271
- // 掩膜模式下,颜色通道全部关闭
272
- var colorMask = stencil !== null && stencil !== void 0 && stencil.enable && stencil.opFront && !pick ? [false, false, false, false] : [true, true, true, true]; // 非掩码模式下,颜色通道全部开启
273
- return colorMask;
274
- }
275
-
276
- /**
277
- * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#culling
278
- */
279
- }, {
280
- key: "initCullDrawParams",
281
- value: function initCullDrawParams(_ref7, drawParams) {
282
- var cull = _ref7.cull;
283
- if (cull) {
284
- var enable = cull.enable,
285
- _cull$face = cull.face,
286
- face = _cull$face === void 0 ? gl.BACK : _cull$face;
287
- drawParams.cull = {
288
- enable: !!enable,
289
- face: cullFaceMap[face]
290
- };
291
- }
292
- }
293
-
294
- /**
295
- * 考虑结构体命名, eg:
296
- * a: { b: 1 } -> 'a.b'
297
- * a: [ { b: 1 } ] -> 'a[0].b'
298
- */
299
- }, {
300
- key: "extractUniforms",
301
- value: function extractUniforms(uniforms) {
302
- var _this = this;
303
- var extractedUniforms = {};
304
- Object.keys(uniforms).forEach(function (uniformName) {
305
- _this.extractUniformsRecursively(uniformName, uniforms[uniformName], extractedUniforms, '');
306
- });
307
- return extractedUniforms;
308
- }
309
- }, {
310
- key: "extractUniformsRecursively",
311
- value: function extractUniformsRecursively(uniformName, uniformValue, uniforms, prefix) {
312
- var _this2 = this;
313
- if (uniformValue === null || typeof uniformValue === 'number' ||
314
- // u_A: 1
315
- typeof uniformValue === 'boolean' ||
316
- // u_A: false
317
- Array.isArray(uniformValue) && typeof uniformValue[0] === 'number' ||
318
- // u_A: [1, 2, 3]
319
- isTypedArray(uniformValue) ||
320
- // u_A: Float32Array
321
- // @ts-ignore
322
- uniformValue === '' || 'resize' in uniformValue) {
323
- uniforms["".concat(prefix && prefix + '.').concat(uniformName)] = uniformValue;
324
- return;
325
- }
326
-
327
- // u_Struct.a.b.c
328
- if (isPlainObject(uniformValue)) {
329
- Object.keys(uniformValue).forEach(function (childName) {
330
- _this2.extractUniformsRecursively(childName,
331
- // @ts-ignore
332
- uniformValue[childName], uniforms, "".concat(prefix && prefix + '.').concat(uniformName));
333
- });
334
- }
335
-
336
- // u_Struct[0].a
337
- if (Array.isArray(uniformValue)) {
338
- uniformValue.forEach(function (child, idx) {
339
- Object.keys(child).forEach(function (childName) {
340
- _this2.extractUniformsRecursively(childName,
341
- // @ts-ignore
342
- child[childName], uniforms, "".concat(prefix && prefix + '.').concat(uniformName, "[").concat(idx, "]"));
343
- });
344
- });
345
- }
346
- }
347
- }]);
348
- return ReglModel;
349
- }();
350
- export { ReglModel as default };
@@ -1,16 +0,0 @@
1
- import { IRenderbuffer, IRenderbufferInitializationOptions } from '@antv/l7-core';
2
- import regl from 'regl';
3
- /**
4
- * adaptor for regl.Renderbuffer
5
- * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#renderbuffers
6
- */
7
- export default class ReglRenderbuffer implements IRenderbuffer {
8
- private renderbuffer;
9
- constructor(reGl: regl.Regl, options: IRenderbufferInitializationOptions);
10
- get(): regl.Renderbuffer;
11
- destroy(): void;
12
- resize({ width, height }: {
13
- width: number;
14
- height: number;
15
- }): void;
16
- }
@@ -1,41 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import { formatMap } from "./constants";
4
-
5
- /**
6
- * adaptor for regl.Renderbuffer
7
- * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#renderbuffers
8
- */
9
- var ReglRenderbuffer = /*#__PURE__*/function () {
10
- function ReglRenderbuffer(reGl, options) {
11
- _classCallCheck(this, ReglRenderbuffer);
12
- var width = options.width,
13
- height = options.height,
14
- format = options.format;
15
- this.renderbuffer = reGl.renderbuffer({
16
- width: width,
17
- height: height,
18
- format: formatMap[format]
19
- });
20
- }
21
- _createClass(ReglRenderbuffer, [{
22
- key: "get",
23
- value: function get() {
24
- return this.renderbuffer;
25
- }
26
- }, {
27
- key: "destroy",
28
- value: function destroy() {
29
- this.renderbuffer.destroy();
30
- }
31
- }, {
32
- key: "resize",
33
- value: function resize(_ref) {
34
- var width = _ref.width,
35
- height = _ref.height;
36
- this.renderbuffer.resize(width, height);
37
- }
38
- }]);
39
- return ReglRenderbuffer;
40
- }();
41
- export { ReglRenderbuffer as default };
@@ -1,22 +0,0 @@
1
- import { ITexture2D, ITexture2DInitializationOptions } from '@antv/l7-core';
2
- import regl from 'regl';
3
- /**
4
- * adaptor for regl.Buffer
5
- * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#buffers
6
- */
7
- export default class ReglTexture2D implements ITexture2D {
8
- private texture;
9
- private width;
10
- private height;
11
- private isDestroy;
12
- constructor(reGl: regl.Regl, options: ITexture2DInitializationOptions);
13
- get(): regl.Texture2D;
14
- update(props?: regl.Texture2DOptions): void;
15
- bind(): void;
16
- resize({ width, height }: {
17
- width: number;
18
- height: number;
19
- }): void;
20
- getSize(): [number, number];
21
- destroy(): void;
22
- }
@@ -1,125 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
- import { gl } from '@antv/l7-core';
5
- import { colorSpaceMap, dataTypeMap, filterMap, formatMap, mipmapMap, wrapModeMap } from "./constants";
6
-
7
- /**
8
- * adaptor for regl.Buffer
9
- * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#buffers
10
- */
11
- var ReglTexture2D = /*#__PURE__*/function () {
12
- function ReglTexture2D(reGl, options) {
13
- _classCallCheck(this, ReglTexture2D);
14
- _defineProperty(this, "isDestroy", false);
15
- var data = options.data,
16
- _options$type = options.type,
17
- type = _options$type === void 0 ? gl.UNSIGNED_BYTE : _options$type,
18
- width = options.width,
19
- height = options.height,
20
- _options$flipY = options.flipY,
21
- flipY = _options$flipY === void 0 ? false : _options$flipY,
22
- _options$format = options.format,
23
- format = _options$format === void 0 ? gl.RGBA : _options$format,
24
- _options$mipmap = options.mipmap,
25
- mipmap = _options$mipmap === void 0 ? false : _options$mipmap,
26
- _options$wrapS = options.wrapS,
27
- wrapS = _options$wrapS === void 0 ? gl.CLAMP_TO_EDGE : _options$wrapS,
28
- _options$wrapT = options.wrapT,
29
- wrapT = _options$wrapT === void 0 ? gl.CLAMP_TO_EDGE : _options$wrapT,
30
- _options$aniso = options.aniso,
31
- aniso = _options$aniso === void 0 ? 0 : _options$aniso,
32
- _options$alignment = options.alignment,
33
- alignment = _options$alignment === void 0 ? 1 : _options$alignment,
34
- _options$premultiplyA = options.premultiplyAlpha,
35
- premultiplyAlpha = _options$premultiplyA === void 0 ? false : _options$premultiplyA,
36
- _options$mag = options.mag,
37
- mag = _options$mag === void 0 ? gl.NEAREST : _options$mag,
38
- _options$min = options.min,
39
- min = _options$min === void 0 ? gl.NEAREST : _options$min,
40
- _options$colorSpace = options.colorSpace,
41
- colorSpace = _options$colorSpace === void 0 ? gl.BROWSER_DEFAULT_WEBGL : _options$colorSpace,
42
- _options$x = options.x,
43
- x = _options$x === void 0 ? 0 : _options$x,
44
- _options$y = options.y,
45
- y = _options$y === void 0 ? 0 : _options$y,
46
- _options$copy = options.copy,
47
- copy = _options$copy === void 0 ? false : _options$copy;
48
- this.width = width;
49
- this.height = height;
50
- var textureOptions = {
51
- width: width,
52
- height: height,
53
- // @ts-ignore
54
- type: dataTypeMap[type],
55
- format: formatMap[format],
56
- wrapS: wrapModeMap[wrapS],
57
- wrapT: wrapModeMap[wrapT],
58
- // @ts-ignore
59
- mag: filterMap[mag],
60
- min: filterMap[min],
61
- alignment: alignment,
62
- flipY: flipY,
63
- colorSpace: colorSpaceMap[colorSpace],
64
- premultiplyAlpha: premultiplyAlpha,
65
- aniso: aniso,
66
- // copy pixels from current bind framebuffer
67
- x: x,
68
- y: y,
69
- copy: copy
70
- };
71
- if (data) {
72
- // @ts-ignore
73
- textureOptions.data = data;
74
- }
75
- if (typeof mipmap === 'number') {
76
- textureOptions.mipmap = mipmapMap[mipmap];
77
- } else if (typeof mipmap === 'boolean') {
78
- textureOptions.mipmap = mipmap;
79
- }
80
- this.texture = reGl.texture(textureOptions);
81
- }
82
- _createClass(ReglTexture2D, [{
83
- key: "get",
84
- value: function get() {
85
- return this.texture;
86
- }
87
- }, {
88
- key: "update",
89
- value: function update() {
90
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
91
- this.texture(props);
92
- }
93
- }, {
94
- key: "bind",
95
- value: function bind() {
96
- // @ts-ignore
97
- this.texture._texture.bind();
98
- }
99
- }, {
100
- key: "resize",
101
- value: function resize(_ref) {
102
- var width = _ref.width,
103
- height = _ref.height;
104
- this.texture.resize(width, height);
105
- this.width = width;
106
- this.height = height;
107
- }
108
- }, {
109
- key: "getSize",
110
- value: function getSize() {
111
- return [this.width, this.height];
112
- }
113
- }, {
114
- key: "destroy",
115
- value: function destroy() {
116
- if (!this.isDestroy) {
117
- var _this$texture;
118
- (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
119
- }
120
- this.isDestroy = true;
121
- }
122
- }]);
123
- return ReglTexture2D;
124
- }();
125
- export { ReglTexture2D as default };
@@ -1,43 +0,0 @@
1
- import regl from 'regl';
2
- export declare const primitiveMap: {
3
- [key: string]: 'points' | 'lines' | 'line loop' | 'line strip' | 'triangles' | 'triangle strip' | 'triangle fan';
4
- };
5
- export declare const usageMap: {
6
- [key: string]: 'static' | 'dynamic' | 'stream';
7
- };
8
- export declare const dataTypeMap: {
9
- [key: string]: 'int8' | 'int16' | 'int32' | 'uint8' | 'uint16' | 'uint32' | 'float';
10
- };
11
- export declare const formatMap: {
12
- [key: string]: 'alpha' | 'luminance' | 'luminance alpha' | 'rgb' | 'rgba' | 'rgba4' | 'rgb5 a1' | 'rgb565' | 'depth' | 'depth stencil';
13
- };
14
- export declare const mipmapMap: {
15
- [key: string]: 'dont care' | 'nice' | 'fast';
16
- };
17
- export declare const filterMap: {
18
- [key: string]: 'nearest' | 'linear' | 'mipmap' | 'nearest mipmap linear' | 'linear mipmap nearest' | 'nearest mipmap nearest';
19
- };
20
- export declare const wrapModeMap: {
21
- [key: string]: 'repeat' | 'clamp' | 'mirror';
22
- };
23
- export declare const colorSpaceMap: {
24
- [key: string]: 'none' | 'browser';
25
- };
26
- export declare const depthFuncMap: {
27
- [key: string]: 'never' | 'always' | 'less' | 'lequal' | 'greater' | 'gequal' | 'equal' | 'notequal';
28
- };
29
- export declare const blendEquationMap: {
30
- [key: string]: regl.BlendingEquation;
31
- };
32
- export declare const blendFuncMap: {
33
- [key: string]: regl.BlendingFunction;
34
- };
35
- export declare const stencilFuncMap: {
36
- [key: string]: regl.ComparisonOperatorType;
37
- };
38
- export declare const stencilOpMap: {
39
- [key: string]: regl.StencilOperationType;
40
- };
41
- export declare const cullFaceMap: {
42
- [key: string]: regl.FaceOrientationType;
43
- };
@@ -1,21 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- var _primitiveMap, _usageMap, _dataTypeMap, _formatMap, _mipmapMap, _filterMap, _wrapModeMap, _colorSpaceMap, _depthFuncMap, _blendEquationMap, _blendFuncMap, _stencilFuncMap, _stencilOpMap, _cullFaceMap;
3
- /**
4
- * @desc 由于 regl 使用大量字符串而非 WebGL 常量,因此需要映射
5
- */
6
- import { gl } from '@antv/l7-core';
7
- // @see https://github.com/regl-project/regl/blob/gh-pages/lib/constants/primitives.json
8
- export var primitiveMap = (_primitiveMap = {}, _defineProperty(_primitiveMap, gl.POINTS, 'points'), _defineProperty(_primitiveMap, gl.LINES, 'lines'), _defineProperty(_primitiveMap, gl.LINE_LOOP, 'line loop'), _defineProperty(_primitiveMap, gl.LINE_STRIP, 'line strip'), _defineProperty(_primitiveMap, gl.TRIANGLES, 'triangles'), _defineProperty(_primitiveMap, gl.TRIANGLE_FAN, 'triangle fan'), _defineProperty(_primitiveMap, gl.TRIANGLE_STRIP, 'triangle strip'), _primitiveMap);
9
- export var usageMap = (_usageMap = {}, _defineProperty(_usageMap, gl.STATIC_DRAW, 'static'), _defineProperty(_usageMap, gl.DYNAMIC_DRAW, 'dynamic'), _defineProperty(_usageMap, gl.STREAM_DRAW, 'stream'), _usageMap);
10
- export var dataTypeMap = (_dataTypeMap = {}, _defineProperty(_dataTypeMap, gl.BYTE, 'int8'), _defineProperty(_dataTypeMap, gl.UNSIGNED_INT, 'int16'), _defineProperty(_dataTypeMap, gl.INT, 'int32'), _defineProperty(_dataTypeMap, gl.UNSIGNED_BYTE, 'uint8'), _defineProperty(_dataTypeMap, gl.UNSIGNED_SHORT, 'uint16'), _defineProperty(_dataTypeMap, gl.UNSIGNED_INT, 'uint32'), _defineProperty(_dataTypeMap, gl.FLOAT, 'float'), _dataTypeMap);
11
- export var formatMap = (_formatMap = {}, _defineProperty(_formatMap, gl.ALPHA, 'alpha'), _defineProperty(_formatMap, gl.LUMINANCE, 'luminance'), _defineProperty(_formatMap, gl.LUMINANCE_ALPHA, 'luminance alpha'), _defineProperty(_formatMap, gl.RGB, 'rgb'), _defineProperty(_formatMap, gl.RGBA, 'rgba'), _defineProperty(_formatMap, gl.RGBA4, 'rgba4'), _defineProperty(_formatMap, gl.RGB5_A1, 'rgb5 a1'), _defineProperty(_formatMap, gl.RGB565, 'rgb565'), _defineProperty(_formatMap, gl.DEPTH_COMPONENT, 'depth'), _defineProperty(_formatMap, gl.DEPTH_STENCIL, 'depth stencil'), _formatMap);
12
- export var mipmapMap = (_mipmapMap = {}, _defineProperty(_mipmapMap, gl.DONT_CARE, 'dont care'), _defineProperty(_mipmapMap, gl.NICEST, 'nice'), _defineProperty(_mipmapMap, gl.FASTEST, 'fast'), _mipmapMap);
13
- export var filterMap = (_filterMap = {}, _defineProperty(_filterMap, gl.NEAREST, 'nearest'), _defineProperty(_filterMap, gl.LINEAR, 'linear'), _defineProperty(_filterMap, gl.LINEAR_MIPMAP_LINEAR, 'mipmap'), _defineProperty(_filterMap, gl.NEAREST_MIPMAP_LINEAR, 'nearest mipmap linear'), _defineProperty(_filterMap, gl.LINEAR_MIPMAP_NEAREST, 'linear mipmap nearest'), _defineProperty(_filterMap, gl.NEAREST_MIPMAP_NEAREST, 'nearest mipmap nearest'), _filterMap);
14
- export var wrapModeMap = (_wrapModeMap = {}, _defineProperty(_wrapModeMap, gl.REPEAT, 'repeat'), _defineProperty(_wrapModeMap, gl.CLAMP_TO_EDGE, 'clamp'), _defineProperty(_wrapModeMap, gl.MIRRORED_REPEAT, 'mirror'), _wrapModeMap);
15
- export var colorSpaceMap = (_colorSpaceMap = {}, _defineProperty(_colorSpaceMap, gl.NONE, 'none'), _defineProperty(_colorSpaceMap, gl.BROWSER_DEFAULT_WEBGL, 'browser'), _colorSpaceMap);
16
- export var depthFuncMap = (_depthFuncMap = {}, _defineProperty(_depthFuncMap, gl.NEVER, 'never'), _defineProperty(_depthFuncMap, gl.ALWAYS, 'always'), _defineProperty(_depthFuncMap, gl.LESS, 'less'), _defineProperty(_depthFuncMap, gl.LEQUAL, 'lequal'), _defineProperty(_depthFuncMap, gl.GREATER, 'greater'), _defineProperty(_depthFuncMap, gl.GEQUAL, 'gequal'), _defineProperty(_depthFuncMap, gl.EQUAL, 'equal'), _defineProperty(_depthFuncMap, gl.NOTEQUAL, 'notequal'), _depthFuncMap);
17
- export var blendEquationMap = (_blendEquationMap = {}, _defineProperty(_blendEquationMap, gl.FUNC_ADD, 'add'), _defineProperty(_blendEquationMap, gl.MIN_EXT, 'min'), _defineProperty(_blendEquationMap, gl.MAX_EXT, 'max'), _defineProperty(_blendEquationMap, gl.FUNC_SUBTRACT, 'subtract'), _defineProperty(_blendEquationMap, gl.FUNC_REVERSE_SUBTRACT, 'reverse subtract'), _blendEquationMap);
18
- export var blendFuncMap = (_blendFuncMap = {}, _defineProperty(_blendFuncMap, gl.ZERO, 'zero'), _defineProperty(_blendFuncMap, gl.ONE, 'one'), _defineProperty(_blendFuncMap, gl.SRC_COLOR, 'src color'), _defineProperty(_blendFuncMap, gl.ONE_MINUS_SRC_COLOR, 'one minus src color'), _defineProperty(_blendFuncMap, gl.SRC_ALPHA, 'src alpha'), _defineProperty(_blendFuncMap, gl.ONE_MINUS_SRC_ALPHA, 'one minus src alpha'), _defineProperty(_blendFuncMap, gl.DST_COLOR, 'dst color'), _defineProperty(_blendFuncMap, gl.ONE_MINUS_DST_COLOR, 'one minus dst color'), _defineProperty(_blendFuncMap, gl.DST_ALPHA, 'dst alpha'), _defineProperty(_blendFuncMap, gl.ONE_MINUS_DST_ALPHA, 'one minus dst alpha'), _defineProperty(_blendFuncMap, gl.CONSTANT_COLOR, 'constant color'), _defineProperty(_blendFuncMap, gl.ONE_MINUS_CONSTANT_COLOR, 'one minus constant color'), _defineProperty(_blendFuncMap, gl.CONSTANT_ALPHA, 'constant alpha'), _defineProperty(_blendFuncMap, gl.ONE_MINUS_CONSTANT_ALPHA, 'one minus constant alpha'), _defineProperty(_blendFuncMap, gl.SRC_ALPHA_SATURATE, 'src alpha saturate'), _blendFuncMap);
19
- export var stencilFuncMap = (_stencilFuncMap = {}, _defineProperty(_stencilFuncMap, gl.NEVER, 'never'), _defineProperty(_stencilFuncMap, gl.ALWAYS, 'always'), _defineProperty(_stencilFuncMap, gl.LESS, 'less'), _defineProperty(_stencilFuncMap, gl.LEQUAL, 'lequal'), _defineProperty(_stencilFuncMap, gl.GREATER, 'greater'), _defineProperty(_stencilFuncMap, gl.GEQUAL, 'gequal'), _defineProperty(_stencilFuncMap, gl.EQUAL, 'equal'), _defineProperty(_stencilFuncMap, gl.NOTEQUAL, 'notequal'), _stencilFuncMap);
20
- export var stencilOpMap = (_stencilOpMap = {}, _defineProperty(_stencilOpMap, gl.ZERO, 'zero'), _defineProperty(_stencilOpMap, gl.KEEP, 'keep'), _defineProperty(_stencilOpMap, gl.REPLACE, 'replace'), _defineProperty(_stencilOpMap, gl.INVERT, 'invert'), _defineProperty(_stencilOpMap, gl.INCR, 'increment'), _defineProperty(_stencilOpMap, gl.DECR, 'decrement'), _defineProperty(_stencilOpMap, gl.INCR_WRAP, 'increment wrap'), _defineProperty(_stencilOpMap, gl.DECR_WRAP, 'decrement wrap'), _stencilOpMap);
21
- export var cullFaceMap = (_cullFaceMap = {}, _defineProperty(_cullFaceMap, gl.FRONT, 'front'), _defineProperty(_cullFaceMap, gl.BACK, 'back'), _cullFaceMap);
@@ -1,51 +0,0 @@
1
- /**
2
- * render w/ regl
3
- * @see https://github.com/regl-project/regl/blob/gh-pages/API.md
4
- */
5
- import { IAttribute, IAttributeInitializationOptions, IBuffer, IBufferInitializationOptions, IClearOptions, IElements, IElementsInitializationOptions, IExtensions, IFramebuffer, IFramebufferInitializationOptions, IModel, IModelInitializationOptions, IReadPixelsOptions, IRenderConfig, IRendererService, ITexture2D, ITexture2DInitializationOptions } from '@antv/l7-core';
6
- import 'reflect-metadata';
7
- import regl from 'regl';
8
- import ReglFramebuffer from './ReglFramebuffer';
9
- /**
10
- * regl renderer
11
- */
12
- export default class ReglRendererService implements IRendererService {
13
- extensionObject: IExtensions;
14
- private gl;
15
- private $container;
16
- private canvas;
17
- private width;
18
- private height;
19
- private isDirty;
20
- init(canvas: HTMLCanvasElement, cfg: IRenderConfig, gl?: regl.Regl): Promise<void>;
21
- getPointSizeRange(): any;
22
- testExtension(name: string): boolean;
23
- createModel: (options: IModelInitializationOptions) => IModel;
24
- createAttribute: (options: IAttributeInitializationOptions) => IAttribute;
25
- createBuffer: (options: IBufferInitializationOptions) => IBuffer;
26
- createElements: (options: IElementsInitializationOptions) => IElements;
27
- createTexture2D: (options: ITexture2DInitializationOptions) => ITexture2D;
28
- createFramebuffer: (options: IFramebufferInitializationOptions) => ReglFramebuffer;
29
- useFramebuffer: (framebuffer: IFramebuffer | null, drawCommands: () => void) => void;
30
- clear: (options: IClearOptions) => void;
31
- viewport: ({ x, y, width, height, }: {
32
- x: number;
33
- y: number;
34
- width: number;
35
- height: number;
36
- }) => void;
37
- readPixels: (options: IReadPixelsOptions) => Uint8Array;
38
- getViewportSize: () => {
39
- width: number;
40
- height: number;
41
- };
42
- getContainer: () => HTMLElement | null;
43
- getCanvas: () => HTMLCanvasElement;
44
- getGLContext: () => WebGLRenderingContext;
45
- setState(): void;
46
- setBaseState(): void;
47
- setCustomLayerDefaults(): void;
48
- setDirty(flag: boolean): void;
49
- getDirty(): boolean;
50
- destroy: () => void;
51
- }