@antv/l7-renderer 2.17.2 → 2.17.4
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 +11 -5
- package/es/regl/ReglBuffer.js +10 -6
- package/es/regl/ReglElements.js +9 -6
- package/es/regl/ReglFramebuffer.js +12 -6
- package/es/regl/ReglModel.js +91 -73
- package/es/regl/ReglRenderbuffer.js +8 -4
- package/es/regl/ReglTexture2D.js +44 -34
- package/es/regl/constants.js +2 -0
- package/es/regl/index.js +106 -69
- package/lib/index.js +0 -4
- package/lib/regl/ReglAttribute.js +2 -0
- package/lib/regl/ReglBuffer.js +2 -1
- package/lib/regl/ReglElements.js +2 -0
- package/lib/regl/ReglFramebuffer.js +2 -0
- package/lib/regl/ReglModel.js +4 -34
- package/lib/regl/ReglRenderbuffer.js +2 -0
- package/lib/regl/ReglTexture2D.js +2 -3
- package/lib/regl/index.js +2 -10
- package/package.json +5 -5
package/es/regl/ReglAttribute.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#attributes
|
|
5
6
|
*/
|
|
6
7
|
var ReglAttribute = /*#__PURE__*/function () {
|
|
7
8
|
function ReglAttribute(gl, options) {
|
|
8
9
|
_classCallCheck(this, ReglAttribute);
|
|
10
|
+
|
|
9
11
|
var buffer = options.buffer,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
offset = options.offset,
|
|
13
|
+
stride = options.stride,
|
|
14
|
+
normalized = options.normalized,
|
|
15
|
+
size = options.size,
|
|
16
|
+
divisor = options.divisor;
|
|
15
17
|
this.buffer = buffer;
|
|
16
18
|
this.attribute = {
|
|
17
19
|
buffer: buffer.get(),
|
|
@@ -20,10 +22,12 @@ var ReglAttribute = /*#__PURE__*/function () {
|
|
|
20
22
|
normalized: normalized || false,
|
|
21
23
|
divisor: divisor || 0
|
|
22
24
|
};
|
|
25
|
+
|
|
23
26
|
if (size) {
|
|
24
27
|
this.attribute.size = size;
|
|
25
28
|
}
|
|
26
29
|
}
|
|
30
|
+
|
|
27
31
|
_createClass(ReglAttribute, [{
|
|
28
32
|
key: "get",
|
|
29
33
|
value: function get() {
|
|
@@ -40,6 +44,8 @@ var ReglAttribute = /*#__PURE__*/function () {
|
|
|
40
44
|
this.buffer.destroy();
|
|
41
45
|
}
|
|
42
46
|
}]);
|
|
47
|
+
|
|
43
48
|
return ReglAttribute;
|
|
44
49
|
}();
|
|
50
|
+
|
|
45
51
|
export { ReglAttribute as default };
|
package/es/regl/ReglBuffer.js
CHANGED
|
@@ -2,24 +2,26 @@ 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
|
-
|
|
6
5
|
/**
|
|
7
6
|
* adaptor for regl.Buffer
|
|
8
7
|
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#buffers
|
|
9
8
|
*/
|
|
9
|
+
|
|
10
10
|
var ReglBuffer = /*#__PURE__*/function () {
|
|
11
11
|
function ReglBuffer(reGl, options) {
|
|
12
12
|
_classCallCheck(this, ReglBuffer);
|
|
13
|
+
|
|
13
14
|
var data = options.data,
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
usage = options.usage,
|
|
16
|
+
type = options.type;
|
|
16
17
|
this.buffer = reGl.buffer({
|
|
17
18
|
data: data,
|
|
18
19
|
usage: usageMap[usage || gl.STATIC_DRAW],
|
|
19
|
-
type: dataTypeMap[type || gl.UNSIGNED_BYTE]
|
|
20
|
-
|
|
20
|
+
type: dataTypeMap[type || gl.UNSIGNED_BYTE] // length: 0,
|
|
21
|
+
|
|
21
22
|
});
|
|
22
23
|
}
|
|
24
|
+
|
|
23
25
|
_createClass(ReglBuffer, [{
|
|
24
26
|
key: "get",
|
|
25
27
|
value: function get() {
|
|
@@ -34,10 +36,12 @@ var ReglBuffer = /*#__PURE__*/function () {
|
|
|
34
36
|
key: "subData",
|
|
35
37
|
value: function subData(_ref) {
|
|
36
38
|
var data = _ref.data,
|
|
37
|
-
|
|
39
|
+
offset = _ref.offset;
|
|
38
40
|
this.buffer.subdata(data, offset);
|
|
39
41
|
}
|
|
40
42
|
}]);
|
|
43
|
+
|
|
41
44
|
return ReglBuffer;
|
|
42
45
|
}();
|
|
46
|
+
|
|
43
47
|
export { ReglBuffer as default };
|
package/es/regl/ReglElements.js
CHANGED
|
@@ -2,17 +2,18 @@ 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
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#elements
|
|
8
7
|
*/
|
|
8
|
+
|
|
9
9
|
var ReglElements = /*#__PURE__*/function () {
|
|
10
10
|
function ReglElements(reGl, options) {
|
|
11
11
|
_classCallCheck(this, ReglElements);
|
|
12
|
+
|
|
12
13
|
var data = options.data,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
usage = options.usage,
|
|
15
|
+
type = options.type,
|
|
16
|
+
count = options.count;
|
|
16
17
|
this.elements = reGl.elements({
|
|
17
18
|
data: data,
|
|
18
19
|
usage: usageMap[usage || gl.STATIC_DRAW],
|
|
@@ -20,6 +21,7 @@ var ReglElements = /*#__PURE__*/function () {
|
|
|
20
21
|
count: count
|
|
21
22
|
});
|
|
22
23
|
}
|
|
24
|
+
|
|
23
25
|
_createClass(ReglElements, [{
|
|
24
26
|
key: "get",
|
|
25
27
|
value: function get() {
|
|
@@ -33,10 +35,11 @@ var ReglElements = /*#__PURE__*/function () {
|
|
|
33
35
|
}
|
|
34
36
|
}, {
|
|
35
37
|
key: "destroy",
|
|
36
|
-
value: function destroy() {
|
|
37
|
-
// this.elements.destroy();
|
|
38
|
+
value: function destroy() {// this.elements.destroy();
|
|
38
39
|
}
|
|
39
40
|
}]);
|
|
41
|
+
|
|
40
42
|
return ReglElements;
|
|
41
43
|
}();
|
|
44
|
+
|
|
42
45
|
export { ReglElements as default };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* adaptor for regl.Framebuffer
|
|
5
6
|
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#framebuffers
|
|
@@ -7,27 +8,30 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
7
8
|
var ReglFramebuffer = /*#__PURE__*/function () {
|
|
8
9
|
function ReglFramebuffer(reGl, options) {
|
|
9
10
|
_classCallCheck(this, ReglFramebuffer);
|
|
11
|
+
|
|
10
12
|
var width = options.width,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
height = options.height,
|
|
14
|
+
color = options.color,
|
|
15
|
+
colors = options.colors;
|
|
14
16
|
var framebufferOptions = {
|
|
15
17
|
width: width,
|
|
16
18
|
height: height
|
|
17
19
|
};
|
|
20
|
+
|
|
18
21
|
if (Array.isArray(colors)) {
|
|
19
22
|
framebufferOptions.colors = colors.map(function (c) {
|
|
20
23
|
return c.get();
|
|
21
24
|
});
|
|
22
25
|
}
|
|
26
|
+
|
|
23
27
|
if (color && typeof color !== 'boolean') {
|
|
24
28
|
framebufferOptions.color = color.get();
|
|
25
|
-
}
|
|
29
|
+
} // TODO: depth & stencil
|
|
26
30
|
|
|
27
|
-
// TODO: depth & stencil
|
|
28
31
|
|
|
29
32
|
this.framebuffer = reGl.framebuffer(framebufferOptions);
|
|
30
33
|
}
|
|
34
|
+
|
|
31
35
|
_createClass(ReglFramebuffer, [{
|
|
32
36
|
key: "get",
|
|
33
37
|
value: function get() {
|
|
@@ -42,10 +46,12 @@ var ReglFramebuffer = /*#__PURE__*/function () {
|
|
|
42
46
|
key: "resize",
|
|
43
47
|
value: function resize(_ref) {
|
|
44
48
|
var width = _ref.width,
|
|
45
|
-
|
|
49
|
+
height = _ref.height;
|
|
46
50
|
this.framebuffer.resize(width, height);
|
|
47
51
|
}
|
|
48
52
|
}]);
|
|
53
|
+
|
|
49
54
|
return ReglFramebuffer;
|
|
50
55
|
}();
|
|
56
|
+
|
|
51
57
|
export { ReglFramebuffer as default };
|
package/es/regl/ReglModel.js
CHANGED
|
@@ -6,27 +6,32 @@ 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
|
+
|
|
9
10
|
/**
|
|
10
11
|
* adaptor for regl.DrawCommand
|
|
11
12
|
*/
|
|
12
13
|
var ReglModel = /*#__PURE__*/function () {
|
|
13
14
|
function ReglModel(reGl, options) {
|
|
14
15
|
_classCallCheck(this, ReglModel);
|
|
16
|
+
|
|
15
17
|
_defineProperty(this, "destroyed", false);
|
|
18
|
+
|
|
16
19
|
_defineProperty(this, "uniforms", {});
|
|
20
|
+
|
|
17
21
|
this.reGl = reGl;
|
|
18
22
|
var vs = options.vs,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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;
|
|
28
32
|
var reglUniforms = {};
|
|
29
33
|
this.options = options;
|
|
34
|
+
|
|
30
35
|
if (uniforms) {
|
|
31
36
|
this.uniforms = this.extractUniforms(uniforms);
|
|
32
37
|
Object.keys(uniforms).forEach(function (uniformName) {
|
|
@@ -35,6 +40,7 @@ var ReglModel = /*#__PURE__*/function () {
|
|
|
35
40
|
reglUniforms[uniformName] = reGl.prop(uniformName);
|
|
36
41
|
});
|
|
37
42
|
}
|
|
43
|
+
|
|
38
44
|
var reglAttributes = {};
|
|
39
45
|
Object.keys(attributes).forEach(function (name) {
|
|
40
46
|
reglAttributes[name] = attributes[name].get();
|
|
@@ -71,29 +77,32 @@ var ReglModel = /*#__PURE__*/function () {
|
|
|
71
77
|
},
|
|
72
78
|
primitive: primitiveMap[primitive === undefined ? gl.TRIANGLES : primitive]
|
|
73
79
|
};
|
|
80
|
+
|
|
74
81
|
if (instances) {
|
|
75
82
|
drawParams.instances = instances;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Tip:
|
|
83
|
+
} // Tip:
|
|
79
84
|
// elements 中可能包含 count,此时不应传入
|
|
80
85
|
// count 和 elements 相比、count 优先
|
|
86
|
+
|
|
87
|
+
|
|
81
88
|
if (count) {
|
|
82
89
|
drawParams.count = count;
|
|
83
90
|
} else if (elements) {
|
|
84
91
|
drawParams.elements = elements.get();
|
|
85
92
|
}
|
|
93
|
+
|
|
86
94
|
this.initDepthDrawParams({
|
|
87
95
|
depth: depth
|
|
88
|
-
}, drawParams);
|
|
89
|
-
// this.initBlendDrawParams({ blend }, drawParams);
|
|
96
|
+
}, drawParams); // this.initBlendDrawParams({ blend }, drawParams);
|
|
90
97
|
// this.initStencilDrawParams({ stencil }, drawParams);
|
|
98
|
+
|
|
91
99
|
this.initCullDrawParams({
|
|
92
100
|
cull: cull
|
|
93
101
|
}, drawParams);
|
|
94
102
|
this.drawCommand = reGl(drawParams);
|
|
95
103
|
this.drawParams = drawParams;
|
|
96
104
|
}
|
|
105
|
+
|
|
97
106
|
_createClass(ReglModel, [{
|
|
98
107
|
key: "updateAttributesAndElements",
|
|
99
108
|
value: function updateAttributesAndElements(attributes, elements) {
|
|
@@ -126,58 +135,62 @@ var ReglModel = /*#__PURE__*/function () {
|
|
|
126
135
|
if (this.drawParams.attributes && Object.keys(this.drawParams.attributes).length === 0) {
|
|
127
136
|
return;
|
|
128
137
|
}
|
|
138
|
+
|
|
129
139
|
var uniforms = _objectSpread(_objectSpread({}, this.uniforms), this.extractUniforms(options.uniforms || {}));
|
|
140
|
+
|
|
130
141
|
var reglDrawProps = {};
|
|
131
142
|
Object.keys(uniforms).forEach(function (uniformName) {
|
|
132
143
|
var type = _typeof(uniforms[uniformName]);
|
|
133
|
-
|
|
134
|
-
// @ts-ignore
|
|
144
|
+
|
|
145
|
+
if (type === 'boolean' || type === 'number' || Array.isArray(uniforms[uniformName]) || // @ts-ignore
|
|
135
146
|
uniforms[uniformName].BYTES_PER_ELEMENT) {
|
|
136
147
|
reglDrawProps[uniformName] = uniforms[uniformName];
|
|
137
148
|
} else {
|
|
138
149
|
reglDrawProps[uniformName] = uniforms[uniformName].get();
|
|
139
150
|
}
|
|
140
|
-
});
|
|
141
|
-
// 更新 blend
|
|
151
|
+
}); // 更新 blend
|
|
142
152
|
// @ts-ignore
|
|
153
|
+
|
|
143
154
|
reglDrawProps.blend = pick // picking 操作不应该使用 blend
|
|
144
155
|
? this.getBlendDrawParams({
|
|
145
156
|
blend: {
|
|
146
157
|
enable: false
|
|
147
158
|
}
|
|
148
|
-
}) : this.getBlendDrawParams(options);
|
|
149
|
-
|
|
150
|
-
// 更新stentil 配置
|
|
151
|
-
// @ts-ignore
|
|
152
|
-
reglDrawProps.stencil = this.getStencilDrawParams(options);
|
|
159
|
+
}) : this.getBlendDrawParams(options); // 更新stentil 配置
|
|
153
160
|
// @ts-ignore
|
|
154
|
-
reglDrawProps.colorMask = this.getColorMaskDrawParams(options, pick);
|
|
155
161
|
|
|
156
|
-
|
|
162
|
+
reglDrawProps.stencil = this.getStencilDrawParams(options); // @ts-ignore
|
|
163
|
+
|
|
164
|
+
reglDrawProps.colorMask = this.getColorMaskDrawParams(options, pick); // 在进行拾取操作的绘制中,不应该使用叠加模式 - picking 根据拾取的颜色作为判断的输入,而叠加模式会产生新的,在 id 序列中不存在的颜色
|
|
165
|
+
|
|
157
166
|
this.drawCommand(reglDrawProps);
|
|
158
167
|
}
|
|
159
168
|
}, {
|
|
160
169
|
key: "destroy",
|
|
161
170
|
value: function destroy() {
|
|
162
171
|
var _this$drawParams, _this$drawParams$elem;
|
|
172
|
+
|
|
163
173
|
// @ts-ignore
|
|
164
174
|
(_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
|
+
|
|
165
176
|
if (this.options.attributes) {
|
|
166
177
|
Object.values(this.options.attributes).forEach(function (attr) {
|
|
167
178
|
// @ts-ignore
|
|
168
179
|
attr === null || attr === void 0 ? void 0 : attr.destroy();
|
|
169
180
|
});
|
|
170
181
|
}
|
|
182
|
+
|
|
171
183
|
this.destroyed = true;
|
|
172
184
|
}
|
|
173
|
-
|
|
174
185
|
/**
|
|
175
186
|
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#depth-buffer
|
|
176
187
|
*/
|
|
188
|
+
|
|
177
189
|
}, {
|
|
178
190
|
key: "initDepthDrawParams",
|
|
179
191
|
value: function initDepthDrawParams(_ref, drawParams) {
|
|
180
192
|
var depth = _ref.depth;
|
|
193
|
+
|
|
181
194
|
if (depth) {
|
|
182
195
|
drawParams.depth = {
|
|
183
196
|
enable: depth.enable === undefined ? true : !!depth.enable,
|
|
@@ -191,13 +204,15 @@ var ReglModel = /*#__PURE__*/function () {
|
|
|
191
204
|
key: "getBlendDrawParams",
|
|
192
205
|
value: function getBlendDrawParams(_ref2) {
|
|
193
206
|
var blend = _ref2.blend;
|
|
207
|
+
|
|
194
208
|
var _ref3 = blend || {},
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
209
|
+
enable = _ref3.enable,
|
|
210
|
+
func = _ref3.func,
|
|
211
|
+
equation = _ref3.equation,
|
|
212
|
+
_ref3$color = _ref3.color,
|
|
213
|
+
color = _ref3$color === void 0 ? [0, 0, 0, 0] : _ref3$color; // @ts-ignore
|
|
214
|
+
|
|
215
|
+
|
|
201
216
|
return {
|
|
202
217
|
enable: !!enable,
|
|
203
218
|
func: {
|
|
@@ -216,32 +231,35 @@ var ReglModel = /*#__PURE__*/function () {
|
|
|
216
231
|
/**
|
|
217
232
|
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#stencil
|
|
218
233
|
*/
|
|
234
|
+
|
|
219
235
|
}, {
|
|
220
236
|
key: "getStencilDrawParams",
|
|
221
237
|
value: function getStencilDrawParams(_ref4) {
|
|
222
238
|
var stencil = _ref4.stencil;
|
|
239
|
+
|
|
223
240
|
var _ref5 = stencil || {},
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
241
|
+
enable = _ref5.enable,
|
|
242
|
+
_ref5$mask = _ref5.mask,
|
|
243
|
+
mask = _ref5$mask === void 0 ? -1 : _ref5$mask,
|
|
244
|
+
_ref5$func = _ref5.func,
|
|
245
|
+
func = _ref5$func === void 0 ? {
|
|
246
|
+
cmp: gl.ALWAYS,
|
|
247
|
+
ref: 0,
|
|
248
|
+
mask: -1
|
|
249
|
+
} : _ref5$func,
|
|
250
|
+
_ref5$opFront = _ref5.opFront,
|
|
251
|
+
opFront = _ref5$opFront === void 0 ? {
|
|
252
|
+
fail: gl.KEEP,
|
|
253
|
+
zfail: gl.KEEP,
|
|
254
|
+
zpass: gl.KEEP
|
|
255
|
+
} : _ref5$opFront,
|
|
256
|
+
_ref5$opBack = _ref5.opBack,
|
|
257
|
+
opBack = _ref5$opBack === void 0 ? {
|
|
258
|
+
fail: gl.KEEP,
|
|
259
|
+
zfail: gl.KEEP,
|
|
260
|
+
zpass: gl.KEEP
|
|
261
|
+
} : _ref5$opBack;
|
|
262
|
+
|
|
245
263
|
return {
|
|
246
264
|
enable: !!enable,
|
|
247
265
|
mask: mask,
|
|
@@ -267,36 +285,39 @@ var ReglModel = /*#__PURE__*/function () {
|
|
|
267
285
|
// TODO: 重构相关参数
|
|
268
286
|
// 掩膜模式下,颜色通道全部关闭
|
|
269
287
|
var colorMask = stencil !== null && stencil !== void 0 && stencil.enable && stencil.opFront && !pick ? [false, false, false, false] : [true, true, true, true]; // 非掩码模式下,颜色通道全部开启
|
|
288
|
+
|
|
270
289
|
return colorMask;
|
|
271
290
|
}
|
|
272
|
-
|
|
273
291
|
/**
|
|
274
292
|
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#culling
|
|
275
293
|
*/
|
|
294
|
+
|
|
276
295
|
}, {
|
|
277
296
|
key: "initCullDrawParams",
|
|
278
297
|
value: function initCullDrawParams(_ref7, drawParams) {
|
|
279
298
|
var cull = _ref7.cull;
|
|
299
|
+
|
|
280
300
|
if (cull) {
|
|
281
301
|
var enable = cull.enable,
|
|
282
|
-
|
|
283
|
-
|
|
302
|
+
_cull$face = cull.face,
|
|
303
|
+
face = _cull$face === void 0 ? gl.BACK : _cull$face;
|
|
284
304
|
drawParams.cull = {
|
|
285
305
|
enable: !!enable,
|
|
286
306
|
face: cullFaceMap[face]
|
|
287
307
|
};
|
|
288
308
|
}
|
|
289
309
|
}
|
|
290
|
-
|
|
291
310
|
/**
|
|
292
311
|
* 考虑结构体命名, eg:
|
|
293
312
|
* a: { b: 1 } -> 'a.b'
|
|
294
313
|
* a: [ { b: 1 } ] -> 'a[0].b'
|
|
295
314
|
*/
|
|
315
|
+
|
|
296
316
|
}, {
|
|
297
317
|
key: "extractUniforms",
|
|
298
318
|
value: function extractUniforms(uniforms) {
|
|
299
319
|
var _this = this;
|
|
320
|
+
|
|
300
321
|
var extractedUniforms = {};
|
|
301
322
|
Object.keys(uniforms).forEach(function (uniformName) {
|
|
302
323
|
_this.extractUniformsRecursively(uniformName, uniforms[uniformName], extractedUniforms, '');
|
|
@@ -307,41 +328,38 @@ var ReglModel = /*#__PURE__*/function () {
|
|
|
307
328
|
key: "extractUniformsRecursively",
|
|
308
329
|
value: function extractUniformsRecursively(uniformName, uniformValue, uniforms, prefix) {
|
|
309
330
|
var _this2 = this;
|
|
310
|
-
|
|
311
|
-
// u_A: 1
|
|
312
|
-
typeof uniformValue === 'boolean' ||
|
|
313
|
-
// u_A:
|
|
314
|
-
|
|
315
|
-
// u_A: [1, 2, 3]
|
|
316
|
-
isTypedArray(uniformValue) ||
|
|
317
|
-
// u_A: Float32Array
|
|
331
|
+
|
|
332
|
+
if (uniformValue === null || typeof uniformValue === 'number' || // u_A: 1
|
|
333
|
+
typeof uniformValue === 'boolean' || // u_A: false
|
|
334
|
+
Array.isArray(uniformValue) && typeof uniformValue[0] === 'number' || // u_A: [1, 2, 3]
|
|
335
|
+
isTypedArray(uniformValue) || // u_A: Float32Array
|
|
318
336
|
// @ts-ignore
|
|
319
337
|
uniformValue === '' || 'resize' in uniformValue) {
|
|
320
338
|
uniforms["".concat(prefix && prefix + '.').concat(uniformName)] = uniformValue;
|
|
321
339
|
return;
|
|
322
|
-
}
|
|
340
|
+
} // u_Struct.a.b.c
|
|
341
|
+
|
|
323
342
|
|
|
324
|
-
// u_Struct.a.b.c
|
|
325
343
|
if (isPlainObject(uniformValue)) {
|
|
326
344
|
Object.keys(uniformValue).forEach(function (childName) {
|
|
327
|
-
_this2.extractUniformsRecursively(childName,
|
|
328
|
-
// @ts-ignore
|
|
345
|
+
_this2.extractUniformsRecursively(childName, // @ts-ignore
|
|
329
346
|
uniformValue[childName], uniforms, "".concat(prefix && prefix + '.').concat(uniformName));
|
|
330
347
|
});
|
|
331
|
-
}
|
|
348
|
+
} // u_Struct[0].a
|
|
349
|
+
|
|
332
350
|
|
|
333
|
-
// u_Struct[0].a
|
|
334
351
|
if (Array.isArray(uniformValue)) {
|
|
335
352
|
uniformValue.forEach(function (child, idx) {
|
|
336
353
|
Object.keys(child).forEach(function (childName) {
|
|
337
|
-
_this2.extractUniformsRecursively(childName,
|
|
338
|
-
// @ts-ignore
|
|
354
|
+
_this2.extractUniformsRecursively(childName, // @ts-ignore
|
|
339
355
|
child[childName], uniforms, "".concat(prefix && prefix + '.').concat(uniformName, "[").concat(idx, "]"));
|
|
340
356
|
});
|
|
341
357
|
});
|
|
342
358
|
}
|
|
343
359
|
}
|
|
344
360
|
}]);
|
|
361
|
+
|
|
345
362
|
return ReglModel;
|
|
346
363
|
}();
|
|
364
|
+
|
|
347
365
|
export { ReglModel as default };
|
|
@@ -1,23 +1,25 @@
|
|
|
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
|
-
|
|
5
4
|
/**
|
|
6
5
|
* adaptor for regl.Renderbuffer
|
|
7
6
|
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#renderbuffers
|
|
8
7
|
*/
|
|
8
|
+
|
|
9
9
|
var ReglRenderbuffer = /*#__PURE__*/function () {
|
|
10
10
|
function ReglRenderbuffer(reGl, options) {
|
|
11
11
|
_classCallCheck(this, ReglRenderbuffer);
|
|
12
|
+
|
|
12
13
|
var width = options.width,
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
height = options.height,
|
|
15
|
+
format = options.format;
|
|
15
16
|
this.renderbuffer = reGl.renderbuffer({
|
|
16
17
|
width: width,
|
|
17
18
|
height: height,
|
|
18
19
|
format: formatMap[format]
|
|
19
20
|
});
|
|
20
21
|
}
|
|
22
|
+
|
|
21
23
|
_createClass(ReglRenderbuffer, [{
|
|
22
24
|
key: "get",
|
|
23
25
|
value: function get() {
|
|
@@ -32,10 +34,12 @@ var ReglRenderbuffer = /*#__PURE__*/function () {
|
|
|
32
34
|
key: "resize",
|
|
33
35
|
value: function resize(_ref) {
|
|
34
36
|
var width = _ref.width,
|
|
35
|
-
|
|
37
|
+
height = _ref.height;
|
|
36
38
|
this.renderbuffer.resize(width, height);
|
|
37
39
|
}
|
|
38
40
|
}]);
|
|
41
|
+
|
|
39
42
|
return ReglRenderbuffer;
|
|
40
43
|
}();
|
|
44
|
+
|
|
41
45
|
export { ReglRenderbuffer as default };
|
package/es/regl/ReglTexture2D.js
CHANGED
|
@@ -3,48 +3,50 @@ 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
|
-
|
|
7
6
|
/**
|
|
8
7
|
* adaptor for regl.Buffer
|
|
9
8
|
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#buffers
|
|
10
9
|
*/
|
|
10
|
+
|
|
11
11
|
var ReglTexture2D = /*#__PURE__*/function () {
|
|
12
12
|
function ReglTexture2D(reGl, options) {
|
|
13
13
|
_classCallCheck(this, ReglTexture2D);
|
|
14
|
+
|
|
14
15
|
_defineProperty(this, "isDestroy", false);
|
|
16
|
+
|
|
15
17
|
var data = options.data,
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
18
|
+
_options$type = options.type,
|
|
19
|
+
type = _options$type === void 0 ? gl.UNSIGNED_BYTE : _options$type,
|
|
20
|
+
width = options.width,
|
|
21
|
+
height = options.height,
|
|
22
|
+
_options$flipY = options.flipY,
|
|
23
|
+
flipY = _options$flipY === void 0 ? false : _options$flipY,
|
|
24
|
+
_options$format = options.format,
|
|
25
|
+
format = _options$format === void 0 ? gl.RGBA : _options$format,
|
|
26
|
+
_options$mipmap = options.mipmap,
|
|
27
|
+
mipmap = _options$mipmap === void 0 ? false : _options$mipmap,
|
|
28
|
+
_options$wrapS = options.wrapS,
|
|
29
|
+
wrapS = _options$wrapS === void 0 ? gl.CLAMP_TO_EDGE : _options$wrapS,
|
|
30
|
+
_options$wrapT = options.wrapT,
|
|
31
|
+
wrapT = _options$wrapT === void 0 ? gl.CLAMP_TO_EDGE : _options$wrapT,
|
|
32
|
+
_options$aniso = options.aniso,
|
|
33
|
+
aniso = _options$aniso === void 0 ? 0 : _options$aniso,
|
|
34
|
+
_options$alignment = options.alignment,
|
|
35
|
+
alignment = _options$alignment === void 0 ? 1 : _options$alignment,
|
|
36
|
+
_options$premultiplyA = options.premultiplyAlpha,
|
|
37
|
+
premultiplyAlpha = _options$premultiplyA === void 0 ? false : _options$premultiplyA,
|
|
38
|
+
_options$mag = options.mag,
|
|
39
|
+
mag = _options$mag === void 0 ? gl.NEAREST : _options$mag,
|
|
40
|
+
_options$min = options.min,
|
|
41
|
+
min = _options$min === void 0 ? gl.NEAREST : _options$min,
|
|
42
|
+
_options$colorSpace = options.colorSpace,
|
|
43
|
+
colorSpace = _options$colorSpace === void 0 ? gl.BROWSER_DEFAULT_WEBGL : _options$colorSpace,
|
|
44
|
+
_options$x = options.x,
|
|
45
|
+
x = _options$x === void 0 ? 0 : _options$x,
|
|
46
|
+
_options$y = options.y,
|
|
47
|
+
y = _options$y === void 0 ? 0 : _options$y,
|
|
48
|
+
_options$copy = options.copy,
|
|
49
|
+
copy = _options$copy === void 0 ? false : _options$copy;
|
|
48
50
|
this.width = width;
|
|
49
51
|
this.height = height;
|
|
50
52
|
var textureOptions = {
|
|
@@ -68,17 +70,21 @@ var ReglTexture2D = /*#__PURE__*/function () {
|
|
|
68
70
|
y: y,
|
|
69
71
|
copy: copy
|
|
70
72
|
};
|
|
73
|
+
|
|
71
74
|
if (data) {
|
|
72
75
|
// @ts-ignore
|
|
73
76
|
textureOptions.data = data;
|
|
74
77
|
}
|
|
78
|
+
|
|
75
79
|
if (typeof mipmap === 'number') {
|
|
76
80
|
textureOptions.mipmap = mipmapMap[mipmap];
|
|
77
81
|
} else if (typeof mipmap === 'boolean') {
|
|
78
82
|
textureOptions.mipmap = mipmap;
|
|
79
83
|
}
|
|
84
|
+
|
|
80
85
|
this.texture = reGl.texture(textureOptions);
|
|
81
86
|
}
|
|
87
|
+
|
|
82
88
|
_createClass(ReglTexture2D, [{
|
|
83
89
|
key: "get",
|
|
84
90
|
value: function get() {
|
|
@@ -100,7 +106,7 @@ var ReglTexture2D = /*#__PURE__*/function () {
|
|
|
100
106
|
key: "resize",
|
|
101
107
|
value: function resize(_ref) {
|
|
102
108
|
var width = _ref.width,
|
|
103
|
-
|
|
109
|
+
height = _ref.height;
|
|
104
110
|
this.texture.resize(width, height);
|
|
105
111
|
this.width = width;
|
|
106
112
|
this.height = height;
|
|
@@ -115,11 +121,15 @@ var ReglTexture2D = /*#__PURE__*/function () {
|
|
|
115
121
|
value: function destroy() {
|
|
116
122
|
if (!this.isDestroy) {
|
|
117
123
|
var _this$texture;
|
|
124
|
+
|
|
118
125
|
(_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
|
|
119
126
|
}
|
|
127
|
+
|
|
120
128
|
this.isDestroy = true;
|
|
121
129
|
}
|
|
122
130
|
}]);
|
|
131
|
+
|
|
123
132
|
return ReglTexture2D;
|
|
124
133
|
}();
|
|
134
|
+
|
|
125
135
|
export { ReglTexture2D as default };
|
package/es/regl/constants.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
|
|
2
3
|
var _primitiveMap, _usageMap, _dataTypeMap, _formatMap, _mipmapMap, _filterMap, _wrapModeMap, _colorSpaceMap, _depthFuncMap, _blendEquationMap, _blendFuncMap, _stencilFuncMap, _stencilOpMap, _cullFaceMap;
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* @desc 由于 regl 使用大量字符串而非 WebGL 常量,因此需要映射
|
|
5
7
|
*/
|
package/es/regl/index.js
CHANGED
|
@@ -2,13 +2,15 @@ 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
|
+
|
|
5
6
|
var _dec, _class;
|
|
7
|
+
|
|
6
8
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
9
|
+
|
|
7
10
|
/**
|
|
8
11
|
* render w/ regl
|
|
9
12
|
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md
|
|
10
13
|
*/
|
|
11
|
-
|
|
12
14
|
import { isMini } from '@antv/l7-utils';
|
|
13
15
|
import { injectable } from 'inversify';
|
|
14
16
|
import regl from 'l7regl';
|
|
@@ -19,45 +21,55 @@ import ReglElements from "./ReglElements";
|
|
|
19
21
|
import ReglFramebuffer from "./ReglFramebuffer";
|
|
20
22
|
import ReglModel from "./ReglModel";
|
|
21
23
|
import ReglTexture2D from "./ReglTexture2D";
|
|
22
|
-
|
|
23
24
|
/**
|
|
24
25
|
* regl renderer
|
|
25
26
|
*/
|
|
27
|
+
|
|
26
28
|
var ReglRendererService = (_dec = injectable(), _dec(_class = /*#__PURE__*/function () {
|
|
27
29
|
function ReglRendererService() {
|
|
28
30
|
var _this = this;
|
|
31
|
+
|
|
29
32
|
_classCallCheck(this, ReglRendererService);
|
|
33
|
+
|
|
30
34
|
_defineProperty(this, "createModel", function (options) {
|
|
31
35
|
return new ReglModel(_this.gl, options);
|
|
32
36
|
});
|
|
37
|
+
|
|
33
38
|
_defineProperty(this, "createAttribute", function (options) {
|
|
34
39
|
return new ReglAttribute(_this.gl, options);
|
|
35
40
|
});
|
|
41
|
+
|
|
36
42
|
_defineProperty(this, "createBuffer", function (options) {
|
|
37
43
|
return new ReglBuffer(_this.gl, options);
|
|
38
44
|
});
|
|
45
|
+
|
|
39
46
|
_defineProperty(this, "createElements", function (options) {
|
|
40
47
|
return new ReglElements(_this.gl, options);
|
|
41
48
|
});
|
|
49
|
+
|
|
42
50
|
_defineProperty(this, "createTexture2D", function (options) {
|
|
43
51
|
return new ReglTexture2D(_this.gl, options);
|
|
44
52
|
});
|
|
53
|
+
|
|
45
54
|
_defineProperty(this, "createFramebuffer", function (options) {
|
|
46
55
|
return new ReglFramebuffer(_this.gl, options);
|
|
47
56
|
});
|
|
57
|
+
|
|
48
58
|
_defineProperty(this, "useFramebuffer", function (framebuffer, drawCommands) {
|
|
49
59
|
_this.gl({
|
|
50
60
|
framebuffer: framebuffer ? framebuffer.get() : null
|
|
51
61
|
})(drawCommands);
|
|
52
62
|
});
|
|
63
|
+
|
|
53
64
|
_defineProperty(this, "clear", function (options) {
|
|
54
65
|
var _this$gl;
|
|
66
|
+
|
|
55
67
|
// @see https://github.com/regl-project/regl/blob/gh-pages/API.md#clear-the-draw-buffer
|
|
56
68
|
var color = options.color,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
depth = options.depth,
|
|
70
|
+
stencil = options.stencil,
|
|
71
|
+
_options$framebuffer = options.framebuffer,
|
|
72
|
+
framebuffer = _options$framebuffer === void 0 ? null : _options$framebuffer;
|
|
61
73
|
var reglClearOptions = {
|
|
62
74
|
color: color,
|
|
63
75
|
depth: depth,
|
|
@@ -66,135 +78,158 @@ var ReglRendererService = (_dec = injectable(), _dec(_class = /*#__PURE__*/funct
|
|
|
66
78
|
reglClearOptions.framebuffer = framebuffer === null ? framebuffer : framebuffer.get();
|
|
67
79
|
(_this$gl = _this.gl) === null || _this$gl === void 0 ? void 0 : _this$gl.clear(reglClearOptions);
|
|
68
80
|
});
|
|
81
|
+
|
|
69
82
|
_defineProperty(this, "viewport", function (_ref) {
|
|
70
83
|
var x = _ref.x,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
84
|
+
y = _ref.y,
|
|
85
|
+
width = _ref.width,
|
|
86
|
+
height = _ref.height;
|
|
87
|
+
|
|
74
88
|
// use WebGL context directly
|
|
75
89
|
// @see https://github.com/regl-project/regl/blob/gh-pages/API.md#unsafe-escape-hatch
|
|
76
90
|
_this.gl._gl.viewport(x, y, width, height);
|
|
91
|
+
|
|
77
92
|
_this.width = width;
|
|
78
93
|
_this.height = height;
|
|
94
|
+
|
|
79
95
|
_this.gl._refresh();
|
|
80
96
|
});
|
|
97
|
+
|
|
81
98
|
_defineProperty(this, "readPixels", function (options) {
|
|
82
99
|
var framebuffer = options.framebuffer,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
100
|
+
x = options.x,
|
|
101
|
+
y = options.y,
|
|
102
|
+
width = options.width,
|
|
103
|
+
height = options.height;
|
|
87
104
|
var readPixelsOptions = {
|
|
88
105
|
x: x,
|
|
89
106
|
y: y,
|
|
90
107
|
width: width,
|
|
91
108
|
height: height
|
|
92
109
|
};
|
|
110
|
+
|
|
93
111
|
if (framebuffer) {
|
|
94
112
|
readPixelsOptions.framebuffer = framebuffer.get();
|
|
95
113
|
}
|
|
114
|
+
|
|
96
115
|
return _this.gl.read(readPixelsOptions);
|
|
97
116
|
});
|
|
117
|
+
|
|
98
118
|
_defineProperty(this, "getViewportSize", function () {
|
|
99
119
|
return {
|
|
100
120
|
width: _this.gl._gl.drawingBufferWidth,
|
|
101
121
|
height: _this.gl._gl.drawingBufferHeight
|
|
102
122
|
};
|
|
103
123
|
});
|
|
124
|
+
|
|
104
125
|
_defineProperty(this, "getContainer", function () {
|
|
105
126
|
if (isMini) {
|
|
106
127
|
return _this.canvas;
|
|
107
128
|
} else {
|
|
108
129
|
var _this$canvas;
|
|
130
|
+
|
|
109
131
|
return (_this$canvas = _this.canvas) === null || _this$canvas === void 0 ? void 0 : _this$canvas.parentElement;
|
|
110
132
|
}
|
|
111
133
|
});
|
|
134
|
+
|
|
112
135
|
_defineProperty(this, "getCanvas", function () {
|
|
113
136
|
// return this.$container?.getElementsByTagName('canvas')[0] || null;
|
|
114
137
|
return _this.canvas;
|
|
115
138
|
});
|
|
139
|
+
|
|
116
140
|
_defineProperty(this, "getGLContext", function () {
|
|
117
141
|
return _this.gl._gl;
|
|
118
142
|
});
|
|
143
|
+
|
|
119
144
|
_defineProperty(this, "destroy", function () {
|
|
120
145
|
var _this$gl2, _this$gl2$_gl, _this$gl2$_gl$getExte;
|
|
146
|
+
|
|
121
147
|
// this.canvas = null 清除对 webgl 实例的引用
|
|
122
148
|
// @ts-ignore
|
|
123
|
-
_this.canvas = null;
|
|
149
|
+
_this.canvas = null; // make sure release webgl context
|
|
124
150
|
|
|
125
|
-
|
|
126
|
-
|
|
151
|
+
(_this$gl2 = _this.gl) === null || _this$gl2 === void 0 ? void 0 : (_this$gl2$_gl = _this$gl2._gl) === null || _this$gl2$_gl === void 0 ? void 0 : (_this$gl2$_gl$getExte = _this$gl2$_gl.getExtension('WEBGL_lose_context')) === null || _this$gl2$_gl$getExte === void 0 ? void 0 : _this$gl2$_gl$getExte.loseContext(); // @see https://github.com/regl-project/regl/blob/gh-pages/API.md#clean-up
|
|
152
|
+
|
|
153
|
+
_this.gl.destroy(); // @ts-ignore
|
|
127
154
|
|
|
128
|
-
// @see https://github.com/regl-project/regl/blob/gh-pages/API.md#clean-up
|
|
129
|
-
_this.gl.destroy();
|
|
130
155
|
|
|
131
|
-
// @ts-ignore
|
|
132
156
|
_this.gl = null;
|
|
133
157
|
});
|
|
134
158
|
}
|
|
159
|
+
|
|
135
160
|
_createClass(ReglRendererService, [{
|
|
136
161
|
key: "init",
|
|
137
162
|
value: function () {
|
|
138
163
|
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(canvas, cfg, gl) {
|
|
139
164
|
var _this2 = this;
|
|
165
|
+
|
|
140
166
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
141
|
-
while (1)
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
167
|
+
while (1) {
|
|
168
|
+
switch (_context.prev = _context.next) {
|
|
169
|
+
case 0:
|
|
170
|
+
// this.$container = $container;
|
|
171
|
+
this.canvas = canvas;
|
|
172
|
+
|
|
173
|
+
if (!gl) {
|
|
174
|
+
_context.next = 5;
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
this.gl = gl;
|
|
179
|
+
_context.next = 8;
|
|
147
180
|
break;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
reject(err);
|
|
181
|
+
|
|
182
|
+
case 5:
|
|
183
|
+
_context.next = 7;
|
|
184
|
+
return new Promise(function (resolve, reject) {
|
|
185
|
+
regl({
|
|
186
|
+
canvas: _this2.canvas,
|
|
187
|
+
attributes: {
|
|
188
|
+
alpha: true,
|
|
189
|
+
// use TAA instead of MSAA
|
|
190
|
+
// @see https://www.khronos.org/registry/webgl/specs/1.0/#5.2.1
|
|
191
|
+
antialias: cfg.antialias,
|
|
192
|
+
premultipliedAlpha: true,
|
|
193
|
+
preserveDrawingBuffer: cfg.preserveDrawingBuffer,
|
|
194
|
+
stencil: cfg.stencil
|
|
195
|
+
},
|
|
196
|
+
// TODO: use extensions
|
|
197
|
+
extensions: ['OES_element_index_uint', 'OES_standard_derivatives', // wireframe
|
|
198
|
+
'ANGLE_instanced_arrays' // VSM shadow map
|
|
199
|
+
],
|
|
200
|
+
optionalExtensions: ['oes_texture_float_linear', 'OES_texture_float', 'EXT_texture_filter_anisotropic', 'EXT_blend_minmax', 'WEBGL_depth_texture', 'WEBGL_lose_context'],
|
|
201
|
+
profile: true,
|
|
202
|
+
onDone: function onDone(err, r) {
|
|
203
|
+
if (err || !r) {
|
|
204
|
+
reject(err);
|
|
205
|
+
} // @ts-ignore
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
resolve(r);
|
|
177
209
|
}
|
|
178
|
-
|
|
179
|
-
resolve(r);
|
|
180
|
-
}
|
|
210
|
+
});
|
|
181
211
|
});
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
212
|
+
|
|
213
|
+
case 7:
|
|
214
|
+
this.gl = _context.sent;
|
|
215
|
+
|
|
216
|
+
case 8:
|
|
217
|
+
this.extensionObject = {
|
|
218
|
+
OES_texture_float: this.testExtension('OES_texture_float')
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
case 9:
|
|
222
|
+
case "end":
|
|
223
|
+
return _context.stop();
|
|
224
|
+
}
|
|
192
225
|
}
|
|
193
226
|
}, _callee, this);
|
|
194
227
|
}));
|
|
228
|
+
|
|
195
229
|
function init(_x, _x2, _x3) {
|
|
196
230
|
return _init.apply(this, arguments);
|
|
197
231
|
}
|
|
232
|
+
|
|
198
233
|
return init;
|
|
199
234
|
}()
|
|
200
235
|
}, {
|
|
@@ -210,8 +245,7 @@ var ReglRendererService = (_dec = injectable(), _dec(_class = /*#__PURE__*/funct
|
|
|
210
245
|
}
|
|
211
246
|
}, {
|
|
212
247
|
key: "setState",
|
|
213
|
-
value:
|
|
214
|
-
// TODO: 临时方法
|
|
248
|
+
value: // TODO: 临时方法
|
|
215
249
|
function setState() {
|
|
216
250
|
this.gl({
|
|
217
251
|
cull: {
|
|
@@ -230,6 +264,7 @@ var ReglRendererService = (_dec = injectable(), _dec(_class = /*#__PURE__*/funct
|
|
|
230
264
|
},
|
|
231
265
|
framebuffer: null
|
|
232
266
|
});
|
|
267
|
+
|
|
233
268
|
this.gl._refresh();
|
|
234
269
|
}
|
|
235
270
|
}, {
|
|
@@ -252,6 +287,7 @@ var ReglRendererService = (_dec = injectable(), _dec(_class = /*#__PURE__*/funct
|
|
|
252
287
|
},
|
|
253
288
|
framebuffer: null
|
|
254
289
|
});
|
|
290
|
+
|
|
255
291
|
this.gl._refresh();
|
|
256
292
|
}
|
|
257
293
|
}, {
|
|
@@ -271,6 +307,7 @@ var ReglRendererService = (_dec = injectable(), _dec(_class = /*#__PURE__*/funct
|
|
|
271
307
|
return this.isDirty;
|
|
272
308
|
}
|
|
273
309
|
}]);
|
|
310
|
+
|
|
274
311
|
return ReglRendererService;
|
|
275
312
|
}()) || _class);
|
|
276
313
|
export { ReglRendererService as default };
|
package/lib/index.js
CHANGED
|
@@ -17,10 +17,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
20
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
21
|
mod
|
|
26
22
|
));
|
package/lib/regl/ReglBuffer.js
CHANGED
|
@@ -31,7 +31,6 @@ var ReglBuffer = class {
|
|
|
31
31
|
data,
|
|
32
32
|
usage: import_constants.usageMap[usage || import_l7_core.gl.STATIC_DRAW],
|
|
33
33
|
type: import_constants.dataTypeMap[type || import_l7_core.gl.UNSIGNED_BYTE]
|
|
34
|
-
// length: 0,
|
|
35
34
|
});
|
|
36
35
|
}
|
|
37
36
|
get() {
|
|
@@ -47,3 +46,5 @@ var ReglBuffer = class {
|
|
|
47
46
|
this.buffer.subdata(data, offset);
|
|
48
47
|
}
|
|
49
48
|
};
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {});
|
package/lib/regl/ReglElements.js
CHANGED
package/lib/regl/ReglModel.js
CHANGED
|
@@ -59,29 +59,19 @@ var ReglModel = class {
|
|
|
59
59
|
frag: fs,
|
|
60
60
|
uniforms: reglUniforms,
|
|
61
61
|
vert: vs,
|
|
62
|
-
// @ts-ignore
|
|
63
62
|
colorMask: reGl.prop("colorMask"),
|
|
64
63
|
lineWidth: 1,
|
|
65
64
|
blend: {
|
|
66
|
-
// @ts-ignore
|
|
67
65
|
enable: reGl.prop("blend.enable"),
|
|
68
|
-
// @ts-ignore
|
|
69
66
|
func: reGl.prop("blend.func"),
|
|
70
|
-
// @ts-ignore
|
|
71
67
|
equation: reGl.prop("blend.equation"),
|
|
72
|
-
// @ts-ignore
|
|
73
68
|
color: reGl.prop("blend.color")
|
|
74
69
|
},
|
|
75
70
|
stencil: {
|
|
76
|
-
// @ts-ignore
|
|
77
71
|
enable: reGl.prop("stencil.enable"),
|
|
78
|
-
// @ts-ignore
|
|
79
72
|
mask: reGl.prop("stencil.mask"),
|
|
80
|
-
// @ts-ignore
|
|
81
73
|
func: reGl.prop("stencil.func"),
|
|
82
|
-
// @ts-ignore
|
|
83
74
|
opFront: reGl.prop("stencil.opFront"),
|
|
84
|
-
// @ts-ignore
|
|
85
75
|
opBack: reGl.prop("stencil.opBack")
|
|
86
76
|
},
|
|
87
77
|
primitive: import_constants.primitiveMap[primitive === void 0 ? import_l7_core.gl.TRIANGLES : primitive]
|
|
@@ -133,8 +123,7 @@ var ReglModel = class {
|
|
|
133
123
|
const reglDrawProps = {};
|
|
134
124
|
Object.keys(uniforms).forEach((uniformName) => {
|
|
135
125
|
const type = typeof uniforms[uniformName];
|
|
136
|
-
if (type === "boolean" || type === "number" || Array.isArray(uniforms[uniformName]) ||
|
|
137
|
-
uniforms[uniformName].BYTES_PER_ELEMENT) {
|
|
126
|
+
if (type === "boolean" || type === "number" || Array.isArray(uniforms[uniformName]) || uniforms[uniformName].BYTES_PER_ELEMENT) {
|
|
138
127
|
reglDrawProps[uniformName] = uniforms[uniformName];
|
|
139
128
|
} else {
|
|
140
129
|
reglDrawProps[uniformName] = uniforms[uniformName].get();
|
|
@@ -157,9 +146,6 @@ var ReglModel = class {
|
|
|
157
146
|
}
|
|
158
147
|
this.destroyed = true;
|
|
159
148
|
}
|
|
160
|
-
/**
|
|
161
|
-
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#depth-buffer
|
|
162
|
-
*/
|
|
163
149
|
initDepthDrawParams({ depth }, drawParams) {
|
|
164
150
|
if (depth) {
|
|
165
151
|
drawParams.depth = {
|
|
@@ -189,9 +175,6 @@ var ReglModel = class {
|
|
|
189
175
|
color
|
|
190
176
|
};
|
|
191
177
|
}
|
|
192
|
-
/**
|
|
193
|
-
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#stencil
|
|
194
|
-
*/
|
|
195
178
|
getStencilDrawParams({
|
|
196
179
|
stencil
|
|
197
180
|
}) {
|
|
@@ -237,9 +220,6 @@ var ReglModel = class {
|
|
|
237
220
|
const colorMask = (stencil == null ? void 0 : stencil.enable) && stencil.opFront && !pick ? [false, false, false, false] : [true, true, true, true];
|
|
238
221
|
return colorMask;
|
|
239
222
|
}
|
|
240
|
-
/**
|
|
241
|
-
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#culling
|
|
242
|
-
*/
|
|
243
223
|
initCullDrawParams({ cull }, drawParams) {
|
|
244
224
|
if (cull) {
|
|
245
225
|
const { enable, face = import_l7_core.gl.BACK } = cull;
|
|
@@ -249,11 +229,6 @@ var ReglModel = class {
|
|
|
249
229
|
};
|
|
250
230
|
}
|
|
251
231
|
}
|
|
252
|
-
/**
|
|
253
|
-
* 考虑结构体命名, eg:
|
|
254
|
-
* a: { b: 1 } -> 'a.b'
|
|
255
|
-
* a: [ { b: 1 } ] -> 'a[0].b'
|
|
256
|
-
*/
|
|
257
232
|
extractUniforms(uniforms) {
|
|
258
233
|
const extractedUniforms = {};
|
|
259
234
|
Object.keys(uniforms).forEach((uniformName) => {
|
|
@@ -267,12 +242,7 @@ var ReglModel = class {
|
|
|
267
242
|
return extractedUniforms;
|
|
268
243
|
}
|
|
269
244
|
extractUniformsRecursively(uniformName, uniformValue, uniforms, prefix) {
|
|
270
|
-
if (uniformValue === null || typeof uniformValue === "number" ||
|
|
271
|
-
typeof uniformValue === "boolean" || // u_A: false
|
|
272
|
-
Array.isArray(uniformValue) && typeof uniformValue[0] === "number" || // u_A: [1, 2, 3]
|
|
273
|
-
(0, import_lodash.isTypedArray)(uniformValue) || // u_A: Float32Array
|
|
274
|
-
// @ts-ignore
|
|
275
|
-
uniformValue === "" || "resize" in uniformValue) {
|
|
245
|
+
if (uniformValue === null || typeof uniformValue === "number" || typeof uniformValue === "boolean" || Array.isArray(uniformValue) && typeof uniformValue[0] === "number" || (0, import_lodash.isTypedArray)(uniformValue) || uniformValue === "" || "resize" in uniformValue) {
|
|
276
246
|
uniforms[`${prefix && prefix + "."}${uniformName}`] = uniformValue;
|
|
277
247
|
return;
|
|
278
248
|
}
|
|
@@ -280,7 +250,6 @@ var ReglModel = class {
|
|
|
280
250
|
Object.keys(uniformValue).forEach((childName) => {
|
|
281
251
|
this.extractUniformsRecursively(
|
|
282
252
|
childName,
|
|
283
|
-
// @ts-ignore
|
|
284
253
|
uniformValue[childName],
|
|
285
254
|
uniforms,
|
|
286
255
|
`${prefix && prefix + "."}${uniformName}`
|
|
@@ -292,7 +261,6 @@ var ReglModel = class {
|
|
|
292
261
|
Object.keys(child).forEach((childName) => {
|
|
293
262
|
this.extractUniformsRecursively(
|
|
294
263
|
childName,
|
|
295
|
-
// @ts-ignore
|
|
296
264
|
child[childName],
|
|
297
265
|
uniforms,
|
|
298
266
|
`${prefix && prefix + "."}${uniformName}[${idx}]`
|
|
@@ -302,3 +270,5 @@ var ReglModel = class {
|
|
|
302
270
|
}
|
|
303
271
|
}
|
|
304
272
|
};
|
|
273
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
274
|
+
0 && (module.exports = {});
|
|
@@ -52,12 +52,10 @@ var ReglTexture2D = class {
|
|
|
52
52
|
const textureOptions = {
|
|
53
53
|
width,
|
|
54
54
|
height,
|
|
55
|
-
// @ts-ignore
|
|
56
55
|
type: import_constants.dataTypeMap[type],
|
|
57
56
|
format: import_constants.formatMap[format],
|
|
58
57
|
wrapS: import_constants.wrapModeMap[wrapS],
|
|
59
58
|
wrapT: import_constants.wrapModeMap[wrapT],
|
|
60
|
-
// @ts-ignore
|
|
61
59
|
mag: import_constants.filterMap[mag],
|
|
62
60
|
min: import_constants.filterMap[min],
|
|
63
61
|
alignment,
|
|
@@ -65,7 +63,6 @@ var ReglTexture2D = class {
|
|
|
65
63
|
colorSpace: import_constants.colorSpaceMap[colorSpace],
|
|
66
64
|
premultiplyAlpha,
|
|
67
65
|
aniso,
|
|
68
|
-
// copy pixels from current bind framebuffer
|
|
69
66
|
x,
|
|
70
67
|
y,
|
|
71
68
|
copy
|
|
@@ -105,3 +102,5 @@ var ReglTexture2D = class {
|
|
|
105
102
|
this.isDestroy = true;
|
|
106
103
|
}
|
|
107
104
|
};
|
|
105
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
106
|
+
0 && (module.exports = {});
|
package/lib/regl/index.js
CHANGED
|
@@ -17,10 +17,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
20
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
21
|
mod
|
|
26
22
|
));
|
|
@@ -137,20 +133,15 @@ var ReglRendererService = class {
|
|
|
137
133
|
canvas: this.canvas,
|
|
138
134
|
attributes: {
|
|
139
135
|
alpha: true,
|
|
140
|
-
// use TAA instead of MSAA
|
|
141
|
-
// @see https://www.khronos.org/registry/webgl/specs/1.0/#5.2.1
|
|
142
136
|
antialias: cfg.antialias,
|
|
143
137
|
premultipliedAlpha: true,
|
|
144
138
|
preserveDrawingBuffer: cfg.preserveDrawingBuffer,
|
|
145
139
|
stencil: cfg.stencil
|
|
146
140
|
},
|
|
147
|
-
// TODO: use extensions
|
|
148
141
|
extensions: [
|
|
149
142
|
"OES_element_index_uint",
|
|
150
143
|
"OES_standard_derivatives",
|
|
151
|
-
// wireframe
|
|
152
144
|
"ANGLE_instanced_arrays"
|
|
153
|
-
// VSM shadow map
|
|
154
145
|
],
|
|
155
146
|
optionalExtensions: [
|
|
156
147
|
"oes_texture_float_linear",
|
|
@@ -180,7 +171,6 @@ var ReglRendererService = class {
|
|
|
180
171
|
testExtension(name) {
|
|
181
172
|
return !!this.getGLContext().getExtension(name);
|
|
182
173
|
}
|
|
183
|
-
// TODO: 临时方法
|
|
184
174
|
setState() {
|
|
185
175
|
this.gl({
|
|
186
176
|
cull: {
|
|
@@ -235,3 +225,5 @@ var ReglRendererService = class {
|
|
|
235
225
|
ReglRendererService = __decorateClass([
|
|
236
226
|
(0, import_inversify.injectable)()
|
|
237
227
|
], ReglRendererService);
|
|
228
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
229
|
+
0 && (module.exports = {});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-renderer",
|
|
3
|
-
"version": "2.17.
|
|
3
|
+
"version": "2.17.4",
|
|
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.17.
|
|
28
|
+
"@antv/l7-test-utils": "^2.17.4",
|
|
29
29
|
"gl": "^5.0.3"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@antv/l7-core": "2.17.
|
|
33
|
-
"@antv/l7-utils": "2.17.
|
|
32
|
+
"@antv/l7-core": "^2.17.4",
|
|
33
|
+
"@antv/l7-utils": "^2.17.4",
|
|
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": "f6a09dc02ed0fc7a7f5dc44b231105f43b26f67b",
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
}
|