@antv/l7-renderer 2.16.1 → 2.16.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.
- package/es/regl/ReglAttribute.js +5 -11
- package/es/regl/ReglBuffer.js +6 -10
- package/es/regl/ReglElements.js +6 -9
- package/es/regl/ReglFramebuffer.js +6 -12
- package/es/regl/ReglModel.js +74 -92
- package/es/regl/ReglRenderbuffer.js +4 -8
- package/es/regl/ReglTexture2D.js +34 -44
- package/es/regl/constants.js +0 -2
- package/es/regl/index.js +69 -106
- package/lib/index.js +4 -0
- package/lib/regl/ReglAttribute.js +0 -2
- package/lib/regl/ReglBuffer.js +1 -2
- package/lib/regl/ReglElements.js +0 -2
- package/lib/regl/ReglFramebuffer.js +0 -2
- package/lib/regl/ReglModel.js +35 -4
- package/lib/regl/ReglRenderbuffer.js +0 -2
- package/lib/regl/ReglTexture2D.js +3 -2
- package/lib/regl/index.js +10 -2
- package/package.json +5 -5
package/es/regl/ReglAttribute.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
|
|
4
3
|
/**
|
|
5
4
|
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#attributes
|
|
6
5
|
*/
|
|
7
6
|
var ReglAttribute = /*#__PURE__*/function () {
|
|
8
7
|
function ReglAttribute(gl, options) {
|
|
9
8
|
_classCallCheck(this, ReglAttribute);
|
|
10
|
-
|
|
11
9
|
var buffer = options.buffer,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
offset = options.offset,
|
|
11
|
+
stride = options.stride,
|
|
12
|
+
normalized = options.normalized,
|
|
13
|
+
size = options.size,
|
|
14
|
+
divisor = options.divisor;
|
|
17
15
|
this.buffer = buffer;
|
|
18
16
|
this.attribute = {
|
|
19
17
|
buffer: buffer.get(),
|
|
@@ -22,12 +20,10 @@ var ReglAttribute = /*#__PURE__*/function () {
|
|
|
22
20
|
normalized: normalized || false,
|
|
23
21
|
divisor: divisor || 0
|
|
24
22
|
};
|
|
25
|
-
|
|
26
23
|
if (size) {
|
|
27
24
|
this.attribute.size = size;
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
|
-
|
|
31
27
|
_createClass(ReglAttribute, [{
|
|
32
28
|
key: "get",
|
|
33
29
|
value: function get() {
|
|
@@ -44,8 +40,6 @@ var ReglAttribute = /*#__PURE__*/function () {
|
|
|
44
40
|
this.buffer.destroy();
|
|
45
41
|
}
|
|
46
42
|
}]);
|
|
47
|
-
|
|
48
43
|
return ReglAttribute;
|
|
49
44
|
}();
|
|
50
|
-
|
|
51
45
|
export { ReglAttribute as default };
|
package/es/regl/ReglBuffer.js
CHANGED
|
@@ -2,26 +2,24 @@ 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
|
+
|
|
5
6
|
/**
|
|
6
7
|
* adaptor for regl.Buffer
|
|
7
8
|
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#buffers
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
10
|
var ReglBuffer = /*#__PURE__*/function () {
|
|
11
11
|
function ReglBuffer(reGl, options) {
|
|
12
12
|
_classCallCheck(this, ReglBuffer);
|
|
13
|
-
|
|
14
13
|
var data = options.data,
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
usage = options.usage,
|
|
15
|
+
type = options.type;
|
|
17
16
|
this.buffer = reGl.buffer({
|
|
18
17
|
data: data,
|
|
19
18
|
usage: usageMap[usage || gl.STATIC_DRAW],
|
|
20
|
-
type: dataTypeMap[type || gl.UNSIGNED_BYTE]
|
|
21
|
-
|
|
19
|
+
type: dataTypeMap[type || gl.UNSIGNED_BYTE]
|
|
20
|
+
// length: 0,
|
|
22
21
|
});
|
|
23
22
|
}
|
|
24
|
-
|
|
25
23
|
_createClass(ReglBuffer, [{
|
|
26
24
|
key: "get",
|
|
27
25
|
value: function get() {
|
|
@@ -36,12 +34,10 @@ var ReglBuffer = /*#__PURE__*/function () {
|
|
|
36
34
|
key: "subData",
|
|
37
35
|
value: function subData(_ref) {
|
|
38
36
|
var data = _ref.data,
|
|
39
|
-
|
|
37
|
+
offset = _ref.offset;
|
|
40
38
|
this.buffer.subdata(data, offset);
|
|
41
39
|
}
|
|
42
40
|
}]);
|
|
43
|
-
|
|
44
41
|
return ReglBuffer;
|
|
45
42
|
}();
|
|
46
|
-
|
|
47
43
|
export { ReglBuffer as default };
|
package/es/regl/ReglElements.js
CHANGED
|
@@ -2,18 +2,17 @@ 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
|
+
|
|
5
6
|
/**
|
|
6
7
|
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#elements
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
9
|
var ReglElements = /*#__PURE__*/function () {
|
|
10
10
|
function ReglElements(reGl, options) {
|
|
11
11
|
_classCallCheck(this, ReglElements);
|
|
12
|
-
|
|
13
12
|
var data = options.data,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
usage = options.usage,
|
|
14
|
+
type = options.type,
|
|
15
|
+
count = options.count;
|
|
17
16
|
this.elements = reGl.elements({
|
|
18
17
|
data: data,
|
|
19
18
|
usage: usageMap[usage || gl.STATIC_DRAW],
|
|
@@ -21,7 +20,6 @@ var ReglElements = /*#__PURE__*/function () {
|
|
|
21
20
|
count: count
|
|
22
21
|
});
|
|
23
22
|
}
|
|
24
|
-
|
|
25
23
|
_createClass(ReglElements, [{
|
|
26
24
|
key: "get",
|
|
27
25
|
value: function get() {
|
|
@@ -35,11 +33,10 @@ var ReglElements = /*#__PURE__*/function () {
|
|
|
35
33
|
}
|
|
36
34
|
}, {
|
|
37
35
|
key: "destroy",
|
|
38
|
-
value: function destroy() {
|
|
36
|
+
value: function destroy() {
|
|
37
|
+
// this.elements.destroy();
|
|
39
38
|
}
|
|
40
39
|
}]);
|
|
41
|
-
|
|
42
40
|
return ReglElements;
|
|
43
41
|
}();
|
|
44
|
-
|
|
45
42
|
export { ReglElements as default };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
|
|
4
3
|
/**
|
|
5
4
|
* adaptor for regl.Framebuffer
|
|
6
5
|
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#framebuffers
|
|
@@ -8,30 +7,27 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
8
7
|
var ReglFramebuffer = /*#__PURE__*/function () {
|
|
9
8
|
function ReglFramebuffer(reGl, options) {
|
|
10
9
|
_classCallCheck(this, ReglFramebuffer);
|
|
11
|
-
|
|
12
10
|
var width = options.width,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
height = options.height,
|
|
12
|
+
color = options.color,
|
|
13
|
+
colors = options.colors;
|
|
16
14
|
var framebufferOptions = {
|
|
17
15
|
width: width,
|
|
18
16
|
height: height
|
|
19
17
|
};
|
|
20
|
-
|
|
21
18
|
if (Array.isArray(colors)) {
|
|
22
19
|
framebufferOptions.colors = colors.map(function (c) {
|
|
23
20
|
return c.get();
|
|
24
21
|
});
|
|
25
22
|
}
|
|
26
|
-
|
|
27
23
|
if (color && typeof color !== 'boolean') {
|
|
28
24
|
framebufferOptions.color = color.get();
|
|
29
|
-
}
|
|
25
|
+
}
|
|
30
26
|
|
|
27
|
+
// TODO: depth & stencil
|
|
31
28
|
|
|
32
29
|
this.framebuffer = reGl.framebuffer(framebufferOptions);
|
|
33
30
|
}
|
|
34
|
-
|
|
35
31
|
_createClass(ReglFramebuffer, [{
|
|
36
32
|
key: "get",
|
|
37
33
|
value: function get() {
|
|
@@ -46,12 +42,10 @@ var ReglFramebuffer = /*#__PURE__*/function () {
|
|
|
46
42
|
key: "resize",
|
|
47
43
|
value: function resize(_ref) {
|
|
48
44
|
var width = _ref.width,
|
|
49
|
-
|
|
45
|
+
height = _ref.height;
|
|
50
46
|
this.framebuffer.resize(width, height);
|
|
51
47
|
}
|
|
52
48
|
}]);
|
|
53
|
-
|
|
54
49
|
return ReglFramebuffer;
|
|
55
50
|
}();
|
|
56
|
-
|
|
57
51
|
export { ReglFramebuffer as default };
|
package/es/regl/ReglModel.js
CHANGED
|
@@ -6,32 +6,27 @@ 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
|
-
|
|
10
9
|
/**
|
|
11
10
|
* adaptor for regl.DrawCommand
|
|
12
11
|
*/
|
|
13
12
|
var ReglModel = /*#__PURE__*/function () {
|
|
14
13
|
function ReglModel(reGl, options) {
|
|
15
14
|
_classCallCheck(this, ReglModel);
|
|
16
|
-
|
|
17
15
|
_defineProperty(this, "destroyed", false);
|
|
18
|
-
|
|
19
16
|
_defineProperty(this, "uniforms", {});
|
|
20
|
-
|
|
21
17
|
this.reGl = reGl;
|
|
22
18
|
var vs = options.vs,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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;
|
|
32
28
|
var reglUniforms = {};
|
|
33
29
|
this.options = options;
|
|
34
|
-
|
|
35
30
|
if (uniforms) {
|
|
36
31
|
this.uniforms = this.extractUniforms(uniforms);
|
|
37
32
|
Object.keys(uniforms).forEach(function (uniformName) {
|
|
@@ -40,7 +35,6 @@ var ReglModel = /*#__PURE__*/function () {
|
|
|
40
35
|
reglUniforms[uniformName] = reGl.prop(uniformName);
|
|
41
36
|
});
|
|
42
37
|
}
|
|
43
|
-
|
|
44
38
|
var reglAttributes = {};
|
|
45
39
|
Object.keys(attributes).forEach(function (name) {
|
|
46
40
|
reglAttributes[name] = attributes[name].get();
|
|
@@ -52,6 +46,7 @@ var ReglModel = /*#__PURE__*/function () {
|
|
|
52
46
|
vert: vs,
|
|
53
47
|
// @ts-ignore
|
|
54
48
|
colorMask: reGl.prop('colorMask'),
|
|
49
|
+
lineWidth: 1,
|
|
55
50
|
blend: {
|
|
56
51
|
// @ts-ignore
|
|
57
52
|
enable: reGl.prop('blend.enable'),
|
|
@@ -76,32 +71,29 @@ var ReglModel = /*#__PURE__*/function () {
|
|
|
76
71
|
},
|
|
77
72
|
primitive: primitiveMap[primitive === undefined ? gl.TRIANGLES : primitive]
|
|
78
73
|
};
|
|
79
|
-
|
|
80
74
|
if (instances) {
|
|
81
75
|
drawParams.instances = instances;
|
|
82
|
-
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Tip:
|
|
83
79
|
// elements 中可能包含 count,此时不应传入
|
|
84
80
|
// count 和 elements 相比、count 优先
|
|
85
|
-
|
|
86
|
-
|
|
87
81
|
if (count) {
|
|
88
82
|
drawParams.count = count;
|
|
89
83
|
} else if (elements) {
|
|
90
84
|
drawParams.elements = elements.get();
|
|
91
85
|
}
|
|
92
|
-
|
|
93
86
|
this.initDepthDrawParams({
|
|
94
87
|
depth: depth
|
|
95
|
-
}, drawParams);
|
|
88
|
+
}, drawParams);
|
|
89
|
+
// this.initBlendDrawParams({ blend }, drawParams);
|
|
96
90
|
// this.initStencilDrawParams({ stencil }, drawParams);
|
|
97
|
-
|
|
98
91
|
this.initCullDrawParams({
|
|
99
92
|
cull: cull
|
|
100
93
|
}, drawParams);
|
|
101
94
|
this.drawCommand = reGl(drawParams);
|
|
102
95
|
this.drawParams = drawParams;
|
|
103
96
|
}
|
|
104
|
-
|
|
105
97
|
_createClass(ReglModel, [{
|
|
106
98
|
key: "updateAttributesAndElements",
|
|
107
99
|
value: function updateAttributesAndElements(attributes, elements) {
|
|
@@ -131,66 +123,61 @@ var ReglModel = /*#__PURE__*/function () {
|
|
|
131
123
|
}, {
|
|
132
124
|
key: "draw",
|
|
133
125
|
value: function draw(options, pick) {
|
|
134
|
-
// console.log('options', this.drawParams)
|
|
135
126
|
if (this.drawParams.attributes && Object.keys(this.drawParams.attributes).length === 0) {
|
|
136
127
|
return;
|
|
137
128
|
}
|
|
138
|
-
|
|
139
129
|
var uniforms = _objectSpread(_objectSpread({}, this.uniforms), this.extractUniforms(options.uniforms || {}));
|
|
140
|
-
|
|
141
130
|
var reglDrawProps = {};
|
|
142
131
|
Object.keys(uniforms).forEach(function (uniformName) {
|
|
143
132
|
var type = _typeof(uniforms[uniformName]);
|
|
144
|
-
|
|
145
|
-
|
|
133
|
+
if (type === 'boolean' || type === 'number' || Array.isArray(uniforms[uniformName]) ||
|
|
134
|
+
// @ts-ignore
|
|
146
135
|
uniforms[uniformName].BYTES_PER_ELEMENT) {
|
|
147
136
|
reglDrawProps[uniformName] = uniforms[uniformName];
|
|
148
137
|
} else {
|
|
149
138
|
reglDrawProps[uniformName] = uniforms[uniformName].get();
|
|
150
139
|
}
|
|
151
|
-
});
|
|
140
|
+
});
|
|
141
|
+
// 更新 blend
|
|
152
142
|
// @ts-ignore
|
|
153
|
-
|
|
154
143
|
reglDrawProps.blend = pick // picking 操作不应该使用 blend
|
|
155
144
|
? this.getBlendDrawParams({
|
|
156
145
|
blend: {
|
|
157
146
|
enable: false
|
|
158
147
|
}
|
|
159
|
-
}) : this.getBlendDrawParams(options);
|
|
160
|
-
// @ts-ignore
|
|
161
|
-
|
|
162
|
-
reglDrawProps.stencil = this.getStencilDrawParams(options); // @ts-ignore
|
|
148
|
+
}) : this.getBlendDrawParams(options);
|
|
163
149
|
|
|
164
|
-
|
|
150
|
+
// 更新stentil 配置
|
|
151
|
+
// @ts-ignore
|
|
152
|
+
reglDrawProps.stencil = this.getStencilDrawParams(options);
|
|
153
|
+
// @ts-ignore
|
|
154
|
+
reglDrawProps.colorMask = this.getColorMaskDrawParams(options, pick);
|
|
165
155
|
|
|
156
|
+
// 在进行拾取操作的绘制中,不应该使用叠加模式 - picking 根据拾取的颜色作为判断的输入,而叠加模式会产生新的,在 id 序列中不存在的颜色
|
|
166
157
|
this.drawCommand(reglDrawProps);
|
|
167
158
|
}
|
|
168
159
|
}, {
|
|
169
160
|
key: "destroy",
|
|
170
161
|
value: function destroy() {
|
|
171
162
|
var _this$drawParams, _this$drawParams$elem;
|
|
172
|
-
|
|
173
163
|
// @ts-ignore
|
|
174
164
|
(_this$drawParams = this.drawParams) === null || _this$drawParams === void 0 ? void 0 : (_this$drawParams$elem = _this$drawParams.elements) === null || _this$drawParams$elem === void 0 ? void 0 : _this$drawParams$elem.destroy();
|
|
175
|
-
|
|
176
165
|
if (this.options.attributes) {
|
|
177
166
|
Object.values(this.options.attributes).forEach(function (attr) {
|
|
178
167
|
// @ts-ignore
|
|
179
168
|
attr === null || attr === void 0 ? void 0 : attr.destroy();
|
|
180
169
|
});
|
|
181
170
|
}
|
|
182
|
-
|
|
183
171
|
this.destroyed = true;
|
|
184
172
|
}
|
|
173
|
+
|
|
185
174
|
/**
|
|
186
175
|
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#depth-buffer
|
|
187
176
|
*/
|
|
188
|
-
|
|
189
177
|
}, {
|
|
190
178
|
key: "initDepthDrawParams",
|
|
191
179
|
value: function initDepthDrawParams(_ref, drawParams) {
|
|
192
180
|
var depth = _ref.depth;
|
|
193
|
-
|
|
194
181
|
if (depth) {
|
|
195
182
|
drawParams.depth = {
|
|
196
183
|
enable: depth.enable === undefined ? true : !!depth.enable,
|
|
@@ -204,15 +191,13 @@ var ReglModel = /*#__PURE__*/function () {
|
|
|
204
191
|
key: "getBlendDrawParams",
|
|
205
192
|
value: function getBlendDrawParams(_ref2) {
|
|
206
193
|
var blend = _ref2.blend;
|
|
207
|
-
|
|
208
194
|
var _ref3 = blend || {},
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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
|
|
216
201
|
return {
|
|
217
202
|
enable: !!enable,
|
|
218
203
|
func: {
|
|
@@ -231,35 +216,32 @@ var ReglModel = /*#__PURE__*/function () {
|
|
|
231
216
|
/**
|
|
232
217
|
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#stencil
|
|
233
218
|
*/
|
|
234
|
-
|
|
235
219
|
}, {
|
|
236
220
|
key: "getStencilDrawParams",
|
|
237
221
|
value: function getStencilDrawParams(_ref4) {
|
|
238
222
|
var stencil = _ref4.stencil;
|
|
239
|
-
|
|
240
223
|
var _ref5 = stencil || {},
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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;
|
|
263
245
|
return {
|
|
264
246
|
enable: !!enable,
|
|
265
247
|
mask: mask,
|
|
@@ -285,39 +267,36 @@ var ReglModel = /*#__PURE__*/function () {
|
|
|
285
267
|
// TODO: 重构相关参数
|
|
286
268
|
// 掩膜模式下,颜色通道全部关闭
|
|
287
269
|
var colorMask = stencil !== null && stencil !== void 0 && stencil.enable && stencil.opFront && !pick ? [false, false, false, false] : [true, true, true, true]; // 非掩码模式下,颜色通道全部开启
|
|
288
|
-
|
|
289
270
|
return colorMask;
|
|
290
271
|
}
|
|
272
|
+
|
|
291
273
|
/**
|
|
292
274
|
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#culling
|
|
293
275
|
*/
|
|
294
|
-
|
|
295
276
|
}, {
|
|
296
277
|
key: "initCullDrawParams",
|
|
297
278
|
value: function initCullDrawParams(_ref7, drawParams) {
|
|
298
279
|
var cull = _ref7.cull;
|
|
299
|
-
|
|
300
280
|
if (cull) {
|
|
301
281
|
var enable = cull.enable,
|
|
302
|
-
|
|
303
|
-
|
|
282
|
+
_cull$face = cull.face,
|
|
283
|
+
face = _cull$face === void 0 ? gl.BACK : _cull$face;
|
|
304
284
|
drawParams.cull = {
|
|
305
285
|
enable: !!enable,
|
|
306
286
|
face: cullFaceMap[face]
|
|
307
287
|
};
|
|
308
288
|
}
|
|
309
289
|
}
|
|
290
|
+
|
|
310
291
|
/**
|
|
311
292
|
* 考虑结构体命名, eg:
|
|
312
293
|
* a: { b: 1 } -> 'a.b'
|
|
313
294
|
* a: [ { b: 1 } ] -> 'a[0].b'
|
|
314
295
|
*/
|
|
315
|
-
|
|
316
296
|
}, {
|
|
317
297
|
key: "extractUniforms",
|
|
318
298
|
value: function extractUniforms(uniforms) {
|
|
319
299
|
var _this = this;
|
|
320
|
-
|
|
321
300
|
var extractedUniforms = {};
|
|
322
301
|
Object.keys(uniforms).forEach(function (uniformName) {
|
|
323
302
|
_this.extractUniformsRecursively(uniformName, uniforms[uniformName], extractedUniforms, '');
|
|
@@ -328,38 +307,41 @@ var ReglModel = /*#__PURE__*/function () {
|
|
|
328
307
|
key: "extractUniformsRecursively",
|
|
329
308
|
value: function extractUniformsRecursively(uniformName, uniformValue, uniforms, prefix) {
|
|
330
309
|
var _this2 = this;
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
typeof uniformValue === 'boolean' ||
|
|
334
|
-
|
|
335
|
-
|
|
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
|
|
336
318
|
// @ts-ignore
|
|
337
319
|
uniformValue === '' || 'resize' in uniformValue) {
|
|
338
320
|
uniforms["".concat(prefix && prefix + '.').concat(uniformName)] = uniformValue;
|
|
339
321
|
return;
|
|
340
|
-
}
|
|
341
|
-
|
|
322
|
+
}
|
|
342
323
|
|
|
324
|
+
// u_Struct.a.b.c
|
|
343
325
|
if (isPlainObject(uniformValue)) {
|
|
344
326
|
Object.keys(uniformValue).forEach(function (childName) {
|
|
345
|
-
_this2.extractUniformsRecursively(childName,
|
|
327
|
+
_this2.extractUniformsRecursively(childName,
|
|
328
|
+
// @ts-ignore
|
|
346
329
|
uniformValue[childName], uniforms, "".concat(prefix && prefix + '.').concat(uniformName));
|
|
347
330
|
});
|
|
348
|
-
}
|
|
349
|
-
|
|
331
|
+
}
|
|
350
332
|
|
|
333
|
+
// u_Struct[0].a
|
|
351
334
|
if (Array.isArray(uniformValue)) {
|
|
352
335
|
uniformValue.forEach(function (child, idx) {
|
|
353
336
|
Object.keys(child).forEach(function (childName) {
|
|
354
|
-
_this2.extractUniformsRecursively(childName,
|
|
337
|
+
_this2.extractUniformsRecursively(childName,
|
|
338
|
+
// @ts-ignore
|
|
355
339
|
child[childName], uniforms, "".concat(prefix && prefix + '.').concat(uniformName, "[").concat(idx, "]"));
|
|
356
340
|
});
|
|
357
341
|
});
|
|
358
342
|
}
|
|
359
343
|
}
|
|
360
344
|
}]);
|
|
361
|
-
|
|
362
345
|
return ReglModel;
|
|
363
346
|
}();
|
|
364
|
-
|
|
365
347
|
export { ReglModel as default };
|
|
@@ -1,25 +1,23 @@
|
|
|
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
|
+
|
|
4
5
|
/**
|
|
5
6
|
* adaptor for regl.Renderbuffer
|
|
6
7
|
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#renderbuffers
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
9
|
var ReglRenderbuffer = /*#__PURE__*/function () {
|
|
10
10
|
function ReglRenderbuffer(reGl, options) {
|
|
11
11
|
_classCallCheck(this, ReglRenderbuffer);
|
|
12
|
-
|
|
13
12
|
var width = options.width,
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
height = options.height,
|
|
14
|
+
format = options.format;
|
|
16
15
|
this.renderbuffer = reGl.renderbuffer({
|
|
17
16
|
width: width,
|
|
18
17
|
height: height,
|
|
19
18
|
format: formatMap[format]
|
|
20
19
|
});
|
|
21
20
|
}
|
|
22
|
-
|
|
23
21
|
_createClass(ReglRenderbuffer, [{
|
|
24
22
|
key: "get",
|
|
25
23
|
value: function get() {
|
|
@@ -34,12 +32,10 @@ var ReglRenderbuffer = /*#__PURE__*/function () {
|
|
|
34
32
|
key: "resize",
|
|
35
33
|
value: function resize(_ref) {
|
|
36
34
|
var width = _ref.width,
|
|
37
|
-
|
|
35
|
+
height = _ref.height;
|
|
38
36
|
this.renderbuffer.resize(width, height);
|
|
39
37
|
}
|
|
40
38
|
}]);
|
|
41
|
-
|
|
42
39
|
return ReglRenderbuffer;
|
|
43
40
|
}();
|
|
44
|
-
|
|
45
41
|
export { ReglRenderbuffer as default };
|