UNPKG

1.26 kBJavaScriptView Raw
1import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2import _createClass from "@babel/runtime/helpers/createClass";
3import { gl } from '@antv/g-webgpu-core';
4import { 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 */
9
10var ReglBuffer = /*#__PURE__*/function () {
11 function ReglBuffer(reGl, options) {
12 _classCallCheck(this, ReglBuffer);
13
14 this.buffer = void 0;
15 var data = options.data,
16 usage = options.usage,
17 type = options.type; // @ts-ignore
18
19 this.buffer = reGl.buffer({
20 data: data,
21 usage: usageMap[usage || gl.STATIC_DRAW],
22 type: dataTypeMap[type || gl.UNSIGNED_BYTE] // length: 0,
23
24 });
25 }
26
27 _createClass(ReglBuffer, [{
28 key: "get",
29 value: function get() {
30 return this.buffer;
31 }
32 }, {
33 key: "destroy",
34 value: function destroy() {// this.buffer.destroy();
35 }
36 }, {
37 key: "subData",
38 value: function subData(_ref) {
39 var data = _ref.data,
40 offset = _ref.offset;
41 // @ts-ignore
42 this.buffer.subdata(data, offset);
43 }
44 }]);
45
46 return ReglBuffer;
47}();
48
49export { ReglBuffer as default };
50//# sourceMappingURL=ReglBuffer.js.map
\No newline at end of file