@antv/l7-renderer 2.15.2 → 2.15.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/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 +73 -91
- 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 +8 -1
- package/lib/regl/ReglBuffer.js +1 -0
- package/lib/regl/ReglFramebuffer.js +3 -1
- package/lib/regl/ReglModel.js +52 -5
- package/lib/regl/ReglTexture2D.js +3 -0
- package/lib/regl/index.js +14 -1
- 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();
|
|
@@ -76,32 +70,29 @@ var ReglModel = /*#__PURE__*/function () {
|
|
|
76
70
|
},
|
|
77
71
|
primitive: primitiveMap[primitive === undefined ? gl.TRIANGLES : primitive]
|
|
78
72
|
};
|
|
79
|
-
|
|
80
73
|
if (instances) {
|
|
81
74
|
drawParams.instances = instances;
|
|
82
|
-
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Tip:
|
|
83
78
|
// elements 中可能包含 count,此时不应传入
|
|
84
79
|
// count 和 elements 相比、count 优先
|
|
85
|
-
|
|
86
|
-
|
|
87
80
|
if (count) {
|
|
88
81
|
drawParams.count = count;
|
|
89
82
|
} else if (elements) {
|
|
90
83
|
drawParams.elements = elements.get();
|
|
91
84
|
}
|
|
92
|
-
|
|
93
85
|
this.initDepthDrawParams({
|
|
94
86
|
depth: depth
|
|
95
|
-
}, drawParams);
|
|
87
|
+
}, drawParams);
|
|
88
|
+
// this.initBlendDrawParams({ blend }, drawParams);
|
|
96
89
|
// this.initStencilDrawParams({ stencil }, drawParams);
|
|
97
|
-
|
|
98
90
|
this.initCullDrawParams({
|
|
99
91
|
cull: cull
|
|
100
92
|
}, drawParams);
|
|
101
93
|
this.drawCommand = reGl(drawParams);
|
|
102
94
|
this.drawParams = drawParams;
|
|
103
95
|
}
|
|
104
|
-
|
|
105
96
|
_createClass(ReglModel, [{
|
|
106
97
|
key: "updateAttributesAndElements",
|
|
107
98
|
value: function updateAttributesAndElements(attributes, elements) {
|
|
@@ -135,62 +126,58 @@ var ReglModel = /*#__PURE__*/function () {
|
|
|
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 };
|
package/es/regl/ReglTexture2D.js
CHANGED
|
@@ -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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
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 };
|
package/es/regl/constants.js
CHANGED
|
@@ -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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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;
|
|
123
|
+
_this.canvas = null;
|
|
150
124
|
|
|
151
|
-
|
|
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
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
this.
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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:
|
|
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
|
@@ -16,7 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
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
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
20
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
28
|
|
|
22
29
|
// src/index.ts
|
package/lib/regl/ReglBuffer.js
CHANGED
|
@@ -30,7 +30,9 @@ var ReglFramebuffer = class {
|
|
|
30
30
|
height
|
|
31
31
|
};
|
|
32
32
|
if (Array.isArray(colors)) {
|
|
33
|
-
framebufferOptions.colors = colors.map(
|
|
33
|
+
framebufferOptions.colors = colors.map(
|
|
34
|
+
(c) => c.get()
|
|
35
|
+
);
|
|
34
36
|
}
|
|
35
37
|
if (color && typeof color !== "boolean") {
|
|
36
38
|
framebufferOptions.color = color.get();
|
package/lib/regl/ReglModel.js
CHANGED
|
@@ -59,18 +59,28 @@ 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
|
blend: {
|
|
65
|
+
// @ts-ignore
|
|
64
66
|
enable: reGl.prop("blend.enable"),
|
|
67
|
+
// @ts-ignore
|
|
65
68
|
func: reGl.prop("blend.func"),
|
|
69
|
+
// @ts-ignore
|
|
66
70
|
equation: reGl.prop("blend.equation"),
|
|
71
|
+
// @ts-ignore
|
|
67
72
|
color: reGl.prop("blend.color")
|
|
68
73
|
},
|
|
69
74
|
stencil: {
|
|
75
|
+
// @ts-ignore
|
|
70
76
|
enable: reGl.prop("stencil.enable"),
|
|
77
|
+
// @ts-ignore
|
|
71
78
|
mask: reGl.prop("stencil.mask"),
|
|
79
|
+
// @ts-ignore
|
|
72
80
|
func: reGl.prop("stencil.func"),
|
|
81
|
+
// @ts-ignore
|
|
73
82
|
opFront: reGl.prop("stencil.opFront"),
|
|
83
|
+
// @ts-ignore
|
|
74
84
|
opBack: reGl.prop("stencil.opBack")
|
|
75
85
|
},
|
|
76
86
|
primitive: import_constants.primitiveMap[primitive === void 0 ? import_l7_core.gl.TRIANGLES : primitive]
|
|
@@ -122,7 +132,8 @@ var ReglModel = class {
|
|
|
122
132
|
const reglDrawProps = {};
|
|
123
133
|
Object.keys(uniforms).forEach((uniformName) => {
|
|
124
134
|
const type = typeof uniforms[uniformName];
|
|
125
|
-
if (type === "boolean" || type === "number" || Array.isArray(uniforms[uniformName]) ||
|
|
135
|
+
if (type === "boolean" || type === "number" || Array.isArray(uniforms[uniformName]) || // @ts-ignore
|
|
136
|
+
uniforms[uniformName].BYTES_PER_ELEMENT) {
|
|
126
137
|
reglDrawProps[uniformName] = uniforms[uniformName];
|
|
127
138
|
} else {
|
|
128
139
|
reglDrawProps[uniformName] = uniforms[uniformName].get();
|
|
@@ -145,6 +156,9 @@ var ReglModel = class {
|
|
|
145
156
|
}
|
|
146
157
|
this.destroyed = true;
|
|
147
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#depth-buffer
|
|
161
|
+
*/
|
|
148
162
|
initDepthDrawParams({ depth }, drawParams) {
|
|
149
163
|
if (depth) {
|
|
150
164
|
drawParams.depth = {
|
|
@@ -174,6 +188,9 @@ var ReglModel = class {
|
|
|
174
188
|
color
|
|
175
189
|
};
|
|
176
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#stencil
|
|
193
|
+
*/
|
|
177
194
|
getStencilDrawParams({
|
|
178
195
|
stencil
|
|
179
196
|
}) {
|
|
@@ -219,6 +236,9 @@ var ReglModel = class {
|
|
|
219
236
|
const colorMask = (stencil == null ? void 0 : stencil.enable) && stencil.opFront && !pick ? [false, false, false, false] : [true, true, true, true];
|
|
220
237
|
return colorMask;
|
|
221
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#culling
|
|
241
|
+
*/
|
|
222
242
|
initCullDrawParams({ cull }, drawParams) {
|
|
223
243
|
if (cull) {
|
|
224
244
|
const { enable, face = import_l7_core.gl.BACK } = cull;
|
|
@@ -228,27 +248,54 @@ var ReglModel = class {
|
|
|
228
248
|
};
|
|
229
249
|
}
|
|
230
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* 考虑结构体命名, eg:
|
|
253
|
+
* a: { b: 1 } -> 'a.b'
|
|
254
|
+
* a: [ { b: 1 } ] -> 'a[0].b'
|
|
255
|
+
*/
|
|
231
256
|
extractUniforms(uniforms) {
|
|
232
257
|
const extractedUniforms = {};
|
|
233
258
|
Object.keys(uniforms).forEach((uniformName) => {
|
|
234
|
-
this.extractUniformsRecursively(
|
|
259
|
+
this.extractUniformsRecursively(
|
|
260
|
+
uniformName,
|
|
261
|
+
uniforms[uniformName],
|
|
262
|
+
extractedUniforms,
|
|
263
|
+
""
|
|
264
|
+
);
|
|
235
265
|
});
|
|
236
266
|
return extractedUniforms;
|
|
237
267
|
}
|
|
238
268
|
extractUniformsRecursively(uniformName, uniformValue, uniforms, prefix) {
|
|
239
|
-
if (uniformValue === null || typeof uniformValue === "number" ||
|
|
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) {
|
|
240
275
|
uniforms[`${prefix && prefix + "."}${uniformName}`] = uniformValue;
|
|
241
276
|
return;
|
|
242
277
|
}
|
|
243
278
|
if ((0, import_lodash.isPlainObject)(uniformValue)) {
|
|
244
279
|
Object.keys(uniformValue).forEach((childName) => {
|
|
245
|
-
this.extractUniformsRecursively(
|
|
280
|
+
this.extractUniformsRecursively(
|
|
281
|
+
childName,
|
|
282
|
+
// @ts-ignore
|
|
283
|
+
uniformValue[childName],
|
|
284
|
+
uniforms,
|
|
285
|
+
`${prefix && prefix + "."}${uniformName}`
|
|
286
|
+
);
|
|
246
287
|
});
|
|
247
288
|
}
|
|
248
289
|
if (Array.isArray(uniformValue)) {
|
|
249
290
|
uniformValue.forEach((child, idx) => {
|
|
250
291
|
Object.keys(child).forEach((childName) => {
|
|
251
|
-
this.extractUniformsRecursively(
|
|
292
|
+
this.extractUniformsRecursively(
|
|
293
|
+
childName,
|
|
294
|
+
// @ts-ignore
|
|
295
|
+
child[childName],
|
|
296
|
+
uniforms,
|
|
297
|
+
`${prefix && prefix + "."}${uniformName}[${idx}]`
|
|
298
|
+
);
|
|
252
299
|
});
|
|
253
300
|
});
|
|
254
301
|
}
|
|
@@ -52,10 +52,12 @@ var ReglTexture2D = class {
|
|
|
52
52
|
const textureOptions = {
|
|
53
53
|
width,
|
|
54
54
|
height,
|
|
55
|
+
// @ts-ignore
|
|
55
56
|
type: import_constants.dataTypeMap[type],
|
|
56
57
|
format: import_constants.formatMap[format],
|
|
57
58
|
wrapS: import_constants.wrapModeMap[wrapS],
|
|
58
59
|
wrapT: import_constants.wrapModeMap[wrapT],
|
|
60
|
+
// @ts-ignore
|
|
59
61
|
mag: import_constants.filterMap[mag],
|
|
60
62
|
min: import_constants.filterMap[min],
|
|
61
63
|
alignment,
|
|
@@ -63,6 +65,7 @@ var ReglTexture2D = class {
|
|
|
63
65
|
colorSpace: import_constants.colorSpaceMap[colorSpace],
|
|
64
66
|
premultiplyAlpha,
|
|
65
67
|
aniso,
|
|
68
|
+
// copy pixels from current bind framebuffer
|
|
66
69
|
x,
|
|
67
70
|
y,
|
|
68
71
|
copy
|
package/lib/regl/index.js
CHANGED
|
@@ -16,7 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
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
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
20
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
28
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
22
29
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
@@ -130,15 +137,20 @@ var ReglRendererService = class {
|
|
|
130
137
|
canvas: this.canvas,
|
|
131
138
|
attributes: {
|
|
132
139
|
alpha: true,
|
|
140
|
+
// use TAA instead of MSAA
|
|
141
|
+
// @see https://www.khronos.org/registry/webgl/specs/1.0/#5.2.1
|
|
133
142
|
antialias: cfg.antialias,
|
|
134
143
|
premultipliedAlpha: true,
|
|
135
144
|
preserveDrawingBuffer: cfg.preserveDrawingBuffer,
|
|
136
145
|
stencil: cfg.stencil
|
|
137
146
|
},
|
|
147
|
+
// TODO: use extensions
|
|
138
148
|
extensions: [
|
|
139
149
|
"OES_element_index_uint",
|
|
140
150
|
"OES_standard_derivatives",
|
|
151
|
+
// wireframe
|
|
141
152
|
"ANGLE_instanced_arrays"
|
|
153
|
+
// VSM shadow map
|
|
142
154
|
],
|
|
143
155
|
optionalExtensions: [
|
|
144
156
|
"oes_texture_float_linear",
|
|
@@ -168,6 +180,7 @@ var ReglRendererService = class {
|
|
|
168
180
|
testExtension(name) {
|
|
169
181
|
return !!this.getGLContext().getExtension(name);
|
|
170
182
|
}
|
|
183
|
+
// TODO: 临时方法
|
|
171
184
|
setState() {
|
|
172
185
|
this.gl({
|
|
173
186
|
cull: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-renderer",
|
|
3
|
-
"version": "2.15.
|
|
3
|
+
"version": "2.15.3",
|
|
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.15.
|
|
28
|
+
"@antv/l7-test-utils": "2.15.3",
|
|
29
29
|
"gl": "^5.0.3"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@antv/l7-core": "2.15.
|
|
33
|
-
"@antv/l7-utils": "2.15.
|
|
32
|
+
"@antv/l7-core": "2.15.3",
|
|
33
|
+
"@antv/l7-utils": "2.15.3",
|
|
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": "
|
|
40
|
+
"gitHead": "615a788e45363d5f811d318e02e5959a1583a4cf",
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
}
|