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