@antv/l7-renderer 2.9.37-alpha.2 → 2.9.37-alpha.3

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