@antv/l7-renderer 2.21.1 → 2.21.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/device/DeviceAttribute.js +26 -32
- package/es/device/DeviceBuffer.js +31 -49
- package/es/device/DeviceCache.js +136 -170
- package/es/device/DeviceElements.js +32 -38
- package/es/device/DeviceFramebuffer.js +76 -104
- package/es/device/DeviceModel.js +358 -384
- package/es/device/DeviceTexture2D.js +103 -122
- package/es/device/constants.js +117 -34
- package/es/device/index.js +254 -381
- package/es/device/utils/HashMap.js +71 -138
- package/es/device/utils/pipeline.js +6 -1
- package/es/device/utils/typedarray.js +23 -24
- package/es/device/utils/webgl.js +7 -6
- package/es/index.js +5 -4
- package/es/regl/ReglAttribute.js +17 -33
- package/es/regl/ReglBuffer.js +25 -40
- package/es/regl/ReglElements.js +21 -36
- package/es/regl/ReglFramebuffer.js +24 -44
- package/es/regl/ReglModel.js +266 -306
- package/es/regl/ReglRenderbuffer.js +19 -36
- package/es/regl/ReglTexture2D.js +72 -103
- package/es/regl/constants.js +133 -21
- package/es/regl/index.js +205 -289
- package/lib/device/DeviceAttribute.d.ts +13 -0
- package/lib/device/DeviceBuffer.d.ts +18 -0
- package/lib/device/DeviceCache.d.ts +14 -0
- package/lib/device/DeviceElements.d.ts +13 -0
- package/lib/device/DeviceFramebuffer.d.ts +24 -0
- package/lib/device/DeviceModel.d.ts +53 -0
- package/lib/device/DeviceModel.js +22 -15
- package/lib/device/DeviceTexture2D.d.ts +23 -0
- package/lib/device/constants.d.ts +35 -0
- package/lib/device/index.d.ts +68 -0
- package/lib/device/index.js +58 -36
- package/lib/device/utils/HashMap.d.ts +24 -0
- package/lib/device/utils/pipeline.d.ts +1 -0
- package/lib/device/utils/typedarray.d.ts +7 -0
- package/lib/device/utils/webgl.d.ts +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/regl/ReglAttribute.d.ts +16 -0
- package/lib/regl/ReglBuffer.d.ts +17 -0
- package/lib/regl/ReglElements.d.ts +14 -0
- package/lib/regl/ReglFramebuffer.d.ts +16 -0
- package/lib/regl/ReglModel.d.ts +46 -0
- package/lib/regl/ReglModel.js +21 -11
- package/lib/regl/ReglRenderbuffer.d.ts +16 -0
- package/lib/regl/ReglTexture2D.d.ts +22 -0
- package/lib/regl/constants.d.ts +43 -0
- package/lib/regl/index.d.ts +56 -0
- package/lib/regl/index.js +70 -48
- package/package.json +14 -18
package/es/regl/index.js
CHANGED
|
@@ -1,311 +1,227 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
10
21
|
|
|
11
|
-
|
|
22
|
+
// src/regl/index.ts
|
|
23
|
+
import regl from "regl";
|
|
12
24
|
import ReglAttribute from "./ReglAttribute";
|
|
13
25
|
import ReglBuffer from "./ReglBuffer";
|
|
14
26
|
import ReglElements from "./ReglElements";
|
|
15
27
|
import ReglFramebuffer from "./ReglFramebuffer";
|
|
16
28
|
import ReglModel from "./ReglModel";
|
|
17
29
|
import ReglTexture2D from "./ReglTexture2D";
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return new ReglBuffer(_this.gl, options);
|
|
38
|
-
});
|
|
39
|
-
_defineProperty(this, "createElements", function (options) {
|
|
40
|
-
return new ReglElements(_this.gl, options);
|
|
41
|
-
});
|
|
42
|
-
_defineProperty(this, "createTexture2D", function (options) {
|
|
43
|
-
return new ReglTexture2D(_this.gl, options);
|
|
44
|
-
});
|
|
45
|
-
_defineProperty(this, "createFramebuffer", function (options) {
|
|
46
|
-
return new ReglFramebuffer(_this.gl, options);
|
|
47
|
-
});
|
|
48
|
-
_defineProperty(this, "useFramebuffer", function (framebuffer, drawCommands) {
|
|
49
|
-
_this.gl({
|
|
30
|
+
var ReglRendererService = class {
|
|
31
|
+
constructor() {
|
|
32
|
+
this.uniformBuffers = [];
|
|
33
|
+
this.queryVerdorInfo = () => {
|
|
34
|
+
return "WebGL1";
|
|
35
|
+
};
|
|
36
|
+
this.createModel = (options) => new ReglModel(this.gl, options);
|
|
37
|
+
this.createAttribute = (options) => new ReglAttribute(this.gl, options);
|
|
38
|
+
this.createBuffer = (options) => new ReglBuffer(this.gl, options);
|
|
39
|
+
this.createElements = (options) => new ReglElements(this.gl, options);
|
|
40
|
+
this.createTexture2D = (options) => new ReglTexture2D(this.gl, options);
|
|
41
|
+
this.createFramebuffer = (options) => new ReglFramebuffer(this.gl, options);
|
|
42
|
+
this.useFramebuffer = (framebuffer, drawCommands) => {
|
|
43
|
+
this.gl({
|
|
44
|
+
framebuffer: framebuffer ? framebuffer.get() : null
|
|
45
|
+
})(drawCommands);
|
|
46
|
+
};
|
|
47
|
+
this.useFramebufferAsync = (framebuffer, drawCommands) => __async(this, null, function* () {
|
|
48
|
+
this.gl({
|
|
50
49
|
framebuffer: framebuffer ? framebuffer.get() : null
|
|
51
50
|
})(drawCommands);
|
|
52
51
|
});
|
|
53
|
-
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
})(drawCommands);
|
|
61
|
-
case 1:
|
|
62
|
-
case "end":
|
|
63
|
-
return _context.stop();
|
|
64
|
-
}
|
|
65
|
-
}, _callee);
|
|
66
|
-
}));
|
|
67
|
-
return function (_x, _x2) {
|
|
68
|
-
return _ref.apply(this, arguments);
|
|
69
|
-
};
|
|
70
|
-
}());
|
|
71
|
-
_defineProperty(this, "clear", function (options) {
|
|
72
|
-
var _this$gl;
|
|
73
|
-
// @see https://github.com/regl-project/regl/blob/gh-pages/API.md#clear-the-draw-buffer
|
|
74
|
-
var color = options.color,
|
|
75
|
-
depth = options.depth,
|
|
76
|
-
stencil = options.stencil,
|
|
77
|
-
_options$framebuffer = options.framebuffer,
|
|
78
|
-
framebuffer = _options$framebuffer === void 0 ? null : _options$framebuffer;
|
|
79
|
-
var reglClearOptions = {
|
|
80
|
-
color: color,
|
|
81
|
-
depth: depth,
|
|
82
|
-
stencil: stencil
|
|
52
|
+
this.clear = (options) => {
|
|
53
|
+
var _a;
|
|
54
|
+
const { color, depth, stencil, framebuffer = null } = options;
|
|
55
|
+
const reglClearOptions = {
|
|
56
|
+
color,
|
|
57
|
+
depth,
|
|
58
|
+
stencil
|
|
83
59
|
};
|
|
84
60
|
reglClearOptions.framebuffer = framebuffer === null ? framebuffer : framebuffer.get();
|
|
85
|
-
(
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
x
|
|
102
|
-
y
|
|
103
|
-
width
|
|
104
|
-
height
|
|
105
|
-
var readPixelsOptions = {
|
|
106
|
-
x: x,
|
|
107
|
-
y: y,
|
|
108
|
-
width: width,
|
|
109
|
-
height: height
|
|
61
|
+
(_a = this.gl) == null ? void 0 : _a.clear(reglClearOptions);
|
|
62
|
+
};
|
|
63
|
+
this.viewport = ({
|
|
64
|
+
x,
|
|
65
|
+
y,
|
|
66
|
+
width,
|
|
67
|
+
height
|
|
68
|
+
}) => {
|
|
69
|
+
this.gl._gl.viewport(x, y, width, height);
|
|
70
|
+
this.width = width;
|
|
71
|
+
this.height = height;
|
|
72
|
+
this.gl._refresh();
|
|
73
|
+
};
|
|
74
|
+
this.readPixels = (options) => {
|
|
75
|
+
const { framebuffer, x, y, width, height } = options;
|
|
76
|
+
const readPixelsOptions = {
|
|
77
|
+
x,
|
|
78
|
+
y,
|
|
79
|
+
width,
|
|
80
|
+
height
|
|
110
81
|
};
|
|
111
82
|
if (framebuffer) {
|
|
112
83
|
readPixelsOptions.framebuffer = framebuffer.get();
|
|
113
84
|
}
|
|
114
|
-
return
|
|
85
|
+
return this.gl.read(readPixelsOptions);
|
|
86
|
+
};
|
|
87
|
+
this.readPixelsAsync = (options) => __async(this, null, function* () {
|
|
88
|
+
return this.readPixels(options);
|
|
115
89
|
});
|
|
116
|
-
|
|
117
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(options) {
|
|
118
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
119
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
120
|
-
case 0:
|
|
121
|
-
return _context2.abrupt("return", _this.readPixels(options));
|
|
122
|
-
case 1:
|
|
123
|
-
case "end":
|
|
124
|
-
return _context2.stop();
|
|
125
|
-
}
|
|
126
|
-
}, _callee2);
|
|
127
|
-
}));
|
|
128
|
-
return function (_x3) {
|
|
129
|
-
return _ref3.apply(this, arguments);
|
|
130
|
-
};
|
|
131
|
-
}());
|
|
132
|
-
_defineProperty(this, "getViewportSize", function () {
|
|
90
|
+
this.getViewportSize = () => {
|
|
133
91
|
return {
|
|
134
|
-
width:
|
|
135
|
-
height:
|
|
92
|
+
width: this.gl._gl.drawingBufferWidth,
|
|
93
|
+
height: this.gl._gl.drawingBufferHeight
|
|
136
94
|
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
var
|
|
140
|
-
return (
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
// make sure release webgl context
|
|
156
|
-
(_this$gl2 = _this.gl) === null || _this$gl2 === void 0 || (_this$gl2 = _this$gl2._gl) === null || _this$gl2 === void 0 || (_this$gl2 = _this$gl2.getExtension('WEBGL_lose_context')) === null || _this$gl2 === void 0 || _this$gl2.loseContext();
|
|
157
|
-
|
|
158
|
-
// @see https://github.com/regl-project/regl/blob/gh-pages/API.md#clean-up
|
|
159
|
-
_this.gl.destroy();
|
|
160
|
-
|
|
161
|
-
// @ts-ignore
|
|
162
|
-
_this.gl = null;
|
|
163
|
-
});
|
|
95
|
+
};
|
|
96
|
+
this.getContainer = () => {
|
|
97
|
+
var _a;
|
|
98
|
+
return (_a = this.canvas) == null ? void 0 : _a.parentElement;
|
|
99
|
+
};
|
|
100
|
+
this.getCanvas = () => {
|
|
101
|
+
return this.canvas;
|
|
102
|
+
};
|
|
103
|
+
this.getGLContext = () => {
|
|
104
|
+
return this.gl._gl;
|
|
105
|
+
};
|
|
106
|
+
this.destroy = () => {
|
|
107
|
+
var _a, _b, _c;
|
|
108
|
+
this.canvas = null;
|
|
109
|
+
(_c = (_b = (_a = this.gl) == null ? void 0 : _a._gl) == null ? void 0 : _b.getExtension("WEBGL_lose_context")) == null ? void 0 : _c.loseContext();
|
|
110
|
+
this.gl.destroy();
|
|
111
|
+
this.gl = null;
|
|
112
|
+
};
|
|
164
113
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
114
|
+
init(canvas, cfg, gl) {
|
|
115
|
+
return __async(this, null, function* () {
|
|
116
|
+
this.canvas = canvas;
|
|
117
|
+
if (gl) {
|
|
118
|
+
this.gl = gl;
|
|
119
|
+
} else {
|
|
120
|
+
this.gl = yield new Promise((resolve, reject) => {
|
|
121
|
+
regl({
|
|
122
|
+
canvas: this.canvas,
|
|
123
|
+
attributes: {
|
|
124
|
+
alpha: true,
|
|
125
|
+
// use TAA instead of MSAA
|
|
126
|
+
// @see https://www.khronos.org/registry/webgl/specs/1.0/#5.2.1
|
|
127
|
+
antialias: cfg.antialias,
|
|
128
|
+
premultipliedAlpha: true,
|
|
129
|
+
preserveDrawingBuffer: cfg.preserveDrawingBuffer,
|
|
130
|
+
stencil: cfg.stencil
|
|
131
|
+
},
|
|
132
|
+
// TODO: use extensions
|
|
133
|
+
extensions: [
|
|
134
|
+
"OES_element_index_uint",
|
|
135
|
+
"OES_standard_derivatives",
|
|
136
|
+
// wireframe
|
|
137
|
+
"ANGLE_instanced_arrays"
|
|
138
|
+
// VSM shadow map
|
|
139
|
+
],
|
|
140
|
+
optionalExtensions: [
|
|
141
|
+
"oes_texture_float_linear",
|
|
142
|
+
"OES_texture_float",
|
|
143
|
+
"EXT_texture_filter_anisotropic",
|
|
144
|
+
"EXT_blend_minmax",
|
|
145
|
+
"WEBGL_depth_texture",
|
|
146
|
+
"WEBGL_lose_context"
|
|
147
|
+
],
|
|
148
|
+
profile: true,
|
|
149
|
+
onDone: (err, r) => {
|
|
150
|
+
if (err || !r) {
|
|
151
|
+
reject(err);
|
|
178
152
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
_context3.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',
|
|
198
|
-
// wireframe
|
|
199
|
-
'ANGLE_instanced_arrays' // VSM shadow map
|
|
200
|
-
],
|
|
201
|
-
optionalExtensions: ['oes_texture_float_linear', 'OES_texture_float', 'EXT_texture_filter_anisotropic', 'EXT_blend_minmax', 'WEBGL_depth_texture', 'WEBGL_lose_context'],
|
|
202
|
-
profile: true,
|
|
203
|
-
onDone: function onDone(err, r) {
|
|
204
|
-
if (err || !r) {
|
|
205
|
-
reject(err);
|
|
206
|
-
}
|
|
207
|
-
// @ts-ignore
|
|
208
|
-
resolve(r);
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
case 7:
|
|
213
|
-
this.gl = _context3.sent;
|
|
214
|
-
case 8:
|
|
215
|
-
this.extensionObject = {
|
|
216
|
-
OES_texture_float: this.testExtension('OES_texture_float')
|
|
217
|
-
};
|
|
218
|
-
case 9:
|
|
219
|
-
case "end":
|
|
220
|
-
return _context3.stop();
|
|
221
|
-
}
|
|
222
|
-
}, _callee3, this);
|
|
223
|
-
}));
|
|
224
|
-
function init(_x4, _x5, _x6) {
|
|
225
|
-
return _init.apply(this, arguments);
|
|
153
|
+
resolve(r);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
});
|
|
226
157
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}, {
|
|
298
|
-
key: "getDirty",
|
|
299
|
-
value: function getDirty() {
|
|
300
|
-
return this.isDirty;
|
|
301
|
-
}
|
|
302
|
-
}, {
|
|
303
|
-
key: "beginFrame",
|
|
304
|
-
value: function beginFrame() {}
|
|
305
|
-
}, {
|
|
306
|
-
key: "endFrame",
|
|
307
|
-
value: function endFrame() {}
|
|
308
|
-
}]);
|
|
309
|
-
return ReglRendererService;
|
|
310
|
-
}();
|
|
311
|
-
export { ReglRendererService as default };
|
|
158
|
+
this.extensionObject = {
|
|
159
|
+
OES_texture_float: this.testExtension("OES_texture_float")
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
getPointSizeRange() {
|
|
164
|
+
return this.gl._gl.getParameter(this.gl._gl.ALIASED_POINT_SIZE_RANGE);
|
|
165
|
+
}
|
|
166
|
+
testExtension(name) {
|
|
167
|
+
return !!this.getGLContext().getExtension(name);
|
|
168
|
+
}
|
|
169
|
+
// TODO: 临时方法
|
|
170
|
+
setState() {
|
|
171
|
+
this.gl({
|
|
172
|
+
cull: {
|
|
173
|
+
enable: false,
|
|
174
|
+
face: "back"
|
|
175
|
+
},
|
|
176
|
+
viewport: {
|
|
177
|
+
x: 0,
|
|
178
|
+
y: 0,
|
|
179
|
+
height: this.width,
|
|
180
|
+
width: this.height
|
|
181
|
+
},
|
|
182
|
+
blend: {
|
|
183
|
+
enable: true,
|
|
184
|
+
equation: "add"
|
|
185
|
+
},
|
|
186
|
+
framebuffer: null
|
|
187
|
+
});
|
|
188
|
+
this.gl._refresh();
|
|
189
|
+
}
|
|
190
|
+
setBaseState() {
|
|
191
|
+
this.gl({
|
|
192
|
+
cull: {
|
|
193
|
+
enable: false,
|
|
194
|
+
face: "back"
|
|
195
|
+
},
|
|
196
|
+
viewport: {
|
|
197
|
+
x: 0,
|
|
198
|
+
y: 0,
|
|
199
|
+
height: this.width,
|
|
200
|
+
width: this.height
|
|
201
|
+
},
|
|
202
|
+
blend: {
|
|
203
|
+
enable: false,
|
|
204
|
+
equation: "add"
|
|
205
|
+
},
|
|
206
|
+
framebuffer: null
|
|
207
|
+
});
|
|
208
|
+
this.gl._refresh();
|
|
209
|
+
}
|
|
210
|
+
setCustomLayerDefaults() {
|
|
211
|
+
const gl = this.getGLContext();
|
|
212
|
+
gl.disable(gl.CULL_FACE);
|
|
213
|
+
}
|
|
214
|
+
setDirty(flag) {
|
|
215
|
+
this.isDirty = flag;
|
|
216
|
+
}
|
|
217
|
+
getDirty() {
|
|
218
|
+
return this.isDirty;
|
|
219
|
+
}
|
|
220
|
+
beginFrame() {
|
|
221
|
+
}
|
|
222
|
+
endFrame() {
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
export {
|
|
226
|
+
ReglRendererService as default
|
|
227
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Device } from '@antv/g-device-api';
|
|
2
|
+
import type { IAttribute, IAttributeInitializationOptions, IBuffer } from '@antv/l7-core';
|
|
3
|
+
export default class DeviceAttribute implements IAttribute {
|
|
4
|
+
private attribute;
|
|
5
|
+
private buffer;
|
|
6
|
+
constructor(device: Device, options: IAttributeInitializationOptions);
|
|
7
|
+
get(): IBuffer;
|
|
8
|
+
updateBuffer(options: {
|
|
9
|
+
data: number[] | number[][] | Uint8Array | Uint16Array | Uint32Array;
|
|
10
|
+
offset: number;
|
|
11
|
+
}): void;
|
|
12
|
+
destroy(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Buffer, Device } from '@antv/g-device-api';
|
|
2
|
+
import type { IBuffer, IBufferInitializationOptions } from '@antv/l7-core';
|
|
3
|
+
/**
|
|
4
|
+
* Use Buffer from @antv/g-device-api
|
|
5
|
+
*/
|
|
6
|
+
export default class DeviceBuffer implements IBuffer {
|
|
7
|
+
private buffer;
|
|
8
|
+
private isDestroyed;
|
|
9
|
+
private type;
|
|
10
|
+
private size;
|
|
11
|
+
constructor(device: Device, options: IBufferInitializationOptions);
|
|
12
|
+
get(): Buffer;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
subData({ data, offset, }: {
|
|
15
|
+
data: number[] | number[][] | Uint8Array | Uint16Array | Uint32Array;
|
|
16
|
+
offset: number;
|
|
17
|
+
}): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Bindings, BindingsDescriptor, Device, InputLayout, InputLayoutDescriptor, Program, ProgramDescriptor, RenderPipeline, RenderPipelineDescriptor } from '@antv/g-device-api';
|
|
2
|
+
export declare class RenderCache {
|
|
3
|
+
private device;
|
|
4
|
+
constructor(device: Device);
|
|
5
|
+
private bindingsCache;
|
|
6
|
+
private renderPipelinesCache;
|
|
7
|
+
private inputLayoutsCache;
|
|
8
|
+
private programCache;
|
|
9
|
+
createBindings(descriptor: BindingsDescriptor): Bindings;
|
|
10
|
+
createRenderPipeline(descriptor: RenderPipelineDescriptor): RenderPipeline;
|
|
11
|
+
createInputLayout(descriptor: InputLayoutDescriptor): InputLayout;
|
|
12
|
+
createProgram(descriptor: ProgramDescriptor): Program;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Buffer, Device } from '@antv/g-device-api';
|
|
2
|
+
import type { IElements, IElementsInitializationOptions } from '@antv/l7-core';
|
|
3
|
+
export default class DeviceElements implements IElements {
|
|
4
|
+
private indexBuffer;
|
|
5
|
+
private type;
|
|
6
|
+
private count;
|
|
7
|
+
constructor(device: Device, options: IElementsInitializationOptions);
|
|
8
|
+
get(): Buffer;
|
|
9
|
+
subData({ data, }: {
|
|
10
|
+
data: number[] | number[][] | Uint8Array | Uint16Array | Uint32Array;
|
|
11
|
+
}): void;
|
|
12
|
+
destroy(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Device, RenderTarget, Texture } from '@antv/g-device-api';
|
|
2
|
+
import type { IFramebuffer, IFramebufferInitializationOptions } from '@antv/l7-core';
|
|
3
|
+
/**
|
|
4
|
+
* Contains 2 render targets: color and depth.
|
|
5
|
+
*/
|
|
6
|
+
export default class DeviceFramebuffer implements IFramebuffer {
|
|
7
|
+
private device;
|
|
8
|
+
private options;
|
|
9
|
+
private colorRenderTarget;
|
|
10
|
+
colorTexture: Texture;
|
|
11
|
+
private depthRenderTarget;
|
|
12
|
+
private depthTexture;
|
|
13
|
+
private width;
|
|
14
|
+
private height;
|
|
15
|
+
constructor(device: Device, options: IFramebufferInitializationOptions);
|
|
16
|
+
private createColorRenderTarget;
|
|
17
|
+
private createDepthRenderTarget;
|
|
18
|
+
get(): RenderTarget;
|
|
19
|
+
destroy(): void;
|
|
20
|
+
resize({ width, height }: {
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
}): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Device } from '@antv/g-device-api';
|
|
2
|
+
import type { IModel, IModelDrawOptions, IModelInitializationOptions, IUniform } from '@antv/l7-core';
|
|
3
|
+
import type DeviceRendererService from '.';
|
|
4
|
+
export default class DeviceModel implements IModel {
|
|
5
|
+
private device;
|
|
6
|
+
private options;
|
|
7
|
+
private service;
|
|
8
|
+
private destroyed;
|
|
9
|
+
private uniforms;
|
|
10
|
+
private program;
|
|
11
|
+
private inputLayout;
|
|
12
|
+
private pipeline;
|
|
13
|
+
private indexBuffer;
|
|
14
|
+
private vertexBuffers;
|
|
15
|
+
private bindings;
|
|
16
|
+
constructor(device: Device, options: IModelInitializationOptions, service: DeviceRendererService);
|
|
17
|
+
private createPipeline;
|
|
18
|
+
updateAttributesAndElements(): void;
|
|
19
|
+
/**
|
|
20
|
+
* No need to implement this method, you should update data on `Attribute` like this:
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* attribute.updateBuffer({
|
|
25
|
+
* data: [],
|
|
26
|
+
* offset: 0,
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
updateAttributes(): void;
|
|
31
|
+
addUniforms(uniforms: {
|
|
32
|
+
[key: string]: IUniform;
|
|
33
|
+
}): void;
|
|
34
|
+
draw(options: IModelDrawOptions, pick?: boolean): void;
|
|
35
|
+
destroy(): void;
|
|
36
|
+
private initDepthDrawParams;
|
|
37
|
+
private getBlendDrawParams;
|
|
38
|
+
/**
|
|
39
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#stencil
|
|
40
|
+
*/
|
|
41
|
+
private getStencilDrawParams;
|
|
42
|
+
/**
|
|
43
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#culling
|
|
44
|
+
*/
|
|
45
|
+
private initCullDrawParams;
|
|
46
|
+
/**
|
|
47
|
+
* 考虑结构体命名, eg:
|
|
48
|
+
* a: { b: 1 } -> 'a.b'
|
|
49
|
+
* a: [ { b: 1 } ] -> 'a[0].b'
|
|
50
|
+
*/
|
|
51
|
+
private extractUniforms;
|
|
52
|
+
private extractUniformsRecursively;
|
|
53
|
+
}
|