UNPKG

2.45 kBJavaScriptView Raw
1import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2import _createClass from "@babel/runtime/helpers/createClass";
3
4var WebGPUFramebuffer = /*#__PURE__*/function () {
5 function WebGPUFramebuffer(engine, options) {
6 _classCallCheck(this, WebGPUFramebuffer);
7
8 this.engine = engine;
9 this.options = options;
10 this.colorTexture = void 0;
11 this.depthTexture = void 0;
12 this.width = 0;
13 this.height = 0;
14 var _options = options,
15 width = _options.width,
16 height = _options.height,
17 color = _options.color,
18 colors = _options.colors,
19 depth = _options.depth,
20 stencil = _options.stencil;
21
22 if (color) {
23 this.colorTexture = color;
24 }
25
26 if (depth) {
27 this.depthTexture = depth;
28 } // TODO: depth & stencil
29
30 }
31
32 _createClass(WebGPUFramebuffer, [{
33 key: "get",
34 value: function get() {
35 var _this$colorTexture, _this$depthTexture;
36
37 return {
38 color: (_this$colorTexture = this.colorTexture) === null || _this$colorTexture === void 0 ? void 0 : _this$colorTexture.get(),
39 depth: (_this$depthTexture = this.depthTexture) === null || _this$depthTexture === void 0 ? void 0 : _this$depthTexture.get()
40 };
41 }
42 }, {
43 key: "destroy",
44 value: function destroy() {
45 var _this$colorTexture2, _this$depthTexture2;
46
47 (_this$colorTexture2 = this.colorTexture) === null || _this$colorTexture2 === void 0 ? void 0 : _this$colorTexture2.destroy();
48 (_this$depthTexture2 = this.depthTexture) === null || _this$depthTexture2 === void 0 ? void 0 : _this$depthTexture2.destroy();
49 }
50 }, {
51 key: "resize",
52 value: function resize(_ref) {
53 var width = _ref.width,
54 height = _ref.height;
55
56 if (width !== this.width || height !== this.height) {
57 var _this$colorTexture3, _this$depthTexture3;
58
59 (_this$colorTexture3 = this.colorTexture) === null || _this$colorTexture3 === void 0 ? void 0 : _this$colorTexture3.resize({
60 width: width,
61 height: height
62 });
63 (_this$depthTexture3 = this.depthTexture) === null || _this$depthTexture3 === void 0 ? void 0 : _this$depthTexture3.resize({
64 width: width,
65 height: height
66 });
67 }
68
69 this.width = width;
70 this.height = height;
71 }
72 }]);
73
74 return WebGPUFramebuffer;
75}();
76
77export { WebGPUFramebuffer as default };
78//# sourceMappingURL=WebGPUFramebuffer.js.map
\No newline at end of file