@antv/l7-renderer 2.17.4 → 2.17.6

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.
@@ -3,50 +3,48 @@ 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
+
6
7
  /**
7
8
  * adaptor for regl.Buffer
8
9
  * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#buffers
9
10
  */
10
-
11
11
  var ReglTexture2D = /*#__PURE__*/function () {
12
12
  function ReglTexture2D(reGl, options) {
13
13
  _classCallCheck(this, ReglTexture2D);
14
-
15
14
  _defineProperty(this, "isDestroy", false);
16
-
17
15
  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;
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;
50
48
  this.width = width;
51
49
  this.height = height;
52
50
  var textureOptions = {
@@ -70,21 +68,17 @@ var ReglTexture2D = /*#__PURE__*/function () {
70
68
  y: y,
71
69
  copy: copy
72
70
  };
73
-
74
71
  if (data) {
75
72
  // @ts-ignore
76
73
  textureOptions.data = data;
77
74
  }
78
-
79
75
  if (typeof mipmap === 'number') {
80
76
  textureOptions.mipmap = mipmapMap[mipmap];
81
77
  } else if (typeof mipmap === 'boolean') {
82
78
  textureOptions.mipmap = mipmap;
83
79
  }
84
-
85
80
  this.texture = reGl.texture(textureOptions);
86
81
  }
87
-
88
82
  _createClass(ReglTexture2D, [{
89
83
  key: "get",
90
84
  value: function get() {
@@ -106,7 +100,7 @@ var ReglTexture2D = /*#__PURE__*/function () {
106
100
  key: "resize",
107
101
  value: function resize(_ref) {
108
102
  var width = _ref.width,
109
- height = _ref.height;
103
+ height = _ref.height;
110
104
  this.texture.resize(width, height);
111
105
  this.width = width;
112
106
  this.height = height;
@@ -121,15 +115,11 @@ var ReglTexture2D = /*#__PURE__*/function () {
121
115
  value: function destroy() {
122
116
  if (!this.isDestroy) {
123
117
  var _this$texture;
124
-
125
118
  (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
126
119
  }
127
-
128
120
  this.isDestroy = true;
129
121
  }
130
122
  }]);
131
-
132
123
  return ReglTexture2D;
133
124
  }();
134
-
135
125
  export { ReglTexture2D as default };
@@ -1,7 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
-
3
2
  var _primitiveMap, _usageMap, _dataTypeMap, _formatMap, _mipmapMap, _filterMap, _wrapModeMap, _colorSpaceMap, _depthFuncMap, _blendEquationMap, _blendFuncMap, _stencilFuncMap, _stencilOpMap, _cullFaceMap;
4
-
5
3
  /**
6
4
  * @desc 由于 regl 使用大量字符串而非 WebGL 常量,因此需要映射
7
5
  */
package/es/regl/index.js CHANGED
@@ -2,15 +2,13 @@ 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
-
6
5
  var _dec, _class;
7
-
8
6
  import _regeneratorRuntime from "@babel/runtime/regenerator";
9
-
10
7
  /**
11
8
  * render w/ regl
12
9
  * @see https://github.com/regl-project/regl/blob/gh-pages/API.md
13
10
  */
11
+
14
12
  import { isMini } from '@antv/l7-utils';
15
13
  import { injectable } from 'inversify';
16
14
  import regl from 'l7regl';
@@ -21,55 +19,45 @@ import ReglElements from "./ReglElements";
21
19
  import ReglFramebuffer from "./ReglFramebuffer";
22
20
  import ReglModel from "./ReglModel";
23
21
  import ReglTexture2D from "./ReglTexture2D";
22
+
24
23
  /**
25
24
  * regl renderer
26
25
  */
27
-
28
26
  var ReglRendererService = (_dec = injectable(), _dec(_class = /*#__PURE__*/function () {
29
27
  function ReglRendererService() {
30
28
  var _this = this;
31
-
32
29
  _classCallCheck(this, ReglRendererService);
33
-
34
30
  _defineProperty(this, "createModel", function (options) {
35
31
  return new ReglModel(_this.gl, options);
36
32
  });
37
-
38
33
  _defineProperty(this, "createAttribute", function (options) {
39
34
  return new ReglAttribute(_this.gl, options);
40
35
  });
41
-
42
36
  _defineProperty(this, "createBuffer", function (options) {
43
37
  return new ReglBuffer(_this.gl, options);
44
38
  });
45
-
46
39
  _defineProperty(this, "createElements", function (options) {
47
40
  return new ReglElements(_this.gl, options);
48
41
  });
49
-
50
42
  _defineProperty(this, "createTexture2D", function (options) {
51
43
  return new ReglTexture2D(_this.gl, options);
52
44
  });
53
-
54
45
  _defineProperty(this, "createFramebuffer", function (options) {
55
46
  return new ReglFramebuffer(_this.gl, options);
56
47
  });
57
-
58
48
  _defineProperty(this, "useFramebuffer", function (framebuffer, drawCommands) {
59
49
  _this.gl({
60
50
  framebuffer: framebuffer ? framebuffer.get() : null
61
51
  })(drawCommands);
62
52
  });
63
-
64
53
  _defineProperty(this, "clear", function (options) {
65
54
  var _this$gl;
66
-
67
55
  // @see https://github.com/regl-project/regl/blob/gh-pages/API.md#clear-the-draw-buffer
68
56
  var color = options.color,
69
- depth = options.depth,
70
- stencil = options.stencil,
71
- _options$framebuffer = options.framebuffer,
72
- framebuffer = _options$framebuffer === void 0 ? null : _options$framebuffer;
57
+ depth = options.depth,
58
+ stencil = options.stencil,
59
+ _options$framebuffer = options.framebuffer,
60
+ framebuffer = _options$framebuffer === void 0 ? null : _options$framebuffer;
73
61
  var reglClearOptions = {
74
62
  color: color,
75
63
  depth: depth,
@@ -78,158 +66,135 @@ var ReglRendererService = (_dec = injectable(), _dec(_class = /*#__PURE__*/funct
78
66
  reglClearOptions.framebuffer = framebuffer === null ? framebuffer : framebuffer.get();
79
67
  (_this$gl = _this.gl) === null || _this$gl === void 0 ? void 0 : _this$gl.clear(reglClearOptions);
80
68
  });
81
-
82
69
  _defineProperty(this, "viewport", function (_ref) {
83
70
  var x = _ref.x,
84
- y = _ref.y,
85
- width = _ref.width,
86
- height = _ref.height;
87
-
71
+ y = _ref.y,
72
+ width = _ref.width,
73
+ height = _ref.height;
88
74
  // use WebGL context directly
89
75
  // @see https://github.com/regl-project/regl/blob/gh-pages/API.md#unsafe-escape-hatch
90
76
  _this.gl._gl.viewport(x, y, width, height);
91
-
92
77
  _this.width = width;
93
78
  _this.height = height;
94
-
95
79
  _this.gl._refresh();
96
80
  });
97
-
98
81
  _defineProperty(this, "readPixels", function (options) {
99
82
  var framebuffer = options.framebuffer,
100
- x = options.x,
101
- y = options.y,
102
- width = options.width,
103
- height = options.height;
83
+ x = options.x,
84
+ y = options.y,
85
+ width = options.width,
86
+ height = options.height;
104
87
  var readPixelsOptions = {
105
88
  x: x,
106
89
  y: y,
107
90
  width: width,
108
91
  height: height
109
92
  };
110
-
111
93
  if (framebuffer) {
112
94
  readPixelsOptions.framebuffer = framebuffer.get();
113
95
  }
114
-
115
96
  return _this.gl.read(readPixelsOptions);
116
97
  });
117
-
118
98
  _defineProperty(this, "getViewportSize", function () {
119
99
  return {
120
100
  width: _this.gl._gl.drawingBufferWidth,
121
101
  height: _this.gl._gl.drawingBufferHeight
122
102
  };
123
103
  });
124
-
125
104
  _defineProperty(this, "getContainer", function () {
126
105
  if (isMini) {
127
106
  return _this.canvas;
128
107
  } else {
129
108
  var _this$canvas;
130
-
131
109
  return (_this$canvas = _this.canvas) === null || _this$canvas === void 0 ? void 0 : _this$canvas.parentElement;
132
110
  }
133
111
  });
134
-
135
112
  _defineProperty(this, "getCanvas", function () {
136
113
  // return this.$container?.getElementsByTagName('canvas')[0] || null;
137
114
  return _this.canvas;
138
115
  });
139
-
140
116
  _defineProperty(this, "getGLContext", function () {
141
117
  return _this.gl._gl;
142
118
  });
143
-
144
119
  _defineProperty(this, "destroy", function () {
145
120
  var _this$gl2, _this$gl2$_gl, _this$gl2$_gl$getExte;
146
-
147
121
  // this.canvas = null 清除对 webgl 实例的引用
148
122
  // @ts-ignore
149
- _this.canvas = null; // make sure release webgl context
123
+ _this.canvas = null;
150
124
 
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
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();
154
127
 
128
+ // @see https://github.com/regl-project/regl/blob/gh-pages/API.md#clean-up
129
+ _this.gl.destroy();
155
130
 
131
+ // @ts-ignore
156
132
  _this.gl = null;
157
133
  });
158
134
  }
159
-
160
135
  _createClass(ReglRendererService, [{
161
136
  key: "init",
162
137
  value: function () {
163
138
  var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(canvas, cfg, gl) {
164
139
  var _this2 = this;
165
-
166
140
  return _regeneratorRuntime.wrap(function _callee$(_context) {
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;
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;
180
147
  break;
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);
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);
209
177
  }
210
- });
178
+ // @ts-ignore
179
+ resolve(r);
180
+ }
211
181
  });
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
- }
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();
225
192
  }
226
193
  }, _callee, this);
227
194
  }));
228
-
229
195
  function init(_x, _x2, _x3) {
230
196
  return _init.apply(this, arguments);
231
197
  }
232
-
233
198
  return init;
234
199
  }()
235
200
  }, {
@@ -245,7 +210,8 @@ var ReglRendererService = (_dec = injectable(), _dec(_class = /*#__PURE__*/funct
245
210
  }
246
211
  }, {
247
212
  key: "setState",
248
- value: // TODO: 临时方法
213
+ value:
214
+ // TODO: 临时方法
249
215
  function setState() {
250
216
  this.gl({
251
217
  cull: {
@@ -264,7 +230,6 @@ var ReglRendererService = (_dec = injectable(), _dec(_class = /*#__PURE__*/funct
264
230
  },
265
231
  framebuffer: null
266
232
  });
267
-
268
233
  this.gl._refresh();
269
234
  }
270
235
  }, {
@@ -287,7 +252,6 @@ var ReglRendererService = (_dec = injectable(), _dec(_class = /*#__PURE__*/funct
287
252
  },
288
253
  framebuffer: null
289
254
  });
290
-
291
255
  this.gl._refresh();
292
256
  }
293
257
  }, {
@@ -307,7 +271,6 @@ var ReglRendererService = (_dec = injectable(), _dec(_class = /*#__PURE__*/funct
307
271
  return this.isDirty;
308
272
  }
309
273
  }]);
310
-
311
274
  return ReglRendererService;
312
275
  }()) || _class);
