@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.
Files changed (51) hide show
  1. package/es/device/DeviceAttribute.js +26 -32
  2. package/es/device/DeviceBuffer.js +31 -49
  3. package/es/device/DeviceCache.js +136 -170
  4. package/es/device/DeviceElements.js +32 -38
  5. package/es/device/DeviceFramebuffer.js +76 -104
  6. package/es/device/DeviceModel.js +358 -384
  7. package/es/device/DeviceTexture2D.js +103 -122
  8. package/es/device/constants.js +117 -34
  9. package/es/device/index.js +254 -381
  10. package/es/device/utils/HashMap.js +71 -138
  11. package/es/device/utils/pipeline.js +6 -1
  12. package/es/device/utils/typedarray.js +23 -24
  13. package/es/device/utils/webgl.js +7 -6
  14. package/es/index.js +5 -4
  15. package/es/regl/ReglAttribute.js +17 -33
  16. package/es/regl/ReglBuffer.js +25 -40
  17. package/es/regl/ReglElements.js +21 -36
  18. package/es/regl/ReglFramebuffer.js +24 -44
  19. package/es/regl/ReglModel.js +266 -306
  20. package/es/regl/ReglRenderbuffer.js +19 -36
  21. package/es/regl/ReglTexture2D.js +72 -103
  22. package/es/regl/constants.js +133 -21
  23. package/es/regl/index.js +205 -289
  24. package/lib/device/DeviceAttribute.d.ts +13 -0
  25. package/lib/device/DeviceBuffer.d.ts +18 -0
  26. package/lib/device/DeviceCache.d.ts +14 -0
  27. package/lib/device/DeviceElements.d.ts +13 -0
  28. package/lib/device/DeviceFramebuffer.d.ts +24 -0
  29. package/lib/device/DeviceModel.d.ts +53 -0
  30. package/lib/device/DeviceModel.js +22 -15
  31. package/lib/device/DeviceTexture2D.d.ts +23 -0
  32. package/lib/device/constants.d.ts +35 -0
  33. package/lib/device/index.d.ts +68 -0
  34. package/lib/device/index.js +58 -36
  35. package/lib/device/utils/HashMap.d.ts +24 -0
  36. package/lib/device/utils/pipeline.d.ts +1 -0
  37. package/lib/device/utils/typedarray.d.ts +7 -0
  38. package/lib/device/utils/webgl.d.ts +1 -0
  39. package/lib/index.d.ts +6 -0
  40. package/lib/regl/ReglAttribute.d.ts +16 -0
  41. package/lib/regl/ReglBuffer.d.ts +17 -0
  42. package/lib/regl/ReglElements.d.ts +14 -0
  43. package/lib/regl/ReglFramebuffer.d.ts +16 -0
  44. package/lib/regl/ReglModel.d.ts +46 -0
  45. package/lib/regl/ReglModel.js +21 -11
  46. package/lib/regl/ReglRenderbuffer.d.ts +16 -0
  47. package/lib/regl/ReglTexture2D.d.ts +22 -0
  48. package/lib/regl/constants.d.ts +43 -0
  49. package/lib/regl/index.d.ts +56 -0
  50. package/lib/regl/index.js +70 -48
  51. package/package.json +14 -18
