@antv/l7-renderer 2.9.24 → 2.9.26-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,348 +0,0 @@
1
- import _typeof from "@babel/runtime/helpers/typeof";
2
- import _objectSpread from "@babel/runtime/helpers/objectSpread2";
3
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
- import _createClass from "@babel/runtime/helpers/createClass";
5
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
- import { gl } from '@antv/l7-core';
7
- import { cloneDeep, isPlainObject, isTypedArray } from 'lodash';
8
- import { blendEquationMap, blendFuncMap, cullFaceMap, depthFuncMap, primitiveMap, stencilFuncMap, stencilOpMap } from "./constants";
9
-
10
- /**
11
- * adaptor for regl.DrawCommand
12
- */
13
- var ReglModel = /*#__PURE__*/function () {
14
- function ReglModel(reGl, options) {
15
- _classCallCheck(this, ReglModel);
16
-
17
- _defineProperty(this, "destroyed", false);
18
-
19
- _defineProperty(this, "uniforms", {});
20
-
21
- this.reGl = reGl;
22
- var vs = options.vs,
23
- fs = options.fs,
24
- attributes = options.attributes,
25
- uniforms = options.uniforms,
26
- primitive = options.primitive,
27
- count = options.count,
28
- elements = options.elements,
29
- depth = options.depth,
30
- blend = options.blend,
31
- stencil = options.stencil,
32
- cull = options.cull,
33
- instances = options.instances;
34
- var reglUniforms = {};
35
- this.options = options;
36
-
37
- if (uniforms) {
38
- this.uniforms = this.extractUniforms(uniforms);
39
- Object.keys(uniforms).forEach(function (uniformName) {
40
- // use regl prop API
41
- // @ts-ignore
42
- reglUniforms[uniformName] = reGl.prop(uniformName);
43
- });
44
- }
45
-
46
- var reglAttributes = {};
47
- Object.keys(attributes).forEach(function (name) {
48
- reglAttributes[name] = attributes[name].get();
49
- });
50
- var drawParams = {
51
- attributes: reglAttributes,
52
- frag: fs,
53
- uniforms: reglUniforms,
54
- vert: vs,
55
- blend: {},
56
- primitive: primitiveMap[primitive === undefined ? gl.TRIANGLES : primitive]
57
- };
58
-
59
- if (instances) {
60
- drawParams.instances = instances;
61
- } // Tip:
62
- // elements 中可能包含 count,此时不应传入
63
- // count 和 elements 相比、count 优先
64
-
65
-
66
- if (count) {
67
- drawParams.count = count;
68
- } else if (elements) {
69
- drawParams.elements = elements.get();
70
- }
71
-
72
- this.initDepthDrawParams({
73
- depth: depth
74
- }, drawParams);
75
- this.initBlendDrawParams({
76
- blend: blend
77
- }, drawParams);
78
- this.initStencilDrawParams({
79
- stencil: stencil
80
- }, drawParams);
81
- this.initCullDrawParams({
82
- cull: cull
83
- }, drawParams);
84
- this.drawCommand = reGl(drawParams);
85
- var pickDrawParams = cloneDeep(drawParams);
86
- pickDrawParams.blend = _objectSpread(_objectSpread({}, pickDrawParams.blend), {}, {
87
- enable: false
88
- });
89
- this.drawPickCommand = reGl(pickDrawParams);
90
- this.drawParams = drawParams;
91
- }
92
-
93
- _createClass(ReglModel, [{
94
- key: "updateAttributesAndElements",
95
- value: function updateAttributesAndElements(attributes, elements) {
96
- var reglAttributes = {};
97
- Object.keys(attributes).forEach(function (name) {
98
- reglAttributes[name] = attributes[name].get();
99
- });
100
- this.drawParams.attributes = reglAttributes;
101
- this.drawParams.elements = elements.get();
102
- this.drawCommand = this.reGl(this.drawParams);
103
- var pickDrawParams = cloneDeep(this.drawParams);
104
- pickDrawParams.blend = _objectSpread(_objectSpread({}, pickDrawParams.blend), {}, {
105
- enable: false
106
- });
107
- this.drawPickCommand = this.reGl(pickDrawParams);
108
- }
109
- }, {
110
- key: "updateAttributes",
111
- value: function updateAttributes(attributes) {
112
- var reglAttributes = {};
113
- Object.keys(attributes).forEach(function (name) {
114
- reglAttributes[name] = attributes[name].get();
115
- });
116
- this.drawParams.attributes = reglAttributes;
117
- this.drawCommand = this.reGl(this.drawParams);
118
- var pickDrawParams = cloneDeep(this.drawParams);
119
- pickDrawParams.blend = _objectSpread(_objectSpread({}, pickDrawParams.blend), {}, {
120
- enable: false
121
- });
122
- this.drawPickCommand = this.reGl(pickDrawParams);
123
- }
124
- }, {
125
- key: "addUniforms",
126
- value: function addUniforms(uniforms) {
127
- this.uniforms = _objectSpread(_objectSpread({}, this.uniforms), this.extractUniforms(uniforms));
128
- }
129
- }, {
130
- key: "draw",
131
- value: function draw(options, pick) {
132
- // console.log('options', this.drawParams)
133
- if (this.drawParams.attributes && Object.keys(this.drawParams.attributes).length === 0) {
134
- return;
135
- }
136
-
137
- var uniforms = _objectSpread(_objectSpread({}, this.uniforms), this.extractUniforms(options.uniforms || {}));
138
-
139
- var reglDrawProps = {};
140
- Object.keys(uniforms).forEach(function (uniformName) {
141
- var type = _typeof(uniforms[uniformName]);
142
-
143
- if (type === 'boolean' || type === 'number' || Array.isArray(uniforms[uniformName]) || // @ts-ignore
144
- uniforms[uniformName].BYTES_PER_ELEMENT) {
145
- reglDrawProps[uniformName] = uniforms[uniformName];
146
- } else {
147
- reglDrawProps[uniformName] = uniforms[uniformName].get();
148
- }
149
- }); // TODO: 在进行拾取操作的绘制中,不应该使用叠加模式 - picking 根据拾取的颜色作为判断的输入,而叠加模式会产生新的,在 id 序列中不存在的颜色
150
-
151
- if (!pick) {
152
- this.drawCommand(reglDrawProps);
153
- } else {
154
- this.drawPickCommand(reglDrawProps);
155
- } // this.drawCommand(reglDrawProps);
156
- // this.drawPickCommand(reglDrawProps);
157
-
158
- }
159
- }, {
160
- key: "destroy",
161
- value: function destroy() {
162
- // @ts-ignore
163
- this.drawParams.elements.destroy();
164
-
165
- if (this.options.attributes) {
166
- Object.values(this.options.attributes).forEach(function (attr) {
167
- // @ts-ignore
168
- attr.destroy();
169
- });
170
- }
171
-
172
- this.destroyed = true;
173
- }
174
- /**
175
- * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#depth-buffer
176
- */
177
-
178
- }, {
179
- key: "initDepthDrawParams",
180
- value: function initDepthDrawParams(_ref, drawParams) {
181
- var depth = _ref.depth;
182
-
183
- if (depth) {
184
- drawParams.depth = {
185
- enable: depth.enable === undefined ? true : !!depth.enable,
186
- mask: depth.mask === undefined ? true : !!depth.mask,
187
- func: depthFuncMap[depth.func || gl.LESS],
188
- range: depth.range || [0, 1]
189
- };
190
- }
191
- }
192
- /**
193
- * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#blending
194
- */
195
-
196
- }, {
197
- key: "initBlendDrawParams",
198
- value: function initBlendDrawParams(_ref2, drawParams) {
199
- var blend = _ref2.blend;
200
-
201
- if (blend) {
202
- var enable = blend.enable,
203
- func = blend.func,
204
- equation = blend.equation,
205
- _blend$color = blend.color,
206
- color = _blend$color === void 0 ? [0, 0, 0, 0] : _blend$color; // @ts-ignore
207
-
208
- drawParams.blend = {
209
- enable: !!enable,
210
- func: {
211
- srcRGB: blendFuncMap[func && func.srcRGB || gl.SRC_ALPHA],
212
- srcAlpha: blendFuncMap[func && func.srcAlpha || gl.SRC_ALPHA],
213
- dstRGB: blendFuncMap[func && func.dstRGB || gl.ONE_MINUS_SRC_ALPHA],
214
- dstAlpha: blendFuncMap[func && func.dstAlpha || gl.ONE_MINUS_SRC_ALPHA]
215
- },
216
- equation: {
217
- rgb: blendEquationMap[equation && equation.rgb || gl.FUNC_ADD],
218
- alpha: blendEquationMap[equation && equation.alpha || gl.FUNC_ADD]
219
- },
220
- color: color
221
- };
222
- }
223
- }
224
- /**
225
- * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#stencil
226
- */
227
-
228
- }, {
229
- key: "initStencilDrawParams",
230
- value: function initStencilDrawParams(_ref3, drawParams) {
231
- var stencil = _ref3.stencil;
232
-
233
- if (stencil) {
234
- var enable = stencil.enable,
235
- _stencil$mask = stencil.mask,
236
- mask = _stencil$mask === void 0 ? -1 : _stencil$mask,
237
- _stencil$func = stencil.func,
238
- func = _stencil$func === void 0 ? {
239
- cmp: gl.ALWAYS,
240
- ref: 0,
241
- mask: -1
242
- } : _stencil$func,
243
- _stencil$opFront = stencil.opFront,
244
- opFront = _stencil$opFront === void 0 ? {
245
- fail: gl.KEEP,
246
- zfail: gl.KEEP,
247
- zpass: gl.KEEP
248
- } : _stencil$opFront,
249
- _stencil$opBack = stencil.opBack,
250
- opBack = _stencil$opBack === void 0 ? {
251
- fail: gl.KEEP,
252
- zfail: gl.KEEP,
253
- zpass: gl.KEEP
254
- } : _stencil$opBack;
255
- drawParams.stencil = {
256
- enable: !!enable,
257
- mask: mask,
258
- func: _objectSpread(_objectSpread({}, func), {}, {
259
- cmp: stencilFuncMap[func.cmp]
260
- }),
261
- opFront: {
262
- fail: stencilOpMap[opFront.fail],
263
- zfail: stencilOpMap[opFront.zfail],
264
- zpass: stencilOpMap[opFront.zpass]
265
- },
266
- opBack: {
267
- fail: stencilOpMap[opBack.fail],
268
- zfail: stencilOpMap[opBack.zfail],
269
- zpass: stencilOpMap[opBack.zpass]
270
- }
271
- };
272
- }
273
- }
274
- /**
275
- * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#culling
276
- */
277
-
278
- }, {
279
- key: "initCullDrawParams",
280
- value: function initCullDrawParams(_ref4, drawParams) {
281
- var cull = _ref4.cull;
282
-
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
- * 考虑结构体命名, eg:
295
- * a: { b: 1 } -> 'a.b'
296
- * a: [ { b: 1 } ] -> 'a[0].b'
297
- */
298
-
299
- }, {
300
- key: "extractUniforms",
301
- value: function extractUniforms(uniforms) {
302
- var _this = this;
303
-
304
- var extractedUniforms = {};
305
- Object.keys(uniforms).forEach(function (uniformName) {
306
- _this.extractUniformsRecursively(uniformName, uniforms[uniformName], extractedUniforms, '');
307
- });
308
- return extractedUniforms;
309
- }
310
- }, {
311
- key: "extractUniformsRecursively",
312
- value: function extractUniformsRecursively(uniformName, uniformValue, uniforms, prefix) {
313
- var _this2 = this;
314
-
315
- if (uniformValue === null || typeof uniformValue === 'number' || // u_A: 1
316
- typeof uniformValue === 'boolean' || // u_A: false
317
- Array.isArray(uniformValue) && typeof uniformValue[0] === 'number' || // u_A: [1, 2, 3]
318
- isTypedArray(uniformValue) || // u_A: Float32Array
319
- // @ts-ignore
320
- uniformValue === '' || 'resize' in uniformValue) {
321
- uniforms["".concat(prefix && prefix + '.').concat(uniformName)] = uniformValue;
322
- return;
323
- } // u_Struct.a.b.c
324
-
325
-
326
- if (isPlainObject(uniformValue)) {
327
- Object.keys(uniformValue).forEach(function (childName) {
328
- _this2.extractUniformsRecursively(childName, // @ts-ignore
329
- uniformValue[childName], uniforms, "".concat(prefix && prefix + '.').concat(uniformName));
330
- });
331
- } // u_Struct[0].a
332
-
333
-
334
- if (Array.isArray(uniformValue)) {
335
- uniformValue.forEach(function (child, idx) {
336
- Object.keys(child).forEach(function (childName) {
337
- _this2.extractUniformsRecursively(childName, // @ts-ignore
338
- child[childName], uniforms, "".concat(prefix && prefix + '.').concat(uniformName, "[").concat(idx, "]"));
339
- });
340
- });
341
- }
342
- }
343
- }]);
344
-
345
- return ReglModel;
346
- }();
347
-
348
- export { ReglModel as default };
@@ -1,16 +0,0 @@
1
- import { IRenderbuffer, IRenderbufferInitializationOptions } from '@antv/l7-core';
2
- import regl from 'l7regl';
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,45 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import { formatMap } from "./constants";
4
- /**
5
- * adaptor for regl.Renderbuffer
6
- * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#renderbuffers
7
- */
8
-
9
- var ReglRenderbuffer = /*#__PURE__*/function () {
10
- function ReglRenderbuffer(reGl, options) {
11
- _classCallCheck(this, ReglRenderbuffer);
12
-
13
- var width = options.width,
14
- height = options.height,
15
- format = options.format;
16
- this.renderbuffer = reGl.renderbuffer({
17
- width: width,
18
- height: height,
19
- format: formatMap[format]
20
- });
21
- }
22
-
23
- _createClass(ReglRenderbuffer, [{
24
- key: "get",
25
- value: function get() {
26
- return this.renderbuffer;
27
- }
28
- }, {
29
- key: "destroy",
30
- value: function destroy() {
31
- this.renderbuffer.destroy();
32
- }
33
- }, {
34
- key: "resize",
35
- value: function resize(_ref) {
36
- var width = _ref.width,
37
- height = _ref.height;
38
- this.renderbuffer.resize(width, height);
39
- }
40
- }]);
41
-
42
- return ReglRenderbuffer;
43
- }();
44
-
45
- export { ReglRenderbuffer as default };
@@ -1,21 +0,0 @@
1
- import { ITexture2D, ITexture2DInitializationOptions } from '@antv/l7-core';
2
- import regl from 'l7regl';
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 isDistroy;
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
- destroy(): void;
21
- }
@@ -1,130 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
- import { gl } from '@antv/l7-core';
5
- import { colorSpaceMap, dataTypeMap, filterMap, formatMap, mipmapMap, wrapModeMap } from "./constants";
6
- /**
7
- * adaptor for regl.Buffer
8
- * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#buffers
9
- */
10
-
11
- var ReglTexture2D = /*#__PURE__*/function () {
12
- function ReglTexture2D(reGl, options) {
13
- _classCallCheck(this, ReglTexture2D);
14
-
15
- _defineProperty(this, "isDistroy", false);
16
-
17
- var data = options.data,
18
- _options$type = options.type,
19
- type = _options$type === void 0 ? gl.UNSIGNED_BYTE : _options$type,
20
- width = options.width,
21
- height = options.height,
22
- _options$flipY = options.flipY,
23
- flipY = _options$flipY === void 0 ? false : _options$flipY,
24
- _options$format = options.format,
25
- format = _options$format === void 0 ? gl.RGBA : _options$format,
26
- _options$mipmap = options.mipmap,
27
- mipmap = _options$mipmap === void 0 ? false : _options$mipmap,
28
- _options$wrapS = options.wrapS,
29
- wrapS = _options$wrapS === void 0 ? gl.CLAMP_TO_EDGE : _options$wrapS,
30
- _options$wrapT = options.wrapT,
31
- wrapT = _options$wrapT === void 0 ? gl.CLAMP_TO_EDGE : _options$wrapT,
32
- _options$aniso = options.aniso,
33
- aniso = _options$aniso === void 0 ? 0 : _options$aniso,
34
- _options$alignment = options.alignment,
35
- alignment = _options$alignment === void 0 ? 1 : _options$alignment,
36
- _options$premultiplyA = options.premultiplyAlpha,
37
- premultiplyAlpha = _options$premultiplyA === void 0 ? false : _options$premultiplyA,
38
- _options$mag = options.mag,
39
- mag = _options$mag === void 0 ? gl.NEAREST : _options$mag,
40
- _options$min = options.min,
41
- min = _options$min === void 0 ? gl.NEAREST : _options$min,
42
- _options$colorSpace = options.colorSpace,
43
- colorSpace = _options$colorSpace === void 0 ? gl.BROWSER_DEFAULT_WEBGL : _options$colorSpace,
44
- _options$x = options.x,
45
- x = _options$x === void 0 ? 0 : _options$x,
46
- _options$y = options.y,
47
- y = _options$y === void 0 ? 0 : _options$y,
48
- _options$copy = options.copy,
49
- copy = _options$copy === void 0 ? false : _options$copy;
50
- this.width = width;
51
- this.height = height;
52
- var textureOptions = {
53
- width: width,
54
- height: height,
55
- // @ts-ignore
56
- type: dataTypeMap[type],
57
- format: formatMap[format],
58
- wrapS: wrapModeMap[wrapS],
59
- wrapT: wrapModeMap[wrapT],
60
- // @ts-ignore
61
- mag: filterMap[mag],
62
- min: filterMap[min],
63
- alignment: alignment,
64
- flipY: flipY,
65
- colorSpace: colorSpaceMap[colorSpace],
66
- premultiplyAlpha: premultiplyAlpha,
67
- aniso: aniso,
68
- // copy pixels from current bind framebuffer
69
- x: x,
70
- y: y,
71
- copy: copy
72
- };
73
-
74
- if (data) {
75
- // @ts-ignore
76
- textureOptions.data = data;
77
- }
78
-
79
- if (typeof mipmap === 'number') {
80
- textureOptions.mipmap = mipmapMap[mipmap];
81
- } else if (typeof mipmap === 'boolean') {
82
- textureOptions.mipmap = mipmap;
83
- }
84
-
85
- this.texture = reGl.texture(textureOptions);
86
- }
87
-
88
- _createClass(ReglTexture2D, [{
89
- key: "get",
90
- value: function get() {
91
- return this.texture;
92
- }
93
- }, {
94
- key: "update",
95
- value: function update() {
96
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
97
- this.texture(props);
98
- }
99
- }, {
100
- key: "bind",
101
- value: function bind() {
102
- // @ts-ignore
103
- this.texture._texture.bind();
104
- }
105
- }, {
106
- key: "resize",
107
- value: function resize(_ref) {
108
- var width = _ref.width,
109
- height = _ref.height;
110
- this.texture.resize(width, height);
111
- this.width = width;
112
- this.height = height;
113
- }
114
- }, {
115
- key: "destroy",
116
- value: function destroy() {
117
- if (!this.isDistroy) {
118
- var _this$texture;
119
-
120
- (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
121
- }
122
-
123
- this.isDistroy = true;
124
- }
125
- }]);
126
-
127
- return ReglTexture2D;
128
- }();
129
-
130
- export { ReglTexture2D as default };
@@ -1,43 +0,0 @@
1
- import regl from 'l7regl';
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,23 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
- var _primitiveMap, _usageMap, _dataTypeMap, _formatMap, _mipmapMap, _filterMap, _wrapModeMap, _colorSpaceMap, _depthFuncMap, _blendEquationMap, _blendFuncMap, _stencilFuncMap, _stencilOpMap, _cullFaceMap;
4
-
5
- /**
6
- * @desc 由于 regl 使用大量字符串而非 WebGL 常量,因此需要映射
7
- */
8
- import { gl } from '@antv/l7-core';
9
- // @see https://github.com/regl-project/regl/blob/gh-pages/lib/constants/primitives.json
10
- 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);
11
- export var usageMap = (_usageMap = {}, _defineProperty(_usageMap, gl.STATIC_DRAW, 'static'), _defineProperty(_usageMap, gl.DYNAMIC_DRAW, 'dynamic'), _defineProperty(_usageMap, gl.STREAM_DRAW, 'stream'), _usageMap);
12
- 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);
13
- 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);
14
- export var mipmapMap = (_mipmapMap = {}, _defineProperty(_mipmapMap, gl.DONT_CARE, 'dont care'), _defineProperty(_mipmapMap, gl.NICEST, 'nice'), _defineProperty(_mipmapMap, gl.FASTEST, 'fast'), _mipmapMap);
15
- 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);
16
- export var wrapModeMap = (_wrapModeMap = {}, _defineProperty(_wrapModeMap, gl.REPEAT, 'repeat'), _defineProperty(_wrapModeMap, gl.CLAMP_TO_EDGE, 'clamp'), _defineProperty(_wrapModeMap, gl.MIRRORED_REPEAT, 'mirror'), _wrapModeMap);
17
- export var colorSpaceMap = (_colorSpaceMap = {}, _defineProperty(_colorSpaceMap, gl.NONE, 'none'), _defineProperty(_colorSpaceMap, gl.BROWSER_DEFAULT_WEBGL, 'browser'), _colorSpaceMap);
18
- 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);
19
- 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);
20
- 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);
21
- 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);
22
- 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);
23
- 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 regl from 'l7regl';
7
- import 'reflect-metadata';
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
- }