UNPKG

1.53 kBJavaScriptView Raw
1import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2import _createClass from "@babel/runtime/helpers/createClass";
3
4/**
5 * adaptor for regl.Framebuffer
6 * @see https://github.com/regl-project/regl/blob/gh-pages/API.md#framebuffers
7 */
8var ReglFramebuffer = /*#__PURE__*/function () {
9 function ReglFramebuffer(reGl, options) {
10 _classCallCheck(this, ReglFramebuffer);
11
12 this.framebuffer = void 0;
13 var width = options.width,
14 height = options.height,
15 color = options.color,
16 colors = options.colors,
17 depth = options.depth,
18 stencil = options.stencil;
19 var framebufferOptions = {
20 width: width,
21 height: height
22 };
23
24 if (Array.isArray(colors)) {
25 framebufferOptions.colors = colors.map(function (c) {
26 return c.get();
27 });
28 }
29
30 if (color && typeof color !== 'boolean') {
31 framebufferOptions.color = color.get();
32 } // TODO: depth & stencil
33
34
35 this.framebuffer = reGl.framebuffer(framebufferOptions);
36 }
37
38 _createClass(ReglFramebuffer, [{
39 key: "get",
40 value: function get() {
41 return this.framebuffer;
42 }
43 }, {
44 key: "destroy",
45 value: function destroy() {
46 this.framebuffer.destroy();
47 }
48 }, {
49 key: "resize",
50 value: function resize(_ref) {
51 var width = _ref.width,
52 height = _ref.height;
53 this.framebuffer.resize(width, height);
54 }
55 }]);
56
57 return ReglFramebuffer;
58}();
59
60export { ReglFramebuffer as default };
61//# sourceMappingURL=ReglFramebuffer.js.map
\No newline at end of file