313
276
  export { ReglRendererService as default };
package/lib/index.js CHANGED
@@ -17,6 +17,10 @@ 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.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -47,5 +47,3 @@ 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 = {});
@@ -26,18 +26,23 @@ var import_l7_core = require("@antv/l7-core");
26
26
  var import_constants = require("./constants");
27
27
  var ReglBuffer = class {
28
28
  constructor(reGl, options) {
29
+ this.isDestroyed = false;
29
30
  const { data, usage, type } = options;
30
31
  this.buffer = reGl.buffer({
31
32
  data,
32
33
  usage: import_constants.usageMap[usage || import_l7_core.gl.STATIC_DRAW],
33
34
  type: import_constants.dataTypeMap[type || import_l7_core.gl.UNSIGNED_BYTE]
35
+ // length: 0,
34
36
  });
35
37
  }
36
38
  get() {
37
39
  return this.buffer;
38
40
  }
39
41
  destroy() {
40
- this.buffer.destroy();
42
+ if (!this.isDestroyed) {
43
+ this.buffer.destroy();
44
+ }
45
+ this.isDestroyed = true;
41
46
  }
42
47
  subData({
43
48
  data,
@@ -46,5 +51,3 @@ var ReglBuffer = class {
46
51
  this.buffer.subdata(data, offset);
47
52
  }
48
53
  };
49
- // Annotate the CommonJS export names for ESM import in node:
50
- 0 && (module.exports = {});
@@ -45,5 +45,3 @@ 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,5 +49,3 @@ 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,19 +59,29 @@ var ReglModel = class {
59
59
  frag: fs,
60
60
  uniforms: reglUniforms,
61
61
  vert: vs,
62
+ // @ts-ignore
62
63
  colorMask: reGl.prop("colorMask"),
63
64
  lineWidth: 1,
64
65
  blend: {
66
+ // @ts-ignore
65
67
  enable: reGl.prop("blend.enable"),
68
+ // @ts-ignore
66
69
  func: reGl.prop("blend.func"),
70
+ // @ts-ignore
67
71
  equation: reGl.prop("blend.equation"),
72
+ // @ts-ignore
68
73
  color: reGl.prop("blend.color")
69
74
  },
70
75
  stencil: {
76
+ // @ts-ignore
71
77
  enable: reGl.prop("stencil.enable"),
78
+ // @ts-ignore
72
79
  mask: reGl.prop("stencil.mask"),
80
+ // @ts-ignore
73
81
  func: reGl.prop("stencil.func"),
82
+ // @ts-ignore
74
83
  opFront: reGl.prop("stencil.opFront"),
84
+ // @ts-ignore
75
85
  opBack: reGl.prop("stencil.opBack")
76
86
  },
77
87
  primitive: import_constants.primitiveMap[primitive === void 0 ? import_l7_core.gl.TRIANGLES : primitive]
@@ -123,7 +133,8 @@ var ReglModel = class {
123
133
  const reglDrawProps = {};
124
134
  Object.keys(uniforms).forEach((uniformName) => {
125
135
  const type = typeof uniforms[uniformName];
126
- if (type === "boolean" || type === "number" || Array.isArray(uniforms[uniformName]) || uniforms[uniformName].BYTES_PER_ELEMENT) {
136
+ if (type === "boolean" || type === "number" || Array.isArray(uniforms[uniformName]) || // @ts-ignore
137
+ uniforms[uniformName].BYTES_PER_ELEMENT) {
127
138
  reglDrawProps[uniformName] = uniforms[uniformName];
128
139
  } else {
129
140
  reglDrawProps[uniformName] = uniforms[uniformName].get();
@@ -146,6 +157,9 @@ var ReglModel = class {
146
157
  }
147
158
  this.destroyed = true;
148
159
  }
160
+ /**
161
+ * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#depth-buffer
162
+ */
149
163
  initDepthDrawParams({ depth }, drawParams) {
150
164
  if (depth) {
151
165
  drawParams.depth = {
@@ -175,6 +189,9 @@ var ReglModel = class {
175
189
  color
176
190
  };
177
191
  }
192
+ /**
193
+ * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#stencil
194
+ */
178
195
  getStencilDrawParams({
179
196
  stencil
180
197
  }) {
@@ -220,6 +237,9 @@ var ReglModel = class {
220
237
  const colorMask = (stencil == null ? void 0 : stencil.enable) && stencil.opFront && !pick ? [false, false, false, false] : [true, true, true, true];
221
238
  return colorMask;
222
239
  }
240
+ /**
241
+ * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#culling
242
+ */
223
243
  initCullDrawParams({ cull }, drawParams) {
224
244
  if (cull) {
225
245
  const { enable, face = import_l7_core.gl.BACK } = cull;
@@ -229,6 +249,11 @@ var ReglModel = class {
229
249
  };
230
250
  }
231
251
  }
252
+ /**
253
+ * 考虑结构体命名, eg:
254
+ * a: { b: 1 } -> 'a.b'
255
+ * a: [ { b: 1 } ] -> 'a[0].b'
256
+ */
232
257
  extractUniforms(uniforms) {
233
258
  const extractedUniforms = {};
234
259
  Object.keys(uniforms).forEach((uniformName) => {
@@ -242,7 +267,12 @@ var ReglModel = class {
242
267
  return extractedUniforms;
243
268
  }
244
269
  extractUniformsRecursively(uniformName, uniformValue, uniforms, prefix) {
245
- 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) {
270
+ if (uniformValue === null || typeof uniformValue === "number" || // u_A: 1
271
+ typeof uniformValue === "boolean" || // u_A: false
272
+ Array.isArray(uniformValue) && typeof uniformValue[0] === "number" || // u_A: [1, 2, 3]
273
+ (0, import_lodash.isTypedArray)(uniformValue) || // u_A: Float32Array
274
+ // @ts-ignore
275
+ uniformValue === "" || "resize" in uniformValue) {
246
276
  uniforms[`${prefix && prefix + "."}${uniformName}`] = uniformValue;
247
277
  return;
248
278
  }
@@ -250,6 +280,7 @@ var ReglModel = class {
250
280
  Object.keys(uniformValue).forEach((childName) => {
251
281
  this.extractUniformsRecursively(
252
282
  childName,
283
+ // @ts-ignore
253
284
  uniformValue[childName],
254
285
  uniforms,
255
286
  `${prefix && prefix + "."}${uniformName}`
@@ -261,6 +292,7 @@ var ReglModel = class {
261
292
  Object.keys(child).forEach((childName) => {
262
293
  this.extractUniformsRecursively(
263
294
  childName,
295
+ // @ts-ignore
264
296
  child[childName],
265
297
  uniforms,
266
298
  `${prefix && prefix + "."}${uniformName}[${idx}]`
@@ -270,5 +302,3 @@ var ReglModel = class {
270
302
  }
271
303
  }
272
304
  };
273
- // Annotate the CommonJS export names for ESM import in node:
274
- 0 && (module.exports = {});
@@ -42,5 +42,3 @@ 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 = {});