@antv/l7-renderer 2.9.21 → 2.9.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/index.js +5 -3
- package/es/regl/ReglAttribute.js +5 -8
- package/es/regl/ReglBuffer.js +9 -8
- package/es/regl/ReglElements.js +8 -8
- package/es/regl/ReglFramebuffer.js +8 -7
- package/es/regl/ReglModel.js +63 -42
- package/es/regl/ReglRenderbuffer.js +7 -7
- package/es/regl/ReglTexture2D.js +12 -10
- package/es/regl/constants.js +5 -2
- package/es/regl/index.js +43 -31
- package/lib/index.js +29 -13
- package/lib/regl/ReglAttribute.js +38 -48
- package/lib/regl/ReglBuffer.js +46 -52
- package/lib/regl/ReglElements.js +45 -51
- package/lib/regl/ReglFramebuffer.js +43 -58
- package/lib/regl/ReglModel.js +217 -283
- package/lib/regl/ReglRenderbuffer.js +42 -50
- package/lib/regl/ReglTexture2D.js +90 -122
- package/lib/regl/constants.js +168 -42
- package/lib/regl/index.js +204 -272
- package/package.json +11 -8
- package/es/index.js.map +0 -1
- package/es/regl/ReglAttribute.js.map +0 -1
- package/es/regl/ReglBuffer.js.map +0 -1
- package/es/regl/ReglElements.js.map +0 -1
- package/es/regl/ReglFramebuffer.js.map +0 -1
- package/es/regl/ReglModel.js.map +0 -1
- package/es/regl/ReglRenderbuffer.js.map +0 -1
- package/es/regl/ReglTexture2D.js.map +0 -1
- package/es/regl/constants.js.map +0 -1
- package/es/regl/index.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/regl/ReglAttribute.js.map +0 -1
- package/lib/regl/ReglBuffer.js.map +0 -1
- package/lib/regl/ReglElements.js.map +0 -1
- package/lib/regl/ReglFramebuffer.js.map +0 -1
- package/lib/regl/ReglModel.js.map +0 -1
- package/lib/regl/ReglRenderbuffer.js.map +0 -1
- package/lib/regl/ReglTexture2D.js.map +0 -1
- package/lib/regl/constants.js.map +0 -1
- package/lib/regl/index.js.map +0 -1
package/es/index.js
CHANGED
package/es/regl/ReglAttribute.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#attributes
|
|
6
|
+
*/
|
|
7
|
+
var ReglAttribute = /*#__PURE__*/function () {
|
|
6
8
|
function ReglAttribute(gl, options) {
|
|
7
9
|
_classCallCheck(this, ReglAttribute);
|
|
8
10
|
|
|
9
|
-
_defineProperty(this, "attribute", void 0);
|
|
10
|
-
|
|
11
|
-
_defineProperty(this, "buffer", void 0);
|
|
12
|
-
|
|
13
11
|
var buffer = options.buffer,
|
|
14
12
|
offset = options.offset,
|
|
15
13
|
stride = options.stride,
|
|
@@ -50,5 +48,4 @@ var ReglAttribute = function () {
|
|
|
50
48
|
return ReglAttribute;
|
|
51
49
|
}();
|
|
52
50
|
|
|
53
|
-
export { ReglAttribute as default };
|
|
54
|
-
//# sourceMappingURL=ReglAttribute.js.map
|
|
51
|
+
export { ReglAttribute as default };
|
package/es/regl/ReglBuffer.js
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
3
|
import { gl } from '@antv/l7-core';
|
|
5
|
-
import { dataTypeMap, usageMap } from
|
|
4
|
+
import { dataTypeMap, usageMap } from "./constants";
|
|
5
|
+
/**
|
|
6
|
+
* adaptor for regl.Buffer
|
|
7
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#buffers
|
|
8
|
+
*/
|
|
6
9
|
|
|
7
|
-
var ReglBuffer = function () {
|
|
10
|
+
var ReglBuffer = /*#__PURE__*/function () {
|
|
8
11
|
function ReglBuffer(reGl, options) {
|
|
9
12
|
_classCallCheck(this, ReglBuffer);
|
|
10
13
|
|
|
11
|
-
_defineProperty(this, "buffer", void 0);
|
|
12
|
-
|
|
13
14
|
var data = options.data,
|
|
14
15
|
usage = options.usage,
|
|
15
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
|
+
type: dataTypeMap[type || gl.UNSIGNED_BYTE] // length: 0,
|
|
21
|
+
|
|
20
22
|
});
|
|
21
23
|
}
|
|
22
24
|
|
|
@@ -42,5 +44,4 @@ var ReglBuffer = function () {
|
|
|
42
44
|
return ReglBuffer;
|
|
43
45
|
}();
|
|
44
46
|
|
|
45
|
-
export { ReglBuffer as default };
|
|
46
|
-
//# sourceMappingURL=ReglBuffer.js.map
|
|
47
|
+
export { ReglBuffer as default };
|
package/es/regl/ReglElements.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
3
|
import { gl } from '@antv/l7-core';
|
|
5
|
-
import { dataTypeMap, usageMap } from
|
|
4
|
+
import { dataTypeMap, usageMap } from "./constants";
|
|
5
|
+
/**
|
|
6
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#elements
|
|
7
|
+
*/
|
|
6
8
|
|
|
7
|
-
var ReglElements = function () {
|
|
9
|
+
var ReglElements = /*#__PURE__*/function () {
|
|
8
10
|
function ReglElements(reGl, options) {
|
|
9
11
|
_classCallCheck(this, ReglElements);
|
|
10
12
|
|
|
11
|
-
_defineProperty(this, "elements", void 0);
|
|
12
|
-
|
|
13
13
|
var data = options.data,
|
|
14
14
|
usage = options.usage,
|
|
15
15
|
type = options.type,
|
|
@@ -35,11 +35,11 @@ var ReglElements = function () {
|
|
|
35
35
|
}
|
|
36
36
|
}, {
|
|
37
37
|
key: "destroy",
|
|
38
|
-
value: function destroy() {
|
|
38
|
+
value: function destroy() {// this.elements.destroy();
|
|
39
|
+
}
|
|
39
40
|
}]);
|
|
40
41
|
|
|
41
42
|
return ReglElements;
|
|
42
43
|
}();
|
|
43
44
|
|
|
44
|
-
export { ReglElements as default };
|
|
45
|
-
//# sourceMappingURL=ReglElements.js.map
|
|
45
|
+
export { ReglElements as default };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* adaptor for regl.Framebuffer
|
|
6
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#framebuffers
|
|
7
|
+
*/
|
|
8
|
+
var ReglFramebuffer = /*#__PURE__*/function () {
|
|
6
9
|
function ReglFramebuffer(reGl, options) {
|
|
7
10
|
_classCallCheck(this, ReglFramebuffer);
|
|
8
11
|
|
|
9
|
-
_defineProperty(this, "framebuffer", void 0);
|
|
10
|
-
|
|
11
12
|
var width = options.width,
|
|
12
13
|
height = options.height,
|
|
13
14
|
color = options.color,
|
|
@@ -27,7 +28,8 @@ var ReglFramebuffer = function () {
|
|
|
27
28
|
|
|
28
29
|
if (color && typeof color !== 'boolean') {
|
|
29
30
|
framebufferOptions.color = color.get();
|
|
30
|
-
}
|
|
31
|
+
} // TODO: depth & stencil
|
|
32
|
+
|
|
31
33
|
|
|
32
34
|
this.framebuffer = reGl.framebuffer(framebufferOptions);
|
|
33
35
|
}
|
|
@@ -54,5 +56,4 @@ var ReglFramebuffer = function () {
|
|
|
54
56
|
return ReglFramebuffer;
|
|
55
57
|
}();
|
|
56
58
|
|
|
57
|
-
export { ReglFramebuffer as default };
|
|
58
|
-
//# sourceMappingURL=ReglFramebuffer.js.map
|
|
59
|
+
export { ReglFramebuffer as default };
|
package/es/regl/ReglModel.js
CHANGED
|
@@ -1,34 +1,21 @@
|
|
|
1
1
|
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
3
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
4
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
5
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
|
-
import _isTypedArray from "lodash/isTypedArray";
|
|
6
|
-
import _isPlainObject from "lodash/isPlainObject";
|
|
7
|
-
import _cloneDeep from "lodash/cloneDeep";
|
|
8
|
-
|
|
9
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
|
-
|
|
11
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
12
|
-
|
|
13
6
|
import { gl } from '@antv/l7-core';
|
|
14
|
-
import {
|
|
7
|
+
import { cloneDeep, isPlainObject, isTypedArray } from 'lodash';
|
|
8
|
+
import { blendEquationMap, blendFuncMap, cullFaceMap, depthFuncMap, primitiveMap, stencilFuncMap, stencilOpMap } from "./constants";
|
|
15
9
|
|
|
16
|
-
|
|
10
|
+
/**
|
|
11
|
+
* adaptor for regl.DrawCommand
|
|
12
|
+
*/
|
|
13
|
+
var ReglModel = /*#__PURE__*/function () {
|
|
17
14
|
function ReglModel(reGl, options) {
|
|
18
15
|
_classCallCheck(this, ReglModel);
|
|
19
16
|
|
|
20
|
-
_defineProperty(this, "reGl", void 0);
|
|
21
|
-
|
|
22
17
|
_defineProperty(this, "destroyed", false);
|
|
23
18
|
|
|
24
|
-
_defineProperty(this, "drawCommand", void 0);
|
|
25
|
-
|
|
26
|
-
_defineProperty(this, "drawPickCommand", void 0);
|
|
27
|
-
|
|
28
|
-
_defineProperty(this, "drawParams", void 0);
|
|
29
|
-
|
|
30
|
-
_defineProperty(this, "options", void 0);
|
|
31
|
-
|
|
32
19
|
_defineProperty(this, "uniforms", {});
|
|
33
20
|
|
|
34
21
|
this.reGl = reGl;
|
|
@@ -50,6 +37,8 @@ var ReglModel = function () {
|
|
|
50
37
|
if (uniforms) {
|
|
51
38
|
this.uniforms = this.extractUniforms(uniforms);
|
|
52
39
|
Object.keys(uniforms).forEach(function (uniformName) {
|
|
40
|
+
// use regl prop API
|
|
41
|
+
// @ts-ignore
|
|
53
42
|
reglUniforms[uniformName] = reGl.prop(uniformName);
|
|
54
43
|
});
|
|
55
44
|
}
|
|
@@ -69,7 +58,8 @@ var ReglModel = function () {
|
|
|
69
58
|
|
|
70
59
|
if (instances) {
|
|
71
60
|
drawParams.instances = instances;
|
|
72
|
-
}
|
|
61
|
+
} // elements 中可能包含 count,此时不应传入
|
|
62
|
+
|
|
73
63
|
|
|
74
64
|
if (count) {
|
|
75
65
|
drawParams.count = count;
|
|
@@ -92,9 +82,7 @@ var ReglModel = function () {
|
|
|
92
82
|
cull: cull
|
|
93
83
|
}, drawParams);
|
|
94
84
|
this.drawCommand = reGl(drawParams);
|
|
95
|
-
|
|
96
|
-
var pickDrawParams = _cloneDeep(drawParams);
|
|
97
|
-
|
|
85
|
+
var pickDrawParams = cloneDeep(drawParams);
|
|
98
86
|
pickDrawParams.blend = _objectSpread(_objectSpread({}, pickDrawParams.blend), {}, {
|
|
99
87
|
enable: false
|
|
100
88
|
});
|
|
@@ -112,9 +100,7 @@ var ReglModel = function () {
|
|
|
112
100
|
this.drawParams.attributes = reglAttributes;
|
|
113
101
|
this.drawParams.elements = elements.get();
|
|
114
102
|
this.drawCommand = this.reGl(this.drawParams);
|
|
115
|
-
|
|
116
|
-
var pickDrawParams = _cloneDeep(this.drawParams);
|
|
117
|
-
|
|
103
|
+
var pickDrawParams = cloneDeep(this.drawParams);
|
|
118
104
|
pickDrawParams.blend = _objectSpread(_objectSpread({}, pickDrawParams.blend), {}, {
|
|
119
105
|
enable: false
|
|
120
106
|
});
|
|
@@ -129,9 +115,7 @@ var ReglModel = function () {
|
|
|
129
115
|
});
|
|
130
116
|
this.drawParams.attributes = reglAttributes;
|
|
131
117
|
this.drawCommand = this.reGl(this.drawParams);
|
|
132
|
-
|
|
133
|
-
var pickDrawParams = _cloneDeep(this.drawParams);
|
|
134
|
-
|
|
118
|
+
var pickDrawParams = cloneDeep(this.drawParams);
|
|
135
119
|
pickDrawParams.blend = _objectSpread(_objectSpread({}, pickDrawParams.blend), {}, {
|
|
136
120
|
enable: false
|
|
137
121
|
});
|
|
@@ -145,6 +129,7 @@ var ReglModel = function () {
|
|
|
145
129
|
}, {
|
|
146
130
|
key: "draw",
|
|
147
131
|
value: function draw(options, pick) {
|
|
132
|
+
// console.log('options', this.drawParams)
|
|
148
133
|
if (this.drawParams.attributes && Object.keys(this.drawParams.attributes).length === 0) {
|
|
149
134
|
return;
|
|
150
135
|
}
|
|
@@ -155,32 +140,41 @@ var ReglModel = function () {
|
|
|
155
140
|
Object.keys(uniforms).forEach(function (uniformName) {
|
|
156
141
|
var type = _typeof(uniforms[uniformName]);
|
|
157
142
|
|
|
158
|
-
if (type === 'boolean' || type === 'number' || Array.isArray(uniforms[uniformName]) ||
|
|
143
|
+
if (type === 'boolean' || type === 'number' || Array.isArray(uniforms[uniformName]) || // @ts-ignore
|
|
144
|
+
uniforms[uniformName].BYTES_PER_ELEMENT) {
|
|
159
145
|
reglDrawProps[uniformName] = uniforms[uniformName];
|
|
160
146
|
} else {
|
|
161
147
|
reglDrawProps[uniformName] = uniforms[uniformName].get();
|
|
162
148
|
}
|
|
163
|
-
});
|
|
149
|
+
}); // TODO: 在进行拾取操作的绘制中,不应该使用叠加模式 - picking 根据拾取的颜色作为判断的输入,而叠加模式会产生新的,在 id 序列中不存在的颜色
|
|
164
150
|
|
|
165
151
|
if (!pick) {
|
|
166
152
|
this.drawCommand(reglDrawProps);
|
|
167
153
|
} else {
|
|
168
154
|
this.drawPickCommand(reglDrawProps);
|
|
169
|
-
}
|
|
155
|
+
} // this.drawCommand(reglDrawProps);
|
|
156
|
+
// this.drawPickCommand(reglDrawProps);
|
|
157
|
+
|
|
170
158
|
}
|
|
171
159
|
}, {
|
|
172
160
|
key: "destroy",
|
|
173
161
|
value: function destroy() {
|
|
162
|
+
// @ts-ignore
|
|
174
163
|
this.drawParams.elements.destroy();
|
|
175
164
|
|
|
176
165
|
if (this.options.attributes) {
|
|
177
166
|
Object.values(this.options.attributes).forEach(function (attr) {
|
|
167
|
+
// @ts-ignore
|
|
178
168
|
attr.destroy();
|
|
179
169
|
});
|
|
180
170
|
}
|
|
181
171
|
|
|
182
172
|
this.destroyed = true;
|
|
183
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#depth-buffer
|
|
176
|
+
*/
|
|
177
|
+
|
|
184
178
|
}, {
|
|
185
179
|
key: "initDepthDrawParams",
|
|
186
180
|
value: function initDepthDrawParams(_ref, drawParams) {
|
|
@@ -195,6 +189,10 @@ var ReglModel = function () {
|
|
|
195
189
|
};
|
|
196
190
|
}
|
|
197
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#blending
|
|
194
|
+
*/
|
|
195
|
+
|
|
198
196
|
}, {
|
|
199
197
|
key: "initBlendDrawParams",
|
|
200
198
|
value: function initBlendDrawParams(_ref2, drawParams) {
|
|
@@ -205,7 +203,8 @@ var ReglModel = function () {
|
|
|
205
203
|
func = blend.func,
|
|
206
204
|
equation = blend.equation,
|
|
207
205
|
_blend$color = blend.color,
|
|
208
|
-
color = _blend$color === void 0 ? [0, 0, 0, 0] : _blend$color;
|
|
206
|
+
color = _blend$color === void 0 ? [0, 0, 0, 0] : _blend$color; // @ts-ignore
|
|
207
|
+
|
|
209
208
|
drawParams.blend = {
|
|
210
209
|
enable: !!enable,
|
|
211
210
|
func: {
|
|
@@ -222,6 +221,10 @@ var ReglModel = function () {
|
|
|
222
221
|
};
|
|
223
222
|
}
|
|
224
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#stencil
|
|
226
|
+
*/
|
|
227
|
+
|
|
225
228
|
}, {
|
|
226
229
|
key: "initStencilDrawParams",
|
|
227
230
|
value: function initStencilDrawParams(_ref3, drawParams) {
|
|
@@ -268,6 +271,10 @@ var ReglModel = function () {
|
|
|
268
271
|
};
|
|
269
272
|
}
|
|
270
273
|
}
|
|
274
|
+
/**
|
|
275
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#culling
|
|
276
|
+
*/
|
|
277
|
+
|
|
271
278
|
}, {
|
|
272
279
|
key: "initCullDrawParams",
|
|
273
280
|
value: function initCullDrawParams(_ref4, drawParams) {
|
|
@@ -283,6 +290,12 @@ var ReglModel = function () {
|
|
|
283
290
|
};
|
|
284
291
|
}
|
|
285
292
|
}
|
|
293
|
+
/**
|
|
294
|
+
* 考虑结构体命名, eg:
|
|
295
|
+
* a: { b: 1 } -> 'a.b'
|
|
296
|
+
* a: [ { b: 1 } ] -> 'a[0].b'
|
|
297
|
+
*/
|
|
298
|
+
|
|
286
299
|
}, {
|
|
287
300
|
key: "extractUniforms",
|
|
288
301
|
value: function extractUniforms(uniforms) {
|
|
@@ -299,21 +312,30 @@ var ReglModel = function () {
|
|
|
299
312
|
value: function extractUniformsRecursively(uniformName, uniformValue, uniforms, prefix) {
|
|
300
313
|
var _this2 = this;
|
|
301
314
|
|
|
302
|
-
if (uniformValue === null || typeof uniformValue === 'number' ||
|
|
315
|
+
if (uniformValue === null || typeof uniformValue === 'number' || // u_A: 1
|
|
316
|
+
typeof uniformValue === 'boolean' || // u_A: false
|
|
317
|
+
Array.isArray(uniformValue) && typeof uniformValue[0] === 'number' || // u_A: [1, 2, 3]
|
|
318
|
+
isTypedArray(uniformValue) || // u_A: Float32Array
|
|
319
|
+
// @ts-ignore
|
|
320
|
+
uniformValue === '' || 'resize' in uniformValue) {
|
|
303
321
|
uniforms["".concat(prefix && prefix + '.').concat(uniformName)] = uniformValue;
|
|
304
322
|
return;
|
|
305
|
-
}
|
|
323
|
+
} // u_Struct.a.b.c
|
|
306
324
|
|
|
307
|
-
|
|
325
|
+
|
|
326
|
+
if (isPlainObject(uniformValue)) {
|
|
308
327
|
Object.keys(uniformValue).forEach(function (childName) {
|
|
309
|
-
_this2.extractUniformsRecursively(childName,
|
|
328
|
+
_this2.extractUniformsRecursively(childName, // @ts-ignore
|
|
329
|
+
uniformValue[childName], uniforms, "".concat(prefix && prefix + '.').concat(uniformName));
|
|
310
330
|
});
|
|
311
|
-
}
|
|
331
|
+
} // u_Struct[0].a
|
|
332
|
+
|
|
312
333
|
|
|
313
334
|
if (Array.isArray(uniformValue)) {
|
|
314
335
|
uniformValue.forEach(function (child, idx) {
|
|
315
336
|
Object.keys(child).forEach(function (childName) {
|
|
316
|
-
_this2.extractUniformsRecursively(childName,
|
|
337
|
+
_this2.extractUniformsRecursively(childName, // @ts-ignore
|
|
338
|
+
child[childName], uniforms, "".concat(prefix && prefix + '.').concat(uniformName, "[").concat(idx, "]"));
|
|
317
339
|
});
|
|
318
340
|
});
|
|
319
341
|
}
|
|
@@ -323,5 +345,4 @@ var ReglModel = function () {
|
|
|
323
345
|
return ReglModel;
|
|
324
346
|
}();
|
|
325
347
|
|
|
326
|
-
export { ReglModel as default };
|
|
327
|
-
//# sourceMappingURL=ReglModel.js.map
|
|
348
|
+
export { ReglModel as default };
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
import { formatMap } from "./constants";
|
|
4
|
+
/**
|
|
5
|
+
* adaptor for regl.Renderbuffer
|
|
6
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#renderbuffers
|
|
7
|
+
*/
|
|
5
8
|
|
|
6
|
-
var ReglRenderbuffer = function () {
|
|
9
|
+
var ReglRenderbuffer = /*#__PURE__*/function () {
|
|
7
10
|
function ReglRenderbuffer(reGl, options) {
|
|
8
11
|
_classCallCheck(this, ReglRenderbuffer);
|
|
9
12
|
|
|
10
|
-
_defineProperty(this, "renderbuffer", void 0);
|
|
11
|
-
|
|
12
13
|
var width = options.width,
|
|
13
14
|
height = options.height,
|
|
14
15
|
format = options.format;
|
|
@@ -41,5 +42,4 @@ var ReglRenderbuffer = function () {
|
|
|
41
42
|
return ReglRenderbuffer;
|
|
42
43
|
}();
|
|
43
44
|
|
|
44
|
-
export { ReglRenderbuffer as default };
|
|
45
|
-
//# sourceMappingURL=ReglRenderbuffer.js.map
|
|
45
|
+
export { ReglRenderbuffer as default };
|
package/es/regl/ReglTexture2D.js
CHANGED
|
@@ -2,18 +2,16 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
import { gl } from '@antv/l7-core';
|
|
5
|
-
import { colorSpaceMap, dataTypeMap, filterMap, formatMap, mipmapMap, wrapModeMap } from
|
|
5
|
+
import { colorSpaceMap, dataTypeMap, filterMap, formatMap, mipmapMap, wrapModeMap } from "./constants";
|
|
6
|
+
/**
|
|
7
|
+
* adaptor for regl.Buffer
|
|
8
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#buffers
|
|
9
|
+
*/
|
|
6
10
|
|
|
7
|
-
var ReglTexture2D = function () {
|
|
11
|
+
var ReglTexture2D = /*#__PURE__*/function () {
|
|
8
12
|
function ReglTexture2D(reGl, options) {
|
|
9
13
|
_classCallCheck(this, ReglTexture2D);
|
|
10
14
|
|
|
11
|
-
_defineProperty(this, "texture", void 0);
|
|
12
|
-
|
|
13
|
-
_defineProperty(this, "width", void 0);
|
|
14
|
-
|
|
15
|
-
_defineProperty(this, "height", void 0);
|
|
16
|
-
|
|
17
15
|
_defineProperty(this, "isDistroy", false);
|
|
18
16
|
|
|
19
17
|
var data = options.data,
|
|
@@ -54,10 +52,12 @@ var ReglTexture2D = function () {
|
|
|
54
52
|
var textureOptions = {
|
|
55
53
|
width: width,
|
|
56
54
|
height: height,
|
|
55
|
+
// @ts-ignore
|
|
57
56
|
type: dataTypeMap[type],
|
|
58
57
|
format: formatMap[format],
|
|
59
58
|
wrapS: wrapModeMap[wrapS],
|
|
60
59
|
wrapT: wrapModeMap[wrapT],
|
|
60
|
+
// @ts-ignore
|
|
61
61
|
mag: filterMap[mag],
|
|
62
62
|
min: filterMap[min],
|
|
63
63
|
alignment: alignment,
|
|
@@ -65,12 +65,14 @@ var ReglTexture2D = function () {
|
|
|
65
65
|
colorSpace: colorSpaceMap[colorSpace],
|
|
66
66
|
premultiplyAlpha: premultiplyAlpha,
|
|
67
67
|
aniso: aniso,
|
|
68
|
+
// copy pixels from current bind framebuffer
|
|
68
69
|
x: x,
|
|
69
70
|
y: y,
|
|
70
71
|
copy: copy
|
|
71
72
|
};
|
|
72
73
|
|
|
73
74
|
if (data) {
|
|
75
|
+
// @ts-ignore
|
|
74
76
|
textureOptions.data = data;
|
|
75
77
|
}
|
|
76
78
|
|
|
@@ -97,6 +99,7 @@ var ReglTexture2D = function () {
|
|
|
97
99
|
}, {
|
|
98
100
|
key: "bind",
|
|
99
101
|
value: function bind() {
|
|
102
|
+
// @ts-ignore
|
|
100
103
|
this.texture._texture.bind();
|
|
101
104
|
}
|
|
102
105
|
}, {
|
|
@@ -124,5 +127,4 @@ var ReglTexture2D = function () {
|
|
|
124
127
|
return ReglTexture2D;
|
|
125
128
|
}();
|
|
126
129
|
|
|
127
|
-
export { ReglTexture2D as default };
|
|
128
|
-
//# sourceMappingURL=ReglTexture2D.js.map
|
|
130
|
+
export { ReglTexture2D as default };
|
package/es/regl/constants.js
CHANGED
|
@@ -2,7 +2,11 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
|
|
3
3
|
var _primitiveMap, _usageMap, _dataTypeMap, _formatMap, _mipmapMap, _filterMap, _wrapModeMap, _colorSpaceMap, _depthFuncMap, _blendEquationMap, _blendFuncMap, _stencilFuncMap, _stencilOpMap, _cullFaceMap;
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @desc 由于 regl 使用大量字符串而非 WebGL 常量,因此需要映射
|
|
7
|
+
*/
|
|
5
8
|
import { gl } from '@antv/l7-core';
|
|
9
|
+
// @see https://github.com/regl-project/regl/blob/gh-pages/lib/constants/primitives.json
|
|
6
10
|
export var primitiveMap = (_primitiveMap = {}, _defineProperty(_primitiveMap, gl.POINTS, 'points'), _defineProperty(_primitiveMap, gl.LINES, 'lines'), _defineProperty(_primitiveMap, gl.LINE_LOOP, 'line loop'), _defineProperty(_primitiveMap, gl.LINE_STRIP, 'line strip'), _defineProperty(_primitiveMap, gl.TRIANGLES, 'triangles'), _defineProperty(_primitiveMap, gl.TRIANGLE_FAN, 'triangle fan'), _defineProperty(_primitiveMap, gl.TRIANGLE_STRIP, 'triangle strip'), _primitiveMap);
|
|
7
11
|
export var usageMap = (_usageMap = {}, _defineProperty(_usageMap, gl.STATIC_DRAW, 'static'), _defineProperty(_usageMap, gl.DYNAMIC_DRAW, 'dynamic'), _defineProperty(_usageMap, gl.STREAM_DRAW, 'stream'), _usageMap);
|
|
8
12
|
export var dataTypeMap = (_dataTypeMap = {}, _defineProperty(_dataTypeMap, gl.BYTE, 'int8'), _defineProperty(_dataTypeMap, gl.UNSIGNED_INT, 'int16'), _defineProperty(_dataTypeMap, gl.INT, 'int32'), _defineProperty(_dataTypeMap, gl.UNSIGNED_BYTE, 'uint8'), _defineProperty(_dataTypeMap, gl.UNSIGNED_SHORT, 'uint16'), _defineProperty(_dataTypeMap, gl.UNSIGNED_INT, 'uint32'), _defineProperty(_dataTypeMap, gl.FLOAT, 'float'), _dataTypeMap);
|
|
@@ -16,5 +20,4 @@ export var blendEquationMap = (_blendEquationMap = {}, _defineProperty(_blendEqu
|
|
|
16
20
|
export var blendFuncMap = (_blendFuncMap = {}, _defineProperty(_blendFuncMap, gl.ZERO, 'zero'), _defineProperty(_blendFuncMap, gl.ONE, 'one'), _defineProperty(_blendFuncMap, gl.SRC_COLOR, 'src color'), _defineProperty(_blendFuncMap, gl.ONE_MINUS_SRC_COLOR, 'one minus src color'), _defineProperty(_blendFuncMap, gl.SRC_ALPHA, 'src alpha'), _defineProperty(_blendFuncMap, gl.ONE_MINUS_SRC_ALPHA, 'one minus src alpha'), _defineProperty(_blendFuncMap, gl.DST_COLOR, 'dst color'), _defineProperty(_blendFuncMap, gl.ONE_MINUS_DST_COLOR, 'one minus dst color'), _defineProperty(_blendFuncMap, gl.DST_ALPHA, 'dst alpha'), _defineProperty(_blendFuncMap, gl.ONE_MINUS_DST_ALPHA, 'one minus dst alpha'), _defineProperty(_blendFuncMap, gl.CONSTANT_COLOR, 'constant color'), _defineProperty(_blendFuncMap, gl.ONE_MINUS_CONSTANT_COLOR, 'one minus constant color'), _defineProperty(_blendFuncMap, gl.CONSTANT_ALPHA, 'constant alpha'), _defineProperty(_blendFuncMap, gl.ONE_MINUS_CONSTANT_ALPHA, 'one minus constant alpha'), _defineProperty(_blendFuncMap, gl.SRC_ALPHA_SATURATE, 'src alpha saturate'), _blendFuncMap);
|
|
17
21
|
export var stencilFuncMap = (_stencilFuncMap = {}, _defineProperty(_stencilFuncMap, gl.NEVER, 'never'), _defineProperty(_stencilFuncMap, gl.ALWAYS, 'always'), _defineProperty(_stencilFuncMap, gl.LESS, 'less'), _defineProperty(_stencilFuncMap, gl.LEQUAL, 'lequal'), _defineProperty(_stencilFuncMap, gl.GREATER, 'greater'), _defineProperty(_stencilFuncMap, gl.GEQUAL, 'gequal'), _defineProperty(_stencilFuncMap, gl.EQUAL, 'equal'), _defineProperty(_stencilFuncMap, gl.NOTEQUAL, 'notequal'), _stencilFuncMap);
|
|
18
22
|
export var stencilOpMap = (_stencilOpMap = {}, _defineProperty(_stencilOpMap, gl.ZERO, 'zero'), _defineProperty(_stencilOpMap, gl.KEEP, 'keep'), _defineProperty(_stencilOpMap, gl.REPLACE, 'replace'), _defineProperty(_stencilOpMap, gl.INVERT, 'invert'), _defineProperty(_stencilOpMap, gl.INCR, 'increment'), _defineProperty(_stencilOpMap, gl.DECR, 'decrement'), _defineProperty(_stencilOpMap, gl.INCR_WRAP, 'increment wrap'), _defineProperty(_stencilOpMap, gl.DECR_WRAP, 'decrement wrap'), _stencilOpMap);
|
|
19
|
-
export var cullFaceMap = (_cullFaceMap = {}, _defineProperty(_cullFaceMap, gl.FRONT, 'front'), _defineProperty(_cullFaceMap, gl.BACK, 'back'), _cullFaceMap);
|
|
20
|
-
//# sourceMappingURL=constants.js.map
|
|
23
|
+
export var cullFaceMap = (_cullFaceMap = {}, _defineProperty(_cullFaceMap, gl.FRONT, 'front'), _defineProperty(_cullFaceMap, gl.BACK, 'back'), _cullFaceMap);
|
package/es/regl/index.js
CHANGED
|
@@ -6,36 +6,31 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
6
6
|
var _dec, _class;
|
|
7
7
|
|
|
8
8
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* render w/ regl
|
|
12
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md
|
|
13
|
+
*/
|
|
9
14
|
import { isMini } from '@antv/l7-utils';
|
|
10
15
|
import { injectable } from 'inversify';
|
|
11
16
|
import regl from 'l7regl';
|
|
12
17
|
import 'reflect-metadata';
|
|
13
|
-
import ReglAttribute from
|
|
14
|
-
import ReglBuffer from
|
|
15
|
-
import ReglElements from
|
|
16
|
-
import ReglFramebuffer from
|
|
17
|
-
import ReglModel from
|
|
18
|
-
import ReglTexture2D from
|
|
19
|
-
|
|
18
|
+
import ReglAttribute from "./ReglAttribute";
|
|
19
|
+
import ReglBuffer from "./ReglBuffer";
|
|
20
|
+
import ReglElements from "./ReglElements";
|
|
21
|
+
import ReglFramebuffer from "./ReglFramebuffer";
|
|
22
|
+
import ReglModel from "./ReglModel";
|
|
23
|
+
import ReglTexture2D from "./ReglTexture2D";
|
|
24
|
+
/**
|
|
25
|
+
* regl renderer
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
var ReglRendererService = (_dec = injectable(), _dec(_class = /*#__PURE__*/function () {
|
|
20
29
|
function ReglRendererService() {
|
|
21
30
|
var _this = this;
|
|
22
31
|
|
|
23
32
|
_classCallCheck(this, ReglRendererService);
|
|
24
33
|
|
|
25
|
-
_defineProperty(this, "extensionObject", void 0);
|
|
26
|
-
|
|
27
|
-
_defineProperty(this, "gl", void 0);
|
|
28
|
-
|
|
29
|
-
_defineProperty(this, "$container", void 0);
|
|
30
|
-
|
|
31
|
-
_defineProperty(this, "canvas", void 0);
|
|
32
|
-
|
|
33
|
-
_defineProperty(this, "width", void 0);
|
|
34
|
-
|
|
35
|
-
_defineProperty(this, "height", void 0);
|
|
36
|
-
|
|
37
|
-
_defineProperty(this, "isDirty", void 0);
|
|
38
|
-
|
|
39
34
|
_defineProperty(this, "createModel", function (options) {
|
|
40
35
|
return new ReglModel(_this.gl, options);
|
|
41
36
|
});
|
|
@@ -69,6 +64,7 @@ var ReglRendererService = (_dec = injectable(), _dec(_class = function () {
|
|
|
69
64
|
_defineProperty(this, "clear", function (options) {
|
|
70
65
|
var _this$gl;
|
|
71
66
|
|
|
67
|
+
// @see https://github.com/regl-project/regl/blob/gh-pages/API.md#clear-the-draw-buffer
|
|
72
68
|
var color = options.color,
|
|
73
69
|
depth = options.depth,
|
|
74
70
|
stencil = options.stencil,
|
|
@@ -89,6 +85,8 @@ var ReglRendererService = (_dec = injectable(), _dec(_class = function () {
|
|
|
89
85
|
width = _ref.width,
|
|
90
86
|
height = _ref.height;
|
|
91
87
|
|
|
88
|
+
// use WebGL context directly
|
|
89
|
+
// @see https://github.com/regl-project/regl/blob/gh-pages/API.md#unsafe-escape-hatch
|
|
92
90
|
_this.gl._gl.viewport(x, y, width, height);
|
|
93
91
|
|
|
94
92
|
_this.width = width;
|
|
@@ -135,6 +133,7 @@ var ReglRendererService = (_dec = injectable(), _dec(_class = function () {
|
|
|
135
133
|
});
|
|
136
134
|
|
|
137
135
|
_defineProperty(this, "getCanvas", function () {
|
|
136
|
+
// return this.$container?.getElementsByTagName('canvas')[0] || null;
|
|
138
137
|
return _this.canvas;
|
|
139
138
|
});
|
|
140
139
|
|
|
@@ -145,10 +144,14 @@ var ReglRendererService = (_dec = injectable(), _dec(_class = function () {
|
|
|
145
144
|
_defineProperty(this, "destroy", function () {
|
|
146
145
|
var _this$gl2, _this$gl2$_gl, _this$gl2$_gl$getExte;
|
|
147
146
|
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
// this.canvas = null 清除对 webgl 实例的引用
|
|
148
|
+
// @ts-ignore
|
|
149
|
+
_this.canvas = null; // make sure release webgl context
|
|
150
|
+
|
|
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
|
|
150
154
|
|
|
151
|
-
_this.gl.destroy();
|
|
152
155
|
|
|
153
156
|
_this.gl = null;
|
|
154
157
|
});
|
|
@@ -157,32 +160,40 @@ var ReglRendererService = (_dec = injectable(), _dec(_class = function () {
|
|
|
157
160
|
_createClass(ReglRendererService, [{
|
|
158
161
|
key: "init",
|
|
159
162
|
value: function () {
|
|
160
|
-
var _init = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(canvas, cfg) {
|
|
163
|
+
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(canvas, cfg) {
|
|
161
164
|
var _this2 = this;
|
|
162
165
|
|
|
163
166
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
164
167
|
while (1) {
|
|
165
168
|
switch (_context.prev = _context.next) {
|
|
166
169
|
case 0:
|
|
167
|
-
this
|
|
170
|
+
// this.$container = $container;
|
|
171
|
+
this.canvas = canvas; // tslint:disable-next-line:typedef
|
|
172
|
+
|
|
168
173
|
_context.next = 3;
|
|
169
174
|
return new Promise(function (resolve, reject) {
|
|
170
175
|
regl({
|
|
171
176
|
canvas: _this2.canvas,
|
|
172
177
|
attributes: {
|
|
173
178
|
alpha: true,
|
|
179
|
+
// use TAA instead of MSAA
|
|
180
|
+
// @see https://www.khronos.org/registry/webgl/specs/1.0/#5.2.1
|
|
174
181
|
antialias: cfg.antialias,
|
|
175
182
|
premultipliedAlpha: true,
|
|
176
183
|
preserveDrawingBuffer: cfg.preserveDrawingBuffer,
|
|
177
184
|
stencil: cfg.stencil
|
|
178
185
|
},
|
|
179
|
-
|
|
186
|
+
// TODO: use extensions
|
|
187
|
+
extensions: ['OES_element_index_uint', 'OES_standard_derivatives', // wireframe
|
|
188
|
+
'ANGLE_instanced_arrays' // VSM shadow map
|
|
189
|
+
],
|
|
180
190
|
optionalExtensions: ['oes_texture_float_linear', 'OES_texture_float', 'EXT_texture_filter_anisotropic', 'EXT_blend_minmax', 'WEBGL_depth_texture'],
|
|
181
191
|
profile: true,
|
|
182
192
|
onDone: function onDone(err, r) {
|
|
183
193
|
if (err || !r) {
|
|
184
194
|
reject(err);
|
|
185
|
-
}
|
|
195
|
+
} // @ts-ignore
|
|
196
|
+
|
|
186
197
|
|
|
187
198
|
resolve(r);
|
|
188
199
|
}
|
|
@@ -217,11 +228,13 @@ var ReglRendererService = (_dec = injectable(), _dec(_class = function () {
|
|
|
217
228
|
}, {
|
|
218
229
|
key: "testExtension",
|
|
219
230
|
value: function testExtension(name) {
|
|
231
|
+
// OES_texture_float
|
|
220
232
|
return !!this.getGLContext().getExtension(name);
|
|
221
233
|
}
|
|
222
234
|
}, {
|
|
223
235
|
key: "setState",
|
|
224
|
-
value:
|
|
236
|
+
value: // TODO: 临时方法
|
|
237
|
+
function setState() {
|
|
225
238
|
this.gl({
|
|
226
239
|
cull: {
|
|
227
240
|
enable: false,
|
|
@@ -285,5 +298,4 @@ var ReglRendererService = (_dec = injectable(), _dec(_class = function () {
|
|
|
285
298
|
|
|
286
299
|
return ReglRendererService;
|
|
287
300
|
}()) || _class);
|
|
288
|
-
export { ReglRendererService as default };
|
|
289
|
-
//# sourceMappingURL=index.js.map
|
|
301
|
+
export { ReglRendererService as default };
|