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() {
35 this.buffer.destroy();
36 }
37 }, {
38 key: "subData",
39 value: function subData(_ref) {
40 var data = _ref.data,
41 offset = _ref.offset;
42 // @ts-ignore
43 this.buffer.subdata(data, offset);
44 }
45 }]);
46
47 return ReglBuffer;
48}();
49
50export { ReglBuffer as default };
51//# sourceMappingURL=ReglBuffer.js.map
\No newline at end of file