@antv/l7-renderer 2.16.0 → 2.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,19 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+
3
4
  /**
4
5
  * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#attributes
5
6
  */
6
7
  var ReglAttribute = /*#__PURE__*/function () {
7
8
  function ReglAttribute(gl, options) {
8
9
  _classCallCheck(this, ReglAttribute);
10
+
9
11
  var buffer = options.buffer,
10
- offset = options.offset,
11
- stride = options.stride,
12
- normalized = options.normalized,
13
- size = options.size,
14
- divisor = options.divisor;
12
+ offset = options.offset,
13
+ stride = options.stride,
14
+ normalized = options.normalized,
15
+ size = options.size,
16
+ divisor = options.divisor;
15
17
  this.buffer = buffer;
16
18
  this.attribute = {
17
19
  buffer: buffer.get(),
@@ -20,10 +22,12 @@ var ReglAttribute = /*#__PURE__*/function () {
20
22
  normalized: normalized || false,
21
23
  divisor: divisor || 0
22
24
  };
25
+
23
26
  if (size) {
24
27
  this.attribute.size = size;
25
28
  }
26
29
  }
30
+
27
31
  _createClass(ReglAttribute, [{
28
32
  key: "get",
29
33
  value: function get() {
@@ -40,6 +44,8 @@ var ReglAttribute = /*#__PURE__*/function () {
40
44
  this.buffer.destroy();
41
45
  }
42
46
  }]);
47
+
43
48
  return ReglAttribute;
44
49
  }();
50
+
45
51
  export { ReglAttribute as default };
@@ -2,24 +2,26 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  import { gl } from '@antv/l7-core';
4
4
  import { dataTypeMap, usageMap } from "./constants";
5
-
6
5
  /**
7
6
  * adaptor for regl.Buffer
8
7
  * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#buffers
9
8
  */
9
+
10
10
  var ReglBuffer = /*#__PURE__*/function () {
11
11
  function ReglBuffer(reGl, options) {
12
12
  _classCallCheck(this, ReglBuffer);
13
+
13
14
  var data = options.data,
14
- usage = options.usage,
15
- type = options.type;
15
+ usage = options.usage,
16
+ type = options.type;
16
17
  this.buffer = reGl.buffer({
17
18
  data: data,
18
19
  usage: usageMap[usage || gl.STATIC_DRAW],
19
- type: dataTypeMap[type || gl.UNSIGNED_BYTE]
20
- // length: 0,
20
+ type: dataTypeMap[type || gl.UNSIGNED_BYTE] // length: 0,
21
+
21
22
  });
22
23
  }
24
+
23
25
  _createClass(ReglBuffer, [{
24
26
  key: "get",
25
27
  value: function get() {
@@ -34,10 +36,12 @@ var ReglBuffer = /*#__PURE__*/function () {
34
36
  key: "subData",
35
37
  value: function subData(_ref) {
36
38
  var data = _ref.data,
37
- offset = _ref.offset;
39
+ offset = _ref.offset;
38
40
  this.buffer.subdata(data, offset);
39
41
  }
40
42
  }]);
43
+
41
44
  return ReglBuffer;
42
45
  }();
46
+
43
47
  export { ReglBuffer as default };
@@ -2,17 +2,18 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  import { gl } from '@antv/l7-core';
4
4
  import { dataTypeMap, usageMap } from "./constants";
5
-
6
5
  /**
7
6
  * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#elements
8
7
  */
8
+
9
9
  var ReglElements = /*#__PURE__*/function () {
10
10
  function ReglElements(reGl, options) {
11
11
  _classCallCheck(this, ReglElements);
12
+
12
13
  var data = options.data,
13
- usage = options.usage,
14
- type = options.type,
15
- count = options.count;
14
+ usage = options.usage,
15
+ type = options.type,
16
+ count = options.count;
16
17
  this.elements = reGl.elements({
17
18
  data: data,
18
19
  usage: usageMap[usage || gl.STATIC_DRAW],
@@ -20,6 +21,7 @@ var ReglElements = /*#__PURE__*/function () {
20
21
  count: count
21
22
  });
22
23
  }
24
+
23
25
  _createClass(ReglElements, [{
24
26
  key: "get",
25
27
  value: function get() {
@@ -33,10 +35,11 @@ var ReglElements = /*#__PURE__*/function () {
33
35
  }
34
36
  }, {
35
37
  key: "destroy",
36
- value: function destroy() {
37
- // this.elements.destroy();
38
+ value: function destroy() {// this.elements.destroy();
38
39
  }
39
40
  }]);
41
+
40
42
  return ReglElements;
41
43
  }();
44
+
42
45
  export { ReglElements as default };
@@ -1,5 +1,6 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+
3
4
  /**
4
5
  * adaptor for regl.Framebuffer
5
6
  * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#framebuffers
@@ -7,27 +8,30 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
7
8
  var ReglFramebuffer = /*#__PURE__*/function () {
8
9
  function ReglFramebuffer(reGl, options) {
9
10
  _classCallCheck(this, ReglFramebuffer);
11
+
10
12
  var width = options.width,
11
- height = options.height,
12
- color = options.color,
13
- colors = options.colors;
13
+ height = options.height,
14
+ color = options.color,
15
+ colors = options.colors;
14
16
  var framebufferOptions = {
15
17
  width: width,
16
18
  height: height
17
19
  };
20
+
18
21
  if (Array.isArray(colors)) {
19
22
  framebufferOptions.colors = colors.map(function (c) {
20
23
  return c.get();
21
24
  });
22
25
  }
26
+
23
27
  if (color && typeof color !== 'boolean') {
24
28
  framebufferOptions.color = color.get();
25
- }
29
+ } // TODO: depth & stencil
26
30
 
27
- // TODO: depth & stencil
28
31
 
29
32
  this.framebuffer = reGl.framebuffer(framebufferOptions);
30
33
  }
34
+
31
35
  _createClass(ReglFramebuffer, [{
32
36
  key: "get",
33
37
  value: function get() {
@@ -42,10 +46,12 @@ var ReglFramebuffer = /*#__PURE__*/function () {
42
46
  key: "resize",
43
47
  value: function resize(_ref) {
44
48
  var width = _ref.width,
45
- height = _ref.height;
49
+ height = _ref.height;
46
50
  this.framebuffer.resize(width, height);
47
51
  }
48
52
  }]);
53
+
49
54
  return ReglFramebuffer;
50
55
  }();
56
+
51
57
  export { ReglFramebuffer as default };
@@ -6,27 +6,32 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
6
6
  import { gl } from '@antv/l7-core';
7
7
  import { isPlainObject, isTypedArray } from 'lodash';
8
8
  import { blendEquationMap, blendFuncMap, cullFaceMap, depthFuncMap, primitiveMap, stencilFuncMap, stencilOpMap } from "./constants";
9
+
9
10
  /**
10
11
  * adaptor for regl.DrawCommand
11
12
  */
12
13
  var ReglModel = /*#__PURE__*/function () {
13
14
  function ReglModel(reGl, options) {
14
15
  _classCallCheck(this, ReglModel);
16
+
15
17
  _defineProperty(this, "destroyed", false);
18
+
16
19
  _defineProperty(this, "uniforms", {});
20
+
17
21
  this.reGl = reGl;
18
22
  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;
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
+ cull = options.cull,
31
+ instances = options.instances;
28
32
  var reglUniforms = {};
29
33
  this.options = options;
34
+
30
35
  if (uniforms) {
31
36
  this.uniforms = this.extractUniforms(uniforms);
32
37
  Object.keys(uniforms).forEach(function (uniformName) {
@@ -35,6 +40,7 @@ var ReglModel = /*#__PURE__*/function () {
35
40
  reglUniforms[uniformName] = reGl.prop(uniformName);
36
41
  });
37
42
  }
43
+
38
44
  var reglAttributes = {};
39
45
  Object.keys(attributes).forEach(function (name) {
40
46
  reglAttributes[name] = attributes[name].get();
@@ -70,29 +76,32 @@ var ReglModel = /*#__PURE__*/function () {
70
76
  },
71
77
  primitive: primitiveMap[primitive === undefined ? gl.TRIANGLES : primitive]
72
78
  };
79
+
73
80
  if (instances) {
74
81
  drawParams.instances = instances;
75
- }
76
-
77
- // Tip:
82
+ } // Tip:
78
83
  // elements 中可能包含 count,此时不应传入
79
84
  // count 和 elements 相比、count 优先
85
+
86
+
80
87
  if (count) {
81
88
  drawParams.count = count;
82
89
  } else if (elements) {
83
90
  drawParams.elements = elements.get();
84
91
  }
92
+
85
93
  this.initDepthDrawParams({
86
94
  depth: depth
87
- }, drawParams);
88
- // this.initBlendDrawParams({ blend }, drawParams);
95
+ }, drawParams); // this.initBlendDrawParams({ blend }, drawParams);
89
96
  // this.initStencilDrawParams({ stencil }, drawParams);
97
+
90
98
  this.initCullDrawParams({
91
99
  cull: cull
92
100
  }, drawParams);
93
101
  this.drawCommand = reGl(drawParams);
94
102
  this.drawParams = drawParams;
95
103
  }
104
+
96
105
  _createClass(ReglModel, [{
97
106
  key: "updateAttributesAndElements",
98
107
  value: function updateAttributesAndElements(attributes, elements) {
@@ -126,58 +135,62 @@ var ReglModel = /*#__PURE__*/function () {
126
135
  if (this.drawParams.attributes && Object.keys(this.drawParams.attributes).length === 0) {
127
136
  return;
128
137
  }
138
+
129
139
  var uniforms = _objectSpread(_objectSpread({}, this.uniforms), this.extractUniforms(options.uniforms || {}));
140
+
130
141
  var reglDrawProps = {};
131
142
  Object.keys(uniforms).forEach(function (uniformName) {
132
143
  var type = _typeof(uniforms[uniformName]);
133
- if (type === 'boolean' || type === 'number' || Array.isArray(uniforms[uniformName]) ||
134
- // @ts-ignore
144
+
145
+ if (type === 'boolean' || type === 'number' || Array.isArray(uniforms[uniformName]) || // @ts-ignore
135
146
  uniforms[uniformName].BYTES_PER_ELEMENT) {
136
147
  reglDrawProps[uniformName] = uniforms[uniformName];
137
148
  } else {
138
149
  reglDrawProps[uniformName] = uniforms[uniformName].get();
139
150
  }
140
- });
141
- // 更新 blend
151
+ }); // 更新 blend
142
152
  // @ts-ignore
153
+
143
154
  reglDrawProps.blend = pick // picking 操作不应该使用 blend
144
155
  ? this.getBlendDrawParams({
145
156
  blend: {
146
157
  enable: false
147
158
  }
148
- }) : this.getBlendDrawParams(options);
149
-
150
- // 更新stentil 配置
151
- // @ts-ignore
152
- reglDrawProps.stencil = this.getStencilDrawParams(options);
159
+ }) : this.getBlendDrawParams(options); // 更新stentil 配置
153
160
  // @ts-ignore
154
- reglDrawProps.colorMask = this.getColorMaskDrawParams(options, pick);
155
161
 
156
- // 在进行拾取操作的绘制中,不应该使用叠加模式 - picking 根据拾取的颜色作为判断的输入,而叠加模式会产生新的,在 id 序列中不存在的颜色
162
+ reglDrawProps.stencil = this.getStencilDrawParams(options); // @ts-ignore
163
+
164
+ reglDrawProps.colorMask = this.getColorMaskDrawParams(options, pick); // 在进行拾取操作的绘制中,不应该使用叠加模式 - picking 根据拾取的颜色作为判断的输入,而叠加模式会产生新的,在 id 序列中不存在的颜色
165
+
157
166
  this.drawCommand(reglDrawProps);
158
167
  }
159
168
  }, {
160
169
  key: "destroy",
161
170
  value: function destroy() {
162
171
  var _this$drawParams, _this$drawParams$elem;
172
+
163
173
  // @ts-ignore
164
174
  (_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();
175
+
165
176
  if (this.options.attributes) {
166
177
  Object.values(this.options.attributes).forEach(function (attr) {
167
178
  // @ts-ignore
168
179
  attr === null || attr === void 0 ? void 0 : attr.destroy();
169
180
  });
170
181
  }
182
+
171
183
  this.destroyed = true;
172
184
  }
173
-
174
185
  /**
175
186
  * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#depth-buffer
176
187
  */
188
+
177
189
  }, {
178
190
  key: "initDepthDrawParams",
179
191
  value: function initDepthDrawParams(_ref, drawParams) {
180
192
  var depth = _ref.depth;
193
+
181
194
  if (depth) {
182
195
  drawParams.depth = {
183
196
  enable: depth.enable === undefined ? true : !!depth.enable,
@@ -191,13 +204,15 @@ var ReglModel = /*#__PURE__*/function () {
191
204
  key: "getBlendDrawParams",
192
205
  value: function getBlendDrawParams(_ref2) {
193
206
  var blend = _ref2.blend;
207
+
194
208
  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
209
+ enable = _ref3.enable,
210
+ func = _ref3.func,
211
+ equation = _ref3.equation,
212
+ _ref3$color = _ref3.color,
213
+ color = _ref3$color === void 0 ? [0, 0, 0, 0] : _ref3$color; // @ts-ignore
214
+
215
+
201
216
  return {
202
217
  enable: !!enable,
203
218
  func: {
@@ -216,32 +231,35 @@ var ReglModel = /*#__PURE__*/function () {
216
231
  /**
217
232
  * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#stencil
218
233
  */
234
+
219
235
  }, {
220
236
  key: "getStencilDrawParams",
221
237
  value: function getStencilDrawParams(_ref4) {
222
238
  var stencil = _ref4.stencil;
239
+
223
240
  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;
241
+ enable = _ref5.enable,
242
+ _ref5$mask = _ref5.mask,
243
+ mask = _ref5$mask === void 0 ? -1 : _ref5$mask,
244
+ _ref5$func = _ref5.func,
245
+ func = _ref5$func === void 0 ? {
246
+ cmp: gl.ALWAYS,
247
+ ref: 0,
248
+ mask: -1
249
+ } : _ref5$func,
250
+ _ref5$opFront = _ref5.opFront,
251
+ opFront = _ref5$opFront === void 0 ? {
252
+ fail: gl.KEEP,
253
+ zfail: gl.KEEP,
254
+ zpass: gl.KEEP
255
+ } : _ref5$opFront,
256
+ _ref5$opBack = _ref5.opBack,
257
+ opBack = _ref5$opBack === void 0 ? {
258
+ fail: gl.KEEP,
259
+ zfail: gl.KEEP,
260
+ zpass: gl.KEEP
261
+ } : _ref5$opBack;
262
+
245
263
  return {
246
264
  enable: !!enable,
247
265
  mask: mask,
@@ -267,36 +285,39 @@ var ReglModel = /*#__PURE__*/function () {
267
285
  // TODO: 重构相关参数
268
286
  // 掩膜模式下,颜色通道全部关闭
269
287
  var colorMask = stencil !== null && stencil !== void 0 && stencil.enable && stencil.opFront && !pick ? [false, false, false, false] : [true, true, true, true]; // 非掩码模式下,颜色通道全部开启
288
+
270
289
  return colorMask;
271
290
  }
272
-
273
291
  /**
274
292
  * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#culling
275
293
  */
294
+
276
295
  }, {
277
296
  key: "initCullDrawParams",
278
297
  value: function initCullDrawParams(_ref7, drawParams) {
279
298
  var cull = _ref7.cull;
299
+
280
300
  if (cull) {
281
301
  var enable = cull.enable,
282
- _cull$face = cull.face,
283
- face = _cull$face === void 0 ? gl.BACK : _cull$face;
302
+ _cull$face = cull.face,
303
+ face = _cull$face === void 0 ? gl.BACK : _cull$face;
284
304
  drawParams.cull = {
285
305
  enable: !!enable,
286
306
  face: cullFaceMap[face]
287
307
  };
288
308
  }
289
309
  }
290
-
291
310
  /**
292
311
  * 考虑结构体命名, eg:
293
312
  * a: { b: 1 } -> 'a.b'
294
313
  * a: [ { b: 1 } ] -> 'a[0].b'
295
314
  */
315
+
296
316
  }, {
297
317
  key: "extractUniforms",
298
318
  value: function extractUniforms(uniforms) {
299
319
  var _this = this;
320
+
300
321
  var extractedUniforms = {};
301
322
  Object.keys(uniforms).forEach(function (uniformName) {
302
323
  _this.extractUniformsRecursively(uniformName, uniforms[uniformName], extractedUniforms, '');
@@ -307,41 +328,38 @@ var ReglModel = /*#__PURE__*/function () {
307
328
  key: "extractUniformsRecursively",
308
329
  value: function extractUniformsRecursively(uniformName, uniformValue, uniforms, prefix) {
309
330
  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
331
+
332
+ if (uniformValue === null || typeof uniformValue === 'number' || // u_A: 1
333
+ typeof uniformValue === 'boolean' || // u_A: false
334
+ Array.isArray(uniformValue) && typeof uniformValue[0] === 'number' || // u_A: [1, 2, 3]
335
+ isTypedArray(uniformValue) || // u_A: Float32Array
318
336
  // @ts-ignore
319
337
  uniformValue === '' || 'resize' in uniformValue) {
320
338
  uniforms["".concat(prefix && prefix + '.').concat(uniformName)] = uniformValue;
321
339
  return;
322
- }
340
+ } // u_Struct.a.b.c
341
+
323
342
 
324
- // u_Struct.a.b.c
325
343
  if (isPlainObject(uniformValue)) {
326
344
  Object.keys(uniformValue).forEach(function (childName) {
327
- _this2.extractUniformsRecursively(childName,
328
- // @ts-ignore
345
+ _this2.extractUniformsRecursively(childName, // @ts-ignore
329
346
  uniformValue[childName], uniforms, "".concat(prefix && prefix + '.').concat(uniformName));
330
347
  });
331
- }
348
+ } // u_Struct[0].a
349
+
332
350
 
333
- // u_Struct[0].a
334
351
  if (Array.isArray(uniformValue)) {
335
352
  uniformValue.forEach(function (child, idx) {
336
353
  Object.keys(child).forEach(function (childName) {
337
- _this2.extractUniformsRecursively(childName,
338
- // @ts-ignore
354
+ _this2.extractUniformsRecursively(childName, // @ts-ignore
339
355
  child[childName], uniforms, "".concat(prefix && prefix + '.').concat(uniformName, "[").concat(idx, "]"));
340
356
  });
341
357
  });
342
358
  }
343
359
  }
344
360
  }]);
361
+
345
362
  return ReglModel;
346
363
  }();
364
+
347
365
  export { ReglModel as default };
@@ -1,23 +1,25 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  import { formatMap } from "./constants";
4
-
5
4
  /**
6
5
  * adaptor for regl.Renderbuffer
7
6
  * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#renderbuffers
8
7
  */
8
+
9
9
  var ReglRenderbuffer = /*#__PURE__*/function () {
10
10
  function ReglRenderbuffer(reGl, options) {
11
11
  _classCallCheck(this, ReglRenderbuffer);
12
+
12
13
  var width = options.width,
13
- height = options.height,
14
- format = options.format;
14
+ height = options.height,
15
+ format = options.format;
15
16
  this.renderbuffer = reGl.renderbuffer({
16
17
  width: width,
17
18
  height: height,
18
19
  format: formatMap[format]
19
20
  });
20
21
  }
22
+
21
23
  _createClass(ReglRenderbuffer, [{
22
24
  key: "get",
23
25
  value: function get() {
@@ -32,10 +34,12 @@ var ReglRenderbuffer = /*#__PURE__*/function () {
32
34
  key: "resize",
33
35
  value: function resize(_ref) {
34
36
  var width = _ref.width,
35
- height = _ref.height;
37
+ height = _ref.height;
36
38
  this.renderbuffer.resize(width, height);
37
39
  }
38
40
  }]);
41
+
39
42
  return ReglRenderbuffer;
40
43
  }();
44
+
41
45
  export { ReglRenderbuffer as default };
@@ -3,48 +3,50 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
4
  import { gl } from '@antv/l7-core';
5
5
  import { colorSpaceMap, dataTypeMap, filterMap, formatMap, mipmapMap, wrapModeMap } from "./constants";
6
-
7
6
  /**
8
7
  * adaptor for regl.Buffer
9
8
  * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#buffers
10
9
  */
10
+
11
11
  var ReglTexture2D = /*#__PURE__*/function () {
12
12
  function ReglTexture2D(reGl, options) {
13
13
  _classCallCheck(this, ReglTexture2D);
14
+
14
15
  _defineProperty(this, "isDestroy", false);
16
+
15
17
  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;
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;
48
50
  this.width = width;
49
51
  this.height = height;
50
52
  var textureOptions = {
@@ -68,17 +70,21 @@ var ReglTexture2D = /*#__PURE__*/function () {
68
70
  y: y,
69
71
  copy: copy
70
72
  };
73
+
71
74
  if (data) {
72
75
  // @ts-ignore
73
76
  textureOptions.data = data;
74
77
  }
78
+
75
79
  if (typeof mipmap === 'number') {
76
80
  textureOptions.mipmap = mipmapMap[mipmap];
77
81
  } else if (typeof mipmap === 'boolean') {
78
82
  textureOptions.mipmap = mipmap;
79
83
  }
84
+
80
85
  this.texture = reGl.texture(textureOptions);
81
86
  }
87
+
82
88
  _createClass(ReglTexture2D, [{
83
89
  key: "get",
84
90
  value: function get() {
@@ -100,7 +106,7 @@ var ReglTexture2D = /*#__PURE__*/function () {
100
106
  key: "resize",
101
107
  value: function resize(_ref) {
102
108
  var width = _ref.width,
103
- height = _ref.height;
109
+ height = _ref.height;
104
110
  this.texture.resize(width, height);
105
111
  this.width = width;
106
112
  this.height = height;
@@ -115,11 +121,15 @@ var ReglTexture2D = /*#__PURE__*/function () {
115
121
  value: function destroy() {
116
122
  if (!this.isDestroy) {
117
123
  var _this$texture;
124
+
118
125
  (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
119
126
  }
127
+
120
128
  this.isDestroy = true;
121
129
  }
122
130
  }]);
131
+
123
132
  return ReglTexture2D;
124
133
  }();
134
+
125
135
  export { ReglTexture2D as default };
@@ -1,5 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+
2
3
  var _primitiveMap, _usageMap, _dataTypeMap, _formatMap, _mipmapMap, _filterMap, _wrapModeMap, _colorSpaceMap, _depthFuncMap, _blendEquationMap, _blendFuncMap, _stencilFuncMap, _stencilOpMap, _cullFaceMap;
4
+
3
5
  /**
4
6
  * @desc 由于 regl 使用大量字符串而非 WebGL 常量,因此需要映射
5
7
  */
package/es/regl/index.js CHANGED
@@ -2,13 +2,15 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
2
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
4
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
5
+
5
6
  var _dec, _class;
7
+
6
8
  import _regeneratorRuntime from "@babel/runtime/regenerator";
9
+
7
10
  /**
8
11
  * render w/ regl
9
12
  * @see https://github.com/regl-project/regl/blob/gh-pages/API.md
10
13
  */
11
-
12
14
  import { isMini } from '@antv/l7-utils';
13
15
  import { injectable } from 'inversify';
14
16
  import regl from 'l7regl';
@@ -19,45 +21,55 @@ import ReglElements from "./ReglElements";
19
21
  import ReglFramebuffer from "./ReglFramebuffer";
20
22
  import ReglModel from "./ReglModel";
21
23
  import ReglTexture2D from "./ReglTexture2D";
22
-
23
24
  /**
24
25
  * regl renderer
25
26
  */
27
+
26
28
  var ReglRendererService = (_dec = injectable(), _dec(_class = /*#__PURE__*/function () {
27
29
  function ReglRendererService() {
28
30
  var _this = this;
31
+
29
32
  _classCallCheck(this, ReglRendererService);
33
+
30
34
  _defineProperty(this, "createModel", function (options) {
31
35
  return new ReglModel(_this.gl, options);
32
36
  });
37
+
33
38
  _defineProperty(this, "createAttribute", function (options) {
34
39
  return new ReglAttribute(_this.gl, options);
35
40
  });
41
+
36
42
  _defineProperty(this, "createBuffer", function (options) {
37
43
  return new ReglBuffer(_this.gl, options);
38
44
  });
45
+
39
46
  _defineProperty(this, "createElements", function (options) {
40
47
  return new ReglElements(_this.gl, options);
41
48
  });
49
+
42
50
  _defineProperty(this, "createTexture2D", function (options) {
43
51
  return new ReglTexture2D(_this.gl, options);
44
52
  });
53
+
45
54
  _defineProperty(this, "createFramebuffer", function (options) {
46
55
  return new ReglFramebuffer(_this.gl, options);
47
56
  });
57
+
48
58
  _defineProperty(this, "useFramebuffer", function (framebuffer, drawCommands) {
49
59
  _this.gl({
50
60
  framebuffer: framebuffer ? framebuffer.get() : null
51
61
  })(drawCommands);
52
62
  });
63
+
53
64
  _defineProperty(this, "clear", function (options) {
54
65
  var _this$gl;
66
+
55
67
  // @see https://github.com/regl-project/regl/blob/gh-pages/API.md#clear-the-draw-buffer
56
68
  var color = options.color,
57
- depth = options.depth,
58
- stencil = options.stencil,
59
- _options$framebuffer = options.framebuffer,
60
- framebuffer = _options$framebuffer === void 0 ? null : _options$framebuffer;
69
+ depth = options.depth,
70
+ stencil = options.stencil,
71
+ _options$framebuffer = options.framebuffer,
72
+ framebuffer = _options$framebuffer === void 0 ? null : _options$framebuffer;
61
73
  var reglClearOptions = {
62
74
  color: color,
63
75
  depth: depth,
@@ -66,135 +78,158 @@ var ReglRendererService = (_dec = injectable(), _dec(_class = /*#__PURE__*/funct
66
78
  reglClearOptions.framebuffer = framebuffer === null ? framebuffer : framebuffer.get();
67
79
  (_this$gl = _this.gl) === null || _this$gl === void 0 ? void 0 : _this$gl.clear(reglClearOptions);
68
80
  });
81
+
69
82
  _defineProperty(this, "viewport", function (_ref) {
70
83
  var x = _ref.x,
71
- y = _ref.y,
72
- width = _ref.width,
73
- height = _ref.height;
84
+ y = _ref.y,
85
+ width = _ref.width,
86
+ height = _ref.height;
87
+
74
88
  // use WebGL context directly
75
89
  // @see https://github.com/regl-project/regl/blob/gh-pages/API.md#unsafe-escape-hatch
76
90
  _this.gl._gl.viewport(x, y, width, height);
91
+
77
92
  _this.width = width;
78
93
  _this.height = height;
94
+
79
95
  _this.gl._refresh();
80
96
  });
97
+
81
98
  _defineProperty(this, "readPixels", function (options) {
82
99
  var framebuffer = options.framebuffer,
83
- x = options.x,
84
- y = options.y,
85
- width = options.width,
86
- height = options.height;
100
+ x = options.x,
101
+ y = options.y,
102
+ width = options.width,
103
+ height = options.height;
87
104
  var readPixelsOptions = {
88
105
  x: x,
89
106
  y: y,
90
107
  width: width,
91
108
  height: height
92
109
  };
110
+
93
111
  if (framebuffer) {
94
112
  readPixelsOptions.framebuffer = framebuffer.get();
95
113
  }
114
+
96
115
  return _this.gl.read(readPixelsOptions);
97
116
  });
117
+
98
118
  _defineProperty(this, "getViewportSize", function () {
99
119
  return {
100
120
  width: _this.gl._gl.drawingBufferWidth,
101
121
  height: _this.gl._gl.drawingBufferHeight
102
122
  };
103
123
  });
124
+
104
125
  _defineProperty(this, "getContainer", function () {
105
126
  if (isMini) {
106
127
  return _this.canvas;
107
128
  } else {
108
129
  var _this$canvas;
130
+
109
131
  return (_this$canvas = _this.canvas) === null || _this$canvas === void 0 ? void 0 : _this$canvas.parentElement;
110
132
  }
111
133
  });
134
+
112
135
  _defineProperty(this, "getCanvas", function () {
113
136
  // return this.$container?.getElementsByTagName('canvas')[0] || null;
114
137
  return _this.canvas;
115
138
  });
139
+
116
140
  _defineProperty(this, "getGLContext", function () {
117
141
  return _this.gl._gl;
118
142
  });
143
+
119
144
  _defineProperty(this, "destroy", function () {
120
145
  var _this$gl2, _this$gl2$_gl, _this$gl2$_gl$getExte;
146
+
121
147
  // this.canvas = null 清除对 webgl 实例的引用
122
148
  // @ts-ignore
123
- _this.canvas = null;
149
+ _this.canvas = null; // make sure release webgl context
124
150
 
125
- // make sure release webgl context
126
- (_this$gl2 = _this.gl) === null || _this$gl2 === void 0 ? void 0 : (_this$gl2$_gl = _this$gl2._gl) === null || _this$gl2$_gl === void 0 ? void 0 : (_this$gl2$_gl$getExte = _this$gl2$_gl.getExtension('WEBGL_lose_context')) === null || _this$gl2$_gl$getExte === void 0 ? void 0 : _this$gl2$_gl$getExte.loseContext();
151
+ (_this$gl2 = _this.gl) === null || _this$gl2 === void 0 ? void 0 : (_this$gl2$_gl = _this$gl2._gl) === null || _this$gl2$_gl === void 0 ? void 0 : (_this$gl2$_gl$getExte = _this$gl2$_gl.getExtension('WEBGL_lose_context')) === null || _this$gl2$_gl$getExte === void 0 ? void 0 : _this$gl2$_gl$getExte.loseContext(); // @see https://github.com/regl-project/regl/blob/gh-pages/API.md#clean-up
152
+
153
+ _this.gl.destroy(); // @ts-ignore
127
154
 
128
- // @see https://github.com/regl-project/regl/blob/gh-pages/API.md#clean-up
129
- _this.gl.destroy();
130
155
 
131
- // @ts-ignore
132
156
  _this.gl = null;
133
157
  });
134
158
  }
159
+
135
160
  _createClass(ReglRendererService, [{
136
161
  key: "init",
137
162
  value: function () {
138
163
  var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(canvas, cfg, gl) {
139
164
  var _this2 = this;
165
+
140
166
  return _regeneratorRuntime.wrap(function _callee$(_context) {
141
- while (1) switch (_context.prev = _context.next) {
142
- case 0:
143
- // this.$container = $container;
144
- this.canvas = canvas;
145
- if (!gl) {
146
- _context.next = 5;
167
+ while (1) {
168
+ switch (_context.prev = _context.next) {
169
+ case 0:
170
+ // this.$container = $container;
171
+ this.canvas = canvas;
172
+
173
+ if (!gl) {
174
+ _context.next = 5;
175
+ break;
176
+ }
177
+
178
+ this.gl = gl;
179
+ _context.next = 8;
147
180
  break;
148
- }
149
- this.gl = gl;
150
- _context.next = 8;
151
- break;
152
- case 5:
153
- _context.next = 7;
154
- return new Promise(function (resolve, reject) {
155
- regl({
156
- canvas: _this2.canvas,
157
- attributes: {
158
- alpha: true,
159
- // use TAA instead of MSAA
160
- // @see https://www.khronos.org/registry/webgl/specs/1.0/#5.2.1
161
- antialias: cfg.antialias,
162
- premultipliedAlpha: true,
163
- preserveDrawingBuffer: cfg.preserveDrawingBuffer,
164
- stencil: cfg.stencil
165
- },
166
- // TODO: use extensions
167
- extensions: ['OES_element_index_uint', 'OES_standard_derivatives',
168
- // wireframe
169
- 'ANGLE_instanced_arrays' // VSM shadow map
170
- ],
171
-
172
- optionalExtensions: ['oes_texture_float_linear', 'OES_texture_float', 'EXT_texture_filter_anisotropic', 'EXT_blend_minmax', 'WEBGL_depth_texture', 'WEBGL_lose_context'],
173
- profile: true,
174
- onDone: function onDone(err, r) {
175
- if (err || !r) {
176
- reject(err);
181
+
182
+ case 5:
183
+ _context.next = 7;
184
+ return new Promise(function (resolve, reject) {
185
+ regl({
186
+ canvas: _this2.canvas,
187
+ attributes: {
188
+ alpha: true,
189
+ // use TAA instead of MSAA
190
+ // @see https://www.khronos.org/registry/webgl/specs/1.0/#5.2.1
191
+ antialias: cfg.antialias,
192
+ premultipliedAlpha: true,
193
+ preserveDrawingBuffer: cfg.preserveDrawingBuffer,
194
+ stencil: cfg.stencil
195
+ },
196
+ // TODO: use extensions
197
+ extensions: ['OES_element_index_uint', 'OES_standard_derivatives', // wireframe
198
+ 'ANGLE_instanced_arrays' // VSM shadow map
199
+ ],
200
+ optionalExtensions: ['oes_texture_float_linear', 'OES_texture_float', 'EXT_texture_filter_anisotropic', 'EXT_blend_minmax', 'WEBGL_depth_texture', 'WEBGL_lose_context'],
201
+ profile: true,
202
+ onDone: function onDone(err, r) {
203
+ if (err || !r) {
204
+ reject(err);
205
+ } // @ts-ignore
206
+
207
+
208
+ resolve(r);
177
209
  }
178
- // @ts-ignore
179
- resolve(r);
180
- }
210
+ });
181
211
  });
182
- });
183
- case 7:
184
- this.gl = _context.sent;
185
- case 8:
186
- this.extensionObject = {
187
- OES_texture_float: this.testExtension('OES_texture_float')
188
- };
189
- case 9:
190
- case "end":
191
- return _context.stop();
212
+
213
+ case 7:
214
+ this.gl = _context.sent;
215
+
216
+ case 8:
217
+ this.extensionObject = {
218
+ OES_texture_float: this.testExtension('OES_texture_float')
219
+ };
220
+
221
+ case 9:
222
+ case "end":
223
+ return _context.stop();
224
+ }
192
225
  }
193
226
  }, _callee, this);
194
227
  }));
228
+
195
229
  function init(_x, _x2, _x3) {
196
230
  return _init.apply(this, arguments);
197
231
  }
232
+
198
233
  return init;
199
234
  }()
200
235
  }, {
@@ -210,8 +245,7 @@ var ReglRendererService = (_dec = injectable(), _dec(_class = /*#__PURE__*/funct
210
245
  }
211
246
  }, {
212
247
  key: "setState",
213
- value:
214
- // TODO: 临时方法
248
+ value: // TODO: 临时方法
215
249
  function setState() {
216
250
  this.gl({
217
251
  cull: {
@@ -230,6 +264,7 @@ var ReglRendererService = (_dec = injectable(), _dec(_class = /*#__PURE__*/funct
230
264
  },
231
265
  framebuffer: null
232
266
  });
267
+
233
268
  this.gl._refresh();
234
269
  }
235
270
  }, {
@@ -252,6 +287,7 @@ var ReglRendererService = (_dec = injectable(), _dec(_class = /*#__PURE__*/funct
252
287
  },
253
288
  framebuffer: null
254
289
  });
290
+
255
291
  this.gl._refresh();
256
292
  }
257
293
  }, {
@@ -271,6 +307,7 @@ var ReglRendererService = (_dec = injectable(), _dec(_class = /*#__PURE__*/funct
271
307
  return this.isDirty;
272
308
  }
273
309
  }]);
310
+
274
311
  return ReglRendererService;
275
312
  }()) || _class);
276
313
  export { ReglRendererService as default };
package/lib/index.js CHANGED
@@ -17,10 +17,6 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
20
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
21
  mod
26
22
  ));
@@ -47,3 +47,5 @@ var ReglAttribute = class {
47
47
  this.buffer.destroy();
48
48
  }
49
49
  };
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {});
@@ -31,7 +31,6 @@ var ReglBuffer = class {
31
31
  data,
32
32
  usage: import_constants.usageMap[usage || import_l7_core.gl.STATIC_DRAW],
33
33
  type: import_constants.dataTypeMap[type || import_l7_core.gl.UNSIGNED_BYTE]
34
- // length: 0,
35
34
  });
36
35
  }
37
36
  get() {
@@ -47,3 +46,5 @@ var ReglBuffer = class {
47
46
  this.buffer.subdata(data, offset);
48
47
  }
49
48
  };
49
+ // Annotate the CommonJS export names for ESM import in node:
50
+ 0 && (module.exports = {});
@@ -45,3 +45,5 @@ var ReglElements = class {
45
45
  destroy() {
46
46
  }
47
47
  };
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {});
@@ -49,3 +49,5 @@ var ReglFramebuffer = class {
49
49
  this.framebuffer.resize(width, height);
50
50
  }
51
51
  };
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {});
@@ -59,28 +59,18 @@ var ReglModel = class {
59
59
  frag: fs,
60
60
  uniforms: reglUniforms,
61
61
  vert: vs,
62
- // @ts-ignore
63
62
  colorMask: reGl.prop("colorMask"),
64
63
  blend: {
65
- // @ts-ignore
66
64
  enable: reGl.prop("blend.enable"),
67
- // @ts-ignore
68
65
  func: reGl.prop("blend.func"),
69
- // @ts-ignore
70
66
  equation: reGl.prop("blend.equation"),
71
- // @ts-ignore
72
67
  color: reGl.prop("blend.color")
73
68
  },
74
69
  stencil: {
75
- // @ts-ignore
76
70
  enable: reGl.prop("stencil.enable"),
77
- // @ts-ignore
78
71
  mask: reGl.prop("stencil.mask"),
79
- // @ts-ignore
80
72
  func: reGl.prop("stencil.func"),
81
- // @ts-ignore
82
73
  opFront: reGl.prop("stencil.opFront"),
83
- // @ts-ignore
84
74
  opBack: reGl.prop("stencil.opBack")
85
75
  },
86
76
  primitive: import_constants.primitiveMap[primitive === void 0 ? import_l7_core.gl.TRIANGLES : primitive]
@@ -132,8 +122,7 @@ var ReglModel = class {
132
122
  const reglDrawProps = {};
133
123
  Object.keys(uniforms).forEach((uniformName) => {
134
124
  const type = typeof uniforms[uniformName];
135
- if (type === "boolean" || type === "number" || Array.isArray(uniforms[uniformName]) || // @ts-ignore
136
- uniforms[uniformName].BYTES_PER_ELEMENT) {
125
+ if (type === "boolean" || type === "number" || Array.isArray(uniforms[uniformName]) || uniforms[uniformName].BYTES_PER_ELEMENT) {
137
126
  reglDrawProps[uniformName] = uniforms[uniformName];
138
127
  } else {
139
128
  reglDrawProps[uniformName] = uniforms[uniformName].get();
@@ -156,9 +145,6 @@ var ReglModel = class {
156
145
  }
157
146
  this.destroyed = true;
158
147
  }
159
- /**
160
- * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#depth-buffer
161
- */
162
148
  initDepthDrawParams({ depth }, drawParams) {
163
149
  if (depth) {
164
150
  drawParams.depth = {
@@ -188,9 +174,6 @@ var ReglModel = class {
188
174
  color
189
175
  };
190
176
  }
191
- /**
192
- * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#stencil
193
- */
194
177
  getStencilDrawParams({
195
178
  stencil
196
179
  }) {
@@ -236,9 +219,6 @@ var ReglModel = class {
236
219
  const colorMask = (stencil == null ? void 0 : stencil.enable) && stencil.opFront && !pick ? [false, false, false, false] : [true, true, true, true];
237
220
  return colorMask;
238
221
  }
239
- /**
240
- * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#culling
241
- */
242
222
  initCullDrawParams({ cull }, drawParams) {
243
223
  if (cull) {
244
224
  const { enable, face = import_l7_core.gl.BACK } = cull;
@@ -248,11 +228,6 @@ var ReglModel = class {
248
228
  };
249
229
  }
250
230
  }
251
- /**
252
- * 考虑结构体命名, eg:
253
- * a: { b: 1 } -> 'a.b'
254
- * a: [ { b: 1 } ] -> 'a[0].b'
255
- */
256
231
  extractUniforms(uniforms) {
257
232
  const extractedUniforms = {};
258
233
  Object.keys(uniforms).forEach((uniformName) => {
@@ -266,12 +241,7 @@ var ReglModel = class {
266
241
  return extractedUniforms;
267
242
  }
268
243
  extractUniformsRecursively(uniformName, uniformValue, uniforms, prefix) {
269
- if (uniformValue === null || typeof uniformValue === "number" || // u_A: 1
270
- typeof uniformValue === "boolean" || // u_A: false
271
- Array.isArray(uniformValue) && typeof uniformValue[0] === "number" || // u_A: [1, 2, 3]
272
- (0, import_lodash.isTypedArray)(uniformValue) || // u_A: Float32Array
273
- // @ts-ignore
274
- uniformValue === "" || "resize" in uniformValue) {
244
+ if (uniformValue === null || typeof uniformValue === "number" || typeof uniformValue === "boolean" || Array.isArray(uniformValue) && typeof uniformValue[0] === "number" || (0, import_lodash.isTypedArray)(uniformValue) || uniformValue === "" || "resize" in uniformValue) {
275
245
  uniforms[`${prefix && prefix + "."}${uniformName}`] = uniformValue;
276
246
  return;
277
247
  }
@@ -279,7 +249,6 @@ var ReglModel = class {
279
249
  Object.keys(uniformValue).forEach((childName) => {
280
250
  this.extractUniformsRecursively(
281
251
  childName,
282
- // @ts-ignore
283
252
  uniformValue[childName],
284
253
  uniforms,
285
254
  `${prefix && prefix + "."}${uniformName}`
@@ -291,7 +260,6 @@ var ReglModel = class {
291
260
  Object.keys(child).forEach((childName) => {
292
261
  this.extractUniformsRecursively(
293
262
  childName,
294
- // @ts-ignore
295
263
  child[childName],
296
264
  uniforms,
297
265
  `${prefix && prefix + "."}${uniformName}[${idx}]`
@@ -301,3 +269,5 @@ var ReglModel = class {
301
269
  }
302
270
  }
303
271
  };
272
+ // Annotate the CommonJS export names for ESM import in node:
273
+ 0 && (module.exports = {});
@@ -42,3 +42,5 @@ var ReglRenderbuffer = class {
42
42
  this.renderbuffer.resize(width, height);
43
43
  }
44
44
  };
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {});
@@ -52,12 +52,10 @@ var ReglTexture2D = class {
52
52
  const textureOptions = {
53
53
  width,
54
54
  height,
55
- // @ts-ignore
56
55
  type: import_constants.dataTypeMap[type],
57
56
  format: import_constants.formatMap[format],
58
57
  wrapS: import_constants.wrapModeMap[wrapS],
59
58
  wrapT: import_constants.wrapModeMap[wrapT],
60
- // @ts-ignore
61
59
  mag: import_constants.filterMap[mag],
62
60
  min: import_constants.filterMap[min],
63
61
  alignment,
@@ -65,7 +63,6 @@ var ReglTexture2D = class {
65
63
  colorSpace: import_constants.colorSpaceMap[colorSpace],
66
64
  premultiplyAlpha,
67
65
  aniso,
68
- // copy pixels from current bind framebuffer
69
66
  x,
70
67
  y,
71
68
  copy
@@ -105,3 +102,5 @@ var ReglTexture2D = class {
105
102
  this.isDestroy = true;
106
103
  }
107
104
  };
105
+ // Annotate the CommonJS export names for ESM import in node:
106
+ 0 && (module.exports = {});
package/lib/regl/index.js CHANGED
@@ -17,10 +17,6 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
20
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
21
  mod
26
22
  ));
@@ -137,20 +133,15 @@ var ReglRendererService = class {
137
133
  canvas: this.canvas,
138
134
  attributes: {
139
135
  alpha: true,
140
- // use TAA instead of MSAA
141
- // @see https://www.khronos.org/registry/webgl/specs/1.0/#5.2.1
142
136
  antialias: cfg.antialias,
143
137
  premultipliedAlpha: true,
144
138
  preserveDrawingBuffer: cfg.preserveDrawingBuffer,
145
139
  stencil: cfg.stencil
146
140
  },
147
- // TODO: use extensions
148
141
  extensions: [
149
142
  "OES_element_index_uint",
150
143
  "OES_standard_derivatives",
151
- // wireframe
152
144
  "ANGLE_instanced_arrays"
153
- // VSM shadow map
154
145
  ],
155
146
  optionalExtensions: [
156
147
  "oes_texture_float_linear",
@@ -180,7 +171,6 @@ var ReglRendererService = class {
180
171
  testExtension(name) {
181
172
  return !!this.getGLContext().getExtension(name);
182
173
  }
183
- // TODO: 临时方法
184
174
  setState() {
185
175
  this.gl({
186
176
  cull: {
@@ -235,3 +225,5 @@ var ReglRendererService = class {
235
225
  ReglRendererService = __decorateClass([
236
226
  (0, import_inversify.injectable)()
237
227
  ], ReglRendererService);
228
+ // Annotate the CommonJS export names for ESM import in node:
229
+ 0 && (module.exports = {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-renderer",
3
- "version": "2.16.0",
3
+ "version": "2.16.1",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -25,19 +25,19 @@
25
25
  "author": "xiaoiver",
26
26
  "license": "ISC",
27
27
  "devDependencies": {
28
- "@antv/l7-test-utils": "2.16.0",
28
+ "@antv/l7-test-utils": "2.16.1",
29
29
  "gl": "^5.0.3"
30
30
  },
31
31
  "dependencies": {
32
- "@antv/l7-core": "2.16.0",
33
- "@antv/l7-utils": "2.16.0",
32
+ "@antv/l7-core": "2.16.1",
33
+ "@antv/l7-utils": "2.16.1",
34
34
  "@babel/runtime": "^7.7.7",
35
35
  "inversify": "^5.0.1",
36
36
  "l7regl": "^0.0.20",
37
37
  "lodash": "^4.17.15",
38
38
  "reflect-metadata": "^0.1.13"
39
39
  },
40
- "gitHead": "901d07c0523b128fbc69ca04e6b3b8367ea3572d",
40
+ "gitHead": "0976422540e1c3e23563239847110b40c6cb852a",
41
41
  "publishConfig": {
42
42
  "access": "public"
43
43
  }