@antv/l7-renderer 2.17.12 → 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,347 +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 { isPlainObject, isTypedArray } from 'lodash';
8
- import { blendEquationMap, blendFuncMap, cullFaceMap, depthFuncMap, primitiveMap, stencilFuncMap, stencilOpMap } from "./constants";
9
- /**
10
- * adaptor for regl.DrawCommand
11
- */
12
- var ReglModel = /*#__PURE__*/function () {
13
- function ReglModel(reGl, options) {
14
- _classCallCheck(this, ReglModel);
15
- _defineProperty(this, "destroyed", false);
16
- _defineProperty(this, "uniforms", {});
17
- this.reGl = reGl;
18
- var vs = options.vs,
19
- fs = options.fs,
20
- attributes = options.attributes,
21
- uniforms = options.uniforms,
22
- primitive = options.primitive,
23
- count = options.count,
24
- elements = options.elements,
25
- depth = options.depth,
26
- cull = options.cull,
27
- instances = options.instances;
28
- var reglUniforms = {};
29
- this.options = options;
30
- if (uniforms) {
31
- this.uniforms = this.extractUniforms(uniforms);
32
- Object.keys(uniforms).forEach(function (uniformName) {
33
- // use regl prop API
34
- // @ts-ignore
35
- reglUniforms[uniformName] = reGl.prop(uniformName);
36
- });
37
- }
38
- var reglAttributes = {};
39
- Object.keys(attributes).forEach(function (name) {
40
- reglAttributes[name] = attributes[name].get();
41
- });
42
- var drawParams = {
43
- attributes: reglAttributes,
44
- frag: fs,
45
- uniforms: reglUniforms,
46
- vert: vs,
47
- // @ts-ignore
48
- colorMask: reGl.prop('colorMask'),
49
- lineWidth: 1,
50
- blend: {
51
- // @ts-ignore
52
- enable: reGl.prop('blend.enable'),
53
- // @ts-ignore
54
- func: reGl.prop('blend.func'),
55
- // @ts-ignore
56
- equation: reGl.prop('blend.equation'),
57
- // @ts-ignore
58
- color: reGl.prop('blend.color')
59
- },
60
- stencil: {
61
- // @ts-ignore
62
- enable: reGl.prop('stencil.enable'),
63
- // @ts-ignore
64
- mask: reGl.prop('stencil.mask'),
65
- // @ts-ignore
66
- func: reGl.prop('stencil.func'),
67
- // @ts-ignore
68
- opFront: reGl.prop('stencil.opFront'),
69
- // @ts-ignore
70
- opBack: reGl.prop('stencil.opBack')
71
- },
72
- primitive: primitiveMap[primitive === undefined ? gl.TRIANGLES : primitive]
73
- };
74
- if (instances) {
75
- drawParams.instances = instances;
76
- }
77
-
78
- // Tip:
79
- // elements 中可能包含 count,此时不应传入
80
- // count 和 elements 相比、count 优先
81
- if (count) {
82
- drawParams.count = count;
83
- } else if (elements) {
84
- drawParams.elements = elements.get();
85
- }
86
- this.initDepthDrawParams({
87
- depth: depth
88
- }, drawParams);
89
- // this.initBlendDrawParams({ blend }, drawParams);
90
- // this.initStencilDrawParams({ stencil }, drawParams);
91
- this.initCullDrawParams({
92
- cull: cull
93
- }, drawParams);
94
- this.drawCommand = reGl(drawParams);
95
- this.drawParams = drawParams;
96
- }
97
- _createClass(ReglModel, [{
98
- key: "updateAttributesAndElements",
99
- value: function updateAttributesAndElements(attributes, elements) {
100
- var reglAttributes = {};
101
- Object.keys(attributes).forEach(function (name) {
102
- reglAttributes[name] = attributes[name].get();
103
- });
104
- this.drawParams.attributes = reglAttributes;
105
- this.drawParams.elements = elements.get();
106
- this.drawCommand = this.reGl(this.drawParams);
107
- }
108
- }, {
109
- key: "updateAttributes",
110
- value: function updateAttributes(attributes) {
111
- var reglAttributes = {};
112
- Object.keys(attributes).forEach(function (name) {
113
- reglAttributes[name] = attributes[name].get();
114
- });
115
- this.drawParams.attributes = reglAttributes;
116
- this.drawCommand = this.reGl(this.drawParams);
117
- }
118
- }, {
119
- key: "addUniforms",
120
- value: function addUniforms(uniforms) {
121
- this.uniforms = _objectSpread(_objectSpread({}, this.uniforms), this.extractUniforms(uniforms));
122
- }
123
- }, {
124
- key: "draw",
125
- value: function draw(options, pick) {
126
- if (this.drawParams.attributes && Object.keys(this.drawParams.attributes).length === 0) {
127
- return;
128
- }
129
- var uniforms = _objectSpread(_objectSpread({}, this.uniforms), this.extractUniforms(options.uniforms || {}));
130
- var reglDrawProps = {};
131
- Object.keys(uniforms).forEach(function (uniformName) {
132
- var type = _typeof(uniforms[uniformName]);
133
- if (type === 'boolean' || type === 'number' || Array.isArray(uniforms[uniformName]) ||
134
- // @ts-ignore
135
- uniforms[uniformName].BYTES_PER_ELEMENT) {
136
- reglDrawProps[uniformName] = uniforms[uniformName];
137
- } else {
138
- reglDrawProps[uniformName] = uniforms[uniformName].get();
139
- }
140
- });
141
- // 更新 blend
142
- // @ts-ignore
143
- reglDrawProps.blend = pick // picking 操作不应该使用 blend
144
- ? this.getBlendDrawParams({
145
- blend: {
146
- enable: false
147
- }
148
- }) : this.getBlendDrawParams(options);
149
-
150
- // 更新stentil 配置
151
- // @ts-ignore
152
- reglDrawProps.stencil = this.getStencilDrawParams(options);
153
- // @ts-ignore
154
- reglDrawProps.colorMask = this.getColorMaskDrawParams(options, pick);
155
-
156
- // 在进行拾取操作的绘制中,不应该使用叠加模式 - picking 根据拾取的颜色作为判断的输入,而叠加模式会产生新的,在 id 序列中不存在的颜色
157
- this.drawCommand(reglDrawProps);
158
- }
159
- }, {
160
- key: "destroy",
161
- value: function destroy() {
162
- var _this$drawParams, _this$drawParams$elem;
163
- // @ts-ignore
164
- (_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();
165
- if (this.options.attributes) {
166
- Object.values(this.options.attributes).forEach(function (attr) {
167
- // @ts-ignore
168
- attr === null || attr === void 0 ? void 0 : attr.destroy();
169
- });
170
- }
171
- this.destroyed = true;
172
- }
173
-
174
- /**
175
- * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#depth-buffer
176
- */
177
- }, {
178
- key: "initDepthDrawParams",
179
- value: function initDepthDrawParams(_ref, drawParams) {
180
- var depth = _ref.depth;
181
- if (depth) {
182
- drawParams.depth = {
183
- enable: depth.enable === undefined ? true : !!depth.enable,
184
- mask: depth.mask === undefined ? true : !!depth.mask,
185
- func: depthFuncMap[depth.func || gl.LESS],
186
- range: depth.range || [0, 1]
187
- };
188
- }
189
- }
190
- }, {
191
- key: "getBlendDrawParams",
192
- value: function getBlendDrawParams(_ref2) {
193
- var blend = _ref2.blend;
194
- var _ref3 = blend || {},
195
- enable = _ref3.enable,
196
- func = _ref3.func,
197
- equation = _ref3.equation,
198
- _ref3$color = _ref3.color,
199
- color = _ref3$color === void 0 ? [0, 0, 0, 0] : _ref3$color;
200
- // @ts-ignore
201
- return {
202
- enable: !!enable,
203
- func: {
204
- srcRGB: blendFuncMap[func && func.srcRGB || gl.SRC_ALPHA],
205
- srcAlpha: blendFuncMap[func && func.srcAlpha || gl.SRC_ALPHA],
206
- dstRGB: blendFuncMap[func && func.dstRGB || gl.ONE_MINUS_SRC_ALPHA],
207
- dstAlpha: blendFuncMap[func && func.dstAlpha || gl.ONE_MINUS_SRC_ALPHA]
208
- },
209
- equation: {
210
- rgb: blendEquationMap[equation && equation.rgb || gl.FUNC_ADD],
211
- alpha: blendEquationMap[equation && equation.alpha || gl.FUNC_ADD]
212
- },
213
- color: color
214
- };
215
- }
216
- /**
217
- * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#stencil
218
- */
219
- }, {
220
- key: "getStencilDrawParams",
221
- value: function getStencilDrawParams(_ref4) {
222
- var stencil = _ref4.stencil;
223
- var _ref5 = stencil || {},
224
- enable = _ref5.enable,
225
- _ref5$mask = _ref5.mask,
226
- mask = _ref5$mask === void 0 ? -1 : _ref5$mask,
227
- _ref5$func = _ref5.func,
228
- func = _ref5$func === void 0 ? {
229
- cmp: gl.ALWAYS,
230
- ref: 0,
231
- mask: -1
232
- } : _ref5$func,
233
- _ref5$opFront = _ref5.opFront,
234
- opFront = _ref5$opFront === void 0 ? {
235
- fail: gl.KEEP,
236
- zfail: gl.KEEP,
237
- zpass: gl.KEEP
238
- } : _ref5$opFront,
239
- _ref5$opBack = _ref5.opBack,
240
- opBack = _ref5$opBack === void 0 ? {
241
- fail: gl.KEEP,
242
- zfail: gl.KEEP,
243
- zpass: gl.KEEP
244
- } : _ref5$opBack;
245
- return {
246
- enable: !!enable,
247
- mask: mask,
248
- func: _objectSpread(_objectSpread({}, func), {}, {
249
- cmp: stencilFuncMap[func.cmp]
250
- }),
251
- opFront: {
252
- fail: stencilOpMap[opFront.fail],
253
- zfail: stencilOpMap[opFront.zfail],
254
- zpass: stencilOpMap[opFront.zpass]
255
- },
256
- opBack: {
257
- fail: stencilOpMap[opBack.fail],
258
- zfail: stencilOpMap[opBack.zfail],
259
- zpass: stencilOpMap[opBack.zpass]
260
- }
261
- };
262
- }
263
- }, {
264
- key: "getColorMaskDrawParams",
265
- value: function getColorMaskDrawParams(_ref6, pick) {
266
- var stencil = _ref6.stencil;
267
- // TODO: 重构相关参数
268
- // 掩膜模式下,颜色通道全部关闭
269
- var colorMask = stencil !== null && stencil !== void 0 && stencil.enable && stencil.opFront && !pick ? [false, false, false, false] : [true, true, true, true]; // 非掩码模式下,颜色通道全部开启
270
- return colorMask;
271
- }
272
-
273
- /**
274
- * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#culling
275
- */
276
- }, {
277
- key: "initCullDrawParams",
278
- value: function initCullDrawParams(_ref7, drawParams) {
279
- var cull = _ref7.cull;
280
- if (cull) {
281
- var enable = cull.enable,
282
- _cull$face = cull.face,
283
- face = _cull$face === void 0 ? gl.BACK : _cull$face;
284
- drawParams.cull = {
285
- enable: !!enable,
286
- face: cullFaceMap[face]
287
- };
288
- }
289
- }
290
-
291
- /**
292
- * 考虑结构体命名, eg:
293
- * a: { b: 1 } -> 'a.b'
294
- * a: [ { b: 1 } ] -> 'a[0].b'
295
- */
296
- }, {
297
- key: "extractUniforms",
298
- value: function extractUniforms(uniforms) {
299
- var _this = this;
300
- var extractedUniforms = {};
301
- Object.keys(uniforms).forEach(function (uniformName) {
302
- _this.extractUniformsRecursively(uniformName, uniforms[uniformName], extractedUniforms, '');
303
- });
304
- return extractedUniforms;
305
- }
306
- }, {
307
- key: "extractUniformsRecursively",
308
- value: function extractUniformsRecursively(uniformName, uniformValue, uniforms, prefix) {
309
- var _this2 = this;
310
- if (uniformValue === null || typeof uniformValue === 'number' ||
311
- // u_A: 1
312
- typeof uniformValue === 'boolean' ||
313
- // u_A: false
314
- Array.isArray(uniformValue) && typeof uniformValue[0] === 'number' ||
315
- // u_A: [1, 2, 3]
316
- isTypedArray(uniformValue) ||
317
- // u_A: Float32Array
318
- // @ts-ignore
319
- uniformValue === '' || 'resize' in uniformValue) {
320
- uniforms["".concat(prefix && prefix + '.').concat(uniformName)] = uniformValue;
321
- return;
322
- }
323
-
324
- // u_Struct.a.b.c
325
- if (isPlainObject(uniformValue)) {
326
- Object.keys(uniformValue).forEach(function (childName) {
327
- _this2.extractUniformsRecursively(childName,
328
- // @ts-ignore
329
- uniformValue[childName], uniforms, "".concat(prefix && prefix + '.').concat(uniformName));
330
- });
331
- }
332
-
333
- // u_Struct[0].a
334
- if (Array.isArray(uniformValue)) {
335
- uniformValue.forEach(function (child, idx) {
336
- Object.keys(child).forEach(function (childName) {
337
- _this2.extractUniformsRecursively(childName,
338
- // @ts-ignore
339
- child[childName], uniforms, "".concat(prefix && prefix + '.').concat(uniformName, "[").concat(idx, "]"));
340
- });
341
- });
342
- }
343
- }
344
- }]);
345
- return ReglModel;
346
- }();
347
- 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,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 '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 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 '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,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 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
- }