package/es/regl/index.js CHANGED
@@ -1,311 +1,227 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
5
- import _regeneratorRuntime from "@babel/runtime/regenerator";
6
- /**
7
- * render w/ regl
8
- * @see https://github.com/regl-project/regl/blob/gh-pages/API.md
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
- import regl from 'regl';
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
- * regl renderer
21
- */
22
- var ReglRendererService = /*#__PURE__*/function () {
23
- function ReglRendererService() {
24
- var _this = this;
25
- _classCallCheck(this, ReglRendererService);
26
- _defineProperty(this, "uniformBuffers", []);
27
- _defineProperty(this, "queryVerdorInfo", function () {
28
- return 'WebGL1';
29
- });
30
- _defineProperty(this, "createModel", function (options) {
31
- return new ReglModel(_this.gl, options);
32
- });
33
- _defineProperty(this, "createAttribute", function (options) {
34
- return new ReglAttribute(_this.gl, options);
35
- });
36
- _defineProperty(this, "createBuffer", function (options) {
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
- _defineProperty(this, "useFramebufferAsync", /*#__PURE__*/function () {
54
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(framebuffer, drawCommands) {
55
- return _regeneratorRuntime.wrap(function _callee$(_context) {
56
- while (1) switch (_context.prev = _context.next) {
57
- case 0:
58
- _this.gl({
59
- framebuffer: framebuffer ? framebuffer.get() : null
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
- (_this$gl = _this.gl) === null || _this$gl === void 0 || _this$gl.clear(reglClearOptions);
86
- });
87
- _defineProperty(this, "viewport", function (_ref2) {
88
- var x = _ref2.x,
89
- y = _ref2.y,
90
- width = _ref2.width,
91
- height = _ref2.height;
92
- // use WebGL context directly
93
- // @see https://github.com/regl-project/regl/blob/gh-pages/API.md#unsafe-escape-hatch
94
- _this.gl._gl.viewport(x, y, width, height);
95
- _this.width = width;
96
- _this.height = height;
97
- _this.gl._refresh();
98
- });
99
- _defineProperty(this, "readPixels", function (options) {
100
- var framebuffer = options.framebuffer,
101
- x = options.x,
102
- y = options.y,
103
- width = options.width,
104
- height = options.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 _this.gl.read(readPixelsOptions);
85
+ return this.gl.read(readPixelsOptions);
86
+ };
87
+ this.readPixelsAsync = (options) => __async(this, null, function* () {
88
+ return this.readPixels(options);
115
89
  });
116
- _defineProperty(this, "readPixelsAsync", /*#__PURE__*/function () {
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: _this.gl._gl.drawingBufferWidth,
135
- height: _this.gl._gl.drawingBufferHeight
92
+ width: this.gl._gl.drawingBufferWidth,
93
+ height: this.gl._gl.drawingBufferHeight
136
94
  };
137
- });
138
- _defineProperty(this, "getContainer", function () {
139
- var _this$canvas;
140
- return (_this$canvas = _this.canvas) === null || _this$canvas === void 0 ? void 0 : _this$canvas.parentElement;
141
- });
142
- _defineProperty(this, "getCanvas", function () {
143
- // return this.$container?.getElementsByTagName('canvas')[0] || null;
144
- return _this.canvas;
145
- });
146
- _defineProperty(this, "getGLContext", function () {
147
- return _this.gl._gl;
148
- });
149
- _defineProperty(this, "destroy", function () {
150
- var _this$gl2;
151
- // this.canvas = null 清除对 webgl 实例的引用
152
- // @ts-ignore
153
- _this.canvas = null;
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
- _createClass(ReglRendererService, [{
166
- key: "init",
167
- value: function () {
168
- var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(canvas, cfg, gl) {
169
- var _this2 = this;
170
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
171
- while (1) switch (_context3.prev = _context3.next) {
172
- case 0:
173
- // this.$container = $container;
174
- this.canvas = canvas;
175
- if (!gl) {
176
- _context3.next = 5;
177
- break;
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
- this.gl = gl;
180
- _context3.next = 8;
181
- break;
182
- case 5:
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
- return init;
228
- }()
229
- }, {
230
- key: "getPointSizeRange",
231
- value: function getPointSizeRange() {
232
- return this.gl._gl.getParameter(this.gl._gl.ALIASED_POINT_SIZE_RANGE);
233
- }
234
- }, {
235
- key: "testExtension",
236
- value: function testExtension(name) {
237
- // OES_texture_float
238
- return !!this.getGLContext().getExtension(name);
239
- }
240
- }, {
241
- key: "setState",
242
- value:
243
- // TODO: 临时方法
244
- function setState() {
245
- this.gl({
246
- cull: {
247
- enable: false,
248
- face: 'back'
249
- },
250
- viewport: {
251
- x: 0,
252
- y: 0,
253
- height: this.width,
254
- width: this.height
255
- },
256
- blend: {
257
- enable: true,
258
- equation: 'add'
259
- },
260
- framebuffer: null
261
- });
262
- this.gl._refresh();
263
- }
264
- }, {
265
- key: "setBaseState",
266
- value: function setBaseState() {
267
- this.gl({
268
- cull: {
269
- enable: false,
270
- face: 'back'
271
- },
272
- viewport: {
273
- x: 0,
274
- y: 0,
275
- height: this.width,
276
- width: this.height
277
- },
278
- blend: {
279
- enable: false,
280
- equation: 'add'
281
- },
282
- framebuffer: null
283
- });
284
- this.gl._refresh();
285
- }
286
- }, {
287
- key: "setCustomLayerDefaults",
288
- value: function setCustomLayerDefaults() {
289
- var gl = this.getGLContext();
290
- gl.disable(gl.CULL_FACE);
291
- }
292
- }, {
293
- key: "setDirty",
294
- value: function setDirty(flag) {
295
- this.isDirty = flag;
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
+ }